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!");
86 FixupMap[Index] = 1 +
I;
93 for (
unsigned I = 0, E = Code.size();
I != E; ++
I) {
98 uint8_t MapEntry = FixupMap[
I * 8 + 0];
99 for (
unsigned J = 1; J != 8; ++J) {
100 if (FixupMap[
I * 8 + J] == MapEntry)
107 if (MapEntry !=
uint8_t(~0U)) {
114 <<
char(
'A' + MapEntry - 1) <<
'\'';
116 OS <<
char(
'A' + MapEntry - 1);
121 for (
unsigned J = 8; J--;) {
122 unsigned Bit = (Code[
I] >> J) & 1;
129 FixupBit =
I * 8 + J;
131 FixupBit =
I * 8 + (7 - J);
133 if (
uint8_t MapEntry = FixupMap[FixupBit]) {
134 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
135 OS <<
char(
'A' + MapEntry - 1);
143 for (
unsigned I = 0, E = Fixups.size();
I != E; ++
I) {
145 OS <<
" fixup " <<
char(
'A' +
I) <<
" - "
146 <<
"offset: " <<
F.getOffset() <<
", value: ";
148 auto Kind =
F.getKind();
150 OS <<
", relocation type: " << Kind;
155 OS <<
"FK_PCRel_" << (Info.TargetSize / 8);
166 std::unique_ptr<formatted_raw_ostream> OSOwner;
169 std::unique_ptr<MCInstPrinter> InstPrinter;
173 bool EmittedSectionDirective =
false;
175 bool IsVerboseAsm =
false;
176 bool ShowInst =
false;
177 bool UseDwarfDirectory =
false;
179 void EmitRegisterName(int64_t
Register);
181 void printDwarfFileDirective(
unsigned FileNo,
StringRef Directory,
183 std::optional<MD5::MD5Result> Checksum,
184 std::optional<StringRef> Source,
185 bool UseDwarfDirectory,
189 void emitBundleAlignMode(
Align Alignment)
override;
190 void emitBundleLock(
bool AlignToEnd,
const MCSubtargetInfo &STI)
override;
194 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
195 unsigned Discriminator);
199 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
200 unsigned Column,
unsigned Flags,
201 unsigned Isa,
unsigned Discriminator,
205 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
206 std::unique_ptr<MCInstPrinter>
printer,
207 std::unique_ptr<MCCodeEmitter> emitter,
208 std::unique_ptr<MCAsmBackend> asmbackend)
210 OSOwner(
std::
move(os)), OS(*OSOwner), MAI(&Context.getAsmInfo()),
213 if (Assembler->getBackendPtr())
214 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
216 Context.setUseNamesOnTempLabels(
true);
221 InstPrinter->setCommentStream(CommentStream);
225 UseDwarfDirectory =
false;
228 UseDwarfDirectory =
true;
232 Context.getAsmInfo().enableDwarfFileDirectoryDefault();
237 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
239 inline void EmitEOL() {
241 emitExplicitComments();
247 EmitCommentsAndEOL();
250 void emitSyntaxDirective(StringRef Syntax, StringRef
Options)
override;
252 void EmitCommentsAndEOL();
255 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
258 bool hasRawTextSupport()
const override {
return true; }
263 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
265 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
267 void addExplicitComment(
const Twine &
T)
override;
268 void emitExplicitComments()
override;
271 void addBlankLine()
override { EmitEOL(); }
276 void switchSection(MCSection *Section, uint32_t Subsection)
override;
277 bool popSection()
override;
279 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
280 bool KeepOriginalSym)
override;
284 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
287 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
288 assert((Bits != 0 || Ptr ==
nullptr) &&
289 "Invalid char pointer for instruction with no mnemonic");
293 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
295 void emitSubsectionsViaSymbols()
override;
296 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
299 unsigned Update, VersionTuple SDKVersion)
override;
300 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
301 unsigned Update, VersionTuple SDKVersion)
override;
302 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
303 unsigned Minor,
unsigned Update,
304 VersionTuple SDKVersion)
override;
305 void emitTargetTriple(StringRef TargetTriple)
override;
307 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
308 void emitConditionalAssignment(MCSymbol *Symbol,
309 const MCExpr *
Value)
override;
310 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
313 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
314 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
315 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
316 void emitCOFFSymbolType(
int Type)
override;
317 void endCOFFSymbolDef()
override;
318 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
319 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
320 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
321 void emitCOFFSecRel32(MCSymbol
const *Symbol,
uint64_t Offset)
override;
322 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
323 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
324 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
325 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
uint64_t Size,
326 MCSymbol *CsectSym, Align Alignment)
override;
327 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
330 void emitXCOFFRenameDirective(
const MCSymbol *Name,
331 StringRef Rename)
override;
333 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
335 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
336 const MCSymbol *
Trap,
337 unsigned Lang,
unsigned Reason,
338 unsigned FunctionSize,
bool hasDebug)
override;
339 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
341 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
343 Align ByteAlignment)
override;
350 void emitLocalCommonSymbol(MCSymbol *Symbol,
uint64_t Size,
351 Align ByteAlignment)
override;
353 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
355 SMLoc Loc = SMLoc())
override;
357 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
uint64_t Size,
358 Align ByteAlignment =
Align(1))
override;
360 void emitBinaryData(StringRef
Data)
override;
362 void emitBytes(StringRef
Data)
override;
364 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
365 SMLoc Loc = SMLoc())
override;
370 void emitULEB128Value(
const MCExpr *
Value)
override;
372 void emitSLEB128Value(
const MCExpr *
Value)
override;
374 void emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
375 SMLoc Loc = SMLoc())
override;
377 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
378 SMLoc Loc = SMLoc())
override;
380 void emitAlignmentDirective(
uint64_t ByteAlignment,
381 std::optional<int64_t>
Value,
unsigned ValueSize,
382 unsigned MaxBytesToEmit);
384 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
386 unsigned MaxBytesToEmit = 0)
override;
388 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo &STI,
389 unsigned MaxBytesToEmit = 0)
override;
390 void emitPrefAlign(Align Alignment,
const MCSymbol &
End,
bool EmitNops,
391 uint8_t Fill,
const MCSubtargetInfo &STI)
override;
393 void emitValueToOffset(
const MCExpr *
Offset,
397 void emitFileDirective(StringRef
Filename)
override;
398 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
399 StringRef TimeStamp, StringRef Description)
override;
400 Expected<unsigned> tryEmitDwarfFileDirective(
401 unsigned FileNo, StringRef Directory, StringRef
Filename,
402 std::optional<MD5::MD5Result> Checksum = std::nullopt,
403 std::optional<StringRef> Source = std::nullopt,
404 unsigned CUID = 0)
override;
405 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
406 std::optional<MD5::MD5Result> Checksum,
407 std::optional<StringRef> Source,
408 unsigned CUID = 0)
override;
409 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
410 unsigned Flags,
unsigned Isa,
411 unsigned Discriminator, StringRef FileName,
412 StringRef Location = {})
override;
413 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
417 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
418 unsigned Column,
unsigned FileIA,
419 unsigned LineIA,
unsigned ColIA,
420 const MCSymbol *Sym,
unsigned Flags,
421 unsigned Isa,
unsigned Discriminator,
423 StringRef Comment = {})
override;
425 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
427 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
428 ArrayRef<uint8_t> Checksum,
429 unsigned ChecksumKind)
override;
430 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
431 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
432 unsigned IAFile,
unsigned IALine,
433 unsigned IACol, SMLoc Loc)
override;
434 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
435 unsigned Column,
bool PrologueEnd,
bool IsStmt,
436 StringRef FileName, SMLoc Loc)
override;
437 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
438 const MCSymbol *FnEnd)
override;
439 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
440 unsigned SourceFileId,
441 unsigned SourceLineNum,
442 const MCSymbol *FnStartSym,
443 const MCSymbol *FnEndSym)
override;
445 void PrintCVDefRangePrefix(
446 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
448 void emitCVDefRangeDirective(
449 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
450 codeview::DefRangeRegisterRelHeader DRHdr)
override;
452 void emitCVDefRangeDirective(
453 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
454 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
456 void emitCVDefRangeDirective(
457 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
458 codeview::DefRangeRegisterHeader DRHdr)
override;
460 void emitCVDefRangeDirective(
461 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
462 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
464 void emitCVDefRangeDirective(
465 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
466 codeview::DefRangeRegisterRelIndirHeader DRHdr)
override;
468 void emitCVStringTableDirective()
override;
469 void emitCVFileChecksumsDirective()
override;
470 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
471 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
473 void emitIdent(StringRef IdentString)
override;
474 void emitCFIBKeyFrame()
override;
475 void emitCFIMTETaggedFrame()
override;
476 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
477 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
478 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
479 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
482 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
483 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
484 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
485 void emitCFIRememberState(SMLoc Loc)
override;
486 void emitCFIRestoreState(SMLoc Loc)
override;
487 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
488 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
489 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
490 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
491 void emitCFIEscape(StringRef
Values, SMLoc Loc)
override;
492 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
493 void emitCFISignalFrame()
override;
494 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
495 void emitCFIRegister(int64_t Register1, int64_t Register2,
497 void emitCFIWindowSave(SMLoc Loc)
override;
498 void emitCFINegateRAState(SMLoc Loc)
override;
499 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
500 void emitCFILLVMSetRAState(
unsigned State, MCSymbol *PACSym,
502 void emitCFILLVMSetRAState(
unsigned State, int64_t
Offset,
504 void emitCFIReturnColumn(int64_t
Register)
override;
505 void emitCFILLVMRegisterPair(int64_t
Register, int64_t R1, int64_t R1Size,
506 int64_t
R2, int64_t R2Size, SMLoc Loc)
override;
507 void emitCFILLVMVectorRegisters(
510 void emitCFILLVMVectorOffset(int64_t
Register, int64_t RegisterSize,
511 int64_t MaskRegister, int64_t MaskRegisterSize,
512 int64_t
Offset, SMLoc Loc)
override;
513 void emitCFILLVMVectorRegisterMask(int64_t
Register, int64_t SpillRegister,
514 int64_t SpillRegisterLaneSizeInBits,
515 int64_t MaskRegister,
516 int64_t MaskRegisterSizeInBits,
519 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
520 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
522 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
523 void emitWinCFIEndProc(SMLoc Loc)
override;
524 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
525 void emitWinCFISplitChained(SMLoc Loc)
override;
526 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
527 void emitWinCFIPush2Regs(MCRegister Reg1, MCRegister Reg2,
531 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
536 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
537 void emitWinCFIEndProlog(SMLoc Loc)
override;
538 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
539 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
540 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
541 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
543 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
545 void emitWinEHHandlerData(SMLoc Loc)
override;
547 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
550 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
555 MCSymbol *FnSym)
override;
557 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
558 const MCExpr *Expr, SMLoc Loc)
override;
560 void emitAddrsig()
override;
561 void emitAddrsigSym(
const MCSymbol *Sym)
override;
566 void emitRawTextImpl(StringRef
String)
override;
568 void finishImpl()
override;
570 void emitDwarfUnitLength(
uint64_t Length,
const Twine &Comment)
override;
572 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
573 const Twine &Comment)
override;
575 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
577 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
578 MCSymbol *EndLabel =
nullptr)
override;
580 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
581 const MCSymbol *Label,
582 unsigned PointerSize)
override;
587void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
588 if (!IsVerboseAsm)
return;
590 T.toVector(CommentToEmit);
593 CommentToEmit.push_back(
'\n');
596void MCAsmStreamer::EmitCommentsAndEOL() {
597 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
605 "Comment array not newline terminated");
609 size_t Position = Comments.
find(
'\n');
612 Comments = Comments.
substr(Position+1);
613 }
while (!Comments.
empty());
615 CommentToEmit.clear();
619 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
620 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
623void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
630void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
635 ExplicitCommentToEmit.
append(
"\t");
640 size_t p = 2, len = c.
size() - 2;
644 ExplicitCommentToEmit.
append(
"\t");
649 ExplicitCommentToEmit.
append(
"\n");
653 ExplicitCommentToEmit.
append(
"\t");
655 }
else if (c.
front() ==
'#') {
657 ExplicitCommentToEmit.
append(
"\t");
661 assert(
false &&
"Unexpected Assembly Comment");
663 if (c.
back() ==
'\n')
664 emitExplicitComments();
667void MCAsmStreamer::emitExplicitComments() {
668 StringRef Comments = ExplicitCommentToEmit;
669 if (!Comments.
empty())
671 ExplicitCommentToEmit.
clear();
674void MCAsmStreamer::switchSection(
MCSection *Section, uint32_t Subsection) {
676 if (!EmittedSectionDirective ||
678 EmittedSectionDirective =
true;
680 TS->changeSection(Cur.first, Section, Subsection, OS);
689bool MCAsmStreamer::popSection() {
692 auto [Sec, Subsec] = getCurrentSection();
698void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
700 bool KeepOriginalSym) {
702 OriginalSym->
print(OS, MAI);
704 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
714 if (!
Symbol->isVariable() &&
729 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
730 assert(str !=
"" &&
"Invalid LOH name");
744void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
745 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
748void MCAsmStreamer::emitSubsectionsViaSymbols() {
749 OS <<
".subsections_via_symbols\n";
753 assert(!
Options.empty() &&
"At least one option is required!");
754 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
756 OS <<
", " <<
'"' << Opt <<
'"';
785 if (SDKVersion.
empty())
787 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
788 if (
auto Minor = SDKVersion.
getMinor()) {
789 OS <<
", " << *Minor;
791 OS <<
", " << *Subminor;
797 unsigned Minor,
unsigned Update,
801 OS <<
", " << Update;
808#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
810 case MachO::PLATFORM_##platform: \
812#include "llvm/BinaryFormat/MachO.def"
817void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
818 unsigned Minor,
unsigned Update,
821 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
823 OS <<
", " << Update;
828void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
829 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
831 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
834void MCAsmStreamer::emitTargetTriple(
StringRef TargetTriple) {
835 OS <<
"\t.target_triple \"" << TargetTriple <<
'"';
844 OS << (UseSet ?
", " :
" = ");
851void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
853 OS <<
".lto_set_conditional ";
860void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
862 Alias->
print(OS, MAI);
868bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
885 default:
return false;
908 OS <<
"\t.no_dead_strip\t";
913 OS <<
"\t.private_extern\t";
922 OS <<
"\t.weak_definition\t";
939 OS <<
"\t.weak_anti_dep\t";
949void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
950 OS <<
".desc" <<
' ';
952 OS <<
',' << DescValue;
957 OS <<
"\t." << Syntax <<
"_syntax";
963void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
970void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
975void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
976 OS <<
"\t.type\t" <<
Type <<
';';
980void MCAsmStreamer::endCOFFSymbolDef() {
985void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
986 OS <<
"\t.safeseh\t";
991void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
997void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
1004 OS <<
"\t.secrel32\t";
1011void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
1021void MCAsmStreamer::emitCOFFSecNumber(
MCSymbol const *Symbol) {
1022 OS <<
"\t.secnum\t";
1027void MCAsmStreamer::emitCOFFSecOffset(
MCSymbol const *Symbol) {
1028 OS <<
"\t.secoffset\t";
1036void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
1041 "We only support writing log base-2 alignment format with XCOFF.");
1044 LabelSym->
print(OS, MAI);
1045 OS <<
',' <<
Size <<
',';
1046 CsectSym->
print(OS, MAI);
1047 OS <<
',' <<
Log2(Alignment);
1054 if (XSym->hasRename())
1055 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1058void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
1069 OS <<
"\t.extern\t";
1072 OS <<
"\t.lglobl\t";
1080 switch (Visibility) {
1100 if (Sym.hasRename())
1101 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
1104void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
1106 OS <<
"\t.rename\t";
1107 Name->print(OS, MAI);
1108 const char DQ =
'"';
1110 for (
char C : Rename) {
1120void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
1126void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
1130 unsigned FunctionSize,
1132 OS <<
"\t.except\t";
1134 OS <<
", " << Lang <<
", " << Reason;
1139 const char InfoDirective[] =
"\t.info ";
1140 const char *Separator =
", ";
1141 constexpr int WordSize =
sizeof(uint32_t);
1144 OS << InfoDirective;
1145 PrintQuotedString(Name, OS);
1148 size_t MetadataSize =
Metadata.size();
1151 OS <<
format_hex(MetadataSize, 10) << Separator;
1154 if (MetadataSize == 0) {
1164 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1165 uint32_t PaddingSize = PaddedSize - MetadataSize;
1172 constexpr int WordsPerDirective = 5;
1175 int WordsBeforeNextDirective = 0;
1176 auto PrintWord = [&](
const uint8_t *WordPtr) {
1177 if (WordsBeforeNextDirective-- == 0) {
1179 OS << InfoDirective;
1180 WordsBeforeNextDirective = WordsPerDirective;
1188 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1189 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1194 assert(PaddedSize - Index == WordSize);
1195 std::array<uint8_t, WordSize> LastWord = {0};
1196 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1197 PrintWord(LastWord.data());
1212 Align ByteAlignment) {
1220 OS <<
',' <<
Log2(ByteAlignment);
1227 if (XSym && XSym->hasRename())
1228 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1238 if (ByteAlign > 1) {
1243 OS <<
',' << ByteAlign.
value();
1246 OS <<
',' <<
Log2(ByteAlign);
1263 ".zerofill is a Mach-O specific directive");
1273 OS <<
',' <<
Log2(ByteAlignment);
1288 ".zerofill is a Mach-O specific directive");
1297 if (ByteAlignment > 1)
1298 OS <<
", " <<
Log2(ByteAlignment);
1304 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1305 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1316 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1317 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1323 const auto printOneCharacterFor = [printCharacterInOctal](
1324 auto printOnePrintingCharacter) {
1325 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1327 printOnePrintingCharacter(
static_cast<char>(
C));
1330 printCharacterInOctal(
C);
1333 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1334 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1335 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1336 printOneCharacter(
C);
1339 printOneCharacter(*(EndPtr - 1));
1343 printCharacterList(printCharacterInOctal);
1346 printCharacterList(printOneCharacterFor([&OS](
char C) {
1347 const char AsmCharLitBuf[2] = {
'\'',
C};
1348 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1359 for (
unsigned char C :
Data) {
1366 for (
unsigned char C :
Data) {
1367 if (
C ==
'"' ||
C ==
'\\') {
1368 OS <<
'\\' << (char)
C;
1407 assert(getCurrentSectionOnly() &&
1408 "Cannot emit contents before setting section!");
1409 if (
Data.empty())
return;
1416 if (
Data.back() == 0) {
1417 OS <<
"\t.string\t";
1422 PrintQuotedString(
Data, OS);
1442 PrintQuotedString(
Data, OS);
1447 if (
Data.size() != 1 && emitAsString(
Data))
1453 TS->emitRawBytes(
Data);
1457 for (
const unsigned char C :
Data.bytes()) {
1465 const size_t Cols = 4;
1466 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1467 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1470 for (; J < EJ - 1; ++J)
1471 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1485void MCAsmStreamer::emitIntValueInHexWithPadding(
uint64_t Value,
1493 assert(getCurrentSectionOnly() &&
1494 "Cannot emit contents before setting section!");
1506 if (!
Value->evaluateAsAbsolute(IntValue))
1521 unsigned ByteOffset =
1522 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1523 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1527 uint64_t Shift = 64 - EmissionSize * 8;
1529 std::numeric_limits<unsigned long long>::digits) &&
1530 "undefined behavior");
1531 ValueToEmit &= ~0ULL >> Shift;
1532 emitIntValue(ValueToEmit, EmissionSize);
1541 TS->emitValue(
Value);
1548void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1550 if (
Value->evaluateAsAbsolute(IntValue)) {
1551 emitULEB128IntValue(IntValue);
1554 OS <<
"\t.uleb128 ";
1559void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1561 if (
Value->evaluateAsAbsolute(IntValue)) {
1562 emitSLEB128IntValue(IntValue);
1565 OS <<
"\t.sleb128 ";
1570void MCAsmStreamer::emitFill(
const MCExpr &NumBytes,
uint64_t FillValue,
1572 int64_t IntNumBytes;
1573 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1574 if (IsAbsolute && IntNumBytes == 0)
1578 if (!MAI->
isAIX() || FillValue == 0) {
1580 OS << ZeroDirective;
1583 OS <<
',' << (int)FillValue;
1588 "Cannot emit non-absolute expression lengths of fill.");
1589 for (
int i = 0; i < IntNumBytes; ++i) {
1600void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1605 OS <<
", " <<
Size <<
", 0x";
1610void MCAsmStreamer::emitAlignmentDirective(
uint64_t ByteAlignment,
1611 std::optional<int64_t>
Value,
1613 unsigned MaxBytesToEmit) {
1627 switch (ValueSize) {
1631 OS <<
"\t.p2align\t";
1645 if (
Value.has_value() || MaxBytesToEmit) {
1646 if (
Value.has_value()) {
1654 OS <<
", " << MaxBytesToEmit;
1662 switch (ValueSize) {
1664 case 1: OS <<
".balign";
break;
1665 case 2: OS <<
".balignw";
break;
1666 case 4: OS <<
".balignl";
break;
1671 if (
Value.has_value())
1673 else if (MaxBytesToEmit)
1676 OS <<
", " << MaxBytesToEmit;
1680void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t Fill,
1682 unsigned MaxBytesToEmit) {
1683 emitAlignmentDirective(
Alignment.value(), Fill, FillLen, MaxBytesToEmit);
1686void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1688 unsigned MaxBytesToEmit) {
1694 emitAlignmentDirective(
Alignment.value(), std::nullopt, 1, MaxBytesToEmit);
1698 bool EmitNops, uint8_t Fill,
1700 OS <<
"\t.prefalign\t" <<
Log2(Alignment) <<
", ";
1705 OS <<
", " <<
static_cast<unsigned>(Fill);
1709void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1710 unsigned char Value,
1715 OS <<
", " << (unsigned)
Value;
1733 bool useTimeStamp = !TimeStamp.
empty();
1734 bool useCompilerVersion = !CompilerVersion.
empty();
1735 bool useDescription = !Description.
empty();
1736 if (useTimeStamp || useCompilerVersion || useDescription) {
1739 PrintQuotedString(TimeStamp, OS);
1740 if (useCompilerVersion || useDescription) {
1742 if (useCompilerVersion)
1743 PrintQuotedString(CompilerVersion, OS);
1744 if (useDescription) {
1746 PrintQuotedString(Description, OS);
1753void MCAsmStreamer::printDwarfFileDirective(
1755 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1759 if (!UseDwarfDirectory && !Directory.
empty()) {
1763 FullPathName = Directory;
1770 OS <<
"\t.file\t" << FileNo <<
' ';
1771 if (!Directory.
empty()) {
1772 PrintQuotedString(Directory, OS);
1777 OS <<
" md5 0x" << Checksum->digest();
1780 PrintQuotedString(*Source, OS);
1786 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1788 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1791 unsigned NumFiles =
Table.getMCDwarfFiles().size();
1797 FileNo = FileNoOrErr.
get();
1801 if (NumFiles ==
Table.getMCDwarfFiles().size() || MAI->
isAIX())
1806 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1807 UseDwarfDirectory, OS1);
1810 TS->emitDwarfFileDirective(OS1.str());
1812 emitRawText(OS1.str());
1817void MCAsmStreamer::emitDwarfFile0Directive(
1819 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1835 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1836 UseDwarfDirectory, OS1);
1839 TS->emitDwarfFileDirective(OS1.str());
1841 emitRawText(OS1.str());
1845void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1846 unsigned Discriminator) {
1851 OS <<
" basic_block";
1853 OS <<
" prologue_end";
1855 OS <<
" epilogue_begin";
1857 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1864 OS <<
" isa " << Isa;
1870void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1871 unsigned Column,
unsigned Flags,
1873 unsigned Discriminator,
1877 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1884 OS << FileName <<
':' <<
Line <<
':' << Column;
1892 Discriminator, FileName, Comment);
1895void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1896 unsigned Column,
unsigned Flags,
1897 unsigned Isa,
unsigned Discriminator,
1907 Discriminator, FileName, Comment);
1912 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1915 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1921void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1922 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1923 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1924 unsigned Isa,
unsigned Discriminator,
StringRef FileName,
1927 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1928 OS <<
", function_name " << *Sym;
1929 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1932 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1938 OS <<
".loc_label\t" <<
Name;
1942MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1950 unsigned ChecksumKind) {
1955 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1958 if (!ChecksumKind) {
1964 PrintQuotedString(
toHex(Checksum), OS);
1971bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1972 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1976bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1979 unsigned IALine,
unsigned IACol,
1981 OS <<
"\t.cv_inline_site_id " <<
FunctionId <<
" within " << IAFunc
1982 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1984 IALine, IACol,
Loc);
1987void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1988 unsigned Line,
unsigned Column,
1989 bool PrologueEnd,
bool IsStmt,
1995 OS <<
"\t.cv_loc\t" <<
FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1998 OS <<
" prologue_end";
2011void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
2014 OS <<
"\t.cv_linetable\t" <<
FunctionId <<
", ";
2015 FnStart->
print(OS, MAI);
2017 FnEnd->
print(OS, MAI);
2022void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
2023 unsigned SourceFileId,
2024 unsigned SourceLineNum,
2027 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
2028 <<
' ' << SourceLineNum <<
' ';
2029 FnStartSym->
print(OS, MAI);
2031 FnEndSym->
print(OS, MAI);
2034 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
2037void MCAsmStreamer::PrintCVDefRangePrefix(
2038 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
2039 OS <<
"\t.cv_def_range\t";
2040 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
2048void MCAsmStreamer::emitCVDefRangeDirective(
2049 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2051 PrintCVDefRangePrefix(Ranges);
2052 OS <<
", reg_rel, ";
2058void MCAsmStreamer::emitCVDefRangeDirective(
2059 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2061 PrintCVDefRangePrefix(Ranges);
2062 OS <<
", subfield_reg, ";
2067void MCAsmStreamer::emitCVDefRangeDirective(
2068 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2070 PrintCVDefRangePrefix(Ranges);
2076void MCAsmStreamer::emitCVDefRangeDirective(
2077 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2079 PrintCVDefRangePrefix(Ranges);
2080 OS <<
", frame_ptr_rel, ";
2085void MCAsmStreamer::emitCVDefRangeDirective(
2086 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2088 PrintCVDefRangePrefix(Ranges);
2089 OS <<
", reg_rel_indir, ";
2095void MCAsmStreamer::emitCVStringTableDirective() {
2096 OS <<
"\t.cv_stringtable";
2100void MCAsmStreamer::emitCVFileChecksumsDirective() {
2101 OS <<
"\t.cv_filechecksums";
2105void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
2106 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
2110void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
2111 OS <<
"\t.cv_fpo_data\t";
2112 ProcSym->
print(OS, MAI);
2116void MCAsmStreamer::emitIdent(
StringRef IdentString) {
2119 PrintQuotedString(IdentString, OS);
2123void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
2125 OS <<
"\t.cfi_sections ";
2134 OS <<
".debug_frame";
2147 OS <<
"\t.cfi_startproc";
2155 OS <<
"\t.cfi_endproc";
2159void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2165 if (std::optional<MCRegister> LLVMRegister =
2167 InstPrinter->printRegName(OS, *LLVMRegister);
2176 OS <<
"\t.cfi_def_cfa ";
2182void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset,
SMLoc Loc) {
2184 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2188void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2191 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2199 OS <<
"\t.cfi_escape ";
2201 size_t e =
Values.size() - 1;
2202 for (
size_t i = 0; i < e; ++i)
2214void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size,
SMLoc Loc) {
2217 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2226 OS <<
"\t.cfi_def_cfa_register ";
2233 OS <<
"\t.cfi_offset ";
2239void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2240 unsigned Encoding) {
2242 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2243 Sym->
print(OS, MAI);
2247void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2249 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2250 Sym->
print(OS, MAI);
2254void MCAsmStreamer::emitCFIRememberState(
SMLoc Loc) {
2256 OS <<
"\t.cfi_remember_state";
2260void MCAsmStreamer::emitCFIRestoreState(
SMLoc Loc) {
2262 OS <<
"\t.cfi_restore_state";
2268 OS <<
"\t.cfi_restore ";
2275 OS <<
"\t.cfi_same_value ";
2280void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2283 OS <<
"\t.cfi_rel_offset ";
2289void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment,
SMLoc Loc) {
2291 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2295void MCAsmStreamer::emitCFISignalFrame() {
2297 OS <<
"\t.cfi_signal_frame";
2303 OS <<
"\t.cfi_undefined ";
2308void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2311 OS <<
"\t.cfi_register ";
2312 EmitRegisterName(Register1);
2314 EmitRegisterName(Register2);
2318void MCAsmStreamer::emitCFILLVMRegisterPair(int64_t
Register, int64_t R1,
2319 int64_t R1Size, int64_t
R2,
2323 OS <<
"\t.cfi_llvm_register_pair ";
2326 EmitRegisterName(R1);
2327 OS <<
", " << R1Size <<
", ";
2328 EmitRegisterName(
R2);
2329 OS <<
", " << R2Size;
2333void MCAsmStreamer::emitCFILLVMVectorRegisters(
2338 OS <<
"\t.cfi_llvm_vector_registers ";
2340 for (
auto [
Reg, Lane,
Size] : VRs)
2341 OS <<
", " <<
Reg <<
", " << Lane <<
", " <<
Size;
2345void MCAsmStreamer::emitCFILLVMVectorOffset(int64_t
Register,
2346 int64_t RegisterSize,
2347 int64_t MaskRegister,
2348 int64_t MaskRegisterSize,
2353 OS <<
"\t.cfi_llvm_vector_offset ";
2355 OS <<
", " << RegisterSize <<
", ";
2356 EmitRegisterName(MaskRegister);
2357 OS <<
", " << MaskRegisterSize <<
", " <<
Offset;
2361void MCAsmStreamer::emitCFILLVMVectorRegisterMask(
2362 int64_t
Register, int64_t SpillRegister,
2363 int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister,
2364 int64_t MaskRegisterSizeInBits,
SMLoc Loc) {
2366 Register, SpillRegister, SpillRegisterLaneSizeInBits, MaskRegister,
2367 MaskRegisterSizeInBits,
Loc);
2369 OS <<
"\t.cfi_llvm_vector_register_mask ";
2372 EmitRegisterName(SpillRegister);
2373 OS <<
", " << SpillRegisterLaneSizeInBits <<
", ";
2374 EmitRegisterName(MaskRegister);
2375 OS <<
", " << MaskRegisterSizeInBits;
2379void MCAsmStreamer::emitCFIWindowSave(
SMLoc Loc) {
2381 OS <<
"\t.cfi_window_save";
2385void MCAsmStreamer::emitCFINegateRAState(
SMLoc Loc) {
2387 OS <<
"\t.cfi_negate_ra_state";
2391void MCAsmStreamer::emitCFINegateRAStateWithPC(
SMLoc Loc) {
2393 OS <<
"\t.cfi_negate_ra_state_with_pc";
2397void MCAsmStreamer::emitCFILLVMSetRAState(
unsigned State,
MCSymbol *PACSym,
2400 OS <<
"\t.cfi_set_ra_state " << State <<
", ";
2402 PACSym->
print(OS, MAI);
2408void MCAsmStreamer::emitCFILLVMSetRAState(
unsigned State, int64_t
Offset,
2411 OS <<
"\t.cfi_set_ra_state " << State <<
", " <<
Offset;
2415void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2417 OS <<
"\t.cfi_return_column ";
2424 OS <<
"\t.cfi_label " <<
Name;
2428void MCAsmStreamer::emitCFIBKeyFrame() {
2430 OS <<
"\t.cfi_b_key_frame";
2434void MCAsmStreamer::emitCFIMTETaggedFrame() {
2436 OS <<
"\t.cfi_mte_tagged_frame";
2440void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2443 OS <<
"\t.cfi_val_offset ";
2449void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2457void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2460 OS <<
"\t.seh_endproc";
2464void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2467 OS <<
"\t.seh_endfunclet";
2471void MCAsmStreamer::emitWinCFISplitChained(
SMLoc Loc) {
2474 OS <<
"\t.seh_splitchained";
2478void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2482 OS <<
"\t.seh_handler ";
2483 Sym->
print(OS, MAI);
2489 OS <<
", " << Marker <<
"unwind";
2491 OS <<
", " << Marker <<
"except";
2495void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2510 MCSection *XData = getAssociatedXDataSection(TextSec);
2511 switchSectionNoPrint(XData);
2513 OS <<
"\t.seh_handlerdata";
2520 OS <<
"\t.seh_pushreg ";
2521 InstPrinter->printRegName(OS,
Register);
2529 OS <<
"\t.seh_push2regs ";
2530 InstPrinter->printRegName(OS, Reg1);
2532 InstPrinter->printRegName(OS, Reg2);
2540 OS <<
"\t.seh_setframe ";
2541 InstPrinter->printRegName(OS,
Register);
2546void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2549 OS <<
"\t.seh_stackalloc " <<
Size;
2557 OS <<
"\t.seh_savereg ";
2558 InstPrinter->printRegName(OS,
Register);
2567 OS <<
"\t.seh_savexmm ";
2568 InstPrinter->printRegName(OS,
Register);
2573void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2576 OS <<
"\t.seh_pushframe";
2582void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2585 OS <<
"\t.seh_endprologue";
2589void MCAsmStreamer::emitWinCFIBeginEpilogue(
SMLoc Loc) {
2592 OS <<
"\t.seh_startepilogue";
2596void MCAsmStreamer::emitWinCFIEndEpilogue(
SMLoc Loc) {
2599 OS <<
"\t.seh_endepilogue";
2603void MCAsmStreamer::emitWinCFIUnwindV2Start(
SMLoc Loc) {
2606 OS <<
"\t.seh_unwindv2start";
2610void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version,
SMLoc Loc) {
2613 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2620 OS <<
"\t.cg_profile ";
2624 OS <<
", " <<
Count;
2628void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2630 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2634 MCSection *Sec = getCurrentSectionOnly();
2638 if (MAI->
isAIX() && CurFrag)
2644 addEncodingComment(Inst, STI);
2649 getCommentOS() <<
"\n";
2652 if(getTargetStreamer())
2653 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2655 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2658 if (Comments.
size() && Comments.
back() !=
'\n')
2659 getCommentOS() <<
"\n";
2669 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2674 for (
const auto &Site : InlineStack)
2675 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2678 FnSym->
print(OS, MAI);
2683void MCAsmStreamer::emitBundleAlignMode(
Align Alignment) {
2684 OS <<
"\t.bundle_align_mode " <<
Log2(Alignment);
2688void MCAsmStreamer::emitBundleLock(
bool AlignToEnd,
2690 OS <<
"\t.bundle_lock";
2692 OS <<
" align_to_end";
2697 OS <<
"\t.bundle_unlock";
2713void MCAsmStreamer::emitAddrsig() {
2718void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2719 OS <<
"\t.addrsig_sym ";
2720 Sym->
print(OS, MAI);
2728 String.consume_back(
"\n");
2733void MCAsmStreamer::finishImpl() {
2751 const auto &Tables =
getContext().getMCDwarfLineTables();
2752 if (!Tables.empty()) {
2753 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2754 if (
auto *Label = Tables.begin()->second.getLabel()) {
2755 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2773MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2774 const Twine &Comment) {
2782 return getContext().createTempSymbol(Prefix +
"_end");
2786void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2797 emitLabel(DebugLineSymTmp);
2801 unsigned LengthFieldSize =
2807 emitAssignment(StartSym, OuterSym);
2813void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2822 ".loc should not be generated together with raw data!");
2835 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2840void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2843 unsigned PointerSize) {
2845 ".loc/.file don't need raw data in debug line section!");
2848 AddComment(
"Set address to " +
Label->getName());
2849 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2850 emitULEB128IntValue(PointerSize + 1);
2851 emitIntValue(dwarf::DW_LNE_set_address, 1);
2852 emitSymbolValue(Label, PointerSize);
2856 AddComment(
"Start sequence");
2864 AddComment(
"End sequence");
2865 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2866 emitULEB128IntValue(1);
2867 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2872 AddComment(
"Advance line " +
Twine(LineDelta));
2873 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2874 emitSLEB128IntValue(LineDelta);
2875 emitIntValue(dwarf::DW_LNS_copy, 1);
2879 std::unique_ptr<formatted_raw_ostream> OS,
2880 std::unique_ptr<MCInstPrinter> IP,
2881 std::unique_ptr<MCCodeEmitter> CE,
2882 std::unique_ptr<MCAsmBackend> MAB) {
2883 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
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
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...
std::optional< MCRegister > getLLVMRegNum(uint64_t RegNum, bool isEH) const
Map a dwarf register back to a target register.
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 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