Make helper functions/classes/globals static. NFC.
[oota-llvm.git] / lib / Target / R600 / AMDGPUInstrInfo.td
1 //===-- AMDGPUInstrInfo.td - AMDGPU DAG nodes --------------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains DAG node defintions for the AMDGPU target.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 // AMDGPU DAG Profiles
16 //===----------------------------------------------------------------------===//
17
18 def AMDGPUDTIntTernaryOp : SDTypeProfile<1, 3, [
19   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
20 ]>;
21
22 def AMDGPUTrigPreOp : SDTypeProfile<1, 2,
23   [SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisInt<2>]
24 >;
25
26 def AMDGPULdExpOp : SDTypeProfile<1, 2,
27   [SDTCisSameAs<0, 1>, SDTCisFP<0>, SDTCisInt<2>]
28 >;
29
30 def AMDGPUFPClassOp : SDTypeProfile<1, 2,
31   [SDTCisInt<0>, SDTCisFP<1>, SDTCisInt<2>]
32 >;
33
34 def AMDGPUDivScaleOp : SDTypeProfile<2, 3,
35   [SDTCisFP<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisSameAs<0, 4>]
36 >;
37
38 //===----------------------------------------------------------------------===//
39 // AMDGPU DAG Nodes
40 //
41
42 // This argument to this node is a dword address.
43 def AMDGPUdwordaddr : SDNode<"AMDGPUISD::DWORDADDR", SDTIntUnaryOp>;
44
45 def AMDGPUcos : SDNode<"AMDGPUISD::COS_HW", SDTFPUnaryOp>;
46 def AMDGPUsin : SDNode<"AMDGPUISD::SIN_HW", SDTFPUnaryOp>;
47
48 // out = a - floor(a)
49 def AMDGPUfract : SDNode<"AMDGPUISD::FRACT", SDTFPUnaryOp>;
50
51 // out = 1.0 / a
52 def AMDGPUrcp : SDNode<"AMDGPUISD::RCP", SDTFPUnaryOp>;
53
54 // out = 1.0 / sqrt(a)
55 def AMDGPUrsq : SDNode<"AMDGPUISD::RSQ", SDTFPUnaryOp>;
56
57 // out = 1.0 / sqrt(a)
58 def AMDGPUrsq_legacy : SDNode<"AMDGPUISD::RSQ_LEGACY", SDTFPUnaryOp>;
59
60 // out = 1.0 / sqrt(a) result clamped to +/- max_float.
61 def AMDGPUrsq_clamped : SDNode<"AMDGPUISD::RSQ_CLAMPED", SDTFPUnaryOp>;
62
63 def AMDGPUldexp : SDNode<"AMDGPUISD::LDEXP", AMDGPULdExpOp>;
64
65 def AMDGPUfp_class : SDNode<"AMDGPUISD::FP_CLASS", AMDGPUFPClassOp>;
66
67 // out = max(a, b) a and b are floats, where a nan comparison fails.
68 // This is not commutative because this gives the second operand:
69 //   x < nan ? x : nan -> nan
70 //   nan < x ? nan : x -> x
71 def AMDGPUfmax_legacy : SDNode<"AMDGPUISD::FMAX_LEGACY", SDTFPBinOp,
72   []
73 >;
74
75 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPTernaryOp, []>;
76 def AMDGPUmad : SDNode<"AMDGPUISD::MAD", SDTFPTernaryOp, []>;
77
78 // out = max(a, b) a and b are signed ints
79 def AMDGPUsmax : SDNode<"AMDGPUISD::SMAX", SDTIntBinOp,
80   [SDNPCommutative, SDNPAssociative]
81 >;
82
83 // out = max(a, b) a and b are unsigned ints
84 def AMDGPUumax : SDNode<"AMDGPUISD::UMAX", SDTIntBinOp,
85   [SDNPCommutative, SDNPAssociative]
86 >;
87
88 // out = min(a, b) a and b are floats, where a nan comparison fails.
89 def AMDGPUfmin_legacy : SDNode<"AMDGPUISD::FMIN_LEGACY", SDTFPBinOp,
90   []
91 >;
92
93 // out = min(a, b) a and b are signed ints
94 def AMDGPUsmin : SDNode<"AMDGPUISD::SMIN", SDTIntBinOp,
95   [SDNPCommutative, SDNPAssociative]
96 >;
97
98 // out = min(a, b) a and b are unsigned ints
99 def AMDGPUumin : SDNode<"AMDGPUISD::UMIN", SDTIntBinOp,
100   [SDNPCommutative, SDNPAssociative]
101 >;
102
103 // FIXME: TableGen doesn't like commutative instructions with more
104 // than 2 operands.
105 // out = max(a, b, c) a, b and c are floats
106 def AMDGPUfmax3 : SDNode<"AMDGPUISD::FMAX3", SDTFPTernaryOp,
107   [/*SDNPCommutative, SDNPAssociative*/]
108 >;
109
110 // out = max(a, b, c) a, b, and c are signed ints
111 def AMDGPUsmax3 : SDNode<"AMDGPUISD::SMAX3", AMDGPUDTIntTernaryOp,
112   [/*SDNPCommutative, SDNPAssociative*/]
113 >;
114
115 // out = max(a, b, c) a, b and c are unsigned ints
116 def AMDGPUumax3 : SDNode<"AMDGPUISD::UMAX3", AMDGPUDTIntTernaryOp,
117   [/*SDNPCommutative, SDNPAssociative*/]
118 >;
119
120 // out = min(a, b, c) a, b and c are floats
121 def AMDGPUfmin3 : SDNode<"AMDGPUISD::FMIN3", SDTFPTernaryOp,
122   [/*SDNPCommutative, SDNPAssociative*/]
123 >;
124
125 // out = min(a, b, c) a, b and c are signed ints
126 def AMDGPUsmin3 : SDNode<"AMDGPUISD::SMIN3", AMDGPUDTIntTernaryOp,
127   [/*SDNPCommutative, SDNPAssociative*/]
128 >;
129
130 // out = min(a, b) a and b are unsigned ints
131 def AMDGPUumin3 : SDNode<"AMDGPUISD::UMIN3", AMDGPUDTIntTernaryOp,
132   [/*SDNPCommutative, SDNPAssociative*/]
133 >;
134
135 def AMDGPUcvt_f32_ubyte0 : SDNode<"AMDGPUISD::CVT_F32_UBYTE0",
136   SDTIntToFPOp, []>;
137 def AMDGPUcvt_f32_ubyte1 : SDNode<"AMDGPUISD::CVT_F32_UBYTE1",
138   SDTIntToFPOp, []>;
139 def AMDGPUcvt_f32_ubyte2 : SDNode<"AMDGPUISD::CVT_F32_UBYTE2",
140   SDTIntToFPOp, []>;
141 def AMDGPUcvt_f32_ubyte3 : SDNode<"AMDGPUISD::CVT_F32_UBYTE3",
142   SDTIntToFPOp, []>;
143
144
145 // urecip - This operation is a helper for integer division, it returns the
146 // result of 1 / a as a fractional unsigned integer.
147 // out = (2^32 / a) + e
148 // e is rounding error
149 def AMDGPUurecip : SDNode<"AMDGPUISD::URECIP", SDTIntUnaryOp>;
150
151 // Special case divide preop and flags.
152 def AMDGPUdiv_scale : SDNode<"AMDGPUISD::DIV_SCALE", AMDGPUDivScaleOp>;
153
154 //  Special case divide FMA with scale and flags (src0 = Quotient,
155 //  src1 = Denominator, src2 = Numerator).
156 def AMDGPUdiv_fmas : SDNode<"AMDGPUISD::DIV_FMAS", SDTFPTernaryOp>;
157
158 // Single or double precision division fixup.
159 // Special case divide fixup and flags(src0 = Quotient, src1 =
160 // Denominator, src2 = Numerator).
161 def AMDGPUdiv_fixup : SDNode<"AMDGPUISD::DIV_FIXUP", SDTFPTernaryOp>;
162
163 // Look Up 2.0 / pi src0 with segment select src1[4:0]
164 def AMDGPUtrig_preop : SDNode<"AMDGPUISD::TRIG_PREOP", AMDGPUTrigPreOp>;
165
166 def AMDGPUregister_load : SDNode<"AMDGPUISD::REGISTER_LOAD",
167                           SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
168                           [SDNPHasChain, SDNPMayLoad]>;
169
170 def AMDGPUregister_store : SDNode<"AMDGPUISD::REGISTER_STORE",
171                            SDTypeProfile<0, 3, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
172                            [SDNPHasChain, SDNPMayStore]>;
173
174 // MSKOR instructions are atomic memory instructions used mainly for storing
175 // 8-bit and 16-bit values.  The definition is:
176 //
177 // MSKOR(dst, mask, src) MEM[dst] = ((MEM[dst] & ~mask) | src)
178 //
179 // src0: vec4(src, 0, 0, mask)
180 // src1: dst - rat offset (aka pointer) in dwords
181 def AMDGPUstore_mskor : SDNode<"AMDGPUISD::STORE_MSKOR",
182                         SDTypeProfile<0, 2, []>,
183                         [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
184
185 def AMDGPUround : SDNode<"ISD::FROUND",
186                          SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>>;
187
188 def AMDGPUbfe_u32 : SDNode<"AMDGPUISD::BFE_U32", AMDGPUDTIntTernaryOp>;
189 def AMDGPUbfe_i32 : SDNode<"AMDGPUISD::BFE_I32", AMDGPUDTIntTernaryOp>;
190 def AMDGPUbfi : SDNode<"AMDGPUISD::BFI", AMDGPUDTIntTernaryOp>;
191 def AMDGPUbfm : SDNode<"AMDGPUISD::BFM", SDTIntBinOp>;
192
193 def AMDGPUbrev : SDNode<"AMDGPUISD::BREV", SDTIntUnaryOp>;
194
195 // Signed and unsigned 24-bit mulitply.  The highest 8-bits are ignore when
196 // performing the mulitply.  The result is a 32-bit value.
197 def AMDGPUmul_u24 : SDNode<"AMDGPUISD::MUL_U24", SDTIntBinOp,
198   [SDNPCommutative]
199 >;
200 def AMDGPUmul_i24 : SDNode<"AMDGPUISD::MUL_I24", SDTIntBinOp,
201   [SDNPCommutative]
202 >;
203
204 def AMDGPUmad_u24 : SDNode<"AMDGPUISD::MAD_U24", AMDGPUDTIntTernaryOp,
205   []
206 >;
207 def AMDGPUmad_i24 : SDNode<"AMDGPUISD::MAD_I24", AMDGPUDTIntTernaryOp,
208   []
209 >;
210
211 //===----------------------------------------------------------------------===//
212 // Flow Control Profile Types
213 //===----------------------------------------------------------------------===//
214 // Branch instruction where second and third are basic blocks
215 def SDTIL_BRCond : SDTypeProfile<0, 2, [
216     SDTCisVT<0, OtherVT>
217     ]>;
218
219 //===----------------------------------------------------------------------===//
220 // Flow Control DAG Nodes
221 //===----------------------------------------------------------------------===//
222 def IL_brcond      : SDNode<"AMDGPUISD::BRANCH_COND", SDTIL_BRCond, [SDNPHasChain]>;
223
224 //===----------------------------------------------------------------------===//
225 // Call/Return DAG Nodes
226 //===----------------------------------------------------------------------===//
227 def IL_retflag       : SDNode<"AMDGPUISD::RET_FLAG", SDTNone,
228     [SDNPHasChain, SDNPOptInGlue]>;