LLVM  6.0.0svn
X86AsmPrinter.cpp
Go to the documentation of this file.
1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to X86 machine code.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "X86AsmPrinter.h"
18 #include "X86InstrInfo.h"
19 #include "X86MachineFunctionInfo.h"
20 #include "llvm/BinaryFormat/COFF.h"
25 #include "llvm/IR/DebugInfo.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Mangler.h"
28 #include "llvm/IR/Module.h"
29 #include "llvm/IR/Type.h"
30 #include "llvm/MC/MCAsmInfo.h"
31 #include "llvm/MC/MCCodeEmitter.h"
32 #include "llvm/MC/MCContext.h"
33 #include "llvm/MC/MCExpr.h"
34 #include "llvm/MC/MCSectionCOFF.h"
35 #include "llvm/MC/MCSectionMachO.h"
36 #include "llvm/MC/MCStreamer.h"
37 #include "llvm/MC/MCSymbol.h"
38 #include "llvm/Support/Debug.h"
41 using namespace llvm;
42 
43 //===----------------------------------------------------------------------===//
44 // Primitive Helper Functions.
45 //===----------------------------------------------------------------------===//
46 
47 /// runOnMachineFunction - Emit the function body.
48 ///
50  Subtarget = &MF.getSubtarget<X86Subtarget>();
51 
52  SMShadowTracker.startFunction(MF);
53  CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(
55  MF.getContext()));
56 
58 
59  if (Subtarget->isTargetCOFF()) {
60  bool Local = MF.getFunction()->hasLocalLinkage();
61  OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
62  OutStreamer->EmitCOFFSymbolStorageClass(
66  OutStreamer->EndCOFFSymbolDef();
67  }
68 
69  // Emit the rest of the function body.
71 
72  // Emit the XRay table for this function.
73  emitXRayTable();
74 
75  // We didn't modify anything.
76  return false;
77 }
78 
79 /// printSymbolOperand - Print a raw symbol reference operand. This handles
80 /// jump tables, constant pools, global address and external symbols, all of
81 /// which print to a label with various suffixes for relocation types etc.
83  raw_ostream &O) {
84  switch (MO.getType()) {
85  default: llvm_unreachable("unknown symbol type!");
87  P.GetCPISymbol(MO.getIndex())->print(O, P.MAI);
88  P.printOffset(MO.getOffset(), O);
89  break;
91  const GlobalValue *GV = MO.getGlobal();
92 
93  MCSymbol *GVSym;
96  GVSym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
97  else
98  GVSym = P.getSymbol(GV);
99 
100  // Handle dllimport linkage.
102  GVSym =
103  P.OutContext.getOrCreateSymbol(Twine("__imp_") + GVSym->getName());
104 
107  MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
109  P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
110  if (!StubSym.getPointer())
111  StubSym = MachineModuleInfoImpl::
112  StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
113  }
114 
115  // If the name begins with a dollar-sign, enclose it in parens. We do this
116  // to avoid having it look like an integer immediate to the assembler.
117  if (GVSym->getName()[0] != '$')
118  GVSym->print(O, P.MAI);
119  else {
120  O << '(';
121  GVSym->print(O, P.MAI);
122  O << ')';
123  }
124  P.printOffset(MO.getOffset(), O);
125  break;
126  }
127  }
128 
129  switch (MO.getTargetFlags()) {
130  default:
131  llvm_unreachable("Unknown target flag on GV operand");
132  case X86II::MO_NO_FLAG: // No flag.
133  break;
135  case X86II::MO_DLLIMPORT:
136  // These affect the name of the symbol, not any suffix.
137  break;
139  O << " + [.-";
140  P.MF->getPICBaseSymbol()->print(O, P.MAI);
141  O << ']';
142  break;
145  O << '-';
146  P.MF->getPICBaseSymbol()->print(O, P.MAI);
147  break;
148  case X86II::MO_TLSGD: O << "@TLSGD"; break;
149  case X86II::MO_TLSLD: O << "@TLSLD"; break;
150  case X86II::MO_TLSLDM: O << "@TLSLDM"; break;
151  case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
152  case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
153  case X86II::MO_TPOFF: O << "@TPOFF"; break;
154  case X86II::MO_DTPOFF: O << "@DTPOFF"; break;
155  case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
156  case X86II::MO_GOTNTPOFF: O << "@GOTNTPOFF"; break;
157  case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
158  case X86II::MO_GOT: O << "@GOT"; break;
159  case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
160  case X86II::MO_PLT: O << "@PLT"; break;
161  case X86II::MO_TLVP: O << "@TLVP"; break;
163  O << "@TLVP" << '-';
164  P.MF->getPICBaseSymbol()->print(O, P.MAI);
165  break;
166  case X86II::MO_SECREL: O << "@SECREL32"; break;
167  }
168 }
169 
170 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
171  unsigned OpNo, raw_ostream &O,
172  const char *Modifier = nullptr, unsigned AsmVariant = 0);
173 
174 /// printPCRelImm - This is used to print an immediate value that ends up
175 /// being encoded as a pc-relative value. These print slightly differently, for
176 /// example, a $ is not emitted.
177 static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI,
178  unsigned OpNo, raw_ostream &O) {
179  const MachineOperand &MO = MI->getOperand(OpNo);
180  switch (MO.getType()) {
181  default: llvm_unreachable("Unknown pcrel immediate operand");
183  // pc-relativeness was handled when computing the value in the reg.
184  printOperand(P, MI, OpNo, O);
185  return;
187  O << MO.getImm();
188  return;
190  printSymbolOperand(P, MO, O);
191  return;
192  }
193 }
194 
195 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
196  unsigned OpNo, raw_ostream &O, const char *Modifier,
197  unsigned AsmVariant) {
198  const MachineOperand &MO = MI->getOperand(OpNo);
199  switch (MO.getType()) {
200  default: llvm_unreachable("unknown operand type!");
202  // FIXME: Enumerating AsmVariant, so we can remove magic number.
203  if (AsmVariant == 0) O << '%';
204  unsigned Reg = MO.getReg();
205  if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
206  unsigned Size = (strcmp(Modifier+6,"64") == 0) ? 64 :
207  (strcmp(Modifier+6,"32") == 0) ? 32 :
208  (strcmp(Modifier+6,"16") == 0) ? 16 : 8;
209  Reg = getX86SubSuperRegister(Reg, Size);
210  }
212  return;
213  }
214 
216  if (AsmVariant == 0) O << '$';
217  O << MO.getImm();
218  return;
219 
221  if (AsmVariant == 0) O << '$';
222  printSymbolOperand(P, MO, O);
223  break;
224  }
225  }
226 }
227 
229  unsigned Op, raw_ostream &O,
230  const char *Modifier = nullptr) {
231  const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
232  const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
233  const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
234 
235  // If we really don't want to print out (rip), don't.
236  bool HasBaseReg = BaseReg.getReg() != 0;
237  if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
238  BaseReg.getReg() == X86::RIP)
239  HasBaseReg = false;
240 
241  // HasParenPart - True if we will print out the () part of the mem ref.
242  bool HasParenPart = IndexReg.getReg() || HasBaseReg;
243 
244  switch (DispSpec.getType()) {
245  default:
246  llvm_unreachable("unknown operand type!");
248  int DispVal = DispSpec.getImm();
249  if (DispVal || !HasParenPart)
250  O << DispVal;
251  break;
252  }
255  printSymbolOperand(P, DispSpec, O);
256  }
257 
258  if (Modifier && strcmp(Modifier, "H") == 0)
259  O << "+8";
260 
261  if (HasParenPart) {
262  assert(IndexReg.getReg() != X86::ESP &&
263  "X86 doesn't allow scaling by ESP");
264 
265  O << '(';
266  if (HasBaseReg)
267  printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier);
268 
269  if (IndexReg.getReg()) {
270  O << ',';
271  printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier);
272  unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
273  if (ScaleVal != 1)
274  O << ',' << ScaleVal;
275  }
276  O << ')';
277  }
278 }
279 
280 static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI,
281  unsigned Op, raw_ostream &O,
282  const char *Modifier = nullptr) {
283  assert(isMem(*MI, Op) && "Invalid memory reference!");
284  const MachineOperand &Segment = MI->getOperand(Op+X86::AddrSegmentReg);
285  if (Segment.getReg()) {
286  printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier);
287  O << ':';
288  }
289  printLeaMemReference(P, MI, Op, O, Modifier);
290 }
291 
293  unsigned Op, raw_ostream &O,
294  const char *Modifier = nullptr,
295  unsigned AsmVariant = 1) {
296  const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
297  unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
298  const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
299  const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
300  const MachineOperand &SegReg = MI->getOperand(Op+X86::AddrSegmentReg);
301 
302  // If this has a segment register, print it.
303  if (SegReg.getReg()) {
304  printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier, AsmVariant);
305  O << ':';
306  }
307 
308  O << '[';
309 
310  bool NeedPlus = false;
311  if (BaseReg.getReg()) {
312  printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier, AsmVariant);
313  NeedPlus = true;
314  }
315 
316  if (IndexReg.getReg()) {
317  if (NeedPlus) O << " + ";
318  if (ScaleVal != 1)
319  O << ScaleVal << '*';
320  printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier, AsmVariant);
321  NeedPlus = true;
322  }
323 
324  if (!DispSpec.isImm()) {
325  if (NeedPlus) O << " + ";
326  printOperand(P, MI, Op+X86::AddrDisp, O, Modifier, AsmVariant);
327  } else {
328  int64_t DispVal = DispSpec.getImm();
329  if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
330  if (NeedPlus) {
331  if (DispVal > 0)
332  O << " + ";
333  else {
334  O << " - ";
335  DispVal = -DispVal;
336  }
337  }
338  O << DispVal;
339  }
340  }
341  O << ']';
342 }
343 
345  char Mode, raw_ostream &O) {
346  unsigned Reg = MO.getReg();
347  switch (Mode) {
348  default: return true; // Unknown mode.
349  case 'b': // Print QImode register
350  Reg = getX86SubSuperRegister(Reg, 8);
351  break;
352  case 'h': // Print QImode high register
353  Reg = getX86SubSuperRegister(Reg, 8, true);
354  break;
355  case 'w': // Print HImode register
356  Reg = getX86SubSuperRegister(Reg, 16);
357  break;
358  case 'k': // Print SImode register
359  Reg = getX86SubSuperRegister(Reg, 32);
360  break;
361  case 'q':
362  // Print 64-bit register names if 64-bit integer registers are available.
363  // Otherwise, print 32-bit register names.
364  Reg = getX86SubSuperRegister(Reg, P.getSubtarget().is64Bit() ? 64 : 32);
365  break;
366  }
367 
368  O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
369  return false;
370 }
371 
372 /// PrintAsmOperand - Print out an operand for an inline asm expression.
373 ///
374 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
375  unsigned AsmVariant,
376  const char *ExtraCode, raw_ostream &O) {
377  // Does this asm operand have a single letter operand modifier?
378  if (ExtraCode && ExtraCode[0]) {
379  if (ExtraCode[1] != 0) return true; // Unknown modifier.
380 
381  const MachineOperand &MO = MI->getOperand(OpNo);
382 
383  switch (ExtraCode[0]) {
384  default:
385  // See if this is a generic print operand
386  return AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, O);
387  case 'a': // This is an address. Currently only 'i' and 'r' are expected.
388  switch (MO.getType()) {
389  default:
390  return true;
392  O << MO.getImm();
393  return false;
397  llvm_unreachable("unexpected operand type!");
399  printSymbolOperand(*this, MO, O);
400  if (Subtarget->isPICStyleRIPRel())
401  O << "(%rip)";
402  return false;
404  O << '(';
405  printOperand(*this, MI, OpNo, O);
406  O << ')';
407  return false;
408  }
409 
410  case 'c': // Don't print "$" before a global var name or constant.
411  switch (MO.getType()) {
412  default:
413  printOperand(*this, MI, OpNo, O);
414  break;
416  O << MO.getImm();
417  break;
421  llvm_unreachable("unexpected operand type!");
423  printSymbolOperand(*this, MO, O);
424  break;
425  }
426  return false;
427 
428  case 'A': // Print '*' before a register (it must be a register)
429  if (MO.isReg()) {
430  O << '*';
431  printOperand(*this, MI, OpNo, O);
432  return false;
433  }
434  return true;
435 
436  case 'b': // Print QImode register
437  case 'h': // Print QImode high register
438  case 'w': // Print HImode register
439  case 'k': // Print SImode register
440  case 'q': // Print DImode register
441  if (MO.isReg())
442  return printAsmMRegister(*this, MO, ExtraCode[0], O);
443  printOperand(*this, MI, OpNo, O);
444  return false;
445 
446  case 'P': // This is the operand of a call, treat specially.
447  printPCRelImm(*this, MI, OpNo, O);
448  return false;
449 
450  case 'n': // Negate the immediate or print a '-' before the operand.
451  // Note: this is a temporary solution. It should be handled target
452  // independently as part of the 'MC' work.
453  if (MO.isImm()) {
454  O << -MO.getImm();
455  return false;
456  }
457  O << '-';
458  }
459  }
460 
461  printOperand(*this, MI, OpNo, O, /*Modifier*/ nullptr, AsmVariant);
462  return false;
463 }
464 
466  unsigned OpNo, unsigned AsmVariant,
467  const char *ExtraCode,
468  raw_ostream &O) {
469  if (AsmVariant) {
470  printIntelMemReference(*this, MI, OpNo, O);
471  return false;
472  }
473 
474  if (ExtraCode && ExtraCode[0]) {
475  if (ExtraCode[1] != 0) return true; // Unknown modifier.
476 
477  switch (ExtraCode[0]) {
478  default: return true; // Unknown modifier.
479  case 'b': // Print QImode register
480  case 'h': // Print QImode high register
481  case 'w': // Print HImode register
482  case 'k': // Print SImode register
483  case 'q': // Print SImode register
484  // These only apply to registers, ignore on mem.
485  break;
486  case 'H':
487  printMemReference(*this, MI, OpNo, O, "H");
488  return false;
489  case 'P': // Don't print @PLT, but do print as memory.
490  printMemReference(*this, MI, OpNo, O, "no-rip");
491  return false;
492  }
493  }
494  printMemReference(*this, MI, OpNo, O);
495  return false;
496 }
497 
499  const Triple &TT = TM.getTargetTriple();
500 
501  if (TT.isOSBinFormatMachO())
502  OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
503 
504  if (TT.isOSBinFormatCOFF()) {
505  // Emit an absolute @feat.00 symbol. This appears to be some kind of
506  // compiler features bitfield read by link.exe.
507  if (TT.getArch() == Triple::x86) {
508  MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
509  OutStreamer->BeginCOFFSymbolDef(S);
510  OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
511  OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
512  OutStreamer->EndCOFFSymbolDef();
513  // According to the PE-COFF spec, the LSB of this value marks the object
514  // for "registered SEH". This means that all SEH handler entry points
515  // must be registered in .sxdata. Use of any unregistered handlers will
516  // cause the process to terminate immediately. LLVM does not know how to
517  // register any SEH handlers, so its object files should be safe.
518  OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
519  OutStreamer->EmitAssignment(
520  S, MCConstantExpr::create(int64_t(1), MMI->getContext()));
521  }
522  }
523  OutStreamer->EmitSyntaxDirective();
524 
525  // If this is not inline asm and we're in 16-bit
526  // mode prefix assembly with .code16.
527  bool is16 = TT.getEnvironment() == Triple::CODE16;
528  if (M.getModuleInlineAsm().empty() && is16)
529  OutStreamer->EmitAssemblerFlag(MCAF_Code16);
530 }
531 
532 static void
535  // L_foo$stub:
536  OutStreamer.EmitLabel(StubLabel);
537  // .indirect_symbol _foo
538  OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
539 
540  if (MCSym.getInt())
541  // External to current translation unit.
542  OutStreamer.EmitIntValue(0, 4/*size*/);
543  else
544  // Internal to current translation unit.
545  //
546  // When we place the LSDA into the TEXT section, the type info
547  // pointers need to be indirect and pc-rel. We accomplish this by
548  // using NLPs; however, sometimes the types are local to the file.
549  // We need to fill in the value for the NLP in those cases.
550  OutStreamer.EmitValue(
551  MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
552  4 /*size*/);
553 }
554 
555 MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
556  if (Subtarget->isTargetKnownWindowsMSVC()) {
557  const MachineConstantPoolEntry &CPE =
558  MF->getConstantPool()->getConstants()[CPID];
559  if (!CPE.isMachineConstantPoolEntry()) {
560  const DataLayout &DL = MF->getDataLayout();
561  SectionKind Kind = CPE.getSectionKind(&DL);
562  const Constant *C = CPE.Val.ConstVal;
563  unsigned Align = CPE.Alignment;
564  if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
565  getObjFileLowering().getSectionForConstant(DL, Kind, C, Align))) {
566  if (MCSymbol *Sym = S->getCOMDATSymbol()) {
567  if (Sym->isUndefined())
568  OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
569  return Sym;
570  }
571  }
572  }
573  }
574 
575  return AsmPrinter::GetCPISymbol(CPID);
576 }
577 
579  const Triple &TT = TM.getTargetTriple();
580 
581  if (TT.isOSBinFormatMachO()) {
582  // All darwin targets use mach-o.
583  MachineModuleInfoMachO &MMIMacho =
585 
586  // Output stubs for dynamically-linked functions.
588 
589  // Output stubs for external and common global variables.
590  Stubs = MMIMacho.GetGVStubList();
591  if (!Stubs.empty()) {
592  MCSection *TheSection = OutContext.getMachOSection(
593  "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS,
595  OutStreamer->SwitchSection(TheSection);
596 
597  for (auto &Stub : Stubs)
598  emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
599 
600  Stubs.clear();
601  OutStreamer->AddBlankLine();
602  }
603 
606 
607  // Funny Darwin hack: This flag tells the linker that no global symbols
608  // contain code that falls through to other global symbols (e.g. the obvious
609  // implementation of multiple entry points). If this doesn't occur, the
610  // linker can safely perform dead code stripping. Since LLVM never
611  // generates code that does this, it is always safe to set.
612  OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
613  }
614 
616  StringRef SymbolName =
617  (TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused";
618  MCSymbol *S = MMI->getContext().getOrCreateSymbol(SymbolName);
619  OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
620  }
621 
622  if (TT.isOSBinFormatCOFF()) {
623  const TargetLoweringObjectFileCOFF &TLOFCOFF =
624  static_cast<const TargetLoweringObjectFileCOFF&>(getObjFileLowering());
625 
626  std::string Flags;
627  raw_string_ostream FlagsOS(Flags);
628 
629  for (const auto &Function : M)
630  TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Function);
631  for (const auto &Global : M.globals())
632  TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Global);
633  for (const auto &Alias : M.aliases())
634  TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Alias);
635 
636  FlagsOS.flush();
637 
638  // Output collected flags.
639  if (!Flags.empty()) {
640  OutStreamer->SwitchSection(TLOFCOFF.getDrectveSection());
641  OutStreamer->EmitBytes(Flags);
642  }
643 
645  }
646 
647  if (TT.isOSBinFormatELF()) {
650  }
651 }
652 
653 //===----------------------------------------------------------------------===//
654 // Target Registry Stuff
655 //===----------------------------------------------------------------------===//
656 
657 // Force static initialization.
658 extern "C" void LLVMInitializeX86AsmPrinter() {
661 }
unsigned getTargetFlags() const
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
Definition: X86BaseInfo.h:215
uint64_t CallInst * C
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:193
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
Definition: X86Subtarget.h:415
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition: MachO.h:132
static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void LLVMInitializeX86AsmPrinter()
bool hasLocalLinkage() const
Definition: GlobalValue.h:416
static const char * getRegisterName(unsigned RegNo)
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:93
SI Whole Quad Mode
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:305
struct fuzzer::@309 Flags
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
PointerTy getPointer() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV) const override
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:123
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
Definition: X86BaseInfo.h:209
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:580
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:88
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
unsigned getReg() const
getReg - Returns the register number.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - Emit the function body.
Address of indexed Jump Table for switch.
const MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:96
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
Definition: X86BaseInfo.h:97
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:166
static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, raw_ostream &O)
printSymbolOperand - Print a raw symbol reference operand.
bool isTargetKnownWindowsMSVC() const
Definition: X86Subtarget.h:571
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
This represents a section on Windows.
Definition: MCSectionCOFF.h:27
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
MCContext & getContext() const
Definition: MCStreamer.h:227
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
Definition: X86BaseInfo.h:197
static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
printPCRelImm - This is used to print an immediate value that ends up being encoded as a pc-relative ...
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
bool isPICStyleRIPRel() const
Definition: X86Subtarget.h:604
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
No complex type; simple scalar variable.
Definition: COFF.h:257
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Definition: Triple.h:522
Name of external global symbol.
Reg
All possible values of the reg field in the ModR/M byte.
static bool isMem(const MachineInstr &MI, unsigned Op)
Definition: X86InstrInfo.h:137
void emitXRayTable()
Emit a table with all XRay instrumentation points.
void EmitFunctionBody()
This method emits the body and trailer for a function.
Definition: AsmPrinter.cpp:971
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:51
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
Definition: MCContext.cpp:271
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
Definition: X86BaseInfo.h:82
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:283
IntType getInt() const
const MCContext & getContext() const
static void printLeaMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr)
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
Definition: X86BaseInfo.h:141
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
This class is a data container for one entry in a MachineConstantPool.
virtual const TargetInstrInfo * getInstrInfo() const
static void printOperand(X86AsmPrinter &P, const MachineInstr *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=nullptr, unsigned AsmVariant=0)
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Definition: MCStreamer.cpp:93
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
Definition: X86BaseInfo.h:192
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:128
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:99
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
MCContext & getContext() const
#define P(N)
Address of a global value.
Streaming machine code generation interface.
Definition: MCStreamer.h:168
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:107
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [...
Definition: X86BaseInfo.h:70
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:84
PointerIntPair - This class implements a pair of a pointer and small integer.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Definition: Triple.h:585
MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...
Definition: X86BaseInfo.h:182
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
Definition: X86BaseInfo.h:203
This is an important base class in LLVM.
Definition: Constant.h:42
const GlobalValue * getGlobal() const
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:133
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition: COFF.h:263
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:80
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
bool hasInternalLinkage() const
Definition: GlobalValue.h:414
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:50
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
A function that returns a base type.
Definition: COFF.h:259
const Triple & getTargetTriple() const
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
Definition: X86BaseInfo.h:174
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:590
const Target & getTarget() const
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:113
MCSection * getDrectveSection() const
void serializeToStackMapSection()
If there is any stack map data, create a stack map section and serialize the map info into it...
Definition: StackMaps.cpp:550
const std::vector< MachineConstantPoolEntry > & getConstants() const
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
Definition: X86BaseInfo.h:158
unsigned Alignment
The required alignment for this entry.
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:422
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:50
MachineOperand class - Representation of each machine instruction operand.
Module.h This file contains the declarations for the Module class.
void EmitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
.indirect_symbol (MachO)
Definition: MCDirectives.h:32
static SectionKind getMetadata()
Definition: SectionKind.h:179
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:301
int64_t getImm() const
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MCSymbol * GetCPISymbol(unsigned CPID) const override
Return the symbol for the specified constant pool entry.
static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr)
Representation of each machine instruction.
Definition: MachineInstr.h:59
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
Definition: X86BaseInfo.h:89
void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
Definition: X86BaseInfo.h:150
.type _foo,
Definition: MCDirectives.h:30
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:121
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr, unsigned AsmVariant=1)
int64_t getOffset() const
Return the offset from the symbol in this operand.
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
SectionKind getSectionKind(const DataLayout *DL) const
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
Definition: Pass.cpp:123
bool isTargetCOFF() const
Definition: X86Subtarget.h:554
Target & getTheX86_32Target()
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
Definition: X86BaseInfo.h:104
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Definition: Module.h:241
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:203
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
const unsigned Kind
AddrSegmentReg - The operand # of the segment in the memory operand.
Definition: X86BaseInfo.h:39
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:466
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:308
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
Definition: X86BaseInfo.h:75
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Address of indexed Constant in Constant Pool.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:284
Target & getTheX86_64Target()
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
union llvm::MachineConstantPoolEntry::@136 Val
The constant itself.
This class can be derived from and used by targets to hold private target-specific information for ea...
const X86Subtarget & getSubtarget() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:159
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
Definition: X86BaseInfo.h:187
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:59