82 for (
const unsigned char C :
Data.bytes()) {
94 : Context(Ctx), CurrentWinFrameInfo(nullptr),
95 CurrentProcWinFrameInfoStartIndex(0) {
96 SectionStack.
push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
102 DwarfFrameInfos.clear();
103 CurrentWinFrameInfo =
nullptr;
104 WinFrameInfos.clear();
105 SectionStack.
clear();
106 SectionStack.
push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
117 return DwarfFrameInfos;
126 for (
auto &FI : DwarfFrameInfos)
127 FI.CompactUnwindEncoding =
140 unsigned Index = IsLittleEndian ? 0 : 8 -
Size;
144 if (
Value.getNumWords() == 1) {
152 const unsigned Size =
Value.getBitWidth() / 8;
184 bool IsSectionRelative) {
186 "SectionRelative value requires 4-bytes");
188 if (!IsSectionRelative)
233 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
241 std::optional<MD5::MD5Result> Checksum,
242 std::optional<StringRef> Source,
263 unsigned Column,
unsigned Flags,
264 unsigned Isa,
unsigned Discriminator,
281 return !FrameInfoStack.empty();
287 "this directive must appear between "
288 ".cfi_startproc and .cfi_endproc directives");
291 return &DwarfFrameInfos[FrameInfoStack.back().first];
296 unsigned ChecksumKind) {
306 unsigned IAFunc,
unsigned IAFile,
307 unsigned IALine,
unsigned IACol,
309 if (
getContext().getCVContext().getCVFunctionInfo(IAFunc) ==
nullptr) {
311 ".cv_func_id or .cv_inline_site_id");
320 unsigned Line,
unsigned Column,
321 bool PrologueEnd,
bool IsStmt,
330 Loc,
"function id not introduced by .cv_func_id or .cv_inline_site_id");
340 "all .cv_loc directives for a function must be in the same section");
351 unsigned SourceFileId,
352 unsigned SourceLineNum,
361 const T &DefRangeHeader) {
362 BytePrefix.
resize(2 +
sizeof(
T));
363 codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
364 memcpy(&BytePrefix[0], &SymKindLE, 2);
365 memcpy(&BytePrefix[2], &DefRangeHeader,
sizeof(
T));
369 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
373 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
381 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
390 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
398 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
415 Symbol->redefineIfPossible();
417 if (!Symbol->isUndefined() || Symbol->isVariable())
419 "' is already defined");
421 assert(!Symbol->isVariable() &&
"Cannot emit a variable symbol!");
423 assert(!Symbol->getFragment() &&
"Unexpected fragment on symbol data!");
424 assert(Symbol->isUndefined() &&
"Cannot define a symbol twice!");
439 if (!FrameInfoStack.empty() &&
442 Loc,
"starting new .cfi frame before finishing the previous one");
460 DwarfFrameInfos.push_back(Frame);
471 FrameInfoStack.pop_back();
703 Loc,
".seh_* directives are not supported on this target");
706 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->
End) {
708 Loc,
".seh_ directive must appear within an active frame");
711 return CurrentWinFrameInfo;
718 Loc,
".seh_* directives are not supported on this target");
719 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->
End)
721 Loc,
"Starting a function before ending the previous one!");
725 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
726 WinFrameInfos.emplace_back(
727 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
728 CurrentWinFrameInfo = WinFrameInfos.back().get();
740 CurFrame->
End = Label;
744 for (
size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
768 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
769 CurFrame->
Function, StartProc, CurFrame));
770 CurrentWinFrameInfo = WinFrameInfos.back().get();
780 Loc,
"End of a chained region outside a chained region!");
784 CurFrame->
End = Label;
795 Loc,
"Chained unwind areas can't have handlers!");
797 if (!Except && !Unwind)
824 const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
825 auto *MainCFISecCOFF = cast<MCSectionCOFF>(MainCFISec);
826 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
832 KeySym = TextSecCOFF->getCOMDATSymbol();
838 std::string
SectionName = (MainCFISecCOFF->getName() +
"$" +
839 TextSecCOFF->getName().split(
'$').second)
842 MainCFISecCOFF->getCharacteristics() |
853 getContext().getObjectFileInfo()->getPDataSection(),
859 getContext().getObjectFileInfo()->getXDataSection(),
888 Loc,
"frame register and offset can be set at most once");
893 Loc,
"frame offset must be less than or equal to 240");
909 "stack allocation size must be non-zero");
912 Loc,
"stack allocation size is not a multiple of 8");
928 Loc,
"register save offset is not 8 byte aligned");
958 Loc,
"If present, PushMachFrame must be the first UOP");
994 "it (target backend is likely missing an AsmStreamer "
1008 if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
1009 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1037 const Twine &Comment) {
1058 Symbol->setVariableValue(
Value);
1078 cast<MCTargetExpr>(Expr).visitUsedExpr(*
this);
1125 FnSym, Probe, InlineStack);
1186 llvm_unreachable(
"emitXCOFFSymbolLinkageWithVisibility is only supported on "
1194 llvm_unreachable(
"emitXCOFFRefDirective is only supported on XCOFF targets");
1199 unsigned Lang,
unsigned Reason,
1200 unsigned FunctionSize,
1215 Align ByteAlignment) {}
1219 CurFrag = &Section->getDummyFragment();
1234 unsigned MaxBytesToEmit) {}
1236 unsigned MaxBytesToEmit) {}
1245 if (SectionStack.
size() <= 1)
1247 auto I = SectionStack.
end();
1253 if (NewSec.first && OldSec != NewSec)
1260 assert(Section &&
"Cannot switch to a null section!");
1262 SectionStack.
back().second = curSection;
1266 assert(!Section->hasEnded() &&
"Section already ended");
1268 if (
Sym && !
Sym->isInSection())
1278 "cannot evaluate subsection number");
1281 if (!isUInt<31>(Subsec)) {
1283 "subsection number " +
Twine(Subsec) +
1284 " is not within [0,2147483647]");
1293 SectionStack.
back().second = SectionStack.
back().first;
1295 CurFrag = &Section->getDummyFragment();
1302 if (
Sym->isInSection())
1314 return !Min.
empty() && Min > TargetVersion ? Min : TargetVersion;
1320 switch (
Target.getOS()) {
1326 "mac Catalyst should use LC_BUILD_VERSION");
1340 switch (
Target.getOS()) {
1346 if (
Target.isMacCatalystEnvironment())
1368 switch (
Target.getOS()) {
1371 return MachO::PLATFORM_MACOS;
1373 if (
Target.isMacCatalystEnvironment())
1374 return MachO::PLATFORM_MACCATALYST;
1375 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1376 : MachO::PLATFORM_IOS;
1378 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1379 : MachO::PLATFORM_TVOS;
1381 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1382 : MachO::PLATFORM_WATCHOS;
1384 return MachO::PLATFORM_DRIVERKIT;
1386 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1387 : MachO::PLATFORM_XROS;
1396 const Triple *DarwinTargetVariantTriple,
1398 if (!
Target.isOSBinFormatMachO() || !
Target.isOSDarwin())
1401 if (
Target.getOSMajorVersion() == 0)
1405 switch (
Target.getOS()) {
1426 assert(
Version.getMajor() != 0 &&
"A non-zero major version is expected");
1427 auto LinkedTargetVersion =
1430 bool ShouldEmitBuildVersion =
false;
1431 if (BuildVersionOSVersion.empty() ||
1432 LinkedTargetVersion >= BuildVersionOSVersion) {
1433 if (
Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1434 DarwinTargetVariantTriple->
isMacOSX()) {
1436 DarwinTargetVariantSDKVersion,
1441 LinkedTargetVersion.getMajor(),
1442 LinkedTargetVersion.getMinor().value_or(0),
1443 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1447 LinkedTargetVersion.getMajor(),
1448 LinkedTargetVersion.getMinor().value_or(0),
1449 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1450 ShouldEmitBuildVersion =
true;
1453 if (
const Triple *TVT = DarwinTargetVariantTriple) {
1454 if (
Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1455 auto TVLinkedTargetVersion =
1459 TVLinkedTargetVersion.getMajor(),
1460 TVLinkedTargetVersion.getMinor().value_or(0),
1461 TVLinkedTargetVersion.getSubminor().value_or(0),
1462 DarwinTargetVariantSDKVersion);
1466 if (ShouldEmitBuildVersion)
1470 LinkedTargetVersion.getMajor(),
1471 LinkedTargetVersion.getMinor().value_or(0),
1472 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 hasCOFFAssociativeComdats() const
bool isLittleEndian() const
True if the target is little endian.
const std::vector< MCCFIInstruction > & getInitialFrameState() const
const char * getData8bitsDirective() 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 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 const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCPseudoProbeTable & getMCPseudoProbeTable()
const MCObjectFileInfo * getObjectFileInfo() const
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
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)
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID)
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
void reportError(SMLoc L, const Twine &Msg)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
dwarf::DwarfFormat getDwarfFormat() const
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
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
void setLabel(MCSymbol *Label)
MCSymbol * getLabel() const
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.
@ Binary
Binary expressions.
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
MCSection * getTextSection() const
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.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
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)
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual 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 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 emitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
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.
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 emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
virtual void emitBundleLock(bool AlignToEnd)
The following instructions are a bundle-locked group.
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
bool hasUnfinishedDwarfFrameInfo()
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
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 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 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 emitCFINegateRAState(SMLoc Loc={})
virtual void emitGPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
MCContext & getContext() const
SMLoc getStartTokLoc() const
virtual void emitBundleUnlock()
Ends a bundle-locked group.
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 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 emitTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
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 emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
virtual void emitCFISections(bool EH, bool Debug)
MCTargetStreamer * getTargetStreamer()
MCStreamer(MCContext &Ctx)
virtual void emitAssemblerFlag(MCAssemblerFlag Flag)
Note in the output the specified Flag.
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
virtual void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
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())
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 emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
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 emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
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 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.
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={})
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 emitBundleAlignMode(Align Alignment)
Set the bundle alignment mode from now on in the section.
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)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
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)
static const bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
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...
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
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
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)
std::vector< Instruction > Instructions
const MCSymbol * Function
const MCSymbol * PrologEnd
const MCSymbol * FuncletOrFuncEnd
const FrameInfo * ChainedParent
const MCSymbol * ExceptionHandler