xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/DSInstructions.td (revision 77013d11e6483b970af25e13c9b892075742f7e5)
1//===-- DSInstructions.td - DS Instruction Definitions --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9class DS_Pseudo <string opName, dag outs, dag ins, string asmOps, list<dag> pattern=[]> :
10  InstSI <outs, ins, "", pattern>,
11  SIMCInstr <opName, SIEncodingFamily.NONE> {
12
13  let LGKM_CNT = 1;
14  let DS = 1;
15  let Size = 8;
16  let UseNamedOperandTable = 1;
17
18  // Most instruction load and store data, so set this as the default.
19  let mayLoad = 1;
20  let mayStore = 1;
21  let maybeAtomic = 1;
22
23  let hasSideEffects = 0;
24  let SchedRW = [WriteLDS];
25
26  let isPseudo = 1;
27  let isCodeGenOnly = 1;
28
29  let AsmMatchConverter = "cvtDS";
30
31  string Mnemonic = opName;
32  string AsmOperands = asmOps;
33
34  // Well these bits a kind of hack because it would be more natural
35  // to test "outs" and "ins" dags for the presence of particular operands
36  bits<1> has_vdst = 1;
37  bits<1> has_addr = 1;
38  bits<1> has_data0 = 1;
39  bits<1> has_data1 = 1;
40
41  bits<1> has_gws_data0 = 0; // data0 is encoded as addr
42
43  bits<1> has_offset  = 1; // has "offset" that should be split to offset0,1
44  bits<1> has_offset0 = 1;
45  bits<1> has_offset1 = 1;
46
47  bits<1> has_gds = 1;
48  bits<1> gdsValue = 0; // if has_gds == 0 set gds to this value
49
50  bits<1> has_m0_read = 1;
51
52  let Uses = !if(has_m0_read, [M0, EXEC], [EXEC]);
53}
54
55class DS_Real <DS_Pseudo ds> :
56  InstSI <ds.OutOperandList, ds.InOperandList, ds.Mnemonic # ds.AsmOperands, []>,
57  Enc64 {
58
59  let isPseudo = 0;
60  let isCodeGenOnly = 0;
61  let DS = 1;
62  let UseNamedOperandTable = 1;
63
64  // copy relevant pseudo op flags
65  let SubtargetPredicate = ds.SubtargetPredicate;
66  let OtherPredicates = ds.OtherPredicates;
67  let AsmMatchConverter  = ds.AsmMatchConverter;
68
69  // encoding fields
70  bits<8> vdst;
71  bits<1> gds;
72  bits<8> addr;
73  bits<8> data0;
74  bits<8> data1;
75  bits<8> offset0;
76  bits<8> offset1;
77
78  bits<16> offset;
79  let offset0 = !if(ds.has_offset, offset{7-0}, ?);
80  let offset1 = !if(ds.has_offset, offset{15-8}, ?);
81}
82
83
84// DS Pseudo instructions
85
86class DS_0A1D_NORET<string opName, RegisterClass rc = VGPR_32>
87: DS_Pseudo<opName,
88  (outs),
89  (ins rc:$data0, offset:$offset, gds:$gds),
90  " $data0$offset$gds"> {
91
92  let has_addr = 0;
93  let has_data1 = 0;
94  let has_vdst = 0;
95}
96
97class DS_1A1D_NORET<string opName, RegisterClass rc = VGPR_32>
98: DS_Pseudo<opName,
99  (outs),
100  (ins VGPR_32:$addr, rc:$data0, offset:$offset, gds:$gds),
101  " $addr, $data0$offset$gds"> {
102
103  let has_data1 = 0;
104  let has_vdst = 0;
105}
106
107multiclass DS_1A1D_NORET_mc<string opName, RegisterClass rc = VGPR_32> {
108  def "" : DS_1A1D_NORET<opName, rc>,
109           AtomicNoRet<opName, 0>;
110
111  let has_m0_read = 0 in {
112    def _gfx9 : DS_1A1D_NORET<opName, rc>,
113                AtomicNoRet<opName#"_gfx9", 0>;
114  }
115}
116
117class DS_1A2D_NORET<string opName, RegisterClass rc = VGPR_32>
118: DS_Pseudo<opName,
119  (outs),
120  (ins VGPR_32:$addr, rc:$data0, rc:$data1, offset:$offset, gds:$gds),
121  " $addr, $data0, $data1$offset$gds"> {
122
123  let has_vdst = 0;
124}
125
126multiclass DS_1A2D_NORET_mc<string opName, RegisterClass rc = VGPR_32> {
127  def "" : DS_1A2D_NORET<opName, rc>,
128           AtomicNoRet<opName, 0>;
129
130  let has_m0_read = 0 in {
131    def _gfx9 : DS_1A2D_NORET<opName, rc>,
132                AtomicNoRet<opName#"_gfx9", 0>;
133  }
134}
135
136class DS_1A2D_Off8_NORET <string opName, RegisterClass rc = VGPR_32>
137: DS_Pseudo<opName,
138  (outs),
139  (ins VGPR_32:$addr, rc:$data0, rc:$data1,
140       offset0:$offset0, offset1:$offset1, gds:$gds),
141  " $addr, $data0, $data1$offset0$offset1$gds"> {
142
143  let has_vdst = 0;
144  let has_offset = 0;
145  let AsmMatchConverter = "cvtDSOffset01";
146}
147
148multiclass DS_1A2D_Off8_NORET_mc <string opName, RegisterClass rc = VGPR_32> {
149  def "" : DS_1A2D_Off8_NORET<opName, rc>;
150
151  let has_m0_read = 0 in {
152    def _gfx9 : DS_1A2D_Off8_NORET<opName, rc>;
153  }
154}
155
156class DS_1A1D_RET <string opName, RegisterClass rc = VGPR_32>
157: DS_Pseudo<opName,
158  (outs rc:$vdst),
159  (ins VGPR_32:$addr, rc:$data0, offset:$offset, gds:$gds),
160  " $vdst, $addr, $data0$offset$gds"> {
161
162  let hasPostISelHook = 1;
163  let has_data1 = 0;
164}
165
166multiclass DS_1A1D_RET_mc <string opName, RegisterClass rc = VGPR_32,
167                           string NoRetOp = ""> {
168  def "" : DS_1A1D_RET<opName, rc>,
169    AtomicNoRet<NoRetOp, !ne(NoRetOp, "")>;
170
171  let has_m0_read = 0 in {
172    def _gfx9 : DS_1A1D_RET<opName, rc>,
173      AtomicNoRet<!if(!eq(NoRetOp, ""), "", NoRetOp#"_gfx9"),
174                  !ne(NoRetOp, "")>;
175  }
176}
177
178class DS_1A2D_RET<string opName,
179                  RegisterClass rc = VGPR_32,
180                  RegisterClass src = rc>
181: DS_Pseudo<opName,
182  (outs rc:$vdst),
183  (ins VGPR_32:$addr, src:$data0, src:$data1, offset:$offset, gds:$gds),
184  " $vdst, $addr, $data0, $data1$offset$gds"> {
185
186  let hasPostISelHook = 1;
187}
188
189multiclass DS_1A2D_RET_mc<string opName,
190                          RegisterClass rc = VGPR_32,
191                          string NoRetOp = "",
192                          RegisterClass src = rc> {
193  def "" : DS_1A2D_RET<opName, rc, src>,
194    AtomicNoRet<NoRetOp, !ne(NoRetOp, "")>;
195
196  let has_m0_read = 0 in {
197    def _gfx9 : DS_1A2D_RET<opName, rc, src>,
198      AtomicNoRet<NoRetOp#"_gfx9", !ne(NoRetOp, "")>;
199  }
200}
201
202class DS_1A2D_Off8_RET<string opName,
203                       RegisterClass rc = VGPR_32,
204                       RegisterClass src = rc>
205: DS_Pseudo<opName,
206  (outs rc:$vdst),
207  (ins VGPR_32:$addr, src:$data0, src:$data1, offset0:$offset0, offset1:$offset1, gds:$gds),
208  " $vdst, $addr, $data0, $data1$offset0$offset1$gds"> {
209
210  let has_offset = 0;
211  let AsmMatchConverter = "cvtDSOffset01";
212
213  let hasPostISelHook = 1;
214}
215
216multiclass DS_1A2D_Off8_RET_mc<string opName,
217                               RegisterClass rc = VGPR_32,
218                               RegisterClass src = rc> {
219  def "" : DS_1A2D_Off8_RET<opName, rc, src>;
220
221  let has_m0_read = 0 in {
222    def _gfx9 : DS_1A2D_Off8_RET<opName, rc, src>;
223  }
224}
225
226
227class DS_1A_RET<string opName, RegisterClass rc = VGPR_32, bit HasTiedOutput = 0, Operand ofs = offset>
228: DS_Pseudo<opName,
229  (outs rc:$vdst),
230  !if(HasTiedOutput,
231    (ins VGPR_32:$addr, ofs:$offset, gds:$gds, rc:$vdst_in),
232    (ins VGPR_32:$addr, ofs:$offset, gds:$gds)),
233  " $vdst, $addr$offset$gds"> {
234  let Constraints = !if(HasTiedOutput, "$vdst = $vdst_in", "");
235  let DisableEncoding = !if(HasTiedOutput, "$vdst_in", "");
236  let has_data0 = 0;
237  let has_data1 = 0;
238}
239
240multiclass DS_1A_RET_mc<string opName, RegisterClass rc = VGPR_32, bit HasTiedOutput = 0, Operand ofs = offset> {
241  def "" : DS_1A_RET<opName, rc, HasTiedOutput, ofs>;
242
243  let has_m0_read = 0 in {
244    def _gfx9 : DS_1A_RET<opName, rc, HasTiedOutput, ofs>;
245  }
246}
247
248class DS_1A_RET_Tied<string opName, RegisterClass rc = VGPR_32> :
249  DS_1A_RET<opName, rc, 1>;
250
251class DS_1A_Off8_RET <string opName, RegisterClass rc = VGPR_32>
252: DS_Pseudo<opName,
253  (outs rc:$vdst),
254  (ins VGPR_32:$addr, offset0:$offset0, offset1:$offset1, gds:$gds),
255  " $vdst, $addr$offset0$offset1$gds"> {
256
257  let has_offset = 0;
258  let has_data0 = 0;
259  let has_data1 = 0;
260  let AsmMatchConverter = "cvtDSOffset01";
261}
262
263multiclass DS_1A_Off8_RET_mc <string opName, RegisterClass rc = VGPR_32> {
264  def "" : DS_1A_Off8_RET<opName, rc>;
265
266  let has_m0_read = 0 in {
267    def _gfx9 : DS_1A_Off8_RET<opName, rc>;
268  }
269}
270
271class DS_1A_RET_GDS <string opName> : DS_Pseudo<opName,
272  (outs VGPR_32:$vdst),
273  (ins VGPR_32:$addr, offset:$offset),
274  " $vdst, $addr$offset gds"> {
275
276  let has_data0 = 0;
277  let has_data1 = 0;
278  let has_gds = 0;
279  let gdsValue = 1;
280  let AsmMatchConverter = "cvtDSGds";
281}
282
283class DS_0A_RET <string opName> : DS_Pseudo<opName,
284  (outs VGPR_32:$vdst),
285  (ins offset:$offset, gds:$gds),
286  " $vdst$offset$gds"> {
287
288  let mayLoad = 1;
289  let mayStore = 1;
290
291  let has_addr = 0;
292  let has_data0 = 0;
293  let has_data1 = 0;
294}
295
296class DS_1A <string opName> : DS_Pseudo<opName,
297  (outs),
298  (ins VGPR_32:$addr, offset:$offset, gds:$gds),
299  " $addr$offset$gds"> {
300
301  let mayLoad = 1;
302  let mayStore = 1;
303
304  let has_vdst = 0;
305  let has_data0 = 0;
306  let has_data1 = 0;
307}
308
309multiclass DS_1A_mc <string opName> {
310  def "" : DS_1A<opName>;
311
312  let has_m0_read = 0 in {
313    def _gfx9 : DS_1A<opName>;
314  }
315}
316
317
318class DS_GWS <string opName, dag ins, string asmOps>
319: DS_Pseudo<opName, (outs), ins, asmOps> {
320
321  let has_vdst  = 0;
322  let has_addr  = 0;
323  let has_data0 = 0;
324  let has_data1 = 0;
325
326  let has_gds   = 0;
327  let gdsValue  = 1;
328  let AsmMatchConverter = "cvtDSGds";
329}
330
331class DS_GWS_0D <string opName>
332: DS_GWS<opName,
333  (ins offset:$offset), "$offset gds"> {
334  let hasSideEffects = 1;
335}
336
337class DS_GWS_1D <string opName>
338: DS_GWS<opName,
339  (ins VGPR_32:$data0, offset:$offset), " $data0$offset gds"> {
340
341  let has_gws_data0 = 1;
342  let hasSideEffects = 1;
343}
344
345class DS_VOID <string opName> : DS_Pseudo<opName,
346  (outs), (ins), ""> {
347  let mayLoad = 0;
348  let mayStore = 0;
349  let hasSideEffects = 1;
350  let UseNamedOperandTable = 0;
351  let AsmMatchConverter = "";
352
353  let has_vdst = 0;
354  let has_addr = 0;
355  let has_data0 = 0;
356  let has_data1 = 0;
357  let has_offset = 0;
358  let has_offset0 = 0;
359  let has_offset1 = 0;
360  let has_gds = 0;
361}
362
363class DS_1A1D_PERMUTE <string opName, SDPatternOperator node = null_frag>
364: DS_Pseudo<opName,
365  (outs VGPR_32:$vdst),
366  (ins VGPR_32:$addr, VGPR_32:$data0, offset:$offset),
367  " $vdst, $addr, $data0$offset",
368  [(set i32:$vdst,
369   (node (DS1Addr1Offset i32:$addr, i16:$offset), i32:$data0))] > {
370
371  let mayLoad = 0;
372  let mayStore = 0;
373  let isConvergent = 1;
374
375  let has_data1 = 0;
376  let has_gds = 0;
377}
378
379defm DS_ADD_U32       : DS_1A1D_NORET_mc<"ds_add_u32">;
380defm DS_SUB_U32       : DS_1A1D_NORET_mc<"ds_sub_u32">;
381defm DS_RSUB_U32      : DS_1A1D_NORET_mc<"ds_rsub_u32">;
382defm DS_INC_U32       : DS_1A1D_NORET_mc<"ds_inc_u32">;
383defm DS_DEC_U32       : DS_1A1D_NORET_mc<"ds_dec_u32">;
384defm DS_MIN_I32       : DS_1A1D_NORET_mc<"ds_min_i32">;
385defm DS_MAX_I32       : DS_1A1D_NORET_mc<"ds_max_i32">;
386defm DS_MIN_U32       : DS_1A1D_NORET_mc<"ds_min_u32">;
387defm DS_MAX_U32       : DS_1A1D_NORET_mc<"ds_max_u32">;
388defm DS_AND_B32       : DS_1A1D_NORET_mc<"ds_and_b32">;
389defm DS_OR_B32        : DS_1A1D_NORET_mc<"ds_or_b32">;
390defm DS_XOR_B32       : DS_1A1D_NORET_mc<"ds_xor_b32">;
391
392let SubtargetPredicate = HasLDSFPAtomics in {
393defm DS_ADD_F32       : DS_1A1D_NORET_mc<"ds_add_f32">;
394}
395
396// FIXME: Are these really present pre-gfx8?
397defm DS_MIN_F32       : DS_1A1D_NORET_mc<"ds_min_f32">;
398defm DS_MAX_F32       : DS_1A1D_NORET_mc<"ds_max_f32">;
399
400let mayLoad = 0 in {
401defm DS_WRITE_B8      : DS_1A1D_NORET_mc<"ds_write_b8">;
402defm DS_WRITE_B16     : DS_1A1D_NORET_mc<"ds_write_b16">;
403defm DS_WRITE_B32     : DS_1A1D_NORET_mc<"ds_write_b32">;
404defm DS_WRITE2_B32    : DS_1A2D_Off8_NORET_mc<"ds_write2_b32">;
405defm DS_WRITE2ST64_B32: DS_1A2D_Off8_NORET_mc<"ds_write2st64_b32">;
406
407
408let has_m0_read = 0 in {
409
410let SubtargetPredicate = HasD16LoadStore in {
411def DS_WRITE_B8_D16_HI  : DS_1A1D_NORET<"ds_write_b8_d16_hi">;
412def DS_WRITE_B16_D16_HI : DS_1A1D_NORET<"ds_write_b16_d16_hi">;
413}
414
415} // End has_m0_read = 0
416
417let SubtargetPredicate = HasDSAddTid in {
418def DS_WRITE_ADDTID_B32 : DS_0A1D_NORET<"ds_write_addtid_b32">;
419}
420
421} // End mayLoad = 0
422
423defm DS_MSKOR_B32     : DS_1A2D_NORET_mc<"ds_mskor_b32">;
424defm DS_CMPST_B32     : DS_1A2D_NORET_mc<"ds_cmpst_b32">;
425defm DS_CMPST_F32     : DS_1A2D_NORET_mc<"ds_cmpst_f32">;
426
427defm DS_ADD_U64       : DS_1A1D_NORET_mc<"ds_add_u64", VReg_64>;
428defm DS_SUB_U64       : DS_1A1D_NORET_mc<"ds_sub_u64", VReg_64>;
429defm DS_RSUB_U64      : DS_1A1D_NORET_mc<"ds_rsub_u64", VReg_64>;
430defm DS_INC_U64       : DS_1A1D_NORET_mc<"ds_inc_u64", VReg_64>;
431defm DS_DEC_U64       : DS_1A1D_NORET_mc<"ds_dec_u64", VReg_64>;
432defm DS_MIN_I64       : DS_1A1D_NORET_mc<"ds_min_i64", VReg_64>;
433defm DS_MAX_I64       : DS_1A1D_NORET_mc<"ds_max_i64", VReg_64>;
434defm DS_MIN_U64       : DS_1A1D_NORET_mc<"ds_min_u64", VReg_64>;
435defm DS_MAX_U64       : DS_1A1D_NORET_mc<"ds_max_u64", VReg_64>;
436defm DS_AND_B64       : DS_1A1D_NORET_mc<"ds_and_b64", VReg_64>;
437defm DS_OR_B64        : DS_1A1D_NORET_mc<"ds_or_b64", VReg_64>;
438defm DS_XOR_B64       : DS_1A1D_NORET_mc<"ds_xor_b64", VReg_64>;
439defm DS_MSKOR_B64     : DS_1A2D_NORET_mc<"ds_mskor_b64", VReg_64>;
440let mayLoad = 0 in {
441defm DS_WRITE_B64     : DS_1A1D_NORET_mc<"ds_write_b64", VReg_64>;
442defm DS_WRITE2_B64    : DS_1A2D_Off8_NORET_mc<"ds_write2_b64", VReg_64>;
443defm DS_WRITE2ST64_B64: DS_1A2D_Off8_NORET_mc<"ds_write2st64_b64", VReg_64>;
444}
445defm DS_CMPST_B64     : DS_1A2D_NORET_mc<"ds_cmpst_b64", VReg_64>;
446defm DS_CMPST_F64     : DS_1A2D_NORET_mc<"ds_cmpst_f64", VReg_64>;
447defm DS_MIN_F64       : DS_1A1D_NORET_mc<"ds_min_f64", VReg_64>;
448defm DS_MAX_F64       : DS_1A1D_NORET_mc<"ds_max_f64", VReg_64>;
449
450defm DS_ADD_RTN_U32   : DS_1A1D_RET_mc<"ds_add_rtn_u32", VGPR_32, "ds_add_u32">;
451
452let SubtargetPredicate = HasLDSFPAtomics in {
453defm DS_ADD_RTN_F32   : DS_1A1D_RET_mc<"ds_add_rtn_f32", VGPR_32, "ds_add_f32">;
454}
455defm DS_SUB_RTN_U32   : DS_1A1D_RET_mc<"ds_sub_rtn_u32", VGPR_32, "ds_sub_u32">;
456defm DS_RSUB_RTN_U32  : DS_1A1D_RET_mc<"ds_rsub_rtn_u32", VGPR_32, "ds_rsub_u32">;
457defm DS_INC_RTN_U32   : DS_1A1D_RET_mc<"ds_inc_rtn_u32", VGPR_32, "ds_inc_u32">;
458defm DS_DEC_RTN_U32   : DS_1A1D_RET_mc<"ds_dec_rtn_u32", VGPR_32, "ds_dec_u32">;
459defm DS_MIN_RTN_I32   : DS_1A1D_RET_mc<"ds_min_rtn_i32", VGPR_32, "ds_min_i32">;
460defm DS_MAX_RTN_I32   : DS_1A1D_RET_mc<"ds_max_rtn_i32", VGPR_32, "ds_max_i32">;
461defm DS_MIN_RTN_U32   : DS_1A1D_RET_mc<"ds_min_rtn_u32", VGPR_32, "ds_min_u32">;
462defm DS_MAX_RTN_U32   : DS_1A1D_RET_mc<"ds_max_rtn_u32", VGPR_32, "ds_max_u32">;
463defm DS_AND_RTN_B32   : DS_1A1D_RET_mc<"ds_and_rtn_b32", VGPR_32, "ds_and_b32">;
464defm DS_OR_RTN_B32    : DS_1A1D_RET_mc<"ds_or_rtn_b32", VGPR_32, "ds_or_b32">;
465defm DS_XOR_RTN_B32   : DS_1A1D_RET_mc<"ds_xor_rtn_b32", VGPR_32, "ds_xor_b32">;
466defm DS_MSKOR_RTN_B32 : DS_1A2D_RET_mc<"ds_mskor_rtn_b32", VGPR_32, "ds_mskor_b32">;
467defm DS_CMPST_RTN_B32 : DS_1A2D_RET_mc<"ds_cmpst_rtn_b32", VGPR_32, "ds_cmpst_b32">;
468defm DS_CMPST_RTN_F32 : DS_1A2D_RET_mc<"ds_cmpst_rtn_f32", VGPR_32, "ds_cmpst_f32">;
469defm DS_MIN_RTN_F32   : DS_1A1D_RET_mc<"ds_min_rtn_f32", VGPR_32, "ds_min_f32">;
470defm DS_MAX_RTN_F32   : DS_1A1D_RET_mc<"ds_max_rtn_f32", VGPR_32, "ds_max_f32">;
471
472defm DS_WRXCHG_RTN_B32 : DS_1A1D_RET_mc<"ds_wrxchg_rtn_b32">;
473defm DS_WRXCHG2_RTN_B32 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2_rtn_b32", VReg_64, VGPR_32>;
474defm DS_WRXCHG2ST64_RTN_B32 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2st64_rtn_b32", VReg_64, VGPR_32>;
475
476defm DS_ADD_RTN_U64  : DS_1A1D_RET_mc<"ds_add_rtn_u64", VReg_64, "ds_add_u64">;
477defm DS_SUB_RTN_U64  : DS_1A1D_RET_mc<"ds_sub_rtn_u64", VReg_64, "ds_sub_u64">;
478defm DS_RSUB_RTN_U64  : DS_1A1D_RET_mc<"ds_rsub_rtn_u64", VReg_64, "ds_rsub_u64">;
479defm DS_INC_RTN_U64   : DS_1A1D_RET_mc<"ds_inc_rtn_u64", VReg_64, "ds_inc_u64">;
480defm DS_DEC_RTN_U64   : DS_1A1D_RET_mc<"ds_dec_rtn_u64", VReg_64, "ds_dec_u64">;
481defm DS_MIN_RTN_I64    : DS_1A1D_RET_mc<"ds_min_rtn_i64", VReg_64, "ds_min_i64">;
482defm DS_MAX_RTN_I64    : DS_1A1D_RET_mc<"ds_max_rtn_i64", VReg_64, "ds_max_i64">;
483defm DS_MIN_RTN_U64   : DS_1A1D_RET_mc<"ds_min_rtn_u64", VReg_64, "ds_min_u64">;
484defm DS_MAX_RTN_U64   : DS_1A1D_RET_mc<"ds_max_rtn_u64", VReg_64, "ds_max_u64">;
485defm DS_AND_RTN_B64    : DS_1A1D_RET_mc<"ds_and_rtn_b64", VReg_64, "ds_and_b64">;
486defm DS_OR_RTN_B64     : DS_1A1D_RET_mc<"ds_or_rtn_b64", VReg_64, "ds_or_b64">;
487defm DS_XOR_RTN_B64    : DS_1A1D_RET_mc<"ds_xor_rtn_b64", VReg_64, "ds_xor_b64">;
488defm DS_MSKOR_RTN_B64  : DS_1A2D_RET_mc<"ds_mskor_rtn_b64", VReg_64, "ds_mskor_b64">;
489defm DS_CMPST_RTN_B64  : DS_1A2D_RET_mc<"ds_cmpst_rtn_b64", VReg_64, "ds_cmpst_b64">;
490defm DS_CMPST_RTN_F64  : DS_1A2D_RET_mc<"ds_cmpst_rtn_f64", VReg_64, "ds_cmpst_f64">;
491defm DS_MIN_RTN_F64    : DS_1A1D_RET_mc<"ds_min_rtn_f64", VReg_64, "ds_min_f64">;
492defm DS_MAX_RTN_F64    : DS_1A1D_RET_mc<"ds_max_rtn_f64", VReg_64, "ds_max_f64">;
493
494defm DS_WRXCHG_RTN_B64 : DS_1A1D_RET_mc<"ds_wrxchg_rtn_b64", VReg_64>;
495defm DS_WRXCHG2_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2_rtn_b64", VReg_128, VReg_64>;
496defm DS_WRXCHG2ST64_RTN_B64 : DS_1A2D_Off8_RET_mc<"ds_wrxchg2st64_rtn_b64", VReg_128, VReg_64>;
497
498let isConvergent = 1, usesCustomInserter = 1 in {
499def DS_GWS_INIT       : DS_GWS_1D<"ds_gws_init"> {
500  let mayLoad = 0;
501}
502def DS_GWS_SEMA_V     : DS_GWS_0D<"ds_gws_sema_v">;
503def DS_GWS_SEMA_BR    : DS_GWS_1D<"ds_gws_sema_br">;
504def DS_GWS_SEMA_P     : DS_GWS_0D<"ds_gws_sema_p">;
505def DS_GWS_BARRIER    : DS_GWS_1D<"ds_gws_barrier">;
506}
507
508let SubtargetPredicate = HasDsSrc2Insts in {
509def DS_ADD_SRC2_U32   : DS_1A<"ds_add_src2_u32">;
510def DS_SUB_SRC2_U32   : DS_1A<"ds_sub_src2_u32">;
511def DS_RSUB_SRC2_U32  : DS_1A<"ds_rsub_src2_u32">;
512def DS_INC_SRC2_U32   : DS_1A<"ds_inc_src2_u32">;
513def DS_DEC_SRC2_U32   : DS_1A<"ds_dec_src2_u32">;
514def DS_MIN_SRC2_I32   : DS_1A<"ds_min_src2_i32">;
515def DS_MAX_SRC2_I32   : DS_1A<"ds_max_src2_i32">;
516def DS_MIN_SRC2_U32   : DS_1A<"ds_min_src2_u32">;
517def DS_MAX_SRC2_U32   : DS_1A<"ds_max_src2_u32">;
518def DS_AND_SRC2_B32   : DS_1A<"ds_and_src2_b32">;
519def DS_OR_SRC2_B32    : DS_1A<"ds_or_src2_b32">;
520def DS_XOR_SRC2_B32   : DS_1A<"ds_xor_src2_b32">;
521def DS_MIN_SRC2_F32   : DS_1A<"ds_min_src2_f32">;
522def DS_MAX_SRC2_F32   : DS_1A<"ds_max_src2_f32">;
523
524def DS_ADD_SRC2_U64   : DS_1A<"ds_add_src2_u64">;
525def DS_SUB_SRC2_U64   : DS_1A<"ds_sub_src2_u64">;
526def DS_RSUB_SRC2_U64  : DS_1A<"ds_rsub_src2_u64">;
527def DS_INC_SRC2_U64   : DS_1A<"ds_inc_src2_u64">;
528def DS_DEC_SRC2_U64   : DS_1A<"ds_dec_src2_u64">;
529def DS_MIN_SRC2_I64   : DS_1A<"ds_min_src2_i64">;
530def DS_MAX_SRC2_I64   : DS_1A<"ds_max_src2_i64">;
531def DS_MIN_SRC2_U64   : DS_1A<"ds_min_src2_u64">;
532def DS_MAX_SRC2_U64   : DS_1A<"ds_max_src2_u64">;
533def DS_AND_SRC2_B64   : DS_1A<"ds_and_src2_b64">;
534def DS_OR_SRC2_B64    : DS_1A<"ds_or_src2_b64">;
535def DS_XOR_SRC2_B64   : DS_1A<"ds_xor_src2_b64">;
536def DS_MIN_SRC2_F64   : DS_1A<"ds_min_src2_f64">;
537def DS_MAX_SRC2_F64   : DS_1A<"ds_max_src2_f64">;
538
539def DS_WRITE_SRC2_B32 : DS_1A<"ds_write_src2_b32">;
540def DS_WRITE_SRC2_B64 : DS_1A<"ds_write_src2_b64">;
541} // End SubtargetPredicate = HasDsSrc2Insts
542
543let Uses = [EXEC], mayLoad = 0, mayStore = 0, isConvergent = 1 in {
544def DS_SWIZZLE_B32 : DS_1A_RET <"ds_swizzle_b32", VGPR_32, 0, SwizzleImm>;
545}
546
547let mayStore = 0 in {
548defm DS_READ_I8      : DS_1A_RET_mc<"ds_read_i8">;
549defm DS_READ_U8      : DS_1A_RET_mc<"ds_read_u8">;
550defm DS_READ_I16     : DS_1A_RET_mc<"ds_read_i16">;
551defm DS_READ_U16     : DS_1A_RET_mc<"ds_read_u16">;
552defm DS_READ_B32     : DS_1A_RET_mc<"ds_read_b32">;
553defm DS_READ_B64     : DS_1A_RET_mc<"ds_read_b64", VReg_64>;
554
555defm DS_READ2_B32    : DS_1A_Off8_RET_mc<"ds_read2_b32", VReg_64>;
556defm DS_READ2ST64_B32: DS_1A_Off8_RET_mc<"ds_read2st64_b32", VReg_64>;
557
558defm DS_READ2_B64    : DS_1A_Off8_RET_mc<"ds_read2_b64", VReg_128>;
559defm DS_READ2ST64_B64: DS_1A_Off8_RET_mc<"ds_read2st64_b64", VReg_128>;
560
561let has_m0_read = 0 in {
562let SubtargetPredicate = HasD16LoadStore in {
563def DS_READ_U8_D16     : DS_1A_RET_Tied<"ds_read_u8_d16">;
564def DS_READ_U8_D16_HI  : DS_1A_RET_Tied<"ds_read_u8_d16_hi">;
565def DS_READ_I8_D16     : DS_1A_RET_Tied<"ds_read_i8_d16">;
566def DS_READ_I8_D16_HI  : DS_1A_RET_Tied<"ds_read_i8_d16_hi">;
567def DS_READ_U16_D16    : DS_1A_RET_Tied<"ds_read_u16_d16">;
568def DS_READ_U16_D16_HI : DS_1A_RET_Tied<"ds_read_u16_d16_hi">;
569}
570} // End has_m0_read = 0
571
572let SubtargetPredicate = HasDSAddTid in {
573def DS_READ_ADDTID_B32 : DS_0A_RET<"ds_read_addtid_b32">;
574}
575
576} // End mayStore = 0
577
578def DS_CONSUME       : DS_0A_RET<"ds_consume">;
579def DS_APPEND        : DS_0A_RET<"ds_append">;
580def DS_ORDERED_COUNT : DS_1A_RET_GDS<"ds_ordered_count">;
581
582//===----------------------------------------------------------------------===//
583// Instruction definitions for CI and newer.
584//===----------------------------------------------------------------------===//
585
586let SubtargetPredicate = isGFX7Plus in {
587
588defm DS_WRAP_RTN_B32 : DS_1A2D_RET_mc<"ds_wrap_rtn_b32", VGPR_32>;
589defm DS_CONDXCHG32_RTN_B64 : DS_1A1D_RET_mc<"ds_condxchg32_rtn_b64", VReg_64>;
590
591let isConvergent = 1, usesCustomInserter = 1 in {
592def DS_GWS_SEMA_RELEASE_ALL : DS_GWS_0D<"ds_gws_sema_release_all">;
593}
594
595let mayStore = 0 in {
596defm DS_READ_B96 : DS_1A_RET_mc<"ds_read_b96", VReg_96>;
597defm DS_READ_B128: DS_1A_RET_mc<"ds_read_b128", VReg_128>;
598} // End mayStore = 0
599
600let mayLoad = 0 in {
601defm DS_WRITE_B96 : DS_1A1D_NORET_mc<"ds_write_b96", VReg_96>;
602defm DS_WRITE_B128 : DS_1A1D_NORET_mc<"ds_write_b128", VReg_128>;
603} // End mayLoad = 0
604
605def DS_NOP : DS_VOID<"ds_nop">;
606
607} // let SubtargetPredicate = isGFX7Plus
608
609//===----------------------------------------------------------------------===//
610// Instruction definitions for VI and newer.
611//===----------------------------------------------------------------------===//
612
613let SubtargetPredicate = isGFX8Plus in {
614
615let Uses = [EXEC] in {
616def DS_PERMUTE_B32  : DS_1A1D_PERMUTE <"ds_permute_b32",
617                                       int_amdgcn_ds_permute>;
618def DS_BPERMUTE_B32 : DS_1A1D_PERMUTE <"ds_bpermute_b32",
619                                       int_amdgcn_ds_bpermute>;
620}
621
622} // let SubtargetPredicate = isGFX8Plus
623
624let SubtargetPredicate = HasLDSFPAtomics, OtherPredicates = [HasDsSrc2Insts] in {
625def DS_ADD_SRC2_F32 : DS_1A<"ds_add_src2_f32">;
626}
627
628//===----------------------------------------------------------------------===//
629// DS Patterns
630//===----------------------------------------------------------------------===//
631
632def : GCNPat <
633  (int_amdgcn_ds_swizzle i32:$src, timm:$offset16),
634  (DS_SWIZZLE_B32 VGPR_32:$src, (as_i16timm $offset16), (i1 0))
635>;
636
637class DSReadPat <DS_Pseudo inst, ValueType vt, PatFrag frag, int gds=0> : GCNPat <
638  (vt (frag (DS1Addr1Offset i32:$ptr, i16:$offset))),
639  (inst $ptr, offset:$offset, (i1 gds))
640>;
641
642multiclass DSReadPat_mc<DS_Pseudo inst, ValueType vt, string frag> {
643
644  let OtherPredicates = [LDSRequiresM0Init] in {
645    def : DSReadPat<inst, vt, !cast<PatFrag>(frag#"_m0")>;
646  }
647
648  let OtherPredicates = [NotLDSRequiresM0Init] in {
649    def : DSReadPat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>;
650  }
651}
652
653class DSReadPat_D16 <DS_Pseudo inst, PatFrag frag, ValueType vt> : GCNPat <
654  (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$in),
655  (inst $ptr, offset:$offset, (i1 0), $in)
656>;
657
658defm : DSReadPat_mc <DS_READ_I8, i32, "sextloadi8_local">;
659defm : DSReadPat_mc <DS_READ_I8,  i16, "sextloadi8_local">;
660defm : DSReadPat_mc <DS_READ_U8,  i32, "extloadi8_local">;
661defm : DSReadPat_mc <DS_READ_U8,  i32, "zextloadi8_local">;
662defm : DSReadPat_mc <DS_READ_U8,  i16, "extloadi8_local">;
663defm : DSReadPat_mc <DS_READ_U8,  i16, "zextloadi8_local">;
664defm : DSReadPat_mc <DS_READ_I16, i32, "sextloadi16_local">;
665defm : DSReadPat_mc <DS_READ_I16, i32, "sextloadi16_local">;
666defm : DSReadPat_mc <DS_READ_U16, i32, "extloadi16_local">;
667defm : DSReadPat_mc <DS_READ_U16, i32, "zextloadi16_local">;
668defm : DSReadPat_mc <DS_READ_U16, i16, "load_local">;
669
670foreach vt = Reg32Types.types in {
671defm : DSReadPat_mc <DS_READ_B32, vt, "load_local">;
672}
673
674defm : DSReadPat_mc <DS_READ_B32, i32, "atomic_load_32_local">;
675defm : DSReadPat_mc <DS_READ_B64, i64, "atomic_load_64_local">;
676
677let AddedComplexity = 100 in {
678
679foreach vt = VReg_64.RegTypes in {
680defm : DSReadPat_mc <DS_READ_B64, vt, "load_align8_local">;
681}
682
683let SubtargetPredicate = isGFX7Plus in {
684
685foreach vt = VReg_96.RegTypes in {
686defm : DSReadPat_mc <DS_READ_B96, vt, "load_align16_local">;
687}
688
689foreach vt = VReg_128.RegTypes in {
690defm : DSReadPat_mc <DS_READ_B128, vt, "load_align16_local">;
691}
692
693let SubtargetPredicate = HasUnalignedAccessMode in {
694
695foreach vt = VReg_96.RegTypes in {
696defm : DSReadPat_mc <DS_READ_B96, vt, "load_local">;
697}
698
699foreach vt = VReg_128.RegTypes in {
700defm : DSReadPat_mc <DS_READ_B128, vt, "load_local">;
701}
702
703} // End SubtargetPredicate = HasUnalignedAccessMode
704
705} // End SubtargetPredicate = isGFX7Plus
706
707} // End AddedComplexity = 100
708
709let OtherPredicates = [D16PreservesUnusedBits] in {
710def : DSReadPat_D16<DS_READ_U16_D16_HI, load_d16_hi_local, v2i16>;
711def : DSReadPat_D16<DS_READ_U16_D16_HI, load_d16_hi_local, v2f16>;
712def : DSReadPat_D16<DS_READ_U8_D16_HI, az_extloadi8_d16_hi_local, v2i16>;
713def : DSReadPat_D16<DS_READ_U8_D16_HI, az_extloadi8_d16_hi_local, v2f16>;
714def : DSReadPat_D16<DS_READ_I8_D16_HI, sextloadi8_d16_hi_local, v2i16>;
715def : DSReadPat_D16<DS_READ_I8_D16_HI, sextloadi8_d16_hi_local, v2f16>;
716
717def : DSReadPat_D16<DS_READ_U16_D16, load_d16_lo_local, v2i16>;
718def : DSReadPat_D16<DS_READ_U16_D16, load_d16_lo_local, v2f16>;
719def : DSReadPat_D16<DS_READ_U8_D16, az_extloadi8_d16_lo_local, v2i16>;
720def : DSReadPat_D16<DS_READ_U8_D16, az_extloadi8_d16_lo_local, v2f16>;
721def : DSReadPat_D16<DS_READ_I8_D16, sextloadi8_d16_lo_local, v2i16>;
722def : DSReadPat_D16<DS_READ_I8_D16, sextloadi8_d16_lo_local, v2f16>;
723}
724
725class DSWritePat <DS_Pseudo inst, ValueType vt, PatFrag frag, int gds=0> : GCNPat <
726  (frag vt:$value, (DS1Addr1Offset i32:$ptr, i16:$offset)),
727  (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 gds))
728>;
729
730multiclass DSWritePat_mc <DS_Pseudo inst, ValueType vt, string frag> {
731  let OtherPredicates = [LDSRequiresM0Init] in {
732    def : DSWritePat<inst, vt, !cast<PatFrag>(frag#"_m0")>;
733  }
734
735  let OtherPredicates = [NotLDSRequiresM0Init] in {
736    def : DSWritePat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>;
737  }
738}
739
740// Irritatingly, atomic_store reverses the order of operands from a
741// normal store.
742class DSAtomicWritePat <DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat <
743  (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$value),
744  (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 0))
745>;
746
747multiclass DSAtomicWritePat_mc <DS_Pseudo inst, ValueType vt, string frag> {
748  let OtherPredicates = [LDSRequiresM0Init] in {
749    def : DSAtomicWritePat<inst, vt, !cast<PatFrag>(frag#"_m0")>;
750  }
751
752  let OtherPredicates = [NotLDSRequiresM0Init] in {
753    def : DSAtomicWritePat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt, !cast<PatFrag>(frag)>;
754  }
755}
756
757defm : DSWritePat_mc <DS_WRITE_B8, i32, "truncstorei8_local">;
758defm : DSWritePat_mc <DS_WRITE_B16, i32, "truncstorei16_local">;
759defm : DSWritePat_mc <DS_WRITE_B8, i16, "truncstorei8_local">;
760defm : DSWritePat_mc <DS_WRITE_B16, i16, "store_local">;
761
762foreach vt = Reg32Types.types in {
763defm : DSWritePat_mc <DS_WRITE_B32, vt, "store_local">;
764}
765
766defm : DSAtomicWritePat_mc <DS_WRITE_B32, i32, "atomic_store_local_32">;
767defm : DSAtomicWritePat_mc <DS_WRITE_B64, i64, "atomic_store_local_64">;
768
769let OtherPredicates = [D16PreservesUnusedBits] in {
770def : DSWritePat <DS_WRITE_B16_D16_HI, i32, store_hi16_local>;
771def : DSWritePat <DS_WRITE_B8_D16_HI, i32, truncstorei8_hi16_local>;
772}
773
774class DS64Bit4ByteAlignedReadPat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat <
775  (vt:$value (frag (DS64Bit4ByteAligned i32:$ptr, i8:$offset0, i8:$offset1))),
776  (inst $ptr, $offset0, $offset1, (i1 0))
777>;
778
779class DS64Bit4ByteAlignedWritePat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat<
780  (frag vt:$value, (DS64Bit4ByteAligned i32:$ptr, i8:$offset0, i8:$offset1)),
781  (inst $ptr, (i32 (EXTRACT_SUBREG VReg_64:$value, sub0)),
782              (i32 (EXTRACT_SUBREG VReg_64:$value, sub1)), $offset0, $offset1,
783              (i1 0))
784>;
785
786class DS128Bit8ByteAlignedReadPat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat <
787  (vt:$value (frag (DS128Bit8ByteAligned i32:$ptr, i8:$offset0, i8:$offset1))),
788  (inst $ptr, $offset0, $offset1, (i1 0))
789>;
790
791class DS128Bit8ByteAlignedWritePat<DS_Pseudo inst, ValueType vt, PatFrag frag> : GCNPat<
792  (frag vt:$value, (DS128Bit8ByteAligned i32:$ptr, i8:$offset0, i8:$offset1)),
793  (inst $ptr, (i64 (EXTRACT_SUBREG VReg_128:$value, sub0_sub1)),
794              (i64 (EXTRACT_SUBREG VReg_128:$value, sub2_sub3)), $offset0, $offset1,
795              (i1 0))
796>;
797
798multiclass DS64Bit4ByteAlignedPat_mc<ValueType vt> {
799  let OtherPredicates = [LDSRequiresM0Init, isGFX7Plus] in {
800    def : DS64Bit4ByteAlignedReadPat<DS_READ2_B32, vt, load_local_m0>;
801    def : DS64Bit4ByteAlignedWritePat<DS_WRITE2_B32, vt, store_local_m0>;
802  }
803
804  let OtherPredicates = [NotLDSRequiresM0Init] in {
805    def : DS64Bit4ByteAlignedReadPat<DS_READ2_B32_gfx9, vt, load_local>;
806    def : DS64Bit4ByteAlignedWritePat<DS_WRITE2_B32_gfx9, vt, store_local>;
807  }
808}
809
810multiclass DS128Bit8ByteAlignedPat_mc<ValueType vt> {
811  let OtherPredicates = [LDSRequiresM0Init, isGFX7Plus] in {
812    def : DS128Bit8ByteAlignedReadPat<DS_READ2_B64, vt, load_local_m0>;
813    def : DS128Bit8ByteAlignedWritePat<DS_WRITE2_B64, vt, store_local_m0>;
814  }
815
816  let OtherPredicates = [NotLDSRequiresM0Init] in {
817    def : DS128Bit8ByteAlignedReadPat<DS_READ2_B64_gfx9, vt, load_local>;
818    def : DS128Bit8ByteAlignedWritePat<DS_WRITE2_B64_gfx9, vt, store_local>;
819  }
820}
821
822// v2i32 loads are split into i32 loads on SI during lowering, due to a bug
823// related to bounds checking.
824foreach vt = VReg_64.RegTypes in {
825defm : DS64Bit4ByteAlignedPat_mc<vt>;
826}
827
828foreach vt = VReg_128.RegTypes in {
829defm : DS128Bit8ByteAlignedPat_mc<vt>;
830}
831
832let AddedComplexity = 100 in {
833
834foreach vt = VReg_64.RegTypes in {
835defm : DSWritePat_mc <DS_WRITE_B64, vt, "store_align8_local">;
836}
837
838let SubtargetPredicate = isGFX7Plus in {
839
840foreach vt = VReg_96.RegTypes in {
841defm : DSWritePat_mc <DS_WRITE_B96, vt, "store_align16_local">;
842}
843
844foreach vt = VReg_128.RegTypes in {
845defm : DSWritePat_mc <DS_WRITE_B128, vt, "store_align16_local">;
846}
847
848let SubtargetPredicate = HasUnalignedAccessMode in {
849
850foreach vt = VReg_96.RegTypes in {
851defm : DSWritePat_mc <DS_WRITE_B96, vt, "store_local">;
852}
853
854foreach vt = VReg_128.RegTypes in {
855defm : DSWritePat_mc <DS_WRITE_B128, vt, "store_local">;
856}
857
858} // End SubtargetPredicate = HasUnalignedAccessMode
859
860} // End SubtargetPredicate = isGFX7Plus
861
862} // End AddedComplexity = 100
863
864class DSAtomicRetPat<DS_Pseudo inst, ValueType vt, PatFrag frag, bit gds=0> : GCNPat <
865  (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$value),
866  (inst $ptr, getVregSrcForVT<vt>.ret:$value, offset:$offset, (i1 gds))
867>;
868
869multiclass DSAtomicRetPat_mc<DS_Pseudo inst, ValueType vt, string frag> {
870  let OtherPredicates = [LDSRequiresM0Init] in {
871    def : DSAtomicRetPat<inst, vt, !cast<PatFrag>(frag#"_local_m0_"#vt.Size)>;
872  }
873
874  let OtherPredicates = [NotLDSRequiresM0Init] in {
875    def : DSAtomicRetPat<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt,
876                         !cast<PatFrag>(frag#"_local_"#vt.Size)>;
877  }
878
879  def : DSAtomicRetPat<inst, vt, !cast<PatFrag>(frag#"_region_m0_"#vt.Size), 1>;
880}
881
882
883
884class DSAtomicCmpXChg<DS_Pseudo inst, ValueType vt, PatFrag frag, bit gds=0> : GCNPat <
885  (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$cmp, vt:$swap),
886  (inst $ptr, getVregSrcForVT<vt>.ret:$cmp, getVregSrcForVT<vt>.ret:$swap, offset:$offset, (i1 gds))
887>;
888
889multiclass DSAtomicCmpXChg_mc<DS_Pseudo inst, ValueType vt, string frag> {
890  let OtherPredicates = [LDSRequiresM0Init] in {
891    def : DSAtomicCmpXChg<inst, vt, !cast<PatFrag>(frag#"_local_m0_"#vt.Size)>;
892  }
893
894  let OtherPredicates = [NotLDSRequiresM0Init] in {
895    def : DSAtomicCmpXChg<!cast<DS_Pseudo>(!cast<string>(inst)#"_gfx9"), vt,
896                          !cast<PatFrag>(frag#"_local_"#vt.Size)>;
897  }
898
899  def : DSAtomicCmpXChg<inst, vt, !cast<PatFrag>(frag#"_region_m0_"#vt.Size), 1>;
900}
901
902
903
904// 32-bit atomics.
905defm : DSAtomicRetPat_mc<DS_WRXCHG_RTN_B32, i32, "atomic_swap">;
906defm : DSAtomicRetPat_mc<DS_ADD_RTN_U32, i32, "atomic_load_add">;
907defm : DSAtomicRetPat_mc<DS_SUB_RTN_U32, i32, "atomic_load_sub">;
908defm : DSAtomicRetPat_mc<DS_INC_RTN_U32, i32, "atomic_inc">;
909defm : DSAtomicRetPat_mc<DS_DEC_RTN_U32, i32, "atomic_dec">;
910defm : DSAtomicRetPat_mc<DS_AND_RTN_B32, i32, "atomic_load_and">;
911defm : DSAtomicRetPat_mc<DS_OR_RTN_B32, i32, "atomic_load_or">;
912defm : DSAtomicRetPat_mc<DS_XOR_RTN_B32, i32, "atomic_load_xor">;
913defm : DSAtomicRetPat_mc<DS_MIN_RTN_I32, i32, "atomic_load_min">;
914defm : DSAtomicRetPat_mc<DS_MAX_RTN_I32, i32, "atomic_load_max">;
915defm : DSAtomicRetPat_mc<DS_MIN_RTN_U32, i32, "atomic_load_umin">;
916defm : DSAtomicRetPat_mc<DS_MAX_RTN_U32, i32, "atomic_load_umax">;
917defm : DSAtomicCmpXChg_mc<DS_CMPST_RTN_B32, i32, "atomic_cmp_swap">;
918
919let SubtargetPredicate = HasLDSFPAtomics in {
920defm : DSAtomicRetPat_mc<DS_MIN_RTN_F32, f32, "atomic_load_fmin">;
921defm : DSAtomicRetPat_mc<DS_MAX_RTN_F32, f32, "atomic_load_fmax">;
922defm : DSAtomicRetPat_mc<DS_ADD_RTN_F32, f32, "atomic_load_fadd">;
923}
924
925// 64-bit atomics.
926defm : DSAtomicRetPat_mc<DS_WRXCHG_RTN_B64, i64, "atomic_swap">;
927defm : DSAtomicRetPat_mc<DS_ADD_RTN_U64, i64, "atomic_load_add">;
928defm : DSAtomicRetPat_mc<DS_SUB_RTN_U64, i64, "atomic_load_sub">;
929defm : DSAtomicRetPat_mc<DS_INC_RTN_U64, i64, "atomic_inc">;
930defm : DSAtomicRetPat_mc<DS_DEC_RTN_U64, i64, "atomic_dec">;
931defm : DSAtomicRetPat_mc<DS_AND_RTN_B64, i64, "atomic_load_and">;
932defm : DSAtomicRetPat_mc<DS_OR_RTN_B64, i64, "atomic_load_or">;
933defm : DSAtomicRetPat_mc<DS_XOR_RTN_B64, i64, "atomic_load_xor">;
934defm : DSAtomicRetPat_mc<DS_MIN_RTN_I64, i64, "atomic_load_min">;
935defm : DSAtomicRetPat_mc<DS_MAX_RTN_I64, i64, "atomic_load_max">;
936defm : DSAtomicRetPat_mc<DS_MIN_RTN_U64, i64, "atomic_load_umin">;
937defm : DSAtomicRetPat_mc<DS_MAX_RTN_U64, i64, "atomic_load_umax">;
938
939defm : DSAtomicCmpXChg_mc<DS_CMPST_RTN_B64, i64, "atomic_cmp_swap">;
940
941def : Pat <
942  (SIds_ordered_count i32:$value, i16:$offset),
943  (DS_ORDERED_COUNT $value, (as_i16imm $offset))
944>;
945
946//===----------------------------------------------------------------------===//
947// Target-specific instruction encodings.
948//===----------------------------------------------------------------------===//
949
950//===----------------------------------------------------------------------===//
951// Base ENC_DS for GFX6, GFX7, GFX10.
952//===----------------------------------------------------------------------===//
953
954class Base_DS_Real_gfx6_gfx7_gfx10<bits<8> op, DS_Pseudo ps, int ef> :
955    DS_Real<ps>, SIMCInstr <ps.Mnemonic, ef> {
956
957  let Inst{7-0}   = !if(ps.has_offset0, offset0, 0);
958  let Inst{15-8}  = !if(ps.has_offset1, offset1, 0);
959  let Inst{17}    = !if(ps.has_gds, gds, ps.gdsValue);
960  let Inst{25-18} = op;
961  let Inst{31-26} = 0x36;
962  let Inst{39-32} = !if(ps.has_addr, addr, !if(ps.has_gws_data0, data0, 0));
963  let Inst{47-40} = !if(ps.has_data0, data0, 0);
964  let Inst{55-48} = !if(ps.has_data1, data1, 0);
965  let Inst{63-56} = !if(ps.has_vdst, vdst, 0);
966}
967
968//===----------------------------------------------------------------------===//
969// GFX10.
970//===----------------------------------------------------------------------===//
971
972let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
973  multiclass DS_Real_gfx10<bits<8> op>  {
974    def _gfx10 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME),
975                                              SIEncodingFamily.GFX10>;
976  }
977} // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
978
979defm DS_ADD_F32          : DS_Real_gfx10<0x015>;
980defm DS_ADD_RTN_F32      : DS_Real_gfx10<0x055>;
981defm DS_ADD_SRC2_F32     : DS_Real_gfx10<0x095>;
982defm DS_WRITE_B8_D16_HI  : DS_Real_gfx10<0x0a0>;
983defm DS_WRITE_B16_D16_HI : DS_Real_gfx10<0x0a1>;
984defm DS_READ_U8_D16      : DS_Real_gfx10<0x0a2>;
985defm DS_READ_U8_D16_HI   : DS_Real_gfx10<0x0a3>;
986defm DS_READ_I8_D16      : DS_Real_gfx10<0x0a4>;
987defm DS_READ_I8_D16_HI   : DS_Real_gfx10<0x0a5>;
988defm DS_READ_U16_D16     : DS_Real_gfx10<0x0a6>;
989defm DS_READ_U16_D16_HI  : DS_Real_gfx10<0x0a7>;
990defm DS_WRITE_ADDTID_B32 : DS_Real_gfx10<0x0b0>;
991defm DS_READ_ADDTID_B32  : DS_Real_gfx10<0x0b1>;
992defm DS_PERMUTE_B32      : DS_Real_gfx10<0x0b2>;
993defm DS_BPERMUTE_B32     : DS_Real_gfx10<0x0b3>;
994
995//===----------------------------------------------------------------------===//
996// GFX7, GFX10.
997//===----------------------------------------------------------------------===//
998
999let AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7" in {
1000  multiclass DS_Real_gfx7<bits<8> op> {
1001    def _gfx7 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME),
1002                                             SIEncodingFamily.SI>;
1003  }
1004} // End AssemblerPredicate = isGFX7Only, DecoderNamespace = "GFX7"
1005
1006multiclass DS_Real_gfx7_gfx10<bits<8> op> :
1007  DS_Real_gfx7<op>, DS_Real_gfx10<op>;
1008
1009// FIXME-GFX7: Add tests when upstreaming this part.
1010defm DS_GWS_SEMA_RELEASE_ALL : DS_Real_gfx7_gfx10<0x018>;
1011defm DS_WRAP_RTN_B32         : DS_Real_gfx7_gfx10<0x034>;
1012defm DS_CONDXCHG32_RTN_B64   : DS_Real_gfx7_gfx10<0x07e>;
1013defm DS_WRITE_B96            : DS_Real_gfx7_gfx10<0x0de>;
1014defm DS_WRITE_B128           : DS_Real_gfx7_gfx10<0x0df>;
1015defm DS_READ_B96             : DS_Real_gfx7_gfx10<0x0fe>;
1016defm DS_READ_B128            : DS_Real_gfx7_gfx10<0x0ff>;
1017
1018//===----------------------------------------------------------------------===//
1019// GFX6, GFX7, GFX10.
1020//===----------------------------------------------------------------------===//
1021
1022let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
1023  multiclass DS_Real_gfx6_gfx7<bits<8> op> {
1024    def _gfx6_gfx7 : Base_DS_Real_gfx6_gfx7_gfx10<op, !cast<DS_Pseudo>(NAME),
1025                                                  SIEncodingFamily.SI>;
1026  }
1027} // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
1028
1029multiclass DS_Real_gfx6_gfx7_gfx10<bits<8> op> :
1030  DS_Real_gfx6_gfx7<op>, DS_Real_gfx10<op>;
1031
1032defm DS_ADD_U32             : DS_Real_gfx6_gfx7_gfx10<0x000>;
1033defm DS_SUB_U32             : DS_Real_gfx6_gfx7_gfx10<0x001>;
1034defm DS_RSUB_U32            : DS_Real_gfx6_gfx7_gfx10<0x002>;
1035defm DS_INC_U32             : DS_Real_gfx6_gfx7_gfx10<0x003>;
1036defm DS_DEC_U32             : DS_Real_gfx6_gfx7_gfx10<0x004>;
1037defm DS_MIN_I32             : DS_Real_gfx6_gfx7_gfx10<0x005>;
1038defm DS_MAX_I32             : DS_Real_gfx6_gfx7_gfx10<0x006>;
1039defm DS_MIN_U32             : DS_Real_gfx6_gfx7_gfx10<0x007>;
1040defm DS_MAX_U32             : DS_Real_gfx6_gfx7_gfx10<0x008>;
1041defm DS_AND_B32             : DS_Real_gfx6_gfx7_gfx10<0x009>;
1042defm DS_OR_B32              : DS_Real_gfx6_gfx7_gfx10<0x00a>;
1043defm DS_XOR_B32             : DS_Real_gfx6_gfx7_gfx10<0x00b>;
1044defm DS_MSKOR_B32           : DS_Real_gfx6_gfx7_gfx10<0x00c>;
1045defm DS_WRITE_B32           : DS_Real_gfx6_gfx7_gfx10<0x00d>;
1046defm DS_WRITE2_B32          : DS_Real_gfx6_gfx7_gfx10<0x00e>;
1047defm DS_WRITE2ST64_B32      : DS_Real_gfx6_gfx7_gfx10<0x00f>;
1048defm DS_CMPST_B32           : DS_Real_gfx6_gfx7_gfx10<0x010>;
1049defm DS_CMPST_F32           : DS_Real_gfx6_gfx7_gfx10<0x011>;
1050defm DS_MIN_F32             : DS_Real_gfx6_gfx7_gfx10<0x012>;
1051defm DS_MAX_F32             : DS_Real_gfx6_gfx7_gfx10<0x013>;
1052defm DS_NOP                 : DS_Real_gfx6_gfx7_gfx10<0x014>;
1053defm DS_GWS_INIT            : DS_Real_gfx6_gfx7_gfx10<0x019>;
1054defm DS_GWS_SEMA_V          : DS_Real_gfx6_gfx7_gfx10<0x01a>;
1055defm DS_GWS_SEMA_BR         : DS_Real_gfx6_gfx7_gfx10<0x01b>;
1056defm DS_GWS_SEMA_P          : DS_Real_gfx6_gfx7_gfx10<0x01c>;
1057defm DS_GWS_BARRIER         : DS_Real_gfx6_gfx7_gfx10<0x01d>;
1058defm DS_WRITE_B8            : DS_Real_gfx6_gfx7_gfx10<0x01e>;
1059defm DS_WRITE_B16           : DS_Real_gfx6_gfx7_gfx10<0x01f>;
1060defm DS_ADD_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x020>;
1061defm DS_SUB_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x021>;
1062defm DS_RSUB_RTN_U32        : DS_Real_gfx6_gfx7_gfx10<0x022>;
1063defm DS_INC_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x023>;
1064defm DS_DEC_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x024>;
1065defm DS_MIN_RTN_I32         : DS_Real_gfx6_gfx7_gfx10<0x025>;
1066defm DS_MAX_RTN_I32         : DS_Real_gfx6_gfx7_gfx10<0x026>;
1067defm DS_MIN_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x027>;
1068defm DS_MAX_RTN_U32         : DS_Real_gfx6_gfx7_gfx10<0x028>;
1069defm DS_AND_RTN_B32         : DS_Real_gfx6_gfx7_gfx10<0x029>;
1070defm DS_OR_RTN_B32          : DS_Real_gfx6_gfx7_gfx10<0x02a>;
1071defm DS_XOR_RTN_B32         : DS_Real_gfx6_gfx7_gfx10<0x02b>;
1072defm DS_MSKOR_RTN_B32       : DS_Real_gfx6_gfx7_gfx10<0x02c>;
1073defm DS_WRXCHG_RTN_B32      : DS_Real_gfx6_gfx7_gfx10<0x02d>;
1074defm DS_WRXCHG2_RTN_B32     : DS_Real_gfx6_gfx7_gfx10<0x02e>;
1075defm DS_WRXCHG2ST64_RTN_B32 : DS_Real_gfx6_gfx7_gfx10<0x02f>;
1076defm DS_CMPST_RTN_B32       : DS_Real_gfx6_gfx7_gfx10<0x030>;
1077defm DS_CMPST_RTN_F32       : DS_Real_gfx6_gfx7_gfx10<0x031>;
1078defm DS_MIN_RTN_F32         : DS_Real_gfx6_gfx7_gfx10<0x032>;
1079defm DS_MAX_RTN_F32         : DS_Real_gfx6_gfx7_gfx10<0x033>;
1080defm DS_SWIZZLE_B32         : DS_Real_gfx6_gfx7_gfx10<0x035>;
1081defm DS_READ_B32            : DS_Real_gfx6_gfx7_gfx10<0x036>;
1082defm DS_READ2_B32           : DS_Real_gfx6_gfx7_gfx10<0x037>;
1083defm DS_READ2ST64_B32       : DS_Real_gfx6_gfx7_gfx10<0x038>;
1084defm DS_READ_I8             : DS_Real_gfx6_gfx7_gfx10<0x039>;
1085defm DS_READ_U8             : DS_Real_gfx6_gfx7_gfx10<0x03a>;
1086defm DS_READ_I16            : DS_Real_gfx6_gfx7_gfx10<0x03b>;
1087defm DS_READ_U16            : DS_Real_gfx6_gfx7_gfx10<0x03c>;
1088defm DS_CONSUME             : DS_Real_gfx6_gfx7_gfx10<0x03d>;
1089defm DS_APPEND              : DS_Real_gfx6_gfx7_gfx10<0x03e>;
1090defm DS_ORDERED_COUNT       : DS_Real_gfx6_gfx7_gfx10<0x03f>;
1091defm DS_ADD_U64             : DS_Real_gfx6_gfx7_gfx10<0x040>;
1092defm DS_SUB_U64             : DS_Real_gfx6_gfx7_gfx10<0x041>;
1093defm DS_RSUB_U64            : DS_Real_gfx6_gfx7_gfx10<0x042>;
1094defm DS_INC_U64             : DS_Real_gfx6_gfx7_gfx10<0x043>;
1095defm DS_DEC_U64             : DS_Real_gfx6_gfx7_gfx10<0x044>;
1096defm DS_MIN_I64             : DS_Real_gfx6_gfx7_gfx10<0x045>;
1097defm DS_MAX_I64             : DS_Real_gfx6_gfx7_gfx10<0x046>;
1098defm DS_MIN_U64             : DS_Real_gfx6_gfx7_gfx10<0x047>;
1099defm DS_MAX_U64             : DS_Real_gfx6_gfx7_gfx10<0x048>;
1100defm DS_AND_B64             : DS_Real_gfx6_gfx7_gfx10<0x049>;
1101defm DS_OR_B64              : DS_Real_gfx6_gfx7_gfx10<0x04a>;
1102defm DS_XOR_B64             : DS_Real_gfx6_gfx7_gfx10<0x04b>;
1103defm DS_MSKOR_B64           : DS_Real_gfx6_gfx7_gfx10<0x04c>;
1104defm DS_WRITE_B64           : DS_Real_gfx6_gfx7_gfx10<0x04d>;
1105defm DS_WRITE2_B64          : DS_Real_gfx6_gfx7_gfx10<0x04e>;
1106defm DS_WRITE2ST64_B64      : DS_Real_gfx6_gfx7_gfx10<0x04f>;
1107defm DS_CMPST_B64           : DS_Real_gfx6_gfx7_gfx10<0x050>;
1108defm DS_CMPST_F64           : DS_Real_gfx6_gfx7_gfx10<0x051>;
1109defm DS_MIN_F64             : DS_Real_gfx6_gfx7_gfx10<0x052>;
1110defm DS_MAX_F64             : DS_Real_gfx6_gfx7_gfx10<0x053>;
1111defm DS_ADD_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x060>;
1112defm DS_SUB_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x061>;
1113defm DS_RSUB_RTN_U64        : DS_Real_gfx6_gfx7_gfx10<0x062>;
1114defm DS_INC_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x063>;
1115defm DS_DEC_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x064>;
1116defm DS_MIN_RTN_I64         : DS_Real_gfx6_gfx7_gfx10<0x065>;
1117defm DS_MAX_RTN_I64         : DS_Real_gfx6_gfx7_gfx10<0x066>;
1118defm DS_MIN_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x067>;
1119defm DS_MAX_RTN_U64         : DS_Real_gfx6_gfx7_gfx10<0x068>;
1120defm DS_AND_RTN_B64         : DS_Real_gfx6_gfx7_gfx10<0x069>;
1121defm DS_OR_RTN_B64          : DS_Real_gfx6_gfx7_gfx10<0x06a>;
1122defm DS_XOR_RTN_B64         : DS_Real_gfx6_gfx7_gfx10<0x06b>;
1123defm DS_MSKOR_RTN_B64       : DS_Real_gfx6_gfx7_gfx10<0x06c>;
1124defm DS_WRXCHG_RTN_B64      : DS_Real_gfx6_gfx7_gfx10<0x06d>;
1125defm DS_WRXCHG2_RTN_B64     : DS_Real_gfx6_gfx7_gfx10<0x06e>;
1126defm DS_WRXCHG2ST64_RTN_B64 : DS_Real_gfx6_gfx7_gfx10<0x06f>;
1127defm DS_CMPST_RTN_B64       : DS_Real_gfx6_gfx7_gfx10<0x070>;
1128defm DS_CMPST_RTN_F64       : DS_Real_gfx6_gfx7_gfx10<0x071>;
1129defm DS_MIN_RTN_F64         : DS_Real_gfx6_gfx7_gfx10<0x072>;
1130defm DS_MAX_RTN_F64         : DS_Real_gfx6_gfx7_gfx10<0x073>;
1131defm DS_READ_B64            : DS_Real_gfx6_gfx7_gfx10<0x076>;
1132defm DS_READ2_B64           : DS_Real_gfx6_gfx7_gfx10<0x077>;
1133defm DS_READ2ST64_B64       : DS_Real_gfx6_gfx7_gfx10<0x078>;
1134defm DS_ADD_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x080>;
1135defm DS_SUB_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x081>;
1136defm DS_RSUB_SRC2_U32       : DS_Real_gfx6_gfx7_gfx10<0x082>;
1137defm DS_INC_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x083>;
1138defm DS_DEC_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x084>;
1139defm DS_MIN_SRC2_I32        : DS_Real_gfx6_gfx7_gfx10<0x085>;
1140defm DS_MAX_SRC2_I32        : DS_Real_gfx6_gfx7_gfx10<0x086>;
1141defm DS_MIN_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x087>;
1142defm DS_MAX_SRC2_U32        : DS_Real_gfx6_gfx7_gfx10<0x088>;
1143defm DS_AND_SRC2_B32        : DS_Real_gfx6_gfx7_gfx10<0x089>;
1144defm DS_OR_SRC2_B32         : DS_Real_gfx6_gfx7_gfx10<0x08a>;
1145defm DS_XOR_SRC2_B32        : DS_Real_gfx6_gfx7_gfx10<0x08b>;
1146defm DS_WRITE_SRC2_B32      : DS_Real_gfx6_gfx7_gfx10<0x08d>;
1147defm DS_MIN_SRC2_F32        : DS_Real_gfx6_gfx7_gfx10<0x092>;
1148defm DS_MAX_SRC2_F32        : DS_Real_gfx6_gfx7_gfx10<0x093>;
1149defm DS_ADD_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c0>;
1150defm DS_SUB_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c1>;
1151defm DS_RSUB_SRC2_U64       : DS_Real_gfx6_gfx7_gfx10<0x0c2>;
1152defm DS_INC_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c3>;
1153defm DS_DEC_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c4>;
1154defm DS_MIN_SRC2_I64        : DS_Real_gfx6_gfx7_gfx10<0x0c5>;
1155defm DS_MAX_SRC2_I64        : DS_Real_gfx6_gfx7_gfx10<0x0c6>;
1156defm DS_MIN_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c7>;
1157defm DS_MAX_SRC2_U64        : DS_Real_gfx6_gfx7_gfx10<0x0c8>;
1158defm DS_AND_SRC2_B64        : DS_Real_gfx6_gfx7_gfx10<0x0c9>;
1159defm DS_OR_SRC2_B64         : DS_Real_gfx6_gfx7_gfx10<0x0ca>;
1160defm DS_XOR_SRC2_B64        : DS_Real_gfx6_gfx7_gfx10<0x0cb>;
1161defm DS_WRITE_SRC2_B64      : DS_Real_gfx6_gfx7_gfx10<0x0cd>;
1162defm DS_MIN_SRC2_F64        : DS_Real_gfx6_gfx7_gfx10<0x0d2>;
1163defm DS_MAX_SRC2_F64        : DS_Real_gfx6_gfx7_gfx10<0x0d3>;
1164
1165//===----------------------------------------------------------------------===//
1166// GFX8, GFX9 (VI).
1167//===----------------------------------------------------------------------===//
1168
1169class DS_Real_vi <bits<8> op, DS_Pseudo ds> :
1170  DS_Real <ds>,
1171  SIMCInstr <ds.Mnemonic, SIEncodingFamily.VI> {
1172  let AssemblerPredicate = isGFX8GFX9;
1173  let DecoderNamespace = "GFX8";
1174
1175  // encoding
1176  let Inst{7-0}   = !if(ds.has_offset0, offset0, 0);
1177  let Inst{15-8}  = !if(ds.has_offset1, offset1, 0);
1178  let Inst{16}    = !if(ds.has_gds, gds, ds.gdsValue);
1179  let Inst{24-17} = op;
1180  let Inst{31-26} = 0x36; // ds prefix
1181  let Inst{39-32} = !if(ds.has_addr, addr, !if(ds.has_gws_data0, data0, 0));
1182  let Inst{47-40} = !if(ds.has_data0, data0, 0);
1183  let Inst{55-48} = !if(ds.has_data1, data1, 0);
1184  let Inst{63-56} = !if(ds.has_vdst, vdst, 0);
1185}
1186
1187def DS_ADD_U32_vi         : DS_Real_vi<0x0,  DS_ADD_U32>;
1188def DS_SUB_U32_vi         : DS_Real_vi<0x1,  DS_SUB_U32>;
1189def DS_RSUB_U32_vi        : DS_Real_vi<0x2,  DS_RSUB_U32>;
1190def DS_INC_U32_vi         : DS_Real_vi<0x3,  DS_INC_U32>;
1191def DS_DEC_U32_vi         : DS_Real_vi<0x4,  DS_DEC_U32>;
1192def DS_MIN_I32_vi         : DS_Real_vi<0x5,  DS_MIN_I32>;
1193def DS_MAX_I32_vi         : DS_Real_vi<0x6,  DS_MAX_I32>;
1194def DS_MIN_U32_vi         : DS_Real_vi<0x7,  DS_MIN_U32>;
1195def DS_MAX_U32_vi         : DS_Real_vi<0x8,  DS_MAX_U32>;
1196def DS_AND_B32_vi         : DS_Real_vi<0x9,  DS_AND_B32>;
1197def DS_OR_B32_vi          : DS_Real_vi<0xa,  DS_OR_B32>;
1198def DS_XOR_B32_vi         : DS_Real_vi<0xb,  DS_XOR_B32>;
1199def DS_MSKOR_B32_vi       : DS_Real_vi<0xc,  DS_MSKOR_B32>;
1200def DS_WRITE_B32_vi       : DS_Real_vi<0xd,  DS_WRITE_B32>;
1201def DS_WRITE2_B32_vi      : DS_Real_vi<0xe,  DS_WRITE2_B32>;
1202def DS_WRITE2ST64_B32_vi  : DS_Real_vi<0xf,  DS_WRITE2ST64_B32>;
1203def DS_CMPST_B32_vi       : DS_Real_vi<0x10, DS_CMPST_B32>;
1204def DS_CMPST_F32_vi       : DS_Real_vi<0x11, DS_CMPST_F32>;
1205def DS_MIN_F32_vi         : DS_Real_vi<0x12, DS_MIN_F32>;
1206def DS_MAX_F32_vi         : DS_Real_vi<0x13, DS_MAX_F32>;
1207def DS_NOP_vi             : DS_Real_vi<0x14, DS_NOP>;
1208def DS_ADD_F32_vi         : DS_Real_vi<0x15, DS_ADD_F32>;
1209def DS_GWS_INIT_vi        : DS_Real_vi<0x99, DS_GWS_INIT>;
1210def DS_GWS_SEMA_V_vi      : DS_Real_vi<0x9a, DS_GWS_SEMA_V>;
1211def DS_GWS_SEMA_BR_vi     : DS_Real_vi<0x9b, DS_GWS_SEMA_BR>;
1212def DS_GWS_SEMA_P_vi      : DS_Real_vi<0x9c, DS_GWS_SEMA_P>;
1213def DS_GWS_BARRIER_vi     : DS_Real_vi<0x9d, DS_GWS_BARRIER>;
1214def DS_WRITE_ADDTID_B32_vi : DS_Real_vi<0x1d, DS_WRITE_ADDTID_B32>;
1215def DS_WRITE_B8_vi        : DS_Real_vi<0x1e, DS_WRITE_B8>;
1216def DS_WRITE_B16_vi       : DS_Real_vi<0x1f, DS_WRITE_B16>;
1217def DS_ADD_RTN_U32_vi     : DS_Real_vi<0x20, DS_ADD_RTN_U32>;
1218def DS_SUB_RTN_U32_vi     : DS_Real_vi<0x21, DS_SUB_RTN_U32>;
1219def DS_RSUB_RTN_U32_vi    : DS_Real_vi<0x22, DS_RSUB_RTN_U32>;
1220def DS_INC_RTN_U32_vi     : DS_Real_vi<0x23, DS_INC_RTN_U32>;
1221def DS_DEC_RTN_U32_vi     : DS_Real_vi<0x24, DS_DEC_RTN_U32>;
1222def DS_MIN_RTN_I32_vi     : DS_Real_vi<0x25, DS_MIN_RTN_I32>;
1223def DS_MAX_RTN_I32_vi     : DS_Real_vi<0x26, DS_MAX_RTN_I32>;
1224def DS_MIN_RTN_U32_vi     : DS_Real_vi<0x27, DS_MIN_RTN_U32>;
1225def DS_MAX_RTN_U32_vi     : DS_Real_vi<0x28, DS_MAX_RTN_U32>;
1226def DS_AND_RTN_B32_vi     : DS_Real_vi<0x29, DS_AND_RTN_B32>;
1227def DS_OR_RTN_B32_vi      : DS_Real_vi<0x2a, DS_OR_RTN_B32>;
1228def DS_XOR_RTN_B32_vi     : DS_Real_vi<0x2b, DS_XOR_RTN_B32>;
1229def DS_MSKOR_RTN_B32_vi   : DS_Real_vi<0x2c, DS_MSKOR_RTN_B32>;
1230def DS_WRXCHG_RTN_B32_vi  : DS_Real_vi<0x2d, DS_WRXCHG_RTN_B32>;
1231def DS_WRXCHG2_RTN_B32_vi : DS_Real_vi<0x2e, DS_WRXCHG2_RTN_B32>;
1232def DS_WRXCHG2ST64_RTN_B32_vi : DS_Real_vi<0x2f, DS_WRXCHG2ST64_RTN_B32>;
1233def DS_CMPST_RTN_B32_vi   : DS_Real_vi<0x30, DS_CMPST_RTN_B32>;
1234def DS_CMPST_RTN_F32_vi   : DS_Real_vi<0x31, DS_CMPST_RTN_F32>;
1235def DS_MIN_RTN_F32_vi     : DS_Real_vi<0x32, DS_MIN_RTN_F32>;
1236def DS_MAX_RTN_F32_vi     : DS_Real_vi<0x33, DS_MAX_RTN_F32>;
1237def DS_WRAP_RTN_B32_vi    : DS_Real_vi<0x34, DS_WRAP_RTN_B32>;
1238def DS_ADD_RTN_F32_vi     : DS_Real_vi<0x35, DS_ADD_RTN_F32>;
1239def DS_READ_B32_vi        : DS_Real_vi<0x36, DS_READ_B32>;
1240def DS_READ2_B32_vi       : DS_Real_vi<0x37, DS_READ2_B32>;
1241def DS_READ2ST64_B32_vi   : DS_Real_vi<0x38, DS_READ2ST64_B32>;
1242def DS_READ_I8_vi         : DS_Real_vi<0x39, DS_READ_I8>;
1243def DS_READ_U8_vi         : DS_Real_vi<0x3a, DS_READ_U8>;
1244def DS_READ_I16_vi        : DS_Real_vi<0x3b, DS_READ_I16>;
1245def DS_READ_U16_vi        : DS_Real_vi<0x3c, DS_READ_U16>;
1246def DS_READ_ADDTID_B32_vi : DS_Real_vi<0xb6, DS_READ_ADDTID_B32>;
1247def DS_CONSUME_vi         : DS_Real_vi<0xbd, DS_CONSUME>;
1248def DS_APPEND_vi          : DS_Real_vi<0xbe, DS_APPEND>;
1249def DS_ORDERED_COUNT_vi   : DS_Real_vi<0xbf, DS_ORDERED_COUNT>;
1250def DS_SWIZZLE_B32_vi     : DS_Real_vi<0x3d, DS_SWIZZLE_B32>;
1251def DS_PERMUTE_B32_vi     : DS_Real_vi<0x3e, DS_PERMUTE_B32>;
1252def DS_BPERMUTE_B32_vi    : DS_Real_vi<0x3f, DS_BPERMUTE_B32>;
1253
1254def DS_ADD_U64_vi         : DS_Real_vi<0x40, DS_ADD_U64>;
1255def DS_SUB_U64_vi         : DS_Real_vi<0x41, DS_SUB_U64>;
1256def DS_RSUB_U64_vi        : DS_Real_vi<0x42, DS_RSUB_U64>;
1257def DS_INC_U64_vi         : DS_Real_vi<0x43, DS_INC_U64>;
1258def DS_DEC_U64_vi         : DS_Real_vi<0x44, DS_DEC_U64>;
1259def DS_MIN_I64_vi         : DS_Real_vi<0x45, DS_MIN_I64>;
1260def DS_MAX_I64_vi         : DS_Real_vi<0x46, DS_MAX_I64>;
1261def DS_MIN_U64_vi         : DS_Real_vi<0x47, DS_MIN_U64>;
1262def DS_MAX_U64_vi         : DS_Real_vi<0x48, DS_MAX_U64>;
1263def DS_AND_B64_vi         : DS_Real_vi<0x49, DS_AND_B64>;
1264def DS_OR_B64_vi          : DS_Real_vi<0x4a, DS_OR_B64>;
1265def DS_XOR_B64_vi         : DS_Real_vi<0x4b, DS_XOR_B64>;
1266def DS_MSKOR_B64_vi       : DS_Real_vi<0x4c, DS_MSKOR_B64>;
1267def DS_WRITE_B64_vi       : DS_Real_vi<0x4d, DS_WRITE_B64>;
1268def DS_WRITE2_B64_vi      : DS_Real_vi<0x4E, DS_WRITE2_B64>;
1269def DS_WRITE2ST64_B64_vi  : DS_Real_vi<0x4f, DS_WRITE2ST64_B64>;
1270def DS_CMPST_B64_vi       : DS_Real_vi<0x50, DS_CMPST_B64>;
1271def DS_CMPST_F64_vi       : DS_Real_vi<0x51, DS_CMPST_F64>;
1272def DS_MIN_F64_vi         : DS_Real_vi<0x52, DS_MIN_F64>;
1273def DS_MAX_F64_vi         : DS_Real_vi<0x53, DS_MAX_F64>;
1274
1275def DS_WRITE_B8_D16_HI_vi  : DS_Real_vi<0x54, DS_WRITE_B8_D16_HI>;
1276def DS_WRITE_B16_D16_HI_vi : DS_Real_vi<0x55, DS_WRITE_B16_D16_HI>;
1277
1278def DS_READ_U8_D16_vi     : DS_Real_vi<0x56, DS_READ_U8_D16>;
1279def DS_READ_U8_D16_HI_vi  : DS_Real_vi<0x57, DS_READ_U8_D16_HI>;
1280def DS_READ_I8_D16_vi     : DS_Real_vi<0x58, DS_READ_I8_D16>;
1281def DS_READ_I8_D16_HI_vi  : DS_Real_vi<0x59, DS_READ_I8_D16_HI>;
1282def DS_READ_U16_D16_vi    : DS_Real_vi<0x5a, DS_READ_U16_D16>;
1283def DS_READ_U16_D16_HI_vi : DS_Real_vi<0x5b, DS_READ_U16_D16_HI>;
1284
1285def DS_ADD_RTN_U64_vi     : DS_Real_vi<0x60, DS_ADD_RTN_U64>;
1286def DS_SUB_RTN_U64_vi     : DS_Real_vi<0x61, DS_SUB_RTN_U64>;
1287def DS_RSUB_RTN_U64_vi    : DS_Real_vi<0x62, DS_RSUB_RTN_U64>;
1288def DS_INC_RTN_U64_vi     : DS_Real_vi<0x63, DS_INC_RTN_U64>;
1289def DS_DEC_RTN_U64_vi     : DS_Real_vi<0x64, DS_DEC_RTN_U64>;
1290def DS_MIN_RTN_I64_vi     : DS_Real_vi<0x65, DS_MIN_RTN_I64>;
1291def DS_MAX_RTN_I64_vi     : DS_Real_vi<0x66, DS_MAX_RTN_I64>;
1292def DS_MIN_RTN_U64_vi     : DS_Real_vi<0x67, DS_MIN_RTN_U64>;
1293def DS_MAX_RTN_U64_vi     : DS_Real_vi<0x68, DS_MAX_RTN_U64>;
1294def DS_AND_RTN_B64_vi     : DS_Real_vi<0x69, DS_AND_RTN_B64>;
1295def DS_OR_RTN_B64_vi      : DS_Real_vi<0x6a, DS_OR_RTN_B64>;
1296def DS_XOR_RTN_B64_vi     : DS_Real_vi<0x6b, DS_XOR_RTN_B64>;
1297def DS_MSKOR_RTN_B64_vi   : DS_Real_vi<0x6c, DS_MSKOR_RTN_B64>;
1298def DS_WRXCHG_RTN_B64_vi  : DS_Real_vi<0x6d, DS_WRXCHG_RTN_B64>;
1299def DS_WRXCHG2_RTN_B64_vi : DS_Real_vi<0x6e, DS_WRXCHG2_RTN_B64>;
1300def DS_WRXCHG2ST64_RTN_B64_vi : DS_Real_vi<0x6f, DS_WRXCHG2ST64_RTN_B64>;
1301def DS_CONDXCHG32_RTN_B64_vi   : DS_Real_vi<0x7e, DS_CONDXCHG32_RTN_B64>;
1302def DS_GWS_SEMA_RELEASE_ALL_vi : DS_Real_vi<0x98, DS_GWS_SEMA_RELEASE_ALL>;
1303def DS_CMPST_RTN_B64_vi   : DS_Real_vi<0x70, DS_CMPST_RTN_B64>;
1304def DS_CMPST_RTN_F64_vi   : DS_Real_vi<0x71, DS_CMPST_RTN_F64>;
1305def DS_MIN_RTN_F64_vi     : DS_Real_vi<0x72, DS_MIN_RTN_F64>;
1306def DS_MAX_RTN_F64_vi     : DS_Real_vi<0x73, DS_MAX_RTN_F64>;
1307
1308def DS_READ_B64_vi        : DS_Real_vi<0x76, DS_READ_B64>;
1309def DS_READ2_B64_vi       : DS_Real_vi<0x77, DS_READ2_B64>;
1310def DS_READ2ST64_B64_vi   : DS_Real_vi<0x78, DS_READ2ST64_B64>;
1311
1312def DS_ADD_SRC2_U32_vi    : DS_Real_vi<0x80, DS_ADD_SRC2_U32>;
1313def DS_SUB_SRC2_U32_vi    : DS_Real_vi<0x81, DS_SUB_SRC2_U32>;
1314def DS_RSUB_SRC2_U32_vi   : DS_Real_vi<0x82, DS_RSUB_SRC2_U32>;
1315def DS_INC_SRC2_U32_vi    : DS_Real_vi<0x83, DS_INC_SRC2_U32>;
1316def DS_DEC_SRC2_U32_vi    : DS_Real_vi<0x84, DS_DEC_SRC2_U32>;
1317def DS_MIN_SRC2_I32_vi    : DS_Real_vi<0x85, DS_MIN_SRC2_I32>;
1318def DS_MAX_SRC2_I32_vi    : DS_Real_vi<0x86, DS_MAX_SRC2_I32>;
1319def DS_MIN_SRC2_U32_vi    : DS_Real_vi<0x87, DS_MIN_SRC2_U32>;
1320def DS_MAX_SRC2_U32_vi    : DS_Real_vi<0x88, DS_MAX_SRC2_U32>;
1321def DS_AND_SRC2_B32_vi    : DS_Real_vi<0x89, DS_AND_SRC2_B32>;
1322def DS_OR_SRC2_B32_vi     : DS_Real_vi<0x8a, DS_OR_SRC2_B32>;
1323def DS_XOR_SRC2_B32_vi    : DS_Real_vi<0x8b, DS_XOR_SRC2_B32>;
1324def DS_WRITE_SRC2_B32_vi  : DS_Real_vi<0x8d, DS_WRITE_SRC2_B32>;
1325def DS_MIN_SRC2_F32_vi    : DS_Real_vi<0x92, DS_MIN_SRC2_F32>;
1326def DS_MAX_SRC2_F32_vi    : DS_Real_vi<0x93, DS_MAX_SRC2_F32>;
1327def DS_ADD_SRC2_F32_vi    : DS_Real_vi<0x95, DS_ADD_SRC2_F32>;
1328def DS_ADD_SRC2_U64_vi    : DS_Real_vi<0xc0, DS_ADD_SRC2_U64>;
1329def DS_SUB_SRC2_U64_vi    : DS_Real_vi<0xc1, DS_SUB_SRC2_U64>;
1330def DS_RSUB_SRC2_U64_vi   : DS_Real_vi<0xc2, DS_RSUB_SRC2_U64>;
1331def DS_INC_SRC2_U64_vi    : DS_Real_vi<0xc3, DS_INC_SRC2_U64>;
1332def DS_DEC_SRC2_U64_vi    : DS_Real_vi<0xc4, DS_DEC_SRC2_U64>;
1333def DS_MIN_SRC2_I64_vi    : DS_Real_vi<0xc5, DS_MIN_SRC2_I64>;
1334def DS_MAX_SRC2_I64_vi    : DS_Real_vi<0xc6, DS_MAX_SRC2_I64>;
1335def DS_MIN_SRC2_U64_vi    : DS_Real_vi<0xc7, DS_MIN_SRC2_U64>;
1336def DS_MAX_SRC2_U64_vi    : DS_Real_vi<0xc8, DS_MAX_SRC2_U64>;
1337def DS_AND_SRC2_B64_vi    : DS_Real_vi<0xc9, DS_AND_SRC2_B64>;
1338def DS_OR_SRC2_B64_vi     : DS_Real_vi<0xca, DS_OR_SRC2_B64>;
1339def DS_XOR_SRC2_B64_vi    : DS_Real_vi<0xcb, DS_XOR_SRC2_B64>;
1340def DS_WRITE_SRC2_B64_vi  : DS_Real_vi<0xcd, DS_WRITE_SRC2_B64>;
1341def DS_MIN_SRC2_F64_vi    : DS_Real_vi<0xd2, DS_MIN_SRC2_F64>;
1342def DS_MAX_SRC2_F64_vi    : DS_Real_vi<0xd3, DS_MAX_SRC2_F64>;
1343def DS_WRITE_B96_vi       : DS_Real_vi<0xde, DS_WRITE_B96>;
1344def DS_WRITE_B128_vi      : DS_Real_vi<0xdf, DS_WRITE_B128>;
1345def DS_READ_B96_vi        : DS_Real_vi<0xfe, DS_READ_B96>;
1346def DS_READ_B128_vi       : DS_Real_vi<0xff, DS_READ_B128>;
1347