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 AMDGPUDivScaleOp : SDTypeProfile<2, 3,
27 [SDTCisFP<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisSameAs<0, 4>]
30 //===----------------------------------------------------------------------===//
34 // This argument to this node is a dword address.
35 def AMDGPUdwordaddr : SDNode<"AMDGPUISD::DWORDADDR", SDTIntUnaryOp>;
38 def AMDGPUfract : SDNode<"AMDGPUISD::FRACT", SDTFPUnaryOp>;
41 def AMDGPUrcp : SDNode<"AMDGPUISD::RCP", SDTFPUnaryOp>;
43 // out = 1.0 / sqrt(a)
44 def AMDGPUrsq : SDNode<"AMDGPUISD::RSQ", SDTFPUnaryOp>;
46 // out = max(a, b) a and b are floats
47 def AMDGPUfmax : SDNode<"AMDGPUISD::FMAX", SDTFPBinOp,
48 [SDNPCommutative, SDNPAssociative]
51 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPTernaryOp, []>;
53 // out = max(a, b) a and b are signed ints
54 def AMDGPUsmax : SDNode<"AMDGPUISD::SMAX", SDTIntBinOp,
55 [SDNPCommutative, SDNPAssociative]
58 // out = max(a, b) a and b are unsigned ints
59 def AMDGPUumax : SDNode<"AMDGPUISD::UMAX", SDTIntBinOp,
60 [SDNPCommutative, SDNPAssociative]
63 // out = min(a, b) a and b are floats
64 def AMDGPUfmin : SDNode<"AMDGPUISD::FMIN", SDTFPBinOp,
65 [SDNPCommutative, SDNPAssociative]
68 // out = min(a, b) a snd b are signed ints
69 def AMDGPUsmin : SDNode<"AMDGPUISD::SMIN", SDTIntBinOp,
70 [SDNPCommutative, SDNPAssociative]
73 // out = min(a, b) a and b are unsigned ints
74 def AMDGPUumin : SDNode<"AMDGPUISD::UMIN", SDTIntBinOp,
75 [SDNPCommutative, SDNPAssociative]
79 def AMDGPUcvt_f32_ubyte0 : SDNode<"AMDGPUISD::CVT_F32_UBYTE0",
81 def AMDGPUcvt_f32_ubyte1 : SDNode<"AMDGPUISD::CVT_F32_UBYTE1",
83 def AMDGPUcvt_f32_ubyte2 : SDNode<"AMDGPUISD::CVT_F32_UBYTE2",
85 def AMDGPUcvt_f32_ubyte3 : SDNode<"AMDGPUISD::CVT_F32_UBYTE3",
89 // urecip - This operation is a helper for integer division, it returns the
90 // result of 1 / a as a fractional unsigned integer.
91 // out = (2^32 / a) + e
92 // e is rounding error
93 def AMDGPUurecip : SDNode<"AMDGPUISD::URECIP", SDTIntUnaryOp>;
95 // Special case divide preop and flags.
96 def AMDGPUdiv_scale : SDNode<"AMDGPUISD::DIV_SCALE", AMDGPUDivScaleOp>;
98 // Special case divide FMA with scale and flags (src0 = Quotient,
99 // src1 = Denominator, src2 = Numerator).
100 def AMDGPUdiv_fmas : SDNode<"AMDGPUISD::DIV_FMAS", SDTFPTernaryOp>;
102 // Single or double precision division fixup.
103 // Special case divide fixup and flags(src0 = Quotient, src1 =
104 // Denominator, src2 = Numerator).
105 def AMDGPUdiv_fixup : SDNode<"AMDGPUISD::DIV_FIXUP", SDTFPTernaryOp>;
107 // Look Up 2.0 / pi src0 with segment select src1[4:0]
108 def AMDGPUtrig_preop : SDNode<"AMDGPUISD::TRIG_PREOP", AMDGPUTrigPreOp>;
110 def AMDGPUregister_load : SDNode<"AMDGPUISD::REGISTER_LOAD",
111 SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
112 [SDNPHasChain, SDNPMayLoad]>;
114 def AMDGPUregister_store : SDNode<"AMDGPUISD::REGISTER_STORE",
115 SDTypeProfile<0, 3, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
116 [SDNPHasChain, SDNPMayStore]>;
118 // MSKOR instructions are atomic memory instructions used mainly for storing
119 // 8-bit and 16-bit values. The definition is:
121 // MSKOR(dst, mask, src) MEM[dst] = ((MEM[dst] & ~mask) | src)
123 // src0: vec4(src, 0, 0, mask)
124 // src1: dst - rat offset (aka pointer) in dwords
125 def AMDGPUstore_mskor : SDNode<"AMDGPUISD::STORE_MSKOR",
126 SDTypeProfile<0, 2, []>,
127 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
129 def AMDGPUround : SDNode<"ISD::FROUND",
130 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>>;
132 def AMDGPUbfe_u32 : SDNode<"AMDGPUISD::BFE_U32", AMDGPUDTIntTernaryOp>;
133 def AMDGPUbfe_i32 : SDNode<"AMDGPUISD::BFE_I32", AMDGPUDTIntTernaryOp>;
134 def AMDGPUbfi : SDNode<"AMDGPUISD::BFI", AMDGPUDTIntTernaryOp>;
135 def AMDGPUbfm : SDNode<"AMDGPUISD::BFM", SDTIntBinOp>;
137 def AMDGPUbrev : SDNode<"AMDGPUISD::BREV", SDTIntUnaryOp>;
139 // Signed and unsigned 24-bit mulitply. The highest 8-bits are ignore when
140 // performing the mulitply. The result is a 32-bit value.
141 def AMDGPUmul_u24 : SDNode<"AMDGPUISD::MUL_U24", SDTIntBinOp,
144 def AMDGPUmul_i24 : SDNode<"AMDGPUISD::MUL_I24", SDTIntBinOp,
148 def AMDGPUmad_u24 : SDNode<"AMDGPUISD::MAD_U24", AMDGPUDTIntTernaryOp,
151 def AMDGPUmad_i24 : SDNode<"AMDGPUISD::MAD_I24", AMDGPUDTIntTernaryOp,
155 //===----------------------------------------------------------------------===//
156 // Flow Control Profile Types
157 //===----------------------------------------------------------------------===//
158 // Branch instruction where second and third are basic blocks
159 def SDTIL_BRCond : SDTypeProfile<0, 2, [
163 //===----------------------------------------------------------------------===//
164 // Flow Control DAG Nodes
165 //===----------------------------------------------------------------------===//
166 def IL_brcond : SDNode<"AMDGPUISD::BRANCH_COND", SDTIL_BRCond, [SDNPHasChain]>;
168 //===----------------------------------------------------------------------===//
169 // Call/Return DAG Nodes
170 //===----------------------------------------------------------------------===//
171 def IL_retflag : SDNode<"AMDGPUISD::RET_FLAG", SDTNone,
172 [SDNPHasChain, SDNPOptInGlue]>;