191e55d0ca612fd367543d6e0190cf3664a01b7a
[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     unsigned isLoadFromStackSlot(const MachineInstr *MI,
36                                  int &FrameIndex) const;
37     unsigned isStoreToStackSlot(const MachineInstr *MI,
38                                 int &FrameIndex) const;
39
40     virtual void copyPhysReg(MachineBasicBlock &MBB,
41                              MachineBasicBlock::iterator I, DebugLoc DL,
42                              unsigned DestReg, unsigned SrcReg,
43                              bool KillSrc) const;
44
45     //! Store a register to a stack slot, based on its register class.
46     virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
47                                      MachineBasicBlock::iterator MBBI,
48                                      unsigned SrcReg, bool isKill, int FrameIndex,
49                                      const TargetRegisterClass *RC,
50                                      const TargetRegisterInfo *TRI) const;
51
52     //! Load a register from a stack slot, based on its register class.
53     virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
54                                       MachineBasicBlock::iterator MBBI,
55                                       unsigned DestReg, int FrameIndex,
56                                       const TargetRegisterClass *RC,
57                                       const TargetRegisterInfo *TRI) const;
58
59     //! Reverses a branch's condition, returning false on success.
60     virtual
61     bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const;
62
63     virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
64                                MachineBasicBlock *&FBB,
65                                SmallVectorImpl<MachineOperand> &Cond,
66                                bool AllowModify) const;
67
68     virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
69
70     virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
71                                   MachineBasicBlock *FBB,
72                                   const SmallVectorImpl<MachineOperand> &Cond,
73                                   DebugLoc DL) const;
74    };
75 }
76
77 #endif