1 //===-- AMDGPUInstrInfo.td - AMDGPU DAG nodes --------------*- tablegen -*-===//
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 //===----------------------------------------------------------------------===//
10 // This file contains DAG node defintions for the AMDGPU target.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // AMDGPU DAG Profiles
16 //===----------------------------------------------------------------------===//
18 def AMDGPUDTIntTernaryOp : SDTypeProfile<1, 3, [
19 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
22 def AMDGPUTrigPreOp : SDTypeProfile<1, 2,
23 [SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisInt<2>]
26 def AMDGPULdExpOp : SDTypeProfile<1, 2,
27 [SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisInt<2>]
30 def AMDGPUFPClassOp : SDTypeProfile<1, 2,
31 [SDTCisInt<0>, SDTCisFP<1>, SDTCisInt<2>]
34 def AMDGPUDivScaleOp : SDTypeProfile<2, 3,
35 [SDTCisFP<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisSameAs<0, 4>]
38 // float, float, float, vcc
39 def AMDGPUFmasOp : SDTypeProfile<1, 4,
40 [SDTCisFP<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisInt<4>]
43 def AMDGPUKillSDT : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
45 //===----------------------------------------------------------------------===//
49 def AMDGPUconstdata_ptr : SDNode<
50 "AMDGPUISD::CONST_DATA_PTR", SDTypeProfile <1, 1, [SDTCisVT<0, iPTR>,
54 // This argument to this node is a dword address.
55 def AMDGPUdwordaddr : SDNode<"AMDGPUISD::DWORDADDR", SDTIntUnaryOp>;
57 def AMDGPUcos : SDNode<"AMDGPUISD::COS_HW", SDTFPUnaryOp>;
58 def AMDGPUsin : SDNode<"AMDGPUISD::SIN_HW", SDTFPUnaryOp>;
61 def AMDGPUfract : SDNode<"AMDGPUISD::FRACT", SDTFPUnaryOp>;
64 def AMDGPUrcp : SDNode<"AMDGPUISD::RCP", SDTFPUnaryOp>;
66 // out = 1.0 / sqrt(a)
67 def AMDGPUrsq : SDNode<"AMDGPUISD::RSQ", SDTFPUnaryOp>;
69 // out = 1.0 / sqrt(a)
70 def AMDGPUrcp_legacy : SDNode<"AMDGPUISD::RCP_LEGACY", SDTFPUnaryOp>;
71 def AMDGPUrsq_legacy : SDNode<"AMDGPUISD::RSQ_LEGACY", SDTFPUnaryOp>;
73 // out = 1.0 / sqrt(a) result clamped to +/- max_float.
74 def AMDGPUrsq_clamp : SDNode<"AMDGPUISD::RSQ_CLAMP", SDTFPUnaryOp>;
76 def AMDGPUldexp : SDNode<"AMDGPUISD::LDEXP", AMDGPULdExpOp>;
78 def AMDGPUfp_class : SDNode<"AMDGPUISD::FP_CLASS", AMDGPUFPClassOp>;
80 // out = max(a, b) a and b are floats, where a nan comparison fails.
81 // This is not commutative because this gives the second operand:
82 // x < nan ? x : nan -> nan
83 // nan < x ? nan : x -> x
84 def AMDGPUfmax_legacy : SDNode<"AMDGPUISD::FMAX_LEGACY", SDTFPBinOp,
88 def AMDGPUfmul_legacy : SDNode<"AMDGPUISD::FMUL_LEGACY", SDTFPBinOp,
89 [SDNPCommutative, SDNPAssociative]
92 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPTernaryOp, []>;
94 // out = max(a, b) a and b are signed ints
95 def AMDGPUsmax : SDNode<"AMDGPUISD::SMAX", SDTIntBinOp,
96 [SDNPCommutative, SDNPAssociative]
99 // out = max(a, b) a and b are unsigned ints
100 def AMDGPUumax : SDNode<"AMDGPUISD::UMAX", SDTIntBinOp,
101 [SDNPCommutative, SDNPAssociative]
104 // out = min(a, b) a and b are floats, where a nan comparison fails.
105 def AMDGPUfmin_legacy : SDNode<"AMDGPUISD::FMIN_LEGACY", SDTFPBinOp,
109 // FIXME: TableGen doesn't like commutative instructions with more
111 // out = max(a, b, c) a, b and c are floats
112 def AMDGPUfmax3 : SDNode<"AMDGPUISD::FMAX3", SDTFPTernaryOp,
113 [/*SDNPCommutative, SDNPAssociative*/]
116 // out = max(a, b, c) a, b, and c are signed ints
117 def AMDGPUsmax3 : SDNode<"AMDGPUISD::SMAX3", AMDGPUDTIntTernaryOp,
118 [/*SDNPCommutative, SDNPAssociative*/]
121 // out = max(a, b, c) a, b and c are unsigned ints
122 def AMDGPUumax3 : SDNode<"AMDGPUISD::UMAX3", AMDGPUDTIntTernaryOp,
123 [/*SDNPCommutative, SDNPAssociative*/]
126 // out = min(a, b, c) a, b and c are floats
127 def AMDGPUfmin3 : SDNode<"AMDGPUISD::FMIN3", SDTFPTernaryOp,
128 [/*SDNPCommutative, SDNPAssociative*/]
131 // out = min(a, b, c) a, b and c are signed ints
132 def AMDGPUsmin3 : SDNode<"AMDGPUISD::SMIN3", AMDGPUDTIntTernaryOp,
133 [/*SDNPCommutative, SDNPAssociative*/]
136 // out = min(a, b) a and b are unsigned ints
137 def AMDGPUumin3 : SDNode<"AMDGPUISD::UMIN3", AMDGPUDTIntTernaryOp,
138 [/*SDNPCommutative, SDNPAssociative*/]
141 // out = (src0 + src1 > 0xFFFFFFFF) ? 1 : 0
142 def AMDGPUcarry : SDNode<"AMDGPUISD::CARRY", SDTIntBinOp, []>;
144 // out = (src1 > src0) ? 1 : 0
145 def AMDGPUborrow : SDNode<"AMDGPUISD::BORROW", SDTIntBinOp, []>;
147 def AMDGPUSetCCOp : SDTypeProfile<1, 3, [ // setcc
148 SDTCisVT<0, i64>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
151 def AMDGPUsetcc : SDNode<"AMDGPUISD::SETCC", AMDGPUSetCCOp>;
153 def AMDGPUSetRegOp : SDTypeProfile<0, 2, [
154 SDTCisInt<0>, SDTCisInt<1>
157 def AMDGPUsetreg : SDNode<"AMDGPUISD::SETREG", AMDGPUSetRegOp, [
158 SDNPHasChain, SDNPSideEffect, SDNPOptInGlue, SDNPOutGlue]>;
160 def AMDGPUfma : SDNode<"AMDGPUISD::FMA_W_CHAIN", SDTFPTernaryOp, [
161 SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
163 def AMDGPUmul : SDNode<"AMDGPUISD::FMUL_W_CHAIN", SDTFPBinOp, [
164 SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
166 def AMDGPUcvt_f32_ubyte0 : SDNode<"AMDGPUISD::CVT_F32_UBYTE0",
168 def AMDGPUcvt_f32_ubyte1 : SDNode<"AMDGPUISD::CVT_F32_UBYTE1",
170 def AMDGPUcvt_f32_ubyte2 : SDNode<"AMDGPUISD::CVT_F32_UBYTE2",
172 def AMDGPUcvt_f32_ubyte3 : SDNode<"AMDGPUISD::CVT_F32_UBYTE3",
176 // urecip - This operation is a helper for integer division, it returns the
177 // result of 1 / a as a fractional unsigned integer.
178 // out = (2^32 / a) + e
179 // e is rounding error
180 def AMDGPUurecip : SDNode<"AMDGPUISD::URECIP", SDTIntUnaryOp>;
182 // Special case divide preop and flags.
183 def AMDGPUdiv_scale : SDNode<"AMDGPUISD::DIV_SCALE", AMDGPUDivScaleOp>;
185 // Special case divide FMA with scale and flags (src0 = Quotient,
186 // src1 = Denominator, src2 = Numerator).
187 def AMDGPUdiv_fmas : SDNode<"AMDGPUISD::DIV_FMAS", AMDGPUFmasOp>;
189 // Single or double precision division fixup.
190 // Special case divide fixup and flags(src0 = Quotient, src1 =
191 // Denominator, src2 = Numerator).
192 def AMDGPUdiv_fixup : SDNode<"AMDGPUISD::DIV_FIXUP", SDTFPTernaryOp>;
194 // Look Up 2.0 / pi src0 with segment select src1[4:0]
195 def AMDGPUtrig_preop : SDNode<"AMDGPUISD::TRIG_PREOP", AMDGPUTrigPreOp>;
197 def AMDGPUregister_load : SDNode<"AMDGPUISD::REGISTER_LOAD",
198 SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
199 [SDNPHasChain, SDNPMayLoad]>;
201 def AMDGPUregister_store : SDNode<"AMDGPUISD::REGISTER_STORE",
202 SDTypeProfile<0, 3, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
203 [SDNPHasChain, SDNPMayStore]>;
205 // MSKOR instructions are atomic memory instructions used mainly for storing
206 // 8-bit and 16-bit values. The definition is:
208 // MSKOR(dst, mask, src) MEM[dst] = ((MEM[dst] & ~mask) | src)
210 // src0: vec4(src, 0, 0, mask)
211 // src1: dst - rat offset (aka pointer) in dwords
212 def AMDGPUstore_mskor : SDNode<"AMDGPUISD::STORE_MSKOR",
213 SDTypeProfile<0, 2, []>,
214 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
216 def AMDGPUatomic_cmp_swap : SDNode<"AMDGPUISD::ATOMIC_CMP_SWAP",
217 SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisVec<2>]>,
218 [SDNPHasChain, SDNPMayStore, SDNPMayLoad,
221 def AMDGPUround : SDNode<"ISD::FROUND",
222 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>>;
224 def AMDGPUbfe_u32 : SDNode<"AMDGPUISD::BFE_U32", AMDGPUDTIntTernaryOp>;
225 def AMDGPUbfe_i32 : SDNode<"AMDGPUISD::BFE_I32", AMDGPUDTIntTernaryOp>;
226 def AMDGPUbfi : SDNode<"AMDGPUISD::BFI", AMDGPUDTIntTernaryOp>;
227 def AMDGPUbfm : SDNode<"AMDGPUISD::BFM", SDTIntBinOp>;
229 def AMDGPUffbh_u32 : SDNode<"AMDGPUISD::FFBH_U32", SDTIntUnaryOp>;
230 def AMDGPUffbh_i32 : SDNode<"AMDGPUISD::FFBH_I32", SDTIntUnaryOp>;
232 // Signed and unsigned 24-bit multiply. The highest 8-bits are ignore
233 // when performing the mulitply. The result is a 32-bit value.
234 def AMDGPUmul_u24 : SDNode<"AMDGPUISD::MUL_U24", SDTIntBinOp,
235 [SDNPCommutative, SDNPAssociative]
237 def AMDGPUmul_i24 : SDNode<"AMDGPUISD::MUL_I24", SDTIntBinOp,
238 [SDNPCommutative, SDNPAssociative]
241 def AMDGPUmulhi_u24 : SDNode<"AMDGPUISD::MULHI_U24", SDTIntBinOp,
242 [SDNPCommutative, SDNPAssociative]
244 def AMDGPUmulhi_i24 : SDNode<"AMDGPUISD::MULHI_I24", SDTIntBinOp,
245 [SDNPCommutative, SDNPAssociative]
248 def AMDGPUmad_u24 : SDNode<"AMDGPUISD::MAD_U24", AMDGPUDTIntTernaryOp,
251 def AMDGPUmad_i24 : SDNode<"AMDGPUISD::MAD_I24", AMDGPUDTIntTernaryOp,
255 def AMDGPUsmed3 : SDNode<"AMDGPUISD::SMED3", AMDGPUDTIntTernaryOp,
259 def AMDGPUumed3 : SDNode<"AMDGPUISD::UMED3", AMDGPUDTIntTernaryOp,
263 def AMDGPUfmed3 : SDNode<"AMDGPUISD::FMED3", SDTFPTernaryOp, []>;
265 def AMDGPUsendmsg : SDNode<"AMDGPUISD::SENDMSG",
266 SDTypeProfile<0, 1, [SDTCisInt<0>]>,
267 [SDNPHasChain, SDNPInGlue]>;
269 def AMDGPUsendmsghalt : SDNode<"AMDGPUISD::SENDMSGHALT",
270 SDTypeProfile<0, 1, [SDTCisInt<0>]>,
271 [SDNPHasChain, SDNPInGlue]>;
273 def AMDGPUinterp_mov : SDNode<"AMDGPUISD::INTERP_MOV",
274 SDTypeProfile<1, 3, [SDTCisFP<0>]>,
277 def AMDGPUinterp_p1 : SDNode<"AMDGPUISD::INTERP_P1",
278 SDTypeProfile<1, 3, [SDTCisFP<0>]>,
279 [SDNPInGlue, SDNPOutGlue]>;
281 def AMDGPUinterp_p2 : SDNode<"AMDGPUISD::INTERP_P2",
282 SDTypeProfile<1, 4, [SDTCisFP<0>]>,
286 def AMDGPUkill : SDNode<"AMDGPUISD::KILL", AMDGPUKillSDT,
287 [SDNPHasChain, SDNPSideEffect]>;
290 def AMDGPUExportOp : SDTypeProfile<0, 8, [
291 SDTCisInt<0>, // i8 en
292 SDTCisInt<1>, // i1 vm
294 SDTCisInt<2>, // i8 tgt
295 SDTCisSameAs<3, 1>, // i1 compr
296 SDTCisFP<4>, // f32 src0
297 SDTCisSameAs<5, 4>, // f32 src1
298 SDTCisSameAs<6, 4>, // f32 src2
299 SDTCisSameAs<7, 4> // f32 src3
302 def AMDGPUexport: SDNode<"AMDGPUISD::EXPORT", AMDGPUExportOp,
303 [SDNPHasChain, SDNPMayStore]>;
305 def AMDGPUexport_done: SDNode<"AMDGPUISD::EXPORT_DONE", AMDGPUExportOp,
306 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
309 def R600ExportOp : SDTypeProfile<0, 7, [SDTCisFP<0>, SDTCisInt<1>]>;
311 def R600_EXPORT: SDNode<"AMDGPUISD::R600_EXPORT", R600ExportOp,
312 [SDNPHasChain, SDNPSideEffect]>;
314 //===----------------------------------------------------------------------===//
315 // Flow Control Profile Types
316 //===----------------------------------------------------------------------===//
317 // Branch instruction where second and third are basic blocks
318 def SDTIL_BRCond : SDTypeProfile<0, 2, [
322 //===----------------------------------------------------------------------===//
323 // Flow Control DAG Nodes
324 //===----------------------------------------------------------------------===//
325 def IL_brcond : SDNode<"AMDGPUISD::BRANCH_COND", SDTIL_BRCond, [SDNPHasChain]>;
327 //===----------------------------------------------------------------------===//
328 // Call/Return DAG Nodes
329 //===----------------------------------------------------------------------===//
330 def AMDGPUendpgm : SDNode<"AMDGPUISD::ENDPGM", SDTNone,
331 [SDNPHasChain, SDNPOptInGlue]>;
333 def AMDGPUreturn : SDNode<"AMDGPUISD::RETURN", SDTNone,
334 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;