LLVM 22.0.0git
AsmPrinterInlineAsm.cpp
Go to the documentation of this file.
1//===-- AsmPrinterInlineAsm.cpp - AsmPrinter Inline Asm Handling ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the inline assembler pieces of the AsmPrinter class.
10//
11//===----------------------------------------------------------------------===//
12
16#include "llvm/ADT/Twine.h"
23#include "llvm/IR/Constants.h"
24#include "llvm/IR/DataLayout.h"
26#include "llvm/IR/InlineAsm.h"
27#include "llvm/IR/LLVMContext.h"
28#include "llvm/IR/Module.h"
29#include "llvm/MC/MCAsmInfo.h"
30#include "llvm/MC/MCInstrInfo.h"
33#include "llvm/MC/MCStreamer.h"
34#include "llvm/MC/MCSymbol.h"
42using namespace llvm;
43
44#define DEBUG_TYPE "asm-printer"
45
46unsigned AsmPrinter::addInlineAsmDiagBuffer(StringRef AsmStr,
47 const MDNode *LocMDNode) const {
48 MCContext &Context = MMI->getContext();
50 SourceMgr &SrcMgr = *Context.getInlineSourceManager();
51 std::vector<const MDNode *> &LocInfos = Context.getLocInfos();
52
53 std::unique_ptr<MemoryBuffer> Buffer;
54 // The inline asm source manager will outlive AsmStr, so make a copy of the
55 // string for SourceMgr to own.
56 Buffer = MemoryBuffer::getMemBufferCopy(AsmStr, "<inline asm>");
57
58 // Tell SrcMgr about this buffer, it takes ownership of the buffer.
59 unsigned BufNum = SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
60
61 // Store LocMDNode in DiagInfo, using BufNum as an identifier.
62 if (LocMDNode) {
63 LocInfos.resize(BufNum);
64 LocInfos[BufNum - 1] = LocMDNode;
65 }
66
67 return BufNum;
68}
69
70
71/// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
72void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
73 const MCTargetOptions &MCOptions,
74 const MDNode *LocMDNode,
75 InlineAsm::AsmDialect Dialect) const {
76 assert(!Str.empty() && "Can't emit empty inline asm block");
77
78 // Remember if the buffer is nul terminated or not so we can avoid a copy.
79 bool isNullTerminated = Str.back() == 0;
80 if (isNullTerminated)
81 Str = Str.substr(0, Str.size()-1);
82
83 // If the output streamer does not have mature MC support or the integrated
84 // assembler has been disabled or not required, just emit the blob textually.
85 // Otherwise parse the asm and emit it via MC support.
86 // This is useful in case the asm parser doesn't handle something but the
87 // system assembler does.
88 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
89 assert(MCAI && "No MCAsmInfo");
90 if (!MCAI->useIntegratedAssembler() &&
92 !OutStreamer->isIntegratedAssemblerRequired()) {
94 OutStreamer->emitRawText(Str);
95 emitInlineAsmEnd(STI, nullptr);
96 return;
97 }
98
99 unsigned BufNum = addInlineAsmDiagBuffer(Str, LocMDNode);
100 SourceMgr &SrcMgr = *MMI->getContext().getInlineSourceManager();
103
104 std::unique_ptr<MCAsmParser> Parser(
106
107 // We create a new MCInstrInfo here since we might be at the module level
108 // and not have a MachineFunction to initialize the TargetInstrInfo from and
109 // we only need MCInstrInfo for asm parsing. We create one unconditionally
110 // because it's not subtarget dependent.
111 std::unique_ptr<MCInstrInfo> MII(TM.getTarget().createMCInstrInfo());
112 assert(MII && "Failed to create instruction info");
113 std::unique_ptr<MCTargetAsmParser> TAP(TM.getTarget().createMCAsmParser(
114 STI, *Parser, *MII, MCOptions));
115 if (!TAP)
116 report_fatal_error("Inline asm not supported by this streamer because"
117 " we don't have an asm parser for this target\n");
118
119 // Respect inlineasm dialect on X86 targets only
120 if (TM.getTargetTriple().isX86()) {
121 Parser->setAssemblerDialect(Dialect);
122 // Enable lexing Masm binary and hex integer literals in intel inline
123 // assembly.
124 if (Dialect == InlineAsm::AD_Intel)
125 Parser->getLexer().setLexMasmIntegers(true);
126 }
127 Parser->setTargetParser(*TAP);
128
130 // Don't implicitly switch to the text section before the asm.
131 (void)Parser->Run(/*NoInitialTextSection*/ true,
132 /*NoFinalize*/ true);
133 emitInlineAsmEnd(STI, &TAP->getSTI());
134}
135
136static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
137 MachineModuleInfo *MMI, const MCAsmInfo *MAI,
138 AsmPrinter *AP, uint64_t LocCookie,
139 raw_ostream &OS) {
140 bool InputIsIntelDialect = MI->getInlineAsmDialect() == InlineAsm::AD_Intel;
141
142 if (InputIsIntelDialect) {
143 // Switch to the inline assembly variant.
144 OS << "\t.intel_syntax\n\t";
145 }
146
147 int CurVariant = -1; // The number of the {.|.|.} region we are in.
148 const char *LastEmitted = AsmStr; // One past the last character emitted.
149 unsigned NumOperands = MI->getNumOperands();
150
151 int AsmPrinterVariant;
152 if (InputIsIntelDialect)
153 AsmPrinterVariant = 1; // X86MCAsmInfo.cpp's AsmWriterFlavorTy::Intel.
154 else
155 AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant();
156
157 // FIXME: Should this happen for `asm inteldialect` as well?
158 if (!InputIsIntelDialect && !MAI->isHLASM())
159 OS << '\t';
160
161 while (*LastEmitted) {
162 switch (*LastEmitted) {
163 default: {
164 // Not a special case, emit the string section literally.
165 const char *LiteralEnd = LastEmitted+1;
166 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
167 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
168 ++LiteralEnd;
169 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
170 OS.write(LastEmitted, LiteralEnd - LastEmitted);
171 LastEmitted = LiteralEnd;
172 break;
173 }
174 case '\n':
175 ++LastEmitted; // Consume newline character.
176 OS << '\n'; // Indent code with newline.
177 break;
178 case '$': {
179 ++LastEmitted; // Consume '$' character.
180 bool Done = true;
181
182 // Handle escapes.
183 switch (*LastEmitted) {
184 default: Done = false; break;
185 case '$': // $$ -> $
186 if (!InputIsIntelDialect)
187 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
188 OS << '$';
189 ++LastEmitted; // Consume second '$' character.
190 break;
191 case '(': // $( -> same as GCC's { character.
192 ++LastEmitted; // Consume '(' character.
193 if (CurVariant != -1)
194 report_fatal_error("Nested variants found in inline asm string: '" +
195 Twine(AsmStr) + "'");
196 CurVariant = 0; // We're in the first variant now.
197 break;
198 case '|':
199 ++LastEmitted; // Consume '|' character.
200 if (CurVariant == -1)
201 OS << '|'; // This is gcc's behavior for | outside a variant.
202 else
203 ++CurVariant; // We're in the next variant.
204 break;
205 case ')': // $) -> same as GCC's } char.
206 ++LastEmitted; // Consume ')' character.
207 if (CurVariant == -1)
208 OS << '}'; // This is gcc's behavior for } outside a variant.
209 else
210 CurVariant = -1;
211 break;
212 }
213 if (Done) break;
214
215 bool HasCurlyBraces = false;
216 if (*LastEmitted == '{') { // ${variable}
217 ++LastEmitted; // Consume '{' character.
218 HasCurlyBraces = true;
219 }
220
221 // If we have ${:foo}, then this is not a real operand reference, it is a
222 // "magic" string reference, just like in .td files. Arrange to call
223 // PrintSpecial.
224 if (HasCurlyBraces && *LastEmitted == ':') {
225 ++LastEmitted;
226 const char *StrStart = LastEmitted;
227 const char *StrEnd = strchr(StrStart, '}');
228 if (!StrEnd)
229 report_fatal_error("Unterminated ${:foo} operand in inline asm"
230 " string: '" + Twine(AsmStr) + "'");
231 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
232 AP->PrintSpecial(MI, OS, StringRef(StrStart, StrEnd - StrStart));
233 LastEmitted = StrEnd+1;
234 break;
235 }
236
237 const char *IDStart = LastEmitted;
238 const char *IDEnd = IDStart;
239 while (isDigit(*IDEnd))
240 ++IDEnd;
241
242 unsigned Val;
243 if (StringRef(IDStart, IDEnd-IDStart).getAsInteger(10, Val))
244 report_fatal_error("Bad $ operand number in inline asm string: '" +
245 Twine(AsmStr) + "'");
246 LastEmitted = IDEnd;
247
248 if (Val >= NumOperands - 1)
249 report_fatal_error("Invalid $ operand number in inline asm string: '" +
250 Twine(AsmStr) + "'");
251
252 char Modifier[2] = { 0, 0 };
253
254 if (HasCurlyBraces) {
255 // If we have curly braces, check for a modifier character. This
256 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
257 if (*LastEmitted == ':') {
258 ++LastEmitted; // Consume ':' character.
259 if (*LastEmitted == 0)
260 report_fatal_error("Bad ${:} expression in inline asm string: '" +
261 Twine(AsmStr) + "'");
262
263 Modifier[0] = *LastEmitted;
264 ++LastEmitted; // Consume modifier character.
265 }
266
267 if (*LastEmitted != '}')
268 report_fatal_error("Bad ${} expression in inline asm string: '" +
269 Twine(AsmStr) + "'");
270 ++LastEmitted; // Consume '}' character.
271 }
272
273 // Okay, we finally have a value number. Ask the target to print this
274 // operand!
275 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
276 unsigned OpNo = InlineAsm::MIOp_FirstOperand;
277
278 bool Error = false;
279
280 // Scan to find the machine operand number for the operand.
281 for (; Val; --Val) {
282 if (OpNo >= MI->getNumOperands())
283 break;
284 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
285 OpNo += F.getNumOperandRegisters() + 1;
286 }
287
288 // We may have a location metadata attached to the end of the
289 // instruction, and at no point should see metadata at any
290 // other point while processing. It's an error if so.
291 if (OpNo >= MI->getNumOperands() || MI->getOperand(OpNo).isMetadata()) {
292 Error = true;
293 } else {
294 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
295 ++OpNo; // Skip over the ID number.
296
297 // FIXME: Shouldn't arch-independent output template handling go into
298 // PrintAsmOperand?
299 // Labels are target independent.
300 if (MI->getOperand(OpNo).isBlockAddress()) {
301 const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
302 MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
303 Sym->print(OS, AP->MAI);
305 } else if (MI->getOperand(OpNo).isMBB()) {
306 const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
307 Sym->print(OS, AP->MAI);
308 } else if (F.isMemKind()) {
310 MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
311 } else {
312 Error = AP->PrintAsmOperand(MI, OpNo,
313 Modifier[0] ? Modifier : nullptr, OS);
314 }
315 }
316 if (Error) {
317 const Function &Fn = MI->getMF()->getFunction();
319 LocCookie,
320 "invalid operand in inline asm: '" + Twine(AsmStr) + "'"));
321 }
322 }
323 break;
324 }
325 }
326 }
327 if (InputIsIntelDialect)
328 OS << "\n\t.att_syntax";
329 OS << '\n' << (char)0; // null terminate string.
330}
331
332/// This method formats and emits the specified machine instruction that is an
333/// inline asm.
334void AsmPrinter::emitInlineAsm(const MachineInstr *MI) const {
335 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms");
336
337 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
338 const char *AsmStr = MI->getOperand(0).getSymbolName();
339
340 // If this asmstr is empty, just print the #APP/#NOAPP markers.
341 // These are useful to see where empty asm's wound up.
342 if (AsmStr[0] == 0) {
343 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
344 OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
345 return;
346 }
347
348 // Emit the #APP start marker. This has to happen even if verbose-asm isn't
349 // enabled, so we use emitRawComment.
350 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
351
352 const MDNode *LocMD = MI->getLocCookieMD();
353 uint64_t LocCookie =
354 LocMD
355 ? mdconst::extract<ConstantInt>(LocMD->getOperand(0))->getZExtValue()
356 : 0;
357
358 // Emit the inline asm to a temporary string so we can emit it through
359 // EmitInlineAsm.
360 SmallString<256> StringData;
361 raw_svector_ostream OS(StringData);
362
363 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
364 EmitInlineAsmStr(AsmStr, MI, MMI, MAI, AP, LocCookie, OS);
365
366 // Emit warnings if we use reserved registers on the clobber list, as
367 // that might lead to undefined behaviour.
368 SmallVector<Register, 8> RestrRegs;
369 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
370 // Start with the first operand descriptor, and iterate over them.
371 for (unsigned I = InlineAsm::MIOp_FirstOperand, NumOps = MI->getNumOperands();
372 I < NumOps; ++I) {
373 const MachineOperand &MO = MI->getOperand(I);
374 if (!MO.isImm())
375 continue;
376 const InlineAsm::Flag F(MO.getImm());
377 if (F.isClobberKind()) {
378 Register Reg = MI->getOperand(I + 1).getReg();
379 if (!TRI->isAsmClobberable(*MF, Reg))
380 RestrRegs.push_back(Reg);
381 }
382 // Skip to one before the next operand descriptor, if it exists.
383 I += F.getNumOperandRegisters();
384 }
385
386 if (!RestrRegs.empty()) {
387 std::string Msg = "inline asm clobber list contains reserved registers: ";
388 ListSeparator LS;
389 for (const Register RR : RestrRegs) {
390 Msg += LS;
391 Msg += TRI->getRegAsmName(RR);
392 }
393
394 const Function &Fn = MF->getFunction();
395 const char *Note =
396 "Reserved registers on the clobber list may not be "
397 "preserved across the asm statement, and clobbering them may "
398 "lead to undefined behaviour.";
399 LLVMContext &Ctx = Fn.getContext();
400 Ctx.diagnose(DiagnosticInfoInlineAsm(LocCookie, Msg,
402 Ctx.diagnose(
403 DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
404
405 for (const Register RR : RestrRegs) {
406 if (std::optional<std::string> reason =
407 TRI->explainReservedReg(*MF, RR)) {
408 Ctx.diagnose(DiagnosticInfoInlineAsm(LocCookie, *reason,
410 }
411 }
412 }
413
414 emitInlineAsm(StringData, getSubtargetInfo(), TM.Options.MCOptions, LocMD,
415 MI->getInlineAsmDialect());
416
417 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't
418 // enabled, so we use emitRawComment.
419 OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
420}
421
422/// PrintSpecial - Print information related to the specified machine instr
423/// that is independent of the operand, and may be independent of the instr
424/// itself. This can be useful for portably encoding the comment character
425/// or other bits of target-specific knowledge into the asmstrings. The
426/// syntax used is ${:comment}. Targets can override this to add support
427/// for their own strange codes.
429 StringRef Code) const {
430 if (Code == "private") {
431 const DataLayout &DL = MF->getDataLayout();
432 OS << DL.getPrivateGlobalPrefix();
433 } else if (Code == "comment") {
434 OS << MAI->getCommentString();
435 } else if (Code == "uid") {
436 // Comparing the address of MI isn't sufficient, because machineinstrs may
437 // be allocated to the same address across functions.
438
439 // If this is a new LastFn instruction, bump the counter.
440 if (LastMI != MI || LastFn != getFunctionNumber()) {
441 ++Counter;
442 LastMI = MI;
443 LastFn = getFunctionNumber();
444 }
445 OS << Counter;
446 } else {
447 std::string msg;
448 raw_string_ostream Msg(msg);
449 Msg << "Unknown special formatter '" << Code
450 << "' for machine instr: " << *MI;
452 }
453}
454
456 assert(MO.isGlobal() && "caller should check MO.isGlobal");
458 printOffset(MO.getOffset(), OS);
459}
460
461/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
462/// instruction, using the specified assembler variant. Targets should
463/// override this to format as appropriate for machine specific ExtraCodes
464/// or when the arch-independent handling would be too complex otherwise.
465bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
466 const char *ExtraCode, raw_ostream &O) {
467 // Does this asm operand have a single letter operand modifier?
468 if (ExtraCode && ExtraCode[0]) {
469 if (ExtraCode[1] != 0) return true; // Unknown modifier.
470
471 // https://gcc.gnu.org/onlinedocs/gccint/Output-Template.html
472 const MachineOperand &MO = MI->getOperand(OpNo);
473 switch (ExtraCode[0]) {
474 default:
475 return true; // Unknown modifier.
476 case 'a': // Print as memory address.
477 if (MO.isReg()) {
478 PrintAsmMemoryOperand(MI, OpNo, nullptr, O);
479 return false;
480 }
481 [[fallthrough]]; // GCC allows '%a' to behave like '%c' with immediates.
482 case 'c': // Substitute immediate value without immediate syntax
483 if (MO.isImm()) {
484 O << MO.getImm();
485 return false;
486 }
487 if (MO.isGlobal()) {
488 PrintSymbolOperand(MO, O);
489 return false;
490 }
491 return true;
492 case 'n': // Negate the immediate constant.
493 if (!MO.isImm())
494 return true;
495 O << -MO.getImm();
496 return false;
497 case 's': // The GCC deprecated s modifier
498 if (!MO.isImm())
499 return true;
500 O << ((32 - MO.getImm()) & 31);
501 return false;
502 }
503 }
504 return true;
505}
506
508 const char *ExtraCode, raw_ostream &O) {
509 // Target doesn't support this yet!
510 return true;
511}
512
514
516 const MCSubtargetInfo *EndInfo) const {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI, MachineModuleInfo *MMI, const MCAsmInfo *MAI, AsmPrinter *AP, uint64_t LocCookie, raw_ostream &OS)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
#define F(x, y, z)
Definition MD5.cpp:55
#define I(x, y, z)
Definition MD5.cpp:58
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
This file defines the SmallString class.
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
Defines the virtual file system interface vfs::FileSystem.
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:96
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
IntrusiveRefCntPtr< vfs::FileSystem > VFS
The VFS to resolve asm include directives.
Definition AsmPrinter.h:114
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:99
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
const MCAsmInfo * MAI
Target Asm Printer information.
Definition AsmPrinter.h:102
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:117
virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, StringRef Code) const
Print information related to the specified machine instr that is independent of the operand,...
unsigned getFunctionNumber() const
Return a unique ID for the current function.
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition AsmPrinter.h:120
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition AsmPrinter.h:106
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:111
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
The address of a basic block.
Definition Constants.h:899
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
Diagnostic information for inline asm reporting.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition Function.cpp:359
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
bool isHLASM() const
Definition MCAsmInfo.h:520
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
Definition MCAsmInfo.h:687
bool parseInlineAsmUsingAsmParser() const
Return true if target want to use AsmParser to parse inlineasm.
Definition MCAsmInfo.h:690
Context object for machine code objects.
Definition MCContext.h:83
LLVM_ABI void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
LLVM_ABI void initInlineSourceManager()
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition MCSymbol.cpp:59
std::vector< std::string > IASSearchPaths
Additional paths to search for .include directives when using the integrated assembler.
Metadata node.
Definition Metadata.h:1078
const MDOperand & getOperand(unsigned I) const
Definition Metadata.h:1442
Representation of each machine instruction.
This class contains meta information specific to a module.
const MCContext & getContext() const
const TargetMachine & getTarget() const
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
int64_t getImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
int64_t getOffset() const
Return the offset from the symbol in this operand.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
Represents a location in source code.
Definition SMLoc.h:23
void push_back(const T &Elt)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Definition SourceMgr.h:37
void setIncludeDirs(const std::vector< std::string > &Dirs)
Definition SourceMgr.h:122
void setVirtualFileSystem(IntrusiveRefCntPtr< vfs::FileSystem > FS)
Definition SourceMgr.cpp:54
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:667
This is an optimization pass for GlobalISel generic memory operations.
@ Done
Definition Threading.h:60
SourceMgr SrcMgr
Definition Error.cpp:24
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:167
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ABI MCAsmParser * createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &, unsigned CB=0)
Create an MCAsmParser instance for parsing assembly similar to gas syntax.