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"
43using namespace llvm;
44
45#define DEBUG_TYPE "asm-printer"
46
47unsigned AsmPrinter::addInlineAsmDiagBuffer(StringRef AsmStr,
48 const MDNode *LocMDNode) const {
49 MCContext &Context = MMI->getContext();
51 SourceMgr &SrcMgr = *Context.getInlineSourceManager();
52 std::vector<const MDNode *> &LocInfos = Context.getLocInfos();
53
54 std::unique_ptr<MemoryBuffer> Buffer;
55 // The inline asm source manager will outlive AsmStr, so make a copy of the
56 // string for SourceMgr to own.
57 Buffer = MemoryBuffer::getMemBufferCopy(AsmStr, "<inline asm>");
58
59 // Tell SrcMgr about this buffer, it takes ownership of the buffer.
60 unsigned BufNum = SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
61
62 // Store LocMDNode in DiagInfo, using BufNum as an identifier.
63 if (LocMDNode) {
64 LocInfos.resize(BufNum);
65 LocInfos[BufNum - 1] = LocMDNode;
66 }
67
68 return BufNum;
69}
70
71
72/// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
73void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
74 const MCTargetOptions &MCOptions,
75 const MDNode *LocMDNode,
76 InlineAsm::AsmDialect Dialect) const {
77 assert(!Str.empty() && "Can't emit empty inline asm block");
78
79 // Remember if the buffer is nul terminated or not so we can avoid a copy.
80 bool isNullTerminated = Str.back() == 0;
81 if (isNullTerminated)
82 Str = Str.substr(0, Str.size()-1);
83
84 // If the output streamer does not have mature MC support or the integrated
85 // assembler has been disabled or not required, just emit the blob textually.
86 // Otherwise parse the asm and emit it via MC support.
87 // This is useful in case the asm parser doesn't handle something but the
88 // system assembler does.
89 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
90 assert(MCAI && "No MCAsmInfo");
91 if (!MCAI->useIntegratedAssembler() &&
93 !OutStreamer->isIntegratedAssemblerRequired()) {
95 OutStreamer->emitRawText(Str);
96 emitInlineAsmEnd(STI, nullptr);
97 return;
98 }
99
100 unsigned BufNum = addInlineAsmDiagBuffer(Str, LocMDNode);
101 SourceMgr &SrcMgr = *MMI->getContext().getInlineSourceManager();
104 // FIXME(sandboxing): Propagating vfs::FileSystem here is lots of work.
105 auto BypassSandbox = sys::sandbox::scopedDisable();
106 return vfs::getRealFileSystem();
107 }());
108
109 std::unique_ptr<MCAsmParser> Parser(
111
112 // We create a new MCInstrInfo here since we might be at the module level
113 // and not have a MachineFunction to initialize the TargetInstrInfo from and
114 // we only need MCInstrInfo for asm parsing. We create one unconditionally
115 // because it's not subtarget dependent.
116 std::unique_ptr<MCInstrInfo> MII(TM.getTarget().createMCInstrInfo());
117 assert(MII && "Failed to create instruction info");
118 std::unique_ptr<MCTargetAsmParser> TAP(TM.getTarget().createMCAsmParser(
119 STI, *Parser, *MII, MCOptions));
120 if (!TAP)
121 report_fatal_error("Inline asm not supported by this streamer because"
122 " we don't have an asm parser for this target\n");
123
124 // Respect inlineasm dialect on X86 targets only
125 if (TM.getTargetTriple().isX86()) {
126 Parser->setAssemblerDialect(Dialect);
127 // Enable lexing Masm binary and hex integer literals in intel inline
128 // assembly.
129 if (Dialect == InlineAsm::AD_Intel)
130 Parser->getLexer().setLexMasmIntegers(true);
131 }
132 Parser->setTargetParser(*TAP);
133
135 // Don't implicitly switch to the text section before the asm.
136 (void)Parser->Run(/*NoInitialTextSection*/ true,
137 /*NoFinalize*/ true);
138 emitInlineAsmEnd(STI, &TAP->getSTI());
139}
140
141static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
142 MachineModuleInfo *MMI, const MCAsmInfo *MAI,
143 AsmPrinter *AP, uint64_t LocCookie,
144 raw_ostream &OS) {
145 bool InputIsIntelDialect = MI->getInlineAsmDialect() == InlineAsm::AD_Intel;
146
147 if (InputIsIntelDialect) {
148 // Switch to the inline assembly variant.
149 OS << "\t.intel_syntax\n\t";
150 }
151
152 int CurVariant = -1; // The number of the {.|.|.} region we are in.
153 const char *LastEmitted = AsmStr; // One past the last character emitted.
154 unsigned NumOperands = MI->getNumOperands();
155
156 int AsmPrinterVariant;
157 if (InputIsIntelDialect)
158 AsmPrinterVariant = 1; // X86MCAsmInfo.cpp's AsmWriterFlavorTy::Intel.
159 else
160 AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant();
161
162 // FIXME: Should this happen for `asm inteldialect` as well?
163 if (!InputIsIntelDialect && !MAI->isHLASM())
164 OS << '\t';
165
166 while (*LastEmitted) {
167 switch (*LastEmitted) {
168 default: {
169 // Not a special case, emit the string section literally.
170 const char *LiteralEnd = LastEmitted+1;
171 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
172 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
173 ++LiteralEnd;
174 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
175 OS.write(LastEmitted, LiteralEnd - LastEmitted);
176 LastEmitted = LiteralEnd;
177 break;
178 }
179 case '\n':
180 ++LastEmitted; // Consume newline character.
181 OS << '\n'; // Indent code with newline.
182 break;
183 case '$': {
184 ++LastEmitted; // Consume '$' character.
185 bool Done = true;
186
187 // Handle escapes.
188 switch (*LastEmitted) {
189 default: Done = false; break;
190 case '$': // $$ -> $
191 if (!InputIsIntelDialect)
192 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
193 OS << '$';
194 ++LastEmitted; // Consume second '$' character.
195 break;
196 case '(': // $( -> same as GCC's { character.
197 ++LastEmitted; // Consume '(' character.
198 if (CurVariant != -1)
199 report_fatal_error("Nested variants found in inline asm string: '" +
200 Twine(AsmStr) + "'");
201 CurVariant = 0; // We're in the first variant now.
202 break;
203 case '|':
204 ++LastEmitted; // Consume '|' character.
205 if (CurVariant == -1)
206 OS << '|'; // This is gcc's behavior for | outside a variant.
207 else
208 ++CurVariant; // We're in the next variant.
209 break;
210 case ')': // $) -> same as GCC's } char.
211 ++LastEmitted; // Consume ')' character.
212 if (CurVariant == -1)
213 OS << '}'; // This is gcc's behavior for } outside a variant.
214 else
215 CurVariant = -1;
216 break;
217 }
218 if (Done) break;
219
220 bool HasCurlyBraces = false;
221 if (*LastEmitted == '{') { // ${variable}
222 ++LastEmitted; // Consume '{' character.
223 HasCurlyBraces = true;
224 }
225
226 // If we have ${:foo}, then this is not a real operand reference, it is a
227 // "magic" string reference, just like in .td files. Arrange to call
228 // PrintSpecial.
229 if (HasCurlyBraces && *LastEmitted == ':') {
230 ++LastEmitted;
231 const char *StrStart = LastEmitted;
232 const char *StrEnd = strchr(StrStart, '}');
233 if (!StrEnd)
234 report_fatal_error("Unterminated ${:foo} operand in inline asm"
235 " string: '" + Twine(AsmStr) + "'");
236 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
237 AP->PrintSpecial(MI, OS, StringRef(StrStart, StrEnd - StrStart));
238 LastEmitted = StrEnd+1;
239 break;
240 }
241
242 const char *IDStart = LastEmitted;
243 const char *IDEnd = IDStart;
244 while (isDigit(*IDEnd))
245 ++IDEnd;
246
247 unsigned Val;
248 if (StringRef(IDStart, IDEnd-IDStart).getAsInteger(10, Val))
249 report_fatal_error("Bad $ operand number in inline asm string: '" +
250 Twine(AsmStr) + "'");
251 LastEmitted = IDEnd;
252
253 if (Val >= NumOperands - 1)
254 report_fatal_error("Invalid $ operand number in inline asm string: '" +
255 Twine(AsmStr) + "'");
256
257 char Modifier[2] = { 0, 0 };
258
259 if (HasCurlyBraces) {
260 // If we have curly braces, check for a modifier character. This
261 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
262 if (*LastEmitted == ':') {
263 ++LastEmitted; // Consume ':' character.
264 if (*LastEmitted == 0)
265 report_fatal_error("Bad ${:} expression in inline asm string: '" +
266 Twine(AsmStr) + "'");
267
268 Modifier[0] = *LastEmitted;
269 ++LastEmitted; // Consume modifier character.
270 }
271
272 if (*LastEmitted != '}')
273 report_fatal_error("Bad ${} expression in inline asm string: '" +
274 Twine(AsmStr) + "'");
275 ++LastEmitted; // Consume '}' character.
276 }
277
278 // Okay, we finally have a value number. Ask the target to print this
279 // operand!
280 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
281 unsigned OpNo = InlineAsm::MIOp_FirstOperand;
282
283 bool Error = false;
284
285 // Scan to find the machine operand number for the operand.
286 for (; Val; --Val) {
287 if (OpNo >= MI->getNumOperands())
288 break;
289 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
290 OpNo += F.getNumOperandRegisters() + 1;
291 }
292
293 // We may have a location metadata attached to the end of the
294 // instruction, and at no point should see metadata at any
295 // other point while processing. It's an error if so.
296 if (OpNo >= MI->getNumOperands() || MI->getOperand(OpNo).isMetadata()) {
297 Error = true;
298 } else {
299 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
300 ++OpNo; // Skip over the ID number.
301
302 // FIXME: Shouldn't arch-independent output template handling go into
303 // PrintAsmOperand?
304 // Labels are target independent.
305 if (MI->getOperand(OpNo).isBlockAddress()) {
306 const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
307 MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
308 Sym->print(OS, AP->MAI);
310 } else if (MI->getOperand(OpNo).isMBB()) {
311 const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
312 Sym->print(OS, AP->MAI);
313 } else if (F.isMemKind()) {
315 MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
316 } else {
317 Error = AP->PrintAsmOperand(MI, OpNo,
318 Modifier[0] ? Modifier : nullptr, OS);
319 }
320 }
321 if (Error) {
322 const Function &Fn = MI->getMF()->getFunction();
324 LocCookie,
325 "invalid operand in inline asm: '" + Twine(AsmStr) + "'"));
326 }
327 }
328 break;
329 }
330 }
331 }
332 if (InputIsIntelDialect)
333 OS << "\n\t.att_syntax";
334 OS << '\n' << (char)0; // null terminate string.
335}
336
337/// This method formats and emits the specified machine instruction that is an
338/// inline asm.
339void AsmPrinter::emitInlineAsm(const MachineInstr *MI) const {
340 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms");
341
342 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
343 const char *AsmStr = MI->getOperand(0).getSymbolName();
344
345 // If this asmstr is empty, just print the #APP/#NOAPP markers.
346 // These are useful to see where empty asm's wound up.
347 if (AsmStr[0] == 0) {
348 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
349 OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
350 return;
351 }
352
353 // Emit the #APP start marker. This has to happen even if verbose-asm isn't
354 // enabled, so we use emitRawComment.
355 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
356
357 const MDNode *LocMD = MI->getLocCookieMD();
358 uint64_t LocCookie =
359 LocMD
360 ? mdconst::extract<ConstantInt>(LocMD->getOperand(0))->getZExtValue()
361 : 0;
362
363 // Emit the inline asm to a temporary string so we can emit it through
364 // EmitInlineAsm.
365 SmallString<256> StringData;
366 raw_svector_ostream OS(StringData);
367
368 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
369 EmitInlineAsmStr(AsmStr, MI, MMI, MAI, AP, LocCookie, OS);
370
371 // Emit warnings if we use reserved registers on the clobber list, as
372 // that might lead to undefined behaviour.
373 SmallVector<Register, 8> RestrRegs;
374 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
375 // Start with the first operand descriptor, and iterate over them.
376 for (unsigned I = InlineAsm::MIOp_FirstOperand, NumOps = MI->getNumOperands();
377 I < NumOps; ++I) {
378 const MachineOperand &MO = MI->getOperand(I);
379 if (!MO.isImm())
380 continue;
381 const InlineAsm::Flag F(MO.getImm());
382 if (F.isClobberKind()) {
383 Register Reg = MI->getOperand(I + 1).getReg();
384 if (!TRI->isAsmClobberable(*MF, Reg))
385 RestrRegs.push_back(Reg);
386 }
387 // Skip to one before the next operand descriptor, if it exists.
388 I += F.getNumOperandRegisters();
389 }
390
391 if (!RestrRegs.empty()) {
392 std::string Msg = "inline asm clobber list contains reserved registers: ";
393 ListSeparator LS;
394 for (const Register RR : RestrRegs) {
395 Msg += LS;
396 Msg += TRI->getRegAsmName(RR);
397 }
398
399 const Function &Fn = MF->getFunction();
400 const char *Note =
401 "Reserved registers on the clobber list may not be "
402 "preserved across the asm statement, and clobbering them may "
403 "lead to undefined behaviour.";
404 LLVMContext &Ctx = Fn.getContext();
405 Ctx.diagnose(DiagnosticInfoInlineAsm(LocCookie, Msg,
407 Ctx.diagnose(
408 DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
409
410 for (const Register RR : RestrRegs) {
411 if (std::optional<std::string> reason =
412 TRI->explainReservedReg(*MF, RR)) {
413 Ctx.diagnose(DiagnosticInfoInlineAsm(LocCookie, *reason,
415 }
416 }
417 }
418
419 emitInlineAsm(StringData, getSubtargetInfo(), TM.Options.MCOptions, LocMD,
420 MI->getInlineAsmDialect());
421
422 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't
423 // enabled, so we use emitRawComment.
424 OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
425}
426
427/// PrintSpecial - Print information related to the specified machine instr
428/// that is independent of the operand, and may be independent of the instr
429/// itself. This can be useful for portably encoding the comment character
430/// or other bits of target-specific knowledge into the asmstrings. The
431/// syntax used is ${:comment}. Targets can override this to add support
432/// for their own strange codes.
434 StringRef Code) const {
435 if (Code == "private") {
436 const DataLayout &DL = MF->getDataLayout();
437 OS << DL.getPrivateGlobalPrefix();
438 } else if (Code == "comment") {
439 OS << MAI->getCommentString();
440 } else if (Code == "uid") {
441 // Comparing the address of MI isn't sufficient, because machineinstrs may
442 // be allocated to the same address across functions.
443
444 // If this is a new LastFn instruction, bump the counter.
445 if (LastMI != MI || LastFn != getFunctionNumber()) {
446 ++Counter;
447 LastMI = MI;
448 LastFn = getFunctionNumber();
449 }
450 OS << Counter;
451 } else {
452 std::string msg;
453 raw_string_ostream Msg(msg);
454 Msg << "Unknown special formatter '" << Code
455 << "' for machine instr: " << *MI;
457 }
458}
459
461 assert(MO.isGlobal() && "caller should check MO.isGlobal");
463 printOffset(MO.getOffset(), OS);
464}
465
466/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
467/// instruction, using the specified assembler variant. Targets should
468/// override this to format as appropriate for machine specific ExtraCodes
469/// or when the arch-independent handling would be too complex otherwise.
470bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
471 const char *ExtraCode, raw_ostream &O) {
472 // Does this asm operand have a single letter operand modifier?
473 if (ExtraCode && ExtraCode[0]) {
474 if (ExtraCode[1] != 0) return true; // Unknown modifier.
475
476 // https://gcc.gnu.org/onlinedocs/gccint/Output-Template.html
477 const MachineOperand &MO = MI->getOperand(OpNo);
478 switch (ExtraCode[0]) {
479 default:
480 return true; // Unknown modifier.
481 case 'a': // Print as memory address.
482 if (MO.isReg()) {
483 PrintAsmMemoryOperand(MI, OpNo, nullptr, O);
484 return false;
485 }
486 [[fallthrough]]; // GCC allows '%a' to behave like '%c' with immediates.
487 case 'c': // Substitute immediate value without immediate syntax
488 if (MO.isImm()) {
489 O << MO.getImm();
490 return false;
491 }
492 if (MO.isGlobal()) {
493 PrintSymbolOperand(MO, O);
494 return false;
495 }
496 return true;
497 case 'n': // Negate the immediate constant.
498 if (!MO.isImm())
499 return true;
500 O << -MO.getImm();
501 return false;
502 case 's': // The GCC deprecated s modifier
503 if (!MO.isImm())
504 return true;
505 O << ((32 - MO.getImm()) & 31);
506 return false;
507 }
508 }
509 return true;
510}
511
513 const char *ExtraCode, raw_ostream &O) {
514 // Target doesn't support this yet!
515 return true;
516}
517
519
521 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:54
#define I(x, y, z)
Definition MD5.cpp:57
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:91
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
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:97
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:109
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:112
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition AsmPrinter.h:101
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:106
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:904
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
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:22
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
LLVM_ABI 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
ScopedSetting scopedDisable()
Definition IOSandbox.h:36
LLVM_ABI IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
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.