blob: e7f00f09c2f135195aa18d8923dfd51338cfb3e7 [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"
Che-Liang Chiou8e5d01c2011-02-10 12:01:24 +000018#include "llvm/CodeGen/SelectionDAG.h"
19#include "llvm/CodeGen/SelectionDAGNodes.h"
Eric Christopher50880d02010-09-18 18:52:28 +000020#include "llvm/Target/TargetInstrInfo.h"
21
22namespace llvm {
23class PTXTargetMachine;
24
25class 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 Chioub48f2c22010-10-19 13:14:40 +000034
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 Chiou8e5d01c2011-02-10 12:01:24 +000050
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 Christopher50880d02010-09-18 18:52:28 +000072 }; // class PTXInstrInfo
73} // namespace llvm
74
75#endif // PTX_INSTR_INFO_H