LLVM  10.0.0
AArch64RegisterInfo.cpp
Go to the documentation of this file.
1 //===- AArch64RegisterInfo.cpp - AArch64 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 AArch64 implementation of the TargetRegisterInfo
10 // class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AArch64RegisterInfo.h"
15 #include "AArch64FrameLowering.h"
16 #include "AArch64InstrInfo.h"
18 #include "AArch64StackOffset.h"
19 #include "AArch64Subtarget.h"
21 #include "llvm/ADT/BitVector.h"
22 #include "llvm/ADT/Triple.h"
28 #include "llvm/IR/DiagnosticInfo.h"
29 #include "llvm/IR/Function.h"
32 
33 using namespace llvm;
34 
35 #define GET_REGINFO_TARGET_DESC
36 #include "AArch64GenRegisterInfo.inc"
37 
39  : AArch64GenRegisterInfo(AArch64::LR), TT(TT) {
41 }
42 
43 const MCPhysReg *
45  assert(MF && "Invalid MachineFunction pointer.");
47  return CSR_Win_AArch64_CFGuard_Check_SaveList;
49  return CSR_Win_AArch64_AAPCS_SaveList;
51  // GHC set of callee saved regs is empty as all those regs are
52  // used for passing STG regs around
53  return CSR_AArch64_NoRegs_SaveList;
55  return CSR_AArch64_AllRegs_SaveList;
57  return CSR_AArch64_AAVPCS_SaveList;
59  return CSR_AArch64_SVE_AAPCS_SaveList;
61  return MF->getInfo<AArch64FunctionInfo>()->isSplitCSR() ?
62  CSR_AArch64_CXX_TLS_Darwin_PE_SaveList :
63  CSR_AArch64_CXX_TLS_Darwin_SaveList;
65  ->supportSwiftError() &&
67  Attribute::SwiftError))
68  return CSR_AArch64_AAPCS_SwiftError_SaveList;
70  return CSR_AArch64_RT_MostRegs_SaveList;
72  return CSR_Darwin_AArch64_AAPCS_SaveList;
73  return CSR_AArch64_AAPCS_SaveList;
74 }
75 
77  const MachineFunction *MF) const {
78  assert(MF && "Invalid MachineFunction pointer.");
80  MF->getInfo<AArch64FunctionInfo>()->isSplitCSR())
81  return CSR_AArch64_CXX_TLS_Darwin_ViaCopy_SaveList;
82  return nullptr;
83 }
84 
86  MachineFunction &MF) const {
87  const MCPhysReg *CSRs = getCalleeSavedRegs(&MF);
88  SmallVector<MCPhysReg, 32> UpdatedCSRs;
89  for (const MCPhysReg *I = CSRs; *I; ++I)
90  UpdatedCSRs.push_back(*I);
91 
92  for (size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
94  UpdatedCSRs.push_back(AArch64::GPR64commonRegClass.getRegister(i));
95  }
96  }
97  // Register lists are zero-terminated.
98  UpdatedCSRs.push_back(0);
99  MF.getRegInfo().setCalleeSavedRegs(UpdatedCSRs);
100 }
101 
102 const TargetRegisterClass *
104  unsigned Idx) const {
105  // edge case for GPR/FPR register classes
106  if (RC == &AArch64::GPR32allRegClass && Idx == AArch64::hsub)
107  return &AArch64::FPR32RegClass;
108  else if (RC == &AArch64::GPR64allRegClass && Idx == AArch64::hsub)
109  return &AArch64::FPR64RegClass;
110 
111  // Forward to TableGen's default version.
112  return AArch64GenRegisterInfo::getSubClassWithSubReg(RC, Idx);
113 }
114 
115 const uint32_t *
117  CallingConv::ID CC) const {
118  bool SCS = MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack);
119  if (CC == CallingConv::GHC)
120  // This is academic because all GHC calls are (supposed to be) tail calls
121  return SCS ? CSR_AArch64_NoRegs_SCS_RegMask : CSR_AArch64_NoRegs_RegMask;
122  if (CC == CallingConv::AnyReg)
123  return SCS ? CSR_AArch64_AllRegs_SCS_RegMask : CSR_AArch64_AllRegs_RegMask;
124  if (CC == CallingConv::CXX_FAST_TLS)
125  return SCS ? CSR_AArch64_CXX_TLS_Darwin_SCS_RegMask
126  : CSR_AArch64_CXX_TLS_Darwin_RegMask;
128  return SCS ? CSR_AArch64_AAVPCS_SCS_RegMask : CSR_AArch64_AAVPCS_RegMask;
130  return SCS ? CSR_AArch64_SVE_AAPCS_SCS_RegMask
131  : CSR_AArch64_SVE_AAPCS_RegMask;
132  if (CC == CallingConv::CFGuard_Check)
133  return CSR_Win_AArch64_CFGuard_Check_RegMask;
135  ->supportSwiftError() &&
136  MF.getFunction().getAttributes().hasAttrSomewhere(Attribute::SwiftError))
137  return SCS ? CSR_AArch64_AAPCS_SwiftError_SCS_RegMask
138  : CSR_AArch64_AAPCS_SwiftError_RegMask;
139  if (CC == CallingConv::PreserveMost)
140  return SCS ? CSR_AArch64_RT_MostRegs_SCS_RegMask
141  : CSR_AArch64_RT_MostRegs_RegMask;
142  else
143  return SCS ? CSR_AArch64_AAPCS_SCS_RegMask : CSR_AArch64_AAPCS_RegMask;
144 }
145 
147  if (TT.isOSDarwin())
148  return CSR_AArch64_TLS_Darwin_RegMask;
149 
150  assert(TT.isOSBinFormatELF() && "Invalid target");
151  return CSR_AArch64_TLS_ELF_RegMask;
152 }
153 
155  const uint32_t **Mask) const {
156  uint32_t *UpdatedMask = MF.allocateRegMask();
157  unsigned RegMaskSize = MachineOperand::getRegMaskSize(getNumRegs());
158  memcpy(UpdatedMask, *Mask, sizeof(UpdatedMask[0]) * RegMaskSize);
159 
160  for (size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
162  for (MCSubRegIterator SubReg(AArch64::GPR64commonRegClass.getRegister(i),
163  this, true);
164  SubReg.isValid(); ++SubReg) {
165  // See TargetRegisterInfo::getCallPreservedMask for how to interpret the
166  // register mask.
167  UpdatedMask[*SubReg / 32] |= 1u << (*SubReg % 32);
168  }
169  }
170  }
171  *Mask = UpdatedMask;
172 }
173 
175  return CSR_AArch64_NoRegs_RegMask;
176 }
177 
178 const uint32_t *
180  CallingConv::ID CC) const {
181  // This should return a register mask that is the same as that returned by
182  // getCallPreservedMask but that additionally preserves the register used for
183  // the first i64 argument (which must also be the register used to return a
184  // single i64 return value)
185  //
186  // In case that the calling convention does not use the same register for
187  // both, the function should return NULL (does not currently apply)
188  assert(CC != CallingConv::GHC && "should not be GHC calling convention.");
189  return CSR_AArch64_AAPCS_ThisReturn_RegMask;
190 }
191 
193  return CSR_AArch64_StackProbe_Windows_RegMask;
194 }
195 
196 BitVector
198  const AArch64FrameLowering *TFI = getFrameLowering(MF);
199 
200  // FIXME: avoid re-calculating this every time.
201  BitVector Reserved(getNumRegs());
202  markSuperRegs(Reserved, AArch64::WSP);
203  markSuperRegs(Reserved, AArch64::WZR);
204 
205  if (TFI->hasFP(MF) || TT.isOSDarwin())
206  markSuperRegs(Reserved, AArch64::W29);
207 
208  for (size_t i = 0; i < AArch64::GPR32commonRegClass.getNumRegs(); ++i) {
210  markSuperRegs(Reserved, AArch64::GPR32commonRegClass.getRegister(i));
211  }
212 
213  if (hasBasePointer(MF))
214  markSuperRegs(Reserved, AArch64::W19);
215 
216  // SLH uses register W16/X16 as the taint register.
217  if (MF.getFunction().hasFnAttribute(Attribute::SpeculativeLoadHardening))
218  markSuperRegs(Reserved, AArch64::W16);
219 
220  assert(checkAllSuperRegsMarked(Reserved));
221  return Reserved;
222 }
223 
225  unsigned Reg) const {
226  return getReservedRegs(MF)[Reg];
227 }
228 
230  return std::any_of(std::begin(*AArch64::GPR64argRegClass.MC),
231  std::end(*AArch64::GPR64argRegClass.MC),
232  [this, &MF](MCPhysReg r){return isReservedReg(MF, r);});
233 }
234 
236  const MachineFunction &MF) const {
237  const Function &F = MF.getFunction();
238  F.getContext().diagnose(DiagnosticInfoUnsupported{F, "AArch64 doesn't support"
239  " function calls if any of the argument registers is reserved."});
240 }
241 
243  unsigned PhysReg) const {
244  return !isReservedReg(MF, PhysReg);
245 }
246 
247 bool AArch64RegisterInfo::isConstantPhysReg(unsigned PhysReg) const {
248  return PhysReg == AArch64::WZR || PhysReg == AArch64::XZR;
249 }
250 
251 const TargetRegisterClass *
253  unsigned Kind) const {
254  return &AArch64::GPR64spRegClass;
255 }
256 
257 const TargetRegisterClass *
259  if (RC == &AArch64::CCRRegClass)
260  return &AArch64::GPR64RegClass; // Only MSR & MRS copy NZCV.
261  return RC;
262 }
263 
264 unsigned AArch64RegisterInfo::getBaseRegister() const { return AArch64::X19; }
265 
267  const MachineFrameInfo &MFI = MF.getFrameInfo();
268 
269  // In the presence of variable sized objects or funclets, if the fixed stack
270  // size is large enough that referencing from the FP won't result in things
271  // being in range relatively often, we can use a base pointer to allow access
272  // from the other direction like the SP normally works.
273  //
274  // Furthermore, if both variable sized objects are present, and the
275  // stack needs to be dynamically re-aligned, the base pointer is the only
276  // reliable way to reference the locals.
277  if (MFI.hasVarSizedObjects() || MF.hasEHFunclets()) {
278  if (needsStackRealignment(MF))
279  return true;
280  // Conservatively estimate whether the negative offset from the frame
281  // pointer will be sufficient to reach. If a function has a smallish
282  // frame, it's less likely to have lots of spills and callee saved
283  // space, so it's all more likely to be within range of the frame pointer.
284  // If it's wrong, we'll materialize the constant and still get to the
285  // object; it's just suboptimal. Negative offsets use the unscaled
286  // load/store instructions, which have a 9-bit signed immediate.
287  return MFI.getLocalFrameSize() >= 256;
288  }
289 
290  return false;
291 }
292 
293 Register
295  const AArch64FrameLowering *TFI = getFrameLowering(MF);
296  return TFI->hasFP(MF) ? AArch64::FP : AArch64::SP;
297 }
298 
300  const MachineFunction &MF) const {
301  return true;
302 }
303 
305  const MachineFunction &MF) const {
306  return true;
307 }
308 
309 bool
311  // This function indicates whether the emergency spillslot should be placed
312  // close to the beginning of the stackframe (closer to FP) or the end
313  // (closer to SP).
314  //
315  // The beginning works most reliably if we have a frame pointer.
316  const AArch64FrameLowering &TFI = *getFrameLowering(MF);
317  return TFI.hasFP(MF);
318 }
319 
321  const MachineFunction &MF) const {
322  return true;
323 }
324 
325 bool
327  const MachineFrameInfo &MFI = MF.getFrameInfo();
329  return true;
330  return MFI.hasVarSizedObjects() || MFI.isFrameAddressTaken();
331 }
332 
333 /// needsFrameBaseReg - Returns true if the instruction's frame index
334 /// reference would be better served by a base register other than FP
335 /// or SP. Used by LocalStackFrameAllocation to determine which frame index
336 /// references it should create new base registers for.
338  int64_t Offset) const {
339  for (unsigned i = 0; !MI->getOperand(i).isFI(); ++i)
340  assert(i < MI->getNumOperands() &&
341  "Instr doesn't have FrameIndex operand!");
342 
343  // It's the load/store FI references that cause issues, as it can be difficult
344  // to materialize the offset if it won't fit in the literal field. Estimate
345  // based on the size of the local frame and some conservative assumptions
346  // about the rest of the stack frame (note, this is pre-regalloc, so
347  // we don't know everything for certain yet) whether this offset is likely
348  // to be out of range of the immediate. Return true if so.
349 
350  // We only generate virtual base registers for loads and stores, so
351  // return false for everything else.
352  if (!MI->mayLoad() && !MI->mayStore())
353  return false;
354 
355  // Without a virtual base register, if the function has variable sized
356  // objects, all fixed-size local references will be via the frame pointer,
357  // Approximate the offset and see if it's legal for the instruction.
358  // Note that the incoming offset is based on the SP value at function entry,
359  // so it'll be negative.
360  MachineFunction &MF = *MI->getParent()->getParent();
361  const AArch64FrameLowering *TFI = getFrameLowering(MF);
362  MachineFrameInfo &MFI = MF.getFrameInfo();
363 
364  // Estimate an offset from the frame pointer.
365  // Conservatively assume all GPR callee-saved registers get pushed.
366  // FP, LR, X19-X28, D8-D15. 64-bits each.
367  int64_t FPOffset = Offset - 16 * 20;
368  // Estimate an offset from the stack pointer.
369  // The incoming offset is relating to the SP at the start of the function,
370  // but when we access the local it'll be relative to the SP after local
371  // allocation, so adjust our SP-relative offset by that allocation size.
372  Offset += MFI.getLocalFrameSize();
373  // Assume that we'll have at least some spill slots allocated.
374  // FIXME: This is a total SWAG number. We should run some statistics
375  // and pick a real one.
376  Offset += 128; // 128 bytes of spill slots
377 
378  // If there is a frame pointer, try using it.
379  // The FP is only available if there is no dynamic realignment. We
380  // don't know for sure yet whether we'll need that, so we guess based
381  // on whether there are any local variables that would trigger it.
382  if (TFI->hasFP(MF) && isFrameOffsetLegal(MI, AArch64::FP, FPOffset))
383  return false;
384 
385  // If we can reference via the stack pointer or base pointer, try that.
386  // FIXME: This (and the code that resolves the references) can be improved
387  // to only disallow SP relative references in the live range of
388  // the VLA(s). In practice, it's unclear how much difference that
389  // would make, but it may be worth doing.
390  if (isFrameOffsetLegal(MI, AArch64::SP, Offset))
391  return false;
392 
393  // The offset likely isn't legal; we want to allocate a virtual base register.
394  return true;
395 }
396 
398  unsigned BaseReg,
399  int64_t Offset) const {
400  assert(MI && "Unable to get the legal offset for nil instruction.");
401  StackOffset SaveOffset(Offset, MVT::i8);
402  return isAArch64FrameOffsetLegal(*MI, SaveOffset) & AArch64FrameOffsetIsLegal;
403 }
404 
405 /// Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx
406 /// at the beginning of the basic block.
408  unsigned BaseReg,
409  int FrameIdx,
410  int64_t Offset) const {
412  DebugLoc DL; // Defaults to "unknown"
413  if (Ins != MBB->end())
414  DL = Ins->getDebugLoc();
415  const MachineFunction &MF = *MBB->getParent();
416  const AArch64InstrInfo *TII =
417  MF.getSubtarget<AArch64Subtarget>().getInstrInfo();
418  const MCInstrDesc &MCID = TII->get(AArch64::ADDXri);
420  MRI.constrainRegClass(BaseReg, TII->getRegClass(MCID, 0, this, MF));
421  unsigned Shifter = AArch64_AM::getShifterImm(AArch64_AM::LSL, 0);
422 
423  BuildMI(*MBB, Ins, DL, MCID, BaseReg)
424  .addFrameIndex(FrameIdx)
425  .addImm(Offset)
426  .addImm(Shifter);
427 }
428 
430  int64_t Offset) const {
431  // ARM doesn't need the general 64-bit offsets
432  StackOffset Off(Offset, MVT::i8);
433 
434  unsigned i = 0;
435 
436  while (!MI.getOperand(i).isFI()) {
437  ++i;
438  assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
439  }
440  const MachineFunction *MF = MI.getParent()->getParent();
441  const AArch64InstrInfo *TII =
442  MF->getSubtarget<AArch64Subtarget>().getInstrInfo();
443  bool Done = rewriteAArch64FrameIndex(MI, i, BaseReg, Off, TII);
444  assert(Done && "Unable to resolve frame index!");
445  (void)Done;
446 }
447 
449  int SPAdj, unsigned FIOperandNum,
450  RegScavenger *RS) const {
451  assert(SPAdj == 0 && "Unexpected");
452 
453  MachineInstr &MI = *II;
454  MachineBasicBlock &MBB = *MI.getParent();
455  MachineFunction &MF = *MBB.getParent();
456  const MachineFrameInfo &MFI = MF.getFrameInfo();
457  const AArch64InstrInfo *TII =
458  MF.getSubtarget<AArch64Subtarget>().getInstrInfo();
459  const AArch64FrameLowering *TFI = getFrameLowering(MF);
460 
461  int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
462  bool Tagged =
463  MI.getOperand(FIOperandNum).getTargetFlags() & AArch64II::MO_TAGGED;
464  unsigned FrameReg;
465 
466  // Special handling of dbg_value, stackmap and patchpoint instructions.
467  if (MI.isDebugValue() || MI.getOpcode() == TargetOpcode::STACKMAP ||
468  MI.getOpcode() == TargetOpcode::PATCHPOINT) {
470  TFI->resolveFrameIndexReference(MF, FrameIndex, FrameReg,
471  /*PreferFP=*/true,
472  /*ForSimm=*/false);
473  Offset += StackOffset(MI.getOperand(FIOperandNum + 1).getImm(), MVT::i8);
474  MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg, false /*isDef*/);
475  MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset.getBytes());
476  return;
477  }
478 
479  if (MI.getOpcode() == TargetOpcode::LOCAL_ESCAPE) {
480  MachineOperand &FI = MI.getOperand(FIOperandNum);
481  int Offset = TFI->getNonLocalFrameIndexReference(MF, FrameIndex);
482  FI.ChangeToImmediate(Offset);
483  return;
484  }
485 
487  if (MI.getOpcode() == AArch64::TAGPstack) {
488  // TAGPstack must use the virtual frame register in its 3rd operand.
490  FrameReg = MI.getOperand(3).getReg();
491  Offset = {MFI.getObjectOffset(FrameIndex) +
493  MVT::i8};
494  } else if (Tagged) {
495  StackOffset SPOffset = {
496  MFI.getObjectOffset(FrameIndex) + (int64_t)MFI.getStackSize(), MVT::i8};
497  if (MFI.hasVarSizedObjects() ||
498  isAArch64FrameOffsetLegal(MI, SPOffset, nullptr, nullptr, nullptr) !=
500  // Can't update to SP + offset in place. Precalculate the tagged pointer
501  // in a scratch register.
502  Offset = TFI->resolveFrameIndexReference(
503  MF, FrameIndex, FrameReg, /*PreferFP=*/false, /*ForSimm=*/true);
504  Register ScratchReg =
505  MF.getRegInfo().createVirtualRegister(&AArch64::GPR64RegClass);
506  emitFrameOffset(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg, Offset,
507  TII);
508  BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(AArch64::LDG), ScratchReg)
509  .addReg(ScratchReg)
510  .addReg(ScratchReg)
511  .addImm(0);
512  MI.getOperand(FIOperandNum)
513  .ChangeToRegister(ScratchReg, false, false, true);
514  return;
515  }
516  FrameReg = AArch64::SP;
517  Offset = {MFI.getObjectOffset(FrameIndex) + (int64_t)MFI.getStackSize(),
518  MVT::i8};
519  } else {
520  Offset = TFI->resolveFrameIndexReference(
521  MF, FrameIndex, FrameReg, /*PreferFP=*/false, /*ForSimm=*/true);
522  }
523 
524  // Modify MI as necessary to handle as much of 'Offset' as possible
525  if (rewriteAArch64FrameIndex(MI, FIOperandNum, FrameReg, Offset, TII))
526  return;
527 
528  assert((!RS || !RS->isScavengingFrameIndex(FrameIndex)) &&
529  "Emergency spill slot is out of reach");
530 
531  // If we get here, the immediate doesn't fit into the instruction. We folded
532  // as much as possible above. Handle the rest, providing a register that is
533  // SP+LargeImm.
534  Register ScratchReg =
535  MF.getRegInfo().createVirtualRegister(&AArch64::GPR64RegClass);
536  emitFrameOffset(MBB, II, MI.getDebugLoc(), ScratchReg, FrameReg, Offset, TII);
537  MI.getOperand(FIOperandNum).ChangeToRegister(ScratchReg, false, false, true);
538 }
539 
541  MachineFunction &MF) const {
542  const AArch64FrameLowering *TFI = getFrameLowering(MF);
543 
544  switch (RC->getID()) {
545  default:
546  return 0;
547  case AArch64::GPR32RegClassID:
548  case AArch64::GPR32spRegClassID:
549  case AArch64::GPR32allRegClassID:
550  case AArch64::GPR64spRegClassID:
551  case AArch64::GPR64allRegClassID:
552  case AArch64::GPR64RegClassID:
553  case AArch64::GPR32commonRegClassID:
554  case AArch64::GPR64commonRegClassID:
555  return 32 - 1 // XZR/SP
556  - (TFI->hasFP(MF) || TT.isOSDarwin()) // FP
558  - hasBasePointer(MF); // X19
559  case AArch64::FPR8RegClassID:
560  case AArch64::FPR16RegClassID:
561  case AArch64::FPR32RegClassID:
562  case AArch64::FPR64RegClassID:
563  case AArch64::FPR128RegClassID:
564  return 32;
565 
566  case AArch64::DDRegClassID:
567  case AArch64::DDDRegClassID:
568  case AArch64::DDDDRegClassID:
569  case AArch64::QQRegClassID:
570  case AArch64::QQQRegClassID:
571  case AArch64::QQQQRegClassID:
572  return 32;
573 
574  case AArch64::FPR128_loRegClassID:
575  return 16;
576  }
577 }
578 
580  const MachineFunction &MF) const {
581  const auto &MFI = MF.getFrameInfo();
582  if (!MF.hasEHFunclets() && !MFI.hasVarSizedObjects())
583  return AArch64::SP;
584  else if (needsStackRealignment(MF))
585  return getBaseRegister();
586  return getFrameRegister(MF);
587 }
unsigned getTargetFlags() const
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
Definition: Triple.h:482
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
Diagnostic information for unsupported feature in backend.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:624
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Definition: MachineInstr.h:400
bool cannotEliminateFrame(const MachineFunction &MF) const
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:188
int64_t getLocalFrameSize() const
Get the size of the local object blob.
unsigned Reg
Offset can apply, at least partly.
bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg, int64_t Offset) const override
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:323
A debug info location.
Definition: DebugLoc.h:33
F(f)
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
Calling convention between AArch64 SVE functions.
Definition: CallingConv.h:237
bool isAnyArgRegReserved(const MachineFunction &MF) const
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:429
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
unsigned SubReg
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:426
unsigned getID() const
Return the register class ID number.
const uint32_t * getNoPreservedMask() const override
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
AArch64RegisterInfo(const Triple &TT)
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:223
bool isXRegisterReserved(size_t i) const
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
int64_t getBytes() const
Returns the non-scalable part of the offset in bytes.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
int getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const override
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
void materializeFrameBaseRegister(MachineBasicBlock *MBB, unsigned BaseReg, int FrameIdx, int64_t Offset) const override
Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx at the beginning of the basic ...
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...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
const AArch64TargetLowering * getTargetLowering() const override
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Definition: MachineInstr.h:869
StackOffset resolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, bool PreferFP, bool ForSimm) const
This file declares the machine register scavenger class.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool hasEHFunclets() const
void eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1189
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that &#39;returned&#39; is on...
Register getFrameRegister(const MachineFunction &MF) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
const MachineInstrBuilder & addFrameIndex(int Idx) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition: Function.cpp:223
MCSubRegIterator enumerates all sub-registers of Reg.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, int64_t Offset) const override
int64_t getImm() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
unsigned getNumXRegisterReserved() const
void UpdateCustomCallPreservedMask(MachineFunction &MF, const uint32_t **Mask) const
const uint32_t * getWindowsStackProbePreservedMask() const
Stack probing calls preserve different CSRs to the normal CC.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:271
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
bool isReservedReg(const MachineFunction &MF, unsigned Reg) const
Representation of each machine instruction.
Definition: MachineInstr.h:63
BitVector getReservedRegs(const MachineFunction &MF) const override
void UpdateCustomCalleeSavedRegs(MachineFunction &MF) const
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
void emitReservedArgRegCallError(const MachineFunction &MF) const
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getLocalAddressRegister(const MachineFunction &MF) const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
TargetOptions Options
#define I(x, y, z)
Definition: MD5.cpp:58
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
bool useFPForScavengingIndex(const MachineFunction &MF) const override
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool requiresRegisterScavenging(const MachineFunction &MF) const override
const uint32_t * getTLSCallPreservedMask() const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Definition: MachineInstr.h:856
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
Definition: CallingConv.h:87
bool isConstantPhysReg(unsigned PhysReg) const override
bool hasBasePointer(const MachineFunction &MF) const
bool isXRegCustomCalleeSaved(size_t i) const
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:80
IRTranslator LLVM IR MI
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction&#39;s frame index reference would be better served by...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:431
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, StackOffset &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access &#39;Offset&#39; bytes from the FP.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isAsmClobberable(const MachineFunction &MF, unsigned PhysReg) const override
Wrapper class representing virtual and physical registers.
Definition: Register.h:19