1 //===-- SIInstructions.td - SI Instruction Defintions ---------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // This file was originally auto-generated from a GPU register header file and
10 // all the instruction definitions were originally commented out. Instructions
11 // that are not yet supported remain commented out.
12 //===----------------------------------------------------------------------===//
19 def INTERP : InterpSlots;
21 def InterpSlot : Operand<i32> {
22 let PrintMethod = "printInterpSlot";
25 def SendMsgImm : Operand<i32> {
26 let PrintMethod = "printSendMsg";
29 def isGCN : Predicate<"Subtarget.getGeneration() "
30 ">= AMDGPUSubtarget::SOUTHERN_ISLANDS">;
31 def isSICI : Predicate<
32 "Subtarget.getGeneration() == AMDGPUSubtarget::SOUTHERN_ISLANDS ||"
33 "Subtarget.getGeneration() == AMDGPUSubtarget::SEA_ISLANDS"
35 def isCI : Predicate<"Subtarget.getGeneration() "
36 ">= AMDGPUSubtarget::SEA_ISLANDS">;
37 def isVI : Predicate <
38 "Subtarget.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS"
41 def HasFlatAddressSpace : Predicate<"Subtarget.hasFlatAddressSpace()">;
43 def SWaitMatchClass : AsmOperandClass {
44 let Name = "SWaitCnt";
45 let RenderMethod = "addImmOperands";
46 let ParserMethod = "parseSWaitCntOps";
49 def WAIT_FLAG : InstFlag<"printWaitFlag"> {
50 let ParserMatchClass = SWaitMatchClass;
53 let SubtargetPredicate = isGCN in {
55 //===----------------------------------------------------------------------===//
57 //===----------------------------------------------------------------------===//
61 //===----------------------------------------------------------------------===//
63 //===----------------------------------------------------------------------===//
67 // We are using the SGPR_32 and not the SReg_32 register class for 32-bit
68 // SMRD instructions, because the SGPR_32 register class does not include M0
69 // and writing to M0 from an SMRD instruction will hang the GPU.
70 defm S_LOAD_DWORD : SMRD_Helper <0x00, "s_load_dword", SReg_64, SGPR_32>;
71 defm S_LOAD_DWORDX2 : SMRD_Helper <0x01, "s_load_dwordx2", SReg_64, SReg_64>;
72 defm S_LOAD_DWORDX4 : SMRD_Helper <0x02, "s_load_dwordx4", SReg_64, SReg_128>;
73 defm S_LOAD_DWORDX8 : SMRD_Helper <0x03, "s_load_dwordx8", SReg_64, SReg_256>;
74 defm S_LOAD_DWORDX16 : SMRD_Helper <0x04, "s_load_dwordx16", SReg_64, SReg_512>;
76 defm S_BUFFER_LOAD_DWORD : SMRD_Helper <
77 0x08, "s_buffer_load_dword", SReg_128, SGPR_32
80 defm S_BUFFER_LOAD_DWORDX2 : SMRD_Helper <
81 0x09, "s_buffer_load_dwordx2", SReg_128, SReg_64
84 defm S_BUFFER_LOAD_DWORDX4 : SMRD_Helper <
85 0x0a, "s_buffer_load_dwordx4", SReg_128, SReg_128
88 defm S_BUFFER_LOAD_DWORDX8 : SMRD_Helper <
89 0x0b, "s_buffer_load_dwordx8", SReg_128, SReg_256
92 defm S_BUFFER_LOAD_DWORDX16 : SMRD_Helper <
93 0x0c, "s_buffer_load_dwordx16", SReg_128, SReg_512
98 //def S_MEMTIME : SMRD_ <0x0000001e, "s_memtime", []>;
99 //def S_DCACHE_INV : SMRD_ <0x0000001f, "s_dcache_inv", []>;
101 //===----------------------------------------------------------------------===//
103 //===----------------------------------------------------------------------===//
105 let isMoveImm = 1 in {
106 let isReMaterializable = 1 in {
107 defm S_MOV_B32 : SOP1_32 <sop1<0x03, 0x00>, "s_mov_b32", []>;
108 defm S_MOV_B64 : SOP1_64 <sop1<0x04, 0x01>, "s_mov_b64", []>;
109 } // let isRematerializeable = 1
111 let Uses = [SCC] in {
112 defm S_CMOV_B32 : SOP1_32 <sop1<0x05, 0x02>, "s_cmov_b32", []>;
113 defm S_CMOV_B64 : SOP1_64 <sop1<0x06, 0x03>, "s_cmov_b64", []>;
114 } // End Uses = [SCC]
115 } // End isMoveImm = 1
117 let Defs = [SCC] in {
118 defm S_NOT_B32 : SOP1_32 <sop1<0x07, 0x04>, "s_not_b32",
119 [(set i32:$dst, (not i32:$src0))]
122 defm S_NOT_B64 : SOP1_64 <sop1<0x08, 0x05>, "s_not_b64",
123 [(set i64:$dst, (not i64:$src0))]
125 defm S_WQM_B32 : SOP1_32 <sop1<0x09, 0x06>, "s_wqm_b32", []>;
126 defm S_WQM_B64 : SOP1_64 <sop1<0x0a, 0x07>, "s_wqm_b64", []>;
127 } // End Defs = [SCC]
130 defm S_BREV_B32 : SOP1_32 <sop1<0x0b, 0x08>, "s_brev_b32",
131 [(set i32:$dst, (AMDGPUbrev i32:$src0))]
133 defm S_BREV_B64 : SOP1_64 <sop1<0x0c, 0x09>, "s_brev_b64", []>;
135 let Defs = [SCC] in {
136 //defm S_BCNT0_I32_B32 : SOP1_BCNT0 <sop1<0x0d, 0x0a>, "s_bcnt0_i32_b32", []>;
137 //defm S_BCNT0_I32_B64 : SOP1_BCNT0 <sop1<0x0e, 0x0b>, "s_bcnt0_i32_b64", []>;
138 defm S_BCNT1_I32_B32 : SOP1_32 <sop1<0x0f, 0x0c>, "s_bcnt1_i32_b32",
139 [(set i32:$dst, (ctpop i32:$src0))]
141 defm S_BCNT1_I32_B64 : SOP1_32_64 <sop1<0x10, 0x0d>, "s_bcnt1_i32_b64", []>;
142 } // End Defs = [SCC]
144 //defm S_FF0_I32_B32 : SOP1_32 <sop1<0x11, 0x0e>, "s_ff0_i32_b32", []>;
145 //defm S_FF0_I32_B64 : SOP1_FF0 <sop1<0x12, 0x0f>, "s_ff0_i32_b64", []>;
146 defm S_FF1_I32_B32 : SOP1_32 <sop1<0x13, 0x10>, "s_ff1_i32_b32",
147 [(set i32:$dst, (cttz_zero_undef i32:$src0))]
149 ////defm S_FF1_I32_B64 : SOP1_FF1 <sop1<0x14, 0x11>, "s_ff1_i32_b64", []>;
151 defm S_FLBIT_I32_B32 : SOP1_32 <sop1<0x15, 0x12>, "s_flbit_i32_b32",
152 [(set i32:$dst, (ctlz_zero_undef i32:$src0))]
155 //defm S_FLBIT_I32_B64 : SOP1_32 <sop1<0x16, 0x13>, "s_flbit_i32_b64", []>;
156 defm S_FLBIT_I32 : SOP1_32 <sop1<0x17, 0x14>, "s_flbit_i32", []>;
157 //defm S_FLBIT_I32_I64 : SOP1_32 <sop1<0x18, 0x15>, "s_flbit_i32_i64", []>;
158 defm S_SEXT_I32_I8 : SOP1_32 <sop1<0x19, 0x16>, "s_sext_i32_i8",
159 [(set i32:$dst, (sext_inreg i32:$src0, i8))]
161 defm S_SEXT_I32_I16 : SOP1_32 <sop1<0x1a, 0x17>, "s_sext_i32_i16",
162 [(set i32:$dst, (sext_inreg i32:$src0, i16))]
165 ////defm S_BITSET0_B32 : SOP1_BITSET0 <sop1<0x1b, 0x18>, "s_bitset0_b32", []>;
166 ////defm S_BITSET0_B64 : SOP1_BITSET0 <sop1<0x1c, 0x19>, "s_bitset0_b64", []>;
167 ////defm S_BITSET1_B32 : SOP1_BITSET1 <sop1<0x1d, 0x1a>, "s_bitset1_b32", []>;
168 ////defm S_BITSET1_B64 : SOP1_BITSET1 <sop1<0x1e, 0x1b>, "s_bitset1_b64", []>;
169 defm S_GETPC_B64 : SOP1_64_0 <sop1<0x1f, 0x1c>, "s_getpc_b64", []>;
170 defm S_SETPC_B64 : SOP1_64 <sop1<0x20, 0x1d>, "s_setpc_b64", []>;
171 defm S_SWAPPC_B64 : SOP1_64 <sop1<0x21, 0x1e>, "s_swappc_b64", []>;
172 defm S_RFE_B64 : SOP1_64 <sop1<0x22, 0x1f>, "s_rfe_b64", []>;
174 let hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC] in {
176 defm S_AND_SAVEEXEC_B64 : SOP1_64 <sop1<0x24, 0x20>, "s_and_saveexec_b64", []>;
177 defm S_OR_SAVEEXEC_B64 : SOP1_64 <sop1<0x25, 0x21>, "s_or_saveexec_b64", []>;
178 defm S_XOR_SAVEEXEC_B64 : SOP1_64 <sop1<0x26, 0x22>, "s_xor_saveexec_b64", []>;
179 defm S_ANDN2_SAVEEXEC_B64 : SOP1_64 <sop1<0x27, 0x23>, "s_andn2_saveexec_b64", []>;
180 defm S_ORN2_SAVEEXEC_B64 : SOP1_64 <sop1<0x28, 0x24>, "s_orn2_saveexec_b64", []>;
181 defm S_NAND_SAVEEXEC_B64 : SOP1_64 <sop1<0x29, 0x25>, "s_nand_saveexec_b64", []>;
182 defm S_NOR_SAVEEXEC_B64 : SOP1_64 <sop1<0x2a, 0x26>, "s_nor_saveexec_b64", []>;
183 defm S_XNOR_SAVEEXEC_B64 : SOP1_64 <sop1<0x2b, 0x27>, "s_xnor_saveexec_b64", []>;
185 } // End hasSideEffects = 1, Uses = [EXEC], Defs = [EXEC, SCC]
187 defm S_QUADMASK_B32 : SOP1_32 <sop1<0x2c, 0x28>, "s_quadmask_b32", []>;
188 defm S_QUADMASK_B64 : SOP1_64 <sop1<0x2d, 0x29>, "s_quadmask_b64", []>;
189 defm S_MOVRELS_B32 : SOP1_32 <sop1<0x2e, 0x2a>, "s_movrels_b32", []>;
190 defm S_MOVRELS_B64 : SOP1_64 <sop1<0x2f, 0x2b>, "s_movrels_b64", []>;
191 defm S_MOVRELD_B32 : SOP1_32 <sop1<0x30, 0x2c>, "s_movreld_b32", []>;
192 defm S_MOVRELD_B64 : SOP1_64 <sop1<0x31, 0x2d>, "s_movreld_b64", []>;
193 //defm S_CBRANCH_JOIN : SOP1_ <sop1<0x32, 0x2e>, "s_cbranch_join", []>;
194 defm S_MOV_REGRD_B32 : SOP1_32 <sop1<0x33, 0x2f>, "s_mov_regrd_b32", []>;
195 let Defs = [SCC] in {
196 defm S_ABS_I32 : SOP1_32 <sop1<0x34, 0x30>, "s_abs_i32", []>;
197 } // End Defs = [SCC]
198 defm S_MOV_FED_B32 : SOP1_32 <sop1<0x35, 0x31>, "s_mov_fed_b32", []>;
200 //===----------------------------------------------------------------------===//
202 //===----------------------------------------------------------------------===//
204 let Defs = [SCC] in { // Carry out goes to SCC
205 let isCommutable = 1 in {
206 defm S_ADD_U32 : SOP2_32 <sop2<0x00>, "s_add_u32", []>;
207 defm S_ADD_I32 : SOP2_32 <sop2<0x02>, "s_add_i32",
208 [(set i32:$dst, (add SSrc_32:$src0, SSrc_32:$src1))]
210 } // End isCommutable = 1
212 defm S_SUB_U32 : SOP2_32 <sop2<0x01>, "s_sub_u32", []>;
213 defm S_SUB_I32 : SOP2_32 <sop2<0x03>, "s_sub_i32",
214 [(set i32:$dst, (sub SSrc_32:$src0, SSrc_32:$src1))]
217 let Uses = [SCC] in { // Carry in comes from SCC
218 let isCommutable = 1 in {
219 defm S_ADDC_U32 : SOP2_32 <sop2<0x04>, "s_addc_u32",
220 [(set i32:$dst, (adde (i32 SSrc_32:$src0), (i32 SSrc_32:$src1)))]>;
221 } // End isCommutable = 1
223 defm S_SUBB_U32 : SOP2_32 <sop2<0x05>, "s_subb_u32",
224 [(set i32:$dst, (sube (i32 SSrc_32:$src0), (i32 SSrc_32:$src1)))]>;
225 } // End Uses = [SCC]
227 defm S_MIN_I32 : SOP2_32 <sop2<0x06>, "s_min_i32",
228 [(set i32:$dst, (AMDGPUsmin i32:$src0, i32:$src1))]
230 defm S_MIN_U32 : SOP2_32 <sop2<0x07>, "s_min_u32",
231 [(set i32:$dst, (AMDGPUumin i32:$src0, i32:$src1))]
233 defm S_MAX_I32 : SOP2_32 <sop2<0x08>, "s_max_i32",
234 [(set i32:$dst, (AMDGPUsmax i32:$src0, i32:$src1))]
236 defm S_MAX_U32 : SOP2_32 <sop2<0x09>, "s_max_u32",
237 [(set i32:$dst, (AMDGPUumax i32:$src0, i32:$src1))]
239 } // End Defs = [SCC]
241 defm S_CSELECT_B32 : SOP2_SELECT_32 <sop2<0x0a>, "s_cselect_b32", []>;
243 let Uses = [SCC] in {
244 defm S_CSELECT_B64 : SOP2_64 <sop2<0x0b>, "s_cselect_b64", []>;
245 } // End Uses = [SCC]
247 let Defs = [SCC] in {
248 defm S_AND_B32 : SOP2_32 <sop2<0x0e, 0x0c>, "s_and_b32",
249 [(set i32:$dst, (and i32:$src0, i32:$src1))]
252 defm S_AND_B64 : SOP2_64 <sop2<0x0f, 0x0d>, "s_and_b64",
253 [(set i64:$dst, (and i64:$src0, i64:$src1))]
256 defm S_OR_B32 : SOP2_32 <sop2<0x10, 0x0e>, "s_or_b32",
257 [(set i32:$dst, (or i32:$src0, i32:$src1))]
260 defm S_OR_B64 : SOP2_64 <sop2<0x11, 0x0f>, "s_or_b64",
261 [(set i64:$dst, (or i64:$src0, i64:$src1))]
264 defm S_XOR_B32 : SOP2_32 <sop2<0x12, 0x10>, "s_xor_b32",
265 [(set i32:$dst, (xor i32:$src0, i32:$src1))]
268 defm S_XOR_B64 : SOP2_64 <sop2<0x13, 0x11>, "s_xor_b64",
269 [(set i64:$dst, (xor i64:$src0, i64:$src1))]
271 defm S_ANDN2_B32 : SOP2_32 <sop2<0x14, 0x12>, "s_andn2_b32", []>;
272 defm S_ANDN2_B64 : SOP2_64 <sop2<0x15, 0x13>, "s_andn2_b64", []>;
273 defm S_ORN2_B32 : SOP2_32 <sop2<0x16, 0x14>, "s_orn2_b32", []>;
274 defm S_ORN2_B64 : SOP2_64 <sop2<0x17, 0x15>, "s_orn2_b64", []>;
275 defm S_NAND_B32 : SOP2_32 <sop2<0x18, 0x16>, "s_nand_b32", []>;
276 defm S_NAND_B64 : SOP2_64 <sop2<0x19, 0x17>, "s_nand_b64", []>;
277 defm S_NOR_B32 : SOP2_32 <sop2<0x1a, 0x18>, "s_nor_b32", []>;
278 defm S_NOR_B64 : SOP2_64 <sop2<0x1b, 0x19>, "s_nor_b64", []>;
279 defm S_XNOR_B32 : SOP2_32 <sop2<0x1c, 0x1a>, "s_xnor_b32", []>;
280 defm S_XNOR_B64 : SOP2_64 <sop2<0x1d, 0x1b>, "s_xnor_b64", []>;
281 } // End Defs = [SCC]
283 // Use added complexity so these patterns are preferred to the VALU patterns.
284 let AddedComplexity = 1 in {
285 let Defs = [SCC] in {
287 defm S_LSHL_B32 : SOP2_32 <sop2<0x1e, 0x1c>, "s_lshl_b32",
288 [(set i32:$dst, (shl i32:$src0, i32:$src1))]
290 defm S_LSHL_B64 : SOP2_64_32 <sop2<0x1f, 0x1d>, "s_lshl_b64",
291 [(set i64:$dst, (shl i64:$src0, i32:$src1))]
293 defm S_LSHR_B32 : SOP2_32 <sop2<0x20, 0x1e>, "s_lshr_b32",
294 [(set i32:$dst, (srl i32:$src0, i32:$src1))]
296 defm S_LSHR_B64 : SOP2_64_32 <sop2<0x21, 0x1f>, "s_lshr_b64",
297 [(set i64:$dst, (srl i64:$src0, i32:$src1))]
299 defm S_ASHR_I32 : SOP2_32 <sop2<0x22, 0x20>, "s_ashr_i32",
300 [(set i32:$dst, (sra i32:$src0, i32:$src1))]
302 defm S_ASHR_I64 : SOP2_64_32 <sop2<0x23, 0x21>, "s_ashr_i64",
303 [(set i64:$dst, (sra i64:$src0, i32:$src1))]
305 } // End Defs = [SCC]
307 defm S_BFM_B32 : SOP2_32 <sop2<0x24, 0x22>, "s_bfm_b32", []>;
308 defm S_BFM_B64 : SOP2_64 <sop2<0x25, 0x23>, "s_bfm_b64", []>;
309 defm S_MUL_I32 : SOP2_32 <sop2<0x26, 0x24>, "s_mul_i32",
310 [(set i32:$dst, (mul i32:$src0, i32:$src1))]
313 } // End AddedComplexity = 1
315 let Defs = [SCC] in {
316 defm S_BFE_U32 : SOP2_32 <sop2<0x27, 0x25>, "s_bfe_u32", []>;
317 defm S_BFE_I32 : SOP2_32 <sop2<0x28, 0x26>, "s_bfe_i32", []>;
318 defm S_BFE_U64 : SOP2_64 <sop2<0x29, 0x27>, "s_bfe_u64", []>;
319 defm S_BFE_I64 : SOP2_64_32 <sop2<0x2a, 0x28>, "s_bfe_i64", []>;
320 } // End Defs = [SCC]
322 //defm S_CBRANCH_G_FORK : SOP2_ <sop2<0x2b, 0x29>, "s_cbranch_g_fork", []>;
323 let Defs = [SCC] in {
324 defm S_ABSDIFF_I32 : SOP2_32 <sop2<0x2c, 0x2a>, "s_absdiff_i32", []>;
325 } // End Defs = [SCC]
327 //===----------------------------------------------------------------------===//
329 //===----------------------------------------------------------------------===//
331 def S_CMP_EQ_I32 : SOPC_32 <0x00000000, "s_cmp_eq_i32">;
332 def S_CMP_LG_I32 : SOPC_32 <0x00000001, "s_cmp_lg_i32">;
333 def S_CMP_GT_I32 : SOPC_32 <0x00000002, "s_cmp_gt_i32">;
334 def S_CMP_GE_I32 : SOPC_32 <0x00000003, "s_cmp_ge_i32">;
335 def S_CMP_LT_I32 : SOPC_32 <0x00000004, "s_cmp_lt_i32">;
336 def S_CMP_LE_I32 : SOPC_32 <0x00000005, "s_cmp_le_i32">;
337 def S_CMP_EQ_U32 : SOPC_32 <0x00000006, "s_cmp_eq_u32">;
338 def S_CMP_LG_U32 : SOPC_32 <0x00000007, "s_cmp_lg_u32">;
339 def S_CMP_GT_U32 : SOPC_32 <0x00000008, "s_cmp_gt_u32">;
340 def S_CMP_GE_U32 : SOPC_32 <0x00000009, "s_cmp_ge_u32">;
341 def S_CMP_LT_U32 : SOPC_32 <0x0000000a, "s_cmp_lt_u32">;
342 def S_CMP_LE_U32 : SOPC_32 <0x0000000b, "s_cmp_le_u32">;
343 ////def S_BITCMP0_B32 : SOPC_BITCMP0 <0x0000000c, "s_bitcmp0_b32", []>;
344 ////def S_BITCMP1_B32 : SOPC_BITCMP1 <0x0000000d, "s_bitcmp1_b32", []>;
345 ////def S_BITCMP0_B64 : SOPC_BITCMP0 <0x0000000e, "s_bitcmp0_b64", []>;
346 ////def S_BITCMP1_B64 : SOPC_BITCMP1 <0x0000000f, "s_bitcmp1_b64", []>;
347 //def S_SETVSKIP : SOPC_ <0x00000010, "s_setvskip", []>;
349 //===----------------------------------------------------------------------===//
351 //===----------------------------------------------------------------------===//
353 let isReMaterializable = 1 in {
354 defm S_MOVK_I32 : SOPK_32 <sopk<0x00>, "s_movk_i32", []>;
355 } // End isReMaterializable = 1
356 let Uses = [SCC] in {
357 defm S_CMOVK_I32 : SOPK_32 <sopk<0x02, 0x01>, "s_cmovk_i32", []>;
360 let isCompare = 1 in {
363 This instruction is disabled for now until we can figure out how to teach
364 the instruction selector to correctly use the S_CMP* vs V_CMP*
367 When this instruction is enabled the code generator sometimes produces this
370 SCC = S_CMPK_EQ_I32 SGPR0, imm
372 VGPR0 = V_CNDMASK VCC, VGPR0, VGPR1
374 defm S_CMPK_EQ_I32 : SOPK_SCC <sopk<0x03, 0x02>, "s_cmpk_eq_i32",
375 [(set i1:$dst, (setcc i32:$src0, imm:$src1, SETEQ))]
379 defm S_CMPK_LG_I32 : SOPK_SCC <sopk<0x04, 0x03>, "s_cmpk_lg_i32", []>;
380 defm S_CMPK_GT_I32 : SOPK_SCC <sopk<0x05, 0x04>, "s_cmpk_gt_i32", []>;
381 defm S_CMPK_GE_I32 : SOPK_SCC <sopk<0x06, 0x05>, "s_cmpk_ge_i32", []>;
382 defm S_CMPK_LT_I32 : SOPK_SCC <sopk<0x07, 0x06>, "s_cmpk_lt_i32", []>;
383 defm S_CMPK_LE_I32 : SOPK_SCC <sopk<0x08, 0x07>, "s_cmpk_le_i32", []>;
384 defm S_CMPK_EQ_U32 : SOPK_SCC <sopk<0x09, 0x08>, "s_cmpk_eq_u32", []>;
385 defm S_CMPK_LG_U32 : SOPK_SCC <sopk<0x0a, 0x09>, "s_cmpk_lg_u32", []>;
386 defm S_CMPK_GT_U32 : SOPK_SCC <sopk<0x0b, 0x0a>, "s_cmpk_gt_u32", []>;
387 defm S_CMPK_GE_U32 : SOPK_SCC <sopk<0x0c, 0x0b>, "s_cmpk_ge_u32", []>;
388 defm S_CMPK_LT_U32 : SOPK_SCC <sopk<0x0d, 0x0c>, "s_cmpk_lt_u32", []>;
389 defm S_CMPK_LE_U32 : SOPK_SCC <sopk<0x0e, 0x0d>, "s_cmpk_le_u32", []>;
390 } // End isCompare = 1
392 let isCommutable = 1 in {
393 let Defs = [SCC], isCommutable = 1 in {
394 defm S_ADDK_I32 : SOPK_32 <sopk<0x0f, 0x0e>, "s_addk_i32", []>;
396 defm S_MULK_I32 : SOPK_32 <sopk<0x10, 0x0f>, "s_mulk_i32", []>;
399 //defm S_CBRANCH_I_FORK : SOPK_ <sopk<0x11, 0x10>, "s_cbranch_i_fork", []>;
400 defm S_GETREG_B32 : SOPK_32 <sopk<0x12, 0x11>, "s_getreg_b32", []>;
401 defm S_SETREG_B32 : SOPK_32 <sopk<0x13, 0x12>, "s_setreg_b32", []>;
402 defm S_GETREG_REGRD_B32 : SOPK_32 <sopk<0x14, 0x13>, "s_getreg_regrd_b32", []>;
403 //defm S_SETREG_IMM32_B32 : SOPK_32 <sopk<0x15, 0x14>, "s_setreg_imm32_b32", []>;
405 //===----------------------------------------------------------------------===//
407 //===----------------------------------------------------------------------===//
409 def S_NOP : SOPP <0x00000000, (ins i16imm:$simm16), "s_nop $simm16">;
411 let isTerminator = 1 in {
413 def S_ENDPGM : SOPP <0x00000001, (ins), "s_endpgm",
420 let isBranch = 1 in {
421 def S_BRANCH : SOPP <
422 0x00000002, (ins sopp_brtarget:$simm16), "s_branch $simm16",
427 let DisableEncoding = "$scc" in {
428 def S_CBRANCH_SCC0 : SOPP <
429 0x00000004, (ins sopp_brtarget:$simm16, SCCReg:$scc),
430 "s_cbranch_scc0 $simm16"
432 def S_CBRANCH_SCC1 : SOPP <
433 0x00000005, (ins sopp_brtarget:$simm16, SCCReg:$scc),
434 "s_cbranch_scc1 $simm16"
436 } // End DisableEncoding = "$scc"
438 def S_CBRANCH_VCCZ : SOPP <
439 0x00000006, (ins sopp_brtarget:$simm16, VCCReg:$vcc),
440 "s_cbranch_vccz $simm16"
442 def S_CBRANCH_VCCNZ : SOPP <
443 0x00000007, (ins sopp_brtarget:$simm16, VCCReg:$vcc),
444 "s_cbranch_vccnz $simm16"
447 let DisableEncoding = "$exec" in {
448 def S_CBRANCH_EXECZ : SOPP <
449 0x00000008, (ins sopp_brtarget:$simm16, EXECReg:$exec),
450 "s_cbranch_execz $simm16"
452 def S_CBRANCH_EXECNZ : SOPP <
453 0x00000009, (ins sopp_brtarget:$simm16, EXECReg:$exec),
454 "s_cbranch_execnz $simm16"
456 } // End DisableEncoding = "$exec"
459 } // End isBranch = 1
460 } // End isTerminator = 1
462 let hasSideEffects = 1 in {
463 def S_BARRIER : SOPP <0x0000000a, (ins), "s_barrier",
464 [(int_AMDGPU_barrier_local)]
473 def S_WAITCNT : SOPP <0x0000000c, (ins WAIT_FLAG:$simm16), "s_waitcnt $simm16">;
474 def S_SETHALT : SOPP <0x0000000d, (ins i16imm:$simm16), "s_sethalt $simm16">;
475 def S_SLEEP : SOPP <0x0000000e, (ins i16imm:$simm16), "s_sleep $simm16">;
476 def S_SETPRIO : SOPP <0x0000000f, (ins i16imm:$sim16), "s_setprio $sim16">;
478 let Uses = [EXEC] in {
479 def S_SENDMSG : SOPP <0x00000010, (ins SendMsgImm:$simm16, M0Reg:$m0), "s_sendmsg $simm16",
480 [(int_SI_sendmsg imm:$simm16, M0Reg:$m0)]
482 let DisableEncoding = "$m0";
484 } // End Uses = [EXEC]
486 def S_SENDMSGHALT : SOPP <0x00000011, (ins i16imm:$simm16), "s_sendmsghalt $simm16">;
487 def S_TRAP : SOPP <0x00000012, (ins i16imm:$simm16), "s_trap $simm16">;
488 def S_ICACHE_INV : SOPP <0x00000013, (ins), "s_icache_inv"> {
491 def S_INCPERFLEVEL : SOPP <0x00000014, (ins i16imm:$simm16), "s_incperflevel $simm16">;
492 def S_DECPERFLEVEL : SOPP <0x00000015, (ins i16imm:$simm16), "s_decperflevel $simm16">;
493 def S_TTRACEDATA : SOPP <0x00000016, (ins), "s_ttracedata"> {
496 } // End hasSideEffects
498 //===----------------------------------------------------------------------===//
500 //===----------------------------------------------------------------------===//
502 let isCompare = 1 in {
504 defm V_CMP_F_F32 : VOPC_F32 <vopc<0x0, 0x40>, "v_cmp_f_f32">;
505 defm V_CMP_LT_F32 : VOPC_F32 <vopc<0x1, 0x41>, "v_cmp_lt_f32", COND_OLT>;
506 defm V_CMP_EQ_F32 : VOPC_F32 <vopc<0x2, 0x42>, "v_cmp_eq_f32", COND_OEQ>;
507 defm V_CMP_LE_F32 : VOPC_F32 <vopc<0x3, 0x43>, "v_cmp_le_f32", COND_OLE>;
508 defm V_CMP_GT_F32 : VOPC_F32 <vopc<0x4, 0x44>, "v_cmp_gt_f32", COND_OGT>;
509 defm V_CMP_LG_F32 : VOPC_F32 <vopc<0x5, 0x45>, "v_cmp_lg_f32", COND_ONE>;
510 defm V_CMP_GE_F32 : VOPC_F32 <vopc<0x6, 0x46>, "v_cmp_ge_f32", COND_OGE>;
511 defm V_CMP_O_F32 : VOPC_F32 <vopc<0x7, 0x47>, "v_cmp_o_f32", COND_O>;
512 defm V_CMP_U_F32 : VOPC_F32 <vopc<0x8, 0x48>, "v_cmp_u_f32", COND_UO>;
513 defm V_CMP_NGE_F32 : VOPC_F32 <vopc<0x9, 0x49>, "v_cmp_nge_f32", COND_ULT>;
514 defm V_CMP_NLG_F32 : VOPC_F32 <vopc<0xa, 0x4a>, "v_cmp_nlg_f32", COND_UEQ>;
515 defm V_CMP_NGT_F32 : VOPC_F32 <vopc<0xb, 0x4b>, "v_cmp_ngt_f32", COND_ULE>;
516 defm V_CMP_NLE_F32 : VOPC_F32 <vopc<0xc, 0x4c>, "v_cmp_nle_f32", COND_UGT>;
517 defm V_CMP_NEQ_F32 : VOPC_F32 <vopc<0xd, 0x4d>, "v_cmp_neq_f32", COND_UNE>;
518 defm V_CMP_NLT_F32 : VOPC_F32 <vopc<0xe, 0x4e>, "v_cmp_nlt_f32", COND_UGE>;
519 defm V_CMP_TRU_F32 : VOPC_F32 <vopc<0xf, 0x4f>, "v_cmp_tru_f32">;
521 let hasSideEffects = 1 in {
523 defm V_CMPX_F_F32 : VOPCX_F32 <vopc<0x10, 0x50>, "v_cmpx_f_f32">;
524 defm V_CMPX_LT_F32 : VOPCX_F32 <vopc<0x11, 0x51>, "v_cmpx_lt_f32">;
525 defm V_CMPX_EQ_F32 : VOPCX_F32 <vopc<0x12, 0x52>, "v_cmpx_eq_f32">;
526 defm V_CMPX_LE_F32 : VOPCX_F32 <vopc<0x13, 0x53>, "v_cmpx_le_f32">;
527 defm V_CMPX_GT_F32 : VOPCX_F32 <vopc<0x14, 0x54>, "v_cmpx_gt_f32">;
528 defm V_CMPX_LG_F32 : VOPCX_F32 <vopc<0x15, 0x55>, "v_cmpx_lg_f32">;
529 defm V_CMPX_GE_F32 : VOPCX_F32 <vopc<0x16, 0x56>, "v_cmpx_ge_f32">;
530 defm V_CMPX_O_F32 : VOPCX_F32 <vopc<0x17, 0x57>, "v_cmpx_o_f32">;
531 defm V_CMPX_U_F32 : VOPCX_F32 <vopc<0x18, 0x58>, "v_cmpx_u_f32">;
532 defm V_CMPX_NGE_F32 : VOPCX_F32 <vopc<0x19, 0x59>, "v_cmpx_nge_f32">;
533 defm V_CMPX_NLG_F32 : VOPCX_F32 <vopc<0x1a, 0x5a>, "v_cmpx_nlg_f32">;
534 defm V_CMPX_NGT_F32 : VOPCX_F32 <vopc<0x1b, 0x5b>, "v_cmpx_ngt_f32">;
535 defm V_CMPX_NLE_F32 : VOPCX_F32 <vopc<0x1c, 0x5c>, "v_cmpx_nle_f32">;
536 defm V_CMPX_NEQ_F32 : VOPCX_F32 <vopc<0x1d, 0x5d>, "v_cmpx_neq_f32">;
537 defm V_CMPX_NLT_F32 : VOPCX_F32 <vopc<0x1e, 0x5e>, "v_cmpx_nlt_f32">;
538 defm V_CMPX_TRU_F32 : VOPCX_F32 <vopc<0x1f, 0x5f>, "v_cmpx_tru_f32">;
540 } // End hasSideEffects = 1
542 defm V_CMP_F_F64 : VOPC_F64 <vopc<0x20, 0x60>, "v_cmp_f_f64">;
543 defm V_CMP_LT_F64 : VOPC_F64 <vopc<0x21, 0x61>, "v_cmp_lt_f64", COND_OLT>;
544 defm V_CMP_EQ_F64 : VOPC_F64 <vopc<0x22, 0x62>, "v_cmp_eq_f64", COND_OEQ>;
545 defm V_CMP_LE_F64 : VOPC_F64 <vopc<0x23, 0x63>, "v_cmp_le_f64", COND_OLE>;
546 defm V_CMP_GT_F64 : VOPC_F64 <vopc<0x24, 0x64>, "v_cmp_gt_f64", COND_OGT>;
547 defm V_CMP_LG_F64 : VOPC_F64 <vopc<0x25, 0x65>, "v_cmp_lg_f64", COND_ONE>;
548 defm V_CMP_GE_F64 : VOPC_F64 <vopc<0x26, 0x66>, "v_cmp_ge_f64", COND_OGE>;
549 defm V_CMP_O_F64 : VOPC_F64 <vopc<0x27, 0x67>, "v_cmp_o_f64", COND_O>;
550 defm V_CMP_U_F64 : VOPC_F64 <vopc<0x28, 0x68>, "v_cmp_u_f64", COND_UO>;
551 defm V_CMP_NGE_F64 : VOPC_F64 <vopc<0x29, 0x69>, "v_cmp_nge_f64", COND_ULT>;
552 defm V_CMP_NLG_F64 : VOPC_F64 <vopc<0x2a, 0x6a>, "v_cmp_nlg_f64", COND_UEQ>;
553 defm V_CMP_NGT_F64 : VOPC_F64 <vopc<0x2b, 0x6b>, "v_cmp_ngt_f64", COND_ULE>;
554 defm V_CMP_NLE_F64 : VOPC_F64 <vopc<0x2c, 0x6c>, "v_cmp_nle_f64", COND_UGT>;
555 defm V_CMP_NEQ_F64 : VOPC_F64 <vopc<0x2d, 0x6d>, "v_cmp_neq_f64", COND_UNE>;
556 defm V_CMP_NLT_F64 : VOPC_F64 <vopc<0x2e, 0x6e>, "v_cmp_nlt_f64", COND_UGE>;
557 defm V_CMP_TRU_F64 : VOPC_F64 <vopc<0x2f, 0x6f>, "v_cmp_tru_f64">;
559 let hasSideEffects = 1 in {
561 defm V_CMPX_F_F64 : VOPCX_F64 <vopc<0x30, 0x70>, "v_cmpx_f_f64">;
562 defm V_CMPX_LT_F64 : VOPCX_F64 <vopc<0x31, 0x71>, "v_cmpx_lt_f64">;
563 defm V_CMPX_EQ_F64 : VOPCX_F64 <vopc<0x32, 0x72>, "v_cmpx_eq_f64">;
564 defm V_CMPX_LE_F64 : VOPCX_F64 <vopc<0x33, 0x73>, "v_cmpx_le_f64">;
565 defm V_CMPX_GT_F64 : VOPCX_F64 <vopc<0x34, 0x74>, "v_cmpx_gt_f64">;
566 defm V_CMPX_LG_F64 : VOPCX_F64 <vopc<0x35, 0x75>, "v_cmpx_lg_f64">;
567 defm V_CMPX_GE_F64 : VOPCX_F64 <vopc<0x36, 0x76>, "v_cmpx_ge_f64">;
568 defm V_CMPX_O_F64 : VOPCX_F64 <vopc<0x37, 0x77>, "v_cmpx_o_f64">;
569 defm V_CMPX_U_F64 : VOPCX_F64 <vopc<0x38, 0x78>, "v_cmpx_u_f64">;
570 defm V_CMPX_NGE_F64 : VOPCX_F64 <vopc<0x39, 0x79>, "v_cmpx_nge_f64">;
571 defm V_CMPX_NLG_F64 : VOPCX_F64 <vopc<0x3a, 0x7a>, "v_cmpx_nlg_f64">;
572 defm V_CMPX_NGT_F64 : VOPCX_F64 <vopc<0x3b, 0x7b>, "v_cmpx_ngt_f64">;
573 defm V_CMPX_NLE_F64 : VOPCX_F64 <vopc<0x3c, 0x7c>, "v_cmpx_nle_f64">;
574 defm V_CMPX_NEQ_F64 : VOPCX_F64 <vopc<0x3d, 0x7d>, "v_cmpx_neq_f64">;
575 defm V_CMPX_NLT_F64 : VOPCX_F64 <vopc<0x3e, 0x7e>, "v_cmpx_nlt_f64">;
576 defm V_CMPX_TRU_F64 : VOPCX_F64 <vopc<0x3f, 0x7f>, "v_cmpx_tru_f64">;
578 } // End hasSideEffects = 1
580 let SubtargetPredicate = isSICI in {
582 defm V_CMPS_F_F32 : VOPC_F32 <vopc<0x40>, "v_cmps_f_f32">;
583 defm V_CMPS_LT_F32 : VOPC_F32 <vopc<0x41>, "v_cmps_lt_f32">;
584 defm V_CMPS_EQ_F32 : VOPC_F32 <vopc<0x42>, "v_cmps_eq_f32">;
585 defm V_CMPS_LE_F32 : VOPC_F32 <vopc<0x43>, "v_cmps_le_f32">;
586 defm V_CMPS_GT_F32 : VOPC_F32 <vopc<0x44>, "v_cmps_gt_f32">;
587 defm V_CMPS_LG_F32 : VOPC_F32 <vopc<0x45>, "v_cmps_lg_f32">;
588 defm V_CMPS_GE_F32 : VOPC_F32 <vopc<0x46>, "v_cmps_ge_f32">;
589 defm V_CMPS_O_F32 : VOPC_F32 <vopc<0x47>, "v_cmps_o_f32">;
590 defm V_CMPS_U_F32 : VOPC_F32 <vopc<0x48>, "v_cmps_u_f32">;
591 defm V_CMPS_NGE_F32 : VOPC_F32 <vopc<0x49>, "v_cmps_nge_f32">;
592 defm V_CMPS_NLG_F32 : VOPC_F32 <vopc<0x4a>, "v_cmps_nlg_f32">;
593 defm V_CMPS_NGT_F32 : VOPC_F32 <vopc<0x4b>, "v_cmps_ngt_f32">;
594 defm V_CMPS_NLE_F32 : VOPC_F32 <vopc<0x4c>, "v_cmps_nle_f32">;
595 defm V_CMPS_NEQ_F32 : VOPC_F32 <vopc<0x4d>, "v_cmps_neq_f32">;
596 defm V_CMPS_NLT_F32 : VOPC_F32 <vopc<0x4e>, "v_cmps_nlt_f32">;
597 defm V_CMPS_TRU_F32 : VOPC_F32 <vopc<0x4f>, "v_cmps_tru_f32">;
599 let hasSideEffects = 1 in {
601 defm V_CMPSX_F_F32 : VOPCX_F32 <vopc<0x50>, "v_cmpsx_f_f32">;
602 defm V_CMPSX_LT_F32 : VOPCX_F32 <vopc<0x51>, "v_cmpsx_lt_f32">;
603 defm V_CMPSX_EQ_F32 : VOPCX_F32 <vopc<0x52>, "v_cmpsx_eq_f32">;
604 defm V_CMPSX_LE_F32 : VOPCX_F32 <vopc<0x53>, "v_cmpsx_le_f32">;
605 defm V_CMPSX_GT_F32 : VOPCX_F32 <vopc<0x54>, "v_cmpsx_gt_f32">;
606 defm V_CMPSX_LG_F32 : VOPCX_F32 <vopc<0x55>, "v_cmpsx_lg_f32">;
607 defm V_CMPSX_GE_F32 : VOPCX_F32 <vopc<0x56>, "v_cmpsx_ge_f32">;
608 defm V_CMPSX_O_F32 : VOPCX_F32 <vopc<0x57>, "v_cmpsx_o_f32">;
609 defm V_CMPSX_U_F32 : VOPCX_F32 <vopc<0x58>, "v_cmpsx_u_f32">;
610 defm V_CMPSX_NGE_F32 : VOPCX_F32 <vopc<0x59>, "v_cmpsx_nge_f32">;
611 defm V_CMPSX_NLG_F32 : VOPCX_F32 <vopc<0x5a>, "v_cmpsx_nlg_f32">;
612 defm V_CMPSX_NGT_F32 : VOPCX_F32 <vopc<0x5b>, "v_cmpsx_ngt_f32">;
613 defm V_CMPSX_NLE_F32 : VOPCX_F32 <vopc<0x5c>, "v_cmpsx_nle_f32">;
614 defm V_CMPSX_NEQ_F32 : VOPCX_F32 <vopc<0x5d>, "v_cmpsx_neq_f32">;
615 defm V_CMPSX_NLT_F32 : VOPCX_F32 <vopc<0x5e>, "v_cmpsx_nlt_f32">;
616 defm V_CMPSX_TRU_F32 : VOPCX_F32 <vopc<0x5f>, "v_cmpsx_tru_f32">;
618 } // End hasSideEffects = 1
620 defm V_CMPS_F_F64 : VOPC_F64 <vopc<0x60>, "v_cmps_f_f64">;
621 defm V_CMPS_LT_F64 : VOPC_F64 <vopc<0x61>, "v_cmps_lt_f64">;
622 defm V_CMPS_EQ_F64 : VOPC_F64 <vopc<0x62>, "v_cmps_eq_f64">;
623 defm V_CMPS_LE_F64 : VOPC_F64 <vopc<0x63>, "v_cmps_le_f64">;
624 defm V_CMPS_GT_F64 : VOPC_F64 <vopc<0x64>, "v_cmps_gt_f64">;
625 defm V_CMPS_LG_F64 : VOPC_F64 <vopc<0x65>, "v_cmps_lg_f64">;
626 defm V_CMPS_GE_F64 : VOPC_F64 <vopc<0x66>, "v_cmps_ge_f64">;
627 defm V_CMPS_O_F64 : VOPC_F64 <vopc<0x67>, "v_cmps_o_f64">;
628 defm V_CMPS_U_F64 : VOPC_F64 <vopc<0x68>, "v_cmps_u_f64">;
629 defm V_CMPS_NGE_F64 : VOPC_F64 <vopc<0x69>, "v_cmps_nge_f64">;
630 defm V_CMPS_NLG_F64 : VOPC_F64 <vopc<0x6a>, "v_cmps_nlg_f64">;
631 defm V_CMPS_NGT_F64 : VOPC_F64 <vopc<0x6b>, "v_cmps_ngt_f64">;
632 defm V_CMPS_NLE_F64 : VOPC_F64 <vopc<0x6c>, "v_cmps_nle_f64">;
633 defm V_CMPS_NEQ_F64 : VOPC_F64 <vopc<0x6d>, "v_cmps_neq_f64">;
634 defm V_CMPS_NLT_F64 : VOPC_F64 <vopc<0x6e>, "v_cmps_nlt_f64">;
635 defm V_CMPS_TRU_F64 : VOPC_F64 <vopc<0x6f>, "v_cmps_tru_f64">;
637 let hasSideEffects = 1, Defs = [EXEC] in {
639 defm V_CMPSX_F_F64 : VOPC_F64 <vopc<0x70>, "v_cmpsx_f_f64">;
640 defm V_CMPSX_LT_F64 : VOPC_F64 <vopc<0x71>, "v_cmpsx_lt_f64">;
641 defm V_CMPSX_EQ_F64 : VOPC_F64 <vopc<0x72>, "v_cmpsx_eq_f64">;
642 defm V_CMPSX_LE_F64 : VOPC_F64 <vopc<0x73>, "v_cmpsx_le_f64">;
643 defm V_CMPSX_GT_F64 : VOPC_F64 <vopc<0x74>, "v_cmpsx_gt_f64">;
644 defm V_CMPSX_LG_F64 : VOPC_F64 <vopc<0x75>, "v_cmpsx_lg_f64">;
645 defm V_CMPSX_GE_F64 : VOPC_F64 <vopc<0x76>, "v_cmpsx_ge_f64">;
646 defm V_CMPSX_O_F64 : VOPC_F64 <vopc<0x77>, "v_cmpsx_o_f64">;
647 defm V_CMPSX_U_F64 : VOPC_F64 <vopc<0x78>, "v_cmpsx_u_f64">;
648 defm V_CMPSX_NGE_F64 : VOPC_F64 <vopc<0x79>, "v_cmpsx_nge_f64">;
649 defm V_CMPSX_NLG_F64 : VOPC_F64 <vopc<0x7a>, "v_cmpsx_nlg_f64">;
650 defm V_CMPSX_NGT_F64 : VOPC_F64 <vopc<0x7b>, "v_cmpsx_ngt_f64">;
651 defm V_CMPSX_NLE_F64 : VOPC_F64 <vopc<0x7c>, "v_cmpsx_nle_f64">;
652 defm V_CMPSX_NEQ_F64 : VOPC_F64 <vopc<0x7d>, "v_cmpsx_neq_f64">;
653 defm V_CMPSX_NLT_F64 : VOPC_F64 <vopc<0x7e>, "v_cmpsx_nlt_f64">;
654 defm V_CMPSX_TRU_F64 : VOPC_F64 <vopc<0x7f>, "v_cmpsx_tru_f64">;
656 } // End hasSideEffects = 1, Defs = [EXEC]
658 } // End SubtargetPredicate = isSICI
660 defm V_CMP_F_I32 : VOPC_I32 <vopc<0x80, 0xc0>, "v_cmp_f_i32">;
661 defm V_CMP_LT_I32 : VOPC_I32 <vopc<0x81, 0xc1>, "v_cmp_lt_i32", COND_SLT>;
662 defm V_CMP_EQ_I32 : VOPC_I32 <vopc<0x82, 0xc2>, "v_cmp_eq_i32", COND_EQ>;
663 defm V_CMP_LE_I32 : VOPC_I32 <vopc<0x83, 0xc3>, "v_cmp_le_i32", COND_SLE>;
664 defm V_CMP_GT_I32 : VOPC_I32 <vopc<0x84, 0xc4>, "v_cmp_gt_i32", COND_SGT>;
665 defm V_CMP_NE_I32 : VOPC_I32 <vopc<0x85, 0xc5>, "v_cmp_ne_i32", COND_NE>;
666 defm V_CMP_GE_I32 : VOPC_I32 <vopc<0x86, 0xc6>, "v_cmp_ge_i32", COND_SGE>;
667 defm V_CMP_T_I32 : VOPC_I32 <vopc<0x87, 0xc7>, "v_cmp_t_i32">;
669 let hasSideEffects = 1 in {
671 defm V_CMPX_F_I32 : VOPCX_I32 <vopc<0x90, 0xd0>, "v_cmpx_f_i32">;
672 defm V_CMPX_LT_I32 : VOPCX_I32 <vopc<0x91, 0xd1>, "v_cmpx_lt_i32">;
673 defm V_CMPX_EQ_I32 : VOPCX_I32 <vopc<0x92, 0xd2>, "v_cmpx_eq_i32">;
674 defm V_CMPX_LE_I32 : VOPCX_I32 <vopc<0x93, 0xd3>, "v_cmpx_le_i32">;
675 defm V_CMPX_GT_I32 : VOPCX_I32 <vopc<0x94, 0xd4>, "v_cmpx_gt_i32">;
676 defm V_CMPX_NE_I32 : VOPCX_I32 <vopc<0x95, 0xd5>, "v_cmpx_ne_i32">;
677 defm V_CMPX_GE_I32 : VOPCX_I32 <vopc<0x96, 0xd6>, "v_cmpx_ge_i32">;
678 defm V_CMPX_T_I32 : VOPCX_I32 <vopc<0x97, 0xd7>, "v_cmpx_t_i32">;
680 } // End hasSideEffects = 1
682 defm V_CMP_F_I64 : VOPC_I64 <vopc<0xa0, 0xe0>, "v_cmp_f_i64">;
683 defm V_CMP_LT_I64 : VOPC_I64 <vopc<0xa1, 0xe1>, "v_cmp_lt_i64", COND_SLT>;
684 defm V_CMP_EQ_I64 : VOPC_I64 <vopc<0xa2, 0xe2>, "v_cmp_eq_i64", COND_EQ>;
685 defm V_CMP_LE_I64 : VOPC_I64 <vopc<0xa3, 0xe3>, "v_cmp_le_i64", COND_SLE>;
686 defm V_CMP_GT_I64 : VOPC_I64 <vopc<0xa4, 0xe4>, "v_cmp_gt_i64", COND_SGT>;
687 defm V_CMP_NE_I64 : VOPC_I64 <vopc<0xa5, 0xe5>, "v_cmp_ne_i64", COND_NE>;
688 defm V_CMP_GE_I64 : VOPC_I64 <vopc<0xa6, 0xe6>, "v_cmp_ge_i64", COND_SGE>;
689 defm V_CMP_T_I64 : VOPC_I64 <vopc<0xa7, 0xe7>, "v_cmp_t_i64">;
691 let hasSideEffects = 1 in {
693 defm V_CMPX_F_I64 : VOPCX_I64 <vopc<0xb0, 0xf0>, "v_cmpx_f_i64">;
694 defm V_CMPX_LT_I64 : VOPCX_I64 <vopc<0xb1, 0xf1>, "v_cmpx_lt_i64">;
695 defm V_CMPX_EQ_I64 : VOPCX_I64 <vopc<0xb2, 0xf2>, "v_cmpx_eq_i64">;
696 defm V_CMPX_LE_I64 : VOPCX_I64 <vopc<0xb3, 0xf3>, "v_cmpx_le_i64">;
697 defm V_CMPX_GT_I64 : VOPCX_I64 <vopc<0xb4, 0xf4>, "v_cmpx_gt_i64">;
698 defm V_CMPX_NE_I64 : VOPCX_I64 <vopc<0xb5, 0xf5>, "v_cmpx_ne_i64">;
699 defm V_CMPX_GE_I64 : VOPCX_I64 <vopc<0xb6, 0xf6>, "v_cmpx_ge_i64">;
700 defm V_CMPX_T_I64 : VOPCX_I64 <vopc<0xb7, 0xf7>, "v_cmpx_t_i64">;
702 } // End hasSideEffects = 1
704 defm V_CMP_F_U32 : VOPC_I32 <vopc<0xc0, 0xc8>, "v_cmp_f_u32">;
705 defm V_CMP_LT_U32 : VOPC_I32 <vopc<0xc1, 0xc9>, "v_cmp_lt_u32", COND_ULT>;
706 defm V_CMP_EQ_U32 : VOPC_I32 <vopc<0xc2, 0xca>, "v_cmp_eq_u32", COND_EQ>;
707 defm V_CMP_LE_U32 : VOPC_I32 <vopc<0xc3, 0xcb>, "v_cmp_le_u32", COND_ULE>;
708 defm V_CMP_GT_U32 : VOPC_I32 <vopc<0xc4, 0xcc>, "v_cmp_gt_u32", COND_UGT>;
709 defm V_CMP_NE_U32 : VOPC_I32 <vopc<0xc5, 0xcd>, "v_cmp_ne_u32", COND_NE>;
710 defm V_CMP_GE_U32 : VOPC_I32 <vopc<0xc6, 0xce>, "v_cmp_ge_u32", COND_UGE>;
711 defm V_CMP_T_U32 : VOPC_I32 <vopc<0xc7, 0xcf>, "v_cmp_t_u32">;
713 let hasSideEffects = 1 in {
715 defm V_CMPX_F_U32 : VOPCX_I32 <vopc<0xd0, 0xd8>, "v_cmpx_f_u32">;
716 defm V_CMPX_LT_U32 : VOPCX_I32 <vopc<0xd1, 0xd9>, "v_cmpx_lt_u32">;
717 defm V_CMPX_EQ_U32 : VOPCX_I32 <vopc<0xd2, 0xda>, "v_cmpx_eq_u32">;
718 defm V_CMPX_LE_U32 : VOPCX_I32 <vopc<0xd3, 0xdb>, "v_cmpx_le_u32">;
719 defm V_CMPX_GT_U32 : VOPCX_I32 <vopc<0xd4, 0xdc>, "v_cmpx_gt_u32">;
720 defm V_CMPX_NE_U32 : VOPCX_I32 <vopc<0xd5, 0xdd>, "v_cmpx_ne_u32">;
721 defm V_CMPX_GE_U32 : VOPCX_I32 <vopc<0xd6, 0xde>, "v_cmpx_ge_u32">;
722 defm V_CMPX_T_U32 : VOPCX_I32 <vopc<0xd7, 0xdf>, "v_cmpx_t_u32">;
724 } // End hasSideEffects = 1
726 defm V_CMP_F_U64 : VOPC_I64 <vopc<0xe0, 0xe8>, "v_cmp_f_u64">;
727 defm V_CMP_LT_U64 : VOPC_I64 <vopc<0xe1, 0xe9>, "v_cmp_lt_u64", COND_ULT>;
728 defm V_CMP_EQ_U64 : VOPC_I64 <vopc<0xe2, 0xea>, "v_cmp_eq_u64", COND_EQ>;
729 defm V_CMP_LE_U64 : VOPC_I64 <vopc<0xe3, 0xeb>, "v_cmp_le_u64", COND_ULE>;
730 defm V_CMP_GT_U64 : VOPC_I64 <vopc<0xe4, 0xec>, "v_cmp_gt_u64", COND_UGT>;
731 defm V_CMP_NE_U64 : VOPC_I64 <vopc<0xe5, 0xed>, "v_cmp_ne_u64", COND_NE>;
732 defm V_CMP_GE_U64 : VOPC_I64 <vopc<0xe6, 0xee>, "v_cmp_ge_u64", COND_UGE>;
733 defm V_CMP_T_U64 : VOPC_I64 <vopc<0xe7, 0xef>, "v_cmp_t_u64">;
735 let hasSideEffects = 1 in {
737 defm V_CMPX_F_U64 : VOPCX_I64 <vopc<0xf0, 0xf8>, "v_cmpx_f_u64">;
738 defm V_CMPX_LT_U64 : VOPCX_I64 <vopc<0xf1, 0xf9>, "v_cmpx_lt_u64">;
739 defm V_CMPX_EQ_U64 : VOPCX_I64 <vopc<0xf2, 0xfa>, "v_cmpx_eq_u64">;
740 defm V_CMPX_LE_U64 : VOPCX_I64 <vopc<0xf3, 0xfb>, "v_cmpx_le_u64">;
741 defm V_CMPX_GT_U64 : VOPCX_I64 <vopc<0xf4, 0xfc>, "v_cmpx_gt_u64">;
742 defm V_CMPX_NE_U64 : VOPCX_I64 <vopc<0xf5, 0xfd>, "v_cmpx_ne_u64">;
743 defm V_CMPX_GE_U64 : VOPCX_I64 <vopc<0xf6, 0xfe>, "v_cmpx_ge_u64">;
744 defm V_CMPX_T_U64 : VOPCX_I64 <vopc<0xf7, 0xff>, "v_cmpx_t_u64">;
746 } // End hasSideEffects = 1
748 defm V_CMP_CLASS_F32 : VOPC_CLASS_F32 <vopc<0x88, 0x10>, "v_cmp_class_f32">;
750 let hasSideEffects = 1 in {
751 defm V_CMPX_CLASS_F32 : VOPCX_CLASS_F32 <vopc<0x98, 0x11>, "v_cmpx_class_f32">;
752 } // End hasSideEffects = 1
754 defm V_CMP_CLASS_F64 : VOPC_CLASS_F64 <vopc<0xa8, 0x12>, "v_cmp_class_f64">;
756 let hasSideEffects = 1 in {
757 defm V_CMPX_CLASS_F64 : VOPCX_CLASS_F64 <vopc<0xb8, 0x13>, "v_cmpx_class_f64">;
758 } // End hasSideEffects = 1
760 } // End isCompare = 1
762 //===----------------------------------------------------------------------===//
764 //===----------------------------------------------------------------------===//
767 def DS_ADD_U32 : DS_1A1D_NORET <0x0, "ds_add_u32", VGPR_32>;
768 def DS_SUB_U32 : DS_1A1D_NORET <0x1, "ds_sub_u32", VGPR_32>;
769 def DS_RSUB_U32 : DS_1A1D_NORET <0x2, "ds_rsub_u32", VGPR_32>;
770 def DS_INC_U32 : DS_1A1D_NORET <0x3, "ds_inc_u32", VGPR_32>;
771 def DS_DEC_U32 : DS_1A1D_NORET <0x4, "ds_dec_u32", VGPR_32>;
772 def DS_MIN_I32 : DS_1A1D_NORET <0x5, "ds_min_i32", VGPR_32>;
773 def DS_MAX_I32 : DS_1A1D_NORET <0x6, "ds_max_i32", VGPR_32>;
774 def DS_MIN_U32 : DS_1A1D_NORET <0x7, "ds_min_u32", VGPR_32>;
775 def DS_MAX_U32 : DS_1A1D_NORET <0x8, "ds_max_u32", VGPR_32>;
776 def DS_AND_B32 : DS_1A1D_NORET <0x9, "ds_and_b32", VGPR_32>;
777 def DS_OR_B32 : DS_1A1D_NORET <0xa, "ds_or_b32", VGPR_32>;
778 def DS_XOR_B32 : DS_1A1D_NORET <0xb, "ds_xor_b32", VGPR_32>;
779 def DS_MSKOR_B32 : DS_1A1D_NORET <0xc, "ds_mskor_b32", VGPR_32>;
780 def DS_CMPST_B32 : DS_1A2D_NORET <0x10, "ds_cmpst_b32", VGPR_32>;
781 def DS_CMPST_F32 : DS_1A2D_NORET <0x11, "ds_cmpst_f32", VGPR_32>;
782 def DS_MIN_F32 : DS_1A1D_NORET <0x12, "ds_min_f32", VGPR_32>;
783 def DS_MAX_F32 : DS_1A1D_NORET <0x13, "ds_max_f32", VGPR_32>;
785 def DS_ADD_RTN_U32 : DS_1A1D_RET <0x20, "ds_add_rtn_u32", VGPR_32, "ds_add_u32">;
786 def DS_SUB_RTN_U32 : DS_1A1D_RET <0x21, "ds_sub_rtn_u32", VGPR_32, "ds_sub_u32">;
787 def DS_RSUB_RTN_U32 : DS_1A1D_RET <0x22, "ds_rsub_rtn_u32", VGPR_32, "ds_rsub_u32">;
788 def DS_INC_RTN_U32 : DS_1A1D_RET <0x23, "ds_inc_rtn_u32", VGPR_32, "ds_inc_u32">;
789 def DS_DEC_RTN_U32 : DS_1A1D_RET <0x24, "ds_dec_rtn_u32", VGPR_32, "ds_dec_u32">;
790 def DS_MIN_RTN_I32 : DS_1A1D_RET <0x25, "ds_min_rtn_i32", VGPR_32, "ds_min_i32">;
791 def DS_MAX_RTN_I32 : DS_1A1D_RET <0x26, "ds_max_rtn_i32", VGPR_32, "ds_max_i32">;
792 def DS_MIN_RTN_U32 : DS_1A1D_RET <0x27, "ds_min_rtn_u32", VGPR_32, "ds_min_u32">;
793 def DS_MAX_RTN_U32 : DS_1A1D_RET <0x28, "ds_max_rtn_u32", VGPR_32, "ds_max_u32">;
794 def DS_AND_RTN_B32 : DS_1A1D_RET <0x29, "ds_and_rtn_b32", VGPR_32, "ds_and_b32">;
795 def DS_OR_RTN_B32 : DS_1A1D_RET <0x2a, "ds_or_rtn_b32", VGPR_32, "ds_or_b32">;
796 def DS_XOR_RTN_B32 : DS_1A1D_RET <0x2b, "ds_xor_rtn_b32", VGPR_32, "ds_xor_b32">;
797 def DS_MSKOR_RTN_B32 : DS_1A1D_RET <0x2c, "ds_mskor_rtn_b32", VGPR_32, "ds_mskor_b32">;
798 def DS_WRXCHG_RTN_B32 : DS_1A1D_RET <0x2d, "ds_wrxchg_rtn_b32", VGPR_32>;
799 //def DS_WRXCHG2_RTN_B32 : DS_2A0D_RET <0x2e, "ds_wrxchg2_rtn_b32", VGPR_32, "ds_wrxchg2_b32">;
800 //def DS_WRXCHG2ST64_RTN_B32 : DS_2A0D_RET <0x2f, "ds_wrxchg2_rtn_b32", VGPR_32, "ds_wrxchg2st64_b32">;
801 def DS_CMPST_RTN_B32 : DS_1A2D_RET <0x30, "ds_cmpst_rtn_b32", VGPR_32, "ds_cmpst_b32">;
802 def DS_CMPST_RTN_F32 : DS_1A2D_RET <0x31, "ds_cmpst_rtn_f32", VGPR_32, "ds_cmpst_f32">;
803 def DS_MIN_RTN_F32 : DS_1A1D_RET <0x32, "ds_min_rtn_f32", VGPR_32, "ds_min_f32">;
804 def DS_MAX_RTN_F32 : DS_1A1D_RET <0x33, "ds_max_rtn_f32", VGPR_32, "ds_max_f32">;
806 let SubtargetPredicate = isCI in {
807 def DS_WRAP_RTN_F32 : DS_1A1D_RET <0x34, "ds_wrap_rtn_f32", VGPR_32, "ds_wrap_f32">;
811 def DS_ADD_U64 : DS_1A1D_NORET <0x40, "ds_add_u64", VReg_64>;
812 def DS_SUB_U64 : DS_1A1D_NORET <0x41, "ds_sub_u64", VReg_64>;
813 def DS_RSUB_U64 : DS_1A1D_NORET <0x42, "ds_rsub_u64", VReg_64>;
814 def DS_INC_U64 : DS_1A1D_NORET <0x43, "ds_inc_u64", VReg_64>;
815 def DS_DEC_U64 : DS_1A1D_NORET <0x44, "ds_dec_u64", VReg_64>;
816 def DS_MIN_I64 : DS_1A1D_NORET <0x45, "ds_min_i64", VReg_64>;
817 def DS_MAX_I64 : DS_1A1D_NORET <0x46, "ds_max_i64", VReg_64>;
818 def DS_MIN_U64 : DS_1A1D_NORET <0x47, "ds_min_u64", VReg_64>;
819 def DS_MAX_U64 : DS_1A1D_NORET <0x48, "ds_max_u64", VReg_64>;
820 def DS_AND_B64 : DS_1A1D_NORET <0x49, "ds_and_b64", VReg_64>;
821 def DS_OR_B64 : DS_1A1D_NORET <0x4a, "ds_or_b64", VReg_64>;
822 def DS_XOR_B64 : DS_1A1D_NORET <0x4b, "ds_xor_b64", VReg_64>;
823 def DS_MSKOR_B64 : DS_1A1D_NORET <0x4c, "ds_mskor_b64", VReg_64>;
824 def DS_CMPST_B64 : DS_1A2D_NORET <0x50, "ds_cmpst_b64", VReg_64>;
825 def DS_CMPST_F64 : DS_1A2D_NORET <0x51, "ds_cmpst_f64", VReg_64>;
826 def DS_MIN_F64 : DS_1A1D_NORET <0x52, "ds_min_f64", VReg_64>;
827 def DS_MAX_F64 : DS_1A1D_NORET <0x53, "ds_max_f64", VReg_64>;
829 def DS_ADD_RTN_U64 : DS_1A1D_RET <0x60, "ds_add_rtn_u64", VReg_64, "ds_add_u64">;
830 def DS_SUB_RTN_U64 : DS_1A1D_RET <0x61, "ds_sub_rtn_u64", VReg_64, "ds_sub_u64">;
831 def DS_RSUB_RTN_U64 : DS_1A1D_RET <0x62, "ds_rsub_rtn_u64", VReg_64, "ds_rsub_u64">;
832 def DS_INC_RTN_U64 : DS_1A1D_RET <0x63, "ds_inc_rtn_u64", VReg_64, "ds_inc_u64">;
833 def DS_DEC_RTN_U64 : DS_1A1D_RET <0x64, "ds_dec_rtn_u64", VReg_64, "ds_dec_u64">;
834 def DS_MIN_RTN_I64 : DS_1A1D_RET <0x65, "ds_min_rtn_i64", VReg_64, "ds_min_i64">;
835 def DS_MAX_RTN_I64 : DS_1A1D_RET <0x66, "ds_max_rtn_i64", VReg_64, "ds_max_i64">;
836 def DS_MIN_RTN_U64 : DS_1A1D_RET <0x67, "ds_min_rtn_u64", VReg_64, "ds_min_u64">;
837 def DS_MAX_RTN_U64 : DS_1A1D_RET <0x68, "ds_max_rtn_u64", VReg_64, "ds_max_u64">;
838 def DS_AND_RTN_B64 : DS_1A1D_RET <0x69, "ds_and_rtn_b64", VReg_64, "ds_and_b64">;
839 def DS_OR_RTN_B64 : DS_1A1D_RET <0x6a, "ds_or_rtn_b64", VReg_64, "ds_or_b64">;
840 def DS_XOR_RTN_B64 : DS_1A1D_RET <0x6b, "ds_xor_rtn_b64", VReg_64, "ds_xor_b64">;
841 def DS_MSKOR_RTN_B64 : DS_1A1D_RET <0x6c, "ds_mskor_rtn_b64", VReg_64, "ds_mskor_b64">;
842 def DS_WRXCHG_RTN_B64 : DS_1A1D_RET <0x6d, "ds_wrxchg_rtn_b64", VReg_64, "ds_wrxchg_b64">;
843 //def DS_WRXCHG2_RTN_B64 : DS_2A0D_RET <0x6e, "ds_wrxchg2_rtn_b64", VReg_64, "ds_wrxchg2_b64">;
844 //def DS_WRXCHG2ST64_RTN_B64 : DS_2A0D_RET <0x6f, "ds_wrxchg2_rtn_b64", VReg_64, "ds_wrxchg2st64_b64">;
845 def DS_CMPST_RTN_B64 : DS_1A2D_RET <0x70, "ds_cmpst_rtn_b64", VReg_64, "ds_cmpst_b64">;
846 def DS_CMPST_RTN_F64 : DS_1A2D_RET <0x71, "ds_cmpst_rtn_f64", VReg_64, "ds_cmpst_f64">;
847 def DS_MIN_RTN_F64 : DS_1A1D_RET <0x72, "ds_min_f64", VReg_64, "ds_min_f64">;
848 def DS_MAX_RTN_F64 : DS_1A1D_RET <0x73, "ds_max_f64", VReg_64, "ds_max_f64">;
850 //let SubtargetPredicate = isCI in {
851 // DS_CONDXCHG32_RTN_B64
852 // DS_CONDXCHG32_RTN_B128
855 // TODO: _SRC2_* forms
857 defm DS_WRITE_B32 : DS_Store_Helper <0x0000000d, "ds_write_b32", VGPR_32>;
858 defm DS_WRITE_B8 : DS_Store_Helper <0x00000001e, "ds_write_b8", VGPR_32>;
859 defm DS_WRITE_B16 : DS_Store_Helper <0x00000001f, "ds_write_b16", VGPR_32>;
860 defm DS_WRITE_B64 : DS_Store_Helper <0x00000004d, "ds_write_b64", VReg_64>;
862 defm DS_READ_B32 : DS_Load_Helper <0x00000036, "ds_read_b32", VGPR_32>;
863 defm DS_READ_I8 : DS_Load_Helper <0x00000039, "ds_read_i8", VGPR_32>;
864 defm DS_READ_U8 : DS_Load_Helper <0x0000003a, "ds_read_u8", VGPR_32>;
865 defm DS_READ_I16 : DS_Load_Helper <0x0000003b, "ds_read_i16", VGPR_32>;
866 defm DS_READ_U16 : DS_Load_Helper <0x0000003c, "ds_read_u16", VGPR_32>;
867 defm DS_READ_B64 : DS_Load_Helper <0x00000076, "ds_read_b64", VReg_64>;
870 defm DS_WRITE2_B32 : DS_Store2_Helper <0x0000000E, "ds_write2_b32", VGPR_32>;
871 defm DS_WRITE2ST64_B32 : DS_Store2_Helper <0x0000000F, "ds_write2st64_b32", VGPR_32>;
872 defm DS_WRITE2_B64 : DS_Store2_Helper <0x0000004E, "ds_write2_b64", VReg_64>;
873 defm DS_WRITE2ST64_B64 : DS_Store2_Helper <0x0000004F, "ds_write2st64_b64", VReg_64>;
875 defm DS_READ2_B32 : DS_Load2_Helper <0x00000037, "ds_read2_b32", VReg_64>;
876 defm DS_READ2ST64_B32 : DS_Load2_Helper <0x00000038, "ds_read2st64_b32", VReg_64>;
877 defm DS_READ2_B64 : DS_Load2_Helper <0x00000075, "ds_read2_b64", VReg_128>;
878 defm DS_READ2ST64_B64 : DS_Load2_Helper <0x00000076, "ds_read2st64_b64", VReg_128>;
880 //===----------------------------------------------------------------------===//
881 // MUBUF Instructions
882 //===----------------------------------------------------------------------===//
884 let SubtargetPredicate = isSICI in {
886 //def BUFFER_LOAD_FORMAT_X : MUBUF_ <0x00000000, "buffer_load_format_x", []>;
887 //def BUFFER_LOAD_FORMAT_XY : MUBUF_ <0x00000001, "buffer_load_format_xy", []>;
888 //def BUFFER_LOAD_FORMAT_XYZ : MUBUF_ <0x00000002, "buffer_load_format_xyz", []>;
889 defm BUFFER_LOAD_FORMAT_XYZW : MUBUF_Load_Helper <0x00000003, "buffer_load_format_xyzw", VReg_128>;
890 //def BUFFER_STORE_FORMAT_X : MUBUF_ <0x00000004, "buffer_store_format_x", []>;
891 //def BUFFER_STORE_FORMAT_XY : MUBUF_ <0x00000005, "buffer_store_format_xy", []>;
892 //def BUFFER_STORE_FORMAT_XYZ : MUBUF_ <0x00000006, "buffer_store_format_xyz", []>;
893 //def BUFFER_STORE_FORMAT_XYZW : MUBUF_ <0x00000007, "buffer_store_format_xyzw", []>;
894 defm BUFFER_LOAD_UBYTE : MUBUF_Load_Helper <
895 0x00000008, "buffer_load_ubyte", VGPR_32, i32, az_extloadi8_global
897 defm BUFFER_LOAD_SBYTE : MUBUF_Load_Helper <
898 0x00000009, "buffer_load_sbyte", VGPR_32, i32, sextloadi8_global
900 defm BUFFER_LOAD_USHORT : MUBUF_Load_Helper <
901 0x0000000a, "buffer_load_ushort", VGPR_32, i32, az_extloadi16_global
903 defm BUFFER_LOAD_SSHORT : MUBUF_Load_Helper <
904 0x0000000b, "buffer_load_sshort", VGPR_32, i32, sextloadi16_global
906 defm BUFFER_LOAD_DWORD : MUBUF_Load_Helper <
907 0x0000000c, "buffer_load_dword", VGPR_32, i32, global_load
909 defm BUFFER_LOAD_DWORDX2 : MUBUF_Load_Helper <
910 0x0000000d, "buffer_load_dwordx2", VReg_64, v2i32, global_load
912 defm BUFFER_LOAD_DWORDX4 : MUBUF_Load_Helper <
913 0x0000000e, "buffer_load_dwordx4", VReg_128, v4i32, global_load
916 defm BUFFER_STORE_BYTE : MUBUF_Store_Helper <
917 0x00000018, "buffer_store_byte", VGPR_32, i32, truncstorei8_global
920 defm BUFFER_STORE_SHORT : MUBUF_Store_Helper <
921 0x0000001a, "buffer_store_short", VGPR_32, i32, truncstorei16_global
924 defm BUFFER_STORE_DWORD : MUBUF_Store_Helper <
925 0x0000001c, "buffer_store_dword", VGPR_32, i32, global_store
928 defm BUFFER_STORE_DWORDX2 : MUBUF_Store_Helper <
929 0x0000001d, "buffer_store_dwordx2", VReg_64, v2i32, global_store
932 defm BUFFER_STORE_DWORDX4 : MUBUF_Store_Helper <
933 0x0000001e, "buffer_store_dwordx4", VReg_128, v4i32, global_store
935 //def BUFFER_ATOMIC_SWAP : MUBUF_ <0x00000030, "buffer_atomic_swap", []>;
936 defm BUFFER_ATOMIC_SWAP : MUBUF_Atomic <
937 0x00000030, "buffer_atomic_swap", VGPR_32, i32, atomic_swap_global
939 //def BUFFER_ATOMIC_CMPSWAP : MUBUF_ <0x00000031, "buffer_atomic_cmpswap", []>;
940 defm BUFFER_ATOMIC_ADD : MUBUF_Atomic <
941 0x00000032, "buffer_atomic_add", VGPR_32, i32, atomic_add_global
943 defm BUFFER_ATOMIC_SUB : MUBUF_Atomic <
944 0x00000033, "buffer_atomic_sub", VGPR_32, i32, atomic_sub_global
946 //def BUFFER_ATOMIC_RSUB : MUBUF_ <0x00000034, "buffer_atomic_rsub", []>;
947 defm BUFFER_ATOMIC_SMIN : MUBUF_Atomic <
948 0x00000035, "buffer_atomic_smin", VGPR_32, i32, atomic_min_global
950 defm BUFFER_ATOMIC_UMIN : MUBUF_Atomic <
951 0x00000036, "buffer_atomic_umin", VGPR_32, i32, atomic_umin_global
953 defm BUFFER_ATOMIC_SMAX : MUBUF_Atomic <
954 0x00000037, "buffer_atomic_smax", VGPR_32, i32, atomic_max_global
956 defm BUFFER_ATOMIC_UMAX : MUBUF_Atomic <
957 0x00000038, "buffer_atomic_umax", VGPR_32, i32, atomic_umax_global
959 defm BUFFER_ATOMIC_AND : MUBUF_Atomic <
960 0x00000039, "buffer_atomic_and", VGPR_32, i32, atomic_and_global
962 defm BUFFER_ATOMIC_OR : MUBUF_Atomic <
963 0x0000003a, "buffer_atomic_or", VGPR_32, i32, atomic_or_global
965 defm BUFFER_ATOMIC_XOR : MUBUF_Atomic <
966 0x0000003b, "buffer_atomic_xor", VGPR_32, i32, atomic_xor_global
968 //def BUFFER_ATOMIC_INC : MUBUF_ <0x0000003c, "buffer_atomic_inc", []>;
969 //def BUFFER_ATOMIC_DEC : MUBUF_ <0x0000003d, "buffer_atomic_dec", []>;
970 //def BUFFER_ATOMIC_FCMPSWAP : MUBUF_ <0x0000003e, "buffer_atomic_fcmpswap", []>;
971 //def BUFFER_ATOMIC_FMIN : MUBUF_ <0x0000003f, "buffer_atomic_fmin", []>;
972 //def BUFFER_ATOMIC_FMAX : MUBUF_ <0x00000040, "buffer_atomic_fmax", []>;
973 //def BUFFER_ATOMIC_SWAP_X2 : MUBUF_X2 <0x00000050, "buffer_atomic_swap_x2", []>;
974 //def BUFFER_ATOMIC_CMPSWAP_X2 : MUBUF_X2 <0x00000051, "buffer_atomic_cmpswap_x2", []>;
975 //def BUFFER_ATOMIC_ADD_X2 : MUBUF_X2 <0x00000052, "buffer_atomic_add_x2", []>;
976 //def BUFFER_ATOMIC_SUB_X2 : MUBUF_X2 <0x00000053, "buffer_atomic_sub_x2", []>;
977 //def BUFFER_ATOMIC_RSUB_X2 : MUBUF_X2 <0x00000054, "buffer_atomic_rsub_x2", []>;
978 //def BUFFER_ATOMIC_SMIN_X2 : MUBUF_X2 <0x00000055, "buffer_atomic_smin_x2", []>;
979 //def BUFFER_ATOMIC_UMIN_X2 : MUBUF_X2 <0x00000056, "buffer_atomic_umin_x2", []>;
980 //def BUFFER_ATOMIC_SMAX_X2 : MUBUF_X2 <0x00000057, "buffer_atomic_smax_x2", []>;
981 //def BUFFER_ATOMIC_UMAX_X2 : MUBUF_X2 <0x00000058, "buffer_atomic_umax_x2", []>;
982 //def BUFFER_ATOMIC_AND_X2 : MUBUF_X2 <0x00000059, "buffer_atomic_and_x2", []>;
983 //def BUFFER_ATOMIC_OR_X2 : MUBUF_X2 <0x0000005a, "buffer_atomic_or_x2", []>;
984 //def BUFFER_ATOMIC_XOR_X2 : MUBUF_X2 <0x0000005b, "buffer_atomic_xor_x2", []>;
985 //def BUFFER_ATOMIC_INC_X2 : MUBUF_X2 <0x0000005c, "buffer_atomic_inc_x2", []>;
986 //def BUFFER_ATOMIC_DEC_X2 : MUBUF_X2 <0x0000005d, "buffer_atomic_dec_x2", []>;
987 //def BUFFER_ATOMIC_FCMPSWAP_X2 : MUBUF_X2 <0x0000005e, "buffer_atomic_fcmpswap_x2", []>;
988 //def BUFFER_ATOMIC_FMIN_X2 : MUBUF_X2 <0x0000005f, "buffer_atomic_fmin_x2", []>;
989 //def BUFFER_ATOMIC_FMAX_X2 : MUBUF_X2 <0x00000060, "buffer_atomic_fmax_x2", []>;
990 //def BUFFER_WBINVL1_SC : MUBUF_WBINVL1 <0x00000070, "buffer_wbinvl1_sc", []>;
991 //def BUFFER_WBINVL1 : MUBUF_WBINVL1 <0x00000071, "buffer_wbinvl1", []>;
993 } // End SubtargetPredicate = isSICI
995 //===----------------------------------------------------------------------===//
996 // MTBUF Instructions
997 //===----------------------------------------------------------------------===//
999 //def TBUFFER_LOAD_FORMAT_X : MTBUF_ <0x00000000, "tbuffer_load_format_x", []>;
1000 //def TBUFFER_LOAD_FORMAT_XY : MTBUF_ <0x00000001, "tbuffer_load_format_xy", []>;
1001 //def TBUFFER_LOAD_FORMAT_XYZ : MTBUF_ <0x00000002, "tbuffer_load_format_xyz", []>;
1002 defm TBUFFER_LOAD_FORMAT_XYZW : MTBUF_Load_Helper <0x00000003, "tbuffer_load_format_xyzw", VReg_128>;
1003 defm TBUFFER_STORE_FORMAT_X : MTBUF_Store_Helper <0x00000004, "tbuffer_store_format_x", VGPR_32>;
1004 defm TBUFFER_STORE_FORMAT_XY : MTBUF_Store_Helper <0x00000005, "tbuffer_store_format_xy", VReg_64>;
1005 defm TBUFFER_STORE_FORMAT_XYZ : MTBUF_Store_Helper <0x00000006, "tbuffer_store_format_xyz", VReg_128>;
1006 defm TBUFFER_STORE_FORMAT_XYZW : MTBUF_Store_Helper <0x00000007, "tbuffer_store_format_xyzw", VReg_128>;
1008 //===----------------------------------------------------------------------===//
1009 // MIMG Instructions
1010 //===----------------------------------------------------------------------===//
1012 defm IMAGE_LOAD : MIMG_NoSampler <0x00000000, "image_load">;
1013 defm IMAGE_LOAD_MIP : MIMG_NoSampler <0x00000001, "image_load_mip">;
1014 //def IMAGE_LOAD_PCK : MIMG_NoPattern_ <"image_load_pck", 0x00000002>;
1015 //def IMAGE_LOAD_PCK_SGN : MIMG_NoPattern_ <"image_load_pck_sgn", 0x00000003>;
1016 //def IMAGE_LOAD_MIP_PCK : MIMG_NoPattern_ <"image_load_mip_pck", 0x00000004>;
1017 //def IMAGE_LOAD_MIP_PCK_SGN : MIMG_NoPattern_ <"image_load_mip_pck_sgn", 0x00000005>;
1018 //def IMAGE_STORE : MIMG_NoPattern_ <"image_store", 0x00000008>;
1019 //def IMAGE_STORE_MIP : MIMG_NoPattern_ <"image_store_mip", 0x00000009>;
1020 //def IMAGE_STORE_PCK : MIMG_NoPattern_ <"image_store_pck", 0x0000000a>;
1021 //def IMAGE_STORE_MIP_PCK : MIMG_NoPattern_ <"image_store_mip_pck", 0x0000000b>;
1022 defm IMAGE_GET_RESINFO : MIMG_NoSampler <0x0000000e, "image_get_resinfo">;
1023 //def IMAGE_ATOMIC_SWAP : MIMG_NoPattern_ <"image_atomic_swap", 0x0000000f>;
1024 //def IMAGE_ATOMIC_CMPSWAP : MIMG_NoPattern_ <"image_atomic_cmpswap", 0x00000010>;
1025 //def IMAGE_ATOMIC_ADD : MIMG_NoPattern_ <"image_atomic_add", 0x00000011>;
1026 //def IMAGE_ATOMIC_SUB : MIMG_NoPattern_ <"image_atomic_sub", 0x00000012>;
1027 //def IMAGE_ATOMIC_RSUB : MIMG_NoPattern_ <"image_atomic_rsub", 0x00000013>;
1028 //def IMAGE_ATOMIC_SMIN : MIMG_NoPattern_ <"image_atomic_smin", 0x00000014>;
1029 //def IMAGE_ATOMIC_UMIN : MIMG_NoPattern_ <"image_atomic_umin", 0x00000015>;
1030 //def IMAGE_ATOMIC_SMAX : MIMG_NoPattern_ <"image_atomic_smax", 0x00000016>;
1031 //def IMAGE_ATOMIC_UMAX : MIMG_NoPattern_ <"image_atomic_umax", 0x00000017>;
1032 //def IMAGE_ATOMIC_AND : MIMG_NoPattern_ <"image_atomic_and", 0x00000018>;
1033 //def IMAGE_ATOMIC_OR : MIMG_NoPattern_ <"image_atomic_or", 0x00000019>;
1034 //def IMAGE_ATOMIC_XOR : MIMG_NoPattern_ <"image_atomic_xor", 0x0000001a>;
1035 //def IMAGE_ATOMIC_INC : MIMG_NoPattern_ <"image_atomic_inc", 0x0000001b>;
1036 //def IMAGE_ATOMIC_DEC : MIMG_NoPattern_ <"image_atomic_dec", 0x0000001c>;
1037 //def IMAGE_ATOMIC_FCMPSWAP : MIMG_NoPattern_ <"image_atomic_fcmpswap", 0x0000001d>;
1038 //def IMAGE_ATOMIC_FMIN : MIMG_NoPattern_ <"image_atomic_fmin", 0x0000001e>;
1039 //def IMAGE_ATOMIC_FMAX : MIMG_NoPattern_ <"image_atomic_fmax", 0x0000001f>;
1040 defm IMAGE_SAMPLE : MIMG_Sampler <0x00000020, "image_sample">;
1041 defm IMAGE_SAMPLE_CL : MIMG_Sampler <0x00000021, "image_sample_cl">;
1042 defm IMAGE_SAMPLE_D : MIMG_Sampler <0x00000022, "image_sample_d">;
1043 defm IMAGE_SAMPLE_D_CL : MIMG_Sampler <0x00000023, "image_sample_d_cl">;
1044 defm IMAGE_SAMPLE_L : MIMG_Sampler <0x00000024, "image_sample_l">;
1045 defm IMAGE_SAMPLE_B : MIMG_Sampler <0x00000025, "image_sample_b">;
1046 defm IMAGE_SAMPLE_B_CL : MIMG_Sampler <0x00000026, "image_sample_b_cl">;
1047 defm IMAGE_SAMPLE_LZ : MIMG_Sampler <0x00000027, "image_sample_lz">;
1048 defm IMAGE_SAMPLE_C : MIMG_Sampler <0x00000028, "image_sample_c">;
1049 defm IMAGE_SAMPLE_C_CL : MIMG_Sampler <0x00000029, "image_sample_c_cl">;
1050 defm IMAGE_SAMPLE_C_D : MIMG_Sampler <0x0000002a, "image_sample_c_d">;
1051 defm IMAGE_SAMPLE_C_D_CL : MIMG_Sampler <0x0000002b, "image_sample_c_d_cl">;
1052 defm IMAGE_SAMPLE_C_L : MIMG_Sampler <0x0000002c, "image_sample_c_l">;
1053 defm IMAGE_SAMPLE_C_B : MIMG_Sampler <0x0000002d, "image_sample_c_b">;
1054 defm IMAGE_SAMPLE_C_B_CL : MIMG_Sampler <0x0000002e, "image_sample_c_b_cl">;
1055 defm IMAGE_SAMPLE_C_LZ : MIMG_Sampler <0x0000002f, "image_sample_c_lz">;
1056 defm IMAGE_SAMPLE_O : MIMG_Sampler <0x00000030, "image_sample_o">;
1057 defm IMAGE_SAMPLE_CL_O : MIMG_Sampler <0x00000031, "image_sample_cl_o">;
1058 defm IMAGE_SAMPLE_D_O : MIMG_Sampler <0x00000032, "image_sample_d_o">;
1059 defm IMAGE_SAMPLE_D_CL_O : MIMG_Sampler <0x00000033, "image_sample_d_cl_o">;
1060 defm IMAGE_SAMPLE_L_O : MIMG_Sampler <0x00000034, "image_sample_l_o">;
1061 defm IMAGE_SAMPLE_B_O : MIMG_Sampler <0x00000035, "image_sample_b_o">;
1062 defm IMAGE_SAMPLE_B_CL_O : MIMG_Sampler <0x00000036, "image_sample_b_cl_o">;
1063 defm IMAGE_SAMPLE_LZ_O : MIMG_Sampler <0x00000037, "image_sample_lz_o">;
1064 defm IMAGE_SAMPLE_C_O : MIMG_Sampler <0x00000038, "image_sample_c_o">;
1065 defm IMAGE_SAMPLE_C_CL_O : MIMG_Sampler <0x00000039, "image_sample_c_cl_o">;
1066 defm IMAGE_SAMPLE_C_D_O : MIMG_Sampler <0x0000003a, "image_sample_c_d_o">;
1067 defm IMAGE_SAMPLE_C_D_CL_O : MIMG_Sampler <0x0000003b, "image_sample_c_d_cl_o">;
1068 defm IMAGE_SAMPLE_C_L_O : MIMG_Sampler <0x0000003c, "image_sample_c_l_o">;
1069 defm IMAGE_SAMPLE_C_B_O : MIMG_Sampler <0x0000003d, "image_sample_c_b_o">;
1070 defm IMAGE_SAMPLE_C_B_CL_O : MIMG_Sampler <0x0000003e, "image_sample_c_b_cl_o">;
1071 defm IMAGE_SAMPLE_C_LZ_O : MIMG_Sampler <0x0000003f, "image_sample_c_lz_o">;
1072 defm IMAGE_GATHER4 : MIMG_Gather <0x00000040, "image_gather4">;
1073 defm IMAGE_GATHER4_CL : MIMG_Gather <0x00000041, "image_gather4_cl">;
1074 defm IMAGE_GATHER4_L : MIMG_Gather <0x00000044, "image_gather4_l">;
1075 defm IMAGE_GATHER4_B : MIMG_Gather <0x00000045, "image_gather4_b">;
1076 defm IMAGE_GATHER4_B_CL : MIMG_Gather <0x00000046, "image_gather4_b_cl">;
1077 defm IMAGE_GATHER4_LZ : MIMG_Gather <0x00000047, "image_gather4_lz">;
1078 defm IMAGE_GATHER4_C : MIMG_Gather <0x00000048, "image_gather4_c">;
1079 defm IMAGE_GATHER4_C_CL : MIMG_Gather <0x00000049, "image_gather4_c_cl">;
1080 defm IMAGE_GATHER4_C_L : MIMG_Gather <0x0000004c, "image_gather4_c_l">;
1081 defm IMAGE_GATHER4_C_B : MIMG_Gather <0x0000004d, "image_gather4_c_b">;
1082 defm IMAGE_GATHER4_C_B_CL : MIMG_Gather <0x0000004e, "image_gather4_c_b_cl">;
1083 defm IMAGE_GATHER4_C_LZ : MIMG_Gather <0x0000004f, "image_gather4_c_lz">;
1084 defm IMAGE_GATHER4_O : MIMG_Gather <0x00000050, "image_gather4_o">;
1085 defm IMAGE_GATHER4_CL_O : MIMG_Gather <0x00000051, "image_gather4_cl_o">;
1086 defm IMAGE_GATHER4_L_O : MIMG_Gather <0x00000054, "image_gather4_l_o">;
1087 defm IMAGE_GATHER4_B_O : MIMG_Gather <0x00000055, "image_gather4_b_o">;
1088 defm IMAGE_GATHER4_B_CL_O : MIMG_Gather <0x00000056, "image_gather4_b_cl_o">;
1089 defm IMAGE_GATHER4_LZ_O : MIMG_Gather <0x00000057, "image_gather4_lz_o">;
1090 defm IMAGE_GATHER4_C_O : MIMG_Gather <0x00000058, "image_gather4_c_o">;
1091 defm IMAGE_GATHER4_C_CL_O : MIMG_Gather <0x00000059, "image_gather4_c_cl_o">;
1092 defm IMAGE_GATHER4_C_L_O : MIMG_Gather <0x0000005c, "image_gather4_c_l_o">;
1093 defm IMAGE_GATHER4_C_B_O : MIMG_Gather <0x0000005d, "image_gather4_c_b_o">;
1094 defm IMAGE_GATHER4_C_B_CL_O : MIMG_Gather <0x0000005e, "image_gather4_c_b_cl_o">;
1095 defm IMAGE_GATHER4_C_LZ_O : MIMG_Gather <0x0000005f, "image_gather4_c_lz_o">;
1096 defm IMAGE_GET_LOD : MIMG_Sampler <0x00000060, "image_get_lod">;
1097 defm IMAGE_SAMPLE_CD : MIMG_Sampler <0x00000068, "image_sample_cd">;
1098 defm IMAGE_SAMPLE_CD_CL : MIMG_Sampler <0x00000069, "image_sample_cd_cl">;
1099 defm IMAGE_SAMPLE_C_CD : MIMG_Sampler <0x0000006a, "image_sample_c_cd">;
1100 defm IMAGE_SAMPLE_C_CD_CL : MIMG_Sampler <0x0000006b, "image_sample_c_cd_cl">;
1101 defm IMAGE_SAMPLE_CD_O : MIMG_Sampler <0x0000006c, "image_sample_cd_o">;
1102 defm IMAGE_SAMPLE_CD_CL_O : MIMG_Sampler <0x0000006d, "image_sample_cd_cl_o">;
1103 defm IMAGE_SAMPLE_C_CD_O : MIMG_Sampler <0x0000006e, "image_sample_c_cd_o">;
1104 defm IMAGE_SAMPLE_C_CD_CL_O : MIMG_Sampler <0x0000006f, "image_sample_c_cd_cl_o">;
1105 //def IMAGE_RSRC256 : MIMG_NoPattern_RSRC256 <"image_rsrc256", 0x0000007e>;
1106 //def IMAGE_SAMPLER : MIMG_NoPattern_ <"image_sampler", 0x0000007f>;
1108 //===----------------------------------------------------------------------===//
1109 // Flat Instructions
1110 //===----------------------------------------------------------------------===//
1112 let Predicates = [HasFlatAddressSpace] in {
1113 def FLAT_LOAD_UBYTE : FLAT_Load_Helper <0x00000008, "flat_load_ubyte", VGPR_32>;
1114 def FLAT_LOAD_SBYTE : FLAT_Load_Helper <0x00000009, "flat_load_sbyte", VGPR_32>;
1115 def FLAT_LOAD_USHORT : FLAT_Load_Helper <0x0000000a, "flat_load_ushort", VGPR_32>;
1116 def FLAT_LOAD_SSHORT : FLAT_Load_Helper <0x0000000b, "flat_load_sshort", VGPR_32>;
1117 def FLAT_LOAD_DWORD : FLAT_Load_Helper <0x0000000c, "flat_load_dword", VGPR_32>;
1118 def FLAT_LOAD_DWORDX2 : FLAT_Load_Helper <0x0000000d, "flat_load_dwordx2", VReg_64>;
1119 def FLAT_LOAD_DWORDX4 : FLAT_Load_Helper <0x0000000e, "flat_load_dwordx4", VReg_128>;
1120 def FLAT_LOAD_DWORDX3 : FLAT_Load_Helper <0x00000010, "flat_load_dwordx3", VReg_96>;
1122 def FLAT_STORE_BYTE : FLAT_Store_Helper <
1123 0x00000018, "flat_store_byte", VGPR_32
1126 def FLAT_STORE_SHORT : FLAT_Store_Helper <
1127 0x0000001a, "flat_store_short", VGPR_32
1130 def FLAT_STORE_DWORD : FLAT_Store_Helper <
1131 0x0000001c, "flat_store_dword", VGPR_32
1134 def FLAT_STORE_DWORDX2 : FLAT_Store_Helper <
1135 0x0000001d, "flat_store_dwordx2", VReg_64
1138 def FLAT_STORE_DWORDX4 : FLAT_Store_Helper <
1139 0x0000001e, "flat_store_dwordx4", VReg_128
1142 def FLAT_STORE_DWORDX3 : FLAT_Store_Helper <
1143 0x0000001e, "flat_store_dwordx3", VReg_96
1146 //def FLAT_ATOMIC_SWAP : FLAT_ <0x00000030, "flat_atomic_swap", []>;
1147 //def FLAT_ATOMIC_CMPSWAP : FLAT_ <0x00000031, "flat_atomic_cmpswap", []>;
1148 //def FLAT_ATOMIC_ADD : FLAT_ <0x00000032, "flat_atomic_add", []>;
1149 //def FLAT_ATOMIC_SUB : FLAT_ <0x00000033, "flat_atomic_sub", []>;
1150 //def FLAT_ATOMIC_RSUB : FLAT_ <0x00000034, "flat_atomic_rsub", []>;
1151 //def FLAT_ATOMIC_SMIN : FLAT_ <0x00000035, "flat_atomic_smin", []>;
1152 //def FLAT_ATOMIC_UMIN : FLAT_ <0x00000036, "flat_atomic_umin", []>;
1153 //def FLAT_ATOMIC_SMAX : FLAT_ <0x00000037, "flat_atomic_smax", []>;
1154 //def FLAT_ATOMIC_UMAX : FLAT_ <0x00000038, "flat_atomic_umax", []>;
1155 //def FLAT_ATOMIC_AND : FLAT_ <0x00000039, "flat_atomic_and", []>;
1156 //def FLAT_ATOMIC_OR : FLAT_ <0x0000003a, "flat_atomic_or", []>;
1157 //def FLAT_ATOMIC_XOR : FLAT_ <0x0000003b, "flat_atomic_xor", []>;
1158 //def FLAT_ATOMIC_INC : FLAT_ <0x0000003c, "flat_atomic_inc", []>;
1159 //def FLAT_ATOMIC_DEC : FLAT_ <0x0000003d, "flat_atomic_dec", []>;
1160 //def FLAT_ATOMIC_FCMPSWAP : FLAT_ <0x0000003e, "flat_atomic_fcmpswap", []>;
1161 //def FLAT_ATOMIC_FMIN : FLAT_ <0x0000003f, "flat_atomic_fmin", []>;
1162 //def FLAT_ATOMIC_FMAX : FLAT_ <0x00000040, "flat_atomic_fmax", []>;
1163 //def FLAT_ATOMIC_SWAP_X2 : FLAT_X2 <0x00000050, "flat_atomic_swap_x2", []>;
1164 //def FLAT_ATOMIC_CMPSWAP_X2 : FLAT_X2 <0x00000051, "flat_atomic_cmpswap_x2", []>;
1165 //def FLAT_ATOMIC_ADD_X2 : FLAT_X2 <0x00000052, "flat_atomic_add_x2", []>;
1166 //def FLAT_ATOMIC_SUB_X2 : FLAT_X2 <0x00000053, "flat_atomic_sub_x2", []>;
1167 //def FLAT_ATOMIC_RSUB_X2 : FLAT_X2 <0x00000054, "flat_atomic_rsub_x2", []>;
1168 //def FLAT_ATOMIC_SMIN_X2 : FLAT_X2 <0x00000055, "flat_atomic_smin_x2", []>;
1169 //def FLAT_ATOMIC_UMIN_X2 : FLAT_X2 <0x00000056, "flat_atomic_umin_x2", []>;
1170 //def FLAT_ATOMIC_SMAX_X2 : FLAT_X2 <0x00000057, "flat_atomic_smax_x2", []>;
1171 //def FLAT_ATOMIC_UMAX_X2 : FLAT_X2 <0x00000058, "flat_atomic_umax_x2", []>;
1172 //def FLAT_ATOMIC_AND_X2 : FLAT_X2 <0x00000059, "flat_atomic_and_x2", []>;
1173 //def FLAT_ATOMIC_OR_X2 : FLAT_X2 <0x0000005a, "flat_atomic_or_x2", []>;
1174 //def FLAT_ATOMIC_XOR_X2 : FLAT_X2 <0x0000005b, "flat_atomic_xor_x2", []>;
1175 //def FLAT_ATOMIC_INC_X2 : FLAT_X2 <0x0000005c, "flat_atomic_inc_x2", []>;
1176 //def FLAT_ATOMIC_DEC_X2 : FLAT_X2 <0x0000005d, "flat_atomic_dec_x2", []>;
1177 //def FLAT_ATOMIC_FCMPSWAP_X2 : FLAT_X2 <0x0000005e, "flat_atomic_fcmpswap_x2", []>;
1178 //def FLAT_ATOMIC_FMIN_X2 : FLAT_X2 <0x0000005f, "flat_atomic_fmin_x2", []>;
1179 //def FLAT_ATOMIC_FMAX_X2 : FLAT_X2 <0x00000060, "flat_atomic_fmax_x2", []>;
1181 } // End HasFlatAddressSpace predicate
1182 //===----------------------------------------------------------------------===//
1183 // VOP1 Instructions
1184 //===----------------------------------------------------------------------===//
1186 //def V_NOP : VOP1_ <0x00000000, "v_nop", []>;
1188 let isMoveImm = 1 in {
1189 defm V_MOV_B32 : VOP1Inst <vop1<0x1>, "v_mov_b32", VOP_I32_I32>;
1190 } // End isMoveImm = 1
1192 let Uses = [EXEC] in {
1194 // FIXME: Specify SchedRW for READFIRSTLANE_B32
1196 def V_READFIRSTLANE_B32 : VOP1 <
1198 (outs SReg_32:$vdst),
1199 (ins VGPR_32:$src0),
1200 "v_readfirstlane_b32 $vdst, $src0",
1206 let SchedRW = [WriteQuarterRate32] in {
1208 defm V_CVT_I32_F64 : VOP1Inst <vop1<0x3>, "v_cvt_i32_f64",
1209 VOP_I32_F64, fp_to_sint
1211 defm V_CVT_F64_I32 : VOP1Inst <vop1<0x4>, "v_cvt_f64_i32",
1212 VOP_F64_I32, sint_to_fp
1214 defm V_CVT_F32_I32 : VOP1Inst <vop1<0x5>, "v_cvt_f32_i32",
1215 VOP_F32_I32, sint_to_fp
1217 defm V_CVT_F32_U32 : VOP1Inst <vop1<0x6>, "v_cvt_f32_u32",
1218 VOP_F32_I32, uint_to_fp
1220 defm V_CVT_U32_F32 : VOP1Inst <vop1<0x7>, "v_cvt_u32_f32",
1221 VOP_I32_F32, fp_to_uint
1223 defm V_CVT_I32_F32 : VOP1Inst <vop1<0x8>, "v_cvt_i32_f32",
1224 VOP_I32_F32, fp_to_sint
1226 defm V_MOV_FED_B32 : VOP1Inst <vop1<0x9>, "v_mov_fed_b32", VOP_I32_I32>;
1227 defm V_CVT_F16_F32 : VOP1Inst <vop1<0xa>, "v_cvt_f16_f32",
1228 VOP_I32_F32, fp_to_f16
1230 defm V_CVT_F32_F16 : VOP1Inst <vop1<0xb>, "v_cvt_f32_f16",
1231 VOP_F32_I32, f16_to_fp
1233 //defm V_CVT_RPI_I32_F32 : VOP1_32 <0x0000000c, "v_cvt_rpi_i32_f32", []>;
1234 //defm V_CVT_FLR_I32_F32 : VOP1_32 <0x0000000d, "v_cvt_flr_i32_f32", []>;
1235 //defm V_CVT_OFF_F32_I4 : VOP1_32 <0x0000000e, "v_cvt_off_f32_i4", []>;
1236 defm V_CVT_F32_F64 : VOP1Inst <vop1<0xf>, "v_cvt_f32_f64",
1239 defm V_CVT_F64_F32 : VOP1Inst <vop1<0x10>, "v_cvt_f64_f32",
1240 VOP_F64_F32, fextend
1242 defm V_CVT_F32_UBYTE0 : VOP1Inst <vop1<0x11>, "v_cvt_f32_ubyte0",
1243 VOP_F32_I32, AMDGPUcvt_f32_ubyte0
1245 defm V_CVT_F32_UBYTE1 : VOP1Inst <vop1<0x12>, "v_cvt_f32_ubyte1",
1246 VOP_F32_I32, AMDGPUcvt_f32_ubyte1
1248 defm V_CVT_F32_UBYTE2 : VOP1Inst <vop1<0x13>, "v_cvt_f32_ubyte2",
1249 VOP_F32_I32, AMDGPUcvt_f32_ubyte2
1251 defm V_CVT_F32_UBYTE3 : VOP1Inst <vop1<0x14>, "v_cvt_f32_ubyte3",
1252 VOP_F32_I32, AMDGPUcvt_f32_ubyte3
1254 defm V_CVT_U32_F64 : VOP1Inst <vop1<0x15>, "v_cvt_u32_f64",
1255 VOP_I32_F64, fp_to_uint
1257 defm V_CVT_F64_U32 : VOP1Inst <vop1<0x16>, "v_cvt_f64_u32",
1258 VOP_F64_I32, uint_to_fp
1261 } // let SchedRW = [WriteQuarterRate32]
1263 defm V_FRACT_F32 : VOP1Inst <vop1<0x20, 0x1b>, "v_fract_f32",
1264 VOP_F32_F32, AMDGPUfract
1266 defm V_TRUNC_F32 : VOP1Inst <vop1<0x21, 0x1c>, "v_trunc_f32",
1269 defm V_CEIL_F32 : VOP1Inst <vop1<0x22, 0x1d>, "v_ceil_f32",
1272 defm V_RNDNE_F32 : VOP1Inst <vop1<0x23, 0x1e>, "v_rndne_f32",
1275 defm V_FLOOR_F32 : VOP1Inst <vop1<0x24, 0x1f>, "v_floor_f32",
1278 defm V_EXP_F32 : VOP1Inst <vop1<0x25, 0x20>, "v_exp_f32",
1282 let SchedRW = [WriteQuarterRate32] in {
1284 defm V_LOG_F32 : VOP1Inst <vop1<0x27, 0x21>, "v_log_f32",
1287 defm V_RCP_F32 : VOP1Inst <vop1<0x2a, 0x22>, "v_rcp_f32",
1288 VOP_F32_F32, AMDGPUrcp
1290 defm V_RCP_IFLAG_F32 : VOP1Inst <vop1<0x2b, 0x23>, "v_rcp_iflag_f32",
1293 defm V_RSQ_F32 : VOP1Inst <vop1<0x2e, 0x24>, "v_rsq_f32",
1294 VOP_F32_F32, AMDGPUrsq
1297 } //let SchedRW = [WriteQuarterRate32]
1299 let SchedRW = [WriteDouble] in {
1301 defm V_RCP_F64 : VOP1Inst <vop1<0x2f, 0x25>, "v_rcp_f64",
1302 VOP_F64_F64, AMDGPUrcp
1304 defm V_RSQ_F64 : VOP1Inst <vop1<0x31, 0x26>, "v_rsq_f64",
1305 VOP_F64_F64, AMDGPUrsq
1308 } // let SchedRW = [WriteDouble];
1310 defm V_SQRT_F32 : VOP1Inst <vop1<0x33, 0x27>, "v_sqrt_f32",
1314 let SchedRW = [WriteDouble] in {
1316 defm V_SQRT_F64 : VOP1Inst <vop1<0x34, 0x28>, "v_sqrt_f64",
1320 } // let SchedRW = [WriteDouble]
1322 defm V_SIN_F32 : VOP1Inst <vop1<0x35, 0x29>, "v_sin_f32",
1323 VOP_F32_F32, AMDGPUsin
1325 defm V_COS_F32 : VOP1Inst <vop1<0x36, 0x2a>, "v_cos_f32",
1326 VOP_F32_F32, AMDGPUcos
1328 defm V_NOT_B32 : VOP1Inst <vop1<0x37, 0x2b>, "v_not_b32", VOP_I32_I32>;
1329 defm V_BFREV_B32 : VOP1Inst <vop1<0x38, 0x2c>, "v_bfrev_b32", VOP_I32_I32>;
1330 defm V_FFBH_U32 : VOP1Inst <vop1<0x39, 0x2d>, "v_ffbh_u32", VOP_I32_I32>;
1331 defm V_FFBL_B32 : VOP1Inst <vop1<0x3a, 0x2e>, "v_ffbl_b32", VOP_I32_I32>;
1332 defm V_FFBH_I32 : VOP1Inst <vop1<0x3b, 0x2f>, "v_ffbh_i32", VOP_I32_I32>;
1333 //defm V_FREXP_EXP_I32_F64 : VOPInst <0x0000003c, "v_frexp_exp_i32_f64", VOP_I32_F32>;
1334 defm V_FREXP_MANT_F64 : VOP1Inst <vop1<0x3d, 0x31>, "v_frexp_mant_f64",
1337 defm V_FRACT_F64 : VOP1Inst <vop1<0x3e, 0x32>, "v_fract_f64", VOP_F64_F64>;
1338 //defm V_FREXP_EXP_I32_F32 : VOPInst <0x0000003f, "v_frexp_exp_i32_f32", VOP_I32_F32>;
1339 defm V_FREXP_MANT_F32 : VOP1Inst <vop1<0x40, 0x34>, "v_frexp_mant_f32",
1342 //def V_CLREXCP : VOP1_ <0x00000041, "v_clrexcp", []>;
1343 defm V_MOVRELD_B32 : VOP1Inst <vop1<0x42, 0x36>, "v_movreld_b32", VOP_I32_I32>;
1344 defm V_MOVRELS_B32 : VOP1Inst <vop1<0x43, 0x37>, "v_movrels_b32", VOP_I32_I32>;
1345 defm V_MOVRELSD_B32 : VOP1Inst <vop1<0x44, 0x38>, "v_movrelsd_b32", VOP_I32_I32>;
1347 // These instruction only exist on SI and CI
1348 let SubtargetPredicate = isSICI in {
1350 let SchedRW = [WriteQuarterRate32] in {
1352 defm V_LOG_CLAMP_F32 : VOP1InstSI <vop1<0x26>, "v_log_clamp_f32", VOP_F32_F32>;
1353 defm V_RCP_CLAMP_F32 : VOP1InstSI <vop1<0x28>, "v_rcp_clamp_f32", VOP_F32_F32>;
1354 defm V_RCP_LEGACY_F32 : VOP1InstSI <vop1<0x29>, "v_rcp_legacy_f32", VOP_F32_F32>;
1355 defm V_RSQ_CLAMP_F32 : VOP1InstSI <vop1<0x2c>, "v_rsq_clamp_f32",
1356 VOP_F32_F32, AMDGPUrsq_clamped
1358 defm V_RSQ_LEGACY_F32 : VOP1InstSI <vop1<0x2d>, "v_rsq_legacy_f32",
1359 VOP_F32_F32, AMDGPUrsq_legacy
1362 } // End let SchedRW = [WriteQuarterRate32]
1364 let SchedRW = [WriteDouble] in {
1366 defm V_RCP_CLAMP_F64 : VOP1InstSI <vop1<0x30>, "v_rcp_clamp_f64", VOP_F64_F64>;
1367 defm V_RSQ_CLAMP_F64 : VOP1InstSI <vop1<0x32>, "v_rsq_clamp_f64",
1368 VOP_F64_F64, AMDGPUrsq_clamped
1371 } // End SchedRW = [WriteDouble]
1373 } // End SubtargetPredicate = isSICI
1375 //===----------------------------------------------------------------------===//
1376 // VINTRP Instructions
1377 //===----------------------------------------------------------------------===//
1379 // FIXME: Specify SchedRW for VINTRP insturctions.
1380 defm V_INTERP_P1_F32 : VINTRP_m <
1381 0x00000000, "v_interp_p1_f32",
1382 (outs VGPR_32:$dst),
1383 (ins VGPR_32:$i, i32imm:$attr_chan, i32imm:$attr, M0Reg:$m0),
1384 "v_interp_p1_f32 $dst, $i, $attr_chan, $attr, [$m0]",
1387 defm V_INTERP_P2_F32 : VINTRP_m <
1388 0x00000001, "v_interp_p2_f32",
1389 (outs VGPR_32:$dst),
1390 (ins VGPR_32:$src0, VGPR_32:$j, i32imm:$attr_chan, i32imm:$attr, M0Reg:$m0),
1391 "v_interp_p2_f32 $dst, [$src0], $j, $attr_chan, $attr, [$m0]",
1395 defm V_INTERP_MOV_F32 : VINTRP_m <
1396 0x00000002, "v_interp_mov_f32",
1397 (outs VGPR_32:$dst),
1398 (ins InterpSlot:$src0, i32imm:$attr_chan, i32imm:$attr, M0Reg:$m0),
1399 "v_interp_mov_f32 $dst, $src0, $attr_chan, $attr, [$m0]",
1402 //===----------------------------------------------------------------------===//
1403 // VOP2 Instructions
1404 //===----------------------------------------------------------------------===//
1406 defm V_CNDMASK_B32_e64 : VOP3_m_nosrcmod <vop3<0x100>, (outs VGPR_32:$dst),
1407 (ins VSrc_32:$src0, VSrc_32:$src1, SSrc_64:$src2),
1408 "v_cndmask_b32_e64 $dst, $src0, $src1, $src2",
1409 [(set i32:$dst, (select i1:$src2, i32:$src1, i32:$src0))],
1410 "v_cndmask_b32_e64", 3
1414 let isCommutable = 1 in {
1415 defm V_ADD_F32 : VOP2Inst <vop2<0x3, 0x1>, "v_add_f32",
1416 VOP_F32_F32_F32, fadd
1419 defm V_SUB_F32 : VOP2Inst <vop2<0x4, 0x2>, "v_sub_f32", VOP_F32_F32_F32, fsub>;
1420 defm V_SUBREV_F32 : VOP2Inst <vop2<0x5, 0x3>, "v_subrev_f32",
1421 VOP_F32_F32_F32, null_frag, "v_sub_f32"
1423 } // End isCommutable = 1
1425 let isCommutable = 1 in {
1427 defm V_MUL_LEGACY_F32 : VOP2Inst <vop2<0x7, 0x4>, "v_mul_legacy_f32",
1428 VOP_F32_F32_F32, int_AMDGPU_mul
1431 defm V_MUL_F32 : VOP2Inst <vop2<0x8, 0x5>, "v_mul_f32",
1432 VOP_F32_F32_F32, fmul
1435 defm V_MUL_I32_I24 : VOP2Inst <vop2<0x9, 0x6>, "v_mul_i32_i24",
1436 VOP_I32_I32_I32, AMDGPUmul_i24
1438 //defm V_MUL_HI_I32_I24 : VOP2_32 <0x0000000a, "v_mul_hi_i32_i24", []>;
1439 defm V_MUL_U32_U24 : VOP2Inst <vop2<0xb, 0x8>, "v_mul_u32_u24",
1440 VOP_I32_I32_I32, AMDGPUmul_u24
1442 //defm V_MUL_HI_U32_U24 : VOP2_32 <0x0000000c, "v_mul_hi_u32_u24", []>;
1444 defm V_MIN_F32 : VOP2Inst <vop2<0xf, 0xa>, "v_min_f32", VOP_F32_F32_F32,
1446 defm V_MAX_F32 : VOP2Inst <vop2<0x10, 0xb>, "v_max_f32", VOP_F32_F32_F32,
1448 defm V_MIN_I32 : VOP2Inst <vop2<0x11, 0xc>, "v_min_i32", VOP_I32_I32_I32,
1451 defm V_MAX_I32 : VOP2Inst <vop2<0x12, 0xd>, "v_max_i32", VOP_I32_I32_I32,
1454 defm V_MIN_U32 : VOP2Inst <vop2<0x13, 0xe>, "v_min_u32", VOP_I32_I32_I32,
1457 defm V_MAX_U32 : VOP2Inst <vop2<0x14, 0xf>, "v_max_u32", VOP_I32_I32_I32,
1461 // No non-Rev Op on VI
1462 defm V_LSHRREV_B32 : VOP2Inst <
1463 vop2<0x16, 0x10>, "v_lshrrev_b32", VOP_I32_I32_I32, null_frag,
1464 "v_lshr_b32", "v_lshrrev_b32"
1467 // No non-Rev OP on VI
1468 defm V_ASHRREV_I32 : VOP2Inst <
1469 vop2<0x18, 0x11>, "v_ashrrev_i32", VOP_I32_I32_I32, null_frag,
1470 "v_ashr_i32", "v_ashrrev_i32"
1473 // No non-Rev OP on VI
1474 defm V_LSHLREV_B32 : VOP2Inst <
1475 vop2<0x1a, 0x12>, "v_lshlrev_b32", VOP_I32_I32_I32, null_frag,
1476 "v_lshl_b32", "v_lshlrev_b32"
1479 defm V_AND_B32 : VOP2Inst <vop2<0x1b, 0x13>, "v_and_b32",
1480 VOP_I32_I32_I32, and>;
1481 defm V_OR_B32 : VOP2Inst <vop2<0x1c, 0x14>, "v_or_b32",
1484 defm V_XOR_B32 : VOP2Inst <vop2<0x1d, 0x15>, "v_xor_b32",
1485 VOP_I32_I32_I32, xor
1488 defm V_MAC_F32 : VOP2Inst <vop2<0x1f, 0x16>, "v_mac_f32", VOP_F32_F32_F32>;
1489 } // End isCommutable = 1
1491 defm V_MADMK_F32 : VOP2Inst <vop2<0x20, 0x17>, "v_madmk_f32", VOP_F32_F32_F32>;
1493 let isCommutable = 1 in {
1494 defm V_MADAK_F32 : VOP2Inst <vop2<0x21, 0x18>, "v_madak_f32", VOP_F32_F32_F32>;
1495 } // End isCommutable = 1
1497 let isCommutable = 1, Defs = [VCC] in { // Carry-out goes to VCC
1498 // No patterns so that the scalar instructions are always selected.
1499 // The scalar versions will be replaced with vector when needed later.
1501 // V_ADD_I32, V_SUB_I32, and V_SUBREV_I32 where renamed to *_U32 in VI,
1502 // but the VI instructions behave the same as the SI versions.
1503 defm V_ADD_I32 : VOP2bInst <vop2<0x25, 0x19>, "v_add_i32",
1504 VOP_I32_I32_I32, add
1506 defm V_SUB_I32 : VOP2bInst <vop2<0x26, 0x1a>, "v_sub_i32",
1507 VOP_I32_I32_I32, sub
1510 defm V_SUBREV_I32 : VOP2bInst <vop2<0x27, 0x1b>, "v_subrev_i32",
1511 VOP_I32_I32_I32, null_frag, "v_sub_i32"
1514 let Uses = [VCC] in { // Carry-in comes from VCC
1515 defm V_ADDC_U32 : VOP2bInst <vop2<0x28, 0x1c>, "v_addc_u32",
1516 VOP_I32_I32_I32_VCC, adde
1518 defm V_SUBB_U32 : VOP2bInst <vop2<0x29, 0x1d>, "v_subb_u32",
1519 VOP_I32_I32_I32_VCC, sube
1521 defm V_SUBBREV_U32 : VOP2bInst <vop2<0x2a, 0x1e>, "v_subbrev_u32",
1522 VOP_I32_I32_I32_VCC, null_frag, "v_subb_u32"
1525 } // End Uses = [VCC]
1526 } // End isCommutable = 1, Defs = [VCC]
1528 // These instructions only exist on SI and CI
1529 let SubtargetPredicate = isSICI in {
1531 def V_READLANE_B32 : VOP2 <
1533 (outs SReg_32:$vdst),
1534 (ins VGPR_32:$src0, SSrc_32:$vsrc1),
1535 "v_readlane_b32 $vdst, $src0, $vsrc1",
1539 def V_WRITELANE_B32 : VOP2 <
1541 (outs VGPR_32:$vdst),
1542 (ins SReg_32:$src0, SSrc_32:$vsrc1),
1543 "v_writelane_b32 $vdst, $src0, $vsrc1",
1547 let isCommutable = 1 in {
1548 defm V_MAC_LEGACY_F32 : VOP2Inst <vop2<0x6>, "v_mac_legacy_f32",
1551 } // End isCommutable = 1
1553 defm V_MIN_LEGACY_F32 : VOP2Inst <vop2<0xd>, "v_min_legacy_f32",
1554 VOP_F32_F32_F32, AMDGPUfmin_legacy
1556 defm V_MAX_LEGACY_F32 : VOP2Inst <vop2<0xe>, "v_max_legacy_f32",
1557 VOP_F32_F32_F32, AMDGPUfmax_legacy
1560 let isCommutable = 1 in {
1561 defm V_LSHR_B32 : VOP2Inst <vop2<0x15>, "v_lshr_b32", VOP_I32_I32_I32, srl>;
1562 defm V_ASHR_I32 : VOP2Inst <vop2<0x17>, "v_ashr_i32",
1563 VOP_I32_I32_I32, sra
1566 let hasPostISelHook = 1 in {
1567 defm V_LSHL_B32 : VOP2Inst <vop2<0x19>, "v_lshl_b32", VOP_I32_I32_I32, shl>;
1570 } // End isCommutable = 1
1572 defm V_BFM_B32 : VOP2Inst <vop2<0x1e>, "v_bfm_b32", VOP_I32_I32_I32,
1574 defm V_BCNT_U32_B32 : VOP2Inst <vop2<0x22>, "v_bcnt_u32_b32", VOP_I32_I32_I32>;
1575 defm V_MBCNT_LO_U32_B32 : VOP2Inst <vop2<0x23>, "v_mbcnt_lo_u32_b32",
1578 defm V_MBCNT_HI_U32_B32 : VOP2Inst <vop2<0x24>, "v_mbcnt_hi_u32_b32",
1581 defm V_LDEXP_F32 : VOP2Inst <vop2<0x2b>, "v_ldexp_f32",
1582 VOP_F32_F32_I32, AMDGPUldexp
1585 ////def V_CVT_PKACCUM_U8_F32 : VOP2_U8 <0x0000002c, "v_cvt_pkaccum_u8_f32", []>;
1586 ////def V_CVT_PKNORM_I16_F32 : VOP2_I16 <0x0000002d, "v_cvt_pknorm_i16_f32", []>;
1587 ////def V_CVT_PKNORM_U16_F32 : VOP2_U16 <0x0000002e, "v_cvt_pknorm_u16_f32", []>;
1588 defm V_CVT_PKRTZ_F16_F32 : VOP2Inst <vop2<0x2f>, "v_cvt_pkrtz_f16_f32",
1589 VOP_I32_F32_F32, int_SI_packf16
1591 ////def V_CVT_PK_U16_U32 : VOP2_U16 <0x00000030, "v_cvt_pk_u16_u32", []>;
1592 ////def V_CVT_PK_I16_I32 : VOP2_I16 <0x00000031, "v_cvt_pk_i16_i32", []>;
1594 } // End let SubtargetPredicate = SICI
1595 //===----------------------------------------------------------------------===//
1596 // VOP3 Instructions
1597 //===----------------------------------------------------------------------===//
1599 let isCommutable = 1 in {
1600 defm V_MAD_LEGACY_F32 : VOP3Inst <vop3<0x140, 0x1c0>, "v_mad_legacy_f32",
1604 defm V_MAD_F32 : VOP3Inst <vop3<0x141, 0x1c1>, "v_mad_f32",
1605 VOP_F32_F32_F32_F32, fmad
1608 defm V_MAD_I32_I24 : VOP3Inst <vop3<0x142, 0x1c2>, "v_mad_i32_i24",
1609 VOP_I32_I32_I32_I32, AMDGPUmad_i24
1611 defm V_MAD_U32_U24 : VOP3Inst <vop3<0x143, 0x1c3>, "v_mad_u32_u24",
1612 VOP_I32_I32_I32_I32, AMDGPUmad_u24
1614 } // End isCommutable = 1
1616 defm V_CUBEID_F32 : VOP3Inst <vop3<0x144, 0x1c4>, "v_cubeid_f32",
1619 defm V_CUBESC_F32 : VOP3Inst <vop3<0x145, 0x1c5>, "v_cubesc_f32",
1622 defm V_CUBETC_F32 : VOP3Inst <vop3<0x146, 0x1c6>, "v_cubetc_f32",
1625 defm V_CUBEMA_F32 : VOP3Inst <vop3<0x147, 0x1c7>, "v_cubema_f32",
1629 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
1630 defm V_BFE_U32 : VOP3Inst <vop3<0x148, 0x1c8>, "v_bfe_u32",
1631 VOP_I32_I32_I32_I32, AMDGPUbfe_u32
1633 defm V_BFE_I32 : VOP3Inst <vop3<0x149, 0x1c9>, "v_bfe_i32",
1634 VOP_I32_I32_I32_I32, AMDGPUbfe_i32
1638 defm V_BFI_B32 : VOP3Inst <vop3<0x14a, 0x1ca>, "v_bfi_b32",
1639 VOP_I32_I32_I32_I32, AMDGPUbfi
1642 let isCommutable = 1 in {
1643 defm V_FMA_F32 : VOP3Inst <vop3<0x14b, 0x1cb>, "v_fma_f32",
1644 VOP_F32_F32_F32_F32, fma
1646 defm V_FMA_F64 : VOP3Inst <vop3<0x14c, 0x1cc>, "v_fma_f64",
1647 VOP_F64_F64_F64_F64, fma
1649 } // End isCommutable = 1
1651 //def V_LERP_U8 : VOP3_U8 <0x0000014d, "v_lerp_u8", []>;
1652 defm V_ALIGNBIT_B32 : VOP3Inst <vop3<0x14e, 0x1ce>, "v_alignbit_b32",
1655 defm V_ALIGNBYTE_B32 : VOP3Inst <vop3<0x14f, 0x1cf>, "v_alignbyte_b32",
1660 defm V_MULLIT_F32 : VOP3Inst <vop3<0x150>, "v_mullit_f32",
1661 VOP_F32_F32_F32_F32>;
1662 defm V_MIN3_F32 : VOP3Inst <vop3<0x151>, "v_min3_f32",
1663 VOP_F32_F32_F32_F32, AMDGPUfmin3>;
1665 defm V_MIN3_I32 : VOP3Inst <vop3<0x152>, "v_min3_i32",
1666 VOP_I32_I32_I32_I32, AMDGPUsmin3
1668 defm V_MIN3_U32 : VOP3Inst <vop3<0x153>, "v_min3_u32",
1669 VOP_I32_I32_I32_I32, AMDGPUumin3
1671 defm V_MAX3_F32 : VOP3Inst <vop3<0x154>, "v_max3_f32",
1672 VOP_F32_F32_F32_F32, AMDGPUfmax3
1674 defm V_MAX3_I32 : VOP3Inst <vop3<0x155>, "v_max3_i32",
1675 VOP_I32_I32_I32_I32, AMDGPUsmax3
1677 defm V_MAX3_U32 : VOP3Inst <vop3<0x156>, "v_max3_u32",
1678 VOP_I32_I32_I32_I32, AMDGPUumax3
1680 //def V_MED3_F32 : VOP3_MED3 <0x00000157, "v_med3_f32", []>;
1681 //def V_MED3_I32 : VOP3_MED3 <0x00000158, "v_med3_i32", []>;
1682 //def V_MED3_U32 : VOP3_MED3 <0x00000159, "v_med3_u32", []>;
1683 //def V_SAD_U8 : VOP3_U8 <0x0000015a, "v_sad_u8", []>;
1684 //def V_SAD_HI_U8 : VOP3_U8 <0x0000015b, "v_sad_hi_u8", []>;
1685 //def V_SAD_U16 : VOP3_U16 <0x0000015c, "v_sad_u16", []>;
1686 defm V_SAD_U32 : VOP3Inst <vop3<0x15d, 0x1dc>, "v_sad_u32",
1689 ////def V_CVT_PK_U8_F32 : VOP3_U8 <0x0000015e, "v_cvt_pk_u8_f32", []>;
1690 defm V_DIV_FIXUP_F32 : VOP3Inst <
1691 vop3<0x15f, 0x1de>, "v_div_fixup_f32", VOP_F32_F32_F32_F32, AMDGPUdiv_fixup
1694 let SchedRW = [WriteDouble] in {
1696 defm V_DIV_FIXUP_F64 : VOP3Inst <
1697 vop3<0x160, 0x1df>, "v_div_fixup_f64", VOP_F64_F64_F64_F64, AMDGPUdiv_fixup
1700 } // let SchedRW = [WriteDouble]
1702 defm V_LSHL_B64 : VOP3Inst <vop3<0x161>, "v_lshl_b64",
1703 VOP_I64_I64_I32, shl
1707 defm V_LSHR_B64 : VOP3Inst <vop3<0x162>, "v_lshr_b64",
1708 VOP_I64_I64_I32, srl
1712 defm V_ASHR_I64 : VOP3Inst <vop3<0x163>, "v_ashr_i64",
1713 VOP_I64_I64_I32, sra
1716 let SchedRW = [WriteDouble] in {
1717 let isCommutable = 1 in {
1719 defm V_ADD_F64 : VOP3Inst <vop3<0x164, 0x280>, "v_add_f64",
1720 VOP_F64_F64_F64, fadd
1722 defm V_MUL_F64 : VOP3Inst <vop3<0x165, 0x281>, "v_mul_f64",
1723 VOP_F64_F64_F64, fmul
1726 defm V_MIN_F64 : VOP3Inst <vop3<0x166, 0x282>, "v_min_f64",
1727 VOP_F64_F64_F64, fminnum
1729 defm V_MAX_F64 : VOP3Inst <vop3<0x167, 0x283>, "v_max_f64",
1730 VOP_F64_F64_F64, fmaxnum
1733 } // isCommutable = 1
1735 defm V_LDEXP_F64 : VOP3Inst <vop3<0x168, 0x284>, "v_ldexp_f64",
1736 VOP_F64_F64_I32, AMDGPUldexp
1739 } // let SchedRW = [WriteDouble]
1741 let isCommutable = 1, SchedRW = [WriteQuarterRate32] in {
1743 defm V_MUL_LO_U32 : VOP3Inst <vop3<0x169, 0x285>, "v_mul_lo_u32",
1746 defm V_MUL_HI_U32 : VOP3Inst <vop3<0x16a, 0x286>, "v_mul_hi_u32",
1750 defm V_MUL_LO_I32 : VOP3Inst <vop3<0x16b, 0x285>, "v_mul_lo_i32",
1753 defm V_MUL_HI_I32 : VOP3Inst <vop3<0x16c, 0x287>, "v_mul_hi_i32",
1757 } // isCommutable = 1, SchedRW = [WriteQuarterRate32]
1759 defm V_DIV_SCALE_F32 : VOP3b_32 <vop3<0x16d, 0x1e0>, "v_div_scale_f32", []>;
1761 let SchedRW = [WriteDouble] in {
1762 // Double precision division pre-scale.
1763 defm V_DIV_SCALE_F64 : VOP3b_64 <vop3<0x16e, 0x1e1>, "v_div_scale_f64", []>;
1764 } // let SchedRW = [WriteDouble]
1766 let isCommutable = 1 in {
1767 defm V_DIV_FMAS_F32 : VOP3Inst <vop3<0x16f, 0x1e2>, "v_div_fmas_f32",
1768 VOP_F32_F32_F32_F32, AMDGPUdiv_fmas
1770 let SchedRW = [WriteDouble] in {
1771 defm V_DIV_FMAS_F64 : VOP3Inst <vop3<0x170, 0x1e3>, "v_div_fmas_f64",
1772 VOP_F64_F64_F64_F64, AMDGPUdiv_fmas
1774 } // End SchedRW = [WriteDouble]
1775 } // End isCommutable = 1
1777 //def V_MSAD_U8 : VOP3_U8 <0x00000171, "v_msad_u8", []>;
1778 //def V_QSAD_U8 : VOP3_U8 <0x00000172, "v_qsad_u8", []>;
1779 //def V_MQSAD_U8 : VOP3_U8 <0x00000173, "v_mqsad_u8", []>;
1781 let SchedRW = [WriteDouble] in {
1782 defm V_TRIG_PREOP_F64 : VOP3Inst <
1783 vop3<0x174, 0x292>, "v_trig_preop_f64", VOP_F64_F64_I32, AMDGPUtrig_preop
1786 } // let SchedRW = [WriteDouble]
1788 //===----------------------------------------------------------------------===//
1789 // Pseudo Instructions
1790 //===----------------------------------------------------------------------===//
1791 let isCodeGenOnly = 1, isPseudo = 1 in {
1793 let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {
1794 // 64-bit vector move instruction. This is mainly used by the SIFoldOperands
1795 // pass to enable folding of inline immediates.
1796 def V_MOV_B64_PSEUDO : InstSI <(outs VReg_64:$dst), (ins VSrc_64:$src0), "", []>;
1797 } // end let hasSideEffects = 0, mayLoad = 0, mayStore = 0
1799 let hasSideEffects = 1 in {
1800 def SGPR_USE : InstSI <(outs),(ins), "", []>;
1803 // SI pseudo instructions. These are used by the CFG structurizer pass
1804 // and should be lowered to ISA instructions prior to codegen.
1806 let mayLoad = 1, mayStore = 1, hasSideEffects = 1,
1807 Uses = [EXEC], Defs = [EXEC] in {
1809 let isBranch = 1, isTerminator = 1 in {
1812 (outs SReg_64:$dst),
1813 (ins SReg_64:$vcc, brtarget:$target),
1815 [(set i64:$dst, (int_SI_if i1:$vcc, bb:$target))]
1818 def SI_ELSE : InstSI <
1819 (outs SReg_64:$dst),
1820 (ins SReg_64:$src, brtarget:$target),
1822 [(set i64:$dst, (int_SI_else i64:$src, bb:$target))]
1824 let Constraints = "$src = $dst";
1827 def SI_LOOP : InstSI <
1829 (ins SReg_64:$saved, brtarget:$target),
1830 "si_loop $saved, $target",
1831 [(int_SI_loop i64:$saved, bb:$target)]
1834 } // end isBranch = 1, isTerminator = 1
1836 def SI_BREAK : InstSI <
1837 (outs SReg_64:$dst),
1839 "si_else $dst, $src",
1840 [(set i64:$dst, (int_SI_break i64:$src))]
1843 def SI_IF_BREAK : InstSI <
1844 (outs SReg_64:$dst),
1845 (ins SReg_64:$vcc, SReg_64:$src),
1846 "si_if_break $dst, $vcc, $src",
1847 [(set i64:$dst, (int_SI_if_break i1:$vcc, i64:$src))]
1850 def SI_ELSE_BREAK : InstSI <
1851 (outs SReg_64:$dst),
1852 (ins SReg_64:$src0, SReg_64:$src1),
1853 "si_else_break $dst, $src0, $src1",
1854 [(set i64:$dst, (int_SI_else_break i64:$src0, i64:$src1))]
1857 def SI_END_CF : InstSI <
1859 (ins SReg_64:$saved),
1861 [(int_SI_end_cf i64:$saved)]
1864 def SI_KILL : InstSI <
1868 [(int_AMDGPU_kill f32:$src)]
1871 } // end mayLoad = 1, mayStore = 1, hasSideEffects = 1
1872 // Uses = [EXEC], Defs = [EXEC]
1874 let Uses = [EXEC], Defs = [EXEC,VCC,M0] in {
1876 //defm SI_ : RegisterLoadStore <VGPR_32, FRAMEri, ADDRIndirect>;
1878 let UseNamedOperandTable = 1 in {
1880 def SI_RegisterLoad : InstSI <
1881 (outs VGPR_32:$dst, SReg_64:$temp),
1882 (ins FRAMEri32:$addr, i32imm:$chan),
1885 let isRegisterLoad = 1;
1889 class SIRegStore<dag outs> : InstSI <
1891 (ins VGPR_32:$val, FRAMEri32:$addr, i32imm:$chan),
1894 let isRegisterStore = 1;
1898 let usesCustomInserter = 1 in {
1899 def SI_RegisterStorePseudo : SIRegStore<(outs)>;
1900 } // End usesCustomInserter = 1
1901 def SI_RegisterStore : SIRegStore<(outs SReg_64:$temp)>;
1904 } // End UseNamedOperandTable = 1
1906 def SI_INDIRECT_SRC : InstSI <
1907 (outs VGPR_32:$dst, SReg_64:$temp),
1908 (ins unknown:$src, VSrc_32:$idx, i32imm:$off),
1909 "si_indirect_src $dst, $temp, $src, $idx, $off",
1913 class SI_INDIRECT_DST<RegisterClass rc> : InstSI <
1914 (outs rc:$dst, SReg_64:$temp),
1915 (ins unknown:$src, VSrc_32:$idx, i32imm:$off, VGPR_32:$val),
1916 "si_indirect_dst $dst, $temp, $src, $idx, $off, $val",
1919 let Constraints = "$src = $dst";
1922 def SI_INDIRECT_DST_V1 : SI_INDIRECT_DST<VGPR_32>;
1923 def SI_INDIRECT_DST_V2 : SI_INDIRECT_DST<VReg_64>;
1924 def SI_INDIRECT_DST_V4 : SI_INDIRECT_DST<VReg_128>;
1925 def SI_INDIRECT_DST_V8 : SI_INDIRECT_DST<VReg_256>;
1926 def SI_INDIRECT_DST_V16 : SI_INDIRECT_DST<VReg_512>;
1928 } // Uses = [EXEC,VCC,M0], Defs = [EXEC,VCC,M0]
1930 let usesCustomInserter = 1 in {
1932 def V_SUB_F64 : InstSI <
1933 (outs VReg_64:$dst),
1934 (ins VReg_64:$src0, VReg_64:$src1),
1935 "v_sub_f64 $dst, $src0, $src1",
1936 [(set f64:$dst, (fsub f64:$src0, f64:$src1))]
1939 } // end usesCustomInserter
1941 multiclass SI_SPILL_SGPR <RegisterClass sgpr_class> {
1943 def _SAVE : InstSI <
1945 (ins sgpr_class:$src, i32imm:$frame_idx),
1949 def _RESTORE : InstSI <
1950 (outs sgpr_class:$dst),
1951 (ins i32imm:$frame_idx),
1957 defm SI_SPILL_S32 : SI_SPILL_SGPR <SReg_32>;
1958 defm SI_SPILL_S64 : SI_SPILL_SGPR <SReg_64>;
1959 defm SI_SPILL_S128 : SI_SPILL_SGPR <SReg_128>;
1960 defm SI_SPILL_S256 : SI_SPILL_SGPR <SReg_256>;
1961 defm SI_SPILL_S512 : SI_SPILL_SGPR <SReg_512>;
1963 multiclass SI_SPILL_VGPR <RegisterClass vgpr_class> {
1964 def _SAVE : InstSI <
1966 (ins vgpr_class:$src, i32imm:$frame_idx),
1970 def _RESTORE : InstSI <
1971 (outs vgpr_class:$dst),
1972 (ins i32imm:$frame_idx),
1977 defm SI_SPILL_V32 : SI_SPILL_VGPR <VGPR_32>;
1978 defm SI_SPILL_V64 : SI_SPILL_VGPR <VReg_64>;
1979 defm SI_SPILL_V96 : SI_SPILL_VGPR <VReg_96>;
1980 defm SI_SPILL_V128 : SI_SPILL_VGPR <VReg_128>;
1981 defm SI_SPILL_V256 : SI_SPILL_VGPR <VReg_256>;
1982 defm SI_SPILL_V512 : SI_SPILL_VGPR <VReg_512>;
1984 let Defs = [SCC] in {
1986 def SI_CONSTDATA_PTR : InstSI <
1987 (outs SReg_64:$dst),
1989 "", [(set SReg_64:$dst, (i64 SIconstdata_ptr))]
1992 } // End Defs = [SCC]
1994 } // end IsCodeGenOnly, isPseudo
1996 } // end SubtargetPredicate = isGCN
1998 let Predicates = [isGCN] in {
2001 (int_AMDGPU_cndlt f32:$src0, f32:$src1, f32:$src2),
2002 (V_CNDMASK_B32_e64 $src2, $src1,
2003 (V_CMP_GT_F32_e64 SRCMODS.NONE, 0, SRCMODS.NONE, $src0,
2004 DSTCLAMP.NONE, DSTOMOD.NONE))
2009 (SI_KILL 0xbf800000)
2012 let Predicates = [isSICI] in {
2014 /* int_SI_vs_load_input */
2016 (SIload_input v4i32:$tlst, imm:$attr_offset, i32:$buf_idx_vgpr),
2017 (BUFFER_LOAD_FORMAT_XYZW_IDXEN $tlst, $buf_idx_vgpr, imm:$attr_offset, 0, 0, 0, 0)
2020 } // End Predicates = [isSICI]
2024 (int_SI_export imm:$en, imm:$vm, imm:$done, imm:$tgt, imm:$compr,
2025 f32:$src0, f32:$src1, f32:$src2, f32:$src3),
2026 (EXP imm:$en, imm:$tgt, imm:$compr, imm:$done, imm:$vm,
2027 $src0, $src1, $src2, $src3)
2030 //===----------------------------------------------------------------------===//
2032 //===----------------------------------------------------------------------===//
2034 multiclass SMRD_Pattern <SMRD Instr_IMM, SMRD Instr_SGPR, ValueType vt> {
2036 // 1. SI-CI: Offset as 8bit DWORD immediate
2038 (constant_load (add i64:$sbase, (i64 IMM8bitDWORD:$offset))),
2039 (vt (Instr_IMM $sbase, (as_dword_i32imm $offset)))
2042 // 2. Offset loaded in an 32bit SGPR
2044 (constant_load (add i64:$sbase, (i64 IMM32bit:$offset))),
2045 (vt (Instr_SGPR $sbase, (S_MOV_B32 (i32 (as_i32imm $offset)))))
2048 // 3. No offset at all
2050 (constant_load i64:$sbase),
2051 (vt (Instr_IMM $sbase, 0))
2055 multiclass SMRD_Pattern_vi <SMRD Instr_IMM, SMRD Instr_SGPR, ValueType vt> {
2057 // 1. VI: Offset as 20bit immediate in bytes
2059 (constant_load (add i64:$sbase, (i64 IMM20bit:$offset))),
2060 (vt (Instr_IMM $sbase, (as_i32imm $offset)))
2063 // 2. Offset loaded in an 32bit SGPR
2065 (constant_load (add i64:$sbase, (i64 IMM32bit:$offset))),
2066 (vt (Instr_SGPR $sbase, (S_MOV_B32 (i32 (as_i32imm $offset)))))
2069 // 3. No offset at all
2071 (constant_load i64:$sbase),
2072 (vt (Instr_IMM $sbase, 0))
2076 let Predicates = [isSICI] in {
2077 defm : SMRD_Pattern <S_LOAD_DWORD_IMM, S_LOAD_DWORD_SGPR, f32>;
2078 defm : SMRD_Pattern <S_LOAD_DWORD_IMM, S_LOAD_DWORD_SGPR, i32>;
2079 defm : SMRD_Pattern <S_LOAD_DWORDX2_IMM, S_LOAD_DWORDX2_SGPR, v2i32>;
2080 defm : SMRD_Pattern <S_LOAD_DWORDX4_IMM, S_LOAD_DWORDX4_SGPR, v4i32>;
2081 defm : SMRD_Pattern <S_LOAD_DWORDX8_IMM, S_LOAD_DWORDX8_SGPR, v32i8>;
2082 defm : SMRD_Pattern <S_LOAD_DWORDX8_IMM, S_LOAD_DWORDX8_SGPR, v8i32>;
2083 defm : SMRD_Pattern <S_LOAD_DWORDX16_IMM, S_LOAD_DWORDX16_SGPR, v16i32>;
2084 } // End Predicates = [isSICI]
2086 let Predicates = [isVI] in {
2087 defm : SMRD_Pattern_vi <S_LOAD_DWORD_IMM, S_LOAD_DWORD_SGPR, f32>;
2088 defm : SMRD_Pattern_vi <S_LOAD_DWORD_IMM, S_LOAD_DWORD_SGPR, i32>;
2089 defm : SMRD_Pattern_vi <S_LOAD_DWORDX2_IMM, S_LOAD_DWORDX2_SGPR, v2i32>;
2090 defm : SMRD_Pattern_vi <S_LOAD_DWORDX4_IMM, S_LOAD_DWORDX4_SGPR, v4i32>;
2091 defm : SMRD_Pattern_vi <S_LOAD_DWORDX8_IMM, S_LOAD_DWORDX8_SGPR, v32i8>;
2092 defm : SMRD_Pattern_vi <S_LOAD_DWORDX8_IMM, S_LOAD_DWORDX8_SGPR, v8i32>;
2093 defm : SMRD_Pattern_vi <S_LOAD_DWORDX16_IMM, S_LOAD_DWORDX16_SGPR, v16i32>;
2094 } // End Predicates = [isVI]
2096 let Predicates = [isSICI] in {
2098 // 1. Offset as 8bit DWORD immediate
2100 (SIload_constant v4i32:$sbase, IMM8bitDWORD:$offset),
2101 (S_BUFFER_LOAD_DWORD_IMM $sbase, (as_dword_i32imm $offset))
2104 } // End Predicates = [isSICI]
2106 // 2. Offset loaded in an 32bit SGPR
2108 (SIload_constant v4i32:$sbase, imm:$offset),
2109 (S_BUFFER_LOAD_DWORD_SGPR $sbase, (S_MOV_B32 imm:$offset))
2112 //===----------------------------------------------------------------------===//
2114 //===----------------------------------------------------------------------===//
2117 (i64 (ctpop i64:$src)),
2118 (i64 (REG_SEQUENCE SReg_64,
2119 (S_BCNT1_I32_B64 $src), sub0,
2120 (S_MOV_B32 0), sub1))
2123 //===----------------------------------------------------------------------===//
2125 //===----------------------------------------------------------------------===//
2127 // V_ADD_I32_e32/S_ADD_U32 produces carry in VCC/SCC. For the vector
2128 // case, the sgpr-copies pass will fix this to use the vector version.
2130 (i32 (addc i32:$src0, i32:$src1)),
2131 (S_ADD_U32 $src0, $src1)
2134 //===----------------------------------------------------------------------===//
2136 //===----------------------------------------------------------------------===//
2139 (int_AMDGPU_barrier_global),
2143 //===----------------------------------------------------------------------===//
2145 //===----------------------------------------------------------------------===//
2147 let Predicates = [UnsafeFPMath] in {
2148 def : RcpPat<V_RCP_F64_e32, f64>;
2149 defm : RsqPat<V_RSQ_F64_e32, f64>;
2150 defm : RsqPat<V_RSQ_F32_e32, f32>;
2153 //===----------------------------------------------------------------------===//
2155 //===----------------------------------------------------------------------===//
2158 (i32 (add (i32 (ctpop i32:$popcnt)), i32:$val)),
2159 (V_BCNT_U32_B32_e64 $popcnt, $val)
2162 /********** ======================= **********/
2163 /********** Image sampling patterns **********/
2164 /********** ======================= **********/
2167 class SampleRawPattern<SDPatternOperator name, MIMG opcode, ValueType vt> : Pat <
2168 (name vt:$addr, v8i32:$rsrc, v4i32:$sampler, i32:$dmask, i32:$unorm,
2169 i32:$r128, i32:$da, i32:$glc, i32:$slc, i32:$tfe, i32:$lwe),
2170 (opcode (as_i32imm $dmask), (as_i1imm $unorm), (as_i1imm $glc), (as_i1imm $da),
2171 (as_i1imm $r128), (as_i1imm $tfe), (as_i1imm $lwe), (as_i1imm $slc),
2172 $addr, $rsrc, $sampler)
2175 multiclass SampleRawPatterns<SDPatternOperator name, string opcode> {
2176 def : SampleRawPattern<name, !cast<MIMG>(opcode # _V4_V1), i32>;
2177 def : SampleRawPattern<name, !cast<MIMG>(opcode # _V4_V2), v2i32>;
2178 def : SampleRawPattern<name, !cast<MIMG>(opcode # _V4_V4), v4i32>;
2179 def : SampleRawPattern<name, !cast<MIMG>(opcode # _V4_V8), v8i32>;
2180 def : SampleRawPattern<name, !cast<MIMG>(opcode # _V4_V16), v16i32>;
2184 class ImagePattern<SDPatternOperator name, MIMG opcode, ValueType vt> : Pat <
2185 (name vt:$addr, v8i32:$rsrc, i32:$dmask, i32:$unorm,
2186 i32:$r128, i32:$da, i32:$glc, i32:$slc, i32:$tfe, i32:$lwe),
2187 (opcode (as_i32imm $dmask), (as_i1imm $unorm), (as_i1imm $glc), (as_i1imm $da),
2188 (as_i1imm $r128), (as_i1imm $tfe), (as_i1imm $lwe), (as_i1imm $slc),
2192 multiclass ImagePatterns<SDPatternOperator name, string opcode> {
2193 def : ImagePattern<name, !cast<MIMG>(opcode # _V4_V1), i32>;
2194 def : ImagePattern<name, !cast<MIMG>(opcode # _V4_V2), v2i32>;
2195 def : ImagePattern<name, !cast<MIMG>(opcode # _V4_V4), v4i32>;
2199 defm : SampleRawPatterns<int_SI_image_sample, "IMAGE_SAMPLE">;
2200 defm : SampleRawPatterns<int_SI_image_sample_cl, "IMAGE_SAMPLE_CL">;
2201 defm : SampleRawPatterns<int_SI_image_sample_d, "IMAGE_SAMPLE_D">;
2202 defm : SampleRawPatterns<int_SI_image_sample_d_cl, "IMAGE_SAMPLE_D_CL">;
2203 defm : SampleRawPatterns<int_SI_image_sample_l, "IMAGE_SAMPLE_L">;
2204 defm : SampleRawPatterns<int_SI_image_sample_b, "IMAGE_SAMPLE_B">;
2205 defm : SampleRawPatterns<int_SI_image_sample_b_cl, "IMAGE_SAMPLE_B_CL">;
2206 defm : SampleRawPatterns<int_SI_image_sample_lz, "IMAGE_SAMPLE_LZ">;
2207 defm : SampleRawPatterns<int_SI_image_sample_cd, "IMAGE_SAMPLE_CD">;
2208 defm : SampleRawPatterns<int_SI_image_sample_cd_cl, "IMAGE_SAMPLE_CD_CL">;
2210 // Sample with comparison
2211 defm : SampleRawPatterns<int_SI_image_sample_c, "IMAGE_SAMPLE_C">;
2212 defm : SampleRawPatterns<int_SI_image_sample_c_cl, "IMAGE_SAMPLE_C_CL">;
2213 defm : SampleRawPatterns<int_SI_image_sample_c_d, "IMAGE_SAMPLE_C_D">;
2214 defm : SampleRawPatterns<int_SI_image_sample_c_d_cl, "IMAGE_SAMPLE_C_D_CL">;
2215 defm : SampleRawPatterns<int_SI_image_sample_c_l, "IMAGE_SAMPLE_C_L">;
2216 defm : SampleRawPatterns<int_SI_image_sample_c_b, "IMAGE_SAMPLE_C_B">;
2217 defm : SampleRawPatterns<int_SI_image_sample_c_b_cl, "IMAGE_SAMPLE_C_B_CL">;
2218 defm : SampleRawPatterns<int_SI_image_sample_c_lz, "IMAGE_SAMPLE_C_LZ">;
2219 defm : SampleRawPatterns<int_SI_image_sample_c_cd, "IMAGE_SAMPLE_C_CD">;
2220 defm : SampleRawPatterns<int_SI_image_sample_c_cd_cl, "IMAGE_SAMPLE_C_CD_CL">;
2222 // Sample with offsets
2223 defm : SampleRawPatterns<int_SI_image_sample_o, "IMAGE_SAMPLE_O">;
2224 defm : SampleRawPatterns<int_SI_image_sample_cl_o, "IMAGE_SAMPLE_CL_O">;
2225 defm : SampleRawPatterns<int_SI_image_sample_d_o, "IMAGE_SAMPLE_D_O">;
2226 defm : SampleRawPatterns<int_SI_image_sample_d_cl_o, "IMAGE_SAMPLE_D_CL_O">;
2227 defm : SampleRawPatterns<int_SI_image_sample_l_o, "IMAGE_SAMPLE_L_O">;
2228 defm : SampleRawPatterns<int_SI_image_sample_b_o, "IMAGE_SAMPLE_B_O">;
2229 defm : SampleRawPatterns<int_SI_image_sample_b_cl_o, "IMAGE_SAMPLE_B_CL_O">;
2230 defm : SampleRawPatterns<int_SI_image_sample_lz_o, "IMAGE_SAMPLE_LZ_O">;
2231 defm : SampleRawPatterns<int_SI_image_sample_cd_o, "IMAGE_SAMPLE_CD_O">;
2232 defm : SampleRawPatterns<int_SI_image_sample_cd_cl_o, "IMAGE_SAMPLE_CD_CL_O">;
2234 // Sample with comparison and offsets
2235 defm : SampleRawPatterns<int_SI_image_sample_c_o, "IMAGE_SAMPLE_C_O">;
2236 defm : SampleRawPatterns<int_SI_image_sample_c_cl_o, "IMAGE_SAMPLE_C_CL_O">;
2237 defm : SampleRawPatterns<int_SI_image_sample_c_d_o, "IMAGE_SAMPLE_C_D_O">;
2238 defm : SampleRawPatterns<int_SI_image_sample_c_d_cl_o, "IMAGE_SAMPLE_C_D_CL_O">;
2239 defm : SampleRawPatterns<int_SI_image_sample_c_l_o, "IMAGE_SAMPLE_C_L_O">;
2240 defm : SampleRawPatterns<int_SI_image_sample_c_b_o, "IMAGE_SAMPLE_C_B_O">;
2241 defm : SampleRawPatterns<int_SI_image_sample_c_b_cl_o, "IMAGE_SAMPLE_C_B_CL_O">;
2242 defm : SampleRawPatterns<int_SI_image_sample_c_lz_o, "IMAGE_SAMPLE_C_LZ_O">;
2243 defm : SampleRawPatterns<int_SI_image_sample_c_cd_o, "IMAGE_SAMPLE_C_CD_O">;
2244 defm : SampleRawPatterns<int_SI_image_sample_c_cd_cl_o, "IMAGE_SAMPLE_C_CD_CL_O">;
2247 // Only the variants which make sense are defined.
2248 def : SampleRawPattern<int_SI_gather4, IMAGE_GATHER4_V4_V2, v2i32>;
2249 def : SampleRawPattern<int_SI_gather4, IMAGE_GATHER4_V4_V4, v4i32>;
2250 def : SampleRawPattern<int_SI_gather4_cl, IMAGE_GATHER4_CL_V4_V4, v4i32>;
2251 def : SampleRawPattern<int_SI_gather4_l, IMAGE_GATHER4_L_V4_V4, v4i32>;
2252 def : SampleRawPattern<int_SI_gather4_b, IMAGE_GATHER4_B_V4_V4, v4i32>;
2253 def : SampleRawPattern<int_SI_gather4_b_cl, IMAGE_GATHER4_B_CL_V4_V4, v4i32>;
2254 def : SampleRawPattern<int_SI_gather4_b_cl, IMAGE_GATHER4_B_CL_V4_V8, v8i32>;
2255 def : SampleRawPattern<int_SI_gather4_lz, IMAGE_GATHER4_LZ_V4_V2, v2i32>;
2256 def : SampleRawPattern<int_SI_gather4_lz, IMAGE_GATHER4_LZ_V4_V4, v4i32>;
2258 def : SampleRawPattern<int_SI_gather4_c, IMAGE_GATHER4_C_V4_V4, v4i32>;
2259 def : SampleRawPattern<int_SI_gather4_c_cl, IMAGE_GATHER4_C_CL_V4_V4, v4i32>;
2260 def : SampleRawPattern<int_SI_gather4_c_cl, IMAGE_GATHER4_C_CL_V4_V8, v8i32>;
2261 def : SampleRawPattern<int_SI_gather4_c_l, IMAGE_GATHER4_C_L_V4_V4, v4i32>;
2262 def : SampleRawPattern<int_SI_gather4_c_l, IMAGE_GATHER4_C_L_V4_V8, v8i32>;
2263 def : SampleRawPattern<int_SI_gather4_c_b, IMAGE_GATHER4_C_B_V4_V4, v4i32>;
2264 def : SampleRawPattern<int_SI_gather4_c_b, IMAGE_GATHER4_C_B_V4_V8, v8i32>;
2265 def : SampleRawPattern<int_SI_gather4_c_b_cl, IMAGE_GATHER4_C_B_CL_V4_V8, v8i32>;
2266 def : SampleRawPattern<int_SI_gather4_c_lz, IMAGE_GATHER4_C_LZ_V4_V4, v4i32>;
2268 def : SampleRawPattern<int_SI_gather4_o, IMAGE_GATHER4_O_V4_V4, v4i32>;
2269 def : SampleRawPattern<int_SI_gather4_cl_o, IMAGE_GATHER4_CL_O_V4_V4, v4i32>;
2270 def : SampleRawPattern<int_SI_gather4_cl_o, IMAGE_GATHER4_CL_O_V4_V8, v8i32>;
2271 def : SampleRawPattern<int_SI_gather4_l_o, IMAGE_GATHER4_L_O_V4_V4, v4i32>;
2272 def : SampleRawPattern<int_SI_gather4_l_o, IMAGE_GATHER4_L_O_V4_V8, v8i32>;
2273 def : SampleRawPattern<int_SI_gather4_b_o, IMAGE_GATHER4_B_O_V4_V4, v4i32>;
2274 def : SampleRawPattern<int_SI_gather4_b_o, IMAGE_GATHER4_B_O_V4_V8, v8i32>;
2275 def : SampleRawPattern<int_SI_gather4_b_cl_o, IMAGE_GATHER4_B_CL_O_V4_V8, v8i32>;
2276 def : SampleRawPattern<int_SI_gather4_lz_o, IMAGE_GATHER4_LZ_O_V4_V4, v4i32>;
2278 def : SampleRawPattern<int_SI_gather4_c_o, IMAGE_GATHER4_C_O_V4_V4, v4i32>;
2279 def : SampleRawPattern<int_SI_gather4_c_o, IMAGE_GATHER4_C_O_V4_V8, v8i32>;
2280 def : SampleRawPattern<int_SI_gather4_c_cl_o, IMAGE_GATHER4_C_CL_O_V4_V8, v8i32>;
2281 def : SampleRawPattern<int_SI_gather4_c_l_o, IMAGE_GATHER4_C_L_O_V4_V8, v8i32>;
2282 def : SampleRawPattern<int_SI_gather4_c_b_o, IMAGE_GATHER4_C_B_O_V4_V8, v8i32>;
2283 def : SampleRawPattern<int_SI_gather4_c_b_cl_o, IMAGE_GATHER4_C_B_CL_O_V4_V8, v8i32>;
2284 def : SampleRawPattern<int_SI_gather4_c_lz_o, IMAGE_GATHER4_C_LZ_O_V4_V4, v4i32>;
2285 def : SampleRawPattern<int_SI_gather4_c_lz_o, IMAGE_GATHER4_C_LZ_O_V4_V8, v8i32>;
2287 def : SampleRawPattern<int_SI_getlod, IMAGE_GET_LOD_V4_V1, i32>;
2288 def : SampleRawPattern<int_SI_getlod, IMAGE_GET_LOD_V4_V2, v2i32>;
2289 def : SampleRawPattern<int_SI_getlod, IMAGE_GET_LOD_V4_V4, v4i32>;
2291 def : ImagePattern<int_SI_getresinfo, IMAGE_GET_RESINFO_V4_V1, i32>;
2292 defm : ImagePatterns<int_SI_image_load, "IMAGE_LOAD">;
2293 defm : ImagePatterns<int_SI_image_load_mip, "IMAGE_LOAD_MIP">;
2295 /* SIsample for simple 1D texture lookup */
2297 (SIsample i32:$addr, v32i8:$rsrc, v4i32:$sampler, imm),
2298 (IMAGE_SAMPLE_V4_V1 0xf, 0, 0, 0, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2301 class SamplePattern<SDNode name, MIMG opcode, ValueType vt> : Pat <
2302 (name vt:$addr, v32i8:$rsrc, v4i32:$sampler, imm),
2303 (opcode 0xf, 0, 0, 0, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2306 class SampleRectPattern<SDNode name, MIMG opcode, ValueType vt> : Pat <
2307 (name vt:$addr, v32i8:$rsrc, v4i32:$sampler, TEX_RECT),
2308 (opcode 0xf, 1, 0, 0, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2311 class SampleArrayPattern<SDNode name, MIMG opcode, ValueType vt> : Pat <
2312 (name vt:$addr, v32i8:$rsrc, v4i32:$sampler, TEX_ARRAY),
2313 (opcode 0xf, 0, 0, 1, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2316 class SampleShadowPattern<SDNode name, MIMG opcode,
2317 ValueType vt> : Pat <
2318 (name vt:$addr, v32i8:$rsrc, v4i32:$sampler, TEX_SHADOW),
2319 (opcode 0xf, 0, 0, 0, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2322 class SampleShadowArrayPattern<SDNode name, MIMG opcode,
2323 ValueType vt> : Pat <
2324 (name vt:$addr, v32i8:$rsrc, v4i32:$sampler, TEX_SHADOW_ARRAY),
2325 (opcode 0xf, 0, 0, 1, 0, 0, 0, 0, $addr, $rsrc, $sampler)
2328 /* SIsample* for texture lookups consuming more address parameters */
2329 multiclass SamplePatterns<MIMG sample, MIMG sample_c, MIMG sample_l,
2330 MIMG sample_c_l, MIMG sample_b, MIMG sample_c_b,
2331 MIMG sample_d, MIMG sample_c_d, ValueType addr_type> {
2332 def : SamplePattern <SIsample, sample, addr_type>;
2333 def : SampleRectPattern <SIsample, sample, addr_type>;
2334 def : SampleArrayPattern <SIsample, sample, addr_type>;
2335 def : SampleShadowPattern <SIsample, sample_c, addr_type>;
2336 def : SampleShadowArrayPattern <SIsample, sample_c, addr_type>;
2338 def : SamplePattern <SIsamplel, sample_l, addr_type>;
2339 def : SampleArrayPattern <SIsamplel, sample_l, addr_type>;
2340 def : SampleShadowPattern <SIsamplel, sample_c_l, addr_type>;
2341 def : SampleShadowArrayPattern <SIsamplel, sample_c_l, addr_type>;
2343 def : SamplePattern <SIsampleb, sample_b, addr_type>;
2344 def : SampleArrayPattern <SIsampleb, sample_b, addr_type>;
2345 def : SampleShadowPattern <SIsampleb, sample_c_b, addr_type>;
2346 def : SampleShadowArrayPattern <SIsampleb, sample_c_b, addr_type>;
2348 def : SamplePattern <SIsampled, sample_d, addr_type>;
2349 def : SampleArrayPattern <SIsampled, sample_d, addr_type>;
2350 def : SampleShadowPattern <SIsampled, sample_c_d, addr_type>;
2351 def : SampleShadowArrayPattern <SIsampled, sample_c_d, addr_type>;
2354 defm : SamplePatterns<IMAGE_SAMPLE_V4_V2, IMAGE_SAMPLE_C_V4_V2,
2355 IMAGE_SAMPLE_L_V4_V2, IMAGE_SAMPLE_C_L_V4_V2,
2356 IMAGE_SAMPLE_B_V4_V2, IMAGE_SAMPLE_C_B_V4_V2,
2357 IMAGE_SAMPLE_D_V4_V2, IMAGE_SAMPLE_C_D_V4_V2,
2359 defm : SamplePatterns<IMAGE_SAMPLE_V4_V4, IMAGE_SAMPLE_C_V4_V4,
2360 IMAGE_SAMPLE_L_V4_V4, IMAGE_SAMPLE_C_L_V4_V4,
2361 IMAGE_SAMPLE_B_V4_V4, IMAGE_SAMPLE_C_B_V4_V4,
2362 IMAGE_SAMPLE_D_V4_V4, IMAGE_SAMPLE_C_D_V4_V4,
2364 defm : SamplePatterns<IMAGE_SAMPLE_V4_V8, IMAGE_SAMPLE_C_V4_V8,
2365 IMAGE_SAMPLE_L_V4_V8, IMAGE_SAMPLE_C_L_V4_V8,
2366 IMAGE_SAMPLE_B_V4_V8, IMAGE_SAMPLE_C_B_V4_V8,
2367 IMAGE_SAMPLE_D_V4_V8, IMAGE_SAMPLE_C_D_V4_V8,
2369 defm : SamplePatterns<IMAGE_SAMPLE_V4_V16, IMAGE_SAMPLE_C_V4_V16,
2370 IMAGE_SAMPLE_L_V4_V16, IMAGE_SAMPLE_C_L_V4_V16,
2371 IMAGE_SAMPLE_B_V4_V16, IMAGE_SAMPLE_C_B_V4_V16,
2372 IMAGE_SAMPLE_D_V4_V16, IMAGE_SAMPLE_C_D_V4_V16,
2375 /* int_SI_imageload for texture fetches consuming varying address parameters */
2376 class ImageLoadPattern<Intrinsic name, MIMG opcode, ValueType addr_type> : Pat <
2377 (name addr_type:$addr, v32i8:$rsrc, imm),
2378 (opcode 0xf, 0, 0, 0, 0, 0, 0, 0, $addr, $rsrc)
2381 class ImageLoadArrayPattern<Intrinsic name, MIMG opcode, ValueType addr_type> : Pat <
2382 (name addr_type:$addr, v32i8:$rsrc, TEX_ARRAY),
2383 (opcode 0xf, 0, 0, 1, 0, 0, 0, 0, $addr, $rsrc)
2386 class ImageLoadMSAAPattern<Intrinsic name, MIMG opcode, ValueType addr_type> : Pat <
2387 (name addr_type:$addr, v32i8:$rsrc, TEX_MSAA),
2388 (opcode 0xf, 0, 0, 0, 0, 0, 0, 0, $addr, $rsrc)
2391 class ImageLoadArrayMSAAPattern<Intrinsic name, MIMG opcode, ValueType addr_type> : Pat <
2392 (name addr_type:$addr, v32i8:$rsrc, TEX_ARRAY_MSAA),
2393 (opcode 0xf, 0, 0, 1, 0, 0, 0, 0, $addr, $rsrc)
2396 multiclass ImageLoadPatterns<MIMG opcode, ValueType addr_type> {
2397 def : ImageLoadPattern <int_SI_imageload, opcode, addr_type>;
2398 def : ImageLoadArrayPattern <int_SI_imageload, opcode, addr_type>;
2401 multiclass ImageLoadMSAAPatterns<MIMG opcode, ValueType addr_type> {
2402 def : ImageLoadMSAAPattern <int_SI_imageload, opcode, addr_type>;
2403 def : ImageLoadArrayMSAAPattern <int_SI_imageload, opcode, addr_type>;
2406 defm : ImageLoadPatterns<IMAGE_LOAD_MIP_V4_V2, v2i32>;
2407 defm : ImageLoadPatterns<IMAGE_LOAD_MIP_V4_V4, v4i32>;
2409 defm : ImageLoadMSAAPatterns<IMAGE_LOAD_V4_V2, v2i32>;
2410 defm : ImageLoadMSAAPatterns<IMAGE_LOAD_V4_V4, v4i32>;
2412 /* Image resource information */
2414 (int_SI_resinfo i32:$mipid, v32i8:$rsrc, imm),
2415 (IMAGE_GET_RESINFO_V4_V1 0xf, 0, 0, 0, 0, 0, 0, 0, (V_MOV_B32_e32 $mipid), $rsrc)
2419 (int_SI_resinfo i32:$mipid, v32i8:$rsrc, TEX_ARRAY),
2420 (IMAGE_GET_RESINFO_V4_V1 0xf, 0, 0, 1, 0, 0, 0, 0, (V_MOV_B32_e32 $mipid), $rsrc)
2424 (int_SI_resinfo i32:$mipid, v32i8:$rsrc, TEX_ARRAY_MSAA),
2425 (IMAGE_GET_RESINFO_V4_V1 0xf, 0, 0, 1, 0, 0, 0, 0, (V_MOV_B32_e32 $mipid), $rsrc)
2428 /********** ============================================ **********/
2429 /********** Extraction, Insertion, Building and Casting **********/
2430 /********** ============================================ **********/
2432 foreach Index = 0-2 in {
2433 def Extract_Element_v2i32_#Index : Extract_Element <
2434 i32, v2i32, Index, !cast<SubRegIndex>(sub#Index)
2436 def Insert_Element_v2i32_#Index : Insert_Element <
2437 i32, v2i32, Index, !cast<SubRegIndex>(sub#Index)
2440 def Extract_Element_v2f32_#Index : Extract_Element <
2441 f32, v2f32, Index, !cast<SubRegIndex>(sub#Index)
2443 def Insert_Element_v2f32_#Index : Insert_Element <
2444 f32, v2f32, Index, !cast<SubRegIndex>(sub#Index)
2448 foreach Index = 0-3 in {
2449 def Extract_Element_v4i32_#Index : Extract_Element <
2450 i32, v4i32, Index, !cast<SubRegIndex>(sub#Index)
2452 def Insert_Element_v4i32_#Index : Insert_Element <
2453 i32, v4i32, Index, !cast<SubRegIndex>(sub#Index)
2456 def Extract_Element_v4f32_#Index : Extract_Element <
2457 f32, v4f32, Index, !cast<SubRegIndex>(sub#Index)
2459 def Insert_Element_v4f32_#Index : Insert_Element <
2460 f32, v4f32, Index, !cast<SubRegIndex>(sub#Index)
2464 foreach Index = 0-7 in {
2465 def Extract_Element_v8i32_#Index : Extract_Element <
2466 i32, v8i32, Index, !cast<SubRegIndex>(sub#Index)
2468 def Insert_Element_v8i32_#Index : Insert_Element <
2469 i32, v8i32, Index, !cast<SubRegIndex>(sub#Index)
2472 def Extract_Element_v8f32_#Index : Extract_Element <
2473 f32, v8f32, Index, !cast<SubRegIndex>(sub#Index)
2475 def Insert_Element_v8f32_#Index : Insert_Element <
2476 f32, v8f32, Index, !cast<SubRegIndex>(sub#Index)
2480 foreach Index = 0-15 in {
2481 def Extract_Element_v16i32_#Index : Extract_Element <
2482 i32, v16i32, Index, !cast<SubRegIndex>(sub#Index)
2484 def Insert_Element_v16i32_#Index : Insert_Element <
2485 i32, v16i32, Index, !cast<SubRegIndex>(sub#Index)
2488 def Extract_Element_v16f32_#Index : Extract_Element <
2489 f32, v16f32, Index, !cast<SubRegIndex>(sub#Index)
2491 def Insert_Element_v16f32_#Index : Insert_Element <
2492 f32, v16f32, Index, !cast<SubRegIndex>(sub#Index)
2496 def : BitConvert <i32, f32, SReg_32>;
2497 def : BitConvert <i32, f32, VGPR_32>;
2499 def : BitConvert <f32, i32, SReg_32>;
2500 def : BitConvert <f32, i32, VGPR_32>;
2502 def : BitConvert <i64, f64, VReg_64>;
2504 def : BitConvert <f64, i64, VReg_64>;
2506 def : BitConvert <v2f32, v2i32, VReg_64>;
2507 def : BitConvert <v2i32, v2f32, VReg_64>;
2508 def : BitConvert <v2i32, i64, VReg_64>;
2509 def : BitConvert <i64, v2i32, VReg_64>;
2510 def : BitConvert <v2f32, i64, VReg_64>;
2511 def : BitConvert <i64, v2f32, VReg_64>;
2512 def : BitConvert <v2i32, f64, VReg_64>;
2513 def : BitConvert <f64, v2i32, VReg_64>;
2514 def : BitConvert <v4f32, v4i32, VReg_128>;
2515 def : BitConvert <v4i32, v4f32, VReg_128>;
2517 def : BitConvert <v8f32, v8i32, SReg_256>;
2518 def : BitConvert <v8i32, v8f32, SReg_256>;
2519 def : BitConvert <v8i32, v32i8, SReg_256>;
2520 def : BitConvert <v32i8, v8i32, SReg_256>;
2521 def : BitConvert <v8i32, v32i8, VReg_256>;
2522 def : BitConvert <v8i32, v8f32, VReg_256>;
2523 def : BitConvert <v8f32, v8i32, VReg_256>;
2524 def : BitConvert <v32i8, v8i32, VReg_256>;
2526 def : BitConvert <v16i32, v16f32, VReg_512>;
2527 def : BitConvert <v16f32, v16i32, VReg_512>;
2529 /********** =================== **********/
2530 /********** Src & Dst modifiers **********/
2531 /********** =================== **********/
2534 (AMDGPUclamp (VOP3Mods0Clamp f32:$src0, i32:$src0_modifiers, i32:$omod),
2535 (f32 FP_ZERO), (f32 FP_ONE)),
2536 (V_ADD_F32_e64 $src0_modifiers, $src0, 0, 0, 1, $omod)
2539 /********** ================================ **********/
2540 /********** Floating point absolute/negative **********/
2541 /********** ================================ **********/
2543 // Prevent expanding both fneg and fabs.
2545 // FIXME: Should use S_OR_B32
2547 (fneg (fabs f32:$src)),
2548 (V_OR_B32_e32 $src, (V_MOV_B32_e32 0x80000000)) /* Set sign bit */
2551 // FIXME: Should use S_OR_B32
2553 (fneg (fabs f64:$src)),
2554 (REG_SEQUENCE VReg_64,
2555 (i32 (EXTRACT_SUBREG f64:$src, sub0)),
2557 (V_OR_B32_e32 (EXTRACT_SUBREG f64:$src, sub1),
2558 (V_MOV_B32_e32 0x80000000)), // Set sign bit.
2564 (V_AND_B32_e32 $src, (V_MOV_B32_e32 0x7fffffff))
2569 (V_XOR_B32_e32 $src, (V_MOV_B32_e32 0x80000000))
2574 (REG_SEQUENCE VReg_64,
2575 (i32 (EXTRACT_SUBREG f64:$src, sub0)),
2577 (V_AND_B32_e32 (EXTRACT_SUBREG f64:$src, sub1),
2578 (V_MOV_B32_e32 0x7fffffff)), // Set sign bit.
2584 (REG_SEQUENCE VReg_64,
2585 (i32 (EXTRACT_SUBREG f64:$src, sub0)),
2587 (V_XOR_B32_e32 (EXTRACT_SUBREG f64:$src, sub1),
2588 (V_MOV_B32_e32 0x80000000)),
2592 /********** ================== **********/
2593 /********** Immediate Patterns **********/
2594 /********** ================== **********/
2597 (SGPRImm<(i32 imm)>:$imm),
2598 (S_MOV_B32 imm:$imm)
2602 (SGPRImm<(f32 fpimm)>:$imm),
2603 (S_MOV_B32 (f32 (bitcast_fpimm_to_i32 $imm)))
2608 (V_MOV_B32_e32 imm:$imm)
2613 (V_MOV_B32_e32 (f32 (bitcast_fpimm_to_i32 $imm)))
2617 (i64 InlineImm<i64>:$imm),
2618 (S_MOV_B64 InlineImm<i64>:$imm)
2621 // XXX - Should this use a s_cmp to set SCC?
2623 // Set to sign-extended 64-bit value (true = -1, false = 0)
2626 (S_MOV_B64 (i64 (as_i64imm $imm)))
2630 (f64 InlineFPImm<f64>:$imm),
2631 (S_MOV_B64 (f64 (bitcast_fpimm_to_i64 InlineFPImm<f64>:$imm)))
2634 /********** ===================== **********/
2635 /********** Interpolation Paterns **********/
2636 /********** ===================== **********/
2638 // The value of $params is constant through out the entire kernel.
2639 // We need to use S_MOV_B32 $params, because CSE ignores copies, so
2640 // without it we end up with a lot of redundant moves.
2643 (int_SI_fs_constant imm:$attr_chan, imm:$attr, i32:$params),
2644 (V_INTERP_MOV_F32 INTERP.P0, imm:$attr_chan, imm:$attr, (S_MOV_B32 $params))
2648 (int_SI_fs_interp imm:$attr_chan, imm:$attr, i32:$params, v2i32:$ij),
2649 (V_INTERP_P2_F32 (V_INTERP_P1_F32 (EXTRACT_SUBREG v2i32:$ij, sub0),
2650 imm:$attr_chan, imm:$attr, (S_MOV_B32 $params)),
2651 (EXTRACT_SUBREG $ij, sub1),
2652 imm:$attr_chan, imm:$attr, (S_MOV_B32 $params))
2655 /********** ================== **********/
2656 /********** Intrinsic Patterns **********/
2657 /********** ================== **********/
2659 /* llvm.AMDGPU.pow */
2660 def : POW_Common <V_LOG_F32_e32, V_EXP_F32_e32, V_MUL_LEGACY_F32_e32>;
2663 (int_AMDGPU_div f32:$src0, f32:$src1),
2664 (V_MUL_LEGACY_F32_e32 $src0, (V_RCP_LEGACY_F32_e32 $src1))
2668 (fdiv f64:$src0, f64:$src1),
2669 (V_MUL_F64 0 /* src0_modifiers */, $src0,
2670 0 /* src1_modifiers */, (V_RCP_F64_e32 $src1),
2671 0 /* clamp */, 0 /* omod */)
2675 (int_AMDGPU_cube v4f32:$src),
2676 (REG_SEQUENCE VReg_128,
2677 (V_CUBETC_F32 0 /* src0_modifiers */, (EXTRACT_SUBREG $src, sub0),
2678 0 /* src1_modifiers */, (EXTRACT_SUBREG $src, sub1),
2679 0 /* src2_modifiers */, (EXTRACT_SUBREG $src, sub2),
2680 0 /* clamp */, 0 /* omod */), sub0,
2681 (V_CUBESC_F32 0 /* src0_modifiers */, (EXTRACT_SUBREG $src, sub0),
2682 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub1),
2683 0 /* src2_modifiers */,(EXTRACT_SUBREG $src, sub2),
2684 0 /* clamp */, 0 /* omod */), sub1,
2685 (V_CUBEMA_F32 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub0),
2686 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub1),
2687 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub2),
2688 0 /* clamp */, 0 /* omod */), sub2,
2689 (V_CUBEID_F32 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub0),
2690 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub1),
2691 0 /* src1_modifiers */,(EXTRACT_SUBREG $src, sub2),
2692 0 /* clamp */, 0 /* omod */), sub3)
2696 (i32 (sext i1:$src0)),
2697 (V_CNDMASK_B32_e64 (i32 0), (i32 -1), $src0)
2700 class Ext32Pat <SDNode ext> : Pat <
2701 (i32 (ext i1:$src0)),
2702 (V_CNDMASK_B32_e64 (i32 0), (i32 1), $src0)
2705 def : Ext32Pat <zext>;
2706 def : Ext32Pat <anyext>;
2708 let Predicates = [isSICI] in {
2710 // Offset in an 32Bit VGPR
2712 (SIload_constant v4i32:$sbase, i32:$voff),
2713 (BUFFER_LOAD_DWORD_OFFEN $sbase, $voff, 0, 0, 0, 0, 0)
2716 } // End Predicates = [isSICI]
2718 // The multiplication scales from [0,1] to the unsigned integer range
2720 (AMDGPUurecip i32:$src0),
2722 (V_MUL_F32_e32 CONST.FP_UINT_MAX_PLUS_1,
2723 (V_RCP_IFLAG_F32_e32 (V_CVT_F32_U32_e32 $src0))))
2726 let Predicates = [isSICI] in {
2730 (V_MBCNT_HI_U32_B32_e32 0xffffffff,
2731 (V_MBCNT_LO_U32_B32_e64 0xffffffff, 0))
2736 //===----------------------------------------------------------------------===//
2738 //===----------------------------------------------------------------------===//
2740 def : IMad24Pat<V_MAD_I32_I24>;
2741 def : UMad24Pat<V_MAD_U32_U24>;
2744 (mulhu i32:$src0, i32:$src1),
2745 (V_MUL_HI_U32 $src0, $src1)
2749 (mulhs i32:$src0, i32:$src1),
2750 (V_MUL_HI_I32 $src0, $src1)
2753 def : Vop3ModPat<V_MAD_F32, VOP_F32_F32_F32_F32, AMDGPUmad>;
2756 defm : BFIPatterns <V_BFI_B32, S_MOV_B32, SReg_64>;
2757 def : ROTRPattern <V_ALIGNBIT_B32>;
2759 /********** ======================= **********/
2760 /********** Load/Store Patterns **********/
2761 /********** ======================= **********/
2763 class DSReadPat <DS inst, ValueType vt, PatFrag frag> : Pat <
2764 (vt (frag (DS1Addr1Offset i32:$ptr, i32:$offset))),
2765 (inst (i1 0), $ptr, (as_i16imm $offset), (S_MOV_B32 -1))
2768 def : DSReadPat <DS_READ_I8, i32, sextloadi8_local>;
2769 def : DSReadPat <DS_READ_U8, i32, az_extloadi8_local>;
2770 def : DSReadPat <DS_READ_I16, i32, sextloadi16_local>;
2771 def : DSReadPat <DS_READ_U16, i32, az_extloadi16_local>;
2772 def : DSReadPat <DS_READ_B32, i32, local_load>;
2774 let AddedComplexity = 100 in {
2776 def : DSReadPat <DS_READ_B64, v2i32, local_load_aligned8bytes>;
2778 } // End AddedComplexity = 100
2781 (v2i32 (local_load (DS64Bit4ByteAligned i32:$ptr, i8:$offset0,
2783 (DS_READ2_B32 (i1 0), $ptr, $offset0, $offset1, (S_MOV_B32 -1))
2786 class DSWritePat <DS inst, ValueType vt, PatFrag frag> : Pat <
2787 (frag vt:$value, (DS1Addr1Offset i32:$ptr, i32:$offset)),
2788 (inst (i1 0), $ptr, $value, (as_i16imm $offset), (S_MOV_B32 -1))
2791 def : DSWritePat <DS_WRITE_B8, i32, truncstorei8_local>;
2792 def : DSWritePat <DS_WRITE_B16, i32, truncstorei16_local>;
2793 def : DSWritePat <DS_WRITE_B32, i32, local_store>;
2795 let AddedComplexity = 100 in {
2797 def : DSWritePat <DS_WRITE_B64, v2i32, local_store_aligned8bytes>;
2798 } // End AddedComplexity = 100
2801 (local_store v2i32:$value, (DS64Bit4ByteAligned i32:$ptr, i8:$offset0,
2803 (DS_WRITE2_B32 (i1 0), $ptr, (EXTRACT_SUBREG $value, sub0),
2804 (EXTRACT_SUBREG $value, sub1), $offset0, $offset1,
2808 class DSAtomicRetPat<DS inst, ValueType vt, PatFrag frag> : Pat <
2809 (frag (DS1Addr1Offset i32:$ptr, i32:$offset), vt:$value),
2810 (inst (i1 0), $ptr, $value, (as_i16imm $offset), (S_MOV_B32 -1))
2813 // Special case of DSAtomicRetPat for add / sub 1 -> inc / dec
2815 // We need to use something for the data0, so we set a register to
2816 // -1. For the non-rtn variants, the manual says it does
2817 // DS[A] = (DS[A] >= D0) ? 0 : DS[A] + 1, and setting D0 to uint_max
2818 // will always do the increment so I'm assuming it's the same.
2820 // We also load this -1 with s_mov_b32 / s_mov_b64 even though this
2821 // needs to be a VGPR. The SGPR copy pass will fix this, and it's
2822 // easier since there is no v_mov_b64.
2823 class DSAtomicIncRetPat<DS inst, ValueType vt,
2824 Instruction LoadImm, PatFrag frag> : Pat <
2825 (frag (DS1Addr1Offset i32:$ptr, i32:$offset), (vt 1)),
2826 (inst (i1 0), $ptr, (LoadImm (vt -1)), (as_i16imm $offset), (S_MOV_B32 -1))
2830 class DSAtomicCmpXChg <DS inst, ValueType vt, PatFrag frag> : Pat <
2831 (frag (DS1Addr1Offset i32:$ptr, i32:$offset), vt:$cmp, vt:$swap),
2832 (inst (i1 0), $ptr, $cmp, $swap, (as_i16imm $offset), (S_MOV_B32 -1))
2837 def : DSAtomicIncRetPat<DS_INC_RTN_U32, i32,
2838 S_MOV_B32, atomic_load_add_local>;
2839 def : DSAtomicIncRetPat<DS_DEC_RTN_U32, i32,
2840 S_MOV_B32, atomic_load_sub_local>;
2842 def : DSAtomicRetPat<DS_WRXCHG_RTN_B32, i32, atomic_swap_local>;
2843 def : DSAtomicRetPat<DS_ADD_RTN_U32, i32, atomic_load_add_local>;
2844 def : DSAtomicRetPat<DS_SUB_RTN_U32, i32, atomic_load_sub_local>;
2845 def : DSAtomicRetPat<DS_AND_RTN_B32, i32, atomic_load_and_local>;
2846 def : DSAtomicRetPat<DS_OR_RTN_B32, i32, atomic_load_or_local>;
2847 def : DSAtomicRetPat<DS_XOR_RTN_B32, i32, atomic_load_xor_local>;
2848 def : DSAtomicRetPat<DS_MIN_RTN_I32, i32, atomic_load_min_local>;
2849 def : DSAtomicRetPat<DS_MAX_RTN_I32, i32, atomic_load_max_local>;
2850 def : DSAtomicRetPat<DS_MIN_RTN_U32, i32, atomic_load_umin_local>;
2851 def : DSAtomicRetPat<DS_MAX_RTN_U32, i32, atomic_load_umax_local>;
2853 def : DSAtomicCmpXChg<DS_CMPST_RTN_B32, i32, atomic_cmp_swap_32_local>;
2856 def : DSAtomicIncRetPat<DS_INC_RTN_U64, i64,
2857 S_MOV_B64, atomic_load_add_local>;
2858 def : DSAtomicIncRetPat<DS_DEC_RTN_U64, i64,
2859 S_MOV_B64, atomic_load_sub_local>;
2861 def : DSAtomicRetPat<DS_WRXCHG_RTN_B64, i64, atomic_swap_local>;
2862 def : DSAtomicRetPat<DS_ADD_RTN_U64, i64, atomic_load_add_local>;
2863 def : DSAtomicRetPat<DS_SUB_RTN_U64, i64, atomic_load_sub_local>;
2864 def : DSAtomicRetPat<DS_AND_RTN_B64, i64, atomic_load_and_local>;
2865 def : DSAtomicRetPat<DS_OR_RTN_B64, i64, atomic_load_or_local>;
2866 def : DSAtomicRetPat<DS_XOR_RTN_B64, i64, atomic_load_xor_local>;
2867 def : DSAtomicRetPat<DS_MIN_RTN_I64, i64, atomic_load_min_local>;
2868 def : DSAtomicRetPat<DS_MAX_RTN_I64, i64, atomic_load_max_local>;
2869 def : DSAtomicRetPat<DS_MIN_RTN_U64, i64, atomic_load_umin_local>;
2870 def : DSAtomicRetPat<DS_MAX_RTN_U64, i64, atomic_load_umax_local>;
2872 def : DSAtomicCmpXChg<DS_CMPST_RTN_B64, i64, atomic_cmp_swap_64_local>;
2875 //===----------------------------------------------------------------------===//
2877 //===----------------------------------------------------------------------===//
2879 multiclass MUBUFLoad_Pattern <MUBUF Instr_ADDR64, ValueType vt,
2880 PatFrag constant_ld> {
2882 (vt (constant_ld (MUBUFAddr64 v4i32:$srsrc, i64:$vaddr, i16:$offset))),
2883 (Instr_ADDR64 $srsrc, $vaddr, $offset)
2887 let Predicates = [isSICI] in {
2888 defm : MUBUFLoad_Pattern <BUFFER_LOAD_SBYTE_ADDR64, i32, sextloadi8_constant>;
2889 defm : MUBUFLoad_Pattern <BUFFER_LOAD_UBYTE_ADDR64, i32, az_extloadi8_constant>;
2890 defm : MUBUFLoad_Pattern <BUFFER_LOAD_SSHORT_ADDR64, i32, sextloadi16_constant>;
2891 defm : MUBUFLoad_Pattern <BUFFER_LOAD_USHORT_ADDR64, i32, az_extloadi16_constant>;
2892 defm : MUBUFLoad_Pattern <BUFFER_LOAD_DWORD_ADDR64, i32, constant_load>;
2893 defm : MUBUFLoad_Pattern <BUFFER_LOAD_DWORDX2_ADDR64, v2i32, constant_load>;
2894 defm : MUBUFLoad_Pattern <BUFFER_LOAD_DWORDX4_ADDR64, v4i32, constant_load>;
2895 } // End Predicates = [isSICI]
2897 class MUBUFScratchLoadPat <MUBUF Instr, ValueType vt, PatFrag ld> : Pat <
2898 (vt (ld (MUBUFScratch v4i32:$srsrc, i32:$vaddr,
2899 i32:$soffset, u16imm:$offset))),
2900 (Instr $srsrc, $vaddr, $soffset, $offset, 0, 0, 0)
2903 let Predicates = [isSICI] in {
2904 def : MUBUFScratchLoadPat <BUFFER_LOAD_SBYTE_OFFEN, i32, sextloadi8_private>;
2905 def : MUBUFScratchLoadPat <BUFFER_LOAD_UBYTE_OFFEN, i32, extloadi8_private>;
2906 def : MUBUFScratchLoadPat <BUFFER_LOAD_SSHORT_OFFEN, i32, sextloadi16_private>;
2907 def : MUBUFScratchLoadPat <BUFFER_LOAD_USHORT_OFFEN, i32, extloadi16_private>;
2908 def : MUBUFScratchLoadPat <BUFFER_LOAD_DWORD_OFFEN, i32, load_private>;
2909 def : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX2_OFFEN, v2i32, load_private>;
2910 def : MUBUFScratchLoadPat <BUFFER_LOAD_DWORDX4_OFFEN, v4i32, load_private>;
2911 } // End Predicates = [isSICI]
2913 // BUFFER_LOAD_DWORD*, addr64=0
2914 multiclass MUBUF_Load_Dword <ValueType vt, MUBUF offset, MUBUF offen, MUBUF idxen,
2918 (vt (int_SI_buffer_load_dword v4i32:$rsrc, (i32 imm), i32:$soffset,
2919 imm:$offset, 0, 0, imm:$glc, imm:$slc,
2921 (offset $rsrc, (as_i16imm $offset), $soffset, (as_i1imm $glc),
2922 (as_i1imm $slc), (as_i1imm $tfe))
2926 (vt (int_SI_buffer_load_dword v4i32:$rsrc, i32:$vaddr, i32:$soffset,
2927 imm:$offset, 1, 0, imm:$glc, imm:$slc,
2929 (offen $rsrc, $vaddr, $soffset, (as_i16imm $offset), (as_i1imm $glc), (as_i1imm $slc),
2934 (vt (int_SI_buffer_load_dword v4i32:$rsrc, i32:$vaddr, i32:$soffset,
2935 imm:$offset, 0, 1, imm:$glc, imm:$slc,
2937 (idxen $rsrc, $vaddr, (as_i16imm $offset), $soffset, (as_i1imm $glc),
2938 (as_i1imm $slc), (as_i1imm $tfe))
2942 (vt (int_SI_buffer_load_dword v4i32:$rsrc, v2i32:$vaddr, i32:$soffset,
2943 imm, 1, 1, imm:$glc, imm:$slc,
2945 (bothen $rsrc, $vaddr, $soffset, (as_i1imm $glc), (as_i1imm $slc),
2950 let Predicates = [isSICI] in {
2951 defm : MUBUF_Load_Dword <i32, BUFFER_LOAD_DWORD_OFFSET, BUFFER_LOAD_DWORD_OFFEN,
2952 BUFFER_LOAD_DWORD_IDXEN, BUFFER_LOAD_DWORD_BOTHEN>;
2953 defm : MUBUF_Load_Dword <v2i32, BUFFER_LOAD_DWORDX2_OFFSET, BUFFER_LOAD_DWORDX2_OFFEN,
2954 BUFFER_LOAD_DWORDX2_IDXEN, BUFFER_LOAD_DWORDX2_BOTHEN>;
2955 defm : MUBUF_Load_Dword <v4i32, BUFFER_LOAD_DWORDX4_OFFSET, BUFFER_LOAD_DWORDX4_OFFEN,
2956 BUFFER_LOAD_DWORDX4_IDXEN, BUFFER_LOAD_DWORDX4_BOTHEN>;
2957 } // End Predicates = [isSICI]
2959 class MUBUFScratchStorePat <MUBUF Instr, ValueType vt, PatFrag st> : Pat <
2960 (st vt:$value, (MUBUFScratch v4i32:$srsrc, i32:$vaddr, i32:$soffset,
2962 (Instr $value, $srsrc, $vaddr, $soffset, $offset, 0, 0, 0)
2965 let Predicates = [isSICI] in {
2966 def : MUBUFScratchStorePat <BUFFER_STORE_BYTE_OFFEN, i32, truncstorei8_private>;
2967 def : MUBUFScratchStorePat <BUFFER_STORE_SHORT_OFFEN, i32, truncstorei16_private>;
2968 def : MUBUFScratchStorePat <BUFFER_STORE_DWORD_OFFEN, i32, store_private>;
2969 def : MUBUFScratchStorePat <BUFFER_STORE_DWORDX2_OFFEN, v2i32, store_private>;
2970 def : MUBUFScratchStorePat <BUFFER_STORE_DWORDX4_OFFEN, v4i32, store_private>;
2971 } // End Predicates = [isSICI]
2974 class MUBUFStore_Pattern <MUBUF Instr, ValueType vt, PatFrag st> : Pat <
2975 (st vt:$value, (MUBUFScratch v4i32:$srsrc, i64:$vaddr, u16imm:$offset)),
2976 (Instr $value, $srsrc, $vaddr, $offset)
2979 let Predicates = [isSICI] in {
2980 def : MUBUFStore_Pattern <BUFFER_STORE_BYTE_ADDR64, i32, truncstorei8_private>;
2981 def : MUBUFStore_Pattern <BUFFER_STORE_SHORT_ADDR64, i32, truncstorei16_private>;
2982 def : MUBUFStore_Pattern <BUFFER_STORE_DWORD_ADDR64, i32, store_private>;
2983 def : MUBUFStore_Pattern <BUFFER_STORE_DWORDX2_ADDR64, v2i32, store_private>;
2984 def : MUBUFStore_Pattern <BUFFER_STORE_DWORDX4_ADDR64, v4i32, store_private>;
2985 } // End Predicates = [isSICI]
2989 //===----------------------------------------------------------------------===//
2991 //===----------------------------------------------------------------------===//
2993 // TBUFFER_STORE_FORMAT_*, addr64=0
2994 class MTBUF_StoreResource <ValueType vt, int num_channels, MTBUF opcode> : Pat<
2995 (SItbuffer_store v4i32:$rsrc, vt:$vdata, num_channels, i32:$vaddr,
2996 i32:$soffset, imm:$inst_offset, imm:$dfmt,
2997 imm:$nfmt, imm:$offen, imm:$idxen,
2998 imm:$glc, imm:$slc, imm:$tfe),
3000 $vdata, (as_i16imm $inst_offset), (as_i1imm $offen), (as_i1imm $idxen),
3001 (as_i1imm $glc), 0, (as_i8imm $dfmt), (as_i8imm $nfmt), $vaddr, $rsrc,
3002 (as_i1imm $slc), (as_i1imm $tfe), $soffset)
3005 def : MTBUF_StoreResource <i32, 1, TBUFFER_STORE_FORMAT_X>;
3006 def : MTBUF_StoreResource <v2i32, 2, TBUFFER_STORE_FORMAT_XY>;
3007 def : MTBUF_StoreResource <v4i32, 3, TBUFFER_STORE_FORMAT_XYZ>;
3008 def : MTBUF_StoreResource <v4i32, 4, TBUFFER_STORE_FORMAT_XYZW>;
3010 let SubtargetPredicate = isCI in {
3012 defm V_QSAD_PK_U16_U8 : VOP3Inst <vop3<0x173>, "v_qsad_pk_u16_u8",
3015 defm V_MQSAD_U16_U8 : VOP3Inst <vop3<0x172>, "v_mqsad_u16_u8",
3018 defm V_MQSAD_U32_U8 : VOP3Inst <vop3<0x175>, "v_mqsad_u32_u8",
3022 let isCommutable = 1 in {
3023 defm V_MAD_U64_U32 : VOP3Inst <vop3<0x176>, "v_mad_u64_u32",
3027 // XXX - Does this set VCC?
3028 defm V_MAD_I64_I32 : VOP3Inst <vop3<0x177>, "v_mad_i64_i32",
3031 } // End isCommutable = 1
3033 // Remaining instructions:
3035 // S_CBRANCH_CDBGUSER
3036 // S_CBRANCH_CDBGSYS
3037 // S_CBRANCH_CDBGSYS_OR_USER
3038 // S_CBRANCH_CDBGSYS_AND_USER
3041 // DS_GWS_SEMA_RELEASE_ALL
3043 // DS_CNDXCHG32_RTN_B64
3046 // DS_CONDXCHG32_RTN_B128
3049 // BUFFER_LOAD_DWORDX3
3050 // BUFFER_STORE_DWORDX3
3054 //===----------------------------------------------------------------------===//
3056 //===----------------------------------------------------------------------===//
3058 class FLATLoad_Pattern <FLAT Instr_ADDR64, ValueType vt,
3060 Pat <(vt (flat_ld i64:$ptr)),
3064 def : FLATLoad_Pattern <FLAT_LOAD_SBYTE, i32, sextloadi8_flat>;
3065 def : FLATLoad_Pattern <FLAT_LOAD_UBYTE, i32, az_extloadi8_flat>;
3066 def : FLATLoad_Pattern <FLAT_LOAD_SSHORT, i32, sextloadi16_flat>;
3067 def : FLATLoad_Pattern <FLAT_LOAD_USHORT, i32, az_extloadi16_flat>;
3068 def : FLATLoad_Pattern <FLAT_LOAD_DWORD, i32, flat_load>;
3069 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, i64, flat_load>;
3070 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, i64, az_extloadi32_flat>;
3071 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX2, v2i32, flat_load>;
3072 def : FLATLoad_Pattern <FLAT_LOAD_DWORDX4, v4i32, flat_load>;
3074 class FLATStore_Pattern <FLAT Instr, ValueType vt, PatFrag st> :
3075 Pat <(st vt:$value, i64:$ptr),
3076 (Instr $value, $ptr)
3079 def : FLATStore_Pattern <FLAT_STORE_BYTE, i32, truncstorei8_flat>;
3080 def : FLATStore_Pattern <FLAT_STORE_SHORT, i32, truncstorei16_flat>;
3081 def : FLATStore_Pattern <FLAT_STORE_DWORD, i32, flat_store>;
3082 def : FLATStore_Pattern <FLAT_STORE_DWORDX2, i64, flat_store>;
3083 def : FLATStore_Pattern <FLAT_STORE_DWORDX2, v2i32, flat_store>;
3084 def : FLATStore_Pattern <FLAT_STORE_DWORDX4, v4i32, flat_store>;
3086 /********** ====================== **********/
3087 /********** Indirect adressing **********/
3088 /********** ====================== **********/
3090 multiclass SI_INDIRECT_Pattern <ValueType vt, ValueType eltvt, SI_INDIRECT_DST IndDst> {
3092 // 1. Extract with offset
3094 (vector_extract vt:$vec, (add i32:$idx, imm:$off)),
3095 (eltvt (SI_INDIRECT_SRC (IMPLICIT_DEF), $vec, $idx, imm:$off))
3098 // 2. Extract without offset
3100 (vector_extract vt:$vec, i32:$idx),
3101 (eltvt (SI_INDIRECT_SRC (IMPLICIT_DEF), $vec, $idx, 0))
3104 // 3. Insert with offset
3106 (vector_insert vt:$vec, eltvt:$val, (add i32:$idx, imm:$off)),
3107 (IndDst (IMPLICIT_DEF), $vec, $idx, imm:$off, $val)
3110 // 4. Insert without offset
3112 (vector_insert vt:$vec, eltvt:$val, i32:$idx),
3113 (IndDst (IMPLICIT_DEF), $vec, $idx, 0, $val)
3117 defm : SI_INDIRECT_Pattern <v2f32, f32, SI_INDIRECT_DST_V2>;
3118 defm : SI_INDIRECT_Pattern <v4f32, f32, SI_INDIRECT_DST_V4>;
3119 defm : SI_INDIRECT_Pattern <v8f32, f32, SI_INDIRECT_DST_V8>;
3120 defm : SI_INDIRECT_Pattern <v16f32, f32, SI_INDIRECT_DST_V16>;
3122 defm : SI_INDIRECT_Pattern <v2i32, i32, SI_INDIRECT_DST_V2>;
3123 defm : SI_INDIRECT_Pattern <v4i32, i32, SI_INDIRECT_DST_V4>;
3124 defm : SI_INDIRECT_Pattern <v8i32, i32, SI_INDIRECT_DST_V8>;
3125 defm : SI_INDIRECT_Pattern <v16i32, i32, SI_INDIRECT_DST_V16>;
3127 //===----------------------------------------------------------------------===//
3128 // Conversion Patterns
3129 //===----------------------------------------------------------------------===//
3131 def : Pat<(i32 (sext_inreg i32:$src, i1)),
3132 (S_BFE_I32 i32:$src, 65536)>; // 0 | 1 << 16
3134 // Handle sext_inreg in i64
3136 (i64 (sext_inreg i64:$src, i1)),
3137 (S_BFE_I64 i64:$src, 0x10000) // 0 | 1 << 16
3141 (i64 (sext_inreg i64:$src, i8)),
3142 (S_BFE_I64 i64:$src, 0x80000) // 0 | 8 << 16
3146 (i64 (sext_inreg i64:$src, i16)),
3147 (S_BFE_I64 i64:$src, 0x100000) // 0 | 16 << 16
3151 (i64 (sext_inreg i64:$src, i32)),
3152 (S_BFE_I64 i64:$src, 0x200000) // 0 | 32 << 16
3155 class ZExt_i64_i32_Pat <SDNode ext> : Pat <
3156 (i64 (ext i32:$src)),
3157 (REG_SEQUENCE SReg_64, $src, sub0, (S_MOV_B32 0), sub1)
3160 class ZExt_i64_i1_Pat <SDNode ext> : Pat <
3161 (i64 (ext i1:$src)),
3162 (REG_SEQUENCE VReg_64,
3163 (V_CNDMASK_B32_e64 (i32 0), (i32 1), $src), sub0,
3164 (S_MOV_B32 0), sub1)
3168 def : ZExt_i64_i32_Pat<zext>;
3169 def : ZExt_i64_i32_Pat<anyext>;
3170 def : ZExt_i64_i1_Pat<zext>;
3171 def : ZExt_i64_i1_Pat<anyext>;
3174 (i64 (sext i32:$src)),
3175 (REG_SEQUENCE SReg_64, $src, sub0,
3176 (S_ASHR_I32 $src, 31), sub1)
3180 (i64 (sext i1:$src)),
3181 (REG_SEQUENCE VReg_64,
3182 (V_CNDMASK_B32_e64 0, -1, $src), sub0,
3183 (V_CNDMASK_B32_e64 0, -1, $src), sub1)
3186 // If we need to perform a logical operation on i1 values, we need to
3187 // use vector comparisons since there is only one SCC register. Vector
3188 // comparisions still write to a pair of SGPRs, so treat these as
3189 // 64-bit comparisons. When legalizing SGPR copies, instructions
3190 // resulting in the copies from SCC to these instructions will be
3191 // moved to the VALU.
3193 (i1 (and i1:$src0, i1:$src1)),
3194 (S_AND_B64 $src0, $src1)
3198 (i1 (or i1:$src0, i1:$src1)),
3199 (S_OR_B64 $src0, $src1)
3203 (i1 (xor i1:$src0, i1:$src1)),
3204 (S_XOR_B64 $src0, $src1)
3208 (f32 (sint_to_fp i1:$src)),
3209 (V_CNDMASK_B32_e64 (i32 0), CONST.FP32_NEG_ONE, $src)
3213 (f32 (uint_to_fp i1:$src)),
3214 (V_CNDMASK_B32_e64 (i32 0), CONST.FP32_ONE, $src)
3218 (f64 (sint_to_fp i1:$src)),
3219 (V_CVT_F64_I32_e32 (V_CNDMASK_B32_e64 (i32 0), (i32 -1), $src))
3223 (f64 (uint_to_fp i1:$src)),
3224 (V_CVT_F64_U32_e32 (V_CNDMASK_B32_e64 (i32 0), (i32 1), $src))
3227 //===----------------------------------------------------------------------===//
3228 // Miscellaneous Patterns
3229 //===----------------------------------------------------------------------===//
3232 (i32 (trunc i64:$a)),
3233 (EXTRACT_SUBREG $a, sub0)
3237 (i1 (trunc i32:$a)),
3238 (V_CMP_EQ_I32_e64 (V_AND_B32_e64 (i32 1), $a), 1)
3242 (i32 (bswap i32:$a)),
3243 (V_BFI_B32 (S_MOV_B32 0x00ff00ff),
3244 (V_ALIGNBIT_B32 $a, $a, 24),
3245 (V_ALIGNBIT_B32 $a, $a, 8))
3249 (f32 (select i1:$src2, f32:$src1, f32:$src0)),
3250 (V_CNDMASK_B32_e64 $src0, $src1, $src2)
3253 //============================================================================//
3254 // Miscellaneous Optimization Patterns
3255 //============================================================================//
3257 def : SHA256MaPattern <V_BFI_B32, V_XOR_B32_e64>;
3259 } // End isGCN predicate