81 for (
const unsigned char C :
Data.bytes()) {
93 :
Context(Ctx), CurrentWinFrameInfo(nullptr),
94 CurrentProcWinFrameInfoStartIndex(0) {
95 SectionStack.
push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
101 DwarfFrameInfos.clear();
102 CurrentWinFrameInfo =
nullptr;
103 WinFrameInfos.clear();
104 SectionStack.
clear();
105 SectionStack.
push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
116 return DwarfFrameInfos;
125 for (
auto &FI : DwarfFrameInfos)
126 FI.CompactUnwindEncoding =
139 unsigned Index = IsLittleEndian ? 0 : 8 -
Size;
143 if (
Value.getNumWords() == 1) {
151 const unsigned Size =
Value.getBitWidth() / 8;
183 bool IsSectionRelative) {
185 "SectionRelative value requires 4-bytes");
187 if (!IsSectionRelative)
208 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
216 std::optional<MD5::MD5Result> Checksum,
217 std::optional<StringRef> Source,
238 unsigned Column,
unsigned Flags,
239 unsigned Isa,
unsigned Discriminator,
262 return !FrameInfoStack.empty();
268 "this directive must appear between "
269 ".cfi_startproc and .cfi_endproc directives");
272 return &DwarfFrameInfos[FrameInfoStack.back().first];
277 unsigned ChecksumKind) {
287 unsigned IAFunc,
unsigned IAFile,
288 unsigned IALine,
unsigned IACol,
290 if (
getContext().getCVContext().getCVFunctionInfo(IAFunc) ==
nullptr) {
292 ".cv_func_id or .cv_inline_site_id");
301 unsigned Line,
unsigned Column,
302 bool PrologueEnd,
bool IsStmt,
311 Loc,
"function id not introduced by .cv_func_id or .cv_inline_site_id");
321 "all .cv_loc directives for a function must be in the same section");
332 unsigned SourceFileId,
333 unsigned SourceLineNum,
342 const T &DefRangeHeader) {
343 BytePrefix.
resize(2 +
sizeof(
T));
344 codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
345 memcpy(&BytePrefix[0], &SymKindLE, 2);
346 memcpy(&BytePrefix[2], &DefRangeHeader,
sizeof(
T));
350 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
354 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
362 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
371 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
379 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
396 Symbol->redefineIfPossible();
398 if (!Symbol->isUndefined() || Symbol->isVariable())
400 "' is already defined");
402 assert(!Symbol->isVariable() &&
"Cannot emit a variable symbol!");
404 assert(!Symbol->getFragment() &&
"Unexpected fragment on symbol data!");
405 assert(Symbol->isUndefined() &&
"Cannot define a symbol twice!");
420 if (!FrameInfoStack.empty() &&
423 Loc,
"starting new .cfi frame before finishing the previous one");
441 DwarfFrameInfos.push_back(std::move(Frame));
452 FrameInfoStack.pop_back();
472 return LineStreamLabel;
718 Loc,
".seh_* directives are not supported on this target");
721 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->
End) {
723 Loc,
".seh_ directive must appear within an active frame");
726 return CurrentWinFrameInfo;
733 Loc,
".seh_* directives are not supported on this target");
734 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->
End)
736 Loc,
"Starting a function before ending the previous one!");
740 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
741 WinFrameInfos.emplace_back(
742 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
743 CurrentWinFrameInfo = WinFrameInfos.back().get();
756 CurFrame->
End = Label;
760 for (
size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
784 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
785 CurFrame->
Function, StartProc, CurFrame));
786 CurrentWinFrameInfo = WinFrameInfos.back().get();
796 Loc,
"End of a chained region outside a chained region!");
800 CurFrame->
End = Label;
811 Loc,
"Chained unwind areas can't have handlers!");
813 if (!Except && !Unwind)
837 if (TextSec ==
Context.getObjectFileInfo()->getTextSection())
840 const auto *TextSecCOFF =
static_cast<const MCSectionCOFF *
>(TextSec);
841 auto *MainCFISecCOFF =
static_cast<MCSectionCOFF *
>(MainCFISec);
848 KeySym = TextSecCOFF->getCOMDATSymbol();
853 if (!
Context.getAsmInfo()->hasCOFFAssociativeComdats()) {
854 std::string
SectionName = (MainCFISecCOFF->getName() +
"$" +
855 TextSecCOFF->getName().split(
'$').second)
858 MainCFISecCOFF->getCharacteristics() |
864 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
869 getContext().getObjectFileInfo()->getPDataSection(),
875 getContext().getObjectFileInfo()->getXDataSection(),
904 Loc,
"frame register and offset can be set at most once");
909 Loc,
"frame offset must be less than or equal to 240");
925 "stack allocation size must be non-zero");
928 Loc,
"stack allocation size is not a multiple of 8");
944 Loc,
"register save offset is not 8 byte aligned");
974 Loc,
"If present, PushMachFrame must be the first UOP");
999 Loc,
"starting epilogue (.seh_startepilogue) before prologue has ended "
1000 "(.seh_endprologue) in " +
1056 Loc,
"Unsupported version specified in .seh_unwindversion in " +
1084 "it (target backend is likely missing an AsmStreamer "
1098 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1099 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1127 const Twine &Comment) {
1148 Symbol->setVariableValue(
Value);
1168 cast<MCTargetExpr>(Expr).visitUsedExpr(*
this);
1219 FnSym, Probe, InlineStack);
1253 "emitSubsectionsViaSymbols only supported on Mach-O targets");
1282 llvm_unreachable(
"emitXCOFFSymbolLinkageWithVisibility is only supported on "
1290 llvm_unreachable(
"emitXCOFFRefDirective is only supported on XCOFF targets");
1295 unsigned Lang,
unsigned Reason,
1296 unsigned FunctionSize,
1311 Align ByteAlignment) {}
1320 if (!
Sym || !
Sym->isUndefined())
1343 unsigned MaxBytesToEmit) {}
1349 if (SectionStack.
size() <= 1)
1351 auto I = SectionStack.
end();
1357 if (NewSec.first && OldSec != NewSec)
1364 assert(Section &&
"Cannot switch to a null section!");
1366 SectionStack.
back().second = curSection;
1370 assert(!Section->hasEnded() &&
"Section already ended");
1379 "cannot evaluate subsection number");
1382 if (!isUInt<31>(Subsec)) {
1384 "subsection number " +
Twine(Subsec) +
1385 " is not within [0,2147483647]");
1394 SectionStack.
back().second = SectionStack.
back().first;
1403 if (
Sym->isInSection())
1417 Sec->curFragList()->Tail =
F;
1424 return !Min.
empty() && Min > TargetVersion ? Min : TargetVersion;
1430 switch (
Target.getOS()) {
1436 "mac Catalyst should use LC_BUILD_VERSION");
1450 switch (
Target.getOS()) {
1456 if (
Target.isMacCatalystEnvironment())
1477 switch (
Target.getOS()) {
1480 return MachO::PLATFORM_MACOS;
1482 if (
Target.isMacCatalystEnvironment())
1483 return MachO::PLATFORM_MACCATALYST;
1484 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1485 : MachO::PLATFORM_IOS;
1487 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1488 : MachO::PLATFORM_TVOS;
1490 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1491 : MachO::PLATFORM_WATCHOS;
1493 return MachO::PLATFORM_DRIVERKIT;
1495 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1496 : MachO::PLATFORM_XROS;
1498 return MachO::PLATFORM_BRIDGEOS;
1507 const Triple *DarwinTargetVariantTriple,
1509 if (!
Target.isOSBinFormatMachO() || !
Target.isOSDarwin())
1512 if (
Target.getOSMajorVersion() == 0)
1516 switch (
Target.getOS()) {
1538 assert(
Version.getMajor() != 0 &&
"A non-zero major version is expected");
1539 auto LinkedTargetVersion =
1542 bool ShouldEmitBuildVersion =
false;
1543 if (BuildVersionOSVersion.empty() ||
1544 LinkedTargetVersion >= BuildVersionOSVersion) {
1545 if (
Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1546 DarwinTargetVariantTriple->
isMacOSX()) {
1548 DarwinTargetVariantSDKVersion,
1553 LinkedTargetVersion.getMajor(),
1554 LinkedTargetVersion.getMinor().value_or(0),
1555 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1559 LinkedTargetVersion.getMajor(),
1560 LinkedTargetVersion.getMinor().value_or(0),
1561 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1562 ShouldEmitBuildVersion =
true;
1565 if (
const Triple *TVT = DarwinTargetVariantTriple) {
1566 if (
Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1567 auto TVLinkedTargetVersion =
1571 TVLinkedTargetVersion.getMajor(),
1572 TVLinkedTargetVersion.getMinor().value_or(0),
1573 TVLinkedTargetVersion.getSubminor().value_or(0),
1574 DarwinTargetVariantSDKVersion);
1578 if (ShouldEmitBuildVersion)
1582 LinkedTargetVersion.getMajor(),
1583 LinkedTargetVersion.getMinor().value_or(0),
1584 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
BlockVerifier::State From
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target)
static void copyBytesForDefRange(SmallString< 20 > &BytePrefix, codeview::SymbolKind SymKind, const T &DefRangeHeader)
Only call this on endian-specific types like ulittle16_t and little32_t, or structs composed of them.
static MCVersionMinType getMachoVersionMinLoadCommandType(const Triple &Target)
static VersionTuple targetVersionOrMinimumSupportedOSVersion(const Triple &Target, VersionTuple TargetVersion)
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
This file defines the SmallString class.
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Holds state from .cv_file and .cv_loc directives for later emission.
bool addFile(MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind)
MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Tagged union holding either a T or a Error.
Generic interface to target specific assembler backends.
virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const
Generate the compact unwind encoding for the CFI instructions.
This class is intended to be used as a base class for asm properties and features specific to the tar...
StringRef getPrivateGlobalPrefix() const
bool isLittleEndian() const
True if the target is little endian.
const std::vector< MCCFIInstruction > & getInitialFrameState() const
const char * getData8bitsDirective() const
void printExpr(raw_ostream &, const MCExpr &) const
virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, const Triple &, raw_ostream &) const
bool doesSetDirectiveSuppressReloc() const
bool usesWindowsCFI() const
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size, SMLoc Loc={})
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int64_t Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_val_offset Previous value of Register is offset Offset from the current CFA register.
static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
static MCCFIInstruction createLabel(MCSymbol *L, MCSymbol *CfiLabel, SMLoc Loc)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCPseudoProbeTable & getMCPseudoProbeTable()
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
LLVM_ABI Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
LLVM_ABI CodeViewContext & getCVContext()
const MCRegisterInfo * getRegisterInfo() const
void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
Saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen.
const MCAsmInfo * getAsmInfo() const
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
const MCDwarfLoc & getCurrentDwarfLoc()
dwarf::DwarfFormat getDwarfFormat() const
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
const Triple & getTargetTriple() const
Instances of this class represent the line information for the dwarf line table entries.
void setLabel(MCSymbol *Label)
LLVM_ABI void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc, StringRef Name)
const MCLineSection & getMCLineSections() const
MCSymbol * getLabel() const
Instances of this class represent the information from a dwarf .loc directive.
Base class for the full range of assembler expressions which are needed for parsing.
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Target
Target specific expression.
@ Specifier
Expression with a relocation specifier.
@ Binary
Binary expressions.
unsigned getLayoutOrder() const
MCSection * getParent() const
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
const MCOperand & getOperand(unsigned i) const
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
const MCExpr * getExpr() const
void addPseudoProbe(MCSymbol *FuncSym, const MCPseudoProbe &Probe, const MCPseudoProbeInlineStack &InlineStack)
MCPseudoProbeSections & getProbeSections()
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
int getSEHRegNum(MCRegister RegNum) const
Map a target register to an equivalent SEH register number.
Wrapper class representing physical registers. Should be passed by value.
This represents a section on Windows.
unsigned getOrAssignWinCFISectionID(unsigned *NextID) const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCFragment & getDummyFragment()
MCSymbol * getBeginSymbol()
Streaming machine code generation interface.
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
MCSymbol * emitLineTableLabel()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
void switchSectionNoPrint(MCSection *Section)
Similar to switchSection, but does not print the section directive.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFIUnwindVersion(uint8_t Version, SMLoc Loc=SMLoc())
virtual void visitUsedSymbol(const MCSymbol &Sym)
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
virtual void finishImpl()
Streamer specific finalization.
virtual void emitCFIBKeyFrame()
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
virtual void beginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void emitSyntaxDirective()
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
virtual void emitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
virtual void initSections(bool NoExecStack, const MCSubtargetInfo &STI)
Create the default sections and set the initial one.
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
virtual void emitWindowsUnwindTables()
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, Align ByteAlignment=Align(1), SMLoc Loc=SMLoc())
Emit the zerofill section and an optional symbol.
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
virtual void emitCFISections(bool EH, bool Debug, bool SFrame)
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
bool hasUnfinishedDwarfFrameInfo()
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual bool emitCVFileDirective(unsigned FileNo, StringRef Filename, ArrayRef< uint8_t > Checksum, unsigned ChecksumKind)
Associate a filename with a specified logical file number, and also specify that file's checksum info...
virtual void emitCFIReturnColumn(int64_t Register)
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
virtual void emitWinCFIUnwindV2Start(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset)
Emits a COFF image relative relocation.
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
virtual MCAssembler * getAssemblerPtr()
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
void setTargetStreamer(MCTargetStreamer *TS)
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
virtual void emitCOFFSecNumber(MCSymbol const *Symbol)
Emits the physical number of the section containing the given symbol as assigned during object writin...
virtual void emitCFINegateRAState(SMLoc Loc={})
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
MCContext & getContext() const
SMLoc getStartTokLoc() const
virtual Expected< unsigned > tryEmitDwarfFileDirective(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.
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, MCSymbol *CsectSym, Align Alignment)
Emits an lcomm directive with XCOFF csect information.
virtual void emitCFIMTETaggedFrame()
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
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 emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
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.
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the .cv_loc directive is in the right section.
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap, unsigned Lang, unsigned Reason, unsigned FunctionSize, bool hasDebug)
Emit an XCOFF .except directive which adds information about a trap instruction to the object file ex...
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
virtual void emitCFIRememberState(SMLoc Loc)
virtual void reset()
State management.
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName, StringRef Comment={})
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitCOFFSecOffset(MCSymbol const *Symbol)
Emits the offset of the symbol from the beginning of the section during object writing (i....
MCTargetStreamer * getTargetStreamer()
MCStreamer(MCContext &Ctx)
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
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.
unsigned getNumFrameInfos()
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
virtual void emitSubsectionsViaSymbols()
Emit a .subsection_via_symbols directive.
void emitVersionForTarget(const Triple &Target, const VersionTuple &SDKVersion, const Triple *DarwinTargetVariantTriple, const VersionTuple &DarwinTargetVariantSDKVersion)
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
virtual void emitXCOFFRenameDirective(const MCSymbol *Name, StringRef Rename)
Emit a XCOFF .rename directive which creates a synonym for an illegal or undesirable name.
virtual void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, uint64_t Discriminator, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
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.
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
virtual void emitCFIRestoreState(SMLoc Loc)
virtual void emitXCOFFRefDirective(const MCSymbol *Symbol)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
virtual void emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
void emitInt32(uint64_t Value)
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
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 emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata)
Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
MCSection * getCurrentSectionOnly() 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.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
void addFragment(MCFragment *F)
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
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 emitCFISignalFrame()
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol, but only if Value is also emitted.
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCFIRestore(int64_t Register, SMLoc Loc={})
WinEH::FrameInfo::Epilog * CurrentWinEpilog
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 emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
virtual void emitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void visitUsedExpr(const MCExpr &Expr)
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID=0)
Specify the "root" file of the compilation, using the ".file 0" extension.
virtual void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
virtual void changeSection(MCSection *, uint32_t)
This is called by popSection and switchSection, if the current section changes.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
Target specific streamer interface.
virtual void emitDwarfFileDirective(StringRef Directive)
virtual void emitValue(const MCExpr *Value)
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
virtual ~MCTargetStreamer()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
MCTargetStreamer(MCStreamer &S)
virtual void changeSection(const MCSection *CurSection, MCSection *Section, uint32_t SubSection, raw_ostream &OS)
Update streamer for a new active section.
virtual void emitLabel(MCSymbol *Symbol)
virtual void emitConstantPools()
Wrapper class representing virtual and physical registers.
Represents a location in source code.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
bool isMacOSX() const
Is this a Mac OS X triple.
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]]].
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
StringRef str() const
Return a StringRef for the vector contents.
This class represents a function that is read from a sample profile.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_COMDAT_SELECT_ANY
@ C
The default llvm calling convention, compatible with C.
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
value_type byte_swap(value_type value, endianness endian)
constexpr bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes)
StoreIntToMemory - Fills the StoreBytes bytes of memory starting from Dst with the integer held in In...
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
std::pair< MCSection *, uint32_t > MCSectionSubPair
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
@ MCVM_WatchOSVersionMin
.watchos_version_min
@ MCVM_OSXVersionMin
.macosx_version_min
@ MCVM_TvOSVersionMin
.tvos_version_min
@ MCVM_IOSVersionMin
.ios_version_min
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Information describing a function or inlined call site introduced by .cv_func_id or ....
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet.
const MCSymbol * Personality
unsigned PersonalityEncoding
std::vector< MCCFIInstruction > Instructions
unsigned CurrentCfaRegister
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
const MCSymbol * UnwindV2Start
std::vector< Instruction > Instructions
const MCSymbol * Function
const MCSymbol * PrologEnd
MapVector< MCSymbol *, Epilog > EpilogMap
const MCSymbol * FuncletOrFuncEnd
const FrameInfo * ChainedParent
static constexpr uint8_t DefaultVersion
const MCSymbol * ExceptionHandler