CellSPU:
[oota-llvm.git] / lib / Target / CellSPU / SPUInstrInfo.h
1 //===- SPUInstrInfo.h - Cell SPU Instruction Information --------*- 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 CellSPU implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SPU_INSTRUCTIONINFO_H
15 #define SPU_INSTRUCTIONINFO_H
16
17 #include "SPU.h"
18 #include "llvm/Target/TargetInstrInfo.h"
19 #include "SPURegisterInfo.h"
20
21 namespace llvm {
22   //! Cell SPU instruction information class
23   class SPUInstrInfo : public TargetInstrInfoImpl {
24     SPUTargetMachine &TM;
25     const SPURegisterInfo RI;
26   public:
27     explicit SPUInstrInfo(SPUTargetMachine &tm);
28
29     /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
30     /// such, whenever a client has an instance of instruction info, it should
31     /// always be able to get register info as well (through this method).
32     ///
33     virtual const SPURegisterInfo &getRegisterInfo() const { return RI; }
34
35     /// getPointerRegClass - Return the register class to use to hold pointers.
36     /// This is used for addressing modes.
37     virtual const TargetRegisterClass *getPointerRegClass() const;  
38
39     // Return true if the instruction is a register to register move and
40     // leave the source and dest operands in the passed parameters.
41     //
42     virtual bool isMoveInstr(const MachineInstr& MI,
43                              unsigned& sourceReg,
44                              unsigned& destReg) const;
45
46     unsigned isLoadFromStackSlot(const MachineInstr *MI,
47                                  int &FrameIndex) const;
48     unsigned isStoreToStackSlot(const MachineInstr *MI,
49                                 int &FrameIndex) const;
50     
51     virtual bool copyRegToReg(MachineBasicBlock &MBB,
52                               MachineBasicBlock::iterator MI,
53                               unsigned DestReg, unsigned SrcReg,
54                               const TargetRegisterClass *DestRC,
55                               const TargetRegisterClass *SrcRC) const;
56     
57     //! Store a register to a stack slot, based on its register class.
58     virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
59                                      MachineBasicBlock::iterator MBBI,
60                                      unsigned SrcReg, bool isKill, int FrameIndex,
61                                      const TargetRegisterClass *RC) const;
62
63     //! Store a register to an address, based on its register class
64     virtual void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
65                                                   SmallVectorImpl<MachineOperand> &Addr,
66                                                   const TargetRegisterClass *RC,
67                                                   SmallVectorImpl<MachineInstr*> &NewMIs) const;
68
69     //! Load a register from a stack slot, based on its register class.
70     virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
71                                       MachineBasicBlock::iterator MBBI,
72                                       unsigned DestReg, int FrameIndex,
73                                       const TargetRegisterClass *RC) const;
74
75     //! Loqad a register from an address, based on its register class
76     virtual void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
77                                                          SmallVectorImpl<MachineOperand> &Addr,
78                                                          const TargetRegisterClass *RC,
79                                  SmallVectorImpl<MachineInstr*> &NewMIs) const;
80     
81     //! Fold spills into load/store instructions
82     virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
83                                                 MachineInstr* MI,
84                                                 const SmallVectorImpl<unsigned> &Ops,
85                                                 int FrameIndex) const;
86
87     //! Fold any load/store to an operand
88     virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
89                                                 MachineInstr* MI,
90                                                 const SmallVectorImpl<unsigned> &Ops,
91                                                 MachineInstr* LoadMI) const {
92       return 0;
93     }
94   };
95 }
96
97 #endif