14 #ifndef LLVM_MC_MCSTREAMER_H
15 #define LLVM_MC_MCSTREAMER_H
24 #include "llvm/Support/DataTypes.h"
38 class MCSymbolRefExpr;
39 class MCSubtargetInfo;
43 class formatted_raw_ostream;
107 virtual void emitSetFP(
unsigned FpReg,
unsigned SpReg,
121 virtual void emitFPU(
unsigned FPU);
122 virtual void emitArch(
unsigned Arch);
136 virtual void reset();
148 std::unique_ptr<AssemblerConstantPools> ConstantPools;
163 std::unique_ptr<MCTargetStreamer> TargetStreamer;
168 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
170 void EnsureValidDwarfFrame();
175 std::vector<WinEH::FrameInfo *> WinFrameInfos;
177 void EnsureValidWinFrameInfo();
191 unsigned NextWinCFIID = 0;
200 return CurrentWinFrameInfo;
214 TargetStreamer.reset(TS);
219 virtual void reset();
224 return TargetStreamer.get();
229 return DwarfFrameInfos;
236 return WinFrameInfos;
298 if (!SectionStack.
empty())
299 return SectionStack.
back().first;
306 if (!SectionStack.
empty())
307 return SectionStack.
back().second;
314 return SymbolOrdering.
lookup(Sym);
334 if (SectionStack.
size() <= 1)
336 auto I = SectionStack.
end();
342 if (OldSection != NewSection)
349 if (SectionStack.
empty())
361 const MCExpr *Subsection =
nullptr);
367 const MCExpr *Subsection =
nullptr) {
368 assert(Section &&
"Cannot switch to a null section!");
370 SectionStack.
back().second = curSection;
558 virtual void EmitIntValue(uint64_t Value,
unsigned Size);
575 bool IsSectionRelative =
false);
621 virtual void emitFill(uint64_t NumBytes, uint8_t FillValue);
641 virtual void emitFill(uint64_t NumValues, int64_t Size, int64_t Expr);
642 virtual void emitFill(
const MCExpr &NumValues, int64_t Size, int64_t Expr,
667 unsigned ValueSize = 1,
668 unsigned MaxBytesToEmit = 0);
681 unsigned MaxBytesToEmit = 0);
713 unsigned Column,
unsigned Flags,
714 unsigned Isa,
unsigned Discriminator,
728 unsigned IAFile,
unsigned IALine,
729 unsigned IACol,
SMLoc Loc);
733 unsigned Line,
unsigned Column,
734 bool PrologueEnd,
bool IsStmt,
745 unsigned SourceFileId,
746 unsigned SourceLineNum,
753 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
875 std::unique_ptr<formatted_raw_ostream> OS,
876 bool isVerboseAsm,
bool useDwarfDirectory,
877 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
878 MCAsmBackend *TAB,
bool ShowInst);
virtual void EmitBundleUnlock()
Ends a bundle-locked group.
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
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.
virtual void EmitBundleAlignMode(unsigned AlignPow2)
Set the bundle alignment mode from now on in the section.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
virtual void emitInst(uint32_t Inst, char Suffix= '\0')
virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE)
virtual void EmitCFISameValue(int64_t Register)
virtual void emitFPU(unsigned FPU)
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
virtual void EmitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
virtual void EmitSLEB128Value(const MCExpr *Value)
virtual void EmitCFIGnuArgsSize(int64_t Size)
void EmitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ...
virtual void EmitWinCFIEndProlog()
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
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.
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
virtual void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0)
Emit a thread local bss (.tbss) symbol.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual void EndCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
virtual ~MCTargetStreamer()
virtual void EmitULEB128Value(const MCExpr *Value)
virtual void emitArchExtension(unsigned ArchExt)
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void SwitchSectionNoChange(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Target specific streamer interface.
virtual void emitPad(int64_t Offset)
virtual void reset()
State management.
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
virtual void EmitWindowsUnwindTables()
void EmitCFIStartProc(bool IsSimple)
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void EmitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
virtual unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, unsigned CUID=0)
Associate a filename with a specified logical file number.
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText...
ArrayRef< WinEH::FrameInfo * > getWinFrameInfos() const
void PushSection()
Save the current and previous section on the section stack.
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
virtual void finishAttributeSection()
virtual void emitExplicitComments()
Emit added explicit comments.
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
virtual void EmitCFIDefCfaOffset(int64_t Offset)
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
COFF::SymbolStorageClass StorageClass
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
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.
virtual void emitPersonality(const MCSymbol *Personality)
virtual void reset()
Reset any state between object emissions, i.e.
virtual void emitPersonalityIndex(unsigned Index)
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
virtual void EmitCFISections(bool EH, bool Debug)
virtual void EmitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
virtual void EmitWinEHHandlerData()
virtual void EmitCFIRememberState()
void emitCurrentConstantPool()
Callback used to implemnt the .ltorg directive.
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
virtual void EmitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
void AssignFragment(MCSymbol *Symbol, MCFragment *Fragment)
Sets the symbol's section.
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
virtual void EmitCFIEscape(StringRef Values)
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
MCSection * getCurrentSectionOnly() const
Base class for the full range of assembler expressions which are needed for parsing.
Reg
All possible values of the reg field in the ModR/M byte.
Represent a reference to a symbol from inside an expression.
virtual void emitLabel(MCSymbol *Symbol)
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
virtual bool mayHaveInstructions(MCSection &Sec) const
virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
unsigned getNumWinFrameInfos()
MCContext & getContext() const
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.
LLVM_NODISCARD bool empty() const
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Context object for machine code objects.
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
virtual void EmitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
virtual bool isIntegratedAssemblerRequired() const
Is the integrated assembler required for this streamer to function correctly?
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
virtual void EmitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
virtual void EmitCFIRestoreState()
virtual void emitCantUnwind()
ARMTargetStreamer(MCStreamer &S)
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...
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Instances of this class represent a single low-level machine instruction.
virtual void EmitCFIRestore(int64_t Register)
virtual void emitAttribute(unsigned Attribute, unsigned Value)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
virtual void EmitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual raw_ostream & GetCommentOS()
Return a raw_ostream that comments can be written to.
virtual void EmitVersionMin(MCVersionMinType, unsigned Major, unsigned Minor, unsigned Update)
Specify the MachO minimum deployment target version.
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Streaming machine code generation interface.
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
WinEH::FrameInfo * getCurrentWinFrameInfo()
MCTargetStreamer * getTargetStreamer()
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, unsigned ByteAlignment=0)=0
Emit the zerofill section and an optional symbol.
The instances of the Type class are immutable: once they are created, they are never changed...
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target, suitable for compiling with a native assembler.
virtual void EmitWinCFIPushReg(unsigned Register)
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value)
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
virtual void emitObjectArch(unsigned Arch)
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
virtual void EmitSyntaxDirective()
virtual void EmitCFIDefCfaRegister(int64_t Register)
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
MCLOHType
Linker Optimization Hint Type.
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl< uint8_t > &Opcodes)
virtual void EmitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
virtual void EmitWinCFIEndChained()
virtual void EmitWinCFIEndProc()
virtual void EmitCFIUndefined(int64_t Register)
virtual void EmitIdent(StringRef IdentString)
Emit the "identifiers" directive.
void Finish()
Finish emission of machine code.
virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except)
virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol)
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
bool SubSection(const MCExpr *Subsection)
~ARMTargetStreamer() override
virtual void EmitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
virtual void emitFnStart()
virtual bool EmitCVFileDirective(unsigned FileNo, StringRef Filename)
Associate a filename with a specified logical file number.
virtual void EmitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
virtual void EmitWinCFIStartChained()
virtual void InitSections(bool NoExecStack)
Create the default sections and set the initial one.
MCStreamer & getStreamer()
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset)
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
Promote Memory to Register
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
virtual void EmitWinCFIAllocStack(unsigned Size)
virtual void ChangeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
bool hasUnfinishedDwarfFrameInfo()
const MCExpr * addConstantPoolEntry(const MCExpr *, SMLoc Loc)
Callback used to implement the ldr= pseudo.
void visitUsedExpr(const MCExpr &Expr)
MCTargetStreamer(MCStreamer &S)
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
virtual void EmitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
unsigned getNumFrameInfos()
virtual bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc)
Emit a .reloc directive.
virtual void EmitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
virtual void EmitCFISignalFrame()
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset)
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue="")
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
virtual void EmitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void EmitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
MCSubtargetInfo - Generic base class for all target subtargets.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
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...
MCSymbol * endSection(MCSection *Section)
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)=0
Emit a common symbol.
virtual void FinishImpl()
Streamer specific finalization.
bool PopSection()
Restore the current and previous section from the section stack.
virtual bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
virtual void emitHandlerData()
LLVM Value Representation.
Generic interface to target specific assembler backends.
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol)
This class implements an extremely fast bulk output stream that can only output to a stream...
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset)
virtual void EmitWinCFIPushFrame(bool Code)
StringRef - Represent a constant reference to a string, i.e.
virtual void emitArch(unsigned Arch)
virtual void visitUsedSymbol(const MCSymbol &Sym)
Represents a location in source code.
void setTargetStreamer(MCTargetStreamer *TS)
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
virtual void EmitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
unsigned GetSymbolOrder(const MCSymbol *Sym) const
Returns an index to represent the order a symbol was emitted in.
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset)
virtual void switchVendor(StringRef Vendor)
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void EmitCFIWindowSave()
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
virtual void emitTextAttribute(unsigned Attribute, StringRef String)