LLVM  15.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:
270  if (MF.getSubtarget<ARMSubtarget>().hasMVEIntegerOps())
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) {
536  case ARMII::AddrMode_i12:
537  InstrOffs = MI->getOperand(Idx+1).getImm();
538  Scale = 1;
539  break;
540  case ARMII::AddrMode5: {
541  // VFP address mode.
542  const MachineOperand &OffOp = MI->getOperand(Idx+1);
543  InstrOffs = ARM_AM::getAM5Offset(OffOp.getImm());
544  if (ARM_AM::getAM5Op(OffOp.getImm()) == ARM_AM::sub)
545  InstrOffs = -InstrOffs;
546  Scale = 4;
547  break;
548  }
549  case ARMII::AddrMode2:
550  ImmIdx = Idx+2;
551  InstrOffs = ARM_AM::getAM2Offset(MI->getOperand(ImmIdx).getImm());
552  if (ARM_AM::getAM2Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
553  InstrOffs = -InstrOffs;
554  break;
555  case ARMII::AddrMode3:
556  ImmIdx = Idx+2;
557  InstrOffs = ARM_AM::getAM3Offset(MI->getOperand(ImmIdx).getImm());
558  if (ARM_AM::getAM3Op(MI->getOperand(ImmIdx).getImm()) == ARM_AM::sub)
559  InstrOffs = -InstrOffs;
560  break;
561  case ARMII::AddrModeT1_s:
562  ImmIdx = Idx+1;
563  InstrOffs = MI->getOperand(ImmIdx).getImm();
564  Scale = 4;
565  break;
566  default:
567  llvm_unreachable("Unsupported addressing mode!");
568  }
569 
570  return InstrOffs * Scale;
571 }
572 
573 /// needsFrameBaseReg - Returns true if the instruction's frame index
574 /// reference would be better served by a base register other than FP
575 /// or SP. Used by LocalStackFrameAllocation to determine which frame index
576 /// references it should create new base registers for.
578 needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const {
579  for (unsigned i = 0; !MI->getOperand(i).isFI(); ++i) {
580  assert(i < MI->getNumOperands() &&"Instr doesn't have FrameIndex operand!");
581  }
582 
583  // It's the load/store FI references that cause issues, as it can be difficult
584  // to materialize the offset if it won't fit in the literal field. Estimate
585  // based on the size of the local frame and some conservative assumptions
586  // about the rest of the stack frame (note, this is pre-regalloc, so
587  // we don't know everything for certain yet) whether this offset is likely
588  // to be out of range of the immediate. Return true if so.
589 
590  // We only generate virtual base registers for loads and stores, so
591  // return false for everything else.
592  unsigned Opc = MI->getOpcode();
593  switch (Opc) {
594  case ARM::LDRi12: case ARM::LDRH: case ARM::LDRBi12:
595  case ARM::STRi12: case ARM::STRH: case ARM::STRBi12:
596  case ARM::t2LDRi12: case ARM::t2LDRi8:
597  case ARM::t2STRi12: case ARM::t2STRi8:
598  case ARM::VLDRS: case ARM::VLDRD:
599  case ARM::VSTRS: case ARM::VSTRD:
600  case ARM::tSTRspi: case ARM::tLDRspi:
601  break;
602  default:
603  return false;
604  }
605 
606  // Without a virtual base register, if the function has variable sized
607  // objects, all fixed-size local references will be via the frame pointer,
608  // Approximate the offset and see if it's legal for the instruction.
609  // Note that the incoming offset is based on the SP value at function entry,
610  // so it'll be negative.
611  MachineFunction &MF = *MI->getParent()->getParent();
612  const ARMFrameLowering *TFI = getFrameLowering(MF);
613  MachineFrameInfo &MFI = MF.getFrameInfo();
615 
616  // Estimate an offset from the frame pointer.
617  // Conservatively assume all callee-saved registers get pushed. R4-R6
618  // will be earlier than the FP, so we ignore those.
619  // R7, LR
620  int64_t FPOffset = Offset - 8;
621  // ARM and Thumb2 functions also need to consider R8-R11 and D8-D15
622  if (!AFI->isThumbFunction() || !AFI->isThumb1OnlyFunction())
623  FPOffset -= 80;
624  // Estimate an offset from the stack pointer.
625  // The incoming offset is relating to the SP at the start of the function,
626  // but when we access the local it'll be relative to the SP after local
627  // allocation, so adjust our SP-relative offset by that allocation size.
628  Offset += MFI.getLocalFrameSize();
629  // Assume that we'll have at least some spill slots allocated.
630  // FIXME: This is a total SWAG number. We should run some statistics
631  // and pick a real one.
632  Offset += 128; // 128 bytes of spill slots
633 
634  // If there's a frame pointer and the addressing mode allows it, try using it.
635  // The FP is only available if there is no dynamic realignment. We
636  // don't know for sure yet whether we'll need that, so we guess based
637  // on whether there are any local variables that would trigger it.
638  if (TFI->hasFP(MF) &&
639  !((MFI.getLocalFrameMaxAlign() > TFI->getStackAlign()) &&
640  canRealignStack(MF))) {
641  if (isFrameOffsetLegal(MI, getFrameRegister(MF), FPOffset))
642  return false;
643  }
644  // If we can reference via the stack pointer, try that.
645  // FIXME: This (and the code that resolves the references) can be improved
646  // to only disallow SP relative references in the live range of
647  // the VLA(s). In practice, it's unclear how much difference that
648  // would make, but it may be worth doing.
649  if (!MFI.hasVarSizedObjects() && isFrameOffsetLegal(MI, ARM::SP, Offset))
650  return false;
651 
652  // The offset likely isn't legal, we want to allocate a virtual base register.
653  return true;
654 }
655 
656 /// materializeFrameBaseRegister - Insert defining instruction(s) for BaseReg to
657 /// be a pointer to FrameIdx at the beginning of the basic block.
658 Register
660  int FrameIdx,
661  int64_t Offset) const {
663  unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri :
664  (AFI->isThumb1OnlyFunction() ? ARM::tADDframe : ARM::t2ADDri);
665 
667  DebugLoc DL; // Defaults to "unknown"
668  if (Ins != MBB->end())
669  DL = Ins->getDebugLoc();
670 
671  const MachineFunction &MF = *MBB->getParent();
673  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
674  const MCInstrDesc &MCID = TII.get(ADDriOpc);
675  Register BaseReg = MRI.createVirtualRegister(&ARM::GPRRegClass);
676  MRI.constrainRegClass(BaseReg, TII.getRegClass(MCID, 0, this, MF));
677 
678  MachineInstrBuilder MIB = BuildMI(*MBB, Ins, DL, MCID, BaseReg)
679  .addFrameIndex(FrameIdx).addImm(Offset);
680 
681  if (!AFI->isThumb1OnlyFunction())
683 
684  return BaseReg;
685 }
686 
688  int64_t Offset) const {
689  MachineBasicBlock &MBB = *MI.getParent();
690  MachineFunction &MF = *MBB.getParent();
691  const ARMBaseInstrInfo &TII =
692  *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
694  int Off = Offset; // ARM doesn't need the general 64-bit offsets
695  unsigned i = 0;
696 
697  assert(!AFI->isThumb1OnlyFunction() &&
698  "This resolveFrameIndex does not support Thumb1!");
699 
700  while (!MI.getOperand(i).isFI()) {
701  ++i;
702  assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
703  }
704  bool Done = false;
705  if (!AFI->isThumbFunction())
706  Done = rewriteARMFrameIndex(MI, i, BaseReg, Off, TII);
707  else {
708  assert(AFI->isThumb2Function());
709  Done = rewriteT2FrameIndex(MI, i, BaseReg, Off, TII, this);
710  }
711  assert(Done && "Unable to resolve frame index!");
712  (void)Done;
713 }
714 
716  Register BaseReg,
717  int64_t Offset) const {
718  const MCInstrDesc &Desc = MI->getDesc();
719  unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
720  unsigned i = 0;
721  for (; !MI->getOperand(i).isFI(); ++i)
722  assert(i+1 < MI->getNumOperands() && "Instr doesn't have FrameIndex operand!");
723 
724  // AddrMode4 and AddrMode6 cannot handle any offset.
726  return Offset == 0;
727 
728  unsigned NumBits = 0;
729  unsigned Scale = 1;
730  bool isSigned = true;
731  switch (AddrMode) {
736  // i8 supports only negative, and i12 supports only positive, so
737  // based on Offset sign, consider the appropriate instruction
738  Scale = 1;
739  if (Offset < 0) {
740  NumBits = 8;
741  Offset = -Offset;
742  } else {
743  NumBits = 12;
744  }
745  break;
746  case ARMII::AddrMode5:
747  // VFP address mode.
748  NumBits = 8;
749  Scale = 4;
750  break;
751  case ARMII::AddrMode_i12:
752  case ARMII::AddrMode2:
753  NumBits = 12;
754  break;
755  case ARMII::AddrMode3:
756  NumBits = 8;
757  break;
758  case ARMII::AddrModeT1_s:
759  NumBits = (BaseReg == ARM::SP ? 8 : 5);
760  Scale = 4;
761  isSigned = false;
762  break;
763  default:
764  llvm_unreachable("Unsupported addressing mode!");
765  }
766 
767  Offset += getFrameIndexInstrOffset(MI, i);
768  // Make sure the offset is encodable for instructions that scale the
769  // immediate.
770  if ((Offset & (Scale-1)) != 0)
771  return false;
772 
773  if (isSigned && Offset < 0)
774  Offset = -Offset;
775 
776  unsigned Mask = (1 << NumBits) - 1;
777  if ((unsigned)Offset <= Mask * Scale)
778  return true;
779 
780  return false;
781 }
782 
783 void
785  int SPAdj, unsigned FIOperandNum,
786  RegScavenger *RS) const {
787  MachineInstr &MI = *II;
788  MachineBasicBlock &MBB = *MI.getParent();
789  MachineFunction &MF = *MBB.getParent();
790  const ARMBaseInstrInfo &TII =
791  *static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());
792  const ARMFrameLowering *TFI = getFrameLowering(MF);
794  assert(!AFI->isThumb1OnlyFunction() &&
795  "This eliminateFrameIndex does not support Thumb1!");
796  int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
797  Register FrameReg;
798 
799  int Offset = TFI->ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
800 
801  // PEI::scavengeFrameVirtualRegs() cannot accurately track SPAdj because the
802  // call frame setup/destroy instructions have already been eliminated. That
803  // means the stack pointer cannot be used to access the emergency spill slot
804  // when !hasReservedCallFrame().
805 #ifndef NDEBUG
806  if (RS && FrameReg == ARM::SP && RS->isScavengingFrameIndex(FrameIndex)){
807  assert(TFI->hasReservedCallFrame(MF) &&
808  "Cannot use SP to access the emergency spill slot in "
809  "functions without a reserved call frame");
811  "Cannot use SP to access the emergency spill slot in "
812  "functions with variable sized frame objects");
813  }
814 #endif // NDEBUG
815 
816  assert(!MI.isDebugValue() && "DBG_VALUEs should be handled in target-independent code");
817 
818  // Modify MI as necessary to handle as much of 'Offset' as possible
819  bool Done = false;
820  if (!AFI->isThumbFunction())
821  Done = rewriteARMFrameIndex(MI, FIOperandNum, FrameReg, Offset, TII);
822  else {
823  assert(AFI->isThumb2Function());
824  Done = rewriteT2FrameIndex(MI, FIOperandNum, FrameReg, Offset, TII, this);
825  }
826  if (Done)
827  return;
828 
829  // If we get here, the immediate doesn't fit into the instruction. We folded
830  // as much as possible above, handle the rest, providing a register that is
831  // SP+LargeImm.
832  assert(
833  (Offset ||
834  (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode4 ||
835  (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrMode6 ||
836  (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7 ||
837  (MI.getDesc().TSFlags & ARMII::AddrModeMask) == ARMII::AddrModeT2_i7s2 ||
838  (MI.getDesc().TSFlags & ARMII::AddrModeMask) ==
840  "This code isn't needed if offset already handled!");
841 
842  unsigned ScratchReg = 0;
843  int PIdx = MI.findFirstPredOperandIdx();
844  ARMCC::CondCodes Pred = (PIdx == -1)
845  ? ARMCC::AL : (ARMCC::CondCodes)MI.getOperand(PIdx).getImm();
846  Register PredReg = (PIdx == -1) ? Register() : MI.getOperand(PIdx+1).getReg();
847 
848  const MCInstrDesc &MCID = MI.getDesc();
849  const TargetRegisterClass *RegClass =
850  TII.getRegClass(MCID, FIOperandNum, this, *MI.getParent()->getParent());
851 
852  if (Offset == 0 &&
853  (Register::isVirtualRegister(FrameReg) || RegClass->contains(FrameReg)))
854  // Must be addrmode4/6.
855  MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false, false, false);
856  else {
857  ScratchReg = MF.getRegInfo().createVirtualRegister(RegClass);
858  if (!AFI->isThumbFunction())
859  emitARMRegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
860  Offset, Pred, PredReg, TII);
861  else {
862  assert(AFI->isThumb2Function());
863  emitT2RegPlusImmediate(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg,
864  Offset, Pred, PredReg, TII);
865  }
866  // Update the original instruction to use the scratch register.
867  MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false, false,true);
868  }
869 }
870 
872  const TargetRegisterClass *SrcRC,
873  unsigned SubReg,
874  const TargetRegisterClass *DstRC,
875  unsigned DstSubReg,
876  const TargetRegisterClass *NewRC,
877  LiveIntervals &LIS) const {
878  auto MBB = MI->getParent();
879  auto MF = MBB->getParent();
880  const MachineRegisterInfo &MRI = MF->getRegInfo();
881  // If not copying into a sub-register this should be ok because we shouldn't
882  // need to split the reg.
883  if (!DstSubReg)
884  return true;
885  // Small registers don't frequently cause a problem, so we can coalesce them.
886  if (getRegSizeInBits(*NewRC) < 256 && getRegSizeInBits(*DstRC) < 256 &&
887  getRegSizeInBits(*SrcRC) < 256)
888  return true;
889 
890  auto NewRCWeight =
892  auto SrcRCWeight =
894  auto DstRCWeight =
896  // If the source register class is more expensive than the destination, the
897  // coalescing is probably profitable.
898  if (SrcRCWeight.RegWeight > NewRCWeight.RegWeight)
899  return true;
900  if (DstRCWeight.RegWeight > NewRCWeight.RegWeight)
901  return true;
902 
903  // If the register allocator isn't constrained, we can always allow coalescing
904  // unfortunately we don't know yet if we will be constrained.
905  // The goal of this heuristic is to restrict how many expensive registers
906  // we allow to coalesce in a given basic block.
907  auto AFI = MF->getInfo<ARMFunctionInfo>();
908  auto It = AFI->getCoalescedWeight(MBB);
909 
910  LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Coalesced Weight: "
911  << It->second << "\n");
912  LLVM_DEBUG(dbgs() << "\tARM::shouldCoalesce - Reg Weight: "
913  << NewRCWeight.RegWeight << "\n");
914 
915  // This number is the largest round number that which meets the criteria:
916  // (1) addresses PR18825
917  // (2) generates better code in some test cases (like vldm-shed-a9.ll)
918  // (3) Doesn't regress any test cases (in-tree, test-suite, and SPEC)
919  // In practice the SizeMultiplier will only factor in for straight line code
920  // that uses a lot of NEON vectors, which isn't terribly common.
921  unsigned SizeMultiplier = MBB->size()/100;
922  SizeMultiplier = SizeMultiplier ? SizeMultiplier : 1;
923  if (It->second < NewRCWeight.WeightLimit * SizeMultiplier) {
924  It->second += NewRCWeight.RegWeight;
925  return true;
926  }
927  return false;
928 }
929 
931  unsigned DefSubReg,
932  const TargetRegisterClass *SrcRC,
933  unsigned SrcSubReg) const {
934  // We can't extract an SPR from an arbitary DPR (as opposed to a DPR_VFP2).
935  if (DefRC == &ARM::SPRRegClass && DefSubReg == 0 &&
936  SrcRC == &ARM::DPRRegClass &&
937  (SrcSubReg == ARM::ssub_0 || SrcSubReg == ARM::ssub_1))
938  return false;
939 
940  return TargetRegisterInfo::shouldRewriteCopySrc(DefRC, DefSubReg,
941  SrcRC, SrcSubReg);
942 }
i
i
Definition: README.txt:29
ARMSubtarget.h
llvm::MachineFrameInfo::isMaxCallFrameSizeComputed
bool isMaxCallFrameSizeComputed() const
Definition: MachineFrameInfo.h:653
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:354
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:659
llvm::ARMII::AddrMode4
@ AddrMode4
Definition: ARMBaseInfo.h:190
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:104
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:72
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::ARMFunctionInfo::isSplitCSR
bool isSplitCSR() const
Definition: ARMMachineFunctionInfo.h:236
llvm::CallingConv::CFGuard_Check
@ CFGuard_Check
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
Definition: CallingConv.h:87
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:156
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:1386
llvm::ARMBaseRegisterInfo::shouldRewriteCopySrc
bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg) const override
Definition: ARMBaseRegisterInfo.cpp:930
llvm::ARMII::AddrModeT2_i8neg
@ AddrModeT2_i8neg
Definition: ARMBaseInfo.h:200
MCInstrDesc.h
llvm::ARMSubtarget
Definition: ARMSubtarget.h:47
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:50
llvm::MachineInstrBuilder::add
const MachineInstrBuilder & add(const MachineOperand &MO) const
Definition: MachineInstrBuilder.h:224
llvm::Function
Definition: Function.h:60
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:93
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:287
contains
return AArch64::GPR64RegClass contains(Reg)
llvm::ARMFunctionInfo::isThumb1OnlyFunction
bool isThumb1OnlyFunction() const
Definition: ARMMachineFunctionInfo.h:162
ErrorHandling.h
llvm::VirtRegMap
Definition: VirtRegMap.h:33
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
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:151
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:907
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::CallingConv::CXX_FAST_TLS
@ CXX_FAST_TLS
Definition: CallingConv.h:76
llvm::ARMBaseRegisterInfo::isFrameOffsetLegal
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg, int64_t Offset) const override
Definition: ARMBaseRegisterInfo.cpp:715
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:319
llvm::ARMSubtarget::getTargetLowering
const ARMTargetLowering * getTargetLowering() const override
Definition: ARMSubtarget.h:268
TargetInstrInfo.h
llvm::ARM_AM::getAM2Offset
unsigned getAM2Offset(unsigned AM2Opc)
Definition: ARMAddressingModes.h:419
llvm::CallingConv::GHC
@ GHC
Definition: CallingConv.h:51
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::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:239
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:55
MachineRegisterInfo.h
llvm::RegScavenger::isScavengingFrameIndex
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
Definition: RegisterScavenging.h:148
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::ARMBaseRegisterInfo::requiresRegisterScavenging
bool requiresRegisterScavenging(const MachineFunction &MF) const override
Code Generation virtual methods...
Definition: ARMBaseRegisterInfo.cpp:510
llvm::BitmaskEnumDetail::Mask
constexpr 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::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:442
llvm::ARMII::AddrMode_i12
@ AddrMode_i12
Definition: ARMBaseInfo.h:204
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:94
llvm::TargetRegisterInfo::canRealignStack
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
Definition: TargetRegisterInfo.cpp:479
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:650
llvm::MCInstrDesc::TSFlags
uint64_t TSFlags
Definition: MCInstrDesc.h:205
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:97
TargetMachine.h
ARMBaseInfo.h
Constants.h
llvm::MachineOperand::getImm
int64_t getImm() const
Definition: MachineOperand.h:546
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:738
llvm::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:925
llvm::ARM_AM::getAM2Op
AddrOpc getAM2Op(unsigned AM2Opc)
Definition: ARMAddressingModes.h:422
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:45
llvm::ARMII::AddrModeT2_i7s4
@ AddrModeT2_i7s4
Definition: ARMBaseInfo.h:207
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:127
llvm::MCInstrDesc
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:197
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
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:919
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:446
llvm::ARMBaseRegisterInfo::getSjLjDispatchPreservedMask
const uint32_t * getSjLjDispatchPreservedMask(const MachineFunction &MF) const
Definition: ARMBaseRegisterInfo.cpp:160
DebugLoc.h
llvm::BitVector
Definition: BitVector.h:75
llvm::ARMFunctionInfo::isThumbFunction
bool isThumbFunction() const
Definition: ARMMachineFunctionInfo.h:161
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
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:209
Type.h
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::ARMII::AddrModeMask
@ AddrModeMask
Definition: ARMBaseInfo.h:303
llvm::MachineRegisterInfo::getRegClass
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Definition: MachineRegisterInfo.h:642
llvm::Function::getAttributes
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:314
llvm::VirtRegMap::hasPhys
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
Definition: VirtRegMap.h:99
llvm::ARMFunctionInfo::getCoalescedWeight
DenseMap< const MachineBasicBlock *, unsigned >::iterator getCoalescedWeight(MachineBasicBlock *MBB)
Definition: ARMMachineFunctionInfo.h:252
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:23
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:640
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:422
llvm::MachineFrameInfo::getLocalFrameSize
int64_t getLocalFrameSize() const
Get the size of the local object blob.
Definition: MachineFrameInfo.h:437
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::MachineInstrBuilder
Definition: MachineInstrBuilder.h:69
llvm::Function::getCallingConv
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:238
VirtRegMap.h
llvm::ARMSubtarget::isR9Reserved
bool isR9Reserved() const
Definition: ARMSubtarget.h:428
llvm::ARMRI::RegPairOdd
@ RegPairOdd
Definition: ARMBaseRegisterInfo.h:36
llvm::ARMSubtarget::isMClass
bool isMClass() const
Definition: ARMSubtarget.h:424
llvm::rewriteT2FrameIndex
bool rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, Register FrameReg, int &Offset, const ARMBaseInstrInfo &TII, const TargetRegisterInfo *TRI)
Definition: Thumb2InstrInfo.cpp:530
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:550
llvm::ARMII::AddrModeT2_i8pos
@ AddrModeT2_i8pos
Definition: ARMBaseInfo.h:199
I
#define I(x, y, z)
Definition: MD5.cpp:58
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:105
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:422
llvm::ARMBaseInstrInfo
Definition: ARMBaseInstrInfo.h:37
llvm::ARMSubtarget::getFramePointerReg
MCPhysReg getFramePointerReg() const
Definition: ARMSubtarget.h:432
llvm::ARMRI::RegLR
@ RegLR
Definition: ARMBaseRegisterInfo.h:39
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:1672
llvm::ARM_MC::initLLVMToCVRegMapping
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
Definition: ARMMCTargetDesc.cpp:223
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:1045
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:118
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:672
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ARMFrameLowering
Definition: ARMFrameLowering.h:21
llvm::MachineBasicBlock::size
unsigned size() const
Definition: MachineBasicBlock.h:248
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:656
llvm::ARMBaseRegisterInfo::resolveFrameIndex
void resolveFrameIndex(MachineInstr &MI, Register BaseReg, int64_t Offset) const override
Definition: ARMBaseRegisterInfo.cpp:687
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition: MachineBasicBlock.h:234
ARMBaseInstrInfo.h
llvm::MCSuperRegIterator
MCSuperRegIterator enumerates all super-registers of Reg.
Definition: MCRegisterInfo.h:644
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:208
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:871
llvm::MachineFunction
Definition: MachineFunction.h:241
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:2611
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
ARMAddressingModes.h
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:578
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:143
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:773
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:370
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:413
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:454
ARMFrameLowering.h
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:606
llvm::ARMSubtarget::isTargetDarwin
bool isTargetDarwin() const
Definition: ARMSubtarget.h:363
uint16_t
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:636
llvm::TargetRegisterClass::getSuperClasses
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
Definition: TargetRegisterInfo.h:177
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
llvm::ARMRI::RegPairEven
@ RegPairEven
Definition: ARMBaseRegisterInfo.h:37
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:49
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:597
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:105
SmallVector.h
llvm::MachineBasicBlock::begin
iterator begin()
Definition: MachineBasicBlock.h:277
MachineInstrBuilder.h
llvm::CallingConv::SwiftTail
@ SwiftTail
SwiftTail - This follows the Swift calling convention in how arguments are passed but guarantees tail...
Definition: CallingConv.h:92
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:697
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:2448
llvm::TargetRegisterInfo::getRegClassWeight
virtual const RegClassWeight & getRegClassWeight(const TargetRegisterClass *RC) const =0
Get the weight in units of pressure for this register class.
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:83
llvm::MipsISD::Ins
@ Ins
Definition: MipsISelLowering.h:160
llvm::SmallVectorImpl< MCPhysReg >
MachineOperand.h
llvm::ARMBaseRegisterInfo::hasBasePointer
bool hasBasePointer(const MachineFunction &MF) const
Definition: ARMBaseRegisterInfo.cpp:410
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:542
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:601
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:163
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::ARMBaseRegisterInfo::eliminateFrameIndex
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
Definition: ARMBaseRegisterInfo.cpp:784
TargetRegisterInfo.h
Debug.h
llvm::MachineBasicBlock::end
iterator end()
Definition: MachineBasicBlock.h:279
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:334
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:803
llvm::MCRegister
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
llvm::LiveRegMatrix
Definition: LiveRegMatrix.h:40