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