blob: a04be7728f88bca947ad9a16050a0cc4354e91d2 [file] [log] [blame]
Eric Christopher50880d02010-09-18 18:52:28 +00001//===- 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.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef PTX_INSTR_INFO_H
15#define PTX_INSTR_INFO_H
16
17#include "PTXRegisterInfo.h"
18#include "llvm/Target/TargetInstrInfo.h"
19
20namespace llvm {
21class PTXTargetMachine;
22
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000023class MachineSDNode;
24class SDValue;
25class SelectionDAG;
26
Eric Christopher50880d02010-09-18 18:52:28 +000027class PTXInstrInfo : public TargetInstrInfoImpl {
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000028private:
29 const PTXRegisterInfo RI;
30 PTXTargetMachine &TM;
Eric Christopher50880d02010-09-18 18:52:28 +000031
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000032public:
33 explicit PTXInstrInfo(PTXTargetMachine &_TM);
Eric Christopher50880d02010-09-18 18:52:28 +000034
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000035 virtual const PTXRegisterInfo &getRegisterInfo() const { return RI; }
Che-Liang Chioub48f2c22010-10-19 13:14:40 +000036
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000037 virtual void copyPhysReg(MachineBasicBlock &MBB,
38 MachineBasicBlock::iterator I, DebugLoc DL,
39 unsigned DstReg, unsigned SrcReg,
40 bool KillSrc) const;
Che-Liang Chioub48f2c22010-10-19 13:14:40 +000041
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000042 virtual bool copyRegToReg(MachineBasicBlock &MBB,
43 MachineBasicBlock::iterator I,
44 unsigned DstReg, unsigned SrcReg,
45 const TargetRegisterClass *DstRC,
46 const TargetRegisterClass *SrcRC,
47 DebugLoc DL) const;
Che-Liang Chioub48f2c22010-10-19 13:14:40 +000048
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000049 virtual bool isMoveInstr(const MachineInstr& MI,
50 unsigned &SrcReg, unsigned &DstReg,
51 unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
Che-Liang Chiou8e5d01c2011-02-10 12:01:24 +000052
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000053 // predicate support
Che-Liang Chiou8e5d01c2011-02-10 12:01:24 +000054
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000055 virtual bool isPredicated(const MachineInstr *MI) const;
Che-Liang Chiou8e5d01c2011-02-10 12:01:24 +000056
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000057 virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
Che-Liang Chiou8e5d01c2011-02-10 12:01:24 +000058
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000059 virtual
60 bool PredicateInstruction(MachineInstr *MI,
61 const SmallVectorImpl<MachineOperand> &Pred) const;
62
63 virtual
64 bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
65 const SmallVectorImpl<MachineOperand> &Pred2) const;
66
67 virtual bool DefinesPredicate(MachineInstr *MI,
68 std::vector<MachineOperand> &Pred) const;
69
70 // PTX is fully-predicable
71 virtual bool isPredicable(MachineInstr *MI) const { return true; }
72
Che-Liang Chiou5e0872e2011-03-22 14:12:00 +000073 // branch support
74
75 virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
76 MachineBasicBlock *&FBB,
77 SmallVectorImpl<MachineOperand> &Cond,
78 bool AllowModify = false) const;
79
80 virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
81
82 virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
83 MachineBasicBlock *FBB,
84 const SmallVectorImpl<MachineOperand> &Cond,
85 DebugLoc DL) const;
86
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +000087 // static helper routines
88
89 static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
90 DebugLoc dl, EVT VT,
91 SDValue Op1);
92
93 static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
94 DebugLoc dl, EVT VT,
95 SDValue Op1, SDValue Op2);
96
97 static void AddDefaultPredicate(MachineInstr *MI);
Che-Liang Chiou5e0872e2011-03-22 14:12:00 +000098
99 static bool IsAnyKindOfBranch(const MachineInstr& inst);
100
101 static bool IsAnySuccessorAlsoLayoutSuccessor(const MachineBasicBlock& MBB);
102
103 static MachineBasicBlock *GetBranchTarget(const MachineInstr& inst);
Che-Liang Chiouc2ec0f92011-03-13 17:26:00 +0000104}; // class PTXInstrInfo
Eric Christopher50880d02010-09-18 18:52:28 +0000105} // namespace llvm
106
107#endif // PTX_INSTR_INFO_H