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