44 class MCAsmStreamer final :
public MCStreamer {
45 std::unique_ptr<formatted_raw_ostream> OSOwner;
48 std::unique_ptr<MCInstPrinter> InstPrinter;
49 std::unique_ptr<MCAssembler> Assembler;
56 unsigned IsVerboseAsm : 1;
57 unsigned ShowInst : 1;
58 unsigned UseDwarfDirectory : 1;
60 void EmitRegisterName(int64_t
Register);
66 bool isVerboseAsm,
bool useDwarfDirectory,
67 MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter,
68 std::unique_ptr<MCAsmBackend> asmbackend,
bool showInst)
70 MAI(Context.getAsmInfo()), InstPrinter(printer),
72 Context,
std::move(asmbackend),
std::move(emitter),
73 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
75 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
76 ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
79 InstPrinter->setCommentStream(CommentStream);
80 if (Assembler->getBackendPtr())
81 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
85 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
87 inline void EmitEOL() {
89 emitExplicitComments();
98 void EmitSyntaxDirective()
override;
100 void EmitCommentsAndEOL();
103 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
106 bool hasRawTextSupport()
const override {
return true; }
111 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
122 return CommentStream;
125 void emitRawComment(
const Twine &
T,
bool TabPrefix =
true)
override;
127 void addExplicitComment(
const Twine &
T)
override;
128 void emitExplicitComments()
override;
131 void AddBlankLine()
override {
140 void emitELFSymverDirective(
StringRef AliasName,
151 void EmitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
153 void EmitThumbFunc(
MCSymbol *Func)
override;
159 void EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue)
override;
160 void BeginCOFFSymbolDef(
const MCSymbol *Symbol)
override;
161 void EmitCOFFSymbolStorageClass(
int StorageClass)
override;
162 void EmitCOFFSymbolType(
int Type)
override;
163 void EndCOFFSymbolDef()
override;
164 void EmitCOFFSafeSEH(
MCSymbol const *Symbol)
override;
165 void EmitCOFFSymbolIndex(
MCSymbol const *Symbol)
override;
166 void EmitCOFFSectionIndex(
MCSymbol const *Symbol)
override;
167 void EmitCOFFSecRel32(
MCSymbol const *Symbol, uint64_t
Offset)
override;
168 void EmitCOFFImgRel32(
MCSymbol const *Symbol, int64_t
Offset)
override;
169 void EmitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym, uint64_t
Size,
171 unsigned ByteAlign)
override;
181 void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
191 void EmitBinaryData(
StringRef Data)
override;
197 void EmitIntValue(uint64_t Value,
unsigned Size)
override;
198 void EmitIntValueInHex(uint64_t Value,
unsigned Size)
override;
200 void EmitULEB128Value(
const MCExpr *Value)
override;
202 void EmitSLEB128Value(
const MCExpr *Value)
override;
204 void EmitDTPRel32Value(
const MCExpr *Value)
override;
205 void EmitDTPRel64Value(
const MCExpr *Value)
override;
206 void EmitTPRel32Value(
const MCExpr *Value)
override;
207 void EmitTPRel64Value(
const MCExpr *Value)
override;
209 void EmitGPRel64Value(
const MCExpr *Value)
override;
211 void EmitGPRel32Value(
const MCExpr *Value)
override;
213 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
216 void emitFill(
const MCExpr &NumValues, int64_t Size, int64_t Expr,
219 void EmitValueToAlignment(
unsigned ByteAlignment, int64_t Value = 0,
220 unsigned ValueSize = 1,
221 unsigned MaxBytesToEmit = 0)
override;
224 unsigned MaxBytesToEmit = 0)
override;
230 void EmitFileDirective(
StringRef Filename)
override;
236 unsigned CUID = 0)
override;
240 unsigned CUID = 0)
override;
241 void EmitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
242 unsigned Column,
unsigned Flags,
243 unsigned Isa,
unsigned Discriminator,
245 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
247 bool EmitCVFileDirective(
unsigned FileNo,
StringRef Filename,
250 bool EmitCVFuncIdDirective(
unsigned FuncId)
override;
251 bool EmitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
252 unsigned IAFile,
unsigned IALine,
253 unsigned IACol,
SMLoc Loc)
override;
254 void EmitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
255 unsigned Column,
bool PrologueEnd,
bool IsStmt,
257 void EmitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
259 void EmitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
260 unsigned SourceFileId,
261 unsigned SourceLineNum,
265 void PrintCVDefRangePrefix(
266 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
268 void EmitCVDefRangeDirective(
269 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
272 void EmitCVDefRangeDirective(
273 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
276 void EmitCVDefRangeDirective(
277 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
280 void EmitCVDefRangeDirective(
281 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
284 void EmitCVStringTableDirective()
override;
285 void EmitCVFileChecksumsDirective()
override;
286 void EmitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
287 void EmitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L)
override;
289 void EmitIdent(
StringRef IdentString)
override;
290 void EmitCFIBKeyFrame()
override;
291 void EmitCFISections(
bool EH,
bool Debug)
override;
293 void EmitCFIDefCfaOffset(int64_t
Offset)
override;
294 void EmitCFIDefCfaRegister(int64_t
Register)
override;
296 void EmitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
297 void EmitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
298 void EmitCFIRememberState()
override;
299 void EmitCFIRestoreState()
override;
300 void EmitCFIRestore(int64_t
Register)
override;
301 void EmitCFISameValue(int64_t
Register)
override;
303 void EmitCFIAdjustCfaOffset(int64_t Adjustment)
override;
304 void EmitCFIEscape(
StringRef Values)
override;
305 void EmitCFIGnuArgsSize(int64_t Size)
override;
306 void EmitCFISignalFrame()
override;
307 void EmitCFIUndefined(int64_t
Register)
override;
308 void EmitCFIRegister(int64_t Register1, int64_t Register2)
override;
309 void EmitCFIWindowSave()
override;
310 void EmitCFINegateRAState()
override;
311 void EmitCFIReturnColumn(int64_t
Register)
override;
313 void EmitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc)
override;
314 void EmitWinCFIEndProc(
SMLoc Loc)
override;
315 void EmitWinCFIFuncletOrFuncEnd(
SMLoc Loc)
override;
316 void EmitWinCFIStartChained(
SMLoc Loc)
override;
317 void EmitWinCFIEndChained(
SMLoc Loc)
override;
321 void EmitWinCFIAllocStack(
unsigned Size,
SMLoc Loc)
override;
326 void EmitWinCFIPushFrame(
bool Code,
SMLoc Loc)
override;
327 void EmitWinCFIEndProlog(
SMLoc Loc)
override;
329 void EmitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
331 void EmitWinEHHandlerData(
SMLoc Loc)
override;
338 void EmitBundleAlignMode(
unsigned AlignPow2)
override;
339 void EmitBundleLock(
bool AlignToEnd)
override;
340 void EmitBundleUnlock()
override;
346 void EmitAddrsig()
override;
347 void EmitAddrsigSym(
const MCSymbol *Sym)
override;
352 void EmitRawTextImpl(
StringRef String)
override;
354 void FinishImpl()
override;
359 void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
360 if (!IsVerboseAsm)
return;
368 void MCAsmStreamer::EmitCommentsAndEOL() {
377 "Comment array not newline terminated");
384 Comments = Comments.
substr(Position+1);
385 }
while (!Comments.
empty());
387 CommentToEmit.
clear();
391 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
392 return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
395 void MCAsmStreamer::emitRawComment(
const Twine &T,
bool TabPrefix) {
402 void MCAsmStreamer::addExplicitComment(
const Twine &T) {
407 ExplicitCommentToEmit.
append(
"\t");
412 size_t p = 2, len = c.
size() - 2;
416 ExplicitCommentToEmit.
append(
"\t");
421 ExplicitCommentToEmit.
append(
"\n");
425 ExplicitCommentToEmit.
append(
"\t");
427 }
else if (c.
front() ==
'#') {
429 ExplicitCommentToEmit.
append(
"\t");
433 assert(
false &&
"Unexpected Assembly Comment");
435 if (c.
back() ==
'\n')
436 emitExplicitComments();
439 void MCAsmStreamer::emitExplicitComments() {
440 StringRef Comments = ExplicitCommentToEmit;
441 if (!Comments.
empty())
443 ExplicitCommentToEmit.
clear();
446 void MCAsmStreamer::ChangeSection(
MCSection *Section,
447 const MCExpr *Subsection) {
448 assert(Section &&
"Cannot switch to a null section!");
450 TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
453 *MAI, getContext().getObjectFileInfo()->getTargetTriple(), OS,
458 void MCAsmStreamer::emitELFSymverDirective(
StringRef AliasName,
461 Aliasee->
print(OS, MAI);
462 OS <<
", " << AliasName;
469 Symbol->
print(OS, MAI);
480 assert(NbArgs != -1 && ((
size_t)NbArgs) == Args.
size() &&
"Malformed LOH!");
481 assert(str !=
"" &&
"Invalid LOH name");
507 assert(!Options.
empty() &&
"At least one option is required!");
508 OS <<
"\t.linker_option \"" << Options[0] <<
'"';
510 ie = Options.end(); it != ie; ++it) {
511 OS <<
", " <<
'"' << *it <<
'"';
541 if (SDKVersion.
empty())
543 OS <<
'\t' <<
"sdk_version " << SDKVersion.
getMajor();
544 if (
auto Minor = SDKVersion.
getMinor()) {
545 OS <<
", " << *Minor;
547 OS <<
", " << *Subminor;
553 unsigned Minor,
unsigned Update,
557 OS <<
", " << Update;
577 void MCAsmStreamer::EmitBuildVersion(
unsigned Platform,
unsigned Major,
578 unsigned Minor,
unsigned Update,
581 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
583 OS <<
", " << Update;
588 void MCAsmStreamer::EmitThumbFunc(
MCSymbol *Func) {
591 OS <<
"\t.thumb_func";
595 Func->
print(OS, MAI);
600 void MCAsmStreamer::EmitAssignment(
MCSymbol *Symbol,
const MCExpr *Value) {
603 if (
auto *
E = dyn_cast<MCTargetExpr>(Value))
604 if (
E->inlineAssignedExpr())
608 Symbol->
print(OS, MAI);
610 Value->
print(OS, MAI);
618 void MCAsmStreamer::EmitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
620 Alias->
print(OS, MAI);
622 Symbol->
print(OS, MAI);
626 bool MCAsmStreamer::EmitSymbolAttribute(
MCSymbol *Symbol,
640 Symbol->
print(OS, MAI);
643 default:
return false;
666 OS <<
"\t.no_dead_strip\t";
671 OS <<
"\t.private_extern\t";
677 OS <<
"\t.weak_definition\t";
687 Symbol->
print(OS, MAI);
693 void MCAsmStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
694 OS <<
".desc" <<
' ';
695 Symbol->
print(OS, MAI);
696 OS <<
',' << DescValue;
700 void MCAsmStreamer::EmitSyntaxDirective() {
702 OS <<
"\t.intel_syntax noprefix";
710 void MCAsmStreamer::BeginCOFFSymbolDef(
const MCSymbol *Symbol) {
712 Symbol->
print(OS, MAI);
717 void MCAsmStreamer::EmitCOFFSymbolStorageClass (
int StorageClass) {
718 OS <<
"\t.scl\t" << StorageClass <<
';';
722 void MCAsmStreamer::EmitCOFFSymbolType (
int Type) {
723 OS <<
"\t.type\t" << Type <<
';';
727 void MCAsmStreamer::EndCOFFSymbolDef() {
732 void MCAsmStreamer::EmitCOFFSafeSEH(
MCSymbol const *Symbol) {
733 OS <<
"\t.safeseh\t";
734 Symbol->
print(OS, MAI);
738 void MCAsmStreamer::EmitCOFFSymbolIndex(
MCSymbol const *Symbol) {
740 Symbol->
print(OS, MAI);
744 void MCAsmStreamer::EmitCOFFSectionIndex(
MCSymbol const *Symbol) {
746 Symbol->
print(OS, MAI);
750 void MCAsmStreamer::EmitCOFFSecRel32(
MCSymbol const *Symbol, uint64_t
Offset) {
751 OS <<
"\t.secrel32\t";
752 Symbol->
print(OS, MAI);
758 void MCAsmStreamer::EmitCOFFImgRel32(
MCSymbol const *Symbol, int64_t Offset) {
760 Symbol->
print(OS, MAI);
771 void MCAsmStreamer::EmitXCOFFLocalCommonSymbol(
MCSymbol *LabelSym,
776 "We only support writing log base-2 alignment format with XCOFF.");
780 LabelSym->
print(OS, MAI);
781 OS <<
',' << Size <<
',';
782 CsectSym->
print(OS, MAI);
783 OS <<
',' <<
Log2_32(ByteAlignment);
788 void MCAsmStreamer::emitELFSize(
MCSymbol *Symbol,
const MCExpr *Value) {
791 Symbol->
print(OS, MAI);
793 Value->
print(OS, MAI);
797 void MCAsmStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
798 unsigned ByteAlignment) {
800 Symbol->
print(OS, MAI);
803 if (ByteAlignment != 0) {
805 OS <<
',' << ByteAlignment;
807 OS <<
',' <<
Log2_32(ByteAlignment);
812 void MCAsmStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
813 unsigned ByteAlign) {
815 Symbol->
print(OS, MAI);
823 OS <<
',' << ByteAlign;
827 OS <<
',' <<
Log2_32(ByteAlign);
835 uint64_t Size,
unsigned ByteAlignment,
844 ".zerofill is a Mach-O specific directive");
848 OS << MOSection->
getSegmentName() <<
"," << MOSection->getSectionName();
852 Symbol->
print(OS, MAI);
854 if (ByteAlignment != 0)
855 OS <<
',' <<
Log2_32(ByteAlignment);
864 uint64_t Size,
unsigned ByteAlignment) {
867 assert(Symbol &&
"Symbol shouldn't be NULL!");
871 ".zerofill is a Mach-O specific directive");
875 Symbol->
print(OS, MAI);
880 if (ByteAlignment > 1) OS <<
", " <<
Log2_32(ByteAlignment);
885 static inline char toOctal(
int X) {
return (X&7)+
'0'; }
890 for (
unsigned i = 0,
e = Data.
size(); i !=
e; ++i) {
891 unsigned char C = Data[i];
892 if (C ==
'"' || C ==
'\\') {
893 OS <<
'\\' << (
char)C;
903 case '\b': OS <<
"\\b";
break;
904 case '\f': OS <<
"\\f";
break;
905 case '\n': OS <<
"\\n";
break;
906 case '\r': OS <<
"\\r";
break;
907 case '\t': OS <<
"\\t";
break;
910 OS << toOctal(C >> 6);
911 OS << toOctal(C >> 3);
912 OS << toOctal(C >> 0);
921 assert(getCurrentSectionOnly() &&
922 "Cannot emit contents before setting section!");
923 if (Data.
empty())
return;
927 if (Data.
size() == 1 ||
930 TS->emitRawBytes(Data);
933 for (
const unsigned char C : Data.
bytes()) {
954 void MCAsmStreamer::EmitBinaryData(
StringRef Data) {
956 const size_t Cols = 4;
957 for (
size_t I = 0, EI =
alignTo(Data.
size(), Cols);
I < EI;
I += Cols) {
958 size_t J =
I, EJ = std::min(
I + Cols, Data.
size());
961 for (; J < EJ - 1; ++J)
962 OS <<
format(
"0x%02x", uint8_t(Data[J])) <<
", ";
963 OS <<
format(
"0x%02x", uint8_t(Data[J]));
968 void MCAsmStreamer::EmitIntValue(uint64_t Value,
unsigned Size) {
972 void MCAsmStreamer::EmitIntValueInHex(uint64_t Value,
unsigned Size) {
976 void MCAsmStreamer::EmitValueImpl(
const MCExpr *Value,
unsigned Size,
978 assert(Size <= 8 &&
"Invalid size");
979 assert(getCurrentSectionOnly() &&
980 "Cannot emit contents before setting section!");
992 if (!Value->evaluateAsAbsolute(IntValue))
1000 for (
unsigned Emitted = 0; Emitted !=
Size;) {
1001 unsigned Remaining = Size - Emitted;
1004 unsigned EmissionSize =
PowerOf2Floor(std::min(Remaining, Size - 1));
1007 unsigned ByteOffset =
1008 IsLittleEndian ? Emitted : (Remaining - EmissionSize);
1009 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1013 uint64_t Shift = 64 - EmissionSize * 8;
1014 assert(Shift < static_cast<uint64_t>(
1015 std::numeric_limits<unsigned long long>::digits) &&
1016 "undefined behavior");
1017 ValueToEmit &= ~0ULL >> Shift;
1018 EmitIntValue(ValueToEmit, EmissionSize);
1019 Emitted += EmissionSize;
1024 assert(Directive &&
"Invalid size for machine code value!");
1027 TS->emitValue(Value);
1029 Value->
print(OS, MAI);
1034 void MCAsmStreamer::EmitULEB128Value(
const MCExpr *Value) {
1036 if (Value->evaluateAsAbsolute(IntValue)) {
1037 EmitULEB128IntValue(IntValue);
1040 OS <<
"\t.uleb128 ";
1041 Value->
print(OS, MAI);
1045 void MCAsmStreamer::EmitSLEB128Value(
const MCExpr *Value) {
1047 if (Value->evaluateAsAbsolute(IntValue)) {
1048 EmitSLEB128IntValue(IntValue);
1051 OS <<
"\t.sleb128 ";
1052 Value->
print(OS, MAI);
1056 void MCAsmStreamer::EmitDTPRel64Value(
const MCExpr *Value) {
1059 Value->
print(OS, MAI);
1063 void MCAsmStreamer::EmitDTPRel32Value(
const MCExpr *Value) {
1066 Value->
print(OS, MAI);
1070 void MCAsmStreamer::EmitTPRel64Value(
const MCExpr *Value) {
1073 Value->
print(OS, MAI);
1077 void MCAsmStreamer::EmitTPRel32Value(
const MCExpr *Value) {
1080 Value->
print(OS, MAI);
1084 void MCAsmStreamer::EmitGPRel64Value(
const MCExpr *Value) {
1087 Value->
print(OS, MAI);
1091 void MCAsmStreamer::EmitGPRel32Value(
const MCExpr *Value) {
1094 Value->
print(OS, MAI);
1098 void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1100 int64_t IntNumBytes;
1101 if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
1106 OS << ZeroDirective;
1107 NumBytes.
print(OS, MAI);
1109 OS <<
',' << (int)FillValue;
1117 void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t Size,
1118 int64_t Expr,
SMLoc Loc) {
1121 NumValues.
print(OS, MAI);
1122 OS <<
", " << Size <<
", 0x";
1127 void MCAsmStreamer::EmitValueToAlignment(
unsigned ByteAlignment, int64_t Value,
1129 unsigned MaxBytesToEmit) {
1143 switch (ValueSize) {
1147 OS <<
"\t.p2align\t";
1161 if (Value || MaxBytesToEmit) {
1166 OS <<
", " << MaxBytesToEmit;
1174 switch (ValueSize) {
1176 case 1: OS <<
".balign";
break;
1177 case 2: OS <<
".balignw";
break;
1178 case 4: OS <<
".balignl";
break;
1185 OS <<
", " << MaxBytesToEmit;
1189 void MCAsmStreamer::EmitCodeAlignment(
unsigned ByteAlignment,
1190 unsigned MaxBytesToEmit) {
1196 void MCAsmStreamer::emitValueToOffset(
const MCExpr *Offset,
1197 unsigned char Value,
1201 Offset->
print(OS, MAI);
1206 void MCAsmStreamer::EmitFileDirective(
StringRef Filename) {
1217 bool UseDwarfDirectory,
1221 if (!UseDwarfDirectory && !Directory.
empty()) {
1225 FullPathName = Directory;
1228 Filename = FullPathName;
1232 OS <<
"\t.file\t" << FileNo <<
' ';
1233 if (!Directory.
empty()) {
1239 OS <<
" md5 0x" << Checksum->
digest();
1249 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1254 Table.
tryGetFile(Directory, Filename, Checksum, Source,
1255 getContext().getDwarfVersion(), FileNo);
1258 FileNo = FileNoOrErr.
get();
1265 UseDwarfDirectory, OS1);
1268 TS->emitDwarfFileDirective(OS1.
str());
1270 EmitRawText(OS1.
str());
1275 void MCAsmStreamer::emitDwarfFile0Directive(
StringRef Directory,
1282 if (getContext().getDwarfVersion() < 5)
1285 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1291 UseDwarfDirectory, OS1);
1294 TS->emitDwarfFileDirective(OS1.
str());
1296 EmitRawText(OS1.
str());
1299 void MCAsmStreamer::EmitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1300 unsigned Column,
unsigned Flags,
1302 unsigned Discriminator,
1304 OS <<
"\t.loc\t" << FileNo <<
" " << Line <<
" " << Column;
1307 OS <<
" basic_block";
1309 OS <<
" prologue_end";
1311 OS <<
" epilogue_begin";
1313 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1317 if (Flags & DWARF2_FLAG_IS_STMT)
1324 OS <<
" isa " << Isa;
1326 OS <<
" discriminator " << Discriminator;
1332 << Line <<
':' << Column;
1336 Isa, Discriminator, FileName);
1339 MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1345 bool MCAsmStreamer::EmitCVFileDirective(
unsigned FileNo,
StringRef Filename,
1348 if (!getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1352 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1355 if (!ChecksumKind) {
1368 bool MCAsmStreamer::EmitCVFuncIdDirective(
unsigned FuncId) {
1369 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1373 bool MCAsmStreamer::EmitCVInlineSiteIdDirective(
unsigned FunctionId,
1376 unsigned IALine,
unsigned IACol,
1378 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1379 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1381 IALine, IACol, Loc);
1384 void MCAsmStreamer::EmitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1385 unsigned Line,
unsigned Column,
1386 bool PrologueEnd,
bool IsStmt,
1389 if (!checkCVLocSection(FunctionId, FileNo, Loc))
1392 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " << Line <<
" " 1395 OS <<
" prologue_end";
1408 void MCAsmStreamer::EmitCVLinetableDirective(
unsigned FunctionId,
1411 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1412 FnStart->
print(OS, MAI);
1414 FnEnd->
print(OS, MAI);
1419 void MCAsmStreamer::EmitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1420 unsigned SourceFileId,
1421 unsigned SourceLineNum,
1424 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1425 <<
' ' << SourceLineNum <<
' ';
1426 FnStartSym->
print(OS, MAI);
1428 FnEndSym->
print(OS, MAI);
1431 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1434 void MCAsmStreamer::PrintCVDefRangePrefix(
1435 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1436 OS <<
"\t.cv_def_range\t";
1437 for (std::pair<const MCSymbol *, const MCSymbol *> Range : Ranges) {
1439 Range.first->print(OS, MAI);
1441 Range.second->print(OS, MAI);
1445 void MCAsmStreamer::EmitCVDefRangeDirective(
1446 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1448 PrintCVDefRangePrefix(Ranges);
1449 OS <<
", reg_rel, ";
1455 void MCAsmStreamer::EmitCVDefRangeDirective(
1456 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1458 PrintCVDefRangePrefix(Ranges);
1459 OS <<
", subfield_reg, ";
1464 void MCAsmStreamer::EmitCVDefRangeDirective(
1465 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1467 PrintCVDefRangePrefix(Ranges);
1473 void MCAsmStreamer::EmitCVDefRangeDirective(
1474 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1476 PrintCVDefRangePrefix(Ranges);
1477 OS <<
", frame_ptr_rel, ";
1482 void MCAsmStreamer::EmitCVStringTableDirective() {
1483 OS <<
"\t.cv_stringtable";
1487 void MCAsmStreamer::EmitCVFileChecksumsDirective() {
1488 OS <<
"\t.cv_filechecksums";
1492 void MCAsmStreamer::EmitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1493 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1497 void MCAsmStreamer::EmitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
1498 OS <<
"\t.cv_fpo_data\t";
1499 ProcSym->
print(OS, MAI);
1503 void MCAsmStreamer::EmitIdent(
StringRef IdentString) {
1510 void MCAsmStreamer::EmitCFISections(
bool EH,
bool Debug) {
1512 OS <<
"\t.cfi_sections ";
1516 OS <<
", .debug_frame";
1518 OS <<
".debug_frame";
1525 OS <<
"\t.cfi_startproc";
1533 OS <<
"\t.cfi_endproc";
1537 void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
1544 InstPrinter->printRegName(OS, *LLVMRegister);
1551 void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
1553 OS <<
"\t.cfi_def_cfa ";
1554 EmitRegisterName(Register);
1559 void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
1561 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
1566 OS <<
"\t.cfi_escape ";
1567 if (!Values.
empty()) {
1568 size_t e = Values.
size() - 1;
1569 for (
size_t i = 0; i <
e; ++i)
1570 OS <<
format(
"0x%02x", uint8_t(Values[i])) <<
", ";
1571 OS <<
format(
"0x%02x", uint8_t(Values[e]));
1575 void MCAsmStreamer::EmitCFIEscape(
StringRef Values) {
1581 void MCAsmStreamer::EmitCFIGnuArgsSize(int64_t Size) {
1584 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
1591 void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
1593 OS <<
"\t.cfi_def_cfa_register ";
1594 EmitRegisterName(Register);
1598 void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
1600 OS <<
"\t.cfi_offset ";
1601 EmitRegisterName(Register);
1606 void MCAsmStreamer::EmitCFIPersonality(
const MCSymbol *Sym,
1607 unsigned Encoding) {
1609 OS <<
"\t.cfi_personality " << Encoding <<
", ";
1610 Sym->
print(OS, MAI);
1614 void MCAsmStreamer::EmitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
1616 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
1617 Sym->
print(OS, MAI);
1621 void MCAsmStreamer::EmitCFIRememberState() {
1623 OS <<
"\t.cfi_remember_state";
1627 void MCAsmStreamer::EmitCFIRestoreState() {
1629 OS <<
"\t.cfi_restore_state";
1633 void MCAsmStreamer::EmitCFIRestore(int64_t Register) {
1635 OS <<
"\t.cfi_restore ";
1636 EmitRegisterName(Register);
1640 void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
1642 OS <<
"\t.cfi_same_value ";
1643 EmitRegisterName(Register);
1647 void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
1649 OS <<
"\t.cfi_rel_offset ";
1650 EmitRegisterName(Register);
1655 void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
1657 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
1661 void MCAsmStreamer::EmitCFISignalFrame() {
1663 OS <<
"\t.cfi_signal_frame";
1667 void MCAsmStreamer::EmitCFIUndefined(int64_t Register) {
1669 OS <<
"\t.cfi_undefined " <<
Register;
1673 void MCAsmStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
1675 OS <<
"\t.cfi_register " << Register1 <<
", " << Register2;
1679 void MCAsmStreamer::EmitCFIWindowSave() {
1681 OS <<
"\t.cfi_window_save";
1685 void MCAsmStreamer::EmitCFINegateRAState() {
1687 OS <<
"\t.cfi_negate_ra_state";
1691 void MCAsmStreamer::EmitCFIReturnColumn(int64_t Register) {
1693 OS <<
"\t.cfi_return_column " <<
Register;
1697 void MCAsmStreamer::EmitCFIBKeyFrame() {
1699 OS <<
"\t.cfi_b_key_frame";
1703 void MCAsmStreamer::EmitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
1707 Symbol->
print(OS, MAI);
1711 void MCAsmStreamer::EmitWinCFIEndProc(
SMLoc Loc) {
1714 OS <<
"\t.seh_endproc";
1719 void MCAsmStreamer::EmitWinCFIFuncletOrFuncEnd(
SMLoc Loc) {
1722 void MCAsmStreamer::EmitWinCFIStartChained(
SMLoc Loc) {
1725 OS <<
"\t.seh_startchained";
1729 void MCAsmStreamer::EmitWinCFIEndChained(
SMLoc Loc) {
1732 OS <<
"\t.seh_endchained";
1736 void MCAsmStreamer::EmitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
1737 bool Except,
SMLoc Loc) {
1740 OS <<
"\t.seh_handler ";
1741 Sym->
print(OS, MAI);
1749 void MCAsmStreamer::EmitWinEHHandlerData(
SMLoc Loc) {
1764 MCSection *XData = getAssociatedXDataSection(TextSec);
1765 SwitchSectionNoChange(XData);
1767 OS <<
"\t.seh_handlerdata";
1771 void MCAsmStreamer::EmitWinCFIPushReg(
MCRegister Register,
SMLoc Loc) {
1774 OS <<
"\t.seh_pushreg ";
1775 InstPrinter->printRegName(OS, Register);
1779 void MCAsmStreamer::EmitWinCFISetFrame(
MCRegister Register,
unsigned Offset,
1783 OS <<
"\t.seh_setframe ";
1784 InstPrinter->printRegName(OS, Register);
1789 void MCAsmStreamer::EmitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
1792 OS <<
"\t.seh_stackalloc " <<
Size;
1796 void MCAsmStreamer::EmitWinCFISaveReg(
MCRegister Register,
unsigned Offset,
1800 OS <<
"\t.seh_savereg ";
1801 InstPrinter->printRegName(OS, Register);
1806 void MCAsmStreamer::EmitWinCFISaveXMM(
MCRegister Register,
unsigned Offset,
1810 OS <<
"\t.seh_savexmm ";
1811 InstPrinter->printRegName(OS, Register);
1816 void MCAsmStreamer::EmitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
1819 OS <<
"\t.seh_pushframe";
1825 void MCAsmStreamer::EmitWinCFIEndProlog(
SMLoc Loc) {
1828 OS <<
"\t.seh_endprologue";
1835 OS <<
"\t.cg_profile ";
1839 OS <<
", " << Count;
1843 void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
1851 if (!getAssembler().getEmitterPtr())
1854 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
1861 for (
unsigned i = 0,
e = Code.
size() * 8; i !=
e; ++i)
1864 for (
unsigned i = 0,
e = Fixups.
size(); i !=
e; ++i) {
1867 getAssembler().getBackend().getFixupKindInfo(F.
getKind());
1868 for (
unsigned j = 0; j != Info.
TargetSize; ++j) {
1870 assert(Index < Code.
size() * 8 &&
"Invalid offset in fixup!");
1871 FixupMap[
Index] = 1 + i;
1877 OS <<
"encoding: [";
1878 for (
unsigned i = 0,
e = Code.
size(); i !=
e; ++i) {
1883 uint8_t MapEntry = FixupMap[i * 8 + 0];
1884 for (
unsigned j = 1; j != 8; ++j) {
1885 if (FixupMap[i * 8 + j] == MapEntry)
1888 MapEntry = uint8_t(~0U);
1892 if (MapEntry != uint8_t(~0U)) {
1893 if (MapEntry == 0) {
1894 OS <<
format(
"0x%02x", uint8_t(Code[i]));
1898 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\'' 1899 <<
char(
'A' + MapEntry - 1) <<
'\'';
1901 OS <<
char(
'A' + MapEntry - 1);
1906 for (
unsigned j = 8; j--;) {
1907 unsigned Bit = (Code[i] >> j) & 1;
1911 FixupBit = i * 8 + j;
1913 FixupBit = i * 8 + (7-j);
1915 if (uint8_t MapEntry = FixupMap[FixupBit]) {
1916 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
1917 OS <<
char(
'A' + MapEntry - 1);
1925 for (
unsigned i = 0,
e = Fixups.
size(); i !=
e; ++i) {
1928 getAssembler().getBackend().getFixupKindInfo(F.
getKind());
1929 OS <<
" fixup " <<
char(
'A' + i) <<
" - " <<
"offset: " << F.
getOffset()
1930 <<
", value: " << *F.
getValue() <<
", kind: " << Info.
Name <<
"\n";
1934 void MCAsmStreamer::EmitInstruction(
const MCInst &Inst,
1936 assert(getCurrentSectionOnly() &&
1937 "Cannot emit contents before setting section!");
1940 AddEncodingComment(Inst, STI);
1944 Inst.
dump_pretty(GetCommentOS(), InstPrinter.get(),
"\n ");
1945 GetCommentOS() <<
"\n";
1948 if(getTargetStreamer())
1949 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
1951 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
1954 if (Comments.
size() && Comments.
back() !=
'\n')
1955 GetCommentOS() <<
"\n";
1960 void MCAsmStreamer::EmitBundleAlignMode(
unsigned AlignPow2) {
1961 OS <<
"\t.bundle_align_mode " << AlignPow2;
1965 void MCAsmStreamer::EmitBundleLock(
bool AlignToEnd) {
1966 OS <<
"\t.bundle_lock";
1968 OS <<
" align_to_end";
1972 void MCAsmStreamer::EmitBundleUnlock() {
1973 OS <<
"\t.bundle_unlock";
1981 Offset.
print(OS, MAI);
1985 Expr->
print(OS, MAI);
1991 void MCAsmStreamer::EmitAddrsig() {
1996 void MCAsmStreamer::EmitAddrsigSym(
const MCSymbol *Sym) {
1997 OS <<
"\t.addrsig_sym ";
1998 Sym->
print(OS, MAI);
2005 void MCAsmStreamer::EmitRawTextImpl(
StringRef String) {
2006 if (!String.
empty() && String.
back() ==
'\n')
2012 void MCAsmStreamer::FinishImpl() {
2014 if (getContext().getGenDwarfForAssembly())
2020 const auto &Tables = getContext().getMCDwarfLineTables();
2021 if (!Tables.empty()) {
2022 assert(Tables.size() == 1 &&
"asm output only supports one line table");
2023 if (
auto *Label = Tables.begin()->second.getLabel()) {
2024 SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
2031 std::unique_ptr<formatted_raw_ostream> OS,
2032 bool isVerboseAsm,
bool useDwarfDirectory,
2034 std::unique_ptr<MCCodeEmitter> &&CE,
2035 std::unique_ptr<MCAsmBackend> &&MAB,
2037 return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
2038 useDwarfDirectory, IP, std::move(CE), std::move(MAB),
bool doesSupportDataRegionDirectives() const
bool getCOMMDirectiveAlignmentIsInBytes() const
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
virtual void EmitCFISameValue(int64_t Register)
const char * getLabelSuffix() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
This represents a section on a Mach-O system (used by Mac OS X).
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
virtual void EmitCFIGnuArgsSize(int64_t Size)
bool useDotAlignForAlignment() const
Wrapper class representing physical registers. Should be passed by value.
bool isPrint(char C)
Checks whether character C is printable.
#define DWARF2_FLAG_PROLOGUE_END
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
const char * getGlobalDirective() const
.type _foo, STT_OBJECT # aka
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
virtual void EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
bool hasSingleParameterDotFile() const
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
A raw_ostream that discards all output.
void push_back(const T &Elt)
SmallString< 32 > digest() const
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ") const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
Target specific streamer interface.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
const char * getCode16Directive() const
bool hasDotTypeDotSizeDirective() const
A raw_ostream that writes to an SmallVector or SmallString.
const char * getData64bitsDirective() const
virtual void EmitCFIRegister(int64_t Register1, int64_t Register2)
const char * getTPRel64Directive() const
Error takeError()
Take ownership of the stored error.
virtual void EmitCFIDefCfaOffset(int64_t Offset)
.type _foo, STT_NOTYPE # aka
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
COFF::SymbolStorageClass StorageClass
bool hasIdentDirective() const
unsigned TargetOffset
The bit offset to write the relocation into.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
virtual void EmitCFISections(bool EH, bool Debug)
const char * getDTPRel64Directive() const
static int64_t truncateToSize(int64_t Value, unsigned Bytes)
virtual void EmitCFIRememberState()
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding)
#define DWARF2_FLAG_IS_STMT
const char * getAscizDirective() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
virtual void EmitWinCFIEndProc(SMLoc Loc=SMLoc())
virtual void EmitCFIEscape(StringRef Values)
const char * getZeroDirective() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
const char * Name
A target specific name for the fixup kind.
Represent a reference to a symbol from inside an expression.
LLVM_NODISCARD StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
iterator_range< const unsigned char * > bytes() const
const char * getGPRel64Directive() const
Tagged union holding either a T or a Error.
virtual void EmitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
static void EmitSDKVersionSuffix(raw_ostream &OS, const VersionTuple &SDKVersion)
StringRef getSingleStringRef() const
This returns the twine as a single StringRef.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
const char * getWeakRefDirective() const
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Position
Position to insert a new instruction relative to an existing instruction.
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void EmitWinCFIStartChained(SMLoc Loc=SMLoc())
Context object for machine code objects.
const char * getWeakDirective() const
.code16 (X86) / .code 16 (ARM)
virtual void EmitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Directive
IDs for all OpenMP directives.
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
.type _foo, STT_GNU_IFUNC
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target, suitable for compiling with a native assembler.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
virtual void EmitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void EmitCFIRestoreState()
const char * getTPRel32Directive() const
bool hasNoDeadStrip() const
StringRef getSegmentName() const
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
bool supportsExtendedDwarfLocDirective() const
virtual void EmitCFIRestore(int64_t Register)
const char * getData8bitsDirective() const
Flag
These should be considered private to the implementation of the MCInstrDesc class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
void append(in_iter S, in_iter E)
Append from an iterator pair.
Optional< unsigned > getLLVMRegNum(unsigned RegNum, bool isEH) const
Map a dwarf register back to a target register.
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Streaming machine code generation interface.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
unsigned const MachineRegisterInfo * MRI
.weak_def_can_be_hidden (MachO)
bool useDwarfRegNumForCFI() const
const char * getData16bitsDirective() const
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
The instances of the Type class are immutable: once they are created, they are never changed...
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
static char toOctal(int X)
unsigned getAssemblerDialect() const
#define DWARF2_FLAG_EPILOGUE_BEGIN
virtual void EmitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char * getSeparatorString() const
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
unsigned getMajor() const
Retrieve the major version number.
virtual void EmitCFIDefCfaRegister(int64_t Register)
MCLOHType
Linker Optimization Hint Type.
StringRef getCommentString() const
.subsections_via_symbols (MachO)
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
#define DWARF2_FLAG_BASIC_BLOCK
virtual void EmitWinEHHandlerData(SMLoc Loc=SMLoc())
static const char * getVersionMinDirective(MCVersionMinType Type)
uint32_t getOffset() const
SectionVariant getVariant() const
virtual void EmitCFIUndefined(int64_t Register)
virtual void EmitCFINegateRAState()
bool hasSubsectionsViaSymbols() const
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
const char * getData32bitsDirective() const
virtual void EmitWinCFIEndChained(SMLoc Loc=SMLoc())
LLVM_NODISCARD char back() const
back - Get the last character in the string.
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const =0
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
virtual void EmitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values)
const MCDummyFragment & getDummyFragment() const
virtual void EmitCFIReturnColumn(int64_t Register)
BlockVerifier::State From
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
const MCSymbol & getSymbol() const
virtual void EmitCFIOffset(int64_t Register, int64_t Offset)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual void EmitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void EmitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
.type _foo, STT_TLS # aka
Promote Memory to Register
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
unsigned TargetSize
The number of bits written by this fixup.
StringRef str()
Return a StringRef for the vector contents.
reference get()
Returns a reference to the stored T value.
static StringRef MCLOHDirectiveName()
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
const MCSymbol * Function
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
size_t GetNumBytesInBuffer() const
static void Emit(MCStreamer *MCOS)
.code32 (X86) / .code 32 (ARM)
.type _foo, STT_COMMON # aka
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
static const char * getPlatformName(MachO::PlatformType Type)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Represents a version number in the form major[.minor[.subminor[.build]]].
virtual void EmitCFISignalFrame()
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset)
LLVM_NODISCARD bool empty() const
.type _foo, STT_FUNC # aka
LLVM_NODISCARD 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.
const char * getDTPRel32Directive() const
Generic base class for all target subtargets.
bool isLittleEndian() const
True if the target is little endian.
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset)
Target independent information on a fixup kind.
const char * getAsciiDirective() const
static void printDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, bool UseDwarfDirectory, raw_svector_ostream &OS)
const char * getGPRel32Directive() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getTextAlignFillValue() const
LLVM_NODISCARD char front() const
front - Get the first character in the string.
unsigned getCommentColumn() const
This indicates the column (zero-based) at which asm comments should be printed.
static int MCLOHIdToNbArgs(MCLOHType Kind)
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.
uint64_t PowerOf2Floor(uint64_t A)
Returns the power of two which is less than or equal to the given value.
LLVM Value Representation.
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
virtual bool EmitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
virtual void EmitCFIBKeyFrame()
static StringRef MCLOHIdToName(MCLOHType Kind)
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
This class implements an extremely fast bulk output stream that can only output to a stream...
const MCExpr * getValue() const
const char * getCode64Directive() const
StringRef - Represent a constant reference to a string, i.e.
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)...
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
static void PrintQuotedString(StringRef Data, raw_ostream &OS)
Represents a location in source code.
std::string toHex(StringRef Input, bool LowerCase=false)
Convert buffer Input to its hexadecimal representation.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
MCFixupKind getKind() const
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
const char * getCode32Directive() const
virtual void EmitCFIWindowSave()
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.