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