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//  f -> float
29//  d -> double
30//  z -> size_t
31//  F -> constant CFString
32//  G -> id
33//  H -> SEL
34//  M -> struct objc_super
35//  a -> __builtin_va_list
36//  A -> "reference" to __builtin_va_list
37//  V -> Vector, followed by the number of elements and the base type.
38//  E -> ext_vector, followed by the number of elements and the base type.
39//  X -> _Complex, followed by the base type.
40//  Y -> ptrdiff_t
41//  P -> FILE
42//  J -> jmp_buf
43//  SJ -> sigjmp_buf
44//  K -> ucontext_t
45//  p -> pid_t
46//  . -> "...".  This may only occur at the end of the function list.
47//
48// Types may be prefixed with the following modifiers:
49//  L   -> long (e.g. Li for 'long int')
50//  LL  -> long long
51//  LLL -> __int128_t (e.g. LLLi)
52//  S   -> signed
53//  U   -> unsigned
54//  I   -> Required to constant fold to an integer constant expression.
55//
56// Types may be postfixed with the following modifiers:
57// * -> pointer (optionally followed by an address space number)
58// & -> reference (optionally followed by an address space number)
59// C -> const
60// D -> volatile
61
62// The third value provided to the macro specifies information about attributes
63// of the function.  These must be kept in sync with the predicates in the
64// Builtin::Context class.  Currently we have:
65//  n -> nothrow
66//  r -> noreturn
67//  c -> const
68//  t -> signature is meaningless, use custom typechecking
69//  F -> this is a libc/libm function with a '__builtin_' prefix added.
70//  f -> this is a libc/libm function without the '__builtin_' prefix. It can
71//       be followed by ':headername:' to state which header this function
72//       comes from.
73//  i -> this is a runtime library implemented function without the
74//       '__builtin_' prefix. It will be implemented in compiter-rt or libgcc.
75//  p:N: -> this is a printf-like function whose Nth argument is the format
76//          string.
77//  P:N: -> similar to the p:N: attribute, but the function is like vprintf
78//          in that it accepts its arguments as a va_list rather than
79//          through an ellipsis
80//  s:N: -> this is a scanf-like function whose Nth argument is the format
81//          string.
82//  S:N: -> similar to the s:N: attribute, but the function is like vscanf
83//          in that it accepts its arguments as a va_list rather than
84//          through an ellipsis
85//  e -> const, but only when -fmath-errno=0
86//  j -> returns_twice (like setjmp)
87//  u -> arguments are not evaluated for their side-effects
88//  FIXME: gcc has nonnull
89
90#if defined(BUILTIN) && !defined(LIBBUILTIN)
91#  define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
92#endif
93
94// Standard libc/libm functions:
95BUILTIN(__builtin_atan2 , "ddd"  , "Fnc")
96BUILTIN(__builtin_atan2f, "fff"  , "Fnc")
97BUILTIN(__builtin_atan2l, "LdLdLd", "Fnc")
98BUILTIN(__builtin_abs  , "ii"  , "ncF")
99BUILTIN(__builtin_copysign, "ddd", "ncF")
100BUILTIN(__builtin_copysignf, "fff", "ncF")
101BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
102BUILTIN(__builtin_fabs , "dd"  , "ncF")
103BUILTIN(__builtin_fabsf, "ff"  , "ncF")
104BUILTIN(__builtin_fabsl, "LdLd", "ncF")
105BUILTIN(__builtin_fmod , "ddd"  , "Fnc")
106BUILTIN(__builtin_fmodf, "fff"  , "Fnc")
107BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc")
108BUILTIN(__builtin_frexp , "ddi*"  , "Fn")
109BUILTIN(__builtin_frexpf, "ffi*"  , "Fn")
110BUILTIN(__builtin_frexpl, "LdLdi*", "Fn")
111BUILTIN(__builtin_huge_val, "d", "nc")
112BUILTIN(__builtin_huge_valf, "f", "nc")
113BUILTIN(__builtin_huge_vall, "Ld", "nc")
114BUILTIN(__builtin_inf  , "d"   , "nc")
115BUILTIN(__builtin_inff , "f"   , "nc")
116BUILTIN(__builtin_infl , "Ld"  , "nc")
117BUILTIN(__builtin_labs , "LiLi"  , "Fnc")
118BUILTIN(__builtin_llabs, "LLiLLi", "Fnc")
119BUILTIN(__builtin_ldexp , "ddi"  , "Fnc")
120BUILTIN(__builtin_ldexpf, "ffi"  , "Fnc")
121BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc")
122BUILTIN(__builtin_modf , "ddd*"  , "Fn")
123BUILTIN(__builtin_modff, "fff*"  , "Fn")
124BUILTIN(__builtin_modfl, "LdLdLd*", "Fn")
125BUILTIN(__builtin_nan,  "dcC*" , "ncF")
126BUILTIN(__builtin_nanf, "fcC*" , "ncF")
127BUILTIN(__builtin_nanl, "LdcC*", "ncF")
128BUILTIN(__builtin_nans,  "dcC*" , "ncF")
129BUILTIN(__builtin_nansf, "fcC*" , "ncF")
130BUILTIN(__builtin_nansl, "LdcC*", "ncF")
131BUILTIN(__builtin_powi , "ddi"  , "Fnc")
132BUILTIN(__builtin_powif, "ffi"  , "Fnc")
133BUILTIN(__builtin_powil, "LdLdi", "Fnc")
134BUILTIN(__builtin_pow , "ddd"  , "Fnc")
135BUILTIN(__builtin_powf, "fff"  , "Fnc")
136BUILTIN(__builtin_powl, "LdLdLd", "Fnc")
137
138// Standard unary libc/libm functions with double/float/long double variants:
139BUILTIN(__builtin_acos , "dd"  , "Fnc")
140BUILTIN(__builtin_acosf, "ff"  , "Fnc")
141BUILTIN(__builtin_acosl, "LdLd", "Fnc")
142BUILTIN(__builtin_acosh , "dd"  , "Fnc")
143BUILTIN(__builtin_acoshf, "ff"  , "Fnc")
144BUILTIN(__builtin_acoshl, "LdLd", "Fnc")
145BUILTIN(__builtin_asin , "dd"  , "Fnc")
146BUILTIN(__builtin_asinf, "ff"  , "Fnc")
147BUILTIN(__builtin_asinl, "LdLd", "Fnc")
148BUILTIN(__builtin_asinh , "dd"  , "Fnc")
149BUILTIN(__builtin_asinhf, "ff"  , "Fnc")
150BUILTIN(__builtin_asinhl, "LdLd", "Fnc")
151BUILTIN(__builtin_atan , "dd"  , "Fnc")
152BUILTIN(__builtin_atanf, "ff"  , "Fnc")
153BUILTIN(__builtin_atanl, "LdLd", "Fnc")
154BUILTIN(__builtin_atanh , "dd", "Fnc")
155BUILTIN(__builtin_atanhf, "ff", "Fnc")
156BUILTIN(__builtin_atanhl, "LdLd", "Fnc")
157BUILTIN(__builtin_cbrt , "dd", "Fnc")
158BUILTIN(__builtin_cbrtf, "ff", "Fnc")
159BUILTIN(__builtin_cbrtl, "LdLd", "Fnc")
160BUILTIN(__builtin_ceil , "dd"  , "Fnc")
161BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
162BUILTIN(__builtin_ceill, "LdLd", "Fnc")
163BUILTIN(__builtin_cos , "dd"  , "Fnc")
164BUILTIN(__builtin_cosf, "ff"  , "Fnc")
165BUILTIN(__builtin_cosh , "dd"  , "Fnc")
166BUILTIN(__builtin_coshf, "ff"  , "Fnc")
167BUILTIN(__builtin_coshl, "LdLd", "Fnc")
168BUILTIN(__builtin_cosl, "LdLd", "Fnc")
169BUILTIN(__builtin_erf , "dd", "Fnc")
170BUILTIN(__builtin_erff, "ff", "Fnc")
171BUILTIN(__builtin_erfl, "LdLd", "Fnc")
172BUILTIN(__builtin_erfc , "dd", "Fnc")
173BUILTIN(__builtin_erfcf, "ff", "Fnc")
174BUILTIN(__builtin_erfcl, "LdLd", "Fnc")
175BUILTIN(__builtin_exp , "dd"  , "Fnc")
176BUILTIN(__builtin_expf, "ff"  , "Fnc")
177BUILTIN(__builtin_expl, "LdLd", "Fnc")
178BUILTIN(__builtin_exp2 , "dd"  , "Fnc")
179BUILTIN(__builtin_exp2f, "ff"  , "Fnc")
180BUILTIN(__builtin_exp2l, "LdLd", "Fnc")
181BUILTIN(__builtin_expm1 , "dd", "Fnc")
182BUILTIN(__builtin_expm1f, "ff", "Fnc")
183BUILTIN(__builtin_expm1l, "LdLd", "Fnc")
184BUILTIN(__builtin_fdim, "ddd", "Fnc")
185BUILTIN(__builtin_fdimf, "fff", "Fnc")
186BUILTIN(__builtin_fdiml, "LdLdLd", "Fnc")
187BUILTIN(__builtin_floor , "dd"  , "Fnc")
188BUILTIN(__builtin_floorf, "ff"  , "Fnc")
189BUILTIN(__builtin_floorl, "LdLd", "Fnc")
190BUILTIN(__builtin_fma, "dddd", "Fnc")
191BUILTIN(__builtin_fmaf, "ffff", "Fnc")
192BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
193BUILTIN(__builtin_fmax, "ddd", "Fnc")
194BUILTIN(__builtin_fmaxf, "fff", "Fnc")
195BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
196BUILTIN(__builtin_fmin, "ddd", "Fnc")
197BUILTIN(__builtin_fminf, "fff", "Fnc")
198BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
199BUILTIN(__builtin_hypot , "ddd"  , "Fnc")
200BUILTIN(__builtin_hypotf, "fff"  , "Fnc")
201BUILTIN(__builtin_hypotl, "LdLdLd", "Fnc")
202BUILTIN(__builtin_ilogb , "id", "Fnc")
203BUILTIN(__builtin_ilogbf, "if", "Fnc")
204BUILTIN(__builtin_ilogbl, "iLd", "Fnc")
205BUILTIN(__builtin_lgamma , "dd", "Fnc")
206BUILTIN(__builtin_lgammaf, "ff", "Fnc")
207BUILTIN(__builtin_lgammal, "LdLd", "Fnc")
208BUILTIN(__builtin_llrint, "LLid", "Fnc")
209BUILTIN(__builtin_llrintf, "LLif", "Fnc")
210BUILTIN(__builtin_llrintl, "LLiLd", "Fnc")
211BUILTIN(__builtin_llround , "LLid", "Fnc")
212BUILTIN(__builtin_llroundf, "LLif", "Fnc")
213BUILTIN(__builtin_llroundl, "LLiLd", "Fnc")
214BUILTIN(__builtin_log , "dd"  , "Fnc")
215BUILTIN(__builtin_log10 , "dd"  , "Fnc")
216BUILTIN(__builtin_log10f, "ff"  , "Fnc")
217BUILTIN(__builtin_log10l, "LdLd", "Fnc")
218BUILTIN(__builtin_log1p , "dd"  , "Fnc")
219BUILTIN(__builtin_log1pf, "ff"  , "Fnc")
220BUILTIN(__builtin_log1pl, "LdLd", "Fnc")
221BUILTIN(__builtin_log2, "dd"  , "Fnc")
222BUILTIN(__builtin_log2f, "ff"  , "Fnc")
223BUILTIN(__builtin_log2l, "LdLd"  , "Fnc")
224BUILTIN(__builtin_logb , "dd", "Fnc")
225BUILTIN(__builtin_logbf, "ff", "Fnc")
226BUILTIN(__builtin_logbl, "LdLd", "Fnc")
227BUILTIN(__builtin_logf, "ff"  , "Fnc")
228BUILTIN(__builtin_logl, "LdLd", "Fnc")
229BUILTIN(__builtin_lrint , "Lid", "Fnc")
230BUILTIN(__builtin_lrintf, "Lif", "Fnc")
231BUILTIN(__builtin_lrintl, "LiLd", "Fnc")
232BUILTIN(__builtin_lround , "Lid", "Fnc")
233BUILTIN(__builtin_lroundf, "Lif", "Fnc")
234BUILTIN(__builtin_lroundl, "LiLd", "Fnc")
235BUILTIN(__builtin_nearbyint , "dd", "Fnc")
236BUILTIN(__builtin_nearbyintf, "ff", "Fnc")
237BUILTIN(__builtin_nearbyintl, "LdLd", "Fnc")
238BUILTIN(__builtin_nextafter , "ddd", "Fnc")
239BUILTIN(__builtin_nextafterf, "fff", "Fnc")
240BUILTIN(__builtin_nextafterl, "LdLdLd", "Fnc")
241BUILTIN(__builtin_nexttoward , "ddd", "Fnc")
242BUILTIN(__builtin_nexttowardf, "fff", "Fnc")
243BUILTIN(__builtin_nexttowardl, "LdLdLd", "Fnc")
244BUILTIN(__builtin_remainder , "ddd", "Fnc")
245BUILTIN(__builtin_remainderf, "fff", "Fnc")
246BUILTIN(__builtin_remainderl, "LdLdLd", "Fnc")
247BUILTIN(__builtin_remquo , "dddi*", "Fn")
248BUILTIN(__builtin_remquof, "fffi*", "Fn")
249BUILTIN(__builtin_remquol, "LdLdLdi*", "Fn")
250BUILTIN(__builtin_rint , "dd", "Fnc")
251BUILTIN(__builtin_rintf, "ff", "Fnc")
252BUILTIN(__builtin_rintl, "LdLd", "Fnc")
253BUILTIN(__builtin_round, "dd"  , "Fnc")
254BUILTIN(__builtin_roundf, "ff"  , "Fnc")
255BUILTIN(__builtin_roundl, "LdLd"  , "Fnc")
256BUILTIN(__builtin_scalbln , "ddLi", "Fnc")
257BUILTIN(__builtin_scalblnf, "ffLi", "Fnc")
258BUILTIN(__builtin_scalblnl, "LdLdLi", "Fnc")
259BUILTIN(__builtin_scalbn , "ddi", "Fnc")
260BUILTIN(__builtin_scalbnf, "ffi", "Fnc")
261BUILTIN(__builtin_scalbnl, "LdLdi", "Fnc")
262BUILTIN(__builtin_sin , "dd"  , "Fnc")
263BUILTIN(__builtin_sinf, "ff"  , "Fnc")
264BUILTIN(__builtin_sinh , "dd"  , "Fnc")
265BUILTIN(__builtin_sinhf, "ff"  , "Fnc")
266BUILTIN(__builtin_sinhl, "LdLd", "Fnc")
267BUILTIN(__builtin_sinl, "LdLd", "Fnc")
268BUILTIN(__builtin_sqrt , "dd"  , "Fnc")
269BUILTIN(__builtin_sqrtf, "ff"  , "Fnc")
270BUILTIN(__builtin_sqrtl, "LdLd", "Fnc")
271BUILTIN(__builtin_tan , "dd"  , "Fnc")
272BUILTIN(__builtin_tanf, "ff"  , "Fnc")
273BUILTIN(__builtin_tanh , "dd"  , "Fnc")
274BUILTIN(__builtin_tanhf, "ff"  , "Fnc")
275BUILTIN(__builtin_tanhl, "LdLd", "Fnc")
276BUILTIN(__builtin_tanl, "LdLd", "Fnc")
277BUILTIN(__builtin_tgamma , "dd", "Fnc")
278BUILTIN(__builtin_tgammaf, "ff", "Fnc")
279BUILTIN(__builtin_tgammal, "LdLd", "Fnc")
280BUILTIN(__builtin_trunc , "dd", "Fnc")
281BUILTIN(__builtin_truncf, "ff", "Fnc")
282BUILTIN(__builtin_truncl, "LdLd", "Fnc")
283
284// C99 complex builtins
285BUILTIN(__builtin_cabs, "dXd", "Fnc")
286BUILTIN(__builtin_cabsf, "fXf", "Fnc")
287BUILTIN(__builtin_cabsl, "LdXLd", "Fnc")
288BUILTIN(__builtin_cacos, "XdXd", "Fnc")
289BUILTIN(__builtin_cacosf, "XfXf", "Fnc")
290BUILTIN(__builtin_cacosh, "XdXd", "Fnc")
291BUILTIN(__builtin_cacoshf, "XfXf", "Fnc")
292BUILTIN(__builtin_cacoshl, "XLdXLd", "Fnc")
293BUILTIN(__builtin_cacosl, "XLdXLd", "Fnc")
294BUILTIN(__builtin_carg, "dXd", "Fnc")
295BUILTIN(__builtin_cargf, "fXf", "Fnc")
296BUILTIN(__builtin_cargl, "LdXLd", "Fnc")
297BUILTIN(__builtin_casin, "XdXd", "Fnc")
298BUILTIN(__builtin_casinf, "XfXf", "Fnc")
299BUILTIN(__builtin_casinh, "XdXd", "Fnc")
300BUILTIN(__builtin_casinhf, "XfXf", "Fnc")
301BUILTIN(__builtin_casinhl, "XLdXLd", "Fnc")
302BUILTIN(__builtin_casinl, "XLdXLd", "Fnc")
303BUILTIN(__builtin_catan, "XdXd", "Fnc")
304BUILTIN(__builtin_catanf, "XfXf", "Fnc")
305BUILTIN(__builtin_catanh, "XdXd", "Fnc")
306BUILTIN(__builtin_catanhf, "XfXf", "Fnc")
307BUILTIN(__builtin_catanhl, "XLdXLd", "Fnc")
308BUILTIN(__builtin_catanl, "XLdXLd", "Fnc")
309BUILTIN(__builtin_ccos, "XdXd", "Fnc")
310BUILTIN(__builtin_ccosf, "XfXf", "Fnc")
311BUILTIN(__builtin_ccosl, "XLdXLd", "Fnc")
312BUILTIN(__builtin_ccosh, "XdXd", "Fnc")
313BUILTIN(__builtin_ccoshf, "XfXf", "Fnc")
314BUILTIN(__builtin_ccoshl, "XLdXLd", "Fnc")
315BUILTIN(__builtin_cexp, "XdXd", "Fnc")
316BUILTIN(__builtin_cexpf, "XfXf", "Fnc")
317BUILTIN(__builtin_cexpl, "XLdXLd", "Fnc")
318BUILTIN(__builtin_cimag, "dXd", "Fnc")
319BUILTIN(__builtin_cimagf, "fXf", "Fnc")
320BUILTIN(__builtin_cimagl, "LdXLd", "Fnc")
321BUILTIN(__builtin_conj, "XdXd", "Fnc")
322BUILTIN(__builtin_conjf, "XfXf", "Fnc")
323BUILTIN(__builtin_conjl, "XLdXLd", "Fnc")
324BUILTIN(__builtin_clog, "XdXd", "Fnc")
325BUILTIN(__builtin_clogf, "XfXf", "Fnc")
326BUILTIN(__builtin_clogl, "XLdXLd", "Fnc")
327BUILTIN(__builtin_cproj, "XdXd", "Fnc")
328BUILTIN(__builtin_cprojf, "XfXf", "Fnc")
329BUILTIN(__builtin_cprojl, "XLdXLd", "Fnc")
330BUILTIN(__builtin_cpow, "XdXdXd", "Fnc")
331BUILTIN(__builtin_cpowf, "XfXfXf", "Fnc")
332BUILTIN(__builtin_cpowl, "XLdXLdXLd", "Fnc")
333BUILTIN(__builtin_creal, "dXd", "Fnc")
334BUILTIN(__builtin_crealf, "fXf", "Fnc")
335BUILTIN(__builtin_creall, "LdXLd", "Fnc")
336BUILTIN(__builtin_csin, "XdXd", "Fnc")
337BUILTIN(__builtin_csinf, "XfXf", "Fnc")
338BUILTIN(__builtin_csinl, "XLdXLd", "Fnc")
339BUILTIN(__builtin_csinh, "XdXd", "Fnc")
340BUILTIN(__builtin_csinhf, "XfXf", "Fnc")
341BUILTIN(__builtin_csinhl, "XLdXLd", "Fnc")
342BUILTIN(__builtin_csqrt, "XdXd", "Fnc")
343BUILTIN(__builtin_csqrtf, "XfXf", "Fnc")
344BUILTIN(__builtin_csqrtl, "XLdXLd", "Fnc")
345BUILTIN(__builtin_ctan, "XdXd", "Fnc")
346BUILTIN(__builtin_ctanf, "XfXf", "Fnc")
347BUILTIN(__builtin_ctanl, "XLdXLd", "Fnc")
348BUILTIN(__builtin_ctanh, "XdXd", "Fnc")
349BUILTIN(__builtin_ctanhf, "XfXf", "Fnc")
350BUILTIN(__builtin_ctanhl, "XLdXLd", "Fnc")
351
352// FP Comparisons.
353BUILTIN(__builtin_isgreater     , "i.", "nc")
354BUILTIN(__builtin_isgreaterequal, "i.", "nc")
355BUILTIN(__builtin_isless        , "i.", "nc")
356BUILTIN(__builtin_islessequal   , "i.", "nc")
357BUILTIN(__builtin_islessgreater , "i.", "nc")
358BUILTIN(__builtin_isunordered   , "i.", "nc")
359
360// Unary FP classification
361BUILTIN(__builtin_fpclassify, "iiiii.", "nc")
362BUILTIN(__builtin_isfinite,   "i.", "nc")
363BUILTIN(__builtin_isinf,      "i.", "nc")
364BUILTIN(__builtin_isinf_sign, "i.", "nc")
365BUILTIN(__builtin_isnan,      "i.", "nc")
366BUILTIN(__builtin_isnormal,   "i.", "nc")
367
368// FP signbit builtins
369BUILTIN(__builtin_signbit, "id", "nc")
370BUILTIN(__builtin_signbitf, "if", "nc")
371BUILTIN(__builtin_signbitl, "iLd", "nc")
372
373// Builtins for arithmetic.
374BUILTIN(__builtin_clzs , "iUs"  , "nc")
375BUILTIN(__builtin_clz  , "iUi"  , "nc")
376BUILTIN(__builtin_clzl , "iULi" , "nc")
377BUILTIN(__builtin_clzll, "iULLi", "nc")
378// TODO: int clzimax(uintmax_t)
379BUILTIN(__builtin_ctzs , "iUs"  , "nc")
380BUILTIN(__builtin_ctz  , "iUi"  , "nc")
381BUILTIN(__builtin_ctzl , "iULi" , "nc")
382BUILTIN(__builtin_ctzll, "iULLi", "nc")
383// TODO: int ctzimax(uintmax_t)
384BUILTIN(__builtin_ffs  , "ii"  , "nc")
385BUILTIN(__builtin_ffsl , "iLi" , "nc")
386BUILTIN(__builtin_ffsll, "iLLi", "nc")
387BUILTIN(__builtin_parity  , "iUi"  , "nc")
388BUILTIN(__builtin_parityl , "iULi" , "nc")
389BUILTIN(__builtin_parityll, "iULLi", "nc")
390BUILTIN(__builtin_popcount  , "iUi"  , "nc")
391BUILTIN(__builtin_popcountl , "iULi" , "nc")
392BUILTIN(__builtin_popcountll, "iULLi", "nc")
393
394// FIXME: These type signatures are not correct for targets with int != 32-bits
395// or with ULL != 64-bits.
396BUILTIN(__builtin_bswap16, "UsUs", "nc")
397BUILTIN(__builtin_bswap32, "UiUi", "nc")
398BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
399
400// Random GCC builtins
401BUILTIN(__builtin_constant_p, "i.", "nctu")
402BUILTIN(__builtin_classify_type, "i.", "nctu")
403BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
404BUILTIN(__builtin___NSStringMakeConstantString, "FC*cC*", "nc")
405BUILTIN(__builtin_va_start, "vA.", "nt")
406BUILTIN(__builtin_va_end, "vA", "n")
407BUILTIN(__builtin_va_copy, "vAA", "n")
408BUILTIN(__builtin_stdarg_start, "vA.", "n")
409BUILTIN(__builtin_bcmp, "iv*v*z", "n")
410BUILTIN(__builtin_bcopy, "vv*v*z", "n")
411BUILTIN(__builtin_bzero, "vv*z", "nF")
412BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
413BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
414BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
415BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
416BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
417BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
418BUILTIN(__builtin_memset, "v*v*iz", "nF")
419BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
420BUILTIN(__builtin_stpcpy, "c*c*cC*", "nF")
421BUILTIN(__builtin_stpncpy, "c*c*cC*z", "nF")
422BUILTIN(__builtin_strcasecmp, "icC*cC*", "nF")
423BUILTIN(__builtin_strcat, "c*c*cC*", "nF")
424BUILTIN(__builtin_strchr, "c*cC*i", "nF")
425BUILTIN(__builtin_strcmp, "icC*cC*", "nF")
426BUILTIN(__builtin_strcpy, "c*c*cC*", "nF")
427BUILTIN(__builtin_strcspn, "zcC*cC*", "nF")
428BUILTIN(__builtin_strdup, "c*cC*", "nF")
429BUILTIN(__builtin_strlen, "zcC*", "nF")
430BUILTIN(__builtin_strncasecmp, "icC*cC*z", "nF")
431BUILTIN(__builtin_strncat, "c*c*cC*z", "nF")
432BUILTIN(__builtin_strncmp, "icC*cC*z", "nF")
433BUILTIN(__builtin_strncpy, "c*c*cC*z", "nF")
434BUILTIN(__builtin_strndup, "c*cC*z", "nF")
435BUILTIN(__builtin_strpbrk, "c*cC*cC*", "nF")
436BUILTIN(__builtin_strrchr, "c*cC*i", "nF")
437BUILTIN(__builtin_strspn, "zcC*cC*", "nF")
438BUILTIN(__builtin_strstr, "c*cC*cC*", "nF")
439BUILTIN(__builtin_return_address, "v*IUi", "n")
440BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
441BUILTIN(__builtin_frame_address, "v*IUi", "n")
442BUILTIN(__builtin_flt_rounds, "i", "nc")
443BUILTIN(__builtin_setjmp, "iv**", "j")
444BUILTIN(__builtin_longjmp, "vv**i", "r")
445BUILTIN(__builtin_unwind_init, "v", "")
446BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
447BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
448BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
449BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
450
451// GCC exception builtins
452BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!
453BUILTIN(__builtin_frob_return_addr, "v*v*", "n")
454BUILTIN(__builtin_dwarf_cfa, "v*", "n")
455BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")
456BUILTIN(__builtin_dwarf_sp_column, "Ui", "n")
457BUILTIN(__builtin_extend_pointer, "ULLiv*", "n") // _Unwind_Word == uint64_t
458
459// GCC Object size checking builtins
460BUILTIN(__builtin_object_size, "zvC*i", "nu")
461BUILTIN(__builtin___memcpy_chk, "v*v*vC*zz", "nF")
462BUILTIN(__builtin___memccpy_chk, "v*v*vC*izz", "nF")
463BUILTIN(__builtin___memmove_chk, "v*v*vC*zz", "nF")
464BUILTIN(__builtin___mempcpy_chk, "v*v*vC*zz", "nF")
465BUILTIN(__builtin___memset_chk, "v*v*izz", "nF")
466BUILTIN(__builtin___stpcpy_chk, "c*c*cC*z", "nF")
467BUILTIN(__builtin___strcat_chk, "c*c*cC*z", "nF")
468BUILTIN(__builtin___strcpy_chk, "c*c*cC*z", "nF")
469BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
470BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
471BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
472BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
473BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
474BUILTIN(__builtin___snprintf_chk, "ic*zizcC*.", "Fp:4:")
475BUILTIN(__builtin___sprintf_chk, "ic*izcC*.", "Fp:3:")
476BUILTIN(__builtin___vsnprintf_chk, "ic*zizcC*a", "FP:4:")
477BUILTIN(__builtin___vsprintf_chk, "ic*izcC*a", "FP:3:")
478BUILTIN(__builtin___fprintf_chk, "iP*icC*.", "Fp:2:")
479BUILTIN(__builtin___printf_chk, "iicC*.", "Fp:1:")
480BUILTIN(__builtin___vfprintf_chk, "iP*icC*a", "FP:2:")
481BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
482
483BUILTIN(__builtin_expect, "LiLiLi"   , "nc")
484BUILTIN(__builtin_prefetch, "vvC*.", "nc")
485BUILTIN(__builtin_readcyclecounter, "ULLi", "n")
486BUILTIN(__builtin_trap, "v", "nr")
487BUILTIN(__builtin_debugtrap, "v", "n")
488BUILTIN(__builtin_unreachable, "v", "nr")
489BUILTIN(__builtin_shufflevector, "v."   , "nc")
490BUILTIN(__builtin_alloca, "v*z"   , "n")
491
492// "Overloaded" Atomic operator builtins.  These are overloaded to support data
493// types of i8, i16, i32, i64, and i128.  The front-end sees calls to the
494// non-suffixed version of these (which has a bogus type) and transforms them to
495// the right overloaded version in Sema (plus casts).
496
497// FIXME: These assume that char -> i8, short -> i16, int -> i32,
498// long long -> i64.
499
500BUILTIN(__sync_fetch_and_add, "v.", "t")
501BUILTIN(__sync_fetch_and_add_1, "ccD*c.", "nt")
502BUILTIN(__sync_fetch_and_add_2, "ssD*s.", "nt")
503BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "nt")
504BUILTIN(__sync_fetch_and_add_8, "LLiLLiD*LLi.", "nt")
505BUILTIN(__sync_fetch_and_add_16, "LLLiLLLiD*LLLi.", "nt")
506
507BUILTIN(__sync_fetch_and_sub, "v.", "t")
508BUILTIN(__sync_fetch_and_sub_1, "ccD*c.", "nt")
509BUILTIN(__sync_fetch_and_sub_2, "ssD*s.", "nt")
510BUILTIN(__sync_fetch_and_sub_4, "iiD*i.", "nt")
511BUILTIN(__sync_fetch_and_sub_8, "LLiLLiD*LLi.", "nt")
512BUILTIN(__sync_fetch_and_sub_16, "LLLiLLLiD*LLLi.", "nt")
513
514BUILTIN(__sync_fetch_and_or, "v.", "t")
515BUILTIN(__sync_fetch_and_or_1, "ccD*c.", "nt")
516BUILTIN(__sync_fetch_and_or_2, "ssD*s.", "nt")
517BUILTIN(__sync_fetch_and_or_4, "iiD*i.", "nt")
518BUILTIN(__sync_fetch_and_or_8, "LLiLLiD*LLi.", "nt")
519BUILTIN(__sync_fetch_and_or_16, "LLLiLLLiD*LLLi.", "nt")
520
521BUILTIN(__sync_fetch_and_and, "v.", "t")
522BUILTIN(__sync_fetch_and_and_1, "ccD*c.", "tn")
523BUILTIN(__sync_fetch_and_and_2, "ssD*s.", "tn")
524BUILTIN(__sync_fetch_and_and_4, "iiD*i.", "tn")
525BUILTIN(__sync_fetch_and_and_8, "LLiLLiD*LLi.", "tn")
526BUILTIN(__sync_fetch_and_and_16, "LLLiLLLiD*LLLi.", "tn")
527
528BUILTIN(__sync_fetch_and_xor, "v.", "t")
529BUILTIN(__sync_fetch_and_xor_1, "ccD*c.", "tn")
530BUILTIN(__sync_fetch_and_xor_2, "ssD*s.", "tn")
531BUILTIN(__sync_fetch_and_xor_4, "iiD*i.", "tn")
532BUILTIN(__sync_fetch_and_xor_8, "LLiLLiD*LLi.", "tn")
533BUILTIN(__sync_fetch_and_xor_16, "LLLiLLLiD*LLLi.", "tn")
534
535
536BUILTIN(__sync_add_and_fetch, "v.", "t")
537BUILTIN(__sync_add_and_fetch_1, "ccD*c.", "tn")
538BUILTIN(__sync_add_and_fetch_2, "ssD*s.", "tn")
539BUILTIN(__sync_add_and_fetch_4, "iiD*i.", "tn")
540BUILTIN(__sync_add_and_fetch_8, "LLiLLiD*LLi.", "tn")
541BUILTIN(__sync_add_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
542
543BUILTIN(__sync_sub_and_fetch, "v.", "t")
544BUILTIN(__sync_sub_and_fetch_1, "ccD*c.", "tn")
545BUILTIN(__sync_sub_and_fetch_2, "ssD*s.", "tn")
546BUILTIN(__sync_sub_and_fetch_4, "iiD*i.", "tn")
547BUILTIN(__sync_sub_and_fetch_8, "LLiLLiD*LLi.", "tn")
548BUILTIN(__sync_sub_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
549
550BUILTIN(__sync_or_and_fetch, "v.", "t")
551BUILTIN(__sync_or_and_fetch_1, "ccD*c.", "tn")
552BUILTIN(__sync_or_and_fetch_2, "ssD*s.", "tn")
553BUILTIN(__sync_or_and_fetch_4, "iiD*i.", "tn")
554BUILTIN(__sync_or_and_fetch_8, "LLiLLiD*LLi.", "tn")
555BUILTIN(__sync_or_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
556
557BUILTIN(__sync_and_and_fetch, "v.", "t")
558BUILTIN(__sync_and_and_fetch_1, "ccD*c.", "tn")
559BUILTIN(__sync_and_and_fetch_2, "ssD*s.", "tn")
560BUILTIN(__sync_and_and_fetch_4, "iiD*i.", "tn")
561BUILTIN(__sync_and_and_fetch_8, "LLiLLiD*LLi.", "tn")
562BUILTIN(__sync_and_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
563
564BUILTIN(__sync_xor_and_fetch, "v.", "t")
565BUILTIN(__sync_xor_and_fetch_1, "ccD*c.", "tn")
566BUILTIN(__sync_xor_and_fetch_2, "ssD*s.", "tn")
567BUILTIN(__sync_xor_and_fetch_4, "iiD*i.", "tn")
568BUILTIN(__sync_xor_and_fetch_8, "LLiLLiD*LLi.", "tn")
569BUILTIN(__sync_xor_and_fetch_16, "LLLiLLLiD*LLLi.", "tn")
570
571BUILTIN(__sync_bool_compare_and_swap, "v.", "t")
572BUILTIN(__sync_bool_compare_and_swap_1, "bcD*cc.", "tn")
573BUILTIN(__sync_bool_compare_and_swap_2, "bsD*ss.", "tn")
574BUILTIN(__sync_bool_compare_and_swap_4, "biD*ii.", "tn")
575BUILTIN(__sync_bool_compare_and_swap_8, "bLLiD*LLiLLi.", "tn")
576BUILTIN(__sync_bool_compare_and_swap_16, "bLLLiD*LLLiLLLi.", "tn")
577
578BUILTIN(__sync_val_compare_and_swap, "v.", "t")
579BUILTIN(__sync_val_compare_and_swap_1, "ccD*cc.", "tn")
580BUILTIN(__sync_val_compare_and_swap_2, "ssD*ss.", "tn")
581BUILTIN(__sync_val_compare_and_swap_4, "iiD*ii.", "tn")
582BUILTIN(__sync_val_compare_and_swap_8, "LLiLLiD*LLiLLi.", "tn")
583BUILTIN(__sync_val_compare_and_swap_16, "LLLiLLLiD*LLLiLLLi.", "tn")
584
585BUILTIN(__sync_lock_test_and_set, "v.", "t")
586BUILTIN(__sync_lock_test_and_set_1, "ccD*c.", "tn")
587BUILTIN(__sync_lock_test_and_set_2, "ssD*s.", "tn")
588BUILTIN(__sync_lock_test_and_set_4, "iiD*i.", "tn")
589BUILTIN(__sync_lock_test_and_set_8, "LLiLLiD*LLi.", "tn")
590BUILTIN(__sync_lock_test_and_set_16, "LLLiLLLiD*LLLi.", "tn")
591
592BUILTIN(__sync_lock_release, "v.", "t")
593BUILTIN(__sync_lock_release_1, "vcD*.", "tn")
594BUILTIN(__sync_lock_release_2, "vsD*.", "tn")
595BUILTIN(__sync_lock_release_4, "viD*.", "tn")
596BUILTIN(__sync_lock_release_8, "vLLiD*.", "tn")
597BUILTIN(__sync_lock_release_16, "vLLLiD*.", "tn")
598
599BUILTIN(__sync_swap, "v.", "t")
600BUILTIN(__sync_swap_1, "ccD*c.", "tn")
601BUILTIN(__sync_swap_2, "ssD*s.", "tn")
602BUILTIN(__sync_swap_4, "iiD*i.", "tn")
603BUILTIN(__sync_swap_8, "LLiLLiD*LLi.", "tn")
604BUILTIN(__sync_swap_16, "LLLiLLLiD*LLLi.", "tn")
605
606// Some of our atomics builtins are handled by AtomicExpr rather than
607// as normal builtin CallExprs. This macro is used for such builtins.
608#ifndef ATOMIC_BUILTIN
609#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)
610#endif
611
612// C11 _Atomic operations for <stdatomic.h>.
613ATOMIC_BUILTIN(__c11_atomic_init, "v.", "t")
614ATOMIC_BUILTIN(__c11_atomic_load, "v.", "t")
615ATOMIC_BUILTIN(__c11_atomic_store, "v.", "t")
616ATOMIC_BUILTIN(__c11_atomic_exchange, "v.", "t")
617ATOMIC_BUILTIN(__c11_atomic_compare_exchange_strong, "v.", "t")
618ATOMIC_BUILTIN(__c11_atomic_compare_exchange_weak, "v.", "t")
619ATOMIC_BUILTIN(__c11_atomic_fetch_add, "v.", "t")
620ATOMIC_BUILTIN(__c11_atomic_fetch_sub, "v.", "t")
621ATOMIC_BUILTIN(__c11_atomic_fetch_and, "v.", "t")
622ATOMIC_BUILTIN(__c11_atomic_fetch_or, "v.", "t")
623ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t")
624BUILTIN(__c11_atomic_thread_fence, "vi", "n")
625BUILTIN(__c11_atomic_signal_fence, "vi", "n")
626BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
627
628// GNU atomic builtins.
629ATOMIC_BUILTIN(__atomic_load, "v.", "t")
630ATOMIC_BUILTIN(__atomic_load_n, "v.", "t")
631ATOMIC_BUILTIN(__atomic_store, "v.", "t")
632ATOMIC_BUILTIN(__atomic_store_n, "v.", "t")
633ATOMIC_BUILTIN(__atomic_exchange, "v.", "t")
634ATOMIC_BUILTIN(__atomic_exchange_n, "v.", "t")
635ATOMIC_BUILTIN(__atomic_compare_exchange, "v.", "t")
636ATOMIC_BUILTIN(__atomic_compare_exchange_n, "v.", "t")
637ATOMIC_BUILTIN(__atomic_fetch_add, "v.", "t")
638ATOMIC_BUILTIN(__atomic_fetch_sub, "v.", "t")
639ATOMIC_BUILTIN(__atomic_fetch_and, "v.", "t")
640ATOMIC_BUILTIN(__atomic_fetch_or, "v.", "t")
641ATOMIC_BUILTIN(__atomic_fetch_xor, "v.", "t")
642ATOMIC_BUILTIN(__atomic_fetch_nand, "v.", "t")
643ATOMIC_BUILTIN(__atomic_add_fetch, "v.", "t")
644ATOMIC_BUILTIN(__atomic_sub_fetch, "v.", "t")
645ATOMIC_BUILTIN(__atomic_and_fetch, "v.", "t")
646ATOMIC_BUILTIN(__atomic_or_fetch, "v.", "t")
647ATOMIC_BUILTIN(__atomic_xor_fetch, "v.", "t")
648ATOMIC_BUILTIN(__atomic_nand_fetch, "v.", "t")
649BUILTIN(__atomic_test_and_set, "bvD*i", "n")
650BUILTIN(__atomic_clear, "vvD*i", "n")
651BUILTIN(__atomic_thread_fence, "vi", "n")
652BUILTIN(__atomic_signal_fence, "vi", "n")
653BUILTIN(__atomic_always_lock_free, "izvCD*", "n")
654BUILTIN(__atomic_is_lock_free, "izvCD*", "n")
655
656#undef ATOMIC_BUILTIN
657
658// Non-overloaded atomic builtins.
659BUILTIN(__sync_synchronize, "v.", "n")
660// GCC does not support these, they are a Clang extension.
661BUILTIN(__sync_fetch_and_min, "iiD*i", "n")
662BUILTIN(__sync_fetch_and_max, "iiD*i", "n")
663BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
664BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
665
666// Random libc builtins.
667BUILTIN(__builtin_abort, "v", "Fnr")
668BUILTIN(__builtin_index, "c*cC*i", "Fn")
669BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
670
671// Microsoft builtins.
672BUILTIN(__assume, "vb", "n")
673BUILTIN(__noop, "v.", "n")
674BUILTIN(__debugbreak, "v", "n")
675
676
677// C99 library functions
678// C99 stdlib.h
679LIBBUILTIN(abort, "v",            "fr",    "stdlib.h", ALL_LANGUAGES)
680LIBBUILTIN(calloc, "v*zz",        "f",     "stdlib.h", ALL_LANGUAGES)
681LIBBUILTIN(exit, "vi",            "fr",    "stdlib.h", ALL_LANGUAGES)
682LIBBUILTIN(_Exit, "vi",           "fr",    "stdlib.h", ALL_LANGUAGES)
683LIBBUILTIN(malloc, "v*z",         "f",     "stdlib.h", ALL_LANGUAGES)
684LIBBUILTIN(realloc, "v*v*z",      "f",     "stdlib.h", ALL_LANGUAGES)
685// C99 string.h
686LIBBUILTIN(memcpy, "v*v*vC*z",    "f",     "string.h", ALL_LANGUAGES)
687LIBBUILTIN(memcmp, "ivC*vC*z",    "f",     "string.h", ALL_LANGUAGES)
688LIBBUILTIN(memmove, "v*v*vC*z",   "f",     "string.h", ALL_LANGUAGES)
689LIBBUILTIN(strcpy, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
690LIBBUILTIN(strncpy, "c*c*cC*z",   "f",     "string.h", ALL_LANGUAGES)
691LIBBUILTIN(strcmp, "icC*cC*",     "f",     "string.h", ALL_LANGUAGES)
692LIBBUILTIN(strncmp, "icC*cC*z",   "f",     "string.h", ALL_LANGUAGES)
693LIBBUILTIN(strcat, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
694LIBBUILTIN(strncat, "c*c*cC*z",   "f",     "string.h", ALL_LANGUAGES)
695LIBBUILTIN(strxfrm, "zc*cC*z",    "f",     "string.h", ALL_LANGUAGES)
696LIBBUILTIN(memchr, "v*vC*iz",     "f",     "string.h", ALL_LANGUAGES)
697LIBBUILTIN(strchr, "c*cC*i",      "f",     "string.h", ALL_LANGUAGES)
698LIBBUILTIN(strcspn, "zcC*cC*",    "f",     "string.h", ALL_LANGUAGES)
699LIBBUILTIN(strpbrk, "c*cC*cC*",   "f",     "string.h", ALL_LANGUAGES)
700LIBBUILTIN(strrchr, "c*cC*i",     "f",     "string.h", ALL_LANGUAGES)
701LIBBUILTIN(strspn, "zcC*cC*",     "f",     "string.h", ALL_LANGUAGES)
702LIBBUILTIN(strstr, "c*cC*cC*",    "f",     "string.h", ALL_LANGUAGES)
703LIBBUILTIN(strtok, "c*c*cC*",     "f",     "string.h", ALL_LANGUAGES)
704LIBBUILTIN(memset, "v*v*iz",      "f",     "string.h", ALL_LANGUAGES)
705LIBBUILTIN(strerror, "c*i",       "f",     "string.h", ALL_LANGUAGES)
706LIBBUILTIN(strlen, "zcC*",        "f",     "string.h", ALL_LANGUAGES)
707// C99 stdio.h
708LIBBUILTIN(printf, "icC*.",       "fp:0:", "stdio.h", ALL_LANGUAGES)
709LIBBUILTIN(fprintf, "iP*cC*.",    "fp:1:", "stdio.h", ALL_LANGUAGES)
710LIBBUILTIN(snprintf, "ic*zcC*.",  "fp:2:", "stdio.h", ALL_LANGUAGES)
711LIBBUILTIN(sprintf, "ic*cC*.",    "fp:1:", "stdio.h", ALL_LANGUAGES)
712LIBBUILTIN(vprintf, "icC*a",      "fP:0:", "stdio.h", ALL_LANGUAGES)
713LIBBUILTIN(vfprintf, "i.",        "fP:1:", "stdio.h", ALL_LANGUAGES)
714LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h", ALL_LANGUAGES)
715LIBBUILTIN(vsprintf, "ic*cC*a",   "fP:1:", "stdio.h", ALL_LANGUAGES)
716LIBBUILTIN(scanf, "icC*R.",       "fs:0:", "stdio.h", ALL_LANGUAGES)
717LIBBUILTIN(fscanf, "iP*RcC*R.",   "fs:1:", "stdio.h", ALL_LANGUAGES)
718LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:", "stdio.h", ALL_LANGUAGES)
719LIBBUILTIN(vscanf, "icC*Ra",      "fS:0:", "stdio.h", ALL_LANGUAGES)
720LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
721LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
722// C99
723#undef setjmp
724LIBBUILTIN(setjmp, "iJ",          "fj",    "setjmp.h", ALL_LANGUAGES)
725LIBBUILTIN(longjmp, "vJi",        "fr",    "setjmp.h", ALL_LANGUAGES)
726
727// Non-C library functions, active in GNU mode only.
728LIBBUILTIN(alloca, "v*z",         "f",     "stdlib.h", ALL_GNU_LANGUAGES)
729// POSIX string.h
730LIBBUILTIN(stpcpy, "c*c*cC*",     "f",     "string.h", ALL_GNU_LANGUAGES)
731LIBBUILTIN(stpncpy, "c*c*cC*z",   "f",     "string.h", ALL_GNU_LANGUAGES)
732LIBBUILTIN(strdup, "c*cC*",       "f",     "string.h", ALL_GNU_LANGUAGES)
733LIBBUILTIN(strndup, "c*cC*z",     "f",     "string.h", ALL_GNU_LANGUAGES)
734// POSIX strings.h
735LIBBUILTIN(index, "c*cC*i",       "f",     "strings.h", ALL_GNU_LANGUAGES)
736LIBBUILTIN(rindex, "c*cC*i",      "f",     "strings.h", ALL_GNU_LANGUAGES)
737LIBBUILTIN(bzero, "vv*z",         "f",     "strings.h", ALL_GNU_LANGUAGES)
738// In some systems str[n]casejmp is a macro that expands to _str[n]icmp.
739// We undefine then here to avoid wrong name.
740#undef strcasecmp
741#undef strncasecmp
742LIBBUILTIN(strcasecmp, "icC*cC*", "f",     "strings.h", ALL_GNU_LANGUAGES)
743LIBBUILTIN(strncasecmp, "icC*cC*z", "f",   "strings.h", ALL_GNU_LANGUAGES)
744// POSIX unistd.h
745LIBBUILTIN(_exit, "vi",           "fr",    "unistd.h", ALL_GNU_LANGUAGES)
746LIBBUILTIN(vfork, "p",            "fj",    "unistd.h", ALL_GNU_LANGUAGES)
747// POSIX setjmp.h
748
749// In some systems setjmp is a macro that expands to _setjmp. We undefine
750// it here to avoid having two identical LIBBUILTIN entries.
751LIBBUILTIN(_setjmp, "iJ",         "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
752LIBBUILTIN(__sigsetjmp, "iSJi",   "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
753LIBBUILTIN(sigsetjmp, "iSJi",     "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
754LIBBUILTIN(setjmp_syscall, "iJ",  "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
755LIBBUILTIN(savectx, "iJ",         "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
756LIBBUILTIN(qsetjmp, "iJ",         "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
757LIBBUILTIN(getcontext, "iK*",     "fj",   "setjmp.h", ALL_GNU_LANGUAGES)
758
759LIBBUILTIN(_longjmp, "vJi",       "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
760LIBBUILTIN(siglongjmp, "vSJi",    "fr",    "setjmp.h", ALL_GNU_LANGUAGES)
761// non-standard but very common
762LIBBUILTIN(strlcpy, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
763LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
764//   id objc_msgSend(id, SEL, ...)
765LIBBUILTIN(objc_msgSend, "GGH.",   "f",     "objc/message.h", OBJC_LANG)
766// long double objc_msgSend_fpret(id self, SEL op, ...) 
767LIBBUILTIN(objc_msgSend_fpret, "LdGH.", "f", "objc/message.h", OBJC_LANG)
768// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...)
769LIBBUILTIN(objc_msgSend_fp2ret, "XLdGH.", "f", "objc/message.h", OBJC_LANG)
770// void objc_msgSend_stret (id, SEL, ...)
771LIBBUILTIN(objc_msgSend_stret, "vGH.", "f", "objc/message.h", OBJC_LANG)
772// id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
773LIBBUILTIN(objc_msgSendSuper, "GM*H.", "f", "objc/message.h", OBJC_LANG)
774// void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...)
775LIBBUILTIN(objc_msgSendSuper_stret, "vM*H.", "f", "objc/message.h", OBJC_LANG)
776//   id objc_getClass(const char *name)
777LIBBUILTIN(objc_getClass, "GcC*",   "f",     "objc/runtime.h", OBJC_LANG)
778//   id objc_getMetaClass(const char *name)
779LIBBUILTIN(objc_getMetaClass, "GcC*",   "f", "objc/runtime.h", OBJC_LANG)
780// void objc_enumerationMutation(id)
781LIBBUILTIN(objc_enumerationMutation, "vG", "f", "objc/runtime.h", OBJC_LANG)
782
783// id objc_read_weak(id *location)
784LIBBUILTIN(objc_read_weak, "GG*", "f", "objc/objc-auto.h", OBJC_LANG)
785// id objc_assign_weak(id value, id *location)
786LIBBUILTIN(objc_assign_weak, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
787// id objc_assign_ivar(id value, id dest, ptrdiff_t offset)
788LIBBUILTIN(objc_assign_ivar, "GGGY", "f", "objc/objc-auto.h", OBJC_LANG)
789// id objc_assign_global(id val, id *dest)
790LIBBUILTIN(objc_assign_global, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
791// id objc_assign_strongCast(id val, id *dest
792LIBBUILTIN(objc_assign_strongCast, "GGG*", "f", "objc/objc-auto.h", OBJC_LANG)
793
794// id objc_exception_extract(void *localExceptionData)
795LIBBUILTIN(objc_exception_extract, "Gv*", "f", "objc/objc-exception.h", OBJC_LANG)
796// void objc_exception_try_enter(void *localExceptionData)
797LIBBUILTIN(objc_exception_try_enter, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
798// void objc_exception_try_exit(void *localExceptionData)
799LIBBUILTIN(objc_exception_try_exit, "vv*", "f", "objc/objc-exception.h", OBJC_LANG)
800// int objc_exception_match(Class exceptionClass, id exception)
801LIBBUILTIN(objc_exception_match, "iGG", "f", "objc/objc-exception.h", OBJC_LANG)
802// void objc_exception_throw(id exception)
803LIBBUILTIN(objc_exception_throw, "vG", "f", "objc/objc-exception.h", OBJC_LANG)
804
805// int objc_sync_enter(id obj)
806LIBBUILTIN(objc_sync_enter, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
807// int objc_sync_exit(id obj)
808LIBBUILTIN(objc_sync_exit, "iG", "f", "objc/objc-sync.h", OBJC_LANG)
809
810BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
811
812// void NSLog(NSString *fmt, ...)
813LIBBUILTIN(NSLog, "vG.", "fp:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
814// void NSLogv(NSString *fmt, va_list args)
815LIBBUILTIN(NSLogv, "vGa", "fP:0:", "Foundation/NSObjCRuntime.h", OBJC_LANG)
816
817// Builtin math library functions
818LIBBUILTIN(acos, "dd", "fe", "math.h", ALL_LANGUAGES)
819LIBBUILTIN(acosl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
820LIBBUILTIN(acosf, "ff", "fe", "math.h", ALL_LANGUAGES)
821
822LIBBUILTIN(asin, "dd", "fe", "math.h", ALL_LANGUAGES)
823LIBBUILTIN(asinl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
824LIBBUILTIN(asinf, "ff", "fe", "math.h", ALL_LANGUAGES)
825
826LIBBUILTIN(atan, "dd", "fe", "math.h", ALL_LANGUAGES)
827LIBBUILTIN(atanl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
828LIBBUILTIN(atanf, "ff", "fe", "math.h", ALL_LANGUAGES)
829
830LIBBUILTIN(atan2, "ddd", "fe", "math.h", ALL_LANGUAGES)
831LIBBUILTIN(atan2l, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
832LIBBUILTIN(atan2f, "fff", "fe", "math.h", ALL_LANGUAGES)
833
834LIBBUILTIN(ceil, "dd", "fc", "math.h", ALL_LANGUAGES)
835LIBBUILTIN(ceill, "LdLd", "fc", "math.h", ALL_LANGUAGES)
836LIBBUILTIN(ceilf, "ff", "fc", "math.h", ALL_LANGUAGES)
837
838LIBBUILTIN(cimag, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
839LIBBUILTIN(cimagf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
840LIBBUILTIN(cimagl, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
841
842LIBBUILTIN(creal, "dXd", "fnc", "complex.h", ALL_LANGUAGES)
843LIBBUILTIN(crealf, "fXf", "fnc", "complex.h", ALL_LANGUAGES)
844LIBBUILTIN(creall, "LdXLd", "fnc", "complex.h", ALL_LANGUAGES)
845
846LIBBUILTIN(copysign, "ddd", "fc", "math.h", ALL_LANGUAGES)
847LIBBUILTIN(copysignl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
848LIBBUILTIN(copysignf, "fff", "fc", "math.h", ALL_LANGUAGES)
849
850LIBBUILTIN(cos, "dd", "fe", "math.h", ALL_LANGUAGES)
851LIBBUILTIN(cosl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
852LIBBUILTIN(cosf, "ff", "fe", "math.h", ALL_LANGUAGES)
853
854LIBBUILTIN(exp, "dd", "fe", "math.h", ALL_LANGUAGES)
855LIBBUILTIN(expl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
856LIBBUILTIN(expf, "ff", "fe", "math.h", ALL_LANGUAGES)
857
858LIBBUILTIN(exp2, "dd", "fe", "math.h", ALL_LANGUAGES)
859LIBBUILTIN(exp2l, "LdLd", "fe", "math.h", ALL_LANGUAGES)
860LIBBUILTIN(exp2f, "ff", "fe", "math.h", ALL_LANGUAGES)
861
862LIBBUILTIN(fabs, "dd", "fc", "math.h", ALL_LANGUAGES)
863LIBBUILTIN(fabsl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
864LIBBUILTIN(fabsf, "ff", "fc", "math.h", ALL_LANGUAGES)
865
866LIBBUILTIN(floor, "dd", "fc", "math.h", ALL_LANGUAGES)
867LIBBUILTIN(floorl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
868LIBBUILTIN(floorf, "ff", "fc", "math.h", ALL_LANGUAGES)
869
870LIBBUILTIN(fma, "dddd", "fc", "math.h", ALL_LANGUAGES)
871LIBBUILTIN(fmal, "LdLdLdLd", "fc", "math.h", ALL_LANGUAGES)
872LIBBUILTIN(fmaf, "ffff", "fc", "math.h", ALL_LANGUAGES)
873
874LIBBUILTIN(fmax, "ddd", "fc", "math.h", ALL_LANGUAGES)
875LIBBUILTIN(fmaxl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
876LIBBUILTIN(fmaxf, "fff", "fc", "math.h", ALL_LANGUAGES)
877
878LIBBUILTIN(fmin, "ddd", "fc", "math.h", ALL_LANGUAGES)
879LIBBUILTIN(fminl, "LdLdLd", "fc", "math.h", ALL_LANGUAGES)
880LIBBUILTIN(fminf, "fff", "fc", "math.h", ALL_LANGUAGES)
881
882LIBBUILTIN(log, "dd", "fe", "math.h", ALL_LANGUAGES)
883LIBBUILTIN(logl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
884LIBBUILTIN(logf, "ff", "fe", "math.h", ALL_LANGUAGES)
885
886LIBBUILTIN(log2, "dd", "fe", "math.h", ALL_LANGUAGES)
887LIBBUILTIN(log2l, "LdLd", "fe", "math.h", ALL_LANGUAGES)
888LIBBUILTIN(log2f, "ff", "fe", "math.h", ALL_LANGUAGES)
889
890LIBBUILTIN(nearbyint, "dd", "fc", "math.h", ALL_LANGUAGES)
891LIBBUILTIN(nearbyintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
892LIBBUILTIN(nearbyintf, "ff", "fc", "math.h", ALL_LANGUAGES)
893
894LIBBUILTIN(pow, "ddd", "fe", "math.h", ALL_LANGUAGES)
895LIBBUILTIN(powl, "LdLdLd", "fe", "math.h", ALL_LANGUAGES)
896LIBBUILTIN(powf, "fff", "fe", "math.h", ALL_LANGUAGES)
897
898LIBBUILTIN(rint, "dd", "fc", "math.h", ALL_LANGUAGES)
899LIBBUILTIN(rintl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
900LIBBUILTIN(rintf, "ff", "fc", "math.h", ALL_LANGUAGES)
901
902LIBBUILTIN(round, "dd", "fc", "math.h", ALL_LANGUAGES)
903LIBBUILTIN(roundl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
904LIBBUILTIN(roundf, "ff", "fc", "math.h", ALL_LANGUAGES)
905
906LIBBUILTIN(sin, "dd", "fe", "math.h", ALL_LANGUAGES)
907LIBBUILTIN(sinl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
908LIBBUILTIN(sinf, "ff", "fe", "math.h", ALL_LANGUAGES)
909
910LIBBUILTIN(sqrt, "dd", "fe", "math.h", ALL_LANGUAGES)
911LIBBUILTIN(sqrtl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
912LIBBUILTIN(sqrtf, "ff", "fe", "math.h", ALL_LANGUAGES)
913
914LIBBUILTIN(tan, "dd", "fe", "math.h", ALL_LANGUAGES)
915LIBBUILTIN(tanl, "LdLd", "fe", "math.h", ALL_LANGUAGES)
916LIBBUILTIN(tanf, "ff", "fe", "math.h", ALL_LANGUAGES)
917
918LIBBUILTIN(trunc, "dd", "fc", "math.h", ALL_LANGUAGES)
919LIBBUILTIN(truncl, "LdLd", "fc", "math.h", ALL_LANGUAGES)
920LIBBUILTIN(truncf, "ff", "fc", "math.h", ALL_LANGUAGES)
921
922// Blocks runtime Builtin math library functions
923LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h", ALL_LANGUAGES)
924LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h", ALL_LANGUAGES)
925// FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
926
927// Annotation function
928BUILTIN(__builtin_annotation, "v.", "tn")
929
930// Multiprecision Arithmetic Builtins.
931BUILTIN(__builtin_addcb, "UcUcCUcCUcCUc*", "n")
932BUILTIN(__builtin_addcs, "UsUsCUsCUsCUs*", "n")
933BUILTIN(__builtin_addc, "UiUiCUiCUiCUi*", "n")
934BUILTIN(__builtin_addcl, "ULiULiCULiCULiCULi*", "n")
935BUILTIN(__builtin_addcll, "ULLiULLiCULLiCULLiCULLi*", "n")
936BUILTIN(__builtin_subcb, "UcUcCUcCUcCUc*", "n")
937BUILTIN(__builtin_subcs, "UsUsCUsCUsCUs*", "n")
938BUILTIN(__builtin_subc, "UiUiCUiCUiCUi*", "n")
939BUILTIN(__builtin_subcl, "ULiULiCULiCULiCULi*", "n")
940BUILTIN(__builtin_subcll, "ULLiULLiCULLiCULLiCULLi*", "n")
941
942// Checked Arithmetic Builtins for Security.
943BUILTIN(__builtin_uadd_overflow, "bUiCUiCUi*", "n")
944BUILTIN(__builtin_uaddl_overflow, "bULiCULiCULi*", "n")
945BUILTIN(__builtin_uaddll_overflow, "bULLiCULLiCULLi*", "n")
946BUILTIN(__builtin_usub_overflow, "bUiCUiCUi*", "n")
947BUILTIN(__builtin_usubl_overflow, "bULiCULiCULi*", "n")
948BUILTIN(__builtin_usubll_overflow, "bULLiCULLiCULLi*", "n")
949BUILTIN(__builtin_umul_overflow, "bUiCUiCUi*", "n")
950BUILTIN(__builtin_umull_overflow, "bULiCULiCULi*", "n")
951BUILTIN(__builtin_umulll_overflow, "bULLiCULLiCULLi*", "n")
952BUILTIN(__builtin_sadd_overflow, "bSiCSiCSi*", "n")
953BUILTIN(__builtin_saddl_overflow, "bSLiCSLiCSLi*", "n")
954BUILTIN(__builtin_saddll_overflow, "bSLLiCSLLiCSLLi*", "n")
955BUILTIN(__builtin_ssub_overflow, "bSiCSiCSi*", "n")
956BUILTIN(__builtin_ssubl_overflow, "bSLiCSLiCSLi*", "n")
957BUILTIN(__builtin_ssubll_overflow, "bSLLiCSLLiCSLLi*", "n")
958BUILTIN(__builtin_smul_overflow, "bSiCSiCSi*", "n")
959BUILTIN(__builtin_smull_overflow, "bSLiCSLiCSLi*", "n")
960BUILTIN(__builtin_smulll_overflow, "bSLLiCSLLiCSLLi*", "n")
961
962// Clang builtins (not available in GCC).
963BUILTIN(__builtin_addressof, "v*v&", "nct")
964
965#undef BUILTIN
966#undef LIBBUILTIN
967