1//==- BuiltinsAMDGPU.def - AMDGPU Builtin function database ------*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the AMDGPU-specific builtin function database. Users of
10// this file must define the BUILTIN macro to make use of this information.
11//
12//===----------------------------------------------------------------------===//
13
14// The format of this database matches clang/Basic/Builtins.def.
15
16#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
17# define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
18#endif
19//===----------------------------------------------------------------------===//
20// SI+ only builtins.
21//===----------------------------------------------------------------------===//
22
23BUILTIN(__builtin_amdgcn_dispatch_ptr, "v*4", "nc")
24BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "v*4", "nc")
25BUILTIN(__builtin_amdgcn_implicitarg_ptr, "v*4", "nc")
26BUILTIN(__builtin_amdgcn_queue_ptr, "v*4", "nc")
27
28BUILTIN(__builtin_amdgcn_workgroup_id_x, "Ui", "nc")
29BUILTIN(__builtin_amdgcn_workgroup_id_y, "Ui", "nc")
30BUILTIN(__builtin_amdgcn_workgroup_id_z, "Ui", "nc")
31
32BUILTIN(__builtin_amdgcn_workitem_id_x, "Ui", "nc")
33BUILTIN(__builtin_amdgcn_workitem_id_y, "Ui", "nc")
34BUILTIN(__builtin_amdgcn_workitem_id_z, "Ui", "nc")
35
36BUILTIN(__builtin_amdgcn_workgroup_size_x, "Us", "nc")
37BUILTIN(__builtin_amdgcn_workgroup_size_y, "Us", "nc")
38BUILTIN(__builtin_amdgcn_workgroup_size_z, "Us", "nc")
39
40BUILTIN(__builtin_amdgcn_grid_size_x, "Ui", "nc")
41BUILTIN(__builtin_amdgcn_grid_size_y, "Ui", "nc")
42BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc")
43
44BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
45BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
46
47TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n", "s-memtime-inst")
48
49//===----------------------------------------------------------------------===//
50// Instruction builtins.
51//===----------------------------------------------------------------------===//
52BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
53BUILTIN(__builtin_amdgcn_s_setreg, "vIiUi", "n")
54BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n")
55BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
56BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
57BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
58BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
59BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
60BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
61BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
62BUILTIN(__builtin_amdgcn_ds_gws_init, "vUiUi", "n")
63BUILTIN(__builtin_amdgcn_ds_gws_barrier, "vUiUi", "n")
64BUILTIN(__builtin_amdgcn_ds_gws_sema_v, "vUi", "n")
65BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n")
66BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n")
67BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
68
69BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n")
70BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n")
71
72BUILTIN(__builtin_amdgcn_atomic_dec32, "UZiUZiD*UZiUicC*", "n")
73BUILTIN(__builtin_amdgcn_atomic_dec64, "UWiUWiD*UWiUicC*", "n")
74
75// FIXME: Need to disallow constant address space.
76BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
77BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
78BUILTIN(__builtin_amdgcn_div_fmas, "ddddb", "nc")
79BUILTIN(__builtin_amdgcn_div_fmasf, "ffffb", "nc")
80BUILTIN(__builtin_amdgcn_div_fixup, "dddd", "nc")
81BUILTIN(__builtin_amdgcn_div_fixupf, "ffff", "nc")
82BUILTIN(__builtin_amdgcn_trig_preop, "ddi", "nc")
83BUILTIN(__builtin_amdgcn_trig_preopf, "ffi", "nc")
84BUILTIN(__builtin_amdgcn_rcp, "dd", "nc")
85BUILTIN(__builtin_amdgcn_rcpf, "ff", "nc")
86BUILTIN(__builtin_amdgcn_sqrt, "dd", "nc")
87BUILTIN(__builtin_amdgcn_sqrtf, "ff", "nc")
88BUILTIN(__builtin_amdgcn_rsq, "dd", "nc")
89BUILTIN(__builtin_amdgcn_rsqf, "ff", "nc")
90BUILTIN(__builtin_amdgcn_rsq_clamp, "dd", "nc")
91BUILTIN(__builtin_amdgcn_rsq_clampf, "ff", "nc")
92BUILTIN(__builtin_amdgcn_sinf, "ff", "nc")
93BUILTIN(__builtin_amdgcn_cosf, "ff", "nc")
94BUILTIN(__builtin_amdgcn_log_clampf, "ff", "nc")
95BUILTIN(__builtin_amdgcn_ldexp, "ddi", "nc")
96BUILTIN(__builtin_amdgcn_ldexpf, "ffi", "nc")
97BUILTIN(__builtin_amdgcn_frexp_mant, "dd", "nc")
98BUILTIN(__builtin_amdgcn_frexp_mantf, "ff", "nc")
99BUILTIN(__builtin_amdgcn_frexp_exp, "id", "nc")
100BUILTIN(__builtin_amdgcn_frexp_expf, "if", "nc")
101BUILTIN(__builtin_amdgcn_fract, "dd", "nc")
102BUILTIN(__builtin_amdgcn_fractf, "ff", "nc")
103BUILTIN(__builtin_amdgcn_lerp, "UiUiUiUi", "nc")
104BUILTIN(__builtin_amdgcn_class, "bdi", "nc")
105BUILTIN(__builtin_amdgcn_classf, "bfi", "nc")
106BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc")
107BUILTIN(__builtin_amdgcn_cubesc, "ffff", "nc")
108BUILTIN(__builtin_amdgcn_cubetc, "ffff", "nc")
109BUILTIN(__builtin_amdgcn_cubema, "ffff", "nc")
110BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
111BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n")
112BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n")
113BUILTIN(__builtin_amdgcn_uicmp, "LUiUiUiIi", "nc")
114BUILTIN(__builtin_amdgcn_uicmpl, "LUiLUiLUiIi", "nc")
115BUILTIN(__builtin_amdgcn_sicmp, "LUiiiIi", "nc")
116BUILTIN(__builtin_amdgcn_sicmpl, "LUiLiLiIi", "nc")
117BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc")
118BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc")
119BUILTIN(__builtin_amdgcn_ds_swizzle, "iiIi", "nc")
120BUILTIN(__builtin_amdgcn_ds_permute, "iii", "nc")
121BUILTIN(__builtin_amdgcn_ds_bpermute, "iii", "nc")
122BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
123BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
124BUILTIN(__builtin_amdgcn_fmed3f, "ffff", "nc")
125BUILTIN(__builtin_amdgcn_ds_faddf, "ff*3fIiIiIb", "n")
126BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3fIiIiIb", "n")
127BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb", "n")
128BUILTIN(__builtin_amdgcn_ds_append, "ii*3", "n")
129BUILTIN(__builtin_amdgcn_ds_consume, "ii*3", "n")
130BUILTIN(__builtin_amdgcn_alignbit, "UiUiUiUi", "nc")
131BUILTIN(__builtin_amdgcn_alignbyte, "UiUiUiUi", "nc")
132BUILTIN(__builtin_amdgcn_ubfe, "UiUiUiUi", "nc")
133BUILTIN(__builtin_amdgcn_sbfe, "UiUiUiUi", "nc")
134BUILTIN(__builtin_amdgcn_cvt_pkrtz, "E2hff", "nc")
135BUILTIN(__builtin_amdgcn_cvt_pknorm_i16, "E2sff", "nc")
136BUILTIN(__builtin_amdgcn_cvt_pknorm_u16, "E2Usff", "nc")
137BUILTIN(__builtin_amdgcn_cvt_pk_i16, "E2sii", "nc")
138BUILTIN(__builtin_amdgcn_cvt_pk_u16, "E2UsUiUi", "nc")
139BUILTIN(__builtin_amdgcn_cvt_pk_u8_f32, "UifUiUi", "nc")
140BUILTIN(__builtin_amdgcn_sad_u8, "UiUiUiUi", "nc")
141BUILTIN(__builtin_amdgcn_msad_u8, "UiUiUiUi", "nc")
142BUILTIN(__builtin_amdgcn_sad_hi_u8, "UiUiUiUi", "nc")
143BUILTIN(__builtin_amdgcn_sad_u16, "UiUiUiUi", "nc")
144BUILTIN(__builtin_amdgcn_qsad_pk_u16_u8, "LUiLUiUiLUi", "nc")
145BUILTIN(__builtin_amdgcn_mqsad_pk_u16_u8, "LUiLUiUiLUi", "nc")
146BUILTIN(__builtin_amdgcn_mqsad_u32_u8, "V4UiLUiUiV4Ui", "nc")
147
148//===----------------------------------------------------------------------===//
149// CI+ only builtins.
150//===----------------------------------------------------------------------===//
151TARGET_BUILTIN(__builtin_amdgcn_s_dcache_inv_vol, "v", "n", "ci-insts")
152TARGET_BUILTIN(__builtin_amdgcn_buffer_wbinvl1_vol, "v", "n", "ci-insts")
153TARGET_BUILTIN(__builtin_amdgcn_ds_gws_sema_release_all, "vUi", "n", "ci-insts")
154TARGET_BUILTIN(__builtin_amdgcn_is_shared, "bvC*0", "nc", "flat-address-space")
155TARGET_BUILTIN(__builtin_amdgcn_is_private, "bvC*0", "nc", "flat-address-space")
156
157//===----------------------------------------------------------------------===//
158// Interpolation builtins.
159//===----------------------------------------------------------------------===//
160BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
161BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
162BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
163BUILTIN(__builtin_amdgcn_interp_p2, "fffUiUiUi", "nc")
164BUILTIN(__builtin_amdgcn_interp_mov, "fUiUiUiUi", "nc")
165
166//===----------------------------------------------------------------------===//
167// VI+ only builtins.
168//===----------------------------------------------------------------------===//
169
170TARGET_BUILTIN(__builtin_amdgcn_div_fixuph, "hhhh", "nc", "16-bit-insts")
171TARGET_BUILTIN(__builtin_amdgcn_rcph, "hh", "nc", "16-bit-insts")
172TARGET_BUILTIN(__builtin_amdgcn_sqrth, "hh", "nc", "16-bit-insts")
173TARGET_BUILTIN(__builtin_amdgcn_rsqh, "hh", "nc", "16-bit-insts")
174TARGET_BUILTIN(__builtin_amdgcn_sinh, "hh", "nc", "16-bit-insts")
175TARGET_BUILTIN(__builtin_amdgcn_cosh, "hh", "nc", "16-bit-insts")
176TARGET_BUILTIN(__builtin_amdgcn_ldexph, "hhi", "nc", "16-bit-insts")
177TARGET_BUILTIN(__builtin_amdgcn_frexp_manth, "hh", "nc", "16-bit-insts")
178TARGET_BUILTIN(__builtin_amdgcn_frexp_exph, "sh", "nc", "16-bit-insts")
179TARGET_BUILTIN(__builtin_amdgcn_fracth, "hh", "nc", "16-bit-insts")
180TARGET_BUILTIN(__builtin_amdgcn_classh, "bhi", "nc", "16-bit-insts")
181TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")
182TARGET_BUILTIN(__builtin_amdgcn_mov_dpp, "iiIiIiIiIb", "nc", "dpp")
183TARGET_BUILTIN(__builtin_amdgcn_update_dpp, "iiiIiIiIiIb", "nc", "dpp")
184TARGET_BUILTIN(__builtin_amdgcn_s_dcache_wb, "v", "n", "gfx8-insts")
185
186//===----------------------------------------------------------------------===//
187// GFX9+ only builtins.
188//===----------------------------------------------------------------------===//
189
190TARGET_BUILTIN(__builtin_amdgcn_fmed3h, "hhhh", "nc", "gfx9-insts")
191
192//===----------------------------------------------------------------------===//
193// Deep learning builtins.
194//===----------------------------------------------------------------------===//
195
196TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot7-insts")
197TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot2-insts")
198TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot2-insts")
199TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot1-insts")
200TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot7-insts")
201TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot1-insts")
202TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot7-insts")
203
204//===----------------------------------------------------------------------===//
205// GFX10+ only builtins.
206//===----------------------------------------------------------------------===//
207TARGET_BUILTIN(__builtin_amdgcn_permlane16, "UiUiUiUiUiIbIb", "nc", "gfx10-insts")
208TARGET_BUILTIN(__builtin_amdgcn_permlanex16, "UiUiUiUiUiIbIb", "nc", "gfx10-insts")
209TARGET_BUILTIN(__builtin_amdgcn_mov_dpp8, "UiUiIUi", "nc", "gfx10-insts")
210
211//===----------------------------------------------------------------------===//
212// Special builtins.
213//===----------------------------------------------------------------------===//
214BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
215BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
216BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
217
218BUILTIN(__builtin_amdgcn_endpgm, "v", "nr")
219
220//===----------------------------------------------------------------------===//
221// R600-NI only builtins.
222//===----------------------------------------------------------------------===//
223
224BUILTIN(__builtin_r600_implicitarg_ptr, "Uc*7", "nc")
225
226BUILTIN(__builtin_r600_read_tgid_x, "Ui", "nc")
227BUILTIN(__builtin_r600_read_tgid_y, "Ui", "nc")
228BUILTIN(__builtin_r600_read_tgid_z, "Ui", "nc")
229
230BUILTIN(__builtin_r600_read_tidig_x, "Ui", "nc")
231BUILTIN(__builtin_r600_read_tidig_y, "Ui", "nc")
232BUILTIN(__builtin_r600_read_tidig_z, "Ui", "nc")
233
234BUILTIN(__builtin_r600_recipsqrt_ieee, "dd", "nc")
235BUILTIN(__builtin_r600_recipsqrt_ieeef, "ff", "nc")
236
237//===----------------------------------------------------------------------===//
238// MFMA builtins.
239//===----------------------------------------------------------------------===//
240
241TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x1f32, "V32fffV32fIiIiIi", "nc", "mai-insts")
242TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x1f32, "V16fffV16fIiIiIi", "nc", "mai-insts")
243TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x1f32, "V4fffV4fIiIiIi", "nc", "mai-insts")
244TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x2f32, "V16fffV16fIiIiIi", "nc", "mai-insts")
245TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4f32, "V4fffV4fIiIiIi", "nc", "mai-insts")
246TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4f16, "V32fV4hV4hV32fIiIiIi", "nc", "mai-insts")
247TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4f16, "V16fV4hV4hV16fIiIiIi", "nc", "mai-insts")
248TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x4f16, "V4fV4hV4hV4fIiIiIi", "nc", "mai-insts")
249TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x8f16, "V16fV4hV4hV16fIiIiIi", "nc", "mai-insts")
250TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x16f16, "V4fV4hV4hV4fIiIiIi", "nc", "mai-insts")
251TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_32x32x4i8, "V32iiiV32iIiIiIi", "nc", "mai-insts")
252TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_16x16x4i8, "V16iiiV16iIiIiIi", "nc", "mai-insts")
253TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_4x4x4i8, "V4iiiV4iIiIiIi", "nc", "mai-insts")
254TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_32x32x8i8, "V16iiiV16iIiIiIi", "nc", "mai-insts")
255TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_16x16x16i8, "V4iiiV4iIiIiIi", "nc", "mai-insts")
256TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x2bf16, "V32fV2sV2sV32fIiIiIi", "nc", "mai-insts")
257TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x2bf16, "V16fV2sV2sV16fIiIiIi", "nc", "mai-insts")
258TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x2bf16, "V4fV2sV2sV4fIiIiIi", "nc", "mai-insts")
259TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16, "V16fV2sV2sV16fIiIiIi", "nc", "mai-insts")
260TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x8bf16, "V4fV2sV2sV4fIiIiIi", "nc", "mai-insts")
261
262TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16_1k, "V32fV4sV4sV32fIiIiIi", "nc", "mai-insts")
263TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts")
264TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x4bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts")
265TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x8bf16_1k, "V16fV4sV4sV16fIiIiIi", "nc", "mai-insts")
266TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x16bf16_1k, "V4fV4sV4sV4fIiIiIi", "nc", "mai-insts")
267TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_16x16x4f64, "V4dddV4dIiIiIi", "nc", "mai-insts")
268TARGET_BUILTIN(__builtin_amdgcn_mfma_f64_4x4x4f64, "ddddIiIiIi", "nc", "mai-insts")
269
270#undef BUILTIN
271#undef TARGET_BUILTIN
272