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