LLVM  7.0.0
MipsSEFrameLowering.cpp
Go to the documentation of this file.
1 //===- MipsSEFrameLowering.cpp - Mips32/64 Frame Information --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the Mips32/64 implementation of TargetFrameLowering class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "MipsSEFrameLowering.h"
16 #include "MipsMachineFunction.h"
17 #include "MipsRegisterInfo.h"
18 #include "MipsSEInstrInfo.h"
19 #include "MipsSubtarget.h"
20 #include "llvm/ADT/BitVector.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/StringSwitch.h"
35 #include "llvm/IR/DebugLoc.h"
36 #include "llvm/IR/Function.h"
37 #include "llvm/MC/MCDwarf.h"
38 #include "llvm/MC/MCRegisterInfo.h"
40 #include "llvm/Support/CodeGen.h"
43 #include <cassert>
44 #include <cstdint>
45 #include <utility>
46 #include <vector>
47 
48 using namespace llvm;
49 
50 static std::pair<unsigned, unsigned> getMFHiLoOpc(unsigned Src) {
51  if (Mips::ACC64RegClass.contains(Src))
52  return std::make_pair((unsigned)Mips::PseudoMFHI,
53  (unsigned)Mips::PseudoMFLO);
54 
55  if (Mips::ACC64DSPRegClass.contains(Src))
56  return std::make_pair((unsigned)Mips::MFHI_DSP, (unsigned)Mips::MFLO_DSP);
57 
58  if (Mips::ACC128RegClass.contains(Src))
59  return std::make_pair((unsigned)Mips::PseudoMFHI64,
60  (unsigned)Mips::PseudoMFLO64);
61 
62  return std::make_pair(0, 0);
63 }
64 
65 namespace {
66 
67 /// Helper class to expand pseudos.
68 class ExpandPseudo {
69 public:
70  ExpandPseudo(MachineFunction &MF);
71  bool expand();
72 
73 private:
74  using Iter = MachineBasicBlock::iterator;
75 
76  bool expandInstr(MachineBasicBlock &MBB, Iter I);
77  void expandLoadCCond(MachineBasicBlock &MBB, Iter I);
78  void expandStoreCCond(MachineBasicBlock &MBB, Iter I);
79  void expandLoadACC(MachineBasicBlock &MBB, Iter I, unsigned RegSize);
80  void expandStoreACC(MachineBasicBlock &MBB, Iter I, unsigned MFHiOpc,
81  unsigned MFLoOpc, unsigned RegSize);
82  bool expandCopy(MachineBasicBlock &MBB, Iter I);
83  bool expandCopyACC(MachineBasicBlock &MBB, Iter I, unsigned MFHiOpc,
84  unsigned MFLoOpc);
85  bool expandBuildPairF64(MachineBasicBlock &MBB,
86  MachineBasicBlock::iterator I, bool FP64) const;
87  bool expandExtractElementF64(MachineBasicBlock &MBB,
88  MachineBasicBlock::iterator I, bool FP64) const;
89 
90  MachineFunction &MF;
92  const MipsSubtarget &Subtarget;
93  const MipsSEInstrInfo &TII;
94  const MipsRegisterInfo &RegInfo;
95 };
96 
97 } // end anonymous namespace
98 
99 ExpandPseudo::ExpandPseudo(MachineFunction &MF_)
100  : MF(MF_), MRI(MF.getRegInfo()),
101  Subtarget(static_cast<const MipsSubtarget &>(MF.getSubtarget())),
102  TII(*static_cast<const MipsSEInstrInfo *>(Subtarget.getInstrInfo())),
103  RegInfo(*Subtarget.getRegisterInfo()) {}
104 
105 bool ExpandPseudo::expand() {
106  bool Expanded = false;
107 
108  for (auto &MBB : MF) {
109  for (Iter I = MBB.begin(), End = MBB.end(); I != End;)
110  Expanded |= expandInstr(MBB, I++);
111  }
112 
113  return Expanded;
114 }
115 
116 bool ExpandPseudo::expandInstr(MachineBasicBlock &MBB, Iter I) {
117  switch(I->getOpcode()) {
118  case Mips::LOAD_CCOND_DSP:
119  expandLoadCCond(MBB, I);
120  break;
121  case Mips::STORE_CCOND_DSP:
122  expandStoreCCond(MBB, I);
123  break;
124  case Mips::LOAD_ACC64:
125  case Mips::LOAD_ACC64DSP:
126  expandLoadACC(MBB, I, 4);
127  break;
128  case Mips::LOAD_ACC128:
129  expandLoadACC(MBB, I, 8);
130  break;
131  case Mips::STORE_ACC64:
132  expandStoreACC(MBB, I, Mips::PseudoMFHI, Mips::PseudoMFLO, 4);
133  break;
134  case Mips::STORE_ACC64DSP:
135  expandStoreACC(MBB, I, Mips::MFHI_DSP, Mips::MFLO_DSP, 4);
136  break;
137  case Mips::STORE_ACC128:
138  expandStoreACC(MBB, I, Mips::PseudoMFHI64, Mips::PseudoMFLO64, 8);
139  break;
140  case Mips::BuildPairF64:
141  if (expandBuildPairF64(MBB, I, false))
142  MBB.erase(I);
143  return false;
144  case Mips::BuildPairF64_64:
145  if (expandBuildPairF64(MBB, I, true))
146  MBB.erase(I);
147  return false;
149  if (expandExtractElementF64(MBB, I, false))
150  MBB.erase(I);
151  return false;
152  case Mips::ExtractElementF64_64:
153  if (expandExtractElementF64(MBB, I, true))
154  MBB.erase(I);
155  return false;
156  case TargetOpcode::COPY:
157  if (!expandCopy(MBB, I))
158  return false;
159  break;
160  default:
161  return false;
162  }
163 
164  MBB.erase(I);
165  return true;
166 }
167 
168 void ExpandPseudo::expandLoadCCond(MachineBasicBlock &MBB, Iter I) {
169  // load $vr, FI
170  // copy ccond, $vr
171 
172  assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
173 
174  const TargetRegisterClass *RC = RegInfo.intRegClass(4);
175  unsigned VR = MRI.createVirtualRegister(RC);
176  unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
177 
178  TII.loadRegFromStack(MBB, I, VR, FI, RC, &RegInfo, 0);
179  BuildMI(MBB, I, I->getDebugLoc(), TII.get(TargetOpcode::COPY), Dst)
180  .addReg(VR, RegState::Kill);
181 }
182 
183 void ExpandPseudo::expandStoreCCond(MachineBasicBlock &MBB, Iter I) {
184  // copy $vr, ccond
185  // store $vr, FI
186 
187  assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
188 
189  const TargetRegisterClass *RC = RegInfo.intRegClass(4);
190  unsigned VR = MRI.createVirtualRegister(RC);
191  unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
192 
193  BuildMI(MBB, I, I->getDebugLoc(), TII.get(TargetOpcode::COPY), VR)
194  .addReg(Src, getKillRegState(I->getOperand(0).isKill()));
195  TII.storeRegToStack(MBB, I, VR, true, FI, RC, &RegInfo, 0);
196 }
197 
198 void ExpandPseudo::expandLoadACC(MachineBasicBlock &MBB, Iter I,
199  unsigned RegSize) {
200  // load $vr0, FI
201  // copy lo, $vr0
202  // load $vr1, FI + 4
203  // copy hi, $vr1
204 
205  assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
206 
207  const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize);
208  unsigned VR0 = MRI.createVirtualRegister(RC);
209  unsigned VR1 = MRI.createVirtualRegister(RC);
210  unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
211  unsigned Lo = RegInfo.getSubReg(Dst, Mips::sub_lo);
212  unsigned Hi = RegInfo.getSubReg(Dst, Mips::sub_hi);
213  DebugLoc DL = I->getDebugLoc();
214  const MCInstrDesc &Desc = TII.get(TargetOpcode::COPY);
215 
216  TII.loadRegFromStack(MBB, I, VR0, FI, RC, &RegInfo, 0);
217  BuildMI(MBB, I, DL, Desc, Lo).addReg(VR0, RegState::Kill);
218  TII.loadRegFromStack(MBB, I, VR1, FI, RC, &RegInfo, RegSize);
219  BuildMI(MBB, I, DL, Desc, Hi).addReg(VR1, RegState::Kill);
220 }
221 
222 void ExpandPseudo::expandStoreACC(MachineBasicBlock &MBB, Iter I,
223  unsigned MFHiOpc, unsigned MFLoOpc,
224  unsigned RegSize) {
225  // mflo $vr0, src
226  // store $vr0, FI
227  // mfhi $vr1, src
228  // store $vr1, FI + 4
229 
230  assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
231 
232  const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize);
233  unsigned VR0 = MRI.createVirtualRegister(RC);
234  unsigned VR1 = MRI.createVirtualRegister(RC);
235  unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
236  unsigned SrcKill = getKillRegState(I->getOperand(0).isKill());
237  DebugLoc DL = I->getDebugLoc();
238 
239  BuildMI(MBB, I, DL, TII.get(MFLoOpc), VR0).addReg(Src);
240  TII.storeRegToStack(MBB, I, VR0, true, FI, RC, &RegInfo, 0);
241  BuildMI(MBB, I, DL, TII.get(MFHiOpc), VR1).addReg(Src, SrcKill);
242  TII.storeRegToStack(MBB, I, VR1, true, FI, RC, &RegInfo, RegSize);
243 }
244 
245 bool ExpandPseudo::expandCopy(MachineBasicBlock &MBB, Iter I) {
246  unsigned Src = I->getOperand(1).getReg();
247  std::pair<unsigned, unsigned> Opcodes = getMFHiLoOpc(Src);
248 
249  if (!Opcodes.first)
250  return false;
251 
252  return expandCopyACC(MBB, I, Opcodes.first, Opcodes.second);
253 }
254 
255 bool ExpandPseudo::expandCopyACC(MachineBasicBlock &MBB, Iter I,
256  unsigned MFHiOpc, unsigned MFLoOpc) {
257  // mflo $vr0, src
258  // copy dst_lo, $vr0
259  // mfhi $vr1, src
260  // copy dst_hi, $vr1
261 
262  unsigned Dst = I->getOperand(0).getReg(), Src = I->getOperand(1).getReg();
263  const TargetRegisterClass *DstRC = RegInfo.getMinimalPhysRegClass(Dst);
264  unsigned VRegSize = RegInfo.getRegSizeInBits(*DstRC) / 16;
265  const TargetRegisterClass *RC = RegInfo.intRegClass(VRegSize);
266  unsigned VR0 = MRI.createVirtualRegister(RC);
267  unsigned VR1 = MRI.createVirtualRegister(RC);
268  unsigned SrcKill = getKillRegState(I->getOperand(1).isKill());
269  unsigned DstLo = RegInfo.getSubReg(Dst, Mips::sub_lo);
270  unsigned DstHi = RegInfo.getSubReg(Dst, Mips::sub_hi);
271  DebugLoc DL = I->getDebugLoc();
272 
273  BuildMI(MBB, I, DL, TII.get(MFLoOpc), VR0).addReg(Src);
274  BuildMI(MBB, I, DL, TII.get(TargetOpcode::COPY), DstLo)
275  .addReg(VR0, RegState::Kill);
276  BuildMI(MBB, I, DL, TII.get(MFHiOpc), VR1).addReg(Src, SrcKill);
277  BuildMI(MBB, I, DL, TII.get(TargetOpcode::COPY), DstHi)
278  .addReg(VR1, RegState::Kill);
279  return true;
280 }
281 
282 /// This method expands the same instruction that MipsSEInstrInfo::
283 /// expandBuildPairF64 does, for the case when ABI is fpxx and mthc1 is not
284 /// available and the case where the ABI is FP64A. It is implemented here
285 /// because frame indexes are eliminated before MipsSEInstrInfo::
286 /// expandBuildPairF64 is called.
287 bool ExpandPseudo::expandBuildPairF64(MachineBasicBlock &MBB,
289  bool FP64) const {
290  // For fpxx and when mthc1 is not available, use:
291  // spill + reload via ldc1
292  //
293  // The case where dmtc1 is available doesn't need to be handled here
294  // because it never creates a BuildPairF64 node.
295  //
296  // The FP64A ABI (fp64 with nooddspreg) must also use a spill/reload sequence
297  // for odd-numbered double precision values (because the lower 32-bits is
298  // transferred with mtc1 which is redirected to the upper half of the even
299  // register). Unfortunately, we have to make this decision before register
300  // allocation so for now we use a spill/reload sequence for all
301  // double-precision values in regardless of being an odd/even register.
302  if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) ||
303  (FP64 && !Subtarget.useOddSPReg())) {
304  unsigned DstReg = I->getOperand(0).getReg();
305  unsigned LoReg = I->getOperand(1).getReg();
306  unsigned HiReg = I->getOperand(2).getReg();
307 
308  // It should be impossible to have FGR64 on MIPS-II or MIPS32r1 (which are
309  // the cases where mthc1 is not available). 64-bit architectures and
310  // MIPS32r2 or later can use FGR64 though.
311  assert(Subtarget.isGP64bit() || Subtarget.hasMTHC1() ||
312  !Subtarget.isFP64bit());
313 
314  const TargetRegisterClass *RC = &Mips::GPR32RegClass;
315  const TargetRegisterClass *RC2 =
316  FP64 ? &Mips::FGR64RegClass : &Mips::AFGR64RegClass;
317 
318  // We re-use the same spill slot each time so that the stack frame doesn't
319  // grow too much in functions with a large number of moves.
320  int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC2);
321  if (!Subtarget.isLittle())
322  std::swap(LoReg, HiReg);
323  TII.storeRegToStack(MBB, I, LoReg, I->getOperand(1).isKill(), FI, RC,
324  &RegInfo, 0);
325  TII.storeRegToStack(MBB, I, HiReg, I->getOperand(2).isKill(), FI, RC,
326  &RegInfo, 4);
327  TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &RegInfo, 0);
328  return true;
329  }
330 
331  return false;
332 }
333 
334 /// This method expands the same instruction that MipsSEInstrInfo::
335 /// expandExtractElementF64 does, for the case when ABI is fpxx and mfhc1 is not
336 /// available and the case where the ABI is FP64A. It is implemented here
337 /// because frame indexes are eliminated before MipsSEInstrInfo::
338 /// expandExtractElementF64 is called.
339 bool ExpandPseudo::expandExtractElementF64(MachineBasicBlock &MBB,
341  bool FP64) const {
342  const MachineOperand &Op1 = I->getOperand(1);
343  const MachineOperand &Op2 = I->getOperand(2);
344 
345  if ((Op1.isReg() && Op1.isUndef()) || (Op2.isReg() && Op2.isUndef())) {
346  unsigned DstReg = I->getOperand(0).getReg();
347  BuildMI(MBB, I, I->getDebugLoc(), TII.get(Mips::IMPLICIT_DEF), DstReg);
348  return true;
349  }
350 
351  // For fpxx and when mfhc1 is not available, use:
352  // spill + reload via ldc1
353  //
354  // The case where dmfc1 is available doesn't need to be handled here
355  // because it never creates a ExtractElementF64 node.
356  //
357  // The FP64A ABI (fp64 with nooddspreg) must also use a spill/reload sequence
358  // for odd-numbered double precision values (because the lower 32-bits is
359  // transferred with mfc1 which is redirected to the upper half of the even
360  // register). Unfortunately, we have to make this decision before register
361  // allocation so for now we use a spill/reload sequence for all
362  // double-precision values in regardless of being an odd/even register.
363 
364  if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) ||
365  (FP64 && !Subtarget.useOddSPReg())) {
366  unsigned DstReg = I->getOperand(0).getReg();
367  unsigned SrcReg = Op1.getReg();
368  unsigned N = Op2.getImm();
369  int64_t Offset = 4 * (Subtarget.isLittle() ? N : (1 - N));
370 
371  // It should be impossible to have FGR64 on MIPS-II or MIPS32r1 (which are
372  // the cases where mfhc1 is not available). 64-bit architectures and
373  // MIPS32r2 or later can use FGR64 though.
374  assert(Subtarget.isGP64bit() || Subtarget.hasMTHC1() ||
375  !Subtarget.isFP64bit());
376 
377  const TargetRegisterClass *RC =
378  FP64 ? &Mips::FGR64RegClass : &Mips::AFGR64RegClass;
379  const TargetRegisterClass *RC2 = &Mips::GPR32RegClass;
380 
381  // We re-use the same spill slot each time so that the stack frame doesn't
382  // grow too much in functions with a large number of moves.
383  int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC);
384  TII.storeRegToStack(MBB, I, SrcReg, Op1.isKill(), FI, RC, &RegInfo, 0);
385  TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &RegInfo, Offset);
386  return true;
387  }
388 
389  return false;
390 }
391 
393  : MipsFrameLowering(STI, STI.getStackAlignment()) {}
394 
396  MachineBasicBlock &MBB) const {
397  MachineFrameInfo &MFI = MF.getFrameInfo();
398  MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
399 
400  const MipsSEInstrInfo &TII =
401  *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
402  const MipsRegisterInfo &RegInfo =
403  *static_cast<const MipsRegisterInfo *>(STI.getRegisterInfo());
404 
405  MachineBasicBlock::iterator MBBI = MBB.begin();
406  DebugLoc dl;
407  MipsABIInfo ABI = STI.getABI();
408  unsigned SP = ABI.GetStackPtr();
409  unsigned FP = ABI.GetFramePtr();
410  unsigned ZERO = ABI.GetNullPtr();
411  unsigned MOVE = ABI.GetGPRMoveOp();
412  unsigned ADDiu = ABI.GetPtrAddiuOp();
413  unsigned AND = ABI.IsN64() ? Mips::AND64 : Mips::AND;
414 
415  const TargetRegisterClass *RC = ABI.ArePtrs64bit() ?
416  &Mips::GPR64RegClass : &Mips::GPR32RegClass;
417 
418  // First, compute final stack size.
419  uint64_t StackSize = MFI.getStackSize();
420 
421  // No need to allocate space on the stack.
422  if (StackSize == 0 && !MFI.adjustsStack()) return;
423 
424  MachineModuleInfo &MMI = MF.getMMI();
425  const MCRegisterInfo *MRI = MMI.getContext().getRegisterInfo();
426 
427  // Adjust stack.
428  TII.adjustStackPtr(SP, -StackSize, MBB, MBBI);
429 
430  // emit ".cfi_def_cfa_offset StackSize"
431  unsigned CFIIndex = MF.addFrameInst(
432  MCCFIInstruction::createDefCfaOffset(nullptr, -StackSize));
433  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
434  .addCFIIndex(CFIIndex);
435 
436  if (MF.getFunction().hasFnAttribute("interrupt"))
437  emitInterruptPrologueStub(MF, MBB);
438 
439  const std::vector<CalleeSavedInfo> &CSI = MFI.getCalleeSavedInfo();
440 
441  if (!CSI.empty()) {
442  // Find the instruction past the last instruction that saves a callee-saved
443  // register to the stack.
444  for (unsigned i = 0; i < CSI.size(); ++i)
445  ++MBBI;
446 
447  // Iterate over list of callee-saved registers and emit .cfi_offset
448  // directives.
449  for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(),
450  E = CSI.end(); I != E; ++I) {
451  int64_t Offset = MFI.getObjectOffset(I->getFrameIdx());
452  unsigned Reg = I->getReg();
453 
454  // If Reg is a double precision register, emit two cfa_offsets,
455  // one for each of the paired single precision registers.
456  if (Mips::AFGR64RegClass.contains(Reg)) {
457  unsigned Reg0 =
458  MRI->getDwarfRegNum(RegInfo.getSubReg(Reg, Mips::sub_lo), true);
459  unsigned Reg1 =
460  MRI->getDwarfRegNum(RegInfo.getSubReg(Reg, Mips::sub_hi), true);
461 
462  if (!STI.isLittle())
463  std::swap(Reg0, Reg1);
464 
465  unsigned CFIIndex = MF.addFrameInst(
466  MCCFIInstruction::createOffset(nullptr, Reg0, Offset));
467  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
468  .addCFIIndex(CFIIndex);
469 
470  CFIIndex = MF.addFrameInst(
471  MCCFIInstruction::createOffset(nullptr, Reg1, Offset + 4));
472  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
473  .addCFIIndex(CFIIndex);
474  } else if (Mips::FGR64RegClass.contains(Reg)) {
475  unsigned Reg0 = MRI->getDwarfRegNum(Reg, true);
476  unsigned Reg1 = MRI->getDwarfRegNum(Reg, true) + 1;
477 
478  if (!STI.isLittle())
479  std::swap(Reg0, Reg1);
480 
481  unsigned CFIIndex = MF.addFrameInst(
482  MCCFIInstruction::createOffset(nullptr, Reg0, Offset));
483  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
484  .addCFIIndex(CFIIndex);
485 
486  CFIIndex = MF.addFrameInst(
487  MCCFIInstruction::createOffset(nullptr, Reg1, Offset + 4));
488  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
489  .addCFIIndex(CFIIndex);
490  } else {
491  // Reg is either in GPR32 or FGR32.
492  unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createOffset(
493  nullptr, MRI->getDwarfRegNum(Reg, true), Offset));
494  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
495  .addCFIIndex(CFIIndex);
496  }
497  }
498  }
499 
500  if (MipsFI->callsEhReturn()) {
501  // Insert instructions that spill eh data registers.
502  for (int I = 0; I < 4; ++I) {
503  if (!MBB.isLiveIn(ABI.GetEhDataReg(I)))
504  MBB.addLiveIn(ABI.GetEhDataReg(I));
505  TII.storeRegToStackSlot(MBB, MBBI, ABI.GetEhDataReg(I), false,
506  MipsFI->getEhDataRegFI(I), RC, &RegInfo);
507  }
508 
509  // Emit .cfi_offset directives for eh data registers.
510  for (int I = 0; I < 4; ++I) {
511  int64_t Offset = MFI.getObjectOffset(MipsFI->getEhDataRegFI(I));
512  unsigned Reg = MRI->getDwarfRegNum(ABI.GetEhDataReg(I), true);
513  unsigned CFIIndex = MF.addFrameInst(
514  MCCFIInstruction::createOffset(nullptr, Reg, Offset));
515  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
516  .addCFIIndex(CFIIndex);
517  }
518  }
519 
520  // if framepointer enabled, set it to point to the stack pointer.
521  if (hasFP(MF)) {
522  // Insert instruction "move $fp, $sp" at this location.
523  BuildMI(MBB, MBBI, dl, TII.get(MOVE), FP).addReg(SP).addReg(ZERO)
525 
526  // emit ".cfi_def_cfa_register $fp"
528  nullptr, MRI->getDwarfRegNum(FP, true)));
529  BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
530  .addCFIIndex(CFIIndex);
531 
532  if (RegInfo.needsStackRealignment(MF)) {
533  // addiu $Reg, $zero, -MaxAlignment
534  // andi $sp, $sp, $Reg
535  unsigned VR = MF.getRegInfo().createVirtualRegister(RC);
537  "Function's alignment size requirement is not supported.");
538  int MaxAlign = -(int)MFI.getMaxAlignment();
539 
540  BuildMI(MBB, MBBI, dl, TII.get(ADDiu), VR).addReg(ZERO) .addImm(MaxAlign);
541  BuildMI(MBB, MBBI, dl, TII.get(AND), SP).addReg(SP).addReg(VR);
542 
543  if (hasBP(MF)) {
544  // move $s7, $sp
545  unsigned BP = STI.isABI_N64() ? Mips::S7_64 : Mips::S7;
546  BuildMI(MBB, MBBI, dl, TII.get(MOVE), BP)
547  .addReg(SP)
548  .addReg(ZERO);
549  }
550  }
551  }
552 }
553 
554 void MipsSEFrameLowering::emitInterruptPrologueStub(
555  MachineFunction &MF, MachineBasicBlock &MBB) const {
556  MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
557  MachineBasicBlock::iterator MBBI = MBB.begin();
558  DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
559 
560  // Report an error the target doesn't support Mips32r2 or later.
561  // The epilogue relies on the use of the "ehb" to clear execution
562  // hazards. Pre R2 Mips relies on an implementation defined number
563  // of "ssnop"s to clear the execution hazard. Support for ssnop hazard
564  // clearing is not provided so reject that configuration.
565  if (!STI.hasMips32r2())
567  "\"interrupt\" attribute is not supported on pre-MIPS32R2 or "
568  "MIPS16 targets.");
569 
570  // The GP register contains the "user" value, so we cannot perform
571  // any gp relative loads until we restore the "kernel" or "system" gp
572  // value. Until support is written we shall only accept the static
573  // relocation model.
575  report_fatal_error("\"interrupt\" attribute is only supported for the "
576  "static relocation model on MIPS at the present time.");
577 
578  if (!STI.isABI_O32() || STI.hasMips64())
579  report_fatal_error("\"interrupt\" attribute is only supported for the "
580  "O32 ABI on MIPS32R2+ at the present time.");
581 
582  // Perform ISR handling like GCC
583  StringRef IntKind =
584  MF.getFunction().getFnAttribute("interrupt").getValueAsString();
585  const TargetRegisterClass *PtrRC = &Mips::GPR32RegClass;
586 
587  // EIC interrupt handling needs to read the Cause register to disable
588  // interrupts.
589  if (IntKind == "eic") {
590  // Coprocessor registers are always live per se.
591  MBB.addLiveIn(Mips::COP013);
592  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K0)
593  .addReg(Mips::COP013)
594  .addImm(0)
596 
597  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::EXT), Mips::K0)
598  .addReg(Mips::K0)
599  .addImm(10)
600  .addImm(6)
602  }
603 
604  // Fetch and spill EPC
605  MBB.addLiveIn(Mips::COP014);
606  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K1)
607  .addReg(Mips::COP014)
608  .addImm(0)
610 
611  STI.getInstrInfo()->storeRegToStack(MBB, MBBI, Mips::K1, false,
612  MipsFI->getISRRegFI(0), PtrRC,
613  STI.getRegisterInfo(), 0);
614 
615  // Fetch and Spill Status
616  MBB.addLiveIn(Mips::COP012);
617  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MFC0), Mips::K1)
618  .addReg(Mips::COP012)
619  .addImm(0)
621 
622  STI.getInstrInfo()->storeRegToStack(MBB, MBBI, Mips::K1, false,
623  MipsFI->getISRRegFI(1), PtrRC,
624  STI.getRegisterInfo(), 0);
625 
626  // Build the configuration for disabling lower priority interrupts. Non EIC
627  // interrupts need to be masked off with zero, EIC from the Cause register.
628  unsigned InsPosition = 8;
629  unsigned InsSize = 0;
630  unsigned SrcReg = Mips::ZERO;
631 
632  // If the interrupt we're tied to is the EIC, switch the source for the
633  // masking off interrupts to the cause register.
634  if (IntKind == "eic") {
635  SrcReg = Mips::K0;
636  InsPosition = 10;
637  InsSize = 6;
638  } else
639  InsSize = StringSwitch<unsigned>(IntKind)
640  .Case("sw0", 1)
641  .Case("sw1", 2)
642  .Case("hw0", 3)
643  .Case("hw1", 4)
644  .Case("hw2", 5)
645  .Case("hw3", 6)
646  .Case("hw4", 7)
647  .Case("hw5", 8)
648  .Default(0);
649  assert(InsSize != 0 && "Unknown interrupt type!");
650 
651  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::INS), Mips::K1)
652  .addReg(SrcReg)
653  .addImm(InsPosition)
654  .addImm(InsSize)
655  .addReg(Mips::K1)
657 
658  // Mask off KSU, ERL, EXL
659  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::INS), Mips::K1)
660  .addReg(Mips::ZERO)
661  .addImm(1)
662  .addImm(4)
663  .addReg(Mips::K1)
665 
666  // Disable the FPU as we are not spilling those register sets.
667  if (!STI.useSoftFloat())
668  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::INS), Mips::K1)
669  .addReg(Mips::ZERO)
670  .addImm(29)
671  .addImm(1)
672  .addReg(Mips::K1)
674 
675  // Set the new status
676  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP012)
677  .addReg(Mips::K1)
678  .addImm(0)
680 }
681 
683  MachineBasicBlock &MBB) const {
685  MachineFrameInfo &MFI = MF.getFrameInfo();
686  MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
687 
688  const MipsSEInstrInfo &TII =
689  *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
690  const MipsRegisterInfo &RegInfo =
691  *static_cast<const MipsRegisterInfo *>(STI.getRegisterInfo());
692 
693  DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
694  MipsABIInfo ABI = STI.getABI();
695  unsigned SP = ABI.GetStackPtr();
696  unsigned FP = ABI.GetFramePtr();
697  unsigned ZERO = ABI.GetNullPtr();
698  unsigned MOVE = ABI.GetGPRMoveOp();
699 
700  // if framepointer enabled, restore the stack pointer.
701  if (hasFP(MF)) {
702  // Find the first instruction that restores a callee-saved register.
704 
705  for (unsigned i = 0; i < MFI.getCalleeSavedInfo().size(); ++i)
706  --I;
707 
708  // Insert instruction "move $sp, $fp" at this location.
709  BuildMI(MBB, I, DL, TII.get(MOVE), SP).addReg(FP).addReg(ZERO);
710  }
711 
712  if (MipsFI->callsEhReturn()) {
713  const TargetRegisterClass *RC =
714  ABI.ArePtrs64bit() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass;
715 
716  // Find first instruction that restores a callee-saved register.
718  for (unsigned i = 0; i < MFI.getCalleeSavedInfo().size(); ++i)
719  --I;
720 
721  // Insert instructions that restore eh data registers.
722  for (int J = 0; J < 4; ++J) {
723  TII.loadRegFromStackSlot(MBB, I, ABI.GetEhDataReg(J),
724  MipsFI->getEhDataRegFI(J), RC, &RegInfo);
725  }
726  }
727 
728  if (MF.getFunction().hasFnAttribute("interrupt"))
729  emitInterruptEpilogueStub(MF, MBB);
730 
731  // Get the number of bytes from FrameInfo
732  uint64_t StackSize = MFI.getStackSize();
733 
734  if (!StackSize)
735  return;
736 
737  // Adjust stack.
738  TII.adjustStackPtr(SP, StackSize, MBB, MBBI);
739 }
740 
741 void MipsSEFrameLowering::emitInterruptEpilogueStub(
742  MachineFunction &MF, MachineBasicBlock &MBB) const {
744  MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
745  DebugLoc DL = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
746 
747  // Perform ISR handling like GCC
748  const TargetRegisterClass *PtrRC = &Mips::GPR32RegClass;
749 
750  // Disable Interrupts.
751  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::DI), Mips::ZERO);
752  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::EHB));
753 
754  // Restore EPC
755  STI.getInstrInfo()->loadRegFromStackSlot(MBB, MBBI, Mips::K1,
756  MipsFI->getISRRegFI(0), PtrRC,
757  STI.getRegisterInfo());
758  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP014)
759  .addReg(Mips::K1)
760  .addImm(0);
761 
762  // Restore Status
763  STI.getInstrInfo()->loadRegFromStackSlot(MBB, MBBI, Mips::K1,
764  MipsFI->getISRRegFI(1), PtrRC,
765  STI.getRegisterInfo());
766  BuildMI(MBB, MBBI, DL, STI.getInstrInfo()->get(Mips::MTC0), Mips::COP012)
767  .addReg(Mips::K1)
768  .addImm(0);
769 }
770 
772  int FI,
773  unsigned &FrameReg) const {
774  const MachineFrameInfo &MFI = MF.getFrameInfo();
775  MipsABIInfo ABI = STI.getABI();
776 
777  if (MFI.isFixedObjectIndex(FI))
778  FrameReg = hasFP(MF) ? ABI.GetFramePtr() : ABI.GetStackPtr();
779  else
780  FrameReg = hasBP(MF) ? ABI.GetBasePtr() : ABI.GetStackPtr();
781 
782  return MFI.getObjectOffset(FI) + MFI.getStackSize() -
784 }
785 
789  const std::vector<CalleeSavedInfo> &CSI,
790  const TargetRegisterInfo *TRI) const {
791  MachineFunction *MF = MBB.getParent();
792  const TargetInstrInfo &TII = *STI.getInstrInfo();
793 
794  for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
795  // Add the callee-saved register as live-in. Do not add if the register is
796  // RA and return address is taken, because it has already been added in
797  // method MipsTargetLowering::lowerRETURNADDR.
798  // It's killed at the spill, unless the register is RA and return address
799  // is taken.
800  unsigned Reg = CSI[i].getReg();
801  bool IsRAAndRetAddrIsTaken = (Reg == Mips::RA || Reg == Mips::RA_64)
803  if (!IsRAAndRetAddrIsTaken)
804  MBB.addLiveIn(Reg);
805 
806  // ISRs require HI/LO to be spilled into kernel registers to be then
807  // spilled to the stack frame.
808  bool IsLOHI = (Reg == Mips::LO0 || Reg == Mips::LO0_64 ||
809  Reg == Mips::HI0 || Reg == Mips::HI0_64);
810  const Function &Func = MBB.getParent()->getFunction();
811  if (IsLOHI && Func.hasFnAttribute("interrupt")) {
812  DebugLoc DL = MI->getDebugLoc();
813 
814  unsigned Op = 0;
815  if (!STI.getABI().ArePtrs64bit()) {
816  Op = (Reg == Mips::HI0) ? Mips::MFHI : Mips::MFLO;
817  Reg = Mips::K0;
818  } else {
819  Op = (Reg == Mips::HI0) ? Mips::MFHI64 : Mips::MFLO64;
820  Reg = Mips::K0_64;
821  }
822  BuildMI(MBB, MI, DL, TII.get(Op), Mips::K0)
823  .setMIFlag(MachineInstr::FrameSetup);
824  }
825 
826  // Insert the spill to the stack frame.
827  bool IsKill = !IsRAAndRetAddrIsTaken;
828  const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
829  TII.storeRegToStackSlot(MBB, MI, Reg, IsKill,
830  CSI[i].getFrameIdx(), RC, TRI);
831  }
832 
833  return true;
834 }
835 
836 bool
838  const MachineFrameInfo &MFI = MF.getFrameInfo();
839  // Reserve call frame if the size of the maximum call frame fits into 16-bit
840  // immediate field and there are no variable sized objects on the stack.
841  // Make sure the second register scavenger spill slot can be accessed with one
842  // instruction.
843  return isInt<16>(MFI.getMaxCallFrameSize() + getStackAlignment()) &&
844  !MFI.hasVarSizedObjects();
845 }
846 
847 /// Mark \p Reg and all registers aliasing it in the bitset.
848 static void setAliasRegs(MachineFunction &MF, BitVector &SavedRegs,
849  unsigned Reg) {
851  for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
852  SavedRegs.set(*AI);
853 }
854 
856  BitVector &SavedRegs,
857  RegScavenger *RS) const {
860  MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
861  MipsABIInfo ABI = STI.getABI();
862  unsigned FP = ABI.GetFramePtr();
863  unsigned BP = ABI.IsN64() ? Mips::S7_64 : Mips::S7;
864 
865  // Mark $fp as used if function has dedicated frame pointer.
866  if (hasFP(MF))
867  setAliasRegs(MF, SavedRegs, FP);
868  // Mark $s7 as used if function has dedicated base pointer.
869  if (hasBP(MF))
870  setAliasRegs(MF, SavedRegs, BP);
871 
872  // Create spill slots for eh data registers if function calls eh_return.
873  if (MipsFI->callsEhReturn())
874  MipsFI->createEhDataRegsFI();
875 
876  // Create spill slots for Coprocessor 0 registers if function is an ISR.
877  if (MipsFI->isISR())
878  MipsFI->createISRRegFI();
879 
880  // Expand pseudo instructions which load, store or copy accumulators.
881  // Add an emergency spill slot if a pseudo was expanded.
882  if (ExpandPseudo(MF).expand()) {
883  // The spill slot should be half the size of the accumulator. If target have
884  // general-purpose registers 64 bits wide, it should be 64-bit, otherwise
885  // it should be 32-bit.
886  const TargetRegisterClass &RC = STI.isGP64bit() ?
887  Mips::GPR64RegClass : Mips::GPR32RegClass;
888  int FI = MF.getFrameInfo().CreateStackObject(TRI->getSpillSize(RC),
889  TRI->getSpillAlignment(RC),
890  false);
891  RS->addScavengingFrameIndex(FI);
892  }
893 
894  // Set scavenging frame index if necessary.
895  uint64_t MaxSPOffset = estimateStackSize(MF);
896 
897  // MSA has a minimum offset of 10 bits signed. If there is a variable
898  // sized object on the stack, the estimation cannot account for it.
899  if (isIntN(STI.hasMSA() ? 10 : 16, MaxSPOffset) &&
901  return;
902 
903  const TargetRegisterClass &RC =
904  ABI.ArePtrs64bit() ? Mips::GPR64RegClass : Mips::GPR32RegClass;
905  int FI = MF.getFrameInfo().CreateStackObject(TRI->getSpillSize(RC),
906  TRI->getSpillAlignment(RC),
907  false);
908  RS->addScavengingFrameIndex(FI);
909 }
910 
911 const MipsFrameLowering *
913  return new MipsSEFrameLowering(ST);
914 }
BitVector & set()
Definition: BitVector.h:398
const MipsFrameLowering * createMipsSEFrameLowering(const MipsSubtarget &ST)
DILocation * get() const
Get the underlying DILocation.
Definition: DebugLoc.cpp:22
bool hasBP(const MachineFunction &MF) const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:119
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
const MipsSubtarget & STI
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool ArePtrs64bit() const
Definition: MipsABIInfo.h:75
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:162
unsigned getReg() const
getReg - Returns the register number.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:487
unsigned Reg
const MipsInstrInfo * getInstrInfo() const override
unsigned GetEhDataReg(unsigned I) const
bool isABI_O32() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:307
constexpr bool isInt< 16 >(int64_t x)
Definition: MathExtras.h:306
unsigned const TargetRegisterInfo * TRI
A debug info location.
Definition: DebugLoc.h:34
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
MachineModuleInfo & getMMI() const
int getEhDataRegFI(unsigned Reg) const
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:474
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
return AArch64::GPR64RegClass contains(Reg)
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool hasMips64() const
SI optimize exec mask operations pre RA
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
const HexagonInstrInfo * TII
virtual void storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset) const =0
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isGP64bit() const
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 ...
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
Definition: StringSwitch.h:203
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
bool IsN64() const
Definition: MipsABIInfo.h:44
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
const MCContext & getContext() const
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
unsigned getKillRegState(bool B)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
MachineInstrBundleIterator< MachineInstr > iterator
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
This file declares the machine register scavenger class.
unsigned const MachineRegisterInfo * MRI
unsigned GetPtrAddiuOp() const
Definition: MipsABIInfo.cpp:93
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:467
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
MCRegAliasIterator enumerates all registers aliasing Reg.
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
static Expected< BitVector > expand(StringRef S, StringRef Original)
Definition: GlobPattern.cpp:28
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:398
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
const MipsABIInfo & getABI() const
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int getISRRegFI(unsigned Reg) const
static void setAliasRegs(MachineFunction &MF, BitVector &SavedRegs, unsigned Reg)
Mark Reg and all registers aliasing it in the bitset.
bool isLittle() const
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
const MipsRegisterInfo * getRegisterInfo() const override
static std::pair< unsigned, unsigned > getMFHiLoOpc(unsigned Src)
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
MachineOperand class - Representation of each machine instruction operand.
int64_t getImm() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:924
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:70
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index...
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:363
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MipsSEFrameLowering(const MipsSubtarget &STI)
StringRef getValueAsString() const
Return the attribute&#39;s value as a string.
Definition: Attributes.cpp:195
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Definition: MCInstrInfo.h:45
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
unsigned GetBasePtr() const
Definition: MipsABIInfo.cpp:73
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
int getOffsetAdjustment() const
Return the correction for frame offsets.
uint64_t estimateStackSize(const MachineFunction &MF) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool hasMips32r2() const
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
unsigned GetGPRMoveOp() const
bool isABI_N64() const
Reloc::Model getRelocationModel() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:295
unsigned GetStackPtr() const
Definition: MipsABIInfo.cpp:65
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:317
bool useSoftFloat() const
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
unsigned GetNullPtr() const
Definition: MipsABIInfo.cpp:81
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
unsigned GetFramePtr() const
Definition: MipsABIInfo.cpp:69
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool hasMSA() const
This class contains meta information specific to a module.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override