46 std::unique_ptr<MCCodeEmitter>
Emitter,
47 std::unique_ptr<MCAsmBackend> AsmBackend)
51 (AsmBackend) ? AsmBackend->createObjectWriter(
NullStream) : nullptr)),
75 FixupMap.
resize(Code.size() * 8);
76 for (
unsigned I = 0, E = Code.size() * 8;
I != E; ++
I)
79 for (
unsigned I = 0, E = Fixups.size();
I != E; ++
I) {
83 for (
unsigned J = 0; J != Info.TargetSize; ++J) {
84 unsigned Index =
F.getOffset() * 8 + Info.TargetOffset + J;
85 assert(Index < Code.size() * 8 &&
"Invalid offset in fixup!");
93 auto Idx = (Index + (Code.size() == 4 ? 16 : 0)) % (Code.size() * 8);
94 FixupMap[Idx] = 1 +
I;
96 FixupMap[Index] = 1 +
I;
101 for (
unsigned I = 0, E = Code.size();
I != E; ++
I) {
106 uint8_t MapEntry = FixupMap[
I * 8 + 0];
107 for (
unsigned J = 1; J != 8; ++J) {
108 if (FixupMap[
I * 8 + J] == MapEntry)
115 if (MapEntry !=
uint8_t(~0U)) {
122 <<
char(
'A' + MapEntry - 1) <<
'\'';
124 OS <<
char(
'A' + MapEntry - 1);
129 for (
unsigned J = 8; J--;) {
130 unsigned Bit = (Code[
I] >> J) & 1;
137 FixupBit =
I * 8 + J;
139 FixupBit =
I * 8 + (7 - J);
141 if (
uint8_t MapEntry = FixupMap[FixupBit]) {
142 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
143 OS <<
char(
'A' + MapEntry - 1);
151 for (
unsigned I = 0, E = Fixups.size();
I != E; ++
I) {
153 OS <<
" fixup " <<
char(
'A' +
I) <<
" - "
154 <<
"offset: " <<
F.getOffset() <<
", value: ";
156 auto Kind =
F.getKind();
158 OS <<
", relocation type: " << Kind;
163 OS <<
"FK_PCRel_" << (Info.TargetSize / 8);
174 std::unique_ptr<formatted_raw_ostream> OSOwner;
177 std::unique_ptr<MCInstPrinter> InstPrinter;
181 bool EmittedSectionDirective =
false;
183 bool IsVerboseAsm =
false;
184 bool ShowInst =
false;
185 bool UseDwarfDirectory =
false;
187 void EmitRegisterName(int64_t
Register);
189 void printDwarfFileDirective(
unsigned FileNo,
StringRef Directory,
191 std::optional<MD5::MD5Result> Checksum,
192 std::optional<StringRef> Source,
193 bool UseDwarfDirectory,
197 void emitBundleAlignMode(
Align Alignment)
override;
198 void emitBundleLock(
bool AlignToEnd,
const MCSubtargetInfo &STI)
override;
202 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
203 unsigned Discriminator);
207 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
208 unsigned Column,
unsigned Flags,
209 unsigned Isa,
unsigned Discriminator,
213 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
214 std::unique_ptr<MCInstPrinter>
printer,
215 std::unique_ptr<MCCodeEmitter> emitter,
216 std::unique_ptr<MCAsmBackend> asmbackend)
218 OSOwner(
std::
move(os)), OS(*OSOwner), MAI(&Context.getAsmInfo()),
221 if (Assembler->getBackendPtr())
222 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
224 Context.setUseNamesOnTempLabels(
true);
229 InstPrinter->setCommentStream(CommentStream);
233 UseDwarfDirectory =
false;
236 UseDwarfDirectory =
true;
240 Context.getAsmInfo().enableDwarfFileDirectoryDefault();
245 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
247 inline void EmitEOL() {
249 emitExplicitComments();
255 EmitCommentsAndEOL();
258 void emitSyntaxDirective(StringRef Syntax, StringRef
Options)
override;
260 void EmitCommentsAndEOL();
263 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
266 bool hasRawTextSupport()
const override {
return true; }
271 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
273 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
275 void addExplicitComment(
const Twine &
T)
override;
276 void emitExplicitComments()
override;
279 void addBlankLine()
override { EmitEOL(); }
284 void switchSection(MCSection *Section, uint32_t Subsection)
override;
285 bool popSection()
override;
287 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
288 bool KeepOriginalSym)
override;
292 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
295 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
296 assert((Bits != 0 || Ptr ==
nullptr) &&
297 "Invalid char pointer for instruction with no mnemonic");
301 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
303 void emitSubsectionsViaSymbols()
override;
304 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
307 unsigned Update, VersionTuple SDKVersion)
override;
308 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
309 unsigned Update, VersionTuple SDKVersion)
override;
310 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
311 unsigned Minor,
unsigned Update,
312 VersionTuple SDKVersion)
override;
313 void emitTargetTriple(StringRef TargetTriple)
override;
315 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
316 void emitConditionalAssignment(MCSymbol *Symbol,
317 const MCExpr *
Value)
override;
318 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
321 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
322 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
323 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
324 void emitCOFFSymbolType(
int Type)
override;
325 void endCOFFSymbolDef()
override;
326 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
327 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
328 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
329 void emitCOFFSecRel32(MCSymbol
const *Symbol,
uint64_t Offset)
override;
330 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
331 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
332 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
333 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
uint64_t Size,
334 MCSymbol *CsectSym, Align Alignment)
override;
335 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
338 void emitXCOFFRenameDirective(
const MCSymbol *Name,
339 StringRef Rename)
override;
341 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
343 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
344 const MCSymbol *
Trap,
345 unsigned Lang,
unsigned Reason,
346 unsigned FunctionSize,
bool hasDebug)
override;
347 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
349 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
351 Align ByteAlignment)
override;
358 void emitLocalCommonSymbol(MCSymbol *Symbol,
uint64_t Size,
359 Align ByteAlignment)
override;
361 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
363 SMLoc Loc = SMLoc())
override;
365 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
uint64_t Size,
366 Align ByteAlignment =
Align(1))
override;
368 void emitBinaryData(StringRef
Data)
override;
370 void emitBytes(StringRef
Data)
override;
372 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
373 SMLoc Loc = SMLoc())
override;
378 void emitULEB128Value(
const MCExpr *
Value)
override;
380 void emitSLEB128Value(
const MCExpr *
Value)
override;
382 void emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
383 SMLoc Loc = SMLoc())
override;
385 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
386 SMLoc Loc = SMLoc())
override;
388 void emitAlignmentDirective(
uint64_t ByteAlignment,
389 std::optional<int64_t>
Value,
unsigned ValueSize,
390 unsigned MaxBytesToEmit);
392 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
394 unsigned MaxBytesToEmit = 0)
override;
396 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo &STI,
397 unsigned MaxBytesToEmit = 0)
override;
398 void emitPrefAlign(Align Alignment,
const MCSymbol &
End,
bool EmitNops,
399 uint8_t Fill,
const MCSubtargetInfo &STI)
override;
401 void emitValueToOffset(
const MCExpr *
Offset,
405 void emitFileDirective(StringRef
Filename)
override;
406 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
407 StringRef TimeStamp, StringRef Description)
override;
408 Expected<unsigned> tryEmitDwarfFileDirective(
409 unsigned FileNo, StringRef Directory, StringRef
Filename,
410 std::optional<MD5::MD5Result> Checksum = std::nullopt,
411 std::optional<StringRef> Source = std::nullopt,
412 unsigned CUID = 0)
override;
413 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
414 std::optional<MD5::MD5Result> Checksum,
415 std::optional<StringRef> Source,
416 unsigned CUID = 0)
override;
417 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
418 unsigned Flags,
unsigned Isa,
419 unsigned Discriminator, StringRef FileName,
420 StringRef Location = {})
override;
421 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
425 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
426 unsigned Column,
unsigned FileIA,
427 unsigned LineIA,
unsigned ColIA,
428 const MCSymbol *Sym,
unsigned Flags,
429 unsigned Isa,
unsigned Discriminator,
431 StringRef Comment = {})
override;
433 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
435 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
436 ArrayRef<uint8_t> Checksum,
437 unsigned ChecksumKind)
override;
438 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
439 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
440 unsigned IAFile,
unsigned IALine,
441 unsigned IACol, SMLoc Loc)
override;
442 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
443 unsigned Column,
bool PrologueEnd,
bool IsStmt,
444 StringRef FileName, SMLoc Loc)
override;
445 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
446 const MCSymbol *FnEnd)
override;
447 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
448 unsigned SourceFileId,
449 unsigned SourceLineNum,
450 const MCSymbol *FnStartSym,
451 const MCSymbol *FnEndSym)
override;
453 void PrintCVDefRangePrefix(
454 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
456 void emitCVDefRangeDirective(
457 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
458 codeview::DefRangeRegisterRelHeader DRHdr)
override;
460 void emitCVDefRangeDirective(
461 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
462 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
464 void emitCVDefRangeDirective(
465 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
466 codeview::DefRangeRegisterHeader DRHdr)
override;
468 void emitCVDefRangeDirective(
469 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
470 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
472 void emitCVDefRangeDirective(
473 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
474 codeview::DefRangeRegisterRelIndirHeader DRHdr)
override;
476 void emitCVStringTableDirective()
override;
477 void emitCVFileChecksumsDirective()
override;
478 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
479 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
481 void emitIdent(StringRef IdentString)
override;
482 void emitCFIBKeyFrame()
override;
483 void emitCFIMTETaggedFrame()
override;
484 void emitCFINonHintPAuthFrame()
override;
485 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
486 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
487 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
488 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
491 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
492 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
493 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
494 void emitCFIRememberState(SMLoc Loc)
override;
495 void emitCFIRestoreState(SMLoc Loc)
override;
496 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
497 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
498 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
499 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
500 void emitCFIEscape(StringRef
Values, SMLoc Loc)
override;
501 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
502 void emitCFISignalFrame()
override;
503 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
504 void emitCFIRegister(int64_t Register1, int64_t Register2,
506 void emitCFIWindowSave(SMLoc Loc)
override;
507 void emitCFINegateRAState(SMLoc Loc)
override;
508 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
509 void emitCFILLVMSetRAState(
unsigned State, MCSymbol *PACSym,
511 void emitCFILLVMSetRAState(
unsigned State, int64_t
Offset,
513 void emitCFIReturnColumn(int64_t
Register)
override;
514 void emitCFILLVMRegisterPair(int64_t
Register, int64_t R1, int64_t R1Size,
515 int64_t
R2, int64_t R2Size, SMLoc Loc)
override;
516 void emitCFILLVMVectorRegisters(
519 void emitCFILLVMVectorOffset(int64_t
Register, int64_t RegisterSize,
520 int64_t MaskRegister, int64_t MaskRegisterSize,
521 int64_t
Offset, SMLoc Loc)
override;
522 void emitCFILLVMVectorRegisterMask(int64_t
Register, int64_t SpillRegister,
523 int64_t SpillRegisterLaneSizeInBits,
524 int64_t MaskRegister,
525 int64_t MaskRegisterSizeInBits,
528 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
529 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
531 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
532 void emitWinCFIEndProc(SMLoc Loc)
override;
533 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
534 void emitWinCFISplitChained(SMLoc Loc)
override;
535 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
536 void emitWinCFIPush2Regs(MCRegister Reg1, MCRegister Reg2,
540 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
545 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
546 void emitWinCFIEndProlog(SMLoc Loc)
override;
547 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
548 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
549 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
550 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
552 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
554 void emitWinEHHandlerData(SMLoc Loc)
override;
556 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
559 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
564 MCSymbol *FnSym)
override;
566 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
567 const MCExpr *Expr, SMLoc Loc)
override;
569 void emitAddrsig()
override;
570 void emitAddrsigSym(
const MCSymbol *Sym)
override;
575 void emitRawTextImpl(StringRef
String)
override;
577 void finishImpl()
override;
579 void emitDwarfUnitLength(
uint64_t Length,
const Twine &Comment)
override;
581 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
582 const Twine &Comment)
override;
584 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
586 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
587 MCSymbol *EndLabel =
nullptr)
override;
589 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
590 const MCSymbol *Label,
591 unsigned PointerSize)
override;
596void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
597 if (!IsVerboseAsm)
return;
599 T.toVector(CommentToEmit);
602 CommentToEmit.push_back(
'\n');
605void MCAsmStreamer::EmitCommentsAndEOL() {
606 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
614 "Comment array not newline terminated");
618 size_t Position = Comments.
find(
'\n');
621 Comments = Comments.
substr(Position+1);
622 }
while (!Comments.
empty());
624 CommentToEmit.clear();
628 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
629 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
632void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
639void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
644 ExplicitCommentToEmit.
append(
"\t");
649 size_t p = 2, len = c.
size() - 2;
653 ExplicitCommentToEmit.
append(
"\t");
658 ExplicitCommentToEmit.
append(
"\n");
662 ExplicitCommentToEmit.
append(
"\t");
664 }
else if (c.
front() ==
'#') {
666 ExplicitCommentToEmit.
append(
"\t");
670 assert(
false &&
"Unexpected Assembly Comment");
672 if (c.
back() ==
'\n')
673 emitExplicitComments();
676void MCAsmStreamer::emitExplicitComments() {
677 StringRef Comments = ExplicitCommentToEmit;
678 if (!Comments.
empty())
680 ExplicitCommentToEmit.
clear();
683void MCAsmStreamer::switchSection(
MCSection *Section, uint32_t Subsection) {
685 if (!EmittedSectionDirective ||
687 EmittedSectionDirective =
true;
689 TS->changeSection(Cur.first, Section, Subsection, OS);
698bool MCAsmStreamer::popSection() {
701 auto [Sec, Subsec] = getCurrentSection();
707void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
709 bool KeepOriginalSym) {
711 OriginalSym->
print(OS, MAI);
713 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
723 if (!
Symbol->isVariable() &&
738 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
739 assert(str !=
"" &&
"Invalid LOH name");
753void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
754 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
757void MCAsmStreamer::emitSubsectionsViaSymbols() {
758 OS <<
".subsections_via_symbols\n";
762 assert(!
Options.empty() &&
"At least one option is required!");
763 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
765 OS <<
", " <<
'"' << Opt <<
'"';
794 if (SDKVersion.
empty())
796 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
797 if (
auto Minor = SDKVersion.
getMinor()) {
798 OS <<
", " << *Minor;
800 OS <<
", " << *Subminor;
806 unsigned Minor,
unsigned Update,
810 OS <<
", " << Update;
817#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
819 case MachO::PLATFORM_##platform: \
821#include "llvm/BinaryFormat/MachO.def"
826void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
827 unsigned Minor,
unsigned Update,
830 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
832 OS <<
", " << Update;
837void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
838 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
840 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
843void MCAsmStreamer::emitTargetTriple(
StringRef TargetTriple) {
844 OS <<
"\t.target_triple \"" << TargetTriple <<
'"';
853 OS << (UseSet ?
", " :
" = ");
860void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
862 OS <<
".lto_set_conditional ";
869void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
871 Alias->
print(OS, MAI);
877bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
894 default:
return false;
917 OS <<
"\t.no_dead_strip\t";
922 OS <<
"\t.private_extern\t";
931 OS <<
"\t.weak_definition\t";
948 OS <<
"\t.weak_anti_dep\t";
958void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
959 OS <<
".desc" <<
' ';
961 OS <<
',' << DescValue;
966 OS <<
"\t." << Syntax <<
"_syntax";
972void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
979void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
984void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
985 OS <<
"\t.type\t" <<
Type <<
';';
989void MCAsmStreamer::endCOFFSymbolDef() {
994void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
995 OS <<
"\t.safeseh\t";
1000void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
1001 OS <<
"\t.symidx\t";
1006void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
1007 OS <<
"\t.secidx\t";
1013 OS <<
"\t.secrel32\t";
1020void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
1030void MCAsmStreamer::emitCOFFSecNumber(
MCSymbol const *Symbol) {
1031 OS <<
"\t.secnum\t";
1036void MCAsmStreamer::emitCOFFSecOffset(
MCSymbol const *Symbol) {
1037 OS <<
"\t.secoffset\t";
1045void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
1050 "We only support writing log base-2 alignment format with XCOFF.");
1053 LabelSym->
print(OS, MAI);
1054 OS <<
',' <<
Size <<
',';
1055 CsectSym->
print(OS, MAI);
1056 OS <<
',' <<
Log2(Alignment);
1063 if (XSym->hasRename())
1064 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1067void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
1078 OS <<
"\t.extern\t";
1081 OS <<
"\t.lglobl\t";
1089 switch (Visibility) {
1109 if (Sym.hasRename())
1110 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
1113void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
1115 OS <<
"\t.rename\t";
1116 Name->print(OS, MAI);
1117 const char DQ =
'"';
1119 for (
char C : Rename) {
1129void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
1135void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
1139 unsigned FunctionSize,
1141 OS <<
"\t.except\t";
1143 OS <<
", " << Lang <<
", " << Reason;
1148 const char InfoDirective[] =
"\t.info ";
1149 const char *Separator =
", ";
1150 constexpr int WordSize =
sizeof(uint32_t);
1153 OS << InfoDirective;
1154 PrintQuotedString(Name, OS);
1157 size_t MetadataSize =
Metadata.size();
1160 OS <<
format_hex(MetadataSize, 10) << Separator;
1163 if (MetadataSize == 0) {
1173 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1174 uint32_t PaddingSize = PaddedSize - MetadataSize;
1181 constexpr int WordsPerDirective = 5;
1184 int WordsBeforeNextDirective = 0;
1185 auto PrintWord = [&](
const uint8_t *WordPtr) {
1186 if (WordsBeforeNextDirective-- == 0) {
1188 OS << InfoDirective;
1189 WordsBeforeNextDirective = WordsPerDirective;
1197 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1198 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1203 assert(PaddedSize - Index == WordSize);
1204 std::array<uint8_t, WordSize> LastWord = {0};
1205 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1206 PrintWord(LastWord.data());
1221 Align ByteAlignment) {
1229 OS <<
',' <<
Log2(ByteAlignment);
1236 if (XSym && XSym->hasRename())
1237 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1247 if (ByteAlign > 1) {
1252 OS <<
',' << ByteAlign.
value();
1255 OS <<
',' <<
Log2(ByteAlign);
1272 ".zerofill is a Mach-O specific directive");
1282 OS <<
',' <<
Log2(ByteAlignment);
1297 ".zerofill is a Mach-O specific directive");
1306 if (ByteAlignment > 1)
1307 OS <<
", " <<
Log2(ByteAlignment);
1313 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1314 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1325 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1326 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1332 const auto printOneCharacterFor = [printCharacterInOctal](
1333 auto printOnePrintingCharacter) {
1334 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1336 printOnePrintingCharacter(
static_cast<char>(
C));
1339 printCharacterInOctal(
C);
1342 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1343 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1344 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1345 printOneCharacter(
C);
1348 printOneCharacter(*(EndPtr - 1));
1352 printCharacterList(printCharacterInOctal);
1355 printCharacterList(printOneCharacterFor([&OS](
char C) {
1356 const char AsmCharLitBuf[2] = {
'\'',
C};
1357 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1368 for (
unsigned char C :
Data) {
1375 for (
unsigned char C :
Data) {
1376 if (
C ==
'"' ||
C ==
'\\') {
1377 OS <<
'\\' << (char)
C;
1416 assert(getCurrentSectionOnly() &&
1417 "Cannot emit contents before setting section!");
1418 if (
Data.empty())
return;
1425 if (
Data.back() == 0) {
1426 OS <<
"\t.string\t";
1431 PrintQuotedString(
Data, OS);
1451 PrintQuotedString(
Data, OS);
1456 if (
Data.size() != 1 && emitAsString(
Data))
1462 TS->emitRawBytes(
Data);
1466 for (
const unsigned char C :
Data.bytes()) {
1474 const size_t Cols = 4;
1475 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1476 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1479 for (; J < EJ - 1; ++J)
1480 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1494void MCAsmStreamer::emitIntValueInHexWithPadding(
uint64_t Value,
1502 assert(getCurrentSectionOnly() &&
1503 "Cannot emit contents before setting section!");
1515 if (!
Value->evaluateAsAbsolute(IntValue))
1530 unsigned ByteOffset =
1531 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1532 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1536 uint64_t Shift = 64 - EmissionSize * 8;
1538 std::numeric_limits<unsigned long long>::digits) &&
1539 "undefined behavior");
1540 ValueToEmit &= ~0ULL >> Shift;
1541 emitIntValue(ValueToEmit, EmissionSize);
1550 TS->emitValue(
Value);
1557void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1559 if (
Value->evaluateAsAbsolute(IntValue)) {
1560 emitULEB128IntValue(IntValue);
1563 OS <<
"\t.uleb128 ";
1568void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1570 if (
Value->evaluateAsAbsolute(IntValue)) {
1571 emitSLEB128IntValue(IntValue);
1574 OS <<
"\t.sleb128 ";
1579void MCAsmStreamer::emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
1581 int64_t IntNumBytes;
1582 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1583 if (IsAbsolute && IntNumBytes == 0)
1587 if (!MAI->
isAIX() || FillValue == 0) {
1589 OS << ZeroDirective;
1592 OS <<
',' << (int)FillValue;
1597 "Cannot emit non-absolute expression lengths of fill.");
1598 for (
int i = 0; i < IntNumBytes; ++i) {
1609void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1614 OS <<
", " <<
Size <<
", 0x";
1619void MCAsmStreamer::emitAlignmentDirective(
uint64_t ByteAlignment,
1620 std::optional<int64_t>
Value,
1622 unsigned MaxBytesToEmit) {
1636 switch (ValueSize) {
1640 OS <<
"\t.p2align\t";
1654 if (
Value.has_value() || MaxBytesToEmit) {
1655 if (
Value.has_value()) {
1663 OS <<
", " << MaxBytesToEmit;
1671 switch (ValueSize) {
1673 case 1: OS <<
".balign";
break;
1674 case 2: OS <<
".balignw";
break;
1675 case 4: OS <<
".balignl";
break;
1680 if (
Value.has_value())
1682 else if (MaxBytesToEmit)
1685 OS <<
", " << MaxBytesToEmit;
1689void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t Fill,
1691 unsigned MaxBytesToEmit) {
1692 emitAlignmentDirective(
Alignment.value(), Fill, FillLen, MaxBytesToEmit);
1695void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1697 unsigned MaxBytesToEmit) {
1703 emitAlignmentDirective(
Alignment.value(), std::nullopt, 1, MaxBytesToEmit);
1707 bool EmitNops, uint8_t Fill,
1709 OS <<
"\t.prefalign\t" <<
Log2(Alignment) <<
", ";
1714 OS <<
", " <<
static_cast<unsigned>(Fill);
1718void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1719 unsigned char Value,
1724 OS <<
", " << (unsigned)
Value;
1742 bool useTimeStamp = !TimeStamp.
empty();
1743 bool useCompilerVersion = !CompilerVersion.
empty();
1744 bool useDescription = !Description.
empty();
1745 if (useTimeStamp || useCompilerVersion || useDescription) {
1748 PrintQuotedString(TimeStamp, OS);
1749 if (useCompilerVersion || useDescription) {
1751 if (useCompilerVersion)
1752 PrintQuotedString(CompilerVersion, OS);
1753 if (useDescription) {
1755 PrintQuotedString(Description, OS);
1762void MCAsmStreamer::printDwarfFileDirective(
1764 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1768 if (!UseDwarfDirectory && !Directory.
empty()) {
1772 FullPathName = Directory;
1779 OS <<
"\t.file\t" << FileNo <<
' ';
1780 if (!Directory.
empty()) {
1781 PrintQuotedString(Directory, OS);
1786 OS <<
" md5 0x" << Checksum->digest();
1789 PrintQuotedString(*Source, OS);
1795 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1797 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1800 unsigned NumFiles =
Table.getMCDwarfFiles().size();
1806 FileNo = FileNoOrErr.
get();
1810 if (NumFiles ==
Table.getMCDwarfFiles().size() || MAI->
isAIX())
1815 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1816 UseDwarfDirectory, OS1);
1819 TS->emitDwarfFileDirective(OS1.str());
1821 emitRawText(OS1.str());
1826void MCAsmStreamer::emitDwarfFile0Directive(
1828 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1844 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1845 UseDwarfDirectory, OS1);
1848 TS->emitDwarfFileDirective(OS1.str());
1850 emitRawText(OS1.str());
1854void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1855 unsigned Discriminator) {
1860 OS <<
" basic_block";
1862 OS <<
" prologue_end";
1864 OS <<
" epilogue_begin";
1866 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1873 OS <<
" isa " << Isa;
1879void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1880 unsigned Column,
unsigned Flags,
1882 unsigned Discriminator,
1886 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1893 OS << FileName <<
':' <<
Line <<
':' << Column;
1901 Discriminator, FileName, Comment);
1904void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1905 unsigned Column,
unsigned Flags,
1906 unsigned Isa,
unsigned Discriminator,
1916 Discriminator, FileName, Comment);
1921 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1924 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1930void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1931 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1932 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1933 unsigned Isa,
unsigned Discriminator,
StringRef FileName,
1936 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1937 OS <<
", function_name " << *Sym;
1938 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1941 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1947 OS <<
".loc_label\t" <<
Name;
1951MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1959 unsigned ChecksumKind) {
1964 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1967 if (!ChecksumKind) {
1973 PrintQuotedString(
toHex(Checksum), OS);
1980bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1981 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1985bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1988 unsigned IALine,
unsigned IACol,
1990 OS <<
"\t.cv_inline_site_id " <<
FunctionId <<
" within " << IAFunc
1991 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1993 IALine, IACol,
Loc);
1996void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1997 unsigned Line,
unsigned Column,
1998 bool PrologueEnd,
bool IsStmt,
2004 OS <<
"\t.cv_loc\t" <<
FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
2007 OS <<
" prologue_end";
2020void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
2023 OS <<
"\t.cv_linetable\t" <<
FunctionId <<
", ";
2024 FnStart->
print(OS, MAI);
2026 FnEnd->
print(OS, MAI);
2031void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
2032 unsigned SourceFileId,
2033 unsigned SourceLineNum,
2036 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
2037 <<
' ' << SourceLineNum <<
' ';
2038 FnStartSym->
print(OS, MAI);
2040 FnEndSym->
print(OS, MAI);
2043 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
2046void MCAsmStreamer::PrintCVDefRangePrefix(
2047 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
2048 OS <<
"\t.cv_def_range\t";
2049 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
2057void MCAsmStreamer::emitCVDefRangeDirective(
2058 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2060 PrintCVDefRangePrefix(Ranges);
2061 OS <<
", reg_rel, ";
2067void MCAsmStreamer::emitCVDefRangeDirective(
2068 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2070 PrintCVDefRangePrefix(Ranges);
2071 OS <<
", subfield_reg, ";
2076void MCAsmStreamer::emitCVDefRangeDirective(
2077 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2079 PrintCVDefRangePrefix(Ranges);
2085void MCAsmStreamer::emitCVDefRangeDirective(
2086 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2088 PrintCVDefRangePrefix(Ranges);
2089 OS <<
", frame_ptr_rel, ";
2094void MCAsmStreamer::emitCVDefRangeDirective(
2095 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2097 PrintCVDefRangePrefix(Ranges);
2098 OS <<
", reg_rel_indir, ";
2104void MCAsmStreamer::emitCVStringTableDirective() {
2105 OS <<
"\t.cv_stringtable";
2109void MCAsmStreamer::emitCVFileChecksumsDirective() {
2110 OS <<
"\t.cv_filechecksums";
2114void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
2115 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
2119void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
2120 OS <<
"\t.cv_fpo_data\t";
2121 ProcSym->
print(OS, MAI);
2125void MCAsmStreamer::emitIdent(
StringRef IdentString) {
2128 PrintQuotedString(IdentString, OS);
2132void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
2134 OS <<
"\t.cfi_sections ";
2143 OS <<
".debug_frame";
2156 OS <<
"\t.cfi_startproc";
2164 OS <<
"\t.cfi_endproc";
2168void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2174 if (std::optional<MCRegister> LLVMRegister =
2176 InstPrinter->printRegName(OS, *LLVMRegister);
2185 OS <<
"\t.cfi_def_cfa ";
2191void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset,
SMLoc Loc) {
2193 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2197void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2200 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2208 OS <<
"\t.cfi_escape ";
2210 size_t e =
Values.size() - 1;
2211 for (
size_t i = 0; i < e; ++i)
2223void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size,
SMLoc Loc) {
2226 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2235 OS <<
"\t.cfi_def_cfa_register ";
2242 OS <<
"\t.cfi_offset ";
2248void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2249 unsigned Encoding) {
2251 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2252 Sym->
print(OS, MAI);
2256void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2258 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2259 Sym->
print(OS, MAI);
2263void MCAsmStreamer::emitCFIRememberState(
SMLoc Loc) {
2265 OS <<
"\t.cfi_remember_state";
2269void MCAsmStreamer::emitCFIRestoreState(
SMLoc Loc) {
2271 OS <<
"\t.cfi_restore_state";
2277 OS <<
"\t.cfi_restore ";
2284 OS <<
"\t.cfi_same_value ";
2289void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2292 OS <<
"\t.cfi_rel_offset ";
2298void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment,
SMLoc Loc) {
2300 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2304void MCAsmStreamer::emitCFISignalFrame() {
2306 OS <<
"\t.cfi_signal_frame";
2312 OS <<
"\t.cfi_undefined ";
2317void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2320 OS <<
"\t.cfi_register ";
2321 EmitRegisterName(Register1);
2323 EmitRegisterName(Register2);
2327void MCAsmStreamer::emitCFILLVMRegisterPair(int64_t
Register, int64_t R1,
2328 int64_t R1Size, int64_t
R2,
2332 OS <<
"\t.cfi_llvm_register_pair ";
2335 EmitRegisterName(R1);
2336 OS <<
", " << R1Size <<
", ";
2337 EmitRegisterName(
R2);
2338 OS <<
", " << R2Size;
2342void MCAsmStreamer::emitCFILLVMVectorRegisters(
2347 OS <<
"\t.cfi_llvm_vector_registers ";
2349 for (
auto [
Reg, Lane,
Size] : VRs)
2350 OS <<
", " <<
Reg <<
", " << Lane <<
", " <<
Size;
2354void MCAsmStreamer::emitCFILLVMVectorOffset(int64_t
Register,
2355 int64_t RegisterSize,
2356 int64_t MaskRegister,
2357 int64_t MaskRegisterSize,
2362 OS <<
"\t.cfi_llvm_vector_offset ";
2364 OS <<
", " << RegisterSize <<
", ";
2365 EmitRegisterName(MaskRegister);
2366 OS <<
", " << MaskRegisterSize <<
", " <<
Offset;
2370void MCAsmStreamer::emitCFILLVMVectorRegisterMask(
2371 int64_t
Register, int64_t SpillRegister,
2372 int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister,
2373 int64_t MaskRegisterSizeInBits,
SMLoc Loc) {
2375 Register, SpillRegister, SpillRegisterLaneSizeInBits, MaskRegister,
2376 MaskRegisterSizeInBits,
Loc);
2378 OS <<
"\t.cfi_llvm_vector_register_mask ";
2381 EmitRegisterName(SpillRegister);
2382 OS <<
", " << SpillRegisterLaneSizeInBits <<
", ";
2383 EmitRegisterName(MaskRegister);
2384 OS <<
", " << MaskRegisterSizeInBits;
2388void MCAsmStreamer::emitCFIWindowSave(
SMLoc Loc) {
2390 OS <<
"\t.cfi_window_save";
2394void MCAsmStreamer::emitCFINegateRAState(
SMLoc Loc) {
2396 OS <<
"\t.cfi_negate_ra_state";
2400void MCAsmStreamer::emitCFINegateRAStateWithPC(
SMLoc Loc) {
2402 OS <<
"\t.cfi_negate_ra_state_with_pc";
2406void MCAsmStreamer::emitCFILLVMSetRAState(
unsigned State,
MCSymbol *PACSym,
2409 OS <<
"\t.cfi_set_ra_state " << State <<
", ";
2411 PACSym->
print(OS, MAI);
2417void MCAsmStreamer::emitCFILLVMSetRAState(
unsigned State, int64_t
Offset,
2420 OS <<
"\t.cfi_set_ra_state " << State <<
", " <<
Offset;
2424void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2426 OS <<
"\t.cfi_return_column ";
2433 OS <<
"\t.cfi_label " <<
Name;
2437void MCAsmStreamer::emitCFIBKeyFrame() {
2439 OS <<
"\t.cfi_b_key_frame";
2443void MCAsmStreamer::emitCFIMTETaggedFrame() {
2445 OS <<
"\t.cfi_mte_tagged_frame";
2449void MCAsmStreamer::emitCFINonHintPAuthFrame() {
2451 OS <<
"\t.cfi_non_hint_pauth_frame";
2455void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2458 OS <<
"\t.cfi_val_offset ";
2464void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2472void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2475 OS <<
"\t.seh_endproc";
2479void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2482 OS <<
"\t.seh_endfunclet";
2486void MCAsmStreamer::emitWinCFISplitChained(
SMLoc Loc) {
2489 OS <<
"\t.seh_splitchained";
2493void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2497 OS <<
"\t.seh_handler ";
2498 Sym->
print(OS, MAI);
2504 OS <<
", " << Marker <<
"unwind";
2506 OS <<
", " << Marker <<
"except";
2510void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2525 MCSection *XData = getAssociatedXDataSection(TextSec);
2526 switchSectionNoPrint(XData);
2528 OS <<
"\t.seh_handlerdata";
2535 OS <<
"\t.seh_pushreg ";
2536 InstPrinter->printRegName(OS,
Register);
2544 OS <<
"\t.seh_push2regs ";
2545 InstPrinter->printRegName(OS, Reg1);
2547 InstPrinter->printRegName(OS, Reg2);
2555 OS <<
"\t.seh_setframe ";
2556 InstPrinter->printRegName(OS,
Register);
2561void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2564 OS <<
"\t.seh_stackalloc " <<
Size;
2572 OS <<
"\t.seh_savereg ";
2573 InstPrinter->printRegName(OS,
Register);
2582 OS <<
"\t.seh_savexmm ";
2583 InstPrinter->printRegName(OS,
Register);
2588void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2591 OS <<
"\t.seh_pushframe";
2597void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2600 OS <<
"\t.seh_endprologue";
2604void MCAsmStreamer::emitWinCFIBeginEpilogue(
SMLoc Loc) {
2607 OS <<
"\t.seh_startepilogue";
2611void MCAsmStreamer::emitWinCFIEndEpilogue(
SMLoc Loc) {
2614 OS <<
"\t.seh_endepilogue";
2618void MCAsmStreamer::emitWinCFIUnwindV2Start(
SMLoc Loc) {
2621 OS <<
"\t.seh_unwindv2start";
2625void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version,
SMLoc Loc) {
2628 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2635 OS <<
"\t.cg_profile ";
2639 OS <<
", " <<
Count;
2643void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2645 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2649 MCSection *Sec = getCurrentSectionOnly();
2653 if (MAI->
isAIX() && CurFrag)
2659 addEncodingComment(Inst, STI);
2664 getCommentOS() <<
"\n";
2667 if(getTargetStreamer())
2668 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2670 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2673 if (Comments.
size() && Comments.
back() !=
'\n')
2674 getCommentOS() <<
"\n";
2684 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2689 for (
const auto &Site : InlineStack)
2690 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2693 FnSym->
print(OS, MAI);
2698void MCAsmStreamer::emitBundleAlignMode(
Align Alignment) {
2699 OS <<
"\t.bundle_align_mode " <<
Log2(Alignment);
2703void MCAsmStreamer::emitBundleLock(
bool AlignToEnd,
2705 OS <<
"\t.bundle_lock";
2707 OS <<
" align_to_end";
2712 OS <<
"\t.bundle_unlock";
2728void MCAsmStreamer::emitAddrsig() {
2733void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2734 OS <<
"\t.addrsig_sym ";
2735 Sym->
print(OS, MAI);
2743 String.consume_back(
"\n");
2748void MCAsmStreamer::finishImpl() {
2766 const auto &Tables =
getContext().getMCDwarfLineTables();
2767 if (!Tables.empty()) {
2768 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2769 if (
auto *Label = Tables.begin()->second.getLabel()) {
2770 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2788MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2789 const Twine &Comment) {
2797 return getContext().createTempSymbol(Prefix +
"_end");
2801void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2812 emitLabel(DebugLineSymTmp);
2816 unsigned LengthFieldSize =
2822 emitAssignment(StartSym, OuterSym);
2828void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2837 ".loc should not be generated together with raw data!");
2850 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2855void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2858 unsigned PointerSize) {
2860 ".loc/.file don't need raw data in debug line section!");
2863 AddComment(
"Set address to " +
Label->getName());
2864 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2865 emitULEB128IntValue(PointerSize + 1);
2866 emitIntValue(dwarf::DW_LNE_set_address, 1);
2867 emitSymbolValue(Label, PointerSize);
2871 AddComment(
"Start sequence");
2879 AddComment(
"End sequence");
2880 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2881 emitULEB128IntValue(1);
2882 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2887 AddComment(
"Advance line " +
Twine(LineDelta));
2888 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2889 emitSLEB128IntValue(LineDelta);
2890 emitIntValue(dwarf::DW_LNS_copy, 1);
2894 std::unique_ptr<formatted_raw_ostream> OS,
2895 std::unique_ptr<MCInstPrinter> IP,
2896 std::unique_ptr<MCCodeEmitter> CE,
2897 std::unique_ptr<MCAsmBackend> MAB) {
2898 return new MCAsmStreamer(Context, std::move(OS), std::move(IP), std::move(CE),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static unsigned getDwarfVersion(const MachineFunction &MF)
Resolve the DWARF version the way DwarfDebug does.
#define LLVM_LIKELY(EXPR)
dxil DXContainer Global Emitter
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
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
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
LFI-specific code for MC.
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static constexpr StringLiteral Filename
MachineRegisterInfo & MRI
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file defines the SmallString class.
StringRef getMnemonic(unsigned Opc)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Functions, function parameters, and return types can have attributes to indicate how they should be t...
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.
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
LLVM_ABI void addEncodingComment(const MCInst &Inst, const MCSubtargetInfo &STI)
Add a comment showing the encoding of an instruction.
std::unique_ptr< MCAssembler > Assembler
SmallString< 128 > CommentToEmit
MCAssembler & getAssembler()
raw_ostream & getCommentOS() override
Return a raw_ostream that comments can be written to.
raw_null_ostream NullStream
LLVM_ABI MCAsmBaseStreamer(MCContext &Context, std::unique_ptr< MCCodeEmitter > Emitter, std::unique_ptr< MCAsmBackend > AsmBackend)
raw_svector_ostream CommentStream
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 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
virtual bool usesCompInstByteOrder(const MCSubtargetInfo &STI) const
True if the instruction is stored in multiple halfwords, with the high-order half appearing first in ...
bool hasNoDeadStrip() const
bool hasIdentDirective() const
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
MCCodeEmitter & getEmitter() const
MCAsmBackend & getBackend() const
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
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.
dwarf::DwarfFormat getDwarfFormat() const
const MCAsmInfo & getAsmInfo() const
const Triple & getTargetTriple() 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)
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 emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void emitCFILLVMVectorOffset(int64_t Register, int64_t RegisterSizeInBits, int64_t MaskRegister, int64_t MaskRegisterSizeInBits, int64_t Offset, SMLoc Loc={})
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
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 emitCFIBKeyFrame()
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
virtual bool popSection()
Restore the current and previous section from the section stack.
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 emitCFINegateRAStateWithPC(SMLoc Loc={})
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual void emitCFIReturnColumn(int64_t Register)
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 emitCFILLVMRegisterPair(int64_t Register, int64_t R1, int64_t R1SizeInBits, int64_t R2, int64_t R2SizeInBits, SMLoc Loc={})
virtual void emitWinCFIUnwindV2Start(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFINegateRAState(SMLoc Loc={})
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
MCContext & getContext() const
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void emitCFIMTETaggedFrame()
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitCFIRememberState(SMLoc Loc)
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.
MCStreamer(MCContext &Ctx)
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
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 emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
virtual void emitWinCFIPush2Regs(MCRegister Reg1, MCRegister Reg2, SMLoc Loc=SMLoc())
virtual void emitCFILLVMVectorRegisterMask(int64_t Register, int64_t SpillRegister, int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister, int64_t MaskRegisterSizeInBits, SMLoc Loc={})
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitCFIRestoreState(SMLoc Loc)
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 emitWinCFISplitChained(SMLoc Loc=SMLoc())
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
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 emitCFILLVMVectorRegisters(int64_t Register, ArrayRef< MCCFIInstruction::VectorRegisterWithLane > VRs, SMLoc Loc={})
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 emitCFINonHintPAuthFrame()
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
virtual void emitCFILLVMSetRAState(unsigned State, MCSymbol *PACSym, 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.
DwarfDirectory MCUseDwarfDirectory
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 is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
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
Check if the string is empty.
char back() const
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
Get the string size.
char front() const
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.
bool isRISCV() const
Tests whether the target is RISC-V (32- and 64-bit).
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.
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.
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 Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
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)
@ Emitted
Assigned address, still materializing.
uint32_t read32be(const void *P)
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.
RelativeUniformCounterPtr Values
@ Debug
Register 'use' is for debugging purpose.
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
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
MCLOHDirective::LOHArgs MCLOHArgs
LLVM_ABI void emitLFINoteSection(MCStreamer &Streamer, MCContext &Ctx)
SmallVector< InlineSite, 8 > MCPseudoProbeInlineStack
@ 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)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
ArrayRef(const T &OneElt) -> ArrayRef< T >
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool isPrint(char C)
Checks whether character C is printable.
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.
std::pair< MCSection *, uint32_t > MCSectionSubPair
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
@ End
Run the machine verifier once, at the end of the pipeline.
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
@ MCSA_Memtag
.memtag (ELF)
@ MCSA_Protected
.protected (ELF)
@ MCSA_OSLinkage
symbol uses OS linkage (GOFF)
@ 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_XPLinkage
symbol uses XP linkage (GOFF)
@ 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.
constexpr 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