14 #ifndef LLVM_MC_MCSTREAMER_H 15 #define LLVM_MC_MCSTREAMER_H 41 class AssemblerConstantPools;
42 class formatted_raw_ostream;
45 struct MCCodePaddingContext;
52 class MCSymbolRefExpr;
53 class MCSubtargetInfo;
128 virtual void emitFnStart();
129 virtual void emitFnEnd();
130 virtual void emitCantUnwind();
131 virtual void emitPersonality(
const MCSymbol *Personality);
132 virtual void emitPersonalityIndex(
unsigned Index);
133 virtual void emitHandlerData();
134 virtual void emitSetFP(
unsigned FpReg,
unsigned SpReg,
136 virtual void emitMovSP(
unsigned Reg, int64_t
Offset = 0);
137 virtual void emitPad(int64_t
Offset);
140 virtual void emitUnwindRaw(int64_t StackOffset,
143 virtual void switchVendor(
StringRef Vendor);
146 virtual void emitIntTextAttribute(
unsigned Attribute,
unsigned IntValue,
148 virtual void emitFPU(
unsigned FPU);
150 virtual void emitArchExtension(
unsigned ArchExt);
153 virtual void finishAttributeSection();
154 virtual void emitInst(
uint32_t Inst,
char Suffix =
'\0');
156 virtual void AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *SRE);
164 virtual void reset();
173 void emitCurrentConstantPool();
176 std::unique_ptr<AssemblerConstantPools> ConstantPools;
191 std::unique_ptr<MCTargetStreamer> TargetStreamer;
193 std::vector<MCDwarfFrameInfo> DwarfFrameInfos;
198 std::vector<std::unique_ptr<WinEH::FrameInfo>> WinFrameInfos;
214 unsigned NextWinCFIID = 0;
216 bool UseAssemblerInfoForParsing;
225 return CurrentWinFrameInfo;
228 virtual void EmitWindowsUnwindTables();
233 bool checkCVLocSection(
unsigned FuncId,
unsigned FileNo,
SMLoc Loc);
240 void visitUsedExpr(
const MCExpr &Expr);
241 virtual void visitUsedSymbol(
const MCSymbol &Sym);
244 TargetStreamer.reset(TS);
249 virtual void reset();
259 return TargetStreamer.get();
272 return DwarfFrameInfos;
275 bool hasUnfinishedDwarfFrameInfo();
279 return WinFrameInfos;
323 virtual void emitRawComment(
const Twine &
T,
bool TabPrefix =
true);
327 virtual void addExplicitComment(
const Twine &T);
330 virtual void emitExplicitComments();
342 if (!SectionStack.
empty())
343 return SectionStack.
back().first;
350 if (!SectionStack.
empty())
351 return SectionStack.
back().second;
358 return SymbolOrdering.
lookup(Sym);
370 std::make_pair(getCurrentSection(), getPreviousSection()));
378 if (SectionStack.
size() <= 1)
380 auto I = SectionStack.
end();
386 if (OldSection != NewSection)
387 ChangeSection(NewSection.first, NewSection.second);
393 if (SectionStack.
empty())
396 SwitchSection(SectionStack.
back().first.first, Subsection);
405 const MCExpr *Subsection =
nullptr);
411 const MCExpr *Subsection =
nullptr) {
412 assert(Section &&
"Cannot switch to a null section!");
414 SectionStack.
back().second = curSection;
420 virtual void InitSections(
bool NoExecStack);
442 virtual void EmitEHSymAttributes(
const MCSymbol *Symbol,
MCSymbol *EHSymbol);
456 unsigned Minor,
unsigned Update,
462 unsigned Minor,
unsigned Update,
470 virtual void EmitThumbFunc(
MCSymbol *Func);
495 virtual bool EmitSymbolAttribute(
MCSymbol *Symbol,
502 virtual void EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue);
507 virtual void BeginCOFFSymbolDef(
const MCSymbol *Symbol);
512 virtual void EmitCOFFSymbolStorageClass(
int StorageClass);
517 virtual void EmitCOFFSymbolType(
int Type);
520 virtual void EndCOFFSymbolDef();
522 virtual void EmitCOFFSafeSEH(
MCSymbol const *Symbol);
525 virtual void EmitCOFFSymbolIndex(
MCSymbol const *Symbol);
530 virtual void EmitCOFFSectionIndex(
MCSymbol const *Symbol);
535 virtual void EmitCOFFSecRel32(
MCSymbol const *Symbol, uint64_t
Offset);
540 virtual void EmitCOFFImgRel32(
MCSymbol const *Symbol, int64_t Offset);
554 virtual void emitELFSymverDirective(
StringRef AliasName,
567 virtual void EmitCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
575 virtual void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
576 unsigned ByteAlignment);
586 uint64_t Size = 0,
unsigned ByteAlignment = 0,
597 uint64_t Size,
unsigned ByteAlignment = 0);
611 virtual void EmitBinaryData(
StringRef Data);
623 virtual void EmitValueImpl(
const MCExpr *Value,
unsigned Size,
630 virtual void EmitIntValue(uint64_t Value,
unsigned Size);
632 virtual void EmitULEB128Value(
const MCExpr *Value);
634 virtual void EmitSLEB128Value(
const MCExpr *Value);
638 void EmitULEB128IntValue(uint64_t Value);
642 void EmitSLEB128IntValue(int64_t Value);
646 void EmitSymbolValue(
const MCSymbol *Sym,
unsigned Size,
647 bool IsSectionRelative =
false);
654 virtual void EmitDTPRel64Value(
const MCExpr *Value);
661 virtual void EmitDTPRel32Value(
const MCExpr *Value);
668 virtual void EmitTPRel64Value(
const MCExpr *Value);
675 virtual void EmitTPRel32Value(
const MCExpr *Value);
682 virtual void EmitGPRel64Value(
const MCExpr *Value);
689 virtual void EmitGPRel32Value(
const MCExpr *Value);
693 void emitFill(uint64_t NumBytes, uint8_t FillValue);
702 virtual void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
713 virtual void emitFill(
const MCExpr &NumValues, int64_t Size, int64_t Expr,
718 void EmitZeros(uint64_t NumBytes);
737 virtual void EmitValueToAlignment(
unsigned ByteAlignment, int64_t Value = 0,
738 unsigned ValueSize = 1,
739 unsigned MaxBytesToEmit = 0);
751 virtual void EmitCodeAlignment(
unsigned ByteAlignment,
752 unsigned MaxBytesToEmit = 0);
762 virtual void emitValueToOffset(
const MCExpr *Offset,
unsigned char Value,
775 virtual void EmitFileDirective(
StringRef Filename);
789 tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum,
809 virtual void EmitCFIBKeyFrame();
813 virtual void EmitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
814 unsigned Column,
unsigned Flags,
815 unsigned Isa,
unsigned Discriminator,
821 virtual bool EmitCVFileDirective(
unsigned FileNo,
StringRef Filename,
826 virtual bool EmitCVFuncIdDirective(
unsigned FunctionId);
830 virtual bool EmitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
831 unsigned IAFile,
unsigned IALine,
832 unsigned IACol,
SMLoc Loc);
835 virtual void EmitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
836 unsigned Line,
unsigned Column,
837 bool PrologueEnd,
bool IsStmt,
841 virtual void EmitCVLinetableDirective(
unsigned FunctionId,
847 virtual void EmitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
848 unsigned SourceFileId,
849 unsigned SourceLineNum,
855 virtual void EmitCVDefRangeDirective(
856 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
879 virtual void emitAbsoluteSymbolDiffAsULEB128(
const MCSymbol *Hi,
882 virtual MCSymbol *getDwarfLineTableSymbol(
unsigned CUID);
883 virtual void EmitCFISections(
bool EH,
bool Debug);
884 void EmitCFIStartProc(
bool IsSimple,
SMLoc Loc =
SMLoc());
885 void EmitCFIEndProc();
886 virtual void EmitCFIDefCfa(int64_t
Register, int64_t Offset);
887 virtual void EmitCFIDefCfaOffset(int64_t Offset);
888 virtual void EmitCFIDefCfaRegister(int64_t Register);
889 virtual void EmitCFIOffset(int64_t Register, int64_t Offset);
890 virtual void EmitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding);
891 virtual void EmitCFILsda(
const MCSymbol *Sym,
unsigned Encoding);
892 virtual void EmitCFIRememberState();
893 virtual void EmitCFIRestoreState();
894 virtual void EmitCFISameValue(int64_t Register);
895 virtual void EmitCFIRestore(int64_t Register);
896 virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
897 virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
898 virtual void EmitCFIEscape(
StringRef Values);
899 virtual void EmitCFIReturnColumn(int64_t Register);
900 virtual void EmitCFIGnuArgsSize(int64_t Size);
901 virtual void EmitCFISignalFrame();
902 virtual void EmitCFIUndefined(int64_t Register);
903 virtual void EmitCFIRegister(int64_t Register1, int64_t Register2);
904 virtual void EmitCFIWindowSave();
905 virtual void EmitCFINegateRAState();
908 virtual void EmitWinCFIEndProc(
SMLoc Loc =
SMLoc());
913 virtual void EmitWinCFIFuncletOrFuncEnd(
SMLoc Loc =
SMLoc());
914 virtual void EmitWinCFIStartChained(
SMLoc Loc =
SMLoc());
915 virtual void EmitWinCFIEndChained(
SMLoc Loc =
SMLoc());
916 virtual void EmitWinCFIPushReg(
unsigned Register,
SMLoc Loc =
SMLoc());
917 virtual void EmitWinCFISetFrame(
unsigned Register,
unsigned Offset,
919 virtual void EmitWinCFIAllocStack(
unsigned Size,
SMLoc Loc =
SMLoc());
920 virtual void EmitWinCFISaveReg(
unsigned Register,
unsigned Offset,
922 virtual void EmitWinCFISaveXMM(
unsigned Register,
unsigned Offset,
924 virtual void EmitWinCFIPushFrame(
bool Code,
SMLoc Loc =
SMLoc());
925 virtual void EmitWinCFIEndProlog(
SMLoc Loc =
SMLoc());
926 virtual void EmitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
928 virtual void EmitWinEHHandlerData(
SMLoc Loc =
SMLoc());
941 virtual void EmitSyntaxDirective();
958 bool PrintSchedInfo =
false);
963 virtual void EmitBundleAlignMode(
unsigned AlignPow2);
969 virtual void EmitBundleLock(
bool AlignToEnd);
972 virtual void EmitBundleUnlock();
977 void EmitRawText(
const Twine &String);
980 virtual void FinishImpl();
1008 std::unique_ptr<formatted_raw_ostream> OS,
1009 bool isVerboseAsm,
bool useDwarfDirectory,
1015 #endif // LLVM_MC_MCSTREAMER_H void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
unsigned GetSymbolOrder(const MCSymbol *Sym) const
Returns an index to represent the order a symbol was emitted in.
virtual void EmitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
virtual ~MCTargetStreamer()
virtual void EmitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
void push_back(const T &Elt)
virtual void EmitAddrsigSym(const MCSymbol *Sym)
void SwitchSectionNoChange(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Target specific streamer interface.
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
void PushSection()
Save the current and previous section on the section stack.
virtual void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
virtual void emitValue(const MCExpr *Value)
COFF::SymbolStorageClass StorageClass
unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum=nullptr, Optional< StringRef > Source=None, unsigned CUID=0)
Associate a filename with a specified logical file number.
MCContext & getContext() const
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
Tagged union holding either a T or a Error.
virtual void emitLabel(MCSymbol *Symbol)
unsigned getNumWinFrameInfos()
ArrayRef< std::unique_ptr< WinEH::FrameInfo > > getWinFrameInfos() const
Context object for machine code objects.
MCSectionSubPair getPreviousSection() const
Return the previous section that the streamer is emitting code to.
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
virtual void EmitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' 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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool getUseAssemblerInfoForParsing()
Instances of this class represent a single low-level machine instruction.
virtual MCAssembler * getAssemblerPtr()
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Streaming machine code generation interface.
WinEH::FrameInfo * getCurrentWinFrameInfo()
MCTargetStreamer * getTargetStreamer()
The instances of the Type class are immutable: once they are created, they are never changed...
MCCodeEmitter - Generic instruction encoding interface.
virtual void EmitCodePaddingBasicBlockStart(const MCCodePaddingContext &Context)
MCLOHType
Linker Optimization Hint Type.
virtual bool mayHaveInstructions(MCSection &Sec) const
void setUseAssemblerInfoForParsing(bool v)
virtual void EmitAddrsig()
virtual void EmitIdent(StringRef IdentString)
Emit the "identifiers" directive.
bool SubSection(const MCExpr *Subsection)
virtual void EmitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
Triple - Helper class for working with autoconf configuration names.
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
MCStreamer & getStreamer()
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
BlockVerifier::State From
virtual void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
virtual bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc, const MCSubtargetInfo &STI)
Emit a .reloc directive.
virtual void EmitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Promote Memory to Register
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
virtual void changeSection(const MCSection *CurSection, MCSection *Section, const MCExpr *SubSection, raw_ostream &OS)
Update streamer for a new active section.
Target - Wrapper for Target specific information.
MCSection * getCurrentSectionOnly() const
MCTargetStreamer(MCStreamer &S)
virtual void EmitCVFileChecksumOffsetDirective(unsigned FileNo)
This implements the CodeView '.cv_filechecksumoffset' 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...
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getNumFrameInfos()
virtual void EmitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
LLVM_NODISCARD bool empty() const
virtual void EmitCodePaddingBasicBlockEnd(const MCCodePaddingContext &Context)
Generic base class for all target subtargets.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool PopSection()
Restore the current and previous section from the section stack.
LLVM Value Representation.
Generic interface to target specific assembler backends.
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
Defines the llvm::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
virtual void emitDwarfFileDirective(StringRef Directive)
Represents a location in source code.
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
void setTargetStreamer(MCTargetStreamer *TS)
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
virtual bool isIntegratedAssemblerRequired() const
Is the integrated assembler required for this streamer to function correctly?