46 std::unique_ptr<formatted_raw_ostream> OSOwner;
49 std::unique_ptr<MCInstPrinter> InstPrinter;
50 std::unique_ptr<MCAssembler> Assembler;
57 unsigned IsVerboseAsm : 1;
58 unsigned ShowInst : 1;
59 unsigned UseDwarfDirectory : 1;
61 void EmitRegisterName(int64_t
Register);
63 void printDwarfFileDirective(
unsigned FileNo,
StringRef Directory,
65 std::optional<MD5::MD5Result> Checksum,
66 std::optional<StringRef> Source,
67 bool UseDwarfDirectory,
73 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
74 bool isVerboseAsm,
bool useDwarfDirectory,
76 std::unique_ptr<MCAsmBackend> asmbackend,
bool showInst)
81 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
83 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
84 ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
87 InstPrinter->setCommentStream(CommentStream);
88 if (Assembler->getBackendPtr())
91 Context.setUseNamesOnTempLabels(
true);
97 inline void EmitEOL() {
105 EmitCommentsAndEOL();
110 void EmitCommentsAndEOL();
113 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
132 return CommentStream;
149 bool KeepOriginalSym)
override;
156 return InstPrinter->getMnemonic(&
MI).first;
169 unsigned Minor,
unsigned Update,
201 unsigned Lang,
unsigned Reason,
202 unsigned FunctionSize,
bool hasDebug)
override;
206 Align ByteAlignment)
override;
214 Align ByteAlignment)
override;
252 void emitAlignmentDirective(
unsigned ByteAlignment,
253 std::optional<int64_t>
Value,
unsigned ValueSize,
254 unsigned MaxBytesToEmit);
257 unsigned ValueSize = 1,
258 unsigned MaxBytesToEmit = 0)
override;
261 unsigned MaxBytesToEmit = 0)
override;
272 std::optional<MD5::MD5Result> Checksum = std::nullopt,
273 std::optional<StringRef> Source = std::nullopt,
274 unsigned CUID = 0)
override;
276 std::optional<MD5::MD5Result> Checksum,
277 std::optional<StringRef> Source,
278 unsigned CUID = 0)
override;
280 unsigned Flags,
unsigned Isa,
281 unsigned Discriminator,
287 unsigned ChecksumKind)
override;
290 unsigned IAFile,
unsigned IALine,
291 unsigned IACol,
SMLoc Loc)
override;
293 unsigned Column,
bool PrologueEnd,
bool IsStmt,
298 unsigned SourceFileId,
299 unsigned SourceLineNum,
303 void PrintCVDefRangePrefix(
304 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
307 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
311 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
315 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
319 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
387 std::optional<std::pair<bool, std::string>>
404 const Twine &Comment)
override;
412 unsigned PointerSize)
override;
419void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
420 if (!IsVerboseAsm)
return;
422 T.toVector(CommentToEmit);
428void MCAsmStreamer::EmitCommentsAndEOL() {
437 "Comment array not newline terminated");
441 size_t Position = Comments.
find(
'\n');
444 Comments = Comments.
substr(Position+1);
445 }
while (!Comments.
empty());
447 CommentToEmit.
clear();
451 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
452 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
455void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
462void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
467 ExplicitCommentToEmit.
append(
"\t");
472 size_t p = 2, len = c.
size() - 2;
476 ExplicitCommentToEmit.
append(
"\t");
481 ExplicitCommentToEmit.
append(
"\n");
485 ExplicitCommentToEmit.
append(
"\t");
487 }
else if (c.
front() ==
'#') {
489 ExplicitCommentToEmit.
append(
"\t");
493 assert(
false &&
"Unexpected Assembly Comment");
495 if (c.
back() ==
'\n')
496 emitExplicitComments();
499void MCAsmStreamer::emitExplicitComments() {
500 StringRef Comments = ExplicitCommentToEmit;
501 if (!Comments.
empty())
503 ExplicitCommentToEmit.
clear();
506void MCAsmStreamer::changeSection(
MCSection *Section,
507 const MCExpr *Subsection) {
508 assert(Section &&
"Cannot switch to a null section!");
510 TS->changeSection(getCurrentSectionOnly(), Section, Subsection,
OS);
512 Section->printSwitchToSection(*MAI, getContext().getTargetTriple(),
OS,
517void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
519 bool KeepOriginalSym) {
523 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
542 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
543 assert(str !=
"" &&
"Invalid LOH name");
557void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
558 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
573 assert(!
Options.empty() &&
"At least one option is required!");
574 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
576 OS <<
", " <<
'"' << Opt <<
'"';
605 if (SDKVersion.
empty())
607 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
608 if (
auto Minor = SDKVersion.
getMinor()) {
609 OS <<
", " << *Minor;
611 OS <<
", " << *Subminor;
617 unsigned Minor,
unsigned Update,
621 OS <<
", " << Update;
644void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
645 unsigned Minor,
unsigned Update,
648 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
650 OS <<
", " << Update;
655void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
656 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
658 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
661void MCAsmStreamer::emitThumbFunc(
MCSymbol *Func) {
664 OS <<
"\t.thumb_func";
676 if (
auto *
E = dyn_cast<MCTargetExpr>(
Value))
677 if (
E->inlineAssignedExpr())
691void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
693 OS <<
".lto_set_conditional ";
700void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
708bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
725 default:
return false;
748 OS <<
"\t.no_dead_strip\t";
753 OS <<
"\t.private_extern\t";
762 OS <<
"\t.weak_definition\t";
783void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
784 OS <<
".desc" <<
' ';
786 OS <<
',' << DescValue;
790void MCAsmStreamer::emitSyntaxDirective() {
792 OS <<
"\t.intel_syntax noprefix";
800void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
807void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
812void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
813 OS <<
"\t.type\t" <<
Type <<
';';
817void MCAsmStreamer::endCOFFSymbolDef() {
822void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
823 OS <<
"\t.safeseh\t";
828void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
834void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
841 OS <<
"\t.secrel32\t";
848void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
861void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
866 "We only support writing log base-2 alignment format with XCOFF.");
872 OS <<
',' <<
Log2(Alignment);
883void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
905 switch (Visibility) {
925 if (cast<MCSymbolXCOFF>(Symbol)->hasRename())
926 emitXCOFFRenameDirective(Symbol,
927 cast<MCSymbolXCOFF>(Symbol)->getSymbolTableName());
930void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *
Name,
936 for (
char C : Rename) {
946void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
952void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
956 unsigned FunctionSize,
960 OS <<
", " << Lang <<
", " << Reason;
974 Align ByteAlignment) {
982 OS <<
',' <<
Log2(ByteAlignment);
1003 OS <<
',' << ByteAlign.
value();
1006 OS <<
',' <<
Log2(ByteAlign);
1017 assignFragment(Symbol, &
Section->getDummyFragment());
1023 ".zerofill is a Mach-O specific directive");
1033 OS <<
',' <<
Log2(ByteAlignment);
1043 assignFragment(Symbol, &
Section->getDummyFragment());
1045 assert(Symbol &&
"Symbol shouldn't be NULL!");
1049 ".zerofill is a Mach-O specific directive");
1058 if (ByteAlignment > 1)
1059 OS <<
", " <<
Log2(ByteAlignment);
1065 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1066 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1070 return isPrint(
Data.back()) ||
Data.back() == 0;
1077 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1078 const auto printCharacterInOctal = [&
OS](
unsigned char C) {
1084 const auto printOneCharacterFor = [printCharacterInOctal](
1085 auto printOnePrintingCharacter) {
1086 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1088 printOnePrintingCharacter(
static_cast<char>(
C));
1091 printCharacterInOctal(
C);
1094 const auto printCharacterList = [
Data, &
OS](
const auto &printOneCharacter) {
1095 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1096 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1097 printOneCharacter(
C);
1100 printOneCharacter(*(EndPtr - 1));
1104 printCharacterList(printCharacterInOctal);
1107 printCharacterList(printOneCharacterFor([&
OS](
char C) {
1108 const char AsmCharLitBuf[2] = {
'\'',
C};
1109 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1120 for (
unsigned char C :
Data) {
1127 for (
unsigned char C :
Data) {
1128 if (
C ==
'"' ||
C ==
'\\') {
1168 assert(getCurrentSectionOnly() &&
1169 "Cannot emit contents before setting section!");
1170 if (
Data.empty())
return;
1185 "hasPairedDoubleQuoteStringConstants target must support "
1186 "PlainString Directive");
1188 "hasPairedDoubleQuoteStringConstants target must support ByteList "
1190 if (
Data.back() == 0) {
1205 PrintQuotedString(
Data,
OS);
1210 if (
Data.size() != 1 && emitAsString(
Data))
1216 TS->emitRawBytes(
Data);
1220 for (
const unsigned char C :
Data.bytes()) {
1228 const size_t Cols = 4;
1229 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1230 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1233 for (; J < EJ - 1; ++J)
1248void MCAsmStreamer::emitIntValueInHexWithPadding(
uint64_t Value,
1256 assert(getCurrentSectionOnly() &&
1257 "Cannot emit contents before setting section!");
1269 if (!
Value->evaluateAsAbsolute(IntValue))
1284 unsigned ByteOffset =
1285 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1286 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1290 uint64_t Shift = 64 - EmissionSize * 8;
1292 std::numeric_limits<unsigned long long>::digits) &&
1293 "undefined behavior");
1294 ValueToEmit &= ~0ULL >> Shift;
1295 emitIntValue(ValueToEmit, EmissionSize);
1304 TS->emitValue(
Value);
1311void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1313 if (
Value->evaluateAsAbsolute(IntValue)) {
1314 emitULEB128IntValue(IntValue);
1317 OS <<
"\t.uleb128 ";
1322void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1324 if (
Value->evaluateAsAbsolute(IntValue)) {
1325 emitSLEB128IntValue(IntValue);
1328 OS <<
"\t.sleb128 ";
1333void MCAsmStreamer::emitDTPRel64Value(
const MCExpr *
Value) {
1340void MCAsmStreamer::emitDTPRel32Value(
const MCExpr *
Value) {
1347void MCAsmStreamer::emitTPRel64Value(
const MCExpr *
Value) {
1354void MCAsmStreamer::emitTPRel32Value(
const MCExpr *
Value) {
1361void MCAsmStreamer::emitGPRel64Value(
const MCExpr *
Value) {
1368void MCAsmStreamer::emitGPRel32Value(
const MCExpr *
Value) {
1375void MCAsmStreamer::emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
1377 int64_t IntNumBytes;
1378 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1379 if (IsAbsolute && IntNumBytes == 0)
1385 OS << ZeroDirective;
1388 OS <<
',' << (int)FillValue;
1393 "Cannot emit non-absolute expression lengths of fill.");
1394 for (
int i = 0; i < IntNumBytes; ++i) {
1405void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1406 int64_t Expr,
SMLoc Loc) {
1410 OS <<
", " <<
Size <<
", 0x";
1415void MCAsmStreamer::emitAlignmentDirective(
unsigned ByteAlignment,
1416 std::optional<int64_t>
Value,
1418 unsigned MaxBytesToEmit) {
1432 switch (ValueSize) {
1436 OS <<
"\t.p2align\t";
1450 if (
Value.has_value() || MaxBytesToEmit) {
1451 if (
Value.has_value()) {
1459 OS <<
", " << MaxBytesToEmit;
1467 switch (ValueSize) {
1469 case 1:
OS <<
".balign";
break;
1470 case 2:
OS <<
".balignw";
break;
1471 case 4:
OS <<
".balignl";
break;
1476 if (
Value.has_value())
1478 else if (MaxBytesToEmit)
1481 OS <<
", " << MaxBytesToEmit;
1485void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t
Value,
1487 unsigned MaxBytesToEmit) {
1488 emitAlignmentDirective(Alignment.
value(),
Value, ValueSize, MaxBytesToEmit);
1491void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1493 unsigned MaxBytesToEmit) {
1499 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1502void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1503 unsigned char Value,
1512void MCAsmStreamer::emitFileDirective(
StringRef Filename) {
1515 PrintQuotedString(Filename,
OS);
1519void MCAsmStreamer::emitFileDirective(
StringRef Filename,
1525 PrintQuotedString(Filename,
OS);
1527 if (!CompilerVerion.
empty()) {
1528 PrintQuotedString(CompilerVerion,
OS);
1530 if (!TimeStamp.
empty()) {
1532 PrintQuotedString(TimeStamp,
OS);
1534 if (!Description.
empty()) {
1536 PrintQuotedString(Description,
OS);
1541void MCAsmStreamer::printDwarfFileDirective(
1543 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1547 if (!UseDwarfDirectory && !Directory.
empty()) {
1551 FullPathName = Directory;
1558 OS <<
"\t.file\t" << FileNo <<
' ';
1559 if (!Directory.
empty()) {
1560 PrintQuotedString(Directory,
OS);
1563 PrintQuotedString(Filename,
OS);
1565 OS <<
" md5 0x" << Checksum->digest();
1568 PrintQuotedString(*Source,
OS);
1574 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1576 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1581 Table.
tryGetFile(Directory, Filename, Checksum, Source,
1585 FileNo = FileNoOrErr.
get();
1595 printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
1596 UseDwarfDirectory, OS1);
1599 TS->emitDwarfFileDirective(OS1.str());
1601 emitRawText(OS1.str());
1606void MCAsmStreamer::emitDwarfFile0Directive(
1608 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1615 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1624 printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
1625 UseDwarfDirectory, OS1);
1628 TS->emitDwarfFileDirective(OS1.str());
1630 emitRawText(OS1.str());
1633void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1634 unsigned Column,
unsigned Flags,
1635 unsigned Isa,
unsigned Discriminator,
1644 Discriminator, FileName);
1648 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1651 OS <<
" basic_block";
1653 OS <<
" prologue_end";
1655 OS <<
" epilogue_begin";
1657 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1668 OS <<
" isa " << Isa;
1676 <<
Line <<
':' << Column;
1680 Discriminator, FileName);
1683MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1689bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo,
StringRef Filename,
1691 unsigned ChecksumKind) {
1692 if (!getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1696 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1697 PrintQuotedString(Filename,
OS);
1699 if (!ChecksumKind) {
1705 PrintQuotedString(toHex(Checksum),
OS);
1712bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1713 OS <<
"\t.cv_func_id " <<
FuncId <<
'\n';
1717bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1720 unsigned IALine,
unsigned IACol,
1722 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1723 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1725 IALine, IACol, Loc);
1728void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1729 unsigned Line,
unsigned Column,
1730 bool PrologueEnd,
bool IsStmt,
1733 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1736 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1739 OS <<
" prologue_end";
1752void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1755 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1763void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1764 unsigned SourceFileId,
1765 unsigned SourceLineNum,
1768 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1769 <<
' ' << SourceLineNum <<
' ';
1775 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1778void MCAsmStreamer::PrintCVDefRangePrefix(
1779 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1780 OS <<
"\t.cv_def_range\t";
1781 for (std::pair<const MCSymbol *, const MCSymbol *> Range : Ranges) {
1789void MCAsmStreamer::emitCVDefRangeDirective(
1790 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1792 PrintCVDefRangePrefix(Ranges);
1793 OS <<
", reg_rel, ";
1799void MCAsmStreamer::emitCVDefRangeDirective(
1800 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1802 PrintCVDefRangePrefix(Ranges);
1803 OS <<
", subfield_reg, ";
1808void MCAsmStreamer::emitCVDefRangeDirective(
1809 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1811 PrintCVDefRangePrefix(Ranges);
1817void MCAsmStreamer::emitCVDefRangeDirective(
1818 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1820 PrintCVDefRangePrefix(Ranges);
1821 OS <<
", frame_ptr_rel, ";
1826void MCAsmStreamer::emitCVStringTableDirective() {
1827 OS <<
"\t.cv_stringtable";
1831void MCAsmStreamer::emitCVFileChecksumsDirective() {
1832 OS <<
"\t.cv_filechecksums";
1836void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1837 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1841void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
1842 OS <<
"\t.cv_fpo_data\t";
1847void MCAsmStreamer::emitIdent(
StringRef IdentString) {
1850 PrintQuotedString(IdentString,
OS);
1854void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug) {
1856 OS <<
"\t.cfi_sections ";
1860 OS <<
", .debug_frame";
1862 OS <<
".debug_frame";
1869 OS <<
"\t.cfi_startproc";
1877 OS <<
"\t.cfi_endproc";
1881void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
1887 if (std::optional<unsigned> LLVMRegister =
1889 InstPrinter->printRegName(
OS, *LLVMRegister);
1896void MCAsmStreamer::emitCFIDefCfa(int64_t
Register, int64_t
Offset) {
1898 OS <<
"\t.cfi_def_cfa ";
1904void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset) {
1906 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
1910void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
1913 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
1921 OS <<
"\t.cfi_escape ";
1922 if (!Values.
empty()) {
1923 size_t e = Values.
size() - 1;
1924 for (
size_t i = 0; i < e; ++i)
1925 OS <<
format(
"0x%02x", uint8_t(Values[i])) <<
", ";
1926 OS <<
format(
"0x%02x", uint8_t(Values[e]));
1930void MCAsmStreamer::emitCFIEscape(
StringRef Values) {
1936void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size) {
1939 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
1946void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register) {
1948 OS <<
"\t.cfi_def_cfa_register ";
1953void MCAsmStreamer::emitCFIOffset(int64_t
Register, int64_t
Offset) {
1955 OS <<
"\t.cfi_offset ";
1961void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
1962 unsigned Encoding) {
1964 OS <<
"\t.cfi_personality " << Encoding <<
", ";
1969void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
1971 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
1976void MCAsmStreamer::emitCFIRememberState() {
1978 OS <<
"\t.cfi_remember_state";
1982void MCAsmStreamer::emitCFIRestoreState() {
1984 OS <<
"\t.cfi_restore_state";
1988void MCAsmStreamer::emitCFIRestore(int64_t
Register) {
1990 OS <<
"\t.cfi_restore ";
1995void MCAsmStreamer::emitCFISameValue(int64_t
Register) {
1997 OS <<
"\t.cfi_same_value ";
2002void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset) {
2004 OS <<
"\t.cfi_rel_offset ";
2010void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment) {
2012 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2016void MCAsmStreamer::emitCFISignalFrame() {
2018 OS <<
"\t.cfi_signal_frame";
2022void MCAsmStreamer::emitCFIUndefined(int64_t
Register) {
2024 OS <<
"\t.cfi_undefined ";
2029void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2) {
2031 OS <<
"\t.cfi_register ";
2032 EmitRegisterName(Register1);
2034 EmitRegisterName(Register2);
2038void MCAsmStreamer::emitCFIWindowSave() {
2040 OS <<
"\t.cfi_window_save";
2044void MCAsmStreamer::emitCFINegateRAState() {
2046 OS <<
"\t.cfi_negate_ra_state";
2050void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2052 OS <<
"\t.cfi_return_column ";
2057void MCAsmStreamer::emitCFIBKeyFrame() {
2059 OS <<
"\t.cfi_b_key_frame";
2063void MCAsmStreamer::emitCFIMTETaggedFrame() {
2065 OS <<
"\t.cfi_mte_tagged_frame";
2069void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2077void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2080 OS <<
"\t.seh_endproc";
2084void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2087 OS <<
"\t.seh_endfunclet";
2091void MCAsmStreamer::emitWinCFIStartChained(
SMLoc Loc) {
2094 OS <<
"\t.seh_startchained";
2098void MCAsmStreamer::emitWinCFIEndChained(
SMLoc Loc) {
2101 OS <<
"\t.seh_endchained";
2105void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2106 bool Except,
SMLoc Loc) {
2109 OS <<
"\t.seh_handler ";
2112 const Triple &
T = getContext().getTargetTriple();
2116 OS <<
", " << Marker <<
"unwind";
2118 OS <<
", " << Marker <<
"except";
2122void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2137 MCSection *XData = getAssociatedXDataSection(TextSec);
2138 switchSectionNoChange(XData);
2140 OS <<
"\t.seh_handlerdata";
2147 OS <<
"\t.seh_pushreg ";
2156 OS <<
"\t.seh_setframe ";
2162void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2165 OS <<
"\t.seh_stackalloc " <<
Size;
2173 OS <<
"\t.seh_savereg ";
2183 OS <<
"\t.seh_savexmm ";
2189void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2192 OS <<
"\t.seh_pushframe";
2198void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2201 OS <<
"\t.seh_endprologue";
2208 OS <<
"\t.cg_profile ";
2209 From->getSymbol().print(
OS, MAI);
2212 OS <<
", " << Count;
2216void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2224 if (!getAssembler().getEmitterPtr())
2227 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
2234 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2237 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2240 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2241 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2242 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2244 FixupMap[
Index] = 1 + i;
2250 OS <<
"encoding: [";
2251 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2256 uint8_t MapEntry = FixupMap[i * 8 + 0];
2257 for (
unsigned j = 1;
j != 8; ++
j) {
2258 if (FixupMap[i * 8 + j] == MapEntry)
2261 MapEntry = uint8_t(~0U);
2265 if (MapEntry != uint8_t(~0U)) {
2266 if (MapEntry == 0) {
2267 OS <<
format(
"0x%02x", uint8_t(Code[i]));
2271 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\''
2272 <<
char(
'A' + MapEntry - 1) <<
'\'';
2274 OS <<
char(
'A' + MapEntry - 1);
2279 for (
unsigned j = 8;
j--;) {
2284 FixupBit = i * 8 + j;
2286 FixupBit = i * 8 + (7-
j);
2288 if (uint8_t MapEntry = FixupMap[FixupBit]) {
2289 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2290 OS <<
char(
'A' + MapEntry - 1);
2298 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2301 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2302 OS <<
" fixup " <<
char(
'A' + i) <<
" - "
2303 <<
"offset: " <<
F.getOffset() <<
", value: ";
2304 F.getValue()->print(
OS, MAI);
2305 OS <<
", kind: " <<
Info.Name <<
"\n";
2309void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2311 assert(getCurrentSectionOnly() &&
2312 "Cannot emit contents before setting section!");
2320 AddEncodingComment(Inst, STI);
2324 Inst.
dump_pretty(getCommentOS(), InstPrinter.get(),
"\n ");
2325 getCommentOS() <<
"\n";
2328 if(getTargetStreamer())
2329 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI,
OS);
2331 InstPrinter->printInst(&Inst, 0,
"", STI,
OS);
2334 if (Comments.
size() && Comments.
back() !=
'\n')
2335 getCommentOS() <<
"\n";
2340void MCAsmStreamer::emitPseudoProbe(
2343 OS <<
"\t.pseudoprobe\t" << Guid <<
" " <<
Index <<
" " <<
Type <<
" "
2347 for (
const auto &Site : InlineStack)
2348 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2355void MCAsmStreamer::emitBundleAlignMode(
Align Alignment) {
2356 OS <<
"\t.bundle_align_mode " <<
Log2(Alignment);
2360void MCAsmStreamer::emitBundleLock(
bool AlignToEnd) {
2361 OS <<
"\t.bundle_lock";
2363 OS <<
" align_to_end";
2367void MCAsmStreamer::emitBundleUnlock() {
2368 OS <<
"\t.bundle_unlock";
2372std::optional<std::pair<bool, std::string>>
2384 return std::nullopt;
2387void MCAsmStreamer::emitAddrsig() {
2392void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2393 OS <<
"\t.addrsig_sym ";
2408void MCAsmStreamer::finishImpl() {
2410 if (getContext().getGenDwarfForAssembly())
2423 const auto &Tables = getContext().getMCDwarfLineTables();
2424 if (!Tables.empty()) {
2425 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2426 if (
auto *Label = Tables.begin()->second.getLabel()) {
2427 switchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
2445MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2446 const Twine &Comment) {
2454 return getContext().createTempSymbol(Prefix +
"_end");
2458void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2469 emitLabel(DebugLineSymTmp);
2473 unsigned LengthFieldSize =
2479 emitAssignment(StartSym, OuterSym);
2485void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2493 ".loc should not be generated together with raw data!");
2505 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, SectionEnd,
2510void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2513 unsigned PointerSize) {
2515 ".loc/.file don't need raw data in debug line section!");
2518 AddComment(
"Set address to " +
Label->getName());
2519 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2520 emitULEB128IntValue(PointerSize + 1);
2521 emitIntValue(dwarf::DW_LNE_set_address, 1);
2522 emitSymbolValue(Label, PointerSize);
2526 AddComment(
"Start sequence");
2534 AddComment(
"End sequence");
2535 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2536 emitULEB128IntValue(1);
2537 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2542 AddComment(
"Advance line " +
Twine(LineDelta));
2543 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2544 emitSLEB128IntValue(LineDelta);
2545 emitIntValue(dwarf::DW_LNS_copy, 1);
2548void MCAsmStreamer::doFinalizationAtSectionEnd(
MCSection *Section) {
2554 switchSectionNoChange(Section);
2556 MCSymbol *Sym = getCurrentSectionOnly()->getEndSymbol(getContext());
2563 std::unique_ptr<formatted_raw_ostream>
OS,
2564 bool isVerboseAsm,
bool useDwarfDirectory,
2566 std::unique_ptr<MCCodeEmitter> &&CE,
2567 std::unique_ptr<MCAsmBackend> &&MAB,
2569 return new MCAsmStreamer(
Context, std::move(
OS), isVerboseAsm,
2570 useDwarfDirectory, IP, std::move(CE), std::move(MAB),
unsigned const MachineRegisterInfo * MRI
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
#define LLVM_LIKELY(EXPR)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values)
static const char * getVersionMinDirective(MCVersionMinType Type)
static bool isPrintableString(StringRef Data)
static void PrintByteList(StringRef Data, raw_ostream &OS, MCAsmInfo::AsmCharLiteralSyntax ACLS)
static char toOctal(int X)
static void EmitSDKVersionSuffix(raw_ostream &OS, const VersionTuple &SDKVersion)
static int64_t truncateToSize(int64_t Value, unsigned Bytes)
static const char * getPlatformName(MachO::PlatformType Type)
#define DWARF2_FLAG_IS_STMT
#define DWARF2_FLAG_BASIC_BLOCK
#define DWARF2_FLAG_PROLOGUE_END
#define DWARF2_FLAG_EPILOGUE_BEGIN
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This class is intended to be used as a base class for asm properties and features specific to the tar...
const char * getPlainStringDirective() const
const char * getLabelSuffix() const
bool hasDotTypeDotSizeDirective() const
bool isLittleEndian() const
True if the target is little endian.
bool doesSupportDataRegionDirectives() const
const char * getTPRel64Directive() const
const char * getData32bitsDirective() const
bool hasFourStringsDotFile() const
unsigned getAssemblerDialect() const
unsigned getTextAlignFillValue() const
bool useDwarfRegNumForCFI() const
bool supportsExtendedDwarfLocDirective() const
const char * getData8bitsDirective() const
const char * getTPRel32Directive() const
const char * getData64bitsDirective() const
AsmCharLiteralSyntax characterLiteralSyntax() const
const char * getByteListDirective() const
const char * getCode16Directive() const
const char * getGPRel64Directive() const
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
StringRef getCommentString() const
const char * getAscizDirective() const
const char * getDTPRel64Directive() const
const char * getZeroDirective() const
const char * getWeakDirective() const
bool hasSubsectionsViaSymbols() const
const char * getData16bitsDirective() const
const char * getSeparatorString() const
bool getCOMMDirectiveAlignmentIsInBytes() const
bool hasPairedDoubleQuoteStringConstants() const
bool needsDwarfSectionSizeInHeader() const
const char * getGlobalDirective() const
const char * getCode32Directive() const
unsigned getCommentColumn() const
This indicates the column (zero-based) at which asm comments should be printed.
const char * getCode64Directive() const
bool hasSingleParameterDotFile() const
bool doesZeroDirectiveSupportNonZeroValue() const
const char * getAsciiDirective() const
AsmCharLiteralSyntax
Assembly character literal syntax types.
@ ACLS_SingleQuotePrefix
Unknown; character literals not used by LLVM for this target.
bool useDotAlignForAlignment() const
const char * getGPRel32Directive() const
const char * getWeakRefDirective() const
const char * getDTPRel32Directive() const
bool hasNoDeadStrip() const
bool usesDwarfFileAndLocDirectives() const
bool hasIdentDirective() const
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
const MCAsmInfo * getAsmInfo() const
dwarf::DwarfFormat getDwarfFormat() const
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
static void make(MCStreamer *MCOS, MCSection *Section)
static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Base class for the full range of assembler expressions which are needed for parsing.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
static void Emit(MCStreamer *MCOS)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCRegisterInfo *RegInfo=nullptr) const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
MCSection * getTextSection() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
This represents a section on a Mach-O system (used by Mac OS X).
StringRef getSegmentName() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCSymbol * getEndSymbol(MCContext &Ctx)
StringRef getName() const
Streaming machine code generation interface.
virtual void emitAddrsig()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
virtual void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel)
Emit the debug line end entry.
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 emitCFIDefCfaOffset(int64_t Offset)
virtual void emitCFIBKeyFrame()
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 StringRef getMnemonic(MCInst &MI)
Returns the mnemonic for MI, if the streamer has access to a instruction printer and returns an empty...
virtual void emitGNUAttribute(unsigned Tag, unsigned Value)
Emit a .gnu_attribute directive.
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
virtual void emitCFIGnuArgsSize(int64_t Size)
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.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace)
virtual void emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
virtual void emitCFIRegister(int64_t Register1, int64_t Register2)
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
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 emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
virtual void emitCVStringTableDirective()
This implements the CodeView '.cv_stringtable' assembler directive.
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
virtual void emitIntValueInHex(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
virtual 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 bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
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 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)=0
Emit a common symbol.
virtual MCAssembler * getAssemblerPtr()
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
virtual void emitCVFileChecksumOffsetDirective(unsigned FileNo)
This implements the CodeView '.cv_filechecksumoffset' assembler directive.
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)
virtual void emitCFIRememberState()
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 emitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc={})
This implements the CodeView '.cv_fpo_data' assembler directive.
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.
virtual void emitCFIOffset(int64_t Register, int64_t Offset)
virtual void doFinalizationAtSectionEnd(MCSection *Section)
Do finalization for the streamer at the end of a 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 std::optional< std::pair< bool, std::string > > emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc, const MCSubtargetInfo &STI)
Record a relocation described by the .reloc directive.
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
virtual void emitIdent(StringRef IdentString)
Emit the "identifiers" directive.
virtual void emitCFIWindowSave()
virtual void emitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
virtual void emitCFIRestoreState()
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
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.
void setAllowAutoPadding(bool v)
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitCFIRestore(int64_t Register)
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)
virtual void emitIntValueInHexWithPadding(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
virtual void 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.
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
If targets does not support representing debug line section by .loc/.file directives in assembly outp...
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
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 emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
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 changeSection(MCSection *, const MCExpr *)
Update streamer for a new active section.
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 emitCFIUndefined(int64_t Register)
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
virtual void emitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
virtual void emitCFIDefCfaRegister(int64_t Register)
virtual void emitULEB128Value(const MCExpr *Value)
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
virtual void emitExplicitComments()
Emit added explicit comments.
virtual void emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
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 emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFINegateRAState()
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment)
virtual void emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, Align ByteAlignment=Align(1), SMLoc Loc=SMLoc())=0
Emit the zerofill section and an optional symbol.
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 emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
virtual void emitCFISameValue(int64_t Register)
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 emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
virtual void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
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 emitCFIDefCfa(int64_t Register, int64_t Offset)
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 emitCFIRelOffset(int64_t Register, int64_t Offset)
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 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 emitCFIEscape(StringRef Values)
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
virtual void emitAddrsigSym(const MCSymbol *Sym)
virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
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.
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
StringRef getSymbolTableName() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
StringRef getName() const
getName - Get the symbol name.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Target specific streamer interface.
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...
void append(StringRef RHS)
Append from a StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
char back() const
back - Get the last character in the string.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
bool startswith(StringRef Prefix) const
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
A raw_ostream that discards all output.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
size_t GetNumBytesInBuffer() const
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
@ PLATFORM_WATCHOSSIMULATOR
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
@ Emitted
Assigned address, still materializing.
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static StringRef MCLOHDirectiveName()
@ MCDR_DataRegionEnd
.end_data_region
@ MCDR_DataRegion
.data_region
@ MCDR_DataRegionJT8
.data_region jt8
@ MCDR_DataRegionJT32
.data_region jt32
@ MCDR_DataRegionJT16
.data_region jt16
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
@ 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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static int MCLOHIdToNbArgs(MCLOHType Kind)
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
@ MCAF_Code64
.code64 (X86)
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
MCLOHType
Linker Optimization Hint Type.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target,...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
unsigned Log2(Align A)
Returns the log2 of the alignment.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
@ MCSA_Memtag
.memtag (ELF)
@ MCSA_Protected
.protected (ELF)
@ MCSA_Exported
.globl _foo, exported (XCOFF)
@ MCSA_PrivateExtern
.private_extern (MachO)
@ MCSA_Internal
.internal (ELF)
@ MCSA_WeakReference
.weak_reference (MachO)
@ MCSA_AltEntry
.alt_entry (MachO)
@ MCSA_ELF_TypeIndFunction
.type _foo, STT_GNU_IFUNC
@ MCSA_LazyReference
.lazy_reference (MachO)
@ MCSA_ELF_TypeNoType
.type _foo, STT_NOTYPE # aka @notype
@ MCSA_Reference
.reference (MachO)
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
@ MCSA_ELF_TypeTLS
.type _foo, STT_TLS # aka @tls_object
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
@ MCSA_WeakDefinition
.weak_definition (MachO)
@ MCSA_ELF_TypeCommon
.type _foo, STT_COMMON # aka @common
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_ELF_TypeGnuUniqueObject
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
@ MCSA_Hidden
.hidden (ELF)
@ MCSA_LGlobal
.lglobl (XCOFF)
@ MCSA_Invalid
Not a valid directive.
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
static StringRef MCLOHIdToName(MCLOHType Kind)
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
Target independent information on a fixup kind.
const MCSymbol * Function