33 *TAB.createObjectWriter(OS))),
34 EmitEHFrame(
true), EmitDebugFrame(
false) {}
44 if (PendingLabels.empty())
52 for (
MCSymbol *Sym : PendingLabels) {
54 Sym->setOffset(FOffset);
56 PendingLabels.clear();
77 EmitDebugFrame =
false;
78 PendingLabels.clear();
97 return &*std::prev(CurInsertionPoint);
121 EmitDebugFrame =
Debug;
135 if (Value->evaluateAsAbsolute(AbsValue,
getAssembler())) {
170 PendingLabels.push_back(Symbol);
176 if (Value->evaluateAsAbsolute(IntValue,
getAssembler())) {
185 if (Value->evaluateAsAbsolute(IntValue,
getAssembler())) {
198 const MCExpr *Subsection) {
203 const MCExpr *Subsection) {
204 assert(Section &&
"Cannot switch to a null section!");
209 int64_t IntSubsection = 0;
211 !Subsection->evaluateAsAbsolute(IntSubsection,
getAssembler()))
213 if (IntSubsection < 0 || IntSubsection > 8192)
244 EmitInstToData(Inst, STI);
257 while (
getAssembler().getBackend().mayNeedRelaxation(Relaxed))
259 EmitInstToData(Relaxed, STI);
286 "Aligned bundling is not implemented for this object format";
302 unsigned Column,
unsigned Flags,
304 unsigned Discriminator,
311 Isa, Discriminator, FileName);
327 int64_t LineDelta,
const MCSymbol *Label,
342 unsigned PointerSize) {
350 if (AddrDelta->evaluateAsAbsolute(Res,
getAssembler())) {
362 if (AddrDelta->evaluateAsAbsolute(Res,
getAssembler())) {
370 unsigned Line,
unsigned Column,
371 bool PrologueEnd,
bool IsStmt,
378 PrologueEnd, IsStmt, FileName, Loc);
390 unsigned PrimaryFunctionId,
unsigned SourceFileId,
unsigned SourceLineNum,
393 *
this, PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym,
396 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
400 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
425 unsigned MaxBytesToEmit) {
426 if (MaxBytesToEmit == 0)
437 unsigned MaxBytesToEmit) {
511 if (!Offset.evaluateAsAbsolute(OffsetValue))
521 if (!MaybeKind.hasValue())
544 if (!NumBytes.evaluateAsAbsolute(IntNumBytes,
getAssembler())) {
549 if (IntNumBytes <= 0) {
558 int64_t Expr,
SMLoc Loc) {
559 int64_t IntNumValues;
560 if (!NumValues.evaluateAsAbsolute(IntNumValues,
getAssembler())) {
565 if (IntNumValues < 0) {
568 "'.fill' directive with negative repeat count has no effect");
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
void emitLineTableForFunction(MCObjectStreamer &OS, unsigned FuncId, const MCSymbol *FuncBegin, const MCSymbol *FuncEnd)
Emits a line table substream.
A eight-byte dtp relative fixup.
void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion) override
This implements the CodeView '.cv_def_range' assembler directive.
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
static const char *const BundlingNotImplementedMsg
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
bool hasInstructions() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const =0
Relax the instruction in the given fragment to the next wider instruction.
virtual void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &)
Emit an instruction to a special fragment, because this instruction can change its size during relaxa...
void setAlignment(unsigned Value)
virtual void reset()
State management.
static void Make(MCObjectStreamer *MCOS)
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
MCCodeEmitter & getEmitter() const
A raw_ostream that writes to an SmallVector or SmallString.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
const_iterator begin(StringRef path)
Get begin iterator over path.
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel)
Return the generic fixup kind for a value with the given size.
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
unsigned getAlignment() const
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
void EmitCVStringTableDirective() override
This implements the CodeView '.cv_stringtable' assembler directive.
virtual void EmitCFISections(bool EH, bool Debug)
void emitInlineLineTableForFunction(MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCFragment * getCurrentFragment() const
struct fuzzer::@269 Flags
void setHasInstructions(bool Value)
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
A four-byte tp relative fixup.
MCSection * getCurrentSectionOnly() const
Base class for the full range of assembler expressions which are needed for parsing.
bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc) override
Emit a .reloc directive.
bool registerSection(MCSection &Section)
bool mayHaveInstructions(MCSection &Sec) const override
MCContext & getContext() const
void EmitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Context object for machine code objects.
void EmitDTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
A four-byte gp relative fixup.
Streaming object file generation interface.
MCObjectWriter & getWriter() const
Function Alias Analysis false
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
void EmitDTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
SmallVectorImpl< char > & getContents()
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Instances of this class represent a single low-level machine instruction.
void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override
Emit the absolute difference between two symbols if possible.
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
A four-byte dtp relative fixup.
void EmitULEB128Value(const MCExpr *Value) override
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
void visitUsedSymbol(const MCSymbol &Sym) override
FragmentListType::iterator iterator
MCDwarfLineTableParams getDWARFLinetableParams() const
void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc) override
This implements the CodeView '.cv_loc' assembler directive.
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
void EmitSLEB128Value(const MCExpr *Value) override
void insert(MCFragment *F)
void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
MCAssembler & getAssembler()
MCCodeEmitter - Generic instruction encoding interface.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
SmallVectorImpl< MCFixup > & getFixups()
virtual bool mayNeedRelaxation(const MCInst &Inst) const =0
Check whether the given instruction may need relaxation.
virtual Optional< MCFixupKind > getFixupKind(StringRef Name) const
Map a relocation name used in .reloc to a fixup kind.
static const unsigned End
void reportError(SMLoc L, const Twine &Msg)
A eight-byte tp relative fixup.
void EmitFrames(MCAsmBackend *MAB)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
const SourceMgr * getSourceManager() const
void setOffset(uint64_t Value)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc) override
Emit some number of copies of Value until the byte offset Offset is reached.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void emitFill(uint64_t NumBytes, uint8_t FillValue) override
Emit NumBytes bytes worth of the value specified by FillValue.
void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
static const MCExpr * buildSymbolDiff(MCObjectStreamer &OS, const MCSymbol *A, const MCSymbol *B)
void EmitCFISections(bool EH, bool Debug) override
void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, const MCSymbol *Label)
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
bool isBundlingEnabled() const
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *Begin, const MCSymbol *End) override
This implements the CodeView '.cv_linetable' assembler directive.
~MCObjectStreamer() override
void flushPendingLabels(MCFragment *F, uint64_t FOffset=0)
If any labels have been emitted but not assigned fragments, ensure that they get assigned, either to F if possible or to a new data fragment.
void EmitBundleAlignMode(unsigned AlignPow2) override
Set the bundle alignment mode from now on in the section.
static void Emit(MCStreamer *MCOS)
static void emitDwarfSetLineAddr(MCObjectStreamer &OS, MCDwarfLineTableParams Params, int64_t LineDelta, const MCSymbol *Label, int PointerSize)
void EmitTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
static void Emit(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
iterator insert(iterator where, pointer New)
unsigned getNumFrameInfos()
void EmitBundleUnlock() override
Ends a bundle-locked group.
void FinishImpl() override
Streamer specific finalization.
uint64_t getOffset() const
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void emitDefRange(MCObjectStreamer &OS, ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
void reset() override
state management
MCAsmBackend & getBackend() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MCSubtargetInfo - Generic base class for all target subtargets.
void emitStringTable(MCObjectStreamer &OS)
Emits the string table substream.
void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName) override
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym) override
This implements the CodeView '.cv_inline_linetable' assembler directive.
void EmitULEB128IntValue(uint64_t Value, unsigned Padding=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
bool isVariable() const
isVariable - Check if this is a variable symbol.
MCFragment * getFragment(bool SetUsed=true) const
CodeViewContext & getCVContext()
An abstract base class for streams implementations that also support a pwrite operation.
void reset()
Reuse an assembler instance.
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection)
LLVM Value Representation.
Generic interface to target specific assembler backends.
bool isBundleLocked() const
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
void EmitGPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
StringRef - Represent a constant reference to a string, i.e.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
void EmitCVFileChecksumsDirective() override
This implements the CodeView '.cv_filechecksums' assembler directive.
Represents a location in source code.
void emitFileChecksums(MCObjectStreamer &OS)
Emits the file checksum substream.
void setParent(MCSection *Value)
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
void Finish()
Finish - Do final processing and write the object to the output stream.
MCSection::FragmentListType & getFragmentList()
void EmitGPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
MCDataFragment * getOrCreateDataFragment()
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment...
MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
void EmitTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (64-bit TP relative) value.