1 //===-- SIInstrInfo.h - SI 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 //===----------------------------------------------------------------------===//
11 /// \brief Interface definition for SIInstrInfo.
13 //===----------------------------------------------------------------------===//
19 #include "AMDGPUInstrInfo.h"
20 #include "SIRegisterInfo.h"
24 class SIInstrInfo : public AMDGPUInstrInfo {
26 const SIRegisterInfo RI;
28 unsigned buildExtractSubReg(MachineBasicBlock::iterator MI,
29 MachineRegisterInfo &MRI,
30 MachineOperand &SuperReg,
31 const TargetRegisterClass *SuperRC,
33 const TargetRegisterClass *SubRC) const;
35 unsigned split64BitImm(SmallVectorImpl<MachineInstr *> &Worklist,
36 MachineBasicBlock::iterator MI,
37 MachineRegisterInfo &MRI,
38 const TargetRegisterClass *RC,
39 const MachineOperand &Op) const;
41 void splitScalar64BitOp(SmallVectorImpl<MachineInstr *> &Worklist,
42 MachineInstr *Inst, unsigned Opcode) const;
46 explicit SIInstrInfo(AMDGPUTargetMachine &tm);
48 const SIRegisterInfo &getRegisterInfo() const {
52 virtual void copyPhysReg(MachineBasicBlock &MBB,
53 MachineBasicBlock::iterator MI, DebugLoc DL,
54 unsigned DestReg, unsigned SrcReg,
57 void storeRegToStackSlot(MachineBasicBlock &MBB,
58 MachineBasicBlock::iterator MI,
59 unsigned SrcReg, bool isKill, int FrameIndex,
60 const TargetRegisterClass *RC,
61 const TargetRegisterInfo *TRI) const;
63 void loadRegFromStackSlot(MachineBasicBlock &MBB,
64 MachineBasicBlock::iterator MI,
65 unsigned DestReg, int FrameIndex,
66 const TargetRegisterClass *RC,
67 const TargetRegisterInfo *TRI) const;
69 unsigned commuteOpcode(unsigned Opcode) const;
71 virtual MachineInstr *commuteInstruction(MachineInstr *MI,
72 bool NewMI=false) const;
74 virtual unsigned getIEQOpcode() const {
75 llvm_unreachable("Unimplemented");
78 MachineInstr *buildMovInstr(MachineBasicBlock *MBB,
79 MachineBasicBlock::iterator I,
80 unsigned DstReg, unsigned SrcReg) const;
81 virtual bool isMov(unsigned Opcode) const;
83 virtual bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const;
84 bool isDS(uint16_t Opcode) const;
85 int isMIMG(uint16_t Opcode) const;
86 int isSMRD(uint16_t Opcode) const;
87 bool isVOP1(uint16_t Opcode) const;
88 bool isVOP2(uint16_t Opcode) const;
89 bool isVOP3(uint16_t Opcode) const;
90 bool isVOPC(uint16_t Opcode) const;
91 bool isInlineConstant(const MachineOperand &MO) const;
92 bool isLiteralConstant(const MachineOperand &MO) const;
94 virtual bool verifyInstruction(const MachineInstr *MI,
95 StringRef &ErrInfo) const;
97 bool isSALUInstr(const MachineInstr &MI) const;
98 static unsigned getVALUOp(const MachineInstr &MI);
100 bool isSALUOpSupportedOnVALU(const MachineInstr &MI) const;
102 /// \brief Return the correct register class for \p OpNo. For target-specific
103 /// instructions, this will return the register class that has been defined
104 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
105 /// the register class of its machine operand.
106 /// to infer the correct register class base on the other operands.
107 const TargetRegisterClass *getOpRegClass(const MachineInstr &MI,
108 unsigned OpNo) const;\
110 /// \returns true if it is legal for the operand at index \p OpNo
112 bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const;
114 /// \brief Legalize the \p OpIndex operand of this instruction by inserting
115 /// a MOV. For example:
116 /// ADD_I32_e32 VGPR0, 15
119 /// ADD_I32_e32 VGPR0, VGPR1
121 /// If the operand being legalized is a register, then a COPY will be used
123 void legalizeOpWithMove(MachineInstr *MI, unsigned OpIdx) const;
125 /// \brief Legalize all operands in this instruction. This function may
126 /// create new instruction and insert them before \p MI.
127 void legalizeOperands(MachineInstr *MI) const;
129 /// \brief Replace this instruction's opcode with the equivalent VALU
130 /// opcode. This function will also move the users of \p MI to the
131 /// VALU if necessary.
132 void moveToVALU(MachineInstr &MI) const;
134 virtual unsigned calculateIndirectAddress(unsigned RegIndex,
135 unsigned Channel) const;
137 virtual const TargetRegisterClass *getIndirectAddrRegClass() const;
139 virtual MachineInstrBuilder buildIndirectWrite(MachineBasicBlock *MBB,
140 MachineBasicBlock::iterator I,
143 unsigned OffsetReg) const;
145 virtual MachineInstrBuilder buildIndirectRead(MachineBasicBlock *MBB,
146 MachineBasicBlock::iterator I,
149 unsigned OffsetReg) const;
150 void reserveIndirectRegisters(BitVector &Reserved,
151 const MachineFunction &MF) const;
153 void LoadM0(MachineInstr *MoveRel, MachineBasicBlock::iterator I,
154 unsigned SavReg, unsigned IndexReg) const;
159 int getVOPe64(uint16_t Opcode);
160 int getCommuteRev(uint16_t Opcode);
161 int getCommuteOrig(uint16_t Opcode);
163 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
166 } // End namespace AMDGPU
168 } // End namespace llvm
170 namespace SIInstrFlags {
172 // First 4 bits are the instruction encoding
179 #endif //SIINSTRINFO_H