LLVM  5.0.0
ARMBaseRegisterInfo.cpp
Go to the documentation of this file.
1 //===-- ARMBaseRegisterInfo.cpp - ARM Register Information ----------------===//
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 the base ARM implementation of TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ARMBaseRegisterInfo.h"
15 #include "ARM.h"
16 #include "ARMBaseInstrInfo.h"
17 #include "ARMFrameLowering.h"
18 #include "ARMMachineFunctionInfo.h"
19 #include "ARMSubtarget.h"
22 #include "llvm/ADT/BitVector.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SmallVector.h"
35 #include "llvm/IR/Attributes.h"
36 #include "llvm/IR/Constants.h"
37 #include "llvm/IR/DebugLoc.h"
38 #include "llvm/IR/Function.h"
39 #include "llvm/IR/Type.h"
40 #include "llvm/MC/MCInstrDesc.h"
41 #include "llvm/Support/Debug.h"
48 #include <cassert>
49 #include <utility>
50 
51 #define DEBUG_TYPE "arm-register-info"
52 
53 #define GET_REGINFO_TARGET_DESC
54 #include "ARMGenRegisterInfo.inc"
55 
56 using namespace llvm;
57 
59  : ARMGenRegisterInfo(ARM::LR, 0, 0, ARM::PC) {}
60 
61 static unsigned getFramePointerReg(const ARMSubtarget &STI) {
62  return STI.useR7AsFramePointer() ? ARM::R7 : ARM::R11;
63 }
64 
65 const MCPhysReg*
67  const ARMSubtarget &STI = MF->getSubtarget<ARMSubtarget>();
68  bool UseSplitPush = STI.splitFramePushPop(*MF);
69  const MCPhysReg *RegList =
70  STI.isTargetDarwin()
71  ? CSR_iOS_SaveList
72  : (UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList);
73 
74  const Function *F = MF->getFunction();
75  if (F->getCallingConv() == CallingConv::GHC) {
76  // GHC set of callee saved regs is empty as all those regs are
77  // used for passing STG regs around
78  return CSR_NoRegs_SaveList;
79  } else if (F->hasFnAttribute("interrupt")) {
80  if (STI.isMClass()) {
81  // M-class CPUs have hardware which saves the registers needed to allow a
82  // function conforming to the AAPCS to function as a handler.
83  return UseSplitPush ? CSR_AAPCS_SplitPush_SaveList : CSR_AAPCS_SaveList;
84  } else if (F->getFnAttribute("interrupt").getValueAsString() == "FIQ") {
85  // Fast interrupt mode gives the handler a private copy of R8-R14, so less
86  // need to be saved to restore user-mode state.
87  return CSR_FIQ_SaveList;
88  } else {
89  // Generally only R13-R14 (i.e. SP, LR) are automatically preserved by
90  // exception handling.
91  return CSR_GenericInt_SaveList;
92  }
93  }
94 
95  if (STI.isTargetDarwin() && STI.getTargetLowering()->supportSwiftError() &&
96  F->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
97  return CSR_iOS_SwiftError_SaveList;
98 
100  return MF->getInfo<ARMFunctionInfo>()->isSplitCSR()
101  ? CSR_iOS_CXX_TLS_PE_SaveList
102  : CSR_iOS_CXX_TLS_SaveList;
103  return RegList;
104 }
105 
107  const MachineFunction *MF) const {
108  assert(MF && "Invalid MachineFunction pointer.");
110  MF->getInfo<ARMFunctionInfo>()->isSplitCSR())
111  return CSR_iOS_CXX_TLS_ViaCopy_SaveList;
112  return nullptr;
113 }
114 
115 const uint32_t *
117  CallingConv::ID CC) const {
118  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
119  if (CC == CallingConv::GHC)
120  // This is academic because all GHC calls are (supposed to be) tail calls
121  return CSR_NoRegs_RegMask;
122 
123  if (STI.isTargetDarwin() && STI.getTargetLowering()->supportSwiftError() &&
124  MF.getFunction()->getAttributes().hasAttrSomewhere(Attribute::SwiftError))
125  return CSR_iOS_SwiftError_RegMask;
126 
127  if (STI.isTargetDarwin() && CC == CallingConv::CXX_FAST_TLS)
128  return CSR_iOS_CXX_TLS_RegMask;
129  return STI.isTargetDarwin() ? CSR_iOS_RegMask : CSR_AAPCS_RegMask;
130 }
131 
132 const uint32_t*
134  return CSR_NoRegs_RegMask;
135 }
136 
137 const uint32_t *
140  "only know about special TLS call on Darwin");
141  return CSR_iOS_TLSCall_RegMask;
142 }
143 
144 const uint32_t *
146  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
147  if (!STI.useSoftFloat() && STI.hasVFP2() && !STI.isThumb1Only())
148  return CSR_NoRegs_RegMask;
149  else
150  return CSR_FPRegs_RegMask;
151 }
152 
153 const uint32_t *
155  CallingConv::ID CC) const {
156  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
157  // This should return a register mask that is the same as that returned by
158  // getCallPreservedMask but that additionally preserves the register used for
159  // the first i32 argument (which must also be the register used to return a
160  // single i32 return value)
161  //
162  // In case that the calling convention does not use the same register for
163  // both or otherwise does not want to enable this optimization, the function
164  // should return NULL
165  if (CC == CallingConv::GHC)
166  // This is academic because all GHC calls are (supposed to be) tail calls
167  return nullptr;
168  return STI.isTargetDarwin() ? CSR_iOS_ThisReturn_RegMask
169  : CSR_AAPCS_ThisReturn_RegMask;
170 }
171 
174  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
175  const ARMFrameLowering *TFI = getFrameLowering(MF);
176 
177  // FIXME: avoid re-calculating this every time.
178  BitVector Reserved(getNumRegs());
179  markSuperRegs(Reserved, ARM::SP);
180  markSuperRegs(Reserved, ARM::PC);
181  markSuperRegs(Reserved, ARM::FPSCR);
182  markSuperRegs(Reserved, ARM::APSR_NZCV);
183  if (TFI->hasFP(MF))
184  markSuperRegs(Reserved, getFramePointerReg(STI));
185  if (hasBasePointer(MF))
186  markSuperRegs(Reserved, BasePtr);
187  // Some targets reserve R9.
188  if (STI.isR9Reserved())
189  markSuperRegs(Reserved, ARM::R9);
190  // Reserve D16-D31 if the subtarget doesn't support them.
191  if (!STI.hasVFP3() || STI.hasD16()) {
192  static_assert(ARM::D31 == ARM::D16 + 15, "Register list not consecutive!");
193  for (unsigned R = 0; R < 16; ++R)
194  markSuperRegs(Reserved, ARM::D16 + R);
195  }
196  const TargetRegisterClass &RC = ARM::GPRPairRegClass;
197  for (unsigned Reg : RC)
198  for (MCSubRegIterator SI(Reg, this); SI.isValid(); ++SI)
199  if (Reserved.test(*SI))
200  markSuperRegs(Reserved, Reg);
201 
202  assert(checkAllSuperRegsMarked(Reserved));
203  return Reserved;
204 }
205 
206 const TargetRegisterClass *
208  const MachineFunction &) const {
209  const TargetRegisterClass *Super = RC;
211  do {
212  switch (Super->getID()) {
213  case ARM::GPRRegClassID:
214  case ARM::SPRRegClassID:
215  case ARM::DPRRegClassID:
216  case ARM::QPRRegClassID:
217  case ARM::QQPRRegClassID:
218  case ARM::QQQQPRRegClassID:
219  case ARM::GPRPairRegClassID:
220  return Super;
221  }
222  Super = *I++;
223  } while (Super);
224  return RC;
225 }
226 
227 const TargetRegisterClass *
229  const {
230  return &ARM::GPRRegClass;
231 }
232 
233 const TargetRegisterClass *
235  if (RC == &ARM::CCRRegClass)
236  return &ARM::rGPRRegClass; // Can't copy CCR registers.
237  return RC;
238 }
239 
240 unsigned
242  MachineFunction &MF) const {
243  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
244  const ARMFrameLowering *TFI = getFrameLowering(MF);
245 
246  switch (RC->getID()) {
247  default:
248  return 0;
249  case ARM::tGPRRegClassID: {
250  // hasFP ends up calling getMaxCallFrameComputed() which may not be
251  // available when getPressureLimit() is called as part of
252  // ScheduleDAGRRList.
253  bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
254  ? TFI->hasFP(MF) : true;
255  return 5 - HasFP;
256  }
257  case ARM::GPRRegClassID: {
258  bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
259  ? TFI->hasFP(MF) : true;
260  return 10 - HasFP - (STI.isR9Reserved() ? 1 : 0);
261  }
262  case ARM::SPRRegClassID: // Currently not used as 'rep' register class.
263  case ARM::DPRRegClassID:
264  return 32 - 10;
265  }
266 }
267 
268 // Get the other register in a GPRPair.
269 static unsigned getPairedGPR(unsigned Reg, bool Odd, const MCRegisterInfo *RI) {
270  for (MCSuperRegIterator Supers(Reg, RI); Supers.isValid(); ++Supers)
271  if (ARM::GPRPairRegClass.contains(*Supers))
272  return RI->getSubReg(*Supers, Odd ? ARM::gsub_1 : ARM::gsub_0);
273  return 0;
274 }
275 
276 // Resolve the RegPairEven / RegPairOdd register allocator hints.
277 void
279  ArrayRef<MCPhysReg> Order,
281  const MachineFunction &MF,
282  const VirtRegMap *VRM,
283  const LiveRegMatrix *Matrix) const {
284  const MachineRegisterInfo &MRI = MF.getRegInfo();
285  std::pair<unsigned, unsigned> Hint = MRI.getRegAllocationHint(VirtReg);
286 
287  unsigned Odd;
288  switch (Hint.first) {
289  case ARMRI::RegPairEven:
290  Odd = 0;
291  break;
292  case ARMRI::RegPairOdd:
293  Odd = 1;
294  break;
295  default:
296  TargetRegisterInfo::getRegAllocationHints(VirtReg, Order, Hints, MF, VRM);
297  return;
298  }
299 
300  // This register should preferably be even (Odd == 0) or odd (Odd == 1).
301  // Check if the other part of the pair has already been assigned, and provide
302  // the paired register as the first hint.
303  unsigned Paired = Hint.second;
304  if (Paired == 0)
305  return;
306 
307  unsigned PairedPhys = 0;
309  PairedPhys = Paired;
310  } else if (VRM && VRM->hasPhys(Paired)) {
311  PairedPhys = getPairedGPR(VRM->getPhys(Paired), Odd, this);
312  }
313 
314  // First prefer the paired physreg.
315  if (PairedPhys && is_contained(Order, PairedPhys))
316  Hints.push_back(PairedPhys);
317 
318  // Then prefer even or odd registers.
319  for (unsigned Reg : Order) {
320  if (Reg == PairedPhys || (getEncodingValue(Reg) & 1) != Odd)
321  continue;
322  // Don't provide hints that are paired to a reserved register.
323  unsigned Paired = getPairedGPR(Reg, !Odd, this);
324  if (!Paired || MRI.isReserved(Paired))
325  continue;
326  Hints.push_back(Reg);
327  }
328 }
329 
330 void
332  MachineFunction &MF) const {
334  std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(Reg);
335  if ((Hint.first == (unsigned)ARMRI::RegPairOdd ||
336  Hint.first == (unsigned)ARMRI::RegPairEven) &&
338  // If 'Reg' is one of the even / odd register pair and it's now changed
339  // (e.g. coalesced) into a different register. The other register of the
340  // pair allocation hint must be updated to reflect the relationship
341  // change.
342  unsigned OtherReg = Hint.second;
343  Hint = MRI->getRegAllocationHint(OtherReg);
344  // Make sure the pair has not already divorced.
345  if (Hint.second == Reg) {
346  MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg);
348  MRI->setRegAllocationHint(NewReg,
349  Hint.first == (unsigned)ARMRI::RegPairOdd ? ARMRI::RegPairEven
350  : ARMRI::RegPairOdd, OtherReg);
351  }
352  }
353 }
354 
356  const MachineFrameInfo &MFI = MF.getFrameInfo();
357  const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
358  const ARMFrameLowering *TFI = getFrameLowering(MF);
359 
360  // When outgoing call frames are so large that we adjust the stack pointer
361  // around the call, we can no longer use the stack pointer to reach the
362  // emergency spill slot.
363  if (needsStackRealignment(MF) && !TFI->hasReservedCallFrame(MF))
364  return true;
365 
366  // Thumb has trouble with negative offsets from the FP. Thumb2 has a limited
367  // negative range for ldr/str (255), and thumb1 is positive offsets only.
368  // It's going to be better to use the SP or Base Pointer instead. When there
369  // are variable sized objects, we can't reference off of the SP, so we
370  // reserve a Base Pointer.
371  if (AFI->isThumbFunction() && MFI.hasVarSizedObjects()) {
372  // Conservatively estimate whether the negative offset from the frame
373  // pointer will be sufficient to reach. If a function has a smallish
374  // frame, it's less likely to have lots of spills and callee saved
375  // space, so it's all more likely to be within range of the frame pointer.
376  // If it's wrong, the scavenger will still enable access to work, it just
377  // won't be optimal.
378  if (AFI->isThumb2Function() && MFI.getLocalFrameSize() < 128)
379  return false;
380  return true;
381  }
382 
383  return false;
384 }
385 
387  const MachineRegisterInfo *MRI = &MF.getRegInfo();
388  const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
389  const ARMFrameLowering *TFI = getFrameLowering(MF);
390  // We can't realign the stack if:
391  // 1. Dynamic stack realignment is explicitly disabled,
392  // 2. This is a Thumb1 function (it's not useful, so we don't bother), or
393  // 3. There are VLAs in the function and the base pointer is disabled.
395  return false;
396  if (AFI->isThumb1OnlyFunction())
397  return false;
398  // Stack realignment requires a frame pointer. If we already started
399  // register allocation with frame pointer elimination, it is too late now.
401  return false;
402  // We may also need a base pointer if there are dynamic allocas or stack
403  // pointer adjustments around calls.
404  if (TFI->hasReservedCallFrame(MF))
405  return true;
406  // A base pointer is required and allowed. Check that it isn't too late to
407  // reserve it.
408  return MRI->canReserveReg(BasePtr);
409 }
410 
413  const MachineFrameInfo &MFI = MF.getFrameInfo();
415  return true;
416  return MFI.hasVarSizedObjects() || MFI.isFrameAddressTaken()
417  || needsStackRealignment(MF);
418 }
419 
420 unsigned
422  const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
423  const ARMFrameLowering *TFI = getFrameLowering(MF);
424 
425  if (TFI->hasFP(MF))
426  return getFramePointerReg(STI);
427  return ARM::SP;
428 }
429 
430 /// emitLoadConstPool - Emits a load from constpool to materialize the
431 /// specified immediate.
434  const DebugLoc &dl, unsigned DestReg, unsigned SubIdx, int Val,
435  ARMCC::CondCodes Pred, unsigned PredReg, unsigned MIFlags) const {
436  MachineFunction &MF = *MBB.getParent();
437  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
439  const Constant *C =
441  unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
442 
443  BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp))
444  .addReg(DestReg, getDefRegState(true), SubIdx)
445  .addConstantPoolIndex(Idx)
446  .addImm(0)
447  .add(predOps(Pred, PredReg))
448  .setMIFlags(MIFlags);
449 }
450 
453  return true;
454 }
455 
458  return true;
459 }
460 
463  return true;
464 }
465 
468  return true;
469 }
470 
471 int64_t ARMBaseRegisterInfo::
472 getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const {
473  const MCInstrDesc &Desc = MI->getDesc();
474  unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
475  int64_t InstrOffs = 0;
476  int Scale = 1;
477  unsigned ImmIdx = 0;
478  switch (AddrMode) {
481  case ARMII::AddrMode_i12:
482  InstrOffs = MI->getOperand(Idx+1).getImm();
483  Scale = 1;
484  break;
485  case ARMII::AddrMode5: {
486  // VFP address mode.
487  const MachineOperand &OffOp = MI->getOperand(Idx+1);
488  InstrOffs = ARM_AM::getAM5Offset(OffOp.getImm());
489  if (ARM_AM::getAM5Op(OffOp.getImm()) == ARM_AM::sub)
490  InstrOffs = -InstrOffs;
491  Scale = 4;
492  break;
493  }
494  case ARMII::AddrMode2:
495  ImmIdx = Idx+2;
496  InstrOffs = ARM_AM::getAM2Offset(MI->getOperand(ImmIdx).getImm());
497  if (ARM_AM::getAM2Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
498  InstrOffs = -InstrOffs;
499  break;
500  case ARMII::AddrMode3:
501  ImmIdx = Idx+2;
502  InstrOffs = ARM_AM::getAM3Offset(MI->getOperand(ImmIdx).getImm());
503  if (ARM_AM::getAM3Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
504  InstrOffs = -InstrOffs;
505  break;
506  case ARMII::AddrModeT1_s:
507  ImmIdx = Idx+1;
508  InstrOffs = MI->getOperand(ImmIdx).getImm();
509  Scale = 4;
510  break;
511  default:
512  llvm_unreachable("Unsupported addressing mode!");
513  }
514 
515  return InstrOffs * Scale;
516 }
517 
518 /// needsFrameBaseReg - Returns true if the instruction's frame index
519 /// reference would be better served by a base register other than FP
520 /// or SP. Used by LocalStackFrameAllocation to determine which frame index
521 /// references it should create new base registers for.
524  for (unsigned i = 0; !MI->getOperand(i).isFI(); ++i) {
525  assert(i < MI->getNumOperands() &&"Instr doesn't have FrameIndex operand!");
526  }
527 
528  // It's the load/store FI references that cause issues, as it can be difficult
529  // to materialize the offset if it won't fit in the literal field. Estimate
530  // based on the size of the local frame and some conservative assumptions
531  // about the rest of the stack frame (note, this is pre-regalloc, so
532  // we don't know everything for certain yet) whether this offset is likely
533  // to be out of range of the immediate. Return true if so.
534 
535  // We only generate virtual base registers for loads and stores, so
536  // return false for everything else.
537  unsigned Opc = MI->getOpcode();
538  switch (Opc) {
539  case ARM::LDRi12: case ARM::LDRH: case ARM::LDRBi12:
540  case ARM::STRi12: case ARM::STRH: case ARM::STRBi12:
541  case ARM::t2LDRi12: case ARM::t2LDRi8:
542  case ARM::t2STRi12: case ARM::t2STRi8:
543  case ARM::VLDRS: case ARM::VLDRD:
544  case ARM::VSTRS: case ARM::VSTRD:
545  case ARM::tSTRspi: case ARM::tLDRspi:
546  break;
547  default:
548  return false;
549  }
550 
551  // Without a virtual base register, if the function has variable sized
552  // objects, all fixed-size local references will be via the frame pointer,
553  // Approximate the offset and see if it's legal for the instruction.
554  // Note that the incoming offset is based on the SP value at function entry,
555  // so it'll be negative.
556  MachineFunction &MF = *MI->getParent()->getParent();
557  const ARMFrameLowering *TFI = getFrameLowering(MF);
558  MachineFrameInfo &MFI = MF.getFrameInfo();
560 
561  // Estimate an offset from the frame pointer.
562  // Conservatively assume all callee-saved registers get pushed. R4-R6
563  // will be earlier than the FP, so we ignore those.
564  // R7, LR
565  int64_t FPOffset = Offset - 8;
566  // ARM and Thumb2 functions also need to consider R8-R11 and D8-D15
567  if (!AFI->isThumbFunction() || !AFI->isThumb1OnlyFunction())
568  FPOffset -= 80;
569  // Estimate an offset from the stack pointer.
570  // The incoming offset is relating to the SP at the start of the function,
571  // but when we access the local it'll be relative to the SP after local
572  // allocation, so adjust our SP-relative offset by that allocation size.
573  Offset += MFI.getLocalFrameSize();
574  // Assume that we'll have at least some spill slots allocated.
575  // FIXME: This is a total SWAG number. We should run some statistics
576  // and pick a real one.
577  Offset += 128; // 128 bytes of spill slots
578 
579  // If there's a frame pointer and the addressing mode allows it, try using it.
580  // The FP is only available if there is no dynamic realignment. We
581  // don't know for sure yet whether we'll need that, so we guess based
582  // on whether there are any local variables that would trigger it.
583  unsigned StackAlign = TFI->getStackAlignment();
584  if (TFI->hasFP(MF) &&
585  !((MFI.getLocalFrameMaxAlign() > StackAlign) && canRealignStack(MF))) {
586  if (isFrameOffsetLegal(MI, getFrameRegister(MF), FPOffset))
587  return false;
588  }
589  // If we can reference via the stack pointer, try that.
590  // FIXME: This (and the code that resolves the references) can be improved
591  // to only disallow SP relative references in the live range of
592  // the VLA(s). In practice, it's unclear how much difference that
593  // would make, but it may be worth doing.
594  if (!MFI.hasVarSizedObjects() && isFrameOffsetLegal(MI, ARM::SP, Offset))
595  return false;
596 
597  // The offset likely isn't legal, we want to allocate a virtual base register.
598  return true;
599 }
600 
601 /// materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to
602 /// be a pointer to FrameIdx at the beginning of the basic block.
605  unsigned BaseReg, int FrameIdx,
606  int64_t Offset) const {
608  unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri :
609  (AFI->isThumb1OnlyFunction() ? ARM::tADDframe : ARM::t2ADDri);
610 
612  DebugLoc DL; // Defaults to "unknown"
613  if (Ins != MBB->end())
614  DL = Ins->getDebugLoc();
615 
616  const MachineFunction &MF = *MBB->getParent();
618  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
619  const MCInstrDesc &MCID = TII.get(ADDriOpc);
620  MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0, this, MF));
621 
622  MachineInstrBuilder MIB = BuildMI(*MBB, Ins, DL, MCID, BaseReg)
623  .addFrameIndex(FrameIdx).addImm(Offset);
624 
625  if (!AFI->isThumb1OnlyFunction())
627 }
628 
630  int64_t Offset) const {
631  MachineBasicBlock &MBB = *MI.getParent();
632  MachineFunction &MF = *MBB.getParent();
633  const ARMBaseInstrInfo &TII =
634  *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
636  int Off = Offset; // ARM doesn't need the general 64-bit offsets
637  unsigned i = 0;
638 
639  assert(!AFI->isThumb1OnlyFunction() &&
640  "This resolveFrameIndex does not support Thumb1!");
641 
642  while (!MI.getOperand(i).isFI()) {
643  ++i;
644  assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
645  }
646  bool Done = false;
647  if (!AFI->isThumbFunction())
648  Done = rewriteARMFrameIndex(MI, i, BaseReg, Off, TII);
649  else {
650  assert(AFI->isThumb2Function());
651  Done = rewriteT2FrameIndex(MI, i, BaseReg, Off, TII);
652  }
653  assert(Done && "Unable to resolve frame index!");
654  (void)Done;
655 }
656 
658  int64_t Offset) const {
659  const MCInstrDesc &Desc = MI->getDesc();
660  unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
661  unsigned i = 0;
662  for (; !MI->getOperand(i).isFI(); ++i)
663  assert(i+1 < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!");
664 
665  // AddrMode4 and AddrMode6 cannot handle any offset.
666  if (AddrMode == ARMII::AddrMode4 || AddrMode == ARMII::AddrMode6)
667  return Offset == 0;
668 
669  unsigned NumBits = 0;
670  unsigned Scale = 1;
671  bool isSigned = true;
672  switch (AddrMode) {
675  // i8 supports only negative, and i12 supports only positive, so
676  // based on Offset sign, consider the appropriate instruction
677  Scale = 1;
678  if (Offset < 0) {
679  NumBits = 8;
680  Offset = -Offset;
681  } else {
682  NumBits = 12;
683  }
684  break;
685  case ARMII::AddrMode5:
686  // VFP address mode.
687  NumBits = 8;
688  Scale = 4;
689  break;
690  case ARMII::AddrMode_i12:
691  case ARMII::AddrMode2:
692  NumBits = 12;
693  break;
694  case ARMII::AddrMode3:
695  NumBits = 8;
696  break;
697  case ARMII::AddrModeT1_s:
698  NumBits = (BaseReg == ARM::SP ? 8 : 5);
699  Scale = 4;
700  isSigned = false;
701  break;
702  default:
703  llvm_unreachable("Unsupported addressing mode!");
704  }
705 
706  Offset += getFrameIndexInstrOffset(MI, i);
707  // Make sure the offset is encodable for instructions that scale the
708  // immediate.
709  if ((Offset & (Scale-1)) != 0)
710  return false;
711 
712  if (isSigned && Offset < 0)
713  Offset = -Offset;
714 
715  unsigned Mask = (1 << NumBits) - 1;
716  if ((unsigned)Offset <= Mask * Scale)
717  return true;
718 
719  return false;
720 }
721 
722 void
724  int SPAdj, unsigned FIOperandNum,
725  RegScavenger *RS) const {
726  MachineInstr &MI = *II;
727  MachineBasicBlock &MBB = *MI.getParent();
728  MachineFunction &MF = *MBB.getParent();
729  const ARMBaseInstrInfo &TII =
730  *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
731  const ARMFrameLowering *TFI = getFrameLowering(MF);
733  assert(!AFI->isThumb1OnlyFunction() &&
734  "This eliminateFrameIndex does not support Thumb1!");
735  int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
736  unsigned FrameReg;
737 
738  int Offset = TFI->ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
739 
740  // PEI::scavengeFrameVirtualRegs() cannot accurately track SPAdj because the
741  // call frame setup/destroy instructions have already been eliminated. That
742  // means the stack pointer cannot be used to access the emergency spill slot
743  // when !hasReservedCallFrame().
744 #ifndef NDEBUG
745  if (RS && FrameReg == ARM::SP && RS->isScavengingFrameIndex(FrameIndex)){
746  assert(TFI->hasReservedCallFrame(MF) &&
747  "Cannot use SP to access the emergency spill slot in "
748  "functions without a reserved call frame");
750  "Cannot use SP to access the emergency spill slot in "
751  "functions with variable sized frame objects");
752  }
753 #endif // NDEBUG
754 
755  assert(!MI.isDebugValue() && "DBG_VALUEs should be handled in target-independent code");
756 
757  // Modify MI as necessary to handle as much of 'Offset' as possible
758  bool Done = false;
759  if (!AFI->isThumbFunction())
760  Done = rewriteARMFrameIndex(MI, FIOperandNum, FrameReg, Offset, TII);
761  else {
762  assert(AFI->isThumb2Function());
763  Done = rewriteT2FrameIndex(MI, FIOperandNum, FrameReg, Offset, TII);
764  }
765  if (Done)
766  return;
767 
768  // If we get here, the immediate doesn't fit into the instruction. We folded
769  // as much as possible above, handle the rest, providing a register that is
770  // SP+LargeImm.
771  assert((Offset ||
774  "This code isn't needed if offset already handled!");
775 
776  unsigned ScratchReg = 0;
777  int PIdx = MI.findFirstPredOperandIdx();
778  ARMCC::CondCodes Pred = (PIdx == -1)
780  unsigned PredReg = (PIdx == -1) ? 0 : MI.getOperand(PIdx+1).getReg();
781  if (Offset == 0)
782  // Must be addrmode4/6.
783  MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false, false, false);
784  else {
785  ScratchReg = MF.getRegInfo().createVirtualRegister(&ARM::GPRRegClass);
786  if (!AFI->isThumbFunction())
787  emitARMRegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
788  Offset, Pred, PredReg, TII);
789  else {
790  assert(AFI->isThumb2Function());
791  emitT2RegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
792  Offset, Pred, PredReg, TII);
793  }
794  // Update the original instruction to use the scratch register.
795  MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false, false,true);
796  }
797 }
798 
800  const TargetRegisterClass *SrcRC,
801  unsigned SubReg,
802  const TargetRegisterClass *DstRC,
803  unsigned DstSubReg,
804  const TargetRegisterClass *NewRC) const {
805  auto MBB = MI->getParent();
806  auto MF = MBB->getParent();
807  const MachineRegisterInfo &MRI = MF->getRegInfo();
808  // If not copying into a sub-register this should be ok because we shouldn't
809  // need to split the reg.
810  if (!DstSubReg)
811  return true;
812  // Small registers don't frequently cause a problem, so we can coalesce them.
813  if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
814  getRegSizeInBits(*SrcRC) < 256)
815  return true;
816 
817  auto NewRCWeight =
819  auto SrcRCWeight =
821  auto DstRCWeight =
823  // If the source register class is more expensive than the destination, the
824  // coalescing is probably profitable.
825  if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
826  return true;
827  if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
828  return true;
829 
830  // If the register allocator isn't constrained, we can always allow coalescing
831  // unfortunately we don't know yet if we will be constrained.
832  // The goal of this heuristic is to restrict how many expensive registers
833  // we allow to coalesce in a given basic block.
834  auto AFI = MF->getInfo<ARMFunctionInfo>();
835  auto It = AFI->getCoalescedWeight(MBB);
836 
837  DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: "
838  << It->second << "\n");
839  DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: "
840  << NewRCWeight.RegWeight << "\n");
841 
842  // This number is the largest round number that which meets the criteria:
843  // (1) addresses PR18825
844  // (2) generates better code in some test cases (like vldm-shed-a9.ll)
845  // (3) Doesn't regress any test cases (in-tree, test-suite, and SPEC)
846  // In practice the SizeMultiplier will only factor in for straight line code
847  // that uses a lot of NEON vectors, which isn't terribly common.
848  unsigned SizeMultiplier = MBB->size()/100;
849  SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
850  if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
851  It->second += NewRCWeight.RegWeight;
852  return true;
853  }
854  return false;
855 }
bool hasPhys(unsigned virtReg) const
returns true if the specified virtual register is mapped to a physical register
Definition: VirtRegMap.h:92
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void push_back(const T &Elt)
Definition: SmallVector.h:211
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
void materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const override
materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx...
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition: Function.cpp:194
bool useR7AsFramePointer() const
Definition: ARMSubtarget.h:661
static unsigned char getAM3Offset(unsigned AM3Opc)
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:163
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
DataLayout DL
void getRegAllocationHints(unsigned VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
const ARMTargetLowering * getTargetLowering() const override
Definition: ARMSubtarget.h:441
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
unsigned getID() const
Return the register class ID number.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Definition: MachineInstr.h:276
A debug info location.
Definition: DebugLoc.h:34
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:262
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool isThumb1Only() const
Definition: ARMSubtarget.h:650
bool canReserveReg(unsigned PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
void updateRegAllocHint(unsigned Reg, unsigned NewReg, MachineFunction &MF) const override
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
return AArch64::GPR64RegClass contains(Reg)
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction's frame index reference would be better served by...
Live Register Matrix
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:186
const uint32_t * getNoPreservedMask() const override
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:197
bool isR9Reserved() const
Definition: ARMSubtarget.h:657
int64_t getLocalFrameSize() const
Get the size of the local object blob.
bool useSoftFloat() const
Definition: ARMSubtarget.h:648
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
static unsigned getPairedGPR(unsigned Reg, bool Odd, const MCRegisterInfo *RI)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool hasVFP3() const
Definition: ARMSubtarget.h:510
MCSuperRegIterator enumerates all super-registers of Reg.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const HexagonInstrInfo * TII
const TargetRegisterInfo * getTargetRegisterInfo() const
bool isTargetDarwin() const
Definition: ARMSubtarget.h:580
unsigned getFrameRegister(const MachineFunction &MF) const override
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
unsigned SubReg
void emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
bool rewriteARMFrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
rewriteARMFrameIndex / rewriteT2FrameIndex - Rewrite MI to access 'Offset' bytes from the FP...
Reg
All possible values of the reg field in the ModR/M byte.
This file contains the simple types necessary to represent the attributes associated with functions a...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
const TargetRegisterClass *const * sc_iterator
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Definition: MachineInstr.h:282
bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg, int64_t Offset) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
#define F(x, y, z)
Definition: MD5.cpp:55
virtual void emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned SubIdx, int Val, ARMCC::CondCodes Pred=ARMCC::AL, unsigned PredReg=0, unsigned MIFlags=MachineInstr::NoFlags) const
emitLoadConstPool - Emits a load from constpool to materialize the specified immediate.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that 'returned' is on...
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
int64_t getImm() const
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
const uint32_t * getSjLjDispatchPreservedMask(const MachineFunction &MF) const
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:279
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:139
TargetInstrInfo - Interface to description of machine instruction set.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
bool isDebugValue() const
Definition: MachineInstr.h:785
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
This file declares the machine register scavenger class.
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
unsigned const MachineRegisterInfo * MRI
bool requiresRegisterScavenging(const MachineFunction &MF) const override
Code Generation virtual methods...
int64_t getFrameIndexInstrOffset(const MachineInstr *MI, int Idx) const override
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This is an important base class in LLVM.
Definition: Constant.h:42
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
static unsigned char getAM5Offset(unsigned AM5Opc)
bool isMClass() const
Definition: ARMSubtarget.h:653
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:284
bool splitFramePushPop(const MachineFunction &MF) const
Returns true if the frame setup is split into two separate pushes (first r0-r7,lr then r8-r11)...
Definition: ARMSubtarget.h:669
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
void emitARMRegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of instructions to materializea des...
static unsigned getFramePointerReg(const ARMSubtarget &STI)
MCSubRegIterator enumerates all sub-registers of Reg.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:45
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
static AddrOpc getAM2Op(unsigned AM2Opc)
bool isMaxCallFrameSizeComputed() const
static unsigned getAM2Offset(unsigned AM2Opc)
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
MachineOperand class - Representation of each machine instruction operand.
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
void setRegAllocationHint(unsigned VReg, unsigned Type, unsigned PrefReg)
setRegAllocationHint - Specify a register allocation hint for the specified virtual register...
bool test(unsigned Idx) const
Definition: BitVector.h:502
bool hasVFP2() const
Definition: ARMSubtarget.h:509
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:560
const MachineInstrBuilder & addFrameIndex(int Idx) const
bool canRealignStack(const MachineFunction &MF) const override
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
bool hasBasePointer(const MachineFunction &MF) const
AddrMode
ARM Addressing Modes.
Definition: ARMBaseInfo.h:235
static AddrOpc getAM3Op(unsigned AM3Opc)
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Definition: MachineInstr.h:257
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const override
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.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:254
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:176
#define C
Definition: LargeTest.cpp:25
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
TargetOptions Options
Definition: TargetMachine.h:95
bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC) const override
SrcRC and DstRC will be morphed into NewRC if this returns true.
#define I(x, y, z)
Definition: MD5.cpp:58
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
unsigned BasePtr
BasePtr - ARM physical register used as a base ptr in complex stack frames.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
static AddrOpc getAM5Op(unsigned AM5Opc)
const unsigned Kind
unsigned getReg() const
getReg - Returns the register number.
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:195
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool cannotEliminateFrame(const MachineFunction &MF) const
virtual const TargetInstrInfo * getInstrInfo() const
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:81
#define DEBUG(X)
Definition: Debug.h:118
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
IRTranslator LLVM IR MI
unsigned getPhys(unsigned virtReg) const
returns the physical register mapped to the specified virtual register
Definition: VirtRegMap.h:98
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
const TargetRegisterClass * getRegClass(const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
bool hasD16() const
Definition: ARMSubtarget.h:571
std::pair< unsigned, unsigned > getRegAllocationHint(unsigned VReg) const
getRegAllocationHint - Return the register allocation hint for the specified virtual register...
DenseMap< const MachineBasicBlock *, unsigned >::iterator getCoalescedWeight(MachineBasicBlock *MBB)
virtual void getRegAllocationHints(unsigned VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM=nullptr, const LiveRegMatrix *Matrix=nullptr) const
Get a list of 'hint' registers that the register allocator should try first when allocating a physica...
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
const uint32_t * getTLSCallPreservedMask(const MachineFunction &MF) const
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:872