Add a comment.
[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 public:
29   PPCRegisterInfo(const PPCSubtarget &SubTarget);
30   
31   /// getRegisterNumbering - Given the enum value for some register, e.g.
32   /// PPC::F14, return the number that it corresponds to (e.g. 14).
33   static unsigned getRegisterNumbering(unsigned RegEnum);
34
35   /// Code Generation virtual methods...
36   void storeRegToStackSlot(MachineBasicBlock &MBB,
37                            MachineBasicBlock::iterator MBBI,
38                            unsigned SrcReg, int FrameIndex,
39                            const TargetRegisterClass *RC) const;
40
41   void loadRegFromStackSlot(MachineBasicBlock &MBB,
42                             MachineBasicBlock::iterator MBBI,
43                             unsigned DestReg, int FrameIndex,
44                             const TargetRegisterClass *RC) const;
45
46   void copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
47                     unsigned DestReg, unsigned SrcReg,
48                     const TargetRegisterClass *RC) const;
49
50   /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
51   /// copy instructions, turning them into load/store instructions.
52   virtual MachineInstr* foldMemoryOperand(MachineInstr* MI, unsigned OpNum,
53                                           int FrameIndex) const;
54   
55   const unsigned *getCalleeSaveRegs() const;
56
57   const TargetRegisterClass* const* getCalleeSaveRegClasses() const;
58
59   void eliminateCallFramePseudoInstr(MachineFunction &MF,
60                                      MachineBasicBlock &MBB,
61                                      MachineBasicBlock::iterator I) const;
62
63   void eliminateFrameIndex(MachineBasicBlock::iterator II) const;
64
65   void emitPrologue(MachineFunction &MF) const;
66   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
67
68   // Debug information queries.
69   unsigned getRARegister() const;
70   unsigned getFrameRegister(MachineFunction &MF) const;
71   void getInitialFrameState(std::vector<MachineMove *> &Moves) const;
72 };
73
74 } // end namespace llvm
75
76 #endif