1
//===-- PTXInstrInfo.h - PTX Instruction Information ------------*- C++ -*-===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
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"
24
class PTXTargetMachine;
30
class PTXInstrInfo : public PTXGenInstrInfo {
32
const PTXRegisterInfo RI;
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,
45
virtual bool copyRegToReg(MachineBasicBlock &MBB,
46
MachineBasicBlock::iterator I,
47
unsigned DstReg, unsigned SrcReg,
48
const TargetRegisterClass *DstRC,
49
const TargetRegisterClass *SrcRC,
52
virtual bool isMoveInstr(const MachineInstr& MI,
53
unsigned &SrcReg, unsigned &DstReg,
54
unsigned &SrcSubIdx, unsigned &DstSubIdx) const;
58
virtual bool isPredicated(const MachineInstr *MI) const;
60
virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
63
bool PredicateInstruction(MachineInstr *MI,
64
const SmallVectorImpl<MachineOperand> &Pred) const;
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; }
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,
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,
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,
119
static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode,
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
133
#endif // PTX_INSTR_INFO_H