1 //===-- EvergreenInstructions.td - EG Instruction defs ----*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // TableGen definitions for instructions which are:
10 // - Available to Evergreen and newer VLIW4/VLIW5 GPUs
11 // - Available only on Evergreen family GPUs.
13 //===----------------------------------------------------------------------===//
16 "Subtarget->getGeneration() >= AMDGPUSubtarget::EVERGREEN && "
17 "!Subtarget->hasCaymanISA()"
20 def isEGorCayman : Predicate<
21 "Subtarget->getGeneration() == AMDGPUSubtarget::EVERGREEN ||"
22 "Subtarget->getGeneration() == AMDGPUSubtarget::NORTHERN_ISLANDS"
25 class EGPat<dag pattern, dag result> : AMDGPUPat<pattern, result> {
26 let SubtargetPredicate = isEG;
29 class EGOrCaymanPat<dag pattern, dag result> : AMDGPUPat<pattern, result> {
30 let SubtargetPredicate = isEGorCayman;
33 //===----------------------------------------------------------------------===//
34 // Evergreen / Cayman store instructions
35 //===----------------------------------------------------------------------===//
37 let SubtargetPredicate = isEGorCayman in {
39 class CF_MEM_RAT_CACHELESS <bits<6> rat_inst, bits<4> rat_id, bits<4> mask, dag ins,
40 string name, list<dag> pattern>
41 : EG_CF_RAT <0x57, rat_inst, rat_id, mask, (outs), ins,
42 "MEM_RAT_CACHELESS "#name, pattern>;
44 class CF_MEM_RAT <bits<6> rat_inst, bits<4> rat_id, bits<4> mask, dag ins,
45 dag outs, string name, list<dag> pattern>
46 : EG_CF_RAT <0x56, rat_inst, rat_id, mask, outs, ins,
47 "MEM_RAT "#name, pattern>;
49 class CF_MEM_RAT_STORE_TYPED<bits<1> has_eop>
50 : CF_MEM_RAT <0x1, ?, 0xf, (ins R600_Reg128:$rw_gpr, R600_Reg128:$index_gpr,
51 i32imm:$rat_id, InstFlag:$eop), (outs),
52 "STORE_TYPED RAT($rat_id) $rw_gpr, $index_gpr"
53 #!if(has_eop, ", $eop", ""),
54 [(int_r600_rat_store_typed R600_Reg128:$rw_gpr,
55 R600_Reg128:$index_gpr,
58 def RAT_MSKOR : CF_MEM_RAT <0x11, 0, 0xf,
59 (ins R600_Reg128:$rw_gpr, R600_TReg32_X:$index_gpr), (outs),
60 "MSKOR $rw_gpr.XW, $index_gpr",
61 [(mskor_global v4i32:$rw_gpr, i32:$index_gpr)]
67 multiclass RAT_ATOMIC<bits<6> op_ret, bits<6> op_noret, string name> {
68 let Constraints = "$rw_gpr = $out_gpr", eop = 0, mayStore = 1 in {
69 def _RTN: CF_MEM_RAT <op_ret, 0, 0xf,
70 (ins R600_Reg128:$rw_gpr, R600_TReg32_X:$index_gpr),
71 (outs R600_Reg128:$out_gpr),
72 name ## "_RTN" ## " $rw_gpr, $index_gpr", [] >;
73 def _NORET: CF_MEM_RAT <op_noret, 0, 0xf,
74 (ins R600_Reg128:$rw_gpr, R600_TReg32_X:$index_gpr),
75 (outs R600_Reg128:$out_gpr),
76 name ## " $rw_gpr, $index_gpr", [] >;
80 // Swap no-ret is just store. Raw store to cached target
81 // can only store on dword, which exactly matches swap_no_ret.
82 defm RAT_ATOMIC_XCHG_INT : RAT_ATOMIC<1, 34, "ATOMIC_XCHG_INT">;
83 defm RAT_ATOMIC_CMPXCHG_INT : RAT_ATOMIC<4, 36, "ATOMIC_CMPXCHG_INT">;
84 defm RAT_ATOMIC_ADD : RAT_ATOMIC<7, 39, "ATOMIC_ADD">;
85 defm RAT_ATOMIC_SUB : RAT_ATOMIC<8, 40, "ATOMIC_SUB">;
86 defm RAT_ATOMIC_RSUB : RAT_ATOMIC<9, 41, "ATOMIC_RSUB">;
87 defm RAT_ATOMIC_MIN_INT : RAT_ATOMIC<10, 42, "ATOMIC_MIN_INT">;
88 defm RAT_ATOMIC_MIN_UINT : RAT_ATOMIC<11, 43, "ATOMIC_MIN_UINT">;
89 defm RAT_ATOMIC_MAX_INT : RAT_ATOMIC<12, 44, "ATOMIC_MAX_INT">;
90 defm RAT_ATOMIC_MAX_UINT : RAT_ATOMIC<13, 45, "ATOMIC_MAX_UINT">;
91 defm RAT_ATOMIC_AND : RAT_ATOMIC<14, 46, "ATOMIC_AND">;
92 defm RAT_ATOMIC_OR : RAT_ATOMIC<15, 47, "ATOMIC_OR">;
93 defm RAT_ATOMIC_XOR : RAT_ATOMIC<16, 48, "ATOMIC_XOR">;
94 defm RAT_ATOMIC_INC_UINT : RAT_ATOMIC<18, 50, "ATOMIC_INC_UINT">;
95 defm RAT_ATOMIC_DEC_UINT : RAT_ATOMIC<19, 51, "ATOMIC_DEC_UINT">;
97 } // End SubtargetPredicate = isEGorCayman
99 //===----------------------------------------------------------------------===//
100 // Evergreen Only instructions
101 //===----------------------------------------------------------------------===//
103 let SubtargetPredicate = isEG in {
105 def RECIP_IEEE_eg : RECIP_IEEE_Common<0x86>;
106 defm DIV_eg : DIV_Common<RECIP_IEEE_eg>;
108 def MULLO_INT_eg : MULLO_INT_Common<0x8F>;
109 def MULHI_INT_eg : MULHI_INT_Common<0x90>;
110 def MULLO_UINT_eg : MULLO_UINT_Common<0x91>;
111 def MULHI_UINT_eg : MULHI_UINT_Common<0x92>;
112 def MULHI_UINT24_eg : MULHI_UINT24_Common<0xb2>;
114 def RECIP_UINT_eg : RECIP_UINT_Common<0x94>;
115 def RECIPSQRT_CLAMPED_eg : RECIPSQRT_CLAMPED_Common<0x87>;
116 def EXP_IEEE_eg : EXP_IEEE_Common<0x81>;
117 def LOG_IEEE_eg : LOG_IEEE_Common<0x83>;
118 def RECIP_CLAMPED_eg : RECIP_CLAMPED_Common<0x84>;
119 def RECIPSQRT_IEEE_eg : RECIPSQRT_IEEE_Common<0x89>;
120 def : RsqPat<RECIPSQRT_IEEE_eg, f32>;
121 def SIN_eg : SIN_Common<0x8D>;
122 def COS_eg : COS_Common<0x8E>;
124 def : POW_Common <LOG_IEEE_eg, EXP_IEEE_eg, MUL>;
125 def : EGPat<(fsqrt f32:$src), (MUL $src, (RECIPSQRT_CLAMPED_eg $src))>;
126 } // End SubtargetPredicate = isEG
128 //===----------------------------------------------------------------------===//
129 // Memory read/write instructions
130 //===----------------------------------------------------------------------===//
132 let usesCustomInserter = 1 in {
135 def RAT_WRITE_CACHELESS_32_eg : CF_MEM_RAT_CACHELESS <0x2, 0, 0x1,
136 (ins R600_TReg32_X:$rw_gpr, R600_TReg32_X:$index_gpr, InstFlag:$eop),
137 "STORE_RAW $rw_gpr, $index_gpr, $eop",
138 [(store_global i32:$rw_gpr, i32:$index_gpr)]
142 def RAT_WRITE_CACHELESS_64_eg : CF_MEM_RAT_CACHELESS <0x2, 0, 0x3,
143 (ins R600_Reg64:$rw_gpr, R600_TReg32_X:$index_gpr, InstFlag:$eop),
144 "STORE_RAW $rw_gpr.XY, $index_gpr, $eop",
145 [(store_global v2i32:$rw_gpr, i32:$index_gpr)]
149 def RAT_WRITE_CACHELESS_128_eg : CF_MEM_RAT_CACHELESS <0x2, 0, 0xf,
150 (ins R600_Reg128:$rw_gpr, R600_TReg32_X:$index_gpr, InstFlag:$eop),
151 "STORE_RAW $rw_gpr.XYZW, $index_gpr, $eop",
152 [(store_global v4i32:$rw_gpr, i32:$index_gpr)]
155 def RAT_STORE_TYPED_eg: CF_MEM_RAT_STORE_TYPED<1>;
157 } // End usesCustomInserter = 1
159 class VTX_READ_eg <string name, dag outs>
160 : VTX_WORD0_eg, VTX_READ<name, outs, []> {
165 let FETCH_WHOLE_QUAD = 0;
167 // XXX: We can infer this field based on the SRC_GPR. This would allow us
168 // to store vertex addresses in any channel, not just X.
171 let Inst{31-0} = Word0;
175 : VTX_READ_eg <"VTX_READ_8 $dst_gpr, $src_gpr",
176 (outs R600_TReg32_X:$dst_gpr)> {
178 let MEGA_FETCH_COUNT = 1;
180 let DST_SEL_Y = 7; // Masked
181 let DST_SEL_Z = 7; // Masked
182 let DST_SEL_W = 7; // Masked
183 let DATA_FORMAT = 1; // FMT_8
187 : VTX_READ_eg <"VTX_READ_16 $dst_gpr, $src_gpr",
188 (outs R600_TReg32_X:$dst_gpr)> {
189 let MEGA_FETCH_COUNT = 2;
191 let DST_SEL_Y = 7; // Masked
192 let DST_SEL_Z = 7; // Masked
193 let DST_SEL_W = 7; // Masked
194 let DATA_FORMAT = 5; // FMT_16
199 : VTX_READ_eg <"VTX_READ_32 $dst_gpr, $src_gpr",
200 (outs R600_TReg32_X:$dst_gpr)> {
202 let MEGA_FETCH_COUNT = 4;
204 let DST_SEL_Y = 7; // Masked
205 let DST_SEL_Z = 7; // Masked
206 let DST_SEL_W = 7; // Masked
207 let DATA_FORMAT = 0xD; // COLOR_32
209 // This is not really necessary, but there were some GPU hangs that appeared
210 // to be caused by ALU instructions in the next instruction group that wrote
211 // to the $src_gpr registers of the VTX_READ.
213 // %t3_x = VTX_READ_PARAM_32_eg killed %t2_x, 24
215 //Adding this constraint prevents this from happening.
216 let Constraints = "$src_gpr.ptr = $dst_gpr";
220 : VTX_READ_eg <"VTX_READ_64 $dst_gpr.XY, $src_gpr",
221 (outs R600_Reg64:$dst_gpr)> {
223 let MEGA_FETCH_COUNT = 8;
228 let DATA_FORMAT = 0x1D; // COLOR_32_32
232 : VTX_READ_eg <"VTX_READ_128 $dst_gpr.XYZW, $src_gpr",
233 (outs R600_Reg128:$dst_gpr)> {
235 let MEGA_FETCH_COUNT = 16;
240 let DATA_FORMAT = 0x22; // COLOR_32_32_32_32
242 // XXX: Need to force VTX_READ_128 instructions to write to the same register
243 // that holds its buffer address to avoid potential hangs. We can't use
244 // the same constraint as VTX_READ_32_eg, because the $src_gpr.ptr and $dst
245 // registers are different sizes.
248 //===----------------------------------------------------------------------===//
249 // VTX Read from parameter memory space
250 //===----------------------------------------------------------------------===//
251 def : EGPat<(i32:$dst_gpr (vtx_id3_az_extloadi8 ADDRVTX_READ:$src_gpr)),
252 (VTX_READ_8_eg MEMxi:$src_gpr, 3)>;
253 def : EGPat<(i32:$dst_gpr (vtx_id3_az_extloadi16 ADDRVTX_READ:$src_gpr)),
254 (VTX_READ_16_eg MEMxi:$src_gpr, 3)>;
255 def : EGPat<(i32:$dst_gpr (vtx_id3_load ADDRVTX_READ:$src_gpr)),
256 (VTX_READ_32_eg MEMxi:$src_gpr, 3)>;
257 def : EGPat<(v2i32:$dst_gpr (vtx_id3_load ADDRVTX_READ:$src_gpr)),
258 (VTX_READ_64_eg MEMxi:$src_gpr, 3)>;
259 def : EGPat<(v4i32:$dst_gpr (vtx_id3_load ADDRVTX_READ:$src_gpr)),
260 (VTX_READ_128_eg MEMxi:$src_gpr, 3)>;
262 //===----------------------------------------------------------------------===//
263 // VTX Read from constant memory space
264 //===----------------------------------------------------------------------===//
265 def : EGPat<(i32:$dst_gpr (vtx_id2_az_extloadi8 ADDRVTX_READ:$src_gpr)),
266 (VTX_READ_8_eg MEMxi:$src_gpr, 2)>;
267 def : EGPat<(i32:$dst_gpr (vtx_id2_az_extloadi16 ADDRVTX_READ:$src_gpr)),
268 (VTX_READ_16_eg MEMxi:$src_gpr, 2)>;
269 def : EGPat<(i32:$dst_gpr (vtx_id2_load ADDRVTX_READ:$src_gpr)),
270 (VTX_READ_32_eg MEMxi:$src_gpr, 2)>;
271 def : EGPat<(v2i32:$dst_gpr (vtx_id2_load ADDRVTX_READ:$src_gpr)),
272 (VTX_READ_64_eg MEMxi:$src_gpr, 2)>;
273 def : EGPat<(v4i32:$dst_gpr (vtx_id2_load ADDRVTX_READ:$src_gpr)),
274 (VTX_READ_128_eg MEMxi:$src_gpr, 2)>;
276 //===----------------------------------------------------------------------===//
277 // VTX Read from global memory space
278 //===----------------------------------------------------------------------===//
279 def : EGPat<(i32:$dst_gpr (vtx_id1_az_extloadi8 ADDRVTX_READ:$src_gpr)),
280 (VTX_READ_8_eg MEMxi:$src_gpr, 1)>;
281 def : EGPat<(i32:$dst_gpr (vtx_id1_az_extloadi16 ADDRVTX_READ:$src_gpr)),
282 (VTX_READ_16_eg MEMxi:$src_gpr, 1)>;
283 def : EGPat<(i32:$dst_gpr (vtx_id1_load ADDRVTX_READ:$src_gpr)),
284 (VTX_READ_32_eg MEMxi:$src_gpr, 1)>;
285 def : EGPat<(v2i32:$dst_gpr (vtx_id1_load ADDRVTX_READ:$src_gpr)),
286 (VTX_READ_64_eg MEMxi:$src_gpr, 1)>;
287 def : EGPat<(v4i32:$dst_gpr (vtx_id1_load ADDRVTX_READ:$src_gpr)),
288 (VTX_READ_128_eg MEMxi:$src_gpr, 1)>;
290 //===----------------------------------------------------------------------===//
291 // Evergreen / Cayman Instructions
292 //===----------------------------------------------------------------------===//
294 let SubtargetPredicate = isEGorCayman in {
296 multiclass AtomicPat<Instruction inst_ret, Instruction inst_noret,
297 SDPatternOperator node_ret, SDPatternOperator node_noret> {
298 // FIXME: Add _RTN version. We need per WI scratch location to store the old value
299 // EXTRACT_SUBREG here is dummy, we know the node has no uses
300 def : EGOrCaymanPat<(i32 (node_noret i32:$ptr, i32:$data)),
301 (EXTRACT_SUBREG (inst_noret
302 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), $data, sub0), $ptr), sub1)>;
304 multiclass AtomicIncDecPat<Instruction inst_ret, Instruction inst_noret,
305 SDPatternOperator node_ret, SDPatternOperator node_noret, int C> {
306 // FIXME: Add _RTN version. We need per WI scratch location to store the old value
307 // EXTRACT_SUBREG here is dummy, we know the node has no uses
308 def : EGOrCaymanPat<(i32 (node_noret i32:$ptr, C)),
309 (EXTRACT_SUBREG (inst_noret
310 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), (MOV_IMM_I32 -1), sub0), $ptr), sub1)>;
313 // CMPSWAP is pattern is special
314 // EXTRACT_SUBREG here is dummy, we know the node has no uses
315 // FIXME: Add _RTN version. We need per WI scratch location to store the old value
316 def : EGOrCaymanPat<(i32 (atomic_cmp_swap_global_noret i32:$ptr, i32:$cmp, i32:$data)),
317 (EXTRACT_SUBREG (RAT_ATOMIC_CMPXCHG_INT_NORET
319 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), $cmp, sub3),
323 defm AtomicSwapPat : AtomicPat <RAT_ATOMIC_XCHG_INT_RTN,
324 RAT_ATOMIC_XCHG_INT_NORET,
325 atomic_swap_global_ret_32,
326 atomic_swap_global_noret_32>;
327 defm AtomicAddPat : AtomicPat <RAT_ATOMIC_ADD_RTN, RAT_ATOMIC_ADD_NORET,
328 atomic_load_add_global_ret_32, atomic_load_add_global_noret_32>;
329 defm AtomicSubPat : AtomicPat <RAT_ATOMIC_SUB_RTN, RAT_ATOMIC_SUB_NORET,
330 atomic_load_sub_global_ret_32, atomic_load_sub_global_noret_32>;
331 defm AtomicMinPat : AtomicPat <RAT_ATOMIC_MIN_INT_RTN,
332 RAT_ATOMIC_MIN_INT_NORET,
333 atomic_load_min_global_ret_32, atomic_load_min_global_noret_32>;
334 defm AtomicUMinPat : AtomicPat <RAT_ATOMIC_MIN_UINT_RTN,
335 RAT_ATOMIC_MIN_UINT_NORET,
336 atomic_load_umin_global_ret_32, atomic_load_umin_global_noret_32>;
337 defm AtomicMaxPat : AtomicPat <RAT_ATOMIC_MAX_INT_RTN,
338 RAT_ATOMIC_MAX_INT_NORET,
339 atomic_load_max_global_ret_32, atomic_load_max_global_noret_32>;
340 defm AtomicUMaxPat : AtomicPat <RAT_ATOMIC_MAX_UINT_RTN,
341 RAT_ATOMIC_MAX_UINT_NORET,
342 atomic_load_umax_global_ret_32, atomic_load_umax_global_noret_32>;
343 defm AtomicAndPat : AtomicPat <RAT_ATOMIC_AND_RTN, RAT_ATOMIC_AND_NORET,
344 atomic_load_and_global_ret_32, atomic_load_and_global_noret_32>;
345 defm AtomicOrPat : AtomicPat <RAT_ATOMIC_OR_RTN, RAT_ATOMIC_OR_NORET,
346 atomic_load_or_global_ret_32, atomic_load_or_global_noret_32>;
347 defm AtomicXorPat : AtomicPat <RAT_ATOMIC_XOR_RTN, RAT_ATOMIC_XOR_NORET,
348 atomic_load_xor_global_ret_32, atomic_load_xor_global_noret_32>;
349 defm AtomicIncAddPat : AtomicIncDecPat <RAT_ATOMIC_INC_UINT_RTN,
350 RAT_ATOMIC_INC_UINT_NORET,
351 atomic_load_add_global_ret_32,
352 atomic_load_add_global_noret_32, 1>;
353 defm AtomicIncSubPat : AtomicIncDecPat <RAT_ATOMIC_INC_UINT_RTN,
354 RAT_ATOMIC_INC_UINT_NORET,
355 atomic_load_sub_global_ret_32,
356 atomic_load_sub_global_noret_32, -1>;
357 defm AtomicDecAddPat : AtomicIncDecPat <RAT_ATOMIC_DEC_UINT_RTN,
358 RAT_ATOMIC_DEC_UINT_NORET,
359 atomic_load_add_global_ret_32,
360 atomic_load_add_global_noret_32, -1>;
361 defm AtomicDecSubPat : AtomicIncDecPat <RAT_ATOMIC_DEC_UINT_RTN,
362 RAT_ATOMIC_DEC_UINT_NORET,
363 atomic_load_sub_global_ret_32,
364 atomic_load_sub_global_noret_32, 1>;
366 // Should be predicated on FeatureFP64
367 // def FMA_64 : R600_3OP <
369 // [(set f64:$dst, (fma f64:$src0, f64:$src1, f64:$src2))]
372 // BFE_UINT - bit_extract, an optimization for mask and shift
377 // bit_extract = (Input << (32 - Offset - Width)) >> (32 - Width)
382 // (0, 8) = (Input << 24) >> 24 = (Input & 0xff) >> 0
383 // (8, 8) = (Input << 16) >> 24 = (Input & 0xffff) >> 8
384 // (16, 8) = (Input << 8) >> 24 = (Input & 0xffffff) >> 16
385 // (24, 8) = (Input << 0) >> 24 = (Input & 0xffffffff) >> 24
386 def BFE_UINT_eg : R600_3OP <0x4, "BFE_UINT",
387 [(set i32:$dst, (AMDGPUbfe_u32 i32:$src0, i32:$src1, i32:$src2))],
391 def BFE_INT_eg : R600_3OP <0x5, "BFE_INT",
392 [(set i32:$dst, (AMDGPUbfe_i32 i32:$src0, i32:$src1, i32:$src2))],
396 defm : BFEPattern <BFE_UINT_eg, BFE_INT_eg, MOV_IMM_I32>;
398 def BFI_INT_eg : R600_3OP <0x06, "BFI_INT",
399 [(set i32:$dst, (AMDGPUbfi i32:$src0, i32:$src1, i32:$src2))],
403 def : EGOrCaymanPat<(i32 (sext_inreg i32:$src, i1)),
404 (BFE_INT_eg i32:$src, (i32 ZERO), (i32 ONE_INT))>;
405 def : EGOrCaymanPat<(i32 (sext_inreg i32:$src, i8)),
406 (BFE_INT_eg i32:$src, (i32 ZERO), (MOV_IMM_I32 8))>;
407 def : EGOrCaymanPat<(i32 (sext_inreg i32:$src, i16)),
408 (BFE_INT_eg i32:$src, (i32 ZERO), (MOV_IMM_I32 16))>;
410 defm : BFIPatterns <BFI_INT_eg, MOV_IMM_I32, R600_Reg64>;
412 def BFM_INT_eg : R600_2OP <0xA0, "BFM_INT",
413 [(set i32:$dst, (AMDGPUbfm i32:$src0, i32:$src1))],
417 def MULADD_UINT24_eg : R600_3OP <0x10, "MULADD_UINT24",
418 [(set i32:$dst, (AMDGPUmad_u24 i32:$src0, i32:$src1, i32:$src2))], VecALU
421 def : UMad24Pat<MULADD_UINT24_eg>;
423 def BIT_ALIGN_INT_eg : R600_3OP <0xC, "BIT_ALIGN_INT", [], VecALU>;
424 def : ROTRPattern <BIT_ALIGN_INT_eg>;
425 def MULADD_eg : MULADD_Common<0x14>;
426 def MULADD_IEEE_eg : MULADD_IEEE_Common<0x18>;
427 def FMA_eg : FMA_Common<0x7>;
428 def ASHR_eg : ASHR_Common<0x15>;
429 def LSHR_eg : LSHR_Common<0x16>;
430 def LSHL_eg : LSHL_Common<0x17>;
431 def CNDE_eg : CNDE_Common<0x19>;
432 def CNDGT_eg : CNDGT_Common<0x1A>;
433 def CNDGE_eg : CNDGE_Common<0x1B>;
434 def MUL_LIT_eg : MUL_LIT_Common<0x1F>;
435 def LOG_CLAMPED_eg : LOG_CLAMPED_Common<0x82>;
436 def MUL_UINT24_eg : R600_2OP <0xB5, "MUL_UINT24",
437 [(set i32:$dst, (AMDGPUmul_u24 i32:$src0, i32:$src1))], VecALU
439 def DOT4_eg : DOT4_Common<0xBE>;
440 defm CUBE_eg : CUBE_Common<0xC0>;
443 def ADDC_UINT : R600_2OP_Helper <0x52, "ADDC_UINT", AMDGPUcarry>;
444 def SUBB_UINT : R600_2OP_Helper <0x53, "SUBB_UINT", AMDGPUborrow>;
446 def FLT32_TO_FLT16 : R600_1OP_Helper <0xA2, "FLT32_TO_FLT16", AMDGPUfp_to_f16, VecALU>;
447 def FLT16_TO_FLT32 : R600_1OP_Helper <0xA3, "FLT16_TO_FLT32", f16_to_fp, VecALU>;
448 def BCNT_INT : R600_1OP_Helper <0xAA, "BCNT_INT", ctpop, VecALU>;
449 def FFBH_UINT : R600_1OP_Helper <0xAB, "FFBH_UINT", AMDGPUffbh_u32, VecALU>;
450 def FFBL_INT : R600_1OP_Helper <0xAC, "FFBL_INT", AMDGPUffbl_b32, VecALU>;
452 let hasSideEffects = 1 in {
453 def MOVA_INT_eg : R600_1OP <0xCC, "MOVA_INT", [], VecALU>;
456 def FLT_TO_INT_eg : FLT_TO_INT_Common<0x50> {
458 let Itinerary = AnyALU;
461 def INT_TO_FLT_eg : INT_TO_FLT_Common<0x9B>;
463 def FLT_TO_UINT_eg : FLT_TO_UINT_Common<0x9A> {
467 def UINT_TO_FLT_eg : UINT_TO_FLT_Common<0x9C>;
469 def GROUP_BARRIER : InstR600 <
470 (outs), (ins), " GROUP_BARRIER", [(int_r600_group_barrier)], AnyALU>,
472 R600ALU_Word1_OP2 <0x54> {
488 let bank_swizzle = 0;
490 let update_exec_mask = 0;
493 let Inst{31-0} = Word0;
494 let Inst{63-32} = Word1;
499 //===----------------------------------------------------------------------===//
501 //===----------------------------------------------------------------------===//
502 class R600_LDS <bits<6> op, dag outs, dag ins, string asm,
503 list<dag> pattern = []> :
505 InstR600 <outs, ins, asm, pattern, XALU>,
512 let Word1{27} = offset{0};
513 let Word1{12} = offset{1};
514 let Word1{28} = offset{2};
515 let Word1{31} = offset{3};
516 let Word0{12} = offset{4};
517 let Word0{25} = offset{5};
520 let Inst{31-0} = Word0;
521 let Inst{63-32} = Word1;
524 let HasNativeOperands = 1;
525 let UseNamedOperandTable = 1;
528 class R600_LDS_1A <bits<6> lds_op, string name, list<dag> pattern> : R600_LDS <
530 (outs R600_Reg32:$dst),
531 (ins R600_Reg32:$src0, REL:$src0_rel, SEL:$src0_sel,
532 LAST:$last, R600_Pred:$pred_sel,
533 BANK_SWIZZLE:$bank_swizzle),
534 " "#name#" $last OQAP, $src0$src0_rel $pred_sel",
543 let usesCustomInserter = 1;
545 let DisableEncoding = "$dst";
548 class R600_LDS_1A1D <bits<6> lds_op, dag outs, string name, list<dag> pattern,
552 (ins R600_Reg32:$src0, REL:$src0_rel, SEL:$src0_sel,
553 R600_Reg32:$src1, REL:$src1_rel, SEL:$src1_sel,
554 LAST:$last, R600_Pred:$pred_sel,
555 BANK_SWIZZLE:$bank_swizzle),
556 " "#name#" $last "#dst#"$src0$src0_rel, $src1$src1_rel, $pred_sel",
567 class R600_LDS_1A1D_NORET <bits<6> lds_op, string name, list<dag> pattern> :
568 R600_LDS_1A1D <lds_op, (outs), name, pattern> {
572 class R600_LDS_1A1D_RET <bits<6> lds_op, string name, list<dag> pattern> :
573 R600_LDS_1A1D <lds_op, (outs R600_Reg32:$dst), name##"_RET", pattern, "OQAP, "> {
576 let usesCustomInserter = 1;
577 let DisableEncoding = "$dst";
580 class R600_LDS_1A2D <bits<6> lds_op, dag outs, string name, list<dag> pattern,
584 (ins R600_Reg32:$src0, REL:$src0_rel, SEL:$src0_sel,
585 R600_Reg32:$src1, REL:$src1_rel, SEL:$src1_sel,
586 R600_Reg32:$src2, REL:$src2_rel, SEL:$src2_sel,
587 LAST:$last, R600_Pred:$pred_sel, BANK_SWIZZLE:$bank_swizzle),
588 " "#name# "$last "#dst#"$src0$src0_rel, $src1$src1_rel, $src2$src2_rel, $pred_sel",
597 class R600_LDS_1A2D_NORET <bits<6> lds_op, string name, list<dag> pattern> :
598 R600_LDS_1A2D <lds_op, (outs), name, pattern> {
602 class R600_LDS_1A2D_RET <bits<6> lds_op, string name, list<dag> pattern> :
603 R600_LDS_1A2D <lds_op, (outs R600_Reg32:$dst), name, pattern> {
606 let usesCustomInserter = 1;
607 let DisableEncoding = "$dst";
610 def LDS_ADD : R600_LDS_1A1D_NORET <0x0, "LDS_ADD", [] >;
611 def LDS_SUB : R600_LDS_1A1D_NORET <0x1, "LDS_SUB", [] >;
612 def LDS_AND : R600_LDS_1A1D_NORET <0x9, "LDS_AND", [] >;
613 def LDS_OR : R600_LDS_1A1D_NORET <0xa, "LDS_OR", [] >;
614 def LDS_XOR : R600_LDS_1A1D_NORET <0xb, "LDS_XOR", [] >;
615 def LDS_WRXCHG: R600_LDS_1A1D_NORET <0xd, "LDS_WRXCHG", [] >;
616 def LDS_CMPST: R600_LDS_1A2D_NORET <0x10, "LDS_CMPST", [] >;
617 def LDS_MIN_INT : R600_LDS_1A1D_NORET <0x5, "LDS_MIN_INT", [] >;
618 def LDS_MAX_INT : R600_LDS_1A1D_NORET <0x6, "LDS_MAX_INT", [] >;
619 def LDS_MIN_UINT : R600_LDS_1A1D_NORET <0x7, "LDS_MIN_UINT", [] >;
620 def LDS_MAX_UINT : R600_LDS_1A1D_NORET <0x8, "LDS_MAX_UINT", [] >;
621 def LDS_WRITE : R600_LDS_1A1D_NORET <0xD, "LDS_WRITE",
622 [(store_local (i32 R600_Reg32:$src1), R600_Reg32:$src0)]
624 def LDS_BYTE_WRITE : R600_LDS_1A1D_NORET<0x12, "LDS_BYTE_WRITE",
625 [(truncstorei8_local i32:$src1, i32:$src0)]
627 def LDS_SHORT_WRITE : R600_LDS_1A1D_NORET<0x13, "LDS_SHORT_WRITE",
628 [(truncstorei16_local i32:$src1, i32:$src0)]
630 def LDS_ADD_RET : R600_LDS_1A1D_RET <0x20, "LDS_ADD",
631 [(set i32:$dst, (atomic_load_add_local_32 i32:$src0, i32:$src1))]
633 def LDS_SUB_RET : R600_LDS_1A1D_RET <0x21, "LDS_SUB",
634 [(set i32:$dst, (atomic_load_sub_local_32 i32:$src0, i32:$src1))]
636 def LDS_AND_RET : R600_LDS_1A1D_RET <0x29, "LDS_AND",
637 [(set i32:$dst, (atomic_load_and_local_32 i32:$src0, i32:$src1))]
639 def LDS_OR_RET : R600_LDS_1A1D_RET <0x2a, "LDS_OR",
640 [(set i32:$dst, (atomic_load_or_local_32 i32:$src0, i32:$src1))]
642 def LDS_XOR_RET : R600_LDS_1A1D_RET <0x2b, "LDS_XOR",
643 [(set i32:$dst, (atomic_load_xor_local_32 i32:$src0, i32:$src1))]
645 def LDS_MIN_INT_RET : R600_LDS_1A1D_RET <0x25, "LDS_MIN_INT",
646 [(set i32:$dst, (atomic_load_min_local_32 i32:$src0, i32:$src1))]
648 def LDS_MAX_INT_RET : R600_LDS_1A1D_RET <0x26, "LDS_MAX_INT",
649 [(set i32:$dst, (atomic_load_max_local_32 i32:$src0, i32:$src1))]
651 def LDS_MIN_UINT_RET : R600_LDS_1A1D_RET <0x27, "LDS_MIN_UINT",
652 [(set i32:$dst, (atomic_load_umin_local_32 i32:$src0, i32:$src1))]
654 def LDS_MAX_UINT_RET : R600_LDS_1A1D_RET <0x28, "LDS_MAX_UINT",
655 [(set i32:$dst, (atomic_load_umax_local_32 i32:$src0, i32:$src1))]
657 def LDS_WRXCHG_RET : R600_LDS_1A1D_RET <0x2d, "LDS_WRXCHG",
658 [(set i32:$dst, (atomic_swap_local_32 i32:$src0, i32:$src1))]
660 def LDS_CMPST_RET : R600_LDS_1A2D_RET <0x30, "LDS_CMPST",
661 [(set i32:$dst, (atomic_cmp_swap_local_32 i32:$src0, i32:$src1, i32:$src2))]
663 def LDS_READ_RET : R600_LDS_1A <0x32, "LDS_READ_RET",
664 [(set (i32 R600_Reg32:$dst), (load_local R600_Reg32:$src0))]
666 def LDS_BYTE_READ_RET : R600_LDS_1A <0x36, "LDS_BYTE_READ_RET",
667 [(set i32:$dst, (sextloadi8_local i32:$src0))]
669 def LDS_UBYTE_READ_RET : R600_LDS_1A <0x37, "LDS_UBYTE_READ_RET",
670 [(set i32:$dst, (az_extloadi8_local i32:$src0))]
672 def LDS_SHORT_READ_RET : R600_LDS_1A <0x38, "LDS_SHORT_READ_RET",
673 [(set i32:$dst, (sextloadi16_local i32:$src0))]
675 def LDS_USHORT_READ_RET : R600_LDS_1A <0x39, "LDS_USHORT_READ_RET",
676 [(set i32:$dst, (az_extloadi16_local i32:$src0))]
679 // TRUNC is used for the FLT_TO_INT instructions to work around a
680 // perceived problem where the rounding modes are applied differently
681 // depending on the instruction and the slot they are in.
683 // https://bugs.freedesktop.org/show_bug.cgi?id=50232
684 // Mesa commit: a1a0974401c467cb86ef818f22df67c21774a38c
686 // XXX: Lowering SELECT_CC will sometimes generate fp_to_[su]int nodes,
687 // which do not need to be truncated since the fp values are 0.0f or 1.0f.
688 // We should look into handling these cases separately.
689 def : EGOrCaymanPat<(fp_to_sint f32:$src0), (FLT_TO_INT_eg (TRUNC $src0))>;
691 def : EGOrCaymanPat<(fp_to_uint f32:$src0), (FLT_TO_UINT_eg (TRUNC $src0))>;
694 defm : SHA256MaPattern <BFI_INT_eg, XOR_INT, R600_Reg64>;
696 def EG_ExportSwz : ExportSwzInst {
697 let Word1{19-16} = 0; // BURST_COUNT
698 let Word1{20} = 0; // VALID_PIXEL_MODE
700 let Word1{29-22} = inst;
701 let Word1{30} = 0; // MARK
702 let Word1{31} = 1; // BARRIER
704 defm : ExportPattern<EG_ExportSwz, 83>;
706 def EG_ExportBuf : ExportBufInst {
707 let Word1{19-16} = 0; // BURST_COUNT
708 let Word1{20} = 0; // VALID_PIXEL_MODE
710 let Word1{29-22} = inst;
711 let Word1{30} = 0; // MARK
712 let Word1{31} = 1; // BARRIER
714 defm : SteamOutputExportPattern<EG_ExportBuf, 0x40, 0x41, 0x42, 0x43>;
716 def CF_TC_EG : CF_CLAUSE_EG<1, (ins i32imm:$ADDR, i32imm:$COUNT),
717 "TEX $COUNT @$ADDR"> {
720 def CF_VC_EG : CF_CLAUSE_EG<2, (ins i32imm:$ADDR, i32imm:$COUNT),
721 "VTX $COUNT @$ADDR"> {
724 def WHILE_LOOP_EG : CF_CLAUSE_EG<6, (ins i32imm:$ADDR),
725 "LOOP_START_DX10 @$ADDR"> {
729 def END_LOOP_EG : CF_CLAUSE_EG<5, (ins i32imm:$ADDR), "END_LOOP @$ADDR"> {
733 def LOOP_BREAK_EG : CF_CLAUSE_EG<9, (ins i32imm:$ADDR),
734 "LOOP_BREAK @$ADDR"> {
738 def CF_CONTINUE_EG : CF_CLAUSE_EG<8, (ins i32imm:$ADDR),
743 def CF_JUMP_EG : CF_CLAUSE_EG<10, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
744 "JUMP @$ADDR POP:$POP_COUNT"> {
747 def CF_PUSH_EG : CF_CLAUSE_EG<11, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
748 "PUSH @$ADDR POP:$POP_COUNT"> {
751 def CF_ELSE_EG : CF_CLAUSE_EG<13, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
752 "ELSE @$ADDR POP:$POP_COUNT"> {
755 def CF_CALL_FS_EG : CF_CLAUSE_EG<19, (ins), "CALL_FS"> {
760 def POP_EG : CF_CLAUSE_EG<14, (ins i32imm:$ADDR, i32imm:$POP_COUNT),
761 "POP @$ADDR POP:$POP_COUNT"> {
764 def CF_END_EG : CF_CLAUSE_EG<0, (ins), "CF_END"> {
768 let END_OF_PROGRAM = 1;
771 } // End Predicates = [isEGorCayman]