Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 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. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PTX_INSTR_INFO_H |
| 15 | #define PTX_INSTR_INFO_H |
| 16 | |
| 17 | #include "PTXRegisterInfo.h" |
Che-Liang Chiou | 8e5d01c | 2011-02-10 12:01:24 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/SelectionDAG.h" |
| 19 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetInstrInfo.h" |
| 21 | |
| 22 | namespace llvm { |
| 23 | class PTXTargetMachine; |
| 24 | |
| 25 | class PTXInstrInfo : public TargetInstrInfoImpl { |
| 26 | private: |
| 27 | const PTXRegisterInfo RI; |
| 28 | PTXTargetMachine &TM; |
| 29 | |
| 30 | public: |
| 31 | explicit PTXInstrInfo(PTXTargetMachine &_TM); |
| 32 | |
| 33 | virtual const PTXRegisterInfo &getRegisterInfo() const { return RI; } |
Che-Liang Chiou | b48f2c2 | 2010-10-19 13:14:40 +0000 | [diff] [blame] | 34 | |
| 35 | virtual void copyPhysReg(MachineBasicBlock &MBB, |
| 36 | MachineBasicBlock::iterator I, DebugLoc DL, |
| 37 | unsigned DstReg, unsigned SrcReg, |
| 38 | bool KillSrc) const; |
| 39 | |
| 40 | virtual bool copyRegToReg(MachineBasicBlock &MBB, |
| 41 | MachineBasicBlock::iterator I, |
| 42 | unsigned DstReg, unsigned SrcReg, |
| 43 | const TargetRegisterClass *DstRC, |
| 44 | const TargetRegisterClass *SrcRC, |
| 45 | DebugLoc DL) const; |
| 46 | |
| 47 | virtual bool isMoveInstr(const MachineInstr& MI, |
| 48 | unsigned &SrcReg, unsigned &DstReg, |
| 49 | unsigned &SrcSubIdx, unsigned &DstSubIdx) const; |
Che-Liang Chiou | 8e5d01c | 2011-02-10 12:01:24 +0000 | [diff] [blame] | 50 | |
| 51 | // static helper routines |
| 52 | |
| 53 | static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode, |
| 54 | DebugLoc dl, EVT VT, |
| 55 | SDValue Op1) { |
| 56 | SDValue pred_reg = DAG->getRegister(0, MVT::i1); |
| 57 | SDValue pred_imm = DAG->getTargetConstant(0, MVT::i32); |
| 58 | SDValue ops[] = { Op1, pred_reg, pred_imm }; |
| 59 | return DAG->getMachineNode(Opcode, dl, VT, ops, array_lengthof(ops)); |
| 60 | } |
| 61 | |
| 62 | static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode, |
| 63 | DebugLoc dl, EVT VT, |
| 64 | SDValue Op1, |
| 65 | SDValue Op2) { |
| 66 | SDValue pred_reg = DAG->getRegister(0, MVT::i1); |
| 67 | SDValue pred_imm = DAG->getTargetConstant(0, MVT::i32); |
| 68 | SDValue ops[] = { Op1, Op2, pred_reg, pred_imm }; |
| 69 | return DAG->getMachineNode(Opcode, dl, VT, ops, array_lengthof(ops)); |
| 70 | } |
| 71 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 72 | }; // class PTXInstrInfo |
| 73 | } // namespace llvm |
| 74 | |
| 75 | #endif // PTX_INSTR_INFO_H |