45 std::unique_ptr<formatted_raw_ostream> OSOwner;
48 std::unique_ptr<MCInstPrinter> InstPrinter;
49 std::unique_ptr<MCAssembler> Assembler;
56 bool EmittedSectionDirective =
false;
58 bool IsVerboseAsm =
false;
59 bool ShowInst =
false;
60 bool UseDwarfDirectory =
false;
62 void EmitRegisterName(int64_t
Register);
64 void printDwarfFileDirective(
unsigned FileNo,
StringRef Directory,
66 std::optional<MD5::MD5Result> Checksum,
67 std::optional<StringRef> Source,
68 bool UseDwarfDirectory,
74 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
75 std::unique_ptr<MCInstPrinter>
printer,
76 std::unique_ptr<MCCodeEmitter> emitter,
77 std::unique_ptr<MCAsmBackend> asmbackend)
82 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
84 CommentStream(CommentToEmit) {
86 if (Assembler->getBackendPtr())
89 Context.setUseNamesOnTempLabels(
true);
91 auto *TO =
Context.getTargetOptions();
94 IsVerboseAsm = TO->AsmVerbose;
96 InstPrinter->setCommentStream(CommentStream);
97 ShowInst = TO->ShowMCInst;
98 switch (TO->MCUseDwarfDirectory) {
100 UseDwarfDirectory =
false;
103 UseDwarfDirectory =
true;
107 Context.getAsmInfo()->enableDwarfFileDirectoryDefault();
115 inline void EmitEOL() {
123 EmitCommentsAndEOL();
128 void EmitCommentsAndEOL();
131 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
150 return CommentStream;
168 bool KeepOriginalSym)
override;
175 auto [
Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
177 "Invalid char pointer for instruction with no mnemonic");
191 unsigned Minor,
unsigned Update,
224 unsigned Lang,
unsigned Reason,
225 unsigned FunctionSize,
bool hasDebug)
override;
230 Align ByteAlignment)
override;
238 Align ByteAlignment)
override;
267 void emitAlignmentDirective(
uint64_t ByteAlignment,
268 std::optional<int64_t>
Value,
unsigned ValueSize,
269 unsigned MaxBytesToEmit);
273 unsigned MaxBytesToEmit = 0)
override;
276 unsigned MaxBytesToEmit = 0)
override;
287 std::optional<MD5::MD5Result> Checksum = std::nullopt,
288 std::optional<StringRef> Source = std::nullopt,
289 unsigned CUID = 0)
override;
291 std::optional<MD5::MD5Result> Checksum,
292 std::optional<StringRef> Source,
293 unsigned CUID = 0)
override;
295 unsigned Flags,
unsigned Isa,
296 unsigned Discriminator,
StringRef FileName,
304 unsigned ChecksumKind)
override;
307 unsigned IAFile,
unsigned IALine,
308 unsigned IACol,
SMLoc Loc)
override;
310 unsigned Column,
bool PrologueEnd,
bool IsStmt,
315 unsigned SourceFileId,
316 unsigned SourceLineNum,
320 void PrintCVDefRangePrefix(
321 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
324 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
328 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
332 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
336 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
425 const Twine &Comment)
override;
430 MCSymbol *EndLabel =
nullptr)
override;
434 unsigned PointerSize)
override;
439void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
440 if (!IsVerboseAsm)
return;
442 T.toVector(CommentToEmit);
448void MCAsmStreamer::EmitCommentsAndEOL() {
457 "Comment array not newline terminated");
461 size_t Position = Comments.
find(
'\n');
464 Comments = Comments.
substr(Position+1);
465 }
while (!Comments.
empty());
467 CommentToEmit.
clear();
471 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
472 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
475void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
482void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
487 ExplicitCommentToEmit.
append(
"\t");
492 size_t p = 2, len = c.
size() - 2;
496 ExplicitCommentToEmit.
append(
"\t");
501 ExplicitCommentToEmit.
append(
"\n");
505 ExplicitCommentToEmit.
append(
"\t");
507 }
else if (c.
front() ==
'#') {
509 ExplicitCommentToEmit.
append(
"\t");
513 assert(
false &&
"Unexpected Assembly Comment");
515 if (c.
back() ==
'\n')
516 emitExplicitComments();
519void MCAsmStreamer::emitExplicitComments() {
520 StringRef Comments = ExplicitCommentToEmit;
521 if (!Comments.
empty())
523 ExplicitCommentToEmit.
clear();
528 if (!EmittedSectionDirective ||
530 EmittedSectionDirective =
true;
532 TS->changeSection(Cur.first, Section, Subsection,
OS);
535 getContext().getTargetTriple(),
OS);
541bool MCAsmStreamer::popSection() {
544 auto [Sec, Subsec] = getCurrentSection();
549void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
551 bool KeepOriginalSym) {
555 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
565 if (!
Symbol->isVariable() &&
580 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
581 assert(str !=
"" &&
"Invalid LOH name");
595void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
596 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
599void MCAsmStreamer::emitSubsectionsViaSymbols() {
600 OS <<
".subsections_via_symbols\n";
604 assert(!
Options.empty() &&
"At least one option is required!");
605 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
607 OS <<
", " <<
'"' << Opt <<
'"';
636 if (SDKVersion.
empty())
638 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
639 if (
auto Minor = SDKVersion.
getMinor()) {
640 OS <<
", " << *Minor;
642 OS <<
", " << *Subminor;
648 unsigned Minor,
unsigned Update,
652 OS <<
", " << Update;
659#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
661 case MachO::PLATFORM_##platform: \
663#include "llvm/BinaryFormat/MachO.def"
668void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
669 unsigned Minor,
unsigned Update,
672 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
674 OS <<
", " << Update;
679void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
680 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
682 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
690 OS << (UseSet ?
", " :
" = ");
697void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
699 OS <<
".lto_set_conditional ";
706void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
714bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
731 default:
return false;
754 OS <<
"\t.no_dead_strip\t";
759 OS <<
"\t.private_extern\t";
768 OS <<
"\t.weak_definition\t";
782 OS <<
"\t.weak_anti_dep\t";
792void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
793 OS <<
".desc" <<
' ';
795 OS <<
',' << DescValue;
799void MCAsmStreamer::emitSyntaxDirective() {
801 OS <<
"\t.intel_syntax noprefix";
809void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
816void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
821void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
822 OS <<
"\t.type\t" <<
Type <<
';';
826void MCAsmStreamer::endCOFFSymbolDef() {
831void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
832 OS <<
"\t.safeseh\t";
837void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
843void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
850 OS <<
"\t.secrel32\t";
857void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
867void MCAsmStreamer::emitCOFFSecNumber(
MCSymbol const *Symbol) {
873void MCAsmStreamer::emitCOFFSecOffset(
MCSymbol const *Symbol) {
874 OS <<
"\t.secoffset\t";
882void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
887 "We only support writing log base-2 alignment format with XCOFF.");
893 OS <<
',' <<
Log2(Alignment);
900 if (XSym->hasRename())
901 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
904void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
926 switch (Visibility) {
947 emitXCOFFRenameDirective(&
Sym,
Sym.getSymbolTableName());
950void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *
Name,
956 for (
char C : Rename) {
966void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
972void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
976 unsigned FunctionSize,
980 OS <<
", " << Lang <<
", " << Reason;
985 const char InfoDirective[] =
"\t.info ";
986 const char *Separator =
", ";
987 constexpr int WordSize =
sizeof(
uint32_t);
991 PrintQuotedString(
Name,
OS);
994 size_t MetadataSize =
Metadata.size();
1000 if (MetadataSize == 0) {
1011 uint32_t PaddingSize = PaddedSize - MetadataSize;
1018 constexpr int WordsPerDirective = 5;
1021 int WordsBeforeNextDirective = 0;
1022 auto PrintWord = [&](
const uint8_t *WordPtr) {
1023 if (WordsBeforeNextDirective-- == 0) {
1025 OS << InfoDirective;
1026 WordsBeforeNextDirective = WordsPerDirective;
1034 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1035 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1040 assert(PaddedSize - Index == WordSize);
1041 std::array<uint8_t, WordSize> LastWord = {0};
1042 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1043 PrintWord(LastWord.data());
1058 Align ByteAlignment) {
1066 OS <<
',' <<
Log2(ByteAlignment);
1071 if (getContext().isXCOFF()) {
1073 if (XSym && XSym->hasRename())
1074 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1084 if (ByteAlign > 1) {
1089 OS <<
',' << ByteAlign.
value();
1092 OS <<
',' <<
Log2(ByteAlign);
1109 ".zerofill is a Mach-O specific directive");
1119 OS <<
',' <<
Log2(ByteAlignment);
1134 ".zerofill is a Mach-O specific directive");
1143 if (ByteAlignment > 1)
1144 OS <<
", " <<
Log2(ByteAlignment);
1150 const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1151 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1155 return isPrint(Data.back()) || Data.back() == 0;
1162 assert(!Data.empty() &&
"Cannot generate an empty list.");
1163 const auto printCharacterInOctal = [&
OS](
unsigned char C) {
1169 const auto printOneCharacterFor = [printCharacterInOctal](
1170 auto printOnePrintingCharacter) {
1171 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1173 printOnePrintingCharacter(
static_cast<char>(
C));
1176 printCharacterInOctal(
C);
1179 const auto printCharacterList = [Data, &
OS](
const auto &printOneCharacter) {
1180 const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1181 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1182 printOneCharacter(
C);
1185 printOneCharacter(*(EndPtr - 1));
1189 printCharacterList(printCharacterInOctal);
1192 printCharacterList(printOneCharacterFor([&
OS](
char C) {
1193 const char AsmCharLitBuf[2] = {
'\'',
C};
1194 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1205 for (
unsigned char C : Data) {
1212 for (
unsigned char C : Data) {
1213 if (
C ==
'"' ||
C ==
'\\') {
1252void MCAsmStreamer::emitBytes(
StringRef Data) {
1253 assert(getCurrentSectionOnly() &&
1254 "Cannot emit contents before setting section!");
1255 if (Data.empty())
return;
1257 const auto emitAsString = [
this](
StringRef Data) {
1262 if (Data.back() == 0) {
1263 OS <<
"\t.string\t";
1264 Data = Data.substr(0, Data.size() - 1);
1268 PrintQuotedString(Data,
OS);
1281 Data = Data.substr(0, Data.size() - 1);
1288 PrintQuotedString(Data,
OS);
1293 if (Data.size() != 1 && emitAsString(Data))
1299 TS->emitRawBytes(Data);
1303 for (
const unsigned char C : Data.bytes()) {
1309void MCAsmStreamer::emitBinaryData(
StringRef Data) {
1311 const size_t Cols = 4;
1312 for (
size_t I = 0, EI =
alignTo(Data.size(), Cols);
I < EI;
I += Cols) {
1313 size_t J =
I, EJ = std::min(
I + Cols, Data.size());
1316 for (; J < EJ - 1; ++J)
1331void MCAsmStreamer::emitIntValueInHexWithPadding(
uint64_t Value,
1339 assert(getCurrentSectionOnly() &&
1340 "Cannot emit contents before setting section!");
1352 if (!
Value->evaluateAsAbsolute(IntValue))
1367 unsigned ByteOffset =
1368 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1369 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1373 uint64_t Shift = 64 - EmissionSize * 8;
1375 std::numeric_limits<unsigned long long>::digits) &&
1376 "undefined behavior");
1377 ValueToEmit &= ~0ULL >> Shift;
1378 emitIntValue(ValueToEmit, EmissionSize);
1387 TS->emitValue(
Value);
1394void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1396 if (
Value->evaluateAsAbsolute(IntValue)) {
1397 emitULEB128IntValue(IntValue);
1400 OS <<
"\t.uleb128 ";
1405void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1407 if (
Value->evaluateAsAbsolute(IntValue)) {
1408 emitSLEB128IntValue(IntValue);
1411 OS <<
"\t.sleb128 ";
1416void MCAsmStreamer::emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
1418 int64_t IntNumBytes;
1419 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1420 if (IsAbsolute && IntNumBytes == 0)
1424 if (!MAI->
isAIX() || FillValue == 0) {
1426 OS << ZeroDirective;
1429 OS <<
',' << (int)FillValue;
1434 "Cannot emit non-absolute expression lengths of fill.");
1435 for (
int i = 0; i < IntNumBytes; ++i) {
1446void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1447 int64_t Expr,
SMLoc Loc) {
1451 OS <<
", " <<
Size <<
", 0x";
1456void MCAsmStreamer::emitAlignmentDirective(
uint64_t ByteAlignment,
1457 std::optional<int64_t>
Value,
1459 unsigned MaxBytesToEmit) {
1473 switch (ValueSize) {
1477 OS <<
"\t.p2align\t";
1491 if (
Value.has_value() || MaxBytesToEmit) {
1492 if (
Value.has_value()) {
1500 OS <<
", " << MaxBytesToEmit;
1508 switch (ValueSize) {
1510 case 1:
OS <<
".balign";
break;
1511 case 2:
OS <<
".balignw";
break;
1512 case 4:
OS <<
".balignl";
break;
1517 if (
Value.has_value())
1519 else if (MaxBytesToEmit)
1522 OS <<
", " << MaxBytesToEmit;
1526void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t Fill,
1528 unsigned MaxBytesToEmit) {
1529 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1532void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1534 unsigned MaxBytesToEmit) {
1540 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1543void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1544 unsigned char Value,
1553void MCAsmStreamer::emitFileDirective(
StringRef Filename) {
1556 PrintQuotedString(Filename,
OS);
1560void MCAsmStreamer::emitFileDirective(
StringRef Filename,
1566 PrintQuotedString(Filename,
OS);
1567 bool useTimeStamp = !TimeStamp.
empty();
1568 bool useCompilerVersion = !CompilerVersion.
empty();
1569 bool useDescription = !Description.
empty();
1570 if (useTimeStamp || useCompilerVersion || useDescription) {
1573 PrintQuotedString(TimeStamp,
OS);
1574 if (useCompilerVersion || useDescription) {
1576 if (useCompilerVersion)
1577 PrintQuotedString(CompilerVersion,
OS);
1578 if (useDescription) {
1580 PrintQuotedString(Description,
OS);
1587void MCAsmStreamer::printDwarfFileDirective(
1589 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1593 if (!UseDwarfDirectory && !Directory.
empty()) {
1597 FullPathName = Directory;
1604 OS <<
"\t.file\t" << FileNo <<
' ';
1605 if (!Directory.
empty()) {
1606 PrintQuotedString(Directory,
OS);
1609 PrintQuotedString(Filename,
OS);
1611 OS <<
" md5 0x" << Checksum->digest();
1614 PrintQuotedString(*Source,
OS);
1620 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1622 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1627 Table.
tryGetFile(Directory, Filename, Checksum, Source,
1631 FileNo = FileNoOrErr.
get();
1640 printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
1641 UseDwarfDirectory, OS1);
1644 TS->emitDwarfFileDirective(OS1.str());
1646 emitRawText(OS1.str());
1651void MCAsmStreamer::emitDwarfFile0Directive(
1653 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1660 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1669 printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
1670 UseDwarfDirectory, OS1);
1673 TS->emitDwarfFileDirective(OS1.str());
1675 emitRawText(OS1.str());
1678void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1679 unsigned Column,
unsigned Flags,
1680 unsigned Isa,
unsigned Discriminator,
1690 Discriminator, FileName, Comment);
1694 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1697 OS <<
" basic_block";
1699 OS <<
" prologue_end";
1701 OS <<
" epilogue_begin";
1703 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1714 OS <<
" isa " << Isa;
1723 OS << FileName <<
':' <<
Line <<
':' << Column;
1729 Discriminator, FileName, Comment);
1734 OS <<
".loc_label\t" <<
Name;
1738MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1744bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo,
StringRef Filename,
1746 unsigned ChecksumKind) {
1747 if (!getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1751 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1752 PrintQuotedString(Filename,
OS);
1754 if (!ChecksumKind) {
1760 PrintQuotedString(toHex(Checksum),
OS);
1767bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1768 OS <<
"\t.cv_func_id " <<
FuncId <<
'\n';
1772bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1775 unsigned IALine,
unsigned IACol,
1777 OS <<
"\t.cv_inline_site_id " <<
FunctionId <<
" within " << IAFunc
1778 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1780 IALine, IACol, Loc);
1783void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1784 unsigned Line,
unsigned Column,
1785 bool PrologueEnd,
bool IsStmt,
1788 if (!checkCVLocSection(
FunctionId, FileNo, Loc))
1794 OS <<
" prologue_end";
1807void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1818void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1819 unsigned SourceFileId,
1820 unsigned SourceLineNum,
1823 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1824 <<
' ' << SourceLineNum <<
' ';
1830 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1833void MCAsmStreamer::PrintCVDefRangePrefix(
1834 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1835 OS <<
"\t.cv_def_range\t";
1836 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1844void MCAsmStreamer::emitCVDefRangeDirective(
1845 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1847 PrintCVDefRangePrefix(Ranges);
1848 OS <<
", reg_rel, ";
1854void MCAsmStreamer::emitCVDefRangeDirective(
1855 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1857 PrintCVDefRangePrefix(Ranges);
1858 OS <<
", subfield_reg, ";
1863void MCAsmStreamer::emitCVDefRangeDirective(
1864 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1866 PrintCVDefRangePrefix(Ranges);
1872void MCAsmStreamer::emitCVDefRangeDirective(
1873 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1875 PrintCVDefRangePrefix(Ranges);
1876 OS <<
", frame_ptr_rel, ";
1881void MCAsmStreamer::emitCVStringTableDirective() {
1882 OS <<
"\t.cv_stringtable";
1886void MCAsmStreamer::emitCVFileChecksumsDirective() {
1887 OS <<
"\t.cv_filechecksums";
1891void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1892 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1896void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
1897 OS <<
"\t.cv_fpo_data\t";
1902void MCAsmStreamer::emitIdent(
StringRef IdentString) {
1905 PrintQuotedString(IdentString,
OS);
1909void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
1911 OS <<
"\t.cfi_sections ";
1920 OS <<
".debug_frame";
1933 OS <<
"\t.cfi_startproc";
1941 OS <<
"\t.cfi_endproc";
1945void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
1951 if (std::optional<MCRegister> LLVMRegister =
1953 InstPrinter->printRegName(
OS, *LLVMRegister);
1962 OS <<
"\t.cfi_def_cfa ";
1968void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset,
SMLoc Loc) {
1970 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
1974void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
1977 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
1985 OS <<
"\t.cfi_escape ";
1986 if (!Values.
empty()) {
1987 size_t e = Values.
size() - 1;
1988 for (
size_t i = 0; i < e; ++i)
2000void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size,
SMLoc Loc) {
2003 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2010void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register,
SMLoc Loc) {
2012 OS <<
"\t.cfi_def_cfa_register ";
2019 OS <<
"\t.cfi_offset ";
2025void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *
Sym,
2026 unsigned Encoding) {
2028 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2029 Sym->print(
OS, MAI);
2033void MCAsmStreamer::emitCFILsda(
const MCSymbol *
Sym,
unsigned Encoding) {
2035 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2036 Sym->print(
OS, MAI);
2040void MCAsmStreamer::emitCFIRememberState(
SMLoc Loc) {
2042 OS <<
"\t.cfi_remember_state";
2046void MCAsmStreamer::emitCFIRestoreState(
SMLoc Loc) {
2048 OS <<
"\t.cfi_restore_state";
2052void MCAsmStreamer::emitCFIRestore(int64_t
Register,
SMLoc Loc) {
2054 OS <<
"\t.cfi_restore ";
2059void MCAsmStreamer::emitCFISameValue(int64_t
Register,
SMLoc Loc) {
2061 OS <<
"\t.cfi_same_value ";
2066void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2069 OS <<
"\t.cfi_rel_offset ";
2075void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment,
SMLoc Loc) {
2077 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2081void MCAsmStreamer::emitCFISignalFrame() {
2083 OS <<
"\t.cfi_signal_frame";
2087void MCAsmStreamer::emitCFIUndefined(int64_t
Register,
SMLoc Loc) {
2089 OS <<
"\t.cfi_undefined ";
2094void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2097 OS <<
"\t.cfi_register ";
2098 EmitRegisterName(Register1);
2100 EmitRegisterName(Register2);
2104void MCAsmStreamer::emitCFIWindowSave(
SMLoc Loc) {
2106 OS <<
"\t.cfi_window_save";
2110void MCAsmStreamer::emitCFINegateRAState(
SMLoc Loc) {
2112 OS <<
"\t.cfi_negate_ra_state";
2116void MCAsmStreamer::emitCFINegateRAStateWithPC(
SMLoc Loc) {
2118 OS <<
"\t.cfi_negate_ra_state_with_pc";
2122void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2124 OS <<
"\t.cfi_return_column ";
2131 OS <<
"\t.cfi_label " <<
Name;
2135void MCAsmStreamer::emitCFIBKeyFrame() {
2137 OS <<
"\t.cfi_b_key_frame";
2141void MCAsmStreamer::emitCFIMTETaggedFrame() {
2143 OS <<
"\t.cfi_mte_tagged_frame";
2147void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2150 OS <<
"\t.cfi_val_offset ";
2156void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2164void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2167 OS <<
"\t.seh_endproc";
2171void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2174 OS <<
"\t.seh_endfunclet";
2178void MCAsmStreamer::emitWinCFIStartChained(
SMLoc Loc) {
2181 OS <<
"\t.seh_startchained";
2185void MCAsmStreamer::emitWinCFIEndChained(
SMLoc Loc) {
2188 OS <<
"\t.seh_endchained";
2192void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *
Sym,
bool Unwind,
2193 bool Except,
SMLoc Loc) {
2196 OS <<
"\t.seh_handler ";
2197 Sym->print(
OS, MAI);
2199 const Triple &
T = getContext().getTargetTriple();
2203 OS <<
", " << Marker <<
"unwind";
2205 OS <<
", " << Marker <<
"except";
2209void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2224 MCSection *XData = getAssociatedXDataSection(TextSec);
2225 switchSectionNoPrint(XData);
2227 OS <<
"\t.seh_handlerdata";
2234 OS <<
"\t.seh_pushreg ";
2243 OS <<
"\t.seh_setframe ";
2249void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2252 OS <<
"\t.seh_stackalloc " <<
Size;
2260 OS <<
"\t.seh_savereg ";
2270 OS <<
"\t.seh_savexmm ";
2276void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2279 OS <<
"\t.seh_pushframe";
2285void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2288 OS <<
"\t.seh_endprologue";
2292void MCAsmStreamer::emitWinCFIBeginEpilogue(
SMLoc Loc) {
2295 OS <<
"\t.seh_startepilogue";
2299void MCAsmStreamer::emitWinCFIEndEpilogue(
SMLoc Loc) {
2302 OS <<
"\t.seh_endepilogue";
2306void MCAsmStreamer::emitWinCFIUnwindV2Start(
SMLoc Loc) {
2309 OS <<
"\t.seh_unwindv2start";
2313void MCAsmStreamer::emitWinCFIUnwindVersion(
uint8_t Version,
SMLoc Loc) {
2316 OS <<
"\t.seh_unwindversion " << (
unsigned)Version;
2323 OS <<
"\t.cg_profile ";
2324 From->getSymbol().print(
OS, MAI);
2327 OS <<
", " << Count;
2331void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2338 if (!getAssembler().getEmitterPtr())
2341 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2344 bool ForceLE = getContext().getTargetTriple().isRISCV();
2351 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2354 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2357 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2358 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2359 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2360 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2361 FixupMap[
Index] = 1 + i;
2367 OS <<
"encoding: [";
2368 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2373 uint8_t MapEntry = FixupMap[i * 8 + 0];
2374 for (
unsigned j = 1;
j != 8; ++
j) {
2375 if (FixupMap[i * 8 + j] == MapEntry)
2382 if (MapEntry !=
uint8_t(~0U)) {
2383 if (MapEntry == 0) {
2389 <<
char(
'A' + MapEntry - 1) <<
'\'';
2391 OS <<
char(
'A' + MapEntry - 1);
2396 for (
unsigned j = 8;
j--;) {
2404 FixupBit = i * 8 + j;
2406 FixupBit = i * 8 + (7-
j);
2408 if (
uint8_t MapEntry = FixupMap[FixupBit]) {
2409 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2410 OS <<
char(
'A' + MapEntry - 1);
2418 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2420 OS <<
" fixup " <<
char(
'A' + i) <<
" - "
2421 <<
"offset: " <<
F.getOffset() <<
", value: ";
2423 auto Kind =
F.getKind();
2425 OS <<
", relocation type: " <<
Kind;
2428 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2430 OS <<
"FK_PCRel_" << (
Info.TargetSize / 8);
2438void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2441 MCSection *Sec = getCurrentSectionOnly();
2445 if (MAI->
isAIX() && CurFrag)
2451 AddEncodingComment(Inst, STI);
2455 Inst.
dump_pretty(getCommentOS(), InstPrinter.get(),
"\n ");
2456 getCommentOS() <<
"\n";
2459 if(getTargetStreamer())
2460 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI,
OS);
2462 InstPrinter->printInst(&Inst, 0,
"", STI,
OS);
2465 if (Comments.
size() && Comments.
back() !=
'\n')
2466 getCommentOS() <<
"\n";
2476 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2481 for (
const auto &Site : InlineStack)
2482 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2502void MCAsmStreamer::emitAddrsig() {
2507void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *
Sym) {
2508 OS <<
"\t.addrsig_sym ";
2509 Sym->print(
OS, MAI);
2517 String.consume_back(
"\n");
2522void MCAsmStreamer::finishImpl() {
2524 if (getContext().getGenDwarfForAssembly())
2537 const auto &Tables = getContext().getMCDwarfLineTables();
2538 if (!Tables.empty()) {
2539 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2540 if (
auto *Label = Tables.begin()->second.getLabel()) {
2541 switchSection(getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2559MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2560 const Twine &Comment) {
2568 return getContext().createTempSymbol(Prefix +
"_end");
2572void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2583 emitLabel(DebugLineSymTmp);
2587 unsigned LengthFieldSize =
2593 emitAssignment(StartSym, OuterSym);
2599void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2608 ".loc should not be generated together with raw data!");
2621 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2626void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2629 unsigned PointerSize) {
2631 ".loc/.file don't need raw data in debug line section!");
2634 AddComment(
"Set address to " +
Label->getName());
2635 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2636 emitULEB128IntValue(PointerSize + 1);
2637 emitIntValue(dwarf::DW_LNE_set_address, 1);
2638 emitSymbolValue(Label, PointerSize);
2642 AddComment(
"Start sequence");
2650 AddComment(
"End sequence");
2651 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2652 emitULEB128IntValue(1);
2653 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2658 AddComment(
"Advance line " +
Twine(LineDelta));
2659 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2660 emitSLEB128IntValue(LineDelta);
2661 emitIntValue(dwarf::DW_LNS_copy, 1);
2665 std::unique_ptr<formatted_raw_ostream>
OS,
2666 std::unique_ptr<MCInstPrinter> IP,
2667 std::unique_ptr<MCCodeEmitter> CE,
2668 std::unique_ptr<MCAsmBackend> MAB) {
2669 return new MCAsmStreamer(
Context, std::move(
OS), std::move(IP), std::move(CE),
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
BlockVerifier::State From
Analysis containing CSE Info
#define LLVM_LIKELY(EXPR)
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
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
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI void print(raw_ostream &OS) const
Print out the bounds to a stream.
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 * getLabelSuffix() const
bool hasDotTypeDotSizeDirective() const
bool isLittleEndian() const
True if the target is little endian.
bool doesSupportDataRegionDirectives() const
bool usesSetToEquateSymbol() const
const char * getData32bitsDirective() const
unsigned getAssemblerDialect() const
unsigned getTextAlignFillValue() const
bool useDwarfRegNumForCFI() const
bool supportsExtendedDwarfLocDirective() const
const char * getData8bitsDirective() const
const char * getData64bitsDirective() const
AsmCharLiteralSyntax characterLiteralSyntax() const
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
void printExpr(raw_ostream &, const MCExpr &) const
virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, const Triple &, raw_ostream &) const
StringRef getCommentString() const
const char * getAscizDirective() const
const char * getZeroDirective() const
const char * getWeakDirective() const
const char * getData16bitsDirective() const
const char * getSeparatorString() const
bool getCOMMDirectiveAlignmentIsInBytes() const
const char * getGlobalDirective() const
unsigned getCommentColumn() const
bool hasSingleParameterDotFile() const
const char * getAsciiDirective() const
AsmCharLiteralSyntax
Assembly character literal syntax types.
@ ACLS_SingleQuotePrefix
Unknown; character literals not used by LLVM for this target.
const char * getWeakRefDirective() const
bool hasNoDeadStrip() 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 LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
const MCAsmInfo * getAsmInfo() const
dwarf::DwarfFormat getDwarfFormat() const
static LLVM_ABI void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
static LLVM_ABI void make(MCStreamer *MCOS, MCSection *Section)
static LLVM_ABI void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
LLVM_ABI 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.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
static LLVM_ABI void Emit(MCStreamer *MCOS)
Instances of this class represent a single low-level machine instruction.
LLVM_ABI void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCContext *Ctx=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)
void setHasInstructions(bool Value)
StringRef getName() const
Streaming machine code generation interface.
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
virtual void emitAddrsig()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
virtual void emitWinCFIUnwindVersion(uint8_t Version, SMLoc Loc=SMLoc())
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
virtual void finishImpl()
Streamer specific finalization.
virtual void emitCFIBKeyFrame()
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 bool popSection()
Restore the current and previous section from the section stack.
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 emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, Align ByteAlignment=Align(1), SMLoc Loc=SMLoc())
Emit the zerofill section and an optional symbol.
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
virtual void emitCFISections(bool EH, bool Debug, bool SFrame)
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual bool 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 emitCFIWindowSave(SMLoc Loc={})
virtual void emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc={})
Record a relocation described by the .reloc directive.
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 emitWinCFIUnwindV2Start(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
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 emitCFIUndefined(int64_t Register, SMLoc Loc={})
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 emitCOFFSecNumber(MCSymbol const *Symbol)
Emits the physical number of the section containing the given symbol as assigned during object writin...
virtual void emitCFINegateRAState(SMLoc Loc={})
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
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 emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, MCSymbol *CsectSym, Align Alignment)
Emits an lcomm directive with XCOFF csect information.
virtual void emitCFIMTETaggedFrame()
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
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())
virtual void emitIdent(StringRef IdentString)
Emit the "identifiers" directive.
virtual StringRef getMnemonic(const MCInst &MI) const
Returns the mnemonic for MI, if the streamer has access to a instruction printer and returns an empty...
virtual void emitCVFileChecksumsDirective()
This implements the CodeView '.cv_filechecksums' assembler directive.
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
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 emitCFIRememberState(SMLoc Loc)
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName, StringRef Comment={})
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitCOFFSecOffset(MCSymbol const *Symbol)
Emits the offset of the symbol from the beginning of the section during object writing (i....
virtual void emitIntValueInHexWithPadding(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers & p...
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
virtual 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 emitSubsectionsViaSymbols()
Emit a .subsection_via_symbols directive.
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 emitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
virtual void emitULEB128Value(const MCExpr *Value)
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
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 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.
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 emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata)
Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
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 emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel, MCSymbol *EndLabel=nullptr)
Emit the debug line end entry.
virtual void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args)
Emit a Linker Optimization Hint (LOH) directive.
virtual 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 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.
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.
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.
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
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).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
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.
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.
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.
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.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
support::ulittle32_t Word
bool isRelocation(MCFixupKind FixupKind)
LLVM_ABI int getDwarfVersion()
@ Emitted
Assigned address, still materializing.
NodeAddr< CodeNode * > Code
uint32_t read32be(const void *P)
LLVM_ABI bool isPrint(int c)
LLVM_ABI bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
LLVM_ABI 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()
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > InstPrint, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB)
Create a machine code streamer which will print out assembly for the native target,...
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
@ MCDR_DataRegionEnd
.end_data_region
@ MCDR_DataRegion
.data_region
@ MCDR_DataRegionJT8
.data_region jt8
@ MCDR_DataRegionJT32
.data_region jt32
@ MCDR_DataRegionJT16
.data_region jt16
std::pair< MCSection *, uint32_t > MCSectionSubPair
@ MCVM_WatchOSVersionMin
.watchos_version_min
@ MCVM_OSXVersionMin
.macosx_version_min
@ MCVM_TvOSVersionMin
.tvos_version_min
@ MCVM_IOSVersionMin
.ios_version_min
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static int MCLOHIdToNbArgs(MCLOHType Kind)
MCLOHType
Linker Optimization Hint Type.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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_WeakAntiDep
.weak_anti_dep (COFF)
@ 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)
Implement std::hash so that hash_code can be used in STL containers.
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