]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
Merge compiler-rt trunk r300890, and update build glue.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / 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 AMDGPUFPPackOp : SDTypeProfile<1, 2,
35   [SDTCisFP<1>, SDTCisSameAs<1, 2>]
36 >;
37
38 def AMDGPUDivScaleOp : SDTypeProfile<2, 3,
39   [SDTCisFP<0>, SDTCisInt<1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisSameAs<0, 4>]
40 >;
41
42 // float, float, float, vcc
43 def AMDGPUFmasOp : SDTypeProfile<1, 4,
44   [SDTCisFP<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisInt<4>]
45 >;
46
47 def AMDGPUKillSDT : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
48
49 def AMDGPUIfOp : SDTypeProfile<1, 2,
50   [SDTCisVT<0, i64>, SDTCisVT<1, i1>, SDTCisVT<2, OtherVT>]
51 >;
52
53 def AMDGPUElseOp : SDTypeProfile<1, 2,
54   [SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, OtherVT>]
55 >;
56
57 def AMDGPULoopOp : SDTypeProfile<0, 2,
58   [SDTCisVT<0, i64>, SDTCisVT<1, OtherVT>]
59 >;
60
61 def AMDGPUBreakOp : SDTypeProfile<1, 1,
62   [SDTCisVT<0, i64>, SDTCisVT<1, i64>]
63 >;
64
65 def AMDGPUIfBreakOp : SDTypeProfile<1, 2,
66   [SDTCisVT<0, i64>, SDTCisVT<1, i1>, SDTCisVT<2, i64>]
67 >;
68
69 def AMDGPUElseBreakOp : SDTypeProfile<1, 2,
70   [SDTCisVT<0, i64>, SDTCisVT<1, i64>, SDTCisVT<2, i64>]
71 >;
72
73 //===----------------------------------------------------------------------===//
74 // AMDGPU DAG Nodes
75 //
76
77 def AMDGPUif : SDNode<"AMDGPUISD::IF", AMDGPUIfOp, [SDNPHasChain]>;
78 def AMDGPUelse : SDNode<"AMDGPUISD::ELSE", AMDGPUElseOp, [SDNPHasChain]>;
79 def AMDGPUloop : SDNode<"AMDGPUISD::LOOP", AMDGPULoopOp, [SDNPHasChain]>;
80
81 def AMDGPUconstdata_ptr : SDNode<
82   "AMDGPUISD::CONST_DATA_PTR", SDTypeProfile <1, 1, [SDTCisVT<0, iPTR>,
83                                                      SDTCisVT<0, iPTR>]>
84 >;
85
86 // This argument to this node is a dword address.
87 def AMDGPUdwordaddr : SDNode<"AMDGPUISD::DWORDADDR", SDTIntUnaryOp>;
88
89 // Force dependencies for vector trunc stores
90 def R600dummy_chain : SDNode<"AMDGPUISD::DUMMY_CHAIN", SDTNone, [SDNPHasChain]>;
91
92 def AMDGPUcos : SDNode<"AMDGPUISD::COS_HW", SDTFPUnaryOp>;
93 def AMDGPUsin : SDNode<"AMDGPUISD::SIN_HW", SDTFPUnaryOp>;
94
95 // out = a - floor(a)
96 def AMDGPUfract : SDNode<"AMDGPUISD::FRACT", SDTFPUnaryOp>;
97
98 // out = 1.0 / a
99 def AMDGPUrcp : SDNode<"AMDGPUISD::RCP", SDTFPUnaryOp>;
100
101 // out = 1.0 / sqrt(a)
102 def AMDGPUrsq : SDNode<"AMDGPUISD::RSQ", SDTFPUnaryOp>;
103
104 // out = 1.0 / sqrt(a)
105 def AMDGPUrcp_legacy : SDNode<"AMDGPUISD::RCP_LEGACY", SDTFPUnaryOp>;
106 def AMDGPUrsq_legacy : SDNode<"AMDGPUISD::RSQ_LEGACY", SDTFPUnaryOp>;
107
108 // out = 1.0 / sqrt(a) result clamped to +/- max_float.
109 def AMDGPUrsq_clamp : SDNode<"AMDGPUISD::RSQ_CLAMP", SDTFPUnaryOp>;
110
111 def AMDGPUldexp : SDNode<"AMDGPUISD::LDEXP", AMDGPULdExpOp>;
112
113 def AMDGPUpkrtz_f16_f32 : SDNode<"AMDGPUISD::CVT_PKRTZ_F16_F32", AMDGPUFPPackOp>;
114 def AMDGPUfp_to_f16 : SDNode<"AMDGPUISD::FP_TO_FP16" , SDTFPToIntOp>;
115 def AMDGPUfp16_zext : SDNode<"AMDGPUISD::FP16_ZEXT" , SDTFPToIntOp>;
116
117
118 def AMDGPUfp_class : SDNode<"AMDGPUISD::FP_CLASS", AMDGPUFPClassOp>;
119
120 // out = max(a, b) a and b are floats, where a nan comparison fails.
121 // This is not commutative because this gives the second operand:
122 //   x < nan ? x : nan -> nan
123 //   nan < x ? nan : x -> x
124 def AMDGPUfmax_legacy : SDNode<"AMDGPUISD::FMAX_LEGACY", SDTFPBinOp,
125   []
126 >;
127
128 def AMDGPUfmul_legacy : SDNode<"AMDGPUISD::FMUL_LEGACY", SDTFPBinOp,
129   [SDNPCommutative, SDNPAssociative]
130 >;
131
132 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPUnaryOp>;
133
134 // out = min(a, b) a and b are floats, where a nan comparison fails.
135 def AMDGPUfmin_legacy : SDNode<"AMDGPUISD::FMIN_LEGACY", SDTFPBinOp,
136   []
137 >;
138
139 // FIXME: TableGen doesn't like commutative instructions with more
140 // than 2 operands.
141 // out = max(a, b, c) a, b and c are floats
142 def AMDGPUfmax3 : SDNode<"AMDGPUISD::FMAX3", SDTFPTernaryOp,
143   [/*SDNPCommutative, SDNPAssociative*/]
144 >;
145
146 // out = max(a, b, c) a, b, and c are signed ints
147 def AMDGPUsmax3 : SDNode<"AMDGPUISD::SMAX3", AMDGPUDTIntTernaryOp,
148   [/*SDNPCommutative, SDNPAssociative*/]
149 >;
150
151 // out = max(a, b, c) a, b and c are unsigned ints
152 def AMDGPUumax3 : SDNode<"AMDGPUISD::UMAX3", AMDGPUDTIntTernaryOp,
153   [/*SDNPCommutative, SDNPAssociative*/]
154 >;
155
156 // out = min(a, b, c) a, b and c are floats
157 def AMDGPUfmin3 : SDNode<"AMDGPUISD::FMIN3", SDTFPTernaryOp,
158   [/*SDNPCommutative, SDNPAssociative*/]
159 >;
160
161 // out = min(a, b, c) a, b and c are signed ints
162 def AMDGPUsmin3 : SDNode<"AMDGPUISD::SMIN3", AMDGPUDTIntTernaryOp,
163   [/*SDNPCommutative, SDNPAssociative*/]
164 >;
165
166 // out = min(a, b) a and b are unsigned ints
167 def AMDGPUumin3 : SDNode<"AMDGPUISD::UMIN3", AMDGPUDTIntTernaryOp,
168   [/*SDNPCommutative, SDNPAssociative*/]
169 >;
170
171 // out = (src0 + src1 > 0xFFFFFFFF) ? 1 : 0
172 def AMDGPUcarry : SDNode<"AMDGPUISD::CARRY", SDTIntBinOp, []>;
173
174 // out = (src1 > src0) ? 1 : 0
175 def AMDGPUborrow : SDNode<"AMDGPUISD::BORROW", SDTIntBinOp, []>;
176
177 def AMDGPUSetCCOp : SDTypeProfile<1, 3, [        // setcc
178   SDTCisVT<0, i64>, SDTCisSameAs<1, 2>, SDTCisVT<3, OtherVT>
179 ]>;
180
181 def AMDGPUsetcc : SDNode<"AMDGPUISD::SETCC", AMDGPUSetCCOp>;
182
183 def AMDGPUSetRegOp :  SDTypeProfile<0, 2, [
184   SDTCisInt<0>, SDTCisInt<1>
185 ]>;
186
187 def AMDGPUsetreg : SDNode<"AMDGPUISD::SETREG", AMDGPUSetRegOp, [
188   SDNPHasChain, SDNPSideEffect, SDNPOptInGlue, SDNPOutGlue]>;
189
190 def AMDGPUfma : SDNode<"AMDGPUISD::FMA_W_CHAIN", SDTFPTernaryOp, [
191    SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
192
193 def AMDGPUmul : SDNode<"AMDGPUISD::FMUL_W_CHAIN", SDTFPBinOp, [
194   SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
195
196 def AMDGPUcvt_f32_ubyte0 : SDNode<"AMDGPUISD::CVT_F32_UBYTE0",
197   SDTIntToFPOp, []>;
198 def AMDGPUcvt_f32_ubyte1 : SDNode<"AMDGPUISD::CVT_F32_UBYTE1",
199   SDTIntToFPOp, []>;
200 def AMDGPUcvt_f32_ubyte2 : SDNode<"AMDGPUISD::CVT_F32_UBYTE2",
201   SDTIntToFPOp, []>;
202 def AMDGPUcvt_f32_ubyte3 : SDNode<"AMDGPUISD::CVT_F32_UBYTE3",
203   SDTIntToFPOp, []>;
204
205
206 // urecip - This operation is a helper for integer division, it returns the
207 // result of 1 / a as a fractional unsigned integer.
208 // out = (2^32 / a) + e
209 // e is rounding error
210 def AMDGPUurecip : SDNode<"AMDGPUISD::URECIP", SDTIntUnaryOp>;
211
212 // Special case divide preop and flags.
213 def AMDGPUdiv_scale : SDNode<"AMDGPUISD::DIV_SCALE", AMDGPUDivScaleOp>;
214
215 //  Special case divide FMA with scale and flags (src0 = Quotient,
216 //  src1 = Denominator, src2 = Numerator).
217 def AMDGPUdiv_fmas : SDNode<"AMDGPUISD::DIV_FMAS", AMDGPUFmasOp>;
218
219 // Single or double precision division fixup.
220 // Special case divide fixup and flags(src0 = Quotient, src1 =
221 // Denominator, src2 = Numerator).
222 def AMDGPUdiv_fixup : SDNode<"AMDGPUISD::DIV_FIXUP", SDTFPTernaryOp>;
223
224 def AMDGPUfmad_ftz : SDNode<"AMDGPUISD::FMAD_FTZ", SDTFPTernaryOp>;
225
226 // Look Up 2.0 / pi src0 with segment select src1[4:0]
227 def AMDGPUtrig_preop : SDNode<"AMDGPUISD::TRIG_PREOP", AMDGPUTrigPreOp>;
228
229 def AMDGPUregister_load : SDNode<"AMDGPUISD::REGISTER_LOAD",
230                           SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
231                           [SDNPHasChain, SDNPMayLoad]>;
232
233 def AMDGPUregister_store : SDNode<"AMDGPUISD::REGISTER_STORE",
234                            SDTypeProfile<0, 3, [SDTCisPtrTy<1>, SDTCisInt<2>]>,
235                            [SDNPHasChain, SDNPMayStore]>;
236
237 // MSKOR instructions are atomic memory instructions used mainly for storing
238 // 8-bit and 16-bit values.  The definition is:
239 //
240 // MSKOR(dst, mask, src) MEM[dst] = ((MEM[dst] & ~mask) | src)
241 //
242 // src0: vec4(src, 0, 0, mask)
243 // src1: dst - rat offset (aka pointer) in dwords
244 def AMDGPUstore_mskor : SDNode<"AMDGPUISD::STORE_MSKOR",
245                         SDTypeProfile<0, 2, []>,
246                         [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
247
248 def AMDGPUatomic_cmp_swap : SDNode<"AMDGPUISD::ATOMIC_CMP_SWAP",
249                             SDTypeProfile<1, 2, [SDTCisPtrTy<1>, SDTCisVec<2>]>,
250                             [SDNPHasChain, SDNPMayStore, SDNPMayLoad,
251                              SDNPMemOperand]>;
252
253 def AMDGPUround : SDNode<"ISD::FROUND",
254                          SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>>;
255
256 def AMDGPUbfe_u32 : SDNode<"AMDGPUISD::BFE_U32", AMDGPUDTIntTernaryOp>;
257 def AMDGPUbfe_i32 : SDNode<"AMDGPUISD::BFE_I32", AMDGPUDTIntTernaryOp>;
258 def AMDGPUbfi : SDNode<"AMDGPUISD::BFI", AMDGPUDTIntTernaryOp>;
259 def AMDGPUbfm : SDNode<"AMDGPUISD::BFM", SDTIntBinOp>;
260
261 def AMDGPUffbh_u32 : SDNode<"AMDGPUISD::FFBH_U32", SDTIntUnaryOp>;
262 def AMDGPUffbh_i32 : SDNode<"AMDGPUISD::FFBH_I32", SDTIntUnaryOp>;
263
264 // Signed and unsigned 24-bit multiply. The highest 8-bits are ignore
265 // when performing the mulitply. The result is a 32-bit value.
266 def AMDGPUmul_u24 : SDNode<"AMDGPUISD::MUL_U24", SDTIntBinOp,
267   [SDNPCommutative, SDNPAssociative]
268 >;
269 def AMDGPUmul_i24 : SDNode<"AMDGPUISD::MUL_I24", SDTIntBinOp,
270   [SDNPCommutative, SDNPAssociative]
271 >;
272
273 def AMDGPUmulhi_u24 : SDNode<"AMDGPUISD::MULHI_U24", SDTIntBinOp,
274   [SDNPCommutative, SDNPAssociative]
275 >;
276 def AMDGPUmulhi_i24 : SDNode<"AMDGPUISD::MULHI_I24", SDTIntBinOp,
277   [SDNPCommutative, SDNPAssociative]
278 >;
279
280 def AMDGPUmad_u24 : SDNode<"AMDGPUISD::MAD_U24", AMDGPUDTIntTernaryOp,
281   []
282 >;
283 def AMDGPUmad_i24 : SDNode<"AMDGPUISD::MAD_I24", AMDGPUDTIntTernaryOp,
284   []
285 >;
286
287 def AMDGPUsmed3 : SDNode<"AMDGPUISD::SMED3", AMDGPUDTIntTernaryOp,
288   []
289 >;
290
291 def AMDGPUumed3 : SDNode<"AMDGPUISD::UMED3", AMDGPUDTIntTernaryOp,
292   []
293 >;
294
295 def AMDGPUfmed3 : SDNode<"AMDGPUISD::FMED3", SDTFPTernaryOp, []>;
296
297 def AMDGPUsendmsg : SDNode<"AMDGPUISD::SENDMSG",
298                     SDTypeProfile<0, 1, [SDTCisInt<0>]>,
299                     [SDNPHasChain, SDNPInGlue]>;
300
301 def AMDGPUsendmsghalt : SDNode<"AMDGPUISD::SENDMSGHALT",
302                     SDTypeProfile<0, 1, [SDTCisInt<0>]>,
303                     [SDNPHasChain, SDNPInGlue]>;
304
305 def AMDGPUinterp_mov : SDNode<"AMDGPUISD::INTERP_MOV",
306                         SDTypeProfile<1, 3, [SDTCisFP<0>]>,
307                         [SDNPInGlue]>;
308
309 def AMDGPUinterp_p1 : SDNode<"AMDGPUISD::INTERP_P1",
310                       SDTypeProfile<1, 3, [SDTCisFP<0>]>,
311                       [SDNPInGlue, SDNPOutGlue]>;
312
313 def AMDGPUinterp_p2 : SDNode<"AMDGPUISD::INTERP_P2",
314                       SDTypeProfile<1, 4, [SDTCisFP<0>]>,
315                       [SDNPInGlue]>;
316
317
318 def AMDGPUkill : SDNode<"AMDGPUISD::KILL", AMDGPUKillSDT,
319   [SDNPHasChain, SDNPSideEffect]>;
320
321 // SI+ export
322 def AMDGPUExportOp : SDTypeProfile<0, 8, [
323   SDTCisInt<0>,       // i8 tgt
324   SDTCisInt<1>,       // i8 en
325                       // i32 or f32 src0
326   SDTCisSameAs<3, 2>, // f32 src1
327   SDTCisSameAs<4, 2>, // f32 src2
328   SDTCisSameAs<5, 2>, // f32 src3
329   SDTCisInt<6>,       // i1 compr
330   // skip done
331   SDTCisInt<1>        // i1 vm
332
333 ]>;
334
335 def AMDGPUexport: SDNode<"AMDGPUISD::EXPORT", AMDGPUExportOp,
336   [SDNPHasChain, SDNPMayStore]>;
337
338 def AMDGPUexport_done: SDNode<"AMDGPUISD::EXPORT_DONE", AMDGPUExportOp,
339   [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
340
341
342 def R600ExportOp : SDTypeProfile<0, 7, [SDTCisFP<0>, SDTCisInt<1>]>;
343
344 def R600_EXPORT: SDNode<"AMDGPUISD::R600_EXPORT", R600ExportOp,
345   [SDNPHasChain, SDNPSideEffect]>;
346
347 //===----------------------------------------------------------------------===//
348 // Flow Control Profile Types
349 //===----------------------------------------------------------------------===//
350 // Branch instruction where second and third are basic blocks
351 def SDTIL_BRCond : SDTypeProfile<0, 2, [
352     SDTCisVT<0, OtherVT>
353     ]>;
354
355 //===----------------------------------------------------------------------===//
356 // Flow Control DAG Nodes
357 //===----------------------------------------------------------------------===//
358 def IL_brcond      : SDNode<"AMDGPUISD::BRANCH_COND", SDTIL_BRCond, [SDNPHasChain]>;
359
360 //===----------------------------------------------------------------------===//
361 // Call/Return DAG Nodes
362 //===----------------------------------------------------------------------===//
363 def AMDGPUendpgm : SDNode<"AMDGPUISD::ENDPGM", SDTNone,
364     [SDNPHasChain, SDNPOptInGlue]>;
365
366 def AMDGPUreturn_to_epilog : SDNode<"AMDGPUISD::RETURN_TO_EPILOG", SDTNone,
367     [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
368
369 def AMDGPUret_flag : SDNode<"AMDGPUISD::RET_FLAG", SDTNone,
370   [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]
371 >;