13#ifndef LLVM_MC_MCSTREAMER_H
14#define LLVM_MC_MCSTREAMER_H
43class AssemblerConstantPools;
60struct DefRangeRegisterRelHeader;
61struct DefRangeSubfieldRegisterHeader;
62struct DefRangeRegisterHeader;
63struct DefRangeFramePointerRelHeader;
105 virtual void emitLabel(
MCSymbol *Symbol);
127 virtual void emitRawBytes(
StringRef Data);
129 virtual void emitConstantPools();
131 virtual void finish();
141 virtual void emitFnStart();
142 virtual void emitFnEnd();
143 virtual void emitCantUnwind();
144 virtual void emitPersonality(
const MCSymbol *Personality);
145 virtual void emitPersonalityIndex(
unsigned Index);
146 virtual void emitHandlerData();
150 virtual void emitPad(int64_t
Offset);
156 virtual void switchVendor(
StringRef Vendor);
159 virtual void emitIntTextAttribute(
unsigned Attribute,
unsigned IntValue,
163 virtual void emitArchExtension(
uint64_t ArchExt);
166 virtual void finishAttributeSection();
167 virtual void emitInst(
uint32_t Inst,
char Suffix =
'\0');
169 virtual void annotateTLSDescriptorSequence(
const MCSymbolRefExpr *SRE);
171 virtual void emitSyntaxUnified();
173 virtual void emitCode16();
174 virtual void emitCode32();
177 virtual void emitThumbFunc(
MCSymbol *Symbol);
180 void emitConstantPools()
override;
182 virtual void emitARMWinCFIAllocStack(
unsigned Size,
bool Wide);
183 virtual void emitARMWinCFISaveRegMask(
unsigned Mask,
bool Wide);
184 virtual void emitARMWinCFISaveSP(
unsigned Reg);
185 virtual void emitARMWinCFISaveFRegs(
unsigned First,
unsigned Last);
186 virtual void emitARMWinCFISaveLR(
unsigned Offset);
187 virtual void emitARMWinCFIPrologEnd(
bool Fragment);
188 virtual void emitARMWinCFINop(
bool Wide);
189 virtual void emitARMWinCFIEpilogStart(
unsigned Condition);
190 virtual void emitARMWinCFIEpilogEnd();
191 virtual void emitARMWinCFICustom(
unsigned Opcode);
195 virtual void reset();
204 void emitCurrentConstantPool();
207 std::unique_ptr<AssemblerConstantPools> ConstantPools;
222 std::unique_ptr<MCTargetStreamer> TargetStreamer;
224 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
233 std::vector<std::unique_ptr<WinEH::FrameInfo>> WinFrameInfos;
236 size_t CurrentProcWinFrameInfoStartIndex;
244 const SMLoc *StartTokLocPtr =
nullptr;
250 unsigned NextWinCFIID = 0;
252 bool UseAssemblerInfoForParsing =
true;
259 bool AllowAutoPadding =
false;
281 return CurrentWinFrameInfo;
286 virtual void emitWindowsUnwindTables();
288 virtual void emitRawTextImpl(
StringRef String);
291 bool checkCVLocSection(
unsigned FuncId,
unsigned FileNo,
SMLoc Loc);
298 void visitUsedExpr(
const MCExpr &Expr);
302 TargetStreamer.reset(TS);
307 return StartTokLocPtr ? *StartTokLocPtr :
SMLoc();
312 virtual void reset();
315 bool isObj()
const {
return IsObj; }
325 return TargetStreamer.get();
341 unsigned getNumFrameInfos();
344 bool hasUnfinishedDwarfFrameInfo();
348 return WinFrameInfos;
352 return CurrentWinEpilog;
398 virtual void emitRawComment(
const Twine &
T,
bool TabPrefix =
true);
402 virtual void addExplicitComment(
const Twine &
T);
405 virtual void emitExplicitComments();
417 if (!SectionStack.
empty())
418 return SectionStack.
back().first;
427 if (!SectionStack.
empty())
428 return SectionStack.
back().second;
434 assert(!getCurrentSection().first ||
435 CurFrag->
getParent() == getCurrentSection().first);
438 assert(!CurFrag || CurFrag->
getKind() == MCFragment::FT_Data);
445 std::make_pair(getCurrentSection(), getPreviousSection()));
452 virtual bool popSection();
462 void switchSectionNoPrint(
MCSection *Section);
465 virtual void initSections(
bool NoExecStack,
const MCSubtargetInfo &STI);
485 virtual void emitEHSymAttributes(
const MCSymbol *Symbol,
MCSymbol *EHSymbol);
488 virtual void emitSubsectionsViaSymbols();
499 unsigned Minor,
unsigned Update,
505 unsigned Minor,
unsigned Update,
516 const Triple *DarwinTargetVariantTriple,
553 virtual void emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue);
558 virtual void beginCOFFSymbolDef(
const MCSymbol *Symbol);
563 virtual void emitCOFFSymbolStorageClass(
int StorageClass);
568 virtual void emitCOFFSymbolType(
int Type);
571 virtual void endCOFFSymbolDef();
573 virtual void emitCOFFSafeSEH(
MCSymbol const *Symbol);
576 virtual void emitCOFFSymbolIndex(
MCSymbol const *Symbol);
581 virtual void emitCOFFSectionIndex(
MCSymbol const *Symbol);
591 virtual void emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset);
595 virtual void emitCOFFSecNumber(
MCSymbol const *Symbol);
599 virtual void emitCOFFSecOffset(
MCSymbol const *Symbol);
616 virtual void emitXCOFFSymbolLinkageWithVisibility(
MCSymbol *Symbol,
635 virtual void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
637 unsigned Lang,
unsigned Reason,
638 unsigned FunctionSize,
bool hasDebug);
644 virtual void emitXCOFFRefDirective(
const MCSymbol *Symbol);
662 virtual void emitELFSymverDirective(
const MCSymbol *OriginalSym,
678 Align ByteAlignment) = 0;
686 Align ByteAlignment);
719 virtual void emitBinaryData(
StringRef Data);
739 virtual void emitIntValue(
const APInt &
Value);
760 virtual void emitULEB128Value(
const MCExpr *
Value);
762 virtual void emitSLEB128Value(
const MCExpr *
Value);
766 unsigned emitULEB128IntValue(
uint64_t Value,
unsigned PadTo = 0);
770 unsigned emitSLEB128IntValue(int64_t
Value);
775 bool IsSectionRelative =
false);
799 virtual void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
802 virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength,
825 virtual void emitValueToAlignment(
Align Alignment, int64_t Fill = 0,
827 unsigned MaxBytesToEmit = 0);
840 unsigned MaxBytesToEmit = 0);
857 virtual void emitFileDirective(
StringRef Filename);
871 std::optional<MD5::MD5Result> Checksum = std::nullopt,
872 std::optional<StringRef> Source = std::nullopt,
unsigned CUID = 0) {
874 tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum,
885 std::optional<MD5::MD5Result> Checksum = std::nullopt,
886 std::optional<StringRef> Source = std::nullopt,
unsigned CUID = 0);
890 std::optional<MD5::MD5Result> Checksum,
891 std::optional<StringRef> Source,
894 virtual void emitCFIBKeyFrame();
895 virtual void emitCFIMTETaggedFrame();
899 virtual void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
900 unsigned Column,
unsigned Flags,
901 unsigned Isa,
unsigned Discriminator,
906 virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef
Name);
911 virtual bool emitCVFileDirective(
unsigned FileNo, StringRef Filename,
912 ArrayRef<uint8_t> Checksum,
913 unsigned ChecksumKind);
916 virtual bool emitCVFuncIdDirective(
unsigned FunctionId);
920 virtual bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
921 unsigned IAFile,
unsigned IALine,
922 unsigned IACol, SMLoc Loc);
925 virtual void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
926 unsigned Line,
unsigned Column,
927 bool PrologueEnd,
bool IsStmt,
928 StringRef FileName, SMLoc Loc);
931 virtual void emitCVLinetableDirective(
unsigned FunctionId,
932 const MCSymbol *FnStart,
933 const MCSymbol *FnEnd);
937 virtual void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
938 unsigned SourceFileId,
939 unsigned SourceLineNum,
940 const MCSymbol *FnStartSym,
941 const MCSymbol *FnEndSym);
945 virtual void emitCVDefRangeDirective(
946 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
947 StringRef FixedSizePortion);
949 virtual void emitCVDefRangeDirective(
950 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
951 codeview::DefRangeRegisterRelHeader DRHdr);
953 virtual void emitCVDefRangeDirective(
954 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
955 codeview::DefRangeSubfieldRegisterHeader DRHdr);
957 virtual void emitCVDefRangeDirective(
958 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
959 codeview::DefRangeRegisterHeader DRHdr);
961 virtual void emitCVDefRangeDirective(
962 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
963 codeview::DefRangeFramePointerRelHeader DRHdr);
981 virtual void emitAbsoluteSymbolDiff(
const MCSymbol *
Hi,
const MCSymbol *
Lo,
985 virtual void emitAbsoluteSymbolDiffAsULEB128(
const MCSymbol *
Hi,
988 virtual MCSymbol *getDwarfLineTableSymbol(
unsigned CUID);
989 virtual void emitCFISections(
bool EH,
bool Debug,
bool SFrame);
990 void emitCFIStartProc(
bool IsSimple, SMLoc Loc = SMLoc());
991 void emitCFIEndProc();
992 virtual void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc = {});
993 virtual void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc = {});
994 virtual void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc = {});
995 virtual void emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
996 int64_t AddressSpace, SMLoc Loc = {});
997 virtual void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc = {});
998 virtual void emitCFIPersonality(
const MCSymbol *
Sym,
unsigned Encoding);
999 virtual void emitCFILsda(
const MCSymbol *
Sym,
unsigned Encoding);
1000 virtual void emitCFIRememberState(SMLoc Loc);
1001 virtual void emitCFIRestoreState(SMLoc Loc);
1002 virtual void emitCFISameValue(int64_t
Register, SMLoc Loc = {});
1003 virtual void emitCFIRestore(int64_t
Register, SMLoc Loc = {});
1004 virtual void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc);
1005 virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc = {});
1006 virtual void emitCFIEscape(StringRef Values, SMLoc Loc = {});
1007 virtual void emitCFIReturnColumn(int64_t
Register);
1008 virtual void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc = {});
1009 virtual void emitCFISignalFrame();
1010 virtual void emitCFIUndefined(int64_t
Register, SMLoc Loc = {});
1011 virtual void emitCFIRegister(int64_t Register1, int64_t Register2,
1013 virtual void emitCFIWindowSave(SMLoc Loc = {});
1014 virtual void emitCFINegateRAState(SMLoc Loc = {});
1015 virtual void emitCFINegateRAStateWithPC(SMLoc Loc = {});
1016 virtual void emitCFILabelDirective(SMLoc Loc, StringRef
Name);
1020 virtual void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc = SMLoc());
1021 virtual void emitWinCFIEndProc(SMLoc Loc = SMLoc());
1026 virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc = SMLoc());
1027 virtual void emitWinCFIStartChained(SMLoc Loc = SMLoc());
1028 virtual void emitWinCFIEndChained(SMLoc Loc = SMLoc());
1029 virtual void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc = SMLoc());
1030 virtual void emitWinCFISetFrame(MCRegister
Register,
unsigned Offset,
1031 SMLoc Loc = SMLoc());
1032 virtual void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc = SMLoc());
1033 virtual void emitWinCFISaveReg(MCRegister
Register,
unsigned Offset,
1034 SMLoc Loc = SMLoc());
1035 virtual void emitWinCFISaveXMM(MCRegister
Register,
unsigned Offset,
1036 SMLoc Loc = SMLoc());
1037 virtual void emitWinCFIPushFrame(
bool Code, SMLoc Loc = SMLoc());
1038 virtual void emitWinCFIEndProlog(SMLoc Loc = SMLoc());
1039 virtual void emitWinCFIBeginEpilogue(SMLoc Loc = SMLoc());
1040 virtual void emitWinCFIEndEpilogue(SMLoc Loc = SMLoc());
1041 virtual void emitWinCFIUnwindV2Start(SMLoc Loc = SMLoc());
1042 virtual void emitWinCFIUnwindVersion(
uint8_t Version, SMLoc Loc = SMLoc());
1043 virtual void emitWinEHHandler(
const MCSymbol *
Sym,
bool Unwind,
bool Except,
1044 SMLoc Loc = SMLoc());
1045 virtual void emitWinEHHandlerData(SMLoc Loc = SMLoc());
1047 virtual void emitCGProfileEntry(
const MCSymbolRefExpr *
From,
1048 const MCSymbolRefExpr *To,
uint64_t Count);
1053 MCSection *getAssociatedPDataSection(
const MCSection *TextSec);
1056 MCSection *getAssociatedXDataSection(
const MCSection *TextSec);
1058 virtual void emitSyntaxDirective();
1079 void emitRawText(
const Twine &String);
1082 virtual void finishImpl();
1089 void maybeEmitDwarf64Mark();
1093 virtual void emitDwarfUnitLength(
uint64_t Length,
const Twine &Comment);
1099 const Twine &Comment);
1102 virtual void emitDwarfLineStartLabel(
MCSymbol *StartSym);
1114 unsigned PointerSize) {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
BlockVerifier::State From
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
This file defines the DenseMap class.
Promote Memory to Register
This file defines the SmallVector class.
Defines the llvm::VersionTuple class, which represents a version in the form major[....
support::ulittle16_t & Lo
support::ulittle16_t & Hi
Class for arbitrary precision integers.
~ARMTargetStreamer() override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Tagged union holding either a T or a Error.
Generic interface to target specific assembler backends.
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
FragmentType getKind() const
MCSection * getParent() const
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
Wrapper class representing physical registers. Should be passed by value.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
virtual void emitAddrsig()
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
MCStreamer(const MCStreamer &)=delete
virtual void emitGNUAttribute(unsigned Tag, unsigned Value)
Emit a .gnu_attribute directive.
unsigned getNumWinFrameInfos()
void setStartTokLocPtr(const SMLoc *Loc)
MCFragment * getCurrentFragment() const
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual void emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc={})
Record a relocation described by the .reloc directive.
virtual void emitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
virtual void emitIntValueInHex(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
unsigned emitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
WinEH::FrameInfo::Epilog * getCurrentWinEpilog() const
virtual void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)=0
Emit a common symbol.
virtual MCAssembler * getAssemblerPtr()
void setTargetStreamer(MCTargetStreamer *TS)
virtual bool isIntegratedAssemblerRequired() const
Is the integrated assembler required for this streamer to function correctly?
virtual void emitCVFileChecksumOffsetDirective(unsigned FileNo)
This implements the CodeView '.cv_filechecksumoffset' assembler directive.
bool getUseAssemblerInfoForParsing()
MCContext & getContext() const
SMLoc getStartTokLoc() const
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
virtual void emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
virtual void emitIdent(StringRef IdentString)
Emit the "identifiers" directive.
virtual StringRef getMnemonic(const MCInst &MI) const
Returns the mnemonic for MI, if the streamer has access to a instruction printer and returns an empty...
virtual void emitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
void setAllowAutoPadding(bool v)
MCTargetStreamer * getTargetStreamer()
virtual void emitIntValueInHexWithPadding(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
virtual bool mayHaveInstructions(MCSection &Sec) const
bool isInEpilogCFI() const
virtual void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
If targets does not support representing debug line section by .loc/.file directives in assembly outp...
void emitInt16(uint64_t Value)
size_t getCurFragSize() const
void pushSection()
Save the current and previous section on the section stack.
void setUseAssemblerInfoForParsing(bool v)
virtual void emitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
bool getAllowAutoPadding() const
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
void emitInt64(uint64_t Value)
void emitInt32(uint64_t Value)
ArrayRef< std::unique_ptr< WinEH::FrameInfo > > getWinFrameInfos() const
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
MCSection * getCurrentSectionOnly() const
MCStreamer & operator=(const MCStreamer &)=delete
virtual void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel, MCSymbol *EndLabel=nullptr)
Emit the debug line end entry.
virtual void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
WinEH::FrameInfo * getCurrentWinFrameInfo()
void emitInt8(uint64_t Value)
virtual void emitAddrsigSym(const MCSymbol *Sym)
virtual void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Target specific streamer interface.
virtual ~MCTargetStreamer()
MCStreamer & getStreamer()
Represents a location in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
Represents a version number in the form major[.minor[.subminor[.build]]].
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
std::pair< MCSection *, uint32_t > MCSectionSubPair
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
MCLOHType
Linker Optimization Hint Type.
This struct is a compact representation of a valid (non-zero power of two) alignment.