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,
191 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
192 unsigned Discriminator);
196 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
197 unsigned Column,
unsigned Flags,
198 unsigned Isa,
unsigned Discriminator,
202 MCAsmStreamer(
MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
203 std::unique_ptr<MCInstPrinter>
printer,
204 std::unique_ptr<MCCodeEmitter> emitter,
205 std::unique_ptr<MCAsmBackend> asmbackend)
207 OSOwner(
std::
move(os)), OS(*OSOwner), MAI(&Context.getAsmInfo()),
210 if (Assembler->getBackendPtr())
211 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
213 Context.setUseNamesOnTempLabels(
true);
218 InstPrinter->setCommentStream(CommentStream);
222 UseDwarfDirectory =
false;
225 UseDwarfDirectory =
true;
229 Context.getAsmInfo().enableDwarfFileDirectoryDefault();
234 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
236 inline void EmitEOL() {
238 emitExplicitComments();
244 EmitCommentsAndEOL();
247 void emitSyntaxDirective(StringRef Syntax, StringRef
Options)
override;
249 void EmitCommentsAndEOL();
252 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
255 bool hasRawTextSupport()
const override {
return true; }
260 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
262 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
264 void addExplicitComment(
const Twine &
T)
override;
265 void emitExplicitComments()
override;
268 void addBlankLine()
override { EmitEOL(); }
273 void switchSection(MCSection *Section, uint32_t Subsection)
override;
274 bool popSection()
override;
276 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
277 bool KeepOriginalSym)
override;
281 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
284 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
285 assert((Bits != 0 || Ptr ==
nullptr) &&
286 "Invalid char pointer for instruction with no mnemonic");
290 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
292 void emitSubsectionsViaSymbols()
override;
293 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
296 unsigned Update, VersionTuple SDKVersion)
override;
297 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
298 unsigned Update, VersionTuple SDKVersion)
override;
299 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
300 unsigned Minor,
unsigned Update,
301 VersionTuple SDKVersion)
override;
303 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
304 void emitConditionalAssignment(MCSymbol *Symbol,
305 const MCExpr *
Value)
override;
306 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
309 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
310 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
311 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
312 void emitCOFFSymbolType(
int Type)
override;
313 void endCOFFSymbolDef()
override;
314 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
315 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
316 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
317 void emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset)
override;
318 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
319 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
320 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
321 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t
Size,
322 MCSymbol *CsectSym, Align Alignment)
override;
323 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
326 void emitXCOFFRenameDirective(
const MCSymbol *Name,
327 StringRef Rename)
override;
329 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
331 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
332 const MCSymbol *
Trap,
333 unsigned Lang,
unsigned Reason,
334 unsigned FunctionSize,
bool hasDebug)
override;
335 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
337 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
338 void emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
339 Align ByteAlignment)
override;
346 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
347 Align ByteAlignment)
override;
349 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
350 uint64_t
Size = 0, Align ByteAlignment =
Align(1),
351 SMLoc Loc = SMLoc())
override;
353 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t
Size,
354 Align ByteAlignment =
Align(1))
override;
356 void emitBinaryData(StringRef
Data)
override;
358 void emitBytes(StringRef
Data)
override;
360 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
361 SMLoc Loc = SMLoc())
override;
362 void emitIntValue(uint64_t
Value,
unsigned Size)
override;
363 void emitIntValueInHex(uint64_t
Value,
unsigned Size)
override;
364 void emitIntValueInHexWithPadding(uint64_t
Value,
unsigned Size)
override;
366 void emitULEB128Value(
const MCExpr *
Value)
override;
368 void emitSLEB128Value(
const MCExpr *
Value)
override;
370 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
371 SMLoc Loc = SMLoc())
override;
373 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
374 SMLoc Loc = SMLoc())
override;
376 void emitAlignmentDirective(uint64_t ByteAlignment,
377 std::optional<int64_t>
Value,
unsigned ValueSize,
378 unsigned MaxBytesToEmit);
380 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
382 unsigned MaxBytesToEmit = 0)
override;
384 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo &STI,
385 unsigned MaxBytesToEmit = 0)
override;
386 void emitPrefAlign(Align Alignment,
const MCSymbol &End,
bool EmitNops,
387 uint8_t Fill,
const MCSubtargetInfo &STI)
override;
389 void emitValueToOffset(
const MCExpr *
Offset,
393 void emitFileDirective(StringRef
Filename)
override;
394 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
395 StringRef TimeStamp, StringRef Description)
override;
396 Expected<unsigned> tryEmitDwarfFileDirective(
397 unsigned FileNo, StringRef Directory, StringRef
Filename,
398 std::optional<MD5::MD5Result> Checksum = std::nullopt,
399 std::optional<StringRef> Source = std::nullopt,
400 unsigned CUID = 0)
override;
401 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
402 std::optional<MD5::MD5Result> Checksum,
403 std::optional<StringRef> Source,
404 unsigned CUID = 0)
override;
405 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
406 unsigned Flags,
unsigned Isa,
407 unsigned Discriminator, StringRef FileName,
408 StringRef Location = {})
override;
409 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
413 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
414 unsigned Column,
unsigned FileIA,
415 unsigned LineIA,
unsigned ColIA,
416 const MCSymbol *Sym,
unsigned Flags,
417 unsigned Isa,
unsigned Discriminator,
419 StringRef Comment = {})
override;
421 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
423 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
424 ArrayRef<uint8_t> Checksum,
425 unsigned ChecksumKind)
override;
426 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
427 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
428 unsigned IAFile,
unsigned IALine,
429 unsigned IACol, SMLoc Loc)
override;
430 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
431 unsigned Column,
bool PrologueEnd,
bool IsStmt,
432 StringRef FileName, SMLoc Loc)
override;
433 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
434 const MCSymbol *FnEnd)
override;
435 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
436 unsigned SourceFileId,
437 unsigned SourceLineNum,
438 const MCSymbol *FnStartSym,
439 const MCSymbol *FnEndSym)
override;
441 void PrintCVDefRangePrefix(
442 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
444 void emitCVDefRangeDirective(
445 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
446 codeview::DefRangeRegisterRelHeader DRHdr)
override;
448 void emitCVDefRangeDirective(
449 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
450 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
452 void emitCVDefRangeDirective(
453 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
454 codeview::DefRangeRegisterHeader DRHdr)
override;
456 void emitCVDefRangeDirective(
457 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
458 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
460 void emitCVDefRangeDirective(
461 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
462 codeview::DefRangeRegisterRelIndirHeader DRHdr)
override;
464 void emitCVStringTableDirective()
override;
465 void emitCVFileChecksumsDirective()
override;
466 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
467 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
469 void emitIdent(StringRef IdentString)
override;
470 void emitCFIBKeyFrame()
override;
471 void emitCFIMTETaggedFrame()
override;
472 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
473 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
474 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
475 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
478 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
479 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
480 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
481 void emitCFIRememberState(SMLoc Loc)
override;
482 void emitCFIRestoreState(SMLoc Loc)
override;
483 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
484 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
485 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
486 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
487 void emitCFIEscape(StringRef
Values, SMLoc Loc)
override;
488 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
489 void emitCFISignalFrame()
override;
490 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
491 void emitCFIRegister(int64_t Register1, int64_t Register2,
493 void emitCFIWindowSave(SMLoc Loc)
override;
494 void emitCFINegateRAState(SMLoc Loc)
override;
495 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
496 void emitCFIReturnColumn(int64_t
Register)
override;
497 void emitCFILLVMRegisterPair(int64_t
Register, int64_t R1, int64_t R1Size,
498 int64_t
R2, int64_t R2Size, SMLoc Loc)
override;
499 void emitCFILLVMVectorRegisters(
502 void emitCFILLVMVectorOffset(int64_t
Register, int64_t RegisterSize,
503 int64_t MaskRegister, int64_t MaskRegisterSize,
504 int64_t
Offset, SMLoc Loc)
override;
505 void emitCFILLVMVectorRegisterMask(int64_t
Register, int64_t SpillRegister,
506 int64_t SpillRegisterLaneSizeInBits,
507 int64_t MaskRegister,
508 int64_t MaskRegisterSizeInBits,
511 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
512 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
514 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
515 void emitWinCFIEndProc(SMLoc Loc)
override;
516 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
517 void emitWinCFISplitChained(SMLoc Loc)
override;
518 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
519 void emitWinCFIPush2Regs(MCRegister Reg1, MCRegister Reg2,
523 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
528 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
529 void emitWinCFIEndProlog(SMLoc Loc)
override;
530 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
531 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
532 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
533 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
535 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
537 void emitWinEHHandlerData(SMLoc Loc)
override;
539 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
540 const MCSymbolRefExpr *To, uint64_t
Count)
override;
542 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
544 void emitPseudoProbe(uint64_t
Guid, uint64_t Index, uint64_t
Type,
545 uint64_t Attr, uint64_t Discriminator,
547 MCSymbol *FnSym)
override;
549 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
550 const MCExpr *Expr, SMLoc Loc)
override;
552 void emitAddrsig()
override;
553 void emitAddrsigSym(
const MCSymbol *Sym)
override;
558 void emitRawTextImpl(StringRef
String)
override;
560 void finishImpl()
override;
562 void emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment)
override;
564 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
565 const Twine &Comment)
override;
567 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
569 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
570 MCSymbol *EndLabel =
nullptr)
override;
572 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
573 const MCSymbol *Label,
574 unsigned PointerSize)
override;
579void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
580 if (!IsVerboseAsm)
return;
582 T.toVector(CommentToEmit);
585 CommentToEmit.push_back(
'\n');
588void MCAsmStreamer::EmitCommentsAndEOL() {
589 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
597 "Comment array not newline terminated");
601 size_t Position = Comments.
find(
'\n');
604 Comments = Comments.
substr(Position+1);
605 }
while (!Comments.
empty());
607 CommentToEmit.clear();
611 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
612 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
615void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
622void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
627 ExplicitCommentToEmit.
append(
"\t");
632 size_t p = 2, len = c.
size() - 2;
636 ExplicitCommentToEmit.
append(
"\t");
641 ExplicitCommentToEmit.
append(
"\n");
645 ExplicitCommentToEmit.
append(
"\t");
647 }
else if (c.
front() ==
'#') {
649 ExplicitCommentToEmit.
append(
"\t");
653 assert(
false &&
"Unexpected Assembly Comment");
655 if (c.
back() ==
'\n')
656 emitExplicitComments();
659void MCAsmStreamer::emitExplicitComments() {
660 StringRef Comments = ExplicitCommentToEmit;
661 if (!Comments.
empty())
663 ExplicitCommentToEmit.
clear();
666void MCAsmStreamer::switchSection(
MCSection *Section, uint32_t Subsection) {
668 if (!EmittedSectionDirective ||
670 EmittedSectionDirective =
true;
672 TS->changeSection(Cur.first, Section, Subsection, OS);
681bool MCAsmStreamer::popSection() {
684 auto [Sec, Subsec] = getCurrentSection();
689void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
691 bool KeepOriginalSym) {
693 OriginalSym->
print(OS, MAI);
695 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
705 if (!
Symbol->isVariable() &&
720 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
721 assert(str !=
"" &&
"Invalid LOH name");
735void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
736 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
739void MCAsmStreamer::emitSubsectionsViaSymbols() {
740 OS <<
".subsections_via_symbols\n";
744 assert(!
Options.empty() &&
"At least one option is required!");
745 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
747 OS <<
", " <<
'"' << Opt <<
'"';
776 if (SDKVersion.
empty())
778 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
779 if (
auto Minor = SDKVersion.
getMinor()) {
780 OS <<
", " << *Minor;
782 OS <<
", " << *Subminor;
788 unsigned Minor,
unsigned Update,
792 OS <<
", " << Update;
799#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
801 case MachO::PLATFORM_##platform: \
803#include "llvm/BinaryFormat/MachO.def"
808void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
809 unsigned Minor,
unsigned Update,
812 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
814 OS <<
", " << Update;
819void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
820 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
822 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
830 OS << (UseSet ?
", " :
" = ");
837void MCAsmStreamer::emitConditionalAssignment(
MCSymbol *Symbol,
839 OS <<
".lto_set_conditional ";
846void MCAsmStreamer::emitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
848 Alias->
print(OS, MAI);
854bool MCAsmStreamer::emitSymbolAttribute(
MCSymbol *Symbol,
871 default:
return false;
894 OS <<
"\t.no_dead_strip\t";
899 OS <<
"\t.private_extern\t";
908 OS <<
"\t.weak_definition\t";
925 OS <<
"\t.weak_anti_dep\t";
935void MCAsmStreamer::emitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
936 OS <<
".desc" <<
' ';
938 OS <<
',' << DescValue;
943 OS <<
"\t." << Syntax <<
"_syntax";
949void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
956void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
961void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
962 OS <<
"\t.type\t" <<
Type <<
';';
966void MCAsmStreamer::endCOFFSymbolDef() {
971void MCAsmStreamer::emitCOFFSafeSEH(
MCSymbol const *Symbol) {
972 OS <<
"\t.safeseh\t";
977void MCAsmStreamer::emitCOFFSymbolIndex(
MCSymbol const *Symbol) {
983void MCAsmStreamer::emitCOFFSectionIndex(
MCSymbol const *Symbol) {
989void MCAsmStreamer::emitCOFFSecRel32(
MCSymbol const *Symbol, uint64_t
Offset) {
990 OS <<
"\t.secrel32\t";
997void MCAsmStreamer::emitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset) {
1007void MCAsmStreamer::emitCOFFSecNumber(
MCSymbol const *Symbol) {
1008 OS <<
"\t.secnum\t";
1013void MCAsmStreamer::emitCOFFSecOffset(
MCSymbol const *Symbol) {
1014 OS <<
"\t.secoffset\t";
1022void MCAsmStreamer::emitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
1027 "We only support writing log base-2 alignment format with XCOFF.");
1030 LabelSym->
print(OS, MAI);
1031 OS <<
',' <<
Size <<
',';
1032 CsectSym->
print(OS, MAI);
1033 OS <<
',' <<
Log2(Alignment);
1040 if (XSym->hasRename())
1041 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1044void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
1055 OS <<
"\t.extern\t";
1058 OS <<
"\t.lglobl\t";
1066 switch (Visibility) {
1086 if (Sym.hasRename())
1087 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
1090void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
1092 OS <<
"\t.rename\t";
1093 Name->print(OS, MAI);
1094 const char DQ =
'"';
1096 for (
char C : Rename) {
1106void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
1112void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
1116 unsigned FunctionSize,
1118 OS <<
"\t.except\t";
1120 OS <<
", " << Lang <<
", " << Reason;
1125 const char InfoDirective[] =
"\t.info ";
1126 const char *Separator =
", ";
1127 constexpr int WordSize =
sizeof(uint32_t);
1130 OS << InfoDirective;
1131 PrintQuotedString(Name, OS);
1134 size_t MetadataSize =
Metadata.size();
1137 OS <<
format_hex(MetadataSize, 10) << Separator;
1140 if (MetadataSize == 0) {
1150 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1151 uint32_t PaddingSize = PaddedSize - MetadataSize;
1158 constexpr int WordsPerDirective = 5;
1161 int WordsBeforeNextDirective = 0;
1162 auto PrintWord = [&](
const uint8_t *WordPtr) {
1163 if (WordsBeforeNextDirective-- == 0) {
1165 OS << InfoDirective;
1166 WordsBeforeNextDirective = WordsPerDirective;
1174 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1175 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1180 assert(PaddedSize - Index == WordSize);
1181 std::array<uint8_t, WordSize> LastWord = {0};
1182 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1183 PrintWord(LastWord.data());
1197void MCAsmStreamer::emitCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
1198 Align ByteAlignment) {
1206 OS <<
',' <<
Log2(ByteAlignment);
1213 if (XSym && XSym->hasRename())
1214 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1218void MCAsmStreamer::emitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
1224 if (ByteAlign > 1) {
1229 OS <<
',' << ByteAlign.
value();
1232 OS <<
',' <<
Log2(ByteAlign);
1249 ".zerofill is a Mach-O specific directive");
1259 OS <<
',' <<
Log2(ByteAlignment);
1274 ".zerofill is a Mach-O specific directive");
1283 if (ByteAlignment > 1)
1284 OS <<
", " <<
Log2(ByteAlignment);
1290 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1291 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1302 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1303 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1309 const auto printOneCharacterFor = [printCharacterInOctal](
1310 auto printOnePrintingCharacter) {
1311 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1313 printOnePrintingCharacter(
static_cast<char>(
C));
1316 printCharacterInOctal(
C);
1319 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1320 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1321 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1322 printOneCharacter(
C);
1325 printOneCharacter(*(EndPtr - 1));
1329 printCharacterList(printCharacterInOctal);
1332 printCharacterList(printOneCharacterFor([&OS](
char C) {
1333 const char AsmCharLitBuf[2] = {
'\'',
C};
1334 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1345 for (
unsigned char C :
Data) {
1352 for (
unsigned char C :
Data) {
1353 if (
C ==
'"' ||
C ==
'\\') {
1354 OS <<
'\\' << (char)
C;
1393 assert(getCurrentSectionOnly() &&
1394 "Cannot emit contents before setting section!");
1395 if (
Data.empty())
return;
1402 if (
Data.back() == 0) {
1403 OS <<
"\t.string\t";
1408 PrintQuotedString(
Data, OS);
1428 PrintQuotedString(
Data, OS);
1433 if (
Data.size() != 1 && emitAsString(
Data))
1439 TS->emitRawBytes(
Data);
1443 for (
const unsigned char C :
Data.bytes()) {
1451 const size_t Cols = 4;
1452 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1453 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1456 for (; J < EJ - 1; ++J)
1457 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1463void MCAsmStreamer::emitIntValue(uint64_t
Value,
unsigned Size) {
1467void MCAsmStreamer::emitIntValueInHex(uint64_t
Value,
unsigned Size) {
1471void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t
Value,
1479 assert(getCurrentSectionOnly() &&
1480 "Cannot emit contents before setting section!");
1492 if (!
Value->evaluateAsAbsolute(IntValue))
1507 unsigned ByteOffset =
1508 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1509 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1513 uint64_t Shift = 64 - EmissionSize * 8;
1514 assert(Shift <
static_cast<uint64_t
>(
1515 std::numeric_limits<unsigned long long>::digits) &&
1516 "undefined behavior");
1517 ValueToEmit &= ~0ULL >> Shift;
1518 emitIntValue(ValueToEmit, EmissionSize);
1527 TS->emitValue(
Value);
1534void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1536 if (
Value->evaluateAsAbsolute(IntValue)) {
1537 emitULEB128IntValue(IntValue);
1540 OS <<
"\t.uleb128 ";
1545void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1547 if (
Value->evaluateAsAbsolute(IntValue)) {
1548 emitSLEB128IntValue(IntValue);
1551 OS <<
"\t.sleb128 ";
1556void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1558 int64_t IntNumBytes;
1559 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1560 if (IsAbsolute && IntNumBytes == 0)
1564 if (!MAI->
isAIX() || FillValue == 0) {
1566 OS << ZeroDirective;
1569 OS <<
',' << (int)FillValue;
1574 "Cannot emit non-absolute expression lengths of fill.");
1575 for (
int i = 0; i < IntNumBytes; ++i) {
1586void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1591 OS <<
", " <<
Size <<
", 0x";
1596void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
1597 std::optional<int64_t>
Value,
1599 unsigned MaxBytesToEmit) {
1613 switch (ValueSize) {
1617 OS <<
"\t.p2align\t";
1631 if (
Value.has_value() || MaxBytesToEmit) {
1632 if (
Value.has_value()) {
1640 OS <<
", " << MaxBytesToEmit;
1648 switch (ValueSize) {
1650 case 1: OS <<
".balign";
break;
1651 case 2: OS <<
".balignw";
break;
1652 case 4: OS <<
".balignl";
break;
1657 if (
Value.has_value())
1659 else if (MaxBytesToEmit)
1662 OS <<
", " << MaxBytesToEmit;
1666void MCAsmStreamer::emitValueToAlignment(
Align Alignment, int64_t Fill,
1668 unsigned MaxBytesToEmit) {
1669 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1672void MCAsmStreamer::emitCodeAlignment(
Align Alignment,
1674 unsigned MaxBytesToEmit) {
1680 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1683void MCAsmStreamer::emitPrefAlign(
Align Alignment,
const MCSymbol &End,
1684 bool EmitNops, uint8_t Fill,
1686 OS <<
"\t.prefalign\t" <<
Log2(Alignment) <<
", ";
1691 OS <<
", " <<
static_cast<unsigned>(Fill);
1695void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1696 unsigned char Value,
1701 OS <<
", " << (unsigned)
Value;
1719 bool useTimeStamp = !TimeStamp.
empty();
1720 bool useCompilerVersion = !CompilerVersion.
empty();
1721 bool useDescription = !Description.
empty();
1722 if (useTimeStamp || useCompilerVersion || useDescription) {
1725 PrintQuotedString(TimeStamp, OS);
1726 if (useCompilerVersion || useDescription) {
1728 if (useCompilerVersion)
1729 PrintQuotedString(CompilerVersion, OS);
1730 if (useDescription) {
1732 PrintQuotedString(Description, OS);
1739void MCAsmStreamer::printDwarfFileDirective(
1741 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1745 if (!UseDwarfDirectory && !Directory.
empty()) {
1749 FullPathName = Directory;
1756 OS <<
"\t.file\t" << FileNo <<
' ';
1757 if (!Directory.
empty()) {
1758 PrintQuotedString(Directory, OS);
1763 OS <<
" md5 0x" << Checksum->digest();
1766 PrintQuotedString(*Source, OS);
1772 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1774 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1783 FileNo = FileNoOrErr.
get();
1792 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1793 UseDwarfDirectory, OS1);
1796 TS->emitDwarfFileDirective(OS1.str());
1798 emitRawText(OS1.str());
1803void MCAsmStreamer::emitDwarfFile0Directive(
1805 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1821 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1822 UseDwarfDirectory, OS1);
1825 TS->emitDwarfFileDirective(OS1.str());
1827 emitRawText(OS1.str());
1831void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1832 unsigned Discriminator) {
1837 OS <<
" basic_block";
1839 OS <<
" prologue_end";
1841 OS <<
" epilogue_begin";
1843 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1850 OS <<
" isa " << Isa;
1856void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1857 unsigned Column,
unsigned Flags,
1859 unsigned Discriminator,
1863 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1870 OS << FileName <<
':' <<
Line <<
':' << Column;
1878 Discriminator, FileName, Comment);
1881void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1882 unsigned Column,
unsigned Flags,
1883 unsigned Isa,
unsigned Discriminator,
1893 Discriminator, FileName, Comment);
1898 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1901 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1907void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1908 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1909 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1910 unsigned Isa,
unsigned Discriminator,
StringRef FileName,
1913 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1914 OS <<
", function_name " << *Sym;
1915 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1918 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1924 OS <<
".loc_label\t" <<
Name;
1928MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1936 unsigned ChecksumKind) {
1941 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1944 if (!ChecksumKind) {
1950 PrintQuotedString(
toHex(Checksum), OS);
1957bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1958 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1962bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1965 unsigned IALine,
unsigned IACol,
1967 OS <<
"\t.cv_inline_site_id " <<
FunctionId <<
" within " << IAFunc
1968 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1970 IALine, IACol,
Loc);
1973void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1974 unsigned Line,
unsigned Column,
1975 bool PrologueEnd,
bool IsStmt,
1981 OS <<
"\t.cv_loc\t" <<
FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1984 OS <<
" prologue_end";
1997void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
2000 OS <<
"\t.cv_linetable\t" <<
FunctionId <<
", ";
2001 FnStart->
print(OS, MAI);
2003 FnEnd->
print(OS, MAI);
2008void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
2009 unsigned SourceFileId,
2010 unsigned SourceLineNum,
2013 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
2014 <<
' ' << SourceLineNum <<
' ';
2015 FnStartSym->
print(OS, MAI);
2017 FnEndSym->
print(OS, MAI);
2020 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
2023void MCAsmStreamer::PrintCVDefRangePrefix(
2024 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
2025 OS <<
"\t.cv_def_range\t";
2026 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
2034void MCAsmStreamer::emitCVDefRangeDirective(
2035 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2037 PrintCVDefRangePrefix(Ranges);
2038 OS <<
", reg_rel, ";
2044void MCAsmStreamer::emitCVDefRangeDirective(
2045 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2047 PrintCVDefRangePrefix(Ranges);
2048 OS <<
", subfield_reg, ";
2053void MCAsmStreamer::emitCVDefRangeDirective(
2054 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2056 PrintCVDefRangePrefix(Ranges);
2062void MCAsmStreamer::emitCVDefRangeDirective(
2063 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2065 PrintCVDefRangePrefix(Ranges);
2066 OS <<
", frame_ptr_rel, ";
2071void MCAsmStreamer::emitCVDefRangeDirective(
2072 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
2074 PrintCVDefRangePrefix(Ranges);
2075 OS <<
", reg_rel_indir, ";
2081void MCAsmStreamer::emitCVStringTableDirective() {
2082 OS <<
"\t.cv_stringtable";
2086void MCAsmStreamer::emitCVFileChecksumsDirective() {
2087 OS <<
"\t.cv_filechecksums";
2091void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
2092 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
2096void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
2097 OS <<
"\t.cv_fpo_data\t";
2098 ProcSym->
print(OS, MAI);
2102void MCAsmStreamer::emitIdent(
StringRef IdentString) {
2105 PrintQuotedString(IdentString, OS);
2109void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
2111 OS <<
"\t.cfi_sections ";
2120 OS <<
".debug_frame";
2133 OS <<
"\t.cfi_startproc";
2141 OS <<
"\t.cfi_endproc";
2145void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2151 if (std::optional<MCRegister> LLVMRegister =
2153 InstPrinter->printRegName(OS, *LLVMRegister);
2162 OS <<
"\t.cfi_def_cfa ";
2168void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset,
SMLoc Loc) {
2170 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2174void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2177 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2185 OS <<
"\t.cfi_escape ";
2187 size_t e =
Values.size() - 1;
2188 for (
size_t i = 0; i < e; ++i)
2200void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size,
SMLoc Loc) {
2203 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2212 OS <<
"\t.cfi_def_cfa_register ";
2219 OS <<
"\t.cfi_offset ";
2225void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2226 unsigned Encoding) {
2228 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2229 Sym->
print(OS, MAI);
2233void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2235 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2236 Sym->
print(OS, MAI);
2240void MCAsmStreamer::emitCFIRememberState(
SMLoc Loc) {
2242 OS <<
"\t.cfi_remember_state";
2246void MCAsmStreamer::emitCFIRestoreState(
SMLoc Loc) {
2248 OS <<
"\t.cfi_restore_state";
2254 OS <<
"\t.cfi_restore ";
2261 OS <<
"\t.cfi_same_value ";
2266void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2269 OS <<
"\t.cfi_rel_offset ";
2275void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment,
SMLoc Loc) {
2277 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2281void MCAsmStreamer::emitCFISignalFrame() {
2283 OS <<
"\t.cfi_signal_frame";
2289 OS <<
"\t.cfi_undefined ";
2294void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2297 OS <<
"\t.cfi_register ";
2298 EmitRegisterName(Register1);
2300 EmitRegisterName(Register2);
2304void MCAsmStreamer::emitCFILLVMRegisterPair(int64_t
Register, int64_t R1,
2305 int64_t R1Size, int64_t
R2,
2309 OS <<
"\t.cfi_llvm_register_pair ";
2312 EmitRegisterName(R1);
2313 OS <<
", " << R1Size <<
", ";
2314 EmitRegisterName(
R2);
2315 OS <<
", " << R2Size;
2319void MCAsmStreamer::emitCFILLVMVectorRegisters(
2324 OS <<
"\t.cfi_llvm_vector_registers ";
2326 for (
auto [
Reg, Lane,
Size] : VRs)
2327 OS <<
", " <<
Reg <<
", " << Lane <<
", " <<
Size;
2331void MCAsmStreamer::emitCFILLVMVectorOffset(int64_t
Register,
2332 int64_t RegisterSize,
2333 int64_t MaskRegister,
2334 int64_t MaskRegisterSize,
2339 OS <<
"\t.cfi_llvm_vector_offset ";
2341 OS <<
", " << RegisterSize <<
", ";
2342 EmitRegisterName(MaskRegister);
2343 OS <<
", " << MaskRegisterSize <<
", " <<
Offset;
2347void MCAsmStreamer::emitCFILLVMVectorRegisterMask(
2348 int64_t
Register, int64_t SpillRegister,
2349 int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister,
2350 int64_t MaskRegisterSizeInBits,
SMLoc Loc) {
2352 Register, SpillRegister, SpillRegisterLaneSizeInBits, MaskRegister,
2353 MaskRegisterSizeInBits,
Loc);
2355 OS <<
"\t.cfi_llvm_vector_register_mask ";
2358 EmitRegisterName(SpillRegister);
2359 OS <<
", " << SpillRegisterLaneSizeInBits <<
", ";
2360 EmitRegisterName(MaskRegister);
2361 OS <<
", " << MaskRegisterSizeInBits;
2365void MCAsmStreamer::emitCFIWindowSave(
SMLoc Loc) {
2367 OS <<
"\t.cfi_window_save";
2371void MCAsmStreamer::emitCFINegateRAState(
SMLoc Loc) {
2373 OS <<
"\t.cfi_negate_ra_state";
2377void MCAsmStreamer::emitCFINegateRAStateWithPC(
SMLoc Loc) {
2379 OS <<
"\t.cfi_negate_ra_state_with_pc";
2383void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2385 OS <<
"\t.cfi_return_column ";
2392 OS <<
"\t.cfi_label " <<
Name;
2396void MCAsmStreamer::emitCFIBKeyFrame() {
2398 OS <<
"\t.cfi_b_key_frame";
2402void MCAsmStreamer::emitCFIMTETaggedFrame() {
2404 OS <<
"\t.cfi_mte_tagged_frame";
2408void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2411 OS <<
"\t.cfi_val_offset ";
2417void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
2425void MCAsmStreamer::emitWinCFIEndProc(
SMLoc Loc) {
2428 OS <<
"\t.seh_endproc";
2432void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
2435 OS <<
"\t.seh_endfunclet";
2439void MCAsmStreamer::emitWinCFISplitChained(
SMLoc Loc) {
2442 OS <<
"\t.seh_splitchained";
2446void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2450 OS <<
"\t.seh_handler ";
2451 Sym->
print(OS, MAI);
2457 OS <<
", " << Marker <<
"unwind";
2459 OS <<
", " << Marker <<
"except";
2463void MCAsmStreamer::emitWinEHHandlerData(
SMLoc Loc) {
2478 MCSection *XData = getAssociatedXDataSection(TextSec);
2479 switchSectionNoPrint(XData);
2481 OS <<
"\t.seh_handlerdata";
2488 OS <<
"\t.seh_pushreg ";
2489 InstPrinter->printRegName(OS,
Register);
2497 OS <<
"\t.seh_push2regs ";
2498 InstPrinter->printRegName(OS, Reg1);
2500 InstPrinter->printRegName(OS, Reg2);
2508 OS <<
"\t.seh_setframe ";
2509 InstPrinter->printRegName(OS,
Register);
2514void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
2517 OS <<
"\t.seh_stackalloc " <<
Size;
2525 OS <<
"\t.seh_savereg ";
2526 InstPrinter->printRegName(OS,
Register);
2535 OS <<
"\t.seh_savexmm ";
2536 InstPrinter->printRegName(OS,
Register);
2541void MCAsmStreamer::emitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
2544 OS <<
"\t.seh_pushframe";
2550void MCAsmStreamer::emitWinCFIEndProlog(
SMLoc Loc) {
2553 OS <<
"\t.seh_endprologue";
2557void MCAsmStreamer::emitWinCFIBeginEpilogue(
SMLoc Loc) {
2560 OS <<
"\t.seh_startepilogue";
2564void MCAsmStreamer::emitWinCFIEndEpilogue(
SMLoc Loc) {
2567 OS <<
"\t.seh_endepilogue";
2571void MCAsmStreamer::emitWinCFIUnwindV2Start(
SMLoc Loc) {
2574 OS <<
"\t.seh_unwindv2start";
2578void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version,
SMLoc Loc) {
2581 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2588 OS <<
"\t.cg_profile ";
2592 OS <<
", " <<
Count;
2596void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2598 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2602 MCSection *Sec = getCurrentSectionOnly();
2606 if (MAI->
isAIX() && CurFrag)
2612 addEncodingComment(Inst, STI);
2617 getCommentOS() <<
"\n";
2620 if(getTargetStreamer())
2621 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2623 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2626 if (Comments.
size() && Comments.
back() !=
'\n')
2627 getCommentOS() <<
"\n";
2632void MCAsmStreamer::emitPseudoProbe(uint64_t
Guid, uint64_t Index,
2633 uint64_t
Type, uint64_t Attr,
2634 uint64_t Discriminator,
2637 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2642 for (
const auto &Site : InlineStack)
2643 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2646 FnSym->
print(OS, MAI);
2663void MCAsmStreamer::emitAddrsig() {
2668void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2669 OS <<
"\t.addrsig_sym ";
2670 Sym->
print(OS, MAI);
2678 String.consume_back(
"\n");
2683void MCAsmStreamer::finishImpl() {
2701 const auto &Tables =
getContext().getMCDwarfLineTables();
2702 if (!Tables.empty()) {
2703 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2704 if (
auto *Label = Tables.begin()->second.getLabel()) {
2705 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2711void MCAsmStreamer::emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment) {
2723MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2724 const Twine &Comment) {
2732 return getContext().createTempSymbol(Prefix +
"_end");
2736void MCAsmStreamer::emitDwarfLineStartLabel(
MCSymbol *StartSym) {
2747 emitLabel(DebugLineSymTmp);
2751 unsigned LengthFieldSize =
2757 emitAssignment(StartSym, OuterSym);
2763void MCAsmStreamer::emitDwarfLineEndEntry(
MCSection *Section,
2772 ".loc should not be generated together with raw data!");
2785 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2790void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2793 unsigned PointerSize) {
2795 ".loc/.file don't need raw data in debug line section!");
2798 AddComment(
"Set address to " +
Label->getName());
2799 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2800 emitULEB128IntValue(PointerSize + 1);
2801 emitIntValue(dwarf::DW_LNE_set_address, 1);
2802 emitSymbolValue(Label, PointerSize);
2806 AddComment(
"Start sequence");
2814 AddComment(
"End sequence");
2815 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2816 emitULEB128IntValue(1);
2817 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2822 AddComment(
"Advance line " +
Twine(LineDelta));
2823 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2824 emitSLEB128IntValue(LineDelta);
2825 emitIntValue(dwarf::DW_LNS_copy, 1);
2829 std::unique_ptr<formatted_raw_ostream> OS,
2830 std::unique_ptr<MCInstPrinter> IP,
2831 std::unique_ptr<MCCodeEmitter> CE,
2832 std::unique_ptr<MCAsmBackend> MAB) {
2833 return new MCAsmStreamer(Context, std::move(OS), std::move(IP), std::move(CE),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#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.
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
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)
LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Base class for the full range of assembler expressions which are needed for parsing.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
static LLVM_ABI void Emit(MCStreamer *MCOS)
Instances of this class represent a single low-level machine instruction.
LLVM_ABI void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCContext *Ctx=nullptr) const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
MCSection * getTextSection() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
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={})
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.
@ C
The default llvm calling convention, compatible with C.
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)
LLVM_ABI int getDwarfVersion()
@ 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.
@ 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