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