Use BranchProbability instead of floating points in IfConverter.
[llvm/stm8.git] / lib / Target / PTX / PTXInstrInfo.h
blob871f1ac8d376717b79d64f5c1caca52e27775e12
1 //===- PTXInstrInfo.h - PTX 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 PTX implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef PTX_INSTR_INFO_H
15 #define PTX_INSTR_INFO_H
17 #include "PTXRegisterInfo.h"
18 #include "llvm/Target/TargetInstrInfo.h"
20 #define GET_INSTRINFO_HEADER
21 #include "PTXGenInstrInfo.inc"
23 namespace llvm {
24 class PTXTargetMachine;
26 class MachineSDNode;
27 class SDValue;
28 class SelectionDAG;
30 class PTXInstrInfo : public PTXGenInstrInfo {
31 private:
32 const PTXRegisterInfo RI;
33 PTXTargetMachine &TM;
35 public:
36 explicit PTXInstrInfo(PTXTargetMachine &_TM);
38 virtual const PTXRegisterInfo &getRegisterInfo() const { return RI; }
40 virtual void copyPhysReg(MachineBasicBlock &MBB,
41 MachineBasicBlock::iterator I, DebugLoc DL,
42 unsigned DstReg, unsigned SrcReg,
43 bool KillSrc) const;
45 virtual bool copyRegToReg(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator I,
47 unsigned DstReg, unsigned SrcReg,
48 const TargetRegisterClass *DstRC,
49 const TargetRegisterClass *SrcRC,
50 DebugLoc DL) const;
52 virtual bool isMoveInstr(const MachineInstr& MI,
53 unsigned &SrcReg, unsigned &DstReg,
54 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
56 // predicate support
58 virtual bool isPredicated(const MachineInstr *MI) const;
60 virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
62 virtual
63 bool PredicateInstruction(MachineInstr *MI,
64 const SmallVectorImpl<MachineOperand> &Pred) const;
66 virtual
67 bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
68 const SmallVectorImpl<MachineOperand> &Pred2) const;
70 virtual bool DefinesPredicate(MachineInstr *MI,
71 std::vector<MachineOperand> &Pred) const;
73 // PTX is fully-predicable
74 virtual bool isPredicable(MachineInstr *MI) const { return true; }
76 // branch support
78 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
79 MachineBasicBlock *&FBB,
80 SmallVectorImpl<MachineOperand> &Cond,
81 bool AllowModify = false) const;
83 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
85 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
86 MachineBasicBlock *FBB,
87 const SmallVectorImpl<MachineOperand> &Cond,
88 DebugLoc DL) const;
90 // Memory operand folding for spills
91 // TODO: Implement this eventually and get rid of storeRegToStackSlot and
92 // loadRegFromStackSlot. Doing so will get rid of the "stack" registers
93 // we currently use to spill, though I doubt the overall effect on ptxas
94 // output will be large. I have yet to see a case where ptxas is unable
95 // to see through the "stack" register usage and hence generates
96 // efficient code anyway.
97 // virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
98 // MachineInstr* MI,
99 // const SmallVectorImpl<unsigned> &Ops,
100 // int FrameIndex) const;
102 virtual void storeRegToStackSlot(MachineBasicBlock& MBB,
103 MachineBasicBlock::iterator MII,
104 unsigned SrcReg, bool isKill, int FrameIndex,
105 const TargetRegisterClass* RC,
106 const TargetRegisterInfo* TRI) const;
107 virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
108 MachineBasicBlock::iterator MII,
109 unsigned DestReg, int FrameIdx,
110 const TargetRegisterClass *RC,
111 const TargetRegisterInfo *TRI) const;
113 // static helper routines
115 static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
116 DebugLoc dl, EVT VT,
117 SDValue Op1);
119 static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
120 DebugLoc dl, EVT VT,
121 SDValue Op1, SDValue Op2);
123 static void AddDefaultPredicate(MachineInstr *MI);
125 static bool IsAnyKindOfBranch(const MachineInstr& inst);
127 static bool IsAnySuccessorAlsoLayoutSuccessor(const MachineBasicBlock& MBB);
129 static MachineBasicBlock *GetBranchTarget(const MachineInstr& inst);
130 }; // class PTXInstrInfo
131 } // namespace llvm
133 #endif // PTX_INSTR_INFO_H