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