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