• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===--- Builtins.def - Builtin function info database ----------*- C++ -*-===//
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 defines the standard builtin function database.  Users of this file
11// must define the BUILTIN macro to make use of this information.
12//
13//===----------------------------------------------------------------------===//
14
15// FIXME: This should really be a .td file, but that requires modifying tblgen.
16// Perhaps tblgen should have plugins.
17
18// The first value provided to the macro specifies the function name of the
19// builtin, and results in a clang::builtin::BIXX enum value for XX.
20
21// The second value provided to the macro specifies the type of the function
22// (result value, then each argument) as follows:
23//  v -> void
24//  b -> boolean
25//  c -> char
26//  s -> short
27//  i -> int
28//  h -> half
29//  f -> float
30//  d -> double
31//  z -> size_t
32//  F -> constant CFString
33//  G -> id
34//  H -> SEL
35//  M -> struct objc_super
36//  a -> __builtin_va_list
37//  A -> "reference" to __builtin_va_list
38//  V -> Vector, followed by the number of elements and the base type.
39//  E -> ext_vector, followed by the number of elements and the base type.
40//  X -> _Complex, followed by the base type.
41//  Y -> ptrdiff_t
42//  P -> FILE
43//  J -> jmp_buf
44//  SJ -> sigjmp_buf
45//  K -> ucontext_t
46//  p -> pid_t
47//  . -> "...".  This may only occur at the end of the function list.
48//
49// Types may be prefixed with the following modifiers:
50//  L   -> long (e.g. Li for 'long int')
51//  LL  -> long long
52//  LLL -> __int128_t (e.g. LLLi)
53//  W   -> int64_t
54//  S   -> signed
55//  U   -> unsigned
56//  I   -> Required to constant fold to an integer constant expression.
57//
58// Types may be postfixed with the following modifiers:
59// * -> pointer (optionally followed by an address space number, if no address
60//               space is specified than any address space will be accepted)
61// & -> reference (optionally followed by an address space number)
62// C -> const
63// D -> volatile
64
65// The third value provided to the macro specifies information about attributes
66// of the function.  These must be kept in sync with the predicates in the
67// Builtin::Context class.  Currently we have:
68//  n -> nothrow
69//  r -> noreturn
70//  U -> pure
71//  c -> const
72//  t -> signature is meaningless, use custom typechecking
73//  F -> this is a libc/libm function with a '__builtin_' prefix added.
74//  f -> this is a libc/libm function without the '__builtin_' prefix. It can
75//       be followed by ':headername:' to state which header this function
76//       comes from.
77//  i -> this is a runtime library implemented function without the
78//       '__builtin_' prefix. It will be implemented in compiler-rt or libgcc.
79//  p:N: -> this is a printf-like function whose Nth argument is the format
80//          string.
81//  P:N: -> similar to the p:N: attribute, but the function is like vprintf
82//          in that it accepts its arguments as a va_list rather than
83//          through an ellipsis
84//  s:N: -> this is a scanf-like function whose Nth argument is the format
85//          string.
86//  S:N: -> similar to the s:N: attribute, but the function is like vscanf
87//          in that it accepts its arguments as a va_list rather than
88//          through an ellipsis
89//  e -> const, but only when -fmath-errno=0
90//  j -> returns_twice (like setjmp)
91//  u -> arguments are not evaluated for their side-effects
92//  FIXME: gcc has nonnull
93
94#if defined(BUILTIN) && !defined(LIBBUILTIN)
95#  define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
96#endif
97
98#if defined(BUILTIN) && !defined(LANGBUILTIN)
99#  define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
100#endif
101
102// Standard libc/libm functions:
103BUILTIN(__builtin_atan2 , "ddd"  , "Fnc")
104BUILTIN(__builtin_atan2f, "fff"  , "Fnc")
105BUILTIN(__builtin_atan2l, "LdLdLd", "Fnc")
106BUILTIN(__builtin_abs  , "ii"  , "ncF")
107BUILTIN(__builtin_copysign, "ddd", "ncF")
108BUILTIN(__builtin_copysignf, "fff", "ncF")
109BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
110BUILTIN(__builtin_fabs , "dd"  , "ncF")
111BUILTIN(__builtin_fabsf, "ff"  , "ncF")
112BUILTIN(__builtin_fabsl, "LdLd", "ncF")
113BUILTIN(__builtin_fmod , "ddd"  , "Fnc")
114BUILTIN(__builtin_fmodf, "fff"  , "Fnc")
115BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc")
116BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
117BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
118BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
119BUILTIN(__builtin_huge_val, "d", "nc")
120BUILTIN(__builtin_huge_valf, "f", "nc")
121BUILTIN(__builtin_huge_vall, "Ld", "nc")
122BUILTIN(__builtin_inf  , "d"   , "nc")
123BUILTIN(__builtin_inff , "f"   , "nc")
124BUILTIN(__builtin_infl , "Ld"  , "nc")
125BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
126BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
127BUILTIN(__builtin_ldexp , "ddi"  , "Fnc")
128BUILTIN(__builtin_ldexpf, "ffi"  , "Fnc")
129BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc")
130BUILTIN(__builtin_modf , "ddd*"  , "Fn")
131BUILTIN(__builtin_modff, "fff*"  , "Fn")
132BUILTIN(__builtin_modfl, "LdLdLd*", "Fn")
133BUILTIN(__builtin_nan,  "dcC*" , "ncF")
134BUILTIN(__builtin_nanf, "fcC*" , "ncF")
135BUILTIN(__builtin_nanl, "LdcC*", "ncF")
136BUILTIN(__builtin_nans,  "dcC*" , "ncF")
137BUILTIN(__builtin_nansf, "fcC*" , "ncF")
138BUILTIN(__builtin_nansl, "LdcC*", "ncF")
139BUILTIN(__builtin_powi , "ddi"  , "Fnc")
140BUILTIN(__builtin_powif, "ffi"  , "Fnc")
141BUILTIN(__builtin_powil, "LdLdi", "Fnc")
142BUILTIN(__builtin_pow , "ddd"  , "Fnc")
143BUILTIN(__builtin_powf, "fff"  , "Fnc")
144BUILTIN(__builtin_powl, "LdLdLd", "Fnc")
145
146// Standard unary libc/libm functions with double/float/long double variants:
147BUILTIN(__builtin_acos , "dd"  , "Fnc")
148BUILTIN(__builtin_acosf, "ff"  , "Fnc")
149BUILTIN(__builtin_acosl, "LdLd", "Fnc")
150BUILTIN(__builtin_acosh , "dd"  , "Fnc")
151BUILTIN(__builtin_acoshf, "ff"  , "Fnc")
152BUILTIN(__builtin_acoshl, "LdLd", "Fnc")
153BUILTIN(__builtin_asin , "dd"  , "Fnc")
154BUILTIN(__builtin_asinf, "ff"  , "Fnc")
155BUILTIN(__builtin_asinl, "LdLd", "Fnc")
156BUILTIN(__builtin_asinh , "dd"  , "Fnc")
157BUILTIN(__builtin_asinhf, "ff"  , "Fnc")
158BUILTIN(__builtin_asinhl, "LdLd", "Fnc")
159BUILTIN(__builtin_atan , "dd"  , "Fnc")
160BUILTIN(__builtin_atanf, "ff"  , "Fnc")
161BUILTIN(__builtin_atanl, "LdLd", "Fnc")
162BUILTIN(__builtin_atanh , "dd", "Fnc")
163BUILTIN(__builtin_atanhf, "ff", "Fnc")
164BUILTIN(__builtin_atanhl, "LdLd", "Fnc")
165BUILTIN(__builtin_cbrt , "dd", "Fnc")
166BUILTIN(__builtin_cbrtf, "ff", "Fnc")
167BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
168BUILTIN(__builtin_ceil , "dd"  , "Fnc")
169BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
170BUILTIN(__builtin_ceill, "LdLd", "Fnc")
171BUILTIN(__builtin_cos , "dd"  , "Fnc")
172BUILTIN(__builtin_cosf, "ff"  , "Fnc")
173BUILTIN(__builtin_cosh , "dd"  , "Fnc")
174BUILTIN(__builtin_coshf, "ff"  , "Fnc")
175BUILTIN(__builtin_coshl, "LdLd", "Fnc")
176BUILTIN(__builtin_cosl, "LdLd", "Fnc")
177BUILTIN(__builtin_erf , "dd", "Fnc")
178BUILTIN(__builtin_erff, "ff", "Fnc")
179BUILTIN(__builtin_erfl, "LdLd", "Fnc")
180BUILTIN(__builtin_erfc , "dd", "Fnc")
181BUILTIN(__builtin_erfcf, "ff", "Fnc")
182BUILTIN(__builtin_erfcl, "LdLd", "Fnc")
183BUILTIN(__builtin_exp , "dd"  , "Fnc")
184BUILTIN(__builtin_expf, "ff"  , "Fnc")
185BUILTIN(__builtin_expl, "LdLd", "Fnc")
186BUILTIN(__builtin_exp2 , "dd"  , "Fnc")
187BUILTIN(__builtin_exp2f, "ff"  , "Fnc")
188BUILTIN(__builtin_exp2l, "LdLd", "Fnc")
189BUILTIN(__builtin_expm1 , "dd", "Fnc")
190BUILTIN(__builtin_expm1f, "ff", "Fnc")
191BUILTIN(__builtin_expm1l, "LdLd", "Fnc")
192BUILTIN(__builtin_fdim, "ddd", "Fnc")
193BUILTIN(__builtin_fdimf, "fff", "Fnc")
194BUILTIN(__builtin_fdiml, "LdLdLd", "Fnc")
195BUILTIN(__builtin_floor , "dd"  , "Fnc")
196BUILTIN(__builtin_floorf, "ff"  , "Fnc")
197BUILTIN(__builtin_floorl, "LdLd", "Fnc")
198BUILTIN(__builtin_fma, "dddd", "Fnc")
199BUILTIN(__builtin_fmaf, "ffff", "Fnc")
200BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
201BUILTIN(__builtin_fmax, "ddd", "Fnc")
202BUILTIN(__builtin_fmaxf, "fff", "Fnc")
203BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
204BUILTIN(__builtin_fmin, "ddd", "Fnc")
205BUILTIN(__builtin_fminf, "fff", "Fnc")
206BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
207BUILTIN(__builtin_hypot , "ddd"  , "Fnc")
208BUILTIN(__builtin_hypotf, "fff"  , "Fnc")
209BUILTIN(__builtin_hypotl, "LdLdLd", "Fnc")
210BUILTIN(__builtin_ilogb , "id", "Fnc")
211BUILTIN(__builtin_ilogbf, "if", "Fnc")
212BUILTIN(__builtin_ilogbl, "iLd", "Fnc")
213BUILTIN(__builtin_lgamma , "dd", "Fnc")
214BUILTIN(__builtin_lgammaf, "ff", "Fnc")
215BUILTIN(__builtin_lgammal, "LdLd", "Fnc")
216BUILTIN(__builtin_llrint, "LLid", "Fnc")
217BUILTIN(__builtin_llrintf, "LLif", "Fnc")
218BUILTIN(__builtin_llrintl, "LLiLd", "Fnc")
219BUILTIN(__builtin_llround , "LLid", "Fnc")
220BUILTIN(__builtin_llroundf, "LLif", "Fnc")
221BUILTIN(__builtin_llroundl, "LLiLd", "Fnc")
222BUILTIN(__builtin_log , "dd"  , "Fnc")
223BUILTIN(__builtin_log10 , "dd"  , "Fnc")
224BUILTIN(__builtin_log10f, "ff"  , "Fnc")
225BUILTIN(__builtin_log10l, "LdLd", "Fnc")
226BUILTIN(__builtin_log1p , "dd"  , "Fnc")
227BUILTIN(__builtin_log1pf, "ff"  , "Fnc")
228BUILTIN(__builtin_log1pl, "LdLd", "Fnc")
229BUILTIN(__builtin_log2, "dd"  , "Fnc")
230BUILTIN(__builtin_log2f, "ff"  , "Fnc")
231BUILTIN(__builtin_log2l, "LdLd"  , "Fnc")
232BUILTIN(__builtin_logb , "dd", "Fnc")
233BUILTIN(__builtin_logbf, "ff", "Fnc")
234BUILTIN(__builtin_logbl, "LdLd", "Fnc")
235BUILTIN(__builtin_logf, "ff"  , "Fnc")
236BUILTIN(__builtin_logl, "LdLd", "Fnc")
237BUILTIN(__builtin_lrint , "Lid", "Fnc")
238BUILTIN(__builtin_lrintf, "Lif", "Fnc")
239BUILTIN(__builtin_lrintl, "LiLd", "Fnc")
240BUILTIN(__builtin_lround , "Lid", "Fnc")
241BUILTIN(__builtin_lroundf, "Lif", "Fnc")
242BUILTIN(__builtin_lroundl, "LiLd", "Fnc")
243BUILTIN(__builtin_nearbyint , "dd", "Fnc")
244BUILTIN(__builtin_nearbyintf, "ff", "Fnc")
245BUILTIN(__builtin_nearbyintl, "LdLd", "Fnc")
246BUILTIN(__builtin_nextafter , "ddd", "Fnc")
247BUILTIN(__builtin_nextafterf, "fff", "Fnc")
248BUILTIN(__builtin_nextafterl, "LdLdLd", "Fnc")
249BUILTIN(__builtin_nexttoward , "ddLd", "Fnc")
250BUILTIN(__builtin_nexttowardf, "ffLd", "Fnc")
251BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fnc")
252BUILTIN(__builtin_remainder , "ddd", "Fnc")
253BUILTIN(__builtin_remainderf, "fff", "Fnc")
254BUILTIN(__builtin_remainderl, "LdLdLd", "Fnc")
255BUILTIN(__builtin_remquo , "dddi*", "Fn")
256BUILTIN(__builtin_remquof, "fffi*", "Fn")
257BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn")
258BUILTIN(__builtin_rint , "dd", "Fnc")
259BUILTIN(__builtin_rintf, "ff", "Fnc")
260BUILTIN(__builtin_rintl, "LdLd", "Fnc")
261BUILTIN(__builtin_round, "dd"  , "Fnc")
262BUILTIN(__builtin_roundf, "ff"  , "Fnc")
263BUILTIN(__builtin_roundl, "LdLd"  , "Fnc")
264BUILTIN(__builtin_scalbln , "ddLi", "Fnc")
265BUILTIN(__builtin_scalblnf, "ffLi", "Fnc")
266BUILTIN(__builtin_scalblnl, "LdLdLi", "Fnc")
267BUILTIN(__builtin_scalbn , "ddi", "Fnc")
268BUILTIN(__builtin_scalbnf, "ffi", "Fnc")
269BUILTIN(__builtin_scalbnl, "LdLdi", "Fnc")
270BUILTIN(__builtin_sin , "dd"  , "Fnc")
271BUILTIN(__builtin_sinf, "ff"  , "Fnc")
272BUILTIN(__builtin_sinh , "dd"  , "Fnc")
273BUILTIN(__builtin_sinhf, "ff"  , "Fnc")
274BUILTIN(__builtin_sinhl, "LdLd", "Fnc")
275BUILTIN(__builtin_sinl, "LdLd", "Fnc")
276BUILTIN(__builtin_sqrt , "dd"  , "Fnc")
277BUILTIN(__builtin_sqrtf, "ff"  , "Fnc")
278BUILTIN(__builtin_sqrtl, "LdLd", "Fnc")
279BUILTIN(__builtin_tan , "dd"  , "Fnc")
280BUILTIN(__builtin_tanf, "ff"  , "Fnc")
281BUILTIN(__builtin_tanh , "dd"  , "Fnc")
282BUILTIN(__builtin_tanhf, "ff"  , "Fnc")
283BUILTIN(__builtin_tanhl, "LdLd", "Fnc")
284BUILTIN(__builtin_tanl, "LdLd", "Fnc")
285BUILTIN(__builtin_tgamma , "dd", "Fnc")
286BUILTIN(__builtin_tgammaf, "ff", "Fnc")
287BUILTIN(__builtin_tgammal, "LdLd", "Fnc")
288BUILTIN(__builtin_trunc , "dd", "Fnc")
289BUILTIN(__builtin_truncf, "ff", "Fnc")
290BUILTIN(__builtin_truncl, "LdLd", "Fnc")
291
292// C99 complex builtins
293BUILTIN(__builtin_cabs, "dXd", "Fnc")
294BUILTIN(__builtin_cabsf, "fXf", "Fnc")
295BUILTIN(__builtin_cabsl, "LdXLd", "Fnc")
296BUILTIN(__builtin_cacos, "XdXd", "Fnc")
297BUILTIN(__builtin_cacosf, "XfXf", "Fnc")
298BUILTIN(__builtin_cacosh, "XdXd", "Fnc")
299BUILTIN(__builtin_cacoshf, "XfXf", "Fnc")
300BUILTIN(__builtin_cacoshl, "XLdXLd", "Fnc")
301BUILTIN(__builtin_cacosl, "XLdXLd", "Fnc")
302BUILTIN(__builtin_carg, "dXd", "Fnc")
303BUILTIN(__builtin_cargf, "fXf", "Fnc")
304BUILTIN(__builtin_cargl, "LdXLd", "Fnc")
305BUILTIN(__builtin_casin, "XdXd", "Fnc")
306BUILTIN(__builtin_casinf, "XfXf", "Fnc")
307BUILTIN(__builtin_casinh, "XdXd", "Fnc")
308BUILTIN(__builtin_casinhf, "XfXf", "Fnc")
309BUILTIN(__builtin_casinhl, "XLdXLd", "Fnc")
310BUILTIN(__builtin_casinl, "XLdXLd", "Fnc")
311BUILTIN(__builtin_catan, "XdXd", "Fnc")
312BUILTIN(__builtin_catanf, "XfXf", "Fnc")
313BUILTIN(__builtin_catanh, "XdXd", "Fnc")
314BUILTIN(__builtin_catanhf, "XfXf", "Fnc")
315BUILTIN(__builtin_catanhl, "XLdXLd", "Fnc")
316BUILTIN(__builtin_catanl, "XLdXLd", "Fnc")
317BUILTIN(__builtin_ccos, "XdXd", "Fnc")
318BUILTIN(__builtin_ccosf, "XfXf", "Fnc")
319BUILTIN(__builtin_ccosl, "XLdXLd", "Fnc")
320BUILTIN(__builtin_ccosh, "XdXd", "Fnc")
321BUILTIN(__builtin_ccoshf, "XfXf", "Fnc")
322BUILTIN(__builtin_ccoshl, "XLdXLd", "Fnc")
323BUILTIN(__builtin_cexp, "XdXd", "Fnc")
324BUILTIN(__builtin_cexpf, "XfXf", "Fnc")
325BUILTIN(__builtin_cexpl, "XLdXLd", "Fnc")
326BUILTIN(__builtin_cimag, "dXd", "Fnc")
327BUILTIN(__builtin_cimagf, "fXf", "Fnc")
328BUILTIN(__builtin_cimagl, "LdXLd", "Fnc")
329BUILTIN(__builtin_conj, "XdXd", "Fnc")
330BUILTIN(__builtin_conjf, "XfXf", "Fnc")
331BUILTIN(__builtin_conjl, "XLdXLd", "Fnc")
332BUILTIN(__builtin_clog, "XdXd", "Fnc")
333BUILTIN(__builtin_clogf, "XfXf", "Fnc")
334BUILTIN(__builtin_clogl, "XLdXLd", "Fnc")
335BUILTIN(__builtin_cproj, "XdXd", "Fnc")
336BUILTIN(__builtin_cprojf, "XfXf", "Fnc")
337BUILTIN(__builtin_cprojl, "XLdXLd", "Fnc")
338BUILTIN(__builtin_cpow, "XdXdXd", "Fnc")
339BUILTIN(__builtin_cpowf, "XfXfXf", "Fnc")
340BUILTIN(__builtin_cpowl, "XLdXLdXLd", "Fnc")
341BUILTIN(__builtin_creal, "dXd", "Fnc")
342BUILTIN(__builtin_crealf, "fXf", "Fnc")
343BUILTIN(__builtin_creall, "LdXLd", "Fnc")
344BUILTIN(__builtin_csin, "XdXd", "Fnc")
345BUILTIN(__builtin_csinf, "XfXf", "Fnc")
346BUILTIN(__builtin_csinl, "XLdXLd", "Fnc")
347BUILTIN(__builtin_csinh, "XdXd", "Fnc")
348BUILTIN(__builtin_csinhf, "XfXf", "Fnc")
349BUILTIN(__builtin_csinhl, "XLdXLd", "Fnc")
350BUILTIN(__builtin_csqrt, "XdXd", "Fnc")
351BUILTIN(__builtin_csqrtf, "XfXf", "Fnc")
352BUILTIN(__builtin_csqrtl, "XLdXLd", "Fnc")
353BUILTIN(__builtin_ctan, "XdXd", "Fnc")
354BUILTIN(__builtin_ctanf, "XfXf", "Fnc")
355BUILTIN(__builtin_ctanl, "XLdXLd", "Fnc")
356BUILTIN(__builtin_ctanh, "XdXd", "Fnc")
357BUILTIN(__builtin_ctanhf, "XfXf", "Fnc")
358BUILTIN(__builtin_ctanhl, "XLdXLd", "Fnc")
359
360// FP Comparisons.
361BUILTIN(__builtin_isgreater     , "i.", "Fnc")
362BUILTIN(__builtin_isgreaterequal, "i.", "Fnc")
363BUILTIN(__builtin_isless        , "i.", "Fnc")
364BUILTIN(__builtin_islessequal   , "i.", "Fnc")
365BUILTIN(__builtin_islessgreater , "i.", "Fnc")
366BUILTIN(__builtin_isunordered   , "i.", "Fnc")
367
368// Unary FP classification
369BUILTIN(__builtin_fpclassify, "iiiii.", "Fnc")
370BUILTIN(__builtin_isfinite,   "i.", "Fnc")
371BUILTIN(__builtin_isinf,      "i.", "Fnc")
372BUILTIN(__builtin_isinf_sign, "i.", "Fnc")
373BUILTIN(__builtin_isnan,      "i.", "Fnc")
374BUILTIN(__builtin_isnormal,   "i.", "Fnc")
375
376// FP signbit builtins
377BUILTIN(__builtin_signbit, "i.", "Fnc")
378BUILTIN(__builtin_signbitf, "if", "Fnc")
379BUILTIN(__builtin_signbitl, "iLd", "Fnc")
380
381// Special FP builtins.
382BUILTIN(__builtin_canonicalize, "dd", "nc")
383BUILTIN(__builtin_canonicalizef, "ff", "nc")
384BUILTIN(__builtin_canonicalizel, "LdLd", "nc")
385
386// Builtins for arithmetic.
387BUILTIN(__builtin_clzs , "iUs"  , "nc")
388BUILTIN(__builtin_clz  , "iUi"  , "nc")
389BUILTIN(__builtin_clzl , "iULi" , "nc")
390BUILTIN(__builtin_clzll, "iULLi", "nc")
391// TODO: int clzimax(uintmax_t)
392BUILTIN(__builtin_ctzs , "iUs"  , "nc")
393BUILTIN(__builtin_ctz  , "iUi"  , "nc")
394BUILTIN(__builtin_ctzl , "iULi" , "nc")
395BUILTIN(__builtin_ctzll, "iULLi", "nc")
396// TODO: int ctzimax(uintmax_t)
397BUILTIN(__builtin_ffs  , "ii"  , "Fnc")
398BUILTIN(__builtin_ffsl , "iLi" , "Fnc")
399BUILTIN(__builtin_ffsll, "iLLi", "Fnc")
400BUILTIN(__builtin_parity  , "iUi"  , "nc")
401BUILTIN(__builtin_parityl , "iULi" , "nc")
402BUILTIN(__builtin_parityll, "iULLi", "nc")
403BUILTIN(__builtin_popcount  , "iUi"  , "nc")
404BUILTIN(__builtin_popcountl , "iULi" , "nc")
405BUILTIN(__builtin_popcountll, "iULLi", "nc")
406
407// FIXME: These type signatures are not correct for targets with int != 32-bits
408// or with ULL != 64-bits.
409BUILTIN(__builtin_bswap16, "UsUs", "nc")
410BUILTIN(__builtin_bswap32, "UiUi", "nc")
411BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
412
413BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
414BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
415BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
416BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")
417
418// Random GCC builtins
419BUILTIN(__builtin_constant_p, "i.", "nctu")
420BUILTIN(__builtin_classify_type, "i.", "nctu")
421BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
422BUILTIN(__builtin___NSStringMakeConstantString, "FC*cC*", "nc")
423BUILTIN(__builtin_va_start, "vA.", "nt")
424BUILTIN(__builtin_va_end, "vA", "n")
425BUILTIN(__builtin_va_copy, "vAA", "n")
426BUILTIN(__builtin_stdarg_start, "vA.", "n")
427BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nc")
428BUILTIN(__builtin_bcmp, "iv*v*z", "Fn")
429BUILTIN(__builtin_bcopy, "vv*v*z", "n")
430BUILTIN(__builtin_bzero, "vv*z", "nF")
431BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
432BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
433BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
434BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
435BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
436BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
437BUILTIN(__builtin_memset, "v*v*iz", "nF")
438BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
439BUILTIN(__builtin_stpcpy, "c*c*cC*", "nF")
440BUILTIN(__builtin_stpncpy, "c*c*cC*z", "nF")
441BUILTIN(__builtin_strcasecmp, "icC*cC*", "nF")
442BUILTIN(__builtin_strcat, "c*c*cC*", "nF")
443BUILTIN(__builtin_strchr, "c*cC*i", "nF")
444BUILTIN(__builtin_strcmp, "icC*cC*", "nF")
445BUILTIN(__builtin_strcpy, "c*c*cC*", "nF")
446BUILTIN(__builtin_strcspn, "zcC*cC*", "nF")
447BUILTIN(__builtin_strdup, "c*cC*", "nF")
448BUILTIN(__builtin_strlen, "zcC*", "nF")
449BUILTIN(__builtin_strncasecmp, "icC*cC*z", "nF")
450BUILTIN(__builtin_strncat, "c*c*cC*z", "nF")
451BUILTIN(__builtin_strncmp, "icC*cC*z", "nF")
452BUILTIN(__builtin_strncpy, "c*c*cC*z", "nF")
453BUILTIN(__builtin_strndup, "c*cC*z", "nF")
454BUILTIN(__builtin_strpbrk, "c*cC*cC*", "nF")
455BUILTIN(__builtin_strrchr, "c*cC*i", "nF")
456BUILTIN(__builtin_strspn, "zcC*cC*", "nF")
457BUILTIN(__builtin_strstr, "c*cC*cC*", "nF")
458BUILTIN(__builtin_return_address, "v*IUi", "n")
459BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
460BUILTIN(__builtin_frame_address, "v*IUi", "n")
461BUILTIN(__builtin___clear_cache, "vc*c*", "n")
462BUILTIN(__builtin_flt_rounds, "i", "nc")
463BUILTIN(__builtin_setjmp, "iv**", "j")
464BUILTIN(__builtin_longjmp, "vv**i", "r")
465BUILTIN(__builtin_unwind_init, "v", "")
466BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
467BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
468BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
469BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
470BUILTIN(__builtin_thread_pointer, "v*", "nc")
471
472// GCC exception builtins
473BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!
474BUILTIN(__builtin_frob_return_addr, "v*v*", "n")
475BUILTIN(__builtin_dwarf_cfa, "v*", "n")
476BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")
477BUILTIN(__builtin_dwarf_sp_column, "Ui", "n")
478BUILTIN(__builtin_extend_pointer, "ULLiv*", "n") // _Unwind_Word == uint64_t
479
480// GCC Object size checking builtins
481BUILTIN(__builtin_object_size, "zvC*i", "nu")
482BUILTIN(__builtin___memcpy_chk, "v*v*vC*zz", "nF")
483BUILTIN(__builtin___memccpy_chk, "v*v*vC*izz", "nF")
484BUILTIN(__builtin___memmove_chk, "v*v*vC*zz", "nF")
485BUILTIN(__builtin___mempcpy_chk, "v*v*vC*zz", "nF")
486BUILTIN(__builtin___memset_chk, "v*v*izz", "nF")
487BUILTIN(__builtin___stpcpy_chk, "c*c*cC*z", "nF")
488BUILTIN(__builtin___strcat_chk, "c*c*cC*z", "nF")
489BUILTIN(__builtin___strcpy_chk, "c*c*cC*z", "nF")
490BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
491BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
492BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
493BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
494BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
495BUILTIN(__builtin___snprintf_chk, "ic*zizcC*.", "Fp:4:")
496BUILTIN(__builtin___sprintf_chk, "ic*izcC*.", "Fp:3:")
497BUILTIN(__builtin___vsnprintf_chk, "ic*zizcC*a", "FP:4:")
498BUILTIN(__builtin___vsprintf_chk, "ic*izcC*a", "FP:3:")
499BUILTIN(__builtin___fprintf_chk, "iP*icC*.", "Fp:2:")
500BUILTIN(__builtin___printf_chk, "iicC*.", "Fp:1:")
501BUILTIN(__builtin___vfprintf_chk, "iP*icC*a", "FP:2:")
502BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
503
504BUILTIN(__builtin_unpredictable, "LiLi"   , "nc")
505BUILTIN(__builtin_expect, "LiLiLi"   , "nc")
506BUILTIN(__builtin_prefetch, "vvC*.", "nc")
507BUILTIN(__builtin_readcyclecounter, "ULLi", "n")
508BUILTIN(__builtin_trap, "v", "nr")
509BUILTIN(__builtin_debugtrap, "v", "n")
510BUILTIN(__builtin_unreachable, "v", "nr")
511BUILTIN(__builtin_shufflevector, "v."   , "nc")
512BUILTIN(__builtin_convertvector, "v."   , "nct")
513BUILTIN(__builtin_alloca, "v*z"   , "Fn")
514BUILTIN(__builtin_call_with_static_chain, "v.", "nt")
515
516// "Overloaded" Atomic operator builtins.  These are overloaded to support data
517// types of i8, i16, i32, i64, and i128.  The front-end sees calls to the
518// non-suffixed version of these (which has a bogus type) and transforms them to
519// the right overloaded version in Sema (plus casts).
520
521// FIXME: These assume that char -> i8, short -> i16, int -> i32,
522// long long -> i64.
523
524BUILTIN(__sync_fetch_and_add, "v.", "t")
525BUILTIN(__sync_fetch_and_add_1, "ccD*c.", "nt")
526BUILTIN(__sync_fetch_and_add_2, "ssD*s.", "nt")
527BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "nt")
528BUILTIN(__sync_fetch_and_add_8, "LLiLLiD*LLi.", "nt")
529BUILTIN(__sync_fetch_and_add_16, "LLLiLLLiD*LLLi.", "nt")
530
531BUILTIN(__sync_fetch_and_sub, "v.", "t")
532BUILTIN(__sync_fetch_and_sub_1, "ccD*c.", "nt")
533BUILTIN(__sync_fetch_and_sub_2, "ssD*s.", "nt")
534BUILTIN(__sync_fetch_and_sub_4, "iiD*i.", "nt")
535BUILTIN(__sync_fetch_and_sub_8, "LLiLLiD*LLi.", "nt")
536BUILTIN(__sync_fetch_and_sub_16, "LLLiLLLiD*LLLi.", "nt")
537
538BUILTIN(__sync_fetch_and_or, "v.", "t")
539BUILTIN(__sync_fetch_and_or_1, "ccD*c.", "nt")
540BUILTIN(__sync_fetch_and_or_2, "ssD*s.", "nt")
541BUILTIN(__sync_fetch_and_or_4, "iiD*i.", "nt")
542BUILTIN(__sync_fetch_and_or_8, "LLiLLiD*LLi.", "nt")
543BUILTIN(__sync_fetch_and_or_16, "LLLiLLLiD*LLLi.", "nt")
544
545BUILTIN(__sync_fetch_and_and, "v.", "t")
546BUILTIN(__sync_fetch_and_and_1, "ccD*c.", "tn")
547BUILTIN(__sync_fetch_and_and_2, "ssD*s.", "tn")
548BUILTIN(__sync_fetch_and_and_4, "iiD*i.", "tn")
549BUILTIN(__sync_fetch_and_and_8, "LLiLLiD*LLi.", "tn")
550BUILTIN(__sync_fetch_and_and_16, "LLLiLLLiD*LLLi.", "tn")
551
552BUILTIN(__sync_fetch_and_xor, "v.", "t")
553BUILTIN(__sync_fetch_and_xor_1, "ccD*c.", "tn")
554BUILTIN(__sync_fetch_and_xor_2, "ssD*s.", "tn")
555BUILTIN(__sync_fetch_and_xor_4, "iiD*i.", "tn")
556BUILTIN(__sync_fetch_and_xor_8, "LLiLLiD*LLi.", "tn")
557BUILTIN(__sync_fetch_and_xor_16, "LLLiLLLiD*LLLi.", "tn")
558
559BUILTIN(__sync_fetch_and_nand, "v.", "t")
560BUILTIN(__sync_fetch_and_nand_1, "ccD*c.", "tn")
561BUILTIN(__sync_fetch_and_nand_2, "ssD*s.", "tn")
562BUILTIN(__sync_fetch_and_nand_4, "iiD*i.", "tn")
563BUILTIN(__sync_fetch_and_nand_8, "LLiLLiD*LLi.", "tn")
564BUILTIN(__sync_fetch_and_nand_16, "LLLiLLLiD*LLLi.", "tn")
565
566BUILTIN(__sync_add_and_fetch, "v.", "t")
567BUILTIN(__sync_add_and_fetch_1, "ccD*c.", "tn")
568BUILTIN(__sync_add_and_fetch_2, "ssD*s.", "tn")
569BUILTIN(__sync_add_and_fetch_4, "iiD*i.", "tn")
570BUILTIN(__sync_add_and_fetch_8, "LLiLLiD*LLi.", "tn")
571BUILTIN(__sync_add_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
572
573BUILTIN(__sync_sub_and_fetch, "v.", "t")
574BUILTIN(__sync_sub_and_fetch_1, "ccD*c.", "tn")
575BUILTIN(__sync_sub_and_fetch_2, "ssD*s.", "tn")
576BUILTIN(__sync_sub_and_fetch_4, "iiD*i.", "tn")
577BUILTIN(__sync_sub_and_fetch_8, "LLiLLiD*LLi.", "tn")
578BUILTIN(__sync_sub_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
579
580BUILTIN(__sync_or_and_fetch, "v.", "t")
581BUILTIN(__sync_or_and_fetch_1, "ccD*c.", "tn")
582BUILTIN(__sync_or_and_fetch_2, "ssD*s.", "tn")
583BUILTIN(__sync_or_and_fetch_4, "iiD*i.", "tn")
584BUILTIN(__sync_or_and_fetch_8, "LLiLLiD*LLi.", "tn")
585BUILTIN(__sync_or_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
586
587BUILTIN(__sync_and_and_fetch, "v.", "t")
588BUILTIN(__sync_and_and_fetch_1, "ccD*c.", "tn")
589BUILTIN(__sync_and_and_fetch_2, "ssD*s.", "tn")
590BUILTIN(__sync_and_and_fetch_4, "iiD*i.", "tn")
591BUILTIN(__sync_and_and_fetch_8, "LLiLLiD*LLi.", "tn")
592BUILTIN(__sync_and_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
593
594BUILTIN(__sync_xor_and_fetch, "v.", "t")
595BUILTIN(__sync_xor_and_fetch_1, "ccD*c.", "tn")
596BUILTIN(__sync_xor_and_fetch_2, "ssD*s.", "tn")
597BUILTIN(__sync_xor_and_fetch_4, "iiD*i.", "tn")
598BUILTIN(__sync_xor_and_fetch_8, "LLiLLiD*LLi.", "tn")
599BUILTIN(__sync_xor_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
600
601BUILTIN(__sync_nand_and_fetch, "v.", "t")
602BUILTIN(__sync_nand_and_fetch_1, "ccD*c.", "tn")
603BUILTIN(__sync_nand_and_fetch_2, "ssD*s.", "tn")
604BUILTIN(__sync_nand_and_fetch_4, "iiD*i.", "tn")
605BUILTIN(__sync_nand_and_fetch_8, "LLiLLiD*LLi.", "tn")
606BUILTIN(__sync_nand_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
607
608BUILTIN(__sync_bool_compare_and_swap, "v.", "t")
609BUILTIN(__sync_bool_compare_and_swap_1, "bcD*cc.", "tn")
610BUILTIN(__sync_bool_compare_and_swap_2, "bsD*ss.", "tn")
611BUILTIN(__sync_bool_compare_and_swap_4, "biD*ii.", "tn")
612BUILTIN(__sync_bool_compare_and_swap_8, "bLLiD*LLiLLi.", "tn")
613BUILTIN(__sync_bool_compare_and_swap_16, "bLLLiD*LLLiLLLi.", "tn")
614
615BUILTIN(__sync_val_compare_and_swap, "v.", "t")
616BUILTIN(__sync_val_compare_and_swap_1, "ccD*cc.", "tn")
617BUILTIN(__sync_val_compare_and_swap_2, "ssD*ss.", "tn")
618BUILTIN(__sync_val_compare_and_swap_4, "iiD*ii.", "tn")
619BUILTIN(__sync_val_compare_and_swap_8, "LLiLLiD*LLiLLi.", "tn")
620BUILTIN(__sync_val_compare_and_swap_16, "LLLiLLLiD*LLLiLLLi.", "tn")
621
622BUILTIN(__sync_lock_test_and_set, "v.", "t")
623BUILTIN(__sync_lock_test_and_set_1, "ccD*c.", "tn")
624BUILTIN(__sync_lock_test_and_set_2, "ssD*s.", "tn")
625BUILTIN(__sync_lock_test_and_set_4, "iiD*i.", "tn")
626BUILTIN(__sync_lock_test_and_set_8, "LLiLLiD*LLi.", "tn")
627BUILTIN(__sync_lock_test_and_set_16, "LLLiLLLiD*LLLi.", "tn")
628
629BUILTIN(__sync_lock_release, "v.", "t")
630BUILTIN(__sync_lock_release_1, "vcD*.", "tn")
631BUILTIN(__sync_lock_release_2, "vsD*.", "tn")
632BUILTIN(__sync_lock_release_4, "viD*.", "tn")
633BUILTIN(__sync_lock_release_8, "vLLiD*.", "tn")
634BUILTIN(__sync_lock_release_16, "vLLLiD*.", "tn")
635
636BUILTIN(__sync_swap, "v.", "t")
637BUILTIN(__sync_swap_1, "ccD*c.", "tn")
638BUILTIN(__sync_swap_2, "ssD*s.", "tn")
639BUILTIN(__sync_swap_4, "iiD*i.", "tn")
640BUILTIN(__sync_swap_8, "LLiLLiD*LLi.", "tn")
641BUILTIN(__sync_swap_16, "LLLiLLLiD*LLLi.", "tn")
642
643// Some of our atomics builtins are handled by AtomicExpr rather than
644// as normal builtin CallExprs. This macro is used for such builtins.
645#ifndef ATOMIC_BUILTIN
646#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
647#endif
648
649// C11 _Atomic operations for <stdatomic.h>.
650ATOMIC_BUILTIN(__c11_atomic_init, "v.", "t")
651ATOMIC_BUILTIN(__c11_atomic_load, "v.", "t")
652ATOMIC_BUILTIN(__c11_atomic_store, "v.", "t")
653ATOMIC_BUILTIN(__c11_atomic_exchange, "v.", "t")
654ATOMIC_BUILTIN(__c11_atomic_compare_exchange_strong, "v.", "t")
655ATOMIC_BUILTIN(__c11_atomic_compare_exchange_weak, "v.", "t")
656ATOMIC_BUILTIN(__c11_atomic_fetch_add, "v.", "t")
657ATOMIC_BUILTIN(__c11_atomic_fetch_sub, "v.", "t")
658ATOMIC_BUILTIN(__c11_atomic_fetch_and, "v.", "t")
659ATOMIC_BUILTIN(__c11_atomic_fetch_or, "v.", "t")
660ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t")
661BUILTIN(__c11_atomic_thread_fence, "vi", "n")
662BUILTIN(__c11_atomic_signal_fence, "vi", "n")
663BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
664
665// GNU atomic builtins.
666ATOMIC_BUILTIN(__atomic_load, "v.", "t")
667ATOMIC_BUILTIN(__atomic_load_n, "v.", "t")
668ATOMIC_BUILTIN(__atomic_store, "v.", "t")
669ATOMIC_BUILTIN(__atomic_store_n, "v.", "t")
670ATOMIC_BUILTIN(__atomic_exchange, "v.", "t")
671ATOMIC_BUILTIN(__atomic_exchange_n, "v.", "t")
672ATOMIC_BUILTIN(__atomic_compare_exchange, "v.", "t")
673ATOMIC_BUILTIN(__atomic_compare_exchange_n, "v.", "t")
674ATOMIC_BUILTIN(__atomic_fetch_add, "v.", "t")
675ATOMIC_BUILTIN(__atomic_fetch_sub, "v.", "t")
676ATOMIC_BUILTIN(__atomic_fetch_and, "v.", "t")
677ATOMIC_BUILTIN(__atomic_fetch_or, "v.", "t")
678ATOMIC_BUILTIN(__atomic_fetch_xor, "v.", "t")
679ATOMIC_BUILTIN(__atomic_fetch_nand, "v.", "t")
680ATOMIC_BUILTIN(__atomic_add_fetch, "v.", "t")
681ATOMIC_BUILTIN(__atomic_sub_fetch, "v.", "t")
682ATOMIC_BUILTIN(__atomic_and_fetch, "v.", "t")
683ATOMIC_BUILTIN(__atomic_or_fetch, "v.", "t")
684ATOMIC_BUILTIN(__atomic_xor_fetch, "v.", "t")
685ATOMIC_BUILTIN(__atomic_nand_fetch, "v.", "t")
686BUILTIN(__atomic_test_and_set, "bvD*i", "n")
687BUILTIN(__atomic_clear, "vvD*i", "n")
688BUILTIN(__atomic_thread_fence, "vi", "n")
689BUILTIN(__atomic_signal_fence, "vi", "n")
690BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
691BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
692
693#undef ATOMIC_BUILTIN
694
695// Non-overloaded atomic builtins.
696BUILTIN(__sync_synchronize, "v.", "n")
697// GCC does not support these, they are a Clang extension.
698BUILTIN(__sync_fetch_and_min, "iiD*i", "n")
699BUILTIN(__sync_fetch_and_max, "iiD*i", "n")
700BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
701BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
702
703// Random libc builtins.
704BUILTIN(__builtin_abort, "v", "Fnr")
705BUILTIN(__builtin_index, "c*cC*i", "Fn")
706BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
707
708// Microsoft builtins.  These are only active with -fms-extensions.
709LANGBUILTIN(_alloca,          "v*z", "n", ALL_MS_LANGUAGES)
710LANGBUILTIN(__assume,         "vb",  "n", ALL_MS_LANGUAGES)
711LANGBUILTIN(__debugbreak,     "v",   "n", ALL_MS_LANGUAGES)
712LANGBUILTIN(__exception_code, "ULi", "n", ALL_MS_LANGUAGES)
713LANGBUILTIN(_exception_code,  "ULi", "n", ALL_MS_LANGUAGES)
714LANGBUILTIN(__exception_info, "v*",  "n", ALL_MS_LANGUAGES)
715LANGBUILTIN(_exception_info,  "v*",  "n", ALL_MS_LANGUAGES)
716LANGBUILTIN(__abnormal_termination, "i", "n", ALL_MS_LANGUAGES)
717LANGBUILTIN(_abnormal_termination,  "i", "n", ALL_MS_LANGUAGES)
718LANGBUILTIN(__GetExceptionInfo, "v*.", "ntu", ALL_MS_LANGUAGES)
719LANGBUILTIN(_InterlockedCompareExchange, "LiLiD*LiLi", "n", ALL_MS_LANGUAGES)
720LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", ALL_MS_LANGUAGES)
721LANGBUILTIN(_InterlockedDecrement,       "LiLiD*",     "n", ALL_MS_LANGUAGES)
722LANGBUILTIN(_InterlockedExchangeAdd,     "LiLiD*Li",   "n", ALL_MS_LANGUAGES)
723LANGBUILTIN(_InterlockedExchange,        "LiLiD*Li",   "n", ALL_MS_LANGUAGES)
724LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*",   "n", ALL_MS_LANGUAGES)
725LANGBUILTIN(_InterlockedIncrement,       "LiLiD*",     "n", ALL_MS_LANGUAGES)
726LANGBUILTIN(__noop,           "i.",  "n", ALL_MS_LANGUAGES)
727LANGBUILTIN(__readfsdword,    "ULiULi", "n", ALL_MS_LANGUAGES)
728LANGBUILTIN(__va_start,       "vc**.", "nt", ALL_MS_LANGUAGES)
729
730// Microsoft library builtins.
731LIBBUILTIN(_setjmpex, "iJ", "fj",   "setjmpex.h", ALL_MS_LANGUAGES)
732
733// C99 library functions
734// C99 stdlib.h
735LIBBUILTIN(abort, "v",            "fr",    "stdlib.h", ALL_LANGUAGES)
736LIBBUILTIN(calloc, "v*zz",        "f",     "stdlib.h", ALL_LANGUAGES)
737LIBBUILTIN(exit, "vi",            "fr",    "stdlib.h", ALL_LANGUAGES)
738LIBBUILTIN(_Exit, "vi",           "fr",    "stdlib.h", ALL_LANGUAGES)
739LIBBUILTIN(malloc, "v*z",         "f",     "stdlib.h", ALL_LANGUAGES)
740LIBBUILTIN(realloc, "v*v*z",      "f",     "stdlib.h", ALL_LANGUAGES)
741// C99 string.h
742LIBBUILTIN(memcpy, "v*v*vC*z",    "f",     "string.h", ALL_LANGUAGES)
743LIBBUILTIN(memcmp, "ivC*vC*z",    "f",     "string.h", ALL_LANGUAGES)
744LIBBUILTIN(memmove, "v*v*vC*z",   "f",     "string.h", ALL_LANGUAGES)
745LIBBUILTIN(strcpy, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
746LIBBUILTIN(strncpy, "c*c*cC*z",   "f",     "string.h", ALL_LANGUAGES)
747LIBBUILTIN(strcmp, "icC*cC*",     "f",     "string.h", ALL_LANGUAGES)
748LIBBUILTIN(strncmp, "icC*cC*z",   "f",     "string.h", ALL_LANGUAGES)
749LIBBUILTIN(strcat, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
750LIBBUILTIN(strncat, "c*c*cC*z",   "f",     "string.h", ALL_LANGUAGES)
751LIBBUILTIN(strxfrm, "zc*cC*z",    "f",     "string.h", ALL_LANGUAGES)
752LIBBUILTIN(memchr, "v*vC*iz",     "f",     "string.h", ALL_LANGUAGES)
753LIBBUILTIN(strchr, "c*cC*i",      "f",     "string.h", ALL_LANGUAGES)
754LIBBUILTIN(strcspn, "zcC*cC*",    "f",     "string.h", ALL_LANGUAGES)
755LIBBUILTIN(strpbrk, "c*cC*cC*",   "f",     "string.h", ALL_LANGUAGES)
756LIBBUILTIN(strrchr, "c*cC*i",     "f",     "string.h", ALL_LANGUAGES)
757LIBBUILTIN(strspn, "zcC*cC*",     "f",     "string.h", ALL_LANGUAGES)
758LIBBUILTIN(strstr, "c*cC*cC*",    "f",     "string.h", ALL_LANGUAGES)
759LIBBUILTIN(strtok, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
760LIBBUILTIN(memset, "v*v*iz",      "f",     "string.h", ALL_LANGUAGES)
761LIBBUILTIN(strerror, "c*i",       "f",     "string.h", ALL_LANGUAGES)
762LIBBUILTIN(strlen, "zcC*",        "f",     "string.h", ALL_LANGUAGES)
763// C99 stdio.h
764LIBBUILTIN(printf, "icC*.",       "fp:0:", "stdio.h", ALL_LANGUAGES)
765LIBBUILTIN(fprintf, "iP*cC*.",    "fp:1:", "stdio.h", ALL_LANGUAGES)
766LIBBUILTIN(snprintf, "ic*zcC*.",  "fp:2:", "stdio.h", ALL_LANGUAGES)
767LIBBUILTIN(sprintf, "ic*cC*.",    "fp:1:", "stdio.h", ALL_LANGUAGES)
768LIBBUILTIN(vprintf, "icC*a",      "fP:0:", "stdio.h", ALL_LANGUAGES)
769LIBBUILTIN(vfprintf, "i.",        "fP:1:", "stdio.h", ALL_LANGUAGES)
770LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h", ALL_LANGUAGES)
771LIBBUILTIN(vsprintf, "ic*cC*a",   "fP:1:", "stdio.h", ALL_LANGUAGES)
772LIBBUILTIN(scanf, "icC*R.",       "fs:0:", "stdio.h", ALL_LANGUAGES)
773LIBBUILTIN(fscanf, "iP*RcC*R.",   "fs:1:", "stdio.h", ALL_LANGUAGES)
774LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:", "stdio.h", ALL_LANGUAGES)
775LIBBUILTIN(vscanf, "icC*Ra",      "fS:0:", "stdio.h", ALL_LANGUAGES)
776LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
777LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
778// C99 ctype.h
779LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
780LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
781LIBBUILTIN(isblank, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
782LIBBUILTIN(iscntrl, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
783LIBBUILTIN(isdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
784LIBBUILTIN(isgraph, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
785LIBBUILTIN(islower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
786LIBBUILTIN(isprint, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
787LIBBUILTIN(ispunct, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
788LIBBUILTIN(isspace, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
789LIBBUILTIN(isupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
790LIBBUILTIN(isxdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
791LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
792LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
793
794// C99
795// In some systems setjmp is a macro that expands to _setjmp. We undefine
796// it here to avoid having two identical LIBBUILTIN entries.
797#undef setjmp
798LIBBUILTIN(setjmp, "iJ",          "fj",    "setjmp.h", ALL_LANGUAGES)
799LIBBUILTIN(longjmp, "vJi",        "fr",    "setjmp.h", ALL_LANGUAGES)
800
801// Non-C library functions, active in GNU mode only.
802// Functions with (returns_twice) attribute (marked as "j") are still active in
803// all languages, because losing this attribute would result in miscompilation
804// when these functions are used in non-GNU mode. PR16138.
805LIBBUILTIN(alloca, "v*z",         "f",     "stdlib.h", ALL_GNU_LANGUAGES)
806// POSIX string.h
807LIBBUILTIN(stpcpy, "c*c*cC*",     "f",     "string.h", ALL_GNU_LANGUAGES)
808LIBBUILTIN(stpncpy, "c*c*cC*z",   "f",     "string.h", ALL_GNU_LANGUAGES)
809LIBBUILTIN(strdup, "c*cC*",       "f",     "string.h", ALL_GNU_LANGUAGES)
810LIBBUILTIN(strndup, "c*cC*z",     "f",     "string.h", ALL_GNU_LANGUAGES)
811// POSIX strings.h
812LIBBUILTIN(index, "c*cC*i",       "f",     "strings.h", ALL_GNU_LANGUAGES)
813LIBBUILTIN(rindex, "c*cC*i",      "f",     "strings.h", ALL_GNU_LANGUAGES)
814LIBBUILTIN(bzero, "vv*z",         "f",     "strings.h", ALL_GNU_LANGUAGES)
815// In some systems str[n]casejmp is a macro that expands to _str[n]icmp.
816// We undefine then here to avoid wrong name.
817#undef strcasecmp
818#undef strncasecmp
819LIBBUILTIN(strcasecmp, "icC*cC*", "f",     "strings.h", ALL_GNU_LANGUAGES)
820LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", ALL_GNU_LANGUAGES)
821// POSIX unistd.h
822LIBBUILTIN(_exit, "vi",           "fr",    "unistd.h", ALL_GNU_LANGUAGES)
823LIBBUILTIN(vfork, "p",            "fj",    "unistd.h", ALL_LANGUAGES)
824// POSIX setjmp.h
825
826LIBBUILTIN(_setjmp, "iJ",         "fj",   "setjmp.h", ALL_LANGUAGES)
827LIBBUILTIN(__sigsetjmp, "iSJi",   "fj",   "setjmp.h", ALL_LANGUAGES)
828LIBBUILTIN(sigsetjmp, "iSJi",     "fj",   "setjmp.h", ALL_LANGUAGES)
829LIBBUILTIN(setjmp_syscall, "iJ",  "fj",   "setjmp.h", ALL_LANGUAGES)
830LIBBUILTIN(savectx, "iJ",         "fj",   "setjmp.h", ALL_LANGUAGES)
831LIBBUILTIN(qsetjmp, "iJ",         "fj",   "setjmp.h", ALL_LANGUAGES)
832LIBBUILTIN(getcontext, "iK*",     "fj",   "setjmp.h", ALL_LANGUAGES)
833
834LIBBUILTIN(_longjmp, "vJi",       "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
835LIBBUILTIN(siglongjmp, "vSJi",    "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
836// non-standard but very common
837LIBBUILTIN(strlcpy, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
838LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
839//   id objc_msgSend(id, SEL, ...)
840LIBBUILTIN(objc_msgSend, "GGH.",   "f",     "objc/message.h", OBJC_LANG)
841// long double objc_msgSend_fpret(id self, SEL op, ...)
842LIBBUILTIN(objc_msgSend_fpret, "LdGH.", "f", "objc/message.h", OBJC_LANG)
843// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...)
844LIBBUILTIN(objc_msgSend_fp2ret, "XLdGH.", "f", "objc/message.h", OBJC_LANG)
845// void objc_msgSend_stret (id, SEL, ...)
846LIBBUILTIN(objc_msgSend_stret, "vGH.", "f", "objc/message.h", OBJC_LANG)
847// id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
848LIBBUILTIN(objc_msgSendSuper, "GM*H.", "f", "objc/message.h", OBJC_LANG)
849// void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...)
850LIBBUILTIN(objc_msgSendSuper_stret, "vM*H.", "f", "objc/message.h", OBJC_LANG)
851//   id objc_getClass(const char *name)
852LIBBUILTIN(objc_getClass, "GcC*",   "f",     "objc/runtime.h", OBJC_LANG)
853//   id objc_getMetaClass(const char *name)
854LIBBUILTIN(objc_getMetaClass, "GcC*",   "f", "objc/runtime.h", OBJC_LANG)
855// void objc_enumerationMutation(id)
856LIBBUILTIN(objc_enumerationMutation, "vG", "f", "objc/runtime.h", OBJC_LANG)
857
858// id objc_read_weak(id *location)
859LIBBUILTIN(objc_read_weak, "GG*", "f", "objc/objc-auto.h", OBJC_LANG)
860// id objc_assign_weak(id value, id *location)
861LIBBUILTIN(objc_assign_weak, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
862// id objc_assign_ivar(id value, id dest, ptrdiff_t offset)
863LIBBUILTIN(objc_assign_ivar, "GGGY", "f", "objc/objc-auto.h", OBJC_LANG)
864// id objc_assign_global(id val, id *dest)
865LIBBUILTIN(objc_assign_global, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
866// id objc_assign_strongCast(id val, id *dest
867LIBBUILTIN(objc_assign_strongCast, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
868
869// id objc_exception_extract(void *localExceptionData)
870LIBBUILTIN(objc_exception_extract, "Gv*", "f", "objc/objc-exception.h", OBJC_LANG)
871// void objc_exception_try_enter(void *localExceptionData)
872LIBBUILTIN(objc_exception_try_enter, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
873// void objc_exception_try_exit(void *localExceptionData)
874LIBBUILTIN(objc_exception_try_exit, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
875// int objc_exception_match(Class exceptionClass, id exception)
876LIBBUILTIN(objc_exception_match, "iGG", "f", "objc/objc-exception.h", OBJC_LANG)
877// void objc_exception_throw(id exception)
878LIBBUILTIN(objc_exception_throw, "vG", "f", "objc/objc-exception.h", OBJC_LANG)
879
880// int objc_sync_enter(id obj)
881LIBBUILTIN(objc_sync_enter, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
882// int objc_sync_exit(id obj)
883LIBBUILTIN(objc_sync_exit, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
884
885BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
886
887// void NSLog(NSString *fmt, ...)
888LIBBUILTIN(NSLog, "vG.", "fp:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
889// void NSLogv(NSString *fmt, va_list args)
890LIBBUILTIN(NSLogv, "vGa", "fP:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
891
892// Builtin math library functions
893LIBBUILTIN(atan2, "ddd", "fne", "math.h", ALL_LANGUAGES)
894LIBBUILTIN(atan2f, "fff", "fne", "math.h", ALL_LANGUAGES)
895LIBBUILTIN(atan2l, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
896
897LIBBUILTIN(abs, "ii", "fnc", "stdlib.h", ALL_LANGUAGES)
898LIBBUILTIN(labs, "LiLi", "fnc", "stdlib.h", ALL_LANGUAGES)
899LIBBUILTIN(llabs, "LLiLLi", "fnc", "stdlib.h", ALL_LANGUAGES)
900
901LIBBUILTIN(copysign, "ddd", "fnc", "math.h", ALL_LANGUAGES)
902LIBBUILTIN(copysignf, "fff", "fnc", "math.h", ALL_LANGUAGES)
903LIBBUILTIN(copysignl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
904
905LIBBUILTIN(fabs, "dd", "fnc", "math.h", ALL_LANGUAGES)
906LIBBUILTIN(fabsf, "ff", "fnc", "math.h", ALL_LANGUAGES)
907LIBBUILTIN(fabsl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
908
909LIBBUILTIN(fmod, "ddd", "fne", "math.h", ALL_LANGUAGES)
910LIBBUILTIN(fmodf, "fff", "fne", "math.h", ALL_LANGUAGES)
911LIBBUILTIN(fmodl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
912
913LIBBUILTIN(frexp, "ddi*", "fn", "math.h", ALL_LANGUAGES)
914LIBBUILTIN(frexpf, "ffi*", "fn", "math.h", ALL_LANGUAGES)
915LIBBUILTIN(frexpl, "LdLdi*", "fn", "math.h", ALL_LANGUAGES)
916
917LIBBUILTIN(ldexp, "ddi", "fne", "math.h", ALL_LANGUAGES)
918LIBBUILTIN(ldexpf, "ffi", "fne", "math.h", ALL_LANGUAGES)
919LIBBUILTIN(ldexpl, "LdLdi", "fne", "math.h", ALL_LANGUAGES)
920
921LIBBUILTIN(modf, "ddd*", "fn", "math.h", ALL_LANGUAGES)
922LIBBUILTIN(modff, "fff*", "fn", "math.h", ALL_LANGUAGES)
923LIBBUILTIN(modfl, "LdLdLd*", "fn", "math.h", ALL_LANGUAGES)
924
925LIBBUILTIN(nan,  "dcC*", "fnc", "math.h", ALL_LANGUAGES)
926LIBBUILTIN(nanf, "fcC*", "fnc", "math.h", ALL_LANGUAGES)
927LIBBUILTIN(nanl, "LdcC*", "fnc", "math.h", ALL_LANGUAGES)
928
929LIBBUILTIN(pow, "ddd", "fne", "math.h", ALL_LANGUAGES)
930LIBBUILTIN(powf, "fff", "fne", "math.h", ALL_LANGUAGES)
931LIBBUILTIN(powl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
932
933LIBBUILTIN(acos, "dd", "fne", "math.h", ALL_LANGUAGES)
934LIBBUILTIN(acosf, "ff", "fne", "math.h", ALL_LANGUAGES)
935LIBBUILTIN(acosl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
936
937LIBBUILTIN(acosh, "dd", "fne", "math.h", ALL_LANGUAGES)
938LIBBUILTIN(acoshf, "ff", "fne", "math.h", ALL_LANGUAGES)
939LIBBUILTIN(acoshl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
940
941LIBBUILTIN(asin, "dd", "fne", "math.h", ALL_LANGUAGES)
942LIBBUILTIN(asinf, "ff", "fne", "math.h", ALL_LANGUAGES)
943LIBBUILTIN(asinl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
944
945LIBBUILTIN(asinh, "dd", "fne", "math.h", ALL_LANGUAGES)
946LIBBUILTIN(asinhf, "ff", "fne", "math.h", ALL_LANGUAGES)
947LIBBUILTIN(asinhl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
948
949LIBBUILTIN(atan, "dd", "fne", "math.h", ALL_LANGUAGES)
950LIBBUILTIN(atanf, "ff", "fne", "math.h", ALL_LANGUAGES)
951LIBBUILTIN(atanl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
952
953LIBBUILTIN(atanh, "dd", "fne", "math.h", ALL_LANGUAGES)
954LIBBUILTIN(atanhf, "ff", "fne", "math.h", ALL_LANGUAGES)
955LIBBUILTIN(atanhl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
956
957LIBBUILTIN(cbrt, "dd", "fne", "math.h", ALL_LANGUAGES)
958LIBBUILTIN(cbrtf, "ff", "fne", "math.h", ALL_LANGUAGES)
959LIBBUILTIN(cbrtl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
960
961LIBBUILTIN(ceil, "dd", "fnc", "math.h", ALL_LANGUAGES)
962LIBBUILTIN(ceilf, "ff", "fnc", "math.h", ALL_LANGUAGES)
963LIBBUILTIN(ceill, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
964
965LIBBUILTIN(cos, "dd", "fne", "math.h", ALL_LANGUAGES)
966LIBBUILTIN(cosf, "ff", "fne", "math.h", ALL_LANGUAGES)
967LIBBUILTIN(cosl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
968
969LIBBUILTIN(cosh, "dd", "fne", "math.h", ALL_LANGUAGES)
970LIBBUILTIN(coshf, "ff", "fne", "math.h", ALL_LANGUAGES)
971LIBBUILTIN(coshl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
972
973LIBBUILTIN(erf, "dd", "fne", "math.h", ALL_LANGUAGES)
974LIBBUILTIN(erff, "ff", "fne", "math.h", ALL_LANGUAGES)
975LIBBUILTIN(erfl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
976
977LIBBUILTIN(erfc, "dd", "fne", "math.h", ALL_LANGUAGES)
978LIBBUILTIN(erfcf, "ff", "fne", "math.h", ALL_LANGUAGES)
979LIBBUILTIN(erfcl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
980
981LIBBUILTIN(exp, "dd", "fne", "math.h", ALL_LANGUAGES)
982LIBBUILTIN(expf, "ff", "fne", "math.h", ALL_LANGUAGES)
983LIBBUILTIN(expl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
984
985LIBBUILTIN(exp2, "dd", "fne", "math.h", ALL_LANGUAGES)
986LIBBUILTIN(exp2f, "ff", "fne", "math.h", ALL_LANGUAGES)
987LIBBUILTIN(exp2l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
988
989LIBBUILTIN(expm1, "dd", "fne", "math.h", ALL_LANGUAGES)
990LIBBUILTIN(expm1f, "ff", "fne", "math.h", ALL_LANGUAGES)
991LIBBUILTIN(expm1l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
992
993LIBBUILTIN(fdim, "ddd", "fne", "math.h", ALL_LANGUAGES)
994LIBBUILTIN(fdimf, "fff", "fne", "math.h", ALL_LANGUAGES)
995LIBBUILTIN(fdiml, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
996
997LIBBUILTIN(floor, "dd", "fnc", "math.h", ALL_LANGUAGES)
998LIBBUILTIN(floorf, "ff", "fnc", "math.h", ALL_LANGUAGES)
999LIBBUILTIN(floorl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
1000
1001LIBBUILTIN(fma, "dddd", "fne", "math.h", ALL_LANGUAGES)
1002LIBBUILTIN(fmaf, "ffff", "fne", "math.h", ALL_LANGUAGES)
1003LIBBUILTIN(fmal, "LdLdLdLd", "fne", "math.h", ALL_LANGUAGES)
1004
1005LIBBUILTIN(fmax, "ddd", "fnc", "math.h", ALL_LANGUAGES)
1006LIBBUILTIN(fmaxf, "fff", "fnc", "math.h", ALL_LANGUAGES)
1007LIBBUILTIN(fmaxl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
1008
1009LIBBUILTIN(fmin, "ddd", "fnc", "math.h", ALL_LANGUAGES)
1010LIBBUILTIN(fminf, "fff", "fnc", "math.h", ALL_LANGUAGES)
1011LIBBUILTIN(fminl, "LdLdLd", "fnc", "math.h", ALL_LANGUAGES)
1012
1013LIBBUILTIN(hypot, "ddd", "fne", "math.h", ALL_LANGUAGES)
1014LIBBUILTIN(hypotf, "fff", "fne", "math.h", ALL_LANGUAGES)
1015LIBBUILTIN(hypotl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
1016
1017LIBBUILTIN(ilogb, "id", "fne", "math.h", ALL_LANGUAGES)
1018LIBBUILTIN(ilogbf, "if", "fne", "math.h", ALL_LANGUAGES)
1019LIBBUILTIN(ilogbl, "iLd", "fne", "math.h", ALL_LANGUAGES)
1020
1021LIBBUILTIN(lgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
1022LIBBUILTIN(lgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
1023LIBBUILTIN(lgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1024
1025LIBBUILTIN(llrint, "LLid", "fne", "math.h", ALL_LANGUAGES)
1026LIBBUILTIN(llrintf, "LLif", "fne", "math.h", ALL_LANGUAGES)
1027LIBBUILTIN(llrintl, "LLiLd", "fne", "math.h", ALL_LANGUAGES)
1028
1029LIBBUILTIN(llround, "LLid", "fne", "math.h", ALL_LANGUAGES)
1030LIBBUILTIN(llroundf, "LLif", "fne", "math.h", ALL_LANGUAGES)
1031LIBBUILTIN(llroundl, "LLiLd", "fne", "math.h", ALL_LANGUAGES)
1032
1033LIBBUILTIN(log, "dd", "fne", "math.h", ALL_LANGUAGES)
1034LIBBUILTIN(logf, "ff", "fne", "math.h", ALL_LANGUAGES)
1035LIBBUILTIN(logl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1036
1037LIBBUILTIN(log10, "dd", "fne", "math.h", ALL_LANGUAGES)
1038LIBBUILTIN(log10f, "ff", "fne", "math.h", ALL_LANGUAGES)
1039LIBBUILTIN(log10l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1040
1041LIBBUILTIN(log1p, "dd", "fne", "math.h", ALL_LANGUAGES)
1042LIBBUILTIN(log1pf, "ff", "fne", "math.h", ALL_LANGUAGES)
1043LIBBUILTIN(log1pl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1044
1045LIBBUILTIN(log2, "dd", "fne", "math.h", ALL_LANGUAGES)
1046LIBBUILTIN(log2f, "ff", "fne", "math.h", ALL_LANGUAGES)
1047LIBBUILTIN(log2l, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1048
1049LIBBUILTIN(logb, "dd", "fne", "math.h", ALL_LANGUAGES)
1050LIBBUILTIN(logbf, "ff", "fne", "math.h", ALL_LANGUAGES)
1051LIBBUILTIN(logbl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1052
1053LIBBUILTIN(lrint, "Lid", "fne", "math.h", ALL_LANGUAGES)
1054LIBBUILTIN(lrintf, "Lif", "fne", "math.h", ALL_LANGUAGES)
1055LIBBUILTIN(lrintl, "LiLd", "fne", "math.h", ALL_LANGUAGES)
1056
1057LIBBUILTIN(lround, "Lid", "fne", "math.h", ALL_LANGUAGES)
1058LIBBUILTIN(lroundf, "Lif", "fne", "math.h", ALL_LANGUAGES)
1059LIBBUILTIN(lroundl, "LiLd", "fne", "math.h", ALL_LANGUAGES)
1060
1061LIBBUILTIN(nearbyint, "dd", "fnc", "math.h", ALL_LANGUAGES)
1062LIBBUILTIN(nearbyintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
1063LIBBUILTIN(nearbyintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
1064
1065LIBBUILTIN(nextafter, "ddd", "fne", "math.h", ALL_LANGUAGES)
1066LIBBUILTIN(nextafterf, "fff", "fne", "math.h", ALL_LANGUAGES)
1067LIBBUILTIN(nextafterl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
1068
1069LIBBUILTIN(nexttoward, "ddLd", "fne", "math.h", ALL_LANGUAGES)
1070LIBBUILTIN(nexttowardf, "ffLd", "fne", "math.h", ALL_LANGUAGES)
1071LIBBUILTIN(nexttowardl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
1072
1073LIBBUILTIN(remainder, "ddd", "fne", "math.h", ALL_LANGUAGES)
1074LIBBUILTIN(remainderf, "fff", "fne", "math.h", ALL_LANGUAGES)
1075LIBBUILTIN(remainderl, "LdLdLd", "fne", "math.h", ALL_LANGUAGES)
1076
1077LIBBUILTIN(rint, "dd", "fnc", "math.h", ALL_LANGUAGES)
1078LIBBUILTIN(rintf, "ff", "fnc", "math.h", ALL_LANGUAGES)
1079LIBBUILTIN(rintl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
1080
1081LIBBUILTIN(round, "dd", "fnc", "math.h", ALL_LANGUAGES)
1082LIBBUILTIN(roundf, "ff", "fnc", "math.h", ALL_LANGUAGES)
1083LIBBUILTIN(roundl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
1084
1085LIBBUILTIN(scalbln, "ddLi", "fne", "math.h", ALL_LANGUAGES)
1086LIBBUILTIN(scalblnf, "ffLi", "fne", "math.h", ALL_LANGUAGES)
1087LIBBUILTIN(scalblnl, "LdLdLi", "fne", "math.h", ALL_LANGUAGES)
1088
1089LIBBUILTIN(scalbn, "ddi", "fne", "math.h", ALL_LANGUAGES)
1090LIBBUILTIN(scalbnf, "ffi", "fne", "math.h", ALL_LANGUAGES)
1091LIBBUILTIN(scalbnl, "LdLdi", "fne", "math.h", ALL_LANGUAGES)
1092
1093LIBBUILTIN(sin, "dd", "fne", "math.h", ALL_LANGUAGES)
1094LIBBUILTIN(sinf, "ff", "fne", "math.h", ALL_LANGUAGES)
1095LIBBUILTIN(sinl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1096
1097LIBBUILTIN(sinh, "dd", "fne", "math.h", ALL_LANGUAGES)
1098LIBBUILTIN(sinhf, "ff", "fne", "math.h", ALL_LANGUAGES)
1099LIBBUILTIN(sinhl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1100
1101LIBBUILTIN(sqrt, "dd", "fne", "math.h", ALL_LANGUAGES)
1102LIBBUILTIN(sqrtf, "ff", "fne", "math.h", ALL_LANGUAGES)
1103LIBBUILTIN(sqrtl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1104
1105LIBBUILTIN(tan, "dd", "fne", "math.h", ALL_LANGUAGES)
1106LIBBUILTIN(tanf, "ff", "fne", "math.h", ALL_LANGUAGES)
1107LIBBUILTIN(tanl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1108
1109LIBBUILTIN(tanh, "dd", "fne", "math.h", ALL_LANGUAGES)
1110LIBBUILTIN(tanhf, "ff", "fne", "math.h", ALL_LANGUAGES)
1111LIBBUILTIN(tanhl, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1112
1113LIBBUILTIN(tgamma, "dd", "fne", "math.h", ALL_LANGUAGES)
1114LIBBUILTIN(tgammaf, "ff", "fne", "math.h", ALL_LANGUAGES)
1115LIBBUILTIN(tgammal, "LdLd", "fne", "math.h", ALL_LANGUAGES)
1116
1117LIBBUILTIN(trunc, "dd", "fnc", "math.h", ALL_LANGUAGES)
1118LIBBUILTIN(truncf, "ff", "fnc", "math.h", ALL_LANGUAGES)
1119LIBBUILTIN(truncl, "LdLd", "fnc", "math.h", ALL_LANGUAGES)
1120
1121LIBBUILTIN(cabs, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
1122LIBBUILTIN(cabsf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
1123LIBBUILTIN(cabsl, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1124
1125LIBBUILTIN(cacos, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1126LIBBUILTIN(cacosf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1127LIBBUILTIN(cacosl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1128
1129LIBBUILTIN(cacosh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1130LIBBUILTIN(cacoshf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1131LIBBUILTIN(cacoshl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1132
1133LIBBUILTIN(carg, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
1134LIBBUILTIN(cargf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
1135LIBBUILTIN(cargl, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1136
1137LIBBUILTIN(casin, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1138LIBBUILTIN(casinf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1139LIBBUILTIN(casinl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1140
1141LIBBUILTIN(casinh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1142LIBBUILTIN(casinhf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1143LIBBUILTIN(casinhl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1144
1145LIBBUILTIN(catan, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1146LIBBUILTIN(catanf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1147LIBBUILTIN(catanl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1148
1149LIBBUILTIN(catanh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1150LIBBUILTIN(catanhf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1151LIBBUILTIN(catanhl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1152
1153LIBBUILTIN(ccos, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1154LIBBUILTIN(ccosf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1155LIBBUILTIN(ccosl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1156
1157LIBBUILTIN(ccosh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1158LIBBUILTIN(ccoshf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1159LIBBUILTIN(ccoshl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1160
1161LIBBUILTIN(cexp, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1162LIBBUILTIN(cexpf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1163LIBBUILTIN(cexpl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1164
1165LIBBUILTIN(cimag, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
1166LIBBUILTIN(cimagf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
1167LIBBUILTIN(cimagl, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1168
1169LIBBUILTIN(conj, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1170LIBBUILTIN(conjf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1171LIBBUILTIN(conjl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1172
1173LIBBUILTIN(clog, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1174LIBBUILTIN(clogf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1175LIBBUILTIN(clogl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1176
1177LIBBUILTIN(cproj, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1178LIBBUILTIN(cprojf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1179LIBBUILTIN(cprojl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1180
1181LIBBUILTIN(cpow, "XdXdXd", "fnc", "complex.h", ALL_LANGUAGES)
1182LIBBUILTIN(cpowf, "XfXfXf", "fnc", "complex.h", ALL_LANGUAGES)
1183LIBBUILTIN(cpowl, "XLdXLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1184
1185LIBBUILTIN(creal, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
1186LIBBUILTIN(crealf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
1187LIBBUILTIN(creall, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1188
1189LIBBUILTIN(csin, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1190LIBBUILTIN(csinf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1191LIBBUILTIN(csinl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1192
1193LIBBUILTIN(csinh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1194LIBBUILTIN(csinhf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1195LIBBUILTIN(csinhl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1196
1197LIBBUILTIN(csqrt, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1198LIBBUILTIN(csqrtf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1199LIBBUILTIN(csqrtl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1200
1201LIBBUILTIN(ctan, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1202LIBBUILTIN(ctanf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1203LIBBUILTIN(ctanl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1204
1205LIBBUILTIN(ctanh, "XdXd", "fnc", "complex.h", ALL_LANGUAGES)
1206LIBBUILTIN(ctanhf, "XfXf", "fnc", "complex.h", ALL_LANGUAGES)
1207LIBBUILTIN(ctanhl, "XLdXLd", "fnc", "complex.h", ALL_LANGUAGES)
1208
1209// __sinpi and friends are OS X specific library functions, but otherwise much
1210// like the standard (non-complex) sin (etc).
1211LIBBUILTIN(__sinpi, "dd", "fne", "math.h", ALL_LANGUAGES)
1212LIBBUILTIN(__sinpif, "ff", "fne", "math.h", ALL_LANGUAGES)
1213
1214LIBBUILTIN(__cospi, "dd", "fne", "math.h", ALL_LANGUAGES)
1215LIBBUILTIN(__cospif, "ff", "fne", "math.h", ALL_LANGUAGES)
1216
1217LIBBUILTIN(__tanpi, "dd", "fne", "math.h", ALL_LANGUAGES)
1218LIBBUILTIN(__tanpif, "ff", "fne", "math.h", ALL_LANGUAGES)
1219
1220// Similarly, __exp10 is OS X only
1221LIBBUILTIN(__exp10, "dd", "fne", "math.h", ALL_LANGUAGES)
1222LIBBUILTIN(__exp10f, "ff", "fne", "math.h", ALL_LANGUAGES)
1223
1224// Blocks runtime Builtin math library functions
1225LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h", ALL_LANGUAGES)
1226LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h", ALL_LANGUAGES)
1227// FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
1228
1229// Annotation function
1230BUILTIN(__builtin_annotation, "v.", "tn")
1231
1232// Invariants
1233BUILTIN(__builtin_assume, "vb", "n")
1234
1235// Multiprecision Arithmetic Builtins.
1236BUILTIN(__builtin_addcb, "UcUcCUcCUcCUc*", "n")
1237BUILTIN(__builtin_addcs, "UsUsCUsCUsCUs*", "n")
1238BUILTIN(__builtin_addc, "UiUiCUiCUiCUi*", "n")
1239BUILTIN(__builtin_addcl, "ULiULiCULiCULiCULi*", "n")
1240BUILTIN(__builtin_addcll, "ULLiULLiCULLiCULLiCULLi*", "n")
1241BUILTIN(__builtin_subcb, "UcUcCUcCUcCUc*", "n")
1242BUILTIN(__builtin_subcs, "UsUsCUsCUsCUs*", "n")
1243BUILTIN(__builtin_subc, "UiUiCUiCUiCUi*", "n")
1244BUILTIN(__builtin_subcl, "ULiULiCULiCULiCULi*", "n")
1245BUILTIN(__builtin_subcll, "ULLiULLiCULLiCULLiCULLi*", "n")
1246
1247// Checked Arithmetic Builtins for Security.
1248BUILTIN(__builtin_add_overflow, "v.", "nt")
1249BUILTIN(__builtin_sub_overflow, "v.", "nt")
1250BUILTIN(__builtin_mul_overflow, "v.", "nt")
1251BUILTIN(__builtin_uadd_overflow, "bUiCUiCUi*", "n")
1252BUILTIN(__builtin_uaddl_overflow, "bULiCULiCULi*", "n")
1253BUILTIN(__builtin_uaddll_overflow, "bULLiCULLiCULLi*", "n")
1254BUILTIN(__builtin_usub_overflow, "bUiCUiCUi*", "n")
1255BUILTIN(__builtin_usubl_overflow, "bULiCULiCULi*", "n")
1256BUILTIN(__builtin_usubll_overflow, "bULLiCULLiCULLi*", "n")
1257BUILTIN(__builtin_umul_overflow, "bUiCUiCUi*", "n")
1258BUILTIN(__builtin_umull_overflow, "bULiCULiCULi*", "n")
1259BUILTIN(__builtin_umulll_overflow, "bULLiCULLiCULLi*", "n")
1260BUILTIN(__builtin_sadd_overflow, "bSiCSiCSi*", "n")
1261BUILTIN(__builtin_saddl_overflow, "bSLiCSLiCSLi*", "n")
1262BUILTIN(__builtin_saddll_overflow, "bSLLiCSLLiCSLLi*", "n")
1263BUILTIN(__builtin_ssub_overflow, "bSiCSiCSi*", "n")
1264BUILTIN(__builtin_ssubl_overflow, "bSLiCSLiCSLi*", "n")
1265BUILTIN(__builtin_ssubll_overflow, "bSLLiCSLLiCSLLi*", "n")
1266BUILTIN(__builtin_smul_overflow, "bSiCSiCSi*", "n")
1267BUILTIN(__builtin_smull_overflow, "bSLiCSLiCSLi*", "n")
1268BUILTIN(__builtin_smulll_overflow, "bSLLiCSLLiCSLLi*", "n")
1269
1270// Clang builtins (not available in GCC).
1271BUILTIN(__builtin_addressof, "v*v&", "nct")
1272BUILTIN(__builtin_operator_new, "v*z", "c")
1273BUILTIN(__builtin_operator_delete, "vv*", "n")
1274
1275// Safestack builtins
1276BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
1277BUILTIN(__builtin___get_unsafe_stack_ptr, "v*", "Fn")
1278
1279// Nontemporal loads/stores builtins
1280BUILTIN(__builtin_nontemporal_store, "v.", "t")
1281BUILTIN(__builtin_nontemporal_load, "v.", "t")
1282
1283// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
1284// We need the generic prototype, since the packet type could be anything.
1285LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
1286LANGBUILTIN(write_pipe, "i.", "tn", OCLC20_LANG)
1287
1288LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG)
1289LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG)
1290
1291LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG)
1292LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG)
1293
1294LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
1295LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
1296
1297LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
1298LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
1299
1300LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
1301LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
1302
1303LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
1304LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
1305
1306LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG)
1307LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG)
1308
1309// OpenCL v2.0 s6.13.17 - Enqueue kernel functions.
1310// Custom builtin check allows to perform special check of passed block arguments.
1311LANGBUILTIN(enqueue_kernel, "i.", "tn", OCLC20_LANG)
1312LANGBUILTIN(get_kernel_work_group_size, "i.", "tn", OCLC20_LANG)
1313LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "i.", "tn", OCLC20_LANG)
1314
1315// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
1316LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
1317LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
1318LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)
1319
1320#undef BUILTIN
1321#undef LIBBUILTIN
1322#undef LANGBUILTIN
1323