fix the definition of __builtin_constant_p, the first arg isn't a short.
[clang.git] / include / clang / Basic / Builtins.def
blobeca73774f0c981d1243193b1be12f1b043afead1
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.
13 //===----------------------------------------------------------------------===//
15 // FIXME: This should really be a .td file, but that requires modifying tblgen.
16 // Perhaps tblgen should have plugins.
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.
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 // a -> __builtin_va_list
33 // A -> "reference" to __builtin_va_list
34 // V -> Vector, following num elements and a base type.
35 // X -> _Complex, followed by the base type.
36 // P -> FILE
37 // J -> jmp_buf
38 // SJ -> sigjmp_buf
39 // . -> "...". This may only occur at the end of the function list.
41 // Types may be prefixed with the following modifiers:
42 // L -> long (e.g. Li for 'long int')
43 // LL -> long long
44 // LLL -> __int128_t (e.g. LLLi)
45 // S -> signed
46 // U -> unsigned
47 // I -> Required to constant fold to an integer constant expression.
49 // Types may be postfixed with the following modifiers:
50 // * -> pointer (optionally followed by an address space number)
51 // & -> reference (optionally followed by an address space number)
52 // C -> const
53 // D -> volatile
55 // The third value provided to the macro specifies information about attributes
56 // of the function. These must be kept in sync with the predicates in the
57 // Builtin::Context class. Currently we have:
58 // n -> nothrow
59 // r -> noreturn
60 // c -> const
61 // F -> this is a libc/libm function with a '__builtin_' prefix added.
62 // f -> this is a libc/libm function without the '__builtin_' prefix. It can
63 // be followed by ':headername:' to state which header this function
64 // comes from.
65 // p:N: -> this is a printf-like function whose Nth argument is the format
66 // string.
67 // P:N: -> similar to the p:N: attribute, but the function is like vprintf
68 // in that it accepts its arguments as a va_list rather than
69 // through an ellipsis
70 // s:N: -> this is a scanf-like function whose Nth argument is the format
71 // string.
72 // S:N: -> similar to the s:N: attribute, but the function is like vscanf
73 // in that it accepts its arguments as a va_list rather than
74 // through an ellipsis
75 // e -> const, but only when -fmath-errno=0
76 // FIXME: gcc has nonnull
78 #if defined(BUILTIN) && !defined(LIBBUILTIN)
79 # define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) BUILTIN(ID, TYPE, ATTRS)
80 #endif
82 // Standard libc/libm functions:
83 BUILTIN(__builtin_atan2 , "ddd" , "Fnc")
84 BUILTIN(__builtin_atan2f, "fff" , "Fnc")
85 BUILTIN(__builtin_atan2l, "LdLdLd", "Fnc")
86 BUILTIN(__builtin_abs , "ii" , "ncF")
87 BUILTIN(__builtin_copysign, "ddd", "ncF")
88 BUILTIN(__builtin_copysignf, "fff", "ncF")
89 BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
90 BUILTIN(__builtin_fabs , "dd" , "ncF")
91 BUILTIN(__builtin_fabsf, "ff" , "ncF")
92 BUILTIN(__builtin_fabsl, "LdLd", "ncF")
93 BUILTIN(__builtin_fmod , "ddd" , "Fnc")
94 BUILTIN(__builtin_fmodf, "fff" , "Fnc")
95 BUILTIN(__builtin_fmodl, "LdLdLd", "Fnc")
96 BUILTIN(__builtin_frexp , "ddi*" , "Fnc")
97 BUILTIN(__builtin_frexpf, "ffi*" , "Fnc")
98 BUILTIN(__builtin_frexpl, "LdLdi*", "Fnc")
99 BUILTIN(__builtin_huge_val, "d", "nc")
100 BUILTIN(__builtin_huge_valf, "f", "nc")
101 BUILTIN(__builtin_huge_vall, "Ld", "nc")
102 BUILTIN(__builtin_inf , "d" , "nc")
103 BUILTIN(__builtin_inff , "f" , "nc")
104 BUILTIN(__builtin_infl , "Ld" , "nc")
105 BUILTIN(__builtin_ldexp , "ddi" , "Fnc")
106 BUILTIN(__builtin_ldexpf, "ffi" , "Fnc")
107 BUILTIN(__builtin_ldexpl, "LdLdi", "Fnc")
108 BUILTIN(__builtin_modf , "ddd*" , "Fnc")
109 BUILTIN(__builtin_modff, "fff*" , "Fnc")
110 BUILTIN(__builtin_modfl, "LdLdLd*", "Fnc")
111 BUILTIN(__builtin_nan, "dcC*" , "ncF")
112 BUILTIN(__builtin_nanf, "fcC*" , "ncF")
113 BUILTIN(__builtin_nanl, "LdcC*", "ncF")
114 BUILTIN(__builtin_nans, "dcC*" , "ncF")
115 BUILTIN(__builtin_nansf, "fcC*" , "ncF")
116 BUILTIN(__builtin_nansl, "LdcC*", "ncF")
117 BUILTIN(__builtin_powi , "ddi" , "Fnc")
118 BUILTIN(__builtin_powif, "ffi" , "Fnc")
119 BUILTIN(__builtin_powil, "LdLdi", "Fnc")
120 BUILTIN(__builtin_pow , "ddd" , "Fnc")
121 BUILTIN(__builtin_powf, "fff" , "Fnc")
122 BUILTIN(__builtin_powl, "LdLdLd", "Fnc")
124 // Standard unary libc/libm functions with double/float/long double variants:
125 BUILTIN(__builtin_acos , "dd" , "Fnc")
126 BUILTIN(__builtin_acosf, "ff" , "Fnc")
127 BUILTIN(__builtin_acosl, "LdLd", "Fnc")
128 BUILTIN(__builtin_asin , "dd" , "Fnc")
129 BUILTIN(__builtin_asinf, "ff" , "Fnc")
130 BUILTIN(__builtin_asinl, "LdLd", "Fnc")
131 BUILTIN(__builtin_atan , "dd" , "Fnc")
132 BUILTIN(__builtin_atanf, "ff" , "Fnc")
133 BUILTIN(__builtin_atanl, "LdLd", "Fnc")
134 BUILTIN(__builtin_ceil , "dd" , "Fnc")
135 BUILTIN(__builtin_ceilf, "ff" , "Fnc")
136 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
137 BUILTIN(__builtin_cos , "dd" , "Fnc")
138 BUILTIN(__builtin_cosf, "ff" , "Fnc")
139 BUILTIN(__builtin_cosh , "dd" , "Fnc")
140 BUILTIN(__builtin_coshf, "ff" , "Fnc")
141 BUILTIN(__builtin_coshl, "LdLd", "Fnc")
142 BUILTIN(__builtin_cosl, "LdLd", "Fnc")
143 BUILTIN(__builtin_exp , "dd" , "Fnc")
144 BUILTIN(__builtin_expf, "ff" , "Fnc")
145 BUILTIN(__builtin_expl, "LdLd", "Fnc")
146 BUILTIN(__builtin_fdim, "ddd", "Fnc")
147 BUILTIN(__builtin_fdimf, "fff", "Fnc")
148 BUILTIN(__builtin_fdiml, "LdLdLd", "Fnc")
149 BUILTIN(__builtin_floor , "dd" , "Fnc")
150 BUILTIN(__builtin_floorf, "ff" , "Fnc")
151 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
152 BUILTIN(__builtin_fma, "dddd", "Fnc")
153 BUILTIN(__builtin_fmaf, "ffff", "Fnc")
154 BUILTIN(__builtin_fmal, "LdLdLdLd", "Fnc")
155 BUILTIN(__builtin_fmax, "ddd", "Fnc")
156 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
157 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
158 BUILTIN(__builtin_fmin, "ddd", "Fnc")
159 BUILTIN(__builtin_fminf, "fff", "Fnc")
160 BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
161 BUILTIN(__builtin_hypot , "ddd" , "Fnc")
162 BUILTIN(__builtin_hypotf, "fff" , "Fnc")
163 BUILTIN(__builtin_hypotl, "LdLdLd", "Fnc")
164 BUILTIN(__builtin_log , "dd" , "Fnc")
165 BUILTIN(__builtin_log10 , "dd" , "Fnc")
166 BUILTIN(__builtin_log10f, "ff" , "Fnc")
167 BUILTIN(__builtin_log10l, "LdLd", "Fnc")
168 BUILTIN(__builtin_logf, "ff" , "Fnc")
169 BUILTIN(__builtin_logl, "LdLd", "Fnc")
170 BUILTIN(__builtin_sin , "dd" , "Fnc")
171 BUILTIN(__builtin_sinf, "ff" , "Fnc")
172 BUILTIN(__builtin_sinh , "dd" , "Fnc")
173 BUILTIN(__builtin_sinhf, "ff" , "Fnc")
174 BUILTIN(__builtin_sinhl, "LdLd", "Fnc")
175 BUILTIN(__builtin_sinl, "LdLd", "Fnc")
176 BUILTIN(__builtin_sqrt , "dd" , "Fnc")
177 BUILTIN(__builtin_sqrtf, "ff" , "Fnc")
178 BUILTIN(__builtin_sqrtl, "LdLd", "Fnc")
179 BUILTIN(__builtin_tan , "dd" , "Fnc")
180 BUILTIN(__builtin_tanf, "ff" , "Fnc")
181 BUILTIN(__builtin_tanh , "dd" , "Fnc")
182 BUILTIN(__builtin_tanhf, "ff" , "Fnc")
183 BUILTIN(__builtin_tanhl, "LdLd", "Fnc")
184 BUILTIN(__builtin_tanl, "LdLd", "Fnc")
186 // C99 complex builtins
187 BUILTIN(__builtin_cabs, "dXd", "Fnc")
188 BUILTIN(__builtin_cabsf, "fXf", "Fnc")
189 BUILTIN(__builtin_cabsl, "LdXLd", "Fnc")
190 BUILTIN(__builtin_cacos, "XdXd", "Fnc")
191 BUILTIN(__builtin_cacosf, "XfXf", "Fnc")
192 BUILTIN(__builtin_cacosl, "XLdXLd", "Fnc")
193 BUILTIN(__builtin_carg, "dXd", "Fnc")
194 BUILTIN(__builtin_cargf, "fXf", "Fnc")
195 BUILTIN(__builtin_cargl, "LdXLd", "Fnc")
196 BUILTIN(__builtin_casin, "XdXd", "Fnc")
197 BUILTIN(__builtin_casinf, "XfXf", "Fnc")
198 BUILTIN(__builtin_casinl, "XLdXLd", "Fnc")
199 BUILTIN(__builtin_catan, "XdXd", "Fnc")
200 BUILTIN(__builtin_catanf, "XfXf", "Fnc")
201 BUILTIN(__builtin_catanl, "XLdXLd", "Fnc")
202 BUILTIN(__builtin_ccos, "XdXd", "Fnc")
203 BUILTIN(__builtin_ccosf, "XfXf", "Fnc")
204 BUILTIN(__builtin_ccosl, "XLdXLd", "Fnc")
205 BUILTIN(__builtin_ccosh, "XdXd", "Fnc")
206 BUILTIN(__builtin_ccoshf, "XfXf", "Fnc")
207 BUILTIN(__builtin_ccoshl, "XLdXLd", "Fnc")
208 BUILTIN(__builtin_cexp, "XdXd", "Fnc")
209 BUILTIN(__builtin_cexpf, "XfXf", "Fnc")
210 BUILTIN(__builtin_cexpl, "XLdXLd", "Fnc")
211 BUILTIN(__builtin_cimag, "dXd", "Fnc")
212 BUILTIN(__builtin_cimagf, "fXf", "Fnc")
213 BUILTIN(__builtin_cimagl, "LdXLd", "Fnc")
214 BUILTIN(__builtin_conj, "XdXd", "Fnc")
215 BUILTIN(__builtin_conjf, "XfXf", "Fnc")
216 BUILTIN(__builtin_conjl, "XLdXLd", "Fnc")
217 BUILTIN(__builtin_clog, "XdXd", "Fnc")
218 BUILTIN(__builtin_clogf, "XfXf", "Fnc")
219 BUILTIN(__builtin_clogl, "XLdXLd", "Fnc")
220 BUILTIN(__builtin_cproj, "XdXd", "Fnc")
221 BUILTIN(__builtin_cprojf, "XfXf", "Fnc")
222 BUILTIN(__builtin_cprojl, "XLdXLd", "Fnc")
223 BUILTIN(__builtin_cpow, "XdXdXd", "Fnc")
224 BUILTIN(__builtin_cpowf, "XfXfXf", "Fnc")
225 BUILTIN(__builtin_cpowl, "XLdXLdXLd", "Fnc")
226 BUILTIN(__builtin_creal, "dXd", "Fnc")
227 BUILTIN(__builtin_crealf, "fXf", "Fnc")
228 BUILTIN(__builtin_creall, "LdXLd", "Fnc")
229 BUILTIN(__builtin_csin, "XdXd", "Fnc")
230 BUILTIN(__builtin_csinf, "XfXf", "Fnc")
231 BUILTIN(__builtin_csinl, "XLdXLd", "Fnc")
232 BUILTIN(__builtin_csinh, "XdXd", "Fnc")
233 BUILTIN(__builtin_csinhf, "XfXf", "Fnc")
234 BUILTIN(__builtin_csinhl, "XLdXLd", "Fnc")
235 BUILTIN(__builtin_csqrt, "XdXd", "Fnc")
236 BUILTIN(__builtin_csqrtf, "XfXf", "Fnc")
237 BUILTIN(__builtin_csqrtl, "XLdXLd", "Fnc")
238 BUILTIN(__builtin_ctan, "XdXd", "Fnc")
239 BUILTIN(__builtin_ctanf, "XfXf", "Fnc")
240 BUILTIN(__builtin_ctanl, "XLdXLd", "Fnc")
241 BUILTIN(__builtin_ctanh, "XdXd", "Fnc")
242 BUILTIN(__builtin_ctanhf, "XfXf", "Fnc")
243 BUILTIN(__builtin_ctanhl, "XLdXLd", "Fnc")
245 // FP Comparisons.
246 BUILTIN(__builtin_isgreater , "i.", "nc")
247 BUILTIN(__builtin_isgreaterequal, "i.", "nc")
248 BUILTIN(__builtin_isless , "i.", "nc")
249 BUILTIN(__builtin_islessequal , "i.", "nc")
250 BUILTIN(__builtin_islessgreater , "i.", "nc")
251 BUILTIN(__builtin_isunordered , "i.", "nc")
253 // Unary FP classification
254 BUILTIN(__builtin_fpclassify, "iiiii.", "nc")
255 BUILTIN(__builtin_isfinite, "i.", "nc")
256 BUILTIN(__builtin_isinf, "i.", "nc")
257 BUILTIN(__builtin_isinf_sign, "i.", "nc")
258 BUILTIN(__builtin_isnan, "i.", "nc")
259 BUILTIN(__builtin_isnormal, "i.", "nc")
261 // FP signbit builtins
262 BUILTIN(__builtin_signbit, "id", "nc")
263 BUILTIN(__builtin_signbitf, "if", "nc")
264 BUILTIN(__builtin_signbitl, "iLd", "nc")
266 // Builtins for arithmetic.
267 BUILTIN(__builtin_clz , "iUi" , "nc")
268 BUILTIN(__builtin_clzl , "iULi" , "nc")
269 BUILTIN(__builtin_clzll, "iULLi", "nc")
270 // TODO: int clzimax(uintmax_t)
271 BUILTIN(__builtin_ctz , "iUi" , "nc")
272 BUILTIN(__builtin_ctzl , "iULi" , "nc")
273 BUILTIN(__builtin_ctzll, "iULLi", "nc")
274 // TODO: int ctzimax(uintmax_t)
275 BUILTIN(__builtin_ffs , "iUi" , "nc")
276 BUILTIN(__builtin_ffsl , "iULi" , "nc")
277 BUILTIN(__builtin_ffsll, "iULLi", "nc")
278 BUILTIN(__builtin_parity , "iUi" , "nc")
279 BUILTIN(__builtin_parityl , "iULi" , "nc")
280 BUILTIN(__builtin_parityll, "iULLi", "nc")
281 BUILTIN(__builtin_popcount , "iUi" , "nc")
282 BUILTIN(__builtin_popcountl , "iULi" , "nc")
283 BUILTIN(__builtin_popcountll, "iULLi", "nc")
285 // FIXME: These type signatures are not correct for targets with int != 32-bits
286 // or with ULL != 64-bits.
287 BUILTIN(__builtin_bswap32, "UiUi", "nc")
288 BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
290 // Random GCC builtins
291 BUILTIN(__builtin_constant_p, "i.", "nc")
292 BUILTIN(__builtin_classify_type, "i.", "nc")
293 BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
294 BUILTIN(__builtin___NSStringMakeConstantString, "FC*cC*", "nc")
295 BUILTIN(__builtin_va_start, "vA.", "n")
296 BUILTIN(__builtin_va_end, "vA", "n")
297 BUILTIN(__builtin_va_copy, "vAA", "n")
298 BUILTIN(__builtin_stdarg_start, "vA.", "n")
299 BUILTIN(__builtin_bcmp, "iv*v*z", "n")
300 BUILTIN(__builtin_bcopy, "vv*v*z", "n")
301 BUILTIN(__builtin_bzero, "vv*z", "nF")
302 BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
303 BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
304 BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
305 BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
306 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
307 BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
308 BUILTIN(__builtin_memset, "v*v*iz", "nF")
309 BUILTIN(__builtin_printf, "icC*.", "Fp:0:")
310 BUILTIN(__builtin_stpcpy, "c*c*cC*", "nF")
311 BUILTIN(__builtin_stpncpy, "c*c*cC*z", "nF")
312 BUILTIN(__builtin_strcasecmp, "icC*cC*", "nF")
313 BUILTIN(__builtin_strcat, "c*c*cC*", "nF")
314 BUILTIN(__builtin_strchr, "c*cC*i", "nF")
315 BUILTIN(__builtin_strcmp, "icC*cC*", "nF")
316 BUILTIN(__builtin_strcpy, "c*c*cC*", "nF")
317 BUILTIN(__builtin_strcspn, "zcC*cC*", "nF")
318 BUILTIN(__builtin_strdup, "c*cC*", "nF")
319 BUILTIN(__builtin_strlen, "zcC*", "nF")
320 BUILTIN(__builtin_strncasecmp, "icC*cC*z", "nF")
321 BUILTIN(__builtin_strncat, "c*c*cC*z", "nF")
322 BUILTIN(__builtin_strncmp, "icC*cC*z", "nF")
323 BUILTIN(__builtin_strncpy, "c*c*cC*z", "nF")
324 BUILTIN(__builtin_strndup, "c*cC*z", "nF")
325 BUILTIN(__builtin_strpbrk, "c*cC*cC*", "nF")
326 BUILTIN(__builtin_strrchr, "c*cC*i", "nF")
327 BUILTIN(__builtin_strspn, "zcC*cC*", "nF")
328 BUILTIN(__builtin_strstr, "c*cC*cC*", "nF")
329 BUILTIN(__builtin_return_address, "v*IUi", "n")
330 BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
331 BUILTIN(__builtin_frame_address, "v*IUi", "n")
332 BUILTIN(__builtin_flt_rounds, "i", "nc")
333 BUILTIN(__builtin_setjmp, "iv**", "")
334 BUILTIN(__builtin_longjmp, "vv**i", "r")
335 BUILTIN(__builtin_unwind_init, "v", "")
336 BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
337 BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
338 BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
339 BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
341 // GCC exception builtins
342 BUILTIN(__builtin_eh_return, "vzv*", "r") // FIXME: Takes intptr_t, not size_t!
343 BUILTIN(__builtin_frob_return_addr, "v*v*", "n")
344 BUILTIN(__builtin_dwarf_cfa, "v*", "n")
345 BUILTIN(__builtin_init_dwarf_reg_size_table, "vv*", "n")
346 BUILTIN(__builtin_dwarf_sp_column, "Ui", "n")
347 BUILTIN(__builtin_extend_pointer, "ULLiv*", "n") // _Unwind_Word == uint64_t
349 // GCC Object size checking builtins
350 BUILTIN(__builtin_object_size, "zv*i", "n")
351 BUILTIN(__builtin___memcpy_chk, "v*v*vC*zz", "nF")
352 BUILTIN(__builtin___memmove_chk, "v*v*vC*zz", "nF")
353 BUILTIN(__builtin___mempcpy_chk, "v*v*vC*zz", "nF")
354 BUILTIN(__builtin___memset_chk, "v*v*izz", "nF")
355 BUILTIN(__builtin___stpcpy_chk, "c*c*cC*z", "nF")
356 BUILTIN(__builtin___strcat_chk, "c*c*cC*z", "nF")
357 BUILTIN(__builtin___strcpy_chk, "c*c*cC*z", "nF")
358 BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
359 BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
360 BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
361 BUILTIN(__builtin___snprintf_chk, "ic*zizcC*.", "Fp:4:")
362 BUILTIN(__builtin___sprintf_chk, "ic*izcC*.", "Fp:3:")
363 BUILTIN(__builtin___vsnprintf_chk, "ic*zizcC*a", "FP:4:")
364 BUILTIN(__builtin___vsprintf_chk, "ic*izcC*a", "FP:3:")
365 BUILTIN(__builtin___fprintf_chk, "iP*icC*.", "Fp:2:")
366 BUILTIN(__builtin___printf_chk, "iicC*.", "Fp:1:")
367 BUILTIN(__builtin___vfprintf_chk, "iP*icC*a", "FP:2:")
368 BUILTIN(__builtin___vprintf_chk, "iicC*a", "FP:1:")
370 BUILTIN(__builtin_expect, "LiLiLi" , "nc")
371 BUILTIN(__builtin_prefetch, "vvC*.", "nc")
372 BUILTIN(__builtin_trap, "v", "nr")
373 BUILTIN(__builtin_unreachable, "v", "nr")
374 BUILTIN(__builtin_shufflevector, "v." , "nc")
375 BUILTIN(__builtin_alloca, "v*z" , "n")
377 // "Overloaded" Atomic operator builtins. These are overloaded to support data
378 // types of i8, i16, i32, i64, and i128. The front-end sees calls to the
379 // non-suffixed version of these (which has a bogus type) and transforms them to
380 // the right overloaded version in Sema (plus casts).
382 // FIXME: These assume that char -> i8, short -> i16, int -> i32,
383 // long long -> i64.
385 BUILTIN(__sync_fetch_and_add, "v.", "")
386 BUILTIN(__sync_fetch_and_add_1, "ccD*c.", "n")
387 BUILTIN(__sync_fetch_and_add_2, "ssD*s.", "n")
388 BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "n")
389 BUILTIN(__sync_fetch_and_add_8, "LLiLLiD*LLi.", "n")
390 BUILTIN(__sync_fetch_and_add_16, "LLLiLLLiD*LLLi.", "n")
392 BUILTIN(__sync_fetch_and_sub, "v.", "")
393 BUILTIN(__sync_fetch_and_sub_1, "ccD*c.", "n")
394 BUILTIN(__sync_fetch_and_sub_2, "ssD*s.", "n")
395 BUILTIN(__sync_fetch_and_sub_4, "iiD*i.", "n")
396 BUILTIN(__sync_fetch_and_sub_8, "LLiLLiD*LLi.", "n")
397 BUILTIN(__sync_fetch_and_sub_16, "LLLiLLLiD*LLLi.", "n")
399 BUILTIN(__sync_fetch_and_or, "v.", "")
400 BUILTIN(__sync_fetch_and_or_1, "ccD*c.", "n")
401 BUILTIN(__sync_fetch_and_or_2, "ssD*s.", "n")
402 BUILTIN(__sync_fetch_and_or_4, "iiD*i.", "n")
403 BUILTIN(__sync_fetch_and_or_8, "LLiLLiD*LLi.", "n")
404 BUILTIN(__sync_fetch_and_or_16, "LLLiLLLiD*LLLi.", "n")
406 BUILTIN(__sync_fetch_and_and, "v.", "")
407 BUILTIN(__sync_fetch_and_and_1, "ccD*c.", "n")
408 BUILTIN(__sync_fetch_and_and_2, "ssD*s.", "n")
409 BUILTIN(__sync_fetch_and_and_4, "iiD*i.", "n")
410 BUILTIN(__sync_fetch_and_and_8, "LLiLLiD*LLi.", "n")
411 BUILTIN(__sync_fetch_and_and_16, "LLLiLLLiD*LLLi.", "n")
413 BUILTIN(__sync_fetch_and_xor, "v.", "")
414 BUILTIN(__sync_fetch_and_xor_1, "ccD*c.", "n")
415 BUILTIN(__sync_fetch_and_xor_2, "ssD*s.", "n")
416 BUILTIN(__sync_fetch_and_xor_4, "iiD*i.", "n")
417 BUILTIN(__sync_fetch_and_xor_8, "LLiLLiD*LLi.", "n")
418 BUILTIN(__sync_fetch_and_xor_16, "LLLiLLLiD*LLLi.", "n")
421 BUILTIN(__sync_add_and_fetch, "v.", "")
422 BUILTIN(__sync_add_and_fetch_1, "ccD*c.", "n")
423 BUILTIN(__sync_add_and_fetch_2, "ssD*s.", "n")
424 BUILTIN(__sync_add_and_fetch_4, "iiD*i.", "n")
425 BUILTIN(__sync_add_and_fetch_8, "LLiLLiD*LLi.", "n")
426 BUILTIN(__sync_add_and_fetch_16, "LLLiLLLiD*LLLi.", "n")
428 BUILTIN(__sync_sub_and_fetch, "v.", "")
429 BUILTIN(__sync_sub_and_fetch_1, "ccD*c.", "n")
430 BUILTIN(__sync_sub_and_fetch_2, "ssD*s.", "n")
431 BUILTIN(__sync_sub_and_fetch_4, "iiD*i.", "n")
432 BUILTIN(__sync_sub_and_fetch_8, "LLiLLiD*LLi.", "n")
433 BUILTIN(__sync_sub_and_fetch_16, "LLLiLLLiD*LLLi.", "n")
435 BUILTIN(__sync_or_and_fetch, "v.", "")
436 BUILTIN(__sync_or_and_fetch_1, "ccD*c.", "n")
437 BUILTIN(__sync_or_and_fetch_2, "ssD*s.", "n")
438 BUILTIN(__sync_or_and_fetch_4, "iiD*i.", "n")
439 BUILTIN(__sync_or_and_fetch_8, "LLiLLiD*LLi.", "n")
440 BUILTIN(__sync_or_and_fetch_16, "LLLiLLLiD*LLLi.", "n")
442 BUILTIN(__sync_and_and_fetch, "v.", "")
443 BUILTIN(__sync_and_and_fetch_1, "ccD*c.", "n")
444 BUILTIN(__sync_and_and_fetch_2, "ssD*s.", "n")
445 BUILTIN(__sync_and_and_fetch_4, "iiD*i.", "n")
446 BUILTIN(__sync_and_and_fetch_8, "LLiLLiD*LLi.", "n")
447 BUILTIN(__sync_and_and_fetch_16, "LLLiLLLiD*LLLi.", "n")
449 BUILTIN(__sync_xor_and_fetch, "v.", "")
450 BUILTIN(__sync_xor_and_fetch_1, "ccD*c.", "n")
451 BUILTIN(__sync_xor_and_fetch_2, "ssD*s.", "n")
452 BUILTIN(__sync_xor_and_fetch_4, "iiD*i.", "n")
453 BUILTIN(__sync_xor_and_fetch_8, "LLiLLiD*LLi.", "n")
454 BUILTIN(__sync_xor_and_fetch_16, "LLLiLLLiD*LLLi.", "n")
456 BUILTIN(__sync_bool_compare_and_swap, "v.", "")
457 BUILTIN(__sync_bool_compare_and_swap_1, "bcD*cc.", "n")
458 BUILTIN(__sync_bool_compare_and_swap_2, "bsD*ss.", "n")
459 BUILTIN(__sync_bool_compare_and_swap_4, "biD*ii.", "n")
460 BUILTIN(__sync_bool_compare_and_swap_8, "bLLiD*LLiLLi.", "n")
461 BUILTIN(__sync_bool_compare_and_swap_16, "bLLLiD*LLLiLLLi.", "n")
463 BUILTIN(__sync_val_compare_and_swap, "v.", "")
464 BUILTIN(__sync_val_compare_and_swap_1, "ccD*cc.", "n")
465 BUILTIN(__sync_val_compare_and_swap_2, "ssD*ss.", "n")
466 BUILTIN(__sync_val_compare_and_swap_4, "iiD*ii.", "n")
467 BUILTIN(__sync_val_compare_and_swap_8, "LLiLLiD*LLiLLi.", "n")
468 BUILTIN(__sync_val_compare_and_swap_16, "LLLiLLLiD*LLLiLLLi.", "n")
470 BUILTIN(__sync_lock_test_and_set, "v.", "")
471 BUILTIN(__sync_lock_test_and_set_1, "ccD*c.", "n")
472 BUILTIN(__sync_lock_test_and_set_2, "ssD*s.", "n")
473 BUILTIN(__sync_lock_test_and_set_4, "iiD*i.", "n")
474 BUILTIN(__sync_lock_test_and_set_8, "LLiLLiD*LLi.", "n")
475 BUILTIN(__sync_lock_test_and_set_16, "LLLiLLLiD*LLLi.", "n")
477 BUILTIN(__sync_lock_release, "v.", "")
478 BUILTIN(__sync_lock_release_1, "vcD*.", "n")
479 BUILTIN(__sync_lock_release_2, "vsD*.", "n")
480 BUILTIN(__sync_lock_release_4, "viD*.", "n")
481 BUILTIN(__sync_lock_release_8, "vLLiD*.", "n")
482 BUILTIN(__sync_lock_release_16, "vLLLiD*.", "n")
486 // Non-overloaded atomic builtins.
487 BUILTIN(__sync_synchronize, "v.", "n")
488 // LLVM instruction builtin [Clang extension].
489 BUILTIN(__builtin_llvm_memory_barrier,"vbbbbb", "n")
490 // GCC does not support these, they are a Clang extension.
491 BUILTIN(__sync_fetch_and_min, "iiD*i", "n")
492 BUILTIN(__sync_fetch_and_max, "iiD*i", "n")
493 BUILTIN(__sync_fetch_and_umin, "UiUiD*Ui", "n")
494 BUILTIN(__sync_fetch_and_umax, "UiUiD*Ui", "n")
496 // Random libc builtins.
497 BUILTIN(__builtin_abort, "v", "Fnr")
498 BUILTIN(__builtin_index, "c*cC*i", "Fn")
499 BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
501 // Microsoft builtins.
502 BUILTIN(__assume, "vb", "n")
503 BUILTIN(__noop, "v.", "n")
505 // C99 library functions
506 // C99 stdlib.h
507 LIBBUILTIN(abort, "v", "fr", "stdlib.h")
508 LIBBUILTIN(calloc, "v*zz", "f", "stdlib.h")
509 LIBBUILTIN(exit, "vi", "fr", "stdlib.h")
510 LIBBUILTIN(_Exit, "vi", "fr", "stdlib.h")
511 LIBBUILTIN(malloc, "v*z", "f", "stdlib.h")
512 LIBBUILTIN(realloc, "v*v*z", "f", "stdlib.h")
513 // C99 string.h
514 LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h")
515 LIBBUILTIN(memmove, "v*v*vC*z", "f", "string.h")
516 LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h")
517 LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h")
518 LIBBUILTIN(strcat, "c*c*cC*", "f", "string.h")
519 LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h")
520 LIBBUILTIN(strxfrm, "zc*cC*z", "f", "string.h")
521 LIBBUILTIN(memchr, "v*vC*iz", "f", "string.h")
522 LIBBUILTIN(strchr, "c*cC*i", "f", "string.h")
523 LIBBUILTIN(strcspn, "zcC*cC*", "f", "string.h")
524 LIBBUILTIN(strpbrk, "c*cC*cC*", "f", "string.h")
525 LIBBUILTIN(strrchr, "c*cC*i", "f", "string.h")
526 LIBBUILTIN(strspn, "zcC*cC*", "f", "string.h")
527 LIBBUILTIN(strstr, "c*cC*cC*", "f", "string.h")
528 LIBBUILTIN(strtok, "c*c*cC*", "f", "string.h")
529 LIBBUILTIN(memset, "v*v*iz", "f", "string.h")
530 LIBBUILTIN(strerror, "c*i", "f", "string.h")
531 LIBBUILTIN(strlen, "zcC*", "f", "string.h")
532 // C99 stdio.h
533 LIBBUILTIN(printf, "icC*.", "fp:0:", "stdio.h")
534 LIBBUILTIN(fprintf, "iP*cC*.", "fp:1:", "stdio.h")
535 LIBBUILTIN(snprintf, "ic*zcC*.", "fp:2:", "stdio.h")
536 LIBBUILTIN(sprintf, "ic*cC*.", "fp:1:", "stdio.h")
537 LIBBUILTIN(vprintf, "icC*a", "fP:0:", "stdio.h")
538 LIBBUILTIN(vfprintf, "i.", "fP:1:", "stdio.h")
539 LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h")
540 LIBBUILTIN(vsprintf, "ic*cC*a", "fP:1:", "stdio.h")
541 LIBBUILTIN(scanf, "icC*.", "fs:0:", "stdio.h")
542 // C99
543 LIBBUILTIN(longjmp, "vJi", "fr", "setjmp.h")
545 // Non-C library functions
546 // FIXME: Non-C-standard stuff shouldn't be builtins in non-GNU mode!
547 LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")
548 // POSIX string.h
549 LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h")
550 LIBBUILTIN(stpncpy, "c*c*cC*z", "f", "string.h")
551 LIBBUILTIN(strdup, "c*cC*", "f", "string.h")
552 LIBBUILTIN(strndup, "c*cC*z", "f", "string.h")
553 // POSIX strings.h
554 LIBBUILTIN(index, "c*cC*i", "f", "strings.h")
555 LIBBUILTIN(rindex, "c*cC*i", "f", "strings.h")
556 LIBBUILTIN(bzero, "vv*z", "f", "strings.h")
557 // POSIX unistd.h
558 LIBBUILTIN(_exit, "vi", "fr", "unistd.h")
559 // POSIX setjmp.h
560 LIBBUILTIN(_longjmp, "vJi", "fr", "setjmp.h")
561 LIBBUILTIN(siglongjmp, "vSJi", "fr", "setjmp.h")
563 // FIXME: This type isn't very correct, it should be
564 // id objc_msgSend(id, SEL)
565 // but we need new type letters for that.
566 LIBBUILTIN(objc_msgSend, "v*.", "f", "objc/message.h")
567 BUILTIN(__builtin_objc_memmove_collectable, "v*v*vC*z", "nF")
569 // Builtin math library functions
570 LIBBUILTIN(pow, "ddd", "fe", "math.h")
571 LIBBUILTIN(powl, "LdLdLd", "fe", "math.h")
572 LIBBUILTIN(powf, "fff", "fe", "math.h")
574 LIBBUILTIN(sqrt, "dd", "fe", "math.h")
575 LIBBUILTIN(sqrtl, "LdLd", "fe", "math.h")
576 LIBBUILTIN(sqrtf, "ff", "fe", "math.h")
578 LIBBUILTIN(sin, "dd", "fe", "math.h")
579 LIBBUILTIN(sinl, "LdLd", "fe", "math.h")
580 LIBBUILTIN(sinf, "ff", "fe", "math.h")
582 LIBBUILTIN(cos, "dd", "fe", "math.h")
583 LIBBUILTIN(cosl, "LdLd", "fe", "math.h")
584 LIBBUILTIN(cosf, "ff", "fe", "math.h")
586 // Blocks runtime Builtin math library functions
587 LIBBUILTIN(_Block_object_assign, "vv*vC*iC", "f", "Blocks.h")
588 LIBBUILTIN(_Block_object_dispose, "vvC*iC", "f", "Blocks.h")
589 // FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
591 #undef BUILTIN
592 #undef LIBBUILTIN