45 std::unique_ptr<formatted_raw_ostream> OSOwner;
46 formatted_raw_ostream &OS;
48 std::unique_ptr<MCInstPrinter> InstPrinter;
49 std::unique_ptr<MCAssembler> Assembler;
51 SmallString<128> ExplicitCommentToEmit;
52 SmallString<128> CommentToEmit;
53 raw_svector_ostream CommentStream;
54 raw_null_ostream NullStream;
56 bool EmittedSectionDirective =
false;
58 bool IsVerboseAsm =
false;
59 bool ShowInst =
false;
60 bool UseDwarfDirectory =
false;
62 void EmitRegisterName(int64_t
Register);
63 void PrintQuotedString(StringRef
Data, raw_ostream &OS)
const;
64 void printDwarfFileDirective(
unsigned FileNo, StringRef Directory,
66 std::optional<MD5::MD5Result> Checksum,
67 std::optional<StringRef> Source,
68 bool UseDwarfDirectory,
69 raw_svector_ostream &OS)
const;
70 void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
override;
71 void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame)
override;
74 MCAsmStreamer(MCContext &
Context, std::unique_ptr<formatted_raw_ostream> os,
75 std::unique_ptr<MCInstPrinter>
printer,
76 std::unique_ptr<MCCodeEmitter> emitter,
77 std::unique_ptr<MCAsmBackend> asmbackend)
78 : MCStreamer(
Context), OSOwner(std::
move(os)), OS(*OSOwner),
80 Assembler(std::make_unique<MCAssembler>(
82 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
84 CommentStream(CommentToEmit) {
86 if (Assembler->getBackendPtr())
87 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
89 Context.setUseNamesOnTempLabels(
true);
91 auto *TO =
Context.getTargetOptions();
94 IsVerboseAsm = TO->AsmVerbose;
96 InstPrinter->setCommentStream(CommentStream);
97 ShowInst = TO->ShowMCInst;
98 switch (TO->MCUseDwarfDirectory) {
100 UseDwarfDirectory =
false;
103 UseDwarfDirectory =
true;
107 Context.getAsmInfo()->enableDwarfFileDirectoryDefault();
112 MCAssembler &getAssembler() {
return *Assembler; }
113 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
115 inline void EmitEOL() {
117 emitExplicitComments();
123 EmitCommentsAndEOL();
126 void emitSyntaxDirective()
override;
128 void EmitCommentsAndEOL();
131 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
134 bool hasRawTextSupport()
const override {
return true; }
139 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
142 void AddEncodingComment(
const MCInst &Inst,
const MCSubtargetInfo &);
147 raw_ostream &getCommentOS()
override {
150 return CommentStream;
153 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
155 void addExplicitComment(
const Twine &
T)
override;
156 void emitExplicitComments()
override;
159 void addBlankLine()
override { EmitEOL(); }
164 void switchSection(MCSection *Section, uint32_t Subsection)
override;
165 bool popSection()
override;
167 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
168 bool KeepOriginalSym)
override;
172 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
175 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
176 assert((Bits != 0 || Ptr ==
nullptr) &&
177 "Invalid char pointer for instruction with no mnemonic");
181 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
183 void emitSubsectionsViaSymbols()
override;
184 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
187 unsigned Update, VersionTuple SDKVersion)
override;
188 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
189 unsigned Update, VersionTuple SDKVersion)
override;
190 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
191 unsigned Minor,
unsigned Update,
192 VersionTuple SDKVersion)
override;
194 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
195 void emitConditionalAssignment(MCSymbol *Symbol,
196 const MCExpr *
Value)
override;
197 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
200 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
201 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
202 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
203 void emitCOFFSymbolType(
int Type)
override;
204 void endCOFFSymbolDef()
override;
205 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
206 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
207 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
208 void emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset)
override;
209 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
210 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
211 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
212 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t
Size,
213 MCSymbol *CsectSym, Align Alignment)
override;
214 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
217 void emitXCOFFRenameDirective(
const MCSymbol *Name,
218 StringRef Rename)
override;
220 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
222 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
223 const MCSymbol *
Trap,
224 unsigned Lang,
unsigned Reason,
225 unsigned FunctionSize,
bool hasDebug)
override;
226 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
228 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
229 void emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
230 Align ByteAlignment)
override;
237 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
238 Align ByteAlignment)
override;
240 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
241 uint64_t
Size = 0, Align ByteAlignment =
Align(1),
242 SMLoc Loc = SMLoc())
override;
244 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t
Size,
245 Align ByteAlignment =
Align(1))
override;
247 void emitBinaryData(StringRef
Data)
override;
249 void emitBytes(StringRef
Data)
override;
251 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
252 SMLoc Loc = SMLoc())
override;
253 void emitIntValue(uint64_t
Value,
unsigned Size)
override;
254 void emitIntValueInHex(uint64_t
Value,
unsigned Size)
override;
255 void emitIntValueInHexWithPadding(uint64_t
Value,
unsigned Size)
override;
257 void emitULEB128Value(
const MCExpr *
Value)
override;
259 void emitSLEB128Value(
const MCExpr *
Value)
override;
261 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
262 SMLoc Loc = SMLoc())
override;
264 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
265 SMLoc Loc = SMLoc())
override;
267 void emitAlignmentDirective(uint64_t ByteAlignment,
268 std::optional<int64_t>
Value,
unsigned ValueSize,
269 unsigned MaxBytesToEmit);
271 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
273 unsigned MaxBytesToEmit = 0)
override;
275 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo *STI,
276 unsigned MaxBytesToEmit = 0)
override;
278 void emitValueToOffset(
const MCExpr *
Offset,
282 void emitFileDirective(StringRef Filename)
override;
283 void emitFileDirective(StringRef Filename, StringRef CompilerVersion,
284 StringRef TimeStamp, StringRef Description)
override;
285 Expected<unsigned> tryEmitDwarfFileDirective(
286 unsigned FileNo, StringRef Directory, StringRef Filename,
287 std::optional<MD5::MD5Result> Checksum = std::nullopt,
288 std::optional<StringRef> Source = std::nullopt,
289 unsigned CUID = 0)
override;
290 void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
291 std::optional<MD5::MD5Result> Checksum,
292 std::optional<StringRef> Source,
293 unsigned CUID = 0)
override;
294 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
295 unsigned Flags,
unsigned Isa,
296 unsigned Discriminator, StringRef FileName,
297 StringRef Location = {})
override;
298 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
300 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
302 bool emitCVFileDirective(
unsigned FileNo, StringRef Filename,
303 ArrayRef<uint8_t> Checksum,
304 unsigned ChecksumKind)
override;
305 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
306 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
307 unsigned IAFile,
unsigned IALine,
308 unsigned IACol, SMLoc Loc)
override;
309 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
310 unsigned Column,
bool PrologueEnd,
bool IsStmt,
311 StringRef FileName, SMLoc Loc)
override;
312 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
313 const MCSymbol *FnEnd)
override;
314 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
315 unsigned SourceFileId,
316 unsigned SourceLineNum,
317 const MCSymbol *FnStartSym,
318 const MCSymbol *FnEndSym)
override;
320 void PrintCVDefRangePrefix(
321 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
323 void emitCVDefRangeDirective(
324 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
325 codeview::DefRangeRegisterRelHeader DRHdr)
override;
327 void emitCVDefRangeDirective(
328 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
329 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
331 void emitCVDefRangeDirective(
332 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
333 codeview::DefRangeRegisterHeader DRHdr)
override;
335 void emitCVDefRangeDirective(
336 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
337 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
339 void emitCVStringTableDirective()
override;
340 void emitCVFileChecksumsDirective()
override;
341 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
342 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
344 void emitIdent(StringRef IdentString)
override;
345 void emitCFIBKeyFrame()
override;
346 void emitCFIMTETaggedFrame()
override;
347 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
348 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
349 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
350 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
353 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
354 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
355 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
356 void emitCFIRememberState(SMLoc Loc)
override;
357 void emitCFIRestoreState(SMLoc Loc)
override;
358 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
359 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
360 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
361 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
362 void emitCFIEscape(StringRef Values, SMLoc Loc)
override;
363 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
364 void emitCFISignalFrame()
override;
365 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
366 void emitCFIRegister(int64_t Register1, int64_t Register2,
368 void emitCFIWindowSave(SMLoc Loc)
override;
369 void emitCFINegateRAState(SMLoc Loc)
override;
370 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
371 void emitCFIReturnColumn(int64_t
Register)
override;
372 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
373 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
375 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
376 void emitWinCFIEndProc(SMLoc Loc)
override;
377 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
378 void emitWinCFIStartChained(SMLoc Loc)
override;
379 void emitWinCFIEndChained(SMLoc Loc)
override;
380 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
383 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
388 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
389 void emitWinCFIEndProlog(SMLoc Loc)
override;
390 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
391 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
392 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
393 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
395 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
397 void emitWinEHHandlerData(SMLoc Loc)
override;
399 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
400 const MCSymbolRefExpr *To, uint64_t
Count)
override;
402 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
404 void emitPseudoProbe(uint64_t
Guid, uint64_t Index, uint64_t
Type,
405 uint64_t Attr, uint64_t Discriminator,
407 MCSymbol *FnSym)
override;
409 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
410 const MCExpr *Expr, SMLoc Loc)
override;
412 void emitAddrsig()
override;
413 void emitAddrsigSym(
const MCSymbol *Sym)
override;
418 void emitRawTextImpl(StringRef
String)
override;
420 void finishImpl()
override;
422 void emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment)
override;
424 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
425 const Twine &Comment)
override;
427 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
429 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
430 MCSymbol *EndLabel =
nullptr)
override;
432 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
433 const MCSymbol *Label,
434 unsigned PointerSize)
override;
439void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
440 if (!IsVerboseAsm)
return;
442 T.toVector(CommentToEmit);
448void MCAsmStreamer::EmitCommentsAndEOL() {
454 StringRef Comments = CommentToEmit;
457 "Comment array not newline terminated");
461 size_t Position = Comments.
find(
'\n');
464 Comments = Comments.
substr(Position+1);
465 }
while (!Comments.
empty());
467 CommentToEmit.
clear();
471 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
472 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
475void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
482void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
483 StringRef c =
T.getSingleStringRef();
487 ExplicitCommentToEmit.
append(
"\t");
492 size_t p = 2, len = c.
size() - 2;
496 ExplicitCommentToEmit.
append(
"\t");
501 ExplicitCommentToEmit.
append(
"\n");
505 ExplicitCommentToEmit.
append(
"\t");
507 }
else if (c.
front() ==
'#') {
509 ExplicitCommentToEmit.
append(
"\t");
513 assert(
false &&
"Unexpected Assembly Comment");
515 if (c.
back() ==
'\n')
516 emitExplicitComments();
519void MCAsmStreamer::emitExplicitComments() {
520 StringRef Comments = ExplicitCommentToEmit;
521 if (!Comments.
empty())
523 ExplicitCommentToEmit.
clear();
526void MCAsmStreamer::switchSection(MCSection *Section, uint32_t Subsection) {
528 if (!EmittedSectionDirective ||
530 EmittedSectionDirective =
true;
531 if (MCTargetStreamer *TS = getTargetStreamer()) {
532 TS->changeSection(Cur.first, Section, Subsection, OS);
541bool MCAsmStreamer::popSection() {
544 auto [Sec, Subsec] = getCurrentSection();
549void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
551 bool KeepOriginalSym) {
553 OriginalSym->
print(OS, MAI);
555 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
560void MCAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
565 if (!
Symbol->isVariable() &&
580 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
581 assert(str !=
"" &&
"Invalid LOH name");
586 for (
const MCSymbol *Arg : Args) {
595void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
596 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
599void MCAsmStreamer::emitSubsectionsViaSymbols() {
600 OS <<
".subsections_via_symbols\n";
603void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string>
Options) {
604 assert(!
Options.empty() &&
"At least one option is required!");
605 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
607 OS <<
", " <<
'"' << Opt <<
'"';
636 if (SDKVersion.
empty())
638 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
639 if (
auto Minor = SDKVersion.
getMinor()) {
640 OS <<
", " << *Minor;
642 OS <<
", " << *Subminor;
648 unsigned Minor,
unsigned Update,
649 VersionTuple SDKVersion) {
652 OS <<
", " << Update;
659#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
661 case MachO::PLATFORM_##platform: \
663#include "llvm/BinaryFormat/MachO.def"
668void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
669 unsigned Minor,
unsigned Update,
670 VersionTuple SDKVersion) {
672 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
674 OS <<
", " << Update;
679void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
680 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
681 VersionTuple SDKVersion) {
682 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
685void MCAsmStreamer::emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value) {
690 OS << (UseSet ?
", " :
" = ");
697void MCAsmStreamer::emitConditionalAssignment(MCSymbol *Symbol,
698 const MCExpr *
Value) {
699 OS <<
".lto_set_conditional ";
706void MCAsmStreamer::emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol) {
708 Alias->
print(OS, MAI);
714bool MCAsmStreamer::emitSymbolAttribute(MCSymbol *Symbol,
731 default:
return false;
754 OS <<
"\t.no_dead_strip\t";
759 OS <<
"\t.private_extern\t";
768 OS <<
"\t.weak_definition\t";
785 OS <<
"\t.weak_anti_dep\t";
795void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue) {
796 OS <<
".desc" <<
' ';
798 OS <<
',' << DescValue;
802void MCAsmStreamer::emitSyntaxDirective() {
804 OS <<
"\t.intel_syntax noprefix";
812void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
819void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
824void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
825 OS <<
"\t.type\t" <<
Type <<
';';
829void MCAsmStreamer::endCOFFSymbolDef() {
834void MCAsmStreamer::emitCOFFSafeSEH(MCSymbol
const *Symbol) {
835 OS <<
"\t.safeseh\t";
840void MCAsmStreamer::emitCOFFSymbolIndex(MCSymbol
const *Symbol) {
846void MCAsmStreamer::emitCOFFSectionIndex(MCSymbol
const *Symbol) {
852void MCAsmStreamer::emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset) {
853 OS <<
"\t.secrel32\t";
860void MCAsmStreamer::emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset) {
870void MCAsmStreamer::emitCOFFSecNumber(MCSymbol
const *Symbol) {
876void MCAsmStreamer::emitCOFFSecOffset(MCSymbol
const *Symbol) {
877 OS <<
"\t.secoffset\t";
885void MCAsmStreamer::emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
890 "We only support writing log base-2 alignment format with XCOFF.");
893 LabelSym->
print(OS, MAI);
894 OS <<
',' <<
Size <<
',';
895 CsectSym->
print(OS, MAI);
896 OS <<
',' <<
Log2(Alignment);
902 auto *XSym =
static_cast<MCSymbolXCOFF *
>(CsectSym);
903 if (XSym->hasRename())
904 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
907void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
909 auto &Sym =
static_cast<MCSymbolXCOFF &
>(*Symbol);
929 switch (Visibility) {
950 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
953void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
956 Name->print(OS, MAI);
959 for (
char C : Rename) {
969void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
975void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
976 const MCSymbol *
Trap,
979 unsigned FunctionSize,
983 OS <<
", " << Lang <<
", " << Reason;
987void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata) {
988 const char InfoDirective[] =
"\t.info ";
989 const char *Separator =
", ";
990 constexpr int WordSize =
sizeof(uint32_t);
994 PrintQuotedString(Name, OS);
997 size_t MetadataSize =
Metadata.size();
1000 OS <<
format_hex(MetadataSize, 10) << Separator;
1003 if (MetadataSize == 0) {
1013 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1014 uint32_t PaddingSize = PaddedSize - MetadataSize;
1021 constexpr int WordsPerDirective = 5;
1024 int WordsBeforeNextDirective = 0;
1025 auto PrintWord = [&](
const uint8_t *WordPtr) {
1026 if (WordsBeforeNextDirective-- == 0) {
1028 OS << InfoDirective;
1029 WordsBeforeNextDirective = WordsPerDirective;
1037 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1038 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1043 assert(PaddedSize - Index == WordSize);
1044 std::array<uint8_t, WordSize> LastWord = {0};
1045 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1046 PrintWord(LastWord.data());
1051void MCAsmStreamer::emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value) {
1060void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1061 Align ByteAlignment) {
1069 OS <<
',' <<
Log2(ByteAlignment);
1075 auto *XSym =
static_cast<MCSymbolXCOFF *
>(
Symbol);
1076 if (XSym && XSym->hasRename())
1077 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1081void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1087 if (ByteAlign > 1) {
1092 OS <<
',' << ByteAlign.
value();
1095 OS <<
',' <<
Log2(ByteAlign);
1102void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
1103 uint64_t
Size, Align ByteAlignment,
1112 ".zerofill is a Mach-O specific directive");
1115 const MCSectionMachO *MOSection = ((
const MCSectionMachO*)Section);
1122 OS <<
',' <<
Log2(ByteAlignment);
1130void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
1131 uint64_t
Size, Align ByteAlignment) {
1137 ".zerofill is a Mach-O specific directive");
1146 if (ByteAlignment > 1)
1147 OS <<
", " <<
Log2(ByteAlignment);
1153 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1154 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1165 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1166 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1172 const auto printOneCharacterFor = [printCharacterInOctal](
1173 auto printOnePrintingCharacter) {
1174 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1176 printOnePrintingCharacter(
static_cast<char>(
C));
1179 printCharacterInOctal(
C);
1182 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1183 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1184 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1185 printOneCharacter(
C);
1188 printOneCharacter(*(EndPtr - 1));
1192 printCharacterList(printCharacterInOctal);
1195 printCharacterList(printOneCharacterFor([&OS](
char C) {
1196 const char AsmCharLitBuf[2] = {
'\'',
C};
1197 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1204void MCAsmStreamer::PrintQuotedString(StringRef
Data, raw_ostream &OS)
const {
1208 for (
unsigned char C :
Data) {
1215 for (
unsigned char C :
Data) {
1216 if (
C ==
'"' ||
C ==
'\\') {
1217 OS <<
'\\' << (char)
C;
1255void MCAsmStreamer::emitBytes(StringRef
Data) {
1256 assert(getCurrentSectionOnly() &&
1257 "Cannot emit contents before setting section!");
1258 if (
Data.empty())
return;
1260 const auto emitAsString = [
this](StringRef
Data) {
1265 if (
Data.back() == 0) {
1266 OS <<
"\t.string\t";
1271 PrintQuotedString(
Data, OS);
1291 PrintQuotedString(
Data, OS);
1296 if (
Data.size() != 1 && emitAsString(
Data))
1301 if (MCTargetStreamer *TS = getTargetStreamer()) {
1302 TS->emitRawBytes(
Data);
1306 for (
const unsigned char C :
Data.bytes()) {
1307 OS << Directive << (unsigned)
C;
1312void MCAsmStreamer::emitBinaryData(StringRef
Data) {
1314 const size_t Cols = 4;
1315 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1316 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1319 for (; J < EJ - 1; ++J)
1320 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1326void MCAsmStreamer::emitIntValue(uint64_t
Value,
unsigned Size) {
1330void MCAsmStreamer::emitIntValueInHex(uint64_t
Value,
unsigned Size) {
1334void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t
Value,
1339void MCAsmStreamer::emitValueImpl(
const MCExpr *
Value,
unsigned Size,
1342 assert(getCurrentSectionOnly() &&
1343 "Cannot emit contents before setting section!");
1344 const char *Directive =
nullptr;
1355 if (!
Value->evaluateAsAbsolute(IntValue))
1370 unsigned ByteOffset =
1371 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1372 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1376 uint64_t Shift = 64 - EmissionSize * 8;
1377 assert(Shift <
static_cast<uint64_t
>(
1378 std::numeric_limits<unsigned long long>::digits) &&
1379 "undefined behavior");
1380 ValueToEmit &= ~0ULL >> Shift;
1381 emitIntValue(ValueToEmit, EmissionSize);
1387 assert(Directive &&
"Invalid size for machine code value!");
1389 if (MCTargetStreamer *TS = getTargetStreamer()) {
1390 TS->emitValue(
Value);
1397void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1399 if (
Value->evaluateAsAbsolute(IntValue)) {
1400 emitULEB128IntValue(IntValue);
1403 OS <<
"\t.uleb128 ";
1408void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1410 if (
Value->evaluateAsAbsolute(IntValue)) {
1411 emitSLEB128IntValue(IntValue);
1414 OS <<
"\t.sleb128 ";
1419void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1421 int64_t IntNumBytes;
1422 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1423 if (IsAbsolute && IntNumBytes == 0)
1427 if (!MAI->
isAIX() || FillValue == 0) {
1429 OS << ZeroDirective;
1432 OS <<
',' << (int)FillValue;
1437 "Cannot emit non-absolute expression lengths of fill.");
1438 for (
int i = 0; i < IntNumBytes; ++i) {
1449void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1450 int64_t Expr, SMLoc Loc) {
1454 OS <<
", " <<
Size <<
", 0x";
1459void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
1460 std::optional<int64_t>
Value,
1462 unsigned MaxBytesToEmit) {
1476 switch (ValueSize) {
1480 OS <<
"\t.p2align\t";
1494 if (
Value.has_value() || MaxBytesToEmit) {
1495 if (
Value.has_value()) {
1503 OS <<
", " << MaxBytesToEmit;
1511 switch (ValueSize) {
1513 case 1: OS <<
".balign";
break;
1514 case 2: OS <<
".balignw";
break;
1515 case 4: OS <<
".balignl";
break;
1520 if (
Value.has_value())
1522 else if (MaxBytesToEmit)
1525 OS <<
", " << MaxBytesToEmit;
1529void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
1531 unsigned MaxBytesToEmit) {
1532 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1535void MCAsmStreamer::emitCodeAlignment(Align Alignment,
1536 const MCSubtargetInfo *STI,
1537 unsigned MaxBytesToEmit) {
1543 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1546void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1547 unsigned char Value,
1552 OS <<
", " << (unsigned)
Value;
1556void MCAsmStreamer::emitFileDirective(StringRef Filename) {
1559 PrintQuotedString(Filename, OS);
1563void MCAsmStreamer::emitFileDirective(StringRef Filename,
1564 StringRef CompilerVersion,
1565 StringRef TimeStamp,
1566 StringRef Description) {
1569 PrintQuotedString(Filename, OS);
1570 bool useTimeStamp = !TimeStamp.
empty();
1571 bool useCompilerVersion = !CompilerVersion.
empty();
1572 bool useDescription = !Description.
empty();
1573 if (useTimeStamp || useCompilerVersion || useDescription) {
1576 PrintQuotedString(TimeStamp, OS);
1577 if (useCompilerVersion || useDescription) {
1579 if (useCompilerVersion)
1580 PrintQuotedString(CompilerVersion, OS);
1581 if (useDescription) {
1583 PrintQuotedString(Description, OS);
1590void MCAsmStreamer::printDwarfFileDirective(
1591 unsigned FileNo, StringRef Directory, StringRef Filename,
1592 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1593 bool UseDwarfDirectory, raw_svector_ostream &OS)
const {
1594 SmallString<128> FullPathName;
1596 if (!UseDwarfDirectory && !Directory.
empty()) {
1600 FullPathName = Directory;
1607 OS <<
"\t.file\t" << FileNo <<
' ';
1608 if (!Directory.
empty()) {
1609 PrintQuotedString(Directory, OS);
1612 PrintQuotedString(Filename, OS);
1614 OS <<
" md5 0x" << Checksum->digest();
1617 PrintQuotedString(*Source, OS);
1621Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
1622 unsigned FileNo, StringRef Directory, StringRef Filename,
1623 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1625 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1627 MCDwarfLineTable &Table =
getContext().getMCDwarfLineTable(CUID);
1629 Expected<unsigned> FileNoOrErr =
1630 Table.
tryGetFile(Directory, Filename, Checksum, Source,
1634 FileNo = FileNoOrErr.
get();
1641 SmallString<128> Str;
1642 raw_svector_ostream OS1(Str);
1643 printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
1644 UseDwarfDirectory, OS1);
1646 if (MCTargetStreamer *TS = getTargetStreamer())
1647 TS->emitDwarfFileDirective(OS1.str());
1649 emitRawText(OS1.str());
1654void MCAsmStreamer::emitDwarfFile0Directive(
1655 StringRef Directory, StringRef Filename,
1656 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1663 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1670 SmallString<128> Str;
1671 raw_svector_ostream OS1(Str);
1672 printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
1673 UseDwarfDirectory, OS1);
1675 if (MCTargetStreamer *TS = getTargetStreamer())
1676 TS->emitDwarfFileDirective(OS1.str());
1678 emitRawText(OS1.str());
1681void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1682 unsigned Column,
unsigned Flags,
1683 unsigned Isa,
unsigned Discriminator,
1685 StringRef Comment) {
1693 Discriminator, FileName, Comment);
1697 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1700 OS <<
" basic_block";
1702 OS <<
" prologue_end";
1704 OS <<
" epilogue_begin";
1706 unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1717 OS <<
" isa " << Isa;
1726 OS << FileName <<
':' <<
Line <<
':' << Column;
1732 Discriminator, FileName, Comment);
1735void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {
1737 OS <<
".loc_label\t" <<
Name;
1741MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1747bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo, StringRef Filename,
1748 ArrayRef<uint8_t> Checksum,
1749 unsigned ChecksumKind) {
1750 if (!
getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1754 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1755 PrintQuotedString(Filename, OS);
1757 if (!ChecksumKind) {
1763 PrintQuotedString(
toHex(Checksum), OS);
1770bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1771 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1775bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1778 unsigned IALine,
unsigned IACol,
1780 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1781 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1783 IALine, IACol, Loc);
1786void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1787 unsigned Line,
unsigned Column,
1788 bool PrologueEnd,
bool IsStmt,
1789 StringRef FileName, SMLoc Loc) {
1791 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1794 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1797 OS <<
" prologue_end";
1810void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1811 const MCSymbol *FnStart,
1812 const MCSymbol *FnEnd) {
1813 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1814 FnStart->
print(OS, MAI);
1816 FnEnd->
print(OS, MAI);
1821void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1822 unsigned SourceFileId,
1823 unsigned SourceLineNum,
1824 const MCSymbol *FnStartSym,
1825 const MCSymbol *FnEndSym) {
1826 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1827 <<
' ' << SourceLineNum <<
' ';
1828 FnStartSym->
print(OS, MAI);
1830 FnEndSym->
print(OS, MAI);
1833 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1836void MCAsmStreamer::PrintCVDefRangePrefix(
1837 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1838 OS <<
"\t.cv_def_range\t";
1839 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1847void MCAsmStreamer::emitCVDefRangeDirective(
1848 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1849 codeview::DefRangeRegisterRelHeader DRHdr) {
1850 PrintCVDefRangePrefix(Ranges);
1851 OS <<
", reg_rel, ";
1857void MCAsmStreamer::emitCVDefRangeDirective(
1858 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1859 codeview::DefRangeSubfieldRegisterHeader DRHdr) {
1860 PrintCVDefRangePrefix(Ranges);
1861 OS <<
", subfield_reg, ";
1866void MCAsmStreamer::emitCVDefRangeDirective(
1867 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1868 codeview::DefRangeRegisterHeader DRHdr) {
1869 PrintCVDefRangePrefix(Ranges);
1875void MCAsmStreamer::emitCVDefRangeDirective(
1876 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1877 codeview::DefRangeFramePointerRelHeader DRHdr) {
1878 PrintCVDefRangePrefix(Ranges);
1879 OS <<
", frame_ptr_rel, ";
1884void MCAsmStreamer::emitCVStringTableDirective() {
1885 OS <<
"\t.cv_stringtable";
1889void MCAsmStreamer::emitCVFileChecksumsDirective() {
1890 OS <<
"\t.cv_filechecksums";
1894void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1895 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1899void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L) {
1900 OS <<
"\t.cv_fpo_data\t";
1901 ProcSym->
print(OS, MAI);
1905void MCAsmStreamer::emitIdent(StringRef IdentString) {
1908 PrintQuotedString(IdentString, OS);
1912void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
1914 OS <<
"\t.cfi_sections ";
1923 OS <<
".debug_frame";
1935void MCAsmStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
1936 OS <<
"\t.cfi_startproc";
1942void MCAsmStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
1944 OS <<
"\t.cfi_endproc";
1948void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
1954 if (std::optional<MCRegister> LLVMRegister =
1956 InstPrinter->printRegName(OS, *LLVMRegister);
1963void MCAsmStreamer::emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc) {
1965 OS <<
"\t.cfi_def_cfa ";
1971void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc) {
1973 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
1977void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
1980 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
1988 OS <<
"\t.cfi_escape ";
1989 if (!Values.
empty()) {
1990 size_t e = Values.
size() - 1;
1991 for (
size_t i = 0; i < e; ++i)
1997void MCAsmStreamer::emitCFIEscape(StringRef Values, SMLoc Loc) {
2003void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc) {
2006 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2013void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc) {
2015 OS <<
"\t.cfi_def_cfa_register ";
2020void MCAsmStreamer::emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2022 OS <<
"\t.cfi_offset ";
2028void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2029 unsigned Encoding) {
2031 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2032 Sym->
print(OS, MAI);
2036void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2038 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2039 Sym->
print(OS, MAI);
2043void MCAsmStreamer::emitCFIRememberState(SMLoc Loc) {
2045 OS <<
"\t.cfi_remember_state";
2049void MCAsmStreamer::emitCFIRestoreState(SMLoc Loc) {
2051 OS <<
"\t.cfi_restore_state";
2055void MCAsmStreamer::emitCFIRestore(int64_t
Register, SMLoc Loc) {
2057 OS <<
"\t.cfi_restore ";
2062void MCAsmStreamer::emitCFISameValue(int64_t
Register, SMLoc Loc) {
2064 OS <<
"\t.cfi_same_value ";
2069void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2072 OS <<
"\t.cfi_rel_offset ";
2078void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
2080 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2084void MCAsmStreamer::emitCFISignalFrame() {
2086 OS <<
"\t.cfi_signal_frame";
2090void MCAsmStreamer::emitCFIUndefined(int64_t
Register, SMLoc Loc) {
2092 OS <<
"\t.cfi_undefined ";
2097void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2100 OS <<
"\t.cfi_register ";
2101 EmitRegisterName(Register1);
2103 EmitRegisterName(Register2);
2107void MCAsmStreamer::emitCFIWindowSave(SMLoc Loc) {
2109 OS <<
"\t.cfi_window_save";
2113void MCAsmStreamer::emitCFINegateRAState(SMLoc Loc) {
2115 OS <<
"\t.cfi_negate_ra_state";
2119void MCAsmStreamer::emitCFINegateRAStateWithPC(SMLoc Loc) {
2121 OS <<
"\t.cfi_negate_ra_state_with_pc";
2125void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2127 OS <<
"\t.cfi_return_column ";
2132void MCAsmStreamer::emitCFILabelDirective(SMLoc Loc, StringRef Name) {
2134 OS <<
"\t.cfi_label " <<
Name;
2138void MCAsmStreamer::emitCFIBKeyFrame() {
2140 OS <<
"\t.cfi_b_key_frame";
2144void MCAsmStreamer::emitCFIMTETaggedFrame() {
2146 OS <<
"\t.cfi_mte_tagged_frame";
2150void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2153 OS <<
"\t.cfi_val_offset ";
2159void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc) {
2167void MCAsmStreamer::emitWinCFIEndProc(SMLoc Loc) {
2170 OS <<
"\t.seh_endproc";
2174void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(SMLoc Loc) {
2177 OS <<
"\t.seh_endfunclet";
2181void MCAsmStreamer::emitWinCFIStartChained(SMLoc Loc) {
2184 OS <<
"\t.seh_startchained";
2188void MCAsmStreamer::emitWinCFIEndChained(SMLoc Loc) {
2191 OS <<
"\t.seh_endchained";
2195void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2196 bool Except, SMLoc Loc) {
2199 OS <<
"\t.seh_handler ";
2200 Sym->
print(OS, MAI);
2206 OS <<
", " << Marker <<
"unwind";
2208 OS <<
", " << Marker <<
"except";
2212void MCAsmStreamer::emitWinEHHandlerData(SMLoc Loc) {
2219 WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
2227 MCSection *XData = getAssociatedXDataSection(TextSec);
2228 switchSectionNoPrint(XData);
2230 OS <<
"\t.seh_handlerdata";
2234void MCAsmStreamer::emitWinCFIPushReg(MCRegister
Register, SMLoc Loc) {
2237 OS <<
"\t.seh_pushreg ";
2238 InstPrinter->printRegName(OS,
Register);
2242void MCAsmStreamer::emitWinCFISetFrame(MCRegister
Register,
unsigned Offset,
2246 OS <<
"\t.seh_setframe ";
2247 InstPrinter->printRegName(OS,
Register);
2252void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size, SMLoc Loc) {
2255 OS <<
"\t.seh_stackalloc " <<
Size;
2259void MCAsmStreamer::emitWinCFISaveReg(MCRegister
Register,
unsigned Offset,
2263 OS <<
"\t.seh_savereg ";
2264 InstPrinter->printRegName(OS,
Register);
2269void MCAsmStreamer::emitWinCFISaveXMM(MCRegister
Register,
unsigned Offset,
2273 OS <<
"\t.seh_savexmm ";
2274 InstPrinter->printRegName(OS,
Register);
2279void MCAsmStreamer::emitWinCFIPushFrame(
bool Code, SMLoc Loc) {
2282 OS <<
"\t.seh_pushframe";
2288void MCAsmStreamer::emitWinCFIEndProlog(SMLoc Loc) {
2291 OS <<
"\t.seh_endprologue";
2295void MCAsmStreamer::emitWinCFIBeginEpilogue(SMLoc Loc) {
2298 OS <<
"\t.seh_startepilogue";
2302void MCAsmStreamer::emitWinCFIEndEpilogue(SMLoc Loc) {
2305 OS <<
"\t.seh_endepilogue";
2309void MCAsmStreamer::emitWinCFIUnwindV2Start(SMLoc Loc) {
2312 OS <<
"\t.seh_unwindv2start";
2316void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc) {
2319 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2323void MCAsmStreamer::emitCGProfileEntry(
const MCSymbolRefExpr *From,
2324 const MCSymbolRefExpr *To,
2326 OS <<
"\t.cg_profile ";
2330 OS <<
", " <<
Count;
2334void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2335 const MCSubtargetInfo &STI) {
2336 raw_ostream &OS = getCommentOS();
2337 SmallString<256>
Code;
2341 if (!getAssembler().getEmitterPtr())
2344 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2347 bool ForceLE =
getContext().getTargetTriple().isRISCV();
2354 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2357 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2359 MCFixupKindInfo
Info =
2360 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2361 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2362 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2363 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2364 FixupMap[
Index] = 1 + i;
2370 OS <<
"encoding: [";
2371 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2376 uint8_t MapEntry = FixupMap[i * 8 + 0];
2377 for (
unsigned j = 1;
j != 8; ++
j) {
2378 if (FixupMap[i * 8 + j] == MapEntry)
2381 MapEntry = uint8_t(~0U);
2385 if (MapEntry != uint8_t(~0U)) {
2386 if (MapEntry == 0) {
2387 OS <<
format(
"0x%02x", uint8_t(Code[i]));
2391 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\''
2392 << char(
'A' + MapEntry - 1) <<
'\'';
2394 OS << char(
'A' + MapEntry - 1);
2399 for (
unsigned j = 8;
j--;) {
2407 FixupBit = i * 8 +
j;
2409 FixupBit = i * 8 + (7-
j);
2411 if (uint8_t MapEntry = FixupMap[FixupBit]) {
2412 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2413 OS << char(
'A' + MapEntry - 1);
2421 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2423 OS <<
" fixup " << char(
'A' + i) <<
" - "
2424 <<
"offset: " <<
F.getOffset() <<
", value: ";
2426 auto Kind =
F.getKind();
2428 OS <<
", relocation type: " <<
Kind;
2431 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2432 if (
F.isPCRel() && StringRef(
Info.Name).starts_with(
"FK_Data_"))
2433 OS <<
"FK_PCRel_" << (
Info.TargetSize / 8);
2441void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2442 const MCSubtargetInfo &STI) {
2444 MCSection *Sec = getCurrentSectionOnly();
2448 if (MAI->
isAIX() && CurFrag)
2454 AddEncodingComment(Inst, STI);
2459 getCommentOS() <<
"\n";
2462 if(getTargetStreamer())
2463 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2465 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2467 StringRef Comments = CommentToEmit;
2468 if (Comments.
size() && Comments.
back() !=
'\n')
2469 getCommentOS() <<
"\n";
2474void MCAsmStreamer::emitPseudoProbe(uint64_t
Guid, uint64_t Index,
2475 uint64_t
Type, uint64_t Attr,
2476 uint64_t Discriminator,
2479 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2484 for (
const auto &Site : InlineStack)
2485 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2488 FnSym->
print(OS, MAI);
2493void MCAsmStreamer::emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
2494 const MCExpr *Expr, SMLoc) {
2505void MCAsmStreamer::emitAddrsig() {
2510void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2511 OS <<
"\t.addrsig_sym ";
2512 Sym->
print(OS, MAI);
2519void MCAsmStreamer::emitRawTextImpl(StringRef
String) {
2520 String.consume_back(
"\n");
2525void MCAsmStreamer::finishImpl() {
2540 const auto &Tables =
getContext().getMCDwarfLineTables();
2541 if (!Tables.empty()) {
2542 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2543 if (
auto *Label = Tables.begin()->second.getLabel()) {
2544 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2550void MCAsmStreamer::emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment) {
2562MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2563 const Twine &Comment) {
2571 return getContext().createTempSymbol(Prefix +
"_end");
2575void MCAsmStreamer::emitDwarfLineStartLabel(MCSymbol *StartSym) {
2586 emitLabel(DebugLineSymTmp);
2590 unsigned LengthFieldSize =
2596 emitAssignment(StartSym, OuterSym);
2602void MCAsmStreamer::emitDwarfLineEndEntry(MCSection *Section,
2603 MCSymbol *LastLabel,
2604 MCSymbol *EndLabel) {
2611 ".loc should not be generated together with raw data!");
2624 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2629void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2630 const MCSymbol *LastLabel,
2631 const MCSymbol *Label,
2632 unsigned PointerSize) {
2634 ".loc/.file don't need raw data in debug line section!");
2637 AddComment(
"Set address to " +
Label->getName());
2638 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2639 emitULEB128IntValue(PointerSize + 1);
2640 emitIntValue(dwarf::DW_LNE_set_address, 1);
2641 emitSymbolValue(Label, PointerSize);
2645 AddComment(
"Start sequence");
2653 AddComment(
"End sequence");
2654 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2655 emitULEB128IntValue(1);
2656 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2661 AddComment(
"Advance line " + Twine(LineDelta));
2662 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2663 emitSLEB128IntValue(LineDelta);
2664 emitIntValue(dwarf::DW_LNS_copy, 1);
2668 std::unique_ptr<formatted_raw_ostream> OS,
2669 std::unique_ptr<MCInstPrinter> IP,
2670 std::unique_ptr<MCCodeEmitter> CE,
2671 std::unique_ptr<MCAsmBackend> MAB) {
2672 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!")
Analysis containing CSE Info
#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
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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 getAssemblerDialect() 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 emitWinCFIEndChained(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 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 emitWinCFIStartChained(SMLoc Loc=SMLoc())
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
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