47 std::unique_ptr<formatted_raw_ostream> OSOwner;
50 std::unique_ptr<MCInstPrinter> InstPrinter;
51 std::unique_ptr<MCAssembler> Assembler;
58 bool EmittedSectionDirective =
false;
60 bool IsVerboseAsm =
false;
61 bool ShowInst =
false;
62 bool UseDwarfDirectory =
false;
64 void EmitRegisterName(int64_t
Register);
66 void printDwarfFileDirective(
unsigned FileNo,
StringRef Directory,
68 std::optional<MD5::MD5Result> Checksum,
69 std::optional<StringRef> Source,
70 bool UseDwarfDirectory,
76 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
78 std::unique_ptr<MCAsmBackend> asmbackend)
80 MAI(Context.getAsmInfo()), InstPrinter(
printer),
83 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
85 CommentStream(CommentToEmit) {
87 if (Assembler->getBackendPtr())
95 IsVerboseAsm = TO->AsmVerbose;
97 InstPrinter->setCommentStream(CommentStream);
98 ShowInst = TO->ShowMCInst;
99 switch (TO->MCUseDwarfDirectory) {
101 UseDwarfDirectory =
false;
104 UseDwarfDirectory =
true;
116 inline void EmitEOL() {
124 EmitCommentsAndEOL();
129 void EmitCommentsAndEOL();
132 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
151 return CommentStream;
169 bool KeepOriginalSym)
override;
176 auto [
Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
178 "Invalid char pointer for instruction with no mnemonic");
192 unsigned Minor,
unsigned Update,
226 unsigned Lang,
unsigned Reason,
227 unsigned FunctionSize,
bool hasDebug)
override;
232 Align ByteAlignment)
override;
240 Align ByteAlignment)
override;
278 void emitAlignmentDirective(
uint64_t ByteAlignment,
279 std::optional<int64_t>
Value,
unsigned ValueSize,
280 unsigned MaxBytesToEmit);
283 unsigned ValueSize = 1,
284 unsigned MaxBytesToEmit = 0)
override;
287 unsigned MaxBytesToEmit = 0)
override;
298 std::optional<MD5::MD5Result> Checksum = std::nullopt,
299 std::optional<StringRef> Source = std::nullopt,
300 unsigned CUID = 0)
override;
302 std::optional<MD5::MD5Result> Checksum,
303 std::optional<StringRef> Source,
304 unsigned CUID = 0)
override;
306 unsigned Flags,
unsigned Isa,
307 unsigned Discriminator,
315 unsigned ChecksumKind)
override;
318 unsigned IAFile,
unsigned IALine,
319 unsigned IACol,
SMLoc Loc)
override;
321 unsigned Column,
bool PrologueEnd,
bool IsStmt,
326 unsigned SourceFileId,
327 unsigned SourceLineNum,
331 void PrintCVDefRangePrefix(
332 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
335 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
339 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
343 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
347 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
420 std::optional<std::pair<bool, std::string>>
437 const Twine &Comment)
override;
442 MCSymbol *EndLabel =
nullptr)
override;
446 unsigned PointerSize)
override;
451void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
452 if (!IsVerboseAsm)
return;
454 T.toVector(CommentToEmit);
460void MCAsmStreamer::EmitCommentsAndEOL() {
469 "Comment array not newline terminated");
473 size_t Position = Comments.
find(
'\n');
476 Comments = Comments.
substr(Position+1);
477 }
while (!Comments.
empty());
479 CommentToEmit.
clear();
483 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
484 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
487void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
494void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
499 ExplicitCommentToEmit.
append(
"\t");
504 size_t p = 2, len = c.
size() - 2;
508 ExplicitCommentToEmit.
append(
"\t");
513 ExplicitCommentToEmit.
append(
"\n");
517 ExplicitCommentToEmit.
append(
"\t");
519 }
else if (c.
front() ==
'#') {
521 ExplicitCommentToEmit.
append(
"\t");
525 assert(
false &&
"Unexpected Assembly Comment");
527 if (c.
back() ==
'\n')
528 emitExplicitComments();
531void MCAsmStreamer::emitExplicitComments() {
532 StringRef Comments = ExplicitCommentToEmit;
533 if (!Comments.
empty())
535 ExplicitCommentToEmit.
clear();
540 if (!EmittedSectionDirective ||
542 EmittedSectionDirective =
true;
544 TS->changeSection(Cur.first, Section, Subsection,
OS);
546 Section->printSwitchToSection(*MAI, getContext().getTargetTriple(),
OS,
553bool MCAsmStreamer::popSection() {
556 auto [Sec, Subsec] = getCurrentSection();
557 Sec->printSwitchToSection(*MAI, getContext().getTargetTriple(),
OS, Subsec);
561void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
563 bool KeepOriginalSym) {
567 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
586 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
587 assert(str !=
"" &&
"Invalid LOH name");
601void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
602 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
617 assert(!
Options.empty() &&
"At least one option is required!");
618 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
620 OS <<
", " <<
'"' << Opt <<
'"';
649 if (SDKVersion.
empty())
651 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
652 if (
auto Minor = SDKVersion.
getMinor()) {
653 OS <<
", " << *Minor;
655 OS <<
", " << *Subminor;
661 unsigned Minor,
unsigned Update,
665 OS <<
", " << Update;
672#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
674 case MachO::PLATFORM_##platform: \
676#include "llvm/BinaryFormat/MachO.def"
681void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
682 unsigned Minor,
unsigned Update,
685 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
687 OS <<
", " << Update;
692void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
693 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
695 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
698void MCAsmStreamer::emitThumbFunc(
MCSymbol *Func) {
701 OS <<
"\t.thumb_func";
713 if (
auto *E = dyn_cast<MCTargetExpr>(
Value))
714 if (E->inlineAssignedExpr())
728void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
730 OS <<
".lto_set_conditional ";
737void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
745bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
762 default:
return false;
785 OS <<
"\t.no_dead_strip\t";
790 OS <<
"\t.private_extern\t";
799 OS <<
"\t.weak_definition\t";
813 OS <<
"\t.weak_anti_dep\t";
823void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
824 OS <<
".desc" <<
' ';
826 OS <<
',' << DescValue;
830void MCAsmStreamer::emitSyntaxDirective() {
832 OS <<
"\t.intel_syntax noprefix";
840void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
847void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
852void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
853 OS <<
"\t.type\t" <<
Type <<
';';
857void MCAsmStreamer::endCOFFSymbolDef() {
862void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
863 OS <<
"\t.safeseh\t";
868void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
874void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
881 OS <<
"\t.secrel32\t";
888void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
898void MCAsmStreamer::emitCOFFSecNumber(
MCSymbol const *Symbol) {
904void MCAsmStreamer::emitCOFFSecOffset(
MCSymbol const *Symbol) {
905 OS <<
"\t.secoffset\t";
913void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
918 "We only support writing log base-2 alignment format with XCOFF.");
924 OS <<
',' <<
Log2(Alignment);
935void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
957 switch (Visibility) {
977 if (cast<MCSymbolXCOFF>(Symbol)->hasRename())
978 emitXCOFFRenameDirective(Symbol,
979 cast<MCSymbolXCOFF>(Symbol)->getSymbolTableName());
982void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *
Name,
988 for (
char C : Rename) {
998void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
1004void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
1008 unsigned FunctionSize,
1010 OS <<
"\t.except\t";
1012 OS <<
", " << Lang <<
", " << Reason;
1017 const char InfoDirective[] =
"\t.info ";
1018 const char *Separator =
", ";
1019 constexpr int WordSize =
sizeof(
uint32_t);
1022 OS << InfoDirective;
1023 PrintQuotedString(
Name,
OS);
1026 size_t MetadataSize =
Metadata.size();
1032 if (MetadataSize == 0) {
1043 uint32_t PaddingSize = PaddedSize - MetadataSize;
1050 constexpr int WordsPerDirective = 5;
1053 int WordsBeforeNextDirective = 0;
1054 auto PrintWord = [&](
const uint8_t *WordPtr) {
1055 if (WordsBeforeNextDirective-- == 0) {
1057 OS << InfoDirective;
1058 WordsBeforeNextDirective = WordsPerDirective;
1066 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1067 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1072 assert(PaddedSize - Index == WordSize);
1073 std::array<uint8_t, WordSize> LastWord = {0};
1074 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1075 PrintWord(LastWord.data());
1090 Align ByteAlignment) {
1098 OS <<
',' <<
Log2(ByteAlignment);
1114 if (ByteAlign > 1) {
1119 OS <<
',' << ByteAlign.
value();
1122 OS <<
',' <<
Log2(ByteAlign);
1139 ".zerofill is a Mach-O specific directive");
1149 OS <<
',' <<
Log2(ByteAlignment);
1164 ".zerofill is a Mach-O specific directive");
1173 if (ByteAlignment > 1)
1174 OS <<
", " <<
Log2(ByteAlignment);
1180 const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1181 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1185 return isPrint(Data.back()) || Data.back() == 0;
1192 assert(!Data.empty() &&
"Cannot generate an empty list.");
1193 const auto printCharacterInOctal = [&
OS](
unsigned char C) {
1199 const auto printOneCharacterFor = [printCharacterInOctal](
1200 auto printOnePrintingCharacter) {
1201 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1203 printOnePrintingCharacter(
static_cast<char>(
C));
1206 printCharacterInOctal(
C);
1209 const auto printCharacterList = [Data, &
OS](
const auto &printOneCharacter) {
1210 const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1211 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1212 printOneCharacter(
C);
1215 printOneCharacter(*(EndPtr - 1));
1219 printCharacterList(printCharacterInOctal);
1222 printCharacterList(printOneCharacterFor([&
OS](
char C) {
1223 const char AsmCharLitBuf[2] = {
'\'',
C};
1224 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1235 for (
unsigned char C : Data) {
1242 for (
unsigned char C : Data) {
1243 if (
C ==
'"' ||
C ==
'\\') {
1282void MCAsmStreamer::emitBytes(
StringRef Data) {
1283 assert(getCurrentSectionOnly() &&
1284 "Cannot emit contents before setting section!");
1285 if (Data.empty())
return;
1287 const auto emitAsString = [
this](
StringRef Data) {
1292 if (Data.back() == 0) {
1293 OS <<
"\t.string\t";
1294 Data = Data.substr(0, Data.size() - 1);
1298 PrintQuotedString(Data,
OS);
1311 Data = Data.substr(0, Data.size() - 1);
1318 PrintQuotedString(Data,
OS);
1323 if (Data.size() != 1 && emitAsString(Data))
1329 TS->emitRawBytes(Data);
1333 for (
const unsigned char C : Data.bytes()) {
1339void MCAsmStreamer::emitBinaryData(
StringRef Data) {
1341 const size_t Cols = 4;
1342 for (
size_t I = 0, EI =
alignTo(Data.size(), Cols);
I < EI;
I += Cols) {
1343 size_t J =
I, EJ = std::min(
I + Cols, Data.size());
1346 for (; J < EJ - 1; ++J)
1361void MCAsmStreamer::emitIntValueInHexWithPadding(
uint64_t Value,
1369 assert(getCurrentSectionOnly() &&
1370 "Cannot emit contents before setting section!");
1382 if (!
Value->evaluateAsAbsolute(IntValue))
1397 unsigned ByteOffset =
1398 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1399 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1403 uint64_t Shift = 64 - EmissionSize * 8;
1405 std::numeric_limits<unsigned long long>::digits) &&
1406 "undefined behavior");
1407 ValueToEmit &= ~0ULL >> Shift;
1408 emitIntValue(ValueToEmit, EmissionSize);
1417 TS->emitValue(
Value);
1424void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1426 if (
Value->evaluateAsAbsolute(IntValue)) {
1427 emitULEB128IntValue(IntValue);
1430 OS <<
"\t.uleb128 ";
1435void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1437 if (
Value->evaluateAsAbsolute(IntValue)) {
1438 emitSLEB128IntValue(IntValue);
1441 OS <<
"\t.sleb128 ";
1446void MCAsmStreamer::emitDTPRel64Value(
const MCExpr *
Value) {
1453void MCAsmStreamer::emitDTPRel32Value(
const MCExpr *
Value) {
1460void MCAsmStreamer::emitTPRel64Value(
const MCExpr *
Value) {
1467void MCAsmStreamer::emitTPRel32Value(
const MCExpr *
Value) {
1474void MCAsmStreamer::emitGPRel64Value(
const MCExpr *
Value) {
1481void MCAsmStreamer::emitGPRel32Value(
const MCExpr *
Value) {
1488void MCAsmStreamer::emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
1490 int64_t IntNumBytes;
1491 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1492 if (IsAbsolute && IntNumBytes == 0)
1496 if (!MAI->
isAIX() || FillValue == 0) {
1498 OS << ZeroDirective;
1501 OS <<
',' << (int)FillValue;
1506 "Cannot emit non-absolute expression lengths of fill.");
1507 for (
int i = 0; i < IntNumBytes; ++i) {
1518void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1519 int64_t Expr,
SMLoc Loc) {
1523 OS <<
", " <<
Size <<
", 0x";
1528void MCAsmStreamer::emitAlignmentDirective(
uint64_t ByteAlignment,
1529 std::optional<int64_t>
Value,
1531 unsigned MaxBytesToEmit) {
1545 switch (ValueSize) {
1549 OS <<
"\t.p2align\t";
1563 if (
Value.has_value() || MaxBytesToEmit) {
1564 if (
Value.has_value()) {
1572 OS <<
", " << MaxBytesToEmit;
1580 switch (ValueSize) {
1582 case 1:
OS <<
".balign";
break;
1583 case 2:
OS <<
".balignw";
break;
1584 case 4:
OS <<
".balignl";
break;
1589 if (
Value.has_value())
1591 else if (MaxBytesToEmit)
1594 OS <<
", " << MaxBytesToEmit;
1598void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t
Value,
1600 unsigned MaxBytesToEmit) {
1601 emitAlignmentDirective(Alignment.
value(),
Value, ValueSize, MaxBytesToEmit);
1604void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1606 unsigned MaxBytesToEmit) {
1612 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1615void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1616 unsigned char Value,
1625void MCAsmStreamer::emitFileDirective(
StringRef Filename) {
1628 PrintQuotedString(Filename,
OS);
1632void MCAsmStreamer::emitFileDirective(
StringRef Filename,
1638 PrintQuotedString(Filename,
OS);
1639 bool useTimeStamp = !TimeStamp.
empty();
1640 bool useCompilerVersion = !CompilerVersion.
empty();
1641 bool useDescription = !Description.
empty();
1642 if (useTimeStamp || useCompilerVersion || useDescription) {
1645 PrintQuotedString(TimeStamp,
OS);
1646 if (useCompilerVersion || useDescription) {
1648 if (useCompilerVersion)
1649 PrintQuotedString(CompilerVersion,
OS);
1650 if (useDescription) {
1652 PrintQuotedString(Description,
OS);
1659void MCAsmStreamer::printDwarfFileDirective(
1661 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1665 if (!UseDwarfDirectory && !Directory.
empty()) {
1669 FullPathName = Directory;
1676 OS <<
"\t.file\t" << FileNo <<
' ';
1677 if (!Directory.
empty()) {
1678 PrintQuotedString(Directory,
OS);
1681 PrintQuotedString(Filename,
OS);
1683 OS <<
" md5 0x" << Checksum->digest();
1686 PrintQuotedString(*Source,
OS);
1692 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1694 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1699 Table.
tryGetFile(Directory, Filename, Checksum, Source,
1703 FileNo = FileNoOrErr.
get();
1712 printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
1713 UseDwarfDirectory, OS1);
1716 TS->emitDwarfFileDirective(OS1.str());
1718 emitRawText(OS1.str());
1723void MCAsmStreamer::emitDwarfFile0Directive(
1725 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1732 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1741 printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
1742 UseDwarfDirectory, OS1);
1745 TS->emitDwarfFileDirective(OS1.str());
1747 emitRawText(OS1.str());
1750void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1751 unsigned Column,
unsigned Flags,
1752 unsigned Isa,
unsigned Discriminator,
1761 Discriminator, FileName);
1765 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1768 OS <<
" basic_block";
1770 OS <<
" prologue_end";
1772 OS <<
" epilogue_begin";
1774 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1785 OS <<
" isa " << Isa;
1793 <<
Line <<
':' << Column;
1797 Discriminator, FileName);
1802 OS <<
".loc_label\t" <<
Name;
1806MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1812bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo,
StringRef Filename,
1814 unsigned ChecksumKind) {
1815 if (!getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1819 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1820 PrintQuotedString(Filename,
OS);
1822 if (!ChecksumKind) {
1828 PrintQuotedString(toHex(Checksum),
OS);
1835bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1836 OS <<
"\t.cv_func_id " <<
FuncId <<
'\n';
1840bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1843 unsigned IALine,
unsigned IACol,
1845 OS <<
"\t.cv_inline_site_id " <<
FunctionId <<
" within " << IAFunc
1846 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1848 IALine, IACol, Loc);
1851void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1852 unsigned Line,
unsigned Column,
1853 bool PrologueEnd,
bool IsStmt,
1856 if (!checkCVLocSection(
FunctionId, FileNo, Loc))
1862 OS <<
" prologue_end";
1875void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1886void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1887 unsigned SourceFileId,
1888 unsigned SourceLineNum,
1891 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1892 <<
' ' << SourceLineNum <<
' ';
1898 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1901void MCAsmStreamer::PrintCVDefRangePrefix(
1902 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1903 OS <<
"\t.cv_def_range\t";
1904 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1912void MCAsmStreamer::emitCVDefRangeDirective(
1913 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1915 PrintCVDefRangePrefix(Ranges);
1916 OS <<
", reg_rel, ";
1922void MCAsmStreamer::emitCVDefRangeDirective(
1923 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1925 PrintCVDefRangePrefix(Ranges);
1926 OS <<
", subfield_reg, ";
1931void MCAsmStreamer::emitCVDefRangeDirective(
1932 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1934 PrintCVDefRangePrefix(Ranges);
1940void MCAsmStreamer::emitCVDefRangeDirective(
1941 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1943 PrintCVDefRangePrefix(Ranges);
1944 OS <<
", frame_ptr_rel, ";
1949void MCAsmStreamer::emitCVStringTableDirective() {
1950 OS <<
"\t.cv_stringtable";
1954void MCAsmStreamer::emitCVFileChecksumsDirective() {
1955 OS <<
"\t.cv_filechecksums";
1959void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1960 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1964void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
1965 OS <<
"\t.cv_fpo_data\t";
1970void MCAsmStreamer::emitIdent(
StringRef IdentString) {
1973 PrintQuotedString(IdentString,
OS);
1977void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug) {
1979 OS <<
"\t.cfi_sections ";
1983 OS <<
", .debug_frame";
1985 OS <<
".debug_frame";
1992 OS <<
"\t.cfi_startproc";
2000 OS <<
"\t.cfi_endproc";
2004void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2010 if (std::optional<MCRegister> LLVMRegister =
2012 InstPrinter->printRegName(
OS, *LLVMRegister);
2021 OS <<
"\t.cfi_def_cfa ";
2027void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset,
SMLoc Loc) {
2029 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2033void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2036 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2044 OS <<
"\t.cfi_escape ";
2045 if (!Values.
empty()) {
2046 size_t e = Values.
size() - 1;
2047 for (
size_t i = 0; i < e; ++i)
2059void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size,
SMLoc Loc) {
2062 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2069void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register,
SMLoc Loc) {
2071 OS <<
"\t.cfi_def_cfa_register ";
2078 OS <<
"\t.cfi_offset ";
2084void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *
Sym,
2085 unsigned Encoding) {
2087 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2088 Sym->print(
OS, MAI);
2092void MCAsmStreamer::emitCFILsda(
const MCSymbol *
Sym,
unsigned Encoding) {
2094 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2095 Sym->print(
OS, MAI);
2099void MCAsmStreamer::emitCFIRememberState(
SMLoc Loc) {
2101 OS <<
"\t.cfi_remember_state";
2105void MCAsmStreamer::emitCFIRestoreState(
SMLoc Loc) {
2107 OS <<
"\t.cfi_restore_state";
2111void MCAsmStreamer::emitCFIRestore(int64_t
Register,
SMLoc Loc) {
2113 OS <<
"\t.cfi_restore ";
2118void MCAsmStreamer::emitCFISameValue(int64_t
Register,
SMLoc Loc) {
2120 OS <<
"\t.cfi_same_value ";
2125void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2128 OS <<
"\t.cfi_rel_offset ";
2134void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment,
SMLoc Loc) {
2136 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2140void MCAsmStreamer::emitCFISignalFrame() {
2142 OS <<
"\t.cfi_signal_frame";
2146void MCAsmStreamer::emitCFIUndefined(int64_t
Register,
SMLoc Loc) {
2148 OS <<
"\t.cfi_undefined ";
2153void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2156 OS <<
"\t.cfi_register ";
2157 EmitRegisterName(Register1);
2159 EmitRegisterName(Register2);
2163void MCAsmStreamer::emitCFIWindowSave(
SMLoc Loc) {
2165 OS <<
"\t.cfi_window_save";
2169void MCAsmStreamer::emitCFINegateRAState(
SMLoc Loc) {
2171 OS <<
"\t.cfi_negate_ra_state";
2175void MCAsmStreamer::emitCFINegateRAStateWithPC(
SMLoc Loc) {
2177 OS <<
"\t.cfi_negate_ra_state_with_pc";
2181void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2183 OS <<
"\t.cfi_return_column ";
2190 OS <<
"\t.cfi_label " <<
Name;
2194void MCAsmStreamer::emitCFIBKeyFrame() {
2196 OS <<
"\t.cfi_b_key_frame";
2200void MCAsmStreamer::emitCFIMTETaggedFrame() {
2202 OS <<
"\t.cfi_mte_tagged_frame";
2206void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2209 OS <<
"\t.cfi_val_offset ";
2215void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2223void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2226 OS <<
"\t.seh_endproc";
2230void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2233 OS <<
"\t.seh_endfunclet";
2237void MCAsmStreamer::emitWinCFIStartChained(
SMLoc Loc) {
2240 OS <<
"\t.seh_startchained";
2244void MCAsmStreamer::emitWinCFIEndChained(
SMLoc Loc) {
2247 OS <<
"\t.seh_endchained";
2251void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *
Sym,
bool Unwind,
2252 bool Except,
SMLoc Loc) {
2255 OS <<
"\t.seh_handler ";
2256 Sym->print(
OS, MAI);
2258 const Triple &
T = getContext().getTargetTriple();
2262 OS <<
", " << Marker <<
"unwind";
2264 OS <<
", " << Marker <<
"except";
2268void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2283 MCSection *XData = getAssociatedXDataSection(TextSec);
2284 switchSectionNoPrint(XData);
2286 OS <<
"\t.seh_handlerdata";
2293 OS <<
"\t.seh_pushreg ";
2302 OS <<
"\t.seh_setframe ";
2308void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2311 OS <<
"\t.seh_stackalloc " <<
Size;
2319 OS <<
"\t.seh_savereg ";
2329 OS <<
"\t.seh_savexmm ";
2335void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2338 OS <<
"\t.seh_pushframe";
2344void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2347 OS <<
"\t.seh_endprologue";
2354 OS <<
"\t.cg_profile ";
2355 From->getSymbol().print(
OS, MAI);
2358 OS <<
", " << Count;
2362void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2369 if (!getAssembler().getEmitterPtr())
2372 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2379 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2382 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2385 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2386 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2387 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2388 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2389 FixupMap[
Index] = 1 + i;
2395 OS <<
"encoding: [";
2396 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2401 uint8_t MapEntry = FixupMap[i * 8 + 0];
2402 for (
unsigned j = 1;
j != 8; ++
j) {
2403 if (FixupMap[i * 8 + j] == MapEntry)
2410 if (MapEntry !=
uint8_t(~0U)) {
2411 if (MapEntry == 0) {
2417 <<
char(
'A' + MapEntry - 1) <<
'\'';
2419 OS <<
char(
'A' + MapEntry - 1);
2424 for (
unsigned j = 8;
j--;) {
2429 FixupBit = i * 8 + j;
2431 FixupBit = i * 8 + (7-
j);
2433 if (
uint8_t MapEntry = FixupMap[FixupBit]) {
2434 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2435 OS <<
char(
'A' + MapEntry - 1);
2443 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2446 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2447 OS <<
" fixup " <<
char(
'A' + i) <<
" - "
2448 <<
"offset: " <<
F.getOffset() <<
", value: ";
2449 F.getValue()->print(
OS, MAI);
2450 OS <<
", kind: " <<
Info.Name <<
"\n";
2454void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2456 if (MAI->
isAIX() && CurFrag)
2462 AddEncodingComment(Inst, STI);
2466 Inst.
dump_pretty(getCommentOS(), InstPrinter.get(),
"\n ");
2467 getCommentOS() <<
"\n";
2470 if(getTargetStreamer())
2471 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI,
OS);
2473 InstPrinter->printInst(&Inst, 0,
"", STI,
OS);
2476 if (Comments.
size() && Comments.
back() !=
'\n')
2477 getCommentOS() <<
"\n";
2487 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2492 for (
const auto &Site : InlineStack)
2493 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2500void MCAsmStreamer::emitBundleAlignMode(
Align Alignment) {
2501 OS <<
"\t.bundle_align_mode " <<
Log2(Alignment);
2505void MCAsmStreamer::emitBundleLock(
bool AlignToEnd) {
2506 OS <<
"\t.bundle_lock";
2508 OS <<
" align_to_end";
2512void MCAsmStreamer::emitBundleUnlock() {
2513 OS <<
"\t.bundle_unlock";
2517std::optional<std::pair<bool, std::string>>
2529 return std::nullopt;
2532void MCAsmStreamer::emitAddrsig() {
2537void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *
Sym) {
2538 OS <<
"\t.addrsig_sym ";
2539 Sym->print(
OS, MAI);
2547 String.consume_back(
"\n");
2552void MCAsmStreamer::finishImpl() {
2554 if (getContext().getGenDwarfForAssembly())
2567 const auto &Tables = getContext().getMCDwarfLineTables();
2568 if (!Tables.empty()) {
2569 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2570 if (
auto *Label = Tables.begin()->second.getLabel()) {
2571 switchSection(getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2589MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2590 const Twine &Comment) {
2598 return getContext().createTempSymbol(Prefix +
"_end");
2602void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2613 emitLabel(DebugLineSymTmp);
2617 unsigned LengthFieldSize =
2623 emitAssignment(StartSym, OuterSym);
2629void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2638 ".loc should not be generated together with raw data!");
2651 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2656void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2659 unsigned PointerSize) {
2661 ".loc/.file don't need raw data in debug line section!");
2664 AddComment(
"Set address to " +
Label->getName());
2665 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2666 emitULEB128IntValue(PointerSize + 1);
2667 emitIntValue(dwarf::DW_LNE_set_address, 1);
2668 emitSymbolValue(Label, PointerSize);
2672 AddComment(
"Start sequence");
2680 AddComment(
"End sequence");
2681 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2682 emitULEB128IntValue(1);
2683 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2688 AddComment(
"Advance line " +
Twine(LineDelta));
2689 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2690 emitSLEB128IntValue(LineDelta);
2691 emitIntValue(dwarf::DW_LNS_copy, 1);
2695 std::unique_ptr<formatted_raw_ostream>
OS,
2697 std::unique_ptr<MCCodeEmitter> &&CE,
2698 std::unique_ptr<MCAsmBackend> &&MAB) {
2699 return new MCAsmStreamer(Context, std::move(
OS), IP, std::move(CE),
unsigned const MachineRegisterInfo * MRI
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))
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),...
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
const char * getTPRel64Directive() const
const char * getData32bitsDirective() 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 * 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
const char * getGlobalDirective() const
const char * getCode32Directive() const
unsigned getCommentColumn() const
const char * getCode64Directive() 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 * getGPRel32Directive() const
const char * getWeakRefDirective() const
const char * getDTPRel32Directive() const
bool hasNoDeadStrip() const
bool enableDwarfFileDirectoryDefault() 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
const MCTargetOptions * getTargetOptions() const
void setUseNamesOnTempLabels(bool Value)
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 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 bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
virtual void finishImpl()
Streamer specific finalization.
virtual void emitDTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
virtual void emitCFIBKeyFrame()
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 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 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 emitGPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual bool 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 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 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 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 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 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 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 emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitTPRel64Value(const MCExpr *Value)
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
virtual void emitCFISections(bool EH, bool Debug)
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 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 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 emitThumbFunc(MCSymbol *Func)
Note in the output that the specified Func is a Thumb mode function (ARM target only).
virtual void emitCFIRestoreState(SMLoc Loc)
virtual void emitXCOFFRefDirective(const MCSymbol *Symbol)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void 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 emitDTPRel32Value(const MCExpr *Value)
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
virtual void 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 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 emitBundleAlignMode(Align Alignment)
Set the bundle alignment mode from now on in the section.
virtual void emitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
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)
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.
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).
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.
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.
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
@ Emitted
Assigned address, still materializing.
NodeAddr< FuncNode * > Func
NodeAddr< CodeNode * > Code
uint32_t read32be(const void *P)
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.
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, 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,...
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.)
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
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.
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)
@ 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.
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