This is a general clean up of the PowerPC ABI. Address several problems and
[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 Type;
24
25 class PPCRegisterInfo : public PPCGenRegisterInfo {
26   std::map<unsigned, unsigned> ImmToIdxMap;
27   const PPCSubtarget &Subtarget;
28   const TargetInstrInfo &TII;
29 public:
30   PPCRegisterInfo(const PPCSubtarget &SubTarget, const TargetInstrInfo &tii);
31   
32   /// getRegisterNumbering - Given the enum value for some register, e.g.
33   /// PPC::F14, return the number that it corresponds to (e.g. 14).
34   static unsigned getRegisterNumbering(unsigned RegEnum);
35
36   /// Code Generation virtual methods...
37   void storeRegToStackSlot(MachineBasicBlock &MBB,
38                            MachineBasicBlock::iterator MBBI,
39                            unsigned SrcReg, int FrameIndex,
40                            const TargetRegisterClass *RC) const;
41
42   void loadRegFromStackSlot(MachineBasicBlock &MBB,
43                             MachineBasicBlock::iterator MBBI,
44                             unsigned DestReg, int FrameIndex,
45                             const TargetRegisterClass *RC) const;
46
47   void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
48                     unsigned DestReg, unsigned SrcReg,
49                     const TargetRegisterClass *RC) const;
50
51   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
52   /// copy instructions, turning them into load/store instructions.
53   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
54                                           int FrameIndex) const;
55   
56   const unsigned *getCalleeSaveRegs() const;
57
58   const TargetRegisterClass* const* getCalleeSaveRegClasses() const;
59
60   void eliminateCallFramePseudoInstr(MachineFunction &MF,
61                                      MachineBasicBlock &MBB,
62                                      MachineBasicBlock::iterator I) const;
63
64   void lowerDynamicAlloc(MachineBasicBlock::iterator II) const;
65   void eliminateFrameIndex(MachineBasicBlock::iterator II) const;
66
67   /// determineFrameLayout - Determine the size of the frame and maximum call
68   /// frame size.
69   void determineFrameLayout(MachineFunction &MF) const;
70
71   void emitPrologue(MachineFunction &MF) const;
72   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
73
74   // Debug information queries.
75   unsigned getRARegister() const;
76   unsigned getFrameRegister(MachineFunction &MF) const;
77   void getInitialFrameState(std::vector<MachineMove *> &Moves) const;
78 };
79
80 } // end namespace llvm
81
82 #endif