43 class MCAsmStreamer final :
public MCStreamer {
44 std::unique_ptr<formatted_raw_ostream> OSOwner;
47 std::unique_ptr<MCInstPrinter> InstPrinter;
48 std::unique_ptr<MCAssembler> Assembler;
55 unsigned IsVerboseAsm : 1;
56 unsigned ShowInst : 1;
57 unsigned UseDwarfDirectory : 1;
59 void EmitRegisterName(int64_t
Register);
65 bool isVerboseAsm,
bool useDwarfDirectory,
66 MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter,
67 std::unique_ptr<MCAsmBackend> asmbackend,
bool showInst)
69 MAI(Context.getAsmInfo()), InstPrinter(printer),
71 Context,
std::move(asmbackend),
std::move(emitter),
72 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
74 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
75 ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
78 InstPrinter->setCommentStream(CommentStream);
82 MCAssembler *getAssemblerPtr()
override {
return nullptr; }
84 inline void EmitEOL() {
86 emitExplicitComments();
95 void EmitSyntaxDirective()
override;
97 void EmitCommentsAndEOL();
100 bool isVerboseAsm()
const override {
return IsVerboseAsm; }
103 bool hasRawTextSupport()
const override {
return true; }
108 void AddComment(
const Twine &
T,
bool EOL =
true)
override;
114 bool PrintSchedInfo);
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,
150 unsigned Update)
override;
151 void EmitBuildVersion(
unsigned Platform,
unsigned Major,
unsigned Minor,
152 unsigned Update)
override;
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;
178 void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
188 void EmitBinaryData(
StringRef Data)
override;
194 void EmitIntValue(uint64_t Value,
unsigned Size)
override;
196 void EmitULEB128Value(
const MCExpr *Value)
override;
198 void EmitSLEB128Value(
const MCExpr *Value)
override;
200 void EmitDTPRel32Value(
const MCExpr *Value)
override;
201 void EmitDTPRel64Value(
const MCExpr *Value)
override;
202 void EmitTPRel32Value(
const MCExpr *Value)
override;
203 void EmitTPRel64Value(
const MCExpr *Value)
override;
205 void EmitGPRel64Value(
const MCExpr *Value)
override;
207 void EmitGPRel32Value(
const MCExpr *Value)
override;
209 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
212 void emitFill(
const MCExpr &NumValues, int64_t Size, int64_t Expr,
215 void EmitValueToAlignment(
unsigned ByteAlignment, int64_t Value = 0,
216 unsigned ValueSize = 1,
217 unsigned MaxBytesToEmit = 0)
override;
220 unsigned MaxBytesToEmit = 0)
override;
226 void EmitFileDirective(
StringRef Filename)
override;
232 unsigned CUID = 0)
override;
236 unsigned CUID = 0)
override;
237 void EmitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
238 unsigned Column,
unsigned Flags,
239 unsigned Isa,
unsigned Discriminator,
241 MCSymbol *getDwarfLineTableSymbol(
unsigned CUID)
override;
243 bool EmitCVFileDirective(
unsigned FileNo,
StringRef Filename,
246 bool EmitCVFuncIdDirective(
unsigned FuncId)
override;
247 bool EmitCVInlineSiteIdDirective(
unsigned FunctionId,
unsigned IAFunc,
248 unsigned IAFile,
unsigned IALine,
249 unsigned IACol,
SMLoc Loc)
override;
250 void EmitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
unsigned Line,
251 unsigned Column,
bool PrologueEnd,
bool IsStmt,
253 void EmitCVLinetableDirective(
unsigned FunctionId,
const MCSymbol *FnStart,
255 void EmitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
256 unsigned SourceFileId,
257 unsigned SourceLineNum,
260 void EmitCVDefRangeDirective(
261 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
263 void EmitCVStringTableDirective()
override;
264 void EmitCVFileChecksumsDirective()
override;
265 void EmitCVFileChecksumOffsetDirective(
unsigned FileNo)
override;
266 void EmitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L)
override;
268 void EmitIdent(
StringRef IdentString)
override;
269 void EmitCFISections(
bool EH,
bool Debug)
override;
271 void EmitCFIDefCfaOffset(int64_t
Offset)
override;
272 void EmitCFIDefCfaRegister(int64_t
Register)
override;
274 void EmitCFIPersonality(
const MCSymbol *Sym,
unsigned Encoding)
override;
275 void EmitCFILsda(
const MCSymbol *Sym,
unsigned Encoding)
override;
276 void EmitCFIRememberState()
override;
277 void EmitCFIRestoreState()
override;
278 void EmitCFIRestore(int64_t
Register)
override;
279 void EmitCFISameValue(int64_t
Register)
override;
281 void EmitCFIAdjustCfaOffset(int64_t Adjustment)
override;
282 void EmitCFIEscape(
StringRef Values)
override;
283 void EmitCFIGnuArgsSize(int64_t Size)
override;
284 void EmitCFISignalFrame()
override;
285 void EmitCFIUndefined(int64_t
Register)
override;
286 void EmitCFIRegister(int64_t Register1, int64_t Register2)
override;
287 void EmitCFIWindowSave()
override;
288 void EmitCFIReturnColumn(int64_t
Register)
override;
290 void EmitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc)
override;
291 void EmitWinCFIEndProc(
SMLoc Loc)
override;
292 void EmitWinCFIStartChained(
SMLoc Loc)
override;
293 void EmitWinCFIEndChained(
SMLoc Loc)
override;
294 void EmitWinCFIPushReg(
unsigned Register,
SMLoc Loc)
override;
297 void EmitWinCFIAllocStack(
unsigned Size,
SMLoc Loc)
override;
302 void EmitWinCFIPushFrame(
bool Code,
SMLoc Loc)
override;
303 void EmitWinCFIEndProlog(
SMLoc Loc)
override;
305 void EmitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
bool Except,
307 void EmitWinEHHandlerData(
SMLoc Loc)
override;
313 bool PrintSchedInfo)
override;
315 void EmitBundleAlignMode(
unsigned AlignPow2)
override;
316 void EmitBundleLock(
bool AlignToEnd)
override;
317 void EmitBundleUnlock()
override;
323 void EmitAddrsig()
override;
324 void EmitAddrsigSym(
const MCSymbol *Sym)
override;
329 void EmitRawTextImpl(
StringRef String)
override;
331 void FinishImpl()
override;
336 void MCAsmStreamer::AddComment(
const Twine &
T,
bool EOL) {
337 if (!IsVerboseAsm)
return;
345 void MCAsmStreamer::EmitCommentsAndEOL() {
354 "Comment array not newline terminated");
361 Comments = Comments.
substr(Position+1);
362 }
while (!Comments.
empty());
364 CommentToEmit.
clear();
368 assert(Bytes > 0 && Bytes <= 8 &&
"Invalid size!");
369 return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
372 void MCAsmStreamer::emitRawComment(
const Twine &T,
bool TabPrefix) {
379 void MCAsmStreamer::addExplicitComment(
const Twine &T) {
384 ExplicitCommentToEmit.
append(
"\t");
389 size_t p = 2, len = c.
size() - 2;
393 ExplicitCommentToEmit.
append(
"\t");
398 ExplicitCommentToEmit.
append(
"\n");
402 ExplicitCommentToEmit.
append(
"\t");
404 }
else if (c.
front() ==
'#') {
406 ExplicitCommentToEmit.
append(
"\t");
410 assert(
false &&
"Unexpected Assembly Comment");
412 if (c.
back() ==
'\n')
413 emitExplicitComments();
416 void MCAsmStreamer::emitExplicitComments() {
417 StringRef Comments = ExplicitCommentToEmit;
418 if (!Comments.
empty())
420 ExplicitCommentToEmit.
clear();
423 void MCAsmStreamer::ChangeSection(
MCSection *Section,
424 const MCExpr *Subsection) {
425 assert(Section &&
"Cannot switch to a null section!");
427 TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
430 *MAI, getContext().getObjectFileInfo()->getTargetTriple(), OS,
435 void MCAsmStreamer::emitELFSymverDirective(
StringRef AliasName,
438 Aliasee->
print(OS, MAI);
439 OS <<
", " << AliasName;
446 Symbol->
print(OS, MAI);
457 assert(NbArgs != -1 && ((
size_t)NbArgs) == Args.
size() &&
"Malformed LOH!");
458 assert(str !=
"" &&
"Invalid LOH name");
484 assert(!Options.
empty() &&
"At least one option is required!");
485 OS <<
"\t.linker_option \"" << Options[0] <<
'"';
487 ie = Options.end(); it != ie; ++it) {
488 OS <<
", " <<
'"' << *it <<
'"';
517 unsigned Minor,
unsigned Update) {
520 OS <<
", " << Update;
535 void MCAsmStreamer::EmitBuildVersion(
unsigned Platform,
unsigned Major,
536 unsigned Minor,
unsigned Update) {
538 OS <<
"\t.build_version " << PlatformName <<
", " << Major <<
", " << Minor;
540 OS <<
", " << Update;
544 void MCAsmStreamer::EmitThumbFunc(
MCSymbol *Func) {
547 OS <<
"\t.thumb_func";
551 Func->
print(OS, MAI);
556 void MCAsmStreamer::EmitAssignment(
MCSymbol *Symbol,
const MCExpr *Value) {
559 if (
auto *
E = dyn_cast<MCTargetExpr>(Value))
560 if (
E->inlineAssignedExpr())
564 Symbol->
print(OS, MAI);
566 Value->
print(OS, MAI);
574 void MCAsmStreamer::EmitWeakReference(
MCSymbol *Alias,
const MCSymbol *Symbol) {
576 Alias->
print(OS, MAI);
578 Symbol->
print(OS, MAI);
582 bool MCAsmStreamer::EmitSymbolAttribute(
MCSymbol *Symbol,
596 Symbol->
print(OS, MAI);
599 default:
return false;
621 OS <<
"\t.no_dead_strip\t";
626 OS <<
"\t.private_extern\t";
632 OS <<
"\t.weak_definition\t";
639 Symbol->
print(OS, MAI);
645 void MCAsmStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
646 OS <<
".desc" <<
' ';
647 Symbol->
print(OS, MAI);
648 OS <<
',' << DescValue;
652 void MCAsmStreamer::EmitSyntaxDirective() {
654 OS <<
"\t.intel_syntax noprefix";
662 void MCAsmStreamer::BeginCOFFSymbolDef(
const MCSymbol *Symbol) {
664 Symbol->
print(OS, MAI);
669 void MCAsmStreamer::EmitCOFFSymbolStorageClass (
int StorageClass) {
670 OS <<
"\t.scl\t" << StorageClass <<
';';
674 void MCAsmStreamer::EmitCOFFSymbolType (
int Type) {
675 OS <<
"\t.type\t" << Type <<
';';
679 void MCAsmStreamer::EndCOFFSymbolDef() {
684 void MCAsmStreamer::EmitCOFFSafeSEH(
MCSymbol const *Symbol) {
685 OS <<
"\t.safeseh\t";
686 Symbol->
print(OS, MAI);
690 void MCAsmStreamer::EmitCOFFSymbolIndex(
MCSymbol const *Symbol) {
692 Symbol->
print(OS, MAI);
696 void MCAsmStreamer::EmitCOFFSectionIndex(
MCSymbol const *Symbol) {
698 Symbol->
print(OS, MAI);
702 void MCAsmStreamer::EmitCOFFSecRel32(
MCSymbol const *Symbol, uint64_t
Offset) {
703 OS <<
"\t.secrel32\t";
704 Symbol->
print(OS, MAI);
710 void MCAsmStreamer::EmitCOFFImgRel32(
MCSymbol const *Symbol, int64_t Offset) {
712 Symbol->
print(OS, MAI);
720 void MCAsmStreamer::emitELFSize(
MCSymbol *Symbol,
const MCExpr *Value) {
723 Symbol->
print(OS, MAI);
725 Value->
print(OS, MAI);
729 void MCAsmStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
732 Symbol->
print(OS, MAI);
735 if (ByteAlignment != 0) {
737 OS <<
',' << ByteAlignment;
739 OS <<
',' <<
Log2_32(ByteAlignment);
744 void MCAsmStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
745 unsigned ByteAlign) {
747 Symbol->
print(OS, MAI);
755 OS <<
',' << ByteAlign;
759 OS <<
',' <<
Log2_32(ByteAlign);
767 uint64_t Size,
unsigned ByteAlignment,
776 ".zerofill is a Mach-O specific directive");
780 OS << MOSection->
getSegmentName() <<
"," << MOSection->getSectionName();
784 Symbol->
print(OS, MAI);
786 if (ByteAlignment != 0)
787 OS <<
',' <<
Log2_32(ByteAlignment);
796 uint64_t Size,
unsigned ByteAlignment) {
799 assert(Symbol &&
"Symbol shouldn't be NULL!");
803 ".zerofill is a Mach-O specific directive");
807 Symbol->
print(OS, MAI);
812 if (ByteAlignment > 1) OS <<
", " <<
Log2_32(ByteAlignment);
817 static inline char toOctal(
int X) {
return (X&7)+
'0'; }
822 for (
unsigned i = 0, e = Data.
size(); i != e; ++i) {
823 unsigned char C = Data[i];
824 if (C ==
'"' || C ==
'\\') {
825 OS <<
'\\' << (
char)C;
835 case '\b': OS <<
"\\b";
break;
836 case '\f': OS <<
"\\f";
break;
837 case '\n': OS <<
"\\n";
break;
838 case '\r': OS <<
"\\r";
break;
839 case '\t': OS <<
"\\t";
break;
842 OS << toOctal(C >> 6);
843 OS << toOctal(C >> 3);
844 OS << toOctal(C >> 0);
853 assert(getCurrentSectionOnly() &&
854 "Cannot emit contents before setting section!");
855 if (Data.
empty())
return;
859 if (Data.
size() == 1 ||
862 for (
const unsigned char C : Data.
bytes()) {
882 void MCAsmStreamer::EmitBinaryData(
StringRef Data) {
884 const size_t Cols = 4;
885 for (
size_t I = 0, EI =
alignTo(Data.
size(), Cols);
I < EI;
I += Cols) {
886 size_t J =
I, EJ = std::min(
I + Cols, Data.
size());
889 for (; J < EJ - 1; ++J)
890 OS <<
format(
"0x%02x", uint8_t(Data[J])) <<
", ";
891 OS <<
format(
"0x%02x", uint8_t(Data[J]));
896 void MCAsmStreamer::EmitIntValue(uint64_t Value,
unsigned Size) {
900 void MCAsmStreamer::EmitValueImpl(
const MCExpr *Value,
unsigned Size,
902 assert(Size <= 8 &&
"Invalid size");
903 assert(getCurrentSectionOnly() &&
904 "Cannot emit contents before setting section!");
905 const char *Directive =
nullptr;
916 if (!Value->evaluateAsAbsolute(IntValue))
924 for (
unsigned Emitted = 0; Emitted !=
Size;) {
925 unsigned Remaining = Size - Emitted;
928 unsigned EmissionSize =
PowerOf2Floor(std::min(Remaining, Size - 1));
931 unsigned ByteOffset =
932 IsLittleEndian ? Emitted : (Remaining - EmissionSize);
933 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
937 uint64_t Shift = 64 - EmissionSize * 8;
938 assert(Shift < static_cast<uint64_t>(
939 std::numeric_limits<unsigned long long>::digits) &&
940 "undefined behavior");
941 ValueToEmit &= ~0ULL >> Shift;
942 EmitIntValue(ValueToEmit, EmissionSize);
943 Emitted += EmissionSize;
948 assert(Directive &&
"Invalid size for machine code value!");
951 TS->emitValue(Value);
953 Value->
print(OS, MAI);
958 void MCAsmStreamer::EmitULEB128Value(
const MCExpr *Value) {
960 if (Value->evaluateAsAbsolute(IntValue)) {
961 EmitULEB128IntValue(IntValue);
965 Value->
print(OS, MAI);
969 void MCAsmStreamer::EmitSLEB128Value(
const MCExpr *Value) {
971 if (Value->evaluateAsAbsolute(IntValue)) {
972 EmitSLEB128IntValue(IntValue);
976 Value->
print(OS, MAI);
980 void MCAsmStreamer::EmitDTPRel64Value(
const MCExpr *Value) {
983 Value->
print(OS, MAI);
987 void MCAsmStreamer::EmitDTPRel32Value(
const MCExpr *Value) {
990 Value->
print(OS, MAI);
994 void MCAsmStreamer::EmitTPRel64Value(
const MCExpr *Value) {
997 Value->
print(OS, MAI);
1001 void MCAsmStreamer::EmitTPRel32Value(
const MCExpr *Value) {
1004 Value->
print(OS, MAI);
1008 void MCAsmStreamer::EmitGPRel64Value(
const MCExpr *Value) {
1011 Value->
print(OS, MAI);
1015 void MCAsmStreamer::EmitGPRel32Value(
const MCExpr *Value) {
1018 Value->
print(OS, MAI);
1022 void MCAsmStreamer::emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
1024 int64_t IntNumBytes;
1025 if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
1030 OS << ZeroDirective;
1031 NumBytes.
print(OS, MAI);
1033 OS <<
',' << (int)FillValue;
1041 void MCAsmStreamer::emitFill(
const MCExpr &NumValues, int64_t Size,
1042 int64_t Expr,
SMLoc Loc) {
1045 NumValues.
print(OS, MAI);
1046 OS <<
", " << Size <<
", 0x";
1051 void MCAsmStreamer::EmitValueToAlignment(
unsigned ByteAlignment, int64_t Value,
1053 unsigned MaxBytesToEmit) {
1057 switch (ValueSize) {
1061 OS <<
"\t.p2align\t";
1075 if (Value || MaxBytesToEmit) {
1080 OS <<
", " << MaxBytesToEmit;
1088 switch (ValueSize) {
1090 case 1: OS <<
".balign";
break;
1091 case 2: OS <<
".balignw";
break;
1092 case 4: OS <<
".balignl";
break;
1099 OS <<
", " << MaxBytesToEmit;
1103 void MCAsmStreamer::EmitCodeAlignment(
unsigned ByteAlignment,
1104 unsigned MaxBytesToEmit) {
1110 void MCAsmStreamer::emitValueToOffset(
const MCExpr *Offset,
1111 unsigned char Value,
1115 Offset->
print(OS, MAI);
1120 void MCAsmStreamer::EmitFileDirective(
StringRef Filename) {
1131 bool UseDwarfDirectory,
1135 if (!UseDwarfDirectory && !Directory.
empty()) {
1139 FullPathName = Directory;
1142 Filename = FullPathName;
1146 OS <<
"\t.file\t" << FileNo <<
' ';
1147 if (!Directory.
empty()) {
1153 OS <<
" md5 0x" << Checksum->
digest();
1163 assert(CUID == 0 &&
"multiple CUs not supported by MCAsmStreamer");
1168 Table.
tryGetFile(Directory, Filename, Checksum, Source, FileNo);
1171 FileNo = FileNoOrErr.
get();
1178 UseDwarfDirectory, OS1);
1181 TS->emitDwarfFileDirective(OS1.
str());
1183 EmitRawText(OS1.
str());
1188 void MCAsmStreamer::emitDwarfFile0Directive(
StringRef Directory,
1195 if (getContext().getDwarfVersion() < 5)
1198 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1204 UseDwarfDirectory, OS1);
1207 TS->emitDwarfFileDirective(OS1.
str());
1209 EmitRawText(OS1.
str());
1212 void MCAsmStreamer::EmitDwarfLocDirective(
unsigned FileNo,
unsigned Line,
1213 unsigned Column,
unsigned Flags,
1215 unsigned Discriminator,
1217 OS <<
"\t.loc\t" << FileNo <<
" " << Line <<
" " << Column;
1220 OS <<
" basic_block";
1222 OS <<
" prologue_end";
1224 OS <<
" epilogue_begin";
1226 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1230 if (Flags & DWARF2_FLAG_IS_STMT)
1237 OS <<
" isa " << Isa;
1239 OS <<
" discriminator " << Discriminator;
1245 << Line <<
':' << Column;
1249 Isa, Discriminator, FileName);
1252 MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(
unsigned CUID) {
1258 bool MCAsmStreamer::EmitCVFileDirective(
unsigned FileNo,
StringRef Filename,
1261 if (!getContext().getCVContext().addFile(*
this, FileNo, Filename, Checksum,
1265 OS <<
"\t.cv_file\t" << FileNo <<
' ';
1268 if (!ChecksumKind) {
1281 bool MCAsmStreamer::EmitCVFuncIdDirective(
unsigned FuncId) {
1282 OS <<
"\t.cv_func_id " << FuncId <<
'\n';
1286 bool MCAsmStreamer::EmitCVInlineSiteIdDirective(
unsigned FunctionId,
1289 unsigned IALine,
unsigned IACol,
1291 OS <<
"\t.cv_inline_site_id " << FunctionId <<
" within " << IAFunc
1292 <<
" inlined_at " << IAFile <<
' ' << IALine <<
' ' << IACol <<
'\n';
1294 IALine, IACol, Loc);
1297 void MCAsmStreamer::EmitCVLocDirective(
unsigned FunctionId,
unsigned FileNo,
1298 unsigned Line,
unsigned Column,
1299 bool PrologueEnd,
bool IsStmt,
1301 OS <<
"\t.cv_loc\t" << FunctionId <<
" " << FileNo <<
" " << Line <<
" " 1304 OS <<
" prologue_end";
1306 unsigned OldIsStmt = getContext().getCVContext().getCurrentCVLoc().isStmt();
1307 if (IsStmt != OldIsStmt) {
1323 PrologueEnd, IsStmt, FileName, Loc);
1326 void MCAsmStreamer::EmitCVLinetableDirective(
unsigned FunctionId,
1329 OS <<
"\t.cv_linetable\t" << FunctionId <<
", ";
1330 FnStart->
print(OS, MAI);
1332 FnEnd->
print(OS, MAI);
1337 void MCAsmStreamer::EmitCVInlineLinetableDirective(
unsigned PrimaryFunctionId,
1338 unsigned SourceFileId,
1339 unsigned SourceLineNum,
1342 OS <<
"\t.cv_inline_linetable\t" << PrimaryFunctionId <<
' ' << SourceFileId
1343 <<
' ' << SourceLineNum <<
' ';
1344 FnStartSym->
print(OS, MAI);
1346 FnEndSym->
print(OS, MAI);
1349 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1352 void MCAsmStreamer::EmitCVDefRangeDirective(
1353 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1355 OS <<
"\t.cv_def_range\t";
1356 for (std::pair<const MCSymbol *, const MCSymbol *> Range : Ranges) {
1358 Range.first->print(OS, MAI);
1360 Range.second->print(OS, MAI);
1368 void MCAsmStreamer::EmitCVStringTableDirective() {
1369 OS <<
"\t.cv_stringtable";
1373 void MCAsmStreamer::EmitCVFileChecksumsDirective() {
1374 OS <<
"\t.cv_filechecksums";
1378 void MCAsmStreamer::EmitCVFileChecksumOffsetDirective(
unsigned FileNo) {
1379 OS <<
"\t.cv_filechecksumoffset\t" << FileNo;
1383 void MCAsmStreamer::EmitCVFPOData(
const MCSymbol *ProcSym,
SMLoc L) {
1384 OS <<
"\t.cv_fpo_data\t";
1385 ProcSym->
print(OS, MAI);
1389 void MCAsmStreamer::EmitIdent(
StringRef IdentString) {
1396 void MCAsmStreamer::EmitCFISections(
bool EH,
bool Debug) {
1398 OS <<
"\t.cfi_sections ";
1402 OS <<
", .debug_frame";
1404 OS <<
".debug_frame";
1411 OS <<
"\t.cfi_startproc";
1419 OS <<
"\t.cfi_endproc";
1423 void MCAsmStreamer::EmitRegisterName(int64_t
Register) {
1430 if (LLVMRegister != -1) {
1431 InstPrinter->printRegName(OS, LLVMRegister);
1438 void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
1440 OS <<
"\t.cfi_def_cfa ";
1441 EmitRegisterName(Register);
1446 void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
1448 OS <<
"\t.cfi_def_cfa_offset " <<
Offset;
1453 OS <<
"\t.cfi_escape ";
1454 if (!Values.
empty()) {
1455 size_t e = Values.
size() - 1;
1456 for (
size_t i = 0; i < e; ++i)
1457 OS <<
format(
"0x%02x", uint8_t(Values[i])) <<
", ";
1458 OS <<
format(
"0x%02x", uint8_t(Values[e]));
1462 void MCAsmStreamer::EmitCFIEscape(
StringRef Values) {
1468 void MCAsmStreamer::EmitCFIGnuArgsSize(int64_t Size) {
1471 uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
1478 void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
1480 OS <<
"\t.cfi_def_cfa_register ";
1481 EmitRegisterName(Register);
1485 void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
1487 OS <<
"\t.cfi_offset ";
1488 EmitRegisterName(Register);
1493 void MCAsmStreamer::EmitCFIPersonality(
const MCSymbol *Sym,
1494 unsigned Encoding) {
1496 OS <<
"\t.cfi_personality " << Encoding <<
", ";
1497 Sym->
print(OS, MAI);
1501 void MCAsmStreamer::EmitCFILsda(
const MCSymbol *Sym,
unsigned Encoding) {
1503 OS <<
"\t.cfi_lsda " << Encoding <<
", ";
1504 Sym->
print(OS, MAI);
1508 void MCAsmStreamer::EmitCFIRememberState() {
1510 OS <<
"\t.cfi_remember_state";
1514 void MCAsmStreamer::EmitCFIRestoreState() {
1516 OS <<
"\t.cfi_restore_state";
1520 void MCAsmStreamer::EmitCFIRestore(int64_t Register) {
1522 OS <<
"\t.cfi_restore ";
1523 EmitRegisterName(Register);
1527 void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
1529 OS <<
"\t.cfi_same_value ";
1530 EmitRegisterName(Register);
1534 void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
1536 OS <<
"\t.cfi_rel_offset ";
1537 EmitRegisterName(Register);
1542 void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
1544 OS <<
"\t.cfi_adjust_cfa_offset " << Adjustment;
1548 void MCAsmStreamer::EmitCFISignalFrame() {
1550 OS <<
"\t.cfi_signal_frame";
1554 void MCAsmStreamer::EmitCFIUndefined(int64_t Register) {
1556 OS <<
"\t.cfi_undefined " <<
Register;
1560 void MCAsmStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
1562 OS <<
"\t.cfi_register " << Register1 <<
", " << Register2;
1566 void MCAsmStreamer::EmitCFIWindowSave() {
1568 OS <<
"\t.cfi_window_save";
1572 void MCAsmStreamer::EmitCFIReturnColumn(int64_t Register) {
1574 OS <<
"\t.cfi_return_column " <<
Register;
1578 void MCAsmStreamer::EmitWinCFIStartProc(
const MCSymbol *Symbol,
SMLoc Loc) {
1582 Symbol->
print(OS, MAI);
1586 void MCAsmStreamer::EmitWinCFIEndProc(
SMLoc Loc) {
1589 OS <<
"\t.seh_endproc";
1593 void MCAsmStreamer::EmitWinCFIStartChained(
SMLoc Loc) {
1596 OS <<
"\t.seh_startchained";
1600 void MCAsmStreamer::EmitWinCFIEndChained(
SMLoc Loc) {
1603 OS <<
"\t.seh_endchained";
1607 void MCAsmStreamer::EmitWinEHHandler(
const MCSymbol *Sym,
bool Unwind,
1608 bool Except,
SMLoc Loc) {
1611 OS <<
"\t.seh_handler ";
1612 Sym->
print(OS, MAI);
1620 void MCAsmStreamer::EmitWinEHHandlerData(
SMLoc Loc) {
1629 MCSection *XData = getAssociatedXDataSection(TextSec);
1630 SwitchSectionNoChange(XData);
1632 OS <<
"\t.seh_handlerdata";
1636 void MCAsmStreamer::EmitWinCFIPushReg(
unsigned Register,
SMLoc Loc) {
1639 OS <<
"\t.seh_pushreg " <<
Register;
1643 void MCAsmStreamer::EmitWinCFISetFrame(
unsigned Register,
unsigned Offset,
1647 OS <<
"\t.seh_setframe " << Register <<
", " <<
Offset;
1651 void MCAsmStreamer::EmitWinCFIAllocStack(
unsigned Size,
SMLoc Loc) {
1654 OS <<
"\t.seh_stackalloc " <<
Size;
1658 void MCAsmStreamer::EmitWinCFISaveReg(
unsigned Register,
unsigned Offset,
1662 OS <<
"\t.seh_savereg " << Register <<
", " <<
Offset;
1666 void MCAsmStreamer::EmitWinCFISaveXMM(
unsigned Register,
unsigned Offset,
1670 OS <<
"\t.seh_savexmm " << Register <<
", " <<
Offset;
1674 void MCAsmStreamer::EmitWinCFIPushFrame(
bool Code,
SMLoc Loc) {
1677 OS <<
"\t.seh_pushframe";
1683 void MCAsmStreamer::EmitWinCFIEndProlog(
SMLoc Loc) {
1686 OS <<
"\t.seh_endprologue";
1693 OS <<
"\t.cg_profile ";
1697 OS <<
", " << Count;
1701 void MCAsmStreamer::AddEncodingComment(
const MCInst &Inst,
1703 bool PrintSchedInfo) {
1710 if (!getAssembler().getEmitterPtr())
1713 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
1720 for (
unsigned i = 0, e = Code.
size() * 8; i != e; ++i)
1723 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
1726 getAssembler().getBackend().getFixupKindInfo(F.
getKind());
1727 for (
unsigned j = 0; j != Info.
TargetSize; ++j) {
1729 assert(Index < Code.
size() * 8 &&
"Invalid offset in fixup!");
1730 FixupMap[
Index] = 1 + i;
1736 OS <<
"encoding: [";
1737 for (
unsigned i = 0, e = Code.
size(); i != e; ++i) {
1742 uint8_t MapEntry = FixupMap[i * 8 + 0];
1743 for (
unsigned j = 1; j != 8; ++j) {
1744 if (FixupMap[i * 8 + j] == MapEntry)
1747 MapEntry = uint8_t(~0U);
1751 if (MapEntry != uint8_t(~0U)) {
1752 if (MapEntry == 0) {
1753 OS <<
format(
"0x%02x", uint8_t(Code[i]));
1757 OS <<
format(
"0x%02x", uint8_t(Code[i])) <<
'\'' 1758 <<
char(
'A' + MapEntry - 1) <<
'\'';
1760 OS <<
char(
'A' + MapEntry - 1);
1765 for (
unsigned j = 8; j--;) {
1766 unsigned Bit = (Code[i] >> j) & 1;
1770 FixupBit = i * 8 + j;
1772 FixupBit = i * 8 + (7-j);
1774 if (uint8_t MapEntry = FixupMap[FixupBit]) {
1775 assert(Bit == 0 &&
"Encoder wrote into fixed up bit!");
1776 OS <<
char(
'A' + MapEntry - 1);
1785 if (Fixups.
size() || !PrintSchedInfo)
1788 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
1791 getAssembler().getBackend().getFixupKindInfo(F.
getKind());
1792 OS <<
" fixup " <<
char(
'A' + i) <<
" - " <<
"offset: " << F.
getOffset()
1793 <<
", value: " << *F.
getValue() <<
", kind: " << Info.
Name <<
"\n";
1797 void MCAsmStreamer::EmitInstruction(
const MCInst &Inst,
1799 bool PrintSchedInfo) {
1800 assert(getCurrentSectionOnly() &&
1801 "Cannot emit contents before setting section!");
1804 AddEncodingComment(Inst, STI, PrintSchedInfo);
1809 GetCommentOS() <<
"\n";
1810 Inst.
dump_pretty(GetCommentOS(), InstPrinter.get(),
"\n ");
1811 GetCommentOS() <<
"\n";
1814 if(getTargetStreamer())
1815 getTargetStreamer()->prettyPrintAsm(*InstPrinter, OS, Inst, STI);
1817 InstPrinter->printInst(&Inst, OS,
"", STI);
1819 if (PrintSchedInfo) {
1822 GetCommentOS() <<
SI;
1826 if (Comments.
size() && Comments.
back() !=
'\n')
1827 GetCommentOS() <<
"\n";
1832 void MCAsmStreamer::EmitBundleAlignMode(
unsigned AlignPow2) {
1833 OS <<
"\t.bundle_align_mode " << AlignPow2;
1837 void MCAsmStreamer::EmitBundleLock(
bool AlignToEnd) {
1838 OS <<
"\t.bundle_lock";
1840 OS <<
" align_to_end";
1844 void MCAsmStreamer::EmitBundleUnlock() {
1845 OS <<
"\t.bundle_unlock";
1853 Offset.
print(OS, MAI);
1857 Expr->
print(OS, MAI);
1863 void MCAsmStreamer::EmitAddrsig() {
1868 void MCAsmStreamer::EmitAddrsigSym(
const MCSymbol *Sym) {
1869 OS <<
"\t.addrsig_sym ";
1870 Sym->
print(OS, MAI);
1877 void MCAsmStreamer::EmitRawTextImpl(
StringRef String) {
1878 if (!String.
empty() && String.
back() ==
'\n')
1884 void MCAsmStreamer::FinishImpl() {
1886 if (getContext().getGenDwarfForAssembly())
1892 auto &Tables = getContext().getMCDwarfLineTables();
1893 if (!Tables.empty()) {
1894 assert(Tables.size() == 1 &&
"asm output only supports one line table");
1895 if (
auto *Label = Tables.begin()->second.getLabel()) {
1896 SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
1903 std::unique_ptr<formatted_raw_ostream> OS,
1904 bool isVerboseAsm,
bool useDwarfDirectory,
1906 std::unique_ptr<MCCodeEmitter> &&CE,
1907 std::unique_ptr<MCAsmBackend> &&MAB,
1909 return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
1910 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...
void push_back(const T &Elt)
virtual void EmitCFISameValue(int64_t Register)
const char * getLabelSuffix() const
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol *>> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
virtual void EmitWinCFIPushReg(unsigned Register, SMLoc Loc=SMLoc())
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 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.
Compute iterated dominance frontiers using a linear time algorithm.
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
A raw_ostream that discards all output.
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
SmallString< 32 > digest() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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
int getLLVMRegNumFromEH(unsigned RegNum) const
Map a DWARF EH register back to a target register (same as getLLVMRegNum(RegNum, true)) but return -1...
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
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&... args)
Constructs a new T() with the given args and returns a unique_ptr<T> which owns the object...
Error takeError()
Take ownership of the stored error.
virtual void EmitCFIDefCfaOffset(int64_t Offset)
.type _foo, STT_NOTYPE # aka
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
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)
virtual std::string getSchedInfoStr(MCInst const &MCI) const
Returns string representation of scheduler comment.
#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.
iterator_range< const unsigned char * > bytes() const
const char * getGPRel64Directive() const
Tagged union holding either a T or a Error.
StringRef getSingleStringRef() const
This returns the twine as a single StringRef.
const char * getWeakRefDirective() const
Position
Position to insert a new instruction relative to an existing instruction.
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
const char * getWeakDirective() const
.code16 (X86) / .code 16 (ARM)
virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
.type _foo, STT_GNU_IFUNC
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
virtual void EmitCFIRestoreState()
const char * getTPRel32Directive() const
bool hasNoDeadStrip() const
StringRef getSegmentName() const
Instances of this class represent a single low-level machine instruction.
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.
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
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char * getSeparatorString() const
virtual void EmitCFIDefCfaRegister(int64_t Register)
MCLOHType
Linker Optimization Hint Type.
StringRef getCommentString() const
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
.subsections_via_symbols (MachO)
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)
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
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual void EmitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values)
static void printDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, MD5::MD5Result *Checksum, Optional< StringRef > Source, bool UseDwarfDirectory, raw_svector_ostream &OS)
const MCDummyFragment & getDummyFragment() const
virtual void EmitCFIReturnColumn(int64_t Register)
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)
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source, unsigned FileNumber=0)
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
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
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.
std::string toHex(StringRef Input)
Convert buffer Input to its hexadecimal representation.
size_t GetNumBytesInBuffer() const
static void Emit(MCStreamer *MCOS)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
.code32 (X86) / .code 32 (ARM)
amdgpu Simplify well known AMD library false Value Value * Arg
.type _foo, STT_COMMON # aka
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...
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
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
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
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.
static void PrintQuotedString(StringRef Data, raw_ostream &OS)
Represents a location in source code.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
MCFixupKind getKind() const
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.