PPCRegisterInfo.h revision 2365f51ed03afe6993bae962fdc2e5a956a64cd5
1//===- PPCRegisterInfo.h - PowerPC Register Information Impl -----*- C++ -*-==// 2// 3// The LLVM Compiler Infrastructure 4// 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. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains the PowerPC implementation of the MRegisterInfo class. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef POWERPC32_REGISTERINFO_H 15#define POWERPC32_REGISTERINFO_H 16 17#include "PPC.h" 18#include "PPCGenRegisterInfo.h.inc" 19#include <map> 20 21namespace llvm { 22class PPCSubtarget; 23class TargetInstrInfo; 24class Type; 25 26class PPCRegisterInfo : public PPCGenRegisterInfo { 27 std::map<unsigned, unsigned> ImmToIdxMap; 28 const PPCSubtarget &Subtarget; 29 const TargetInstrInfo &TII; 30public: 31 PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii); 32 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); 36 37 /// Code Generation virtual methods... 38 void storeRegToStackSlot(MachineBasicBlock &MBB, 39 MachineBasicBlock::iterator MBBI, 40 unsigned SrcReg, int FrameIndex, 41 const TargetRegisterClass *RC) const; 42 43 void loadRegFromStackSlot(MachineBasicBlock &MBB, 44 MachineBasicBlock::iterator MBBI, 45 unsigned DestReg, int FrameIndex, 46 const TargetRegisterClass *RC) const; 47 48 void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, 49 unsigned DestReg, unsigned SrcReg, 50 const TargetRegisterClass *RC) const; 51 52 void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, 53 unsigned DestReg, const MachineInstr *Orig) const; 54 55 /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into 56 /// copy instructions, turning them into load/store instructions. 57 virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum, 58 int FrameIndex) const; 59 60 const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const; 61 62 const TargetRegisterClass* const* getCalleeSavedRegClasses( 63 const MachineFunction *MF = 0) const; 64 65 BitVector getReservedRegs(const MachineFunction &MF) const; 66 67 /// targetHandlesStackFrameRounding - Returns true if the target is 68 /// responsible for rounding up the stack frame (probably at emitPrologue 69 /// time). 70 bool targetHandlesStackFrameRounding() const { return true; } 71 72 bool hasFP(const MachineFunction &MF) const; 73 74 void eliminateCallFramePseudoInstr(MachineFunction &MF, 75 MachineBasicBlock &MBB, 76 MachineBasicBlock::iterator I) const; 77 78 /// usesLR - Returns if the link registers (LR) has been used in the function. 79 /// 80 bool usesLR(MachineFunction &MF) const; 81 82 void lowerDynamicAlloc(MachineBasicBlock::iterator II) const; 83 void eliminateFrameIndex(MachineBasicBlock::iterator II, 84 int SPAdj, RegScavenger *RS = NULL) const; 85 86 /// determineFrameLayout - Determine the size of the frame and maximum call 87 /// frame size. 88 void determineFrameLayout(MachineFunction &MF) const; 89 90 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 91 RegScavenger *RS = NULL) const; 92 void emitPrologue(MachineFunction &MF) const; 93 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; 94 95 // Debug information queries. 96 unsigned getRARegister() const; 97 unsigned getFrameRegister(MachineFunction &MF) const; 98 void getInitialFrameState(std::vector<MachineMove> &Moves) const; 99 100 // Exception handling queries. 101 unsigned getEHExceptionRegister() const; 102 unsigned getEHHandlerRegister() const; 103}; 104 105} // end namespace llvm 106 107#endif 108