xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1//===-- SOPInstructions.td - SOP 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
9def GPRIdxMode : CustomOperand<i32>;
10
11class SOP_Pseudo<string opName, dag outs, dag ins, string asmOps,
12                  list<dag> pattern=[]> :
13    InstSI<outs, ins, "", pattern>,
14    SIMCInstr<opName, SIEncodingFamily.NONE> {
15
16  let isPseudo = 1;
17  let isCodeGenOnly = 1;
18  let Size = 4;
19
20  string Mnemonic = opName;
21  string AsmOperands = asmOps;
22
23  bits<1> has_sdst = 0;
24}
25
26//===----------------------------------------------------------------------===//
27// SOP1 Instructions
28//===----------------------------------------------------------------------===//
29
30class SOP1_Pseudo <string opName, dag outs, dag ins,
31                   string asmOps, list<dag> pattern=[]> :
32  SOP_Pseudo<opName, outs, ins, " " # asmOps, pattern> {
33
34  let mayLoad = 0;
35  let mayStore = 0;
36  let hasSideEffects = 0;
37  let SALU = 1;
38  let SOP1 = 1;
39  let SchedRW = [WriteSALU];
40  let UseNamedOperandTable = 1;
41
42  bits<1> has_src0 = 1;
43  let has_sdst = 1;
44}
45
46class SOP1_Real<bits<8> op, SOP1_Pseudo ps, string real_name = ps.Mnemonic> :
47  InstSI <ps.OutOperandList, ps.InOperandList,
48          real_name # ps.AsmOperands>,
49  Enc32 {
50
51  let SALU = 1;
52  let SOP1 = 1;
53  let isPseudo = 0;
54  let isCodeGenOnly = 0;
55  let Size = 4;
56
57  // copy relevant pseudo op flags
58  let SubtargetPredicate = ps.SubtargetPredicate;
59  let AsmMatchConverter  = ps.AsmMatchConverter;
60  let SchedRW            = ps.SchedRW;
61  let mayLoad            = ps.mayLoad;
62  let mayStore           = ps.mayStore;
63
64  // encoding
65  bits<7> sdst;
66  bits<8> src0;
67
68  let Inst{7-0} = !if(ps.has_src0, src0, ?);
69  let Inst{15-8} = op;
70  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
71  let Inst{31-23} = 0x17d; //encoding;
72}
73
74class SOP1_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo <
75  opName, (outs SReg_32:$sdst),
76  !if(tied_in, (ins SSrc_b32:$src0, SReg_32:$sdst_in),
77               (ins SSrc_b32:$src0)),
78  "$sdst, $src0", pattern> {
79  let Constraints = !if(tied_in, "$sdst = $sdst_in", "");
80}
81
82// Only register input allowed.
83class SOP1_32R <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
84  opName, (outs SReg_32:$sdst), (ins SReg_32:$src0),
85  "$sdst, $src0", pattern>;
86
87// 32-bit input, no output.
88class SOP1_0_32 <string opName, list<dag> pattern = []> : SOP1_Pseudo <
89  opName, (outs), (ins SSrc_b32:$src0),
90  "$src0", pattern> {
91  let has_sdst = 0;
92}
93
94// Special case for movreld where sdst is treated as a use operand.
95class SOP1_32_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
96  opName, (outs), (ins SReg_32:$sdst, SSrc_b32:$src0),
97  "$sdst, $src0", pattern>;
98
99// Special case for movreld where sdst is treated as a use operand.
100class SOP1_64_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
101  opName, (outs), (ins SReg_64:$sdst, SSrc_b64:$src0),
102  "$sdst, $src0", pattern
103>;
104
105class SOP1_0_32R <string opName, list<dag> pattern = []> : SOP1_Pseudo <
106  opName, (outs), (ins SReg_32:$src0),
107  "$src0", pattern> {
108  let has_sdst = 0;
109}
110
111class SOP1_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
112  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0),
113  "$sdst, $src0", pattern
114>;
115
116// Only register input allowed.
117class SOP1_64R <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
118  opName, (outs SReg_64:$sdst), (ins SReg_64:$src0),
119  "$sdst, $src0", pattern
120>;
121
122// 64-bit input, 32-bit output.
123class SOP1_32_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
124  opName, (outs SReg_32:$sdst), (ins SSrc_b64:$src0),
125  "$sdst, $src0", pattern
126>;
127
128// 32-bit input, 64-bit output.
129class SOP1_64_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo <
130  opName, (outs SReg_64:$sdst),
131  !if(tied_in, (ins SSrc_b32:$src0, SReg_64:$sdst_in),
132               (ins SSrc_b32:$src0)),
133  "$sdst, $src0", pattern> {
134  let Constraints = !if(tied_in, "$sdst = $sdst_in", "");
135}
136
137// no input, 64-bit output.
138class SOP1_64_0 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
139  opName, (outs SReg_64:$sdst), (ins), "$sdst", pattern> {
140  let has_src0 = 0;
141}
142
143// 64-bit input, no output
144class SOP1_1 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
145  opName, (outs), (ins SReg_64:$src0), "$src0", pattern> {
146  let has_sdst = 0;
147}
148
149
150class UniformUnaryFrag<SDPatternOperator Op> : PatFrag <
151  (ops node:$src0),
152  (Op $src0),
153  [{ return !N->isDivergent(); }]> {
154  // This check is unnecessary as it's captured by the result register
155  // bank constraint.
156  //
157  // FIXME: Should add a way for the emitter to recognize this is a
158  // trivially true predicate to eliminate the check.
159  let GISelPredicateCode = [{return true;}];
160}
161
162class UniformBinFrag<SDPatternOperator Op> : PatFrag <
163  (ops node:$src0, node:$src1),
164  (Op $src0, $src1),
165  [{ return !N->isDivergent(); }]> {
166  // This check is unnecessary as it's captured by the result register
167  // bank constraint.
168  //
169  // FIXME: Should add a way for the emitter to recognize this is a
170  // trivially true predicate to eliminate the check.
171  let GISelPredicateCode = [{return true;}];
172}
173
174class UniformTernaryFrag<SDPatternOperator Op> : PatFrag <
175  (ops node:$src0, node:$src1, node:$src2),
176  (Op $src0, $src1, $src2),
177  [{ return !N->isDivergent(); }]> {
178  // This check is unnecessary as it's captured by the result register
179  // bank constraint.
180  //
181  // FIXME: Should add a way for the emitter to recognize this is a
182  // trivially true predicate to eliminate the check.
183  let GISelPredicateCode = [{return true;}];
184}
185
186class DivergentBinFrag<SDPatternOperator Op> : PatFrag <
187  (ops node:$src0, node:$src1),
188  (Op $src0, $src1),
189  [{ return N->isDivergent(); }]> {
190  // This check is unnecessary as it's captured by the result register
191  // bank constraint.
192  //
193  // FIXME: Should add a way for the emitter to recognize this is a
194  // trivially true predicate to eliminate the check.
195  let GISelPredicateCode = [{return true;}];
196}
197
198
199let isMoveImm = 1 in {
200  let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
201    def S_MOV_B32 : SOP1_32 <"s_mov_b32">;
202    def S_MOV_B64 : SOP1_64 <"s_mov_b64">;
203  } // End isReMaterializable = 1
204
205  let Uses = [SCC] in {
206    def S_CMOV_B32 : SOP1_32 <"s_cmov_b32">;
207    def S_CMOV_B64 : SOP1_64 <"s_cmov_b64">;
208  } // End Uses = [SCC]
209} // End isMoveImm = 1
210
211let Defs = [SCC] in {
212  def S_NOT_B32 : SOP1_32 <"s_not_b32",
213    [(set i32:$sdst, (UniformUnaryFrag<not> i32:$src0))]
214  >;
215
216  def S_NOT_B64 : SOP1_64 <"s_not_b64",
217    [(set i64:$sdst, (UniformUnaryFrag<not> i64:$src0))]
218  >;
219  def S_WQM_B32 : SOP1_32 <"s_wqm_b32",
220    [(set i32:$sdst, (int_amdgcn_s_wqm i32:$src0))]>;
221  def S_WQM_B64 : SOP1_64 <"s_wqm_b64",
222    [(set i64:$sdst, (int_amdgcn_s_wqm i64:$src0))]>;
223} // End Defs = [SCC]
224
225
226let WaveSizePredicate = isWave32 in {
227def : GCNPat <
228  (int_amdgcn_wqm_vote i1:$src0),
229  (S_WQM_B32 SSrc_b32:$src0)
230>;
231}
232
233let WaveSizePredicate = isWave64 in {
234def : GCNPat <
235  (int_amdgcn_wqm_vote i1:$src0),
236  (S_WQM_B64 SSrc_b64:$src0)
237>;
238}
239
240let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
241def S_BREV_B32 : SOP1_32 <"s_brev_b32",
242  [(set i32:$sdst, (UniformUnaryFrag<bitreverse> i32:$src0))]
243>;
244def S_BREV_B64 : SOP1_64 <"s_brev_b64",
245  [(set i64:$sdst, (UniformUnaryFrag<bitreverse> i64:$src0))]
246>;
247} // End isReMaterializable = 1, isAsCheapAsAMove = 1
248
249let Defs = [SCC] in {
250def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32">;
251def S_BCNT0_I32_B64 : SOP1_32_64 <"s_bcnt0_i32_b64">;
252def S_BCNT1_I32_B32 : SOP1_32 <"s_bcnt1_i32_b32",
253  [(set i32:$sdst, (UniformUnaryFrag<ctpop> i32:$src0))]
254>;
255def S_BCNT1_I32_B64 : SOP1_32_64 <"s_bcnt1_i32_b64",
256  [(set i32:$sdst, (UniformUnaryFrag<ctpop> i64:$src0))]
257>;
258} // End Defs = [SCC]
259
260let isReMaterializable = 1 in {
261def S_FF0_I32_B32 : SOP1_32 <"s_ff0_i32_b32">;
262def S_FF0_I32_B64 : SOP1_32_64 <"s_ff0_i32_b64">;
263def S_FF1_I32_B64 : SOP1_32_64 <"s_ff1_i32_b64",
264  [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbl_b32> i64:$src0))]
265>;
266
267def S_FF1_I32_B32 : SOP1_32 <"s_ff1_i32_b32",
268  [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbl_b32> i32:$src0))]
269>;
270
271def S_FLBIT_I32_B32 : SOP1_32 <"s_flbit_i32_b32",
272  [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_u32> i32:$src0))]
273>;
274
275def S_FLBIT_I32_B64 : SOP1_32_64 <"s_flbit_i32_b64",
276  [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_u32> i64:$src0))]
277>;
278def S_FLBIT_I32 : SOP1_32 <"s_flbit_i32",
279  [(set i32:$sdst, (UniformUnaryFrag<AMDGPUffbh_i32> i32:$src0))]
280>;
281def S_FLBIT_I32_I64 : SOP1_32_64 <"s_flbit_i32_i64">;
282def S_SEXT_I32_I8 : SOP1_32 <"s_sext_i32_i8",
283  [(set i32:$sdst, (UniformSextInreg<i8> i32:$src0))]
284>;
285def S_SEXT_I32_I16 : SOP1_32 <"s_sext_i32_i16",
286  [(set i32:$sdst, (UniformSextInreg<i16> i32:$src0))]
287>;
288} // End isReMaterializable = 1
289
290def S_BITSET0_B32 : SOP1_32    <"s_bitset0_b32", [], 1>;
291def S_BITSET0_B64 : SOP1_64_32 <"s_bitset0_b64", [], 1>;
292def S_BITSET1_B32 : SOP1_32    <"s_bitset1_b32", [], 1>;
293def S_BITSET1_B64 : SOP1_64_32 <"s_bitset1_b64", [], 1>;
294
295def S_GETPC_B64 : SOP1_64_0  <"s_getpc_b64">;
296// PSEUDO includes a workaround for a hardware anomaly where some ASICs
297// zero-extend the result from 48 bits instead of sign-extending.
298let isReMaterializable = 1 in
299def S_GETPC_B64_pseudo : SOP1_64_0  <"s_getpc_b64",
300  [(set i64:$sdst, (int_amdgcn_s_getpc))]
301>;
302
303let isTerminator = 1, isBarrier = 1, SchedRW = [WriteBranch] in {
304
305let isBranch = 1, isIndirectBranch = 1 in {
306def S_SETPC_B64 : SOP1_1  <"s_setpc_b64">;
307} // End isBranch = 1, isIndirectBranch = 1
308
309let isReturn = 1 in {
310// Define variant marked as return rather than branch.
311def S_SETPC_B64_return : SOP1_1<"">;
312}
313} // End isTerminator = 1, isBarrier = 1
314
315let isCall = 1 in {
316def S_SWAPPC_B64 : SOP1_64 <"s_swappc_b64"
317>;
318}
319
320def S_RFE_B64 : SOP1_1  <"s_rfe_b64">;
321
322let hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] in {
323
324def S_AND_SAVEEXEC_B64 : SOP1_64 <"s_and_saveexec_b64">;
325def S_OR_SAVEEXEC_B64 : SOP1_64 <"s_or_saveexec_b64">;
326def S_XOR_SAVEEXEC_B64 : SOP1_64 <"s_xor_saveexec_b64">;
327def S_ANDN2_SAVEEXEC_B64 : SOP1_64 <"s_andn2_saveexec_b64">;
328def S_ORN2_SAVEEXEC_B64 : SOP1_64 <"s_orn2_saveexec_b64">;
329def S_NAND_SAVEEXEC_B64 : SOP1_64 <"s_nand_saveexec_b64">;
330def S_NOR_SAVEEXEC_B64 : SOP1_64 <"s_nor_saveexec_b64">;
331def S_XNOR_SAVEEXEC_B64 : SOP1_64 <"s_xnor_saveexec_b64">;
332
333} // End hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC]
334
335def S_QUADMASK_B32 : SOP1_32 <"s_quadmask_b32",
336  [(set i32:$sdst, (int_amdgcn_s_quadmask i32:$src0))]>;
337def S_QUADMASK_B64 : SOP1_64 <"s_quadmask_b64",
338  [(set i64:$sdst, (int_amdgcn_s_quadmask i64:$src0))]>;
339
340let Uses = [M0] in {
341def S_MOVRELS_B32 : SOP1_32R <"s_movrels_b32">;
342def S_MOVRELS_B64 : SOP1_64R <"s_movrels_b64">;
343def S_MOVRELD_B32 : SOP1_32_movreld <"s_movreld_b32">;
344def S_MOVRELD_B64 : SOP1_64_movreld <"s_movreld_b64">;
345} // End Uses = [M0]
346
347let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in {
348def S_CBRANCH_JOIN : SOP1_0_32R <"s_cbranch_join">;
349} // End SubtargetPredicate = isGFX6GFX7GFX8GFX9
350
351let Defs = [SCC] in {
352def S_ABS_I32 : SOP1_32 <"s_abs_i32",
353    [(set i32:$sdst, (UniformUnaryFrag<abs> i32:$src0))]
354  >;
355} // End Defs = [SCC]
356
357let SubtargetPredicate = HasVGPRIndexMode in {
358def S_SET_GPR_IDX_IDX : SOP1_0_32<"s_set_gpr_idx_idx"> {
359  let Uses = [M0, MODE];
360  let Defs = [M0, MODE];
361}
362}
363
364let SubtargetPredicate = isGFX9Plus in {
365  let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in {
366    def S_ANDN1_SAVEEXEC_B64 : SOP1_64<"s_andn1_saveexec_b64">;
367    def S_ORN1_SAVEEXEC_B64  : SOP1_64<"s_orn1_saveexec_b64">;
368    def S_ANDN1_WREXEC_B64   : SOP1_64<"s_andn1_wrexec_b64">;
369    def S_ANDN2_WREXEC_B64   : SOP1_64<"s_andn2_wrexec_b64">;
370  } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC]
371
372  let isReMaterializable = 1 in
373  def S_BITREPLICATE_B64_B32 : SOP1_64_32<"s_bitreplicate_b64_b32",
374  [(set i64:$sdst, (int_amdgcn_s_bitreplicate i32:$src0))]>;
375} // End SubtargetPredicate = isGFX9Plus
376
377let SubtargetPredicate = isGFX10Plus in {
378  let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in {
379    def S_AND_SAVEEXEC_B32   : SOP1_32<"s_and_saveexec_b32">;
380    def S_OR_SAVEEXEC_B32    : SOP1_32<"s_or_saveexec_b32">;
381    def S_XOR_SAVEEXEC_B32   : SOP1_32<"s_xor_saveexec_b32">;
382    def S_ANDN2_SAVEEXEC_B32 : SOP1_32<"s_andn2_saveexec_b32">;
383    def S_ORN2_SAVEEXEC_B32  : SOP1_32<"s_orn2_saveexec_b32">;
384    def S_NAND_SAVEEXEC_B32  : SOP1_32<"s_nand_saveexec_b32">;
385    def S_NOR_SAVEEXEC_B32   : SOP1_32<"s_nor_saveexec_b32">;
386    def S_XNOR_SAVEEXEC_B32  : SOP1_32<"s_xnor_saveexec_b32">;
387    def S_ANDN1_SAVEEXEC_B32 : SOP1_32<"s_andn1_saveexec_b32">;
388    def S_ORN1_SAVEEXEC_B32  : SOP1_32<"s_orn1_saveexec_b32">;
389    def S_ANDN1_WREXEC_B32   : SOP1_32<"s_andn1_wrexec_b32">;
390    def S_ANDN2_WREXEC_B32   : SOP1_32<"s_andn2_wrexec_b32">;
391  } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC]
392
393  let Uses = [M0] in {
394    def S_MOVRELSD_2_B32 : SOP1_32<"s_movrelsd_2_b32">;
395  } // End Uses = [M0]
396} // End SubtargetPredicate = isGFX10Plus
397
398let SubtargetPredicate = isGFX11Plus in {
399  let hasSideEffects = 1 in {
400    // For s_sendmsg_rtn_* the src0 field encodes the message type directly; it
401    // is not an SGPR number.
402    def S_SENDMSG_RTN_B32 : SOP1_Pseudo<
403      "s_sendmsg_rtn_b32", (outs SReg_32:$sdst), (ins SendMsg:$src0),
404      "$sdst, $src0", [(set i32:$sdst, (int_amdgcn_s_sendmsg_rtn timm:$src0))]
405    >;
406    def S_SENDMSG_RTN_B64 : SOP1_Pseudo<
407      "s_sendmsg_rtn_b64", (outs SReg_64:$sdst), (ins SendMsg:$src0),
408      "$sdst, $src0", [(set i64:$sdst, (int_amdgcn_s_sendmsg_rtn timm:$src0))]
409    >;
410  }
411} // End SubtargetPredicate = isGFX11Plus
412
413class SOP1_F32_Inst<string opName, SDPatternOperator Op, ValueType vt0=f32,
414                    ValueType vt1=vt0> :
415  SOP1_32<opName, [(set vt0:$sdst, (UniformUnaryFrag<Op> vt1:$src0))]>;
416
417let SubtargetPredicate = HasSALUFloatInsts, Uses = [MODE],
418    SchedRW = [WriteSFPU], isReMaterializable = 1 in {
419  def S_CVT_F32_I32 : SOP1_F32_Inst<"s_cvt_f32_i32", sint_to_fp, f32, i32>;
420  def S_CVT_F32_U32 : SOP1_F32_Inst<"s_cvt_f32_u32", uint_to_fp, f32, i32>;
421
422  let mayRaiseFPException = 1 in {
423    def S_CVT_I32_F32    : SOP1_F32_Inst<"s_cvt_i32_f32", fp_to_sint, i32, f32>;
424    def S_CVT_U32_F32    : SOP1_F32_Inst<"s_cvt_u32_f32", fp_to_uint, i32, f32>;
425    def S_CVT_F32_F16    : SOP1_F32_Inst<"s_cvt_f32_f16", fpextend, f32, f16>;
426    def S_CVT_HI_F32_F16 : SOP1_32<"s_cvt_hi_f32_f16">;
427
428    def S_CEIL_F32  : SOP1_F32_Inst<"s_ceil_f32", fceil>;
429    def S_FLOOR_F32 : SOP1_F32_Inst<"s_floor_f32", ffloor>;
430    def S_TRUNC_F32 : SOP1_F32_Inst<"s_trunc_f32", ftrunc>;
431    def S_RNDNE_F32 : SOP1_F32_Inst<"s_rndne_f32", froundeven>;
432
433    let FPDPRounding = 1 in
434      def S_CVT_F16_F32 : SOP1_F32_Inst<"s_cvt_f16_f32", fpround, f16, f32>;
435
436    def S_CEIL_F16  : SOP1_F32_Inst<"s_ceil_f16", fceil, f16>;
437    def S_FLOOR_F16 : SOP1_F32_Inst<"s_floor_f16", ffloor, f16>;
438    def S_TRUNC_F16 : SOP1_F32_Inst<"s_trunc_f16", ftrunc, f16>;
439    def S_RNDNE_F16 : SOP1_F32_Inst<"s_rndne_f16", froundeven, f16>;
440  } // End mayRaiseFPException = 1
441} // End SubtargetPredicate = HasSALUFloatInsts, Uses = [MODE]
442  // SchedRW = [WriteSFPU], isReMaterializable = 1
443
444let hasSideEffects = 1 in {
445let has_sdst = 0 in {
446let Uses = [M0] in {
447def S_BARRIER_SIGNAL_M0 : SOP1_Pseudo <"s_barrier_signal m0", (outs), (ins),
448  "", [(int_amdgcn_s_barrier_signal_var M0)]>{
449  let SchedRW = [WriteBarrier];
450  let isConvergent = 1;
451}
452
453def S_BARRIER_SIGNAL_ISFIRST_M0 : SOP1_Pseudo <"s_barrier_signal_isfirst m0", (outs), (ins),
454  "", [(set SCC, (int_amdgcn_s_barrier_signal_isfirst_var M0))]>{
455  let Defs = [SCC];
456  let SchedRW = [WriteBarrier];
457  let isConvergent = 1;
458}
459
460def S_BARRIER_INIT_M0 : SOP1_Pseudo <"s_barrier_init m0", (outs), (ins),
461  "", []>{
462  let SchedRW = [WriteBarrier];
463  let isConvergent = 1;
464}
465
466def S_BARRIER_INIT_IMM : SOP1_Pseudo <"s_barrier_init", (outs),
467  (ins SplitBarrier:$src0), "$src0", []>{
468  let SchedRW = [WriteBarrier];
469  let isConvergent = 1;
470}
471
472def S_BARRIER_JOIN_M0 : SOP1_Pseudo <"s_barrier_join m0", (outs), (ins),
473  "", []>{
474  let SchedRW = [WriteBarrier];
475  let isConvergent = 1;
476}
477
478def S_WAKEUP_BARRIER_M0 : SOP1_Pseudo <"s_wakeup_barrier m0", (outs), (ins),
479  "", []>{
480  let SchedRW = [WriteBarrier];
481  let isConvergent = 1;
482}
483} // End Uses = [M0]
484
485def S_BARRIER_SIGNAL_IMM : SOP1_Pseudo <"s_barrier_signal", (outs),
486  (ins SplitBarrier:$src0), "$src0", [(int_amdgcn_s_barrier_signal timm:$src0)]>{
487  let SchedRW = [WriteBarrier];
488  let isConvergent = 1;
489}
490
491def S_BARRIER_SIGNAL_ISFIRST_IMM : SOP1_Pseudo <"s_barrier_signal_isfirst", (outs),
492  (ins SplitBarrier:$src0), "$src0", [(set SCC, (int_amdgcn_s_barrier_signal_isfirst timm:$src0))]>{
493  let Defs = [SCC];
494  let SchedRW = [WriteBarrier];
495  let isConvergent = 1;
496}
497
498def S_BARRIER_JOIN_IMM : SOP1_Pseudo <"s_barrier_join", (outs),
499  (ins SplitBarrier:$src0), "$src0", []>{
500  let SchedRW = [WriteBarrier];
501  let isConvergent = 1;
502}
503
504def S_WAKEUP_BARRIER_IMM : SOP1_Pseudo <"s_wakeup_barrier", (outs),
505  (ins SplitBarrier:$src0), "$src0", []>{
506  let SchedRW = [WriteBarrier];
507  let isConvergent = 1;
508}
509} // End has_sdst = 0
510
511def S_GET_BARRIER_STATE_IMM : SOP1_Pseudo <"s_get_barrier_state", (outs SSrc_b32:$sdst),
512  (ins SplitBarrier:$src0), "$sdst, $src0", []>{
513  let SchedRW = [WriteBarrier];
514  let isConvergent = 1;
515}
516
517def S_GET_BARRIER_STATE_M0 : SOP1_Pseudo <"s_get_barrier_state $sdst, m0", (outs SSrc_b32:$sdst),
518  (ins), "", []>{
519  let Uses = [M0];
520  let SchedRW = [WriteBarrier];
521  let isConvergent = 1;
522}
523} // End hasSideEffects = 1
524
525//===----------------------------------------------------------------------===//
526// SOP2 Instructions
527//===----------------------------------------------------------------------===//
528
529class SOP2_Pseudo<string opName, dag outs, dag ins,
530                  string asmOps, list<dag> pattern=[]> :
531  SOP_Pseudo<opName, outs, ins, " " # asmOps, pattern> {
532
533  let mayLoad = 0;
534  let mayStore = 0;
535  let hasSideEffects = 0;
536  let SALU = 1;
537  let SOP2 = 1;
538  let SchedRW = [WriteSALU];
539  let UseNamedOperandTable = 1;
540
541  let has_sdst = 1;
542
543  // Pseudo instructions have no encodings, but adding this field here allows
544  // us to do:
545  // let sdst = xxx in {
546  // for multiclasses that include both real and pseudo instructions.
547  // field bits<7> sdst = 0;
548}
549
550class SOP2_Real<SOP_Pseudo ps, string real_name = ps.Mnemonic> :
551  InstSI <ps.OutOperandList, ps.InOperandList,
552          real_name # ps.AsmOperands> {
553  let SALU = 1;
554  let SOP2 = 1;
555  let isPseudo = 0;
556  let isCodeGenOnly = 0;
557
558  // copy relevant pseudo op flags
559  let SubtargetPredicate   = ps.SubtargetPredicate;
560  let AsmMatchConverter    = ps.AsmMatchConverter;
561  let UseNamedOperandTable = ps.UseNamedOperandTable;
562  let TSFlags              = ps.TSFlags;
563  let SchedRW              = ps.SchedRW;
564  let mayLoad              = ps.mayLoad;
565  let mayStore             = ps.mayStore;
566  let Constraints          = ps.Constraints;
567  let DisableEncoding      = ps.DisableEncoding;
568
569  // encoding
570  bits<7> sdst;
571  bits<8> src0;
572  bits<8> src1;
573  bits<32> imm;
574}
575
576class SOP2_Real32<bits<7> op, SOP_Pseudo ps, string real_name = ps.Mnemonic> :
577  SOP2_Real<ps, real_name>, Enc32 {
578  let Inst{7-0}   = src0;
579  let Inst{15-8}  = src1;
580  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
581  let Inst{29-23} = op;
582  let Inst{31-30} = 0x2; // encoding
583}
584
585class SOP2_Real64<bits<7> op, SOP_Pseudo ps, string real_name = ps.Mnemonic> :
586  SOP2_Real<ps, real_name>, Enc64 {
587  let Inst{7-0}   = src0;
588  let Inst{15-8}  = src1;
589  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
590  let Inst{29-23} = op;
591  let Inst{31-30} = 0x2; // encoding
592  let Inst{63-32} = imm;
593}
594
595class SOP2_F16 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
596  opName, (outs SReg_32:$sdst), (ins SSrc_f16:$src0, SSrc_f16:$src1),
597  "$sdst, $src0, $src1", pattern
598>;
599
600class SOP2_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
601  opName, (outs SReg_32:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1),
602  "$sdst, $src0, $src1", pattern
603>;
604
605class SOP2_F32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
606  opName, (outs SReg_32:$sdst), (ins SSrc_f32:$src0, SSrc_f32:$src1),
607  "$sdst, $src0, $src1", pattern
608>;
609
610class SOP2_64 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
611  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1),
612  "$sdst, $src0, $src1", pattern
613>;
614
615class SOP2_64_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
616  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b32:$src1),
617  "$sdst, $src0, $src1", pattern
618>;
619
620class SOP2_64_32_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
621  opName, (outs SReg_64:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1),
622  "$sdst, $src0, $src1", pattern
623>;
624
625
626let Defs = [SCC] in { // Carry out goes to SCC
627let isCommutable = 1 in {
628def S_ADD_U32 : SOP2_32 <"s_add_u32">;
629def S_ADD_I32 : SOP2_32 <"s_add_i32",
630  [(set i32:$sdst, (UniformBinFrag<add> SSrc_b32:$src0, SSrc_b32:$src1))]
631>;
632} // End isCommutable = 1
633
634def S_SUB_U32 : SOP2_32 <"s_sub_u32">;
635def S_SUB_I32 : SOP2_32 <"s_sub_i32",
636  [(set i32:$sdst, (UniformBinFrag<sub> SSrc_b32:$src0, SSrc_b32:$src1))]
637>;
638
639let Uses = [SCC] in { // Carry in comes from SCC
640let isCommutable = 1 in {
641def S_ADDC_U32 : SOP2_32 <"s_addc_u32",
642  [(set i32:$sdst, (UniformBinFrag<adde> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>;
643} // End isCommutable = 1
644
645def S_SUBB_U32 : SOP2_32 <"s_subb_u32",
646  [(set i32:$sdst, (UniformBinFrag<sube> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>;
647} // End Uses = [SCC]
648
649let isCommutable = 1 in {
650def S_MIN_I32 : SOP2_32 <"s_min_i32",
651  [(set i32:$sdst, (UniformBinFrag<smin> i32:$src0, i32:$src1))]
652>;
653def S_MIN_U32 : SOP2_32 <"s_min_u32",
654  [(set i32:$sdst, (UniformBinFrag<umin> i32:$src0, i32:$src1))]
655>;
656def S_MAX_I32 : SOP2_32 <"s_max_i32",
657  [(set i32:$sdst, (UniformBinFrag<smax> i32:$src0, i32:$src1))]
658>;
659def S_MAX_U32 : SOP2_32 <"s_max_u32",
660  [(set i32:$sdst, (UniformBinFrag<umax> i32:$src0, i32:$src1))]
661>;
662} // End isCommutable = 1
663} // End Defs = [SCC]
664
665let SubtargetPredicate = isGFX12Plus in {
666  def S_ADD_U64 : SOP2_64<"s_add_u64">{
667    let isCommutable = 1;
668  }
669
670  def S_SUB_U64 : SOP2_64<"s_sub_u64">;
671
672  def S_MUL_U64 : SOP2_64 <"s_mul_u64",
673    [(set i64:$sdst, (UniformBinFrag<mul> i64:$src0, i64:$src1))]> {
674    let isCommutable = 1;
675  }
676
677  // The higher 32-bits of the inputs contain the sign extension bits.
678  def S_MUL_I64_I32_PSEUDO : SPseudoInstSI <
679    (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1)
680  >;
681
682  // The higher 32-bits of the inputs are zero.
683  def S_MUL_U64_U32_PSEUDO : SPseudoInstSI <
684    (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1)
685  >;
686
687} // End SubtargetPredicate = isGFX12Plus
688
689let Uses = [SCC] in {
690  def S_CSELECT_B32 : SOP2_32 <"s_cselect_b32">;
691  def S_CSELECT_B64 : SOP2_64 <"s_cselect_b64">;
692} // End Uses = [SCC]
693
694let Defs = [SCC] in {
695let isCommutable = 1 in {
696def S_AND_B32 : SOP2_32 <"s_and_b32",
697  [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, i32:$src1))]
698>;
699
700def S_AND_B64 : SOP2_64 <"s_and_b64",
701  [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, i64:$src1))]
702>;
703
704def S_OR_B32 : SOP2_32 <"s_or_b32",
705  [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, i32:$src1))]
706>;
707
708def S_OR_B64 : SOP2_64 <"s_or_b64",
709  [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, i64:$src1))]
710>;
711
712def S_XOR_B32 : SOP2_32 <"s_xor_b32",
713  [(set i32:$sdst, (UniformBinFrag<xor> i32:$src0, i32:$src1))]
714>;
715
716def S_XOR_B64 : SOP2_64 <"s_xor_b64",
717  [(set i64:$sdst, (UniformBinFrag<xor> i64:$src0, i64:$src1))]
718>;
719
720def S_XNOR_B32 : SOP2_32 <"s_xnor_b32",
721  [(set i32:$sdst, (UniformUnaryFrag<not> (xor_oneuse i32:$src0, i32:$src1)))]
722>;
723
724def S_XNOR_B64 : SOP2_64 <"s_xnor_b64",
725  [(set i64:$sdst, (UniformUnaryFrag<not> (xor_oneuse i64:$src0, i64:$src1)))]
726>;
727
728def S_NAND_B32 : SOP2_32 <"s_nand_b32",
729  [(set i32:$sdst, (UniformUnaryFrag<not> (and_oneuse i32:$src0, i32:$src1)))]
730>;
731
732def S_NAND_B64 : SOP2_64 <"s_nand_b64",
733  [(set i64:$sdst, (UniformUnaryFrag<not> (and_oneuse i64:$src0, i64:$src1)))]
734>;
735
736def S_NOR_B32 : SOP2_32 <"s_nor_b32",
737  [(set i32:$sdst, (UniformUnaryFrag<not> (or_oneuse i32:$src0, i32:$src1)))]
738>;
739
740def S_NOR_B64 : SOP2_64 <"s_nor_b64",
741  [(set i64:$sdst, (UniformUnaryFrag<not> (or_oneuse i64:$src0, i64:$src1)))]
742>;
743} // End isCommutable = 1
744
745// There are also separate patterns for types other than i32
746def S_ANDN2_B32 : SOP2_32 <"s_andn2_b32",
747  [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))]
748>;
749
750def S_ANDN2_B64 : SOP2_64 <"s_andn2_b64",
751  [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))]
752>;
753
754def S_ORN2_B32 : SOP2_32 <"s_orn2_b32",
755  [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))]
756>;
757
758def S_ORN2_B64 : SOP2_64 <"s_orn2_b64",
759  [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))]
760>;
761} // End Defs = [SCC]
762
763// Use added complexity so these patterns are preferred to the VALU patterns.
764let AddedComplexity = 1 in {
765
766let Defs = [SCC] in {
767// TODO: b64 versions require VOP3 change since v_lshlrev_b64 is VOP3
768def S_LSHL_B32 : SOP2_32 <"s_lshl_b32",
769  [(set SReg_32:$sdst, (UniformBinFrag<cshl_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
770>;
771def S_LSHL_B64 : SOP2_64_32 <"s_lshl_b64",
772  [(set SReg_64:$sdst, (UniformBinFrag<cshl_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
773>;
774def S_LSHR_B32 : SOP2_32 <"s_lshr_b32",
775  [(set SReg_32:$sdst, (UniformBinFrag<csrl_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
776>;
777def S_LSHR_B64 : SOP2_64_32 <"s_lshr_b64",
778  [(set SReg_64:$sdst, (UniformBinFrag<csrl_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
779>;
780def S_ASHR_I32 : SOP2_32 <"s_ashr_i32",
781  [(set SReg_32:$sdst, (UniformBinFrag<csra_32> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
782>;
783def S_ASHR_I64 : SOP2_64_32 <"s_ashr_i64",
784  [(set SReg_64:$sdst, (UniformBinFrag<csra_64> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
785>;
786} // End Defs = [SCC]
787
788let isReMaterializable = 1 in {
789def S_BFM_B32 : SOP2_32 <"s_bfm_b32",
790  [(set i32:$sdst, (UniformBinFrag<AMDGPUbfm> i32:$src0, i32:$src1))]>;
791def S_BFM_B64 : SOP2_64_32_32 <"s_bfm_b64">;
792
793def S_MUL_I32 : SOP2_32 <"s_mul_i32",
794  [(set i32:$sdst, (UniformBinFrag<mul> i32:$src0, i32:$src1))]> {
795  let isCommutable = 1;
796}
797} // End isReMaterializable = 1
798} // End AddedComplexity = 1
799
800let Defs = [SCC] in {
801def S_BFE_U32 : SOP2_32 <"s_bfe_u32">;
802def S_BFE_I32 : SOP2_32 <"s_bfe_i32">;
803def S_BFE_U64 : SOP2_64_32 <"s_bfe_u64">;
804def S_BFE_I64 : SOP2_64_32 <"s_bfe_i64">;
805} // End Defs = [SCC]
806
807def S_CBRANCH_G_FORK : SOP2_Pseudo <
808  "s_cbranch_g_fork", (outs),
809  (ins SCSrc_b64:$src0, SCSrc_b64:$src1),
810  "$src0, $src1"
811> {
812  let has_sdst = 0;
813  let SubtargetPredicate = isGFX6GFX7GFX8GFX9;
814}
815
816let Defs = [SCC] in {
817def S_ABSDIFF_I32 : SOP2_32 <"s_absdiff_i32">;
818} // End Defs = [SCC]
819
820let SubtargetPredicate = isGFX8GFX9 in {
821  def S_RFE_RESTORE_B64 : SOP2_Pseudo <
822    "s_rfe_restore_b64", (outs),
823    (ins SSrc_b64:$src0, SSrc_b32:$src1),
824    "$src0, $src1"
825  > {
826    let hasSideEffects = 1;
827    let has_sdst = 0;
828  }
829}
830
831let SubtargetPredicate = isGFX9Plus in {
832  let isReMaterializable = 1 in {
833    def S_PACK_LL_B32_B16 : SOP2_32<"s_pack_ll_b32_b16">;
834    def S_PACK_LH_B32_B16 : SOP2_32<"s_pack_lh_b32_b16">;
835    def S_PACK_HH_B32_B16 : SOP2_32<"s_pack_hh_b32_b16">;
836  } // End isReMaterializable = 1
837
838  let Defs = [SCC] in {
839    def S_LSHL1_ADD_U32 : SOP2_32<"s_lshl1_add_u32",
840      [(set i32:$sdst, (shl1_add SSrc_b32:$src0, SSrc_b32:$src1))]
841    >;
842    def S_LSHL2_ADD_U32 : SOP2_32<"s_lshl2_add_u32",
843      [(set i32:$sdst, (shl2_add SSrc_b32:$src0, SSrc_b32:$src1))]
844    >;
845    def S_LSHL3_ADD_U32 : SOP2_32<"s_lshl3_add_u32",
846      [(set i32:$sdst, (shl3_add SSrc_b32:$src0, SSrc_b32:$src1))]
847    >;
848    def S_LSHL4_ADD_U32 : SOP2_32<"s_lshl4_add_u32",
849      [(set i32:$sdst, (shl4_add SSrc_b32:$src0, SSrc_b32:$src1))]
850    >;
851  } // End Defs = [SCC]
852
853  let isCommutable = 1, isReMaterializable = 1 in {
854    def S_MUL_HI_U32 : SOP2_32<"s_mul_hi_u32",
855      [(set i32:$sdst, (UniformBinFrag<mulhu> SSrc_b32:$src0, SSrc_b32:$src1))]>;
856    def S_MUL_HI_I32 : SOP2_32<"s_mul_hi_i32",
857      [(set i32:$sdst, (UniformBinFrag<mulhs> SSrc_b32:$src0, SSrc_b32:$src1))]>;
858  } // End isCommutable = 1, isReMaterializable = 1
859} // End SubtargetPredicate = isGFX9Plus
860
861let SubtargetPredicate = isGFX11Plus in {
862  def S_PACK_HL_B32_B16 : SOP2_32<"s_pack_hl_b32_b16">;
863} // End SubtargetPredicate = isGFX11Plus
864
865class SOP2_F32_Inst<string opName, SDPatternOperator Op, ValueType dstVt=f32> :
866  SOP2_F32<opName,
867    [(set dstVt:$sdst, (UniformBinFrag<Op> SSrc_f32:$src0, SSrc_f32:$src1))]>;
868
869class SOP2_F16_Inst<string opName, SDPatternOperator Op> :
870  SOP2_F16<opName,
871    [(set f16:$sdst, (UniformBinFrag<Op> SSrc_f16:$src0, SSrc_f16:$src1))]>;
872
873let SubtargetPredicate = HasSALUFloatInsts, mayRaiseFPException = 1,
874    Uses = [MODE], SchedRW = [WriteSFPU] in {
875  let isReMaterializable = 1 in {
876    let isCommutable = 1 in {
877      def S_ADD_F32 : SOP2_F32_Inst<"s_add_f32", any_fadd>;
878      def S_MIN_F32 : SOP2_F32_Inst<"s_min_f32", fminnum_like>;
879      def S_MAX_F32 : SOP2_F32_Inst<"s_max_f32", fmaxnum_like>;
880      def S_MUL_F32 : SOP2_F32_Inst<"s_mul_f32", any_fmul>;
881
882      let FixedSize = 1 in
883      def S_FMAAK_F32 : SOP2_Pseudo<
884        "s_fmaak_f32", (outs SReg_32:$sdst),
885        (ins SSrc_f32_Deferred:$src0, SSrc_f32_Deferred:$src1, KImmFP32:$imm),
886        "$sdst, $src0, $src1, $imm"
887      >;
888
889      let FPDPRounding = 1 in {
890        def S_ADD_F16 : SOP2_F16_Inst<"s_add_f16", any_fadd>;
891        def S_MUL_F16 : SOP2_F16_Inst<"s_mul_f16", any_fmul>;
892      } // End FPDPRounding
893
894      def S_MIN_F16 : SOP2_F16_Inst<"s_min_f16", fminnum_like>;
895      def S_MAX_F16 : SOP2_F16_Inst<"s_max_f16", fmaxnum_like>;
896    } // End isCommutable = 1
897
898    let FPDPRounding = 1 in
899      def S_SUB_F16 : SOP2_F16_Inst<"s_sub_f16", any_fsub>;
900
901    def S_SUB_F32            : SOP2_F32_Inst<"s_sub_f32", any_fsub>;
902    def S_CVT_PK_RTZ_F16_F32 : SOP2_F32_Inst<"s_cvt_pk_rtz_f16_f32",
903                                             AMDGPUpkrtz_f16_f32, v2f16>;
904
905    let FixedSize = 1 in
906    def S_FMAMK_F32 : SOP2_Pseudo<
907      "s_fmamk_f32", (outs SReg_32:$sdst),
908      (ins SSrc_f32_Deferred:$src0, KImmFP32:$imm, SSrc_f32_Deferred:$src1),
909      "$sdst, $src0, $imm, $src1"
910    >;
911  } // End isReMaterializable = 1
912
913  let Constraints = "$sdst = $src2", DisableEncoding="$src2",
914      isCommutable = 1, AddedComplexity = 20 in {
915    def S_FMAC_F32 : SOP2_Pseudo<
916      "s_fmac_f32", (outs SReg_32:$sdst),
917      (ins SSrc_f32:$src0, SSrc_f32:$src1, SReg_32:$src2),
918      "$sdst, $src0, $src1",
919      [(set f32:$sdst, (UniformTernaryFrag<any_fma> SSrc_f32:$src0, SSrc_f32:$src1, SReg_32:$src2))]
920    >;
921
922    def S_FMAC_F16 : SOP2_Pseudo<
923      "s_fmac_f16", (outs SReg_32:$sdst),
924      (ins SSrc_f16:$src0, SSrc_f16:$src1, SReg_32:$src2),
925      "$sdst, $src0, $src1",
926      [(set f16:$sdst, (UniformTernaryFrag<any_fma> SSrc_f16:$src0, SSrc_f16:$src1, SReg_32:$src2))]
927    >;
928  } // End Constraints = "$sdst = $src2", DisableEncoding="$src2",
929    // isCommutable = 1, AddedComplexity = 20
930} // End SubtargetPredicate = HasSALUFloatInsts, mayRaiseFPException = 1,
931  // Uses = [MODE], SchedRW = [WriteSFPU]
932
933// On GFX12 MIN/MAX instructions do not read MODE register.
934let SubtargetPredicate = isGFX12Plus, mayRaiseFPException = 1, isCommutable = 1,
935    isReMaterializable = 1, SchedRW = [WriteSFPU] in {
936  def S_MINIMUM_F32 : SOP2_F32_Inst<"s_minimum_f32", fminimum>;
937  def S_MAXIMUM_F32 : SOP2_F32_Inst<"s_maximum_f32", fmaximum>;
938  def S_MINIMUM_F16 : SOP2_F16_Inst<"s_minimum_f16", fminimum>;
939  def S_MAXIMUM_F16 : SOP2_F16_Inst<"s_maximum_f16", fmaximum>;
940}
941
942//===----------------------------------------------------------------------===//
943// SOPK Instructions
944//===----------------------------------------------------------------------===//
945
946class SOPK_Pseudo <string opName, dag outs, dag ins,
947                   string asmOps, list<dag> pattern=[]> :
948  SOP_Pseudo<opName, outs, ins, " " # asmOps, pattern> {
949  let mayLoad = 0;
950  let mayStore = 0;
951  let hasSideEffects = 0;
952  let SALU = 1;
953  let SOPK = 1;
954  let FixedSize = 1;
955  let SchedRW = [WriteSALU];
956  let UseNamedOperandTable = 1;
957
958  let has_sdst = 1;
959}
960
961class SOPK_Real<SOPK_Pseudo ps, string real_name = ps.Mnemonic> :
962  InstSI <ps.OutOperandList, ps.InOperandList,
963          real_name # ps.AsmOperands> {
964  let SALU = 1;
965  let SOPK = 1;
966  let isPseudo = 0;
967  let isCodeGenOnly = 0;
968  let UseNamedOperandTable = 1;
969
970  // copy relevant pseudo op flags
971  let SubtargetPredicate = ps.SubtargetPredicate;
972  let AsmMatchConverter  = ps.AsmMatchConverter;
973  let DisableEncoding    = ps.DisableEncoding;
974  let Constraints        = ps.Constraints;
975  let SchedRW            = ps.SchedRW;
976  let mayLoad            = ps.mayLoad;
977  let mayStore           = ps.mayStore;
978  let isBranch           = ps.isBranch;
979  let isCall             = ps.isCall;
980
981  // encoding
982  bits<7>  sdst;
983  bits<16> simm16;
984  bits<32> imm;
985}
986
987class SOPK_Real32<bits<5> op, SOPK_Pseudo ps, string real_name = ps.Mnemonic> :
988  SOPK_Real <ps, real_name>,
989  Enc32 {
990  let Inst{15-0}  = simm16;
991  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
992  let Inst{27-23} = op;
993  let Inst{31-28} = 0xb; //encoding
994}
995
996class SOPK_Real64<bits<5> op, SOPK_Pseudo ps> :
997  SOPK_Real<ps>,
998  Enc64 {
999  let Inst{15-0}  = simm16;
1000  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
1001  let Inst{27-23} = op;
1002  let Inst{31-28} = 0xb; //encoding
1003  let Inst{63-32} = imm;
1004}
1005
1006class SOPKInstTable <bit is_sopk, string cmpOp = ""> {
1007  bit IsSOPK = is_sopk;
1008  string BaseCmpOp = cmpOp;
1009}
1010
1011class SOPK_32 <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
1012  opName,
1013  (outs SReg_32:$sdst),
1014  (ins s16imm:$simm16),
1015  "$sdst, $simm16",
1016  pattern>;
1017
1018class SOPK_32_BR <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
1019  opName,
1020  (outs),
1021  (ins SOPPBrTarget:$simm16, SReg_32:$sdst),
1022  "$sdst, $simm16",
1023  pattern> {
1024  let Defs = [EXEC];
1025  let Uses = [EXEC];
1026  let isBranch = 1;
1027  let isTerminator = 1;
1028  let SchedRW = [WriteBranch];
1029}
1030
1031class SOPK_SCC <string opName, string base_op, bit isSignExt> : SOPK_Pseudo <
1032  opName,
1033  (outs),
1034  !if(isSignExt,
1035      (ins SReg_32:$sdst, s16imm:$simm16),
1036      (ins SReg_32:$sdst, u16imm:$simm16)),
1037  "$sdst, $simm16">,
1038  SOPKInstTable<1, base_op>{
1039  let Defs = [SCC];
1040}
1041
1042class SOPK_32TIE <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
1043  opName,
1044  (outs SReg_32:$sdst),
1045  (ins SReg_32:$src0, s16imm:$simm16),
1046  "$sdst, $simm16",
1047  pattern
1048>;
1049
1050let isReMaterializable = 1, isMoveImm = 1 in {
1051def S_MOVK_I32 : SOPK_32 <"s_movk_i32">;
1052} // End isReMaterializable = 1
1053let Uses = [SCC] in {
1054def S_CMOVK_I32 : SOPK_32 <"s_cmovk_i32">;
1055}
1056
1057let isCompare = 1 in {
1058
1059// This instruction is disabled for now until we can figure out how to teach
1060// the instruction selector to correctly use the  S_CMP* vs V_CMP*
1061// instructions.
1062//
1063// When this instruction is enabled the code generator sometimes produces this
1064// invalid sequence:
1065//
1066// SCC = S_CMPK_EQ_I32 SGPR0, imm
1067// VCC = COPY SCC
1068// VGPR0 = V_CNDMASK VCC, VGPR0, VGPR1
1069//
1070// def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32",
1071//   [(set i1:$dst, (setcc i32:$src0, imm:$src1, SETEQ))]
1072// >;
1073
1074def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32", "s_cmp_eq_i32", 1>;
1075def S_CMPK_LG_I32 : SOPK_SCC <"s_cmpk_lg_i32", "s_cmp_lg_i32", 1>;
1076def S_CMPK_GT_I32 : SOPK_SCC <"s_cmpk_gt_i32", "s_cmp_gt_i32", 1>;
1077def S_CMPK_GE_I32 : SOPK_SCC <"s_cmpk_ge_i32", "s_cmp_ge_i32", 1>;
1078def S_CMPK_LT_I32 : SOPK_SCC <"s_cmpk_lt_i32", "s_cmp_lt_i32", 1>;
1079def S_CMPK_LE_I32 : SOPK_SCC <"s_cmpk_le_i32", "s_cmp_le_i32", 1>;
1080
1081let SOPKZext = 1 in {
1082def S_CMPK_EQ_U32 : SOPK_SCC <"s_cmpk_eq_u32", "s_cmp_eq_u32", 0>;
1083def S_CMPK_LG_U32 : SOPK_SCC <"s_cmpk_lg_u32", "s_cmp_lg_u32", 0>;
1084def S_CMPK_GT_U32 : SOPK_SCC <"s_cmpk_gt_u32", "s_cmp_gt_u32", 0>;
1085def S_CMPK_GE_U32 : SOPK_SCC <"s_cmpk_ge_u32", "s_cmp_ge_u32", 0>;
1086def S_CMPK_LT_U32 : SOPK_SCC <"s_cmpk_lt_u32", "s_cmp_lt_u32", 0>;
1087def S_CMPK_LE_U32 : SOPK_SCC <"s_cmpk_le_u32", "s_cmp_le_u32", 0>;
1088} // End SOPKZext = 1
1089} // End isCompare = 1
1090
1091let isCommutable = 1, DisableEncoding = "$src0",
1092    Constraints = "$sdst = $src0" in {
1093  let Defs = [SCC] in
1094    def S_ADDK_I32 : SOPK_32TIE <"s_addk_i32">;
1095  def S_MULK_I32 : SOPK_32TIE <"s_mulk_i32">;
1096}
1097
1098let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in
1099def S_CBRANCH_I_FORK : SOPK_Pseudo <
1100  "s_cbranch_i_fork",
1101  (outs), (ins SReg_64:$sdst, SOPPBrTarget:$simm16),
1102  "$sdst, $simm16"
1103>;
1104
1105// This is hasSideEffects to allow its use in readcyclecounter selection.
1106// FIXME: Need to truncate immediate to 16-bits.
1107// FIXME: Missing mode register use. Should have separate pseudos for
1108// known may read MODE and only read MODE.
1109def S_GETREG_B32 : SOPK_Pseudo <
1110  "s_getreg_b32",
1111  (outs SReg_32:$sdst), (ins hwreg:$simm16),
1112  "$sdst, $simm16",
1113  [(set i32:$sdst, (int_amdgcn_s_getreg (i32 timm:$simm16)))]> {
1114  let SOPKZext = 1;
1115  let hasSideEffects = 1;
1116}
1117
1118let Defs = [MODE], Uses = [MODE] in {
1119
1120// FIXME: Need to truncate immediate to 16-bits.
1121class S_SETREG_B32_Pseudo <list<dag> pattern=[]> : SOPK_Pseudo <
1122  "s_setreg_b32",
1123  (outs), (ins SReg_32:$sdst, hwreg:$simm16),
1124  "$simm16, $sdst",
1125  pattern>;
1126
1127def S_SETREG_B32 : S_SETREG_B32_Pseudo <
1128  [(int_amdgcn_s_setreg (i32 SIMM16bit:$simm16), i32:$sdst)]> {
1129  // Use custom inserter to optimize some cases to
1130  // S_DENORM_MODE/S_ROUND_MODE/S_SETREG_B32_mode.
1131  let usesCustomInserter = 1;
1132  let hasSideEffects = 1;
1133}
1134
1135// Variant of SETREG that is guaranteed to only touch FP bits in the MODE
1136// register, so doesn't have unmodeled side effects.
1137def S_SETREG_B32_mode : S_SETREG_B32_Pseudo {
1138  let hasSideEffects = 0;
1139}
1140
1141// FIXME: Not on SI?
1142//def S_GETREG_REGRD_B32 : SOPK_32 <sopk<0x14, 0x13>, "s_getreg_regrd_b32">;
1143
1144class S_SETREG_IMM32_B32_Pseudo : SOPK_Pseudo <
1145  "s_setreg_imm32_b32",
1146  (outs), (ins i32imm:$imm, hwreg:$simm16),
1147  "$simm16, $imm"> {
1148  let Size = 8; // Unlike every other SOPK instruction.
1149  let has_sdst = 0;
1150}
1151
1152def S_SETREG_IMM32_B32 : S_SETREG_IMM32_B32_Pseudo {
1153  let hasSideEffects = 1;
1154}
1155
1156// Variant of SETREG_IMM32 that is guaranteed to only touch FP bits in the MODE
1157// register, so doesn't have unmodeled side effects.
1158def S_SETREG_IMM32_B32_mode : S_SETREG_IMM32_B32_Pseudo {
1159  let hasSideEffects = 0;
1160}
1161
1162} // End Defs = [MODE], Uses = [MODE]
1163
1164class SOPK_WAITCNT<string opName, list<dag> pat=[]> :
1165    SOPK_Pseudo<
1166        opName,
1167        (outs),
1168        (ins SReg_32:$sdst, s16imm:$simm16),
1169        "$sdst, $simm16",
1170        pat> {
1171  let hasSideEffects = 1;
1172  let mayLoad = 1;
1173  let mayStore = 1;
1174  let has_sdst = 1; // First source takes place of sdst in encoding
1175}
1176
1177let SubtargetPredicate = isGFX9Plus in {
1178  def S_CALL_B64 : SOPK_Pseudo<
1179      "s_call_b64",
1180      (outs SReg_64:$sdst),
1181      (ins SOPPBrTarget:$simm16),
1182      "$sdst, $simm16"> {
1183    let isCall = 1;
1184  }
1185} // End SubtargetPredicate = isGFX9Plus
1186
1187let SubtargetPredicate = isGFX10Plus in {
1188  def S_VERSION : SOPK_Pseudo<
1189      "s_version",
1190      (outs),
1191      (ins s16imm:$simm16),
1192      "$simm16"> {
1193    let has_sdst = 0;
1194  }
1195} // End SubtargetPredicate = isGFX10Plus
1196
1197let SubtargetPredicate = isGFX10GFX11 in {
1198  def S_SUBVECTOR_LOOP_BEGIN : SOPK_32_BR<"s_subvector_loop_begin">;
1199  def S_SUBVECTOR_LOOP_END   : SOPK_32_BR<"s_subvector_loop_end">;
1200
1201  def S_WAITCNT_VSCNT   : SOPK_WAITCNT<"s_waitcnt_vscnt">;
1202  def S_WAITCNT_VMCNT   : SOPK_WAITCNT<"s_waitcnt_vmcnt">;
1203  def S_WAITCNT_EXPCNT  : SOPK_WAITCNT<"s_waitcnt_expcnt">;
1204  def S_WAITCNT_LGKMCNT : SOPK_WAITCNT<"s_waitcnt_lgkmcnt">;
1205} // End SubtargetPredicate = isGFX10GFX11
1206
1207//===----------------------------------------------------------------------===//
1208// SOPC Instructions
1209//===----------------------------------------------------------------------===//
1210
1211class SOPC_Pseudo<string opName, dag outs, dag ins,
1212                  string asmOps, list<dag> pattern=[]> :
1213  SOP_Pseudo<opName, outs, ins, " " # asmOps, pattern> {
1214  let mayLoad = 0;
1215  let mayStore = 0;
1216  let hasSideEffects = 0;
1217  let SALU = 1;
1218  let SOPC = 1;
1219  let Defs = [SCC];
1220  let SchedRW = [WriteSALU];
1221  let UseNamedOperandTable = 1;
1222}
1223
1224class SOPC_Real<bits<7> op, SOPC_Pseudo ps> :
1225  InstSI <ps.OutOperandList, ps.InOperandList,
1226          ps.Mnemonic # ps.AsmOperands>,
1227  Enc32 {
1228  let SALU = 1;
1229  let SOPC = 1;
1230  let isPseudo = 0;
1231  let isCodeGenOnly = 0;
1232
1233  // copy relevant pseudo op flags
1234  let SubtargetPredicate   = ps.SubtargetPredicate;
1235  let OtherPredicates      = ps.OtherPredicates;
1236  let AsmMatchConverter    = ps.AsmMatchConverter;
1237  let UseNamedOperandTable = ps.UseNamedOperandTable;
1238  let TSFlags              = ps.TSFlags;
1239  let SchedRW              = ps.SchedRW;
1240  let mayLoad              = ps.mayLoad;
1241  let mayStore             = ps.mayStore;
1242
1243  // encoding
1244  bits<8> src0;
1245  bits<8> src1;
1246
1247  let Inst{7-0} = src0;
1248  let Inst{15-8} = src1;
1249  let Inst{22-16} = op;
1250  let Inst{31-23} = 0x17e;
1251}
1252
1253class SOPC_Base <RegisterOperand rc0, RegisterOperand rc1,
1254                 string opName, list<dag> pattern = []> : SOPC_Pseudo <
1255  opName, (outs), (ins rc0:$src0, rc1:$src1),
1256  "$src0, $src1", pattern > {
1257}
1258
1259class SOPC_Helper <RegisterOperand rc, ValueType vt,
1260                    string opName, SDPatternOperator cond> : SOPC_Base <
1261  rc, rc, opName,
1262  [(set SCC, (UniformTernaryFrag<setcc> vt:$src0, vt:$src1, cond))] > {
1263}
1264
1265class SOPC_CMP_32<string opName,
1266                  SDPatternOperator cond = COND_NULL, string revOp = opName>
1267  : SOPC_Helper<SSrc_b32, i32, opName, cond>,
1268    Commutable_REV<revOp, !eq(revOp, opName)>,
1269    SOPKInstTable<0, opName> {
1270  let isCompare = 1;
1271  let isCommutable = 1;
1272}
1273
1274class SOPC_CMP_F32<string opName,
1275                  SDPatternOperator cond = COND_NULL, string revOp = opName>
1276  : SOPC_Helper<SSrc_b32, f32, opName, cond>,
1277    Commutable_REV<revOp, !eq(revOp, opName)>,
1278    SOPKInstTable<0, opName> {
1279  let isCompare = 1;
1280  let isCommutable = 1;
1281  let mayRaiseFPException = 1;
1282  let Uses = [MODE];
1283  let SchedRW = [WriteSFPU];
1284}
1285
1286class SOPC_CMP_F16<string opName,
1287                  SDPatternOperator cond = COND_NULL, string revOp = opName>
1288  : SOPC_Helper<SSrc_b16, f16, opName, cond>,
1289    Commutable_REV<revOp, !eq(revOp, opName)>,
1290    SOPKInstTable<0, opName> {
1291  let isCompare = 1;
1292  let isCommutable = 1;
1293  let mayRaiseFPException = 1;
1294  let Uses = [MODE];
1295  let SchedRW = [WriteSFPU];
1296}
1297
1298class SOPC_CMP_64<string opName,
1299                  SDPatternOperator cond = COND_NULL, string revOp = opName>
1300  : SOPC_Helper<SSrc_b64, i64, opName, cond>,
1301    Commutable_REV<revOp, !eq(revOp, opName)> {
1302  let isCompare = 1;
1303  let isCommutable = 1;
1304}
1305
1306class SOPC_32<string opName, list<dag> pattern = []>
1307  : SOPC_Base<SSrc_b32, SSrc_b32, opName, pattern>;
1308
1309class SOPC_64_32<string opName, list<dag> pattern = []>
1310  : SOPC_Base<SSrc_b64, SSrc_b32, opName, pattern>;
1311
1312def S_CMP_EQ_I32 : SOPC_CMP_32 <"s_cmp_eq_i32">;
1313def S_CMP_LG_I32 : SOPC_CMP_32 <"s_cmp_lg_i32">;
1314def S_CMP_GT_I32 : SOPC_CMP_32 <"s_cmp_gt_i32", COND_SGT>;
1315def S_CMP_GE_I32 : SOPC_CMP_32 <"s_cmp_ge_i32", COND_SGE>;
1316def S_CMP_LT_I32 : SOPC_CMP_32 <"s_cmp_lt_i32", COND_SLT, "s_cmp_gt_i32">;
1317def S_CMP_LE_I32 : SOPC_CMP_32 <"s_cmp_le_i32", COND_SLE, "s_cmp_ge_i32">;
1318def S_CMP_EQ_U32 : SOPC_CMP_32 <"s_cmp_eq_u32", COND_EQ>;
1319def S_CMP_LG_U32 : SOPC_CMP_32 <"s_cmp_lg_u32", COND_NE>;
1320def S_CMP_GT_U32 : SOPC_CMP_32 <"s_cmp_gt_u32", COND_UGT>;
1321def S_CMP_GE_U32 : SOPC_CMP_32 <"s_cmp_ge_u32", COND_UGE>;
1322def S_CMP_LT_U32 : SOPC_CMP_32 <"s_cmp_lt_u32", COND_ULT, "s_cmp_gt_u32">;
1323def S_CMP_LE_U32 : SOPC_CMP_32 <"s_cmp_le_u32", COND_ULE, "s_cmp_ge_u32">;
1324
1325def S_BITCMP0_B32 : SOPC_32 <"s_bitcmp0_b32">;
1326def S_BITCMP1_B32 : SOPC_32 <"s_bitcmp1_b32">;
1327def S_BITCMP0_B64 : SOPC_64_32 <"s_bitcmp0_b64">;
1328def S_BITCMP1_B64 : SOPC_64_32 <"s_bitcmp1_b64">;
1329let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in
1330def S_SETVSKIP : SOPC_32 <"s_setvskip">;
1331
1332let SubtargetPredicate = isGFX8Plus in {
1333def S_CMP_EQ_U64 : SOPC_CMP_64 <"s_cmp_eq_u64", COND_EQ>;
1334def S_CMP_LG_U64 : SOPC_CMP_64 <"s_cmp_lg_u64", COND_NE>;
1335} // End SubtargetPredicate = isGFX8Plus
1336
1337let SubtargetPredicate = HasVGPRIndexMode in {
1338// Setting the GPR index mode is really writing the fields in the mode
1339// register. We don't want to add mode register uses to every
1340// instruction, and it's too complicated to deal with anyway. This is
1341// modeled just as a side effect.
1342def S_SET_GPR_IDX_ON : SOPC_Pseudo <
1343  "s_set_gpr_idx_on" ,
1344  (outs),
1345  (ins SSrc_b32:$src0, GPRIdxMode:$src1),
1346  "$src0, $src1"> {
1347  let Defs = [M0, MODE]; // No scc def
1348  let Uses = [M0, MODE]; // Other bits of mode, m0 unmodified.
1349  let hasSideEffects = 1; // Sets mode.gpr_idx_en
1350  let FixedSize = 1;
1351}
1352}
1353
1354let SubtargetPredicate = HasSALUFloatInsts in {
1355
1356def S_CMP_LT_F32  : SOPC_CMP_F32<"s_cmp_lt_f32", COND_OLT, "s_cmp_gt_f32">;
1357def S_CMP_EQ_F32  : SOPC_CMP_F32<"s_cmp_eq_f32", COND_OEQ>;
1358def S_CMP_LE_F32  : SOPC_CMP_F32<"s_cmp_le_f32", COND_OLE, "s_cmp_ge_f32">;
1359def S_CMP_GT_F32  : SOPC_CMP_F32<"s_cmp_gt_f32", COND_OGT>;
1360def S_CMP_LG_F32  : SOPC_CMP_F32<"s_cmp_lg_f32", COND_ONE>;
1361def S_CMP_GE_F32  : SOPC_CMP_F32<"s_cmp_ge_f32", COND_OGE>;
1362def S_CMP_O_F32   : SOPC_CMP_F32<"s_cmp_o_f32", COND_O>;
1363def S_CMP_U_F32   : SOPC_CMP_F32<"s_cmp_u_f32", COND_UO>;
1364def S_CMP_NGE_F32 : SOPC_CMP_F32<"s_cmp_nge_f32", COND_ULT, "s_cmp_nle_f32">;
1365def S_CMP_NLG_F32 : SOPC_CMP_F32<"s_cmp_nlg_f32", COND_UEQ>;
1366def S_CMP_NGT_F32 : SOPC_CMP_F32<"s_cmp_ngt_f32", COND_ULE, "s_cmp_nlt_f32">;
1367def S_CMP_NLE_F32 : SOPC_CMP_F32<"s_cmp_nle_f32", COND_UGT>;
1368def S_CMP_NEQ_F32 : SOPC_CMP_F32<"s_cmp_neq_f32", COND_UNE>;
1369def S_CMP_NLT_F32 : SOPC_CMP_F32<"s_cmp_nlt_f32", COND_UGE>;
1370
1371def S_CMP_LT_F16  : SOPC_CMP_F16<"s_cmp_lt_f16", COND_OLT, "s_cmp_gt_f16">;
1372def S_CMP_EQ_F16  : SOPC_CMP_F16<"s_cmp_eq_f16", COND_OEQ>;
1373def S_CMP_LE_F16  : SOPC_CMP_F16<"s_cmp_le_f16", COND_OLE, "s_cmp_ge_f16">;
1374def S_CMP_GT_F16  : SOPC_CMP_F16<"s_cmp_gt_f16", COND_OGT>;
1375def S_CMP_LG_F16  : SOPC_CMP_F16<"s_cmp_lg_f16", COND_ONE>;
1376def S_CMP_GE_F16  : SOPC_CMP_F16<"s_cmp_ge_f16", COND_OGE>;
1377def S_CMP_O_F16   : SOPC_CMP_F16<"s_cmp_o_f16", COND_O>;
1378def S_CMP_U_F16   : SOPC_CMP_F16<"s_cmp_u_f16", COND_UO>;
1379def S_CMP_NGE_F16 : SOPC_CMP_F16<"s_cmp_nge_f16", COND_ULT, "s_cmp_nle_f16">;
1380def S_CMP_NLG_F16 : SOPC_CMP_F16<"s_cmp_nlg_f16", COND_UEQ>;
1381def S_CMP_NGT_F16 : SOPC_CMP_F16<"s_cmp_ngt_f16", COND_ULE, "s_cmp_nlt_f16">;
1382def S_CMP_NLE_F16 : SOPC_CMP_F16<"s_cmp_nle_f16", COND_UGT>;
1383def S_CMP_NEQ_F16 : SOPC_CMP_F16<"s_cmp_neq_f16", COND_UNE>;
1384def S_CMP_NLT_F16 : SOPC_CMP_F16<"s_cmp_nlt_f16", COND_UGE>;
1385
1386} // End SubtargetPredicate = HasSALUFloatInsts
1387
1388//===----------------------------------------------------------------------===//
1389// SOPP Instructions
1390//===----------------------------------------------------------------------===//
1391
1392class SOPP_Pseudo<string opName, dag ins,
1393                  string asmOps = "", list<dag> pattern=[],
1394                  string sep = !if(!empty(asmOps), "", " "),
1395                  string keyName = opName> :
1396  SOP_Pseudo<opName, (outs), ins, sep # asmOps, pattern> {
1397  let mayLoad = 0;
1398  let mayStore = 0;
1399  let hasSideEffects = 0;
1400  let SALU = 1;
1401  let SOPP = 1;
1402  let FixedSize = 1;
1403  let SchedRW = [WriteSALU];
1404  let UseNamedOperandTable = 1;
1405  bits <16> simm16;
1406  bits <1> fixed_imm = 0;
1407  string KeyName = keyName;
1408}
1409
1410class SOPPRelaxTable <bit isRelaxed, string keyName, string gfxip> {
1411  bit IsRelaxed = isRelaxed;
1412  string KeyName = keyName # gfxip;
1413}
1414
1415class SOPP_Real<SOPP_Pseudo ps, string real_name = ps.Mnemonic> :
1416  InstSI <ps.OutOperandList, ps.InOperandList,
1417          real_name # ps.AsmOperands> {
1418  let SALU = 1;
1419  let SOPP = 1;
1420  let isPseudo = 0;
1421  let isCodeGenOnly = 0;
1422
1423  // copy relevant pseudo op flags
1424  let SubtargetPredicate   = ps.SubtargetPredicate;
1425  let OtherPredicates      = ps.OtherPredicates;
1426  let AsmMatchConverter    = ps.AsmMatchConverter;
1427  let UseNamedOperandTable = ps.UseNamedOperandTable;
1428  let TSFlags              = ps.TSFlags;
1429  let SchedRW              = ps.SchedRW;
1430  let mayLoad              = ps.mayLoad;
1431  let mayStore             = ps.mayStore;
1432  bits <16> simm16;
1433}
1434
1435class SOPP_Real_32 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<ps, real_name>,
1436Enc32 {
1437  let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16);
1438  let Inst{22-16} = op;
1439  let Inst{31-23} = 0x17f;
1440}
1441
1442class SOPP_Real_64 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<ps, real_name>,
1443Enc64 {
1444  // encoding
1445  let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16);
1446  let Inst{22-16} = op;
1447  let Inst{31-23} = 0x17f;
1448  //effectively a nop
1449  let Inst{47-32} = 0x0;
1450  let Inst{54-48} = 0x0;
1451  let Inst{63-55} = 0x17f;
1452}
1453
1454multiclass SOPP_With_Relaxation <string opName, dag ins,
1455                  string asmOps, list<dag> pattern=[]> {
1456  def "" : SOPP_Pseudo <opName, ins, asmOps, pattern>;
1457  def _pad_s_nop : SOPP_Pseudo <opName # "_pad_s_nop", ins, asmOps, pattern, " ", opName>;
1458}
1459
1460def S_NOP : SOPP_Pseudo<"s_nop" , (ins i16imm:$simm16), "$simm16",
1461  [(int_amdgcn_s_nop timm:$simm16)]> {
1462  let hasSideEffects = 1;
1463}
1464
1465let isTerminator = 1 in {
1466def S_ENDPGM : SOPP_Pseudo<"s_endpgm", (ins Endpgm:$simm16), "$simm16", [], ""> {
1467  let isBarrier = 1;
1468  let isReturn = 1;
1469  let hasSideEffects = 1;
1470}
1471
1472def S_ENDPGM_SAVED : SOPP_Pseudo<"s_endpgm_saved", (ins)> {
1473  let SubtargetPredicate = isGFX8Plus;
1474  let simm16 = 0;
1475  let fixed_imm = 1;
1476  let isBarrier = 1;
1477  let isReturn = 1;
1478}
1479
1480let SubtargetPredicate = isGFX9GFX10 in {
1481  let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in {
1482    def S_ENDPGM_ORDERED_PS_DONE :
1483      SOPP_Pseudo<"s_endpgm_ordered_ps_done", (ins)>;
1484  } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1
1485} // End SubtargetPredicate = isGFX9GFX10
1486
1487let SubtargetPredicate = isGFX10Plus in {
1488  let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in {
1489    def S_CODE_END :
1490      SOPP_Pseudo<"s_code_end", (ins)>;
1491  } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1
1492} // End SubtargetPredicate = isGFX10Plus
1493
1494let isBranch = 1, SchedRW = [WriteBranch] in {
1495let isBarrier = 1 in {
1496defm S_BRANCH : SOPP_With_Relaxation<
1497  "s_branch" , (ins SOPPBrTarget:$simm16), "$simm16",
1498  [(br bb:$simm16)]>;
1499}
1500
1501let Uses = [SCC] in {
1502defm S_CBRANCH_SCC0 : SOPP_With_Relaxation<
1503  "s_cbranch_scc0" , (ins SOPPBrTarget:$simm16),
1504  "$simm16"
1505>;
1506defm S_CBRANCH_SCC1 : SOPP_With_Relaxation <
1507  "s_cbranch_scc1" , (ins SOPPBrTarget:$simm16),
1508  "$simm16"
1509>;
1510} // End Uses = [SCC]
1511
1512let Uses = [VCC] in {
1513defm S_CBRANCH_VCCZ : SOPP_With_Relaxation <
1514  "s_cbranch_vccz" , (ins SOPPBrTarget:$simm16),
1515  "$simm16"
1516>;
1517defm S_CBRANCH_VCCNZ : SOPP_With_Relaxation <
1518  "s_cbranch_vccnz" , (ins SOPPBrTarget:$simm16),
1519  "$simm16"
1520>;
1521} // End Uses = [VCC]
1522
1523let Uses = [EXEC] in {
1524defm S_CBRANCH_EXECZ : SOPP_With_Relaxation <
1525  "s_cbranch_execz" , (ins SOPPBrTarget:$simm16),
1526  "$simm16"
1527>;
1528defm S_CBRANCH_EXECNZ : SOPP_With_Relaxation <
1529  "s_cbranch_execnz" , (ins SOPPBrTarget:$simm16),
1530  "$simm16"
1531>;
1532} // End Uses = [EXEC]
1533
1534defm S_CBRANCH_CDBGSYS : SOPP_With_Relaxation <
1535  "s_cbranch_cdbgsys" , (ins SOPPBrTarget:$simm16),
1536  "$simm16"
1537>;
1538
1539defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_With_Relaxation <
1540  "s_cbranch_cdbgsys_and_user" , (ins SOPPBrTarget:$simm16),
1541  "$simm16"
1542>;
1543
1544defm S_CBRANCH_CDBGSYS_OR_USER : SOPP_With_Relaxation <
1545  "s_cbranch_cdbgsys_or_user" , (ins SOPPBrTarget:$simm16),
1546  "$simm16"
1547>;
1548
1549defm S_CBRANCH_CDBGUSER : SOPP_With_Relaxation <
1550  "s_cbranch_cdbguser" , (ins SOPPBrTarget:$simm16),
1551  "$simm16"
1552>;
1553
1554} // End isBranch = 1
1555} // End isTerminator = 1
1556
1557let hasSideEffects = 1 in {
1558def S_BARRIER : SOPP_Pseudo <"s_barrier", (ins), "",
1559  [(int_amdgcn_s_barrier)]> {
1560  let SchedRW = [WriteBarrier];
1561  let simm16 = 0;
1562  let fixed_imm = 1;
1563  let isConvergent = 1;
1564}
1565
1566def S_BARRIER_WAIT : SOPP_Pseudo <"s_barrier_wait", (ins i16imm:$simm16), "$simm16",
1567  [(int_amdgcn_s_barrier_wait timm:$simm16)]> {
1568  let SchedRW = [WriteBarrier];
1569  let isConvergent = 1;
1570}
1571
1572def S_BARRIER_LEAVE : SOPP_Pseudo <"s_barrier_leave", (ins), "",
1573  [(set SCC, (int_amdgcn_s_barrier_leave))]> {
1574  let SchedRW = [WriteBarrier];
1575  let simm16 = 0;
1576  let fixed_imm = 1;
1577  let isConvergent = 1;
1578  let Defs = [SCC];
1579}
1580
1581def S_WAKEUP : SOPP_Pseudo <"s_wakeup", (ins) > {
1582  let SubtargetPredicate = isGFX8Plus;
1583  let simm16 = 0;
1584  let fixed_imm = 1;
1585  let mayLoad = 1;
1586  let mayStore = 1;
1587}
1588
1589def S_WAITCNT : SOPP_Pseudo <"s_waitcnt" , (ins SWaitCnt:$simm16), "$simm16",
1590    [(int_amdgcn_s_waitcnt timm:$simm16)]>;
1591
1592// "_soft" waitcnts are waitcnts that are either relaxed into their non-soft
1593// counterpart, or completely removed.
1594//
1595// These are inserted by SIMemoryLegalizer to resolve memory dependencies
1596// and later optimized by SIInsertWaitcnts
1597// For example, a S_WAITCNT_soft 0 can be completely removed in a function
1598// that doesn't access memory.
1599def S_WAITCNT_soft : SOPP_Pseudo <"s_soft_waitcnt" , (ins SWaitCnt:$simm16), "$simm16">;
1600def S_WAITCNT_VSCNT_soft : SOPK_WAITCNT<"s_soft_waitcnt_vscnt">;
1601let SubtargetPredicate = isGFX12Plus in {
1602  def S_WAIT_LOADCNT_soft : SOPP_Pseudo <"s_soft_wait_loadcnt", (ins s16imm:$simm16), "$simm16">;
1603  def S_WAIT_STORECNT_soft : SOPP_Pseudo <"s_soft_wait_storecnt", (ins s16imm:$simm16), "$simm16">;
1604  def S_WAIT_SAMPLECNT_soft : SOPP_Pseudo <"s_soft_wait_samplecnt", (ins s16imm:$simm16), "$simm16">;
1605  def S_WAIT_BVHCNT_soft : SOPP_Pseudo <"s_soft_wait_bvhcnt", (ins s16imm:$simm16), "$simm16">;
1606  def S_WAIT_DSCNT_soft : SOPP_Pseudo <"s_soft_wait_dscnt", (ins s16imm:$simm16), "$simm16">;
1607}
1608
1609def S_SETHALT : SOPP_Pseudo <"s_sethalt" , (ins i32imm:$simm16), "$simm16",
1610    [(int_amdgcn_s_sethalt timm:$simm16)]>;
1611def S_SETKILL : SOPP_Pseudo <"s_setkill" , (ins i16imm:$simm16), "$simm16">;
1612
1613// On SI the documentation says sleep for approximately 64 * low 2
1614// bits, consistent with the reported maximum of 448. On VI the
1615// maximum reported is 960 cycles, so 960 / 64 = 15 max, so is the
1616// maximum really 15 on VI?
1617def S_SLEEP : SOPP_Pseudo <"s_sleep", (ins i32imm:$simm16),
1618  "$simm16", [(int_amdgcn_s_sleep timm:$simm16)]> {
1619}
1620
1621def S_SLEEP_VAR : SOP1_0_32 <"s_sleep_var", [(int_amdgcn_s_sleep_var SSrc_b32:$src0)]> {
1622  let hasSideEffects = 1;
1623}
1624
1625def S_SETPRIO : SOPP_Pseudo <"s_setprio", (ins i16imm:$simm16), "$simm16",
1626  [(int_amdgcn_s_setprio timm:$simm16)]> {
1627}
1628
1629let Uses = [EXEC, M0] in {
1630def S_SENDMSG : SOPP_Pseudo <"s_sendmsg" , (ins SendMsg:$simm16), "$simm16",
1631  [(int_amdgcn_s_sendmsg (i32 timm:$simm16), M0)]> {
1632}
1633
1634def S_SENDMSGHALT : SOPP_Pseudo <"s_sendmsghalt" , (ins SendMsg:$simm16), "$simm16",
1635  [(int_amdgcn_s_sendmsghalt (i32 timm:$simm16), M0)]> {
1636}
1637
1638} // End Uses = [EXEC, M0]
1639
1640def S_TRAP : SOPP_Pseudo <"s_trap" , (ins i16imm:$simm16), "$simm16"> {
1641  let isTrap = 1;
1642}
1643
1644def S_ICACHE_INV : SOPP_Pseudo <"s_icache_inv", (ins)> {
1645  let simm16 = 0;
1646  let fixed_imm = 1;
1647}
1648def S_INCPERFLEVEL : SOPP_Pseudo <"s_incperflevel", (ins i32imm:$simm16), "$simm16",
1649  [(int_amdgcn_s_incperflevel timm:$simm16)]> {
1650}
1651def S_DECPERFLEVEL : SOPP_Pseudo <"s_decperflevel", (ins i32imm:$simm16), "$simm16",
1652  [(int_amdgcn_s_decperflevel timm:$simm16)]> {
1653}
1654
1655let Uses = [M0] in
1656def S_TTRACEDATA : SOPP_Pseudo <"s_ttracedata", (ins), "",
1657                                [(int_amdgcn_s_ttracedata M0)]> {
1658  let simm16 = 0;
1659  let fixed_imm = 1;
1660}
1661
1662let SubtargetPredicate = HasVGPRIndexMode in {
1663def S_SET_GPR_IDX_OFF : SOPP_Pseudo<"s_set_gpr_idx_off", (ins) > {
1664  let simm16 = 0;
1665  let fixed_imm = 1;
1666  let Defs = [MODE];
1667  let Uses = [MODE];
1668}
1669}
1670} // End hasSideEffects
1671
1672let SubtargetPredicate = HasVGPRIndexMode in {
1673def S_SET_GPR_IDX_MODE : SOPP_Pseudo<"s_set_gpr_idx_mode", (ins GPRIdxMode:$simm16),
1674  "$simm16"> {
1675  let Defs = [M0, MODE];
1676  let Uses = [MODE];
1677}
1678}
1679
1680let SubtargetPredicate = isGFX10Plus in {
1681  def S_INST_PREFETCH :
1682    SOPP_Pseudo<"s_inst_prefetch", (ins s16imm:$simm16), "$simm16">;
1683  def S_CLAUSE :
1684    SOPP_Pseudo<"s_clause", (ins s16imm:$simm16), "$simm16">;
1685  def S_WAIT_IDLE :
1686    SOPP_Pseudo <"s_wait_idle", (ins)> {
1687      let simm16 = 0;
1688      let fixed_imm = 1;
1689    }
1690  def S_WAITCNT_DEPCTR :
1691    SOPP_Pseudo <"s_waitcnt_depctr" , (ins DepCtr:$simm16), "$simm16">;
1692
1693  let hasSideEffects = 0, Uses = [MODE], Defs = [MODE] in {
1694    def S_ROUND_MODE :
1695      SOPP_Pseudo<"s_round_mode", (ins s16imm:$simm16), "$simm16">;
1696    def S_DENORM_MODE :
1697      SOPP_Pseudo<"s_denorm_mode", (ins i32imm:$simm16), "$simm16",
1698      [(SIdenorm_mode (i32 timm:$simm16))]>;
1699  }
1700
1701  let hasSideEffects = 1 in
1702  def S_TTRACEDATA_IMM :
1703    SOPP_Pseudo<"s_ttracedata_imm", (ins s16imm:$simm16), "$simm16",
1704                [(int_amdgcn_s_ttracedata_imm timm:$simm16)]>;
1705} // End SubtargetPredicate = isGFX10Plus
1706
1707let SubtargetPredicate = isGFX11Plus in {
1708  def S_WAIT_EVENT : SOPP_Pseudo<"s_wait_event", (ins s16imm:$simm16),
1709                                 "$simm16"> {
1710                                   let hasSideEffects = 1;
1711                                 }
1712  def S_DELAY_ALU : SOPP_Pseudo<"s_delay_alu", (ins SDelayALU:$simm16),
1713                                "$simm16">;
1714} // End SubtargetPredicate = isGFX11Plus
1715
1716let SubtargetPredicate = HasVGPRSingleUseHintInsts in {
1717  def S_SINGLEUSE_VDST :
1718    SOPP_Pseudo<"s_singleuse_vdst", (ins s16imm:$simm16), "$simm16">;
1719} // End SubtargetPredicate = HasVGPRSingeUseHintInsts
1720
1721let SubtargetPredicate = isGFX12Plus, hasSideEffects = 1 in {
1722  def S_WAIT_LOADCNT :
1723    SOPP_Pseudo<"s_wait_loadcnt", (ins s16imm:$simm16), "$simm16",
1724                [(int_amdgcn_s_wait_loadcnt timm:$simm16)]>;
1725  def S_WAIT_LOADCNT_DSCNT :
1726    SOPP_Pseudo<"s_wait_loadcnt_dscnt", (ins s16imm:$simm16), "$simm16">;
1727  def S_WAIT_STORECNT :
1728    SOPP_Pseudo<"s_wait_storecnt", (ins s16imm:$simm16), "$simm16",
1729                [(int_amdgcn_s_wait_storecnt timm:$simm16)]>;
1730  def S_WAIT_STORECNT_DSCNT :
1731    SOPP_Pseudo<"s_wait_storecnt_dscnt", (ins s16imm:$simm16), "$simm16">;
1732  def S_WAIT_SAMPLECNT :
1733    SOPP_Pseudo<"s_wait_samplecnt", (ins s16imm:$simm16), "$simm16",
1734                [(int_amdgcn_s_wait_samplecnt timm:$simm16)]>;
1735  def S_WAIT_BVHCNT :
1736    SOPP_Pseudo<"s_wait_bvhcnt", (ins s16imm:$simm16), "$simm16",
1737                [(int_amdgcn_s_wait_bvhcnt timm:$simm16)]>;
1738  def S_WAIT_EXPCNT :
1739    SOPP_Pseudo<"s_wait_expcnt", (ins s16imm:$simm16), "$simm16",
1740                [(int_amdgcn_s_wait_expcnt timm:$simm16)]>;
1741  def S_WAIT_DSCNT :
1742    SOPP_Pseudo<"s_wait_dscnt", (ins s16imm:$simm16), "$simm16",
1743                [(int_amdgcn_s_wait_dscnt timm:$simm16)]>;
1744  def S_WAIT_KMCNT :
1745    SOPP_Pseudo<"s_wait_kmcnt", (ins s16imm:$simm16), "$simm16",
1746                [(int_amdgcn_s_wait_kmcnt timm:$simm16)]>;
1747} // End SubtargetPredicate = isGFX12Plus, hasSideEffects = 1
1748
1749//===----------------------------------------------------------------------===//
1750// SOP1 Patterns
1751//===----------------------------------------------------------------------===//
1752
1753def : GCNPat <
1754  (AMDGPUendpgm),
1755    (S_ENDPGM (i16 0))
1756>;
1757
1758def : GCNPat <
1759  (int_amdgcn_endpgm),
1760    (S_ENDPGM (i16 0))
1761>;
1762
1763def : GCNPat <
1764  (i64 (UniformUnaryFrag<ctpop> i64:$src)),
1765    (i64 (REG_SEQUENCE SReg_64,
1766     (i32 (COPY_TO_REGCLASS (S_BCNT1_I32_B64 $src), SReg_32)), sub0,
1767     (S_MOV_B32 (i32 0)), sub1))
1768>;
1769
1770def : GCNPat <
1771  (i32 (UniformBinFrag<smax> i32:$x, (i32 (ineg i32:$x)))),
1772  (S_ABS_I32 SReg_32:$x)
1773>;
1774
1775def : GCNPat <
1776  (i16 imm:$imm),
1777  (S_MOV_B32 imm:$imm)
1778>;
1779
1780// Same as a 32-bit inreg
1781def : GCNPat<
1782  (i32 (UniformUnaryFrag<sext> i16:$src)),
1783  (S_SEXT_I32_I16 $src)
1784>;
1785
1786let SubtargetPredicate = isNotGFX12Plus in
1787  def : GCNPat <(int_amdgcn_s_wait_event_export_ready), (S_WAIT_EVENT (i16 0))>;
1788let SubtargetPredicate = isGFX12Plus in
1789  def : GCNPat <(int_amdgcn_s_wait_event_export_ready), (S_WAIT_EVENT (i16 2))>;
1790
1791// The first 10 bits of the mode register are the core FP mode on all
1792// subtargets.
1793//
1794// The high bits include additional fields, intermixed with some
1795// non-floating point environment information. We extract the full
1796// register and clear non-relevant bits.
1797//
1798// EXCP_EN covers floating point exceptions, but also some other
1799// non-FP exceptions.
1800//
1801// Bits 12-18 cover the relevant exception mask on all subtargets.
1802//
1803// FIXME: Bit 18 is int_div0, should this be in the FP environment? I
1804// think the only source is v_rcp_iflag_i32.
1805//
1806// On GFX9+:
1807// Bit 23 is the additional FP16_OVFL mode.
1808//
1809// Bits 19, 20, and 21 cover non-FP exceptions and differ between
1810// gfx9/10/11, so we ignore them here.
1811
1812// TODO: Would it be cheaper to emit multiple s_getreg_b32 calls for
1813// the ranges and combine the results?
1814
1815defvar fp_round_mask = !add(!shl(1, 4), -1);
1816defvar fp_denorm_mask = !shl(!add(!shl(1, 4), -1), 4);
1817defvar dx10_clamp_mask = !shl(1, 8);
1818defvar ieee_mode_mask = !shl(1, 9);
1819
1820// Covers fp_round, fp_denorm, dx10_clamp, and IEEE bit.
1821defvar fpmode_mask =
1822  !or(fp_round_mask, fp_denorm_mask, dx10_clamp_mask, ieee_mode_mask);
1823
1824defvar fp_excp_en_mask = !shl(!add(!shl(1, 7), -1), 12);
1825defvar fp16_ovfl = !shl(1, 23);
1826defvar fpmode_mask_gfx6plus = !or(fpmode_mask, fp_excp_en_mask);
1827defvar fpmode_mask_gfx9plus = !or(fpmode_mask_gfx6plus, fp16_ovfl);
1828
1829class GetFPModePat<int fpmode_mask> : GCNPat<
1830  (i32 get_fpmode),
1831  (S_AND_B32 (i32 fpmode_mask),
1832             (S_GETREG_B32 getHwRegImm<
1833                HWREG.MODE, 0,
1834                !add(!logtwo(fpmode_mask), 1)>.ret))
1835>;
1836
1837// TODO: Might be worth moving to custom lowering so the and is
1838// exposed to demanded bits optimizations. Most users probably only
1839// care about the rounding or denorm mode bits. We also can reduce the
1840// demanded read from the getreg immediate.
1841let SubtargetPredicate = isGFX9Plus in {
1842// Last bit = FP16_OVFL
1843def : GetFPModePat<fpmode_mask_gfx9plus>;
1844}
1845
1846// Last bit = EXCP_EN.int_div0
1847let SubtargetPredicate = isNotGFX9Plus in {
1848def : GetFPModePat<fpmode_mask_gfx6plus>;
1849}
1850
1851//===----------------------------------------------------------------------===//
1852// SOP2 Patterns
1853//===----------------------------------------------------------------------===//
1854
1855def UniformSelect : PatFrag<
1856  (ops node:$src0, node:$src1),
1857  (select SCC, $src0, $src1),
1858  [{ return !N->isDivergent(); }]
1859>;
1860
1861let AddedComplexity = 20 in {
1862  def : GCNPat<
1863    (i32 (UniformSelect i32:$src0, i32:$src1)),
1864    (S_CSELECT_B32 SSrc_b32:$src0, SSrc_b32:$src1)
1865  >;
1866
1867  // TODO: The predicate should not be necessary, but enabling this pattern for
1868  // all subtargets generates worse code in some cases.
1869  let OtherPredicates = [HasPseudoScalarTrans] in
1870  def : GCNPat<
1871    (f32 (UniformSelect f32:$src0, f32:$src1)),
1872    (S_CSELECT_B32 SSrc_b32:$src0, SSrc_b32:$src1)
1873  >;
1874}
1875
1876// V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector
1877// case, the sgpr-copies pass will fix this to use the vector version.
1878def : GCNPat <
1879  (i32 (addc i32:$src0, i32:$src1)),
1880  (S_ADD_U32 $src0, $src1)
1881>;
1882
1883// FIXME: We need to use COPY_TO_REGCLASS to work-around the fact that
1884// REG_SEQUENCE patterns don't support instructions with multiple
1885// outputs.
1886def : GCNPat<
1887  (i64 (UniformUnaryFrag<zext> i16:$src)),
1888    (REG_SEQUENCE SReg_64,
1889      (i32 (COPY_TO_REGCLASS (S_AND_B32 $src, (S_MOV_B32 (i32 0xffff))), SGPR_32)), sub0,
1890      (S_MOV_B32 (i32 0)), sub1)
1891>;
1892
1893def : GCNPat <
1894  (i64 (UniformUnaryFrag<sext> i16:$src)),
1895    (REG_SEQUENCE SReg_64, (i32 (S_SEXT_I32_I16 $src)), sub0,
1896    (i32 (COPY_TO_REGCLASS (S_ASHR_I32 (i32 (S_SEXT_I32_I16 $src)), (S_MOV_B32 (i32 31))), SGPR_32)), sub1)
1897>;
1898
1899def : GCNPat<
1900  (i32 (UniformUnaryFrag<zext> i16:$src)),
1901  (S_AND_B32 (S_MOV_B32 (i32 0xffff)), $src)
1902>;
1903
1904// FIXME: ValueType should have isVector field
1905class ScalarNot2Pat<Instruction inst, SDPatternOperator op, ValueType vt,
1906                    bit isVector = 1> : GCNPat<
1907  (UniformBinFrag<op> vt:$src0, (UniformUnaryFrag<!if(isVector, vnot, not)> vt:$src1)),
1908  (inst getSOPSrcForVT<vt>.ret:$src0, getSOPSrcForVT<vt>.ret:$src1)
1909>;
1910
1911// Match these for some more types
1912// TODO: i1
1913def : ScalarNot2Pat<S_ANDN2_B32, and, i16, 0>;
1914def : ScalarNot2Pat<S_ANDN2_B32, and, v2i16>;
1915def : ScalarNot2Pat<S_ANDN2_B64, and, v4i16>;
1916def : ScalarNot2Pat<S_ANDN2_B64, and, v2i32>;
1917
1918def : ScalarNot2Pat<S_ORN2_B32, or, i16, 0>;
1919def : ScalarNot2Pat<S_ORN2_B32, or, v2i16>;
1920def : ScalarNot2Pat<S_ORN2_B64, or, v4i16>;
1921def : ScalarNot2Pat<S_ORN2_B64, or, v2i32>;
1922
1923//===----------------------------------------------------------------------===//
1924// Target-specific instruction encodings.
1925//===----------------------------------------------------------------------===//
1926
1927class Select_gfx12<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX12> {
1928  Predicate AssemblerPredicate = isGFX12Only;
1929  string DecoderNamespace      = "GFX12";
1930}
1931
1932class Select_gfx11<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX11> {
1933  Predicate AssemblerPredicate = isGFX11Only;
1934  string DecoderNamespace      = "GFX11";
1935}
1936
1937class Select_gfx10<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX10> {
1938  Predicate AssemblerPredicate = isGFX10Only;
1939  string DecoderNamespace      = "GFX10";
1940}
1941
1942class Select_vi<string opName> : SIMCInstr<opName, SIEncodingFamily.VI> {
1943  Predicate AssemblerPredicate = isGFX8GFX9;
1944  string DecoderNamespace = "GFX8";
1945}
1946
1947class Select_gfx6_gfx7<string opName> : SIMCInstr<opName, SIEncodingFamily.SI> {
1948  Predicate AssemblerPredicate = isGFX6GFX7;
1949  string DecoderNamespace      = "GFX6GFX7";
1950}
1951
1952//===----------------------------------------------------------------------===//
1953//  SOP1 - GFX11, GFX12
1954//===----------------------------------------------------------------------===//
1955
1956multiclass SOP1_Real_gfx12<bits<8> op> {
1957  def _gfx12 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
1958               Select_gfx12<!cast<SOP1_Pseudo>(NAME).Mnemonic>;
1959}
1960
1961multiclass SOP1_M0_Real_gfx12<bits<8> op> {
1962  def _gfx12 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
1963               Select_gfx12<!cast<SOP1_Pseudo>(NAME).Mnemonic> {
1964    let Inst{7-0} = M0_gfx11plus.HWEncoding{7-0}; // Set Src0 encoding to M0
1965  }
1966}
1967
1968multiclass SOP1_Real_gfx11<bits<8> op> {
1969  def _gfx11 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
1970               Select_gfx11<!cast<SOP1_Pseudo>(NAME).Mnemonic>;
1971}
1972
1973multiclass SOP1_Real_Renamed_gfx12<bits<8> op, SOP1_Pseudo backing_pseudo, string real_name> {
1974  def _gfx12 : SOP1_Real<op, backing_pseudo, real_name>,
1975               Select_gfx12<backing_pseudo.Mnemonic>,
1976               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX12Plus]>;
1977}
1978
1979multiclass SOP1_Real_Renamed_gfx11<bits<8> op, SOP1_Pseudo backing_pseudo, string real_name> {
1980  def _gfx11 : SOP1_Real<op, backing_pseudo, real_name>,
1981               Select_gfx11<backing_pseudo.Mnemonic>,
1982               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX11Only]>;
1983}
1984
1985multiclass SOP1_Real_gfx11_gfx12<bits<8> op> :
1986  SOP1_Real_gfx11<op>, SOP1_Real_gfx12<op>;
1987
1988multiclass SOP1_Real_Renamed_gfx11_gfx12<bits<8> op, SOP1_Pseudo backing_pseudo, string real_name> :
1989  SOP1_Real_Renamed_gfx11<op, backing_pseudo, real_name>,
1990  SOP1_Real_Renamed_gfx12<op, backing_pseudo, real_name>;
1991
1992defm S_MOV_B32                    : SOP1_Real_gfx11_gfx12<0x000>;
1993defm S_MOV_B64                    : SOP1_Real_gfx11_gfx12<0x001>;
1994defm S_CMOV_B32                   : SOP1_Real_gfx11_gfx12<0x002>;
1995defm S_CMOV_B64                   : SOP1_Real_gfx11_gfx12<0x003>;
1996defm S_BREV_B32                   : SOP1_Real_gfx11_gfx12<0x004>;
1997defm S_BREV_B64                   : SOP1_Real_gfx11_gfx12<0x005>;
1998defm S_CTZ_I32_B32                : SOP1_Real_Renamed_gfx11_gfx12<0x008, S_FF1_I32_B32, "s_ctz_i32_b32">;
1999defm S_CTZ_I32_B64                : SOP1_Real_Renamed_gfx11_gfx12<0x009, S_FF1_I32_B64, "s_ctz_i32_b64">;
2000defm S_CLZ_I32_U32                : SOP1_Real_Renamed_gfx11_gfx12<0x00a, S_FLBIT_I32_B32, "s_clz_i32_u32">;
2001defm S_CLZ_I32_U64                : SOP1_Real_Renamed_gfx11_gfx12<0x00b, S_FLBIT_I32_B64, "s_clz_i32_u64">;
2002defm S_CLS_I32                    : SOP1_Real_Renamed_gfx11_gfx12<0x00c, S_FLBIT_I32, "s_cls_i32">;
2003defm S_CLS_I32_I64                : SOP1_Real_Renamed_gfx11_gfx12<0x00d, S_FLBIT_I32_I64, "s_cls_i32_i64">;
2004defm S_SEXT_I32_I8                : SOP1_Real_gfx11_gfx12<0x00e>;
2005defm S_SEXT_I32_I16               : SOP1_Real_gfx11_gfx12<0x00f>;
2006defm S_BITSET0_B32                : SOP1_Real_gfx11_gfx12<0x010>;
2007defm S_BITSET0_B64                : SOP1_Real_gfx11_gfx12<0x011>;
2008defm S_BITSET1_B32                : SOP1_Real_gfx11_gfx12<0x012>;
2009defm S_BITSET1_B64                : SOP1_Real_gfx11_gfx12<0x013>;
2010defm S_BITREPLICATE_B64_B32       : SOP1_Real_gfx11_gfx12<0x014>;
2011defm S_ABS_I32                    : SOP1_Real_gfx11_gfx12<0x015>;
2012defm S_BCNT0_I32_B32              : SOP1_Real_gfx11_gfx12<0x016>;
2013defm S_BCNT0_I32_B64              : SOP1_Real_gfx11_gfx12<0x017>;
2014defm S_BCNT1_I32_B32              : SOP1_Real_gfx11_gfx12<0x018>;
2015defm S_BCNT1_I32_B64              : SOP1_Real_gfx11_gfx12<0x019>;
2016defm S_QUADMASK_B32               : SOP1_Real_gfx11_gfx12<0x01a>;
2017defm S_QUADMASK_B64               : SOP1_Real_gfx11_gfx12<0x01b>;
2018defm S_WQM_B32                    : SOP1_Real_gfx11_gfx12<0x01c>;
2019defm S_WQM_B64                    : SOP1_Real_gfx11_gfx12<0x01d>;
2020defm S_NOT_B32                    : SOP1_Real_gfx11_gfx12<0x01e>;
2021defm S_NOT_B64                    : SOP1_Real_gfx11_gfx12<0x01f>;
2022defm S_AND_SAVEEXEC_B32           : SOP1_Real_gfx11_gfx12<0x020>;
2023defm S_AND_SAVEEXEC_B64           : SOP1_Real_gfx11_gfx12<0x021>;
2024defm S_OR_SAVEEXEC_B32            : SOP1_Real_gfx11_gfx12<0x022>;
2025defm S_OR_SAVEEXEC_B64            : SOP1_Real_gfx11_gfx12<0x023>;
2026defm S_XOR_SAVEEXEC_B32           : SOP1_Real_gfx11_gfx12<0x024>;
2027defm S_XOR_SAVEEXEC_B64           : SOP1_Real_gfx11_gfx12<0x025>;
2028defm S_NAND_SAVEEXEC_B32          : SOP1_Real_gfx11_gfx12<0x026>;
2029defm S_NAND_SAVEEXEC_B64          : SOP1_Real_gfx11_gfx12<0x027>;
2030defm S_NOR_SAVEEXEC_B32           : SOP1_Real_gfx11_gfx12<0x028>;
2031defm S_NOR_SAVEEXEC_B64           : SOP1_Real_gfx11_gfx12<0x029>;
2032defm S_XNOR_SAVEEXEC_B32          : SOP1_Real_gfx11_gfx12<0x02a>;
2033/*defm S_XNOR_SAVEEXEC_B64        : SOP1_Real_gfx11_gfx12<0x02b>; //same as older arch, handled there*/
2034defm S_AND_NOT0_SAVEEXEC_B32      : SOP1_Real_Renamed_gfx11_gfx12<0x02c, S_ANDN1_SAVEEXEC_B32, "s_and_not0_saveexec_b32">;
2035defm S_AND_NOT0_SAVEEXEC_B64      : SOP1_Real_Renamed_gfx11_gfx12<0x02d, S_ANDN1_SAVEEXEC_B64, "s_and_not0_saveexec_b64">;
2036defm S_OR_NOT0_SAVEEXEC_B32       : SOP1_Real_Renamed_gfx11_gfx12<0x02e, S_ORN1_SAVEEXEC_B32, "s_or_not0_saveexec_b32">;
2037defm S_OR_NOT0_SAVEEXEC_B64       : SOP1_Real_Renamed_gfx11_gfx12<0x02f, S_ORN1_SAVEEXEC_B64, "s_or_not0_saveexec_b64">;
2038defm S_AND_NOT1_SAVEEXEC_B32      : SOP1_Real_Renamed_gfx11_gfx12<0x030, S_ANDN2_SAVEEXEC_B32, "s_and_not1_saveexec_b32">;
2039defm S_AND_NOT1_SAVEEXEC_B64      : SOP1_Real_Renamed_gfx11_gfx12<0x031, S_ANDN2_SAVEEXEC_B64, "s_and_not1_saveexec_b64">;
2040defm S_OR_NOT1_SAVEEXEC_B32       : SOP1_Real_Renamed_gfx11_gfx12<0x032, S_ORN2_SAVEEXEC_B32, "s_or_not1_saveexec_b32">;
2041defm S_OR_NOT1_SAVEEXEC_B64       : SOP1_Real_Renamed_gfx11_gfx12<0x033, S_ORN2_SAVEEXEC_B64, "s_or_not1_saveexec_b64">;
2042defm S_AND_NOT0_WREXEC_B32        : SOP1_Real_Renamed_gfx11_gfx12<0x034, S_ANDN1_WREXEC_B32, "s_and_not0_wrexec_b32">;
2043defm S_AND_NOT0_WREXEC_B64        : SOP1_Real_Renamed_gfx11_gfx12<0x035, S_ANDN1_WREXEC_B64, "s_and_not0_wrexec_b64">;
2044defm S_AND_NOT1_WREXEC_B32        : SOP1_Real_Renamed_gfx11_gfx12<0x036, S_ANDN2_WREXEC_B32, "s_and_not1_wrexec_b32">;
2045defm S_AND_NOT1_WREXEC_B64        : SOP1_Real_Renamed_gfx11_gfx12<0x037, S_ANDN2_WREXEC_B64, "s_and_not1_wrexec_b64">;
2046defm S_MOVRELS_B32                : SOP1_Real_gfx11_gfx12<0x040>;
2047defm S_MOVRELS_B64                : SOP1_Real_gfx11_gfx12<0x041>;
2048defm S_MOVRELD_B32                : SOP1_Real_gfx11_gfx12<0x042>;
2049defm S_MOVRELD_B64                : SOP1_Real_gfx11_gfx12<0x043>;
2050defm S_MOVRELSD_2_B32             : SOP1_Real_gfx11_gfx12<0x044>;
2051defm S_GETPC_B64                  : SOP1_Real_gfx11_gfx12<0x047>;
2052defm S_SETPC_B64                  : SOP1_Real_gfx11_gfx12<0x048>;
2053defm S_SWAPPC_B64                 : SOP1_Real_gfx11_gfx12<0x049>;
2054defm S_RFE_B64                    : SOP1_Real_gfx11_gfx12<0x04a>;
2055defm S_SENDMSG_RTN_B32            : SOP1_Real_gfx11_gfx12<0x04c>;
2056defm S_SENDMSG_RTN_B64            : SOP1_Real_gfx11_gfx12<0x04d>;
2057defm S_BARRIER_SIGNAL_M0          : SOP1_M0_Real_gfx12<0x04e>;
2058defm S_BARRIER_SIGNAL_ISFIRST_M0  : SOP1_M0_Real_gfx12<0x04f>;
2059defm S_GET_BARRIER_STATE_M0       : SOP1_M0_Real_gfx12<0x050>;
2060defm S_BARRIER_INIT_M0            : SOP1_M0_Real_gfx12<0x051>;
2061defm S_BARRIER_JOIN_M0            : SOP1_M0_Real_gfx12<0x052>;
2062defm S_WAKEUP_BARRIER_M0          : SOP1_M0_Real_gfx12<0x057>;
2063defm S_BARRIER_SIGNAL_IMM         : SOP1_Real_gfx12<0x04e>;
2064defm S_BARRIER_SIGNAL_ISFIRST_IMM : SOP1_Real_gfx12<0x04f>;
2065defm S_GET_BARRIER_STATE_IMM      : SOP1_Real_gfx12<0x050>;
2066defm S_BARRIER_INIT_IMM           : SOP1_Real_gfx12<0x051>;
2067defm S_BARRIER_JOIN_IMM           : SOP1_Real_gfx12<0x052>;
2068defm S_WAKEUP_BARRIER_IMM         : SOP1_Real_gfx12<0x057>;
2069defm S_SLEEP_VAR                  : SOP1_Real_gfx12<0x058>;
2070
2071//===----------------------------------------------------------------------===//
2072// SOP1 - GFX1150, GFX12
2073//===----------------------------------------------------------------------===//
2074
2075defm S_CEIL_F32          : SOP1_Real_gfx11_gfx12<0x060>;
2076defm S_FLOOR_F32         : SOP1_Real_gfx11_gfx12<0x061>;
2077defm S_TRUNC_F32         : SOP1_Real_gfx11_gfx12<0x062>;
2078defm S_RNDNE_F32         : SOP1_Real_gfx11_gfx12<0x063>;
2079defm S_CVT_F32_I32       : SOP1_Real_gfx11_gfx12<0x064>;
2080defm S_CVT_F32_U32       : SOP1_Real_gfx11_gfx12<0x065>;
2081defm S_CVT_I32_F32       : SOP1_Real_gfx11_gfx12<0x066>;
2082defm S_CVT_U32_F32       : SOP1_Real_gfx11_gfx12<0x067>;
2083defm S_CVT_F16_F32       : SOP1_Real_gfx11_gfx12<0x068>;
2084defm S_CVT_F32_F16       : SOP1_Real_gfx11_gfx12<0x069>;
2085defm S_CVT_HI_F32_F16    : SOP1_Real_gfx11_gfx12<0x06a>;
2086defm S_CEIL_F16          : SOP1_Real_gfx11_gfx12<0x06b>;
2087defm S_FLOOR_F16         : SOP1_Real_gfx11_gfx12<0x06c>;
2088defm S_TRUNC_F16         : SOP1_Real_gfx11_gfx12<0x06d>;
2089defm S_RNDNE_F16         : SOP1_Real_gfx11_gfx12<0x06e>;
2090
2091//===----------------------------------------------------------------------===//
2092// SOP1 - GFX10.
2093//===----------------------------------------------------------------------===//
2094
2095multiclass SOP1_Real_gfx10<bits<8> op> {
2096  defvar ps = !cast<SOP1_Pseudo>(NAME);
2097  def _gfx10 : SOP1_Real<op, ps>,
2098               Select_gfx10<ps.Mnemonic>;
2099}
2100
2101multiclass SOP1_Real_gfx10_gfx11_gfx12<bits<8> op> :
2102  SOP1_Real_gfx10<op>, SOP1_Real_gfx11_gfx12<op>;
2103
2104defm S_ANDN1_SAVEEXEC_B64   : SOP1_Real_gfx10<0x037>;
2105defm S_ORN1_SAVEEXEC_B64    : SOP1_Real_gfx10<0x038>;
2106defm S_ANDN1_WREXEC_B64     : SOP1_Real_gfx10<0x039>;
2107defm S_ANDN2_WREXEC_B64     : SOP1_Real_gfx10<0x03a>;
2108defm S_BITREPLICATE_B64_B32 : SOP1_Real_gfx10<0x03b>;
2109defm S_AND_SAVEEXEC_B32     : SOP1_Real_gfx10<0x03c>;
2110defm S_OR_SAVEEXEC_B32      : SOP1_Real_gfx10<0x03d>;
2111defm S_XOR_SAVEEXEC_B32     : SOP1_Real_gfx10<0x03e>;
2112defm S_ANDN2_SAVEEXEC_B32   : SOP1_Real_gfx10<0x03f>;
2113defm S_ORN2_SAVEEXEC_B32    : SOP1_Real_gfx10<0x040>;
2114defm S_NAND_SAVEEXEC_B32    : SOP1_Real_gfx10<0x041>;
2115defm S_NOR_SAVEEXEC_B32     : SOP1_Real_gfx10<0x042>;
2116defm S_XNOR_SAVEEXEC_B32    : SOP1_Real_gfx10<0x043>;
2117defm S_ANDN1_SAVEEXEC_B32   : SOP1_Real_gfx10<0x044>;
2118defm S_ORN1_SAVEEXEC_B32    : SOP1_Real_gfx10<0x045>;
2119defm S_ANDN1_WREXEC_B32     : SOP1_Real_gfx10<0x046>;
2120defm S_ANDN2_WREXEC_B32     : SOP1_Real_gfx10<0x047>;
2121defm S_MOVRELSD_2_B32       : SOP1_Real_gfx10<0x049>;
2122
2123//===----------------------------------------------------------------------===//
2124// SOP1 - GFX6, GFX7, GFX10, GFX11.
2125//===----------------------------------------------------------------------===//
2126
2127
2128multiclass SOP1_Real_gfx6_gfx7<bits<8> op> {
2129  defvar ps = !cast<SOP1_Pseudo>(NAME);
2130  def _gfx6_gfx7 : SOP1_Real<op, ps>,
2131                   Select_gfx6_gfx7<ps.Mnemonic>;
2132}
2133
2134multiclass SOP1_Real_gfx6_gfx7_gfx10<bits<8> op> :
2135  SOP1_Real_gfx6_gfx7<op>, SOP1_Real_gfx10<op>;
2136
2137multiclass SOP1_Real_gfx6_gfx7_gfx10_gfx11_gfx12<bits<8> op> :
2138  SOP1_Real_gfx6_gfx7<op>, SOP1_Real_gfx10_gfx11_gfx12<op>;
2139
2140defm S_CBRANCH_JOIN  : SOP1_Real_gfx6_gfx7<0x032>;
2141
2142defm S_MOV_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x003>;
2143defm S_MOV_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x004>;
2144defm S_CMOV_B32           : SOP1_Real_gfx6_gfx7_gfx10<0x005>;
2145defm S_CMOV_B64           : SOP1_Real_gfx6_gfx7_gfx10<0x006>;
2146defm S_NOT_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x007>;
2147defm S_NOT_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x008>;
2148defm S_WQM_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x009>;
2149defm S_WQM_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x00a>;
2150defm S_BREV_B32           : SOP1_Real_gfx6_gfx7_gfx10<0x00b>;
2151defm S_BREV_B64           : SOP1_Real_gfx6_gfx7_gfx10<0x00c>;
2152defm S_BCNT0_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x00d>;
2153defm S_BCNT0_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x00e>;
2154defm S_BCNT1_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x00f>;
2155defm S_BCNT1_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x010>;
2156defm S_FF0_I32_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x011>;
2157defm S_FF0_I32_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x012>;
2158defm S_FF1_I32_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x013>;
2159defm S_FF1_I32_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x014>;
2160defm S_FLBIT_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x015>;
2161defm S_FLBIT_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x016>;
2162defm S_FLBIT_I32          : SOP1_Real_gfx6_gfx7_gfx10<0x017>;
2163defm S_FLBIT_I32_I64      : SOP1_Real_gfx6_gfx7_gfx10<0x018>;
2164defm S_SEXT_I32_I8        : SOP1_Real_gfx6_gfx7_gfx10<0x019>;
2165defm S_SEXT_I32_I16       : SOP1_Real_gfx6_gfx7_gfx10<0x01a>;
2166defm S_BITSET0_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x01b>;
2167defm S_BITSET0_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x01c>;
2168defm S_BITSET1_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x01d>;
2169defm S_BITSET1_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x01e>;
2170defm S_GETPC_B64          : SOP1_Real_gfx6_gfx7_gfx10<0x01f>;
2171defm S_SETPC_B64          : SOP1_Real_gfx6_gfx7_gfx10<0x020>;
2172defm S_SWAPPC_B64         : SOP1_Real_gfx6_gfx7_gfx10<0x021>;
2173defm S_RFE_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x022>;
2174defm S_AND_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x024>;
2175defm S_OR_SAVEEXEC_B64    : SOP1_Real_gfx6_gfx7_gfx10<0x025>;
2176defm S_XOR_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x026>;
2177defm S_ANDN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x027>;
2178defm S_ORN2_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10<0x028>;
2179defm S_NAND_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10<0x029>;
2180defm S_NOR_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x02a>;
2181defm S_XNOR_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10_gfx11_gfx12<0x02b>;
2182defm S_QUADMASK_B32       : SOP1_Real_gfx6_gfx7_gfx10<0x02c>;
2183defm S_QUADMASK_B64       : SOP1_Real_gfx6_gfx7_gfx10<0x02d>;
2184defm S_MOVRELS_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x02e>;
2185defm S_MOVRELS_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x02f>;
2186defm S_MOVRELD_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x030>;
2187defm S_MOVRELD_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x031>;
2188defm S_ABS_I32            : SOP1_Real_gfx6_gfx7_gfx10<0x034>;
2189
2190//===----------------------------------------------------------------------===//
2191// SOP2 - GFX12
2192//===----------------------------------------------------------------------===//
2193
2194multiclass SOP2_Real_gfx12<bits<7> op> {
2195  def _gfx12 : SOP2_Real32<op, !cast<SOP2_Pseudo>(NAME)>,
2196               Select_gfx12<!cast<SOP2_Pseudo>(NAME).Mnemonic>;
2197}
2198
2199multiclass SOP2_Real_Renamed_gfx12<bits<7> op, SOP2_Pseudo backing_pseudo, string real_name> {
2200  def _gfx12 : SOP2_Real32<op, backing_pseudo, real_name>,
2201               Select_gfx12<backing_pseudo.Mnemonic>,
2202               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX12Plus]>;
2203}
2204
2205defm S_MIN_NUM_F32 : SOP2_Real_Renamed_gfx12<0x042, S_MIN_F32, "s_min_num_f32">;
2206defm S_MAX_NUM_F32 : SOP2_Real_Renamed_gfx12<0x043, S_MAX_F32, "s_max_num_f32">;
2207defm S_MIN_NUM_F16 : SOP2_Real_Renamed_gfx12<0x04b, S_MIN_F16, "s_min_num_f16">;
2208defm S_MAX_NUM_F16 : SOP2_Real_Renamed_gfx12<0x04c, S_MAX_F16, "s_max_num_f16">;
2209defm S_MINIMUM_F32 : SOP2_Real_gfx12<0x04f>;
2210defm S_MAXIMUM_F32 : SOP2_Real_gfx12<0x050>;
2211defm S_MINIMUM_F16 : SOP2_Real_gfx12<0x051>;
2212defm S_MAXIMUM_F16 : SOP2_Real_gfx12<0x052>;
2213
2214defm S_ADD_CO_U32    : SOP2_Real_Renamed_gfx12<0x000, S_ADD_U32, "s_add_co_u32">;
2215defm S_SUB_CO_U32    : SOP2_Real_Renamed_gfx12<0x001, S_SUB_U32, "s_sub_co_u32">;
2216defm S_ADD_CO_I32    : SOP2_Real_Renamed_gfx12<0x002, S_ADD_I32, "s_add_co_i32">;
2217defm S_SUB_CO_I32    : SOP2_Real_Renamed_gfx12<0x003, S_SUB_I32, "s_sub_co_i32">;
2218defm S_ADD_CO_CI_U32 : SOP2_Real_Renamed_gfx12<0x004, S_ADDC_U32, "s_add_co_ci_u32">;
2219defm S_SUB_CO_CI_U32 : SOP2_Real_Renamed_gfx12<0x005, S_SUBB_U32, "s_sub_co_ci_u32">;
2220
2221//===----------------------------------------------------------------------===//
2222// SOP2 - GFX11, GFX12.
2223//===----------------------------------------------------------------------===//
2224
2225multiclass SOP2_Real_gfx11<bits<7> op> {
2226  def _gfx11 : SOP2_Real32<op, !cast<SOP2_Pseudo>(NAME)>,
2227               Select_gfx11<!cast<SOP2_Pseudo>(NAME).Mnemonic>;
2228}
2229
2230multiclass SOP2_Real_Renamed_gfx11<bits<7> op, SOP2_Pseudo backing_pseudo, string real_name> {
2231  def _gfx11 : SOP2_Real32<op, backing_pseudo, real_name>,
2232               Select_gfx11<backing_pseudo.Mnemonic>,
2233               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX11Only]>;
2234}
2235
2236multiclass SOP2_Real_gfx11_gfx12<bits<7> op> :
2237  SOP2_Real_gfx11<op>, SOP2_Real_gfx12<op>;
2238
2239multiclass SOP2_Real_Renamed_gfx11_gfx12<bits<8> op, SOP2_Pseudo backing_pseudo, string real_name> :
2240  SOP2_Real_Renamed_gfx11<op, backing_pseudo, real_name>,
2241  SOP2_Real_Renamed_gfx12<op, backing_pseudo, real_name>;
2242
2243defm S_ABSDIFF_I32     : SOP2_Real_gfx11_gfx12<0x006>;
2244defm S_LSHL_B32        : SOP2_Real_gfx11_gfx12<0x008>;
2245defm S_LSHL_B64        : SOP2_Real_gfx11_gfx12<0x009>;
2246defm S_LSHR_B32        : SOP2_Real_gfx11_gfx12<0x00a>;
2247defm S_LSHR_B64        : SOP2_Real_gfx11_gfx12<0x00b>;
2248defm S_ASHR_I32        : SOP2_Real_gfx11_gfx12<0x00c>;
2249defm S_ASHR_I64        : SOP2_Real_gfx11_gfx12<0x00d>;
2250defm S_LSHL1_ADD_U32   : SOP2_Real_gfx11_gfx12<0x00e>;
2251defm S_LSHL2_ADD_U32   : SOP2_Real_gfx11_gfx12<0x00f>;
2252defm S_LSHL3_ADD_U32   : SOP2_Real_gfx11_gfx12<0x010>;
2253defm S_LSHL4_ADD_U32   : SOP2_Real_gfx11_gfx12<0x011>;
2254defm S_MIN_I32         : SOP2_Real_gfx11_gfx12<0x012>;
2255defm S_MIN_U32         : SOP2_Real_gfx11_gfx12<0x013>;
2256defm S_MAX_I32         : SOP2_Real_gfx11_gfx12<0x014>;
2257defm S_MAX_U32         : SOP2_Real_gfx11_gfx12<0x015>;
2258defm S_AND_B32         : SOP2_Real_gfx11_gfx12<0x016>;
2259defm S_AND_B64         : SOP2_Real_gfx11_gfx12<0x017>;
2260defm S_OR_B32          : SOP2_Real_gfx11_gfx12<0x018>;
2261defm S_OR_B64          : SOP2_Real_gfx11_gfx12<0x019>;
2262defm S_XOR_B32         : SOP2_Real_gfx11_gfx12<0x01a>;
2263defm S_XOR_B64         : SOP2_Real_gfx11_gfx12<0x01b>;
2264defm S_NAND_B32        : SOP2_Real_gfx11_gfx12<0x01c>;
2265defm S_NAND_B64        : SOP2_Real_gfx11_gfx12<0x01d>;
2266defm S_NOR_B32         : SOP2_Real_gfx11_gfx12<0x01e>;
2267defm S_NOR_B64         : SOP2_Real_gfx11_gfx12<0x01f>;
2268defm S_XNOR_B32        : SOP2_Real_gfx11_gfx12<0x020>;
2269defm S_XNOR_B64        : SOP2_Real_gfx11_gfx12<0x021>;
2270defm S_AND_NOT1_B32    : SOP2_Real_Renamed_gfx11_gfx12<0x022, S_ANDN2_B32, "s_and_not1_b32">;
2271defm S_AND_NOT1_B64    : SOP2_Real_Renamed_gfx11_gfx12<0x023, S_ANDN2_B64, "s_and_not1_b64">;
2272defm S_OR_NOT1_B32     : SOP2_Real_Renamed_gfx11_gfx12<0x024, S_ORN2_B32, "s_or_not1_b32">;
2273defm S_OR_NOT1_B64     : SOP2_Real_Renamed_gfx11_gfx12<0x025, S_ORN2_B64, "s_or_not1_b64">;
2274defm S_BFE_U32         : SOP2_Real_gfx11_gfx12<0x026>;
2275defm S_BFE_I32         : SOP2_Real_gfx11_gfx12<0x027>;
2276defm S_BFE_U64         : SOP2_Real_gfx11_gfx12<0x028>;
2277defm S_BFE_I64         : SOP2_Real_gfx11_gfx12<0x029>;
2278defm S_BFM_B32         : SOP2_Real_gfx11_gfx12<0x02a>;
2279defm S_BFM_B64         : SOP2_Real_gfx11_gfx12<0x02b>;
2280defm S_MUL_I32         : SOP2_Real_gfx11_gfx12<0x02c>;
2281defm S_MUL_HI_U32      : SOP2_Real_gfx11_gfx12<0x02d>;
2282defm S_MUL_HI_I32      : SOP2_Real_gfx11_gfx12<0x02e>;
2283defm S_CSELECT_B32     : SOP2_Real_gfx11_gfx12<0x030>;
2284defm S_CSELECT_B64     : SOP2_Real_gfx11_gfx12<0x031>;
2285defm S_PACK_HL_B32_B16 : SOP2_Real_gfx11_gfx12<0x035>;
2286defm S_ADD_NC_U64      : SOP2_Real_Renamed_gfx12<0x053, S_ADD_U64, "s_add_nc_u64">;
2287defm S_SUB_NC_U64      : SOP2_Real_Renamed_gfx12<0x054, S_SUB_U64, "s_sub_nc_u64">;
2288defm S_MUL_U64         : SOP2_Real_gfx12<0x055>;
2289
2290//===----------------------------------------------------------------------===//
2291// SOP2 - GFX1150, GFX12
2292//===----------------------------------------------------------------------===//
2293
2294multiclass SOP2_Real_FMAK_gfx12<bits<7> op> {
2295  def _gfx12 : SOP2_Real64<op, !cast<SOP2_Pseudo>(NAME)>,
2296               Select_gfx12<!cast<SOP2_Pseudo>(NAME).Mnemonic>;
2297}
2298
2299multiclass SOP2_Real_FMAK_gfx11<bits<7> op> {
2300  def _gfx11 : SOP2_Real64<op, !cast<SOP2_Pseudo>(NAME)>,
2301               Select_gfx11<!cast<SOP2_Pseudo>(NAME).Mnemonic>;
2302}
2303
2304multiclass SOP2_Real_FMAK_gfx11_gfx12<bits<7> op> :
2305  SOP2_Real_FMAK_gfx11<op>, SOP2_Real_FMAK_gfx12<op>;
2306
2307defm S_ADD_F32            : SOP2_Real_gfx11_gfx12<0x040>;
2308defm S_SUB_F32            : SOP2_Real_gfx11_gfx12<0x041>;
2309defm S_MUL_F32            : SOP2_Real_gfx11_gfx12<0x044>;
2310defm S_FMAAK_F32          : SOP2_Real_FMAK_gfx11_gfx12<0x045>;
2311defm S_FMAMK_F32          : SOP2_Real_FMAK_gfx11_gfx12<0x046>;
2312defm S_FMAC_F32           : SOP2_Real_gfx11_gfx12<0x047>;
2313defm S_CVT_PK_RTZ_F16_F32 : SOP2_Real_gfx11_gfx12<0x048>;
2314defm S_ADD_F16            : SOP2_Real_gfx11_gfx12<0x049>;
2315defm S_SUB_F16            : SOP2_Real_gfx11_gfx12<0x04a>;
2316defm S_MUL_F16            : SOP2_Real_gfx11_gfx12<0x04d>;
2317defm S_FMAC_F16           : SOP2_Real_gfx11_gfx12<0x04e>;
2318
2319//===----------------------------------------------------------------------===//
2320// SOP2 - GFX1150
2321//===----------------------------------------------------------------------===//
2322
2323defm S_MIN_F32 : SOP2_Real_gfx11<0x042>;
2324defm S_MAX_F32 : SOP2_Real_gfx11<0x043>;
2325defm S_MIN_F16 : SOP2_Real_gfx11<0x04b>;
2326defm S_MAX_F16 : SOP2_Real_gfx11<0x04c>;
2327
2328//===----------------------------------------------------------------------===//
2329// SOP2 - GFX10.
2330//===----------------------------------------------------------------------===//
2331
2332multiclass SOP2_Real_gfx10<bits<7> op> {
2333  defvar ps = !cast<SOP2_Pseudo>(NAME);
2334  def _gfx10 : SOP2_Real32<op, ps>,
2335               Select_gfx10<ps.Mnemonic>;
2336}
2337
2338multiclass SOP2_Real_gfx10_gfx11_gfx12<bits<7> op> :
2339  SOP2_Real_gfx10<op>, SOP2_Real_gfx11_gfx12<op>;
2340
2341defm S_LSHL1_ADD_U32   : SOP2_Real_gfx10<0x02e>;
2342defm S_LSHL2_ADD_U32   : SOP2_Real_gfx10<0x02f>;
2343defm S_LSHL3_ADD_U32   : SOP2_Real_gfx10<0x030>;
2344defm S_LSHL4_ADD_U32   : SOP2_Real_gfx10<0x031>;
2345defm S_PACK_LL_B32_B16 : SOP2_Real_gfx10_gfx11_gfx12<0x032>;
2346defm S_PACK_LH_B32_B16 : SOP2_Real_gfx10_gfx11_gfx12<0x033>;
2347defm S_PACK_HH_B32_B16 : SOP2_Real_gfx10_gfx11_gfx12<0x034>;
2348defm S_MUL_HI_U32      : SOP2_Real_gfx10<0x035>;
2349defm S_MUL_HI_I32      : SOP2_Real_gfx10<0x036>;
2350
2351//===----------------------------------------------------------------------===//
2352// SOP2 - GFX6, GFX7.
2353//===----------------------------------------------------------------------===//
2354
2355multiclass SOP2_Real_gfx6_gfx7<bits<7> op> {
2356  defvar ps = !cast<SOP_Pseudo>(NAME);
2357  def _gfx6_gfx7 : SOP2_Real32<op, ps>,
2358                   Select_gfx6_gfx7<ps.Mnemonic>;
2359}
2360
2361multiclass SOP2_Real_gfx6_gfx7_gfx10<bits<7> op> :
2362  SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10<op>;
2363
2364multiclass SOP2_Real_gfx6_gfx7_gfx10_gfx11<bits<7> op> :
2365  SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10<op>, SOP2_Real_gfx11<op>;
2366
2367multiclass SOP2_Real_gfx6_gfx7_gfx10_gfx11_gfx12<bits<7> op> :
2368  SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10_gfx11_gfx12<op>;
2369
2370defm S_CBRANCH_G_FORK : SOP2_Real_gfx6_gfx7<0x02b>;
2371
2372defm S_ADD_U32     : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x000>;
2373defm S_SUB_U32     : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x001>;
2374defm S_ADD_I32     : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x002>;
2375defm S_SUB_I32     : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x003>;
2376defm S_ADDC_U32    : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x004>;
2377defm S_SUBB_U32    : SOP2_Real_gfx6_gfx7_gfx10_gfx11<0x005>;
2378defm S_MIN_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x006>;
2379defm S_MIN_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x007>;
2380defm S_MAX_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x008>;
2381defm S_MAX_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x009>;
2382defm S_CSELECT_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00a>;
2383defm S_CSELECT_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00b>;
2384defm S_AND_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x00e>;
2385defm S_AND_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x00f>;
2386defm S_OR_B32      : SOP2_Real_gfx6_gfx7_gfx10<0x010>;
2387defm S_OR_B64      : SOP2_Real_gfx6_gfx7_gfx10<0x011>;
2388defm S_XOR_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x012>;
2389defm S_XOR_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x013>;
2390defm S_ANDN2_B32   : SOP2_Real_gfx6_gfx7_gfx10<0x014>;
2391defm S_ANDN2_B64   : SOP2_Real_gfx6_gfx7_gfx10<0x015>;
2392defm S_ORN2_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x016>;
2393defm S_ORN2_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x017>;
2394defm S_NAND_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x018>;
2395defm S_NAND_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x019>;
2396defm S_NOR_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x01a>;
2397defm S_NOR_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x01b>;
2398defm S_XNOR_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x01c>;
2399defm S_XNOR_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x01d>;
2400defm S_LSHL_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x01e>;
2401defm S_LSHL_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x01f>;
2402defm S_LSHR_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x020>;
2403defm S_LSHR_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x021>;
2404defm S_ASHR_I32    : SOP2_Real_gfx6_gfx7_gfx10<0x022>;
2405defm S_ASHR_I64    : SOP2_Real_gfx6_gfx7_gfx10<0x023>;
2406defm S_BFM_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x024>;
2407defm S_BFM_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x025>;
2408defm S_MUL_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x026>;
2409defm S_BFE_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x027>;
2410defm S_BFE_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x028>;
2411defm S_BFE_U64     : SOP2_Real_gfx6_gfx7_gfx10<0x029>;
2412defm S_BFE_I64     : SOP2_Real_gfx6_gfx7_gfx10<0x02a>;
2413defm S_ABSDIFF_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x02c>;
2414
2415//===----------------------------------------------------------------------===//
2416// SOPK - GFX11, GFX12.
2417//===----------------------------------------------------------------------===//
2418
2419multiclass SOPK_Real32_gfx12<bits<5> op> {
2420  def _gfx12 : SOPK_Real32<op, !cast<SOPK_Pseudo>(NAME)>,
2421               Select_gfx12<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
2422}
2423
2424multiclass SOPK_Real32_Renamed_gfx12<bits<5> op, SOPK_Pseudo backing_pseudo, string real_name> {
2425  def _gfx12 : SOPK_Real32<op, backing_pseudo, real_name>,
2426               Select_gfx12<backing_pseudo.Mnemonic>,
2427               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX12Plus]>;
2428}
2429
2430multiclass SOPK_Real32_gfx11<bits<5> op> {
2431  def _gfx11 : SOPK_Real32<op, !cast<SOPK_Pseudo>(NAME)>,
2432               Select_gfx11<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
2433}
2434
2435multiclass SOPK_Real64_gfx12<bits<5> op> {
2436  def _gfx12 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
2437               Select_gfx12<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
2438}
2439
2440multiclass SOPK_Real64_gfx11<bits<5> op> {
2441  def _gfx11 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
2442               Select_gfx11<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
2443}
2444
2445multiclass SOPK_Real32_gfx11_gfx12<bits<5> op> :
2446  SOPK_Real32_gfx11<op>, SOPK_Real32_gfx12<op>;
2447
2448multiclass SOPK_Real64_gfx11_gfx12<bits<5> op> :
2449  SOPK_Real64_gfx11<op>, SOPK_Real64_gfx12<op>;
2450
2451defm S_ADDK_CO_I32          : SOPK_Real32_Renamed_gfx12<0x00f, S_ADDK_I32, "s_addk_co_i32">;
2452defm S_GETREG_B32           : SOPK_Real32_gfx11_gfx12<0x011>;
2453defm S_SETREG_B32           : SOPK_Real32_gfx11_gfx12<0x012>;
2454defm S_SETREG_IMM32_B32     : SOPK_Real64_gfx11_gfx12<0x013>;
2455defm S_CALL_B64             : SOPK_Real32_gfx11_gfx12<0x014>;
2456defm S_SUBVECTOR_LOOP_BEGIN : SOPK_Real32_gfx11<0x016>;
2457defm S_SUBVECTOR_LOOP_END   : SOPK_Real32_gfx11<0x017>;
2458defm S_WAITCNT_VSCNT        : SOPK_Real32_gfx11<0x018>;
2459defm S_WAITCNT_VMCNT        : SOPK_Real32_gfx11<0x019>;
2460defm S_WAITCNT_EXPCNT       : SOPK_Real32_gfx11<0x01a>;
2461defm S_WAITCNT_LGKMCNT      : SOPK_Real32_gfx11<0x01b>;
2462
2463//===----------------------------------------------------------------------===//
2464// SOPK - GFX10.
2465//===----------------------------------------------------------------------===//
2466
2467multiclass SOPK_Real32_gfx10<bits<5> op> {
2468  defvar ps = !cast<SOPK_Pseudo>(NAME);
2469  def _gfx10 : SOPK_Real32<op, ps>,
2470               Select_gfx10<ps.Mnemonic>;
2471}
2472
2473multiclass SOPK_Real64_gfx10<bits<5> op> {
2474  defvar ps = !cast<SOPK_Pseudo>(NAME);
2475  def _gfx10 : SOPK_Real64<op, ps>,
2476               Select_gfx10<ps.Mnemonic>;
2477}
2478
2479multiclass SOPK_Real32_gfx10_gfx11<bits<5> op> :
2480  SOPK_Real32_gfx10<op>, SOPK_Real32_gfx11<op>;
2481
2482multiclass SOPK_Real32_gfx10_gfx11_gfx12<bits<5> op> :
2483  SOPK_Real32_gfx10<op>, SOPK_Real32_gfx11_gfx12<op>;
2484
2485defm S_VERSION              : SOPK_Real32_gfx10_gfx11_gfx12<0x001>;
2486defm S_CALL_B64             : SOPK_Real32_gfx10<0x016>;
2487defm S_WAITCNT_VSCNT        : SOPK_Real32_gfx10<0x017>;
2488defm S_WAITCNT_VMCNT        : SOPK_Real32_gfx10<0x018>;
2489defm S_WAITCNT_EXPCNT       : SOPK_Real32_gfx10<0x019>;
2490defm S_WAITCNT_LGKMCNT      : SOPK_Real32_gfx10<0x01a>;
2491defm S_SUBVECTOR_LOOP_BEGIN : SOPK_Real32_gfx10<0x01b>;
2492defm S_SUBVECTOR_LOOP_END   : SOPK_Real32_gfx10<0x01c>;
2493
2494//===----------------------------------------------------------------------===//
2495// SOPK - GFX6, GFX7.
2496//===----------------------------------------------------------------------===//
2497
2498multiclass SOPK_Real32_gfx6_gfx7<bits<5> op> {
2499  defvar ps = !cast<SOPK_Pseudo>(NAME);
2500  def _gfx6_gfx7 : SOPK_Real32<op, ps>,
2501                   Select_gfx6_gfx7<ps.Mnemonic>;
2502}
2503
2504multiclass SOPK_Real64_gfx6_gfx7<bits<5> op> {
2505  defvar ps = !cast<SOPK_Pseudo>(NAME);
2506  def _gfx6_gfx7 : SOPK_Real64<op, ps>,
2507                   Select_gfx6_gfx7<ps.Mnemonic>;
2508}
2509
2510multiclass SOPK_Real32_gfx6_gfx7_gfx10<bits<5> op> :
2511  SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10<op>;
2512
2513multiclass SOPK_Real64_gfx6_gfx7_gfx10<bits<5> op> :
2514  SOPK_Real64_gfx6_gfx7<op>, SOPK_Real64_gfx10<op>;
2515
2516multiclass SOPK_Real32_gfx6_gfx7_gfx10_gfx11<bits<5> op> :
2517  SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10_gfx11<op>;
2518
2519multiclass SOPK_Real32_gfx6_gfx7_gfx10_gfx11_gfx12<bits<5> op> :
2520  SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10_gfx11_gfx12<op>;
2521
2522defm S_CBRANCH_I_FORK : SOPK_Real32_gfx6_gfx7<0x011>;
2523
2524defm S_MOVK_I32         : SOPK_Real32_gfx6_gfx7_gfx10_gfx11_gfx12<0x000>;
2525defm S_CMOVK_I32        : SOPK_Real32_gfx6_gfx7_gfx10_gfx11_gfx12<0x002>;
2526defm S_CMPK_EQ_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x003>;
2527defm S_CMPK_LG_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x004>;
2528defm S_CMPK_GT_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x005>;
2529defm S_CMPK_GE_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x006>;
2530defm S_CMPK_LT_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x007>;
2531defm S_CMPK_LE_I32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x008>;
2532defm S_CMPK_EQ_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x009>;
2533defm S_CMPK_LG_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00a>;
2534defm S_CMPK_GT_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00b>;
2535defm S_CMPK_GE_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00c>;
2536defm S_CMPK_LT_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00d>;
2537defm S_CMPK_LE_U32      : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00e>;
2538defm S_ADDK_I32         : SOPK_Real32_gfx6_gfx7_gfx10_gfx11<0x00f>;
2539defm S_MULK_I32         : SOPK_Real32_gfx6_gfx7_gfx10_gfx11_gfx12<0x010>;
2540defm S_GETREG_B32       : SOPK_Real32_gfx6_gfx7_gfx10<0x012>;
2541defm S_SETREG_B32       : SOPK_Real32_gfx6_gfx7_gfx10<0x013>;
2542defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>;
2543
2544//===----------------------------------------------------------------------===//
2545// SOPP - GFX12 only.
2546//===----------------------------------------------------------------------===//
2547
2548multiclass SOPP_Real_32_gfx12<bits<7> op> {
2549  def _gfx12 : SOPP_Real_32<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
2550               Select_gfx12<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
2551               SOPPRelaxTable<0, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx12">;
2552}
2553
2554multiclass SOPP_Real_32_Renamed_gfx12<bits<7> op, SOPP_Pseudo backing_pseudo, string real_name> {
2555  def _gfx12 : SOPP_Real_32<op, backing_pseudo, real_name>,
2556               Select_gfx12<backing_pseudo.Mnemonic>,
2557               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX12Plus]>;
2558}
2559
2560defm S_WAIT_ALU             : SOPP_Real_32_Renamed_gfx12<0x008, S_WAITCNT_DEPCTR, "s_wait_alu">;
2561defm S_BARRIER_WAIT         : SOPP_Real_32_gfx12<0x014>;
2562defm S_BARRIER_LEAVE        : SOPP_Real_32_gfx12<0x015>;
2563defm S_WAIT_LOADCNT         : SOPP_Real_32_gfx12<0x040>;
2564defm S_WAIT_STORECNT        : SOPP_Real_32_gfx12<0x041>;
2565defm S_WAIT_SAMPLECNT       : SOPP_Real_32_gfx12<0x042>;
2566defm S_WAIT_BVHCNT          : SOPP_Real_32_gfx12<0x043>;
2567defm S_WAIT_EXPCNT          : SOPP_Real_32_gfx12<0x044>;
2568defm S_WAIT_DSCNT           : SOPP_Real_32_gfx12<0x046>;
2569defm S_WAIT_KMCNT           : SOPP_Real_32_gfx12<0x047>;
2570defm S_WAIT_LOADCNT_DSCNT   : SOPP_Real_32_gfx12<0x048>;
2571defm S_WAIT_STORECNT_DSCNT  : SOPP_Real_32_gfx12<0x049>;
2572
2573//===----------------------------------------------------------------------===//
2574// SOPP - GFX11, GFX12.
2575//===----------------------------------------------------------------------===//
2576
2577
2578multiclass SOPP_Real_32_gfx11<bits<7> op> {
2579  def _gfx11 : SOPP_Real_32<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
2580               Select_gfx11<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
2581               SOPPRelaxTable<0, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx11">;
2582}
2583
2584multiclass SOPP_Real_64_gfx12<bits<7> op> {
2585  def _gfx12 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
2586               Select_gfx12<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
2587               SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx12">;
2588}
2589
2590multiclass SOPP_Real_64_gfx11<bits<7> op> {
2591  def _gfx11 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
2592               Select_gfx11<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
2593               SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx11">;
2594}
2595
2596multiclass SOPP_Real_32_Renamed_gfx11<bits<7> op, SOPP_Pseudo backing_pseudo, string real_name> {
2597  def _gfx11 : SOPP_Real_32<op, backing_pseudo, real_name>,
2598               Select_gfx11<backing_pseudo.Mnemonic>,
2599               MnemonicAlias<backing_pseudo.Mnemonic, real_name>, Requires<[isGFX11Only]>;
2600}
2601
2602multiclass SOPP_Real_32_gfx11_gfx12<bits<7> op> :
2603  SOPP_Real_32_gfx11<op>, SOPP_Real_32_gfx12<op>;
2604
2605multiclass SOPP_Real_64_gfx11_gfx12<bits<7> op> :
2606  SOPP_Real_64_gfx11<op>, SOPP_Real_64_gfx12<op>;
2607
2608multiclass SOPP_Real_32_Renamed_gfx11_gfx12<bits<7> op, SOPP_Pseudo backing_pseudo, string real_name> :
2609  SOPP_Real_32_Renamed_gfx11<op, backing_pseudo, real_name>,
2610  SOPP_Real_32_Renamed_gfx12<op, backing_pseudo, real_name>;
2611
2612multiclass SOPP_Real_With_Relaxation_gfx12<bits<7> op> {
2613  defm "" : SOPP_Real_32_gfx12<op>;
2614  defm _pad_s_nop : SOPP_Real_64_gfx12<op>;
2615}
2616
2617multiclass SOPP_Real_With_Relaxation_gfx11<bits<7> op> {
2618  defm "" : SOPP_Real_32_gfx11<op>;
2619  defm _pad_s_nop : SOPP_Real_64_gfx11<op>;
2620}
2621
2622multiclass SOPP_Real_With_Relaxation_gfx11_gfx12<bits<7>op> :
2623  SOPP_Real_With_Relaxation_gfx11<op>, SOPP_Real_With_Relaxation_gfx12<op>;
2624
2625defm S_SETKILL                    : SOPP_Real_32_gfx11_gfx12<0x001>;
2626defm S_SETHALT                    : SOPP_Real_32_gfx11_gfx12<0x002>;
2627defm S_SLEEP                      : SOPP_Real_32_gfx11_gfx12<0x003>;
2628defm S_SET_INST_PREFETCH_DISTANCE : SOPP_Real_32_Renamed_gfx11<0x004, S_INST_PREFETCH, "s_set_inst_prefetch_distance">;
2629defm S_CLAUSE                     : SOPP_Real_32_gfx11_gfx12<0x005>;
2630defm S_DELAY_ALU                  : SOPP_Real_32_gfx11_gfx12<0x007>;
2631defm S_WAITCNT_DEPCTR             : SOPP_Real_32_gfx11<0x008>;
2632defm S_WAITCNT                    : SOPP_Real_32_gfx11_gfx12<0x009>;
2633defm S_WAIT_IDLE                  : SOPP_Real_32_gfx11_gfx12<0x00a>;
2634defm S_WAIT_EVENT                 : SOPP_Real_32_gfx11_gfx12<0x00b>;
2635defm S_TRAP                       : SOPP_Real_32_gfx11_gfx12<0x010>;
2636defm S_ROUND_MODE                 : SOPP_Real_32_gfx11_gfx12<0x011>;
2637defm S_DENORM_MODE                : SOPP_Real_32_gfx11_gfx12<0x012>;
2638defm S_BRANCH                     : SOPP_Real_With_Relaxation_gfx11_gfx12<0x020>;
2639defm S_CBRANCH_SCC0               : SOPP_Real_With_Relaxation_gfx11_gfx12<0x021>;
2640defm S_CBRANCH_SCC1               : SOPP_Real_With_Relaxation_gfx11_gfx12<0x022>;
2641defm S_CBRANCH_VCCZ               : SOPP_Real_With_Relaxation_gfx11_gfx12<0x023>;
2642defm S_CBRANCH_VCCNZ              : SOPP_Real_With_Relaxation_gfx11_gfx12<0x024>;
2643defm S_CBRANCH_EXECZ              : SOPP_Real_With_Relaxation_gfx11_gfx12<0x025>;
2644defm S_CBRANCH_EXECNZ             : SOPP_Real_With_Relaxation_gfx11_gfx12<0x026>;
2645defm S_CBRANCH_CDBGSYS            : SOPP_Real_With_Relaxation_gfx11<0x027>;
2646defm S_CBRANCH_CDBGUSER           : SOPP_Real_With_Relaxation_gfx11<0x028>;
2647defm S_CBRANCH_CDBGSYS_OR_USER    : SOPP_Real_With_Relaxation_gfx11<0x029>;
2648defm S_CBRANCH_CDBGSYS_AND_USER   : SOPP_Real_With_Relaxation_gfx11<0x02a>;
2649defm S_ENDPGM                     : SOPP_Real_32_gfx11_gfx12<0x030>;
2650defm S_ENDPGM_SAVED               : SOPP_Real_32_gfx11_gfx12<0x031>;
2651defm S_WAKEUP                     : SOPP_Real_32_gfx11_gfx12<0x034>;
2652defm S_SETPRIO                    : SOPP_Real_32_gfx11_gfx12<0x035>;
2653defm S_SENDMSG                    : SOPP_Real_32_gfx11_gfx12<0x036>;
2654defm S_SENDMSGHALT                : SOPP_Real_32_gfx11_gfx12<0x037>;
2655defm S_INCPERFLEVEL               : SOPP_Real_32_gfx11_gfx12<0x038>;
2656defm S_DECPERFLEVEL               : SOPP_Real_32_gfx11_gfx12<0x039>;
2657defm S_TTRACEDATA                 : SOPP_Real_32_gfx11_gfx12<0x03a>;
2658defm S_TTRACEDATA_IMM             : SOPP_Real_32_gfx11_gfx12<0x03b>;
2659defm S_ICACHE_INV                 : SOPP_Real_32_gfx11_gfx12<0x03c>;
2660defm S_BARRIER                    : SOPP_Real_32_gfx11_gfx12<0x03d>;
2661
2662//===----------------------------------------------------------------------===//
2663// SOPP - GFX1150, GFX12.
2664//===----------------------------------------------------------------------===//
2665
2666defm S_SINGLEUSE_VDST             : SOPP_Real_32_gfx11_gfx12<0x013>;
2667
2668//===----------------------------------------------------------------------===//
2669// SOPP - GFX6, GFX7, GFX8, GFX9, GFX10
2670//===----------------------------------------------------------------------===//
2671
2672multiclass SOPP_Real_32_gfx6_gfx7<bits<7> op> {
2673  defvar ps = !cast<SOPP_Pseudo>(NAME);
2674  def _gfx6_gfx7 : SOPP_Real_32<op, ps, !cast<SOPP_Pseudo>(NAME).Mnemonic>,
2675                   Select_gfx6_gfx7<ps.Mnemonic>,
2676                   SOPPRelaxTable<0, ps.KeyName, "_gfx6_gfx7">;
2677}
2678
2679multiclass SOPP_Real_32_gfx8_gfx9<bits<7> op> {
2680  defvar ps = !cast<SOPP_Pseudo>(NAME);
2681  def _vi : SOPP_Real_32<op, ps>,
2682            Select_vi<ps.Mnemonic>,
2683            SOPPRelaxTable<0, ps.KeyName, "_vi">;
2684}
2685
2686multiclass SOPP_Real_32_gfx10<bits<7> op> {
2687  defvar ps = !cast<SOPP_Pseudo>(NAME);
2688  def _gfx10 : SOPP_Real_32<op, ps>,
2689               Select_gfx10<ps.Mnemonic>,
2690               SOPPRelaxTable<0, ps.KeyName, "_gfx10">;
2691}
2692
2693multiclass SOPP_Real_32_gfx8_gfx9_gfx10<bits<7> op> :
2694  SOPP_Real_32_gfx8_gfx9<op>, SOPP_Real_32_gfx10<op>;
2695
2696multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<bits<7> op> :
2697  SOPP_Real_32_gfx6_gfx7<op>, SOPP_Real_32_gfx8_gfx9<op>;
2698
2699multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> :
2700  SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<op>, SOPP_Real_32_gfx10<op>;
2701
2702multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10_gfx11_gfx12<bits<7> op> :
2703  SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<op>, SOPP_Real_32_gfx11_gfx12<op>;
2704
2705multiclass SOPP_Real_32_gfx10_gfx11_gfx12<bits<7> op> :
2706  SOPP_Real_32_gfx10<op>, SOPP_Real_32_gfx11_gfx12<op>;
2707
2708//64 bit encodings, for Relaxation
2709multiclass SOPP_Real_64_gfx6_gfx7<bits<7> op> {
2710  defvar ps = !cast<SOPP_Pseudo>(NAME);
2711  def _gfx6_gfx7 : SOPP_Real_64<op, ps>,
2712                   Select_gfx6_gfx7<ps.Mnemonic>,
2713                   SOPPRelaxTable<1, ps.KeyName, "_gfx6_gfx7">;
2714}
2715
2716multiclass SOPP_Real_64_gfx8_gfx9<bits<7> op> {
2717  defvar ps = !cast<SOPP_Pseudo>(NAME);
2718  def _vi : SOPP_Real_64<op, ps>,
2719            Select_vi<ps.Mnemonic>,
2720            SOPPRelaxTable<1, ps.KeyName, "_vi">;
2721}
2722
2723multiclass SOPP_Real_64_gfx10<bits<7> op> {
2724  defvar ps = !cast<SOPP_Pseudo>(NAME);
2725  def _gfx10 : SOPP_Real_64<op, ps>,
2726               Select_gfx10<ps.Mnemonic>,
2727               SOPPRelaxTable<1, ps.KeyName, "_gfx10">;
2728}
2729
2730multiclass SOPP_Real_64_gfx8_gfx9_gfx10<bits<7> op> :
2731  SOPP_Real_64_gfx8_gfx9<op>, SOPP_Real_64_gfx10<op>;
2732
2733multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<bits<7> op> :
2734  SOPP_Real_64_gfx6_gfx7<op>, SOPP_Real_64_gfx8_gfx9<op>;
2735
2736multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> :
2737  SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<op>, SOPP_Real_64_gfx10<op>;
2738
2739multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10_gfx11_gfx12<bits<7> op> :
2740  SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<op>, SOPP_Real_64_gfx11_gfx12<op>;
2741
2742//relaxation for insts with no operands not implemented
2743multiclass SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> {
2744  defm "" : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<op>;
2745  defm _pad_s_nop : SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<op>;
2746}
2747
2748defm S_NOP                      : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10_gfx11_gfx12<0x000>;
2749defm S_ENDPGM                   : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x001>;
2750defm S_WAKEUP                   : SOPP_Real_32_gfx8_gfx9_gfx10<0x003>;
2751defm S_BARRIER                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00a>;
2752defm S_WAITCNT                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00c>;
2753defm S_SETHALT                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00d>;
2754defm S_SETKILL                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00b>;
2755defm S_SLEEP                    : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00e>;
2756defm S_SETPRIO                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00f>;
2757defm S_SENDMSG                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x010>;
2758defm S_SENDMSGHALT              : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x011>;
2759defm S_TRAP                     : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x012>;
2760defm S_ICACHE_INV               : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x013>;
2761defm S_INCPERFLEVEL             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x014>;
2762defm S_DECPERFLEVEL             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x015>;
2763defm S_TTRACEDATA               : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x016>;
2764defm S_ENDPGM_SAVED             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x01B>;
2765defm S_SET_GPR_IDX_OFF          : SOPP_Real_32_gfx8_gfx9<0x01c>;
2766defm S_SET_GPR_IDX_MODE         : SOPP_Real_32_gfx8_gfx9<0x01d>;
2767defm S_ENDPGM_ORDERED_PS_DONE   : SOPP_Real_32_gfx8_gfx9_gfx10<0x01e>;
2768defm S_CODE_END                 : SOPP_Real_32_gfx10_gfx11_gfx12<0x01f>;
2769defm S_INST_PREFETCH            : SOPP_Real_32_gfx10<0x020>;
2770defm S_CLAUSE                   : SOPP_Real_32_gfx10<0x021>;
2771defm S_WAIT_IDLE                : SOPP_Real_32_gfx10<0x022>;
2772defm S_WAITCNT_DEPCTR           : SOPP_Real_32_gfx10<0x023>;
2773defm S_ROUND_MODE               : SOPP_Real_32_gfx10<0x024>;
2774defm S_DENORM_MODE              : SOPP_Real_32_gfx10<0x025>;
2775defm S_TTRACEDATA_IMM           : SOPP_Real_32_gfx10<0x028>;
2776
2777let isBranch = 1 in {
2778defm S_BRANCH                   : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x002>;
2779defm S_CBRANCH_SCC0             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x004>;
2780defm S_CBRANCH_SCC1             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x005>;
2781defm S_CBRANCH_VCCZ             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x006>;
2782defm S_CBRANCH_VCCNZ            : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x007>;
2783defm S_CBRANCH_EXECZ            : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x008>;
2784defm S_CBRANCH_EXECNZ           : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x009>;
2785defm S_CBRANCH_CDBGSYS          : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x017>;
2786defm S_CBRANCH_CDBGUSER         : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x018>;
2787defm S_CBRANCH_CDBGSYS_OR_USER  : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x019>;
2788defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x01A>;
2789}
2790
2791//===----------------------------------------------------------------------===//
2792// SOPC - GFX11, GFX12.
2793//===----------------------------------------------------------------------===//
2794
2795multiclass SOPC_Real_gfx12<bits<7> op> {
2796  def _gfx12 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
2797               Select_gfx12<!cast<SOPC_Pseudo>(NAME).Mnemonic>;
2798}
2799
2800multiclass SOPC_Real_gfx11<bits<7> op> {
2801  def _gfx11 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
2802               Select_gfx11<!cast<SOPC_Pseudo>(NAME).Mnemonic>;
2803}
2804
2805multiclass SOPC_Real_gfx11_gfx12<bits<7> op> :
2806  SOPC_Real_gfx11<op>, SOPC_Real_gfx12<op>;
2807
2808defm S_CMP_EQ_I32     : SOPC_Real_gfx11_gfx12<0x00>;
2809defm S_CMP_LG_I32     : SOPC_Real_gfx11_gfx12<0x01>;
2810defm S_CMP_GT_I32     : SOPC_Real_gfx11_gfx12<0x02>;
2811defm S_CMP_GE_I32     : SOPC_Real_gfx11_gfx12<0x03>;
2812defm S_CMP_LT_I32     : SOPC_Real_gfx11_gfx12<0x04>;
2813defm S_CMP_LE_I32     : SOPC_Real_gfx11_gfx12<0x05>;
2814defm S_CMP_EQ_U32     : SOPC_Real_gfx11_gfx12<0x06>;
2815defm S_CMP_LG_U32     : SOPC_Real_gfx11_gfx12<0x07>;
2816defm S_CMP_GT_U32     : SOPC_Real_gfx11_gfx12<0x08>;
2817defm S_CMP_GE_U32     : SOPC_Real_gfx11_gfx12<0x09>;
2818defm S_CMP_LT_U32     : SOPC_Real_gfx11_gfx12<0x0a>;
2819defm S_CMP_LE_U32     : SOPC_Real_gfx11_gfx12<0x0b>;
2820defm S_BITCMP0_B32    : SOPC_Real_gfx11_gfx12<0x0c>;
2821defm S_BITCMP1_B32    : SOPC_Real_gfx11_gfx12<0x0d>;
2822defm S_BITCMP0_B64    : SOPC_Real_gfx11_gfx12<0x0e>;
2823defm S_BITCMP1_B64    : SOPC_Real_gfx11_gfx12<0x0f>;
2824defm S_CMP_EQ_U64     : SOPC_Real_gfx11_gfx12<0x10>;
2825defm S_CMP_LG_U64     : SOPC_Real_gfx11_gfx12<0x11>;
2826
2827//===----------------------------------------------------------------------===//
2828// SOPC - GFX1150, GFX12
2829//===----------------------------------------------------------------------===//
2830
2831defm S_CMP_LT_F32  : SOPC_Real_gfx11_gfx12<0x41>;
2832defm S_CMP_EQ_F32  : SOPC_Real_gfx11_gfx12<0x42>;
2833defm S_CMP_LE_F32  : SOPC_Real_gfx11_gfx12<0x43>;
2834defm S_CMP_GT_F32  : SOPC_Real_gfx11_gfx12<0x44>;
2835defm S_CMP_LG_F32  : SOPC_Real_gfx11_gfx12<0x45>;
2836defm S_CMP_GE_F32  : SOPC_Real_gfx11_gfx12<0x46>;
2837defm S_CMP_O_F32   : SOPC_Real_gfx11_gfx12<0x47>;
2838defm S_CMP_U_F32   : SOPC_Real_gfx11_gfx12<0x48>;
2839defm S_CMP_NGE_F32 : SOPC_Real_gfx11_gfx12<0x49>;
2840defm S_CMP_NLG_F32 : SOPC_Real_gfx11_gfx12<0x4a>;
2841defm S_CMP_NGT_F32 : SOPC_Real_gfx11_gfx12<0x4b>;
2842defm S_CMP_NLE_F32 : SOPC_Real_gfx11_gfx12<0x4c>;
2843defm S_CMP_NEQ_F32 : SOPC_Real_gfx11_gfx12<0x4d>;
2844defm S_CMP_NLT_F32 : SOPC_Real_gfx11_gfx12<0x4e>;
2845
2846defm S_CMP_LT_F16  : SOPC_Real_gfx11_gfx12<0x51>;
2847defm S_CMP_EQ_F16  : SOPC_Real_gfx11_gfx12<0x52>;
2848defm S_CMP_LE_F16  : SOPC_Real_gfx11_gfx12<0x53>;
2849defm S_CMP_GT_F16  : SOPC_Real_gfx11_gfx12<0x54>;
2850defm S_CMP_LG_F16  : SOPC_Real_gfx11_gfx12<0x55>;
2851defm S_CMP_GE_F16  : SOPC_Real_gfx11_gfx12<0x56>;
2852defm S_CMP_O_F16   : SOPC_Real_gfx11_gfx12<0x57>;
2853defm S_CMP_U_F16   : SOPC_Real_gfx11_gfx12<0x58>;
2854defm S_CMP_NGE_F16 : SOPC_Real_gfx11_gfx12<0x59>;
2855defm S_CMP_NLG_F16 : SOPC_Real_gfx11_gfx12<0x5a>;
2856defm S_CMP_NGT_F16 : SOPC_Real_gfx11_gfx12<0x5b>;
2857defm S_CMP_NLE_F16 : SOPC_Real_gfx11_gfx12<0x5c>;
2858defm S_CMP_NEQ_F16 : SOPC_Real_gfx11_gfx12<0x5d>;
2859defm S_CMP_NLT_F16 : SOPC_Real_gfx11_gfx12<0x5e>;
2860
2861//===----------------------------------------------------------------------===//
2862// SOPC - GFX6, GFX7, GFX8, GFX9, GFX10
2863//===----------------------------------------------------------------------===//
2864
2865multiclass SOPC_Real_gfx6_gfx7<bits<7> op> {
2866  defvar ps = !cast<SOPC_Pseudo>(NAME);
2867  def _gfx6_gfx7 : SOPC_Real<op, ps>,
2868                   Select_gfx6_gfx7<ps.Mnemonic>;
2869}
2870
2871multiclass SOPC_Real_gfx8_gfx9<bits<7> op> {
2872  defvar ps = !cast<SOPC_Pseudo>(NAME);
2873  def _vi : SOPC_Real<op, ps>,
2874            Select_vi<ps.Mnemonic>;
2875}
2876
2877multiclass SOPC_Real_gfx10<bits<7> op> {
2878  defvar ps = !cast<SOPC_Pseudo>(NAME);
2879  def _gfx10 : SOPC_Real<op, ps>,
2880               Select_gfx10<ps.Mnemonic>;
2881}
2882
2883multiclass SOPC_Real_gfx8_gfx9_gfx10<bits<7> op> :
2884  SOPC_Real_gfx8_gfx9<op>, SOPC_Real_gfx10<op>;
2885
2886multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9<bits<7> op> :
2887  SOPC_Real_gfx6_gfx7<op>, SOPC_Real_gfx8_gfx9<op>;
2888
2889multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> :
2890  SOPC_Real_gfx6_gfx7_gfx8_gfx9<op>, SOPC_Real_gfx10<op>;
2891
2892defm S_CMP_EQ_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x00>;
2893defm S_CMP_LG_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x01>;
2894defm S_CMP_GT_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x02>;
2895defm S_CMP_GE_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x03>;
2896defm S_CMP_LT_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x04>;
2897defm S_CMP_LE_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x05>;
2898defm S_CMP_EQ_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x06>;
2899defm S_CMP_LG_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x07>;
2900defm S_CMP_GT_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x08>;
2901defm S_CMP_GE_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x09>;
2902defm S_CMP_LT_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0a>;
2903defm S_CMP_LE_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0b>;
2904defm S_BITCMP0_B32    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0c>;
2905defm S_BITCMP1_B32    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0d>;
2906defm S_BITCMP0_B64    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0e>;
2907defm S_BITCMP1_B64    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0f>;
2908defm S_SETVSKIP       : SOPC_Real_gfx6_gfx7_gfx8_gfx9<0x10>;
2909defm S_SET_GPR_IDX_ON : SOPC_Real_gfx8_gfx9<0x11>;
2910defm S_CMP_EQ_U64     : SOPC_Real_gfx8_gfx9_gfx10<0x12>;
2911defm S_CMP_LG_U64     : SOPC_Real_gfx8_gfx9_gfx10<0x13>;
2912
2913//===----------------------------------------------------------------------===//
2914// GFX8 (VI), GFX9.
2915//===----------------------------------------------------------------------===//
2916
2917class SOP1_Real_vi<bits<8> op, SOP1_Pseudo ps> :
2918  SOP1_Real<op, ps>,
2919  Select_vi<ps.Mnemonic>;
2920
2921class SOP2_Real_vi<bits<7> op, SOP2_Pseudo ps> :
2922  SOP2_Real32<op, ps>,
2923  Select_vi<ps.Mnemonic>;
2924
2925class SOPK_Real_vi<bits<5> op, SOPK_Pseudo ps> :
2926  SOPK_Real32<op, ps>,
2927  Select_vi<ps.Mnemonic>;
2928
2929def S_MOV_B32_vi           : SOP1_Real_vi <0x00, S_MOV_B32>;
2930def S_MOV_B64_vi           : SOP1_Real_vi <0x01, S_MOV_B64>;
2931def S_CMOV_B32_vi          : SOP1_Real_vi <0x02, S_CMOV_B32>;
2932def S_CMOV_B64_vi          : SOP1_Real_vi <0x03, S_CMOV_B64>;
2933def S_NOT_B32_vi           : SOP1_Real_vi <0x04, S_NOT_B32>;
2934def S_NOT_B64_vi           : SOP1_Real_vi <0x05, S_NOT_B64>;
2935def S_WQM_B32_vi           : SOP1_Real_vi <0x06, S_WQM_B32>;
2936def S_WQM_B64_vi           : SOP1_Real_vi <0x07, S_WQM_B64>;
2937def S_BREV_B32_vi          : SOP1_Real_vi <0x08, S_BREV_B32>;
2938def S_BREV_B64_vi          : SOP1_Real_vi <0x09, S_BREV_B64>;
2939def S_BCNT0_I32_B32_vi     : SOP1_Real_vi <0x0a, S_BCNT0_I32_B32>;
2940def S_BCNT0_I32_B64_vi     : SOP1_Real_vi <0x0b, S_BCNT0_I32_B64>;
2941def S_BCNT1_I32_B32_vi     : SOP1_Real_vi <0x0c, S_BCNT1_I32_B32>;
2942def S_BCNT1_I32_B64_vi     : SOP1_Real_vi <0x0d, S_BCNT1_I32_B64>;
2943def S_FF0_I32_B32_vi       : SOP1_Real_vi <0x0e, S_FF0_I32_B32>;
2944def S_FF0_I32_B64_vi       : SOP1_Real_vi <0x0f, S_FF0_I32_B64>;
2945def S_FF1_I32_B32_vi       : SOP1_Real_vi <0x10, S_FF1_I32_B32>;
2946def S_FF1_I32_B64_vi       : SOP1_Real_vi <0x11, S_FF1_I32_B64>;
2947def S_FLBIT_I32_B32_vi     : SOP1_Real_vi <0x12, S_FLBIT_I32_B32>;
2948def S_FLBIT_I32_B64_vi     : SOP1_Real_vi <0x13, S_FLBIT_I32_B64>;
2949def S_FLBIT_I32_vi         : SOP1_Real_vi <0x14, S_FLBIT_I32>;
2950def S_FLBIT_I32_I64_vi     : SOP1_Real_vi <0x15, S_FLBIT_I32_I64>;
2951def S_SEXT_I32_I8_vi       : SOP1_Real_vi <0x16, S_SEXT_I32_I8>;
2952def S_SEXT_I32_I16_vi      : SOP1_Real_vi <0x17, S_SEXT_I32_I16>;
2953def S_BITSET0_B32_vi       : SOP1_Real_vi <0x18, S_BITSET0_B32>;
2954def S_BITSET0_B64_vi       : SOP1_Real_vi <0x19, S_BITSET0_B64>;
2955def S_BITSET1_B32_vi       : SOP1_Real_vi <0x1a, S_BITSET1_B32>;
2956def S_BITSET1_B64_vi       : SOP1_Real_vi <0x1b, S_BITSET1_B64>;
2957def S_GETPC_B64_vi         : SOP1_Real_vi <0x1c, S_GETPC_B64>;
2958def S_SETPC_B64_vi         : SOP1_Real_vi <0x1d, S_SETPC_B64>;
2959def S_SWAPPC_B64_vi        : SOP1_Real_vi <0x1e, S_SWAPPC_B64>;
2960def S_RFE_B64_vi           : SOP1_Real_vi <0x1f, S_RFE_B64>;
2961def S_AND_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x20, S_AND_SAVEEXEC_B64>;
2962def S_OR_SAVEEXEC_B64_vi   : SOP1_Real_vi <0x21, S_OR_SAVEEXEC_B64>;
2963def S_XOR_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x22, S_XOR_SAVEEXEC_B64>;
2964def S_ANDN2_SAVEEXEC_B64_vi: SOP1_Real_vi <0x23, S_ANDN2_SAVEEXEC_B64>;
2965def S_ORN2_SAVEEXEC_B64_vi : SOP1_Real_vi <0x24, S_ORN2_SAVEEXEC_B64>;
2966def S_NAND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x25, S_NAND_SAVEEXEC_B64>;
2967def S_NOR_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x26, S_NOR_SAVEEXEC_B64>;
2968def S_XNOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x27, S_XNOR_SAVEEXEC_B64>;
2969def S_QUADMASK_B32_vi      : SOP1_Real_vi <0x28, S_QUADMASK_B32>;
2970def S_QUADMASK_B64_vi      : SOP1_Real_vi <0x29, S_QUADMASK_B64>;
2971def S_MOVRELS_B32_vi       : SOP1_Real_vi <0x2a, S_MOVRELS_B32>;
2972def S_MOVRELS_B64_vi       : SOP1_Real_vi <0x2b, S_MOVRELS_B64>;
2973def S_MOVRELD_B32_vi       : SOP1_Real_vi <0x2c, S_MOVRELD_B32>;
2974def S_MOVRELD_B64_vi       : SOP1_Real_vi <0x2d, S_MOVRELD_B64>;
2975def S_CBRANCH_JOIN_vi      : SOP1_Real_vi <0x2e, S_CBRANCH_JOIN>;
2976def S_ABS_I32_vi           : SOP1_Real_vi <0x30, S_ABS_I32>;
2977def S_SET_GPR_IDX_IDX_vi   : SOP1_Real_vi <0x32, S_SET_GPR_IDX_IDX>;
2978
2979def S_ADD_U32_vi           : SOP2_Real_vi <0x00, S_ADD_U32>;
2980def S_ADD_I32_vi           : SOP2_Real_vi <0x02, S_ADD_I32>;
2981def S_SUB_U32_vi           : SOP2_Real_vi <0x01, S_SUB_U32>;
2982def S_SUB_I32_vi           : SOP2_Real_vi <0x03, S_SUB_I32>;
2983def S_ADDC_U32_vi          : SOP2_Real_vi <0x04, S_ADDC_U32>;
2984def S_SUBB_U32_vi          : SOP2_Real_vi <0x05, S_SUBB_U32>;
2985def S_MIN_I32_vi           : SOP2_Real_vi <0x06, S_MIN_I32>;
2986def S_MIN_U32_vi           : SOP2_Real_vi <0x07, S_MIN_U32>;
2987def S_MAX_I32_vi           : SOP2_Real_vi <0x08, S_MAX_I32>;
2988def S_MAX_U32_vi           : SOP2_Real_vi <0x09, S_MAX_U32>;
2989def S_CSELECT_B32_vi       : SOP2_Real_vi <0x0a, S_CSELECT_B32>;
2990def S_CSELECT_B64_vi       : SOP2_Real_vi <0x0b, S_CSELECT_B64>;
2991def S_AND_B32_vi           : SOP2_Real_vi <0x0c, S_AND_B32>;
2992def S_AND_B64_vi           : SOP2_Real_vi <0x0d, S_AND_B64>;
2993def S_OR_B32_vi            : SOP2_Real_vi <0x0e, S_OR_B32>;
2994def S_OR_B64_vi            : SOP2_Real_vi <0x0f, S_OR_B64>;
2995def S_XOR_B32_vi           : SOP2_Real_vi <0x10, S_XOR_B32>;
2996def S_XOR_B64_vi           : SOP2_Real_vi <0x11, S_XOR_B64>;
2997def S_ANDN2_B32_vi         : SOP2_Real_vi <0x12, S_ANDN2_B32>;
2998def S_ANDN2_B64_vi         : SOP2_Real_vi <0x13, S_ANDN2_B64>;
2999def S_ORN2_B32_vi          : SOP2_Real_vi <0x14, S_ORN2_B32>;
3000def S_ORN2_B64_vi          : SOP2_Real_vi <0x15, S_ORN2_B64>;
3001def S_NAND_B32_vi          : SOP2_Real_vi <0x16, S_NAND_B32>;
3002def S_NAND_B64_vi          : SOP2_Real_vi <0x17, S_NAND_B64>;
3003def S_NOR_B32_vi           : SOP2_Real_vi <0x18, S_NOR_B32>;
3004def S_NOR_B64_vi           : SOP2_Real_vi <0x19, S_NOR_B64>;
3005def S_XNOR_B32_vi          : SOP2_Real_vi <0x1a, S_XNOR_B32>;
3006def S_XNOR_B64_vi          : SOP2_Real_vi <0x1b, S_XNOR_B64>;
3007def S_LSHL_B32_vi          : SOP2_Real_vi <0x1c, S_LSHL_B32>;
3008def S_LSHL_B64_vi          : SOP2_Real_vi <0x1d, S_LSHL_B64>;
3009def S_LSHR_B32_vi          : SOP2_Real_vi <0x1e, S_LSHR_B32>;
3010def S_LSHR_B64_vi          : SOP2_Real_vi <0x1f, S_LSHR_B64>;
3011def S_ASHR_I32_vi          : SOP2_Real_vi <0x20, S_ASHR_I32>;
3012def S_ASHR_I64_vi          : SOP2_Real_vi <0x21, S_ASHR_I64>;
3013def S_BFM_B32_vi           : SOP2_Real_vi <0x22, S_BFM_B32>;
3014def S_BFM_B64_vi           : SOP2_Real_vi <0x23, S_BFM_B64>;
3015def S_MUL_I32_vi           : SOP2_Real_vi <0x24, S_MUL_I32>;
3016def S_BFE_U32_vi           : SOP2_Real_vi <0x25, S_BFE_U32>;
3017def S_BFE_I32_vi           : SOP2_Real_vi <0x26, S_BFE_I32>;
3018def S_BFE_U64_vi           : SOP2_Real_vi <0x27, S_BFE_U64>;
3019def S_BFE_I64_vi           : SOP2_Real_vi <0x28, S_BFE_I64>;
3020def S_CBRANCH_G_FORK_vi    : SOP2_Real_vi <0x29, S_CBRANCH_G_FORK>;
3021def S_ABSDIFF_I32_vi       : SOP2_Real_vi <0x2a, S_ABSDIFF_I32>;
3022def S_PACK_LL_B32_B16_vi   : SOP2_Real_vi <0x32, S_PACK_LL_B32_B16>;
3023def S_PACK_LH_B32_B16_vi   : SOP2_Real_vi <0x33, S_PACK_LH_B32_B16>;
3024def S_PACK_HH_B32_B16_vi   : SOP2_Real_vi <0x34, S_PACK_HH_B32_B16>;
3025def S_RFE_RESTORE_B64_vi   : SOP2_Real_vi <0x2b, S_RFE_RESTORE_B64>;
3026
3027def S_MOVK_I32_vi          : SOPK_Real_vi <0x00, S_MOVK_I32>;
3028def S_CMOVK_I32_vi         : SOPK_Real_vi <0x01, S_CMOVK_I32>;
3029def S_CMPK_EQ_I32_vi       : SOPK_Real_vi <0x02, S_CMPK_EQ_I32>;
3030def S_CMPK_LG_I32_vi       : SOPK_Real_vi <0x03, S_CMPK_LG_I32>;
3031def S_CMPK_GT_I32_vi       : SOPK_Real_vi <0x04, S_CMPK_GT_I32>;
3032def S_CMPK_GE_I32_vi       : SOPK_Real_vi <0x05, S_CMPK_GE_I32>;
3033def S_CMPK_LT_I32_vi       : SOPK_Real_vi <0x06, S_CMPK_LT_I32>;
3034def S_CMPK_LE_I32_vi       : SOPK_Real_vi <0x07, S_CMPK_LE_I32>;
3035def S_CMPK_EQ_U32_vi       : SOPK_Real_vi <0x08, S_CMPK_EQ_U32>;
3036def S_CMPK_LG_U32_vi       : SOPK_Real_vi <0x09, S_CMPK_LG_U32>;
3037def S_CMPK_GT_U32_vi       : SOPK_Real_vi <0x0A, S_CMPK_GT_U32>;
3038def S_CMPK_GE_U32_vi       : SOPK_Real_vi <0x0B, S_CMPK_GE_U32>;
3039def S_CMPK_LT_U32_vi       : SOPK_Real_vi <0x0C, S_CMPK_LT_U32>;
3040def S_CMPK_LE_U32_vi       : SOPK_Real_vi <0x0D, S_CMPK_LE_U32>;
3041def S_ADDK_I32_vi          : SOPK_Real_vi <0x0E, S_ADDK_I32>;
3042def S_MULK_I32_vi          : SOPK_Real_vi <0x0F, S_MULK_I32>;
3043def S_CBRANCH_I_FORK_vi    : SOPK_Real_vi <0x10, S_CBRANCH_I_FORK>;
3044def S_GETREG_B32_vi        : SOPK_Real_vi <0x11, S_GETREG_B32>;
3045def S_SETREG_B32_vi        : SOPK_Real_vi <0x12, S_SETREG_B32>;
3046//def S_GETREG_REGRD_B32_vi  : SOPK_Real_vi <0x13, S_GETREG_REGRD_B32>; // see pseudo for comments
3047def S_SETREG_IMM32_B32_vi  : SOPK_Real64<0x14, S_SETREG_IMM32_B32>,
3048                             Select_vi<S_SETREG_IMM32_B32.Mnemonic>;
3049
3050def S_CALL_B64_vi          : SOPK_Real_vi <0x15, S_CALL_B64>;
3051
3052//===----------------------------------------------------------------------===//
3053// SOP1 - GFX9.
3054//===----------------------------------------------------------------------===//
3055
3056def S_ANDN1_SAVEEXEC_B64_vi   : SOP1_Real_vi<0x33, S_ANDN1_SAVEEXEC_B64>;
3057def S_ORN1_SAVEEXEC_B64_vi    : SOP1_Real_vi<0x34, S_ORN1_SAVEEXEC_B64>;
3058def S_ANDN1_WREXEC_B64_vi     : SOP1_Real_vi<0x35, S_ANDN1_WREXEC_B64>;
3059def S_ANDN2_WREXEC_B64_vi     : SOP1_Real_vi<0x36, S_ANDN2_WREXEC_B64>;
3060def S_BITREPLICATE_B64_B32_vi : SOP1_Real_vi<0x37, S_BITREPLICATE_B64_B32>;
3061
3062//===----------------------------------------------------------------------===//
3063// SOP2 - GFX9.
3064//===----------------------------------------------------------------------===//
3065
3066def S_LSHL1_ADD_U32_vi   : SOP2_Real_vi<0x2e, S_LSHL1_ADD_U32>;
3067def S_LSHL2_ADD_U32_vi   : SOP2_Real_vi<0x2f, S_LSHL2_ADD_U32>;
3068def S_LSHL3_ADD_U32_vi   : SOP2_Real_vi<0x30, S_LSHL3_ADD_U32>;
3069def S_LSHL4_ADD_U32_vi   : SOP2_Real_vi<0x31, S_LSHL4_ADD_U32>;
3070def S_MUL_HI_U32_vi      : SOP2_Real_vi<0x2c, S_MUL_HI_U32>;
3071def S_MUL_HI_I32_vi      : SOP2_Real_vi<0x2d, S_MUL_HI_I32>;
3072