47 std::unique_ptr<formatted_raw_ostream> OSOwner;
48 formatted_raw_ostream &OS;
50 std::unique_ptr<MCInstPrinter> InstPrinter;
51 std::unique_ptr<MCAssembler> Assembler;
53 SmallString<128> ExplicitCommentToEmit;
54 SmallString<128> CommentToEmit;
55 raw_svector_ostream CommentStream;
56 raw_null_ostream NullStream;
58 bool EmittedSectionDirective =
false;
60 bool IsVerboseAsm =
false;
61 bool ShowInst =
false;
62 bool UseDwarfDirectory =
false;
64 void EmitRegisterName(int64_t
Register);
65 void PrintQuotedString(StringRef
Data, raw_ostream &OS)
const;
66 void printDwarfFileDirective(
unsigned FileNo, StringRef Directory,
68 std::optional<MD5::MD5Result> Checksum,
69 std::optional<StringRef> Source,
70 bool UseDwarfDirectory,
71 raw_svector_ostream &OS)
const;
72 void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
override;
73 void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame)
override;
76 void emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
77 unsigned Discriminator);
81 void emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
82 unsigned Column,
unsigned Flags,
83 unsigned Isa,
unsigned Discriminator,
84 StringRef FileName, StringRef Comment);
87 MCAsmStreamer(MCContext &
Context, std::unique_ptr<formatted_raw_ostream> os,
88 std::unique_ptr<MCInstPrinter>
printer,
89 std::unique_ptr<MCCodeEmitter> emitter,
90 std::unique_ptr<MCAsmBackend> asmbackend)
91 : MCAsmBaseStreamer(
Context), OSOwner(std::
move(os)), OS(*OSOwner),
93 Assembler(std::make_unique<MCAssembler>(
95 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
97 CommentStream(CommentToEmit) {
99 if (Assembler->getBackendPtr())
100 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
102 Context.setUseNamesOnTempLabels(
true);
104 auto *TO =
Context.getTargetOptions();
107 IsVerboseAsm = TO->AsmVerbose;
109 InstPrinter->setCommentStream(CommentStream);
110 ShowInst = TO->ShowMCInst;
111 switch (TO->MCUseDwarfDirectory) {
113 UseDwarfDirectory =
false;
116 UseDwarfDirectory =
true;
120 Context.getAsmInfo()->enableDwarfFileDirectoryDefault();
125 MCAssembler &getAssembler() {
return *Assembler; }
126 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
128 inline void EmitEOL() {
130 emitExplicitComments();
136 EmitCommentsAndEOL();
139 void emitSyntaxDirective(StringRef Syntax, StringRef
Options)
override;
141 void EmitCommentsAndEOL();
144 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
147 bool hasRawTextSupport()
const override {
return true; }
152 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
155 void AddEncodingComment(
const MCInst &Inst,
const MCSubtargetInfo &);
160 raw_ostream &getCommentOS()
override {
163 return CommentStream;
166 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
168 void addExplicitComment(
const Twine &
T)
override;
169 void emitExplicitComments()
override;
172 void addBlankLine()
override { EmitEOL(); }
177 void switchSection(MCSection *Section, uint32_t Subsection)
override;
178 bool popSection()
override;
180 void emitELFSymverDirective(
const MCSymbol *OriginalSym, StringRef Name,
181 bool KeepOriginalSym)
override;
185 void emitGNUAttribute(
unsigned Tag,
unsigned Value)
override;
188 auto [Ptr,
Bits] = InstPrinter->getMnemonic(
MI);
189 assert((Bits != 0 || Ptr ==
nullptr) &&
190 "Invalid char pointer for instruction with no mnemonic");
194 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc())
override;
196 void emitSubsectionsViaSymbols()
override;
197 void emitLinkerOptions(ArrayRef<std::string>
Options)
override;
200 unsigned Update, VersionTuple SDKVersion)
override;
201 void emitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
202 unsigned Update, VersionTuple SDKVersion)
override;
203 void emitDarwinTargetVariantBuildVersion(
unsigned Platform,
unsigned Major,
204 unsigned Minor,
unsigned Update,
205 VersionTuple SDKVersion)
override;
207 void emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value)
override;
208 void emitConditionalAssignment(MCSymbol *Symbol,
209 const MCExpr *
Value)
override;
210 void emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol)
override;
213 void emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue)
override;
214 void beginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
215 void emitCOFFSymbolStorageClass(
int StorageClass)
override;
216 void emitCOFFSymbolType(
int Type)
override;
217 void endCOFFSymbolDef()
override;
218 void emitCOFFSafeSEH(MCSymbol
const *Symbol)
override;
219 void emitCOFFSymbolIndex(MCSymbol
const *Symbol)
override;
220 void emitCOFFSectionIndex(MCSymbol
const *Symbol)
override;
221 void emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset)
override;
222 void emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset)
override;
223 void emitCOFFSecNumber(MCSymbol
const *Symbol)
override;
224 void emitCOFFSecOffset(MCSymbol
const *Symbol)
override;
225 void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t
Size,
226 MCSymbol *CsectSym, Align Alignment)
override;
227 void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
230 void emitXCOFFRenameDirective(
const MCSymbol *Name,
231 StringRef Rename)
override;
233 void emitXCOFFRefDirective(
const MCSymbol *Symbol)
override;
235 void emitXCOFFExceptDirective(
const MCSymbol *Symbol,
236 const MCSymbol *
Trap,
237 unsigned Lang,
unsigned Reason,
238 unsigned FunctionSize,
bool hasDebug)
override;
239 void emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata)
override;
241 void emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value)
override;
242 void emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
243 Align ByteAlignment)
override;
250 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
251 Align ByteAlignment)
override;
253 void emitZerofill(MCSection *Section, MCSymbol *Symbol =
nullptr,
254 uint64_t
Size = 0, Align ByteAlignment =
Align(1),
255 SMLoc Loc = SMLoc())
override;
257 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t
Size,
258 Align ByteAlignment =
Align(1))
override;
260 void emitBinaryData(StringRef
Data)
override;
262 void emitBytes(StringRef
Data)
override;
264 void emitValueImpl(
const MCExpr *
Value,
unsigned Size,
265 SMLoc Loc = SMLoc())
override;
266 void emitIntValue(uint64_t
Value,
unsigned Size)
override;
267 void emitIntValueInHex(uint64_t
Value,
unsigned Size)
override;
268 void emitIntValueInHexWithPadding(uint64_t
Value,
unsigned Size)
override;
270 void emitULEB128Value(
const MCExpr *
Value)
override;
272 void emitSLEB128Value(
const MCExpr *
Value)
override;
274 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
275 SMLoc Loc = SMLoc())
override;
277 void emitFill(
const MCExpr &NumValues, int64_t
Size, int64_t Expr,
278 SMLoc Loc = SMLoc())
override;
280 void emitAlignmentDirective(uint64_t ByteAlignment,
281 std::optional<int64_t>
Value,
unsigned ValueSize,
282 unsigned MaxBytesToEmit);
284 void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
286 unsigned MaxBytesToEmit = 0)
override;
288 void emitCodeAlignment(Align Alignment,
const MCSubtargetInfo *STI,
289 unsigned MaxBytesToEmit = 0)
override;
290 void emitPrefAlign(Align Alignment)
override;
292 void emitValueToOffset(
const MCExpr *
Offset,
296 void emitFileDirective(StringRef
Filename)
override;
297 void emitFileDirective(StringRef
Filename, StringRef CompilerVersion,
298 StringRef TimeStamp, StringRef Description)
override;
299 Expected<unsigned> tryEmitDwarfFileDirective(
300 unsigned FileNo, StringRef Directory, StringRef
Filename,
301 std::optional<MD5::MD5Result> Checksum = std::nullopt,
302 std::optional<StringRef> Source = std::nullopt,
303 unsigned CUID = 0)
override;
304 void emitDwarfFile0Directive(StringRef Directory, StringRef
Filename,
305 std::optional<MD5::MD5Result> Checksum,
306 std::optional<StringRef> Source,
307 unsigned CUID = 0)
override;
308 void emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
unsigned Column,
309 unsigned Flags,
unsigned Isa,
310 unsigned Discriminator, StringRef FileName,
311 StringRef Location = {})
override;
312 void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
override;
316 void emitDwarfLocDirectiveWithInlinedAt(
unsigned FileNo,
unsigned Line,
317 unsigned Column,
unsigned FileIA,
318 unsigned LineIA,
unsigned ColIA,
319 const MCSymbol *Sym,
unsigned Flags,
320 unsigned Isa,
unsigned Discriminator,
322 StringRef Comment = {})
override;
324 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
326 bool emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
327 ArrayRef<uint8_t> Checksum,
328 unsigned ChecksumKind)
override;
329 bool emitCVFuncIdDirective(
unsigned FuncId)
override;
330 bool emitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
331 unsigned IAFile,
unsigned IALine,
332 unsigned IACol, SMLoc Loc)
override;
333 void emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
334 unsigned Column,
bool PrologueEnd,
bool IsStmt,
335 StringRef FileName, SMLoc Loc)
override;
336 void emitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
337 const MCSymbol *FnEnd)
override;
338 void emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
339 unsigned SourceFileId,
340 unsigned SourceLineNum,
341 const MCSymbol *FnStartSym,
342 const MCSymbol *FnEndSym)
override;
344 void PrintCVDefRangePrefix(
345 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
347 void emitCVDefRangeDirective(
348 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
349 codeview::DefRangeRegisterRelHeader DRHdr)
override;
351 void emitCVDefRangeDirective(
352 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
353 codeview::DefRangeSubfieldRegisterHeader DRHdr)
override;
355 void emitCVDefRangeDirective(
356 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
357 codeview::DefRangeRegisterHeader DRHdr)
override;
359 void emitCVDefRangeDirective(
360 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
361 codeview::DefRangeFramePointerRelHeader DRHdr)
override;
363 void emitCVStringTableDirective()
override;
364 void emitCVFileChecksumsDirective()
override;
365 void emitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
366 void emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L)
override;
368 void emitIdent(StringRef IdentString)
override;
369 void emitCFIBKeyFrame()
override;
370 void emitCFIMTETaggedFrame()
override;
371 void emitCFISections(
bool EH,
bool Debug,
bool SFrame)
override;
372 void emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
373 void emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc)
override;
374 void emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc)
override;
377 void emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
378 void emitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
379 void emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
380 void emitCFIRememberState(SMLoc Loc)
override;
381 void emitCFIRestoreState(SMLoc Loc)
override;
382 void emitCFIRestore(int64_t
Register, SMLoc Loc)
override;
383 void emitCFISameValue(int64_t
Register, SMLoc Loc)
override;
384 void emitCFIRelOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
385 void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc)
override;
386 void emitCFIEscape(StringRef Values, SMLoc Loc)
override;
387 void emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc)
override;
388 void emitCFISignalFrame()
override;
389 void emitCFIUndefined(int64_t
Register, SMLoc Loc)
override;
390 void emitCFIRegister(int64_t Register1, int64_t Register2,
392 void emitCFIWindowSave(SMLoc Loc)
override;
393 void emitCFINegateRAState(SMLoc Loc)
override;
394 void emitCFINegateRAStateWithPC(SMLoc Loc)
override;
395 void emitCFIReturnColumn(int64_t
Register)
override;
396 void emitCFILabelDirective(SMLoc Loc, StringRef Name)
override;
397 void emitCFIValOffset(int64_t
Register, int64_t
Offset, SMLoc Loc)
override;
399 void emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc)
override;
400 void emitWinCFIEndProc(SMLoc Loc)
override;
401 void emitWinCFIFuncletOrFuncEnd(SMLoc Loc)
override;
402 void emitWinCFISplitChained(SMLoc Loc)
override;
403 void emitWinCFIPushReg(MCRegister
Register, SMLoc Loc)
override;
406 void emitWinCFIAllocStack(
unsigned Size, SMLoc Loc)
override;
411 void emitWinCFIPushFrame(
bool Code, SMLoc Loc)
override;
412 void emitWinCFIEndProlog(SMLoc Loc)
override;
413 void emitWinCFIBeginEpilogue(SMLoc Loc)
override;
414 void emitWinCFIEndEpilogue(SMLoc Loc)
override;
415 void emitWinCFIUnwindV2Start(SMLoc Loc)
override;
416 void emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc)
override;
418 void emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
420 void emitWinEHHandlerData(SMLoc Loc)
override;
422 void emitCGProfileEntry(
const MCSymbolRefExpr *From,
423 const MCSymbolRefExpr *To, uint64_t
Count)
override;
425 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
427 void emitPseudoProbe(uint64_t
Guid, uint64_t Index, uint64_t
Type,
428 uint64_t Attr, uint64_t Discriminator,
430 MCSymbol *FnSym)
override;
432 void emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
433 const MCExpr *Expr, SMLoc Loc)
override;
435 void emitAddrsig()
override;
436 void emitAddrsigSym(
const MCSymbol *Sym)
override;
441 void emitRawTextImpl(StringRef
String)
override;
443 void finishImpl()
override;
445 void emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment)
override;
447 MCSymbol *emitDwarfUnitLength(
const Twine &Prefix,
448 const Twine &Comment)
override;
450 void emitDwarfLineStartLabel(MCSymbol *StartSym)
override;
452 void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel,
453 MCSymbol *EndLabel =
nullptr)
override;
455 void emitDwarfAdvanceLineAddr(int64_t LineDelta,
const MCSymbol *LastLabel,
456 const MCSymbol *Label,
457 unsigned PointerSize)
override;
462void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
463 if (!IsVerboseAsm)
return;
465 T.toVector(CommentToEmit);
471void MCAsmStreamer::EmitCommentsAndEOL() {
477 StringRef Comments = CommentToEmit;
480 "Comment array not newline terminated");
484 size_t Position = Comments.
find(
'\n');
487 Comments = Comments.
substr(Position+1);
488 }
while (!Comments.
empty());
490 CommentToEmit.
clear();
494 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
495 return Value & ((
uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
498void MCAsmStreamer::emitRawComment(
const Twine &
T,
bool TabPrefix) {
505void MCAsmStreamer::addExplicitComment(
const Twine &
T) {
506 StringRef c =
T.getSingleStringRef();
510 ExplicitCommentToEmit.
append(
"\t");
515 size_t p = 2, len = c.
size() - 2;
519 ExplicitCommentToEmit.
append(
"\t");
524 ExplicitCommentToEmit.
append(
"\n");
528 ExplicitCommentToEmit.
append(
"\t");
530 }
else if (c.
front() ==
'#') {
532 ExplicitCommentToEmit.
append(
"\t");
536 assert(
false &&
"Unexpected Assembly Comment");
538 if (c.
back() ==
'\n')
539 emitExplicitComments();
542void MCAsmStreamer::emitExplicitComments() {
543 StringRef Comments = ExplicitCommentToEmit;
544 if (!Comments.
empty())
546 ExplicitCommentToEmit.
clear();
549void MCAsmStreamer::switchSection(MCSection *Section, uint32_t Subsection) {
551 if (!EmittedSectionDirective ||
553 EmittedSectionDirective =
true;
554 if (MCTargetStreamer *TS = getTargetStreamer()) {
555 TS->changeSection(Cur.first, Section, Subsection, OS);
564bool MCAsmStreamer::popSection() {
567 auto [Sec, Subsec] = getCurrentSection();
572void MCAsmStreamer::emitELFSymverDirective(
const MCSymbol *OriginalSym,
574 bool KeepOriginalSym) {
576 OriginalSym->
print(OS, MAI);
578 if (!KeepOriginalSym && !
Name.contains(
"@@@"))
583void MCAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
588 if (!
Symbol->isVariable() &&
603 assert(NbArgs != -1 && ((
size_t)NbArgs) ==
Args.size() &&
"Malformed LOH!");
604 assert(str !=
"" &&
"Invalid LOH name");
609 for (
const MCSymbol *Arg : Args) {
618void MCAsmStreamer::emitGNUAttribute(
unsigned Tag,
unsigned Value) {
619 OS <<
"\t.gnu_attribute " <<
Tag <<
", " <<
Value <<
"\n";
622void MCAsmStreamer::emitSubsectionsViaSymbols() {
623 OS <<
".subsections_via_symbols\n";
626void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string>
Options) {
627 assert(!
Options.empty() &&
"At least one option is required!");
628 OS <<
"\t.linker_option \"" <<
Options[0] <<
'"';
630 OS <<
", " <<
'"' << Opt <<
'"';
659 if (SDKVersion.
empty())
661 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
662 if (
auto Minor = SDKVersion.
getMinor()) {
663 OS <<
", " << *Minor;
665 OS <<
", " << *Subminor;
671 unsigned Minor,
unsigned Update,
672 VersionTuple SDKVersion) {
675 OS <<
", " << Update;
682#define PLATFORM(platform, id, name, build_name, target, tapi_target, \
684 case MachO::PLATFORM_##platform: \
686#include "llvm/BinaryFormat/MachO.def"
691void MCAsmStreamer::emitBuildVersion(
unsigned Platform,
unsigned Major,
692 unsigned Minor,
unsigned Update,
693 VersionTuple SDKVersion) {
695 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
697 OS <<
", " << Update;
702void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
703 unsigned Platform,
unsigned Major,
unsigned Minor,
unsigned Update,
704 VersionTuple SDKVersion) {
705 emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
708void MCAsmStreamer::emitAssignment(MCSymbol *Symbol,
const MCExpr *
Value) {
713 OS << (UseSet ?
", " :
" = ");
720void MCAsmStreamer::emitConditionalAssignment(MCSymbol *Symbol,
721 const MCExpr *
Value) {
722 OS <<
".lto_set_conditional ";
729void MCAsmStreamer::emitWeakReference(MCSymbol *Alias,
const MCSymbol *Symbol) {
731 Alias->
print(OS, MAI);
737bool MCAsmStreamer::emitSymbolAttribute(MCSymbol *Symbol,
754 default:
return false;
777 OS <<
"\t.no_dead_strip\t";
782 OS <<
"\t.private_extern\t";
791 OS <<
"\t.weak_definition\t";
808 OS <<
"\t.weak_anti_dep\t";
818void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol,
unsigned DescValue) {
819 OS <<
".desc" <<
' ';
821 OS <<
',' << DescValue;
825void MCAsmStreamer::emitSyntaxDirective(StringRef Syntax, StringRef
Options) {
826 OS <<
"\t." << Syntax <<
"_syntax";
832void MCAsmStreamer::beginCOFFSymbolDef(
const MCSymbol *Symbol) {
839void MCAsmStreamer::emitCOFFSymbolStorageClass(
int StorageClass) {
844void MCAsmStreamer::emitCOFFSymbolType(
int Type) {
845 OS <<
"\t.type\t" <<
Type <<
';';
849void MCAsmStreamer::endCOFFSymbolDef() {
854void MCAsmStreamer::emitCOFFSafeSEH(MCSymbol
const *Symbol) {
855 OS <<
"\t.safeseh\t";
860void MCAsmStreamer::emitCOFFSymbolIndex(MCSymbol
const *Symbol) {
866void MCAsmStreamer::emitCOFFSectionIndex(MCSymbol
const *Symbol) {
872void MCAsmStreamer::emitCOFFSecRel32(MCSymbol
const *Symbol, uint64_t
Offset) {
873 OS <<
"\t.secrel32\t";
880void MCAsmStreamer::emitCOFFImgRel32(MCSymbol
const *Symbol, int64_t
Offset) {
890void MCAsmStreamer::emitCOFFSecNumber(MCSymbol
const *Symbol) {
896void MCAsmStreamer::emitCOFFSecOffset(MCSymbol
const *Symbol) {
897 OS <<
"\t.secoffset\t";
905void MCAsmStreamer::emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
910 "We only support writing log base-2 alignment format with XCOFF.");
913 LabelSym->
print(OS, MAI);
914 OS <<
',' <<
Size <<
',';
915 CsectSym->
print(OS, MAI);
916 OS <<
',' <<
Log2(Alignment);
922 auto *XSym =
static_cast<MCSymbolXCOFF *
>(CsectSym);
923 if (XSym->hasRename())
924 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
927void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
929 auto &Sym =
static_cast<MCSymbolXCOFF &
>(*Symbol);
949 switch (Visibility) {
970 emitXCOFFRenameDirective(&Sym, Sym.getSymbolTableName());
973void MCAsmStreamer::emitXCOFFRenameDirective(
const MCSymbol *Name,
976 Name->print(OS, MAI);
979 for (
char C : Rename) {
989void MCAsmStreamer::emitXCOFFRefDirective(
const MCSymbol *Symbol) {
995void MCAsmStreamer::emitXCOFFExceptDirective(
const MCSymbol *Symbol,
996 const MCSymbol *
Trap,
999 unsigned FunctionSize,
1001 OS <<
"\t.except\t";
1003 OS <<
", " << Lang <<
", " << Reason;
1007void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef
Metadata) {
1008 const char InfoDirective[] =
"\t.info ";
1009 const char *Separator =
", ";
1010 constexpr int WordSize =
sizeof(uint32_t);
1013 OS << InfoDirective;
1014 PrintQuotedString(Name, OS);
1017 size_t MetadataSize =
Metadata.size();
1020 OS <<
format_hex(MetadataSize, 10) << Separator;
1023 if (MetadataSize == 0) {
1033 uint32_t PaddedSize =
alignTo(MetadataSize, WordSize);
1034 uint32_t PaddingSize = PaddedSize - MetadataSize;
1041 constexpr int WordsPerDirective = 5;
1044 int WordsBeforeNextDirective = 0;
1045 auto PrintWord = [&](
const uint8_t *WordPtr) {
1046 if (WordsBeforeNextDirective-- == 0) {
1048 OS << InfoDirective;
1049 WordsBeforeNextDirective = WordsPerDirective;
1057 for (;
Index + WordSize <= MetadataSize;
Index += WordSize)
1058 PrintWord(
reinterpret_cast<const uint8_t *
>(
Metadata.data()) + Index);
1063 assert(PaddedSize - Index == WordSize);
1064 std::array<uint8_t, WordSize> LastWord = {0};
1065 ::memcpy(LastWord.data(),
Metadata.data() + Index, MetadataSize - Index);
1066 PrintWord(LastWord.data());
1071void MCAsmStreamer::emitELFSize(MCSymbol *Symbol,
const MCExpr *
Value) {
1080void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1081 Align ByteAlignment) {
1089 OS <<
',' <<
Log2(ByteAlignment);
1095 auto *XSym =
static_cast<MCSymbolXCOFF *
>(
Symbol);
1096 if (XSym && XSym->hasRename())
1097 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1101void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t
Size,
1107 if (ByteAlign > 1) {
1112 OS <<
',' << ByteAlign.
value();
1115 OS <<
',' <<
Log2(ByteAlign);
1122void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
1123 uint64_t
Size, Align ByteAlignment,
1132 ".zerofill is a Mach-O specific directive");
1135 const MCSectionMachO *MOSection = ((
const MCSectionMachO*)Section);
1142 OS <<
',' <<
Log2(ByteAlignment);
1150void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
1151 uint64_t
Size, Align ByteAlignment) {
1157 ".zerofill is a Mach-O specific directive");
1166 if (ByteAlignment > 1)
1167 OS <<
", " <<
Log2(ByteAlignment);
1173 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1174 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1185 assert(!
Data.empty() &&
"Cannot generate an empty list.");
1186 const auto printCharacterInOctal = [&OS](
unsigned char C) {
1192 const auto printOneCharacterFor = [printCharacterInOctal](
1193 auto printOnePrintingCharacter) {
1194 return [printCharacterInOctal, printOnePrintingCharacter](
unsigned char C) {
1196 printOnePrintingCharacter(
static_cast<char>(
C));
1199 printCharacterInOctal(
C);
1202 const auto printCharacterList = [
Data, &OS](
const auto &printOneCharacter) {
1203 const auto BeginPtr =
Data.begin(), EndPtr =
Data.end();
1204 for (
const unsigned char C :
make_range(BeginPtr, EndPtr - 1)) {
1205 printOneCharacter(
C);
1208 printOneCharacter(*(EndPtr - 1));
1212 printCharacterList(printCharacterInOctal);
1215 printCharacterList(printOneCharacterFor([&OS](
char C) {
1216 const char AsmCharLitBuf[2] = {
'\'',
C};
1217 OS <<
StringRef(AsmCharLitBuf,
sizeof(AsmCharLitBuf));
1224void MCAsmStreamer::PrintQuotedString(StringRef
Data, raw_ostream &OS)
const {
1228 for (
unsigned char C :
Data) {
1235 for (
unsigned char C :
Data) {
1236 if (
C ==
'"' ||
C ==
'\\') {
1237 OS <<
'\\' << (char)
C;
1275void MCAsmStreamer::emitBytes(StringRef
Data) {
1276 assert(getCurrentSectionOnly() &&
1277 "Cannot emit contents before setting section!");
1278 if (
Data.empty())
return;
1280 const auto emitAsString = [
this](StringRef
Data) {
1285 if (
Data.back() == 0) {
1286 OS <<
"\t.string\t";
1291 PrintQuotedString(
Data, OS);
1311 PrintQuotedString(
Data, OS);
1316 if (
Data.size() != 1 && emitAsString(
Data))
1321 if (MCTargetStreamer *TS = getTargetStreamer()) {
1322 TS->emitRawBytes(
Data);
1326 for (
const unsigned char C :
Data.bytes()) {
1327 OS << Directive << (unsigned)
C;
1332void MCAsmStreamer::emitBinaryData(StringRef
Data) {
1334 const size_t Cols = 4;
1335 for (
size_t I = 0, EI =
alignTo(
Data.size(), Cols);
I < EI;
I += Cols) {
1336 size_t J =
I, EJ = std::min(
I + Cols,
Data.size());
1339 for (; J < EJ - 1; ++J)
1340 OS <<
format(
"0x%02x", uint8_t(
Data[J])) <<
", ";
1346void MCAsmStreamer::emitIntValue(uint64_t
Value,
unsigned Size) {
1350void MCAsmStreamer::emitIntValueInHex(uint64_t
Value,
unsigned Size) {
1354void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t
Value,
1359void MCAsmStreamer::emitValueImpl(
const MCExpr *
Value,
unsigned Size,
1362 assert(getCurrentSectionOnly() &&
1363 "Cannot emit contents before setting section!");
1364 const char *Directive =
nullptr;
1375 if (!
Value->evaluateAsAbsolute(IntValue))
1390 unsigned ByteOffset =
1391 IsLittleEndian ?
Emitted : (Remaining - EmissionSize);
1392 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1396 uint64_t Shift = 64 - EmissionSize * 8;
1397 assert(Shift <
static_cast<uint64_t
>(
1398 std::numeric_limits<unsigned long long>::digits) &&
1399 "undefined behavior");
1400 ValueToEmit &= ~0ULL >> Shift;
1401 emitIntValue(ValueToEmit, EmissionSize);
1407 assert(Directive &&
"Invalid size for machine code value!");
1409 if (MCTargetStreamer *TS = getTargetStreamer()) {
1410 TS->emitValue(
Value);
1417void MCAsmStreamer::emitULEB128Value(
const MCExpr *
Value) {
1419 if (
Value->evaluateAsAbsolute(IntValue)) {
1420 emitULEB128IntValue(IntValue);
1423 OS <<
"\t.uleb128 ";
1428void MCAsmStreamer::emitSLEB128Value(
const MCExpr *
Value) {
1430 if (
Value->evaluateAsAbsolute(IntValue)) {
1431 emitSLEB128IntValue(IntValue);
1434 OS <<
"\t.sleb128 ";
1439void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1441 int64_t IntNumBytes;
1442 const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1443 if (IsAbsolute && IntNumBytes == 0)
1447 if (!MAI->
isAIX() || FillValue == 0) {
1449 OS << ZeroDirective;
1452 OS <<
',' << (int)FillValue;
1457 "Cannot emit non-absolute expression lengths of fill.");
1458 for (
int i = 0; i < IntNumBytes; ++i) {
1469void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t
Size,
1470 int64_t Expr, SMLoc Loc) {
1474 OS <<
", " <<
Size <<
", 0x";
1479void MCAsmStreamer::emitAlignmentDirective(uint64_t ByteAlignment,
1480 std::optional<int64_t>
Value,
1482 unsigned MaxBytesToEmit) {
1496 switch (ValueSize) {
1500 OS <<
"\t.p2align\t";
1514 if (
Value.has_value() || MaxBytesToEmit) {
1515 if (
Value.has_value()) {
1523 OS <<
", " << MaxBytesToEmit;
1531 switch (ValueSize) {
1533 case 1: OS <<
".balign";
break;
1534 case 2: OS <<
".balignw";
break;
1535 case 4: OS <<
".balignl";
break;
1540 if (
Value.has_value())
1542 else if (MaxBytesToEmit)
1545 OS <<
", " << MaxBytesToEmit;
1549void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Fill,
1551 unsigned MaxBytesToEmit) {
1552 emitAlignmentDirective(Alignment.
value(), Fill, FillLen, MaxBytesToEmit);
1555void MCAsmStreamer::emitCodeAlignment(Align Alignment,
1556 const MCSubtargetInfo *STI,
1557 unsigned MaxBytesToEmit) {
1563 emitAlignmentDirective(Alignment.
value(), std::nullopt, 1, MaxBytesToEmit);
1566void MCAsmStreamer::emitPrefAlign(Align Alignment) {
1567 OS <<
"\t.prefalign\t" << Alignment.
value();
1571void MCAsmStreamer::emitValueToOffset(
const MCExpr *
Offset,
1572 unsigned char Value,
1577 OS <<
", " << (unsigned)
Value;
1581void MCAsmStreamer::emitFileDirective(StringRef
Filename) {
1588void MCAsmStreamer::emitFileDirective(StringRef
Filename,
1589 StringRef CompilerVersion,
1590 StringRef TimeStamp,
1591 StringRef Description) {
1595 bool useTimeStamp = !TimeStamp.
empty();
1596 bool useCompilerVersion = !CompilerVersion.
empty();
1597 bool useDescription = !Description.
empty();
1598 if (useTimeStamp || useCompilerVersion || useDescription) {
1601 PrintQuotedString(TimeStamp, OS);
1602 if (useCompilerVersion || useDescription) {
1604 if (useCompilerVersion)
1605 PrintQuotedString(CompilerVersion, OS);
1606 if (useDescription) {
1608 PrintQuotedString(Description, OS);
1615void MCAsmStreamer::printDwarfFileDirective(
1616 unsigned FileNo, StringRef Directory, StringRef
Filename,
1617 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1618 bool UseDwarfDirectory, raw_svector_ostream &OS)
const {
1619 SmallString<128> FullPathName;
1621 if (!UseDwarfDirectory && !Directory.
empty()) {
1625 FullPathName = Directory;
1632 OS <<
"\t.file\t" << FileNo <<
' ';
1633 if (!Directory.
empty()) {
1634 PrintQuotedString(Directory, OS);
1639 OS <<
" md5 0x" << Checksum->digest();
1642 PrintQuotedString(*Source, OS);
1646Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
1647 unsigned FileNo, StringRef Directory, StringRef
Filename,
1648 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1650 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1652 MCDwarfLineTable &Table =
getContext().getMCDwarfLineTable(CUID);
1654 Expected<unsigned> FileNoOrErr =
1659 FileNo = FileNoOrErr.
get();
1666 SmallString<128> Str;
1667 raw_svector_ostream OS1(Str);
1668 printDwarfFileDirective(FileNo, Directory,
Filename, Checksum, Source,
1669 UseDwarfDirectory, OS1);
1671 if (MCTargetStreamer *TS = getTargetStreamer())
1672 TS->emitDwarfFileDirective(OS1.str());
1674 emitRawText(OS1.str());
1679void MCAsmStreamer::emitDwarfFile0Directive(
1680 StringRef Directory, StringRef
Filename,
1681 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
1695 SmallString<128> Str;
1696 raw_svector_ostream OS1(Str);
1697 printDwarfFileDirective(0, Directory,
Filename, Checksum, Source,
1698 UseDwarfDirectory, OS1);
1700 if (MCTargetStreamer *TS = getTargetStreamer())
1701 TS->emitDwarfFileDirective(OS1.str());
1703 emitRawText(OS1.str());
1707void MCAsmStreamer::emitDwarfLocDirectiveFlags(
unsigned Flags,
unsigned Isa,
1708 unsigned Discriminator) {
1713 OS <<
" basic_block";
1715 OS <<
" prologue_end";
1717 OS <<
" epilogue_begin";
1719 const unsigned OldFlags =
getContext().getCurrentDwarfLoc().getFlags();
1726 OS <<
" isa " << Isa;
1732void MCAsmStreamer::emitDwarfLocDirectiveSuffix(
unsigned FileNo,
unsigned Line,
1733 unsigned Column,
unsigned Flags,
1735 unsigned Discriminator,
1737 StringRef Comment) {
1739 emitDwarfLocDirectiveFlags(Flags, Isa, Discriminator);
1746 OS << FileName <<
':' <<
Line <<
':' << Column;
1754 Discriminator, FileName, Comment);
1757void MCAsmStreamer::emitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1758 unsigned Column,
unsigned Flags,
1759 unsigned Isa,
unsigned Discriminator,
1761 StringRef Comment) {
1769 Discriminator, FileName, Comment);
1774 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1777 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1783void MCAsmStreamer::emitDwarfLocDirectiveWithInlinedAt(
1784 unsigned FileNo,
unsigned Line,
unsigned Column,
unsigned FileIA,
1785 unsigned LineIA,
unsigned ColIA,
const MCSymbol *Sym,
unsigned Flags,
1786 unsigned Isa,
unsigned Discriminator, StringRef FileName,
1787 StringRef Comment) {
1789 OS <<
"\t.loc\t" << FileNo <<
" " <<
Line <<
" " << Column;
1790 OS <<
", function_name " << *Sym;
1791 OS <<
", inlined_at " << FileIA <<
" " << LineIA <<
" " << ColIA;
1794 emitDwarfLocDirectiveSuffix(FileNo, Line, Column, Flags, Isa, Discriminator,
1798void MCAsmStreamer::emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name) {
1800 OS <<
".loc_label\t" <<
Name;
1804MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1810bool MCAsmStreamer::emitCVFileDirective(
unsigned FileNo, StringRef
Filename,
1811 ArrayRef<uint8_t> Checksum,
1812 unsigned ChecksumKind) {
1817 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1820 if (!ChecksumKind) {
1826 PrintQuotedString(
toHex(Checksum), OS);
1833bool MCAsmStreamer::emitCVFuncIdDirective(
unsigned FuncId) {
1834 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1838bool MCAsmStreamer::emitCVInlineSiteIdDirective(
unsigned FunctionId,
1841 unsigned IALine,
unsigned IACol,
1843 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1844 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1846 IALine, IACol, Loc);
1849void MCAsmStreamer::emitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1850 unsigned Line,
unsigned Column,
1851 bool PrologueEnd,
bool IsStmt,
1852 StringRef FileName, SMLoc Loc) {
1854 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1857 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " <<
Line <<
" "
1860 OS <<
" prologue_end";
1873void MCAsmStreamer::emitCVLinetableDirective(
unsigned FunctionId,
1874 const MCSymbol *FnStart,
1875 const MCSymbol *FnEnd) {
1876 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1877 FnStart->
print(OS, MAI);
1879 FnEnd->
print(OS, MAI);
1884void MCAsmStreamer::emitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1885 unsigned SourceFileId,
1886 unsigned SourceLineNum,
1887 const MCSymbol *FnStartSym,
1888 const MCSymbol *FnEndSym) {
1889 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1890 <<
' ' << SourceLineNum <<
' ';
1891 FnStartSym->
print(OS, MAI);
1893 FnEndSym->
print(OS, MAI);
1896 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1899void MCAsmStreamer::PrintCVDefRangePrefix(
1900 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1901 OS <<
"\t.cv_def_range\t";
1902 for (std::pair<const MCSymbol *, const MCSymbol *>
Range : Ranges) {
1910void MCAsmStreamer::emitCVDefRangeDirective(
1911 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1912 codeview::DefRangeRegisterRelHeader DRHdr) {
1913 PrintCVDefRangePrefix(Ranges);
1914 OS <<
", reg_rel, ";
1920void MCAsmStreamer::emitCVDefRangeDirective(
1921 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1922 codeview::DefRangeSubfieldRegisterHeader DRHdr) {
1923 PrintCVDefRangePrefix(Ranges);
1924 OS <<
", subfield_reg, ";
1929void MCAsmStreamer::emitCVDefRangeDirective(
1930 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1931 codeview::DefRangeRegisterHeader DRHdr) {
1932 PrintCVDefRangePrefix(Ranges);
1938void MCAsmStreamer::emitCVDefRangeDirective(
1939 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1940 codeview::DefRangeFramePointerRelHeader DRHdr) {
1941 PrintCVDefRangePrefix(Ranges);
1942 OS <<
", frame_ptr_rel, ";
1947void MCAsmStreamer::emitCVStringTableDirective() {
1948 OS <<
"\t.cv_stringtable";
1952void MCAsmStreamer::emitCVFileChecksumsDirective() {
1953 OS <<
"\t.cv_filechecksums";
1957void MCAsmStreamer::emitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1958 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1962void MCAsmStreamer::emitCVFPOData(
const MCSymbol *ProcSym, SMLoc L) {
1963 OS <<
"\t.cv_fpo_data\t";
1964 ProcSym->
print(OS, MAI);
1968void MCAsmStreamer::emitIdent(StringRef IdentString) {
1971 PrintQuotedString(IdentString, OS);
1975void MCAsmStreamer::emitCFISections(
bool EH,
bool Debug,
bool SFrame) {
1977 OS <<
"\t.cfi_sections ";
1986 OS <<
".debug_frame";
1998void MCAsmStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
1999 OS <<
"\t.cfi_startproc";
2005void MCAsmStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
2007 OS <<
"\t.cfi_endproc";
2011void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
2016 const MCRegisterInfo *MRI =
getContext().getRegisterInfo();
2017 if (std::optional<MCRegister> LLVMRegister =
2019 InstPrinter->printRegName(OS, *LLVMRegister);
2026void MCAsmStreamer::emitCFIDefCfa(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2028 OS <<
"\t.cfi_def_cfa ";
2034void MCAsmStreamer::emitCFIDefCfaOffset(int64_t
Offset, SMLoc Loc) {
2036 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
2040void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t
Register, int64_t
Offset,
2043 OS <<
"\t.cfi_llvm_def_aspace_cfa ";
2051 OS <<
"\t.cfi_escape ";
2052 if (!Values.
empty()) {
2053 size_t e = Values.
size() - 1;
2054 for (
size_t i = 0; i < e; ++i)
2060void MCAsmStreamer::emitCFIEscape(StringRef Values, SMLoc Loc) {
2066void MCAsmStreamer::emitCFIGnuArgsSize(int64_t
Size, SMLoc Loc) {
2069 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
2076void MCAsmStreamer::emitCFIDefCfaRegister(int64_t
Register, SMLoc Loc) {
2078 OS <<
"\t.cfi_def_cfa_register ";
2083void MCAsmStreamer::emitCFIOffset(int64_t
Register, int64_t
Offset, SMLoc Loc) {
2085 OS <<
"\t.cfi_offset ";
2091void MCAsmStreamer::emitCFIPersonality(
const MCSymbol *Sym,
2092 unsigned Encoding) {
2094 OS <<
"\t.cfi_personality " << Encoding <<
", ";
2095 Sym->
print(OS, MAI);
2099void MCAsmStreamer::emitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
2101 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
2102 Sym->
print(OS, MAI);
2106void MCAsmStreamer::emitCFIRememberState(SMLoc Loc) {
2108 OS <<
"\t.cfi_remember_state";
2112void MCAsmStreamer::emitCFIRestoreState(SMLoc Loc) {
2114 OS <<
"\t.cfi_restore_state";
2118void MCAsmStreamer::emitCFIRestore(int64_t
Register, SMLoc Loc) {
2120 OS <<
"\t.cfi_restore ";
2125void MCAsmStreamer::emitCFISameValue(int64_t
Register, SMLoc Loc) {
2127 OS <<
"\t.cfi_same_value ";
2132void MCAsmStreamer::emitCFIRelOffset(int64_t
Register, int64_t
Offset,
2135 OS <<
"\t.cfi_rel_offset ";
2141void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc) {
2143 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
2147void MCAsmStreamer::emitCFISignalFrame() {
2149 OS <<
"\t.cfi_signal_frame";
2153void MCAsmStreamer::emitCFIUndefined(int64_t
Register, SMLoc Loc) {
2155 OS <<
"\t.cfi_undefined ";
2160void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
2163 OS <<
"\t.cfi_register ";
2164 EmitRegisterName(Register1);
2166 EmitRegisterName(Register2);
2170void MCAsmStreamer::emitCFIWindowSave(SMLoc Loc) {
2172 OS <<
"\t.cfi_window_save";
2176void MCAsmStreamer::emitCFINegateRAState(SMLoc Loc) {
2178 OS <<
"\t.cfi_negate_ra_state";
2182void MCAsmStreamer::emitCFINegateRAStateWithPC(SMLoc Loc) {
2184 OS <<
"\t.cfi_negate_ra_state_with_pc";
2188void MCAsmStreamer::emitCFIReturnColumn(int64_t
Register) {
2190 OS <<
"\t.cfi_return_column ";
2195void MCAsmStreamer::emitCFILabelDirective(SMLoc Loc, StringRef Name) {
2197 OS <<
"\t.cfi_label " <<
Name;
2201void MCAsmStreamer::emitCFIBKeyFrame() {
2203 OS <<
"\t.cfi_b_key_frame";
2207void MCAsmStreamer::emitCFIMTETaggedFrame() {
2209 OS <<
"\t.cfi_mte_tagged_frame";
2213void MCAsmStreamer::emitCFIValOffset(int64_t
Register, int64_t
Offset,
2216 OS <<
"\t.cfi_val_offset ";
2222void MCAsmStreamer::emitWinCFIStartProc(
const MCSymbol *Symbol, SMLoc Loc) {
2230void MCAsmStreamer::emitWinCFIEndProc(SMLoc Loc) {
2233 OS <<
"\t.seh_endproc";
2237void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(SMLoc Loc) {
2240 OS <<
"\t.seh_endfunclet";
2244void MCAsmStreamer::emitWinCFISplitChained(SMLoc Loc) {
2247 OS <<
"\t.seh_splitchained";
2251void MCAsmStreamer::emitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
2252 bool Except, SMLoc Loc) {
2255 OS <<
"\t.seh_handler ";
2256 Sym->
print(OS, MAI);
2262 OS <<
", " << Marker <<
"unwind";
2264 OS <<
", " << Marker <<
"except";
2268void MCAsmStreamer::emitWinEHHandlerData(SMLoc Loc) {
2275 WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
2283 MCSection *XData = getAssociatedXDataSection(TextSec);
2284 switchSectionNoPrint(XData);
2286 OS <<
"\t.seh_handlerdata";
2290void MCAsmStreamer::emitWinCFIPushReg(MCRegister
Register, SMLoc Loc) {
2293 OS <<
"\t.seh_pushreg ";
2294 InstPrinter->printRegName(OS,
Register);
2298void MCAsmStreamer::emitWinCFISetFrame(MCRegister
Register,
unsigned Offset,
2302 OS <<
"\t.seh_setframe ";
2303 InstPrinter->printRegName(OS,
Register);
2308void MCAsmStreamer::emitWinCFIAllocStack(
unsigned Size, SMLoc Loc) {
2311 OS <<
"\t.seh_stackalloc " <<
Size;
2315void MCAsmStreamer::emitWinCFISaveReg(MCRegister
Register,
unsigned Offset,
2319 OS <<
"\t.seh_savereg ";
2320 InstPrinter->printRegName(OS,
Register);
2325void MCAsmStreamer::emitWinCFISaveXMM(MCRegister
Register,
unsigned Offset,
2329 OS <<
"\t.seh_savexmm ";
2330 InstPrinter->printRegName(OS,
Register);
2335void MCAsmStreamer::emitWinCFIPushFrame(
bool Code, SMLoc Loc) {
2338 OS <<
"\t.seh_pushframe";
2344void MCAsmStreamer::emitWinCFIEndProlog(SMLoc Loc) {
2347 OS <<
"\t.seh_endprologue";
2351void MCAsmStreamer::emitWinCFIBeginEpilogue(SMLoc Loc) {
2354 OS <<
"\t.seh_startepilogue";
2358void MCAsmStreamer::emitWinCFIEndEpilogue(SMLoc Loc) {
2361 OS <<
"\t.seh_endepilogue";
2365void MCAsmStreamer::emitWinCFIUnwindV2Start(SMLoc Loc) {
2368 OS <<
"\t.seh_unwindv2start";
2372void MCAsmStreamer::emitWinCFIUnwindVersion(uint8_t
Version, SMLoc Loc) {
2375 OS <<
"\t.seh_unwindversion " << (unsigned)
Version;
2379void MCAsmStreamer::emitCGProfileEntry(
const MCSymbolRefExpr *From,
2380 const MCSymbolRefExpr *To,
2382 OS <<
"\t.cg_profile ";
2386 OS <<
", " <<
Count;
2390void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
2391 const MCSubtargetInfo &STI) {
2392 raw_ostream &OS = getCommentOS();
2393 SmallString<256>
Code;
2397 if (!getAssembler().getEmitterPtr())
2400 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
2403 bool ForceLE =
getContext().getTargetTriple().isRISCV();
2410 for (
unsigned i = 0, e =
Code.size() * 8; i != e; ++i)
2413 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2415 MCFixupKindInfo
Info =
2416 getAssembler().getBackend().getFixupKindInfo(
F.getKind());
2417 for (
unsigned j = 0;
j !=
Info.TargetSize; ++
j) {
2418 unsigned Index =
F.getOffset() * 8 +
Info.TargetOffset +
j;
2419 assert(Index <
Code.size() * 8 &&
"Invalid offset in fixup!");
2420 FixupMap[
Index] = 1 + i;
2426 OS <<
"encoding: [";
2427 for (
unsigned i = 0, e =
Code.size(); i != e; ++i) {
2432 uint8_t MapEntry = FixupMap[i * 8 + 0];
2433 for (
unsigned j = 1;
j != 8; ++
j) {
2434 if (FixupMap[i * 8 + j] == MapEntry)
2437 MapEntry = uint8_t(~0U);
2441 if (MapEntry != uint8_t(~0U)) {
2442 if (MapEntry == 0) {
2443 OS <<
format(
"0x%02x", uint8_t(Code[i]));
2447 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\''
2448 << char(
'A' + MapEntry - 1) <<
'\'';
2450 OS << char(
'A' + MapEntry - 1);
2455 for (
unsigned j = 8;
j--;) {
2463 FixupBit = i * 8 +
j;
2465 FixupBit = i * 8 + (7-
j);
2467 if (uint8_t MapEntry = FixupMap[FixupBit]) {
2468 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
2469 OS << char(
'A' + MapEntry - 1);
2477 for (
unsigned i = 0, e =
Fixups.size(); i != e; ++i) {
2479 OS <<
" fixup " << char(
'A' + i) <<
" - "
2480 <<
"offset: " <<
F.getOffset() <<
", value: ";
2482 auto Kind =
F.getKind();
2484 OS <<
", relocation type: " <<
Kind;
2487 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
2488 if (
F.isPCRel() && StringRef(
Info.Name).starts_with(
"FK_Data_"))
2489 OS <<
"FK_PCRel_" << (
Info.TargetSize / 8);
2497void MCAsmStreamer::emitInstruction(
const MCInst &Inst,
2498 const MCSubtargetInfo &STI) {
2499 if (LFIRewriter && LFIRewriter->rewriteInst(Inst, *
this, STI))
2503 MCSection *Sec = getCurrentSectionOnly();
2507 if (MAI->
isAIX() && CurFrag)
2513 AddEncodingComment(Inst, STI);
2518 getCommentOS() <<
"\n";
2521 if(getTargetStreamer())
2522 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2524 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
2526 StringRef Comments = CommentToEmit;
2527 if (Comments.
size() && Comments.
back() !=
'\n')
2528 getCommentOS() <<
"\n";
2533void MCAsmStreamer::emitPseudoProbe(uint64_t
Guid, uint64_t Index,
2534 uint64_t
Type, uint64_t Attr,
2535 uint64_t Discriminator,
2538 OS <<
"\t.pseudoprobe\t" <<
Guid <<
" " <<
Index <<
" " <<
Type <<
" " << Attr;
2543 for (
const auto &Site : InlineStack)
2544 OS <<
" @ " << std::get<0>(Site) <<
":" << std::get<1>(Site);
2547 FnSym->
print(OS, MAI);
2552void MCAsmStreamer::emitRelocDirective(
const MCExpr &
Offset, StringRef Name,
2553 const MCExpr *Expr, SMLoc) {
2564void MCAsmStreamer::emitAddrsig() {
2569void MCAsmStreamer::emitAddrsigSym(
const MCSymbol *Sym) {
2570 OS <<
"\t.addrsig_sym ";
2571 Sym->
print(OS, MAI);
2578void MCAsmStreamer::emitRawTextImpl(StringRef
String) {
2579 String.consume_back(
"\n");
2584void MCAsmStreamer::finishImpl() {
2599 const auto &Tables =
getContext().getMCDwarfLineTables();
2600 if (!Tables.empty()) {
2601 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2602 if (
auto *Label = Tables.begin()->second.getLabel()) {
2603 switchSection(
getContext().getObjectFileInfo()->getDwarfLineSection(), 0);
2609void MCAsmStreamer::emitDwarfUnitLength(uint64_t
Length,
const Twine &Comment) {
2621MCSymbol *MCAsmStreamer::emitDwarfUnitLength(
const Twine &Prefix,
2622 const Twine &Comment) {
2630 return getContext().createTempSymbol(Prefix +
"_end");
2634void MCAsmStreamer::emitDwarfLineStartLabel(MCSymbol *StartSym) {
2645 emitLabel(DebugLineSymTmp);
2649 unsigned LengthFieldSize =
2655 emitAssignment(StartSym, OuterSym);
2661void MCAsmStreamer::emitDwarfLineEndEntry(MCSection *Section,
2662 MCSymbol *LastLabel,
2663 MCSymbol *EndLabel) {
2670 ".loc should not be generated together with raw data!");
2683 emitDwarfAdvanceLineAddr(
INT64_MAX, LastLabel, EndLabel,
2688void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2689 const MCSymbol *LastLabel,
2690 const MCSymbol *Label,
2691 unsigned PointerSize) {
2693 ".loc/.file don't need raw data in debug line section!");
2696 AddComment(
"Set address to " +
Label->getName());
2697 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2698 emitULEB128IntValue(PointerSize + 1);
2699 emitIntValue(dwarf::DW_LNE_set_address, 1);
2700 emitSymbolValue(Label, PointerSize);
2704 AddComment(
"Start sequence");
2712 AddComment(
"End sequence");
2713 emitIntValue(dwarf::DW_LNS_extended_op, 1);
2714 emitULEB128IntValue(1);
2715 emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2720 AddComment(
"Advance line " + Twine(LineDelta));
2721 emitIntValue(dwarf::DW_LNS_advance_line, 1);
2722 emitSLEB128IntValue(LineDelta);
2723 emitIntValue(dwarf::DW_LNS_copy, 1);
2727 std::unique_ptr<formatted_raw_ostream> OS,
2728 std::unique_ptr<MCInstPrinter> IP,
2729 std::unique_ptr<MCCodeEmitter> CE,
2730 std::unique_ptr<MCAsmBackend> MAB) {
2731 return new MCAsmStreamer(Context, std::move(OS), std::move(IP), std::move(CE),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_LIKELY(EXPR)
static ManagedStatic< cl::opt< bool, true >, CreateDebug > Debug
static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values)
static const char * getVersionMinDirective(MCVersionMinType Type)
static bool isPrintableString(StringRef Data)
static void PrintByteList(StringRef Data, raw_ostream &OS, MCAsmInfo::AsmCharLiteralSyntax ACLS)
static char toOctal(int X)
static void EmitSDKVersionSuffix(raw_ostream &OS, const VersionTuple &SDKVersion)
static int64_t truncateToSize(int64_t Value, unsigned Bytes)
static const char * getPlatformName(MachO::PlatformType Type)
#define DWARF2_FLAG_IS_STMT
#define DWARF2_FLAG_BASIC_BLOCK
#define DWARF2_FLAG_PROLOGUE_END
#define DWARF2_FLAG_EPILOGUE_BEGIN
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
Promote Memory to Register
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static constexpr StringLiteral Filename
This file defines the SmallString class.
StringRef getMnemonic(unsigned Opc)
LLVM_ABI void print(raw_ostream &OS) const
Print out the bounds to a stream.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
const char * getLabelSuffix() const
bool hasDotTypeDotSizeDirective() const
bool isLittleEndian() const
True if the target is little endian.
bool doesSupportDataRegionDirectives() const
bool usesSetToEquateSymbol() const
const char * getData32bitsDirective() const
unsigned getTextAlignFillValue() const
bool useDwarfRegNumForCFI() const
bool supportsExtendedDwarfLocDirective() const
const char * getData8bitsDirective() const
const char * getData64bitsDirective() const
AsmCharLiteralSyntax characterLiteralSyntax() const
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
void printExpr(raw_ostream &, const MCExpr &) const
virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, const Triple &, raw_ostream &) const
StringRef getCommentString() const
const char * getAscizDirective() const
const char * getZeroDirective() const
const char * getWeakDirective() const
const char * getData16bitsDirective() const
const char * getSeparatorString() const
bool getCOMMDirectiveAlignmentIsInBytes() const
const char * getGlobalDirective() const
unsigned getCommentColumn() const
bool hasSingleParameterDotFile() const
const char * getAsciiDirective() const
AsmCharLiteralSyntax
Assembly character literal syntax types.
@ ACLS_SingleQuotePrefix
Unknown; character literals not used by LLVM for this target.
const char * getWeakRefDirective() const
bool hasNoDeadStrip() const
bool hasIdentDirective() const
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
const MCAsmInfo * getAsmInfo() const
dwarf::DwarfFormat getDwarfFormat() const
static LLVM_ABI void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
static LLVM_ABI void make(MCStreamer *MCOS, MCSection *Section)
static LLVM_ABI void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
static LLVM_ABI void Emit(MCStreamer *MCOS)
LLVM_ABI void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCContext *Ctx=nullptr) const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
MCSection * getTextSection() const
std::optional< MCRegister > getLLVMRegNum(uint64_t RegNum, bool isEH) const
Map a dwarf register back to a target register.
StringRef getSegmentName() const
MCSymbol * getEndSymbol(MCContext &Ctx)
void setHasInstructions(bool Value)
StringRef getName() const
Streaming machine code generation interface.
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFIUnwindVersion(uint8_t Version, SMLoc Loc=SMLoc())
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
virtual void emitCFIBKeyFrame()
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
virtual void emitCFISections(bool EH, bool Debug, bool SFrame)
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual void emitCFIReturnColumn(int64_t Register)
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
virtual void emitWinCFIUnwindV2Start(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFINegateRAState(SMLoc Loc={})
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void emitCFIMTETaggedFrame()
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitCFIRememberState(SMLoc Loc)
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName, StringRef Comment={})
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitCFIRestoreState(SMLoc Loc)
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISplitChained(SMLoc Loc=SMLoc())
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
virtual void emitCFISignalFrame()
virtual void emitCFIRestore(int64_t Register, SMLoc Loc={})
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
void append(StringRef RHS)
Append from a StringRef.
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
char back() const
back - Get the last character in the string.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
char front() const
front - Get the first character in the string.
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
size_t GetNumBytesInBuffer() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
support::ulittle32_t Word
bool isRelocation(MCFixupKind FixupKind)
LLVM_ABI int getDwarfVersion()
@ Emitted
Assigned address, still materializing.
NodeAddr< CodeNode * > Code
Context & getContext() const
uint32_t read32be(const void *P)
LLVM_ABI bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionAddr VTableAddr Value
@ Debug
Register 'use' is for debugging purpose.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static StringRef MCLOHDirectiveName()
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > InstPrint, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB)
Create a machine code streamer which will print out assembly for the native target,...
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
@ MCDR_DataRegionEnd
.end_data_region
@ MCDR_DataRegion
.data_region
@ MCDR_DataRegionJT8
.data_region jt8
@ MCDR_DataRegionJT32
.data_region jt32
@ MCDR_DataRegionJT16
.data_region jt16
MCLOHDirective::LOHArgs MCLOHArgs
FunctionAddr VTableAddr uintptr_t uintptr_t Version
SmallVector< InlineSite, 8 > MCPseudoProbeInlineStack
@ MCVM_WatchOSVersionMin
.watchos_version_min
@ MCVM_OSXVersionMin
.macosx_version_min
@ MCVM_TvOSVersionMin
.tvos_version_min
@ MCVM_IOSVersionMin
.ios_version_min
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
FunctionAddr VTableAddr Count
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static int MCLOHIdToNbArgs(MCLOHType Kind)
FunctionAddr VTableAddr uintptr_t uintptr_t Data
MCLOHType
Linker Optimization Hint Type.
ArrayRef(const T &OneElt) -> ArrayRef< T >
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
bool isPrint(char C)
Checks whether character C is printable.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
unsigned Log2(Align A)
Returns the log2 of the alignment.
std::pair< MCSection *, uint32_t > MCSectionSubPair
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
@ MCSA_Memtag
.memtag (ELF)
@ MCSA_Protected
.protected (ELF)
@ MCSA_OSLinkage
symbol uses OS linkage (GOFF)
@ MCSA_Exported
.globl _foo, exported (XCOFF)
@ MCSA_PrivateExtern
.private_extern (MachO)
@ MCSA_Internal
.internal (ELF)
@ MCSA_WeakReference
.weak_reference (MachO)
@ MCSA_AltEntry
.alt_entry (MachO)
@ MCSA_ELF_TypeIndFunction
.type _foo, STT_GNU_IFUNC
@ MCSA_LazyReference
.lazy_reference (MachO)
@ MCSA_ELF_TypeNoType
.type _foo, STT_NOTYPE # aka @notype
@ MCSA_Reference
.reference (MachO)
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
@ MCSA_ELF_TypeTLS
.type _foo, STT_TLS # aka @tls_object
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
@ MCSA_WeakDefinition
.weak_definition (MachO)
@ MCSA_ELF_TypeCommon
.type _foo, STT_COMMON # aka @common
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_WeakAntiDep
.weak_anti_dep (COFF)
@ MCSA_XPLinkage
symbol uses XP linkage (GOFF)
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_ELF_TypeGnuUniqueObject
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
@ MCSA_Hidden
.hidden (ELF)
@ MCSA_LGlobal
.lglobl (XCOFF)
@ MCSA_Invalid
Not a valid directive.
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
static StringRef MCLOHIdToName(MCLOHType Kind)
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
const MCSymbol * Function