Allow copyRegToReg to emit cross register classes copies.
[oota-llvm.git] / lib / Target / PowerPC / PPCRegisterInfo.h
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
21 namespace llvm {
22 class PPCSubtarget;
23 class TargetInstrInfo;
24 class Type;
25
26 class PPCRegisterInfo : public PPCGenRegisterInfo {
27   std::map<unsigned, unsigned> ImmToIdxMap;
28   const PPCSubtarget &Subtarget;
29   const TargetInstrInfo &TII;
30 public:
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 *DestRC,
51                     const TargetRegisterClass *SrcRC) const;
52
53   void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
54                      unsigned DestReg, const MachineInstr *Orig) const;
55
56   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
57   /// copy instructions, turning them into load/store instructions.
58   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
59                                           int FrameIndex) const;
60   
61   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
62                                           MachineInstr* LoadMI) const {
63     return 0;
64   }
65
66   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
67
68   const TargetRegisterClass* const*
69   getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
70
71   BitVector getReservedRegs(const MachineFunction &MF) const;
72
73   /// targetHandlesStackFrameRounding - Returns true if the target is
74   /// responsible for rounding up the stack frame (probably at emitPrologue
75   /// time).
76   bool targetHandlesStackFrameRounding() const { return true; }
77
78   bool hasFP(const MachineFunction &MF) const;
79
80   void eliminateCallFramePseudoInstr(MachineFunction &MF,
81                                      MachineBasicBlock &MBB,
82                                      MachineBasicBlock::iterator I) const;
83
84   /// usesLR - Returns if the link registers (LR) has been used in the function.
85   ///
86   bool usesLR(MachineFunction &MF) const;
87   
88   void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
89   void eliminateFrameIndex(MachineBasicBlock::iterator II,
90                            int SPAdj, RegScavenger *RS = NULL) const;
91
92   /// determineFrameLayout - Determine the size of the frame and maximum call
93   /// frame size.
94   void determineFrameLayout(MachineFunction &MF) const;
95
96   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
97                                             RegScavenger *RS = NULL) const;
98   void emitPrologue(MachineFunction &MF) const;
99   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
100
101   // Debug information queries.
102   unsigned getRARegister() const;
103   unsigned getFrameRegister(MachineFunction &MF) const;
104   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
105
106   // Exception handling queries.
107   unsigned getEHExceptionRegister() const;
108   unsigned getEHHandlerRegister() const;
109 };
110
111 } // end namespace llvm
112
113 #endif