46 std::unique_ptr<formatted_raw_ostream> OSOwner;
47 formatted_raw_ostream &OS;
49 std::unique_ptr<MCInstPrinter> InstPrinter;
50 std::unique_ptr<MCAssembler> Assembler;
52 SmallString<128> ExplicitCommentToEmit;
53 SmallString<128> CommentToEmit;
54 raw_svector_ostream CommentStream;
55 raw_null_ostream NullStream;
57 bool EmittedSectionDirective =
false;
59 bool IsVerboseAsm =
false;
60 bool ShowInst =
false;
61 bool UseDwarfDirectory =
false;
63 void EmitRegisterName(int64_t
Register);
64 void PrintQuotedString(StringRef
Data, raw_ostream &OS)
const;
65 void printDwarfFileDirective(
unsigned FileNo, StringRef Directory,
67 std::optional<MD5::MD5Result> Checksum,
68 std::optional<StringRef> Source,
69 bool UseDwarfDirectory,
70 raw_svector_ostream &OS)
const;
71 void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
override;
72 void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame)
override;
75 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
76 unsigned Discriminator);
80 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
81 unsigned Column,
unsigned Flags,
82 unsigned Isa,
unsigned Discriminator,
83 StringRef FileName, StringRef Comment);
86 MCAsmStreamer(MCContext &
Context, std::unique_ptr<formatted_raw_ostream> os,
87 std::unique_ptr<MCInstPrinter>
printer,
88 std::unique_ptr<MCCodeEmitter> emitter,
89 std::unique_ptr<MCAsmBackend> asmbackend)
90 : MCStreamer(
Context), OSOwner(std::
move(os)), OS(*OSOwner),
92 Assembler(std::make_unique<MCAssembler>(
94 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
96 CommentStream(CommentToEmit) {
98 if (Assembler->getBackendPtr())
99 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
101 Context.setUseNamesOnTempLabels(
true);
103 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)
override;
291 void emitValueToOffset(
const MCExpr *
Offset,
295 void emitFileDirective(StringRef
Filename)
override;
296 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
297 StringRef TimeStamp, StringRef Description)
override;
298 Expected<unsigned> tryEmitDwarfFileDirective(
299 unsigned FileNo, StringRef Directory, StringRef
Filename,
300 std::optional<MD5::MD5Result> Checksum = std::nullopt,
301 std::optional<StringRef> Source = std::nullopt,
302 unsigned CUID = 0)
override;
303 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
304 std::optional<MD5::MD5Result> Checksum,
305 std::optional<StringRef> Source,
306 unsigned CUID = 0)
override;
307 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
308 unsigned Flags,
unsigned Isa,
309 unsigned Discriminator, StringRef FileName,
310 StringRef Location = {})
override;
311 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
315 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
316 unsigned Column,
unsigned FileIA,
317 unsigned LineIA,
unsigned ColIA,
318 const MCSymbol *Sym,
unsigned Flags,
319 unsigned Isa,
unsigned Discriminator,
321 StringRef Comment = {})
override;
323 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
325 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
326 ArrayRef<uint8_t> Checksum,
327 unsigned ChecksumKind)
override;
328 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
329 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
330 unsigned IAFile,
unsigned IALine,
331 unsigned IACol, SMLoc Loc)
override;
332 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
333 unsigned Column,
bool PrologueEnd,
bool IsStmt,
334 StringRef FileName, SMLoc Loc)
override;
335 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
336 const MCSymbol *FnEnd)
override;
337 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
338 unsigned SourceFileId,
339 unsigned SourceLineNum,
340 const MCSymbol *FnStartSym,
341 const MCSymbol *FnEndSym)
override;
343 void PrintCVDefRangePrefix(
344 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
346 void emitCVDefRangeDirective(
347 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
348 codeview::DefRangeRegisterRelHeader DRHdr)
override;
350 void emitCVDefRangeDirective(
351 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
352 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
354 void emitCVDefRangeDirective(
355 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
356 codeview::DefRangeRegisterHeader DRHdr)
override;
358 void emitCVDefRangeDirective(
359 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
360 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
362 void emitCVStringTableDirective()
override;
363 void emitCVFileChecksumsDirective()
override;
364 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
365 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
367 void emitIdent(StringRef IdentString)
override;
368 void emitCFIBKeyFrame()
override;
369 void emitCFIMTETaggedFrame()
override;
370 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
371 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
372 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
373 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
376 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
377 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
378 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
379 void emitCFIRememberState(SMLoc Loc)
override;
380 void emitCFIRestoreState(SMLoc Loc)
override;
381 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
382 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
383 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
384 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
385 void emitCFIEscape(StringRef Values, SMLoc Loc)
override;
386 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
387 void emitCFISignalFrame()
override;
388 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
389 void emitCFIRegister(int64_t Register1, int64_t Register2,
391 void emitCFIWindowSave(SMLoc Loc)
override;
392 void emitCFINegateRAState(SMLoc Loc)
override;
393 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
394 void emitCFIReturnColumn(int64_t
Register)
override;
395 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
396 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
398 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
399 void emitWinCFIEndProc(SMLoc Loc)
override;
400 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
401 void emitWinCFISplitChained(SMLoc Loc)
override;
402 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
405 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
410 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
411 void emitWinCFIEndProlog(SMLoc Loc)
override;
412 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
413 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
414 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
415 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
417 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
419 void emitWinEHHandlerData(SMLoc Loc)
override;
421 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
422 const MCSymbolRefExpr *To, uint64_t
Count)
override;
424 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
426 void emitPseudoProbe(uint64_t
Guid, uint64_t Index, uint64_t
Type,
427 uint64_t Attr, uint64_t Discriminator,
429 MCSymbol *FnSym)
override;
431 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
432 const MCExpr *Expr, SMLoc Loc)
override;
434 void emitAddrsig()
override;
435 void emitAddrsigSym(
const MCSymbol *Sym)
override;
440 void emitRawTextImpl(StringRef
String)
override;
442 void finishImpl()
override;
444 void emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment)
override;
446 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
447 const Twine &Comment)
override;
449 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
451 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
452 MCSymbol *EndLabel =
nullptr)
override;
454 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
455 const MCSymbol *Label,
456 unsigned PointerSize)
override;
461void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
462 if (!IsVerboseAsm)
return;
464 T.toVector(CommentToEmit);
470void MCAsmStreamer::EmitCommentsAndEOL() {
476 StringRef Comments = CommentToEmit;
479 "Comment array not newline terminated");
483 size_t Position = Comments.
find(
'\n');
486 Comments = Comments.
substr(Position+1);
487 }
while (!Comments.
empty());
489 CommentToEmit.
clear();
493 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
494 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
497void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
504void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
505 StringRef c =
T.getSingleStringRef();
509 ExplicitCommentToEmit.
append(
"\t");
514 size_t p = 2, len = c.
size() - 2;
518 ExplicitCommentToEmit.
append(
"\t");
523 ExplicitCommentToEmit.
append(
"\n");
527 ExplicitCommentToEmit.
append(
"\t");
529 }
else if (c.
front() ==
'#') {
531 ExplicitCommentToEmit.
append(
"\t");
535 assert(
false &&
"Unexpected Assembly Comment");
537 if (c.
back() ==
'\n')
538 emitExplicitComments();
541void MCAsmStreamer::emitExplicitComments() {
542 StringRef Comments = ExplicitCommentToEmit;
543 if (!Comments.
empty())
545 ExplicitCommentToEmit.
clear();
548void MCAsmStreamer::switchSection(MCSection *Section, uint32_t Subsection) {
550 if (!EmittedSectionDirective ||
552 EmittedSectionDirective =
true;
553 if (MCTargetStreamer *TS = getTargetStreamer()) {
554 TS->changeSection(Cur.first, Section, Subsection, OS);
563bool MCAsmStreamer::popSection() {
566 auto [Sec, Subsec] = getCurrentSection();
571void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
573 bool KeepOriginalSym) {
575 OriginalSym->
print(OS, MAI);
577 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
582void MCAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
587 if (!
Symbol->isVariable() &&
602 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
603 assert(str !=
"" &&
"Invalid LOH name");
608 for (
const MCSymbol *Arg : Args) {
617void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
618 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
621void MCAsmStreamer::emitSubsectionsViaSymbols() {
622 OS <<
".subsections_via_symbols\n";
625void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string>
Options) {
626 assert(!
Options.empty() &&
"At least one option is required!");
627 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
629 OS <<
", " <<
'"' << Opt <<
'"';
658 if (SDKVersion.
empty())
660 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
661 if (
auto Minor = SDKVersion.
getMinor()) {
662 OS <<
", " << *Minor;
664 OS <<
", " << *Subminor;
670 unsigned Minor,
unsigned Update,
671 VersionTuple SDKVersion) {
674 OS <<
", " << Update;
681#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
683 case MachO::PLATFORM_##platform: \
685#include "llvm/BinaryFormat/MachO.def"
690void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
691 unsigned Minor,
unsigned Update,
692 VersionTuple SDKVersion) {
694 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
696 OS <<
", " << Update;
701void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
702 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
703 VersionTuple SDKVersion) {
704 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
707void MCAsmStreamer::emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value) {
712 OS << (UseSet ?
", " :
" = ");
719void MCAsmStreamer::emitConditionalAssignment(MCSymbol *Symbol,
720 const MCExpr *
Value) {
721 OS <<
".lto_set_conditional ";
728void MCAsmStreamer::emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol) {
730 Alias->
print(OS, MAI);
736bool MCAsmStreamer::emitSymbolAttribute(MCSymbol *Symbol,
753 default:
return false;
776 OS <<
"\t.no_dead_strip\t";
781 OS <<
"\t.private_extern\t";
790 OS <<
"\t.weak_definition\t";
807 OS <<
"\t.weak_anti_dep\t";
817void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue) {
818 OS <<
".desc" <<
' ';
820 OS <<
',' << DescValue;
824void MCAsmStreamer::emitSyntaxDirective(StringRef Syntax, StringRef
Options) {
825 OS <<
"\t." << Syntax <<
"_syntax";
831void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
838void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
843void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
844 OS <<
"\t.type\t" <<
Type <<
';';
848void MCAsmStreamer::endCOFFSymbolDef() {
853void MCAsmStreamer::emitCOFFSafeSEH(MCSymbol
const *Symbol) {
854 OS <<
"\t.safeseh\t";
859void MCAsmStreamer::emitCOFFSymbolIndex(MCSymbol
const *Symbol) {
865void MCAsmStreamer::emitCOFFSectionIndex(MCSymbol
const *Symbol) {
871void MCAsmStreamer::emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset) {
872 OS <<
"\t.secrel32\t";
879void MCAsmStreamer::emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset) {
889void MCAsmStreamer::emitCOFFSecNumber(MCSymbol
const *Symbol) {
895void MCAsmStreamer::emitCOFFSecOffset(MCSymbol
const *Symbol) {
896 OS <<
"\t.secoffset\t";
904void MCAsmStreamer::emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
909 "We only support writing log base-2 alignment format with XCOFF.");
912 LabelSym->
print(OS, MAI);
913 OS <<
',' <<
Size <<
',';
914 CsectSym->
print(OS, MAI);
915 OS <<
',' <<
Log2(Alignment);
921 auto *XSym =
static_cast<MCSymbolXCOFF *
>(CsectSym);
922 if (XSym->hasRename())
923 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
926void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
928 auto &Sym =
static_cast<MCSymbolXCOFF &
>(*Symbol);
948 switch (Visibility) {
969 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
972void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
975 Name->print(OS, MAI);
978 for (
char C : Rename) {
988void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
994void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
995 const MCSymbol *
Trap,
998 unsigned FunctionSize,
1000 OS <<
"\t.except\t";
1002 OS <<
", " << Lang <<
", " << Reason;
1006void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata) {
1007 const char InfoDirective[] =
"\t.info ";
1008 const char *Separator =
", ";
1009 constexpr int WordSize =
sizeof(uint32_t);
1012 OS << InfoDirective;
1013 PrintQuotedString(Name, OS);
1016 size_t MetadataSize =
Metadata.size();
1019 OS <<
format_hex(MetadataSize, 10) << Separator;
1022 if (MetadataSize == 0) {
1032 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1033 uint32_t PaddingSize = PaddedSize - MetadataSize;
1040 constexpr int WordsPerDirective = 5;
1043 int WordsBeforeNextDirective = 0;
1044 auto PrintWord = [&](
const uint8_t *WordPtr) {
1045 if (WordsBeforeNextDirective-- == 0) {
1047 OS << InfoDirective;
1048 WordsBeforeNextDirective = WordsPerDirective;
1056 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1057 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1062 assert(PaddedSize - Index == WordSize);
1063 std::array<uint8_t, WordSize> LastWord = {0};
1064 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1065 PrintWord(LastWord.data());
1070void MCAsmStreamer::emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value) {
1079void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1080 Align ByteAlignment) {
1088 OS <<
',' <<
Log2(ByteAlignment);
1094 auto *XSym =
static_cast<MCSymbolXCOFF *
>(
Symbol);
1095 if (XSym && XSym->hasRename())
1096 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1100void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1106 if (ByteAlign > 1) {
1111 OS <<
',' << ByteAlign.
value();
1114 OS <<
',' <<
Log2(ByteAlign);
1121void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
1122 uint64_t
Size, Align ByteAlignment,
1131 ".zerofill is a Mach-O specific directive");
1134 const MCSectionMachO *MOSection = ((
const MCSectionMachO*)Section);
1141 OS <<
',' <<
Log2(ByteAlignment);
1149void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
1150 uint64_t
Size, Align ByteAlignment) {
1156 ".zerofill is a Mach-O specific directive");
1165 if (ByteAlignment > 1)
1166 OS <<
", " <<
Log2(ByteAlignment);
1172 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1173 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1184 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1185 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1191 const auto printOneCharacterFor = [printCharacterInOctal](
1192 auto printOnePrintingCharacter) {
1193 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1195 printOnePrintingCharacter(
static_cast<char>(
C));
1198 printCharacterInOctal(
C);
1201 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1202 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1203 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1204 printOneCharacter(
C);
1207 printOneCharacter(*(EndPtr - 1));
1211 printCharacterList(printCharacterInOctal);
1214 printCharacterList(printOneCharacterFor([&OS](
char C) {
1215 const char AsmCharLitBuf[2] = {
'\'',
C};
1216 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1223void MCAsmStreamer::PrintQuotedString(StringRef
Data, raw_ostream &OS)
const {
1227 for (
unsigned char C :
Data) {
1234 for (
unsigned char C :
Data) {
1235 if (
C ==
'"' ||
C ==
'\\') {
1236 OS <<
'\\' << (char)
C;
1274void MCAsmStreamer::emitBytes(StringRef
Data) {
1275 assert(getCurrentSectionOnly() &&
1276 "Cannot emit contents before setting section!");
1277 if (
Data.empty())
return;
1279 const auto emitAsString = [
this](StringRef
Data) {
1284 if (
Data.back() == 0) {
1285 OS <<
"\t.string\t";
1290 PrintQuotedString(
Data, OS);
1310 PrintQuotedString(
Data, OS);
1315 if (
Data.size() != 1 && emitAsString(
Data))
1320 if (MCTargetStreamer *TS = getTargetStreamer()) {
1321 TS->emitRawBytes(
Data);
1325 for (
const unsigned char C :
Data.bytes()) {
1326 OS << Directive << (unsigned)
C;
1331void MCAsmStreamer::emitBinaryData(StringRef
Data) {
1333 const size_t Cols = 4;
1334 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1335 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1338 for (; J < EJ - 1; ++J)
1339 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1345void MCAsmStreamer::emitIntValue(uint64_t
Value,
unsigned Size) {
1349void MCAsmStreamer::emitIntValueInHex(uint64_t
Value,
unsigned Size) {
1353void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t
Value,
1358void MCAsmStreamer::emitValueImpl(
const MCExpr *
Value,
unsigned Size,
1361 assert(getCurrentSectionOnly() &&
1362 "Cannot emit contents before setting section!");
1363 const char *Directive =
nullptr;
1374 if (!
Value->evaluateAsAbsolute(IntValue))
1389 unsigned ByteOffset =
1390 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1391 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1395 uint64_t Shift = 64 - EmissionSize * 8;
1396 assert(Shift <
static_cast<uint64_t
>(
1397 std::numeric_limits<unsigned long long>::digits) &&
1398 "undefined behavior");
1399 ValueToEmit &= ~0ULL >> Shift;
1400 emitIntValue(ValueToEmit, EmissionSize);
1406 assert(Directive &&
"Invalid size for machine code value!");
1408 if (MCTargetStreamer *TS = getTargetStreamer()) {
1409 TS->emitValue(
Value);
1416void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1418 if (
Value->evaluateAsAbsolute(IntValue)) {
1419 emitULEB128IntValue(IntValue);
1422 OS <<
"\t.uleb128 ";
1427void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1429 if (
Value->evaluateAsAbsolute(IntValue)) {
1430 emitSLEB128IntValue(IntValue);
1433 OS <<
"\t.sleb128 ";
1438void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1440 int64_t IntNumBytes;
1441 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1442 if (IsAbsolute && IntNumBytes == 0)
1446 if (!MAI->
isAIX() || FillValue == 0) {
1448 OS << ZeroDirective;
1451 OS <<
',' << (int)FillValue;
1456 "Cannot emit non-absolute expression lengths of fill.");
1457 for (
int i = 0; i < IntNumBytes; ++i) {
1468void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1469 int64_t Expr, SMLoc Loc) {
1473 OS <<
", " <<
Size <<
", 0x";
1478void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
1479 std::optional<int64_t>
Value,
1481 unsigned MaxBytesToEmit) {
1495 switch (ValueSize) {
1499 OS <<
"\t.p2align\t";
1513 if (
Value.has_value() || MaxBytesToEmit) {
1514 if (
Value.has_value()) {
1522 OS <<
", " << MaxBytesToEmit;
1530 switch (ValueSize) {
1532 case 1: OS <<
".balign";
break;
1533 case 2: OS <<
".balignw";
break;
1534 case 4: OS <<
".balignl";
break;
1539 if (
Value.has_value())
1541 else if (MaxBytesToEmit)
1544 OS <<
", " << MaxBytesToEmit;
1548void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
1550 unsigned MaxBytesToEmit) {
1551 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1554void MCAsmStreamer::emitCodeAlignment(Align Alignment,
1555 const MCSubtargetInfo *STI,
1556 unsigned MaxBytesToEmit) {
1562 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1565void MCAsmStreamer::emitPrefAlign(Align Alignment) {
1566 OS <<
"\t.prefalign\t" << Alignment.
value();
1570void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1571 unsigned char Value,
1576 OS <<
", " << (unsigned)
Value;
1580void MCAsmStreamer::emitFileDirective(StringRef
Filename) {
1587void MCAsmStreamer::emitFileDirective(StringRef
Filename,
1588 StringRef CompilerVersion,
1589 StringRef TimeStamp,
1590 StringRef Description) {
1594 bool useTimeStamp = !TimeStamp.
empty();
1595 bool useCompilerVersion = !CompilerVersion.
empty();
1596 bool useDescription = !Description.
empty();
1597 if (useTimeStamp || useCompilerVersion || useDescription) {
1600 PrintQuotedString(TimeStamp, OS);
1601 if (useCompilerVersion || useDescription) {
1603 if (useCompilerVersion)
1604 PrintQuotedString(CompilerVersion, OS);
1605 if (useDescription) {
1607 PrintQuotedString(Description, OS);
1614void MCAsmStreamer::printDwarfFileDirective(
1615 unsigned FileNo, StringRef Directory, StringRef
Filename,
1616 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1617 bool UseDwarfDirectory, raw_svector_ostream &OS)
const {
1618 SmallString<128> FullPathName;
1620 if (!UseDwarfDirectory && !Directory.
empty()) {
1624 FullPathName = Directory;
1631 OS <<
"\t.file\t" << FileNo <<
' ';
1632 if (!Directory.
empty()) {
1633 PrintQuotedString(Directory, OS);
1638 OS <<
" md5 0x" << Checksum->digest();
1641 PrintQuotedString(*Source, OS);
1645Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
1646 unsigned FileNo, StringRef Directory, StringRef
Filename,
1647 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1649 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1651 MCDwarfLineTable &Table =
getContext().getMCDwarfLineTable(CUID);
1653 Expected<unsigned> FileNoOrErr =
1658 FileNo = FileNoOrErr.
get();
1665 SmallString<128> Str;
1666 raw_svector_ostream OS1(Str);
1667 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1668 UseDwarfDirectory, OS1);
1670 if (MCTargetStreamer *TS = getTargetStreamer())
1671 TS->emitDwarfFileDirective(OS1.str());
1673 emitRawText(OS1.str());
1678void MCAsmStreamer::emitDwarfFile0Directive(
1679 StringRef Directory, StringRef
Filename,
1680 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1694 SmallString<128> Str;
1695 raw_svector_ostream OS1(Str);
1696 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1697 UseDwarfDirectory, OS1);
1699 if (MCTargetStreamer *TS = getTargetStreamer())
1700 TS->emitDwarfFileDirective(OS1.str());
1702 emitRawText(OS1.str());
1706void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1707 unsigned Discriminator) {
1712 OS <<
" basic_block";
1714 OS <<
" prologue_end";
1716 OS <<
" epilogue_begin";
1718 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1725 OS <<
" isa " << Isa;
1731void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1732 unsigned Column,
unsigned Flags,
1734 unsigned Discriminator,
1736 StringRef Comment) {
1738 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1745 OS << FileName <<
':' <<
Line <<
':' << Column;
1753 Discriminator, FileName, Comment);
1756void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1757 unsigned Column,
unsigned Flags,
1758 unsigned Isa,
unsigned Discriminator,
1760 StringRef Comment) {
1768 Discriminator, FileName, Comment);
1773 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1776 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1782void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1783 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1784 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1785 unsigned Isa,
unsigned Discriminator, StringRef FileName,
1786 StringRef Comment) {
1788 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1789 OS <<
", function_name " << *Sym;
1790 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1793 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1797void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {
1799 OS <<
".loc_label\t" <<
Name;
1803MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1809bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
1810 ArrayRef<uint8_t> Checksum,
1811 unsigned ChecksumKind) {
1816 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1819 if (!ChecksumKind) {
1825 PrintQuotedString(
toHex(Checksum), OS);
1832bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1833 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1837bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1840 unsigned IALine,
unsigned IACol,
1842 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1843 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1845 IALine, IACol, Loc);
1848void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1849 unsigned Line,
unsigned Column,
1850 bool PrologueEnd,
bool IsStmt,
1851 StringRef FileName, SMLoc Loc) {
1853 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1856 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1859 OS <<
" prologue_end";
1872void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1873 const MCSymbol *FnStart,
1874 const MCSymbol *FnEnd) {
1875 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1876 FnStart->
print(OS, MAI);
1878 FnEnd->
print(OS, MAI);
1883void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1884 unsigned SourceFileId,
1885 unsigned SourceLineNum,
1886 const MCSymbol *FnStartSym,
1887 const MCSymbol *FnEndSym) {
1888 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1889 <<
' ' << SourceLineNum <<
' ';
1890 FnStartSym->
print(OS, MAI);
1892 FnEndSym->
print(OS, MAI);
1895 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1898void MCAsmStreamer::PrintCVDefRangePrefix(
1899 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1900 OS <<
"\t.cv_def_range\t";
1901 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1909void MCAsmStreamer::emitCVDefRangeDirective(
1910 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1911 codeview::DefRangeRegisterRelHeader DRHdr) {
1912 PrintCVDefRangePrefix(Ranges);
1913 OS <<
", reg_rel, ";
1919void MCAsmStreamer::emitCVDefRangeDirective(
1920 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1921 codeview::DefRangeSubfieldRegisterHeader DRHdr) {
1922 PrintCVDefRangePrefix(Ranges);
1923 OS <<
", subfield_reg, ";
1928void MCAsmStreamer::emitCVDefRangeDirective(
1929 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1930 codeview::DefRangeRegisterHeader DRHdr) {
1931 PrintCVDefRangePrefix(Ranges);
1937void MCAsmStreamer::emitCVDefRangeDirective(
1938 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1939 codeview::DefRangeFramePointerRelHeader DRHdr) {
1940 PrintCVDefRangePrefix(Ranges);
1941 OS <<
", frame_ptr_rel, ";
1946void MCAsmStreamer::emitCVStringTableDirective() {
1947 OS <<
"\t.cv_stringtable";
1951void MCAsmStreamer::emitCVFileChecksumsDirective() {
1952 OS <<
"\t.cv_filechecksums";
1956void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1957 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1961void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L) {
1962 OS <<
"\t.cv_fpo_data\t";
1963 ProcSym->
print(OS, MAI);
1967void MCAsmStreamer::emitIdent(StringRef IdentString) {
1970 PrintQuotedString(IdentString, OS);
1974void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
1976 OS <<
"\t.cfi_sections ";
1985 OS <<
".debug_frame";
1997void MCAsmStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
1998 OS <<
"\t.cfi_startproc";
2004void MCAsmStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
2006 OS <<
"\t.cfi_endproc";
2010void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2016 if (std::optional<MCRegister> LLVMRegister =
2018 InstPrinter->printRegName(OS, *LLVMRegister);
2025void MCAsmStreamer::emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2027 OS <<
"\t.cfi_def_cfa ";
2033void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc) {
2035 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2039void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2042 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2050 OS <<
"\t.cfi_escape ";
2051 if (!Values.
empty()) {
2052 size_t e = Values.
size() - 1;
2053 for (
size_t i = 0; i < e; ++i)
2059void MCAsmStreamer::emitCFIEscape(StringRef Values, SMLoc Loc) {
2065void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc) {
2068 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2075void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc) {
2077 OS <<
"\t.cfi_def_cfa_register ";
2082void MCAsmStreamer::emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2084 OS <<
"\t.cfi_offset ";
2090void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2091 unsigned Encoding) {
2093 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2094 Sym->
print(OS, MAI);
2098void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2100 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2101 Sym->
print(OS, MAI);
2105void MCAsmStreamer::emitCFIRememberState(SMLoc Loc) {
2107 OS <<
"\t.cfi_remember_state";
2111void MCAsmStreamer::emitCFIRestoreState(SMLoc Loc) {
2113 OS <<
"\t.cfi_restore_state";
2117void MCAsmStreamer::emitCFIRestore(int64_t
Register, SMLoc Loc) {
2119 OS <<
"\t.cfi_restore ";
2124void MCAsmStreamer::emitCFISameValue(int64_t
Register, SMLoc Loc) {
2126 OS <<
"\t.cfi_same_value ";
2131void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2134 OS <<
"\t.cfi_rel_offset ";
2140void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
2142 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2146void MCAsmStreamer::emitCFISignalFrame() {
2148 OS <<
"\t.cfi_signal_frame";
2152void MCAsmStreamer::emitCFIUndefined(int64_t
Register, SMLoc Loc) {
2154 OS <<
"\t.cfi_undefined ";
2159void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2162 OS <<
"\t.cfi_register ";
2163 EmitRegisterName(Register1);
2165 EmitRegisterName(Register2);
2169void MCAsmStreamer::emitCFIWindowSave(SMLoc Loc) {
2171 OS <<
"\t.cfi_window_save";
2175void MCAsmStreamer::emitCFINegateRAState(SMLoc Loc) {
2177 OS <<
"\t.cfi_negate_ra_state";
2181void MCAsmStreamer::emitCFINegateRAStateWithPC(SMLoc Loc) {
2183 OS <<
"\t.cfi_negate_ra_state_with_pc";
2187void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2189 OS <<
"\t.cfi_return_column ";
2194void MCAsmStreamer::emitCFILabelDirective(SMLoc Loc, StringRef Name) {
2196 OS <<
"\t.cfi_label " <<
Name;
2200void MCAsmStreamer::emitCFIBKeyFrame() {
2202 OS <<
"\t.cfi_b_key_frame";
2206void MCAsmStreamer::emitCFIMTETaggedFrame() {
2208 OS <<
"\t.cfi_mte_tagged_frame";
2212void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2215 OS <<
"\t.cfi_val_offset ";
2221void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc) {
2229void MCAsmStreamer::emitWinCFIEndProc(SMLoc Loc) {
2232 OS <<
"\t.seh_endproc";
2236void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(SMLoc Loc) {
2239 OS <<
"\t.seh_endfunclet";
2243void MCAsmStreamer::emitWinCFISplitChained(SMLoc Loc) {
2246 OS <<
"\t.seh_splitchained";
2250void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2251 bool Except, SMLoc Loc) {
2254 OS <<
"\t.seh_handler ";
2255 Sym->
print(OS, MAI);
2261 OS <<
", " << Marker <<
"unwind";
2263 OS <<
", " << Marker <<
"except";
2267void MCAsmStreamer::emitWinEHHandlerData(SMLoc Loc) {
2274 WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
2282 MCSection *XData = getAssociatedXDataSection(TextSec);
2283 switchSectionNoPrint(XData);
2285 OS <<
"\t.seh_handlerdata";
2289void MCAsmStreamer::emitWinCFIPushReg(MCRegister
Register, SMLoc Loc) {
2292 OS <<
"\t.seh_pushreg ";
2293 InstPrinter->printRegName(OS,
Register);
2297void MCAsmStreamer::emitWinCFISetFrame(MCRegister
Register,
unsigned Offset,
2301 OS <<
"\t.seh_setframe ";
2302 InstPrinter->printRegName(OS,
Register);
2307void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size, SMLoc Loc) {
2310 OS <<
"\t.seh_stackalloc " <<
Size;
2314void MCAsmStreamer::emitWinCFISaveReg(MCRegister
Register,
unsigned Offset,
2318 OS <<
"\t.seh_savereg ";
2319 InstPrinter->printRegName(OS,
Register);
2324void MCAsmStreamer::emitWinCFISaveXMM(MCRegister
Register,
unsigned Offset,
2328 OS <<
"\t.seh_savexmm ";
2329 InstPrinter->printRegName(OS,
Register);
2334void MCAsmStreamer::emitWinCFIPushFrame(
bool Code, SMLoc Loc) {
2337 OS <<
"\t.seh_pushframe";
2343void MCAsmStreamer::emitWinCFIEndProlog(SMLoc Loc) {
2346 OS <<
"\t.seh_endprologue";
2350void MCAsmStreamer::emitWinCFIBeginEpilogue(SMLoc Loc) {
2353 OS <<
"\t.seh_startepilogue";
2357void MCAsmStreamer::emitWinCFIEndEpilogue(SMLoc Loc) {
2360 OS <<
"\t.seh_endepilogue";
2364void MCAsmStreamer::emitWinCFIUnwindV2Start(SMLoc Loc) {
2367 OS <<
"\t.seh_unwindv2start";
2371void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc) {
2374 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2378void MCAsmStreamer::emitCGProfileEntry(
const MCSymbolRefExpr *From,
2379 const MCSymbolRefExpr *To,
2381 OS <<
"\t.cg_profile ";
2385 OS <<
", " <<
Count;
2389void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2390 const MCSubtargetInfo &STI) {
2391 raw_ostream &OS = getCommentOS();
2392 SmallString<256>
Code;
2396 if (!getAssembler().getEmitterPtr())
2399 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2402 bool ForceLE =
getContext().getTargetTriple().isRISCV();
2409 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2412 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2414 MCFixupKindInfo
Info =
2415 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2416 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2417 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2418 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2419 FixupMap[
Index] = 1 + i;
2425 OS <<
"encoding: [";
2426 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2431 uint8_t MapEntry = FixupMap[i * 8 + 0];
2432 for (
unsigned j = 1;
j != 8; ++
j) {
2433 if (FixupMap[i * 8 + j] == MapEntry)
2436 MapEntry = uint8_t(~0U);
2440 if (MapEntry != uint8_t(~0U)) {
2441 if (MapEntry == 0) {
2442 OS <<
format(
"0x%02x", uint8_t(Code[i]));
2446 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\''
2447 << char(
'A' + MapEntry - 1) <<
'\'';
2449 OS << char(
'A' + MapEntry - 1);
2454 for (
unsigned j = 8;
j--;) {
2462 FixupBit = i * 8 +
j;
2464 FixupBit = i * 8 + (7-
j);
2466 if (uint8_t MapEntry = FixupMap[FixupBit]) {
2467 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2468 OS << char(
'A' + MapEntry - 1);
2476 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2478 OS <<
" fixup " << char(
'A' + i) <<
" - "
2479 <<
"offset: " <<
F.getOffset() <<
", value: ";
2481 auto Kind =
F.getKind();
2483 OS <<
", relocation type: " <<
Kind;
2486 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2487 if (
F.isPCRel() && StringRef(
Info.Name).starts_with(
"FK_Data_"))
2488 OS <<
"FK_PCRel_" << (
Info.TargetSize / 8);
2496void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2497 const MCSubtargetInfo &STI) {
2498 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2502 MCSection *Sec = getCurrentSectionOnly();
2506 if (MAI->
isAIX() && CurFrag)
2512 AddEncodingComment(Inst, STI);
2517 getCommentOS() <<
"\n";
2520 if(getTargetStreamer())
2521 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2523 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2525 StringRef Comments = CommentToEmit;
2526 if (Comments.
size() && Comments.
back() !=
'\n')
2527 getCommentOS() <<
"\n";
2532void MCAsmStreamer::emitPseudoProbe(uint64_t
Guid, uint64_t Index,
2533 uint64_t
Type, uint64_t Attr,
2534 uint64_t Discriminator,
2537 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2542 for (
const auto &Site : InlineStack)
2543 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2546 FnSym->
print(OS, MAI);
2551void MCAsmStreamer::emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
2552 const MCExpr *Expr, SMLoc) {
2563void MCAsmStreamer::emitAddrsig() {
2568void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2569 OS <<
"\t.addrsig_sym ";
2570 Sym->
print(OS, MAI);
2577void MCAsmStreamer::emitRawTextImpl(StringRef
String) {
2578 String.consume_back(
"\n");
2583void MCAsmStreamer::finishImpl() {
2598 const auto &Tables =
getContext().getMCDwarfLineTables();
2599 if (!Tables.empty()) {
2600 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2601 if (
auto *Label = Tables.begin()->second.getLabel()) {
2602 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2608void MCAsmStreamer::emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment) {
2620MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2621 const Twine &Comment) {
2629 return getContext().createTempSymbol(Prefix +
"_end");
2633void MCAsmStreamer::emitDwarfLineStartLabel(MCSymbol *StartSym) {
2644 emitLabel(DebugLineSymTmp);
2648 unsigned LengthFieldSize =
2654 emitAssignment(StartSym, OuterSym);
2660void MCAsmStreamer::emitDwarfLineEndEntry(MCSection *Section,
2661 MCSymbol *LastLabel,
2662 MCSymbol *EndLabel) {
2669 ".loc should not be generated together with raw data!");
2682 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2687void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2688 const MCSymbol *LastLabel,
2689 const MCSymbol *Label,
2690 unsigned PointerSize) {
2692 ".loc/.file don't need raw data in debug line section!");
2695 AddComment(
"Set address to " +
Label->getName());
2696 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2697 emitULEB128IntValue(PointerSize + 1);
2698 emitIntValue(dwarf::DW_LNE_set_address, 1);
2699 emitSymbolValue(Label, PointerSize);
2703 AddComment(
"Start sequence");
2711 AddComment(
"End sequence");
2712 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2713 emitULEB128IntValue(1);
2714 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2719 AddComment(
"Advance line " + Twine(LineDelta));
2720 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2721 emitSLEB128IntValue(LineDelta);
2722 emitIntValue(dwarf::DW_LNS_copy, 1);
2726 std::unique_ptr<formatted_raw_ostream> OS,
2727 std::unique_ptr<MCInstPrinter> IP,
2728 std::unique_ptr<MCCodeEmitter> CE,
2729 std::unique_ptr<MCAsmBackend> MAB) {
2730 return new MCAsmStreamer(Context, std::move(OS), std::move(IP), std::move(CE),
unsigned const MachineRegisterInfo * MRI
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...
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static constexpr StringLiteral Filename
This file defines the SmallString class.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton 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
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
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)
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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