LLVM  15.0.0git
X86AsmPrinter.cpp
Go to the documentation of this file.
1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
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 contains a printer that converts from our internal representation
10 // of machine-dependent LLVM code to X86 machine code.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "X86AsmPrinter.h"
19 #include "X86InstrInfo.h"
20 #include "X86MachineFunctionInfo.h"
21 #include "X86Subtarget.h"
22 #include "llvm/BinaryFormat/COFF.h"
23 #include "llvm/BinaryFormat/ELF.h"
27 #include "llvm/IR/DerivedTypes.h"
28 #include "llvm/IR/InlineAsm.h"
29 #include "llvm/IR/Mangler.h"
30 #include "llvm/IR/Module.h"
31 #include "llvm/IR/Type.h"
32 #include "llvm/MC/MCAsmInfo.h"
33 #include "llvm/MC/MCCodeEmitter.h"
34 #include "llvm/MC/MCContext.h"
35 #include "llvm/MC/MCExpr.h"
36 #include "llvm/MC/MCSectionCOFF.h"
37 #include "llvm/MC/MCSectionELF.h"
38 #include "llvm/MC/MCSectionMachO.h"
39 #include "llvm/MC/MCStreamer.h"
40 #include "llvm/MC/MCSymbol.h"
41 #include "llvm/MC/TargetRegistry.h"
42 #include "llvm/Support/Debug.h"
46 
47 using namespace llvm;
48 
50  std::unique_ptr<MCStreamer> Streamer)
51  : AsmPrinter(TM, std::move(Streamer)), SM(*this), FM(*this) {}
52 
53 //===----------------------------------------------------------------------===//
54 // Primitive Helper Functions.
55 //===----------------------------------------------------------------------===//
56 
57 /// runOnMachineFunction - Emit the function body.
58 ///
60  Subtarget = &MF.getSubtarget<X86Subtarget>();
61 
62  SMShadowTracker.startFunction(MF);
63  CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(
64  *Subtarget->getInstrInfo(), MF.getContext()));
65 
66  EmitFPOData =
67  Subtarget->isTargetWin32() && MF.getMMI().getModule()->getCodeViewFlag();
68 
70 
71  if (Subtarget->isTargetCOFF()) {
72  bool Local = MF.getFunction().hasLocalLinkage();
73  OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
74  OutStreamer->emitCOFFSymbolStorageClass(
78  OutStreamer->EndCOFFSymbolDef();
79  }
80 
81  // Emit the rest of the function body.
83 
84  // Emit the XRay table for this function.
85  emitXRayTable();
86 
87  EmitFPOData = false;
88 
89  // We didn't modify anything.
90  return false;
91 }
92 
94  if (EmitFPOData) {
95  if (auto *XTS =
96  static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
97  XTS->emitFPOProc(
100  }
101 }
102 
104  if (EmitFPOData) {
105  if (auto *XTS =
106  static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
107  XTS->emitFPOEndProc();
108  }
109 }
110 
111 /// PrintSymbolOperand - Print a raw symbol reference operand. This handles
112 /// jump tables, constant pools, global address and external symbols, all of
113 /// which print to a label with various suffixes for relocation types etc.
114 void X86AsmPrinter::PrintSymbolOperand(const MachineOperand &MO,
115  raw_ostream &O) {
116  switch (MO.getType()) {
117  default: llvm_unreachable("unknown symbol type!");
119  GetCPISymbol(MO.getIndex())->print(O, MAI);
120  printOffset(MO.getOffset(), O);
121  break;
123  const GlobalValue *GV = MO.getGlobal();
124 
125  MCSymbol *GVSym;
128  GVSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
129  else
130  GVSym = getSymbolPreferLocal(*GV);
131 
132  // Handle dllimport linkage.
134  GVSym = OutContext.getOrCreateSymbol(Twine("__imp_") + GVSym->getName());
135  else if (MO.getTargetFlags() == X86II::MO_COFFSTUB)
136  GVSym =
137  OutContext.getOrCreateSymbol(Twine(".refptr.") + GVSym->getName());
138 
141  MCSymbol *Sym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
143  MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
144  if (!StubSym.getPointer())
146  !GV->hasInternalLinkage());
147  }
148 
149  // If the name begins with a dollar-sign, enclose it in parens. We do this
150  // to avoid having it look like an integer immediate to the assembler.
151  if (GVSym->getName()[0] != '$')
152  GVSym->print(O, MAI);
153  else {
154  O << '(';
155  GVSym->print(O, MAI);
156  O << ')';
157  }
158  printOffset(MO.getOffset(), O);
159  break;
160  }
161  }
162 
163  switch (MO.getTargetFlags()) {
164  default:
165  llvm_unreachable("Unknown target flag on GV operand");
166  case X86II::MO_NO_FLAG: // No flag.
167  break;
169  case X86II::MO_DLLIMPORT:
170  case X86II::MO_COFFSTUB:
171  // These affect the name of the symbol, not any suffix.
172  break;
174  O << " + [.-";
175  MF->getPICBaseSymbol()->print(O, MAI);
176  O << ']';
177  break;
180  O << '-';
181  MF->getPICBaseSymbol()->print(O, MAI);
182  break;
183  case X86II::MO_TLSGD: O << "@TLSGD"; break;
184  case X86II::MO_TLSLD: O << "@TLSLD"; break;
185  case X86II::MO_TLSLDM: O << "@TLSLDM"; break;
186  case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
187  case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
188  case X86II::MO_TPOFF: O << "@TPOFF"; break;
189  case X86II::MO_DTPOFF: O << "@DTPOFF"; break;
190  case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
191  case X86II::MO_GOTNTPOFF: O << "@GOTNTPOFF"; break;
192  case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
193  case X86II::MO_GOTPCREL_NORELAX: O << "@GOTPCREL_NORELAX"; break;
194  case X86II::MO_GOT: O << "@GOT"; break;
195  case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
196  case X86II::MO_PLT: O << "@PLT"; break;
197  case X86II::MO_TLVP: O << "@TLVP"; break;
199  O << "@TLVP" << '-';
200  MF->getPICBaseSymbol()->print(O, MAI);
201  break;
202  case X86II::MO_SECREL: O << "@SECREL32"; break;
203  }
204 }
205 
206 void X86AsmPrinter::PrintOperand(const MachineInstr *MI, unsigned OpNo,
207  raw_ostream &O) {
208  const MachineOperand &MO = MI->getOperand(OpNo);
209  const bool IsATT = MI->getInlineAsmDialect() == InlineAsm::AD_ATT;
210  switch (MO.getType()) {
211  default: llvm_unreachable("unknown operand type!");
213  if (IsATT)
214  O << '%';
216  return;
217  }
218 
220  if (IsATT)
221  O << '$';
222  O << MO.getImm();
223  return;
224 
227  switch (MI->getInlineAsmDialect()) {
228  case InlineAsm::AD_ATT:
229  O << '$';
230  break;
231  case InlineAsm::AD_Intel:
232  O << "offset ";
233  break;
234  }
235  PrintSymbolOperand(MO, O);
236  break;
237  }
240  Sym->print(O, MAI);
241  break;
242  }
243  }
244 }
245 
246 /// PrintModifiedOperand - Print subregisters based on supplied modifier,
247 /// deferring to PrintOperand() if no modifier was supplied or if operand is not
248 /// a register.
249 void X86AsmPrinter::PrintModifiedOperand(const MachineInstr *MI, unsigned OpNo,
250  raw_ostream &O, const char *Modifier) {
251  const MachineOperand &MO = MI->getOperand(OpNo);
252  if (!Modifier || MO.getType() != MachineOperand::MO_Register)
253  return PrintOperand(MI, OpNo, O);
254  if (MI->getInlineAsmDialect() == InlineAsm::AD_ATT)
255  O << '%';
256  Register Reg = MO.getReg();
257  if (strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
258  unsigned Size = (strcmp(Modifier+6,"64") == 0) ? 64 :
259  (strcmp(Modifier+6,"32") == 0) ? 32 :
260  (strcmp(Modifier+6,"16") == 0) ? 16 : 8;
261  Reg = getX86SubSuperRegister(Reg, Size);
262  }
264 }
265 
266 /// PrintPCRelImm - This is used to print an immediate value that ends up
267 /// being encoded as a pc-relative value. These print slightly differently, for
268 /// example, a $ is not emitted.
269 void X86AsmPrinter::PrintPCRelImm(const MachineInstr *MI, unsigned OpNo,
270  raw_ostream &O) {
271  const MachineOperand &MO = MI->getOperand(OpNo);
272  switch (MO.getType()) {
273  default: llvm_unreachable("Unknown pcrel immediate operand");
275  // pc-relativeness was handled when computing the value in the reg.
276  PrintOperand(MI, OpNo, O);
277  return;
279  O << MO.getImm();
280  return;
282  PrintSymbolOperand(MO, O);
283  return;
284  }
285 }
286 
287 void X86AsmPrinter::PrintLeaMemReference(const MachineInstr *MI, unsigned OpNo,
288  raw_ostream &O, const char *Modifier) {
289  const MachineOperand &BaseReg = MI->getOperand(OpNo + X86::AddrBaseReg);
290  const MachineOperand &IndexReg = MI->getOperand(OpNo + X86::AddrIndexReg);
291  const MachineOperand &DispSpec = MI->getOperand(OpNo + X86::AddrDisp);
292 
293  // If we really don't want to print out (rip), don't.
294  bool HasBaseReg = BaseReg.getReg() != 0;
295  if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
296  BaseReg.getReg() == X86::RIP)
297  HasBaseReg = false;
298 
299  // HasParenPart - True if we will print out the () part of the mem ref.
300  bool HasParenPart = IndexReg.getReg() || HasBaseReg;
301 
302  switch (DispSpec.getType()) {
303  default:
304  llvm_unreachable("unknown operand type!");
306  int DispVal = DispSpec.getImm();
307  if (DispVal || !HasParenPart)
308  O << DispVal;
309  break;
310  }
313  PrintSymbolOperand(DispSpec, O);
314  break;
315  }
316 
317  if (Modifier && strcmp(Modifier, "H") == 0)
318  O << "+8";
319 
320  if (HasParenPart) {
321  assert(IndexReg.getReg() != X86::ESP &&
322  "X86 doesn't allow scaling by ESP");
323 
324  O << '(';
325  if (HasBaseReg)
326  PrintModifiedOperand(MI, OpNo + X86::AddrBaseReg, O, Modifier);
327 
328  if (IndexReg.getReg()) {
329  O << ',';
330  PrintModifiedOperand(MI, OpNo + X86::AddrIndexReg, O, Modifier);
331  unsigned ScaleVal = MI->getOperand(OpNo + X86::AddrScaleAmt).getImm();
332  if (ScaleVal != 1)
333  O << ',' << ScaleVal;
334  }
335  O << ')';
336  }
337 }
338 
339 void X86AsmPrinter::PrintMemReference(const MachineInstr *MI, unsigned OpNo,
340  raw_ostream &O, const char *Modifier) {
341  assert(isMem(*MI, OpNo) && "Invalid memory reference!");
342  const MachineOperand &Segment = MI->getOperand(OpNo + X86::AddrSegmentReg);
343  if (Segment.getReg()) {
344  PrintModifiedOperand(MI, OpNo + X86::AddrSegmentReg, O, Modifier);
345  O << ':';
346  }
347  PrintLeaMemReference(MI, OpNo, O, Modifier);
348 }
349 
350 
351 void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,
352  unsigned OpNo, raw_ostream &O,
353  const char *Modifier) {
354  const MachineOperand &BaseReg = MI->getOperand(OpNo + X86::AddrBaseReg);
355  unsigned ScaleVal = MI->getOperand(OpNo + X86::AddrScaleAmt).getImm();
356  const MachineOperand &IndexReg = MI->getOperand(OpNo + X86::AddrIndexReg);
357  const MachineOperand &DispSpec = MI->getOperand(OpNo + X86::AddrDisp);
358  const MachineOperand &SegReg = MI->getOperand(OpNo + X86::AddrSegmentReg);
359 
360  // If we really don't want to print out (rip), don't.
361  bool HasBaseReg = BaseReg.getReg() != 0;
362  if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
363  BaseReg.getReg() == X86::RIP)
364  HasBaseReg = false;
365 
366  // If we really just want to print out displacement.
367  if (Modifier && (DispSpec.isGlobal() || DispSpec.isSymbol()) &&
368  !strcmp(Modifier, "disp-only")) {
369  HasBaseReg = false;
370  }
371 
372  // If this has a segment register, print it.
373  if (SegReg.getReg()) {
374  PrintOperand(MI, OpNo + X86::AddrSegmentReg, O);
375  O << ':';
376  }
377 
378  O << '[';
379 
380  bool NeedPlus = false;
381  if (HasBaseReg) {
382  PrintOperand(MI, OpNo + X86::AddrBaseReg, O);
383  NeedPlus = true;
384  }
385 
386  if (IndexReg.getReg()) {
387  if (NeedPlus) O << " + ";
388  if (ScaleVal != 1)
389  O << ScaleVal << '*';
390  PrintOperand(MI, OpNo + X86::AddrIndexReg, O);
391  NeedPlus = true;
392  }
393 
394  if (!DispSpec.isImm()) {
395  if (NeedPlus) O << " + ";
396  PrintOperand(MI, OpNo + X86::AddrDisp, O);
397  } else {
398  int64_t DispVal = DispSpec.getImm();
399  if (DispVal || (!IndexReg.getReg() && !HasBaseReg)) {
400  if (NeedPlus) {
401  if (DispVal > 0)
402  O << " + ";
403  else {
404  O << " - ";
405  DispVal = -DispVal;
406  }
407  }
408  O << DispVal;
409  }
410  }
411  O << ']';
412 }
413 
414 static bool printAsmMRegister(const X86AsmPrinter &P, const MachineOperand &MO,
415  char Mode, raw_ostream &O) {
416  Register Reg = MO.getReg();
417  bool EmitPercent = MO.getParent()->getInlineAsmDialect() == InlineAsm::AD_ATT;
418 
419  if (!X86::GR8RegClass.contains(Reg) &&
420  !X86::GR16RegClass.contains(Reg) &&
421  !X86::GR32RegClass.contains(Reg) &&
422  !X86::GR64RegClass.contains(Reg))
423  return true;
424 
425  switch (Mode) {
426  default: return true; // Unknown mode.
427  case 'b': // Print QImode register
429  break;
430  case 'h': // Print QImode high register
431  Reg = getX86SubSuperRegister(Reg, 8, true);
432  break;
433  case 'w': // Print HImode register
435  break;
436  case 'k': // Print SImode register
438  break;
439  case 'V':
440  EmitPercent = false;
442  case 'q':
443  // Print 64-bit register names if 64-bit integer registers are available.
444  // Otherwise, print 32-bit register names.
445  Reg = getX86SubSuperRegister(Reg, P.getSubtarget().is64Bit() ? 64 : 32);
446  break;
447  }
448 
449  if (EmitPercent)
450  O << '%';
451 
453  return false;
454 }
455 
456 static bool printAsmVRegister(const MachineOperand &MO, char Mode,
457  raw_ostream &O) {
458  Register Reg = MO.getReg();
459  bool EmitPercent = MO.getParent()->getInlineAsmDialect() == InlineAsm::AD_ATT;
460 
461  unsigned Index;
462  if (X86::VR128XRegClass.contains(Reg))
463  Index = Reg - X86::XMM0;
464  else if (X86::VR256XRegClass.contains(Reg))
465  Index = Reg - X86::YMM0;
466  else if (X86::VR512RegClass.contains(Reg))
467  Index = Reg - X86::ZMM0;
468  else
469  return true;
470 
471  switch (Mode) {
472  default: // Unknown mode.
473  return true;
474  case 'x': // Print V4SFmode register
475  Reg = X86::XMM0 + Index;
476  break;
477  case 't': // Print V8SFmode register
478  Reg = X86::YMM0 + Index;
479  break;
480  case 'g': // Print V16SFmode register
481  Reg = X86::ZMM0 + Index;
482  break;
483  }
484 
485  if (EmitPercent)
486  O << '%';
487 
489  return false;
490 }
491 
492 /// PrintAsmOperand - Print out an operand for an inline asm expression.
493 ///
494 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
495  const char *ExtraCode, raw_ostream &O) {
496  // Does this asm operand have a single letter operand modifier?
497  if (ExtraCode && ExtraCode[0]) {
498  if (ExtraCode[1] != 0) return true; // Unknown modifier.
499 
500  const MachineOperand &MO = MI->getOperand(OpNo);
501 
502  switch (ExtraCode[0]) {
503  default:
504  // See if this is a generic print operand
505  return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, O);
506  case 'a': // This is an address. Currently only 'i' and 'r' are expected.
507  switch (MO.getType()) {
508  default:
509  return true;
511  O << MO.getImm();
512  return false;
516  llvm_unreachable("unexpected operand type!");
518  PrintSymbolOperand(MO, O);
519  if (Subtarget->isPICStyleRIPRel())
520  O << "(%rip)";
521  return false;
523  O << '(';
524  PrintOperand(MI, OpNo, O);
525  O << ')';
526  return false;
527  }
528 
529  case 'c': // Don't print "$" before a global var name or constant.
530  switch (MO.getType()) {
531  default:
532  PrintOperand(MI, OpNo, O);
533  break;
535  O << MO.getImm();
536  break;
540  llvm_unreachable("unexpected operand type!");
542  PrintSymbolOperand(MO, O);
543  break;
544  }
545  return false;
546 
547  case 'A': // Print '*' before a register (it must be a register)
548  if (MO.isReg()) {
549  O << '*';
550  PrintOperand(MI, OpNo, O);
551  return false;
552  }
553  return true;
554 
555  case 'b': // Print QImode register
556  case 'h': // Print QImode high register
557  case 'w': // Print HImode register
558  case 'k': // Print SImode register
559  case 'q': // Print DImode register
560  case 'V': // Print native register without '%'
561  if (MO.isReg())
562  return printAsmMRegister(*this, MO, ExtraCode[0], O);
563  PrintOperand(MI, OpNo, O);
564  return false;
565 
566  case 'x': // Print V4SFmode register
567  case 't': // Print V8SFmode register
568  case 'g': // Print V16SFmode register
569  if (MO.isReg())
570  return printAsmVRegister(MO, ExtraCode[0], O);
571  PrintOperand(MI, OpNo, O);
572  return false;
573 
574  case 'P': // This is the operand of a call, treat specially.
575  PrintPCRelImm(MI, OpNo, O);
576  return false;
577 
578  case 'n': // Negate the immediate or print a '-' before the operand.
579  // Note: this is a temporary solution. It should be handled target
580  // independently as part of the 'MC' work.
581  if (MO.isImm()) {
582  O << -MO.getImm();
583  return false;
584  }
585  O << '-';
586  }
587  }
588 
589  PrintOperand(MI, OpNo, O);
590  return false;
591 }
592 
594  const char *ExtraCode,
595  raw_ostream &O) {
596  if (ExtraCode && ExtraCode[0]) {
597  if (ExtraCode[1] != 0) return true; // Unknown modifier.
598 
599  switch (ExtraCode[0]) {
600  default: return true; // Unknown modifier.
601  case 'b': // Print QImode register
602  case 'h': // Print QImode high register
603  case 'w': // Print HImode register
604  case 'k': // Print SImode register
605  case 'q': // Print SImode register
606  // These only apply to registers, ignore on mem.
607  break;
608  case 'H':
609  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
610  return true; // Unsupported modifier in Intel inline assembly.
611  } else {
612  PrintMemReference(MI, OpNo, O, "H");
613  }
614  return false;
615  // Print memory only with displacement. The Modifer 'P' is used in inline
616  // asm to present a call symbol or a global symbol which can not use base
617  // reg or index reg.
618  case 'P':
619  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
620  PrintIntelMemReference(MI, OpNo, O, "disp-only");
621  } else {
622  PrintMemReference(MI, OpNo, O, "disp-only");
623  }
624  return false;
625  }
626  }
627  if (MI->getInlineAsmDialect() == InlineAsm::AD_Intel) {
628  PrintIntelMemReference(MI, OpNo, O, nullptr);
629  } else {
630  PrintMemReference(MI, OpNo, O, nullptr);
631  }
632  return false;
633 }
634 
636  const Triple &TT = TM.getTargetTriple();
637 
638  if (TT.isOSBinFormatELF()) {
639  // Assemble feature flags that may require creation of a note section.
640  unsigned FeatureFlagsAnd = 0;
641  if (M.getModuleFlag("cf-protection-branch"))
642  FeatureFlagsAnd |= ELF::GNU_PROPERTY_X86_FEATURE_1_IBT;
643  if (M.getModuleFlag("cf-protection-return"))
644  FeatureFlagsAnd |= ELF::GNU_PROPERTY_X86_FEATURE_1_SHSTK;
645 
646  if (FeatureFlagsAnd) {
647  // Emit a .note.gnu.property section with the flags.
648  if (!TT.isArch32Bit() && !TT.isArch64Bit())
649  llvm_unreachable("CFProtection used on invalid architecture!");
650  MCSection *Cur = OutStreamer->getCurrentSectionOnly();
652  ".note.gnu.property", ELF::SHT_NOTE, ELF::SHF_ALLOC);
653  OutStreamer->SwitchSection(Nt);
654 
655  // Emitting note header.
656  const int WordSize = TT.isArch64Bit() && !TT.isX32() ? 8 : 4;
657  emitAlignment(WordSize == 4 ? Align(4) : Align(8));
658  OutStreamer->emitIntValue(4, 4 /*size*/); // data size for "GNU\0"
659  OutStreamer->emitIntValue(8 + WordSize, 4 /*size*/); // Elf_Prop size
660  OutStreamer->emitIntValue(ELF::NT_GNU_PROPERTY_TYPE_0, 4 /*size*/);
661  OutStreamer->emitBytes(StringRef("GNU", 4)); // note name
662 
663  // Emitting an Elf_Prop for the CET properties.
665  OutStreamer->emitInt32(4); // data size
666  OutStreamer->emitInt32(FeatureFlagsAnd); // data
667  emitAlignment(WordSize == 4 ? Align(4) : Align(8)); // padding
668 
669  OutStreamer->endSection(Nt);
670  OutStreamer->SwitchSection(Cur);
671  }
672  }
673 
674  if (TT.isOSBinFormatMachO())
675  OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
676 
677  if (TT.isOSBinFormatCOFF()) {
678  // Emit an absolute @feat.00 symbol. This appears to be some kind of
679  // compiler features bitfield read by link.exe.
680  MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
681  OutStreamer->BeginCOFFSymbolDef(S);
682  OutStreamer->emitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
683  OutStreamer->emitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
684  OutStreamer->EndCOFFSymbolDef();
685  int64_t Feat00Flags = 0;
686 
687  if (TT.getArch() == Triple::x86) {
688  // According to the PE-COFF spec, the LSB of this value marks the object
689  // for "registered SEH". This means that all SEH handler entry points
690  // must be registered in .sxdata. Use of any unregistered handlers will
691  // cause the process to terminate immediately. LLVM does not know how to
692  // register any SEH handlers, so its object files should be safe.
693  Feat00Flags |= 1;
694  }
695 
696  if (M.getModuleFlag("cfguard")) {
697  Feat00Flags |= 0x800; // Object is CFG-aware.
698  }
699 
700  if (M.getModuleFlag("ehcontguard")) {
701  Feat00Flags |= 0x4000; // Object also has EHCont.
702  }
703 
704  OutStreamer->emitSymbolAttribute(S, MCSA_Global);
705  OutStreamer->emitAssignment(
706  S, MCConstantExpr::create(Feat00Flags, MMI->getContext()));
707  }
708  OutStreamer->emitSyntaxDirective();
709 
710  // If this is not inline asm and we're in 16-bit
711  // mode prefix assembly with .code16.
712  bool is16 = TT.getEnvironment() == Triple::CODE16;
713  if (M.getModuleInlineAsm().empty() && is16)
714  OutStreamer->emitAssemblerFlag(MCAF_Code16);
715 }
716 
717 static void
720  // L_foo$stub:
721  OutStreamer.emitLabel(StubLabel);
722  // .indirect_symbol _foo
723  OutStreamer.emitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
724 
725  if (MCSym.getInt())
726  // External to current translation unit.
727  OutStreamer.emitIntValue(0, 4/*size*/);
728  else
729  // Internal to current translation unit.
730  //
731  // When we place the LSDA into the TEXT section, the type info
732  // pointers need to be indirect and pc-rel. We accomplish this by
733  // using NLPs; however, sometimes the types are local to the file.
734  // We need to fill in the value for the NLP in those cases.
735  OutStreamer.emitValue(
736  MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
737  4 /*size*/);
738 }
739 
740 static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer) {
741 
742  MachineModuleInfoMachO &MMIMacho =
744 
745  // Output stubs for dynamically-linked functions.
747 
748  // Output stubs for external and common global variables.
749  Stubs = MMIMacho.GetGVStubList();
750  if (!Stubs.empty()) {
751  OutStreamer.SwitchSection(MMI->getContext().getMachOSection(
752  "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS,
754 
755  for (auto &Stub : Stubs)
756  emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second);
757 
758  Stubs.clear();
759  OutStreamer.AddBlankLine();
760  }
761 }
762 
764  const Triple &TT = TM.getTargetTriple();
765 
766  if (TT.isOSBinFormatMachO()) {
767  // Mach-O uses non-lazy symbol stubs to encode per-TU information into
768  // global table for symbol lookup.
770 
771  // Emit stack and fault map information.
772  emitStackMaps(SM);
774 
775  // This flag tells the linker that no global symbols contain code that fall
776  // through to other global symbols (e.g. an implementation of multiple entry
777  // points). If this doesn't occur, the linker can safely perform dead code
778  // stripping. Since LLVM never generates code that does this, it is always
779  // safe to set.
780  OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
781  } else if (TT.isOSBinFormatCOFF()) {
782  if (MMI->usesMSVCFloatingPoint()) {
783  // In Windows' libcmt.lib, there is a file which is linked in only if the
784  // symbol _fltused is referenced. Linking this in causes some
785  // side-effects:
786  //
787  // 1. For x86-32, it will set the x87 rounding mode to 53-bit instead of
788  // 64-bit mantissas at program start.
789  //
790  // 2. It links in support routines for floating-point in scanf and printf.
791  //
792  // MSVC emits an undefined reference to _fltused when there are any
793  // floating point operations in the program (including calls). A program
794  // that only has: `scanf("%f", &global_float);` may fail to trigger this,
795  // but oh well...that's a documented issue.
797  (TT.getArch() == Triple::x86) ? "__fltused" : "_fltused";
799  OutStreamer->emitSymbolAttribute(S, MCSA_Global);
800  return;
801  }
802  emitStackMaps(SM);
803  } else if (TT.isOSBinFormatELF()) {
804  emitStackMaps(SM);
806  }
807 
808  // Emit __morestack address if needed for indirect calls.
809  if (TT.getArch() == Triple::x86_64 && TM.getCodeModel() == CodeModel::Large) {
810  if (MCSymbol *AddrSymbol = OutContext.lookupSymbol("__morestack_addr")) {
811  Align Alignment(1);
814  /*C=*/nullptr, Alignment);
815  OutStreamer->SwitchSection(ReadOnlySection);
816  OutStreamer->emitLabel(AddrSymbol);
817 
818  unsigned PtrSize = MAI->getCodePointerSize();
819  OutStreamer->emitSymbolValue(GetExternalSymbolSymbol("__morestack"),
820  PtrSize);
821  }
822  }
823 }
824 
825 //===----------------------------------------------------------------------===//
826 // Target Registry Stuff
827 //===----------------------------------------------------------------------===//
828 
829 // Force static initialization.
833 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
llvm::ELF::GNU_PROPERTY_X86_FEATURE_1_AND
@ GNU_PROPERTY_X86_FEATURE_1_AND
Definition: ELF.h:1603
llvm::X86II::MO_TLVP
@ MO_TLVP
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
Definition: X86BaseInfo.h:553
llvm::X86II::MO_DARWIN_NONLAZY
@ MO_DARWIN_NONLAZY
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
Definition: X86BaseInfo.h:542
llvm::X86II::MO_GOTTPOFF
@ MO_GOTTPOFF
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
Definition: X86BaseInfo.h:491
llvm::X86AsmPrinter::emitFunctionBodyEnd
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
Definition: X86AsmPrinter.cpp:103
llvm::X86::AddrDisp
@ AddrDisp
Definition: X86BaseInfo.h:35
llvm::MachineOperand::MO_BlockAddress
@ MO_BlockAddress
Address of a basic block.
Definition: MachineOperand.h:62
MachineModuleInfoImpls.h
llvm::X86MachineFunctionInfo::getArgumentStackSize
unsigned getArgumentStackSize() const
Definition: X86MachineFunctionInfo.h:185
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:104
llvm::MachineOperand::MO_Immediate
@ MO_Immediate
Immediate operand.
Definition: MachineOperand.h:52
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::X86::AddrIndexReg
@ AddrIndexReg
Definition: X86BaseInfo.h:34
llvm::AsmPrinter::printOffset
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
Definition: AsmPrinter.cpp:3299
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::X86AsmPrinter::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - Emit the function body.
Definition: X86AsmPrinter.cpp:59
llvm::SectionKind::getMetadata
static SectionKind getMetadata()
Definition: SectionKind.h:188
llvm::ELF::GNU_PROPERTY_X86_FEATURE_1_SHSTK
@ GNU_PROPERTY_X86_FEATURE_1_SHSTK
Definition: ELF.h:1623
llvm::MachineModuleInfo::getContext
const MCContext & getContext() const
Definition: MachineModuleInfo.h:144
X86Subtarget.h
llvm::COFF::IMAGE_SYM_CLASS_STATIC
@ IMAGE_SYM_CLASS_STATIC
Static.
Definition: COFF.h:209
emitNonLazyStubs
static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer)
Definition: X86AsmPrinter.cpp:740
llvm::MachineOperand::getGlobal
const GlobalValue * getGlobal() const
Definition: MachineOperand.h:572
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:592
llvm::X86::AddrSegmentReg
@ AddrSegmentReg
AddrSegmentReg - The operand # of the segment in the memory operand.
Definition: X86BaseInfo.h:38
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::getTheX86_64Target
Target & getTheX86_64Target()
Definition: X86TargetInfo.cpp:17
llvm::X86Subtarget::getInstrInfo
const X86InstrInfo * getInstrInfo() const override
Definition: X86Subtarget.h:128
llvm::X86II::MO_INDNTPOFF
@ MO_INDNTPOFF
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
Definition: X86BaseInfo.h:500
MCCodeEmitter.h
llvm::Triple::x86
@ x86
Definition: Triple.h:85
llvm::InlineAsm::AD_ATT
@ AD_ATT
Definition: InlineAsm.h:34
llvm::AsmPrinter::MAI
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:87
llvm::MCConstantExpr::create
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
contains
return AArch64::GPR64RegClass contains(Reg)
MCSectionELF.h
InlineAsm.h
llvm::Module::getCodeViewFlag
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
Definition: Module.cpp:568
llvm::MachineOperand::getBlockAddress
const BlockAddress * getBlockAddress() const
Definition: MachineOperand.h:577
llvm::X86II::MO_GOT_ABSOLUTE_ADDRESS
@ MO_GOT_ABSOLUTE_ADDRESS
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [.
Definition: X86BaseInfo.h:415
llvm::X86Subtarget
Definition: X86Subtarget.h:52
llvm::X86II::MO_TLSGD
@ MO_TLSGD
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:463
llvm::COFF::IMAGE_SYM_CLASS_EXTERNAL
@ IMAGE_SYM_CLASS_EXTERNAL
External symbol.
Definition: COFF.h:208
ErrorHandling.h
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
MCSectionCOFF.h
llvm::X86II::MO_TLSLDM
@ MO_TLSLDM
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:483
llvm::COFF::SCT_COMPLEX_TYPE_SHIFT
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition: COFF.h:264
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
COFF.h
llvm::AsmPrinter::emitStackMaps
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
Definition: AsmPrinter.cpp:3639
llvm::MachineModuleInfoImpl::SymbolListTy
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
Definition: MachineModuleInfo.h:60
llvm::MCStreamer::emitValue
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:178
llvm::MachineModuleInfoImpl::StubValueTy
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
Definition: MachineModuleInfo.h:59
llvm::MachineOperand::isSymbol
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
Definition: MachineOperand.h:340
llvm::AsmPrinter::emitAlignment
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
Definition: AsmPrinter.cpp:2650
Module.h
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:86
llvm::X86II::MO_SECREL
@ MO_SECREL
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
Definition: X86BaseInfo.h:565
llvm::X86II::MO_TPOFF
@ MO_TPOFF
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
Definition: X86BaseInfo.h:508
llvm::MCAsmInfo::getCodePointerSize
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition: MCAsmInfo.h:548
llvm::X86Subtarget::isPICStyleRIPRel
bool isPICStyleRIPRel() const
Definition: X86Subtarget.h:319
llvm::X86AsmPrinter::emitStartOfAsmFile
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Definition: X86AsmPrinter.cpp:635
llvm::MCStreamer::AddBlankLine
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
Definition: MCStreamer.h:365
llvm::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition: ELF.h:1035
llvm::FaultMaps::serializeToFaultMapSection
void serializeToFaultMapSection()
Definition: FaultMaps.cpp:45
X86AsmPrinter.h
llvm::X86II::MO_GOTOFF
@ MO_GOTOFF
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
Definition: X86BaseInfo.h:434
llvm::MachineOperand::getOffset
int64_t getOffset() const
Return the offset from the symbol in this operand.
Definition: MachineOperand.h:609
llvm::MCContext::lookupSymbol
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
Definition: MCContext.cpp:362
llvm::MachineOperand::MO_Register
@ MO_Register
Register operand.
Definition: MachineOperand.h:51
X86ATTInstPrinter.h
llvm::MCContext::getMachOSection
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:438
llvm::X86II::MO_GOT
@ MO_GOT
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
Definition: X86BaseInfo.h:427
MachineValueType.h
llvm::X86AsmPrinter::PrintAsmOperand
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
PrintAsmOperand - Print out an operand for an inline asm expression.
Definition: X86AsmPrinter.cpp:494
llvm::SectionKind::getReadOnly
static SectionKind getReadOnly()
Definition: SectionKind.h:192
llvm::Target::createMCCodeEmitter
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
Definition: TargetRegistry.h:518
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:201
X86MachineFunctionInfo.h
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:204
llvm::X86II::MO_COFFSTUB
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
Definition: X86BaseInfo.h:575
ELF.h
llvm::ELF::NT_GNU_PROPERTY_TYPE_0
@ NT_GNU_PROPERTY_TYPE_0
Definition: ELF.h:1570
TargetMachine.h
llvm::MachineOperand::MO_GlobalAddress
@ MO_GlobalAddress
Address of a global value.
Definition: MachineOperand.h:61
llvm::X86II::MO_PLT
@ MO_PLT
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
Definition: X86BaseInfo.h:454
llvm::MachineOperand::getImm
int64_t getImm() const
Definition: MachineOperand.h:546
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:738
llvm::X86Subtarget::isTargetWin32
bool isTargetWin32() const
Definition: X86Subtarget.h:316
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:96
MCContext.h
llvm::X86II::MO_GOTPCREL
@ MO_GOTPCREL
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
Definition: X86BaseInfo.h:442
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::Triple::CODE16
@ CODE16
Definition: Triple.h:234
MCSectionMachO.h
llvm::MCStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:416
llvm::AsmPrinter::SetupMachineFunction
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
Definition: AsmPrinter.cpp:2153
MCSymbol.h
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:556
llvm::MCAF_Code16
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:54
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:75
llvm::X86II::MO_NO_FLAG
@ MO_NO_FLAG
Definition: X86BaseInfo.h:410
llvm::AsmPrinter::CurrentFnSym
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:118
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::X86II::MO_GOTPCREL_NORELAX
@ MO_GOTPCREL_NORELAX
MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...
Definition: X86BaseInfo.h:447
llvm::GlobalValue::hasInternalLinkage
bool hasInternalLinkage() const
Definition: GlobalValue.h:448
llvm::MCSymbol::getName
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:198
llvm::X86II::MO_TLVP_PIC_BASE
@ MO_TLVP_PIC_BASE
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
Definition: X86BaseInfo.h:559
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineOperand::getParent
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Definition: MachineOperand.h:237
llvm::MCSymbol::print
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:58
emitNonLazySymbolPointer
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
Definition: X86AsmPrinter.cpp:718
Type.h
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition: MachO.h:137
printAsmVRegister
static bool printAsmVRegister(const MachineOperand &MO, char Mode, raw_ostream &O)
Definition: X86AsmPrinter.cpp:456
llvm::X86AsmPrinter
Definition: X86AsmPrinter.h:27
llvm::PointerIntPair::getPointer
PointerTy getPointer() const
Definition: PointerIntPair.h:60
llvm::MachineFunction::getMMI
MachineModuleInfo & getMMI() const
Definition: MachineFunction.h:591
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:640
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:239
llvm::getTheX86_32Target
Target & getTheX86_32Target()
Definition: X86TargetInfo.cpp:13
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::X86II::MO_DARWIN_NONLAZY_PIC_BASE
@ MO_DARWIN_NONLAZY_PIC_BASE
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
Definition: X86BaseInfo.h:547
llvm::MachineOperand::getTargetFlags
unsigned getTargetFlags() const
Definition: MachineOperand.h:220
llvm::MCAF_SubsectionsViaSymbols
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:53
llvm::AsmPrinter::GetCPISymbol
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
Definition: AsmPrinter.cpp:3330
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition: MachineOperand.h:320
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::X86II::MO_GOTNTPOFF
@ MO_GOTNTPOFF
MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...
Definition: X86BaseInfo.h:532
llvm::X86II::MO_PIC_BASE_OFFSET
@ MO_PIC_BASE_OFFSET
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
Definition: X86BaseInfo.h:420
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:126
llvm::getX86SubSuperRegister
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
Definition: X86MCTargetDesc.cpp:913
X86TargetStreamer.h
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:3320
llvm::AsmPrinter::getSymbolPreferLocal
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
Definition: AsmPrinter.cpp:658
llvm::X86Subtarget::isTargetCOFF
bool isTargetCOFF() const
Definition: X86Subtarget.h:277
llvm::PointerIntPair::getInt
IntType getInt() const
Definition: PointerIntPair.h:62
MachineConstantPool.h
llvm::X86II::MO_DTPOFF
@ MO_DTPOFF
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
Definition: X86BaseInfo.h:516
llvm::X86AsmPrinter::X86AsmPrinter
X86AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
Definition: X86AsmPrinter.cpp:49
llvm::MachineOperand::getType
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Definition: MachineOperand.h:218
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::AsmPrinter::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:654
llvm::X86ATTInstPrinter::getRegisterName
static const char * getRegisterName(unsigned RegNo)
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1665
llvm::MCStreamer::emitIntValue
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:134
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:450
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
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
llvm::X86MachineFunctionInfo
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
Definition: X86MachineFunctionInfo.h:25
llvm::MachineInstr::getInlineAsmDialect
InlineAsm::AsmDialect getInlineAsmDialect() const
Definition: MachineInstr.cpp:757
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition: MachineOperand.h:359
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MachineFunction
Definition: MachineFunction.h:241
Mangler.h
llvm::MachineOperand::MO_JumpTableIndex
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
Definition: MachineOperand.h:59
llvm::AsmPrinter::GetExternalSymbolSymbol
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
Definition: AsmPrinter.cpp:3377
llvm::X86II::MO_DLLIMPORT
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
Definition: X86BaseInfo.h:537
llvm::X86AsmPrinter::PrintAsmMemoryOperand
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
Definition: X86AsmPrinter.cpp:593
llvm::N86::ESP
@ ESP
Definition: X86MCTargetDesc.h:51
MCAsmInfo.h
llvm::InlineAsm::AD_Intel
@ AD_Intel
Definition: InlineAsm.h:35
llvm::ELF::SHT_NOTE
@ SHT_NOTE
Definition: ELF.h:961
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
LLVMInitializeX86AsmPrinter
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmPrinter()
Definition: X86AsmPrinter.cpp:830
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::X86AsmPrinter::emitEndOfAsmFile
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
Definition: X86AsmPrinter.cpp:763
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
printAsmMRegister
static bool printAsmMRegister(const X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)
Definition: X86AsmPrinter.cpp:414
llvm::MCSA_IndirectSymbol
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
Definition: MCDirectives.h:35
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:280
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::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:386
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::X86AsmPrinter::emitFunctionBodyStart
void emitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
Definition: X86AsmPrinter.cpp:93
std
Definition: BitVector.h:851
llvm::ELF::GNU_PROPERTY_X86_FEATURE_1_IBT
@ GNU_PROPERTY_X86_FEATURE_1_IBT
Definition: ELF.h:1622
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:606
llvm::MCStreamer::emitSymbolAttribute
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
llvm::MachineOperand::MO_ExternalSymbol
@ MO_ExternalSymbol
Name of external global symbol.
Definition: MachineOperand.h:60
llvm::MachineOperand::getIndex
int getIndex() const
Definition: MachineOperand.h:566
llvm::MachineModuleInfoMachO::GetGVStubList
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
Definition: MachineModuleInfoImpls.h:55
llvm::X86II::MO_TLSLD
@ MO_TLSLD
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
Definition: X86BaseInfo.h:473
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:81
llvm::TargetMachine::getCodeModel
CodeModel::Model getCodeModel() const
Returns the code model.
Definition: TargetMachine.cpp:72
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
llvm::MCSA_Global
@ MCSA_Global
.type _foo, @gnu_unique_object
Definition: MCDirectives.h:30
llvm::MachineOperand::isImm
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
Definition: MachineOperand.h:322
llvm::X86TargetStreamer
X86 target streamer implementing x86-only assembly directives.
Definition: X86TargetStreamer.h:17
llvm::TargetLoweringObjectFile::getSectionForConstant
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const
Given a constant with the SectionKind, return a section that it should be placed in.
Definition: TargetLoweringObjectFile.cpp:373
llvm::CodeModel::Large
@ Large
Definition: CodeGen.h:28
llvm::MachineFunction::getPICBaseSymbol
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
Definition: MachineFunction.cpp:719
X86BaseInfo.h
llvm::PointerIntPair
PointerIntPair - This class implements a pair of a pointer and small integer.
Definition: PointerIntPair.h:46
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition: MCStreamer.h:282
llvm::AsmPrinter::TM
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:84
llvm::COFF::IMAGE_SYM_DTYPE_NULL
@ IMAGE_SYM_DTYPE_NULL
No complex type; simple scalar variable.
Definition: COFF.h:258
llvm::AsmPrinter::getSymbolWithGlobalValueBase
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...
Definition: AsmPrinter.cpp:3371
llvm::AsmPrinter::getObjFileLowering
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:382
MCStreamer.h
llvm::AsmPrinter::emitFunctionBody
void emitFunctionBody()
This method emits the body and trailer for a function.
Definition: AsmPrinter.cpp:1413
llvm::TargetMachine::getTargetTriple
const Triple & getTargetTriple() const
Definition: TargetMachine.h:126
llvm::isMem
static bool isMem(const MachineInstr &MI, unsigned Op)
Definition: X86InstrInfo.h:131
llvm::AsmPrinter::getDataLayout
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:386
DerivedTypes.h
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::X86::AddrBaseReg
@ AddrBaseReg
Definition: X86BaseInfo.h:32
llvm::AsmPrinter::emitXRayTable
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Definition: AsmPrinter.cpp:3679
llvm::RegisterAsmPrinter
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Definition: TargetRegistry.h:1359
llvm::TargetMachine::getTarget
const Target & getTarget() const
Definition: TargetMachine.h:124
llvm::X86II::MO_NTPOFF
@ MO_NTPOFF
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
Definition: X86BaseInfo.h:524
llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
Definition: COFF.h:260
X86InstrInfo.h
X86TargetInfo.h
TargetRegistry.h
llvm::MCStreamer::SwitchSection
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:1218
MCExpr.h
llvm::MachineModuleInfo::getModule
const Module * getModule() const
Definition: MachineModuleInfo.h:151
Debug.h
llvm::X86::AddrScaleAmt
@ AddrScaleAmt
Definition: X86BaseInfo.h:33
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:467
llvm::MachineModuleInfo::getObjFileInfo
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
Definition: MachineModuleInfo.h:171
llvm::MachineModuleInfoMachO
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
Definition: MachineModuleInfoImpls.h:28
llvm::MachineOperand::isGlobal
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
Definition: MachineOperand.h:338
llvm::MachineModuleInfo::usesMSVCFloatingPoint
bool usesMSVCFloatingPoint() const
Definition: MachineModuleInfo.h:185
llvm::MachineOperand::MO_ConstantPoolIndex
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
Definition: MachineOperand.h:57
TargetLoweringObjectFileImpl.h