gn build: Extract git() and git_out() functions in sync script
[llvm-complete.git] / lib / Target / AMDGPU / SIInstrInfo.td
blob425105fde5402e72b8910fc663814ff38f3d18fe
1 //===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===//
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 //===----------------------------------------------------------------------===//
9 def isWave32 : Predicate<"Subtarget->getWavefrontSize() == 32">,
10   AssemblerPredicate <"FeatureWavefrontSize32">;
11 def isWave64 : Predicate<"Subtarget->getWavefrontSize() == 64">,
12   AssemblerPredicate <"FeatureWavefrontSize64">;
14 def DisableInst : Predicate <"false">, AssemblerPredicate<"FeatureDisable">;
16 class GCNPredicateControl : PredicateControl {
17   Predicate SIAssemblerPredicate = isGFX6GFX7;
18   Predicate VIAssemblerPredicate = isGFX8GFX9;
21 // Execpt for the NONE field, this must be kept in sync with the
22 // SIEncodingFamily enum in AMDGPUInstrInfo.cpp
23 def SIEncodingFamily {
24   int NONE = -1;
25   int SI = 0;
26   int VI = 1;
27   int SDWA = 2;
28   int SDWA9 = 3;
29   int GFX80 = 4;
30   int GFX9 = 5;
31   int GFX10 = 6;
32   int SDWA10 = 7;
35 //===----------------------------------------------------------------------===//
36 // SI DAG Nodes
37 //===----------------------------------------------------------------------===//
39 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPUnaryOp>;
41 def SIsbuffer_load : SDNode<"AMDGPUISD::SBUFFER_LOAD",
42   SDTypeProfile<1, 4, [SDTCisVT<1, v4i32>, SDTCisVT<2, i32>, SDTCisVT<3, i1>,
43                        SDTCisVT<4, i1>]>,
44   [SDNPMayLoad, SDNPMemOperand]
47 def SIds_ordered_count : SDNode<"AMDGPUISD::DS_ORDERED_COUNT",
48   SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVT<1, i32>, SDTCisVT<2, i16>]>,
49   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain, SDNPInGlue]
52 def SIatomic_inc : SDNode<"AMDGPUISD::ATOMIC_INC", SDTAtomic2,
53   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
56 def SIatomic_dec : SDNode<"AMDGPUISD::ATOMIC_DEC", SDTAtomic2,
57   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
60 def SDTAtomic2_f32 : SDTypeProfile<1, 2, [
61   SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1>
62 ]>;
64 def SIatomic_fmin : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMIN", SDTAtomic2_f32,
65   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
68 def SIatomic_fmax : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMAX", SDTAtomic2_f32,
69   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
72 // load_d16_{lo|hi} ptr, tied_input
73 def SIload_d16 : SDTypeProfile<1, 2, [
74   SDTCisPtrTy<1>,
75   SDTCisSameAs<0, 2>
76 ]>;
79 def SDTtbuffer_load : SDTypeProfile<1, 8,
80   [                     // vdata
81    SDTCisVT<1, v4i32>,  // rsrc
82    SDTCisVT<2, i32>,    // vindex(VGPR)
83    SDTCisVT<3, i32>,    // voffset(VGPR)
84    SDTCisVT<4, i32>,    // soffset(SGPR)
85    SDTCisVT<5, i32>,    // offset(imm)
86    SDTCisVT<6, i32>,    // format(imm)
87    SDTCisVT<7, i32>,    // cachecontrol(imm)
88    SDTCisVT<8, i1>      // idxen(imm)
89   ]>;
91 def SItbuffer_load :   SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT", SDTtbuffer_load,
92                               [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>;
93 def SItbuffer_load_d16 : SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT_D16",
94                                 SDTtbuffer_load,
95                                 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>;
97 def SDTtbuffer_store : SDTypeProfile<0, 9,
98     [                     // vdata
99      SDTCisVT<1, v4i32>,  // rsrc
100      SDTCisVT<2, i32>,    // vindex(VGPR)
101      SDTCisVT<3, i32>,    // voffset(VGPR)
102      SDTCisVT<4, i32>,    // soffset(SGPR)
103      SDTCisVT<5, i32>,    // offset(imm)
104      SDTCisVT<6, i32>,    // format(imm)
105      SDTCisVT<7, i32>,    // cachecontrol(imm)
106      SDTCisVT<8, i1>      // idxen(imm)
107     ]>;
109 def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT", SDTtbuffer_store,
110                              [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
111 def SItbuffer_store_d16 : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT_D16",
112                                 SDTtbuffer_store,
113                                 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
115 def SDTBufferLoad : SDTypeProfile<1, 7,
116     [                    // vdata
117      SDTCisVT<1, v4i32>, // rsrc
118      SDTCisVT<2, i32>,   // vindex(VGPR)
119      SDTCisVT<3, i32>,   // voffset(VGPR)
120      SDTCisVT<4, i32>,   // soffset(SGPR)
121      SDTCisVT<5, i32>,   // offset(imm)
122      SDTCisVT<6, i32>,   // cachepolicy(imm)
123      SDTCisVT<7, i1>]>;  // idxen(imm)
125 def SIbuffer_load : SDNode <"AMDGPUISD::BUFFER_LOAD", SDTBufferLoad,
126                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
127 def SIbuffer_load_ubyte : SDNode <"AMDGPUISD::BUFFER_LOAD_UBYTE", SDTBufferLoad,
128                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
129 def SIbuffer_load_ushort : SDNode <"AMDGPUISD::BUFFER_LOAD_USHORT", SDTBufferLoad,
130                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
131 def SIbuffer_load_byte : SDNode <"AMDGPUISD::BUFFER_LOAD_BYTE", SDTBufferLoad,
132                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
133 def SIbuffer_load_short: SDNode <"AMDGPUISD::BUFFER_LOAD_SHORT", SDTBufferLoad,
134                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
135 def SIbuffer_load_format : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT", SDTBufferLoad,
136                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
137 def SIbuffer_load_format_d16 : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT_D16",
138                                 SDTBufferLoad,
139                                 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
141 def SDTBufferStore : SDTypeProfile<0, 8,
142     [                    // vdata
143      SDTCisVT<1, v4i32>, // rsrc
144      SDTCisVT<2, i32>,   // vindex(VGPR)
145      SDTCisVT<3, i32>,   // voffset(VGPR)
146      SDTCisVT<4, i32>,   // soffset(SGPR)
147      SDTCisVT<5, i32>,   // offset(imm)
148      SDTCisVT<6, i32>,   // cachepolicy(imm)
149      SDTCisVT<7, i1>]>;  // idxen(imm)
151 def SIbuffer_store : SDNode <"AMDGPUISD::BUFFER_STORE", SDTBufferStore,
152                              [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
153 def SIbuffer_store_byte: SDNode <"AMDGPUISD::BUFFER_STORE_BYTE",
154                          SDTBufferStore,
155                          [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
156 def SIbuffer_store_short : SDNode <"AMDGPUISD::BUFFER_STORE_SHORT",
157                            SDTBufferStore,
158                            [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
159 def SIbuffer_store_format : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT",
160                             SDTBufferStore,
161                             [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
162 def SIbuffer_store_format_d16 : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT_D16",
163                             SDTBufferStore,
164                             [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
166 class SDBufferAtomic<string opcode> : SDNode <opcode,
167   SDTypeProfile<1, 8,
168        [SDTCisVT<2, v4i32>, // rsrc
169        SDTCisVT<3, i32>,   // vindex(VGPR)
170        SDTCisVT<4, i32>,   // voffset(VGPR)
171        SDTCisVT<5, i32>,   // soffset(SGPR)
172        SDTCisVT<6, i32>,   // offset(imm)
173        SDTCisVT<7, i32>,   // cachepolicy(imm)
174        SDTCisVT<8, i1>]>,  // idxen(imm)
175   [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
178 class SDBufferAtomicNoRtn<string opcode, ValueType ty> : SDNode <opcode,
179   SDTypeProfile<0, 8,
180       [SDTCisVT<0, ty>,    // vdata
181        SDTCisVT<1, v4i32>, // rsrc
182        SDTCisVT<2, i32>,   // vindex(VGPR)
183        SDTCisVT<3, i32>,   // voffset(VGPR)
184        SDTCisVT<4, i32>,   // soffset(SGPR)
185        SDTCisVT<5, i32>,   // offset(imm)
186        SDTCisVT<6, i32>,   // cachepolicy(imm)
187        SDTCisVT<7, i1>]>,  // idxen(imm)
188   [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
191 def SIbuffer_atomic_swap : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SWAP">;
192 def SIbuffer_atomic_add : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_ADD">;
193 def SIbuffer_atomic_sub : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SUB">;
194 def SIbuffer_atomic_smin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMIN">;
195 def SIbuffer_atomic_umin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMIN">;
196 def SIbuffer_atomic_smax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMAX">;
197 def SIbuffer_atomic_umax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMAX">;
198 def SIbuffer_atomic_and : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_AND">;
199 def SIbuffer_atomic_or : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_OR">;
200 def SIbuffer_atomic_xor : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_XOR">;
201 def SIbuffer_atomic_inc : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_INC">;
202 def SIbuffer_atomic_dec : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_DEC">;
203 def SIbuffer_atomic_fadd : SDBufferAtomicNoRtn <"AMDGPUISD::BUFFER_ATOMIC_FADD", f32>;
204 def SIbuffer_atomic_pk_fadd : SDBufferAtomicNoRtn <"AMDGPUISD::BUFFER_ATOMIC_PK_FADD", v2f16>;
206 def SIbuffer_atomic_cmpswap : SDNode <"AMDGPUISD::BUFFER_ATOMIC_CMPSWAP",
207   SDTypeProfile<1, 9,
208     [SDTCisVT<0, i32>,   // dst
209      SDTCisVT<1, i32>,   // src
210      SDTCisVT<2, i32>,   // cmp
211      SDTCisVT<3, v4i32>, // rsrc
212      SDTCisVT<4, i32>,   // vindex(VGPR)
213      SDTCisVT<5, i32>,   // voffset(VGPR)
214      SDTCisVT<6, i32>,   // soffset(SGPR)
215      SDTCisVT<7, i32>,   // offset(imm)
216      SDTCisVT<8, i32>,   // cachepolicy(imm)
217      SDTCisVT<9, i1>]>,  // idxen(imm)
218   [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
221 class SDGlobalAtomicNoRtn<string opcode, ValueType ty> : SDNode <opcode,
222   SDTypeProfile<0, 2,
223       [SDTCisPtrTy<0>,     // vaddr
224        SDTCisVT<1, ty>]>,  // vdata
225   [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
228 def SIglobal_atomic_fadd    : SDGlobalAtomicNoRtn <"AMDGPUISD::ATOMIC_FADD", f32>;
229 def SIglobal_atomic_pk_fadd : SDGlobalAtomicNoRtn <"AMDGPUISD::ATOMIC_PK_FADD", v2f16>;
231 def SIpc_add_rel_offset : SDNode<"AMDGPUISD::PC_ADD_REL_OFFSET",
232   SDTypeProfile<1, 2, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>, SDTCisSameAs<0,2>]>
235 def SIlds : SDNode<"AMDGPUISD::LDS",
236   SDTypeProfile<1, 1, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>]>
239 def SIload_d16_lo : SDNode<"AMDGPUISD::LOAD_D16_LO",
240   SIload_d16,
241   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
244 def SIload_d16_lo_u8 : SDNode<"AMDGPUISD::LOAD_D16_LO_U8",
245   SIload_d16,
246   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
249 def SIload_d16_lo_i8 : SDNode<"AMDGPUISD::LOAD_D16_LO_I8",
250   SIload_d16,
251   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
254 def SIload_d16_hi : SDNode<"AMDGPUISD::LOAD_D16_HI",
255   SIload_d16,
256   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
259 def SIload_d16_hi_u8 : SDNode<"AMDGPUISD::LOAD_D16_HI_U8",
260   SIload_d16,
261   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
264 def SIload_d16_hi_i8 : SDNode<"AMDGPUISD::LOAD_D16_HI_I8",
265   SIload_d16,
266   [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]
269 def SIdenorm_mode : SDNode<"AMDGPUISD::DENORM_MODE",
270   SDTypeProfile<0 ,1, [SDTCisInt<0>]>,
271   [SDNPHasChain, SDNPSideEffect, SDNPOptInGlue, SDNPOutGlue]
274 //===----------------------------------------------------------------------===//
275 // ValueType helpers
276 //===----------------------------------------------------------------------===//
278 // Returns 1 if the source arguments have modifiers, 0 if they do not.
279 // XXX - do f16 instructions?
280 class isFloatType<ValueType SrcVT> {
281   bit ret =
282     !if(!eq(SrcVT.Value, f16.Value), 1,
283     !if(!eq(SrcVT.Value, f32.Value), 1,
284     !if(!eq(SrcVT.Value, f64.Value), 1,
285     !if(!eq(SrcVT.Value, v2f16.Value), 1,
286     !if(!eq(SrcVT.Value, v4f16.Value), 1,
287     0)))));
290 class isIntType<ValueType SrcVT> {
291   bit ret =
292     !if(!eq(SrcVT.Value, i16.Value), 1,
293     !if(!eq(SrcVT.Value, i32.Value), 1,
294     !if(!eq(SrcVT.Value, i64.Value), 1,
295     0)));
298 class isPackedType<ValueType SrcVT> {
299   bit ret =
300     !if(!eq(SrcVT.Value, v2i16.Value), 1,
301       !if(!eq(SrcVT.Value, v2f16.Value), 1,
302         !if(!eq(SrcVT.Value, v4f16.Value), 1, 0)
303     ));
306 //===----------------------------------------------------------------------===//
307 // PatFrags for global memory operations
308 //===----------------------------------------------------------------------===//
310 foreach as = [ "global", "flat", "constant", "local", "private", "region" ] in {
311 let AddressSpaces = !cast<AddressSpaceList>("LoadAddress_"#as).AddrSpaces in {
314 defm atomic_inc_#as : binary_atomic_op<SIatomic_inc>;
315 defm atomic_dec_#as : binary_atomic_op<SIatomic_dec>;
316 defm atomic_load_fmin_#as : binary_atomic_op<SIatomic_fmin, 0>;
317 defm atomic_load_fmax_#as : binary_atomic_op<SIatomic_fmax, 0>;
320 } // End let AddressSpaces = ...
321 } // End foreach AddrSpace
323 def atomic_fadd_global_noret : PatFrag<
324   (ops node:$ptr, node:$value),
325   (SIglobal_atomic_fadd node:$ptr, node:$value)> {
326   // FIXME: Move this
327   let MemoryVT = f32;
328   let IsAtomic = 1;
329   let AddressSpaces = StoreAddress_global.AddrSpaces;
332 def atomic_pk_fadd_global_noret : PatFrag<
333     (ops node:$ptr, node:$value),
334     (SIglobal_atomic_pk_fadd node:$ptr, node:$value)> {
335   // FIXME: Move this
336   let MemoryVT = v2f16;
337   let IsAtomic = 1;
338   let AddressSpaces = StoreAddress_global.AddrSpaces;
341 //===----------------------------------------------------------------------===//
342 // SDNodes PatFrags for loads/stores with a glue input.
343 // This is for SDNodes and PatFrag for local loads and stores to
344 // enable s_mov_b32 m0, -1 to be glued to the memory instructions.
346 // These mirror the regular load/store PatFrags and rely on special
347 // processing during Select() to add the glued copy.
349 //===----------------------------------------------------------------------===//
351 def AMDGPUld_glue : SDNode <"ISD::LOAD", SDTLoad,
352   [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
355 def AMDGPUatomic_ld_glue : SDNode <"ISD::ATOMIC_LOAD", SDTAtomicLoad,
356   [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
359 def unindexedload_glue : PatFrag <(ops node:$ptr), (AMDGPUld_glue node:$ptr)> {
360   let IsLoad = 1;
361   let IsUnindexed = 1;
364 def load_glue : PatFrag <(ops node:$ptr), (unindexedload_glue node:$ptr)> {
365   let IsLoad = 1;
366   let IsNonExtLoad = 1;
369 def atomic_load_32_glue : PatFrag<(ops node:$ptr),
370   (AMDGPUatomic_ld_glue node:$ptr)> {
371   let IsAtomic = 1;
372   let MemoryVT = i32;
375 def atomic_load_64_glue : PatFrag<(ops node:$ptr),
376   (AMDGPUatomic_ld_glue node:$ptr)> {
377   let IsAtomic = 1;
378   let MemoryVT = i64;
381 def extload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> {
382   let IsLoad = 1;
383   let IsAnyExtLoad = 1;
386 def sextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> {
387   let IsLoad = 1;
388   let IsSignExtLoad = 1;
391 def zextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr)> {
392   let IsLoad = 1;
393   let IsZeroExtLoad = 1;
396 def extloadi8_glue : PatFrag<(ops node:$ptr), (extload_glue node:$ptr)> {
397   let IsLoad = 1;
398   let MemoryVT = i8;
401 def zextloadi8_glue : PatFrag<(ops node:$ptr), (zextload_glue node:$ptr)> {
402   let IsLoad = 1;
403   let MemoryVT = i8;
406 def extloadi16_glue : PatFrag<(ops node:$ptr), (extload_glue node:$ptr)> {
407   let IsLoad = 1;
408   let MemoryVT = i16;
411 def zextloadi16_glue : PatFrag<(ops node:$ptr), (zextload_glue node:$ptr)> {
412   let IsLoad = 1;
413   let MemoryVT = i16;
416 def sextloadi8_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr)> {
417   let IsLoad = 1;
418   let MemoryVT = i8;
421 def sextloadi16_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr)> {
422   let IsLoad = 1;
423   let MemoryVT = i16;
427 let IsLoad = 1, AddressSpaces = LoadAddress_local.AddrSpaces in {
428 def load_local_m0 : PatFrag<(ops node:$ptr), (load_glue node:$ptr)> {
429   let IsNonExtLoad = 1;
432 let MemoryVT = i8 in {
433 def extloadi8_local_m0 : PatFrag<(ops node:$ptr), (extloadi8_glue node:$ptr)>;
434 def sextloadi8_local_m0 : PatFrag<(ops node:$ptr), (sextloadi8_glue node:$ptr)>;
435 def zextloadi8_local_m0 : PatFrag<(ops node:$ptr), (zextloadi8_glue node:$ptr)>;
438 let MemoryVT = i16 in {
439 def extloadi16_local_m0 : PatFrag<(ops node:$ptr), (extloadi16_glue node:$ptr)>;
440 def sextloadi16_local_m0 : PatFrag<(ops node:$ptr), (sextloadi16_glue node:$ptr)>;
441 def zextloadi16_local_m0 : PatFrag<(ops node:$ptr), (zextloadi16_glue node:$ptr)>;
444 def load_align8_local_m0 : LoadFrag <load_glue>, LocalAddress {
445   let MinAlignment = 8;
446   let IsNonExtLoad = 1;
448 def load_align16_local_m0 : LoadFrag <load_glue>, LocalAddress {
449   let MinAlignment = 16;
450   let IsNonExtLoad = 1;
453 } // End IsLoad = 1
455 def atomic_load_32_local_m0 : LoadFrag<atomic_load_32_glue>, LocalAddress;
456 def atomic_load_64_local_m0 : LoadFrag<atomic_load_64_glue>, LocalAddress;
459 def AMDGPUst_glue : SDNode <"ISD::STORE", SDTStore,
460   [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue]
463 def AMDGPUatomic_st_glue : SDNode <"ISD::ATOMIC_STORE", SDTAtomicStore,
464   [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue]
467 def atomic_store_glue : PatFrag<(ops node:$ptr, node:$val),
468   (AMDGPUatomic_st_glue node:$ptr, node:$val)> {
471 def unindexedstore_glue : PatFrag<(ops node:$val, node:$ptr),
472                                    (AMDGPUst_glue node:$val, node:$ptr)> {
473   let IsStore = 1;
474   let IsUnindexed = 1;
477 def store_glue : PatFrag<(ops node:$val, node:$ptr),
478                          (unindexedstore_glue node:$val, node:$ptr)> {
479   let IsStore = 1;
480   let IsTruncStore = 0;
483 def truncstore_glue : PatFrag<(ops node:$val, node:$ptr),
484   (unindexedstore_glue node:$val, node:$ptr)> {
485   let IsStore = 1;
486   let IsTruncStore = 1;
489 def truncstorei8_glue : PatFrag<(ops node:$val, node:$ptr),
490                            (truncstore_glue node:$val, node:$ptr)> {
491   let IsStore = 1;
492   let MemoryVT = i8;
495 def truncstorei16_glue : PatFrag<(ops node:$val, node:$ptr),
496                            (truncstore_glue node:$val, node:$ptr)> {
497   let IsStore = 1;
498   let MemoryVT = i16;
501 let IsStore = 1, AddressSpaces = StoreAddress_local.AddrSpaces in {
502 def store_glue_align8 : PatFrag<(ops node:$val, node:$ptr),
503                                 (store_glue node:$val, node:$ptr)>, Aligned<8>;
504 def store_glue_align16 : PatFrag<(ops node:$val, node:$ptr),
505                                 (store_glue node:$val, node:$ptr)>, Aligned<16>;
507 def store_local_m0 : PatFrag<(ops node:$val, node:$ptr),
508                              (unindexedstore_glue node:$val, node:$ptr)> {
509   let IsStore = 1;
510   let IsTruncStore = 0;
513 def truncstorei8_local_m0 : PatFrag<(ops node:$val, node:$ptr),
514                                     (unindexedstore_glue node:$val, node:$ptr)> {
515   let IsStore = 1;
516   let MemoryVT = i8;
520 def truncstorei16_local_m0 : PatFrag<(ops node:$val, node:$ptr),
521                                     (unindexedstore_glue node:$val, node:$ptr)> {
522   let IsStore = 1;
523   let MemoryVT = i16;
526 // FIXME: atomic store doesn't work.
527 def atomic_store_local_m0 : StoreFrag<AMDGPUatomic_st_glue>, LocalAddress;
528 def store_align8_local_m0 : StoreFrag<store_glue_align8>, LocalAddress {
529   let IsTruncStore = 0;
532 def store_align16_local_m0 : StoreFrag<store_glue_align16>, LocalAddress {
533   let IsTruncStore = 0;
537 def si_setcc_uniform : PatFrag <
538   (ops node:$lhs, node:$rhs, node:$cond),
539   (setcc node:$lhs, node:$rhs, node:$cond), [{
540   for (SDNode *Use : N->uses()) {
541     if (Use->isMachineOpcode() || Use->getOpcode() != ISD::CopyToReg)
542       return false;
544     unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
545     if (Reg != AMDGPU::SCC)
546       return false;
547   }
548   return true;
549 }]>;
551 //===----------------------------------------------------------------------===//
552 // SDNodes PatFrags for d16 loads
553 //===----------------------------------------------------------------------===//
555 class LoadD16Frag <SDPatternOperator op> : PatFrag<(ops node:$ptr, node:$tied_in), (op node:$ptr, node:$tied_in)>;
556 class LocalLoadD16 <SDPatternOperator op> : LoadD16Frag <op>, LocalAddress;
557 class GlobalLoadD16 <SDPatternOperator op> : LoadD16Frag <op>, GlobalLoadAddress;
558 class PrivateLoadD16 <SDPatternOperator op> : LoadD16Frag <op>, PrivateAddress;
559 class FlatLoadD16 <SDPatternOperator op> : LoadD16Frag <op>, FlatLoadAddress;
561 def load_d16_hi_local : LocalLoadD16 <SIload_d16_hi>;
562 def az_extloadi8_d16_hi_local : LocalLoadD16 <SIload_d16_hi_u8>;
563 def sextloadi8_d16_hi_local : LocalLoadD16 <SIload_d16_hi_i8>;
565 def load_d16_hi_global : GlobalLoadD16 <SIload_d16_hi>;
566 def az_extloadi8_d16_hi_global : GlobalLoadD16 <SIload_d16_hi_u8>;
567 def sextloadi8_d16_hi_global : GlobalLoadD16 <SIload_d16_hi_i8>;
569 def load_d16_hi_private : PrivateLoadD16 <SIload_d16_hi>;
570 def az_extloadi8_d16_hi_private : PrivateLoadD16 <SIload_d16_hi_u8>;
571 def sextloadi8_d16_hi_private : PrivateLoadD16 <SIload_d16_hi_i8>;
573 def load_d16_hi_flat : FlatLoadD16 <SIload_d16_hi>;
574 def az_extloadi8_d16_hi_flat : FlatLoadD16 <SIload_d16_hi_u8>;
575 def sextloadi8_d16_hi_flat : FlatLoadD16 <SIload_d16_hi_i8>;
578 def load_d16_lo_local : LocalLoadD16 <SIload_d16_lo>;
579 def az_extloadi8_d16_lo_local : LocalLoadD16 <SIload_d16_lo_u8>;
580 def sextloadi8_d16_lo_local : LocalLoadD16 <SIload_d16_lo_i8>;
582 def load_d16_lo_global : GlobalLoadD16 <SIload_d16_lo>;
583 def az_extloadi8_d16_lo_global : GlobalLoadD16 <SIload_d16_lo_u8>;
584 def sextloadi8_d16_lo_global : GlobalLoadD16 <SIload_d16_lo_i8>;
586 def load_d16_lo_private : PrivateLoadD16 <SIload_d16_lo>;
587 def az_extloadi8_d16_lo_private : PrivateLoadD16 <SIload_d16_lo_u8>;
588 def sextloadi8_d16_lo_private : PrivateLoadD16 <SIload_d16_lo_i8>;
590 def load_d16_lo_flat : FlatLoadD16 <SIload_d16_lo>;
591 def az_extloadi8_d16_lo_flat : FlatLoadD16 <SIload_d16_lo_u8>;
592 def sextloadi8_d16_lo_flat : FlatLoadD16 <SIload_d16_lo_i8>;
596 def lshr_rev : PatFrag <
597   (ops node:$src1, node:$src0),
598   (srl $src0, $src1)
601 def ashr_rev : PatFrag <
602   (ops node:$src1, node:$src0),
603   (sra $src0, $src1)
606 def lshl_rev : PatFrag <
607   (ops node:$src1, node:$src0),
608   (shl $src0, $src1)
611 multiclass SIAtomicM0Glue2 <string op_name, bit is_amdgpu = 0,
612                             SDTypeProfile tc = SDTAtomic2,
613                             bit IsInt = 1> {
615   def _glue : SDNode <
616     !if(is_amdgpu, "AMDGPUISD", "ISD")#"::ATOMIC_"#op_name, tc,
617     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
618   >;
620   let AddressSpaces = StoreAddress_local.AddrSpaces in {
621     defm _local_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>;
622   }
624   let AddressSpaces = StoreAddress_region.AddrSpaces in {
625     defm _region_m0 : binary_atomic_op <!cast<SDNode>(NAME#"_glue"), IsInt>;
626   }
629 defm atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">;
630 defm atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">;
631 defm atomic_inc : SIAtomicM0Glue2 <"INC", 1>;
632 defm atomic_dec : SIAtomicM0Glue2 <"DEC", 1>;
633 defm atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">;
634 defm atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">;
635 defm atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">;
636 defm atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">;
637 defm atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">;
638 defm atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">;
639 defm atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">;
640 defm atomic_swap : SIAtomicM0Glue2 <"SWAP">;
641 defm atomic_load_fadd : SIAtomicM0Glue2 <"LOAD_FADD", 0, SDTAtomic2_f32, 0>;
642 defm atomic_load_fmin : SIAtomicM0Glue2 <"LOAD_FMIN", 1, SDTAtomic2_f32, 0>;
643 defm atomic_load_fmax : SIAtomicM0Glue2 <"LOAD_FMAX", 1, SDTAtomic2_f32, 0>;
645 def as_i1imm : SDNodeXForm<imm, [{
646   return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1);
647 }]>;
649 def as_i8imm : SDNodeXForm<imm, [{
650   return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8);
651 }]>;
653 def as_i16imm : SDNodeXForm<imm, [{
654   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16);
655 }]>;
657 def as_i32imm: SDNodeXForm<imm, [{
658   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
659 }]>;
661 def as_i64imm: SDNodeXForm<imm, [{
662   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64);
663 }]>;
665 def cond_as_i32imm: SDNodeXForm<cond, [{
666   return CurDAG->getTargetConstant(N->get(), SDLoc(N), MVT::i32);
667 }]>;
669 // Copied from the AArch64 backend:
670 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
671 return CurDAG->getTargetConstant(
672   N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
673 }]>;
675 def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{
676   auto FI = cast<FrameIndexSDNode>(N);
677   return CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
678 }]>;
680 // Copied from the AArch64 backend:
681 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
682 return CurDAG->getTargetConstant(
683   N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
684 }]>;
686 class bitextract_imm<int bitnum> : SDNodeXForm<imm, [{
687   uint64_t Imm = N->getZExtValue();
688   unsigned Bit = (Imm >> }] # bitnum # [{ ) & 1;
689   return CurDAG->getTargetConstant(Bit, SDLoc(N), MVT::i1);
690 }]>;
692 def SIMM16bit : ImmLeaf <i32,
693   [{return isInt<16>(Imm);}]
696 def UIMM16bit : ImmLeaf <i32,
697   [{return isUInt<16>(Imm);}]
700 class InlineImm <ValueType vt> : PatLeaf <(vt imm), [{
701   return isInlineImmediate(N);
702 }]>;
704 class InlineFPImm <ValueType vt> : PatLeaf <(vt fpimm), [{
705   return isInlineImmediate(N);
706 }]>;
708 class VGPRImm <dag frag> : PatLeaf<frag, [{
709   return isVGPRImm(N);
710 }]>;
712 def NegateImm : SDNodeXForm<imm, [{
713   return CurDAG->getConstant(-N->getSExtValue(), SDLoc(N), MVT::i32);
714 }]>;
716 // TODO: When FP inline imm values work?
717 def NegSubInlineConst32 : ImmLeaf<i32, [{
718   return Imm < -16 && Imm >= -64;
719 }], NegateImm>;
721 def NegSubInlineConst16 : ImmLeaf<i16, [{
722   return Imm < -16 && Imm >= -64;
723 }], NegateImm>;
725 def ShiftAmt32Imm : PatLeaf <(imm), [{
726   return N->getZExtValue() < 32;
727 }]>;
729 def getNegV2I16Imm : SDNodeXForm<build_vector, [{
730   return SDValue(packNegConstantV2I16(N, *CurDAG), 0);
731 }]>;
733 def NegSubInlineConstV216 : PatLeaf<(build_vector), [{
734   assert(N->getNumOperands() == 2);
735   assert(N->getOperand(0).getValueType().getSizeInBits() == 16);
736   SDValue Src0 = N->getOperand(0);
737   SDValue Src1 = N->getOperand(1);
738   if (Src0 == Src1)
739     return isNegInlineImmediate(Src0.getNode());
741   return (isNullConstantOrUndef(Src0) && isNegInlineImmediate(Src1.getNode())) ||
742          (isNullConstantOrUndef(Src1) && isNegInlineImmediate(Src0.getNode()));
743 }], getNegV2I16Imm>;
745 //===----------------------------------------------------------------------===//
746 // Custom Operands
747 //===----------------------------------------------------------------------===//
749 def SoppBrTarget : AsmOperandClass {
750   let Name = "SoppBrTarget";
751   let ParserMethod = "parseSOppBrTarget";
754 def sopp_brtarget : Operand<OtherVT> {
755   let EncoderMethod = "getSOPPBrEncoding";
756   let DecoderMethod = "decodeSoppBrTarget";
757   let OperandType = "OPERAND_PCREL";
758   let ParserMatchClass = SoppBrTarget;
761 def si_ga : Operand<iPTR>;
763 def InterpSlotMatchClass : AsmOperandClass {
764   let Name = "InterpSlot";
765   let PredicateMethod = "isInterpSlot";
766   let ParserMethod = "parseInterpSlot";
767   let RenderMethod = "addImmOperands";
770 def InterpSlot : Operand<i32> {
771   let PrintMethod = "printInterpSlot";
772   let ParserMatchClass = InterpSlotMatchClass;
773   let OperandType = "OPERAND_IMMEDIATE";
776 def AttrMatchClass : AsmOperandClass {
777   let Name = "Attr";
778   let PredicateMethod = "isInterpAttr";
779   let ParserMethod = "parseInterpAttr";
780   let RenderMethod = "addImmOperands";
783 // It appears to be necessary to create a separate operand for this to
784 // be able to parse attr<num> with no space.
785 def Attr : Operand<i32> {
786   let PrintMethod = "printInterpAttr";
787   let ParserMatchClass = AttrMatchClass;
788   let OperandType = "OPERAND_IMMEDIATE";
791 def AttrChanMatchClass : AsmOperandClass {
792   let Name = "AttrChan";
793   let PredicateMethod = "isAttrChan";
794   let RenderMethod = "addImmOperands";
797 def AttrChan : Operand<i32> {
798   let PrintMethod = "printInterpAttrChan";
799   let ParserMatchClass = AttrChanMatchClass;
800   let OperandType = "OPERAND_IMMEDIATE";
803 def SendMsgMatchClass : AsmOperandClass {
804   let Name = "SendMsg";
805   let PredicateMethod = "isSendMsg";
806   let ParserMethod = "parseSendMsgOp";
807   let RenderMethod = "addImmOperands";
810 def SwizzleMatchClass : AsmOperandClass {
811   let Name = "Swizzle";
812   let PredicateMethod = "isSwizzle";
813   let ParserMethod = "parseSwizzleOp";
814   let RenderMethod = "addImmOperands";
815   let IsOptional = 1;
818 def EndpgmMatchClass : AsmOperandClass {
819   let Name = "EndpgmImm";
820   let PredicateMethod = "isEndpgm";
821   let ParserMethod = "parseEndpgmOp";
822   let RenderMethod = "addImmOperands";
823   let IsOptional = 1;
826 def ExpTgtMatchClass : AsmOperandClass {
827   let Name = "ExpTgt";
828   let PredicateMethod = "isExpTgt";
829   let ParserMethod = "parseExpTgt";
830   let RenderMethod = "printExpTgt";
833 def SendMsgImm : Operand<i32> {
834   let PrintMethod = "printSendMsg";
835   let ParserMatchClass = SendMsgMatchClass;
838 def SwizzleImm : Operand<i16> {
839   let PrintMethod = "printSwizzle";
840   let ParserMatchClass = SwizzleMatchClass;
843 def EndpgmImm : Operand<i16> {
844   let PrintMethod = "printEndpgm";
845   let ParserMatchClass = EndpgmMatchClass;
848 def SWaitMatchClass : AsmOperandClass {
849   let Name = "SWaitCnt";
850   let RenderMethod = "addImmOperands";
851   let ParserMethod = "parseSWaitCntOps";
854 def VReg32OrOffClass : AsmOperandClass {
855   let Name = "VReg32OrOff";
856   let ParserMethod = "parseVReg32OrOff";
859 def WAIT_FLAG : Operand <i32> {
860   let ParserMatchClass = SWaitMatchClass;
861   let PrintMethod = "printWaitFlag";
862   let OperandType = "OPERAND_IMMEDIATE";
865 include "SIInstrFormats.td"
866 include "VIInstrFormats.td"
868 def BoolReg : AsmOperandClass {
869   let Name = "BoolReg";
870   let ParserMethod = "parseBoolReg";
871   let RenderMethod = "addRegOperands";
874 class BoolRC : RegisterOperand<SReg_1> {
875   let ParserMatchClass = BoolReg;
876   let DecoderMethod = "decodeBoolReg";
879 def SSrc_i1 : RegisterOperand<SReg_1_XEXEC> {
880   let ParserMatchClass = BoolReg;
881   let DecoderMethod = "decodeBoolReg";
884 def VOPDstS64orS32 : BoolRC {
885   let PrintMethod = "printVOPDst";
888 // SCSrc_i1 is the operand for pseudo instructions only.
889 // Boolean immeadiates shall not be exposed to codegen instructions.
890 def SCSrc_i1 : RegisterOperand<SReg_1_XEXEC> {
891   let OperandNamespace = "AMDGPU";
892   let OperandType = "OPERAND_REG_IMM_INT32";
893   let ParserMatchClass = BoolReg;
894   let DecoderMethod = "decodeBoolReg";
897 // ===----------------------------------------------------------------------===//
898 // ExpSrc* Special cases for exp src operands which are printed as
899 // "off" depending on en operand.
900 // ===----------------------------------------------------------------------===//
902 def ExpSrc0 : RegisterOperand<VGPR_32> {
903   let PrintMethod = "printExpSrc0";
904   let ParserMatchClass = VReg32OrOffClass;
907 def ExpSrc1 : RegisterOperand<VGPR_32> {
908   let PrintMethod = "printExpSrc1";
909   let ParserMatchClass = VReg32OrOffClass;
912 def ExpSrc2 : RegisterOperand<VGPR_32> {
913   let PrintMethod = "printExpSrc2";
914   let ParserMatchClass = VReg32OrOffClass;
917 def ExpSrc3 : RegisterOperand<VGPR_32> {
918   let PrintMethod = "printExpSrc3";
919   let ParserMatchClass = VReg32OrOffClass;
922 class SDWASrc<ValueType vt> : RegisterOperand<VS_32> {
923   let OperandNamespace = "AMDGPU";
924   string Type = !if(isFloatType<vt>.ret, "FP", "INT");
925   let OperandType = "OPERAND_REG_INLINE_C_"#Type#vt.Size;
926   let DecoderMethod = "decodeSDWASrc"#vt.Size;
927   let EncoderMethod = "getSDWASrcEncoding";
930 def SDWASrc_i32 : SDWASrc<i32>;
931 def SDWASrc_i16 : SDWASrc<i16>;
932 def SDWASrc_f32 : SDWASrc<f32>;
933 def SDWASrc_f16 : SDWASrc<f16>;
935 def SDWAVopcDst : BoolRC {
936   let OperandNamespace = "AMDGPU";
937   let OperandType = "OPERAND_SDWA_VOPC_DST";
938   let EncoderMethod = "getSDWAVopcDstEncoding";
939   let DecoderMethod = "decodeSDWAVopcDst";
940   let PrintMethod = "printVOPDst";
943 class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass {
944   let Name = "Imm"#CName;
945   let PredicateMethod = "is"#CName;
946   let ParserMethod = !if(Optional, "parseOptionalOperand", "parse"#CName);
947   let RenderMethod = "addImmOperands";
948   let IsOptional = Optional;
949   let DefaultMethod = !if(Optional, "default"#CName, ?);
952 class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> {
953   let PrintMethod = "print"#Name;
954   let ParserMatchClass = MatchClass;
957 class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> {
958   let PrintMethod = "print"#Name;
959   let ParserMatchClass = MatchClass;
962 class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> {
963   let PrintMethod = "print"#Name;
964   let ParserMatchClass = MatchClass;
967 class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
968   let PrintMethod = "print"#Name;
969   let ParserMatchClass = MatchClass;
972 class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> :
973   OperandWithDefaultOps<i32, (ops (i32 0))> {
974   let PrintMethod = "print"#Name;
975   let ParserMatchClass = MatchClass;
978 let OperandType = "OPERAND_IMMEDIATE" in {
980 def offen : NamedOperandBit<"Offen", NamedMatchClass<"Offen">>;
981 def idxen : NamedOperandBit<"Idxen", NamedMatchClass<"Idxen">>;
982 def addr64 : NamedOperandBit<"Addr64", NamedMatchClass<"Addr64">>;
984 def flat_offset : NamedOperandU16<"FlatOffset", NamedMatchClass<"FlatOffset">>;
985 def offset : NamedOperandU16<"Offset", NamedMatchClass<"Offset">>;
986 def offset0 : NamedOperandU8<"Offset0", NamedMatchClass<"Offset0">>;
987 def offset1 : NamedOperandU8<"Offset1", NamedMatchClass<"Offset1">>;
989 def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>;
991 def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>;
992 def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>;
993 def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>;
995 def DLC : NamedOperandBit<"DLC", NamedMatchClass<"DLC">>;
996 def GLC : NamedOperandBit<"GLC", NamedMatchClass<"GLC">>;
997 def SLC : NamedOperandBit<"SLC", NamedMatchClass<"SLC">>;
998 def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>;
999 def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>;
1000 def DA : NamedOperandBit<"DA", NamedMatchClass<"DA">>;
1001 def R128A16 : NamedOperandBit<"R128A16", NamedMatchClass<"R128A16">>;
1002 def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16">>;
1003 def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>;
1004 def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>;
1005 def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>;
1007 def FORMAT : NamedOperandU8<"FORMAT", NamedMatchClass<"FORMAT">>;
1009 def DMask : NamedOperandU16<"DMask", NamedMatchClass<"DMask">>;
1010 def Dim : NamedOperandU8<"Dim", NamedMatchClass<"Dim", 0>>;
1012 def dpp8 : NamedOperandU32<"DPP8", NamedMatchClass<"DPP8", 0>>;
1014 def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>;
1015 def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>;
1016 def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>;
1017 def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>;
1018 def FI : NamedOperandU32<"FI", NamedMatchClass<"FI">>;
1020 def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>;
1021 def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>;
1022 def src1_sel : NamedOperandU32<"SDWASrc1Sel", NamedMatchClass<"SDWASrc1Sel">>;
1023 def dst_unused : NamedOperandU32<"SDWADstUnused", NamedMatchClass<"SDWADstUnused">>;
1025 def op_sel : NamedOperandU32Default0<"OpSel", NamedMatchClass<"OpSel">>;
1026 def op_sel_hi : NamedOperandU32Default0<"OpSelHi", NamedMatchClass<"OpSelHi">>;
1027 def neg_lo : NamedOperandU32Default0<"NegLo", NamedMatchClass<"NegLo">>;
1028 def neg_hi : NamedOperandU32Default0<"NegHi", NamedMatchClass<"NegHi">>;
1030 def blgp : NamedOperandU32<"BLGP", NamedMatchClass<"BLGP">>;
1031 def cbsz : NamedOperandU32<"CBSZ", NamedMatchClass<"CBSZ">>;
1032 def abid : NamedOperandU32<"ABID", NamedMatchClass<"ABID">>;
1034 def hwreg : NamedOperandU16<"Hwreg", NamedMatchClass<"Hwreg", 0>>;
1036 def exp_tgt : NamedOperandU8<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> {
1040 } // End OperandType = "OPERAND_IMMEDIATE"
1042 class KImmMatchClass<int size> : AsmOperandClass {
1043   let Name = "KImmFP"#size;
1044   let PredicateMethod = "isKImmFP"#size;
1045   let ParserMethod = "parseImm";
1046   let RenderMethod = "addKImmFP"#size#"Operands";
1049 class kimmOperand<ValueType vt> : Operand<vt> {
1050   let OperandNamespace = "AMDGPU";
1051   let OperandType = "OPERAND_KIMM"#vt.Size;
1052   let PrintMethod = "printU"#vt.Size#"ImmOperand";
1053   let ParserMatchClass = !cast<AsmOperandClass>("KImmFP"#vt.Size#"MatchClass");
1056 // 32-bit VALU immediate operand that uses the constant bus.
1057 def KImmFP32MatchClass : KImmMatchClass<32>;
1058 def f32kimm : kimmOperand<i32>;
1060 // 32-bit VALU immediate operand with a 16-bit value that uses the
1061 // constant bus.
1062 def KImmFP16MatchClass : KImmMatchClass<16>;
1063 def f16kimm : kimmOperand<i16>;
1065 class FPInputModsMatchClass <int opSize> : AsmOperandClass {
1066   let Name = "RegOrImmWithFP"#opSize#"InputMods";
1067   let ParserMethod = "parseRegOrImmWithFPInputMods";
1068   let PredicateMethod = "isRegOrImmWithFP"#opSize#"InputMods";
1071 def FP16InputModsMatchClass : FPInputModsMatchClass<16>;
1072 def FP32InputModsMatchClass : FPInputModsMatchClass<32>;
1073 def FP64InputModsMatchClass : FPInputModsMatchClass<64>;
1075 class InputMods <AsmOperandClass matchClass> : Operand <i32> {
1076   let OperandNamespace = "AMDGPU";
1077   let OperandType = "OPERAND_INPUT_MODS";
1078   let ParserMatchClass = matchClass;
1081 class FPInputMods <FPInputModsMatchClass matchClass> : InputMods <matchClass> {
1082   let PrintMethod = "printOperandAndFPInputMods";
1085 def FP16InputMods : FPInputMods<FP16InputModsMatchClass>;
1086 def FP32InputMods : FPInputMods<FP32InputModsMatchClass>;
1087 def FP64InputMods : FPInputMods<FP64InputModsMatchClass>;
1089 class IntInputModsMatchClass <int opSize> : AsmOperandClass {
1090   let Name = "RegOrImmWithInt"#opSize#"InputMods";
1091   let ParserMethod = "parseRegOrImmWithIntInputMods";
1092   let PredicateMethod = "isRegOrImmWithInt"#opSize#"InputMods";
1094 def Int32InputModsMatchClass : IntInputModsMatchClass<32>;
1095 def Int64InputModsMatchClass : IntInputModsMatchClass<64>;
1097 class IntInputMods <IntInputModsMatchClass matchClass> : InputMods <matchClass> {
1098   let PrintMethod = "printOperandAndIntInputMods";
1100 def Int32InputMods : IntInputMods<Int32InputModsMatchClass>;
1101 def Int64InputMods : IntInputMods<Int64InputModsMatchClass>;
1103 class OpSelModsMatchClass : AsmOperandClass {
1104   let Name = "OpSelMods";
1105   let ParserMethod = "parseRegOrImm";
1106   let PredicateMethod = "isRegOrImm";
1109 def IntOpSelModsMatchClass : OpSelModsMatchClass;
1110 def IntOpSelMods : InputMods<IntOpSelModsMatchClass>;
1112 class FPSDWAInputModsMatchClass <int opSize> : AsmOperandClass {
1113   let Name = "SDWAWithFP"#opSize#"InputMods";
1114   let ParserMethod = "parseRegOrImmWithFPInputMods";
1115   let PredicateMethod = "isSDWAFP"#opSize#"Operand";
1118 def FP16SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<16>;
1119 def FP32SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<32>;
1121 class FPSDWAInputMods <FPSDWAInputModsMatchClass matchClass> :
1122   InputMods <matchClass> {
1123   let PrintMethod = "printOperandAndFPInputMods";
1126 def FP16SDWAInputMods : FPSDWAInputMods<FP16SDWAInputModsMatchClass>;
1127 def FP32SDWAInputMods : FPSDWAInputMods<FP32SDWAInputModsMatchClass>;
1129 def FPVRegInputModsMatchClass : AsmOperandClass {
1130   let Name = "VRegWithFPInputMods";
1131   let ParserMethod = "parseRegWithFPInputMods";
1132   let PredicateMethod = "isVReg32";
1135 def FPVRegInputMods : InputMods <FPVRegInputModsMatchClass> {
1136   let PrintMethod = "printOperandAndFPInputMods";
1139 class IntSDWAInputModsMatchClass <int opSize> : AsmOperandClass {
1140   let Name = "SDWAWithInt"#opSize#"InputMods";
1141   let ParserMethod = "parseRegOrImmWithIntInputMods";
1142   let PredicateMethod = "isSDWAInt"#opSize#"Operand";
1145 def Int16SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<16>;
1146 def Int32SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<32>;
1148 class IntSDWAInputMods <IntSDWAInputModsMatchClass matchClass> :
1149   InputMods <matchClass> {
1150   let PrintMethod = "printOperandAndIntInputMods";
1153 def Int16SDWAInputMods : IntSDWAInputMods<Int16SDWAInputModsMatchClass>;
1154 def Int32SDWAInputMods : IntSDWAInputMods<Int32SDWAInputModsMatchClass>;
1156 def IntVRegInputModsMatchClass : AsmOperandClass {
1157   let Name = "VRegWithIntInputMods";
1158   let ParserMethod = "parseRegWithIntInputMods";
1159   let PredicateMethod = "isVReg32";
1162 def IntVRegInputMods : InputMods <IntVRegInputModsMatchClass> {
1163   let PrintMethod = "printOperandAndIntInputMods";
1166 class PackedFPInputModsMatchClass <int opSize> : AsmOperandClass {
1167   let Name = "PackedFP"#opSize#"InputMods";
1168   let ParserMethod = "parseRegOrImm";
1169   let PredicateMethod = "isRegOrImm";
1170 //  let PredicateMethod = "isPackedFP"#opSize#"InputMods";
1173 class PackedIntInputModsMatchClass <int opSize> : AsmOperandClass {
1174   let Name = "PackedInt"#opSize#"InputMods";
1175   let ParserMethod = "parseRegOrImm";
1176   let PredicateMethod = "isRegOrImm";
1177 //  let PredicateMethod = "isPackedInt"#opSize#"InputMods";
1180 def PackedF16InputModsMatchClass : PackedFPInputModsMatchClass<16>;
1181 def PackedI16InputModsMatchClass : PackedIntInputModsMatchClass<16>;
1183 class PackedFPInputMods <PackedFPInputModsMatchClass matchClass> : InputMods <matchClass> {
1184 //  let PrintMethod = "printPackedFPInputMods";
1187 class PackedIntInputMods <PackedIntInputModsMatchClass matchClass> : InputMods <matchClass> {
1188   //let PrintMethod = "printPackedIntInputMods";
1191 def PackedF16InputMods : PackedFPInputMods<PackedF16InputModsMatchClass>;
1192 def PackedI16InputMods : PackedIntInputMods<PackedI16InputModsMatchClass>;
1194 //===----------------------------------------------------------------------===//
1195 // Complex patterns
1196 //===----------------------------------------------------------------------===//
1198 def DS1Addr1Offset : ComplexPattern<i32, 2, "SelectDS1Addr1Offset">;
1199 def DS64Bit4ByteAligned : ComplexPattern<i32, 3, "SelectDS64Bit4ByteAligned">;
1201 def MOVRELOffset : ComplexPattern<i32, 2, "SelectMOVRELOffset">;
1203 def VOP3Mods0 : ComplexPattern<untyped, 4, "SelectVOP3Mods0">;
1204 def VOP3Mods0Clamp : ComplexPattern<untyped, 3, "SelectVOP3Mods0Clamp">;
1205 def VOP3Mods0Clamp0OMod : ComplexPattern<untyped, 4, "SelectVOP3Mods0Clamp0OMod">;
1206 def VOP3Mods  : ComplexPattern<untyped, 2, "SelectVOP3Mods">;
1207 def VOP3NoMods : ComplexPattern<untyped, 1, "SelectVOP3NoMods">;
1208 // VOP3Mods, but the input source is known to never be NaN.
1209 def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">;
1210 // VOP3Mods, but only allowed for f32 operands.
1211 def VOP3Mods_f32 : ComplexPattern<fAny, 2, "SelectVOP3Mods_f32">;
1213 def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">;
1215 def VOP3PMods  : ComplexPattern<untyped, 2, "SelectVOP3PMods">;
1216 def VOP3PMods0 : ComplexPattern<untyped, 3, "SelectVOP3PMods0">;
1218 def VOP3OpSel  : ComplexPattern<untyped, 2, "SelectVOP3OpSel">;
1219 def VOP3OpSel0 : ComplexPattern<untyped, 3, "SelectVOP3OpSel0">;
1221 def VOP3OpSelMods  : ComplexPattern<untyped, 2, "SelectVOP3OpSelMods">;
1222 def VOP3OpSelMods0 : ComplexPattern<untyped, 3, "SelectVOP3OpSelMods0">;
1224 def VOP3PMadMixMods  : ComplexPattern<untyped, 2, "SelectVOP3PMadMixMods">;
1227 def Hi16Elt  : ComplexPattern<untyped, 1, "SelectHi16Elt">;
1229 //===----------------------------------------------------------------------===//
1230 // SI assembler operands
1231 //===----------------------------------------------------------------------===//
1233 def SIOperand {
1234   int ZERO = 0x80;
1235   int VCC = 0x6A;
1236   int FLAT_SCR = 0x68;
1239 // This should be kept in sync with SISrcMods enum
1240 def SRCMODS {
1241   int NONE = 0;
1242   int NEG = 1;
1243   int ABS = 2;
1244   int NEG_ABS = 3;
1246   int NEG_HI = ABS;
1247   int OP_SEL_0 = 4;
1248   int OP_SEL_1 = 8;
1249   int DST_OP_SEL = 8;
1252 def DSTCLAMP {
1253   int NONE = 0;
1254   int ENABLE = 1;
1257 def DSTOMOD {
1258   int NONE = 0;
1261 def TRAPID{
1262   int LLVM_TRAP = 2;
1263   int LLVM_DEBUG_TRAP = 3;
1266 def HWREG {
1267   int MODE = 1;
1268   int STATUS = 2;
1269   int TRAPSTS = 3;
1270   int HW_ID = 4;
1271   int GPR_ALLOC = 5;
1272   int LDS_ALLOC = 6;
1273   int IB_STS = 7;
1274   int MEM_BASES = 15;
1275   int TBA_LO = 16;
1276   int TBA_HI = 17;
1277   int TMA_LO = 18;
1278   int TMA_HI = 19;
1279   int FLAT_SCR_LO = 20;
1280   int FLAT_SCR_HI = 21;
1281   int XNACK_MASK = 22;
1282   int POPS_PACKER = 25;
1285 class getHwRegImm<int Reg, int Offset = 0, int Size = 32> {
1286   int ret = !or(Reg,
1287                 !or(!shl(Offset, 6),
1288                     !shl(!add(Size, -1), 11)));
1291 //===----------------------------------------------------------------------===//
1293 // SI Instruction multiclass helpers.
1295 // Instructions with _32 take 32-bit operands.
1296 // Instructions with _64 take 64-bit operands.
1298 // VOP_* instructions can use either a 32-bit or 64-bit encoding.  The 32-bit
1299 // encoding is the standard encoding, but instruction that make use of
1300 // any of the instruction modifiers must use the 64-bit encoding.
1302 // Instructions with _e32 use the 32-bit encoding.
1303 // Instructions with _e64 use the 64-bit encoding.
1305 //===----------------------------------------------------------------------===//
1307 class SIMCInstr <string pseudo, int subtarget> {
1308   string PseudoInstr = pseudo;
1309   int Subtarget = subtarget;
1312 //===----------------------------------------------------------------------===//
1313 // EXP classes
1314 //===----------------------------------------------------------------------===//
1316 class EXP_Helper<bit done, SDPatternOperator node = null_frag> : EXPCommon<
1317   (outs),
1318   (ins exp_tgt:$tgt,
1319        ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3,
1320        exp_vm:$vm, exp_compr:$compr, i8imm:$en),
1321   "exp$tgt $src0, $src1, $src2, $src3"#!if(done, " done", "")#"$compr$vm",
1322   [(node (i8 timm:$tgt), (i8 timm:$en),
1323          f32:$src0, f32:$src1, f32:$src2, f32:$src3,
1324          (i1 timm:$compr), (i1 timm:$vm))]> {
1325   let AsmMatchConverter = "cvtExp";
1328 // Split EXP instruction into EXP and EXP_DONE so we can set
1329 // mayLoad for done=1.
1330 multiclass EXP_m<bit done, SDPatternOperator node> {
1331   let mayLoad = done, DisableWQM = 1 in {
1332     let isPseudo = 1, isCodeGenOnly = 1 in {
1333       def "" : EXP_Helper<done, node>,
1334                SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.NONE>;
1335     }
1337     let done = done in {
1338       def _si : EXP_Helper<done>,
1339                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.SI>,
1340                 EXPe {
1341         let AssemblerPredicates = [isGFX6GFX7];
1342         let DecoderNamespace = "GFX6GFX7";
1343         let DisableDecoder = DisableSIDecoder;
1344       }
1346       def _vi : EXP_Helper<done>,
1347                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.VI>,
1348                 EXPe_vi {
1349         let AssemblerPredicates = [isGFX8GFX9];
1350         let DecoderNamespace = "GFX8";
1351         let DisableDecoder = DisableVIDecoder;
1352       }
1354       def _gfx10 : EXP_Helper<done>,
1355                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.GFX10>,
1356                 EXPe {
1357         let AssemblerPredicates = [isGFX10Plus];
1358         let DecoderNamespace = "GFX10";
1359         let DisableDecoder = DisableSIDecoder;
1360       }
1361     }
1362   }
1365 //===----------------------------------------------------------------------===//
1366 // Vector ALU classes
1367 //===----------------------------------------------------------------------===//
1369 class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> {
1370   int ret =
1371     !if (!eq(Src0.Value, untyped.Value),      0,
1372       !if (!eq(Src1.Value, untyped.Value),    1,   // VOP1
1373          !if (!eq(Src2.Value, untyped.Value), 2,   // VOP2
1374                                               3))); // VOP3
1377 // Returns the register class to use for the destination of VOP[123C]
1378 // instructions for the given VT.
1379 class getVALUDstForVT<ValueType VT> {
1380   RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>,
1381                           !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>,
1382                             !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>,
1383                               !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>,
1384                               VOPDstS64orS32)))); // else VT == i1
1387 // Returns true if VT is floating point.
1388 class getIsFP<ValueType VT> {
1389   bit ret = !if(!eq(VT.Value, f16.Value), 1,
1390             !if(!eq(VT.Value, v2f16.Value), 1,
1391             !if(!eq(VT.Value, v4f16.Value), 1,
1392             !if(!eq(VT.Value, f32.Value), 1,
1393             !if(!eq(VT.Value, v2f32.Value), 1,
1394             !if(!eq(VT.Value, f64.Value), 1,
1395             !if(!eq(VT.Value, v2f64.Value), 1,
1396             0)))))));
1399 // Returns the register class to use for the destination of VOP[12C]
1400 // instructions with SDWA extension
1401 class getSDWADstForVT<ValueType VT> {
1402   RegisterOperand ret = !if(!eq(VT.Size, 1),
1403                             SDWAVopcDst, // VOPC
1404                             VOPDstOperand<VGPR_32>); // VOP1/2 32-bit dst
1407 // Returns the register class to use for source 0 of VOP[12C]
1408 // instructions for the given VT.
1409 class getVOPSrc0ForVT<ValueType VT> {
1410   bit isFP = getIsFP<VT>.ret;
1412   RegisterOperand ret =
1413     !if(isFP,
1414       !if(!eq(VT.Size, 64),
1415          VSrc_f64,
1416          !if(!eq(VT.Value, f16.Value),
1417             VSrc_f16,
1418             !if(!eq(VT.Value, v2f16.Value),
1419                VSrc_v2f16,
1420                !if(!eq(VT.Value, v4f16.Value),
1421                  AVSrc_64,
1422                  VSrc_f32
1423                )
1424             )
1425          )
1426        ),
1427        !if(!eq(VT.Size, 64),
1428           VSrc_b64,
1429           !if(!eq(VT.Value, i16.Value),
1430              VSrc_b16,
1431              !if(!eq(VT.Value, v2i16.Value),
1432                 VSrc_v2b16,
1433                 VSrc_b32
1434              )
1435           )
1436        )
1437     );
1440 // Returns the vreg register class to use for source operand given VT
1441 class getVregSrcForVT<ValueType VT> {
1442   RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128,
1443                         !if(!eq(VT.Size, 64), VReg_64, VGPR_32));
1446 class getSDWASrcForVT <ValueType VT> {
1447   bit isFP = getIsFP<VT>.ret;
1448   RegisterOperand retFlt = !if(!eq(VT.Size, 16), SDWASrc_f16, SDWASrc_f32);
1449   RegisterOperand retInt = !if(!eq(VT.Size, 16), SDWASrc_i16, SDWASrc_i32);
1450   RegisterOperand ret = !if(isFP, retFlt, retInt);
1453 // Returns the register class to use for sources of VOP3 instructions for the
1454 // given VT.
1455 class getVOP3SrcForVT<ValueType VT> {
1456   bit isFP = getIsFP<VT>.ret;
1457   RegisterOperand ret =
1458   !if(!eq(VT.Size, 128),
1459      VSrc_128,
1460      !if(!eq(VT.Size, 64),
1461         !if(isFP,
1462            VSrc_f64,
1463            VSrc_b64),
1464         !if(!eq(VT.Value, i1.Value),
1465            SSrc_i1,
1466            !if(isFP,
1467               !if(!eq(VT.Value, f16.Value),
1468                  VSrc_f16,
1469                  !if(!eq(VT.Value, v2f16.Value),
1470                     VSrc_v2f16,
1471                     !if(!eq(VT.Value, v4f16.Value),
1472                       AVSrc_64,
1473                       VSrc_f32
1474                     )
1475                  )
1476               ),
1477               !if(!eq(VT.Value, i16.Value),
1478                  VSrc_b16,
1479                  !if(!eq(VT.Value, v2i16.Value),
1480                     VSrc_v2b16,
1481                     VSrc_b32
1482                  )
1483               )
1484            )
1485         )
1486      )
1487   );
1490 // Float or packed int
1491 class isModifierType<ValueType SrcVT> {
1492   bit ret =
1493     !if(!eq(SrcVT.Value, f16.Value), 1,
1494     !if(!eq(SrcVT.Value, f32.Value), 1,
1495     !if(!eq(SrcVT.Value, f64.Value), 1,
1496     !if(!eq(SrcVT.Value, v2f16.Value), 1,
1497     !if(!eq(SrcVT.Value, v2i16.Value), 1,
1498     0)))));
1501 // Return type of input modifiers operand for specified input operand
1502 class getSrcMod <ValueType VT, bit EnableF32SrcMods> {
1503   bit isFP = getIsFP<VT>.ret;
1504   bit isPacked = isPackedType<VT>.ret;
1505   Operand ret =  !if(!eq(VT.Size, 64),
1506                      !if(isFP, FP64InputMods, Int64InputMods),
1507                        !if(isFP,
1508                          !if(!eq(VT.Value, f16.Value),
1509                             FP16InputMods,
1510                             FP32InputMods
1511                           ),
1512                          !if(EnableF32SrcMods, FP32InputMods, Int32InputMods))
1513                      );
1516 class getOpSelMod <ValueType VT> {
1517   Operand ret = !if(!eq(VT.Value, f16.Value), FP16InputMods, IntOpSelMods);
1520 // Return type of input modifiers operand specified input operand for DPP
1521 class getSrcModExt <ValueType VT> {
1522   bit isFP = getIsFP<VT>.ret;
1523   Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods);
1526 // Return type of input modifiers operand specified input operand for SDWA
1527 class getSrcModSDWA <ValueType VT> {
1528   Operand ret = !if(!eq(VT.Value, f16.Value), FP16SDWAInputMods,
1529                 !if(!eq(VT.Value, f32.Value), FP32SDWAInputMods,
1530                 !if(!eq(VT.Value, i16.Value), Int16SDWAInputMods,
1531                 Int32SDWAInputMods)));
1534 // Returns the input arguments for VOP[12C] instructions for the given SrcVT.
1535 class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> {
1536   dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0),               // VOP1
1537             !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2
1538                                     (ins)));
1541 // Returns the input arguments for VOP3 instructions for the given SrcVT.
1542 class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC,
1543                 RegisterOperand Src2RC, int NumSrcArgs,
1544                 bit HasIntClamp, bit HasModifiers, bit HasSrc2Mods, bit HasOMod,
1545                 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
1547   dag ret =
1548     !if (!eq(NumSrcArgs, 0),
1549       // VOP1 without input operands (V_NOP, V_CLREXCP)
1550       (ins),
1551       /* else */
1552     !if (!eq(NumSrcArgs, 1),
1553       !if (!eq(HasModifiers, 1),
1554         // VOP1 with modifiers
1555         (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1556              clampmod:$clamp, omod:$omod)
1557       /* else */,
1558         // VOP1 without modifiers
1559         !if (!eq(HasIntClamp, 1),
1560           (ins Src0RC:$src0, clampmod:$clamp),
1561           (ins Src0RC:$src0))
1562       /* endif */ ),
1563     !if (!eq(NumSrcArgs, 2),
1564       !if (!eq(HasModifiers, 1),
1565         // VOP 2 with modifiers
1566         !if( !eq(HasOMod, 1),
1567           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1568                Src1Mod:$src1_modifiers, Src1RC:$src1,
1569                clampmod:$clamp, omod:$omod),
1570            (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1571                Src1Mod:$src1_modifiers, Src1RC:$src1,
1572                clampmod:$clamp))
1573       /* else */,
1574         // VOP2 without modifiers
1575         !if (!eq(HasIntClamp, 1),
1576           (ins Src0RC:$src0, Src1RC:$src1, clampmod:$clamp),
1577           (ins Src0RC:$src0, Src1RC:$src1))
1579       /* endif */ )
1580     /* NumSrcArgs == 3 */,
1581       !if (!eq(HasModifiers, 1),
1582         !if (!eq(HasSrc2Mods, 1),
1583           // VOP3 with modifiers
1584           !if (!eq(HasOMod, 1),
1585             (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1586                  Src1Mod:$src1_modifiers, Src1RC:$src1,
1587                  Src2Mod:$src2_modifiers, Src2RC:$src2,
1588                  clampmod:$clamp, omod:$omod),
1589             !if (!eq(HasIntClamp, 1),
1590               (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1591                    Src1Mod:$src1_modifiers, Src1RC:$src1,
1592                    Src2Mod:$src2_modifiers, Src2RC:$src2,
1593                    clampmod:$clamp),
1594               (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1595                    Src1Mod:$src1_modifiers, Src1RC:$src1,
1596                    Src2Mod:$src2_modifiers, Src2RC:$src2))),
1597           // VOP3 with modifiers except src2
1598           !if (!eq(HasOMod, 1),
1599             (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1600                  Src1Mod:$src1_modifiers, Src1RC:$src1,
1601                  Src2RC:$src2, clampmod:$clamp, omod:$omod),
1602             !if (!eq(HasIntClamp, 1),
1603               (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1604                    Src1Mod:$src1_modifiers, Src1RC:$src1,
1605                    Src2RC:$src2, clampmod:$clamp),
1606               (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1607                    Src1Mod:$src1_modifiers, Src1RC:$src1,
1608                    Src2RC:$src2))))
1609       /* else */,
1610         // VOP3 without modifiers
1611         !if (!eq(HasIntClamp, 1),
1612           (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2, clampmod:$clamp),
1613           (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2))
1614       /* endif */ ))));
1617 /// XXX - src1 may only allow VGPRs?
1619 // The modifiers (except clamp) are dummy operands for the benefit of
1620 // printing and parsing. They defer their values to looking at the
1621 // srcN_modifiers for what to print.
1622 class getInsVOP3P <RegisterOperand Src0RC, RegisterOperand Src1RC,
1623                    RegisterOperand Src2RC, int NumSrcArgs,
1624                    bit HasClamp,
1625                    Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
1626   dag ret = !if (!eq(NumSrcArgs, 2),
1627     !if (HasClamp,
1628       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1629            Src1Mod:$src1_modifiers, Src1RC:$src1,
1630            clampmod:$clamp,
1631            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1632            neg_lo:$neg_lo, neg_hi:$neg_hi),
1633       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1634            Src1Mod:$src1_modifiers, Src1RC:$src1,
1635            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1636            neg_lo:$neg_lo, neg_hi:$neg_hi)),
1637     // else NumSrcArgs == 3
1638     !if (HasClamp,
1639       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1640            Src1Mod:$src1_modifiers, Src1RC:$src1,
1641            Src2Mod:$src2_modifiers, Src2RC:$src2,
1642            clampmod:$clamp,
1643            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1644            neg_lo:$neg_lo, neg_hi:$neg_hi),
1645       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1646            Src1Mod:$src1_modifiers, Src1RC:$src1,
1647            Src2Mod:$src2_modifiers, Src2RC:$src2,
1648            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1649            neg_lo:$neg_lo, neg_hi:$neg_hi))
1650   );
1653 class getInsVOP3OpSel <RegisterOperand Src0RC,
1654                        RegisterOperand Src1RC,
1655                        RegisterOperand Src2RC,
1656                        int NumSrcArgs,
1657                        bit HasClamp,
1658                        Operand Src0Mod,
1659                        Operand Src1Mod,
1660                        Operand Src2Mod> {
1661   dag ret = !if (!eq(NumSrcArgs, 2),
1662     !if (HasClamp,
1663       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1664            Src1Mod:$src1_modifiers, Src1RC:$src1,
1665            clampmod:$clamp,
1666            op_sel:$op_sel),
1667       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1668            Src1Mod:$src1_modifiers, Src1RC:$src1,
1669            op_sel:$op_sel)),
1670     // else NumSrcArgs == 3
1671     !if (HasClamp,
1672       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1673            Src1Mod:$src1_modifiers, Src1RC:$src1,
1674            Src2Mod:$src2_modifiers, Src2RC:$src2,
1675            clampmod:$clamp,
1676            op_sel:$op_sel),
1677       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1678            Src1Mod:$src1_modifiers, Src1RC:$src1,
1679            Src2Mod:$src2_modifiers, Src2RC:$src2,
1680            op_sel:$op_sel))
1681   );
1684 class getInsDPP <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC,
1685                  int NumSrcArgs, bit HasModifiers,
1686                  Operand Src0Mod, Operand Src1Mod> {
1688   dag ret = !if (!eq(NumSrcArgs, 0),
1689                 // VOP1 without input operands (V_NOP)
1690                 (ins dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1691                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl),
1692             !if (!eq(NumSrcArgs, 1),
1693               !if (!eq(HasModifiers, 1),
1694                 // VOP1_DPP with modifiers
1695                 (ins DstRC:$old, Src0Mod:$src0_modifiers,
1696                      Src0RC:$src0, dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1697                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1698               /* else */,
1699                 // VOP1_DPP without modifiers
1700                 (ins DstRC:$old, Src0RC:$src0,
1701                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1702                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1703               /* endif */)
1704               /* NumSrcArgs == 2 */,
1705               !if (!eq(HasModifiers, 1),
1706                 // VOP2_DPP with modifiers
1707                 (ins DstRC:$old,
1708                      Src0Mod:$src0_modifiers, Src0RC:$src0,
1709                      Src1Mod:$src1_modifiers, Src1RC:$src1,
1710                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1711                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1712               /* else */,
1713                 // VOP2_DPP without modifiers
1714                 (ins DstRC:$old,
1715                      Src0RC:$src0, Src1RC:$src1, dpp_ctrl:$dpp_ctrl,
1716                      row_mask:$row_mask, bank_mask:$bank_mask,
1717                      bound_ctrl:$bound_ctrl)
1718              /* endif */)));
1721 class getInsDPP16 <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC,
1722                    int NumSrcArgs, bit HasModifiers,
1723                    Operand Src0Mod, Operand Src1Mod> {
1724   dag ret = !con(getInsDPP<DstRC, Src0RC, Src1RC, NumSrcArgs,
1725                            HasModifiers, Src0Mod, Src1Mod>.ret,
1726                  (ins FI:$fi));
1729 class getInsDPP8 <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC,
1730                  int NumSrcArgs, bit HasModifiers,
1731                  Operand Src0Mod, Operand Src1Mod> {
1732   dag ret = !if (!eq(NumSrcArgs, 0),
1733                 // VOP1 without input operands (V_NOP)
1734                 (ins dpp8:$dpp8, FI:$fi),
1735             !if (!eq(NumSrcArgs, 1),
1736               !if (!eq(HasModifiers, 1),
1737                 // VOP1_DPP with modifiers
1738                 (ins DstRC:$old, Src0Mod:$src0_modifiers,
1739                      Src0RC:$src0, dpp8:$dpp8, FI:$fi)
1740               /* else */,
1741                 // VOP1_DPP without modifiers
1742                 (ins DstRC:$old, Src0RC:$src0, dpp8:$dpp8, FI:$fi)
1743               /* endif */)
1744               /* NumSrcArgs == 2 */,
1745               !if (!eq(HasModifiers, 1),
1746                 // VOP2_DPP with modifiers
1747                 (ins DstRC:$old,
1748                      Src0Mod:$src0_modifiers, Src0RC:$src0,
1749                      Src1Mod:$src1_modifiers, Src1RC:$src1,
1750                      dpp8:$dpp8, FI:$fi)
1751               /* else */,
1752                 // VOP2_DPP without modifiers
1753                 (ins DstRC:$old,
1754                      Src0RC:$src0, Src1RC:$src1, dpp8:$dpp8, FI:$fi)
1755              /* endif */)));
1759 // Ins for SDWA
1760 class getInsSDWA <RegisterOperand Src0RC, RegisterOperand Src1RC, int NumSrcArgs,
1761                   bit HasSDWAOMod, Operand Src0Mod, Operand Src1Mod,
1762                   ValueType DstVT> {
1764   dag ret = !if(!eq(NumSrcArgs, 0),
1765                // VOP1 without input operands (V_NOP)
1766                (ins),
1767             !if(!eq(NumSrcArgs, 1),
1768                // VOP1
1769                !if(!eq(HasSDWAOMod, 0),
1770                   // VOP1_SDWA without omod
1771                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1772                        clampmod:$clamp,
1773                        dst_sel:$dst_sel, dst_unused:$dst_unused,
1774                        src0_sel:$src0_sel),
1775                   // VOP1_SDWA with omod
1776                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1777                        clampmod:$clamp, omod:$omod,
1778                        dst_sel:$dst_sel, dst_unused:$dst_unused,
1779                        src0_sel:$src0_sel)),
1780             !if(!eq(NumSrcArgs, 2),
1781                !if(!eq(DstVT.Size, 1),
1782                   // VOPC_SDWA
1783                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1784                        Src1Mod:$src1_modifiers, Src1RC:$src1,
1785                        clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1786                   // VOP2_SDWA
1787                   !if(!eq(HasSDWAOMod, 0),
1788                      // VOP2_SDWA without omod
1789                      (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1790                           Src1Mod:$src1_modifiers, Src1RC:$src1,
1791                           clampmod:$clamp,
1792                           dst_sel:$dst_sel, dst_unused:$dst_unused,
1793                           src0_sel:$src0_sel, src1_sel:$src1_sel),
1794                      // VOP2_SDWA with omod
1795                      (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1796                           Src1Mod:$src1_modifiers, Src1RC:$src1,
1797                           clampmod:$clamp, omod:$omod,
1798                           dst_sel:$dst_sel, dst_unused:$dst_unused,
1799                           src0_sel:$src0_sel, src1_sel:$src1_sel))),
1800             (ins)/* endif */)));
1803 // Outs for DPP and SDWA
1804 class getOutsExt <bit HasDst, ValueType DstVT, RegisterOperand DstRCExt> {
1805   dag ret = !if(HasDst,
1806                 !if(!eq(DstVT.Size, 1),
1807                     (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions
1808                     (outs DstRCExt:$vdst)),
1809                 (outs)); // V_NOP
1812 // Outs for SDWA
1813 class getOutsSDWA <bit HasDst, ValueType DstVT, RegisterOperand DstRCSDWA> {
1814   dag ret = !if(HasDst,
1815                 !if(!eq(DstVT.Size, 1),
1816                     (outs DstRCSDWA:$sdst),
1817                     (outs DstRCSDWA:$vdst)),
1818                 (outs)); // V_NOP
1821 // Returns the assembly string for the inputs and outputs of a VOP[12C]
1822 // instruction.  This does not add the _e32 suffix, so it can be reused
1823 // by getAsm64.
1824 class getAsm32 <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1825   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1826   string src0 = ", $src0";
1827   string src1 = ", $src1";
1828   string src2 = ", $src2";
1829   string ret = !if(HasDst, dst, "") #
1830                !if(!eq(NumSrcArgs, 1), src0, "") #
1831                !if(!eq(NumSrcArgs, 2), src0#src1, "") #
1832                !if(!eq(NumSrcArgs, 3), src0#src1#src2, "");
1835 // Returns the assembly string for the inputs and outputs of a VOP3
1836 // instruction.
1837 class getAsm64 <bit HasDst, int NumSrcArgs, bit HasIntClamp, bit HasModifiers,
1838                 bit HasOMod, ValueType DstVT = i32> {
1839   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1840   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1841   string src1 = !if(!eq(NumSrcArgs, 1), "",
1842                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1843                                            " $src1_modifiers,"));
1844   string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1845   string iclamp = !if(HasIntClamp, "$clamp", "");
1846   string ret =
1847   !if(!eq(HasModifiers, 0),
1848       getAsm32<HasDst, NumSrcArgs, DstVT>.ret # iclamp,
1849       dst#", "#src0#src1#src2#"$clamp"#!if(HasOMod, "$omod", ""));
1852 // Returns the assembly string for the inputs and outputs of a VOP3P
1853 // instruction.
1854 class getAsmVOP3P <bit HasDst, int NumSrcArgs, bit HasModifiers,
1855                    bit HasClamp, ValueType DstVT = i32> {
1856   string dst = " $vdst";
1857   string src0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1858   string src1 = !if(!eq(NumSrcArgs, 1), "",
1859                    !if(!eq(NumSrcArgs, 2), " $src1",
1860                                            " $src1,"));
1861   string src2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1863   string mods = !if(HasModifiers, "$neg_lo$neg_hi", "");
1864   string clamp = !if(HasClamp, "$clamp", "");
1866   // Each modifier is printed as an array of bits for each operand, so
1867   // all operands are printed as part of src0_modifiers.
1868   string ret = dst#", "#src0#src1#src2#"$op_sel$op_sel_hi"#mods#clamp;
1871 class getAsmVOP3OpSel <int NumSrcArgs,
1872                        bit HasClamp,
1873                        bit Src0HasMods,
1874                        bit Src1HasMods,
1875                        bit Src2HasMods> {
1876   string dst = " $vdst";
1878   string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1879   string isrc1 = !if(!eq(NumSrcArgs, 1), "",
1880                      !if(!eq(NumSrcArgs, 2), " $src1",
1881                                              " $src1,"));
1882   string isrc2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1884   string fsrc0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1885   string fsrc1 = !if(!eq(NumSrcArgs, 1), "",
1886                      !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1887                                              " $src1_modifiers,"));
1888   string fsrc2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1890   string src0 = !if(Src0HasMods, fsrc0, isrc0);
1891   string src1 = !if(Src1HasMods, fsrc1, isrc1);
1892   string src2 = !if(Src2HasMods, fsrc2, isrc2);
1894   string clamp = !if(HasClamp, "$clamp", "");
1896   string ret = dst#", "#src0#src1#src2#"$op_sel"#clamp;
1899 class getAsmDPP <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1900   string dst = !if(HasDst,
1901                    !if(!eq(DstVT.Size, 1),
1902                        "$sdst",
1903                        "$vdst"),
1904                     ""); // use $sdst for VOPC
1905   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1906   string src1 = !if(!eq(NumSrcArgs, 1), "",
1907                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1908                                            " $src1_modifiers,"));
1909   string args = !if(!eq(HasModifiers, 0),
1910                      getAsm32<0, NumSrcArgs, DstVT>.ret,
1911                      ", "#src0#src1);
1912   string ret = dst#args#" $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
1915 class getAsmDPP16 <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1916   string ret = getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret#"$fi";
1919 class getAsmDPP8 <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1920   string dst = !if(HasDst,
1921                    !if(!eq(DstVT.Size, 1),
1922                        "$sdst",
1923                        "$vdst"),
1924                     ""); // use $sdst for VOPC
1925   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1926   string src1 = !if(!eq(NumSrcArgs, 1), "",
1927                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1928                                            " $src1_modifiers,"));
1929   string args = !if(!eq(HasModifiers, 0),
1930                      getAsm32<0, NumSrcArgs, DstVT>.ret,
1931                      ", "#src0#src1);
1932   string ret = dst#args#"$dpp8$fi";
1935 class getAsmSDWA <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1936   string dst = !if(HasDst,
1937                    !if(!eq(DstVT.Size, 1),
1938                        " vcc", // use vcc token as dst for VOPC instructioins
1939                        "$vdst"),
1940                     "");
1941   string src0 = "$src0_modifiers";
1942   string src1 = "$src1_modifiers";
1943   string args = !if(!eq(NumSrcArgs, 0),
1944                     "",
1945                     !if(!eq(NumSrcArgs, 1),
1946                         ", "#src0#"$clamp",
1947                         ", "#src0#", "#src1#"$clamp"
1948                      )
1949                 );
1950   string sdwa = !if(!eq(NumSrcArgs, 0),
1951                     "",
1952                     !if(!eq(NumSrcArgs, 1),
1953                         " $dst_sel $dst_unused $src0_sel",
1954                         !if(!eq(DstVT.Size, 1),
1955                             " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC
1956                             " $dst_sel $dst_unused $src0_sel $src1_sel"
1957                         )
1958                     )
1959                 );
1960   string ret = dst#args#sdwa;
1963 class getAsmSDWA9 <bit HasDst, bit HasOMod, int NumSrcArgs,
1964                    ValueType DstVT = i32> {
1965   string dst = !if(HasDst,
1966                    !if(!eq(DstVT.Size, 1),
1967                        "$sdst", // VOPC
1968                        "$vdst"), // VOP1/2
1969                     "");
1970   string src0 = "$src0_modifiers";
1971   string src1 = "$src1_modifiers";
1972   string out_mods = !if(!eq(HasOMod, 0), "$clamp", "$clamp$omod");
1973   string args = !if(!eq(NumSrcArgs, 0), "",
1974                     !if(!eq(NumSrcArgs, 1),
1975                         ", "#src0,
1976                         ", "#src0#", "#src1
1977                      )
1978                 );
1979   string sdwa = !if(!eq(NumSrcArgs, 0), "",
1980                     !if(!eq(NumSrcArgs, 1),
1981                         out_mods#" $dst_sel $dst_unused $src0_sel",
1982                         !if(!eq(DstVT.Size, 1),
1983                             " $src0_sel $src1_sel", // No dst_sel, dst_unused and output modifiers for VOPC
1984                             out_mods#" $dst_sel $dst_unused $src0_sel $src1_sel"
1985                         )
1986                     )
1987                 );
1988   string ret = dst#args#sdwa;
1992 // Function that checks if instruction supports DPP and SDWA
1993 class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
1994                  ValueType Src1VT = i32> {
1995   bit ret = !if(!eq(NumSrcArgs, 3),
1996                 0, // NumSrcArgs == 3 - No DPP or SDWA for VOP3
1997                 !if(!eq(DstVT.Size, 64),
1998                     0, // 64-bit dst - No DPP or SDWA for 64-bit operands
1999                     !if(!eq(Src0VT.Size, 64),
2000                         0, // 64-bit src0
2001                         !if(!eq(Src1VT.Size, 64),
2002                             0, // 64-bit src2
2003                             1
2004                         )
2005                     )
2006                 )
2007             );
2010 class getHasDPP <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
2011                  ValueType Src1VT = i32> {
2012   bit ret = !if(!eq(NumSrcArgs, 0), 0,
2013                 getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret);
2016 class BitOr<bit a, bit b> {
2017   bit ret = !if(a, 1, !if(b, 1, 0));
2020 class BitAnd<bit a, bit b> {
2021   bit ret = !if(a, !if(b, 1, 0), 0);
2024 def PatGenMode {
2025   int NoPattern = 0;
2026   int Pattern   = 1;
2029 class VOPProfile <list<ValueType> _ArgVT, bit _EnableF32SrcMods = 0,
2030                   bit _EnableClamp = 0> {
2032   field list<ValueType> ArgVT = _ArgVT;
2033   field bit EnableF32SrcMods = _EnableF32SrcMods;
2034   field bit EnableClamp = _EnableClamp;
2036   field ValueType DstVT = ArgVT[0];
2037   field ValueType Src0VT = ArgVT[1];
2038   field ValueType Src1VT = ArgVT[2];
2039   field ValueType Src2VT = ArgVT[3];
2040   field RegisterOperand DstRC = getVALUDstForVT<DstVT>.ret;
2041   field RegisterOperand DstRCDPP = getVALUDstForVT<DstVT>.ret;
2042   field RegisterOperand DstRCSDWA = getSDWADstForVT<DstVT>.ret;
2043   field RegisterOperand Src0RC32 = getVOPSrc0ForVT<Src0VT>.ret;
2044   field RegisterClass Src1RC32 = getVregSrcForVT<Src1VT>.ret;
2045   field RegisterOperand Src0RC64 = getVOP3SrcForVT<Src0VT>.ret;
2046   field RegisterOperand Src1RC64 = getVOP3SrcForVT<Src1VT>.ret;
2047   field RegisterOperand Src2RC64 = getVOP3SrcForVT<Src2VT>.ret;
2048   field RegisterClass Src0DPP = getVregSrcForVT<Src0VT>.ret;
2049   field RegisterClass Src1DPP = getVregSrcForVT<Src1VT>.ret;
2050   field RegisterOperand Src0SDWA = getSDWASrcForVT<Src0VT>.ret;
2051   field RegisterOperand Src1SDWA = getSDWASrcForVT<Src0VT>.ret;
2052   field Operand Src0Mod = getSrcMod<Src0VT, EnableF32SrcMods>.ret;
2053   field Operand Src1Mod = getSrcMod<Src1VT, EnableF32SrcMods>.ret;
2054   field Operand Src2Mod = getSrcMod<Src2VT, EnableF32SrcMods>.ret;
2055   field Operand Src0ModDPP = getSrcModExt<Src0VT>.ret;
2056   field Operand Src1ModDPP = getSrcModExt<Src1VT>.ret;
2057   field Operand Src0ModSDWA = getSrcModSDWA<Src0VT>.ret;
2058   field Operand Src1ModSDWA = getSrcModSDWA<Src1VT>.ret;
2061   field bit HasDst = !if(!eq(DstVT.Value, untyped.Value), 0, 1);
2062   field bit HasDst32 = HasDst;
2063   field bit EmitDst = HasDst; // force dst encoding, see v_movreld_b32 special case
2064   field int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret;
2065   field bit HasSrc0 = !if(!eq(Src0VT.Value, untyped.Value), 0, 1);
2066   field bit HasSrc1 = !if(!eq(Src1VT.Value, untyped.Value), 0, 1);
2067   field bit HasSrc2 = !if(!eq(Src2VT.Value, untyped.Value), 0, 1);
2069   // TODO: Modifiers logic is somewhat adhoc here, to be refined later
2070   // HasModifiers affects the normal and DPP encodings. We take note of EnableF32SrcMods, which
2071   // enables modifiers for i32 type.
2072   field bit HasModifiers = BitOr<isModifierType<Src0VT>.ret, EnableF32SrcMods>.ret;
2074   // HasSrc*FloatMods affects the SDWA encoding. We ignore EnableF32SrcMods.
2075   field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret;
2076   field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret;
2077   field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret;
2079   // HasSrc*IntMods affects the SDWA encoding. We ignore EnableF32SrcMods.
2080   field bit HasSrc0IntMods = isIntType<Src0VT>.ret;
2081   field bit HasSrc1IntMods = isIntType<Src1VT>.ret;
2082   field bit HasSrc2IntMods = isIntType<Src2VT>.ret;
2084   field bit HasSrc0Mods = HasModifiers;
2085   field bit HasSrc1Mods = !if(HasModifiers, BitOr<HasSrc1FloatMods, HasSrc1IntMods>.ret, 0);
2086   field bit HasSrc2Mods = !if(HasModifiers, BitOr<HasSrc2FloatMods, HasSrc2IntMods>.ret, 0);
2088   field bit HasClamp = BitOr<isModifierType<Src0VT>.ret, EnableClamp>.ret;
2089   field bit HasSDWAClamp = EmitDst;
2090   field bit HasFPClamp = BitAnd<isFloatType<DstVT>.ret, HasClamp>.ret;
2091   field bit HasIntClamp = !if(isFloatType<DstVT>.ret, 0, HasClamp);
2092   field bit HasClampLo = HasClamp;
2093   field bit HasClampHi = BitAnd<isPackedType<DstVT>.ret, HasClamp>.ret;
2094   field bit HasHigh = 0;
2096   field bit IsPacked = isPackedType<Src0VT>.ret;
2097   field bit HasOpSel = IsPacked;
2098   field bit HasOMod = !if(HasOpSel, 0, isFloatType<DstVT>.ret);
2099   field bit HasSDWAOMod = isFloatType<DstVT>.ret;
2101   field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret;
2102   field bit HasExtDPP = getHasDPP<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret;
2103   field bit HasExtSDWA = HasExt;
2104   field bit HasExtSDWA9 = HasExt;
2105   field int NeedPatGen = PatGenMode.NoPattern;
2107   field bit IsMAI = 0;
2109   field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods);
2110   field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods);
2111   field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods);
2113   field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs));
2115   // VOP3b instructions are a special case with a second explicit
2116   // output. This is manually overridden for them.
2117   field dag Outs32 = Outs;
2118   field dag Outs64 = Outs;
2119   field dag OutsDPP = getOutsExt<HasDst, DstVT, DstRCDPP>.ret;
2120   field dag OutsDPP8 = getOutsExt<HasDst, DstVT, DstRCDPP>.ret;
2121   field dag OutsSDWA = getOutsSDWA<HasDst, DstVT, DstRCSDWA>.ret;
2123   field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret;
2124   field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
2125                              HasIntClamp, HasModifiers, HasSrc2Mods,
2126                              HasOMod, Src0Mod, Src1Mod, Src2Mod>.ret;
2127   field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64,
2128                                    NumSrcArgs, HasClamp,
2129                                    Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret;
2130   field dag InsVOP3OpSel = getInsVOP3OpSel<Src0RC64, Src1RC64, Src2RC64,
2131                                            NumSrcArgs,
2132                                            HasClamp,
2133                                            getOpSelMod<Src0VT>.ret,
2134                                            getOpSelMod<Src1VT>.ret,
2135                                            getOpSelMod<Src2VT>.ret>.ret;
2136   field dag InsDPP = !if(HasExtDPP,
2137                          getInsDPP<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs,
2138                                    HasModifiers, Src0ModDPP, Src1ModDPP>.ret,
2139                          (ins));
2140   field dag InsDPP16 = getInsDPP16<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs,
2141                                    HasModifiers, Src0ModDPP, Src1ModDPP>.ret;
2142   field dag InsDPP8 = getInsDPP8<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs, 0,
2143                                  Src0ModDPP, Src1ModDPP>.ret;
2144   field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs,
2145                                  HasSDWAOMod, Src0ModSDWA, Src1ModSDWA,
2146                                  DstVT>.ret;
2149   field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret;
2150   field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasIntClamp, HasModifiers, HasOMod, DstVT>.ret;
2151   field string AsmVOP3P = getAsmVOP3P<HasDst, NumSrcArgs, HasModifiers, HasClamp, DstVT>.ret;
2152   field string AsmVOP3OpSel = getAsmVOP3OpSel<NumSrcArgs,
2153                                               HasClamp,
2154                                               HasSrc0FloatMods,
2155                                               HasSrc1FloatMods,
2156                                               HasSrc2FloatMods>.ret;
2157   field string AsmDPP = !if(HasExtDPP,
2158                             getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret, "");
2159   field string AsmDPP16 = getAsmDPP16<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
2160   field string AsmDPP8 = getAsmDPP8<HasDst, NumSrcArgs, 0, DstVT>.ret;
2161   field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, DstVT>.ret;
2162   field string AsmSDWA9 = getAsmSDWA9<HasDst, HasSDWAOMod, NumSrcArgs, DstVT>.ret;
2164   field string TieRegDPP = "$old";
2167 class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> {
2168   let HasExt = 0;
2169   let HasExtDPP = 0;
2170   let HasExtSDWA = 0;
2171   let HasExtSDWA9 = 0;
2174 class VOP_PAT_GEN <VOPProfile p, int mode=PatGenMode.Pattern> : VOPProfile <p.ArgVT> {
2175   let NeedPatGen = mode;
2178 def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>;
2179 def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>;
2180 def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>;
2182 def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>;
2183 def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>;
2184 def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>;
2185 def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>;
2187 def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>;
2188 def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>;
2190 def VOP_I32_I16_I16_I32 : VOPProfile <[i32, i16, i16, i32, untyped]>;
2192 def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>;
2193 def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>;
2194 def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>;
2196 def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>;
2197 def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>;
2198 def VOP_V2I16_F32_F32 : VOPProfile <[v2i16, f32, f32, untyped]>;
2199 def VOP_V2I16_I32_I32 : VOPProfile <[v2i16, i32, i32, untyped]>;
2201 def VOP_F32_V2F16_V2F16_V2F16 : VOPProfile <[f32, v2f16, v2f16, v2f16]>;
2203 def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>;
2205 def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>;
2206 def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>;
2207 def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>;
2208 def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>;
2209 def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>;
2210 def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>;
2211 def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>;
2212 def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>;
2213 def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>;
2214 def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>;
2215 def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>;
2217 def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>;
2218 def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>;
2219 def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>;
2220 def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>;
2221 def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>;
2222 def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>;
2223 def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>;
2224 def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>;
2225 def VOP_I32_I32_I32_ARITH : VOPProfile <[i32, i32, i32, untyped], 0, /*EnableClamp=*/1>;
2226 def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>;
2227 def VOP_F32_F16_F16_F16 : VOPProfile <[f32, f16, f16, f16]>;
2229 def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>;
2230 def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
2231 def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
2233 def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>;
2234 def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>;
2235 def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>;
2236 def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>;
2237 def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>;
2238 def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>;
2239 def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>;
2240 def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>;
2241 def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>;
2243 def VOP_F32_V2F16_V2F16_F32 : VOPProfile <[f32, v2f16, v2f16, f32]>;
2244 def VOP_I32_V2I16_V2I16_I32 : VOPProfile <[i32, v2i16, v2i16, i32]>;
2246 def VOP_V4F32_F32_F32_V4F32       : VOPProfile <[v4f32,  f32,   f32,   v4f32]>;
2247 def VOP_V16F32_F32_F32_V16F32     : VOPProfile <[v16f32, f32,   f32,   v16f32]>;
2248 def VOP_V32F32_F32_F32_V32F32     : VOPProfile <[v32f32, f32,   f32,   v32f32]>;
2249 def VOP_V4F32_V4F16_V4F16_V4F32   : VOPProfile <[v4f32,  v4f16, v4f16, v4f32]>;
2250 def VOP_V16F32_V4F16_V4F16_V16F32 : VOPProfile <[v16f32, v4f16, v4f16, v16f32]>;
2251 def VOP_V32F32_V4F16_V4F16_V32F32 : VOPProfile <[v32f32, v4f16, v4f16, v32f32]>;
2252 def VOP_V4F32_V2I16_V2I16_V4F32   : VOPProfile <[v4f32,  v2i16, v2i16, v4f32]>;
2253 def VOP_V16F32_V2I16_V2I16_V16F32 : VOPProfile <[v16f32, v2i16, v2i16, v16f32]>;
2254 def VOP_V32F32_V2I16_V2I16_V32F32 : VOPProfile <[v32f32, v2i16, v2i16, v32f32]>;
2255 def VOP_V4I32_I32_I32_V4I32       : VOPProfile <[v4i32,  i32,   i32,   v4i32]>;
2256 def VOP_V16I32_I32_I32_V16I32     : VOPProfile <[v16i32, i32,   i32,   v16i32]>;
2257 def VOP_V32I32_I32_I32_V32I32     : VOPProfile <[v32i32, i32,   i32,   v32i32]>;
2259 class Commutable_REV <string revOp, bit isOrig> {
2260   string RevOp = revOp;
2261   bit IsOrig = isOrig;
2264 class AtomicNoRet <string noRetOp, bit isRet> {
2265   string NoRetOp = noRetOp;
2266   bit IsRet = isRet;
2269 //===----------------------------------------------------------------------===//
2270 // Interpolation opcodes
2271 //===----------------------------------------------------------------------===//
2273 class VINTRPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVINTRPDst">;
2275 class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> :
2276   VINTRPCommon <outs, ins, "", pattern>,
2277   SIMCInstr<opName, SIEncodingFamily.NONE> {
2278   let isPseudo = 1;
2279   let isCodeGenOnly = 1;
2282 // FIXME-GFX10: WIP.
2283 class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins,
2284                       string asm, int encodingFamily> :
2285   VINTRPCommon <outs, ins, asm, []>,
2286   VINTRPe <op>,
2287   SIMCInstr<opName, encodingFamily> {
2288   let DisableDecoder = DisableSIDecoder;
2291 class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins,
2292                       string asm> :
2293   VINTRPCommon <outs, ins, asm, []>,
2294   VINTRPe_vi <op>,
2295   SIMCInstr<opName, SIEncodingFamily.VI> {
2296   let AssemblerPredicate = VIAssemblerPredicate;
2297   let DecoderNamespace = "GFX8";
2298   let DisableDecoder = DisableVIDecoder;
2301 // FIXME-GFX10: WIP.
2302 multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm,
2303                      list<dag> pattern = []> {
2304   def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>;
2306   let AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7" in {
2307     def _si : VINTRP_Real_si <op, NAME, outs, ins, asm, SIEncodingFamily.SI>;
2308   } // End AssemblerPredicate = isGFX6GFX7, DecoderNamespace = "GFX6GFX7"
2310   def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>;
2312   let AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10" in {
2313     def _gfx10 : VINTRP_Real_si<op, NAME, outs, ins, asm, SIEncodingFamily.GFX10>;
2314   } // End AssemblerPredicate = isGFX10Plus, DecoderNamespace = "GFX10"
2316 //===----------------------------------------------------------------------===//
2317 // Vector instruction mappings
2318 //===----------------------------------------------------------------------===//
2320 // Maps an opcode in e32 form to its e64 equivalent
2321 def getVOPe64 : InstrMapping {
2322   let FilterClass = "VOP";
2323   let RowFields = ["OpName"];
2324   let ColFields = ["Size", "VOP3"];
2325   let KeyCol = ["4", "0"];
2326   let ValueCols = [["8", "1"]];
2329 // Maps an opcode in e64 form to its e32 equivalent
2330 def getVOPe32 : InstrMapping {
2331   let FilterClass = "VOP";
2332   let RowFields = ["OpName"];
2333   let ColFields = ["Size", "VOP3"];
2334   let KeyCol = ["8", "1"];
2335   let ValueCols = [["4", "0"]];
2338 // Maps ordinary instructions to their SDWA counterparts
2339 def getSDWAOp : InstrMapping {
2340   let FilterClass = "VOP";
2341   let RowFields = ["OpName"];
2342   let ColFields = ["AsmVariantName"];
2343   let KeyCol = ["Default"];
2344   let ValueCols = [["SDWA"]];
2347 // Maps SDWA instructions to their ordinary counterparts
2348 def getBasicFromSDWAOp : InstrMapping {
2349   let FilterClass = "VOP";
2350   let RowFields = ["OpName"];
2351   let ColFields = ["AsmVariantName"];
2352   let KeyCol = ["SDWA"];
2353   let ValueCols = [["Default"]];
2356 // Maps ordinary instructions to their DPP counterparts
2357 def getDPPOp32 : InstrMapping {
2358   let FilterClass = "VOP";
2359   let RowFields = ["OpName"];
2360   let ColFields = ["AsmVariantName"];
2361   let KeyCol = ["Default"];
2362   let ValueCols = [["DPP"]];
2365 // Maps an commuted opcode to its original version
2366 def getCommuteOrig : InstrMapping {
2367   let FilterClass = "Commutable_REV";
2368   let RowFields = ["RevOp"];
2369   let ColFields = ["IsOrig"];
2370   let KeyCol = ["0"];
2371   let ValueCols = [["1"]];
2374 // Maps an original opcode to its commuted version
2375 def getCommuteRev : InstrMapping {
2376   let FilterClass = "Commutable_REV";
2377   let RowFields = ["RevOp"];
2378   let ColFields = ["IsOrig"];
2379   let KeyCol = ["1"];
2380   let ValueCols = [["0"]];
2383 def getMCOpcodeGen : InstrMapping {
2384   let FilterClass = "SIMCInstr";
2385   let RowFields = ["PseudoInstr"];
2386   let ColFields = ["Subtarget"];
2387   let KeyCol = [!cast<string>(SIEncodingFamily.NONE)];
2388   let ValueCols = [[!cast<string>(SIEncodingFamily.SI)],
2389                    [!cast<string>(SIEncodingFamily.VI)],
2390                    [!cast<string>(SIEncodingFamily.SDWA)],
2391                    [!cast<string>(SIEncodingFamily.SDWA9)],
2392                    // GFX80 encoding is added to work around a multiple matching
2393                    // issue for buffer instructions with unpacked d16 data. This
2394                    // does not actually change the encoding, and thus may be
2395                    // removed later.
2396                    [!cast<string>(SIEncodingFamily.GFX80)],
2397                    [!cast<string>(SIEncodingFamily.GFX9)],
2398                    [!cast<string>(SIEncodingFamily.GFX10)],
2399                    [!cast<string>(SIEncodingFamily.SDWA10)]];
2402 // Get equivalent SOPK instruction.
2403 def getSOPKOp : InstrMapping {
2404   let FilterClass = "SOPKInstTable";
2405   let RowFields = ["BaseCmpOp"];
2406   let ColFields = ["IsSOPK"];
2407   let KeyCol = ["0"];
2408   let ValueCols = [["1"]];
2411 def getAddr64Inst : InstrMapping {
2412   let FilterClass = "MUBUFAddr64Table";
2413   let RowFields = ["OpName"];
2414   let ColFields = ["IsAddr64"];
2415   let KeyCol = ["0"];
2416   let ValueCols = [["1"]];
2419 def getIfAddr64Inst : InstrMapping {
2420   let FilterClass = "MUBUFAddr64Table";
2421   let RowFields = ["OpName"];
2422   let ColFields = ["IsAddr64"];
2423   let KeyCol = ["1"];
2424   let ValueCols = [["1"]];
2427 def getMUBUFNoLdsInst : InstrMapping {
2428   let FilterClass = "MUBUFLdsTable";
2429   let RowFields = ["OpName"];
2430   let ColFields = ["IsLds"];
2431   let KeyCol = ["1"];
2432   let ValueCols = [["0"]];
2435 // Maps an atomic opcode to its version with a return value.
2436 def getAtomicRetOp : InstrMapping {
2437   let FilterClass = "AtomicNoRet";
2438   let RowFields = ["NoRetOp"];
2439   let ColFields = ["IsRet"];
2440   let KeyCol = ["0"];
2441   let ValueCols = [["1"]];
2444 // Maps an atomic opcode to its returnless version.
2445 def getAtomicNoRetOp : InstrMapping {
2446   let FilterClass = "AtomicNoRet";
2447   let RowFields = ["NoRetOp"];
2448   let ColFields = ["IsRet"];
2449   let KeyCol = ["1"];
2450   let ValueCols = [["0"]];
2453 // Maps a GLOBAL to its SADDR form.
2454 def getGlobalSaddrOp : InstrMapping {
2455   let FilterClass = "GlobalSaddrTable";
2456   let RowFields = ["SaddrOp"];
2457   let ColFields = ["IsSaddr"];
2458   let KeyCol = ["0"];
2459   let ValueCols = [["1"]];
2462 // Maps a v_cmpx opcode with sdst to opcode without sdst.
2463 def getVCMPXNoSDstOp : InstrMapping {
2464   let FilterClass = "VCMPXNoSDstTable";
2465   let RowFields = ["NoSDstOp"];
2466   let ColFields = ["HasSDst"];
2467   let KeyCol = ["1"];
2468   let ValueCols = [["0"]];
2471 // Maps a SOPP to a SOPP with S_NOP
2472 def getSOPPWithRelaxation : InstrMapping {
2473   let FilterClass = "Base_SOPP";
2474   let RowFields = ["AsmString"];
2475   let ColFields = ["Size"];
2476   let KeyCol = ["4"];
2477   let ValueCols = [["8"]];
2480 include "SIInstructions.td"
2482 include "DSInstructions.td"
2483 include "MIMGInstructions.td"