48 std::unique_ptr<formatted_raw_ostream> OSOwner;
49 formatted_raw_ostream &OS;
51 std::unique_ptr<MCInstPrinter> InstPrinter;
52 std::unique_ptr<MCAssembler> Assembler;
54 SmallString<128> ExplicitCommentToEmit;
55 SmallString<128> CommentToEmit;
56 raw_svector_ostream CommentStream;
57 raw_null_ostream NullStream;
59 bool EmittedSectionDirective =
false;
61 bool IsVerboseAsm =
false;
62 bool ShowInst =
false;
63 bool UseDwarfDirectory =
false;
65 void EmitRegisterName(int64_t
Register);
66 void PrintQuotedString(StringRef
Data, raw_ostream &OS)
const;
67 void printDwarfFileDirective(
unsigned FileNo, StringRef Directory,
69 std::optional<MD5::MD5Result> Checksum,
70 std::optional<StringRef> Source,
71 bool UseDwarfDirectory,
72 raw_svector_ostream &OS)
const;
73 void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
override;
74 void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame)
override;
77 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
78 unsigned Discriminator);
82 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
83 unsigned Column,
unsigned Flags,
84 unsigned Isa,
unsigned Discriminator,
85 StringRef FileName, StringRef Comment);
88 MCAsmStreamer(MCContext &
Context, std::unique_ptr<formatted_raw_ostream> os,
89 std::unique_ptr<MCInstPrinter>
printer,
90 std::unique_ptr<MCCodeEmitter> emitter,
91 std::unique_ptr<MCAsmBackend> asmbackend)
92 : MCAsmBaseStreamer(
Context), OSOwner(std::
move(os)), OS(*OSOwner),
94 Assembler(std::make_unique<MCAssembler>(
96 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
98 CommentStream(CommentToEmit) {
100 if (Assembler->getBackendPtr())
101 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
103 Context.setUseNamesOnTempLabels(
true);
105 auto *TO =
Context.getTargetOptions();
106 IsVerboseAsm = TO->AsmVerbose;
108 InstPrinter->setCommentStream(CommentStream);
109 ShowInst = TO->ShowMCInst;
110 switch (TO->MCUseDwarfDirectory) {
112 UseDwarfDirectory =
false;
115 UseDwarfDirectory =
true;
119 Context.getAsmInfo()->enableDwarfFileDirectoryDefault();
124 MCAssembler &getAssembler() {
return *Assembler; }
125 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
127 inline void EmitEOL() {
129 emitExplicitComments();
135 EmitCommentsAndEOL();
138 void emitSyntaxDirective(StringRef Syntax, StringRef
Options)
override;
140 void EmitCommentsAndEOL();
143 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
146 bool hasRawTextSupport()
const override {
return true; }
151 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
154 void AddEncodingComment(
const MCInst &Inst,
const MCSubtargetInfo &);
159 raw_ostream &getCommentOS()
override {
162 return CommentStream;
165 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
167 void addExplicitComment(
const Twine &
T)
override;
168 void emitExplicitComments()
override;
171 void addBlankLine()
override { EmitEOL(); }
176 void switchSection(MCSection *Section, uint32_t Subsection)
override;
177 bool popSection()
override;
179 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
180 bool KeepOriginalSym)
override;
184 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
187 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
188 assert((Bits != 0 || Ptr ==
nullptr) &&
189 "Invalid char pointer for instruction with no mnemonic");
193 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
195 void emitSubsectionsViaSymbols()
override;
196 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
199 unsigned Update, VersionTuple SDKVersion)
override;
200 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
201 unsigned Update, VersionTuple SDKVersion)
override;
202 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
203 unsigned Minor,
unsigned Update,
204 VersionTuple SDKVersion)
override;
206 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
207 void emitConditionalAssignment(MCSymbol *Symbol,
208 const MCExpr *
Value)
override;
209 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
212 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
213 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
214 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
215 void emitCOFFSymbolType(
int Type)
override;
216 void endCOFFSymbolDef()
override;
217 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
218 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
219 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
220 void emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset)
override;
221 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
222 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
223 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
224 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t
Size,
225 MCSymbol *CsectSym, Align Alignment)
override;
226 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
229 void emitXCOFFRenameDirective(
const MCSymbol *Name,
230 StringRef Rename)
override;
232 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
234 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
235 const MCSymbol *
Trap,
236 unsigned Lang,
unsigned Reason,
237 unsigned FunctionSize,
bool hasDebug)
override;
238 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
240 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
241 void emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
242 Align ByteAlignment)
override;
249 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
250 Align ByteAlignment)
override;
252 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
253 uint64_t
Size = 0, Align ByteAlignment =
Align(1),
254 SMLoc Loc = SMLoc())
override;
256 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t
Size,
257 Align ByteAlignment =
Align(1))
override;
259 void emitBinaryData(StringRef
Data)
override;
261 void emitBytes(StringRef
Data)
override;
263 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
264 SMLoc Loc = SMLoc())
override;
265 void emitIntValue(uint64_t
Value,
unsigned Size)
override;
266 void emitIntValueInHex(uint64_t
Value,
unsigned Size)
override;
267 void emitIntValueInHexWithPadding(uint64_t
Value,
unsigned Size)
override;
269 void emitULEB128Value(
const MCExpr *
Value)
override;
271 void emitSLEB128Value(
const MCExpr *
Value)
override;
273 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
274 SMLoc Loc = SMLoc())
override;
276 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
277 SMLoc Loc = SMLoc())
override;
279 void emitAlignmentDirective(uint64_t ByteAlignment,
280 std::optional<int64_t>
Value,
unsigned ValueSize,
281 unsigned MaxBytesToEmit);
283 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
285 unsigned MaxBytesToEmit = 0)
override;
287 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo *STI,
288 unsigned MaxBytesToEmit = 0)
override;
289 void emitPrefAlign(Align Alignment,
const MCSymbol &End,
bool EmitNops,
290 uint8_t Fill,
const MCSubtargetInfo &STI)
override;
292 void emitValueToOffset(
const MCExpr *
Offset,
296 void emitFileDirective(StringRef
Filename)
override;
297 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
298 StringRef TimeStamp, StringRef Description)
override;
299 Expected<unsigned> tryEmitDwarfFileDirective(
300 unsigned FileNo, StringRef Directory, StringRef
Filename,
301 std::optional<MD5::MD5Result> Checksum = std::nullopt,
302 std::optional<StringRef> Source = std::nullopt,
303 unsigned CUID = 0)
override;
304 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
305 std::optional<MD5::MD5Result> Checksum,
306 std::optional<StringRef> Source,
307 unsigned CUID = 0)
override;
308 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
309 unsigned Flags,
unsigned Isa,
310 unsigned Discriminator, StringRef FileName,
311 StringRef Location = {})
override;
312 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
316 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
317 unsigned Column,
unsigned FileIA,
318 unsigned LineIA,
unsigned ColIA,
319 const MCSymbol *Sym,
unsigned Flags,
320 unsigned Isa,
unsigned Discriminator,
322 StringRef Comment = {})
override;
324 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
326 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
327 ArrayRef<uint8_t> Checksum,
328 unsigned ChecksumKind)
override;
329 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
330 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
331 unsigned IAFile,
unsigned IALine,
332 unsigned IACol, SMLoc Loc)
override;
333 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
334 unsigned Column,
bool PrologueEnd,
bool IsStmt,
335 StringRef FileName, SMLoc Loc)
override;
336 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
337 const MCSymbol *FnEnd)
override;
338 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
339 unsigned SourceFileId,
340 unsigned SourceLineNum,
341 const MCSymbol *FnStartSym,
342 const MCSymbol *FnEndSym)
override;
344 void PrintCVDefRangePrefix(
345 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
347 void emitCVDefRangeDirective(
348 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
349 codeview::DefRangeRegisterRelHeader DRHdr)
override;
351 void emitCVDefRangeDirective(
352 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
353 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
355 void emitCVDefRangeDirective(
356 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
357 codeview::DefRangeRegisterHeader DRHdr)
override;
359 void emitCVDefRangeDirective(
360 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
361 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
363 void emitCVDefRangeDirective(
364 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
365 codeview::DefRangeRegisterRelIndirHeader DRHdr)
override;
367 void emitCVStringTableDirective()
override;
368 void emitCVFileChecksumsDirective()
override;
369 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
370 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
372 void emitIdent(StringRef IdentString)
override;
373 void emitCFIBKeyFrame()
override;
374 void emitCFIMTETaggedFrame()
override;
375 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
376 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
377 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
378 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
381 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
382 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
383 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
384 void emitCFIRememberState(SMLoc Loc)
override;
385 void emitCFIRestoreState(SMLoc Loc)
override;
386 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
387 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
388 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
389 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
390 void emitCFIEscape(StringRef Values, SMLoc Loc)
override;
391 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
392 void emitCFISignalFrame()
override;
393 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
394 void emitCFIRegister(int64_t Register1, int64_t Register2,
396 void emitCFIWindowSave(SMLoc Loc)
override;
397 void emitCFINegateRAState(SMLoc Loc)
override;
398 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
399 void emitCFIReturnColumn(int64_t
Register)
override;
400 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
401 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
403 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
404 void emitWinCFIEndProc(SMLoc Loc)
override;
405 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
406 void emitWinCFISplitChained(SMLoc Loc)
override;
407 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
410 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
415 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
416 void emitWinCFIEndProlog(SMLoc Loc)
override;
417 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
418 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
419 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
420 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
422 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
424 void emitWinEHHandlerData(SMLoc Loc)
override;
426 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
427 const MCSymbolRefExpr *To, uint64_t
Count)
override;
429 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
431 void emitPseudoProbe(uint64_t
Guid, uint64_t Index, uint64_t
Type,
432 uint64_t Attr, uint64_t Discriminator,
434 MCSymbol *FnSym)
override;
436 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
437 const MCExpr *Expr, SMLoc Loc)
override;
439 void emitAddrsig()
override;
440 void emitAddrsigSym(
const MCSymbol *Sym)
override;
445 void emitRawTextImpl(StringRef
String)
override;
447 void finishImpl()
override;
449 void emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment)
override;
451 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
452 const Twine &Comment)
override;
454 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
456 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
457 MCSymbol *EndLabel =
nullptr)
override;
459 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
460 const MCSymbol *Label,
461 unsigned PointerSize)
override;
466void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
467 if (!IsVerboseAsm)
return;
469 T.toVector(CommentToEmit);
475void MCAsmStreamer::EmitCommentsAndEOL() {
481 StringRef Comments = CommentToEmit;
484 "Comment array not newline terminated");
488 size_t Position = Comments.
find(
'\n');
491 Comments = Comments.
substr(Position+1);
492 }
while (!Comments.
empty());
494 CommentToEmit.
clear();
498 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
499 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
502void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
509void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
510 StringRef c =
T.getSingleStringRef();
514 ExplicitCommentToEmit.
append(
"\t");
519 size_t p = 2, len = c.
size() - 2;
523 ExplicitCommentToEmit.
append(
"\t");
528 ExplicitCommentToEmit.
append(
"\n");
532 ExplicitCommentToEmit.
append(
"\t");
534 }
else if (c.
front() ==
'#') {
536 ExplicitCommentToEmit.
append(
"\t");
540 assert(
false &&
"Unexpected Assembly Comment");
542 if (c.
back() ==
'\n')
543 emitExplicitComments();
546void MCAsmStreamer::emitExplicitComments() {
547 StringRef Comments = ExplicitCommentToEmit;
548 if (!Comments.
empty())
550 ExplicitCommentToEmit.
clear();
553void MCAsmStreamer::switchSection(MCSection *Section, uint32_t Subsection) {
555 if (!EmittedSectionDirective ||
557 EmittedSectionDirective =
true;
558 if (MCTargetStreamer *TS = getTargetStreamer()) {
559 TS->changeSection(Cur.first, Section, Subsection, OS);
568bool MCAsmStreamer::popSection() {
571 auto [Sec, Subsec] = getCurrentSection();
576void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
578 bool KeepOriginalSym) {
580 OriginalSym->
print(OS, MAI);
582 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
587void MCAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
592 if (!
Symbol->isVariable() &&
607 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
608 assert(str !=
"" &&
"Invalid LOH name");
613 for (
const MCSymbol *Arg : Args) {
622void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
623 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
626void MCAsmStreamer::emitSubsectionsViaSymbols() {
627 OS <<
".subsections_via_symbols\n";
630void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string>
Options) {
631 assert(!
Options.empty() &&
"At least one option is required!");
632 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
634 OS <<
", " <<
'"' << Opt <<
'"';
663 if (SDKVersion.
empty())
665 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
666 if (
auto Minor = SDKVersion.
getMinor()) {
667 OS <<
", " << *Minor;
669 OS <<
", " << *Subminor;
675 unsigned Minor,
unsigned Update,
676 VersionTuple SDKVersion) {
679 OS <<
", " << Update;
686#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
688 case MachO::PLATFORM_##platform: \
690#include "llvm/BinaryFormat/MachO.def"
695void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
696 unsigned Minor,
unsigned Update,
697 VersionTuple SDKVersion) {
699 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
701 OS <<
", " << Update;
706void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
707 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
708 VersionTuple SDKVersion) {
709 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
712void MCAsmStreamer::emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value) {
717 OS << (UseSet ?
", " :
" = ");
724void MCAsmStreamer::emitConditionalAssignment(MCSymbol *Symbol,
725 const MCExpr *
Value) {
726 OS <<
".lto_set_conditional ";
733void MCAsmStreamer::emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol) {
735 Alias->
print(OS, MAI);
741bool MCAsmStreamer::emitSymbolAttribute(MCSymbol *Symbol,
758 default:
return false;
781 OS <<
"\t.no_dead_strip\t";
786 OS <<
"\t.private_extern\t";
795 OS <<
"\t.weak_definition\t";
812 OS <<
"\t.weak_anti_dep\t";
822void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue) {
823 OS <<
".desc" <<
' ';
825 OS <<
',' << DescValue;
829void MCAsmStreamer::emitSyntaxDirective(StringRef Syntax, StringRef
Options) {
830 OS <<
"\t." << Syntax <<
"_syntax";
836void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
843void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
848void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
849 OS <<
"\t.type\t" <<
Type <<
';';
853void MCAsmStreamer::endCOFFSymbolDef() {
858void MCAsmStreamer::emitCOFFSafeSEH(MCSymbol
const *Symbol) {
859 OS <<
"\t.safeseh\t";
864void MCAsmStreamer::emitCOFFSymbolIndex(MCSymbol
const *Symbol) {
870void MCAsmStreamer::emitCOFFSectionIndex(MCSymbol
const *Symbol) {
876void MCAsmStreamer::emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset) {
877 OS <<
"\t.secrel32\t";
884void MCAsmStreamer::emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset) {
894void MCAsmStreamer::emitCOFFSecNumber(MCSymbol
const *Symbol) {
900void MCAsmStreamer::emitCOFFSecOffset(MCSymbol
const *Symbol) {
901 OS <<
"\t.secoffset\t";
909void MCAsmStreamer::emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
914 "We only support writing log base-2 alignment format with XCOFF.");
917 LabelSym->
print(OS, MAI);
918 OS <<
',' <<
Size <<
',';
919 CsectSym->
print(OS, MAI);
920 OS <<
',' <<
Log2(Alignment);
926 auto *XSym =
static_cast<MCSymbolXCOFF *
>(CsectSym);
927 if (XSym->hasRename())
928 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
931void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
933 auto &Sym =
static_cast<MCSymbolXCOFF &
>(*Symbol);
953 switch (Visibility) {
974 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
977void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
980 Name->print(OS, MAI);
983 for (
char C : Rename) {
993void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
999void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
1000 const MCSymbol *
Trap,
1003 unsigned FunctionSize,
1005 OS <<
"\t.except\t";
1007 OS <<
", " << Lang <<
", " << Reason;
1011void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata) {
1012 const char InfoDirective[] =
"\t.info ";
1013 const char *Separator =
", ";
1014 constexpr int WordSize =
sizeof(uint32_t);
1017 OS << InfoDirective;
1018 PrintQuotedString(Name, OS);
1021 size_t MetadataSize =
Metadata.size();
1024 OS <<
format_hex(MetadataSize, 10) << Separator;
1027 if (MetadataSize == 0) {
1037 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1038 uint32_t PaddingSize = PaddedSize - MetadataSize;
1045 constexpr int WordsPerDirective = 5;
1048 int WordsBeforeNextDirective = 0;
1049 auto PrintWord = [&](
const uint8_t *WordPtr) {
1050 if (WordsBeforeNextDirective-- == 0) {
1052 OS << InfoDirective;
1053 WordsBeforeNextDirective = WordsPerDirective;
1061 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1062 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1067 assert(PaddedSize - Index == WordSize);
1068 std::array<uint8_t, WordSize> LastWord = {0};
1069 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1070 PrintWord(LastWord.data());
1075void MCAsmStreamer::emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value) {
1084void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1085 Align ByteAlignment) {
1093 OS <<
',' <<
Log2(ByteAlignment);
1099 auto *XSym =
static_cast<MCSymbolXCOFF *
>(
Symbol);
1100 if (XSym && XSym->hasRename())
1101 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1105void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1111 if (ByteAlign > 1) {
1116 OS <<
',' << ByteAlign.
value();
1119 OS <<
',' <<
Log2(ByteAlign);
1126void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
1127 uint64_t
Size, Align ByteAlignment,
1136 ".zerofill is a Mach-O specific directive");
1139 const MCSectionMachO *MOSection = ((
const MCSectionMachO*)Section);
1146 OS <<
',' <<
Log2(ByteAlignment);
1154void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
1155 uint64_t
Size, Align ByteAlignment) {
1161 ".zerofill is a Mach-O specific directive");
1170 if (ByteAlignment > 1)
1171 OS <<
", " <<
Log2(ByteAlignment);
1177 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1178 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1189 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1190 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1196 const auto printOneCharacterFor = [printCharacterInOctal](
1197 auto printOnePrintingCharacter) {
1198 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1200 printOnePrintingCharacter(
static_cast<char>(
C));
1203 printCharacterInOctal(
C);
1206 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1207 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1208 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1209 printOneCharacter(
C);
1212 printOneCharacter(*(EndPtr - 1));
1216 printCharacterList(printCharacterInOctal);
1219 printCharacterList(printOneCharacterFor([&OS](
char C) {
1220 const char AsmCharLitBuf[2] = {
'\'',
C};
1221 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1228void MCAsmStreamer::PrintQuotedString(StringRef
Data, raw_ostream &OS)
const {
1232 for (
unsigned char C :
Data) {
1239 for (
unsigned char C :
Data) {
1240 if (
C ==
'"' ||
C ==
'\\') {
1241 OS <<
'\\' << (char)
C;
1279void MCAsmStreamer::emitBytes(StringRef
Data) {
1280 assert(getCurrentSectionOnly() &&
1281 "Cannot emit contents before setting section!");
1282 if (
Data.empty())
return;
1284 const auto emitAsString = [
this](StringRef
Data) {
1289 if (
Data.back() == 0) {
1290 OS <<
"\t.string\t";
1295 PrintQuotedString(
Data, OS);
1315 PrintQuotedString(
Data, OS);
1320 if (
Data.size() != 1 && emitAsString(
Data))
1325 if (MCTargetStreamer *TS = getTargetStreamer()) {
1326 TS->emitRawBytes(
Data);
1330 for (
const unsigned char C :
Data.bytes()) {
1331 OS << Directive << (unsigned)
C;
1336void MCAsmStreamer::emitBinaryData(StringRef
Data) {
1338 const size_t Cols = 4;
1339 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1340 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1343 for (; J < EJ - 1; ++J)
1344 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1350void MCAsmStreamer::emitIntValue(uint64_t
Value,
unsigned Size) {
1354void MCAsmStreamer::emitIntValueInHex(uint64_t
Value,
unsigned Size) {
1358void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t
Value,
1363void MCAsmStreamer::emitValueImpl(
const MCExpr *
Value,
unsigned Size,
1366 assert(getCurrentSectionOnly() &&
1367 "Cannot emit contents before setting section!");
1368 const char *Directive =
nullptr;
1379 if (!
Value->evaluateAsAbsolute(IntValue))
1394 unsigned ByteOffset =
1395 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1396 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1400 uint64_t Shift = 64 - EmissionSize * 8;
1401 assert(Shift <
static_cast<uint64_t
>(
1402 std::numeric_limits<unsigned long long>::digits) &&
1403 "undefined behavior");
1404 ValueToEmit &= ~0ULL >> Shift;
1405 emitIntValue(ValueToEmit, EmissionSize);
1411 assert(Directive &&
"Invalid size for machine code value!");
1413 if (MCTargetStreamer *TS = getTargetStreamer()) {
1414 TS->emitValue(
Value);
1421void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1423 if (
Value->evaluateAsAbsolute(IntValue)) {
1424 emitULEB128IntValue(IntValue);
1427 OS <<
"\t.uleb128 ";
1432void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1434 if (
Value->evaluateAsAbsolute(IntValue)) {
1435 emitSLEB128IntValue(IntValue);
1438 OS <<
"\t.sleb128 ";
1443void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1445 int64_t IntNumBytes;
1446 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1447 if (IsAbsolute && IntNumBytes == 0)
1451 if (!MAI->
isAIX() || FillValue == 0) {
1453 OS << ZeroDirective;
1456 OS <<
',' << (int)FillValue;
1461 "Cannot emit non-absolute expression lengths of fill.");
1462 for (
int i = 0; i < IntNumBytes; ++i) {
1473void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1474 int64_t Expr, SMLoc Loc) {
1478 OS <<
", " <<
Size <<
", 0x";
1483void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
1484 std::optional<int64_t>
Value,
1486 unsigned MaxBytesToEmit) {
1500 switch (ValueSize) {
1504 OS <<
"\t.p2align\t";
1518 if (
Value.has_value() || MaxBytesToEmit) {
1519 if (
Value.has_value()) {
1527 OS <<
", " << MaxBytesToEmit;
1535 switch (ValueSize) {
1537 case 1: OS <<
".balign";
break;
1538 case 2: OS <<
".balignw";
break;
1539 case 4: OS <<
".balignl";
break;
1544 if (
Value.has_value())
1546 else if (MaxBytesToEmit)
1549 OS <<
", " << MaxBytesToEmit;
1553void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
1555 unsigned MaxBytesToEmit) {
1556 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1559void MCAsmStreamer::emitCodeAlignment(Align Alignment,
1560 const MCSubtargetInfo *STI,
1561 unsigned MaxBytesToEmit) {
1567 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1570void MCAsmStreamer::emitPrefAlign(Align Alignment,
const MCSymbol &End,
1571 bool EmitNops, uint8_t Fill,
1572 const MCSubtargetInfo &) {
1573 OS <<
"\t.prefalign\t" <<
Log2(Alignment) <<
", ";
1578 OS <<
", " <<
static_cast<unsigned>(Fill);
1582void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1583 unsigned char Value,
1588 OS <<
", " << (unsigned)
Value;
1592void MCAsmStreamer::emitFileDirective(StringRef
Filename) {
1599void MCAsmStreamer::emitFileDirective(StringRef
Filename,
1600 StringRef CompilerVersion,
1601 StringRef TimeStamp,
1602 StringRef Description) {
1606 bool useTimeStamp = !TimeStamp.
empty();
1607 bool useCompilerVersion = !CompilerVersion.
empty();
1608 bool useDescription = !Description.
empty();
1609 if (useTimeStamp || useCompilerVersion || useDescription) {
1612 PrintQuotedString(TimeStamp, OS);
1613 if (useCompilerVersion || useDescription) {
1615 if (useCompilerVersion)
1616 PrintQuotedString(CompilerVersion, OS);
1617 if (useDescription) {
1619 PrintQuotedString(Description, OS);
1626void MCAsmStreamer::printDwarfFileDirective(
1627 unsigned FileNo, StringRef Directory, StringRef
Filename,
1628 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1629 bool UseDwarfDirectory, raw_svector_ostream &OS)
const {
1630 SmallString<128> FullPathName;
1632 if (!UseDwarfDirectory && !Directory.
empty()) {
1636 FullPathName = Directory;
1643 OS <<
"\t.file\t" << FileNo <<
' ';
1644 if (!Directory.
empty()) {
1645 PrintQuotedString(Directory, OS);
1650 OS <<
" md5 0x" << Checksum->digest();
1653 PrintQuotedString(*Source, OS);
1657Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
1658 unsigned FileNo, StringRef Directory, StringRef
Filename,
1659 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1661 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1663 MCDwarfLineTable &Table =
getContext().getMCDwarfLineTable(CUID);
1665 Expected<unsigned> FileNoOrErr =
1670 FileNo = FileNoOrErr.
get();
1677 SmallString<128> Str;
1678 raw_svector_ostream OS1(Str);
1679 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1680 UseDwarfDirectory, OS1);
1682 if (MCTargetStreamer *TS = getTargetStreamer())
1683 TS->emitDwarfFileDirective(OS1.str());
1685 emitRawText(OS1.str());
1690void MCAsmStreamer::emitDwarfFile0Directive(
1691 StringRef Directory, StringRef
Filename,
1692 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1706 SmallString<128> Str;
1707 raw_svector_ostream OS1(Str);
1708 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1709 UseDwarfDirectory, OS1);
1711 if (MCTargetStreamer *TS = getTargetStreamer())
1712 TS->emitDwarfFileDirective(OS1.str());
1714 emitRawText(OS1.str());
1718void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1719 unsigned Discriminator) {
1724 OS <<
" basic_block";
1726 OS <<
" prologue_end";
1728 OS <<
" epilogue_begin";
1730 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1737 OS <<
" isa " << Isa;
1743void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1744 unsigned Column,
unsigned Flags,
1746 unsigned Discriminator,
1748 StringRef Comment) {
1750 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1757 OS << FileName <<
':' <<
Line <<
':' << Column;
1765 Discriminator, FileName, Comment);
1768void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1769 unsigned Column,
unsigned Flags,
1770 unsigned Isa,
unsigned Discriminator,
1772 StringRef Comment) {
1780 Discriminator, FileName, Comment);
1785 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1788 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1794void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1795 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1796 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1797 unsigned Isa,
unsigned Discriminator, StringRef FileName,
1798 StringRef Comment) {
1800 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1801 OS <<
", function_name " << *Sym;
1802 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1805 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1809void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {
1811 OS <<
".loc_label\t" <<
Name;
1815MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1821bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
1822 ArrayRef<uint8_t> Checksum,
1823 unsigned ChecksumKind) {
1828 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1831 if (!ChecksumKind) {
1837 PrintQuotedString(
toHex(Checksum), OS);
1844bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1845 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1849bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1852 unsigned IALine,
unsigned IACol,
1854 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1855 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1857 IALine, IACol, Loc);
1860void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1861 unsigned Line,
unsigned Column,
1862 bool PrologueEnd,
bool IsStmt,
1863 StringRef FileName, SMLoc Loc) {
1865 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1868 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1871 OS <<
" prologue_end";
1884void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1885 const MCSymbol *FnStart,
1886 const MCSymbol *FnEnd) {
1887 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1888 FnStart->
print(OS, MAI);
1890 FnEnd->
print(OS, MAI);
1895void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1896 unsigned SourceFileId,
1897 unsigned SourceLineNum,
1898 const MCSymbol *FnStartSym,
1899 const MCSymbol *FnEndSym) {
1900 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1901 <<
' ' << SourceLineNum <<
' ';
1902 FnStartSym->
print(OS, MAI);
1904 FnEndSym->
print(OS, MAI);
1907 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1910void MCAsmStreamer::PrintCVDefRangePrefix(
1911 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1912 OS <<
"\t.cv_def_range\t";
1913 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1921void MCAsmStreamer::emitCVDefRangeDirective(
1922 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1923 codeview::DefRangeRegisterRelHeader DRHdr) {
1924 PrintCVDefRangePrefix(Ranges);
1925 OS <<
", reg_rel, ";
1931void MCAsmStreamer::emitCVDefRangeDirective(
1932 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1933 codeview::DefRangeSubfieldRegisterHeader DRHdr) {
1934 PrintCVDefRangePrefix(Ranges);
1935 OS <<
", subfield_reg, ";
1940void MCAsmStreamer::emitCVDefRangeDirective(
1941 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1942 codeview::DefRangeRegisterHeader DRHdr) {
1943 PrintCVDefRangePrefix(Ranges);
1949void MCAsmStreamer::emitCVDefRangeDirective(
1950 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1951 codeview::DefRangeFramePointerRelHeader DRHdr) {
1952 PrintCVDefRangePrefix(Ranges);
1953 OS <<
", frame_ptr_rel, ";
1958void MCAsmStreamer::emitCVDefRangeDirective(
1959 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1960 codeview::DefRangeRegisterRelIndirHeader DRHdr) {
1961 PrintCVDefRangePrefix(Ranges);
1962 OS <<
", reg_rel_indir, ";
1968void MCAsmStreamer::emitCVStringTableDirective() {
1969 OS <<
"\t.cv_stringtable";
1973void MCAsmStreamer::emitCVFileChecksumsDirective() {
1974 OS <<
"\t.cv_filechecksums";
1978void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1979 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1983void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L) {
1984 OS <<
"\t.cv_fpo_data\t";
1985 ProcSym->
print(OS, MAI);
1989void MCAsmStreamer::emitIdent(StringRef IdentString) {
1992 PrintQuotedString(IdentString, OS);
1996void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
1998 OS <<
"\t.cfi_sections ";
2007 OS <<
".debug_frame";
2019void MCAsmStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
2020 OS <<
"\t.cfi_startproc";
2026void MCAsmStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
2028 OS <<
"\t.cfi_endproc";
2032void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2037 const MCRegisterInfo *MRI =
getContext().getRegisterInfo();
2038 if (std::optional<MCRegister> LLVMRegister =
2040 InstPrinter->printRegName(OS, *LLVMRegister);
2047void MCAsmStreamer::emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2049 OS <<
"\t.cfi_def_cfa ";
2055void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc) {
2057 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2061void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2064 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2072 OS <<
"\t.cfi_escape ";
2073 if (!Values.
empty()) {
2074 size_t e = Values.
size() - 1;
2075 for (
size_t i = 0; i < e; ++i)
2081void MCAsmStreamer::emitCFIEscape(StringRef Values, SMLoc Loc) {
2087void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc) {
2090 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2097void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc) {
2099 OS <<
"\t.cfi_def_cfa_register ";
2104void MCAsmStreamer::emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2106 OS <<
"\t.cfi_offset ";
2112void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2113 unsigned Encoding) {
2115 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2116 Sym->
print(OS, MAI);
2120void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2122 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2123 Sym->
print(OS, MAI);
2127void MCAsmStreamer::emitCFIRememberState(SMLoc Loc) {
2129 OS <<
"\t.cfi_remember_state";
2133void MCAsmStreamer::emitCFIRestoreState(SMLoc Loc) {
2135 OS <<
"\t.cfi_restore_state";
2139void MCAsmStreamer::emitCFIRestore(int64_t
Register, SMLoc Loc) {
2141 OS <<
"\t.cfi_restore ";
2146void MCAsmStreamer::emitCFISameValue(int64_t
Register, SMLoc Loc) {
2148 OS <<
"\t.cfi_same_value ";
2153void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2156 OS <<
"\t.cfi_rel_offset ";
2162void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
2164 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2168void MCAsmStreamer::emitCFISignalFrame() {
2170 OS <<
"\t.cfi_signal_frame";
2174void MCAsmStreamer::emitCFIUndefined(int64_t
Register, SMLoc Loc) {
2176 OS <<
"\t.cfi_undefined ";
2181void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2184 OS <<
"\t.cfi_register ";
2185 EmitRegisterName(Register1);
2187 EmitRegisterName(Register2);
2191void MCAsmStreamer::emitCFIWindowSave(SMLoc Loc) {
2193 OS <<
"\t.cfi_window_save";
2197void MCAsmStreamer::emitCFINegateRAState(SMLoc Loc) {
2199 OS <<
"\t.cfi_negate_ra_state";
2203void MCAsmStreamer::emitCFINegateRAStateWithPC(SMLoc Loc) {
2205 OS <<
"\t.cfi_negate_ra_state_with_pc";
2209void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2211 OS <<
"\t.cfi_return_column ";
2216void MCAsmStreamer::emitCFILabelDirective(SMLoc Loc, StringRef Name) {
2218 OS <<
"\t.cfi_label " <<
Name;
2222void MCAsmStreamer::emitCFIBKeyFrame() {
2224 OS <<
"\t.cfi_b_key_frame";
2228void MCAsmStreamer::emitCFIMTETaggedFrame() {
2230 OS <<
"\t.cfi_mte_tagged_frame";
2234void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2237 OS <<
"\t.cfi_val_offset ";
2243void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc) {
2251void MCAsmStreamer::emitWinCFIEndProc(SMLoc Loc) {
2254 OS <<
"\t.seh_endproc";
2258void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(SMLoc Loc) {
2261 OS <<
"\t.seh_endfunclet";
2265void MCAsmStreamer::emitWinCFISplitChained(SMLoc Loc) {
2268 OS <<
"\t.seh_splitchained";
2272void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2273 bool Except, SMLoc Loc) {
2276 OS <<
"\t.seh_handler ";
2277 Sym->
print(OS, MAI);
2283 OS <<
", " << Marker <<
"unwind";
2285 OS <<
", " << Marker <<
"except";
2289void MCAsmStreamer::emitWinEHHandlerData(SMLoc Loc) {
2296 WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
2304 MCSection *XData = getAssociatedXDataSection(TextSec);
2305 switchSectionNoPrint(XData);
2307 OS <<
"\t.seh_handlerdata";
2311void MCAsmStreamer::emitWinCFIPushReg(MCRegister
Register, SMLoc Loc) {
2314 OS <<
"\t.seh_pushreg ";
2315 InstPrinter->printRegName(OS,
Register);
2319void MCAsmStreamer::emitWinCFISetFrame(MCRegister
Register,
unsigned Offset,
2323 OS <<
"\t.seh_setframe ";
2324 InstPrinter->printRegName(OS,
Register);
2329void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size, SMLoc Loc) {
2332 OS <<
"\t.seh_stackalloc " <<
Size;
2336void MCAsmStreamer::emitWinCFISaveReg(MCRegister
Register,
unsigned Offset,
2340 OS <<
"\t.seh_savereg ";
2341 InstPrinter->printRegName(OS,
Register);
2346void MCAsmStreamer::emitWinCFISaveXMM(MCRegister
Register,
unsigned Offset,
2350 OS <<
"\t.seh_savexmm ";
2351 InstPrinter->printRegName(OS,
Register);
2356void MCAsmStreamer::emitWinCFIPushFrame(
bool Code, SMLoc Loc) {
2359 OS <<
"\t.seh_pushframe";
2365void MCAsmStreamer::emitWinCFIEndProlog(SMLoc Loc) {
2368 OS <<
"\t.seh_endprologue";
2372void MCAsmStreamer::emitWinCFIBeginEpilogue(SMLoc Loc) {
2375 OS <<
"\t.seh_startepilogue";
2379void MCAsmStreamer::emitWinCFIEndEpilogue(SMLoc Loc) {
2382 OS <<
"\t.seh_endepilogue";
2386void MCAsmStreamer::emitWinCFIUnwindV2Start(SMLoc Loc) {
2389 OS <<
"\t.seh_unwindv2start";
2393void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc) {
2396 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2400void MCAsmStreamer::emitCGProfileEntry(
const MCSymbolRefExpr *From,
2401 const MCSymbolRefExpr *To,
2403 OS <<
"\t.cg_profile ";
2407 OS <<
", " <<
Count;
2411void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2412 const MCSubtargetInfo &STI) {
2413 raw_ostream &OS = getCommentOS();
2414 SmallString<256>
Code;
2418 if (!getAssembler().getEmitterPtr())
2421 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2424 bool ForceLE =
getContext().getTargetTriple().isRISCV();
2431 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2434 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2436 MCFixupKindInfo
Info =
2437 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2438 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2439 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2440 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2441 FixupMap[
Index] = 1 + i;
2447 OS <<
"encoding: [";
2448 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2453 uint8_t MapEntry = FixupMap[i * 8 + 0];
2454 for (
unsigned j = 1;
j != 8; ++
j) {
2455 if (FixupMap[i * 8 + j] == MapEntry)
2458 MapEntry = uint8_t(~0U);
2462 if (MapEntry != uint8_t(~0U)) {
2463 if (MapEntry == 0) {
2464 OS <<
format(
"0x%02x", uint8_t(Code[i]));
2468 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\''
2469 << char(
'A' + MapEntry - 1) <<
'\'';
2471 OS << char(
'A' + MapEntry - 1);
2476 for (
unsigned j = 8;
j--;) {
2484 FixupBit = i * 8 +
j;
2486 FixupBit = i * 8 + (7-
j);
2488 if (uint8_t MapEntry = FixupMap[FixupBit]) {
2489 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2490 OS << char(
'A' + MapEntry - 1);
2498 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2500 OS <<
" fixup " << char(
'A' + i) <<
" - "
2501 <<
"offset: " <<
F.getOffset() <<
", value: ";
2503 auto Kind =
F.getKind();
2505 OS <<
", relocation type: " <<
Kind;
2508 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2509 if (
F.isPCRel() && StringRef(
Info.Name).starts_with(
"FK_Data_"))
2510 OS <<
"FK_PCRel_" << (
Info.TargetSize / 8);
2518void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2519 const MCSubtargetInfo &STI) {
2520 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2524 MCSection *Sec = getCurrentSectionOnly();
2528 if (MAI->
isAIX() && CurFrag)
2534 AddEncodingComment(Inst, STI);
2539 getCommentOS() <<
"\n";
2542 if(getTargetStreamer())
2543 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2545 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2547 StringRef Comments = CommentToEmit;
2548 if (Comments.
size() && Comments.
back() !=
'\n')
2549 getCommentOS() <<
"\n";
2554void MCAsmStreamer::emitPseudoProbe(uint64_t
Guid, uint64_t Index,
2555 uint64_t
Type, uint64_t Attr,
2556 uint64_t Discriminator,
2559 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2564 for (
const auto &Site : InlineStack)
2565 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2568 FnSym->
print(OS, MAI);
2573void MCAsmStreamer::emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
2574 const MCExpr *Expr, SMLoc) {
2585void MCAsmStreamer::emitAddrsig() {
2590void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2591 OS <<
"\t.addrsig_sym ";
2592 Sym->
print(OS, MAI);
2599void MCAsmStreamer::emitRawTextImpl(StringRef
String) {
2600 String.consume_back(
"\n");
2605void MCAsmStreamer::finishImpl() {
2623 const auto &Tables =
getContext().getMCDwarfLineTables();
2624 if (!Tables.empty()) {
2625 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2626 if (
auto *Label = Tables.begin()->second.getLabel()) {
2627 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2633void MCAsmStreamer::emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment) {
2645MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2646 const Twine &Comment) {
2654 return getContext().createTempSymbol(Prefix +
"_end");
2658void MCAsmStreamer::emitDwarfLineStartLabel(MCSymbol *StartSym) {
2669 emitLabel(DebugLineSymTmp);
2673 unsigned LengthFieldSize =
2679 emitAssignment(StartSym, OuterSym);
2685void MCAsmStreamer::emitDwarfLineEndEntry(MCSection *Section,
2686 MCSymbol *LastLabel,
2687 MCSymbol *EndLabel) {
2694 ".loc should not be generated together with raw data!");
2707 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2712void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2713 const MCSymbol *LastLabel,
2714 const MCSymbol *Label,
2715 unsigned PointerSize) {
2717 ".loc/.file don't need raw data in debug line section!");
2720 AddComment(
"Set address to " +
Label->getName());
2721 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2722 emitULEB128IntValue(PointerSize + 1);
2723 emitIntValue(dwarf::DW_LNE_set_address, 1);
2724 emitSymbolValue(Label, PointerSize);
2728 AddComment(
"Start sequence");
2736 AddComment(
"End sequence");
2737 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2738 emitULEB128IntValue(1);
2739 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2744 AddComment(
"Advance line " + Twine(LineDelta));
2745 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2746 emitSLEB128IntValue(LineDelta);
2747 emitIntValue(dwarf::DW_LNS_copy, 1);
2751 std::unique_ptr<formatted_raw_ostream> OS,
2752 std::unique_ptr<MCInstPrinter> IP,
2753 std::unique_ptr<MCCodeEmitter> CE,
2754 std::unique_ptr<MCAsmBackend> MAB) {
2755 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)
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
This file defines the SmallString class.
StringRef getMnemonic(unsigned Opc)
LLVM_ABI void print(raw_ostream &OS) const
Print out the bounds to a stream.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
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.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
const MCAsmInfo * getAsmInfo() const
dwarf::DwarfFormat getDwarfFormat() const
static LLVM_ABI void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
static LLVM_ABI void make(MCStreamer *MCOS, MCSection *Section)
static LLVM_ABI void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
static LLVM_ABI void Emit(MCStreamer *MCOS)
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
std::optional< MCRegister > getLLVMRegNum(uint64_t RegNum, bool isEH) const
Map a dwarf register back to a target register.
StringRef getSegmentName() const
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 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 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)
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.
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 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 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={})
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
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.
void append(StringRef RHS)
Append from a StringRef.
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
char back() const
back - Get the last character in the string.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
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.
size_t GetNumBytesInBuffer() const
#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.
NodeAddr< CodeNode * > Code
Context & getContext() const
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.
FunctionAddr VTableAddr Value
@ 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
MCLOHDirective::LOHArgs MCLOHArgs
LLVM_ABI void emitLFINoteSection(MCStreamer &Streamer, MCContext &Ctx)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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.
FunctionAddr VTableAddr Count
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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)
FunctionAddr VTableAddr uintptr_t uintptr_t Data
MCLOHType
Linker Optimization Hint Type.
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)
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
const MCSymbol * Function