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