LLVM 19.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 Parser->setAssemblerDialect(Dialect);
117 Parser->setTargetParser(*TAP);
118 // Enable lexing Masm binary and hex integer literals in intel inline
119 // assembly.
120 if (Dialect == InlineAsm::AD_Intel)
121 Parser->getLexer().setLexMasmIntegers(true);
122
124 // Don't implicitly switch to the text section before the asm.
125 (void)Parser->Run(/*NoInitialTextSection*/ true,
126 /*NoFinalize*/ true);
127 emitInlineAsmEnd(STI, &TAP->getSTI());
128}
129
130static void EmitInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
131 MachineModuleInfo *MMI, const MCAsmInfo *MAI,
132 AsmPrinter *AP, uint64_t LocCookie,
133 raw_ostream &OS) {
134 bool InputIsIntelDialect = MI->getInlineAsmDialect() == InlineAsm::AD_Intel;
135
136 if (InputIsIntelDialect) {
137 // Switch to the inline assembly variant.
138 OS << "\t.intel_syntax\n\t";
139 }
140
141 int CurVariant = -1; // The number of the {.|.|.} region we are in.
142 const char *LastEmitted = AsmStr; // One past the last character emitted.
143 unsigned NumOperands = MI->getNumOperands();
144
145 int AsmPrinterVariant;
146 if (InputIsIntelDialect)
147 AsmPrinterVariant = 1; // X86MCAsmInfo.cpp's AsmWriterFlavorTy::Intel.
148 else
149 AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant();
150
151 // FIXME: Should this happen for `asm inteldialect` as well?
152 if (!InputIsIntelDialect && MAI->getEmitGNUAsmStartIndentationMarker())
153 OS << '\t';
154
155 while (*LastEmitted) {
156 switch (*LastEmitted) {
157 default: {
158 // Not a special case, emit the string section literally.
159 const char *LiteralEnd = LastEmitted+1;
160 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
161 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
162 ++LiteralEnd;
163 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
164 OS.write(LastEmitted, LiteralEnd - LastEmitted);
165 LastEmitted = LiteralEnd;
166 break;
167 }
168 case '\n':
169 ++LastEmitted; // Consume newline character.
170 OS << '\n'; // Indent code with newline.
171 break;
172 case '$': {
173 ++LastEmitted; // Consume '$' character.
174 bool Done = true;
175
176 // Handle escapes.
177 switch (*LastEmitted) {
178 default: Done = false; break;
179 case '$': // $$ -> $
180 if (!InputIsIntelDialect)
181 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
182 OS << '$';
183 ++LastEmitted; // Consume second '$' character.
184 break;
185 case '(': // $( -> same as GCC's { character.
186 ++LastEmitted; // Consume '(' character.
187 if (CurVariant != -1)
188 report_fatal_error("Nested variants found in inline asm string: '" +
189 Twine(AsmStr) + "'");
190 CurVariant = 0; // We're in the first variant now.
191 break;
192 case '|':
193 ++LastEmitted; // Consume '|' character.
194 if (CurVariant == -1)
195 OS << '|'; // This is gcc's behavior for | outside a variant.
196 else
197 ++CurVariant; // We're in the next variant.
198 break;
199 case ')': // $) -> same as GCC's } char.
200 ++LastEmitted; // Consume ')' character.
201 if (CurVariant == -1)
202 OS << '}'; // This is gcc's behavior for } outside a variant.
203 else
204 CurVariant = -1;
205 break;
206 }
207 if (Done) break;
208
209 bool HasCurlyBraces = false;
210 if (*LastEmitted == '{') { // ${variable}
211 ++LastEmitted; // Consume '{' character.
212 HasCurlyBraces = true;
213 }
214
215 // If we have ${:foo}, then this is not a real operand reference, it is a
216 // "magic" string reference, just like in .td files. Arrange to call
217 // PrintSpecial.
218 if (HasCurlyBraces && *LastEmitted == ':') {
219 ++LastEmitted;
220 const char *StrStart = LastEmitted;
221 const char *StrEnd = strchr(StrStart, '}');
222 if (!StrEnd)
223 report_fatal_error("Unterminated ${:foo} operand in inline asm"
224 " string: '" + Twine(AsmStr) + "'");
225 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
226 AP->PrintSpecial(MI, OS, StringRef(StrStart, StrEnd - StrStart));
227 LastEmitted = StrEnd+1;
228 break;
229 }
230
231 const char *IDStart = LastEmitted;
232 const char *IDEnd = IDStart;
233 while (isDigit(*IDEnd))
234 ++IDEnd;
235
236 unsigned Val;
237 if (StringRef(IDStart, IDEnd-IDStart).getAsInteger(10, Val))
238 report_fatal_error("Bad $ operand number in inline asm string: '" +
239 Twine(AsmStr) + "'");
240 LastEmitted = IDEnd;
241
242 if (Val >= NumOperands - 1)
243 report_fatal_error("Invalid $ operand number in inline asm string: '" +
244 Twine(AsmStr) + "'");
245
246 char Modifier[2] = { 0, 0 };
247
248 if (HasCurlyBraces) {
249 // If we have curly braces, check for a modifier character. This
250 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
251 if (*LastEmitted == ':') {
252 ++LastEmitted; // Consume ':' character.
253 if (*LastEmitted == 0)
254 report_fatal_error("Bad ${:} expression in inline asm string: '" +
255 Twine(AsmStr) + "'");
256
257 Modifier[0] = *LastEmitted;
258 ++LastEmitted; // Consume modifier character.
259 }
260
261 if (*LastEmitted != '}')
262 report_fatal_error("Bad ${} expression in inline asm string: '" +
263 Twine(AsmStr) + "'");
264 ++LastEmitted; // Consume '}' character.
265 }
266
267 // Okay, we finally have a value number. Ask the target to print this
268 // operand!
269 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
270 unsigned OpNo = InlineAsm::MIOp_FirstOperand;
271
272 bool Error = false;
273
274 // Scan to find the machine operand number for the operand.
275 for (; Val; --Val) {
276 if (OpNo >= MI->getNumOperands())
277 break;
278 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
279 OpNo += F.getNumOperandRegisters() + 1;
280 }
281
282 // We may have a location metadata attached to the end of the
283 // instruction, and at no point should see metadata at any
284 // other point while processing. It's an error if so.
285 if (OpNo >= MI->getNumOperands() || MI->getOperand(OpNo).isMetadata()) {
286 Error = true;
287 } else {
288 const InlineAsm::Flag F(MI->getOperand(OpNo).getImm());
289 ++OpNo; // Skip over the ID number.
290
291 // FIXME: Shouldn't arch-independent output template handling go into
292 // PrintAsmOperand?
293 // Labels are target independent.
294 if (MI->getOperand(OpNo).isBlockAddress()) {
295 const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
297 Sym->print(OS, AP->MAI);
299 } else if (MI->getOperand(OpNo).isMBB()) {
300 const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
301 Sym->print(OS, AP->MAI);
302 } else if (F.isMemKind()) {
304 MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
305 } else {
306 Error = AP->PrintAsmOperand(MI, OpNo,
307 Modifier[0] ? Modifier : nullptr, OS);
308 }
309 }
310 if (Error) {
311 std::string msg;
312 raw_string_ostream Msg(msg);
313 Msg << "invalid operand in inline asm: '" << AsmStr << "'";
314 MMI->getModule()->getContext().emitError(LocCookie, Msg.str());
315 }
316 }
317 break;
318 }
319 }
320 }
321 if (InputIsIntelDialect)
322 OS << "\n\t.att_syntax";
323 OS << '\n' << (char)0; // null terminate string.
324}
325
326/// This method formats and emits the specified machine instruction that is an
327/// inline asm.
328void AsmPrinter::emitInlineAsm(const MachineInstr *MI) const {
329 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms");
330
331 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
332 const char *AsmStr = MI->getOperand(0).getSymbolName();
333
334 // If this asmstr is empty, just print the #APP/#NOAPP markers.
335 // These are useful to see where empty asm's wound up.
336 if (AsmStr[0] == 0) {
337 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
338 OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
339 return;
340 }
341
342 // Emit the #APP start marker. This has to happen even if verbose-asm isn't
343 // enabled, so we use emitRawComment.
344 OutStreamer->emitRawComment(MAI->getInlineAsmStart());
345
346 // Get the !srcloc metadata node if we have it, and decode the loc cookie from
347 // it.
348 uint64_t LocCookie = 0;
349 const MDNode *LocMD = nullptr;
350 for (const MachineOperand &MO : llvm::reverse(MI->operands())) {
351 if (MO.isMetadata() && (LocMD = MO.getMetadata()) &&
352 LocMD->getNumOperands() != 0) {
353 if (const ConstantInt *CI =
354 mdconst::dyn_extract<ConstantInt>(LocMD->getOperand(0))) {
355 LocCookie = CI->getZExtValue();
356 break;
357 }
358 }
359 }
360
361 // Emit the inline asm to a temporary string so we can emit it through
362 // EmitInlineAsm.
365
366 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
367 EmitInlineAsmStr(AsmStr, MI, MMI, MAI, AP, LocCookie, OS);
368
369 // Emit warnings if we use reserved registers on the clobber list, as
370 // that might lead to undefined behaviour.
371 SmallVector<Register, 8> RestrRegs;
373 // Start with the first operand descriptor, and iterate over them.
374 for (unsigned I = InlineAsm::MIOp_FirstOperand, NumOps = MI->getNumOperands();
375 I < NumOps; ++I) {
376 const MachineOperand &MO = MI->getOperand(I);
377 if (!MO.isImm())
378 continue;
379 const InlineAsm::Flag F(MO.getImm());
380 if (F.isClobberKind()) {
381 Register Reg = MI->getOperand(I + 1).getReg();
382 if (!TRI->isAsmClobberable(*MF, Reg))
383 RestrRegs.push_back(Reg);
384 }
385 // Skip to one before the next operand descriptor, if it exists.
386 I += F.getNumOperandRegisters();
387 }
388
389 if (!RestrRegs.empty()) {
390 std::string Msg = "inline asm clobber list contains reserved registers: ";
391 ListSeparator LS;
392 for (const Register RR : RestrRegs) {
393 Msg += LS;
394 Msg += TRI->getRegAsmName(RR);
395 }
396 const char *Note =
397 "Reserved registers on the clobber list may not be "
398 "preserved across the asm statement, and clobbering them may "
399 "lead to undefined behaviour.";
401 LocCookie, Msg, DiagnosticSeverity::DS_Warning));
404
405 for (const Register RR : RestrRegs) {
406 if (std::optional<std::string> reason =
407 TRI->explainReservedReg(*MF, RR)) {
409 LocCookie, *reason, DiagnosticSeverity::DS_Note));
410 }
411 }
412 }
413
414 emitInlineAsm(OS.str(), 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 {}
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
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned const TargetRegisterInfo * TRI
Module.h This file contains the declarations for the Module class.
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:85
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:88
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:91
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:103
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:395
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:708
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:106
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:95
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:100
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:414
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:890
This is the shared class of boolean and integer constants.
Definition: Constants.h:81
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Diagnostic information for inline asm reporting.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void emitError(uint64_t LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
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:677
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
Definition: MCAsmInfo.h:842
const char * getInlineAsmEnd() const
Definition: MCAsmInfo.h:678
StringRef getCommentString() const
Definition: MCAsmInfo.h:651
bool getEmitGNUAsmStartIndentationMarker() const
Definition: MCAsmInfo.h:656
bool parseInlineAsmUsingAsmParser() const
Return true if target want to use AsmParser to parse inlineasm.
Definition: MCAsmInfo.h:845
Context object for machine code objects.
Definition: MCContext.h:81
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
Definition: MCContext.cpp:375
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:40
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:1067
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1428
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1434
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.
Representation of each machine instruction.
Definition: MachineInstr.h:69
This class contains meta information specific to a module.
const MCContext & getContext() const
const Module * getModule() const
const LLVMTargetMachine & 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.
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:301
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:94
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
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:50
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.
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
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:419
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:159
MCAsmParser * createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &, unsigned CB=0)
Create an MCAsmParser instance for parsing assembly similar to gas syntax.
Definition: AsmParser.cpp:6452
@ DS_Warning