blob: c2d51a56d5c783feaf9ed0c521bbf38af408d93a [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
Marek Olsak7ed6b2f2015-11-25 21:22:45 +000044 void lowerScalarAbs(SmallVectorImpl<MachineInstr *> &Worklist,
45 MachineInstr *Inst) const;
46
Matt Arsenault689f3252014-06-09 16:36:31 +000047 void splitScalar64BitUnaryOp(SmallVectorImpl<MachineInstr *> &Worklist,
48 MachineInstr *Inst, unsigned Opcode) const;
49
50 void splitScalar64BitBinaryOp(SmallVectorImpl<MachineInstr *> &Worklist,
51 MachineInstr *Inst, unsigned Opcode) const;
Matt Arsenaultf35182c2014-03-24 20:08:05 +000052
Matt Arsenault8333e432014-06-10 19:18:24 +000053 void splitScalar64BitBCNT(SmallVectorImpl<MachineInstr *> &Worklist,
54 MachineInstr *Inst) const;
Matt Arsenault94812212014-11-14 18:18:16 +000055 void splitScalar64BitBFE(SmallVectorImpl<MachineInstr *> &Worklist,
56 MachineInstr *Inst) const;
Matt Arsenault8333e432014-06-10 19:18:24 +000057
Matt Arsenaultf003c382015-08-26 20:47:50 +000058 void addUsersToMoveToVALUWorklist(
59 unsigned Reg, MachineRegisterInfo &MRI,
60 SmallVectorImpl<MachineInstr *> &Worklist) const;
61
Matt Arsenaultba6aae72015-09-28 20:54:57 +000062 const TargetRegisterClass *
63 getDestEquivalentVGPRClass(const MachineInstr &Inst) const;
64
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +000065 bool checkInstOffsetsDoNotOverlap(MachineInstr *MIa,
66 MachineInstr *MIb) const;
67
Matt Arsenaultee522bf2014-09-26 17:55:06 +000068 unsigned findUsedSGPR(const MachineInstr *MI, int OpIndices[3]) const;
69
Andrew Kaylor16c4da02015-09-28 20:33:22 +000070protected:
71 MachineInstr *commuteInstructionImpl(MachineInstr *MI,
72 bool NewMI,
73 unsigned OpIdx0,
74 unsigned OpIdx1) const override;
75
Tom Stellard75aadc22012-12-11 21:25:42 +000076public:
Tom Stellard2e59a452014-06-13 01:32:00 +000077 explicit SIInstrInfo(const AMDGPUSubtarget &st);
Tom Stellard75aadc22012-12-11 21:25:42 +000078
Craig Topper5656db42014-04-29 07:57:24 +000079 const SIRegisterInfo &getRegisterInfo() const override {
Matt Arsenault6dde3032014-03-11 00:01:34 +000080 return RI;
81 }
Tom Stellard75aadc22012-12-11 21:25:42 +000082
Matt Arsenaulta48b8662015-04-23 23:34:48 +000083 bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
84 AliasAnalysis *AA) const override;
85
Matt Arsenaultc10853f2014-08-06 00:29:43 +000086 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
87 int64_t &Offset1,
88 int64_t &Offset2) const override;
89
Sanjoy Dasb666ea32015-06-15 18:44:14 +000090 bool getMemOpBaseRegImmOfs(MachineInstr *LdSt, unsigned &BaseReg,
91 unsigned &Offset,
92 const TargetRegisterInfo *TRI) const final;
Matt Arsenault1acc72f2014-07-29 21:34:55 +000093
Matt Arsenault0e75a062014-09-17 17:48:30 +000094 bool shouldClusterLoads(MachineInstr *FirstLdSt,
95 MachineInstr *SecondLdSt,
96 unsigned NumLoads) const final;
97
Craig Topper5656db42014-04-29 07:57:24 +000098 void copyPhysReg(MachineBasicBlock &MBB,
99 MachineBasicBlock::iterator MI, DebugLoc DL,
100 unsigned DestReg, unsigned SrcReg,
101 bool KillSrc) const override;
Tom Stellard75aadc22012-12-11 21:25:42 +0000102
Tom Stellard96468902014-09-24 01:33:17 +0000103 unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB,
104 MachineBasicBlock::iterator MI,
105 RegScavenger *RS,
106 unsigned TmpReg,
107 unsigned Offset,
108 unsigned Size) const;
109
Tom Stellardc149dc02013-11-27 21:23:35 +0000110 void storeRegToStackSlot(MachineBasicBlock &MBB,
111 MachineBasicBlock::iterator MI,
112 unsigned SrcReg, bool isKill, int FrameIndex,
113 const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000114 const TargetRegisterInfo *TRI) const override;
Tom Stellardc149dc02013-11-27 21:23:35 +0000115
116 void loadRegFromStackSlot(MachineBasicBlock &MBB,
117 MachineBasicBlock::iterator MI,
118 unsigned DestReg, int FrameIndex,
119 const TargetRegisterClass *RC,
Craig Topper5656db42014-04-29 07:57:24 +0000120 const TargetRegisterInfo *TRI) const override;
Tom Stellardc149dc02013-11-27 21:23:35 +0000121
Benjamin Kramer8c90fd72014-09-03 11:41:21 +0000122 bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const override;
Tom Stellardeba61072014-05-02 15:41:42 +0000123
Tom Stellardef3b8642015-01-07 19:56:17 +0000124 // \brief Returns an opcode that can be used to move a value to a \p DstRC
125 // register. If there is no hardware instruction that can store to \p
126 // DstRC, then AMDGPU::COPY is returned.
127 unsigned getMovOpcode(const TargetRegisterClass *DstRC) const;
Matt Arsenaultfa242962015-09-24 07:51:23 +0000128
129 LLVM_READONLY
Marek Olsakcfbdba22015-06-26 20:29:10 +0000130 int commuteOpcode(const MachineInstr &MI) const;
Christian Konig3c145802013-03-27 09:12:59 +0000131
Matt Arsenault92befe72014-09-26 17:54:54 +0000132 bool findCommutedOpIndices(MachineInstr *MI,
133 unsigned &SrcOpIdx1,
134 unsigned &SrcOpIdx2) const override;
Christian Konig76edd4f2013-02-26 17:52:29 +0000135
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +0000136 bool areMemAccessesTriviallyDisjoint(
137 MachineInstr *MIa, MachineInstr *MIb,
138 AliasAnalysis *AA = nullptr) const override;
139
Matt Arsenault0325d3d2015-02-21 21:29:07 +0000140 bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
141 unsigned Reg, MachineRegisterInfo *MRI) const final;
142
Tom Stellardf01af292015-05-09 00:56:07 +0000143 unsigned getMachineCSELookAheadLimit() const override { return 500; }
144
Tom Stellarddb5a11f2015-07-13 15:47:57 +0000145 MachineInstr *convertToThreeAddress(MachineFunction::iterator &MBB,
146 MachineBasicBlock::iterator &MI,
147 LiveVariables *LV) const override;
148
Matt Arsenault3add6432015-10-20 04:35:43 +0000149 static bool isSALU(const MachineInstr &MI) {
150 return MI.getDesc().TSFlags & SIInstrFlags::SALU;
151 }
152
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000153 bool isSALU(uint16_t Opcode) const {
154 return get(Opcode).TSFlags & SIInstrFlags::SALU;
155 }
156
Matt Arsenault3add6432015-10-20 04:35:43 +0000157 static bool isVALU(const MachineInstr &MI) {
158 return MI.getDesc().TSFlags & SIInstrFlags::VALU;
159 }
160
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000161 bool isVALU(uint16_t Opcode) const {
162 return get(Opcode).TSFlags & SIInstrFlags::VALU;
163 }
164
Matt Arsenault3add6432015-10-20 04:35:43 +0000165 static bool isSOP1(const MachineInstr &MI) {
166 return MI.getDesc().TSFlags & SIInstrFlags::SOP1;
167 }
168
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000169 bool isSOP1(uint16_t Opcode) const {
170 return get(Opcode).TSFlags & SIInstrFlags::SOP1;
171 }
172
Matt Arsenault3add6432015-10-20 04:35:43 +0000173 static bool isSOP2(const MachineInstr &MI) {
174 return MI.getDesc().TSFlags & SIInstrFlags::SOP2;
175 }
176
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000177 bool isSOP2(uint16_t Opcode) const {
178 return get(Opcode).TSFlags & SIInstrFlags::SOP2;
179 }
180
Matt Arsenault3add6432015-10-20 04:35:43 +0000181 static bool isSOPC(const MachineInstr &MI) {
182 return MI.getDesc().TSFlags & SIInstrFlags::SOPC;
183 }
184
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000185 bool isSOPC(uint16_t Opcode) const {
186 return get(Opcode).TSFlags & SIInstrFlags::SOPC;
187 }
188
Matt Arsenault3add6432015-10-20 04:35:43 +0000189 static bool isSOPK(const MachineInstr &MI) {
190 return MI.getDesc().TSFlags & SIInstrFlags::SOPK;
191 }
192
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000193 bool isSOPK(uint16_t Opcode) const {
194 return get(Opcode).TSFlags & SIInstrFlags::SOPK;
195 }
196
Matt Arsenault3add6432015-10-20 04:35:43 +0000197 static bool isSOPP(const MachineInstr &MI) {
198 return MI.getDesc().TSFlags & SIInstrFlags::SOPP;
199 }
200
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000201 bool isSOPP(uint16_t Opcode) const {
202 return get(Opcode).TSFlags & SIInstrFlags::SOPP;
203 }
204
Matt Arsenault3add6432015-10-20 04:35:43 +0000205 static bool isVOP1(const MachineInstr &MI) {
206 return MI.getDesc().TSFlags & SIInstrFlags::VOP1;
207 }
208
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000209 bool isVOP1(uint16_t Opcode) const {
210 return get(Opcode).TSFlags & SIInstrFlags::VOP1;
211 }
212
Matt Arsenault3add6432015-10-20 04:35:43 +0000213 static bool isVOP2(const MachineInstr &MI) {
214 return MI.getDesc().TSFlags & SIInstrFlags::VOP2;
215 }
216
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000217 bool isVOP2(uint16_t Opcode) const {
218 return get(Opcode).TSFlags & SIInstrFlags::VOP2;
219 }
220
Matt Arsenault3add6432015-10-20 04:35:43 +0000221 static bool isVOP3(const MachineInstr &MI) {
222 return MI.getDesc().TSFlags & SIInstrFlags::VOP3;
223 }
224
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000225 bool isVOP3(uint16_t Opcode) const {
226 return get(Opcode).TSFlags & SIInstrFlags::VOP3;
227 }
228
Matt Arsenault3add6432015-10-20 04:35:43 +0000229 static bool isVOPC(const MachineInstr &MI) {
230 return MI.getDesc().TSFlags & SIInstrFlags::VOPC;
231 }
232
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000233 bool isVOPC(uint16_t Opcode) const {
234 return get(Opcode).TSFlags & SIInstrFlags::VOPC;
235 }
236
Matt Arsenault3add6432015-10-20 04:35:43 +0000237 static bool isMUBUF(const MachineInstr &MI) {
238 return MI.getDesc().TSFlags & SIInstrFlags::MUBUF;
239 }
240
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000241 bool isMUBUF(uint16_t Opcode) const {
242 return get(Opcode).TSFlags & SIInstrFlags::MUBUF;
243 }
244
Matt Arsenault3add6432015-10-20 04:35:43 +0000245 static bool isMTBUF(const MachineInstr &MI) {
246 return MI.getDesc().TSFlags & SIInstrFlags::MTBUF;
247 }
248
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000249 bool isMTBUF(uint16_t Opcode) const {
250 return get(Opcode).TSFlags & SIInstrFlags::MTBUF;
251 }
252
Matt Arsenault3add6432015-10-20 04:35:43 +0000253 static bool isSMRD(const MachineInstr &MI) {
254 return MI.getDesc().TSFlags & SIInstrFlags::SMRD;
255 }
256
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000257 bool isSMRD(uint16_t Opcode) const {
258 return get(Opcode).TSFlags & SIInstrFlags::SMRD;
259 }
260
Matt Arsenault3add6432015-10-20 04:35:43 +0000261 static bool isDS(const MachineInstr &MI) {
262 return MI.getDesc().TSFlags & SIInstrFlags::DS;
263 }
264
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000265 bool isDS(uint16_t Opcode) const {
266 return get(Opcode).TSFlags & SIInstrFlags::DS;
267 }
268
Matt Arsenault3add6432015-10-20 04:35:43 +0000269 static bool isMIMG(const MachineInstr &MI) {
270 return MI.getDesc().TSFlags & SIInstrFlags::MIMG;
271 }
272
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000273 bool isMIMG(uint16_t Opcode) const {
274 return get(Opcode).TSFlags & SIInstrFlags::MIMG;
275 }
276
Matt Arsenault3add6432015-10-20 04:35:43 +0000277 static bool isFLAT(const MachineInstr &MI) {
278 return MI.getDesc().TSFlags & SIInstrFlags::FLAT;
279 }
280
Matt Arsenaultc5f174d2014-12-01 15:52:46 +0000281 bool isFLAT(uint16_t Opcode) const {
282 return get(Opcode).TSFlags & SIInstrFlags::FLAT;
283 }
Matt Arsenaultc09cc3c2014-11-19 00:01:31 +0000284
Matt Arsenault3add6432015-10-20 04:35:43 +0000285 static bool isWQM(const MachineInstr &MI) {
286 return MI.getDesc().TSFlags & SIInstrFlags::WQM;
287 }
288
Michel Danzer494391b2015-02-06 02:51:20 +0000289 bool isWQM(uint16_t Opcode) const {
290 return get(Opcode).TSFlags & SIInstrFlags::WQM;
291 }
292
Matt Arsenault3add6432015-10-20 04:35:43 +0000293 static bool isVGPRSpill(const MachineInstr &MI) {
294 return MI.getDesc().TSFlags & SIInstrFlags::VGPRSpill;
295 }
296
Tom Stellarda77c3f72015-05-12 18:59:17 +0000297 bool isVGPRSpill(uint16_t Opcode) const {
298 return get(Opcode).TSFlags & SIInstrFlags::VGPRSpill;
299 }
300
Matt Arsenaultd7bdcc42014-03-31 19:54:27 +0000301 bool isInlineConstant(const APInt &Imm) const;
Matt Arsenault11a4d672015-02-13 19:05:03 +0000302 bool isInlineConstant(const MachineOperand &MO, unsigned OpSize) const;
303 bool isLiteralConstant(const MachineOperand &MO, unsigned OpSize) const;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000304
Tom Stellardb02094e2014-07-21 15:45:01 +0000305 bool isImmOperandLegal(const MachineInstr *MI, unsigned OpNo,
306 const MachineOperand &MO) const;
307
Tom Stellard86d12eb2014-08-01 00:32:28 +0000308 /// \brief Return true if this 64-bit VALU instruction has a 32-bit encoding.
309 /// This function will return false if you pass it a 32-bit instruction.
310 bool hasVALU32BitEncoding(unsigned Opcode) const;
311
Tom Stellard73ae1cb2014-09-23 21:26:25 +0000312 /// \brief Returns true if this operand uses the constant bus.
313 bool usesConstantBus(const MachineRegisterInfo &MRI,
Matt Arsenault11a4d672015-02-13 19:05:03 +0000314 const MachineOperand &MO,
315 unsigned OpSize) const;
Tom Stellard73ae1cb2014-09-23 21:26:25 +0000316
Tom Stellardb4a313a2014-08-01 00:32:39 +0000317 /// \brief Return true if this instruction has any modifiers.
318 /// e.g. src[012]_mod, omod, clamp.
319 bool hasModifiers(unsigned Opcode) const;
Matt Arsenaultace5b762014-10-17 18:00:43 +0000320
321 bool hasModifiersSet(const MachineInstr &MI,
322 unsigned OpName) const;
323
Craig Topper5656db42014-04-29 07:57:24 +0000324 bool verifyInstruction(const MachineInstr *MI,
325 StringRef &ErrInfo) const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000326
Matt Arsenaultf14032a2013-11-15 22:02:28 +0000327 static unsigned getVALUOp(const MachineInstr &MI);
Matt Arsenaultf35182c2014-03-24 20:08:05 +0000328
Tom Stellard82166022013-11-13 23:36:37 +0000329 bool isSALUOpSupportedOnVALU(const MachineInstr &MI) const;
330
331 /// \brief Return the correct register class for \p OpNo. For target-specific
332 /// instructions, this will return the register class that has been defined
333 /// in tablegen. For generic instructions, like REG_SEQUENCE it will return
334 /// the register class of its machine operand.
335 /// to infer the correct register class base on the other operands.
336 const TargetRegisterClass *getOpRegClass(const MachineInstr &MI,
Matt Arsenault11a4d672015-02-13 19:05:03 +0000337 unsigned OpNo) const;
338
339 /// \brief Return the size in bytes of the operand OpNo on the given
340 // instruction opcode.
341 unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
342 const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
Matt Arsenault657b1cb2015-02-21 21:29:04 +0000343
344 if (OpInfo.RegClass == -1) {
345 // If this is an immediate operand, this must be a 32-bit literal.
346 assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
347 return 4;
348 }
349
Matt Arsenault11a4d672015-02-13 19:05:03 +0000350 return RI.getRegClass(OpInfo.RegClass)->getSize();
351 }
352
353 /// \brief This form should usually be preferred since it handles operands
354 /// with unknown register classes.
355 unsigned getOpSize(const MachineInstr &MI, unsigned OpNo) const {
356 return getOpRegClass(MI, OpNo)->getSize();
357 }
Tom Stellard82166022013-11-13 23:36:37 +0000358
359 /// \returns true if it is legal for the operand at index \p OpNo
360 /// to read a VGPR.
361 bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const;
362
363 /// \brief Legalize the \p OpIndex operand of this instruction by inserting
364 /// a MOV. For example:
365 /// ADD_I32_e32 VGPR0, 15
366 /// to
367 /// MOV VGPR1, 15
368 /// ADD_I32_e32 VGPR0, VGPR1
369 ///
370 /// If the operand being legalized is a register, then a COPY will be used
371 /// instead of MOV.
372 void legalizeOpWithMove(MachineInstr *MI, unsigned OpIdx) const;
373
Tom Stellard0e975cf2014-08-01 00:32:35 +0000374 /// \brief Check if \p MO is a legal operand if it was the \p OpIdx Operand
375 /// for \p MI.
376 bool isOperandLegal(const MachineInstr *MI, unsigned OpIdx,
377 const MachineOperand *MO = nullptr) const;
378
Matt Arsenault856d1922015-12-01 19:57:17 +0000379 /// \brief Check if \p MO would be a valid operand for the given operand
380 /// definition \p OpInfo. Note this does not attempt to validate constant bus
381 /// restrictions (e.g. literal constant usage).
382 bool isLegalVSrcOperand(const MachineRegisterInfo &MRI,
383 const MCOperandInfo &OpInfo,
384 const MachineOperand &MO) const;
385
386 /// \brief Check if \p MO (a register operand) is a legal register for the
387 /// given operand description.
388 bool isLegalRegOperand(const MachineRegisterInfo &MRI,
389 const MCOperandInfo &OpInfo,
390 const MachineOperand &MO) const;
391
392 /// \brief Legalize operands in \p MI by either commuting it or inserting a
393 /// copy of src1.
394 void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr *MI) const;
395
Matt Arsenault6005fcb2015-10-21 21:51:02 +0000396 /// \brief Fix operands in \p MI to satisfy constant bus requirements.
397 void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr *MI) const;
398
Tom Stellard82166022013-11-13 23:36:37 +0000399 /// \brief Legalize all operands in this instruction. This function may
400 /// create new instruction and insert them before \p MI.
401 void legalizeOperands(MachineInstr *MI) const;
402
Tom Stellard745f2ed2014-08-21 20:41:00 +0000403 /// \brief Split an SMRD instruction into two smaller loads of half the
404 // size storing the results in \p Lo and \p Hi.
405 void splitSMRD(MachineInstr *MI, const TargetRegisterClass *HalfRC,
406 unsigned HalfImmOp, unsigned HalfSGPROp,
407 MachineInstr *&Lo, MachineInstr *&Hi) const;
408
Matt Arsenaulte229c0c2015-09-25 22:21:19 +0000409 void moveSMRDToVALU(MachineInstr *MI, MachineRegisterInfo &MRI,
410 SmallVectorImpl<MachineInstr *> &Worklist) const;
Tom Stellard0c354f22014-04-30 15:31:29 +0000411
Tom Stellard82166022013-11-13 23:36:37 +0000412 /// \brief Replace this instruction's opcode with the equivalent VALU
413 /// opcode. This function will also move the users of \p MI to the
414 /// VALU if necessary.
415 void moveToVALU(MachineInstr &MI) const;
416
Craig Topper5656db42014-04-29 07:57:24 +0000417 const TargetRegisterClass *getIndirectAddrRegClass() const override;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +0000418
Tom Stellard81d871d2013-11-13 23:36:50 +0000419 void reserveIndirectRegisters(BitVector &Reserved,
420 const MachineFunction &MF) const;
421
422 void LoadM0(MachineInstr *MoveRel, MachineBasicBlock::iterator I,
423 unsigned SavReg, unsigned IndexReg) const;
Tom Stellardeba61072014-05-02 15:41:42 +0000424
Nicolai Haehnle87323da2015-12-17 16:46:42 +0000425 void insertWaitStates(MachineBasicBlock::iterator MI, int Count) const;
Tom Stellard1aaad692014-07-21 16:55:33 +0000426
427 /// \brief Returns the operand named \p Op. If \p MI does not have an
428 /// operand named \c Op, this function returns nullptr.
Matt Arsenaultf743b832015-09-25 18:09:15 +0000429 LLVM_READONLY
Tom Stellard6407e1e2014-08-01 00:32:33 +0000430 MachineOperand *getNamedOperand(MachineInstr &MI, unsigned OperandName) const;
Matt Arsenaultace5b762014-10-17 18:00:43 +0000431
Matt Arsenaultf743b832015-09-25 18:09:15 +0000432 LLVM_READONLY
Matt Arsenaultace5b762014-10-17 18:00:43 +0000433 const MachineOperand *getNamedOperand(const MachineInstr &MI,
434 unsigned OpName) const {
435 return getNamedOperand(const_cast<MachineInstr &>(MI), OpName);
436 }
Tom Stellard794c8c02014-12-02 17:05:41 +0000437
Matt Arsenaulta40450c2015-11-05 02:46:56 +0000438 /// Get required immediate operand
439 int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const {
440 int Idx = AMDGPU::getNamedOperandIdx(MI.getOpcode(), OpName);
441 return MI.getOperand(Idx).getImm();
442 }
443
Tom Stellard794c8c02014-12-02 17:05:41 +0000444 uint64_t getDefaultRsrcDataFormat() const;
Marek Olsakd1a69a22015-09-29 23:37:32 +0000445 uint64_t getScratchRsrcWords23() const;
Nicolai Haehnle02c32912016-01-13 16:10:10 +0000446
447 bool isLowLatencyInstruction(const MachineInstr *MI) const;
448 bool isHighLatencyInstruction(const MachineInstr *MI) const;
Tom Stellard2ff72622016-01-28 16:04:37 +0000449
450 /// \brief Return the descriptor of the target-specific machine instruction
451 /// that corresponds to the specified pseudo or native opcode.
452 const MCInstrDesc &getMCOpcodeFromPseudo(unsigned Opcode) const {
453 return get(pseudoToMCOpcode(Opcode));
454 }
455
456 ArrayRef<std::pair<int, const char *>>
457 getSerializableTargetIndices() const override;
458
Tom Stellard81d871d2013-11-13 23:36:50 +0000459};
Tom Stellard75aadc22012-12-11 21:25:42 +0000460
Christian Konigf741fbf2013-02-26 17:52:42 +0000461namespace AMDGPU {
Matt Arsenaultfa242962015-09-24 07:51:23 +0000462 LLVM_READONLY
Christian Konigf741fbf2013-02-26 17:52:42 +0000463 int getVOPe64(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000464
465 LLVM_READONLY
Tom Stellard1aaad692014-07-21 16:55:33 +0000466 int getVOPe32(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000467
468 LLVM_READONLY
Christian Konig3c145802013-03-27 09:12:59 +0000469 int getCommuteRev(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000470
471 LLVM_READONLY
Christian Konig3c145802013-03-27 09:12:59 +0000472 int getCommuteOrig(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000473
474 LLVM_READONLY
Tom Stellard155bbb72014-08-11 22:18:17 +0000475 int getAddr64Inst(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000476
477 LLVM_READONLY
Matt Arsenault9903ccf2014-09-08 15:07:27 +0000478 int getAtomicRetOp(uint16_t Opcode);
Matt Arsenaultfa242962015-09-24 07:51:23 +0000479
480 LLVM_READONLY
Matt Arsenault9903ccf2014-09-08 15:07:27 +0000481 int getAtomicNoRetOp(uint16_t Opcode);
Christian Konigf741fbf2013-02-26 17:52:42 +0000482
Tom Stellard15834092014-03-21 15:51:57 +0000483 const uint64_t RSRC_DATA_FORMAT = 0xf00000000000LL;
Tom Stellardb02094e2014-07-21 15:45:01 +0000484 const uint64_t RSRC_TID_ENABLE = 1LL << 55;
Tom Stellard15834092014-03-21 15:51:57 +0000485
Christian Konigf741fbf2013-02-26 17:52:42 +0000486} // End namespace AMDGPU
487
Tom Stellardec2e43c2014-09-22 15:35:29 +0000488namespace SI {
489namespace KernelInputOffsets {
490
491/// Offsets in bytes from the start of the input buffer
492enum Offsets {
493 NGROUPS_X = 0,
494 NGROUPS_Y = 4,
495 NGROUPS_Z = 8,
496 GLOBAL_SIZE_X = 12,
497 GLOBAL_SIZE_Y = 16,
498 GLOBAL_SIZE_Z = 20,
499 LOCAL_SIZE_X = 24,
500 LOCAL_SIZE_Y = 28,
501 LOCAL_SIZE_Z = 32
502};
503
504} // End namespace KernelInputOffsets
505} // End namespace SI
506
Tom Stellard75aadc22012-12-11 21:25:42 +0000507} // End namespace llvm
508
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000509#endif