1 //===-- R600InstrInfo.h - R600 Instruction Info Interface -------*- 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 // Interface definition for R600InstrInfo
12 //===----------------------------------------------------------------------===//
14 #ifndef R600INSTRUCTIONINFO_H_
15 #define R600INSTRUCTIONINFO_H_
18 #include "AMDGPUInstrInfo.h"
19 #include "R600RegisterInfo.h"
25 class AMDGPUTargetMachine
;
28 class MachineFunction
;
30 class MachineInstrBuilder
;
32 class R600InstrInfo
: public AMDGPUInstrInfo
{
34 const R600RegisterInfo RI
;
35 AMDGPUTargetMachine
&TM
;
37 int getBranchInstr(const MachineOperand
&op
) const;
40 explicit R600InstrInfo(AMDGPUTargetMachine
&tm
);
42 const R600RegisterInfo
&getRegisterInfo() const;
43 virtual void copyPhysReg(MachineBasicBlock
&MBB
,
44 MachineBasicBlock::iterator MI
, DebugLoc DL
,
45 unsigned DestReg
, unsigned SrcReg
,
48 bool isTrig(const MachineInstr
&MI
) const;
49 bool isPlaceHolderOpcode(unsigned opcode
) const;
50 bool isReductionOp(unsigned opcode
) const;
51 bool isCubeOp(unsigned opcode
) const;
53 /// isVector - Vector instructions are instructions that must fill all
54 /// instruction slots within an instruction group.
55 bool isVector(const MachineInstr
&MI
) const;
57 virtual MachineInstr
* getMovImmInstr(MachineFunction
*MF
, unsigned DstReg
,
60 virtual unsigned getIEQOpcode() const;
61 virtual bool isMov(unsigned Opcode
) const;
63 DFAPacketizer
*CreateTargetScheduleState(const TargetMachine
*TM
,
64 const ScheduleDAG
*DAG
) const;
66 bool ReverseBranchCondition(SmallVectorImpl
<MachineOperand
> &Cond
) const;
68 bool AnalyzeBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*&TBB
, MachineBasicBlock
*&FBB
,
69 SmallVectorImpl
<MachineOperand
> &Cond
, bool AllowModify
) const;
71 unsigned InsertBranch(MachineBasicBlock
&MBB
, MachineBasicBlock
*TBB
, MachineBasicBlock
*FBB
, const SmallVectorImpl
<MachineOperand
> &Cond
, DebugLoc DL
) const;
73 unsigned RemoveBranch(MachineBasicBlock
&MBB
) const;
75 bool isPredicated(const MachineInstr
*MI
) const;
77 bool isPredicable(MachineInstr
*MI
) const;
80 isProfitableToDupForIfCvt(MachineBasicBlock
&MBB
, unsigned NumCyles
,
81 const BranchProbability
&Probability
) const;
83 bool isProfitableToIfCvt(MachineBasicBlock
&MBB
, unsigned NumCyles
,
84 unsigned ExtraPredCycles
,
85 const BranchProbability
&Probability
) const ;
88 isProfitableToIfCvt(MachineBasicBlock
&TMBB
,
89 unsigned NumTCycles
, unsigned ExtraTCycles
,
90 MachineBasicBlock
&FMBB
,
91 unsigned NumFCycles
, unsigned ExtraFCycles
,
92 const BranchProbability
&Probability
) const;
94 bool DefinesPredicate(MachineInstr
*MI
,
95 std::vector
<MachineOperand
> &Pred
) const;
97 bool SubsumesPredicate(const SmallVectorImpl
<MachineOperand
> &Pred1
,
98 const SmallVectorImpl
<MachineOperand
> &Pred2
) const;
100 bool isProfitableToUnpredicate(MachineBasicBlock
&TMBB
,
101 MachineBasicBlock
&FMBB
) const;
103 bool PredicateInstruction(MachineInstr
*MI
,
104 const SmallVectorImpl
<MachineOperand
> &Pred
) const;
106 int getInstrLatency(const InstrItineraryData
*ItinData
,
107 const MachineInstr
*MI
,
108 unsigned *PredCost
= 0) const;
110 virtual int getInstrLatency(const InstrItineraryData
*ItinData
,
111 SDNode
*Node
) const { return 1;}
113 ///hasFlagOperand - Returns true if this instruction has an operand for
114 /// storing target flags.
115 bool hasFlagOperand(const MachineInstr
&MI
) const;
117 ///addFlag - Add one of the MO_FLAG* flags to the specified Operand.
118 void addFlag(MachineInstr
*MI
, unsigned Operand
, unsigned Flag
) const;
120 ///isFlagSet - Determine if the specified flag is set on this Operand.
121 bool isFlagSet(const MachineInstr
&MI
, unsigned Operand
, unsigned Flag
) const;
123 ///getFlagOp - Return the operand containing the flags for this instruction.
124 MachineOperand
&getFlagOp(MachineInstr
*MI
) const;
126 ///clearFlag - Clear the specified flag on the instruction.
127 void clearFlag(MachineInstr
*MI
, unsigned Operand
, unsigned Flag
) const;
130 } // End llvm namespace
132 #endif // R600INSTRINFO_H_