1 //===- PPCRegisterInfo.h - PowerPC Register Information Impl -----*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the PowerPC implementation of the MRegisterInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef POWERPC32_REGISTERINFO_H
15 #define POWERPC32_REGISTERINFO_H
18 #include "PPCGenRegisterInfo.h.inc"
23 class TargetInstrInfo;
26 class PPCRegisterInfo : public PPCGenRegisterInfo {
27 std::map<unsigned, unsigned> ImmToIdxMap;
28 const PPCSubtarget &Subtarget;
29 const TargetInstrInfo &TII;
31 PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii);
33 /// getRegisterNumbering - Given the enum value for some register, e.g.
34 /// PPC::F14, return the number that it corresponds to (e.g. 14).
35 static unsigned getRegisterNumbering(unsigned RegEnum);
37 /// Code Generation virtual methods...
38 void storeRegToStackSlot(MachineBasicBlock &MBB,
39 MachineBasicBlock::iterator MBBI,
40 unsigned SrcReg, int FrameIndex,
41 const TargetRegisterClass *RC) const;
43 void loadRegFromStackSlot(MachineBasicBlock &MBB,
44 MachineBasicBlock::iterator MBBI,
45 unsigned DestReg, int FrameIndex,
46 const TargetRegisterClass *RC) const;
48 void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
49 unsigned DestReg, unsigned SrcReg,
50 const TargetRegisterClass *RC) const;
52 /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
53 /// copy instructions, turning them into load/store instructions.
54 virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
55 int FrameIndex) const;
57 const unsigned *getCalleeSavedRegs() const;
59 const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
61 BitVector getReservedRegs(const MachineFunction &MF) const;
63 /// targetHandlesStackFrameRounding - Returns true if the target is
64 /// responsible for rounding up the stack frame (probably at emitPrologue
66 bool targetHandlesStackFrameRounding() const { return true; }
68 bool hasFP(const MachineFunction &MF) const;
70 void eliminateCallFramePseudoInstr(MachineFunction &MF,
71 MachineBasicBlock &MBB,
72 MachineBasicBlock::iterator I) const;
74 /// usesLR - Returns if the link registers (LR) has been used in the function.
76 bool usesLR(MachineFunction &MF) const;
78 void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
79 void eliminateFrameIndex(MachineBasicBlock::iterator II) const;
81 /// determineFrameLayout - Determine the size of the frame and maximum call
83 void determineFrameLayout(MachineFunction &MF) const;
85 void emitPrologue(MachineFunction &MF) const;
86 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
88 // Debug information queries.
89 unsigned getRARegister() const;
90 unsigned getFrameRegister(MachineFunction &MF) const;
91 void getInitialFrameState(std::vector<MachineMove> &Moves) const;
94 } // end namespace llvm