LLVM  6.0.0svn
ARMAsmPrinter.cpp
Go to the documentation of this file.
1 //===-- ARMAsmPrinter.cpp - Print machine code to an ARM .s file ----------===//
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 GAS-format ARM assembly language.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "ARMAsmPrinter.h"
16 #include "ARM.h"
17 #include "ARMConstantPoolValue.h"
18 #include "ARMMachineFunctionInfo.h"
19 #include "ARMTargetMachine.h"
20 #include "ARMTargetObjectFile.h"
23 #include "MCTargetDesc/ARMMCExpr.h"
24 #include "llvm/ADT/SetVector.h"
25 #include "llvm/ADT/SmallString.h"
26 #include "llvm/BinaryFormat/COFF.h"
27 #include "llvm/BinaryFormat/ELF.h"
31 #include "llvm/IR/Constants.h"
32 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/DebugInfo.h"
34 #include "llvm/IR/Mangler.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/IR/Type.h"
37 #include "llvm/MC/MCAsmInfo.h"
38 #include "llvm/MC/MCAssembler.h"
39 #include "llvm/MC/MCContext.h"
40 #include "llvm/MC/MCELFStreamer.h"
41 #include "llvm/MC/MCInst.h"
42 #include "llvm/MC/MCInstBuilder.h"
44 #include "llvm/MC/MCSectionMachO.h"
45 #include "llvm/MC/MCStreamer.h"
46 #include "llvm/MC/MCSymbol.h"
48 #include "llvm/Support/Debug.h"
54 #include <cctype>
55 using namespace llvm;
56 
57 #define DEBUG_TYPE "asm-printer"
58 
60  std::unique_ptr<MCStreamer> Streamer)
61  : AsmPrinter(TM, std::move(Streamer)), AFI(nullptr), MCP(nullptr),
62  InConstantPool(false), OptimizationGoals(-1) {}
63 
65  // Make sure to terminate any constant pools that were at the end
66  // of the function.
67  if (!InConstantPool)
68  return;
69  InConstantPool = false;
70  OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
71 }
72 
74  if (AFI->isThumbFunction()) {
75  OutStreamer->EmitAssemblerFlag(MCAF_Code16);
76  OutStreamer->EmitThumbFunc(CurrentFnSym);
77  } else {
78  OutStreamer->EmitAssemblerFlag(MCAF_Code32);
79  }
80  OutStreamer->EmitLabel(CurrentFnSym);
81 }
82 
84  uint64_t Size = getDataLayout().getTypeAllocSize(CV->getType());
85  assert(Size && "C++ constructor pointer had zero size!");
86 
88  assert(GV && "C++ constructor pointer was not a GlobalValue!");
89 
90  const MCExpr *E = MCSymbolRefExpr::create(GetARMGVSymbol(GV,
92  (Subtarget->isTargetELF()
95  OutContext);
96 
97  OutStreamer->EmitValue(E, Size);
98 }
99 
101  if (PromotedGlobals.count(GV))
102  // The global was promoted into a constant pool. It should not be emitted.
103  return;
105 }
106 
107 /// runOnMachineFunction - This uses the EmitInstruction()
108 /// method to print assembly for each instruction.
109 ///
111  AFI = MF.getInfo<ARMFunctionInfo>();
112  MCP = MF.getConstantPool();
113  Subtarget = &MF.getSubtarget<ARMSubtarget>();
114 
116  const Function* F = MF.getFunction();
117  const TargetMachine& TM = MF.getTarget();
118 
119  // Collect all globals that had their storage promoted to a constant pool.
120  // Functions are emitted before variables, so this accumulates promoted
121  // globals from all functions in PromotedGlobals.
122  for (auto *GV : AFI->getGlobalsPromotedToConstantPool())
123  PromotedGlobals.insert(GV);
124 
125  // Calculate this function's optimization goal.
126  unsigned OptimizationGoal;
127  if (F->hasFnAttribute(Attribute::OptimizeNone))
128  // For best debugging illusion, speed and small size sacrificed
129  OptimizationGoal = 6;
130  else if (F->optForMinSize())
131  // Aggressively for small size, speed and debug illusion sacrificed
132  OptimizationGoal = 4;
133  else if (F->optForSize())
134  // For small size, but speed and debugging illusion preserved
135  OptimizationGoal = 3;
136  else if (TM.getOptLevel() == CodeGenOpt::Aggressive)
137  // Aggressively for speed, small size and debug illusion sacrificed
138  OptimizationGoal = 2;
139  else if (TM.getOptLevel() > CodeGenOpt::None)
140  // For speed, but small size and good debug illusion preserved
141  OptimizationGoal = 1;
142  else // TM.getOptLevel() == CodeGenOpt::None
143  // For good debugging, but speed and small size preserved
144  OptimizationGoal = 5;
145 
146  // Combine a new optimization goal with existing ones.
147  if (OptimizationGoals == -1) // uninitialized goals
148  OptimizationGoals = OptimizationGoal;
149  else if (OptimizationGoals != (int)OptimizationGoal) // conflicting goals
150  OptimizationGoals = 0;
151 
152  if (Subtarget->isTargetCOFF()) {
153  bool Internal = F->hasInternalLinkage();
157 
158  OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
159  OutStreamer->EmitCOFFSymbolStorageClass(Scl);
160  OutStreamer->EmitCOFFSymbolType(Type);
161  OutStreamer->EndCOFFSymbolDef();
162  }
163 
164  // Emit the rest of the function body.
166 
167  // Emit the XRay table for this function.
168  emitXRayTable();
169 
170  // If we need V4T thumb mode Register Indirect Jump pads, emit them.
171  // These are created per function, rather than per TU, since it's
172  // relatively easy to exceed the thumb branch range within a TU.
173  if (! ThumbIndirectPads.empty()) {
174  OutStreamer->EmitAssemblerFlag(MCAF_Code16);
175  EmitAlignment(1);
176  for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) {
177  OutStreamer->EmitLabel(ThumbIndirectPads[i].second);
179  .addReg(ThumbIndirectPads[i].first)
180  // Add predicate operands.
181  .addImm(ARMCC::AL)
182  .addReg(0));
183  }
184  ThumbIndirectPads.clear();
185  }
186 
187  // We didn't modify anything.
188  return false;
189 }
190 
192  raw_ostream &O) {
193  const MachineOperand &MO = MI->getOperand(OpNum);
194  unsigned TF = MO.getTargetFlags();
195 
196  switch (MO.getType()) {
197  default: llvm_unreachable("<unknown operand type>");
199  unsigned Reg = MO.getReg();
201  assert(!MO.getSubReg() && "Subregs should be eliminated!");
202  if(ARM::GPRPairRegClass.contains(Reg)) {
203  const MachineFunction &MF = *MI->getParent()->getParent();
204  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
205  Reg = TRI->getSubReg(Reg, ARM::gsub_0);
206  }
208  break;
209  }
211  int64_t Imm = MO.getImm();
212  O << '#';
213  if (TF == ARMII::MO_LO16)
214  O << ":lower16:";
215  else if (TF == ARMII::MO_HI16)
216  O << ":upper16:";
217  O << Imm;
218  break;
219  }
221  MO.getMBB()->getSymbol()->print(O, MAI);
222  return;
224  const GlobalValue *GV = MO.getGlobal();
225  if (TF & ARMII::MO_LO16)
226  O << ":lower16:";
227  else if (TF & ARMII::MO_HI16)
228  O << ":upper16:";
229  GetARMGVSymbol(GV, TF)->print(O, MAI);
230 
231  printOffset(MO.getOffset(), O);
232  break;
233  }
235  if (Subtarget->genExecuteOnly())
236  llvm_unreachable("execute-only should not generate constant pools");
237  GetCPISymbol(MO.getIndex())->print(O, MAI);
238  break;
239  }
240 }
241 
242 //===--------------------------------------------------------------------===//
243 
244 MCSymbol *ARMAsmPrinter::
245 GetARMJTIPICJumpTableLabel(unsigned uid) const {
246  const DataLayout &DL = getDataLayout();
248  raw_svector_ostream(Name) << DL.getPrivateGlobalPrefix() << "JTI"
249  << getFunctionNumber() << '_' << uid;
250  return OutContext.getOrCreateSymbol(Name);
251 }
252 
253 bool ARMAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
254  unsigned AsmVariant, const char *ExtraCode,
255  raw_ostream &O) {
256  // Does this asm operand have a single letter operand modifier?
257  if (ExtraCode && ExtraCode[0]) {
258  if (ExtraCode[1] != 0) return true; // Unknown modifier.
259 
260  switch (ExtraCode[0]) {
261  default:
262  // See if this is a generic print operand
263  return AsmPrinter::PrintAsmOperand(MI, OpNum, AsmVariant, ExtraCode, O);
264  case 'a': // Print as a memory address.
265  if (MI->getOperand(OpNum).isReg()) {
266  O << "["
268  << "]";
269  return false;
270  }
272  case 'c': // Don't print "#" before an immediate operand.
273  if (!MI->getOperand(OpNum).isImm())
274  return true;
275  O << MI->getOperand(OpNum).getImm();
276  return false;
277  case 'P': // Print a VFP double precision register.
278  case 'q': // Print a NEON quad precision register.
279  printOperand(MI, OpNum, O);
280  return false;
281  case 'y': // Print a VFP single precision register as indexed double.
282  if (MI->getOperand(OpNum).isReg()) {
283  unsigned Reg = MI->getOperand(OpNum).getReg();
285  // Find the 'd' register that has this 's' register as a sub-register,
286  // and determine the lane number.
287  for (MCSuperRegIterator SR(Reg, TRI); SR.isValid(); ++SR) {
288  if (!ARM::DPRRegClass.contains(*SR))
289  continue;
290  bool Lane0 = TRI->getSubReg(*SR, ARM::ssub_0) == Reg;
291  O << ARMInstPrinter::getRegisterName(*SR) << (Lane0 ? "[0]" : "[1]");
292  return false;
293  }
294  }
295  return true;
296  case 'B': // Bitwise inverse of integer or symbol without a preceding #.
297  if (!MI->getOperand(OpNum).isImm())
298  return true;
299  O << ~(MI->getOperand(OpNum).getImm());
300  return false;
301  case 'L': // The low 16 bits of an immediate constant.
302  if (!MI->getOperand(OpNum).isImm())
303  return true;
304  O << (MI->getOperand(OpNum).getImm() & 0xffff);
305  return false;
306  case 'M': { // A register range suitable for LDM/STM.
307  if (!MI->getOperand(OpNum).isReg())
308  return true;
309  const MachineOperand &MO = MI->getOperand(OpNum);
310  unsigned RegBegin = MO.getReg();
311  // This takes advantage of the 2 operand-ness of ldm/stm and that we've
312  // already got the operands in registers that are operands to the
313  // inline asm statement.
314  O << "{";
315  if (ARM::GPRPairRegClass.contains(RegBegin)) {
317  unsigned Reg0 = TRI->getSubReg(RegBegin, ARM::gsub_0);
318  O << ARMInstPrinter::getRegisterName(Reg0) << ", ";
319  RegBegin = TRI->getSubReg(RegBegin, ARM::gsub_1);
320  }
321  O << ARMInstPrinter::getRegisterName(RegBegin);
322 
323  // FIXME: The register allocator not only may not have given us the
324  // registers in sequence, but may not be in ascending registers. This
325  // will require changes in the register allocator that'll need to be
326  // propagated down here if the operands change.
327  unsigned RegOps = OpNum + 1;
328  while (MI->getOperand(RegOps).isReg()) {
329  O << ", "
331  RegOps++;
332  }
333 
334  O << "}";
335 
336  return false;
337  }
338  case 'R': // The most significant register of a pair.
339  case 'Q': { // The least significant register of a pair.
340  if (OpNum == 0)
341  return true;
342  const MachineOperand &FlagsOP = MI->getOperand(OpNum - 1);
343  if (!FlagsOP.isImm())
344  return true;
345  unsigned Flags = FlagsOP.getImm();
346 
347  // This operand may not be the one that actually provides the register. If
348  // it's tied to a previous one then we should refer instead to that one
349  // for registers and their classes.
350  unsigned TiedIdx;
351  if (InlineAsm::isUseOperandTiedToDef(Flags, TiedIdx)) {
352  for (OpNum = InlineAsm::MIOp_FirstOperand; TiedIdx; --TiedIdx) {
353  unsigned OpFlags = MI->getOperand(OpNum).getImm();
354  OpNum += InlineAsm::getNumOperandRegisters(OpFlags) + 1;
355  }
356  Flags = MI->getOperand(OpNum).getImm();
357 
358  // Later code expects OpNum to be pointing at the register rather than
359  // the flags.
360  OpNum += 1;
361  }
362 
363  unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags);
364  unsigned RC;
366  if (RC == ARM::GPRPairRegClassID) {
367  if (NumVals != 1)
368  return true;
369  const MachineOperand &MO = MI->getOperand(OpNum);
370  if (!MO.isReg())
371  return true;
373  unsigned Reg = TRI->getSubReg(MO.getReg(), ExtraCode[0] == 'Q' ?
374  ARM::gsub_0 : ARM::gsub_1);
376  return false;
377  }
378  if (NumVals != 2)
379  return true;
380  unsigned RegOp = ExtraCode[0] == 'Q' ? OpNum : OpNum + 1;
381  if (RegOp >= MI->getNumOperands())
382  return true;
383  const MachineOperand &MO = MI->getOperand(RegOp);
384  if (!MO.isReg())
385  return true;
386  unsigned Reg = MO.getReg();
388  return false;
389  }
390 
391  case 'e': // The low doubleword register of a NEON quad register.
392  case 'f': { // The high doubleword register of a NEON quad register.
393  if (!MI->getOperand(OpNum).isReg())
394  return true;
395  unsigned Reg = MI->getOperand(OpNum).getReg();
396  if (!ARM::QPRRegClass.contains(Reg))
397  return true;
399  unsigned SubReg = TRI->getSubReg(Reg, ExtraCode[0] == 'e' ?
400  ARM::dsub_0 : ARM::dsub_1);
401  O << ARMInstPrinter::getRegisterName(SubReg);
402  return false;
403  }
404 
405  // This modifier is not yet supported.
406  case 'h': // A range of VFP/NEON registers suitable for VLD1/VST1.
407  return true;
408  case 'H': { // The highest-numbered register of a pair.
409  const MachineOperand &MO = MI->getOperand(OpNum);
410  if (!MO.isReg())
411  return true;
412  const MachineFunction &MF = *MI->getParent()->getParent();
413  const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
414  unsigned Reg = MO.getReg();
415  if(!ARM::GPRPairRegClass.contains(Reg))
416  return false;
417  Reg = TRI->getSubReg(Reg, ARM::gsub_1);
419  return false;
420  }
421  }
422  }
423 
424  printOperand(MI, OpNum, O);
425  return false;
426 }
427 
429  unsigned OpNum, unsigned AsmVariant,
430  const char *ExtraCode,
431  raw_ostream &O) {
432  // Does this asm operand have a single letter operand modifier?
433  if (ExtraCode && ExtraCode[0]) {
434  if (ExtraCode[1] != 0) return true; // Unknown modifier.
435 
436  switch (ExtraCode[0]) {
437  case 'A': // A memory operand for a VLD1/VST1 instruction.
438  default: return true; // Unknown modifier.
439  case 'm': // The base register of a memory operand.
440  if (!MI->getOperand(OpNum).isReg())
441  return true;
443  return false;
444  }
445  }
446 
447  const MachineOperand &MO = MI->getOperand(OpNum);
448  assert(MO.isReg() && "unexpected inline asm memory operand");
449  O << "[" << ARMInstPrinter::getRegisterName(MO.getReg()) << "]";
450  return false;
451 }
452 
453 static bool isThumb(const MCSubtargetInfo& STI) {
454  return STI.getFeatureBits()[ARM::ModeThumb];
455 }
456 
458  const MCSubtargetInfo *EndInfo) const {
459  // If either end mode is unknown (EndInfo == NULL) or different than
460  // the start mode, then restore the start mode.
461  const bool WasThumb = isThumb(StartInfo);
462  if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
463  OutStreamer->EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
464  }
465 }
466 
468  const Triple &TT = TM.getTargetTriple();
469  // Use unified assembler syntax.
470  OutStreamer->EmitAssemblerFlag(MCAF_SyntaxUnified);
471 
472  // Emit ARM Build Attributes
473  if (TT.isOSBinFormatELF())
474  emitAttributes();
475 
476  // Use the triple's architecture and subarchitecture to determine
477  // if we're thumb for the purposes of the top level code16 assembler
478  // flag.
479  bool isThumb = TT.getArch() == Triple::thumb ||
480  TT.getArch() == Triple::thumbeb ||
483  if (!M.getModuleInlineAsm().empty() && isThumb)
484  OutStreamer->EmitAssemblerFlag(MCAF_Code16);
485 }
486 
487 static void
490  // L_foo$stub:
491  OutStreamer.EmitLabel(StubLabel);
492  // .indirect_symbol _foo
493  OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
494 
495  if (MCSym.getInt())
496  // External to current translation unit.
497  OutStreamer.EmitIntValue(0, 4/*size*/);
498  else
499  // Internal to current translation unit.
500  //
501  // When we place the LSDA into the TEXT section, the type info
502  // pointers need to be indirect and pc-rel. We accomplish this by
503  // using NLPs; however, sometimes the types are local to the file.
504  // We need to fill in the value for the NLP in those cases.
505  OutStreamer.EmitValue(
506  MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
507  4 /*size*/);
508 }
509 
510 
512  const Triple &TT = TM.getTargetTriple();
513  if (TT.isOSBinFormatMachO()) {
514  // All darwin targets use mach-o.
515  const TargetLoweringObjectFileMachO &TLOFMacho =
516  static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
517  MachineModuleInfoMachO &MMIMacho =
519 
520  // Output non-lazy-pointers for external and common global variables.
522 
523  if (!Stubs.empty()) {
524  // Switch with ".non_lazy_symbol_pointer" directive.
525  OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
526  EmitAlignment(2);
527 
528  for (auto &Stub : Stubs)
529  emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
530 
531  Stubs.clear();
532  OutStreamer->AddBlankLine();
533  }
534 
535  Stubs = MMIMacho.GetThreadLocalGVStubList();
536  if (!Stubs.empty()) {
537  // Switch with ".non_lazy_symbol_pointer" directive.
538  OutStreamer->SwitchSection(TLOFMacho.getThreadLocalPointerSection());
539  EmitAlignment(2);
540 
541  for (auto &Stub : Stubs)
542  emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
543 
544  Stubs.clear();
545  OutStreamer->AddBlankLine();
546  }
547 
548  // Funny Darwin hack: This flag tells the linker that no global symbols
549  // contain code that falls through to other global symbols (e.g. the obvious
550  // implementation of multiple entry points). If this doesn't occur, the
551  // linker can safely perform dead code stripping. Since LLVM never
552  // generates code that does this, it is always safe to set.
553  OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
554  }
555 
556  if (TT.isOSBinFormatCOFF()) {
557  const auto &TLOF =
558  static_cast<const TargetLoweringObjectFileCOFF &>(getObjFileLowering());
559 
560  std::string Flags;
561  raw_string_ostream OS(Flags);
562 
563  for (const auto &Function : M)
564  TLOF.emitLinkerFlagsForGlobal(OS, &Function);
565  for (const auto &Global : M.globals())
566  TLOF.emitLinkerFlagsForGlobal(OS, &Global);
567  for (const auto &Alias : M.aliases())
568  TLOF.emitLinkerFlagsForGlobal(OS, &Alias);
569 
570  OS.flush();
571 
572  // Output collected flags
573  if (!Flags.empty()) {
574  OutStreamer->SwitchSection(TLOF.getDrectveSection());
575  OutStreamer->EmitBytes(Flags);
576  }
577  }
578 
579  // The last attribute to be emitted is ABI_optimization_goals
580  MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
581  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
582 
583  if (OptimizationGoals > 0 &&
584  (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
585  Subtarget->isTargetMuslAEABI()))
587  OptimizationGoals = -1;
588 
590 }
591 
592 //===----------------------------------------------------------------------===//
593 // Helper routines for EmitStartOfAsmFile() and EmitEndOfAsmFile()
594 // FIXME:
595 // The following seem like one-off assembler flags, but they actually need
596 // to appear in the .ARM.attributes section in ELF.
597 // Instead of subclassing the MCELFStreamer, we do the work here.
598 
599 // Returns true if all functions have the same function attribute value.
600 // It also returns true when the module has no functions.
602  StringRef Value) {
603  return !any_of(M, [&](const Function &F) {
604  return F.getFnAttribute(Attr).getValueAsString() != Value;
605  });
606 }
607 
608 void ARMAsmPrinter::emitAttributes() {
609  MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
610  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
611 
613 
614  ATS.switchVendor("aeabi");
615 
616  // Compute ARM ELF Attributes based on the default subtarget that
617  // we'd have constructed. The existing ARM behavior isn't LTO clean
618  // anyhow.
619  // FIXME: For ifunc related functions we could iterate over and look
620  // for a feature string that doesn't match the default one.
621  const Triple &TT = TM.getTargetTriple();
622  StringRef CPU = TM.getTargetCPU();
624  std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
625  if (!FS.empty()) {
626  if (!ArchFS.empty())
627  ArchFS = (Twine(ArchFS) + "," + FS).str();
628  else
629  ArchFS = FS;
630  }
631  const ARMBaseTargetMachine &ATM =
632  static_cast<const ARMBaseTargetMachine &>(TM);
633  const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
634 
635  // Emit build attributes for the available hardware.
636  ATS.emitTargetAttributes(STI);
637 
638  // RW data addressing.
639  if (isPositionIndependent()) {
642  } else if (STI.isRWPI()) {
643  // RWPI specific attributes.
646  }
647 
648  // RO data addressing.
649  if (isPositionIndependent() || STI.isROPI()) {
652  }
653 
654  // GOT use.
655  if (isPositionIndependent()) {
658  } else {
661  }
662 
663  // Set FP Denormals.
665  "denormal-fp-math",
666  "preserve-sign") ||
671  "denormal-fp-math",
672  "positive-zero") ||
676  else if (!TM.Options.UnsafeFPMath)
679  else {
680  if (!STI.hasVFP2()) {
681  // When the target doesn't have an FPU (by design or
682  // intention), the assumptions made on the software support
683  // mirror that of the equivalent hardware support *if it
684  // existed*. For v7 and better we indicate that denormals are
685  // flushed preserving sign, and for V6 we indicate that
686  // denormals are flushed to positive zero.
687  if (STI.hasV7Ops())
690  } else if (STI.hasVFP3()) {
691  // In VFPv4, VFPv4U, VFPv3, or VFPv3U, it is preserved. That is,
692  // the sign bit of the zero matches the sign bit of the input or
693  // result that is being flushed to zero.
696  }
697  // For VFPv2 implementations it is implementation defined as
698  // to whether denormals are flushed to positive zero or to
699  // whatever the sign of zero is (ARM v7AR ARM 2.7.5). Historically
700  // LLVM has chosen to flush this to positive zero (most likely for
701  // GCC compatibility), so that's the chosen value here (the
702  // absence of its emission implies zero).
703  }
704 
705  // Set FP exceptions and rounding
707  "no-trapping-math", "true") ||
711  else if (!TM.Options.UnsafeFPMath) {
713 
714  // If the user has permitted this code to choose the IEEE 754
715  // rounding at run-time, emit the rounding attribute.
718  }
719 
720  // TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath is the
721  // equivalent of GCC's -ffinite-math-only flag.
725  else
728 
729  // FIXME: add more flags to ARMBuildAttributes.h
730  // 8-bytes alignment stuff.
733 
734  // Hard float. Use both S and D registers and conform to AAPCS-VFP.
735  if (STI.isAAPCS_ABI() && TM.Options.FloatABIType == FloatABI::Hard)
737 
738  // FIXME: To support emitting this build attribute as GCC does, the
739  // -mfp16-format option and associated plumbing must be
740  // supported. For now the __fp16 type is exposed by default, so this
741  // attribute should be emitted with value 1.
744 
745  if (MMI) {
746  if (const Module *SourceModule = MMI->getModule()) {
747  // ABI_PCS_wchar_t to indicate wchar_t width
748  // FIXME: There is no way to emit value 0 (wchar_t prohibited).
749  if (auto WCharWidthValue = mdconst::extract_or_null<ConstantInt>(
750  SourceModule->getModuleFlag("wchar_size"))) {
751  int WCharWidth = WCharWidthValue->getZExtValue();
752  assert((WCharWidth == 2 || WCharWidth == 4) &&
753  "wchar_t width must be 2 or 4 bytes");
755  }
756 
757  // ABI_enum_size to indicate enum width
758  // FIXME: There is no way to emit value 0 (enums prohibited) or value 3
759  // (all enums contain a value needing 32 bits to encode).
760  if (auto EnumWidthValue = mdconst::extract_or_null<ConstantInt>(
761  SourceModule->getModuleFlag("min_enum_size"))) {
762  int EnumWidth = EnumWidthValue->getZExtValue();
763  assert((EnumWidth == 1 || EnumWidth == 4) &&
764  "Minimum enum width must be 1 or 4 bytes");
765  int EnumBuildAttr = EnumWidth == 1 ? 1 : 2;
766  ATS.emitAttribute(ARMBuildAttrs::ABI_enum_size, EnumBuildAttr);
767  }
768  }
769  }
770 
771  // We currently do not support using R9 as the TLS pointer.
772  if (STI.isRWPI())
775  else if (STI.isR9Reserved())
778  else
781 }
782 
783 //===----------------------------------------------------------------------===//
784 
786  unsigned LabelId, MCContext &Ctx) {
787 
788  MCSymbol *Label = Ctx.getOrCreateSymbol(Twine(Prefix)
789  + "PC" + Twine(FunctionNumber) + "_" + Twine(LabelId));
790  return Label;
791 }
792 
795  switch (Modifier) {
796  case ARMCP::no_modifier:
798  case ARMCP::TLSGD:
800  case ARMCP::TPOFF:
802  case ARMCP::GOTTPOFF:
804  case ARMCP::SBREL:
806  case ARMCP::GOT_PREL:
808  case ARMCP::SECREL:
810  }
811  llvm_unreachable("Invalid ARMCPModifier!");
812 }
813 
814 MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
815  unsigned char TargetFlags) {
816  if (Subtarget->isTargetMachO()) {
817  bool IsIndirect =
818  (TargetFlags & ARMII::MO_NONLAZY) && Subtarget->isGVIndirectSymbol(GV);
819 
820  if (!IsIndirect)
821  return getSymbol(GV);
822 
823  // FIXME: Remove this when Darwin transition to @GOT like syntax.
824  MCSymbol *MCSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
825  MachineModuleInfoMachO &MMIMachO =
828  GV->isThreadLocal() ? MMIMachO.getThreadLocalGVStubEntry(MCSym)
829  : MMIMachO.getGVStubEntry(MCSym);
830 
831  if (!StubSym.getPointer())
833  !GV->hasInternalLinkage());
834  return MCSym;
835  } else if (Subtarget->isTargetCOFF()) {
836  assert(Subtarget->isTargetWindows() &&
837  "Windows is the only supported COFF target");
838 
839  bool IsIndirect = (TargetFlags & ARMII::MO_DLLIMPORT);
840  if (!IsIndirect)
841  return getSymbol(GV);
842 
844  Name = "__imp_";
845  getNameWithPrefix(Name, GV);
846 
847  return OutContext.getOrCreateSymbol(Name);
848  } else if (Subtarget->isTargetELF()) {
849  return getSymbol(GV);
850  }
851  llvm_unreachable("unexpected target");
852 }
853 
854 void ARMAsmPrinter::
856  const DataLayout &DL = getDataLayout();
857  int Size = DL.getTypeAllocSize(MCPV->getType());
858 
859  ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
860 
861  if (ACPV->isPromotedGlobal()) {
862  // This constant pool entry is actually a global whose storage has been
863  // promoted into the constant pool. This global may be referenced still
864  // by debug information, and due to the way AsmPrinter is set up, the debug
865  // info is immutable by the time we decide to promote globals to constant
866  // pools. Because of this, we need to ensure we emit a symbol for the global
867  // with private linkage (the default) so debug info can refer to it.
868  //
869  // However, if this global is promoted into several functions we must ensure
870  // we don't try and emit duplicate symbols!
871  auto *ACPC = cast<ARMConstantPoolConstant>(ACPV);
872  auto *GV = ACPC->getPromotedGlobal();
873  if (!EmittedPromotedGlobalLabels.count(GV)) {
874  MCSymbol *GVSym = getSymbol(GV);
875  OutStreamer->EmitLabel(GVSym);
876  EmittedPromotedGlobalLabels.insert(GV);
877  }
878  return EmitGlobalConstant(DL, ACPC->getPromotedGlobalInit());
879  }
880 
881  MCSymbol *MCSym;
882  if (ACPV->isLSDA()) {
883  MCSym = getCurExceptionSym();
884  } else if (ACPV->isBlockAddress()) {
885  const BlockAddress *BA =
886  cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
887  MCSym = GetBlockAddressSymbol(BA);
888  } else if (ACPV->isGlobalValue()) {
889  const GlobalValue *GV = cast<ARMConstantPoolConstant>(ACPV)->getGV();
890 
891  // On Darwin, const-pool entries may get the "FOO$non_lazy_ptr" mangling, so
892  // flag the global as MO_NONLAZY.
893  unsigned char TF = Subtarget->isTargetMachO() ? ARMII::MO_NONLAZY : 0;
894  MCSym = GetARMGVSymbol(GV, TF);
895  } else if (ACPV->isMachineBasicBlock()) {
896  const MachineBasicBlock *MBB = cast<ARMConstantPoolMBB>(ACPV)->getMBB();
897  MCSym = MBB->getSymbol();
898  } else {
899  assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
900  auto Sym = cast<ARMConstantPoolSymbol>(ACPV)->getSymbol();
901  MCSym = GetExternalSymbolSymbol(Sym);
902  }
903 
904  // Create an MCSymbol for the reference.
905  const MCExpr *Expr =
907  OutContext);
908 
909  if (ACPV->getPCAdjustment()) {
910  MCSymbol *PCLabel =
912  ACPV->getLabelId(), OutContext);
913  const MCExpr *PCRelExpr = MCSymbolRefExpr::create(PCLabel, OutContext);
914  PCRelExpr =
915  MCBinaryExpr::createAdd(PCRelExpr,
917  OutContext),
918  OutContext);
919  if (ACPV->mustAddCurrentAddress()) {
920  // We want "(<expr> - .)", but MC doesn't have a concept of the '.'
921  // label, so just emit a local label end reference that instead.
923  OutStreamer->EmitLabel(DotSym);
924  const MCExpr *DotExpr = MCSymbolRefExpr::create(DotSym, OutContext);
925  PCRelExpr = MCBinaryExpr::createSub(PCRelExpr, DotExpr, OutContext);
926  }
927  Expr = MCBinaryExpr::createSub(Expr, PCRelExpr, OutContext);
928  }
929  OutStreamer->EmitValue(Expr, Size);
930 }
931 
933  const MachineOperand &MO1 = MI->getOperand(1);
934  unsigned JTI = MO1.getIndex();
935 
936  // Make sure the Thumb jump table is 4-byte aligned. This will be a nop for
937  // ARM mode tables.
938  EmitAlignment(2);
939 
940  // Emit a label for the jump table.
941  MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
942  OutStreamer->EmitLabel(JTISymbol);
943 
944  // Mark the jump table as data-in-code.
945  OutStreamer->EmitDataRegion(MCDR_DataRegionJT32);
946 
947  // Emit each entry of the table.
948  const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
949  const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
950  const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
951 
952  for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
953  MachineBasicBlock *MBB = JTBBs[i];
954  // Construct an MCExpr for the entry. We want a value of the form:
955  // (BasicBlockAddr - TableBeginAddr)
956  //
957  // For example, a table with entries jumping to basic blocks BB0 and BB1
958  // would look like:
959  // LJTI_0_0:
960  // .word (LBB0 - LJTI_0_0)
961  // .word (LBB1 - LJTI_0_0)
962  const MCExpr *Expr = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext);
963 
964  if (isPositionIndependent() || Subtarget->isROPI())
965  Expr = MCBinaryExpr::createSub(Expr, MCSymbolRefExpr::create(JTISymbol,
966  OutContext),
967  OutContext);
968  // If we're generating a table of Thumb addresses in static relocation
969  // model, we need to add one to keep interworking correctly.
970  else if (AFI->isThumbFunction())
972  OutContext);
973  OutStreamer->EmitValue(Expr, 4);
974  }
975  // Mark the end of jump table data-in-code region.
976  OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
977 }
978 
980  const MachineOperand &MO1 = MI->getOperand(1);
981  unsigned JTI = MO1.getIndex();
982 
983  // Make sure the Thumb jump table is 4-byte aligned. This will be a nop for
984  // ARM mode tables.
985  EmitAlignment(2);
986 
987  // Emit a label for the jump table.
988  MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
989  OutStreamer->EmitLabel(JTISymbol);
990 
991  // Emit each entry of the table.
992  const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
993  const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
994  const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
995 
996  for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
997  MachineBasicBlock *MBB = JTBBs[i];
998  const MCExpr *MBBSymbolExpr = MCSymbolRefExpr::create(MBB->getSymbol(),
999  OutContext);
1000  // If this isn't a TBB or TBH, the entries are direct branch instructions.
1002  .addExpr(MBBSymbolExpr)
1003  .addImm(ARMCC::AL)
1004  .addReg(0));
1005  }
1006 }
1007 
1009  unsigned OffsetWidth) {
1010  assert((OffsetWidth == 1 || OffsetWidth == 2) && "invalid tbb/tbh width");
1011  const MachineOperand &MO1 = MI->getOperand(1);
1012  unsigned JTI = MO1.getIndex();
1013 
1014  if (Subtarget->isThumb1Only())
1015  EmitAlignment(2);
1016 
1017  MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
1018  OutStreamer->EmitLabel(JTISymbol);
1019 
1020  // Emit each entry of the table.
1021  const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
1022  const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
1023  const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1024 
1025  // Mark the jump table as data-in-code.
1026  OutStreamer->EmitDataRegion(OffsetWidth == 1 ? MCDR_DataRegionJT8
1028 
1029  for (auto MBB : JTBBs) {
1030  const MCExpr *MBBSymbolExpr = MCSymbolRefExpr::create(MBB->getSymbol(),
1031  OutContext);
1032  // Otherwise it's an offset from the dispatch instruction. Construct an
1033  // MCExpr for the entry. We want a value of the form:
1034  // (BasicBlockAddr - TBBInstAddr + 4) / 2
1035  //
1036  // For example, a TBB table with entries jumping to basic blocks BB0 and BB1
1037  // would look like:
1038  // LJTI_0_0:
1039  // .byte (LBB0 - (LCPI0_0 + 4)) / 2
1040  // .byte (LBB1 - (LCPI0_0 + 4)) / 2
1041  // where LCPI0_0 is a label defined just before the TBB instruction using
1042  // this table.
1043  MCSymbol *TBInstPC = GetCPISymbol(MI->getOperand(0).getImm());
1044  const MCExpr *Expr = MCBinaryExpr::createAdd(
1047  Expr = MCBinaryExpr::createSub(MBBSymbolExpr, Expr, OutContext);
1049  OutContext);
1050  OutStreamer->EmitValue(Expr, OffsetWidth);
1051  }
1052  // Mark the end of jump table data-in-code region. 32-bit offsets use
1053  // actual branch instructions here, so we don't mark those as a data-region
1054  // at all.
1055  OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
1056 
1057  // Make sure the next instruction is 2-byte aligned.
1058  EmitAlignment(1);
1059 }
1060 
1061 void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
1063  "Only instruction which are involved into frame setup code are allowed");
1064 
1065  MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
1066  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1067  const MachineFunction &MF = *MI->getParent()->getParent();
1068  const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
1069  const ARMFunctionInfo &AFI = *MF.getInfo<ARMFunctionInfo>();
1070 
1071  unsigned FramePtr = RegInfo->getFrameRegister(MF);
1072  unsigned Opc = MI->getOpcode();
1073  unsigned SrcReg, DstReg;
1074 
1075  if (Opc == ARM::tPUSH || Opc == ARM::tLDRpci) {
1076  // Two special cases:
1077  // 1) tPUSH does not have src/dst regs.
1078  // 2) for Thumb1 code we sometimes materialize the constant via constpool
1079  // load. Yes, this is pretty fragile, but for now I don't see better
1080  // way... :(
1081  SrcReg = DstReg = ARM::SP;
1082  } else {
1083  SrcReg = MI->getOperand(1).getReg();
1084  DstReg = MI->getOperand(0).getReg();
1085  }
1086 
1087  // Try to figure out the unwinding opcode out of src / dst regs.
1088  if (MI->mayStore()) {
1089  // Register saves.
1090  assert(DstReg == ARM::SP &&
1091  "Only stack pointer as a destination reg is supported");
1092 
1093  SmallVector<unsigned, 4> RegList;
1094  // Skip src & dst reg, and pred ops.
1095  unsigned StartOp = 2 + 2;
1096  // Use all the operands.
1097  unsigned NumOffset = 0;
1098 
1099  switch (Opc) {
1100  default:
1101  MI->print(errs());
1102  llvm_unreachable("Unsupported opcode for unwinding information");
1103  case ARM::tPUSH:
1104  // Special case here: no src & dst reg, but two extra imp ops.
1105  StartOp = 2; NumOffset = 2;
1107  case ARM::STMDB_UPD:
1108  case ARM::t2STMDB_UPD:
1109  case ARM::VSTMDDB_UPD:
1110  assert(SrcReg == ARM::SP &&
1111  "Only stack pointer as a source reg is supported");
1112  for (unsigned i = StartOp, NumOps = MI->getNumOperands() - NumOffset;
1113  i != NumOps; ++i) {
1114  const MachineOperand &MO = MI->getOperand(i);
1115  // Actually, there should never be any impdef stuff here. Skip it
1116  // temporary to workaround PR11902.
1117  if (MO.isImplicit())
1118  continue;
1119  RegList.push_back(MO.getReg());
1120  }
1121  break;
1122  case ARM::STR_PRE_IMM:
1123  case ARM::STR_PRE_REG:
1124  case ARM::t2STR_PRE:
1125  assert(MI->getOperand(2).getReg() == ARM::SP &&
1126  "Only stack pointer as a source reg is supported");
1127  RegList.push_back(SrcReg);
1128  break;
1129  }
1131  ATS.emitRegSave(RegList, Opc == ARM::VSTMDDB_UPD);
1132  } else {
1133  // Changes of stack / frame pointer.
1134  if (SrcReg == ARM::SP) {
1135  int64_t Offset = 0;
1136  switch (Opc) {
1137  default:
1138  MI->print(errs());
1139  llvm_unreachable("Unsupported opcode for unwinding information");
1140  case ARM::MOVr:
1141  case ARM::tMOVr:
1142  Offset = 0;
1143  break;
1144  case ARM::ADDri:
1145  case ARM::t2ADDri:
1146  Offset = -MI->getOperand(2).getImm();
1147  break;
1148  case ARM::SUBri:
1149  case ARM::t2SUBri:
1150  Offset = MI->getOperand(2).getImm();
1151  break;
1152  case ARM::tSUBspi:
1153  Offset = MI->getOperand(2).getImm()*4;
1154  break;
1155  case ARM::tADDspi:
1156  case ARM::tADDrSPi:
1157  Offset = -MI->getOperand(2).getImm()*4;
1158  break;
1159  case ARM::tLDRpci: {
1160  // Grab the constpool index and check, whether it corresponds to
1161  // original or cloned constpool entry.
1162  unsigned CPI = MI->getOperand(1).getIndex();
1163  const MachineConstantPool *MCP = MF.getConstantPool();
1164  if (CPI >= MCP->getConstants().size())
1165  CPI = AFI.getOriginalCPIdx(CPI);
1166  assert(CPI != -1U && "Invalid constpool index");
1167 
1168  // Derive the actual offset.
1169  const MachineConstantPoolEntry &CPE = MCP->getConstants()[CPI];
1170  assert(!CPE.isMachineConstantPoolEntry() && "Invalid constpool entry");
1171  // FIXME: Check for user, it should be "add" instruction!
1172  Offset = -cast<ConstantInt>(CPE.Val.ConstVal)->getSExtValue();
1173  break;
1174  }
1175  }
1176 
1178  if (DstReg == FramePtr && FramePtr != ARM::SP)
1179  // Set-up of the frame pointer. Positive values correspond to "add"
1180  // instruction.
1181  ATS.emitSetFP(FramePtr, ARM::SP, -Offset);
1182  else if (DstReg == ARM::SP) {
1183  // Change of SP by an offset. Positive values correspond to "sub"
1184  // instruction.
1185  ATS.emitPad(Offset);
1186  } else {
1187  // Move of SP to a register. Positive values correspond to an "add"
1188  // instruction.
1189  ATS.emitMovSP(DstReg, -Offset);
1190  }
1191  }
1192  } else if (DstReg == ARM::SP) {
1193  MI->print(errs());
1194  llvm_unreachable("Unsupported opcode for unwinding information");
1195  }
1196  else {
1197  MI->print(errs());
1198  llvm_unreachable("Unsupported opcode for unwinding information");
1199  }
1200  }
1201 }
1202 
1203 // Simple pseudo-instructions have their lowering (with expansion to real
1204 // instructions) auto-generated.
1205 #include "ARMGenMCPseudoLowering.inc"
1206 
1208  const DataLayout &DL = getDataLayout();
1209  MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
1210  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1211 
1212  // If we just ended a constant pool, mark it as such.
1213  if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
1214  OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
1215  InConstantPool = false;
1216  }
1217 
1218  // Emit unwinding stuff for frame-related instructions
1219  if (Subtarget->isTargetEHABICompatible() &&
1221  EmitUnwindingInstruction(MI);
1222 
1223  // Do any auto-generated pseudo lowerings.
1224  if (emitPseudoExpansionLowering(*OutStreamer, MI))
1225  return;
1226 
1228  "Pseudo flag setting opcode should be expanded early");
1229 
1230  // Check for manual lowerings.
1231  unsigned Opc = MI->getOpcode();
1232  switch (Opc) {
1233  case ARM::t2MOVi32imm: llvm_unreachable("Should be lowered by thumb2it pass");
1234  case ARM::DBG_VALUE: llvm_unreachable("Should be handled by generic printing");
1235  case ARM::LEApcrel:
1236  case ARM::tLEApcrel:
1237  case ARM::t2LEApcrel: {
1238  // FIXME: Need to also handle globals and externals
1239  MCSymbol *CPISymbol = GetCPISymbol(MI->getOperand(1).getIndex());
1241  ARM::t2LEApcrel ? ARM::t2ADR
1242  : (MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR
1243  : ARM::ADR))
1244  .addReg(MI->getOperand(0).getReg())
1245  .addExpr(MCSymbolRefExpr::create(CPISymbol, OutContext))
1246  // Add predicate operands.
1247  .addImm(MI->getOperand(2).getImm())
1248  .addReg(MI->getOperand(3).getReg()));
1249  return;
1250  }
1251  case ARM::LEApcrelJT:
1252  case ARM::tLEApcrelJT:
1253  case ARM::t2LEApcrelJT: {
1254  MCSymbol *JTIPICSymbol =
1255  GetARMJTIPICJumpTableLabel(MI->getOperand(1).getIndex());
1257  ARM::t2LEApcrelJT ? ARM::t2ADR
1258  : (MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR
1259  : ARM::ADR))
1260  .addReg(MI->getOperand(0).getReg())
1261  .addExpr(MCSymbolRefExpr::create(JTIPICSymbol, OutContext))
1262  // Add predicate operands.
1263  .addImm(MI->getOperand(2).getImm())
1264  .addReg(MI->getOperand(3).getReg()));
1265  return;
1266  }
1267  // Darwin call instructions are just normal call instructions with different
1268  // clobber semantics (they clobber R9).
1269  case ARM::BX_CALL: {
1271  .addReg(ARM::LR)
1272  .addReg(ARM::PC)
1273  // Add predicate operands.
1274  .addImm(ARMCC::AL)
1275  .addReg(0)
1276  // Add 's' bit operand (always reg0 for this)
1277  .addReg(0));
1278 
1280  .addReg(MI->getOperand(0).getReg()));
1281  return;
1282  }
1283  case ARM::tBX_CALL: {
1284  if (Subtarget->hasV5TOps())
1285  llvm_unreachable("Expected BLX to be selected for v5t+");
1286 
1287  // On ARM v4t, when doing a call from thumb mode, we need to ensure
1288  // that the saved lr has its LSB set correctly (the arch doesn't
1289  // have blx).
1290  // So here we generate a bl to a small jump pad that does bx rN.
1291  // The jump pads are emitted after the function body.
1292 
1293  unsigned TReg = MI->getOperand(0).getReg();
1294  MCSymbol *TRegSym = nullptr;
1295  for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) {
1296  if (ThumbIndirectPads[i].first == TReg) {
1297  TRegSym = ThumbIndirectPads[i].second;
1298  break;
1299  }
1300  }
1301 
1302  if (!TRegSym) {
1303  TRegSym = OutContext.createTempSymbol();
1304  ThumbIndirectPads.push_back(std::make_pair(TReg, TRegSym));
1305  }
1306 
1307  // Create a link-saving branch to the Reg Indirect Jump Pad.
1309  // Predicate comes first here.
1310  .addImm(ARMCC::AL).addReg(0)
1311  .addExpr(MCSymbolRefExpr::create(TRegSym, OutContext)));
1312  return;
1313  }
1314  case ARM::BMOVPCRX_CALL: {
1316  .addReg(ARM::LR)
1317  .addReg(ARM::PC)
1318  // Add predicate operands.
1319  .addImm(ARMCC::AL)
1320  .addReg(0)
1321  // Add 's' bit operand (always reg0 for this)
1322  .addReg(0));
1323 
1325  .addReg(ARM::PC)
1326  .addReg(MI->getOperand(0).getReg())
1327  // Add predicate operands.
1328  .addImm(ARMCC::AL)
1329  .addReg(0)
1330  // Add 's' bit operand (always reg0 for this)
1331  .addReg(0));
1332  return;
1333  }
1334  case ARM::BMOVPCB_CALL: {
1336  .addReg(ARM::LR)
1337  .addReg(ARM::PC)
1338  // Add predicate operands.
1339  .addImm(ARMCC::AL)
1340  .addReg(0)
1341  // Add 's' bit operand (always reg0 for this)
1342  .addReg(0));
1343 
1344  const MachineOperand &Op = MI->getOperand(0);
1345  const GlobalValue *GV = Op.getGlobal();
1346  const unsigned TF = Op.getTargetFlags();
1347  MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1348  const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
1350  .addExpr(GVSymExpr)
1351  // Add predicate operands.
1352  .addImm(ARMCC::AL)
1353  .addReg(0));
1354  return;
1355  }
1356  case ARM::MOVi16_ga_pcrel:
1357  case ARM::t2MOVi16_ga_pcrel: {
1358  MCInst TmpInst;
1359  TmpInst.setOpcode(Opc == ARM::MOVi16_ga_pcrel? ARM::MOVi16 : ARM::t2MOVi16);
1360  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
1361 
1362  unsigned TF = MI->getOperand(1).getTargetFlags();
1363  const GlobalValue *GV = MI->getOperand(1).getGlobal();
1364  MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1365  const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
1366 
1367  MCSymbol *LabelSym =
1369  MI->getOperand(2).getImm(), OutContext);
1370  const MCExpr *LabelSymExpr= MCSymbolRefExpr::create(LabelSym, OutContext);
1371  unsigned PCAdj = (Opc == ARM::MOVi16_ga_pcrel) ? 8 : 4;
1372  const MCExpr *PCRelExpr =
1374  MCBinaryExpr::createAdd(LabelSymExpr,
1377  TmpInst.addOperand(MCOperand::createExpr(PCRelExpr));
1378 
1379  // Add predicate operands.
1381  TmpInst.addOperand(MCOperand::createReg(0));
1382  // Add 's' bit operand (always reg0 for this)
1383  TmpInst.addOperand(MCOperand::createReg(0));
1384  EmitToStreamer(*OutStreamer, TmpInst);
1385  return;
1386  }
1387  case ARM::MOVTi16_ga_pcrel:
1388  case ARM::t2MOVTi16_ga_pcrel: {
1389  MCInst TmpInst;
1390  TmpInst.setOpcode(Opc == ARM::MOVTi16_ga_pcrel
1391  ? ARM::MOVTi16 : ARM::t2MOVTi16);
1392  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
1393  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(1).getReg()));
1394 
1395  unsigned TF = MI->getOperand(2).getTargetFlags();
1396  const GlobalValue *GV = MI->getOperand(2).getGlobal();
1397  MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1398  const MCExpr *GVSymExpr = MCSymbolRefExpr::create(GVSym, OutContext);
1399 
1400  MCSymbol *LabelSym =
1402  MI->getOperand(3).getImm(), OutContext);
1403  const MCExpr *LabelSymExpr= MCSymbolRefExpr::create(LabelSym, OutContext);
1404  unsigned PCAdj = (Opc == ARM::MOVTi16_ga_pcrel) ? 8 : 4;
1405  const MCExpr *PCRelExpr =
1407  MCBinaryExpr::createAdd(LabelSymExpr,
1410  TmpInst.addOperand(MCOperand::createExpr(PCRelExpr));
1411  // Add predicate operands.
1413  TmpInst.addOperand(MCOperand::createReg(0));
1414  // Add 's' bit operand (always reg0 for this)
1415  TmpInst.addOperand(MCOperand::createReg(0));
1416  EmitToStreamer(*OutStreamer, TmpInst);
1417  return;
1418  }
1419  case ARM::tPICADD: {
1420  // This is a pseudo op for a label + instruction sequence, which looks like:
1421  // LPC0:
1422  // add r0, pc
1423  // This adds the address of LPC0 to r0.
1424 
1425  // Emit the label.
1428  MI->getOperand(2).getImm(), OutContext));
1429 
1430  // Form and emit the add.
1431  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr)
1432  .addReg(MI->getOperand(0).getReg())
1433  .addReg(MI->getOperand(0).getReg())
1434  .addReg(ARM::PC)
1435  // Add predicate operands.
1436  .addImm(ARMCC::AL)
1437  .addReg(0));
1438  return;
1439  }
1440  case ARM::PICADD: {
1441  // This is a pseudo op for a label + instruction sequence, which looks like:
1442  // LPC0:
1443  // add r0, pc, r0
1444  // This adds the address of LPC0 to r0.
1445 
1446  // Emit the label.
1449  MI->getOperand(2).getImm(), OutContext));
1450 
1451  // Form and emit the add.
1453  .addReg(MI->getOperand(0).getReg())
1454  .addReg(ARM::PC)
1455  .addReg(MI->getOperand(1).getReg())
1456  // Add predicate operands.
1457  .addImm(MI->getOperand(3).getImm())
1458  .addReg(MI->getOperand(4).getReg())
1459  // Add 's' bit operand (always reg0 for this)
1460  .addReg(0));
1461  return;
1462  }
1463  case ARM::PICSTR:
1464  case ARM::PICSTRB:
1465  case ARM::PICSTRH:
1466  case ARM::PICLDR:
1467  case ARM::PICLDRB:
1468  case ARM::PICLDRH:
1469  case ARM::PICLDRSB:
1470  case ARM::PICLDRSH: {
1471  // This is a pseudo op for a label + instruction sequence, which looks like:
1472  // LPC0:
1473  // OP r0, [pc, r0]
1474  // The LCP0 label is referenced by a constant pool entry in order to get
1475  // a PC-relative address at the ldr instruction.
1476 
1477  // Emit the label.
1480  MI->getOperand(2).getImm(), OutContext));
1481 
1482  // Form and emit the load
1483  unsigned Opcode;
1484  switch (MI->getOpcode()) {
1485  default:
1486  llvm_unreachable("Unexpected opcode!");
1487  case ARM::PICSTR: Opcode = ARM::STRrs; break;
1488  case ARM::PICSTRB: Opcode = ARM::STRBrs; break;
1489  case ARM::PICSTRH: Opcode = ARM::STRH; break;
1490  case ARM::PICLDR: Opcode = ARM::LDRrs; break;
1491  case ARM::PICLDRB: Opcode = ARM::LDRBrs; break;
1492  case ARM::PICLDRH: Opcode = ARM::LDRH; break;
1493  case ARM::PICLDRSB: Opcode = ARM::LDRSB; break;
1494  case ARM::PICLDRSH: Opcode = ARM::LDRSH; break;
1495  }
1497  .addReg(MI->getOperand(0).getReg())
1498  .addReg(ARM::PC)
1499  .addReg(MI->getOperand(1).getReg())
1500  .addImm(0)
1501  // Add predicate operands.
1502  .addImm(MI->getOperand(3).getImm())
1503  .addReg(MI->getOperand(4).getReg()));
1504 
1505  return;
1506  }
1507  case ARM::CONSTPOOL_ENTRY: {
1508  if (Subtarget->genExecuteOnly())
1509  llvm_unreachable("execute-only should not generate constant pools");
1510 
1511  /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool
1512  /// in the function. The first operand is the ID# for this instruction, the
1513  /// second is the index into the MachineConstantPool that this is, the third
1514  /// is the size in bytes of this constant pool entry.
1515  /// The required alignment is specified on the basic block holding this MI.
1516  unsigned LabelId = (unsigned)MI->getOperand(0).getImm();
1517  unsigned CPIdx = (unsigned)MI->getOperand(1).getIndex();
1518 
1519  // If this is the first entry of the pool, mark it.
1520  if (!InConstantPool) {
1521  OutStreamer->EmitDataRegion(MCDR_DataRegion);
1522  InConstantPool = true;
1523  }
1524 
1525  OutStreamer->EmitLabel(GetCPISymbol(LabelId));
1526 
1527  const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx];
1528  if (MCPE.isMachineConstantPoolEntry())
1530  else
1531  EmitGlobalConstant(DL, MCPE.Val.ConstVal);
1532  return;
1533  }
1534  case ARM::JUMPTABLE_ADDRS:
1535  EmitJumpTableAddrs(MI);
1536  return;
1537  case ARM::JUMPTABLE_INSTS:
1538  EmitJumpTableInsts(MI);
1539  return;
1540  case ARM::JUMPTABLE_TBB:
1541  case ARM::JUMPTABLE_TBH:
1542  EmitJumpTableTBInst(MI, MI->getOpcode() == ARM::JUMPTABLE_TBB ? 1 : 2);
1543  return;
1544  case ARM::t2BR_JT: {
1545  // Lower and emit the instruction itself, then the jump table following it.
1547  .addReg(ARM::PC)
1548  .addReg(MI->getOperand(0).getReg())
1549  // Add predicate operands.
1550  .addImm(ARMCC::AL)
1551  .addReg(0));
1552  return;
1553  }
1554  case ARM::t2TBB_JT:
1555  case ARM::t2TBH_JT: {
1556  unsigned Opc = MI->getOpcode() == ARM::t2TBB_JT ? ARM::t2TBB : ARM::t2TBH;
1557  // Lower and emit the PC label, then the instruction itself.
1558  OutStreamer->EmitLabel(GetCPISymbol(MI->getOperand(3).getImm()));
1560  .addReg(MI->getOperand(0).getReg())
1561  .addReg(MI->getOperand(1).getReg())
1562  // Add predicate operands.
1563  .addImm(ARMCC::AL)
1564  .addReg(0));
1565  return;
1566  }
1567  case ARM::tTBB_JT:
1568  case ARM::tTBH_JT: {
1569 
1570  bool Is8Bit = MI->getOpcode() == ARM::tTBB_JT;
1571  unsigned Base = MI->getOperand(0).getReg();
1572  unsigned Idx = MI->getOperand(1).getReg();
1573  assert(MI->getOperand(1).isKill() && "We need the index register as scratch!");
1574 
1575  // Multiply up idx if necessary.
1576  if (!Is8Bit)
1578  .addReg(Idx)
1579  .addReg(ARM::CPSR)
1580  .addReg(Idx)
1581  .addImm(1)
1582  // Add predicate operands.
1583  .addImm(ARMCC::AL)
1584  .addReg(0));
1585 
1586  if (Base == ARM::PC) {
1587  // TBB [base, idx] =
1588  // ADDS idx, idx, base
1589  // LDRB idx, [idx, #4] ; or LDRH if TBH
1590  // LSLS idx, #1
1591  // ADDS pc, pc, idx
1592 
1593  // When using PC as the base, it's important that there is no padding
1594  // between the last ADDS and the start of the jump table. The jump table
1595  // is 4-byte aligned, so we ensure we're 4 byte aligned here too.
1596  //
1597  // FIXME: Ideally we could vary the LDRB index based on the padding
1598  // between the sequence and jump table, however that relies on MCExprs
1599  // for load indexes which are currently not supported.
1600  OutStreamer->EmitCodeAlignment(4);
1601  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr)
1602  .addReg(Idx)
1603  .addReg(Idx)
1604  .addReg(Base)
1605  // Add predicate operands.
1606  .addImm(ARMCC::AL)
1607  .addReg(0));
1608 
1609  unsigned Opc = Is8Bit ? ARM::tLDRBi : ARM::tLDRHi;
1611  .addReg(Idx)
1612  .addReg(Idx)
1613  .addImm(Is8Bit ? 4 : 2)
1614  // Add predicate operands.
1615  .addImm(ARMCC::AL)
1616  .addReg(0));
1617  } else {
1618  // TBB [base, idx] =
1619  // LDRB idx, [base, idx] ; or LDRH if TBH
1620  // LSLS idx, #1
1621  // ADDS pc, pc, idx
1622 
1623  unsigned Opc = Is8Bit ? ARM::tLDRBr : ARM::tLDRHr;
1625  .addReg(Idx)
1626  .addReg(Base)
1627  .addReg(Idx)
1628  // Add predicate operands.
1629  .addImm(ARMCC::AL)
1630  .addReg(0));
1631  }
1632 
1634  .addReg(Idx)
1635  .addReg(ARM::CPSR)
1636  .addReg(Idx)
1637  .addImm(1)
1638  // Add predicate operands.
1639  .addImm(ARMCC::AL)
1640  .addReg(0));
1641 
1642  OutStreamer->EmitLabel(GetCPISymbol(MI->getOperand(3).getImm()));
1643  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr)
1644  .addReg(ARM::PC)
1645  .addReg(ARM::PC)
1646  .addReg(Idx)
1647  // Add predicate operands.
1648  .addImm(ARMCC::AL)
1649  .addReg(0));
1650  return;
1651  }
1652  case ARM::tBR_JTr:
1653  case ARM::BR_JTr: {
1654  // Lower and emit the instruction itself, then the jump table following it.
1655  // mov pc, target
1656  MCInst TmpInst;
1657  unsigned Opc = MI->getOpcode() == ARM::BR_JTr ?
1658  ARM::MOVr : ARM::tMOVr;
1659  TmpInst.setOpcode(Opc);
1660  TmpInst.addOperand(MCOperand::createReg(ARM::PC));
1661  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
1662  // Add predicate operands.
1664  TmpInst.addOperand(MCOperand::createReg(0));
1665  // Add 's' bit operand (always reg0 for this)
1666  if (Opc == ARM::MOVr)
1667  TmpInst.addOperand(MCOperand::createReg(0));
1668  EmitToStreamer(*OutStreamer, TmpInst);
1669  return;
1670  }
1671  case ARM::BR_JTm: {
1672  // Lower and emit the instruction itself, then the jump table following it.
1673  // ldr pc, target
1674  MCInst TmpInst;
1675  if (MI->getOperand(1).getReg() == 0) {
1676  // literal offset
1677  TmpInst.setOpcode(ARM::LDRi12);
1678  TmpInst.addOperand(MCOperand::createReg(ARM::PC));
1679  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
1680  TmpInst.addOperand(MCOperand::createImm(MI->getOperand(2).getImm()));
1681  } else {
1682  TmpInst.setOpcode(ARM::LDRrs);
1683  TmpInst.addOperand(MCOperand::createReg(ARM::PC));
1684  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg()));
1685  TmpInst.addOperand(MCOperand::createReg(MI->getOperand(1).getReg()));
1686  TmpInst.addOperand(MCOperand::createImm(0));
1687  }
1688  // Add predicate operands.
1690  TmpInst.addOperand(MCOperand::createReg(0));
1691  EmitToStreamer(*OutStreamer, TmpInst);
1692  return;
1693  }
1694  case ARM::BR_JTadd: {
1695  // Lower and emit the instruction itself, then the jump table following it.
1696  // add pc, target, idx
1698  .addReg(ARM::PC)
1699  .addReg(MI->getOperand(0).getReg())
1700  .addReg(MI->getOperand(1).getReg())
1701  // Add predicate operands.
1702  .addImm(ARMCC::AL)
1703  .addReg(0)
1704  // Add 's' bit operand (always reg0 for this)
1705  .addReg(0));
1706  return;
1707  }
1708  case ARM::SPACE:
1709  OutStreamer->EmitZeros(MI->getOperand(1).getImm());
1710  return;
1711  case ARM::TRAP: {
1712  // Non-Darwin binutils don't yet support the "trap" mnemonic.
1713  // FIXME: Remove this special case when they do.
1714  if (!Subtarget->isTargetMachO()) {
1715  uint32_t Val = 0xe7ffdefeUL;
1716  OutStreamer->AddComment("trap");
1717  ATS.emitInst(Val);
1718  return;
1719  }
1720  break;
1721  }
1722  case ARM::TRAPNaCl: {
1723  uint32_t Val = 0xe7fedef0UL;
1724  OutStreamer->AddComment("trap");
1725  ATS.emitInst(Val);
1726  return;
1727  }
1728  case ARM::tTRAP: {
1729  // Non-Darwin binutils don't yet support the "trap" mnemonic.
1730  // FIXME: Remove this special case when they do.
1731  if (!Subtarget->isTargetMachO()) {
1732  uint16_t Val = 0xdefe;
1733  OutStreamer->AddComment("trap");
1734  ATS.emitInst(Val, 'n');
1735  return;
1736  }
1737  break;
1738  }
1739  case ARM::t2Int_eh_sjlj_setjmp:
1740  case ARM::t2Int_eh_sjlj_setjmp_nofp:
1741  case ARM::tInt_eh_sjlj_setjmp: {
1742  // Two incoming args: GPR:$src, GPR:$val
1743  // mov $val, pc
1744  // adds $val, #7
1745  // str $val, [$src, #4]
1746  // movs r0, #0
1747  // b LSJLJEH
1748  // movs r0, #1
1749  // LSJLJEH:
1750  unsigned SrcReg = MI->getOperand(0).getReg();
1751  unsigned ValReg = MI->getOperand(1).getReg();
1752  MCSymbol *Label = OutContext.createTempSymbol("SJLJEH", false, true);
1753  OutStreamer->AddComment("eh_setjmp begin");
1755  .addReg(ValReg)
1756  .addReg(ARM::PC)
1757  // Predicate.
1758  .addImm(ARMCC::AL)
1759  .addReg(0));
1760 
1762  .addReg(ValReg)
1763  // 's' bit operand
1764  .addReg(ARM::CPSR)
1765  .addReg(ValReg)
1766  .addImm(7)
1767  // Predicate.
1768  .addImm(ARMCC::AL)
1769  .addReg(0));
1770 
1772  .addReg(ValReg)
1773  .addReg(SrcReg)
1774  // The offset immediate is #4. The operand value is scaled by 4 for the
1775  // tSTR instruction.
1776  .addImm(1)
1777  // Predicate.
1778  .addImm(ARMCC::AL)
1779  .addReg(0));
1780 
1782  .addReg(ARM::R0)
1783  .addReg(ARM::CPSR)
1784  .addImm(0)
1785  // Predicate.
1786  .addImm(ARMCC::AL)
1787  .addReg(0));
1788 
1789  const MCExpr *SymbolExpr = MCSymbolRefExpr::create(Label, OutContext);
1791  .addExpr(SymbolExpr)
1792  .addImm(ARMCC::AL)
1793  .addReg(0));
1794 
1795  OutStreamer->AddComment("eh_setjmp end");
1797  .addReg(ARM::R0)
1798  .addReg(ARM::CPSR)
1799  .addImm(1)
1800  // Predicate.
1801  .addImm(ARMCC::AL)
1802  .addReg(0));
1803 
1804  OutStreamer->EmitLabel(Label);
1805  return;
1806  }
1807 
1808  case ARM::Int_eh_sjlj_setjmp_nofp:
1809  case ARM::Int_eh_sjlj_setjmp: {
1810  // Two incoming args: GPR:$src, GPR:$val
1811  // add $val, pc, #8
1812  // str $val, [$src, #+4]
1813  // mov r0, #0
1814  // add pc, pc, #0
1815  // mov r0, #1
1816  unsigned SrcReg = MI->getOperand(0).getReg();
1817  unsigned ValReg = MI->getOperand(1).getReg();
1818 
1819  OutStreamer->AddComment("eh_setjmp begin");
1821  .addReg(ValReg)
1822  .addReg(ARM::PC)
1823  .addImm(8)
1824  // Predicate.
1825  .addImm(ARMCC::AL)
1826  .addReg(0)
1827  // 's' bit operand (always reg0 for this).
1828  .addReg(0));
1829 
1831  .addReg(ValReg)
1832  .addReg(SrcReg)
1833  .addImm(4)
1834  // Predicate.
1835  .addImm(ARMCC::AL)
1836  .addReg(0));
1837 
1839  .addReg(ARM::R0)
1840  .addImm(0)
1841  // Predicate.
1842  .addImm(ARMCC::AL)
1843  .addReg(0)
1844  // 's' bit operand (always reg0 for this).
1845  .addReg(0));
1846 
1848  .addReg(ARM::PC)
1849  .addReg(ARM::PC)
1850  .addImm(0)
1851  // Predicate.
1852  .addImm(ARMCC::AL)
1853  .addReg(0)
1854  // 's' bit operand (always reg0 for this).
1855  .addReg(0));
1856 
1857  OutStreamer->AddComment("eh_setjmp end");
1859  .addReg(ARM::R0)
1860  .addImm(1)
1861  // Predicate.
1862  .addImm(ARMCC::AL)
1863  .addReg(0)
1864  // 's' bit operand (always reg0 for this).
1865  .addReg(0));
1866  return;
1867  }
1868  case ARM::Int_eh_sjlj_longjmp: {
1869  // ldr sp, [$src, #8]
1870  // ldr $scratch, [$src, #4]
1871  // ldr r7, [$src]
1872  // bx $scratch
1873  unsigned SrcReg = MI->getOperand(0).getReg();
1874  unsigned ScratchReg = MI->getOperand(1).getReg();
1876  .addReg(ARM::SP)
1877  .addReg(SrcReg)
1878  .addImm(8)
1879  // Predicate.
1880  .addImm(ARMCC::AL)
1881  .addReg(0));
1882 
1884  .addReg(ScratchReg)
1885  .addReg(SrcReg)
1886  .addImm(4)
1887  // Predicate.
1888  .addImm(ARMCC::AL)
1889  .addReg(0));
1890 
1892  .addReg(ARM::R7)
1893  .addReg(SrcReg)
1894  .addImm(0)
1895  // Predicate.
1896  .addImm(ARMCC::AL)
1897  .addReg(0));
1898 
1900  .addReg(ScratchReg)
1901  // Predicate.
1902  .addImm(ARMCC::AL)
1903  .addReg(0));
1904  return;
1905  }
1906  case ARM::tInt_eh_sjlj_longjmp: {
1907  // ldr $scratch, [$src, #8]
1908  // mov sp, $scratch
1909  // ldr $scratch, [$src, #4]
1910  // ldr r7, [$src]
1911  // bx $scratch
1912  unsigned SrcReg = MI->getOperand(0).getReg();
1913  unsigned ScratchReg = MI->getOperand(1).getReg();
1914 
1916  .addReg(ScratchReg)
1917  .addReg(SrcReg)
1918  // The offset immediate is #8. The operand value is scaled by 4 for the
1919  // tLDR instruction.
1920  .addImm(2)
1921  // Predicate.
1922  .addImm(ARMCC::AL)
1923  .addReg(0));
1924 
1926  .addReg(ARM::SP)
1927  .addReg(ScratchReg)
1928  // Predicate.
1929  .addImm(ARMCC::AL)
1930  .addReg(0));
1931 
1933  .addReg(ScratchReg)
1934  .addReg(SrcReg)
1935  .addImm(1)
1936  // Predicate.
1937  .addImm(ARMCC::AL)
1938  .addReg(0));
1939 
1941  .addReg(ARM::R7)
1942  .addReg(SrcReg)
1943  .addImm(0)
1944  // Predicate.
1945  .addImm(ARMCC::AL)
1946  .addReg(0));
1947 
1949  .addReg(ScratchReg)
1950  // Predicate.
1951  .addImm(ARMCC::AL)
1952  .addReg(0));
1953  return;
1954  }
1955  case ARM::tInt_WIN_eh_sjlj_longjmp: {
1956  // ldr.w r11, [$src, #0]
1957  // ldr.w sp, [$src, #8]
1958  // ldr.w pc, [$src, #4]
1959 
1960  unsigned SrcReg = MI->getOperand(0).getReg();
1961 
1962  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2LDRi12)
1963  .addReg(ARM::R11)
1964  .addReg(SrcReg)
1965  .addImm(0)
1966  // Predicate
1967  .addImm(ARMCC::AL)
1968  .addReg(0));
1969  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2LDRi12)
1970  .addReg(ARM::SP)
1971  .addReg(SrcReg)
1972  .addImm(8)
1973  // Predicate
1974  .addImm(ARMCC::AL)
1975  .addReg(0));
1976  EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2LDRi12)
1977  .addReg(ARM::PC)
1978  .addReg(SrcReg)
1979  .addImm(4)
1980  // Predicate
1981  .addImm(ARMCC::AL)
1982  .addReg(0));
1983  return;
1984  }
1985  case ARM::PATCHABLE_FUNCTION_ENTER:
1987  return;
1988  case ARM::PATCHABLE_FUNCTION_EXIT:
1990  return;
1991  case ARM::PATCHABLE_TAIL_CALL:
1993  return;
1994  }
1995 
1996  MCInst TmpInst;
1997  LowerARMMachineInstrToMCInst(MI, TmpInst, *this);
1998 
1999  EmitToStreamer(*OutStreamer, TmpInst);
2000 }
2001 
2002 //===----------------------------------------------------------------------===//
2003 // Target Registry Stuff
2004 //===----------------------------------------------------------------------===//
2005 
2006 // Force static initialization.
2007 extern "C" void LLVMInitializeARMAsmPrinter() {
2012 }
unsigned getTargetFlags() const
virtual void EmitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
Definition: AsmPrinter.cpp:425
MachineConstantPoolValue * MachineCPVal
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
Definition: ARMBaseInfo.h:303
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:192
void push_back(const T &Elt)
Definition: SmallVector.h:212
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
StringRef getTargetFeatureString() const
unsigned NoTrappingFPMath
NoTrappingFPMath - This flag is enabled when the -enable-no-trapping-fp-math is specified on the comm...
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
bool isTargetGNUAEABI() const
Definition: ARMSubtarget.h:605
union llvm::MachineConstantPoolEntry::@132 Val
The constant itself.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void EmitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
const std::vector< MachineJumpTableEntry > & getJumpTables() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:93
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:305
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
PointerTy getPointer() const
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:281
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 EmitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth)
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:572
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:88
virtual void print(raw_ostream &O, const Module *M) const
print - Print out the internal state of the pass.
Definition: Pass.cpp:117
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:137
ARMConstantPoolValue - ARM specific constantpool value.
unsigned getReg() const
getReg - Returns the register number.
Target specific streamer interface.
Definition: MCStreamer.h:78
virtual void emitPad(int64_t Offset)
const MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:96
unsigned getSubReg() const
Global Offset Table, Thread Pointer Offset.
unsigned char getPCAdjustment() const
bool isTargetCOFF() const
Definition: ARMSubtarget.h:589
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:254
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
unsigned second
MachineBasicBlock reference.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This uses the EmitInstruction() method to print assembly for each instruction...
virtual void finishAttributeSection()
setjmp/longjmp based exceptions
bool isThumb1Only() const
Definition: ARMSubtarget.h:650
bool isTargetMuslAEABI() const
Definition: ARMSubtarget.h:610
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI)
Global Offset Table, PC Relative.
Thread Pointer Offset.
Target & getTheThumbLETarget()
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
StubValueTy & getThreadLocalGVStubEntry(MCSymbol *Sym)
static bool isThumb(const MCSubtargetInfo &STI)
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
Definition: InlineAsm.h:342
void LLVMInitializeARMAsmPrinter()
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const override
Let the target do anything it needs to do after emitting inlineasm.
return AArch64::GPR64RegClass contains(Reg)
bool genExecuteOnly() const
Definition: ARMSubtarget.h:568
void EmitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
bool isTargetELF() const
Definition: ARMSubtarget.h:590
ARMCP::ARMCPModifier getModifier() const
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
The address of a basic block.
Definition: Constants.h:813
MCContext & getContext() const
Definition: MCStreamer.h:226
Definition: BitVector.h:920
virtual void emitInst(uint32_t Inst, char Suffix='\0')
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:116
MCSuperRegIterator enumerates all super-registers of Reg.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Definition: MachineInstr.h:282
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
void EmitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:453
unsigned SubReg
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Reg
All possible values of the reg field in the ModR/M byte.
.data_region jt16
Definition: MCDirectives.h:59
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:279
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
void EmitAlignment(unsigned NumBits, const GlobalObject *GO=nullptr) const
Emit an alignment directive to the specified power of two boundary.
Target & getTheARMBETarget()
bool isGVIndirectSymbol(const GlobalValue *GV) const
True if the GV will be accessed via an indirect symbol.
void EmitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
void emitXRayTable()
Emit a table with all XRay instrumentation points.
Context object for machine code objects.
Definition: MCContext.h:59
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Definition: Triple.h:283
static const ARMMCExpr * createLower16(const MCExpr *Expr, MCContext &Ctx)
Definition: ARMMCExpr.h:43
void EmitFunctionBody()
This method emits the body and trailer for a function.
Definition: AsmPrinter.cpp:969
#define F(x, y, z)
Definition: MD5.cpp:55
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
EmitMachineConstantPoolValue - Print a machine constantpool value to the .s file. ...
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:528
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:51
bool isPositionIndependent() const
Definition: AsmPrinter.cpp:182
Target & getTheThumbBETarget()
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:280
IntType getInt() const
bool isTargetEHABICompatible() const
Definition: ARMSubtarget.h:618
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
This class is a data container for one entry in a MachineConstantPool.
static MCSymbolRefExpr::VariantKind getModifierVariantKind(ARMCP::ARMCPModifier Modifier)
StringRef getTargetCPU() const
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
static const char * getRegisterName(unsigned RegNo)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:443
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
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:124
const char * Name
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:99
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI)
virtual void emitAttribute(unsigned Attribute, unsigned Value)
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Definition: MachineInstr.h:610
.data_region jt32
Definition: MCDirectives.h:60
Address of a global value.
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O)
Streaming machine code generation interface.
Definition: MCStreamer.h:167
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
Definition: MCInstBuilder.h:32
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:215
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:107
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:84
PointerIntPair - This class implements a pair of a pointer and small integer.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
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:577
This is an important base class in LLVM.
Definition: Constant.h:42
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const GlobalValue * getGlobal() const
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
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
#define A
Definition: LargeTest.cpp:12
MCSection * getNonLazySymbolPointerSection() const
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:80
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:76
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
Definition: InlineAsm.h:336
static MCSymbol * getPICLabel(StringRef Prefix, unsigned FunctionNumber, unsigned LabelId, MCContext &Ctx)
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Definition: AsmPrinter.cpp:415
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:825
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
bool hasInternalLinkage() const
Definition: GlobalValue.h:414
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Definition: Function.h:522
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:50
TRAP - Trapping instruction.
Definition: ISDOpcodes.h:727
Thread Local Storage (General Dynamic Mode)
A function that returns a base type.
Definition: COFF.h:259
const Triple & getTargetTriple() const
unsigned convertAddSubFlagsOpcode(unsigned OldOpc)
Map pseudo instructions that imply an &#39;S&#39; bit onto real opcodes.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Definition: MCInstBuilder.h:38
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
ARMAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:582
SmallPtrSet< const GlobalVariable *, 2 > & getGlobalsPromotedToConstantPool()
FPDenormal::DenormalMode FPDenormalMode
FPDenormalMode - This flags specificies which denormal numbers the code is permitted to require...
const Constant * stripPointerCasts() const
Definition: Constant.h:153
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void EmitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
Abstract base class for all machine specific constantpool value subclasses.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MO_LO16 - On a symbol operand, this represents a relocation containing lower 16 bit of the address...
Definition: ARMBaseInfo.h:286
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCSection * getThreadLocalPointerSection() const
unsigned first
void EmitJumpTableInsts(const MachineInstr *MI)
const std::vector< MachineConstantPoolEntry > & getConstants() const
unsigned getFunctionNumber() const
Return a unique ID for the current function.
Definition: AsmPrinter.cpp:188
void setOpcode(unsigned Op)
Definition: MCInst.h:167
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
#define E
Definition: LargeTest.cpp:27
#define B
Definition: LargeTest.cpp:24
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
bool isTargetAEABI() const
Definition: ARMSubtarget.h:600
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:420
MachineOperand class - Representation of each machine instruction operand.
Module.h This file contains the declarations for the Module class.
.indirect_symbol (MachO)
Definition: MCDirectives.h:32
unsigned getOriginalCPIdx(unsigned CloneIdx) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:209
void emitTargetAttributes(const MCSubtargetInfo &STI)
Emit the build attributes that only depend on the hardware that we expect.
int64_t getImm() const
SymbolStorageClass
Storage class tells where and what the symbol represents.
Definition: COFF.h:201
.syntax (ARM/ELF)
Definition: MCDirectives.h:49
MCSymbol * getCurExceptionSym()
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void LowerARMMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, ARMAsmPrinter &AP)
bool isROPI() const
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI)
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:52
FunctionNumber(functionNumber)
Definition: LLParser.cpp:2511
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:139
static bool hasRegClassConstraint(unsigned Flag, unsigned &RC)
hasRegClassConstraint - Returns true if the flag contains a register class constraint.
Definition: InlineAsm.h:351
Section Relative (Windows TLS)
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:405
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
Representation of each machine instruction.
Definition: MachineInstr.h:59
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:121
static bool checkFunctionsAttributeConsistency(const Module &M, StringRef Attr, StringRef Value)
StringRef getValueAsString() const
Return the attribute&#39;s value as a string.
Definition: Attributes.cpp:195
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
TargetOptions Options
Definition: TargetMachine.h:95
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
Definition: Function.h:519
void EmitJumpTableAddrs(const MachineInstr *MI)
static const ARMMCExpr * createUpper16(const MCExpr *Expr, MCContext &Ctx)
Definition: ARMMCExpr.h:39
MCSubtargetInfo - Generic base class for all target subtargets.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
bool hasV5TOps() const
Definition: ARMSubtarget.h:479
Type * getType() const
getType - get type of this MachineConstantPoolValue.
void print(raw_ostream &OS, bool SkipOpers=false, bool SkipDebugLoc=false, const TargetInstrInfo *TII=nullptr) const
Debugging supportPrint this MI to OS.
const Module * getModule() const
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
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Definition: Module.h:241
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool isTargetMachO() const
Definition: ARMSubtarget.h:591
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
.data_region jt8
Definition: MCDirectives.h:58
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:463
void EmitGlobalConstant(const DataLayout &DL, const Constant *CV)
Print a general LLVM constant to the .s file.
LLVM Value Representation.
Definition: Value.h:73
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:235
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:301
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which...
Definition: ARMBaseInfo.h:316
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:554
std::string ParseARMTriple(const Triple &TT, StringRef CPU)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:262
static const unsigned FramePtr
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
bool isTargetWindows() const
Definition: ARMSubtarget.h:587
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:196
bool isThreadLocal() const
If the value is "Thread Local", its value isn&#39;t shared by the threads.
Definition: GlobalValue.h:233
IRTranslator LLVM IR MI
void addOperand(const MCOperand &Op)
Definition: MCInst.h:177
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Address of indexed Constant in Constant Pool.
Target & getTheARMLETarget()
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 MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:284
void EmitXXStructor(const DataLayout &DL, const Constant *CV) override
Targets can override this to change how global constants that are part of a C++ static/global constru...
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:123
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
Definition: MachineInstr.h:169
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:159
.end_data_region
Definition: MCDirectives.h:61
MO_HI16 - On a symbol operand, this represents a relocation containing higher 16 bit of the address...
Definition: ARMBaseInfo.h:290
bool isImplicit() const
virtual void switchVendor(StringRef Vendor)
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:59
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...