Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1 | //===-- R600InstrInfo.h - R600 Instruction Info Interface -------*- 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 | /// \file |
| 11 | /// \brief Interface definition for R600InstrInfo |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Matt Arsenault | 6b6a2c3 | 2016-03-11 08:00:27 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_TARGET_AMDGPU_R600INSTRINFO_H |
| 16 | #define LLVM_LIB_TARGET_AMDGPU_R600INSTRINFO_H |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 17 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 18 | #include "AMDGPUInstrInfo.h" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 19 | #include "R600RegisterInfo.h" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 22 | class AMDGPUTargetMachine; |
| 23 | class DFAPacketizer; |
| 24 | class MachineFunction; |
| 25 | class MachineInstr; |
| 26 | class MachineInstrBuilder; |
| 27 | class R600Subtarget; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 28 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 29 | class R600InstrInfo final : public AMDGPUInstrInfo { |
| 30 | private: |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 31 | const R600RegisterInfo RI; |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 32 | const R600Subtarget &ST; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 33 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 34 | std::vector<std::pair<int, unsigned>> |
| 35 | ExtractSrcs(MachineInstr *MI, |
| 36 | const DenseMap<unsigned, unsigned> &PV, |
| 37 | unsigned &ConstCount) const; |
Tom Stellard | 880a80a | 2014-06-17 16:53:14 +0000 | [diff] [blame] | 38 | |
| 39 | MachineInstrBuilder buildIndirectRead(MachineBasicBlock *MBB, |
| 40 | MachineBasicBlock::iterator I, |
| 41 | unsigned ValueReg, unsigned Address, |
| 42 | unsigned OffsetReg, |
| 43 | unsigned AddrChan) const; |
| 44 | |
| 45 | MachineInstrBuilder buildIndirectWrite(MachineBasicBlock *MBB, |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 46 | MachineBasicBlock::iterator I, |
| 47 | unsigned ValueReg, unsigned Address, |
| 48 | unsigned OffsetReg, |
| 49 | unsigned AddrChan) const; |
| 50 | public: |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 51 | enum BankSwizzle { |
Vincent Lejeune | bb8a8721 | 2013-06-29 19:32:29 +0000 | [diff] [blame] | 52 | ALU_VEC_012_SCL_210 = 0, |
| 53 | ALU_VEC_021_SCL_122, |
| 54 | ALU_VEC_120_SCL_212, |
| 55 | ALU_VEC_102_SCL_221, |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 56 | ALU_VEC_201, |
| 57 | ALU_VEC_210 |
| 58 | }; |
| 59 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 60 | explicit R600InstrInfo(const R600Subtarget &); |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 61 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 62 | const R600RegisterInfo &getRegisterInfo() const { |
| 63 | return RI; |
| 64 | } |
| 65 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 66 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
| 67 | const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 68 | bool KillSrc) const override; |
Tom Stellard | cd6b0a6 | 2013-11-22 00:41:08 +0000 | [diff] [blame] | 69 | bool isLegalToSplitMBBAt(MachineBasicBlock &MBB, |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 70 | MachineBasicBlock::iterator MBBI) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 71 | |
| 72 | bool isTrig(const MachineInstr &MI) const; |
| 73 | bool isPlaceHolderOpcode(unsigned opcode) const; |
| 74 | bool isReductionOp(unsigned opcode) const; |
| 75 | bool isCubeOp(unsigned opcode) const; |
| 76 | |
| 77 | /// \returns true if this \p Opcode represents an ALU instruction. |
| 78 | bool isALUInstr(unsigned Opcode) const; |
Tom Stellard | c026e8b | 2013-06-28 15:47:08 +0000 | [diff] [blame] | 79 | bool hasInstrModifiers(unsigned Opcode) const; |
| 80 | bool isLDSInstr(unsigned Opcode) const; |
Tom Stellard | 8f9fc20 | 2013-11-15 00:12:45 +0000 | [diff] [blame] | 81 | bool isLDSNoRetInstr(unsigned Opcode) const; |
| 82 | bool isLDSRetInstr(unsigned Opcode) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 83 | |
Vincent Lejeune | a4da6fb | 2013-10-01 19:32:58 +0000 | [diff] [blame] | 84 | /// \returns true if this \p Opcode represents an ALU instruction or an |
| 85 | /// instruction that will be lowered in ExpandSpecialInstrs Pass. |
| 86 | bool canBeConsideredALU(const MachineInstr *MI) const; |
| 87 | |
Vincent Lejeune | 076c0b2 | 2013-04-30 00:14:17 +0000 | [diff] [blame] | 88 | bool isTransOnly(unsigned Opcode) const; |
| 89 | bool isTransOnly(const MachineInstr *MI) const; |
Vincent Lejeune | 4d5c5e5 | 2013-09-04 19:53:30 +0000 | [diff] [blame] | 90 | bool isVectorOnly(unsigned Opcode) const; |
| 91 | bool isVectorOnly(const MachineInstr *MI) const; |
Tom Stellard | 676c16d | 2013-08-16 01:11:51 +0000 | [diff] [blame] | 92 | bool isExport(unsigned Opcode) const; |
Vincent Lejeune | 076c0b2 | 2013-04-30 00:14:17 +0000 | [diff] [blame] | 93 | |
Vincent Lejeune | c299164 | 2013-04-30 00:13:39 +0000 | [diff] [blame] | 94 | bool usesVertexCache(unsigned Opcode) const; |
| 95 | bool usesVertexCache(const MachineInstr *MI) const; |
| 96 | bool usesTextureCache(unsigned Opcode) const; |
| 97 | bool usesTextureCache(const MachineInstr *MI) const; |
| 98 | |
Tom Stellard | ce54033 | 2013-06-28 15:46:59 +0000 | [diff] [blame] | 99 | bool mustBeLastInClause(unsigned Opcode) const; |
Tom Stellard | 26a3b67 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 100 | bool usesAddressRegister(MachineInstr *MI) const; |
| 101 | bool definesAddressRegister(MachineInstr *MI) const; |
Tom Stellard | 7f6fa4c | 2013-09-12 02:55:06 +0000 | [diff] [blame] | 102 | bool readsLDSSrcReg(const MachineInstr *MI) const; |
Tom Stellard | ce54033 | 2013-06-28 15:46:59 +0000 | [diff] [blame] | 103 | |
Tom Stellard | 8402144 | 2013-07-23 01:48:24 +0000 | [diff] [blame] | 104 | /// \returns The operand index for the given source number. Legal values |
| 105 | /// for SrcNum are 0, 1, and 2. |
| 106 | int getSrcIdx(unsigned Opcode, unsigned SrcNum) const; |
| 107 | /// \returns The operand Index for the Sel operand given an index to one |
| 108 | /// of the instruction's src operands. |
| 109 | int getSelIdx(unsigned Opcode, unsigned SrcIdx) const; |
| 110 | |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 111 | /// \returns a pair for each src of an ALU instructions. |
| 112 | /// The first member of a pair is the register id. |
| 113 | /// If register is ALU_CONST, second member is SEL. |
| 114 | /// If register is ALU_LITERAL, second member is IMM. |
| 115 | /// Otherwise, second member value is undefined. |
| 116 | SmallVector<std::pair<MachineOperand *, int64_t>, 3> |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 117 | getSrcs(MachineInstr *MI) const; |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 118 | |
Vincent Lejeune | 77a8352 | 2013-06-29 19:32:43 +0000 | [diff] [blame] | 119 | unsigned isLegalUpTo( |
| 120 | const std::vector<std::vector<std::pair<int, unsigned> > > &IGSrcs, |
| 121 | const std::vector<R600InstrInfo::BankSwizzle> &Swz, |
| 122 | const std::vector<std::pair<int, unsigned> > &TransSrcs, |
| 123 | R600InstrInfo::BankSwizzle TransSwz) const; |
| 124 | |
| 125 | bool FindSwizzleForVectorSlot( |
| 126 | const std::vector<std::vector<std::pair<int, unsigned> > > &IGSrcs, |
| 127 | std::vector<R600InstrInfo::BankSwizzle> &SwzCandidate, |
| 128 | const std::vector<std::pair<int, unsigned> > &TransSrcs, |
| 129 | R600InstrInfo::BankSwizzle TransSwz) const; |
Tom Stellard | c026e8b | 2013-06-28 15:47:08 +0000 | [diff] [blame] | 130 | |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 131 | /// Given the order VEC_012 < VEC_021 < VEC_120 < VEC_102 < VEC_201 < VEC_210 |
| 132 | /// returns true and the first (in lexical order) BankSwizzle affectation |
| 133 | /// starting from the one already provided in the Instruction Group MIs that |
| 134 | /// fits Read Port limitations in BS if available. Otherwise returns false |
| 135 | /// and undefined content in BS. |
Vincent Lejeune | 77a8352 | 2013-06-29 19:32:43 +0000 | [diff] [blame] | 136 | /// isLastAluTrans should be set if the last Alu of MIs will be executed on |
| 137 | /// Trans ALU. In this case, ValidTSwizzle returns the BankSwizzle value to |
| 138 | /// apply to the last instruction. |
Vincent Lejeune | 0fca91d | 2013-05-17 16:50:02 +0000 | [diff] [blame] | 139 | /// PV holds GPR to PV registers in the Instruction Group MIs. |
| 140 | bool fitsReadPortLimitations(const std::vector<MachineInstr *> &MIs, |
| 141 | const DenseMap<unsigned, unsigned> &PV, |
Vincent Lejeune | 77a8352 | 2013-06-29 19:32:43 +0000 | [diff] [blame] | 142 | std::vector<BankSwizzle> &BS, |
| 143 | bool isLastAluTrans) const; |
| 144 | |
| 145 | /// An instruction group can only access 2 channel pair (either [XY] or [ZW]) |
| 146 | /// from KCache bank on R700+. This function check if MI set in input meet |
| 147 | /// this limitations |
| 148 | bool fitsConstReadLimitations(const std::vector<MachineInstr *> &) const; |
| 149 | /// Same but using const index set instead of MI set. |
Vincent Lejeune | 0a22bc4 | 2013-03-14 15:50:45 +0000 | [diff] [blame] | 150 | bool fitsConstReadLimitations(const std::vector<unsigned>&) const; |
Vincent Lejeune | 0a22bc4 | 2013-03-14 15:50:45 +0000 | [diff] [blame] | 151 | |
Alp Toker | cb40291 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 152 | /// \brief Vector instructions are instructions that must fill all |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 153 | /// instruction slots within an instruction group. |
| 154 | bool isVector(const MachineInstr &MI) const; |
| 155 | |
Tom Stellard | 2ff7262 | 2016-01-28 16:04:37 +0000 | [diff] [blame] | 156 | bool isMov(unsigned Opcode) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 157 | |
Eric Christopher | 143f02c | 2014-10-09 01:59:35 +0000 | [diff] [blame] | 158 | DFAPacketizer * |
| 159 | CreateTargetScheduleState(const TargetSubtargetInfo &) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 160 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 161 | bool ReverseBranchCondition( |
| 162 | SmallVectorImpl<MachineOperand> &Cond) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 163 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 164 | bool AnalyzeBranch(MachineBasicBlock &MBB, |
| 165 | MachineBasicBlock *&TBB, |
| 166 | MachineBasicBlock *&FBB, |
| 167 | SmallVectorImpl<MachineOperand> &Cond, |
| 168 | bool AllowModify) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 169 | |
Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 170 | unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, |
| 171 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 172 | const DebugLoc &DL) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 173 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 174 | unsigned RemoveBranch(MachineBasicBlock &MBB) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 175 | |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 176 | bool isPredicated(const MachineInstr &MI) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 177 | |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 178 | bool isPredicable(MachineInstr &MI) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 179 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 180 | bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCyles, |
| 181 | BranchProbability Probability) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 182 | |
| 183 | bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCyles, |
| 184 | unsigned ExtraPredCycles, |
Cong Hou | c536bd9 | 2015-09-10 23:10:42 +0000 | [diff] [blame] | 185 | BranchProbability Probability) const override ; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 186 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 187 | bool isProfitableToIfCvt(MachineBasicBlock &TMBB, |
| 188 | unsigned NumTCycles, unsigned ExtraTCycles, |
| 189 | MachineBasicBlock &FMBB, |
| 190 | unsigned NumFCycles, unsigned ExtraFCycles, |
| 191 | BranchProbability Probability) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 192 | |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 193 | bool DefinesPredicate(MachineInstr &MI, |
| 194 | std::vector<MachineOperand> &Pred) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 195 | |
Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 196 | bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1, |
| 197 | ArrayRef<MachineOperand> Pred2) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 198 | |
| 199 | bool isProfitableToUnpredicate(MachineBasicBlock &TMBB, |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 200 | MachineBasicBlock &FMBB) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 201 | |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 202 | bool PredicateInstruction(MachineInstr &MI, |
Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 203 | ArrayRef<MachineOperand> Pred) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 204 | |
Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 205 | unsigned int getPredicationCost(const MachineInstr &) const override; |
Arnold Schwaighofer | d2f96b9 | 2013-09-30 15:28:56 +0000 | [diff] [blame] | 206 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 207 | unsigned int getInstrLatency(const InstrItineraryData *ItinData, |
| 208 | const MachineInstr *MI, |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 209 | unsigned *PredCost = nullptr) const override; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 210 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 211 | int getInstrLatency(const InstrItineraryData *ItinData, |
| 212 | SDNode *Node) const override { return 1;} |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 213 | |
Benjamin Kramer | 8c90fd7 | 2014-09-03 11:41:21 +0000 | [diff] [blame] | 214 | bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override; |
Tom Stellard | 880a80a | 2014-06-17 16:53:14 +0000 | [diff] [blame] | 215 | |
Tom Stellard | 81d871d | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 216 | /// \brief Reserve the registers that may be accesed using indirect addressing. |
| 217 | void reserveIndirectRegisters(BitVector &Reserved, |
| 218 | const MachineFunction &MF) const; |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 219 | |
Tom Stellard | 1242ce9 | 2016-02-05 18:44:57 +0000 | [diff] [blame] | 220 | /// Calculate the "Indirect Address" for the given \p RegIndex and |
| 221 | /// \p Channel |
| 222 | /// |
| 223 | /// We model indirect addressing using a virtual address space that can be |
| 224 | /// accesed with loads and stores. The "Indirect Address" is the memory |
| 225 | /// address in this virtual address space that maps to the given \p RegIndex |
| 226 | /// and \p Channel. |
| 227 | unsigned calculateIndirectAddress(unsigned RegIndex, unsigned Channel) const; |
| 228 | |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 229 | |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 230 | const TargetRegisterClass *getIndirectAddrRegClass() const override; |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 231 | |
Tom Stellard | 1242ce9 | 2016-02-05 18:44:57 +0000 | [diff] [blame] | 232 | /// \brief Build instruction(s) for an indirect register write. |
| 233 | /// |
| 234 | /// \returns The instruction that performs the indirect register write |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 235 | MachineInstrBuilder buildIndirectWrite(MachineBasicBlock *MBB, |
Tom Stellard | 1242ce9 | 2016-02-05 18:44:57 +0000 | [diff] [blame] | 236 | MachineBasicBlock::iterator I, |
| 237 | unsigned ValueReg, unsigned Address, |
| 238 | unsigned OffsetReg) const; |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 239 | |
Tom Stellard | 1242ce9 | 2016-02-05 18:44:57 +0000 | [diff] [blame] | 240 | /// \brief Build instruction(s) for an indirect register read. |
| 241 | /// |
| 242 | /// \returns The instruction that performs the indirect register read |
Craig Topper | 5656db4 | 2014-04-29 07:57:24 +0000 | [diff] [blame] | 243 | MachineInstrBuilder buildIndirectRead(MachineBasicBlock *MBB, |
| 244 | MachineBasicBlock::iterator I, |
| 245 | unsigned ValueReg, unsigned Address, |
Tom Stellard | 1242ce9 | 2016-02-05 18:44:57 +0000 | [diff] [blame] | 246 | unsigned OffsetReg) const; |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 247 | |
Vincent Lejeune | 80031d9f | 2013-04-03 16:49:34 +0000 | [diff] [blame] | 248 | unsigned getMaxAlusPerClause() const; |
Tom Stellard | f3b2a1e | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 249 | |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 250 | /// buildDefaultInstruction - This function returns a MachineInstr with all |
| 251 | /// the instruction modifiers initialized to their default values. You can |
| 252 | /// use this function to avoid manually specifying each instruction modifier |
| 253 | /// operand when building a new instruction. |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 254 | /// |
| 255 | /// \returns a MachineInstr with all the instruction modifiers initialized |
| 256 | /// to their default values. |
| 257 | MachineInstrBuilder buildDefaultInstruction(MachineBasicBlock &MBB, |
| 258 | MachineBasicBlock::iterator I, |
| 259 | unsigned Opcode, |
| 260 | unsigned DstReg, |
| 261 | unsigned Src0Reg, |
| 262 | unsigned Src1Reg = 0) const; |
| 263 | |
Vincent Lejeune | 519f21e | 2013-05-17 16:50:32 +0000 | [diff] [blame] | 264 | MachineInstr *buildSlotOfVectorInstruction(MachineBasicBlock &MBB, |
| 265 | MachineInstr *MI, |
| 266 | unsigned Slot, |
| 267 | unsigned DstReg) const; |
| 268 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 269 | MachineInstr *buildMovImm(MachineBasicBlock &BB, |
Matt Arsenault | 43e92fe | 2016-06-24 06:30:11 +0000 | [diff] [blame^] | 270 | MachineBasicBlock::iterator I, |
| 271 | unsigned DstReg, |
| 272 | uint64_t Imm) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 273 | |
Tom Stellard | 26a3b67 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 274 | MachineInstr *buildMovInstr(MachineBasicBlock *MBB, |
| 275 | MachineBasicBlock::iterator I, |
Tom Stellard | 2ff7262 | 2016-01-28 16:04:37 +0000 | [diff] [blame] | 276 | unsigned DstReg, unsigned SrcReg) const; |
Tom Stellard | 26a3b67 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 277 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 278 | /// \brief Get the index of Op in the MachineInstr. |
| 279 | /// |
| 280 | /// \returns -1 if the Instruction does not contain the specified \p Op. |
Tom Stellard | 02661d9 | 2013-06-25 21:22:18 +0000 | [diff] [blame] | 281 | int getOperandIdx(const MachineInstr &MI, unsigned Op) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 282 | |
| 283 | /// \brief Get the index of \p Op for the given Opcode. |
| 284 | /// |
| 285 | /// \returns -1 if the Instruction does not contain the specified \p Op. |
Tom Stellard | 02661d9 | 2013-06-25 21:22:18 +0000 | [diff] [blame] | 286 | int getOperandIdx(unsigned Opcode, unsigned Op) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 287 | |
| 288 | /// \brief Helper function for setting instruction flag values. |
Tom Stellard | 02661d9 | 2013-06-25 21:22:18 +0000 | [diff] [blame] | 289 | void setImmOperand(MachineInstr *MI, unsigned Op, int64_t Imm) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 290 | |
| 291 | /// \returns true if this instruction has an operand for storing target flags. |
| 292 | bool hasFlagOperand(const MachineInstr &MI) const; |
| 293 | |
| 294 | ///\brief Add one of the MO_FLAG* flags to the specified \p Operand. |
| 295 | void addFlag(MachineInstr *MI, unsigned Operand, unsigned Flag) const; |
| 296 | |
| 297 | ///\brief Determine if the specified \p Flag is set on this \p Operand. |
| 298 | bool isFlagSet(const MachineInstr &MI, unsigned Operand, unsigned Flag) const; |
| 299 | |
| 300 | /// \param SrcIdx The register source to set the flag on (e.g src0, src1, src2) |
| 301 | /// \param Flag The flag being set. |
| 302 | /// |
| 303 | /// \returns the operand containing the flags for this instruction. |
| 304 | MachineOperand &getFlagOp(MachineInstr *MI, unsigned SrcIdx = 0, |
| 305 | unsigned Flag = 0) const; |
| 306 | |
| 307 | /// \brief Clear the specified flag on the instruction. |
| 308 | void clearFlag(MachineInstr *MI, unsigned Operand, unsigned Flag) const; |
Tom Stellard | 2ff7262 | 2016-01-28 16:04:37 +0000 | [diff] [blame] | 309 | |
| 310 | // Helper functions that check the opcode for status information |
| 311 | bool isRegisterStore(const MachineInstr &MI) const; |
| 312 | bool isRegisterLoad(const MachineInstr &MI) const; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 313 | }; |
| 314 | |
Tom Stellard | 13c68ef | 2013-09-05 18:38:09 +0000 | [diff] [blame] | 315 | namespace AMDGPU { |
| 316 | |
| 317 | int getLDSNoRetOp(uint16_t Opcode); |
| 318 | |
| 319 | } //End namespace AMDGPU |
| 320 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 321 | } // End llvm namespace |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 322 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 323 | #endif |