Move some more instruction creation methods from RegisterInfo into InstrInfo.
[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 is distributed under the University of Illinois Open Source
6 // 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 reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
39                      unsigned DestReg, const MachineInstr *Orig) const;
40
41   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
42   /// copy instructions, turning them into load/store instructions.
43   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
44                                           SmallVectorImpl<unsigned> &Ops,
45                                           int FrameIndex) const;
46
47   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI,
48                                           SmallVectorImpl<unsigned> &Ops,
49                                           MachineInstr* LoadMI) const {
50     return 0;
51   }
52
53   virtual bool canFoldMemoryOperand(MachineInstr *MI,
54                                     SmallVectorImpl<unsigned> &Ops) const;
55
56   const unsigned *getCalleeSavedRegs(const MachineFunction* MF = 0) const;
57
58   const TargetRegisterClass* const*
59   getCalleeSavedRegClasses(const MachineFunction *MF = 0) const;
60
61   BitVector getReservedRegs(const MachineFunction &MF) const;
62
63   /// targetHandlesStackFrameRounding - Returns true if the target is
64   /// responsible for rounding up the stack frame (probably at emitPrologue
65   /// time).
66   bool targetHandlesStackFrameRounding() const { return true; }
67
68   bool hasFP(const MachineFunction &MF) const;
69
70   void eliminateCallFramePseudoInstr(MachineFunction &MF,
71                                      MachineBasicBlock &MBB,
72                                      MachineBasicBlock::iterator I) const;
73
74   void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
75   void eliminateFrameIndex(MachineBasicBlock::iterator II,
76                            int SPAdj, RegScavenger *RS = NULL) const;
77
78   /// determineFrameLayout - Determine the size of the frame and maximum call
79   /// frame size.
80   void determineFrameLayout(MachineFunction &MF) const;
81
82   void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
83                                             RegScavenger *RS = NULL) const;
84   void emitPrologue(MachineFunction &MF) const;
85   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
86
87   // Debug information queries.
88   unsigned getRARegister() const;
89   unsigned getFrameRegister(MachineFunction &MF) const;
90   void getInitialFrameState(std::vector<MachineMove> &Moves) const;
91
92   // Exception handling queries.
93   unsigned getEHExceptionRegister() const;
94   unsigned getEHHandlerRegister() const;
95
96   int getDwarfRegNum(unsigned RegNum, bool isEH) const;
97 };
98
99 } // end namespace llvm
100
101 #endif