1 //===- SPURegisterInfo.h - Cell SPU Register Information Impl ----*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file contains the Cell SPU implementation of the MRegisterInfo class.
13 //===----------------------------------------------------------------------===//
15 #ifndef SPU_REGISTERINFO_H
16 #define SPU_REGISTERINFO_H
19 #include "SPUGenRegisterInfo.h.inc"
23 class TargetInstrInfo;
26 class SPURegisterInfo : public SPUGenRegisterInfo {
28 const SPUSubtarget &Subtarget;
29 const TargetInstrInfo &TII;
31 //! Predicate: Does the machine function use the link register?
32 bool usesLR(MachineFunction &MF) const;
35 SPURegisterInfo(const SPUSubtarget &subtarget, const TargetInstrInfo &tii);
37 //! Translate a register's enum value to a register number
39 This method translates a register's enum value to it's regiser number,
42 static unsigned getRegisterNumbering(unsigned RegEnum);
44 //! Store a register to a stack slot, based on its register class.
45 void storeRegToStackSlot(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MBBI,
47 unsigned SrcReg, int FrameIndex,
48 const TargetRegisterClass *RC) const;
50 //! Store a register to an address, based on its register class
51 void storeRegToAddr(MachineFunction &MF, unsigned SrcReg,
52 SmallVectorImpl<MachineOperand> &Addr,
53 const TargetRegisterClass *RC,
54 SmallVectorImpl<MachineInstr*> &NewMIs) const;
56 //! Load a register from a stack slot, based on its register class.
57 void loadRegFromStackSlot(MachineBasicBlock &MBB,
58 MachineBasicBlock::iterator MBBI,
59 unsigned DestReg, int FrameIndex,
60 const TargetRegisterClass *RC) const;
62 //! Loqad a register from an address, based on its register class
63 virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
64 SmallVectorImpl<MachineOperand> &Addr,
65 const TargetRegisterClass *RC,
66 SmallVectorImpl<MachineInstr*> &NewMIs) const;
68 //! Copy a register to another
69 void copyRegToReg(MachineBasicBlock &MBB,
70 MachineBasicBlock::iterator MI,
71 unsigned DestReg, unsigned SrcReg,
72 const TargetRegisterClass *DestRC,
73 const TargetRegisterClass *SrcRC) const;
75 void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
76 unsigned DestReg, const MachineInstr *Orig) const;
78 //! Fold spills into load/store instructions
79 virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
80 int FrameIndex) const;
82 //! Fold any load/store to an operand
83 virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
84 MachineInstr* LoadMI) const;
86 //! Return the array of callee-saved registers
87 virtual const unsigned* getCalleeSavedRegs(const MachineFunction *MF) const;
89 //! Return the register class array of the callee-saved registers
90 virtual const TargetRegisterClass* const *
91 getCalleeSavedRegClasses(const MachineFunction *MF) const;
93 //! Return the reserved registers
94 BitVector getReservedRegs(const MachineFunction &MF) const;
96 //! Prediate: Target has dedicated frame pointer
97 bool hasFP(const MachineFunction &MF) const;
98 //! Eliminate the call frame setup pseudo-instructions
99 void eliminateCallFramePseudoInstr(MachineFunction &MF,
100 MachineBasicBlock &MBB,
101 MachineBasicBlock::iterator I) const;
102 //! Convert frame indicies into machine operands
103 void eliminateFrameIndex(MachineBasicBlock::iterator II, int,
104 RegScavenger *RS) const;
105 //! Determine the frame's layour
106 void determineFrameLayout(MachineFunction &MF) const;
108 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
109 RegScavenger *RS = NULL) const;
110 //! Emit the function prologue
111 void emitPrologue(MachineFunction &MF) const;
112 //! Emit the function epilogue
113 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
114 //! Get return address register (LR, aka R0)
115 unsigned getRARegister() const;
116 //! Get the stack frame register (SP, aka R1)
117 unsigned getFrameRegister(MachineFunction &MF) const;
118 //! Perform target-specific stack frame setup.
119 void getInitialFrameState(std::vector<MachineMove> &Moves) const;
121 //------------------------------------------------------------------------
122 // New methods added:
123 //------------------------------------------------------------------------
125 //! Return the array of argument passing registers
127 \note The size of this array is returned by getArgRegsSize().
129 static const unsigned *getArgRegs();
131 //! Return the size of the argument passing register array
132 static const unsigned getNumArgRegs();
134 //! Get DWARF debugging register number
135 int getDwarfRegNum(unsigned RegNum, bool isEH) const;
137 } // end namespace llvm