xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/SOPInstructions.td (revision 5def4c47d4bd90b209b9b4a4ba9faec15846d8fd)
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 GPRIdxModeMatchClass : AsmOperandClass {
10  let Name = "GPRIdxMode";
11  let PredicateMethod = "isGPRIdxMode";
12  let ParserMethod = "parseGPRIdxMode";
13  let RenderMethod = "addImmOperands";
14}
15
16def GPRIdxMode : Operand<i32> {
17  let PrintMethod = "printVGPRIndexMode";
18  let ParserMatchClass = GPRIdxModeMatchClass;
19  let OperandType = "OPERAND_IMMEDIATE";
20}
21
22class SOP_Pseudo<string opName, dag outs, dag ins, string asmOps,
23                  list<dag> pattern=[]> :
24    InstSI<outs, ins, "", pattern>,
25    SIMCInstr<opName, SIEncodingFamily.NONE> {
26
27  let isPseudo = 1;
28  let isCodeGenOnly = 1;
29
30  string Mnemonic = opName;
31  string AsmOperands = asmOps;
32
33  bits<1> has_sdst = 0;
34}
35
36//===----------------------------------------------------------------------===//
37// SOP1 Instructions
38//===----------------------------------------------------------------------===//
39
40class SOP1_Pseudo <string opName, dag outs, dag ins,
41                   string asmOps, list<dag> pattern=[]> :
42  SOP_Pseudo<opName, outs, ins, asmOps, pattern> {
43
44  let mayLoad = 0;
45  let mayStore = 0;
46  let hasSideEffects = 0;
47  let SALU = 1;
48  let SOP1 = 1;
49  let SchedRW = [WriteSALU];
50  let Size = 4;
51  let UseNamedOperandTable = 1;
52
53  bits<1> has_src0 = 1;
54  bits<1> has_sdst = 1;
55}
56
57class SOP1_Real<bits<8> op, SOP1_Pseudo ps, string real_name = ps.Mnemonic> :
58  InstSI <ps.OutOperandList, ps.InOperandList,
59          real_name # " " # ps.AsmOperands, []>,
60  Enc32 {
61
62  let isPseudo = 0;
63  let isCodeGenOnly = 0;
64  let Size = 4;
65
66  // copy relevant pseudo op flags
67  let SubtargetPredicate = ps.SubtargetPredicate;
68  let AsmMatchConverter  = ps.AsmMatchConverter;
69
70  // encoding
71  bits<7> sdst;
72  bits<8> src0;
73
74  let Inst{7-0} = !if(ps.has_src0, src0, ?);
75  let Inst{15-8} = op;
76  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
77  let Inst{31-23} = 0x17d; //encoding;
78}
79
80class SOP1_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo <
81  opName, (outs SReg_32:$sdst),
82  !if(tied_in, (ins SSrc_b32:$src0, SReg_32:$sdst_in),
83               (ins SSrc_b32:$src0)),
84  "$sdst, $src0", pattern> {
85  let Constraints = !if(tied_in, "$sdst = $sdst_in", "");
86}
87
88// Only register input allowed.
89class SOP1_32R <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
90  opName, (outs SReg_32:$sdst), (ins SReg_32:$src0),
91  "$sdst, $src0", pattern>;
92
93// 32-bit input, no output.
94class SOP1_0_32 <string opName, list<dag> pattern = []> : SOP1_Pseudo <
95  opName, (outs), (ins SSrc_b32:$src0),
96  "$src0", pattern> {
97  let has_sdst = 0;
98}
99
100// Special case for movreld where sdst is treated as a use operand.
101class SOP1_32_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
102  opName, (outs), (ins SReg_32:$sdst, SSrc_b32:$src0),
103  "$sdst, $src0", pattern>;
104
105// Special case for movreld where sdst is treated as a use operand.
106class SOP1_64_movreld <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
107  opName, (outs), (ins SReg_64:$sdst, SSrc_b64:$src0),
108  "$sdst, $src0", pattern
109>;
110
111class SOP1_0_32R <string opName, list<dag> pattern = []> : SOP1_Pseudo <
112  opName, (outs), (ins SReg_32:$src0),
113  "$src0", pattern> {
114  let has_sdst = 0;
115}
116
117class SOP1_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
118  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0),
119  "$sdst, $src0", pattern
120>;
121
122// Only register input allowed.
123class SOP1_64R <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
124  opName, (outs SReg_64:$sdst), (ins SReg_64:$src0),
125  "$sdst, $src0", pattern
126>;
127
128// 64-bit input, 32-bit output.
129class SOP1_32_64 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
130  opName, (outs SReg_32:$sdst), (ins SSrc_b64:$src0),
131  "$sdst, $src0", pattern
132>;
133
134// 32-bit input, 64-bit output.
135class SOP1_64_32 <string opName, list<dag> pattern=[], bit tied_in = 0> : SOP1_Pseudo <
136  opName, (outs SReg_64:$sdst),
137  !if(tied_in, (ins SSrc_b32:$src0, SReg_64:$sdst_in),
138               (ins SSrc_b32:$src0)),
139  "$sdst, $src0", pattern> {
140  let Constraints = !if(tied_in, "$sdst = $sdst_in", "");
141}
142
143// no input, 64-bit output.
144class SOP1_64_0 <string opName, list<dag> pattern=[]> : SOP1_Pseudo <
145  opName, (outs SReg_64:$sdst), (ins), "$sdst", pattern> {
146  let has_src0 = 0;
147}
148
149// 64-bit input, no output
150class SOP1_1 <string opName, RegisterClass rc = SReg_64, list<dag> pattern=[]> : SOP1_Pseudo <
151  opName, (outs), (ins rc:$src0), "$src0", pattern> {
152  let has_sdst = 0;
153}
154
155
156let isMoveImm = 1 in {
157  let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
158    def S_MOV_B32 : SOP1_32 <"s_mov_b32">;
159    def S_MOV_B64 : SOP1_64 <"s_mov_b64">;
160  } // End isRematerializeable = 1
161
162  let Uses = [SCC] in {
163    def S_CMOV_B32 : SOP1_32 <"s_cmov_b32">;
164    def S_CMOV_B64 : SOP1_64 <"s_cmov_b64">;
165  } // End Uses = [SCC]
166} // End isMoveImm = 1
167
168let Defs = [SCC] in {
169  def S_NOT_B32 : SOP1_32 <"s_not_b32",
170    [(set i32:$sdst, (not i32:$src0))]
171  >;
172
173  def S_NOT_B64 : SOP1_64 <"s_not_b64",
174    [(set i64:$sdst, (not i64:$src0))]
175  >;
176  def S_WQM_B32 : SOP1_32 <"s_wqm_b32">;
177  def S_WQM_B64 : SOP1_64 <"s_wqm_b64">;
178} // End Defs = [SCC]
179
180
181let WaveSizePredicate = isWave32 in {
182def : GCNPat <
183  (int_amdgcn_wqm_vote i1:$src0),
184  (S_WQM_B32 SSrc_b32:$src0)
185>;
186}
187
188let WaveSizePredicate = isWave64 in {
189def : GCNPat <
190  (int_amdgcn_wqm_vote i1:$src0),
191  (S_WQM_B64 SSrc_b64:$src0)
192>;
193}
194
195def S_BREV_B32 : SOP1_32 <"s_brev_b32",
196  [(set i32:$sdst, (bitreverse i32:$src0))]
197>;
198def S_BREV_B64 : SOP1_64 <"s_brev_b64">;
199
200let Defs = [SCC] in {
201def S_BCNT0_I32_B32 : SOP1_32 <"s_bcnt0_i32_b32">;
202def S_BCNT0_I32_B64 : SOP1_32_64 <"s_bcnt0_i32_b64">;
203def S_BCNT1_I32_B32 : SOP1_32 <"s_bcnt1_i32_b32",
204  [(set i32:$sdst, (ctpop i32:$src0))]
205>;
206def S_BCNT1_I32_B64 : SOP1_32_64 <"s_bcnt1_i32_b64",
207  [(set i32:$sdst, (ctpop i64:$src0))]
208>;
209} // End Defs = [SCC]
210
211def S_FF0_I32_B32 : SOP1_32 <"s_ff0_i32_b32">;
212def S_FF0_I32_B64 : SOP1_32_64 <"s_ff0_i32_b64">;
213def S_FF1_I32_B64 : SOP1_32_64 <"s_ff1_i32_b64",
214  [(set i32:$sdst, (AMDGPUffbl_b32 i64:$src0))]
215>;
216
217def S_FF1_I32_B32 : SOP1_32 <"s_ff1_i32_b32",
218  [(set i32:$sdst, (AMDGPUffbl_b32 i32:$src0))]
219>;
220
221def S_FLBIT_I32_B32 : SOP1_32 <"s_flbit_i32_b32",
222  [(set i32:$sdst, (AMDGPUffbh_u32 i32:$src0))]
223>;
224
225def S_FLBIT_I32_B64 : SOP1_32_64 <"s_flbit_i32_b64",
226  [(set i32:$sdst, (AMDGPUffbh_u32 i64:$src0))]
227>;
228def S_FLBIT_I32 : SOP1_32 <"s_flbit_i32",
229  [(set i32:$sdst, (AMDGPUffbh_i32 i32:$src0))]
230>;
231def S_FLBIT_I32_I64 : SOP1_32_64 <"s_flbit_i32_i64">;
232def S_SEXT_I32_I8 : SOP1_32 <"s_sext_i32_i8",
233  [(set i32:$sdst, (sext_inreg i32:$src0, i8))]
234>;
235def S_SEXT_I32_I16 : SOP1_32 <"s_sext_i32_i16",
236  [(set i32:$sdst, (sext_inreg i32:$src0, i16))]
237>;
238
239def S_BITSET0_B32 : SOP1_32    <"s_bitset0_b32", [], 1>;
240def S_BITSET0_B64 : SOP1_64_32 <"s_bitset0_b64", [], 1>;
241def S_BITSET1_B32 : SOP1_32    <"s_bitset1_b32", [], 1>;
242def S_BITSET1_B64 : SOP1_64_32 <"s_bitset1_b64", [], 1>;
243def S_GETPC_B64 : SOP1_64_0  <"s_getpc_b64",
244  [(set i64:$sdst, (int_amdgcn_s_getpc))]
245>;
246
247let isTerminator = 1, isBarrier = 1, SchedRW = [WriteBranch] in {
248
249let isBranch = 1, isIndirectBranch = 1 in {
250def S_SETPC_B64 : SOP1_1  <"s_setpc_b64">;
251} // End isBranch = 1, isIndirectBranch = 1
252
253let isReturn = 1 in {
254// Define variant marked as return rather than branch.
255def S_SETPC_B64_return : SOP1_1<"", CCR_SGPR_64, [(AMDGPUret_flag i64:$src0)]>;
256}
257} // End isTerminator = 1, isBarrier = 1
258
259let isCall = 1 in {
260def S_SWAPPC_B64 : SOP1_64 <"s_swappc_b64"
261>;
262}
263
264def S_RFE_B64 : SOP1_1  <"s_rfe_b64">;
265
266let hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] in {
267
268def S_AND_SAVEEXEC_B64 : SOP1_64 <"s_and_saveexec_b64">;
269def S_OR_SAVEEXEC_B64 : SOP1_64 <"s_or_saveexec_b64">;
270def S_XOR_SAVEEXEC_B64 : SOP1_64 <"s_xor_saveexec_b64">;
271def S_ANDN2_SAVEEXEC_B64 : SOP1_64 <"s_andn2_saveexec_b64">;
272def S_ORN2_SAVEEXEC_B64 : SOP1_64 <"s_orn2_saveexec_b64">;
273def S_NAND_SAVEEXEC_B64 : SOP1_64 <"s_nand_saveexec_b64">;
274def S_NOR_SAVEEXEC_B64 : SOP1_64 <"s_nor_saveexec_b64">;
275def S_XNOR_SAVEEXEC_B64 : SOP1_64 <"s_xnor_saveexec_b64">;
276
277} // End hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC]
278
279def S_QUADMASK_B32 : SOP1_32 <"s_quadmask_b32">;
280def S_QUADMASK_B64 : SOP1_64 <"s_quadmask_b64">;
281
282let Uses = [M0] in {
283def S_MOVRELS_B32 : SOP1_32R <"s_movrels_b32">;
284def S_MOVRELS_B64 : SOP1_64R <"s_movrels_b64">;
285def S_MOVRELD_B32 : SOP1_32_movreld <"s_movreld_b32">;
286def S_MOVRELD_B64 : SOP1_64_movreld <"s_movreld_b64">;
287} // End Uses = [M0]
288
289let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in {
290def S_CBRANCH_JOIN : SOP1_0_32R <"s_cbranch_join">;
291} // End SubtargetPredicate = isGFX6GFX7GFX8GFX9
292
293let Defs = [SCC] in {
294def S_ABS_I32 : SOP1_32 <"s_abs_i32">;
295} // End Defs = [SCC]
296
297let SubtargetPredicate = HasVGPRIndexMode in {
298def S_SET_GPR_IDX_IDX : SOP1_0_32<"s_set_gpr_idx_idx"> {
299  let Uses = [M0, MODE];
300  let Defs = [M0, MODE];
301}
302}
303
304let SubtargetPredicate = isGFX9Plus in {
305  let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in {
306    def S_ANDN1_SAVEEXEC_B64 : SOP1_64<"s_andn1_saveexec_b64">;
307    def S_ORN1_SAVEEXEC_B64  : SOP1_64<"s_orn1_saveexec_b64">;
308    def S_ANDN1_WREXEC_B64   : SOP1_64<"s_andn1_wrexec_b64">;
309    def S_ANDN2_WREXEC_B64   : SOP1_64<"s_andn2_wrexec_b64">;
310  } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC]
311
312  def S_BITREPLICATE_B64_B32 : SOP1_64_32<"s_bitreplicate_b64_b32">;
313} // End SubtargetPredicate = isGFX9Plus
314
315let SubtargetPredicate = isGFX10Plus in {
316  let hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC] in {
317    def S_AND_SAVEEXEC_B32   : SOP1_32<"s_and_saveexec_b32">;
318    def S_OR_SAVEEXEC_B32    : SOP1_32<"s_or_saveexec_b32">;
319    def S_XOR_SAVEEXEC_B32   : SOP1_32<"s_xor_saveexec_b32">;
320    def S_ANDN2_SAVEEXEC_B32 : SOP1_32<"s_andn2_saveexec_b32">;
321    def S_ORN2_SAVEEXEC_B32  : SOP1_32<"s_orn2_saveexec_b32">;
322    def S_NAND_SAVEEXEC_B32  : SOP1_32<"s_nand_saveexec_b32">;
323    def S_NOR_SAVEEXEC_B32   : SOP1_32<"s_nor_saveexec_b32">;
324    def S_XNOR_SAVEEXEC_B32  : SOP1_32<"s_xnor_saveexec_b32">;
325    def S_ANDN1_SAVEEXEC_B32 : SOP1_32<"s_andn1_saveexec_b32">;
326    def S_ORN1_SAVEEXEC_B32  : SOP1_32<"s_orn1_saveexec_b32">;
327    def S_ANDN1_WREXEC_B32   : SOP1_32<"s_andn1_wrexec_b32">;
328    def S_ANDN2_WREXEC_B32   : SOP1_32<"s_andn2_wrexec_b32">;
329  } // End hasSideEffects = 1, Defs = [EXEC, SCC], Uses = [EXEC]
330
331  let Uses = [M0] in {
332    def S_MOVRELSD_2_B32 : SOP1_32<"s_movrelsd_2_b32">;
333  } // End Uses = [M0]
334} // End SubtargetPredicate = isGFX10Plus
335
336//===----------------------------------------------------------------------===//
337// SOP2 Instructions
338//===----------------------------------------------------------------------===//
339
340class SOP2_Pseudo<string opName, dag outs, dag ins,
341                  string asmOps, list<dag> pattern=[]> :
342  SOP_Pseudo<opName, outs, ins, asmOps, pattern> {
343
344  let mayLoad = 0;
345  let mayStore = 0;
346  let hasSideEffects = 0;
347  let SALU = 1;
348  let SOP2 = 1;
349  let SchedRW = [WriteSALU];
350  let UseNamedOperandTable = 1;
351
352  let has_sdst = 1;
353
354  // Pseudo instructions have no encodings, but adding this field here allows
355  // us to do:
356  // let sdst = xxx in {
357  // for multiclasses that include both real and pseudo instructions.
358  // field bits<7> sdst = 0;
359  // let Size = 4; // Do we need size here?
360}
361
362class SOP2_Real<bits<7> op, SOP_Pseudo ps, string real_name = ps.Mnemonic> :
363  InstSI <ps.OutOperandList, ps.InOperandList,
364          real_name # " " # ps.AsmOperands, []>,
365  Enc32 {
366  let isPseudo = 0;
367  let isCodeGenOnly = 0;
368
369  // copy relevant pseudo op flags
370  let SubtargetPredicate = ps.SubtargetPredicate;
371  let AsmMatchConverter  = ps.AsmMatchConverter;
372  let UseNamedOperandTable = ps.UseNamedOperandTable;
373  let TSFlags = ps.TSFlags;
374
375  // encoding
376  bits<7> sdst;
377  bits<8> src0;
378  bits<8> src1;
379
380  let Inst{7-0}   = src0;
381  let Inst{15-8}  = src1;
382  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
383  let Inst{29-23} = op;
384  let Inst{31-30} = 0x2; // encoding
385}
386
387
388class SOP2_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
389  opName, (outs SReg_32:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1),
390  "$sdst, $src0, $src1", pattern
391>;
392
393class SOP2_64 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
394  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1),
395  "$sdst, $src0, $src1", pattern
396>;
397
398class SOP2_64_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
399  opName, (outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b32:$src1),
400  "$sdst, $src0, $src1", pattern
401>;
402
403class SOP2_64_32_32 <string opName, list<dag> pattern=[]> : SOP2_Pseudo <
404  opName, (outs SReg_64:$sdst), (ins SSrc_b32:$src0, SSrc_b32:$src1),
405  "$sdst, $src0, $src1", pattern
406>;
407
408class UniformUnaryFrag<SDPatternOperator Op> : PatFrag <
409  (ops node:$src0),
410  (Op $src0),
411  [{ return !N->isDivergent(); }]> {
412  // This check is unnecessary as it's captured by the result register
413  // bank constraint.
414  //
415  // FIXME: Should add a way for the emitter to recognize this is a
416  // trivially true predicate to eliminate the check.
417  let GISelPredicateCode = [{return true;}];
418}
419
420class UniformBinFrag<SDPatternOperator Op> : PatFrag <
421  (ops node:$src0, node:$src1),
422  (Op $src0, $src1),
423  [{ return !N->isDivergent(); }]> {
424  // This check is unnecessary as it's captured by the result register
425  // bank constraint.
426  //
427  // FIXME: Should add a way for the emitter to recognize this is a
428  // trivially true predicate to eliminate the check.
429  let GISelPredicateCode = [{return true;}];
430}
431
432class DivergentBinFrag<SDPatternOperator Op> : PatFrag <
433  (ops node:$src0, node:$src1),
434  (Op $src0, $src1),
435  [{ return N->isDivergent(); }]> {
436  // This check is unnecessary as it's captured by the result register
437  // bank constraint.
438  //
439  // FIXME: Should add a way for the emitter to recognize this is a
440  // trivially true predicate to eliminate the check.
441  let GISelPredicateCode = [{return true;}];
442}
443
444let Defs = [SCC] in { // Carry out goes to SCC
445let isCommutable = 1 in {
446def S_ADD_U32 : SOP2_32 <"s_add_u32">;
447def S_ADD_I32 : SOP2_32 <"s_add_i32",
448  [(set i32:$sdst, (UniformBinFrag<add> SSrc_b32:$src0, SSrc_b32:$src1))]
449>;
450} // End isCommutable = 1
451
452def S_SUB_U32 : SOP2_32 <"s_sub_u32">;
453def S_SUB_I32 : SOP2_32 <"s_sub_i32",
454  [(set i32:$sdst, (UniformBinFrag<sub> SSrc_b32:$src0, SSrc_b32:$src1))]
455>;
456
457let Uses = [SCC] in { // Carry in comes from SCC
458let isCommutable = 1 in {
459def S_ADDC_U32 : SOP2_32 <"s_addc_u32",
460  [(set i32:$sdst, (UniformBinFrag<adde> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>;
461} // End isCommutable = 1
462
463def S_SUBB_U32 : SOP2_32 <"s_subb_u32",
464  [(set i32:$sdst, (UniformBinFrag<sube> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>;
465} // End Uses = [SCC]
466
467
468let isCommutable = 1 in {
469def S_MIN_I32 : SOP2_32 <"s_min_i32",
470  [(set i32:$sdst, (smin i32:$src0, i32:$src1))]
471>;
472def S_MIN_U32 : SOP2_32 <"s_min_u32",
473  [(set i32:$sdst, (umin i32:$src0, i32:$src1))]
474>;
475def S_MAX_I32 : SOP2_32 <"s_max_i32",
476  [(set i32:$sdst, (smax i32:$src0, i32:$src1))]
477>;
478def S_MAX_U32 : SOP2_32 <"s_max_u32",
479  [(set i32:$sdst, (umax i32:$src0, i32:$src1))]
480>;
481} // End isCommutable = 1
482} // End Defs = [SCC]
483
484// This pattern is restricted to certain subtargets (practically GFX8Plus)
485// because isel sometimes produces an sreg_64 copy to SCC as a by-product
486// of this pattern, and only for subtargets with hasScalarCompareEq64
487// is it possible to map such copy to a single instruction (S_CMP_LG_U64).
488class SelectPat<SDPatternOperator select> : PatFrag <
489  (ops node:$src1, node:$src2),
490  (select SCC, $src1, $src2),
491  [{ return Subtarget->hasScalarCompareEq64() &&
492            N->getOperand(0)->hasOneUse() && !N->isDivergent(); }]
493>;
494
495let Uses = [SCC] in {
496  let AddedComplexity = 20 in {
497    def S_CSELECT_B32 : SOP2_32 <"s_cselect_b32",
498      [(set i32:$sdst, (SelectPat<select> i32:$src0, i32:$src1))]
499    >;
500  }
501
502  def S_CSELECT_B64 : SOP2_64 <"s_cselect_b64">;
503} // End Uses = [SCC]
504
505let Defs = [SCC] in {
506let isCommutable = 1 in {
507def S_AND_B32 : SOP2_32 <"s_and_b32",
508  [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, i32:$src1))]
509>;
510
511def S_AND_B64 : SOP2_64 <"s_and_b64",
512  [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, i64:$src1))]
513>;
514
515def S_OR_B32 : SOP2_32 <"s_or_b32",
516  [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, i32:$src1))]
517>;
518
519def S_OR_B64 : SOP2_64 <"s_or_b64",
520  [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, i64:$src1))]
521>;
522
523def S_XOR_B32 : SOP2_32 <"s_xor_b32",
524  [(set i32:$sdst, (UniformBinFrag<xor> i32:$src0, i32:$src1))]
525>;
526
527def S_XOR_B64 : SOP2_64 <"s_xor_b64",
528  [(set i64:$sdst, (UniformBinFrag<xor> i64:$src0, i64:$src1))]
529>;
530
531def S_XNOR_B32 : SOP2_32 <"s_xnor_b32",
532  [(set i32:$sdst, (not (xor_oneuse i32:$src0, i32:$src1)))]
533>;
534
535def S_XNOR_B64 : SOP2_64 <"s_xnor_b64",
536  [(set i64:$sdst, (not (xor_oneuse i64:$src0, i64:$src1)))]
537>;
538
539def S_NAND_B32 : SOP2_32 <"s_nand_b32",
540  [(set i32:$sdst, (not (and_oneuse i32:$src0, i32:$src1)))]
541>;
542
543def S_NAND_B64 : SOP2_64 <"s_nand_b64",
544  [(set i64:$sdst, (not (and_oneuse i64:$src0, i64:$src1)))]
545>;
546
547def S_NOR_B32 : SOP2_32 <"s_nor_b32",
548  [(set i32:$sdst, (not (or_oneuse i32:$src0, i32:$src1)))]
549>;
550
551def S_NOR_B64 : SOP2_64 <"s_nor_b64",
552  [(set i64:$sdst, (not (or_oneuse i64:$src0, i64:$src1)))]
553>;
554} // End isCommutable = 1
555
556// There are also separate patterns for types other than i32
557def S_ANDN2_B32 : SOP2_32 <"s_andn2_b32",
558  [(set i32:$sdst, (UniformBinFrag<and> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))]
559>;
560
561def S_ANDN2_B64 : SOP2_64 <"s_andn2_b64",
562  [(set i64:$sdst, (UniformBinFrag<and> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))]
563>;
564
565def S_ORN2_B32 : SOP2_32 <"s_orn2_b32",
566  [(set i32:$sdst, (UniformBinFrag<or> i32:$src0, (UniformUnaryFrag<not> i32:$src1)))]
567>;
568
569def S_ORN2_B64 : SOP2_64 <"s_orn2_b64",
570  [(set i64:$sdst, (UniformBinFrag<or> i64:$src0, (UniformUnaryFrag<not> i64:$src1)))]
571>;
572} // End Defs = [SCC]
573
574// Use added complexity so these patterns are preferred to the VALU patterns.
575let AddedComplexity = 1 in {
576
577let Defs = [SCC] in {
578// TODO: b64 versions require VOP3 change since v_lshlrev_b64 is VOP3
579def S_LSHL_B32 : SOP2_32 <"s_lshl_b32",
580  [(set SReg_32:$sdst, (UniformBinFrag<shl> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
581>;
582def S_LSHL_B64 : SOP2_64_32 <"s_lshl_b64",
583  [(set SReg_64:$sdst, (UniformBinFrag<shl> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
584>;
585def S_LSHR_B32 : SOP2_32 <"s_lshr_b32",
586  [(set SReg_32:$sdst, (UniformBinFrag<srl> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
587>;
588def S_LSHR_B64 : SOP2_64_32 <"s_lshr_b64",
589  [(set SReg_64:$sdst, (UniformBinFrag<srl> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
590>;
591def S_ASHR_I32 : SOP2_32 <"s_ashr_i32",
592  [(set SReg_32:$sdst, (UniformBinFrag<sra> (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]
593>;
594def S_ASHR_I64 : SOP2_64_32 <"s_ashr_i64",
595  [(set SReg_64:$sdst, (UniformBinFrag<sra> (i64 SSrc_b64:$src0), (i32 SSrc_b32:$src1)))]
596>;
597} // End Defs = [SCC]
598
599def S_BFM_B32 : SOP2_32 <"s_bfm_b32",
600  [(set i32:$sdst, (UniformBinFrag<AMDGPUbfm> i32:$src0, i32:$src1))]>;
601def S_BFM_B64 : SOP2_64_32_32 <"s_bfm_b64">;
602
603// TODO: S_MUL_I32 require V_MUL_LO_I32 from VOP3 change
604def S_MUL_I32 : SOP2_32 <"s_mul_i32",
605  [(set i32:$sdst, (mul i32:$src0, i32:$src1))]> {
606  let isCommutable = 1;
607}
608
609} // End AddedComplexity = 1
610
611let Defs = [SCC] in {
612def S_BFE_U32 : SOP2_32 <"s_bfe_u32">;
613def S_BFE_I32 : SOP2_32 <"s_bfe_i32">;
614def S_BFE_U64 : SOP2_64_32 <"s_bfe_u64">;
615def S_BFE_I64 : SOP2_64_32 <"s_bfe_i64">;
616} // End Defs = [SCC]
617
618def S_CBRANCH_G_FORK : SOP2_Pseudo <
619  "s_cbranch_g_fork", (outs),
620  (ins SCSrc_b64:$src0, SCSrc_b64:$src1),
621  "$src0, $src1"
622> {
623  let has_sdst = 0;
624  let SubtargetPredicate = isGFX6GFX7GFX8GFX9;
625}
626
627let Defs = [SCC] in {
628def S_ABSDIFF_I32 : SOP2_32 <"s_absdiff_i32">;
629} // End Defs = [SCC]
630
631let SubtargetPredicate = isGFX8GFX9 in {
632  def S_RFE_RESTORE_B64 : SOP2_Pseudo <
633    "s_rfe_restore_b64", (outs),
634    (ins SSrc_b64:$src0, SSrc_b32:$src1),
635    "$src0, $src1"
636  > {
637    let hasSideEffects = 1;
638    let has_sdst = 0;
639  }
640}
641
642let SubtargetPredicate = isGFX9Plus in {
643  def S_PACK_LL_B32_B16 : SOP2_32<"s_pack_ll_b32_b16">;
644  def S_PACK_LH_B32_B16 : SOP2_32<"s_pack_lh_b32_b16">;
645  def S_PACK_HH_B32_B16 : SOP2_32<"s_pack_hh_b32_b16">;
646
647  let Defs = [SCC] in {
648    def S_LSHL1_ADD_U32 : SOP2_32<"s_lshl1_add_u32",
649      [(set i32:$sdst, (shl1_add SSrc_b32:$src0, SSrc_b32:$src1))]
650    >;
651    def S_LSHL2_ADD_U32 : SOP2_32<"s_lshl2_add_u32",
652      [(set i32:$sdst, (shl2_add SSrc_b32:$src0, SSrc_b32:$src1))]
653    >;
654    def S_LSHL3_ADD_U32 : SOP2_32<"s_lshl3_add_u32",
655      [(set i32:$sdst, (shl3_add SSrc_b32:$src0, SSrc_b32:$src1))]
656    >;
657    def S_LSHL4_ADD_U32 : SOP2_32<"s_lshl4_add_u32",
658      [(set i32:$sdst, (shl4_add SSrc_b32:$src0, SSrc_b32:$src1))]
659    >;
660  } // End Defs = [SCC]
661
662  let isCommutable = 1 in {
663    def S_MUL_HI_U32 : SOP2_32<"s_mul_hi_u32",
664      [(set i32:$sdst, (UniformBinFrag<mulhu> SSrc_b32:$src0, SSrc_b32:$src1))]>;
665    def S_MUL_HI_I32 : SOP2_32<"s_mul_hi_i32",
666      [(set i32:$sdst, (UniformBinFrag<mulhs> SSrc_b32:$src0, SSrc_b32:$src1))]>;
667  }
668} // End SubtargetPredicate = isGFX9Plus
669
670//===----------------------------------------------------------------------===//
671// SOPK Instructions
672//===----------------------------------------------------------------------===//
673
674class SOPK_Pseudo <string opName, dag outs, dag ins,
675                   string asmOps, list<dag> pattern=[]> :
676  InstSI <outs, ins, "", pattern>,
677  SIMCInstr<opName, SIEncodingFamily.NONE> {
678  let isPseudo = 1;
679  let isCodeGenOnly = 1;
680  let mayLoad = 0;
681  let mayStore = 0;
682  let hasSideEffects = 0;
683  let SALU = 1;
684  let SOPK = 1;
685  let SchedRW = [WriteSALU];
686  let UseNamedOperandTable = 1;
687  string Mnemonic = opName;
688  string AsmOperands = asmOps;
689
690  bits<1> has_sdst = 1;
691}
692
693class SOPK_Real<bits<5> op, SOPK_Pseudo ps> :
694  InstSI <ps.OutOperandList, ps.InOperandList,
695          ps.Mnemonic # " " # ps.AsmOperands, []> {
696  let isPseudo = 0;
697  let isCodeGenOnly = 0;
698
699  // copy relevant pseudo op flags
700  let SubtargetPredicate = ps.SubtargetPredicate;
701  let AsmMatchConverter  = ps.AsmMatchConverter;
702  let DisableEncoding    = ps.DisableEncoding;
703  let Constraints        = ps.Constraints;
704
705  // encoding
706  bits<7>  sdst;
707  bits<16> simm16;
708  bits<32> imm;
709}
710
711class SOPK_Real32<bits<5> op, SOPK_Pseudo ps> :
712  SOPK_Real <op, ps>,
713  Enc32 {
714  let Inst{15-0}  = simm16;
715  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
716  let Inst{27-23} = op;
717  let Inst{31-28} = 0xb; //encoding
718}
719
720class SOPK_Real64<bits<5> op, SOPK_Pseudo ps> :
721  SOPK_Real<op, ps>,
722  Enc64 {
723  let Inst{15-0}  = simm16;
724  let Inst{22-16} = !if(ps.has_sdst, sdst, ?);
725  let Inst{27-23} = op;
726  let Inst{31-28} = 0xb; //encoding
727  let Inst{63-32} = imm;
728}
729
730class SOPKInstTable <bit is_sopk, string cmpOp = ""> {
731  bit IsSOPK = is_sopk;
732  string BaseCmpOp = cmpOp;
733}
734
735class SOPK_32 <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
736  opName,
737  (outs SReg_32:$sdst),
738  (ins s16imm:$simm16),
739  "$sdst, $simm16",
740  pattern>;
741
742class SOPK_32_BR <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
743  opName,
744  (outs),
745  (ins sopp_brtarget:$simm16, SReg_32:$sdst),
746  "$sdst, $simm16",
747  pattern> {
748  let Defs = [EXEC];
749  let Uses = [EXEC];
750  let isBranch = 1;
751  let isTerminator = 1;
752  let SchedRW = [WriteBranch];
753}
754
755class SOPK_SCC <string opName, string base_op, bit isSignExt> : SOPK_Pseudo <
756  opName,
757  (outs),
758  !if(isSignExt,
759      (ins SReg_32:$sdst, s16imm:$simm16),
760      (ins SReg_32:$sdst, u16imm:$simm16)),
761  "$sdst, $simm16", []>,
762  SOPKInstTable<1, base_op>{
763  let Defs = [SCC];
764}
765
766class SOPK_32TIE <string opName, list<dag> pattern=[]> : SOPK_Pseudo <
767  opName,
768  (outs SReg_32:$sdst),
769  (ins SReg_32:$src0, s16imm:$simm16),
770  "$sdst, $simm16",
771  pattern
772>;
773
774let isReMaterializable = 1, isMoveImm = 1 in {
775def S_MOVK_I32 : SOPK_32 <"s_movk_i32">;
776} // End isReMaterializable = 1
777let Uses = [SCC] in {
778def S_CMOVK_I32 : SOPK_32 <"s_cmovk_i32">;
779}
780
781let isCompare = 1 in {
782
783// This instruction is disabled for now until we can figure out how to teach
784// the instruction selector to correctly use the  S_CMP* vs V_CMP*
785// instructions.
786//
787// When this instruction is enabled the code generator sometimes produces this
788// invalid sequence:
789//
790// SCC = S_CMPK_EQ_I32 SGPR0, imm
791// VCC = COPY SCC
792// VGPR0 = V_CNDMASK VCC, VGPR0, VGPR1
793//
794// def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32",
795//   [(set i1:$dst, (setcc i32:$src0, imm:$src1, SETEQ))]
796// >;
797
798def S_CMPK_EQ_I32 : SOPK_SCC <"s_cmpk_eq_i32", "s_cmp_eq_i32", 1>;
799def S_CMPK_LG_I32 : SOPK_SCC <"s_cmpk_lg_i32", "s_cmp_lg_i32", 1>;
800def S_CMPK_GT_I32 : SOPK_SCC <"s_cmpk_gt_i32", "s_cmp_gt_i32", 1>;
801def S_CMPK_GE_I32 : SOPK_SCC <"s_cmpk_ge_i32", "s_cmp_ge_i32", 1>;
802def S_CMPK_LT_I32 : SOPK_SCC <"s_cmpk_lt_i32", "s_cmp_lt_i32", 1>;
803def S_CMPK_LE_I32 : SOPK_SCC <"s_cmpk_le_i32", "s_cmp_le_i32", 1>;
804
805let SOPKZext = 1 in {
806def S_CMPK_EQ_U32 : SOPK_SCC <"s_cmpk_eq_u32", "s_cmp_eq_u32", 0>;
807def S_CMPK_LG_U32 : SOPK_SCC <"s_cmpk_lg_u32", "s_cmp_lg_u32", 0>;
808def S_CMPK_GT_U32 : SOPK_SCC <"s_cmpk_gt_u32", "s_cmp_gt_u32", 0>;
809def S_CMPK_GE_U32 : SOPK_SCC <"s_cmpk_ge_u32", "s_cmp_ge_u32", 0>;
810def S_CMPK_LT_U32 : SOPK_SCC <"s_cmpk_lt_u32", "s_cmp_lt_u32", 0>;
811def S_CMPK_LE_U32 : SOPK_SCC <"s_cmpk_le_u32", "s_cmp_le_u32", 0>;
812} // End SOPKZext = 1
813} // End isCompare = 1
814
815let Defs = [SCC], isCommutable = 1, DisableEncoding = "$src0",
816    Constraints = "$sdst = $src0" in {
817  def S_ADDK_I32 : SOPK_32TIE <"s_addk_i32">;
818  def S_MULK_I32 : SOPK_32TIE <"s_mulk_i32">;
819}
820
821let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in
822def S_CBRANCH_I_FORK : SOPK_Pseudo <
823  "s_cbranch_i_fork",
824  (outs), (ins SReg_64:$sdst, sopp_brtarget:$simm16),
825  "$sdst, $simm16"
826>;
827
828let mayLoad = 1 in {
829// s_getreg_b32 should use hasSideEffects = 1 for tablegen to allow
830// its use in the readcyclecounter selection.
831// FIXME: Need to truncate immediate to 16-bits.
832def S_GETREG_B32 : SOPK_Pseudo <
833  "s_getreg_b32",
834  (outs SReg_32:$sdst), (ins hwreg:$simm16),
835  "$sdst, $simm16",
836  [(set i32:$sdst, (int_amdgcn_s_getreg (i32 timm:$simm16)))]> {
837  let SOPKZext = 1;
838  let hasSideEffects = 1;
839}
840} // End mayLoad = 1
841
842let mayLoad = 0, mayStore = 0, Defs = [MODE], Uses = [MODE] in {
843
844// FIXME: Need to truncate immediate to 16-bits.
845class S_SETREG_B32_Pseudo <list<dag> pattern=[]> : SOPK_Pseudo <
846  "s_setreg_b32",
847  (outs), (ins SReg_32:$sdst, hwreg:$simm16),
848  "$simm16, $sdst",
849  pattern>;
850
851def S_SETREG_B32 : S_SETREG_B32_Pseudo <
852  [(int_amdgcn_s_setreg (i32 timm:$simm16), i32:$sdst)]> {
853  // Use custom inserter to optimize some cases to
854  // S_DENORM_MODE/S_ROUND_MODE/S_SETREG_B32_mode.
855  let usesCustomInserter = 1;
856  let hasSideEffects = 1;
857}
858
859// Variant of SETREG that is guaranteed to only touch FP bits in the MODE
860// register, so doesn't have unmodeled side effects.
861def S_SETREG_B32_mode : S_SETREG_B32_Pseudo {
862  let hasSideEffects = 0;
863}
864
865// FIXME: Not on SI?
866//def S_GETREG_REGRD_B32 : SOPK_32 <sopk<0x14, 0x13>, "s_getreg_regrd_b32">;
867
868class S_SETREG_IMM32_B32_Pseudo : SOPK_Pseudo <
869  "s_setreg_imm32_b32",
870  (outs), (ins i32imm:$imm, hwreg:$simm16),
871  "$simm16, $imm"> {
872  let Size = 8; // Unlike every other SOPK instruction.
873  let has_sdst = 0;
874}
875
876def S_SETREG_IMM32_B32 : S_SETREG_IMM32_B32_Pseudo {
877  let hasSideEffects = 1;
878}
879
880// Variant of SETREG_IMM32 that is guaranteed to only touch FP bits in the MODE
881// register, so doesn't have unmodeled side effects.
882def S_SETREG_IMM32_B32_mode : S_SETREG_IMM32_B32_Pseudo {
883  let hasSideEffects = 0;
884}
885
886} // End mayLoad = 0, mayStore = 0, Defs = [MODE], Uses = [MODE]
887
888class SOPK_WAITCNT<string opName, list<dag> pat=[]> :
889    SOPK_Pseudo<
890        opName,
891        (outs),
892        (ins SReg_32:$sdst, s16imm:$simm16),
893        "$sdst, $simm16",
894        pat> {
895  let hasSideEffects = 1;
896  let mayLoad = 1;
897  let mayStore = 1;
898  let has_sdst = 1; // First source takes place of sdst in encoding
899}
900
901let SubtargetPredicate = isGFX9Plus in {
902  def S_CALL_B64 : SOPK_Pseudo<
903      "s_call_b64",
904      (outs SReg_64:$sdst),
905      (ins sopp_brtarget:$simm16),
906      "$sdst, $simm16"> {
907    let isCall = 1;
908  }
909} // End SubtargetPredicate = isGFX9Plus
910
911let SubtargetPredicate = isGFX10Plus in {
912  def S_VERSION : SOPK_Pseudo<
913      "s_version",
914      (outs),
915      (ins s16imm:$simm16),
916      "$simm16"> {
917    let has_sdst = 0;
918  }
919
920  def S_SUBVECTOR_LOOP_BEGIN : SOPK_32_BR<"s_subvector_loop_begin">;
921  def S_SUBVECTOR_LOOP_END   : SOPK_32_BR<"s_subvector_loop_end">;
922
923  def S_WAITCNT_VSCNT   : SOPK_WAITCNT<"s_waitcnt_vscnt">;
924  def S_WAITCNT_VMCNT   : SOPK_WAITCNT<"s_waitcnt_vmcnt">;
925  def S_WAITCNT_EXPCNT  : SOPK_WAITCNT<"s_waitcnt_expcnt">;
926  def S_WAITCNT_LGKMCNT : SOPK_WAITCNT<"s_waitcnt_lgkmcnt">;
927} // End SubtargetPredicate = isGFX10Plus
928
929//===----------------------------------------------------------------------===//
930// SOPC Instructions
931//===----------------------------------------------------------------------===//
932
933class SOPC_Pseudo<string opName, dag outs, dag ins,
934                  string asmOps, list<dag> pattern=[]> :
935  SOP_Pseudo<opName, outs, ins, asmOps, pattern> {
936  let mayLoad = 0;
937  let mayStore = 0;
938  let hasSideEffects = 0;
939  let SALU = 1;
940  let SOPC = 1;
941  let Defs = [SCC];
942  let SchedRW = [WriteSALU];
943  let UseNamedOperandTable = 1;
944}
945
946class SOPC_Real<bits<7> op, SOPC_Pseudo ps, string real_name = ps.Mnemonic> :
947  InstSI <ps.OutOperandList, ps.InOperandList,
948          real_name # " " # ps.AsmOperands, []>,
949  Enc32 {
950  let isPseudo = 0;
951  let isCodeGenOnly = 0;
952
953  // copy relevant pseudo op flags
954  let SubtargetPredicate = ps.SubtargetPredicate;
955  let OtherPredicates    = ps.OtherPredicates;
956  let AsmMatchConverter  = ps.AsmMatchConverter;
957  let UseNamedOperandTable = ps.UseNamedOperandTable;
958  let TSFlags = ps.TSFlags;
959
960  // encoding
961  bits<8> src0;
962  bits<8> src1;
963
964  let Inst{7-0} = src0;
965  let Inst{15-8} = src1;
966  let Inst{22-16} = op;
967  let Inst{31-23} = 0x17e;
968}
969
970class SOPC_Base <RegisterOperand rc0, RegisterOperand rc1,
971                 string opName, list<dag> pattern = []> : SOPC_Pseudo <
972  opName, (outs), (ins rc0:$src0, rc1:$src1),
973  "$src0, $src1", pattern > {
974}
975
976class SOPC_Helper <RegisterOperand rc, ValueType vt,
977                    string opName, SDPatternOperator cond> : SOPC_Base <
978  rc, rc, opName,
979  [(set SCC, (si_setcc_uniform vt:$src0, vt:$src1, cond))] > {
980}
981
982class SOPC_CMP_32<string opName,
983                  SDPatternOperator cond = COND_NULL, string revOp = opName>
984  : SOPC_Helper<SSrc_b32, i32, opName, cond>,
985    Commutable_REV<revOp, !eq(revOp, opName)>,
986    SOPKInstTable<0, opName> {
987  let isCompare = 1;
988  let isCommutable = 1;
989}
990
991class SOPC_CMP_64<string opName,
992                  SDPatternOperator cond = COND_NULL, string revOp = opName>
993  : SOPC_Helper<SSrc_b64, i64, opName, cond>,
994    Commutable_REV<revOp, !eq(revOp, opName)> {
995  let isCompare = 1;
996  let isCommutable = 1;
997}
998
999class SOPC_32<string opName, list<dag> pattern = []>
1000  : SOPC_Base<SSrc_b32, SSrc_b32, opName, pattern>;
1001
1002class SOPC_64_32<string opName, list<dag> pattern = []>
1003  : SOPC_Base<SSrc_b64, SSrc_b32, opName, pattern>;
1004
1005def S_CMP_EQ_I32 : SOPC_CMP_32 <"s_cmp_eq_i32">;
1006def S_CMP_LG_I32 : SOPC_CMP_32 <"s_cmp_lg_i32">;
1007def S_CMP_GT_I32 : SOPC_CMP_32 <"s_cmp_gt_i32", COND_SGT>;
1008def S_CMP_GE_I32 : SOPC_CMP_32 <"s_cmp_ge_i32", COND_SGE>;
1009def S_CMP_LT_I32 : SOPC_CMP_32 <"s_cmp_lt_i32", COND_SLT, "s_cmp_gt_i32">;
1010def S_CMP_LE_I32 : SOPC_CMP_32 <"s_cmp_le_i32", COND_SLE, "s_cmp_ge_i32">;
1011def S_CMP_EQ_U32 : SOPC_CMP_32 <"s_cmp_eq_u32", COND_EQ>;
1012def S_CMP_LG_U32 : SOPC_CMP_32 <"s_cmp_lg_u32", COND_NE>;
1013def S_CMP_GT_U32 : SOPC_CMP_32 <"s_cmp_gt_u32", COND_UGT>;
1014def S_CMP_GE_U32 : SOPC_CMP_32 <"s_cmp_ge_u32", COND_UGE>;
1015def S_CMP_LT_U32 : SOPC_CMP_32 <"s_cmp_lt_u32", COND_ULT, "s_cmp_gt_u32">;
1016def S_CMP_LE_U32 : SOPC_CMP_32 <"s_cmp_le_u32", COND_ULE, "s_cmp_ge_u32">;
1017
1018def S_BITCMP0_B32 : SOPC_32 <"s_bitcmp0_b32">;
1019def S_BITCMP1_B32 : SOPC_32 <"s_bitcmp1_b32">;
1020def S_BITCMP0_B64 : SOPC_64_32 <"s_bitcmp0_b64">;
1021def S_BITCMP1_B64 : SOPC_64_32 <"s_bitcmp1_b64">;
1022let SubtargetPredicate = isGFX6GFX7GFX8GFX9 in
1023def S_SETVSKIP : SOPC_32 <"s_setvskip">;
1024
1025let SubtargetPredicate = isGFX8Plus in {
1026def S_CMP_EQ_U64 : SOPC_CMP_64 <"s_cmp_eq_u64", COND_EQ>;
1027def S_CMP_LG_U64 : SOPC_CMP_64 <"s_cmp_lg_u64", COND_NE>;
1028} // End SubtargetPredicate = isGFX8Plus
1029
1030let SubtargetPredicate = HasVGPRIndexMode in {
1031// Setting the GPR index mode is really writing the fields in the mode
1032// register. We don't want to add mode register uses to every
1033// instruction, and it's too complicated to deal with anyway. This is
1034// modeled just as a side effect.
1035def S_SET_GPR_IDX_ON : SOPC_Pseudo <
1036  "s_set_gpr_idx_on" ,
1037  (outs),
1038  (ins SSrc_b32:$src0, GPRIdxMode:$src1),
1039  "$src0, $src1"> {
1040  let Defs = [M0, MODE]; // No scc def
1041  let Uses = [M0, MODE]; // Other bits of mode, m0 unmodified.
1042  let hasSideEffects = 1; // Sets mode.gpr_idx_en
1043  let FixedSize = 1;
1044}
1045}
1046
1047//===----------------------------------------------------------------------===//
1048// SOPP Instructions
1049//===----------------------------------------------------------------------===//
1050
1051class SOPP_Pseudo<string opName, dag ins,
1052                  string asmOps = "", list<dag> pattern=[], string keyName = opName> :
1053  SOP_Pseudo<opName, (outs), ins, asmOps, pattern> {
1054  let isPseudo = 1;
1055  let isCodeGenOnly = 1;
1056  let mayLoad = 0;
1057  let mayStore = 0;
1058  let hasSideEffects = 0;
1059  let SALU = 1;
1060  let SOPP = 1;
1061  let FixedSize = 1;
1062  let SchedRW = [WriteSALU];
1063  let UseNamedOperandTable = 1;
1064  bits <16> simm16;
1065  bits <1> fixed_imm = 0;
1066  string KeyName = keyName;
1067}
1068
1069class SOPPRelaxTable <bit isRelaxed, string keyName, string gfxip> {
1070  bit IsRelaxed = isRelaxed;
1071  string KeyName = keyName # gfxip;
1072}
1073
1074//spaces inserted in realname on instantiation of this record to allow s_endpgm to omit whitespace
1075class SOPP_Real<bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> :
1076  InstSI <ps.OutOperandList, ps.InOperandList,
1077          real_name # ps.AsmOperands, []> {
1078  let isPseudo = 0;
1079  let isCodeGenOnly = 0;
1080
1081  // copy relevant pseudo op flags
1082  let SubtargetPredicate = ps.SubtargetPredicate;
1083  let OtherPredicates    = ps.OtherPredicates;
1084  let AsmMatchConverter  = ps.AsmMatchConverter;
1085  let UseNamedOperandTable = ps.UseNamedOperandTable;
1086  let TSFlags = ps.TSFlags;
1087  bits <16> simm16;
1088}
1089
1090class SOPP_Real_32 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<op, ps, real_name>,
1091Enc32 {
1092  let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16);
1093  let Inst{22-16} = op;
1094  let Inst{31-23} = 0x17f;
1095}
1096
1097class SOPP_Real_64 <bits<7> op, SOPP_Pseudo ps, string real_name = ps.Mnemonic> : SOPP_Real<op, ps, real_name>,
1098Enc64 {
1099  // encoding
1100  let Inst{15-0} = !if(ps.fixed_imm, ps.simm16, simm16);
1101  let Inst{22-16} = op;
1102  let Inst{31-23} = 0x17f;
1103  //effectively a nop
1104  let Inst{47-32} = 0x0;
1105  let Inst{54-48} = 0x0;
1106  let Inst{63-55} = 0x17f;
1107}
1108
1109multiclass SOPP_With_Relaxation <string opName, dag ins,
1110                  string asmOps, list<dag> pattern=[]> {
1111  def "" : SOPP_Pseudo <opName, ins, asmOps, pattern>;
1112  def _pad_s_nop : SOPP_Pseudo <opName # "_pad_s_nop", ins, asmOps, pattern, opName>;
1113}
1114
1115def S_NOP : SOPP_Pseudo<"s_nop" , (ins i16imm:$simm16), "$simm16">;
1116
1117let isTerminator = 1 in {
1118def S_ENDPGM : SOPP_Pseudo<"s_endpgm", (ins EndpgmImm:$simm16), "$simm16"> {
1119  let isBarrier = 1;
1120  let isReturn = 1;
1121  let hasSideEffects = 1;
1122}
1123
1124def S_ENDPGM_SAVED : SOPP_Pseudo<"s_endpgm_saved", (ins)> {
1125  let SubtargetPredicate = isGFX8Plus;
1126  let simm16 = 0;
1127  let fixed_imm = 1;
1128  let isBarrier = 1;
1129  let isReturn = 1;
1130}
1131
1132let SubtargetPredicate = isGFX9Plus in {
1133  let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in {
1134    def S_ENDPGM_ORDERED_PS_DONE :
1135      SOPP_Pseudo<"s_endpgm_ordered_ps_done", (ins)>;
1136  } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1
1137} // End SubtargetPredicate = isGFX9Plus
1138
1139let SubtargetPredicate = isGFX10Plus in {
1140  let isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1 in {
1141    def S_CODE_END :
1142      SOPP_Pseudo<"s_code_end", (ins)>;
1143  } // End isBarrier = 1, isReturn = 1, simm16 = 0, fixed_imm = 1
1144} // End SubtargetPredicate = isGFX10Plus
1145
1146let isBranch = 1, SchedRW = [WriteBranch] in {
1147let isBarrier = 1 in {
1148defm S_BRANCH : SOPP_With_Relaxation<
1149  "s_branch" , (ins sopp_brtarget:$simm16), "$simm16",
1150  [(br bb:$simm16)]>;
1151}
1152
1153let Uses = [SCC] in {
1154defm S_CBRANCH_SCC0 : SOPP_With_Relaxation<
1155  "s_cbranch_scc0" , (ins sopp_brtarget:$simm16),
1156  "$simm16"
1157>;
1158defm S_CBRANCH_SCC1 : SOPP_With_Relaxation <
1159  "s_cbranch_scc1" , (ins sopp_brtarget:$simm16),
1160  "$simm16"
1161>;
1162} // End Uses = [SCC]
1163
1164let Uses = [VCC] in {
1165defm S_CBRANCH_VCCZ : SOPP_With_Relaxation <
1166  "s_cbranch_vccz" , (ins sopp_brtarget:$simm16),
1167  "$simm16"
1168>;
1169defm S_CBRANCH_VCCNZ : SOPP_With_Relaxation <
1170  "s_cbranch_vccnz" , (ins sopp_brtarget:$simm16),
1171  "$simm16"
1172>;
1173} // End Uses = [VCC]
1174
1175let Uses = [EXEC] in {
1176defm S_CBRANCH_EXECZ : SOPP_With_Relaxation <
1177  "s_cbranch_execz" , (ins sopp_brtarget:$simm16),
1178  "$simm16"
1179>;
1180defm S_CBRANCH_EXECNZ : SOPP_With_Relaxation <
1181  "s_cbranch_execnz" , (ins sopp_brtarget:$simm16),
1182  "$simm16"
1183>;
1184} // End Uses = [EXEC]
1185
1186defm S_CBRANCH_CDBGSYS : SOPP_With_Relaxation <
1187  "s_cbranch_cdbgsys" , (ins sopp_brtarget:$simm16),
1188  "$simm16"
1189>;
1190
1191defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_With_Relaxation <
1192  "s_cbranch_cdbgsys_and_user" , (ins sopp_brtarget:$simm16),
1193  "$simm16"
1194>;
1195
1196defm S_CBRANCH_CDBGSYS_OR_USER : SOPP_With_Relaxation <
1197  "s_cbranch_cdbgsys_or_user" , (ins sopp_brtarget:$simm16),
1198  "$simm16"
1199>;
1200
1201defm S_CBRANCH_CDBGUSER : SOPP_With_Relaxation <
1202  "s_cbranch_cdbguser" , (ins sopp_brtarget:$simm16),
1203  "$simm16"
1204>;
1205
1206} // End isBranch = 1
1207} // End isTerminator = 1
1208
1209let hasSideEffects = 1 in {
1210def S_BARRIER : SOPP_Pseudo <"s_barrier", (ins), "",
1211  [(int_amdgcn_s_barrier)]> {
1212  let SchedRW = [WriteBarrier];
1213  let simm16 = 0;
1214  let fixed_imm = 1;
1215  let isConvergent = 1;
1216}
1217
1218def S_WAKEUP : SOPP_Pseudo <"s_wakeup", (ins) > {
1219  let SubtargetPredicate = isGFX8Plus;
1220  let simm16 = 0;
1221  let fixed_imm = 1;
1222  let mayLoad = 1;
1223  let mayStore = 1;
1224}
1225
1226let mayLoad = 0, mayStore = 0, hasSideEffects = 1 in
1227def S_WAITCNT : SOPP_Pseudo <"s_waitcnt" , (ins WAIT_FLAG:$simm16), "$simm16",
1228    [(int_amdgcn_s_waitcnt timm:$simm16)]>;
1229def S_SETHALT : SOPP_Pseudo <"s_sethalt" , (ins i16imm:$simm16), "$simm16">;
1230def S_SETKILL : SOPP_Pseudo <"s_setkill" , (ins i16imm:$simm16), "$simm16">;
1231
1232// On SI the documentation says sleep for approximately 64 * low 2
1233// bits, consistent with the reported maximum of 448. On VI the
1234// maximum reported is 960 cycles, so 960 / 64 = 15 max, so is the
1235// maximum really 15 on VI?
1236def S_SLEEP : SOPP_Pseudo <"s_sleep", (ins i32imm:$simm16),
1237  "$simm16", [(int_amdgcn_s_sleep timm:$simm16)]> {
1238  let hasSideEffects = 1;
1239  let mayLoad = 0;
1240  let mayStore = 0;
1241}
1242
1243def S_SETPRIO : SOPP_Pseudo <"s_setprio" , (ins i16imm:$simm16), "$simm16">;
1244
1245let Uses = [EXEC, M0] in {
1246// FIXME: Should this be mayLoad+mayStore?
1247def S_SENDMSG : SOPP_Pseudo <"s_sendmsg" , (ins SendMsgImm:$simm16), "$simm16",
1248  [(int_amdgcn_s_sendmsg (i32 timm:$simm16), M0)]>;
1249
1250def S_SENDMSGHALT : SOPP_Pseudo <"s_sendmsghalt" , (ins SendMsgImm:$simm16), "$simm16",
1251  [(int_amdgcn_s_sendmsghalt (i32 timm:$simm16), M0)]>;
1252
1253} // End Uses = [EXEC, M0]
1254
1255def S_TRAP : SOPP_Pseudo <"s_trap" , (ins i16imm:$simm16), "$simm16"> {
1256  let isTrap = 1;
1257}
1258
1259def S_ICACHE_INV : SOPP_Pseudo <"s_icache_inv", (ins)> {
1260  let simm16 = 0;
1261  let fixed_imm = 1;
1262}
1263def S_INCPERFLEVEL : SOPP_Pseudo <"s_incperflevel", (ins i32imm:$simm16), "$simm16",
1264  [(int_amdgcn_s_incperflevel timm:$simm16)]> {
1265  let hasSideEffects = 1;
1266  let mayLoad = 0;
1267  let mayStore = 0;
1268}
1269def S_DECPERFLEVEL : SOPP_Pseudo <"s_decperflevel", (ins i32imm:$simm16), "$simm16",
1270  [(int_amdgcn_s_decperflevel timm:$simm16)]> {
1271  let hasSideEffects = 1;
1272  let mayLoad = 0;
1273  let mayStore = 0;
1274}
1275def S_TTRACEDATA : SOPP_Pseudo <"s_ttracedata", (ins)> {
1276  let simm16 = 0;
1277  let fixed_imm = 1;
1278}
1279
1280let SubtargetPredicate = HasVGPRIndexMode in {
1281def S_SET_GPR_IDX_OFF : SOPP_Pseudo<"s_set_gpr_idx_off", (ins) > {
1282  let simm16 = 0;
1283  let fixed_imm = 1;
1284  let Defs = [MODE];
1285  let Uses = [MODE];
1286}
1287}
1288} // End hasSideEffects
1289
1290let SubtargetPredicate = HasVGPRIndexMode in {
1291def S_SET_GPR_IDX_MODE : SOPP_Pseudo<"s_set_gpr_idx_mode", (ins GPRIdxMode:$simm16),
1292  "$simm16"> {
1293  let Defs = [M0, MODE];
1294  let Uses = [MODE];
1295}
1296}
1297
1298let SubtargetPredicate = isGFX10Plus in {
1299  def S_INST_PREFETCH :
1300    SOPP_Pseudo<"s_inst_prefetch", (ins s16imm:$simm16), "$simm16">;
1301  def S_CLAUSE :
1302    SOPP_Pseudo<"s_clause", (ins s16imm:$simm16), "$simm16">;
1303  def S_WAIT_IDLE :
1304    SOPP_Pseudo <"s_wait_idle", (ins), ""> {
1305      let simm16 = 0;
1306      let fixed_imm = 1;
1307    }
1308  def S_WAITCNT_DEPCTR :
1309    SOPP_Pseudo <"s_waitcnt_depctr" , (ins s16imm:$simm16), "$simm16">;
1310
1311  let hasSideEffects = 0, Uses = [MODE], Defs = [MODE] in {
1312    def S_ROUND_MODE :
1313      SOPP_Pseudo<"s_round_mode", (ins s16imm:$simm16), "$simm16">;
1314    def S_DENORM_MODE :
1315      SOPP_Pseudo<"s_denorm_mode", (ins i32imm:$simm16), "$simm16",
1316      [(SIdenorm_mode (i32 timm:$simm16))]>;
1317  }
1318
1319  def S_TTRACEDATA_IMM :
1320    SOPP_Pseudo<"s_ttracedata_imm", (ins s16imm:$simm16), "$simm16">;
1321} // End SubtargetPredicate = isGFX10Plus
1322
1323//===----------------------------------------------------------------------===//
1324// SOP1 Patterns
1325//===----------------------------------------------------------------------===//
1326
1327def : GCNPat <
1328  (AMDGPUendpgm),
1329    (S_ENDPGM (i16 0))
1330>;
1331
1332def : GCNPat <
1333  (int_amdgcn_endpgm),
1334    (S_ENDPGM (i16 0))
1335>;
1336
1337def : GCNPat <
1338  (i64 (ctpop i64:$src)),
1339    (i64 (REG_SEQUENCE SReg_64,
1340     (i32 (COPY_TO_REGCLASS (S_BCNT1_I32_B64 $src), SReg_32)), sub0,
1341     (S_MOV_B32 (i32 0)), sub1))
1342>;
1343
1344def : GCNPat <
1345  (i32 (smax i32:$x, (i32 (ineg i32:$x)))),
1346  (S_ABS_I32 SReg_32:$x)
1347>;
1348
1349def : GCNPat <
1350  (i16 imm:$imm),
1351  (S_MOV_B32 imm:$imm)
1352>;
1353
1354// Same as a 32-bit inreg
1355def : GCNPat<
1356  (i32 (UniformUnaryFrag<sext> i16:$src)),
1357  (S_SEXT_I32_I16 $src)
1358>;
1359
1360
1361//===----------------------------------------------------------------------===//
1362// SOP2 Patterns
1363//===----------------------------------------------------------------------===//
1364
1365// V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector
1366// case, the sgpr-copies pass will fix this to use the vector version.
1367def : GCNPat <
1368  (i32 (addc i32:$src0, i32:$src1)),
1369  (S_ADD_U32 $src0, $src1)
1370>;
1371
1372// FIXME: We need to use COPY_TO_REGCLASS to work-around the fact that
1373// REG_SEQUENCE patterns don't support instructions with multiple
1374// outputs.
1375def : GCNPat<
1376  (i64 (zext i16:$src)),
1377    (REG_SEQUENCE SReg_64,
1378      (i32 (COPY_TO_REGCLASS (S_AND_B32 $src, (S_MOV_B32 (i32 0xffff))), SGPR_32)), sub0,
1379      (S_MOV_B32 (i32 0)), sub1)
1380>;
1381
1382def : GCNPat <
1383  (i64 (UniformUnaryFrag<sext> i16:$src)),
1384    (REG_SEQUENCE SReg_64, (i32 (S_SEXT_I32_I16 $src)), sub0,
1385    (i32 (COPY_TO_REGCLASS (S_ASHR_I32 (i32 (S_SEXT_I32_I16 $src)), (S_MOV_B32 (i32 31))), SGPR_32)), sub1)
1386>;
1387
1388def : GCNPat<
1389  (i32 (zext i16:$src)),
1390  (S_AND_B32 (S_MOV_B32 (i32 0xffff)), $src)
1391>;
1392
1393// FIXME: ValueType should have isVector field
1394class ScalarNot2Pat<Instruction inst, SDPatternOperator op, ValueType vt,
1395                    bit isVector = 1> : GCNPat<
1396  (UniformBinFrag<op> vt:$src0, (UniformUnaryFrag<!if(isVector, vnot, not)> vt:$src1)),
1397  (inst getSOPSrcForVT<vt>.ret:$src0, getSOPSrcForVT<vt>.ret:$src1)
1398>;
1399
1400// Match these for some more types
1401// TODO: i1
1402def : ScalarNot2Pat<S_ANDN2_B32, and, i16, 0>;
1403def : ScalarNot2Pat<S_ANDN2_B32, and, v2i16>;
1404def : ScalarNot2Pat<S_ANDN2_B64, and, v4i16>;
1405def : ScalarNot2Pat<S_ANDN2_B64, and, v2i32>;
1406
1407def : ScalarNot2Pat<S_ORN2_B32, or, i16, 0>;
1408def : ScalarNot2Pat<S_ORN2_B32, or, v2i16>;
1409def : ScalarNot2Pat<S_ORN2_B64, or, v4i16>;
1410def : ScalarNot2Pat<S_ORN2_B64, or, v2i32>;
1411
1412//===----------------------------------------------------------------------===//
1413// Target-specific instruction encodings.
1414//===----------------------------------------------------------------------===//
1415
1416class Select_gfx10<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX10> {
1417  Predicate AssemblerPredicate = isGFX10Plus;
1418  string DecoderNamespace      = "GFX10";
1419}
1420
1421class Select_vi<string opName> : SIMCInstr<opName, SIEncodingFamily.VI> {
1422  Predicate AssemblerPredicate = isGFX8GFX9;
1423  string DecoderNamespace = "GFX8";
1424}
1425
1426class Select_gfx6_gfx7<string opName> : SIMCInstr<opName, SIEncodingFamily.SI> {
1427  Predicate AssemblerPredicate = isGFX6GFX7;
1428  string DecoderNamespace      = "GFX6GFX7";
1429}
1430
1431//===----------------------------------------------------------------------===//
1432// SOP1 - GFX10.
1433//===----------------------------------------------------------------------===//
1434
1435multiclass SOP1_Real_gfx10<bits<8> op> {
1436  def _gfx10 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
1437               Select_gfx10<!cast<SOP1_Pseudo>(NAME).Mnemonic>;
1438}
1439
1440defm S_ANDN1_SAVEEXEC_B64   : SOP1_Real_gfx10<0x037>;
1441defm S_ORN1_SAVEEXEC_B64    : SOP1_Real_gfx10<0x038>;
1442defm S_ANDN1_WREXEC_B64     : SOP1_Real_gfx10<0x039>;
1443defm S_ANDN2_WREXEC_B64     : SOP1_Real_gfx10<0x03a>;
1444defm S_BITREPLICATE_B64_B32 : SOP1_Real_gfx10<0x03b>;
1445defm S_AND_SAVEEXEC_B32     : SOP1_Real_gfx10<0x03c>;
1446defm S_OR_SAVEEXEC_B32      : SOP1_Real_gfx10<0x03d>;
1447defm S_XOR_SAVEEXEC_B32     : SOP1_Real_gfx10<0x03e>;
1448defm S_ANDN2_SAVEEXEC_B32   : SOP1_Real_gfx10<0x03f>;
1449defm S_ORN2_SAVEEXEC_B32    : SOP1_Real_gfx10<0x040>;
1450defm S_NAND_SAVEEXEC_B32    : SOP1_Real_gfx10<0x041>;
1451defm S_NOR_SAVEEXEC_B32     : SOP1_Real_gfx10<0x042>;
1452defm S_XNOR_SAVEEXEC_B32    : SOP1_Real_gfx10<0x043>;
1453defm S_ANDN1_SAVEEXEC_B32   : SOP1_Real_gfx10<0x044>;
1454defm S_ORN1_SAVEEXEC_B32    : SOP1_Real_gfx10<0x045>;
1455defm S_ANDN1_WREXEC_B32     : SOP1_Real_gfx10<0x046>;
1456defm S_ANDN2_WREXEC_B32     : SOP1_Real_gfx10<0x047>;
1457defm S_MOVRELSD_2_B32       : SOP1_Real_gfx10<0x049>;
1458
1459//===----------------------------------------------------------------------===//
1460// SOP1 - GFX6, GFX7.
1461//===----------------------------------------------------------------------===//
1462
1463
1464multiclass SOP1_Real_gfx6_gfx7<bits<8> op> {
1465  def _gfx6_gfx7 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
1466                   Select_gfx6_gfx7<!cast<SOP1_Pseudo>(NAME).Mnemonic>;
1467}
1468
1469multiclass SOP1_Real_gfx6_gfx7_gfx10<bits<8> op> :
1470  SOP1_Real_gfx6_gfx7<op>, SOP1_Real_gfx10<op>;
1471
1472defm S_CBRANCH_JOIN  : SOP1_Real_gfx6_gfx7<0x032>;
1473
1474defm S_MOV_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x003>;
1475defm S_MOV_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x004>;
1476defm S_CMOV_B32           : SOP1_Real_gfx6_gfx7_gfx10<0x005>;
1477defm S_CMOV_B64           : SOP1_Real_gfx6_gfx7_gfx10<0x006>;
1478defm S_NOT_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x007>;
1479defm S_NOT_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x008>;
1480defm S_WQM_B32            : SOP1_Real_gfx6_gfx7_gfx10<0x009>;
1481defm S_WQM_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x00a>;
1482defm S_BREV_B32           : SOP1_Real_gfx6_gfx7_gfx10<0x00b>;
1483defm S_BREV_B64           : SOP1_Real_gfx6_gfx7_gfx10<0x00c>;
1484defm S_BCNT0_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x00d>;
1485defm S_BCNT0_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x00e>;
1486defm S_BCNT1_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x00f>;
1487defm S_BCNT1_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x010>;
1488defm S_FF0_I32_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x011>;
1489defm S_FF0_I32_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x012>;
1490defm S_FF1_I32_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x013>;
1491defm S_FF1_I32_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x014>;
1492defm S_FLBIT_I32_B32      : SOP1_Real_gfx6_gfx7_gfx10<0x015>;
1493defm S_FLBIT_I32_B64      : SOP1_Real_gfx6_gfx7_gfx10<0x016>;
1494defm S_FLBIT_I32          : SOP1_Real_gfx6_gfx7_gfx10<0x017>;
1495defm S_FLBIT_I32_I64      : SOP1_Real_gfx6_gfx7_gfx10<0x018>;
1496defm S_SEXT_I32_I8        : SOP1_Real_gfx6_gfx7_gfx10<0x019>;
1497defm S_SEXT_I32_I16       : SOP1_Real_gfx6_gfx7_gfx10<0x01a>;
1498defm S_BITSET0_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x01b>;
1499defm S_BITSET0_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x01c>;
1500defm S_BITSET1_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x01d>;
1501defm S_BITSET1_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x01e>;
1502defm S_GETPC_B64          : SOP1_Real_gfx6_gfx7_gfx10<0x01f>;
1503defm S_SETPC_B64          : SOP1_Real_gfx6_gfx7_gfx10<0x020>;
1504defm S_SWAPPC_B64         : SOP1_Real_gfx6_gfx7_gfx10<0x021>;
1505defm S_RFE_B64            : SOP1_Real_gfx6_gfx7_gfx10<0x022>;
1506defm S_AND_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x024>;
1507defm S_OR_SAVEEXEC_B64    : SOP1_Real_gfx6_gfx7_gfx10<0x025>;
1508defm S_XOR_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x026>;
1509defm S_ANDN2_SAVEEXEC_B64 : SOP1_Real_gfx6_gfx7_gfx10<0x027>;
1510defm S_ORN2_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10<0x028>;
1511defm S_NAND_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10<0x029>;
1512defm S_NOR_SAVEEXEC_B64   : SOP1_Real_gfx6_gfx7_gfx10<0x02a>;
1513defm S_XNOR_SAVEEXEC_B64  : SOP1_Real_gfx6_gfx7_gfx10<0x02b>;
1514defm S_QUADMASK_B32       : SOP1_Real_gfx6_gfx7_gfx10<0x02c>;
1515defm S_QUADMASK_B64       : SOP1_Real_gfx6_gfx7_gfx10<0x02d>;
1516defm S_MOVRELS_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x02e>;
1517defm S_MOVRELS_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x02f>;
1518defm S_MOVRELD_B32        : SOP1_Real_gfx6_gfx7_gfx10<0x030>;
1519defm S_MOVRELD_B64        : SOP1_Real_gfx6_gfx7_gfx10<0x031>;
1520defm S_ABS_I32            : SOP1_Real_gfx6_gfx7_gfx10<0x034>;
1521
1522//===----------------------------------------------------------------------===//
1523// SOP2 - GFX10.
1524//===----------------------------------------------------------------------===//
1525
1526multiclass SOP2_Real_gfx10<bits<7> op> {
1527  def _gfx10 : SOP2_Real<op, !cast<SOP2_Pseudo>(NAME)>,
1528               Select_gfx10<!cast<SOP2_Pseudo>(NAME).Mnemonic>;
1529}
1530
1531defm S_LSHL1_ADD_U32   : SOP2_Real_gfx10<0x02e>;
1532defm S_LSHL2_ADD_U32   : SOP2_Real_gfx10<0x02f>;
1533defm S_LSHL3_ADD_U32   : SOP2_Real_gfx10<0x030>;
1534defm S_LSHL4_ADD_U32   : SOP2_Real_gfx10<0x031>;
1535defm S_PACK_LL_B32_B16 : SOP2_Real_gfx10<0x032>;
1536defm S_PACK_LH_B32_B16 : SOP2_Real_gfx10<0x033>;
1537defm S_PACK_HH_B32_B16 : SOP2_Real_gfx10<0x034>;
1538defm S_MUL_HI_U32      : SOP2_Real_gfx10<0x035>;
1539defm S_MUL_HI_I32      : SOP2_Real_gfx10<0x036>;
1540
1541//===----------------------------------------------------------------------===//
1542// SOP2 - GFX6, GFX7.
1543//===----------------------------------------------------------------------===//
1544
1545multiclass SOP2_Real_gfx6_gfx7<bits<7> op> {
1546  def _gfx6_gfx7 : SOP2_Real<op, !cast<SOP_Pseudo>(NAME)>,
1547                   Select_gfx6_gfx7<!cast<SOP_Pseudo>(NAME).Mnemonic>;
1548}
1549
1550multiclass SOP2_Real_gfx6_gfx7_gfx10<bits<7> op> :
1551  SOP2_Real_gfx6_gfx7<op>, SOP2_Real_gfx10<op>;
1552
1553defm S_CBRANCH_G_FORK : SOP2_Real_gfx6_gfx7<0x02b>;
1554
1555defm S_ADD_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x000>;
1556defm S_SUB_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x001>;
1557defm S_ADD_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x002>;
1558defm S_SUB_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x003>;
1559defm S_ADDC_U32    : SOP2_Real_gfx6_gfx7_gfx10<0x004>;
1560defm S_SUBB_U32    : SOP2_Real_gfx6_gfx7_gfx10<0x005>;
1561defm S_MIN_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x006>;
1562defm S_MIN_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x007>;
1563defm S_MAX_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x008>;
1564defm S_MAX_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x009>;
1565defm S_CSELECT_B32 : SOP2_Real_gfx6_gfx7_gfx10<0x00a>;
1566defm S_CSELECT_B64 : SOP2_Real_gfx6_gfx7_gfx10<0x00b>;
1567defm S_AND_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x00e>;
1568defm S_AND_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x00f>;
1569defm S_OR_B32      : SOP2_Real_gfx6_gfx7_gfx10<0x010>;
1570defm S_OR_B64      : SOP2_Real_gfx6_gfx7_gfx10<0x011>;
1571defm S_XOR_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x012>;
1572defm S_XOR_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x013>;
1573defm S_ANDN2_B32   : SOP2_Real_gfx6_gfx7_gfx10<0x014>;
1574defm S_ANDN2_B64   : SOP2_Real_gfx6_gfx7_gfx10<0x015>;
1575defm S_ORN2_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x016>;
1576defm S_ORN2_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x017>;
1577defm S_NAND_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x018>;
1578defm S_NAND_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x019>;
1579defm S_NOR_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x01a>;
1580defm S_NOR_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x01b>;
1581defm S_XNOR_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x01c>;
1582defm S_XNOR_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x01d>;
1583defm S_LSHL_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x01e>;
1584defm S_LSHL_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x01f>;
1585defm S_LSHR_B32    : SOP2_Real_gfx6_gfx7_gfx10<0x020>;
1586defm S_LSHR_B64    : SOP2_Real_gfx6_gfx7_gfx10<0x021>;
1587defm S_ASHR_I32    : SOP2_Real_gfx6_gfx7_gfx10<0x022>;
1588defm S_ASHR_I64    : SOP2_Real_gfx6_gfx7_gfx10<0x023>;
1589defm S_BFM_B32     : SOP2_Real_gfx6_gfx7_gfx10<0x024>;
1590defm S_BFM_B64     : SOP2_Real_gfx6_gfx7_gfx10<0x025>;
1591defm S_MUL_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x026>;
1592defm S_BFE_U32     : SOP2_Real_gfx6_gfx7_gfx10<0x027>;
1593defm S_BFE_I32     : SOP2_Real_gfx6_gfx7_gfx10<0x028>;
1594defm S_BFE_U64     : SOP2_Real_gfx6_gfx7_gfx10<0x029>;
1595defm S_BFE_I64     : SOP2_Real_gfx6_gfx7_gfx10<0x02a>;
1596defm S_ABSDIFF_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x02c>;
1597
1598//===----------------------------------------------------------------------===//
1599// SOPK - GFX10.
1600//===----------------------------------------------------------------------===//
1601
1602multiclass SOPK_Real32_gfx10<bits<5> op> {
1603  def _gfx10 : SOPK_Real32<op, !cast<SOPK_Pseudo>(NAME)>,
1604               Select_gfx10<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
1605}
1606
1607multiclass SOPK_Real64_gfx10<bits<5> op> {
1608  def _gfx10 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
1609               Select_gfx10<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
1610}
1611
1612defm S_VERSION              : SOPK_Real32_gfx10<0x001>;
1613defm S_CALL_B64             : SOPK_Real32_gfx10<0x016>;
1614defm S_WAITCNT_VSCNT        : SOPK_Real32_gfx10<0x017>;
1615defm S_WAITCNT_VMCNT        : SOPK_Real32_gfx10<0x018>;
1616defm S_WAITCNT_EXPCNT       : SOPK_Real32_gfx10<0x019>;
1617defm S_WAITCNT_LGKMCNT      : SOPK_Real32_gfx10<0x01a>;
1618defm S_SUBVECTOR_LOOP_BEGIN : SOPK_Real32_gfx10<0x01b>;
1619defm S_SUBVECTOR_LOOP_END   : SOPK_Real32_gfx10<0x01c>;
1620
1621//===----------------------------------------------------------------------===//
1622// SOPK - GFX6, GFX7.
1623//===----------------------------------------------------------------------===//
1624
1625multiclass SOPK_Real32_gfx6_gfx7<bits<5> op> {
1626  def _gfx6_gfx7 : SOPK_Real32<op, !cast<SOPK_Pseudo>(NAME)>,
1627                   Select_gfx6_gfx7<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
1628}
1629
1630multiclass SOPK_Real64_gfx6_gfx7<bits<5> op> {
1631  def _gfx6_gfx7 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
1632                   Select_gfx6_gfx7<!cast<SOPK_Pseudo>(NAME).Mnemonic>;
1633}
1634
1635multiclass SOPK_Real32_gfx6_gfx7_gfx10<bits<5> op> :
1636  SOPK_Real32_gfx6_gfx7<op>, SOPK_Real32_gfx10<op>;
1637
1638multiclass SOPK_Real64_gfx6_gfx7_gfx10<bits<5> op> :
1639  SOPK_Real64_gfx6_gfx7<op>, SOPK_Real64_gfx10<op>;
1640
1641defm S_CBRANCH_I_FORK : SOPK_Real32_gfx6_gfx7<0x011>;
1642
1643defm S_MOVK_I32         : SOPK_Real32_gfx6_gfx7_gfx10<0x000>;
1644defm S_CMOVK_I32        : SOPK_Real32_gfx6_gfx7_gfx10<0x002>;
1645defm S_CMPK_EQ_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x003>;
1646defm S_CMPK_LG_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x004>;
1647defm S_CMPK_GT_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x005>;
1648defm S_CMPK_GE_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x006>;
1649defm S_CMPK_LT_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x007>;
1650defm S_CMPK_LE_I32      : SOPK_Real32_gfx6_gfx7_gfx10<0x008>;
1651defm S_CMPK_EQ_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x009>;
1652defm S_CMPK_LG_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x00a>;
1653defm S_CMPK_GT_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x00b>;
1654defm S_CMPK_GE_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x00c>;
1655defm S_CMPK_LT_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x00d>;
1656defm S_CMPK_LE_U32      : SOPK_Real32_gfx6_gfx7_gfx10<0x00e>;
1657defm S_ADDK_I32         : SOPK_Real32_gfx6_gfx7_gfx10<0x00f>;
1658defm S_MULK_I32         : SOPK_Real32_gfx6_gfx7_gfx10<0x010>;
1659defm S_GETREG_B32       : SOPK_Real32_gfx6_gfx7_gfx10<0x012>;
1660defm S_SETREG_B32       : SOPK_Real32_gfx6_gfx7_gfx10<0x013>;
1661defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>;
1662
1663//===----------------------------------------------------------------------===//
1664// SOPP - GFX6, GFX7, GFX8, GFX9, GFX10
1665//===----------------------------------------------------------------------===//
1666
1667multiclass SOPP_Real_32_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic> {
1668  def _gfx6_gfx7 : SOPP_Real_32<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1669                   Select_gfx6_gfx7<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1670                   SOPPRelaxTable<0, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx6_gfx7">;
1671}
1672
1673multiclass SOPP_Real_32_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> {
1674  def _vi : SOPP_Real_32<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1675            Select_vi<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1676            SOPPRelaxTable<0, !cast<SOPP_Pseudo>(NAME).KeyName, "_vi">;
1677}
1678
1679multiclass SOPP_Real_32_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> {
1680  def _gfx10 : SOPP_Real_32<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1681               Select_gfx10<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1682               SOPPRelaxTable<0, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx10">;
1683}
1684
1685multiclass SOPP_Real_32_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1686  SOPP_Real_32_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>;
1687
1688multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1689  SOPP_Real_32_gfx6_gfx7<op, real_name>, SOPP_Real_32_gfx8_gfx9<op, real_name>;
1690
1691multiclass SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1692  SOPP_Real_32_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_32_gfx10<op, real_name>;
1693
1694//64 bit encodings, for Relaxation
1695multiclass SOPP_Real_64_gfx6_gfx7<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> {
1696  def _gfx6_gfx7 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1697                   Select_gfx6_gfx7<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1698                   SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx6_gfx7">;
1699}
1700
1701multiclass SOPP_Real_64_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> {
1702  def _vi : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1703            Select_vi<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1704            SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_vi">;
1705}
1706
1707multiclass SOPP_Real_64_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> {
1708  def _gfx10 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), real_name>,
1709               Select_gfx10<!cast<SOPP_Pseudo>(NAME).Mnemonic>,
1710               SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx10">;
1711}
1712
1713multiclass SOPP_Real_64_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1714  SOPP_Real_64_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>;
1715
1716multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1717  SOPP_Real_64_gfx6_gfx7<op, real_name>, SOPP_Real_64_gfx8_gfx9<op, real_name>;
1718
1719multiclass SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op, string real_name = !cast<SOPP_Pseudo>(NAME).Mnemonic # " "> :
1720  SOPP_Real_64_gfx6_gfx7_gfx8_gfx9<op, real_name>, SOPP_Real_64_gfx10<op, real_name>;
1721
1722//relaxation for insts with no operands not implemented
1723multiclass SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> {
1724  defm "" : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<op>;
1725  defm _pad_s_nop : SOPP_Real_64_gfx6_gfx7_gfx8_gfx9_gfx10<op>;
1726}
1727
1728defm S_NOP                      : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x000>;
1729defm S_ENDPGM                   : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x001, "s_endpgm">;
1730defm S_BRANCH                   : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x002>;
1731defm S_WAKEUP                   : SOPP_Real_32_gfx8_gfx9_gfx10<0x003>;
1732defm S_CBRANCH_SCC0             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x004>;
1733defm S_CBRANCH_SCC1             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x005>;
1734defm S_CBRANCH_VCCZ             : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x006>;
1735defm S_CBRANCH_VCCNZ            : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x007>;
1736defm S_CBRANCH_EXECZ            : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x008>;
1737defm S_CBRANCH_EXECNZ           : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x009>;
1738defm S_CBRANCH_CDBGSYS          : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x017>;
1739defm S_CBRANCH_CDBGUSER         : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x018>;
1740defm S_CBRANCH_CDBGSYS_OR_USER  : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x019>;
1741defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_gfx10<0x01A>;
1742defm S_BARRIER                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00a>;
1743defm S_WAITCNT                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00c>;
1744defm S_SETHALT                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00d>;
1745defm S_SETKILL                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00b>;
1746defm S_SLEEP                    : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00e>;
1747defm S_SETPRIO                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x00f>;
1748defm S_SENDMSG                  : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x010>;
1749defm S_SENDMSGHALT              : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x011>;
1750defm S_TRAP                     : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x012>;
1751defm S_ICACHE_INV               : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x013>;
1752defm S_INCPERFLEVEL             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x014>;
1753defm S_DECPERFLEVEL             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x015>;
1754defm S_TTRACEDATA               : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x016>;
1755defm S_ENDPGM_SAVED             : SOPP_Real_32_gfx6_gfx7_gfx8_gfx9_gfx10<0x01B>;
1756defm S_SET_GPR_IDX_OFF          : SOPP_Real_32_gfx8_gfx9<0x01c>;
1757defm S_SET_GPR_IDX_MODE         : SOPP_Real_32_gfx8_gfx9<0x01d>;
1758defm S_ENDPGM_ORDERED_PS_DONE   : SOPP_Real_32_gfx8_gfx9_gfx10<0x01e>;
1759defm S_CODE_END                 : SOPP_Real_32_gfx10<0x01f>;
1760defm S_INST_PREFETCH            : SOPP_Real_32_gfx10<0x020>;
1761defm S_CLAUSE                   : SOPP_Real_32_gfx10<0x021>;
1762defm S_WAIT_IDLE                : SOPP_Real_32_gfx10<0x022>;
1763defm S_WAITCNT_DEPCTR           : SOPP_Real_32_gfx10<0x023>;
1764defm S_ROUND_MODE               : SOPP_Real_32_gfx10<0x024>;
1765defm S_DENORM_MODE              : SOPP_Real_32_gfx10<0x025>;
1766defm S_TTRACEDATA_IMM           : SOPP_Real_32_gfx10<0x028>;
1767
1768//===----------------------------------------------------------------------===//
1769// SOPC - GFX6, GFX7, GFX8, GFX9, GFX10
1770//===----------------------------------------------------------------------===//
1771
1772multiclass SOPC_Real_gfx6_gfx7<bits<7> op> {
1773  def _gfx6_gfx7 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
1774                   Select_gfx6_gfx7<!cast<SOPC_Pseudo>(NAME).Mnemonic>;
1775}
1776
1777multiclass SOPC_Real_gfx8_gfx9<bits<7> op> {
1778  def _vi : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
1779            Select_vi<!cast<SOPC_Pseudo>(NAME).Mnemonic>;
1780}
1781
1782multiclass SOPC_Real_gfx10<bits<7> op> {
1783  def _gfx10 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
1784               Select_gfx10<!cast<SOPC_Pseudo>(NAME).Mnemonic>;
1785}
1786
1787multiclass SOPC_Real_gfx8_gfx9_gfx10<bits<7> op> :
1788  SOPC_Real_gfx8_gfx9<op>, SOPC_Real_gfx10<op>;
1789
1790multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9<bits<7> op> :
1791  SOPC_Real_gfx6_gfx7<op>, SOPC_Real_gfx8_gfx9<op>;
1792
1793multiclass SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<bits<7> op> :
1794  SOPC_Real_gfx6_gfx7_gfx8_gfx9<op>, SOPC_Real_gfx10<op>;
1795
1796defm S_CMP_EQ_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x00>;
1797defm S_CMP_LG_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x01>;
1798defm S_CMP_GT_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x02>;
1799defm S_CMP_GE_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x03>;
1800defm S_CMP_LT_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x04>;
1801defm S_CMP_LE_I32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x05>;
1802defm S_CMP_EQ_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x06>;
1803defm S_CMP_LG_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x07>;
1804defm S_CMP_GT_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x08>;
1805defm S_CMP_GE_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x09>;
1806defm S_CMP_LT_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0a>;
1807defm S_CMP_LE_U32     : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0b>;
1808defm S_BITCMP0_B32    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0c>;
1809defm S_BITCMP1_B32    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0d>;
1810defm S_BITCMP0_B64    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0e>;
1811defm S_BITCMP1_B64    : SOPC_Real_gfx6_gfx7_gfx8_gfx9_gfx10<0x0f>;
1812defm S_SETVSKIP       : SOPC_Real_gfx6_gfx7_gfx8_gfx9<0x10>;
1813defm S_SET_GPR_IDX_ON : SOPC_Real_gfx8_gfx9<0x11>;
1814defm S_CMP_EQ_U64     : SOPC_Real_gfx8_gfx9_gfx10<0x12>;
1815defm S_CMP_LG_U64     : SOPC_Real_gfx8_gfx9_gfx10<0x13>;
1816
1817//===----------------------------------------------------------------------===//
1818// GFX8 (VI), GFX9.
1819//===----------------------------------------------------------------------===//
1820
1821class SOP1_Real_vi<bits<8> op, SOP1_Pseudo ps> :
1822  SOP1_Real<op, ps>,
1823  Select_vi<ps.Mnemonic>;
1824
1825
1826class SOP2_Real_vi<bits<7> op, SOP2_Pseudo ps> :
1827  SOP2_Real<op, ps>,
1828  Select_vi<ps.Mnemonic>;
1829
1830class SOPK_Real_vi<bits<5> op, SOPK_Pseudo ps> :
1831  SOPK_Real32<op, ps>,
1832  Select_vi<ps.Mnemonic>;
1833
1834def S_MOV_B32_vi           : SOP1_Real_vi <0x00, S_MOV_B32>;
1835def S_MOV_B64_vi           : SOP1_Real_vi <0x01, S_MOV_B64>;
1836def S_CMOV_B32_vi          : SOP1_Real_vi <0x02, S_CMOV_B32>;
1837def S_CMOV_B64_vi          : SOP1_Real_vi <0x03, S_CMOV_B64>;
1838def S_NOT_B32_vi           : SOP1_Real_vi <0x04, S_NOT_B32>;
1839def S_NOT_B64_vi           : SOP1_Real_vi <0x05, S_NOT_B64>;
1840def S_WQM_B32_vi           : SOP1_Real_vi <0x06, S_WQM_B32>;
1841def S_WQM_B64_vi           : SOP1_Real_vi <0x07, S_WQM_B64>;
1842def S_BREV_B32_vi          : SOP1_Real_vi <0x08, S_BREV_B32>;
1843def S_BREV_B64_vi          : SOP1_Real_vi <0x09, S_BREV_B64>;
1844def S_BCNT0_I32_B32_vi     : SOP1_Real_vi <0x0a, S_BCNT0_I32_B32>;
1845def S_BCNT0_I32_B64_vi     : SOP1_Real_vi <0x0b, S_BCNT0_I32_B64>;
1846def S_BCNT1_I32_B32_vi     : SOP1_Real_vi <0x0c, S_BCNT1_I32_B32>;
1847def S_BCNT1_I32_B64_vi     : SOP1_Real_vi <0x0d, S_BCNT1_I32_B64>;
1848def S_FF0_I32_B32_vi       : SOP1_Real_vi <0x0e, S_FF0_I32_B32>;
1849def S_FF0_I32_B64_vi       : SOP1_Real_vi <0x0f, S_FF0_I32_B64>;
1850def S_FF1_I32_B32_vi       : SOP1_Real_vi <0x10, S_FF1_I32_B32>;
1851def S_FF1_I32_B64_vi       : SOP1_Real_vi <0x11, S_FF1_I32_B64>;
1852def S_FLBIT_I32_B32_vi     : SOP1_Real_vi <0x12, S_FLBIT_I32_B32>;
1853def S_FLBIT_I32_B64_vi     : SOP1_Real_vi <0x13, S_FLBIT_I32_B64>;
1854def S_FLBIT_I32_vi         : SOP1_Real_vi <0x14, S_FLBIT_I32>;
1855def S_FLBIT_I32_I64_vi     : SOP1_Real_vi <0x15, S_FLBIT_I32_I64>;
1856def S_SEXT_I32_I8_vi       : SOP1_Real_vi <0x16, S_SEXT_I32_I8>;
1857def S_SEXT_I32_I16_vi      : SOP1_Real_vi <0x17, S_SEXT_I32_I16>;
1858def S_BITSET0_B32_vi       : SOP1_Real_vi <0x18, S_BITSET0_B32>;
1859def S_BITSET0_B64_vi       : SOP1_Real_vi <0x19, S_BITSET0_B64>;
1860def S_BITSET1_B32_vi       : SOP1_Real_vi <0x1a, S_BITSET1_B32>;
1861def S_BITSET1_B64_vi       : SOP1_Real_vi <0x1b, S_BITSET1_B64>;
1862def S_GETPC_B64_vi         : SOP1_Real_vi <0x1c, S_GETPC_B64>;
1863def S_SETPC_B64_vi         : SOP1_Real_vi <0x1d, S_SETPC_B64>;
1864def S_SWAPPC_B64_vi        : SOP1_Real_vi <0x1e, S_SWAPPC_B64>;
1865def S_RFE_B64_vi           : SOP1_Real_vi <0x1f, S_RFE_B64>;
1866def S_AND_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x20, S_AND_SAVEEXEC_B64>;
1867def S_OR_SAVEEXEC_B64_vi   : SOP1_Real_vi <0x21, S_OR_SAVEEXEC_B64>;
1868def S_XOR_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x22, S_XOR_SAVEEXEC_B64>;
1869def S_ANDN2_SAVEEXEC_B64_vi: SOP1_Real_vi <0x23, S_ANDN2_SAVEEXEC_B64>;
1870def S_ORN2_SAVEEXEC_B64_vi : SOP1_Real_vi <0x24, S_ORN2_SAVEEXEC_B64>;
1871def S_NAND_SAVEEXEC_B64_vi : SOP1_Real_vi <0x25, S_NAND_SAVEEXEC_B64>;
1872def S_NOR_SAVEEXEC_B64_vi  : SOP1_Real_vi <0x26, S_NOR_SAVEEXEC_B64>;
1873def S_XNOR_SAVEEXEC_B64_vi : SOP1_Real_vi <0x27, S_XNOR_SAVEEXEC_B64>;
1874def S_QUADMASK_B32_vi      : SOP1_Real_vi <0x28, S_QUADMASK_B32>;
1875def S_QUADMASK_B64_vi      : SOP1_Real_vi <0x29, S_QUADMASK_B64>;
1876def S_MOVRELS_B32_vi       : SOP1_Real_vi <0x2a, S_MOVRELS_B32>;
1877def S_MOVRELS_B64_vi       : SOP1_Real_vi <0x2b, S_MOVRELS_B64>;
1878def S_MOVRELD_B32_vi       : SOP1_Real_vi <0x2c, S_MOVRELD_B32>;
1879def S_MOVRELD_B64_vi       : SOP1_Real_vi <0x2d, S_MOVRELD_B64>;
1880def S_CBRANCH_JOIN_vi      : SOP1_Real_vi <0x2e, S_CBRANCH_JOIN>;
1881def S_ABS_I32_vi           : SOP1_Real_vi <0x30, S_ABS_I32>;
1882def S_SET_GPR_IDX_IDX_vi   : SOP1_Real_vi <0x32, S_SET_GPR_IDX_IDX>;
1883
1884def S_ADD_U32_vi           : SOP2_Real_vi <0x00, S_ADD_U32>;
1885def S_ADD_I32_vi           : SOP2_Real_vi <0x02, S_ADD_I32>;
1886def S_SUB_U32_vi           : SOP2_Real_vi <0x01, S_SUB_U32>;
1887def S_SUB_I32_vi           : SOP2_Real_vi <0x03, S_SUB_I32>;
1888def S_ADDC_U32_vi          : SOP2_Real_vi <0x04, S_ADDC_U32>;
1889def S_SUBB_U32_vi          : SOP2_Real_vi <0x05, S_SUBB_U32>;
1890def S_MIN_I32_vi           : SOP2_Real_vi <0x06, S_MIN_I32>;
1891def S_MIN_U32_vi           : SOP2_Real_vi <0x07, S_MIN_U32>;
1892def S_MAX_I32_vi           : SOP2_Real_vi <0x08, S_MAX_I32>;
1893def S_MAX_U32_vi           : SOP2_Real_vi <0x09, S_MAX_U32>;
1894def S_CSELECT_B32_vi       : SOP2_Real_vi <0x0a, S_CSELECT_B32>;
1895def S_CSELECT_B64_vi       : SOP2_Real_vi <0x0b, S_CSELECT_B64>;
1896def S_AND_B32_vi           : SOP2_Real_vi <0x0c, S_AND_B32>;
1897def S_AND_B64_vi           : SOP2_Real_vi <0x0d, S_AND_B64>;
1898def S_OR_B32_vi            : SOP2_Real_vi <0x0e, S_OR_B32>;
1899def S_OR_B64_vi            : SOP2_Real_vi <0x0f, S_OR_B64>;
1900def S_XOR_B32_vi           : SOP2_Real_vi <0x10, S_XOR_B32>;
1901def S_XOR_B64_vi           : SOP2_Real_vi <0x11, S_XOR_B64>;
1902def S_ANDN2_B32_vi         : SOP2_Real_vi <0x12, S_ANDN2_B32>;
1903def S_ANDN2_B64_vi         : SOP2_Real_vi <0x13, S_ANDN2_B64>;
1904def S_ORN2_B32_vi          : SOP2_Real_vi <0x14, S_ORN2_B32>;
1905def S_ORN2_B64_vi          : SOP2_Real_vi <0x15, S_ORN2_B64>;
1906def S_NAND_B32_vi          : SOP2_Real_vi <0x16, S_NAND_B32>;
1907def S_NAND_B64_vi          : SOP2_Real_vi <0x17, S_NAND_B64>;
1908def S_NOR_B32_vi           : SOP2_Real_vi <0x18, S_NOR_B32>;
1909def S_NOR_B64_vi           : SOP2_Real_vi <0x19, S_NOR_B64>;
1910def S_XNOR_B32_vi          : SOP2_Real_vi <0x1a, S_XNOR_B32>;
1911def S_XNOR_B64_vi          : SOP2_Real_vi <0x1b, S_XNOR_B64>;
1912def S_LSHL_B32_vi          : SOP2_Real_vi <0x1c, S_LSHL_B32>;
1913def S_LSHL_B64_vi          : SOP2_Real_vi <0x1d, S_LSHL_B64>;
1914def S_LSHR_B32_vi          : SOP2_Real_vi <0x1e, S_LSHR_B32>;
1915def S_LSHR_B64_vi          : SOP2_Real_vi <0x1f, S_LSHR_B64>;
1916def S_ASHR_I32_vi          : SOP2_Real_vi <0x20, S_ASHR_I32>;
1917def S_ASHR_I64_vi          : SOP2_Real_vi <0x21, S_ASHR_I64>;
1918def S_BFM_B32_vi           : SOP2_Real_vi <0x22, S_BFM_B32>;
1919def S_BFM_B64_vi           : SOP2_Real_vi <0x23, S_BFM_B64>;
1920def S_MUL_I32_vi           : SOP2_Real_vi <0x24, S_MUL_I32>;
1921def S_BFE_U32_vi           : SOP2_Real_vi <0x25, S_BFE_U32>;
1922def S_BFE_I32_vi           : SOP2_Real_vi <0x26, S_BFE_I32>;
1923def S_BFE_U64_vi           : SOP2_Real_vi <0x27, S_BFE_U64>;
1924def S_BFE_I64_vi           : SOP2_Real_vi <0x28, S_BFE_I64>;
1925def S_CBRANCH_G_FORK_vi    : SOP2_Real_vi <0x29, S_CBRANCH_G_FORK>;
1926def S_ABSDIFF_I32_vi       : SOP2_Real_vi <0x2a, S_ABSDIFF_I32>;
1927def S_PACK_LL_B32_B16_vi   : SOP2_Real_vi <0x32, S_PACK_LL_B32_B16>;
1928def S_PACK_LH_B32_B16_vi   : SOP2_Real_vi <0x33, S_PACK_LH_B32_B16>;
1929def S_PACK_HH_B32_B16_vi   : SOP2_Real_vi <0x34, S_PACK_HH_B32_B16>;
1930def S_RFE_RESTORE_B64_vi   : SOP2_Real_vi <0x2b, S_RFE_RESTORE_B64>;
1931
1932def S_MOVK_I32_vi          : SOPK_Real_vi <0x00, S_MOVK_I32>;
1933def S_CMOVK_I32_vi         : SOPK_Real_vi <0x01, S_CMOVK_I32>;
1934def S_CMPK_EQ_I32_vi       : SOPK_Real_vi <0x02, S_CMPK_EQ_I32>;
1935def S_CMPK_LG_I32_vi       : SOPK_Real_vi <0x03, S_CMPK_LG_I32>;
1936def S_CMPK_GT_I32_vi       : SOPK_Real_vi <0x04, S_CMPK_GT_I32>;
1937def S_CMPK_GE_I32_vi       : SOPK_Real_vi <0x05, S_CMPK_GE_I32>;
1938def S_CMPK_LT_I32_vi       : SOPK_Real_vi <0x06, S_CMPK_LT_I32>;
1939def S_CMPK_LE_I32_vi       : SOPK_Real_vi <0x07, S_CMPK_LE_I32>;
1940def S_CMPK_EQ_U32_vi       : SOPK_Real_vi <0x08, S_CMPK_EQ_U32>;
1941def S_CMPK_LG_U32_vi       : SOPK_Real_vi <0x09, S_CMPK_LG_U32>;
1942def S_CMPK_GT_U32_vi       : SOPK_Real_vi <0x0A, S_CMPK_GT_U32>;
1943def S_CMPK_GE_U32_vi       : SOPK_Real_vi <0x0B, S_CMPK_GE_U32>;
1944def S_CMPK_LT_U32_vi       : SOPK_Real_vi <0x0C, S_CMPK_LT_U32>;
1945def S_CMPK_LE_U32_vi       : SOPK_Real_vi <0x0D, S_CMPK_LE_U32>;
1946def S_ADDK_I32_vi          : SOPK_Real_vi <0x0E, S_ADDK_I32>;
1947def S_MULK_I32_vi          : SOPK_Real_vi <0x0F, S_MULK_I32>;
1948def S_CBRANCH_I_FORK_vi    : SOPK_Real_vi <0x10, S_CBRANCH_I_FORK>;
1949def S_GETREG_B32_vi        : SOPK_Real_vi <0x11, S_GETREG_B32>;
1950def S_SETREG_B32_vi        : SOPK_Real_vi <0x12, S_SETREG_B32>;
1951//def S_GETREG_REGRD_B32_vi  : SOPK_Real_vi <0x13, S_GETREG_REGRD_B32>; // see pseudo for comments
1952def S_SETREG_IMM32_B32_vi  : SOPK_Real64<0x14, S_SETREG_IMM32_B32>,
1953                             Select_vi<S_SETREG_IMM32_B32.Mnemonic>;
1954
1955def S_CALL_B64_vi          : SOPK_Real_vi <0x15, S_CALL_B64>;
1956
1957//===----------------------------------------------------------------------===//
1958// SOP1 - GFX9.
1959//===----------------------------------------------------------------------===//
1960
1961def S_ANDN1_SAVEEXEC_B64_vi   : SOP1_Real_vi<0x33, S_ANDN1_SAVEEXEC_B64>;
1962def S_ORN1_SAVEEXEC_B64_vi    : SOP1_Real_vi<0x34, S_ORN1_SAVEEXEC_B64>;
1963def S_ANDN1_WREXEC_B64_vi     : SOP1_Real_vi<0x35, S_ANDN1_WREXEC_B64>;
1964def S_ANDN2_WREXEC_B64_vi     : SOP1_Real_vi<0x36, S_ANDN2_WREXEC_B64>;
1965def S_BITREPLICATE_B64_B32_vi : SOP1_Real_vi<0x37, S_BITREPLICATE_B64_B32>;
1966
1967//===----------------------------------------------------------------------===//
1968// SOP2 - GFX9.
1969//===----------------------------------------------------------------------===//
1970
1971def S_LSHL1_ADD_U32_vi   : SOP2_Real_vi<0x2e, S_LSHL1_ADD_U32>;
1972def S_LSHL2_ADD_U32_vi   : SOP2_Real_vi<0x2f, S_LSHL2_ADD_U32>;
1973def S_LSHL3_ADD_U32_vi   : SOP2_Real_vi<0x30, S_LSHL3_ADD_U32>;
1974def S_LSHL4_ADD_U32_vi   : SOP2_Real_vi<0x31, S_LSHL4_ADD_U32>;
1975def S_MUL_HI_U32_vi      : SOP2_Real_vi<0x2c, S_MUL_HI_U32>;
1976def S_MUL_HI_I32_vi      : SOP2_Real_vi<0x2d, S_MUL_HI_I32>;
1977