blob: 906c15c43d127f3e32cd1af330b654ecf511b5d9 [file] [log] [blame]
Matt Arsenaultdf90c022013-10-15 23:44:45 +00001//===-- SIInstrInfo.h - SI Instruction Info Interface -----------*- C++ -*-===//
Tom Stellard75aadc22012-12-11 21:25:42 +00002//
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 SIInstrInfo.
12//
13//===----------------------------------------------------------------------===//
14
15
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000016#ifndef LLVM_LIB_TARGET_R600_SIINSTRINFO_H
17#define LLVM_LIB_TARGET_R600_SIINSTRINFO_H
Tom Stellard75aadc22012-12-11 21:25:42 +000018
19#include "AMDGPUInstrInfo.h"
Matt Arsenaultc5f174d2014-12-01 15:52:46 +000020#include "SIDefines.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000021#include "SIRegisterInfo.h"
22
23namespace llvm {
24
25class SIInstrInfo : public AMDGPUInstrInfo {
26private:
27 const SIRegisterInfo RI;
28
Tom Stellard15834092014-03-21 15:51:57 +000029 unsigned buildExtractSubReg(MachineBasicBlock::iterator MI,
30 MachineRegisterInfo &MRI,
31 MachineOperand &SuperReg,
32 const TargetRegisterClass *SuperRC,
33 unsigned SubIdx,
34 const TargetRegisterClass *SubRC) const;
Matt Arsenault248b7b62014-03-24 20:08:09 +000035 MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI,
36 MachineRegisterInfo &MRI,
37 MachineOperand &SuperReg,
38 const TargetRegisterClass *SuperRC,
39 unsigned SubIdx,
40 const TargetRegisterClass *SubRC) const;
Tom Stellard15834092014-03-21 15:51:57 +000041
Marek Olsakbe047802014-12-07 12:19:03 +000042 void swapOperands(MachineBasicBlock::iterator Inst) const;
43
Matt Arsenault689f3252014-06-09 16:36:31 +000044 void splitScalar64BitUnaryOp(SmallVectorImpl<MachineInstr *> &Worklist,
45 MachineInstr *Inst, unsigned Opcode) const;
46
47 void splitScalar64BitBinaryOp(SmallVectorImpl<MachineInstr *> &Worklist,
48 MachineInstr *Inst, unsigned Opcode) const;
Matt Arsenaultf35182c2014-03-24 20:08:05 +000049
Matt Arsenault8333e432014-06-10 19:18:24 +000050 void splitScalar64BitBCNT(SmallVectorImpl<MachineInstr *> &Worklist,
51 MachineInstr *Inst) const;
Matt Arsenault94812212014-11-14 18:18:16 +000052 void splitScalar64BitBFE(SmallVectorImpl<MachineInstr *> &Worklist,
53 MachineInstr *Inst) const;
Matt Arsenault8333e432014-06-10 19:18:24 +000054
Matt Arsenaultf003c382015-08-26 20:47:50 +000055 void addUsersToMoveToVALUWorklist(
56 unsigned Reg, MachineRegisterInfo &MRI,
57 SmallVectorImpl<MachineInstr *> &Worklist) const;
58
Matt Arsenaultba6aae72015-09-28 20:54:57 +000059 const TargetRegisterClass *
60 getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
61
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +000062 bool checkInstOffsetsDoNotOverlap(MachineInstr *MIa,
63 MachineInstr *MIb) const;
64
Matt Arsenaultee522bf2014-09-26 17:55:06 +000065 unsigned findUsedSGPR(const MachineInstr *MI, int OpIndices[3]) const;
66
Andrew Kaylor16c4da02015-09-28 20:33:22 +000067protected:
68 MachineInstr *commuteInstructionImpl(MachineInstr *MI,
69 bool NewMI,
70 unsigned OpIdx0,
71 unsigned OpIdx1) const override;
72
Tom Stellard75aadc22012-12-11 21:25:42 +000073public:
Tom Stellard2e59a452014-06-13 01:32:00 +000074 explicit SIInstrInfo(const AMDGPUSubtarget &st);
Tom Stellard75aadc22012-12-11 21:25:42 +000075
Craig Topper5656db42014-04-29 07:57:24 +000076 const SIRegisterInfo &getRegisterInfo() const override {
Matt Arsenault6dde3032014-03-11 00:01:34 +000077 return RI;
78 }
Tom Stellard75aadc22012-12-11 21:25:42 +000079
Matt Arsenaulta48b8662015-04-23 23:34:48 +000080 bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
81 AliasAnalysis *AA) const override;
82
Matt Arsenaultc10853f2014-08-06 00:29:43 +000083 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
84 int64_t &Offset1,
85 int64_t &Offset2) const override;
86
Sanjoy Dasb666ea32015-06-15 18:44:14 +000087 bool getMemOpBaseRegImmOfs(MachineInstr *LdSt, unsigned &BaseReg,
88 unsigned &Offset,
89 const TargetRegisterInfo *TRI) const final;
Matt Arsenault1acc72f2014-07-29 21:34:55 +000090
Matt Arsenault0e75a062014-09-17 17:48:30 +000091 bool shouldClusterLoads(MachineInstr *FirstLdSt,
92 MachineInstr *SecondLdSt,
93 unsigned NumLoads) const final;
94
Craig Topper5656db42014-04-29 07:57:24 +000095 void copyPhysReg(MachineBasicBlock &MBB,
96 MachineBasicBlock::iterator MI, DebugLoc DL,
97 unsigned DestReg, unsigned SrcReg,
98 bool KillSrc) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +000099
Tom Stellard96468902014-09-24 01:33:17 +0000100 unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB,
101 MachineBasicBlock::iterator MI,
102 RegScavenger *RS,
103 unsigned TmpReg,
104 unsigned Offset,
105 unsigned Size) const;
106
Tom Stellardc149dc02013-11-27 21:23:35 +0000107 void storeRegToStackSlot(MachineBasicBlock &MBB,
108 MachineBasicBlock::iterator MI,
109 unsigned SrcReg, bool isKill, int FrameIndex,
110 const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000111 const TargetRegisterInfo *TRI) const override;
Tom Stellardc149dc02013-11-27 21:23:35 +0000112
113 void loadRegFromStackSlot(MachineBasicBlock &MBB,
114 MachineBasicBlock::iterator MI,
115 unsigned DestReg, int FrameIndex,
116 const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000117 const TargetRegisterInfo *TRI) const override;
Tom Stellardc149dc02013-11-27 21:23:35 +0000118
Benjamin Kramer8c90fd72014-09-03 11:41:21 +0000119 bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
Tom Stellardeba61072014-05-02 15:41:42 +0000120
Tom Stellardef3b8642015-01-07 19:56:17 +0000121 // \brief Returns an opcode that can be used to move a value to a \p DstRC
122 // register. If there is no hardware instruction that can store to \p
123 // DstRC, then AMDGPU::COPY is returned.
124 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
Matt Arsenaultfa242962015-09-24 07:51:23 +0000125
126 LLVM_READONLY
Marek Olsakcfbdba22015-06-26 20:29:10 +0000127 int commuteOpcode(const MachineInstr &MI) const;
Christian Konig3c145802013-03-27 09:12:59 +0000128
Matt Arsenault92befe72014-09-26 17:54:54 +0000129 bool findCommutedOpIndices(MachineInstr *MI,
130 unsigned &SrcOpIdx1,
131 unsigned &SrcOpIdx2) const override;
Christian Konig76edd4f2013-02-26 17:52:29 +0000132
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +0000133 bool areMemAccessesTriviallyDisjoint(
134 MachineInstr *MIa, MachineInstr *MIb,
135 AliasAnalysis *AA = nullptr) const override;
136
Tom Stellard26a3b672013-10-22 18:19:10 +0000137 MachineInstr *buildMovInstr(MachineBasicBlock *MBB,
138 MachineBasicBlock::iterator I,
Craig Topper5656db42014-04-29 07:57:24 +0000139 unsigned DstReg, unsigned SrcReg) const override;
140 bool isMov(unsigned Opcode) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +0000141
Matt Arsenault0325d3d2015-02-21 21:29:07 +0000142 bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
143 unsigned Reg, MachineRegisterInfo *MRI) const final;
144
Tom Stellardf01af292015-05-09 00:56:07 +0000145 unsigned getMachineCSELookAheadLimit() const override { return 500; }
146
Tom Stellarddb5a11f2015-07-13 15:47:57 +0000147 MachineInstr *convertToThreeAddress(MachineFunction::iterator &MBB,
148 MachineBasicBlock::iterator &MI,
149 LiveVariables *LV) const override;
150
Matt Arsenault3add6432015-10-20 04:35:43 +0000151 static bool isSALU(const MachineInstr &MI) {
152 return MI.getDesc().TSFlags & SIInstrFlags::SALU;
153 }
154
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000155 bool isSALU(uint16_t Opcode) const {
156 return get(Opcode).TSFlags & SIInstrFlags::SALU;
157 }
158
Matt Arsenault3add6432015-10-20 04:35:43 +0000159 static bool isVALU(const MachineInstr &MI) {
160 return MI.getDesc().TSFlags & SIInstrFlags::VALU;
161 }
162
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000163 bool isVALU(uint16_t Opcode) const {
164 return get(Opcode).TSFlags & SIInstrFlags::VALU;
165 }
166
Matt Arsenault3add6432015-10-20 04:35:43 +0000167 static bool isSOP1(const MachineInstr &MI) {
168 return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
169 }
170
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000171 bool isSOP1(uint16_t Opcode) const {
172 return get(Opcode).TSFlags & SIInstrFlags::SOP1;
173 }
174
Matt Arsenault3add6432015-10-20 04:35:43 +0000175 static bool isSOP2(const MachineInstr &MI) {
176 return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
177 }
178
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000179 bool isSOP2(uint16_t Opcode) const {
180 return get(Opcode).TSFlags & SIInstrFlags::SOP2;
181 }
182
Matt Arsenault3add6432015-10-20 04:35:43 +0000183 static bool isSOPC(const MachineInstr &MI) {
184 return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
185 }
186
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000187 bool isSOPC(uint16_t Opcode) const {
188 return get(Opcode).TSFlags & SIInstrFlags::SOPC;
189 }
190
Matt Arsenault3add6432015-10-20 04:35:43 +0000191 static bool isSOPK(const MachineInstr &MI) {
192 return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
193 }
194
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000195 bool isSOPK(uint16_t Opcode) const {
196 return get(Opcode).TSFlags & SIInstrFlags::SOPK;
197 }
198
Matt Arsenault3add6432015-10-20 04:35:43 +0000199 static bool isSOPP(const MachineInstr &MI) {
200 return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
201 }
202
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000203 bool isSOPP(uint16_t Opcode) const {
204 return get(Opcode).TSFlags & SIInstrFlags::SOPP;
205 }
206
Matt Arsenault3add6432015-10-20 04:35:43 +0000207 static bool isVOP1(const MachineInstr &MI) {
208 return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
209 }
210
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000211 bool isVOP1(uint16_t Opcode) const {
212 return get(Opcode).TSFlags & SIInstrFlags::VOP1;
213 }
214
Matt Arsenault3add6432015-10-20 04:35:43 +0000215 static bool isVOP2(const MachineInstr &MI) {
216 return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
217 }
218
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000219 bool isVOP2(uint16_t Opcode) const {
220 return get(Opcode).TSFlags & SIInstrFlags::VOP2;
221 }
222
Matt Arsenault3add6432015-10-20 04:35:43 +0000223 static bool isVOP3(const MachineInstr &MI) {
224 return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
225 }
226
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000227 bool isVOP3(uint16_t Opcode) const {
228 return get(Opcode).TSFlags & SIInstrFlags::VOP3;
229 }
230
Matt Arsenault3add6432015-10-20 04:35:43 +0000231 static bool isVOPC(const MachineInstr &MI) {
232 return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
233 }
234
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000235 bool isVOPC(uint16_t Opcode) const {
236 return get(Opcode).TSFlags & SIInstrFlags::VOPC;
237 }
238
Matt Arsenault3add6432015-10-20 04:35:43 +0000239 static bool isMUBUF(const MachineInstr &MI) {
240 return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
241 }
242
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000243 bool isMUBUF(uint16_t Opcode) const {
244 return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
245 }
246
Matt Arsenault3add6432015-10-20 04:35:43 +0000247 static bool isMTBUF(const MachineInstr &MI) {
248 return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
249 }
250
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000251 bool isMTBUF(uint16_t Opcode) const {
252 return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
253 }
254
Matt Arsenault3add6432015-10-20 04:35:43 +0000255 static bool isSMRD(const MachineInstr &MI) {
256 return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
257 }
258
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000259 bool isSMRD(uint16_t Opcode) const {
260 return get(Opcode).TSFlags & SIInstrFlags::SMRD;
261 }
262
Matt Arsenault3add6432015-10-20 04:35:43 +0000263 static bool isDS(const MachineInstr &MI) {
264 return MI.getDesc().TSFlags & SIInstrFlags::DS;
265 }
266
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000267 bool isDS(uint16_t Opcode) const {
268 return get(Opcode).TSFlags & SIInstrFlags::DS;
269 }
270
Matt Arsenault3add6432015-10-20 04:35:43 +0000271 static bool isMIMG(const MachineInstr &MI) {
272 return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
273 }
274
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000275 bool isMIMG(uint16_t Opcode) const {
276 return get(Opcode).TSFlags & SIInstrFlags::MIMG;
277 }
278
Matt Arsenault3add6432015-10-20 04:35:43 +0000279 static bool isFLAT(const MachineInstr &MI) {
280 return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
281 }
282
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000283 bool isFLAT(uint16_t Opcode) const {
284 return get(Opcode).TSFlags & SIInstrFlags::FLAT;
285 }
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +0000286
Matt Arsenault3add6432015-10-20 04:35:43 +0000287 static bool isWQM(const MachineInstr &MI) {
288 return MI.getDesc().TSFlags & SIInstrFlags::WQM;
289 }
290
Michel Danzer494391b2015-02-06 02:51:20 +0000291 bool isWQM(uint16_t Opcode) const {
292 return get(Opcode).TSFlags & SIInstrFlags::WQM;
293 }
294
Matt Arsenault3add6432015-10-20 04:35:43 +0000295 static bool isVGPRSpill(const MachineInstr &MI) {
296 return MI.getDesc().TSFlags & SIInstrFlags::VGPRSpill;
297 }
298
Tom Stellarda77c3f72015-05-12 18:59:17 +0000299 bool isVGPRSpill(uint16_t Opcode) const {
300 return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill;
301 }
302
Matt Arsenaultd7bdcc42014-03-31 19:54:27 +0000303 bool isInlineConstant(const APInt &Imm) const;
Matt Arsenault11a4d672015-02-13 19:05:03 +0000304 bool isInlineConstant(const MachineOperand &MO, unsigned OpSize) const;
305 bool isLiteralConstant(const MachineOperand &MO, unsigned OpSize) const;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000306
Tom Stellardb02094e2014-07-21 15:45:01 +0000307 bool isImmOperandLegal(const MachineInstr *MI, unsigned OpNo,
308 const MachineOperand &MO) const;
309
Tom Stellard86d12eb2014-08-01 00:32:28 +0000310 /// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding.
311 /// This function will return false if you pass it a 32-bit instruction.
312 bool hasVALU32BitEncoding(unsigned Opcode) const;
313
Tom Stellard73ae1cb2014-09-23 21:26:25 +0000314 /// \brief Returns true if this operand uses the constant bus.
315 bool usesConstantBus(const MachineRegisterInfo &MRI,
Matt Arsenault11a4d672015-02-13 19:05:03 +0000316 const MachineOperand &MO,
317 unsigned OpSize) const;
Tom Stellard73ae1cb2014-09-23 21:26:25 +0000318
Tom Stellardb4a313a2014-08-01 00:32:39 +0000319 /// \brief Return true if this instruction has any modifiers.
320 /// e.g. src[012]_mod, omod, clamp.
321 bool hasModifiers(unsigned Opcode) const;
Matt Arsenaultace5b762014-10-17 18:00:43 +0000322
323 bool hasModifiersSet(const MachineInstr &MI,
324 unsigned OpName) const;
325
Craig Topper5656db42014-04-29 07:57:24 +0000326 bool verifyInstruction(const MachineInstr *MI,
327 StringRef &ErrInfo) const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000328
Matt Arsenaultf14032a2013-11-15 22:02:28 +0000329 static unsigned getVALUOp(const MachineInstr &MI);
Matt Arsenaultf35182c2014-03-24 20:08:05 +0000330
Tom Stellard82166022013-11-13 23:36:37 +0000331 bool isSALUOpSupportedOnVALU(const MachineInstr &MI) const;
332
333 /// \brief Return the correct register class for \p OpNo. For target-specific
334 /// instructions, this will return the register class that has been defined
335 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
336 /// the register class of its machine operand.
337 /// to infer the correct register class base on the other operands.
338 const TargetRegisterClass *getOpRegClass(const MachineInstr &MI,
Matt Arsenault11a4d672015-02-13 19:05:03 +0000339 unsigned OpNo) const;
340
341 /// \brief Return the size in bytes of the operand OpNo on the given
342 // instruction opcode.
343 unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
344 const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
Matt Arsenault657b1cb2015-02-21 21:29:04 +0000345
346 if (OpInfo.RegClass == -1) {
347 // If this is an immediate operand, this must be a 32-bit literal.
348 assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
349 return 4;
350 }
351
Matt Arsenault11a4d672015-02-13 19:05:03 +0000352 return RI.getRegClass(OpInfo.RegClass)->getSize();
353 }
354
355 /// \brief This form should usually be preferred since it handles operands
356 /// with unknown register classes.
357 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
358 return getOpRegClass(MI, OpNo)->getSize();
359 }
Tom Stellard82166022013-11-13 23:36:37 +0000360
361 /// \returns true if it is legal for the operand at index \p OpNo
362 /// to read a VGPR.
363 bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const;
364
365 /// \brief Legalize the \p OpIndex operand of this instruction by inserting
366 /// a MOV. For example:
367 /// ADD_I32_e32 VGPR0, 15
368 /// to
369 /// MOV VGPR1, 15
370 /// ADD_I32_e32 VGPR0, VGPR1
371 ///
372 /// If the operand being legalized is a register, then a COPY will be used
373 /// instead of MOV.
374 void legalizeOpWithMove(MachineInstr *MI, unsigned OpIdx) const;
375
Tom Stellard0e975cf2014-08-01 00:32:35 +0000376 /// \brief Check if \p MO is a legal operand if it was the \p OpIdx Operand
377 /// for \p MI.
378 bool isOperandLegal(const MachineInstr *MI, unsigned OpIdx,
379 const MachineOperand *MO = nullptr) const;
380
Tom Stellard82166022013-11-13 23:36:37 +0000381 /// \brief Legalize all operands in this instruction. This function may
382 /// create new instruction and insert them before \p MI.
383 void legalizeOperands(MachineInstr *MI) const;
384
Tom Stellard745f2ed2014-08-21 20:41:00 +0000385 /// \brief Split an SMRD instruction into two smaller loads of half the
386 // size storing the results in \p Lo and \p Hi.
387 void splitSMRD(MachineInstr *MI, const TargetRegisterClass *HalfRC,
388 unsigned HalfImmOp, unsigned HalfSGPROp,
389 MachineInstr *&Lo, MachineInstr *&Hi) const;
390
Matt Arsenaulte229c0c2015-09-25 22:21:19 +0000391 void moveSMRDToVALU(MachineInstr *MI, MachineRegisterInfo &MRI,
392 SmallVectorImpl<MachineInstr *> &Worklist) const;
Tom Stellard0c354f22014-04-30 15:31:29 +0000393
Tom Stellard82166022013-11-13 23:36:37 +0000394 /// \brief Replace this instruction's opcode with the equivalent VALU
395 /// opcode. This function will also move the users of \p MI to the
396 /// VALU if necessary.
397 void moveToVALU(MachineInstr &MI) const;
398
Craig Topper5656db42014-04-29 07:57:24 +0000399 unsigned calculateIndirectAddress(unsigned RegIndex,
400 unsigned Channel) const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000401
Craig Topper5656db42014-04-29 07:57:24 +0000402 const TargetRegisterClass *getIndirectAddrRegClass() const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000403
Craig Topper5656db42014-04-29 07:57:24 +0000404 MachineInstrBuilder buildIndirectWrite(MachineBasicBlock *MBB,
405 MachineBasicBlock::iterator I,
406 unsigned ValueReg,
407 unsigned Address,
408 unsigned OffsetReg) const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000409
Craig Topper5656db42014-04-29 07:57:24 +0000410 MachineInstrBuilder buildIndirectRead(MachineBasicBlock *MBB,
411 MachineBasicBlock::iterator I,
412 unsigned ValueReg,
413 unsigned Address,
414 unsigned OffsetReg) const override;
Tom Stellard81d871d2013-11-13 23:36:50 +0000415 void reserveIndirectRegisters(BitVector &Reserved,
416 const MachineFunction &MF) const;
417
418 void LoadM0(MachineInstr *MoveRel, MachineBasicBlock::iterator I,
419 unsigned SavReg, unsigned IndexReg) const;
Tom Stellardeba61072014-05-02 15:41:42 +0000420
421 void insertNOPs(MachineBasicBlock::iterator MI, int Count) const;
Tom Stellard1aaad692014-07-21 16:55:33 +0000422
423 /// \brief Returns the operand named \p Op. If \p MI does not have an
424 /// operand named \c Op, this function returns nullptr.
Matt Arsenaultf743b832015-09-25 18:09:15 +0000425 LLVM_READONLY
Tom Stellard6407e1e2014-08-01 00:32:33 +0000426 MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const;
Matt Arsenaultace5b762014-10-17 18:00:43 +0000427
Matt Arsenaultf743b832015-09-25 18:09:15 +0000428 LLVM_READONLY
Matt Arsenaultace5b762014-10-17 18:00:43 +0000429 const MachineOperand *getNamedOperand(const MachineInstr &MI,
430 unsigned OpName) const {
431 return getNamedOperand(const_cast<MachineInstr &>(MI), OpName);
432 }
Tom Stellard794c8c02014-12-02 17:05:41 +0000433
434 uint64_t getDefaultRsrcDataFormat() const;
Marek Olsakd1a69a22015-09-29 23:37:32 +0000435 uint64_t getScratchRsrcWords23() const;
Tom Stellard81d871d2013-11-13 23:36:50 +0000436};
Tom Stellard75aadc22012-12-11 21:25:42 +0000437
Christian Konigf741fbf2013-02-26 17:52:42 +0000438namespace AMDGPU {
Matt Arsenaultfa242962015-09-24 07:51:23 +0000439 LLVM_READONLY
Christian Konigf741fbf2013-02-26 17:52:42 +0000440 int getVOPe64(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000441
442 LLVM_READONLY
Tom Stellard1aaad692014-07-21 16:55:33 +0000443 int getVOPe32(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000444
445 LLVM_READONLY
Christian Konig3c145802013-03-27 09:12:59 +0000446 int getCommuteRev(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000447
448 LLVM_READONLY
Christian Konig3c145802013-03-27 09:12:59 +0000449 int getCommuteOrig(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000450
451 LLVM_READONLY
Tom Stellard155bbb72014-08-11 22:18:17 +0000452 int getAddr64Inst(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000453
454 LLVM_READONLY
Matt Arsenault9903ccf2014-09-08 15:07:27 +0000455 int getAtomicRetOp(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000456
457 LLVM_READONLY
Matt Arsenault9903ccf2014-09-08 15:07:27 +0000458 int getAtomicNoRetOp(uint16_t Opcode);
Christian Konigf741fbf2013-02-26 17:52:42 +0000459
Tom Stellard15834092014-03-21 15:51:57 +0000460 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
Tom Stellardb02094e2014-07-21 15:45:01 +0000461 const uint64_t RSRC_TID_ENABLE = 1LL << 55;
Tom Stellard15834092014-03-21 15:51:57 +0000462
Christian Konigf741fbf2013-02-26 17:52:42 +0000463} // End namespace AMDGPU
464
Tom Stellardec2e43c2014-09-22 15:35:29 +0000465namespace SI {
466namespace KernelInputOffsets {
467
468/// Offsets in bytes from the start of the input buffer
469enum Offsets {
470 NGROUPS_X = 0,
471 NGROUPS_Y = 4,
472 NGROUPS_Z = 8,
473 GLOBAL_SIZE_X = 12,
474 GLOBAL_SIZE_Y = 16,
475 GLOBAL_SIZE_Z = 20,
476 LOCAL_SIZE_X = 24,
477 LOCAL_SIZE_Y = 28,
478 LOCAL_SIZE_Z = 32
479};
480
481} // End namespace KernelInputOffsets
482} // End namespace SI
483
Tom Stellard75aadc22012-12-11 21:25:42 +0000484} // End namespace llvm
485
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000486#endif