4b5d0eb18424fede62c1809164668881748d2400
[oota-llvm.git] / lib / Target / Sparc / SparcInstrInfo.h
1 //===- SparcInstrInfo.h - Sparc 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 Sparc implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SPARCINSTRUCTIONINFO_H
15 #define SPARCINSTRUCTIONINFO_H
16
17 #include "llvm/Target/TargetInstrInfo.h"
18 #include "SparcRegisterInfo.h"
19
20 #define GET_INSTRINFO_HEADER
21 #include "SparcGenInstrInfo.inc"
22
23 namespace llvm {
24
25 /// SPII - This namespace holds all of the target specific flags that
26 /// instruction info tracks.
27 ///
28 namespace SPII {
29   enum {
30     Pseudo = (1<<0),
31     Load = (1<<1),
32     Store = (1<<2),
33     DelaySlot = (1<<3)
34   };
35 }
36
37 class SparcInstrInfo : public SparcGenInstrInfo {
38   const SparcRegisterInfo RI;
39   const SparcSubtarget& Subtarget;
40 public:
41   explicit SparcInstrInfo(SparcSubtarget &ST);
42
43   /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info.  As
44   /// such, whenever a client has an instance of instruction info, it should
45   /// always be able to get register info as well (through this method).
46   ///
47   virtual const SparcRegisterInfo &getRegisterInfo() const { return RI; }
48
49   /// isLoadFromStackSlot - If the specified machine instruction is a direct
50   /// load from a stack slot, return the virtual or physical register number of
51   /// the destination along with the FrameIndex of the loaded stack slot.  If
52   /// not, return 0.  This predicate must return 0 if the instruction has
53   /// any side effects other than loading from the stack slot.
54   virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
55                                        int &FrameIndex) const;
56   
57   /// isStoreToStackSlot - If the specified machine instruction is a direct
58   /// store to a stack slot, return the virtual or physical register number of
59   /// the source reg along with the FrameIndex of the loaded stack slot.  If
60   /// not, return 0.  This predicate must return 0 if the instruction has
61   /// any side effects other than storing to the stack slot.
62   virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
63                                       int &FrameIndex) const;
64
65   /// emitFrameIndexDebugValue - Emit a target-dependent form of
66   /// DBG_VALUE encoding the address of a frame index.
67   virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
68                                                  int FrameIx,
69                                                  uint64_t Offset,
70                                                  const MDNode *MDPtr,
71                                                  DebugLoc dl) const;
72
73   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
74                              MachineBasicBlock *&FBB,
75                              SmallVectorImpl<MachineOperand> &Cond,
76                              bool AllowModify = false) const ;
77
78   virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
79
80   virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
81                                 MachineBasicBlock *FBB,
82                                 const SmallVectorImpl<MachineOperand> &Cond,
83                                 DebugLoc DL) const;
84
85   virtual void copyPhysReg(MachineBasicBlock &MBB,
86                            MachineBasicBlock::iterator I, DebugLoc DL,
87                            unsigned DestReg, unsigned SrcReg,
88                            bool KillSrc) const;
89   
90   virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
91                                    MachineBasicBlock::iterator MBBI,
92                                    unsigned SrcReg, bool isKill, int FrameIndex,
93                                    const TargetRegisterClass *RC,
94                                    const TargetRegisterInfo *TRI) const;
95
96   virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
97                                     MachineBasicBlock::iterator MBBI,
98                                     unsigned DestReg, int FrameIndex,
99                                     const TargetRegisterClass *RC,
100                                     const TargetRegisterInfo *TRI) const;
101   
102   unsigned getGlobalBaseReg(MachineFunction *MF) const;
103 };
104
105 }
106
107 #endif