Print this page
new smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/builtin.c
+++ new/usr/src/tools/smatch/src/builtin.c
1 1 /*
2 2 * builtin evaluation & expansion.
3 3 *
4 4 * Copyright (C) 2003 Transmeta Corp.
5 5 * 2003-2004 Linus Torvalds
6 6 *
7 7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 8 * of this software and associated documentation files (the "Software"), to deal
9 9 * in the Software without restriction, including without limitation the rights
10 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 11 * copies of the Software, and to permit persons to whom the Software is
12 12 * furnished to do so, subject to the following conditions:
13 13 *
14 14 * The above copyright notice and this permission notice shall be included in
15 15 * all copies or substantial portions of the Software.
16 16 *
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 23 * THE SOFTWARE.
24 24 */
25 25
26 26 #include "expression.h"
27 +#include "evaluate.h"
27 28 #include "expand.h"
28 29 #include "symbol.h"
29 30 #include "compat/bswap.h"
31 +#include <stdarg.h>
30 32
31 33 static int evaluate_to_int_const_expr(struct expression *expr)
32 34 {
33 35 expr->ctype = &int_ctype;
34 36 expr->flags |= CEF_SET_ICE;
35 37 return 1;
36 38 }
37 39
38 40 static int evaluate_pure_unop(struct expression *expr)
39 41 {
40 42 struct expression *arg = first_expression(expr->args);
41 43 int flags = arg->flags;
42 44
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
43 45 /*
44 46 * Allow such functions with a constant integer expression
45 47 * argument to be treated as a *constant* integer.
46 48 * This allow us to use them in switch() { case ...:
47 49 */
48 50 flags |= (flags & CEF_ICE) ? CEF_SET_INT : 0;
49 51 expr->flags = flags;
50 52 return 1;
51 53 }
52 54
53 -
54 -static int evaluate_expect(struct expression *expr)
55 +/*
56 + * eval_args - check the number of arguments and evaluate them.
57 + */
58 +static int eval_args(struct expression *expr, int n)
55 59 {
56 - /* Should we evaluate it to return the type of the first argument? */
57 - expr->ctype = &int_ctype;
58 - return 1;
59 -}
60 -
61 -static int arguments_choose(struct expression *expr)
62 -{
63 - struct expression_list *arglist = expr->args;
64 60 struct expression *arg;
65 - int i = 0;
61 + struct symbol *sym;
62 + const char *msg;
63 + int rc = 1;
66 64
67 - FOR_EACH_PTR (arglist, arg) {
65 + FOR_EACH_PTR(expr->args, arg) {
66 + if (n-- == 0) {
67 + msg = "too many arguments";
68 + goto error;
69 + }
68 70 if (!evaluate_expression(arg))
69 - return 0;
70 - i++;
71 + rc = 0;
71 72 } END_FOR_EACH_PTR(arg);
72 - if (i < 3) {
73 - sparse_error(expr->pos,
74 - "not enough arguments for __builtin_choose_expr");
75 - return 0;
76 - } if (i > 3) {
77 - sparse_error(expr->pos,
78 - "too many arguments for __builtin_choose_expr");
79 - return 0;
73 + if (n > 0) {
74 + msg = "not enough arguments";
75 + goto error;
80 76 }
81 - return 1;
77 + return rc;
78 +
79 +error:
80 + sym = expr->fn->ctype;
81 + expression_error(expr, "%s for %s", msg, show_ident(sym->ident));
82 + return 0;
82 83 }
83 84
85 +static int args_triadic(struct expression *expr)
86 +{
87 + return eval_args(expr, 3);
88 +}
89 +
84 90 static int evaluate_choose(struct expression *expr)
85 91 {
86 92 struct expression_list *list = expr->args;
87 93 struct expression *arg, *args[3];
88 94 int n = 0;
89 95
90 96 /* there will be exactly 3; we'd already verified that */
91 97 FOR_EACH_PTR(list, arg) {
92 98 args[n++] = arg;
93 99 } END_FOR_EACH_PTR(arg);
94 100
95 101 *expr = get_expression_value(args[0]) ? *args[1] : *args[2];
96 102
97 103 return 1;
98 104 }
99 105
100 106 static int expand_expect(struct expression *expr, int cost)
101 107 {
102 108 struct expression *arg = first_ptr_list((struct ptr_list *) expr->args);
103 109
104 110 if (arg)
105 111 *expr = *arg;
106 112 return 0;
107 113 }
108 114
109 115 /*
110 116 * __builtin_warning() has type "int" and always returns 1,
111 117 * so that you can use it in conditionals or whatever
112 118 */
113 119 static int expand_warning(struct expression *expr, int cost)
114 120 {
115 121 struct expression *arg;
116 122 struct expression_list *arglist = expr->args;
117 123
118 124 FOR_EACH_PTR (arglist, arg) {
119 125 /*
120 126 * Constant strings get printed out as a warning. By the
121 127 * time we get here, the EXPR_STRING has been fully
122 128 * evaluated, so by now it's an anonymous symbol with a
123 129 * string initializer.
124 130 *
125 131 * Just for the heck of it, allow any constant string
126 132 * symbol.
127 133 */
128 134 if (arg->type == EXPR_SYMBOL) {
129 135 struct symbol *sym = arg->symbol;
130 136 if (sym->initializer && sym->initializer->type == EXPR_STRING) {
131 137 struct string *string = sym->initializer->string;
132 138 warning(expr->pos, "%*s", string->length-1, string->data);
133 139 }
134 140 continue;
135 141 }
136 142
137 143 /*
138 144 * Any other argument is a conditional. If it's
139 145 * non-constant, or it is false, we exit and do
140 146 * not print any warning.
141 147 */
142 148 if (arg->type != EXPR_VALUE)
143 149 goto out;
144 150 if (!arg->value)
145 151 goto out;
146 152 } END_FOR_EACH_PTR(arg);
147 153 out:
148 154 expr->type = EXPR_VALUE;
149 155 expr->value = 1;
150 156 expr->taint = 0;
151 157 return 0;
152 158 }
153 159
154 160 /* The arguments are constant if the cost of all of them is zero */
155 161 static int expand_constant_p(struct expression *expr, int cost)
156 162 {
157 163 expr->type = EXPR_VALUE;
158 164 expr->value = !cost;
159 165 expr->taint = 0;
160 166 return 0;
161 167 }
162 168
163 169 /* The arguments are safe, if their cost is less than SIDE_EFFECTS */
164 170 static int expand_safe_p(struct expression *expr, int cost)
165 171 {
166 172 expr->type = EXPR_VALUE;
167 173 expr->value = (cost < SIDE_EFFECTS);
168 174 expr->taint = 0;
169 175 return 0;
170 176 }
171 177
172 178 static struct symbol_op constant_p_op = {
173 179 .evaluate = evaluate_to_int_const_expr,
174 180 .expand = expand_constant_p
175 181 };
176 182
177 183 static struct symbol_op safe_p_op = {
↓ open down ↓ |
84 lines elided |
↑ open up ↑ |
178 184 .evaluate = evaluate_to_int_const_expr,
179 185 .expand = expand_safe_p
180 186 };
181 187
182 188 static struct symbol_op warning_op = {
183 189 .evaluate = evaluate_to_int_const_expr,
184 190 .expand = expand_warning
185 191 };
186 192
187 193 static struct symbol_op expect_op = {
188 - .evaluate = evaluate_expect,
189 194 .expand = expand_expect
190 195 };
191 196
192 197 static struct symbol_op choose_op = {
198 + .args = args_triadic,
193 199 .evaluate = evaluate_choose,
194 - .args = arguments_choose,
195 200 };
196 201
197 202 /* The argument is constant and valid if the cost is zero */
198 203 static int expand_bswap(struct expression *expr, int cost)
199 204 {
200 205 struct expression *arg;
201 206 long long val;
202 207
203 208 if (cost)
204 209 return cost;
205 210
206 211 /* the arguments number & type have already been checked */
207 212 arg = first_expression(expr->args);
208 213 val = get_expression_value_silent(arg);
209 214 switch (expr->ctype->bit_size) {
210 215 case 16: expr->value = bswap16(val); break;
211 216 case 32: expr->value = bswap32(val); break;
212 217 case 64: expr->value = bswap64(val); break;
213 218 default: /* impossible error */
214 219 return SIDE_EFFECTS;
215 220 }
216 221
217 222 expr->type = EXPR_VALUE;
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
218 223 expr->taint = 0;
219 224 return 0;
220 225 }
221 226
222 227 static struct symbol_op bswap_op = {
223 228 .evaluate = evaluate_pure_unop,
224 229 .expand = expand_bswap,
225 230 };
226 231
227 232
233 +static int evaluate_fp_unop(struct expression *expr)
234 +{
235 + struct expression *arg;
236 +
237 + if (!eval_args(expr, 1))
238 + return 0;
239 +
240 + arg = first_expression(expr->args);
241 + if (!is_float_type(arg->ctype)) {
242 + expression_error(expr, "non-floating-point argument in call to %s()",
243 + show_ident(expr->fn->ctype->ident));
244 + return 0;
245 + }
246 + return 1;
247 +}
248 +
249 +static struct symbol_op fp_unop_op = {
250 + .evaluate = evaluate_fp_unop,
251 +};
252 +
253 +
254 +static int evaluate_overflow_gen(struct expression *expr, int ptr)
255 +{
256 + struct expression *arg;
257 + int n = 0;
258 +
259 + /* there will be exactly 3; we'd already verified that */
260 + FOR_EACH_PTR(expr->args, arg) {
261 + struct symbol *type;
262 +
263 + n++;
264 + if (!arg || !(type = arg->ctype))
265 + return 0;
266 + // 1st & 2nd args must be a basic integer type
267 + // 3rd arg must be a pointer to such a type.
268 + if (n == 3 && ptr) {
269 + if (type->type == SYM_NODE)
270 + type = type->ctype.base_type;
271 + if (!type)
272 + return 0;
273 + if (type->type != SYM_PTR)
274 + goto err;
275 + type = type->ctype.base_type;
276 + if (!type)
277 + return 0;
278 + }
279 + if (type->type == SYM_NODE)
280 + type = type->ctype.base_type;
281 + if (!type)
282 + return 0;
283 + if (type->ctype.base_type != &int_type || type == &bool_ctype)
284 + goto err;
285 + } END_FOR_EACH_PTR(arg);
286 +
287 + // the builtin returns a bool
288 + expr->ctype = &bool_ctype;
289 + return 1;
290 +
291 +err:
292 + sparse_error(arg->pos, "invalid type for argument %d:", n);
293 + info(arg->pos, " %s", show_typename(arg->ctype));
294 + expr->ctype = &bad_ctype;
295 + return 0;
296 +}
297 +
298 +static int evaluate_overflow(struct expression *expr)
299 +{
300 + return evaluate_overflow_gen(expr, 1);
301 +}
302 +
303 +static struct symbol_op overflow_op = {
304 + .args = args_triadic,
305 + .evaluate = evaluate_overflow,
306 +};
307 +
308 +static int evaluate_overflow_p(struct expression *expr)
309 +{
310 + return evaluate_overflow_gen(expr, 0);
311 +}
312 +
313 +static struct symbol_op overflow_p_op = {
314 + .args = args_triadic,
315 + .evaluate = evaluate_overflow_p,
316 +};
317 +
318 +
228 319 /*
229 320 * Builtin functions
230 321 */
231 322 static struct symbol builtin_fn_type = { .type = SYM_FN /* , .variadic =1 */ };
232 323 static struct sym_init {
233 324 const char *name;
234 325 struct symbol *base_type;
235 326 unsigned int modifiers;
236 327 struct symbol_op *op;
237 328 } builtins_table[] = {
238 329 { "__builtin_constant_p", &builtin_fn_type, MOD_TOPLEVEL, &constant_p_op },
239 330 { "__builtin_safe_p", &builtin_fn_type, MOD_TOPLEVEL, &safe_p_op },
240 331 { "__builtin_warning", &builtin_fn_type, MOD_TOPLEVEL, &warning_op },
241 332 { "__builtin_expect", &builtin_fn_type, MOD_TOPLEVEL, &expect_op },
242 333 { "__builtin_choose_expr", &builtin_fn_type, MOD_TOPLEVEL, &choose_op },
243 - { "__builtin_bswap16", NULL, MOD_TOPLEVEL, &bswap_op },
244 - { "__builtin_bswap32", NULL, MOD_TOPLEVEL, &bswap_op },
245 - { "__builtin_bswap64", NULL, MOD_TOPLEVEL, &bswap_op },
334 + { "__builtin_bswap16", &builtin_fn_type, MOD_TOPLEVEL, &bswap_op },
335 + { "__builtin_bswap32", &builtin_fn_type, MOD_TOPLEVEL, &bswap_op },
336 + { "__builtin_bswap64", &builtin_fn_type, MOD_TOPLEVEL, &bswap_op },
337 + { "__builtin_isfinite", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
338 + { "__builtin_isinf", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
339 + { "__builtin_isinf_sign", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
340 + { "__builtin_isnan", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
341 + { "__builtin_isnormal", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
342 + { "__builtin_signbit", &builtin_fn_type, MOD_TOPLEVEL, &fp_unop_op },
343 + { "__builtin_add_overflow", &builtin_fn_type, MOD_TOPLEVEL, &overflow_op },
344 + { "__builtin_sub_overflow", &builtin_fn_type, MOD_TOPLEVEL, &overflow_op },
345 + { "__builtin_mul_overflow", &builtin_fn_type, MOD_TOPLEVEL, &overflow_op },
346 + { "__builtin_add_overflow_p", &builtin_fn_type, MOD_TOPLEVEL, &overflow_p_op },
347 + { "__builtin_sub_overflow_p", &builtin_fn_type, MOD_TOPLEVEL, &overflow_p_op },
348 + { "__builtin_mul_overflow_p", &builtin_fn_type, MOD_TOPLEVEL, &overflow_p_op },
246 349 { NULL, NULL, 0 }
247 350 };
248 351
249 352 void init_builtins(int stream)
250 353 {
251 354 struct sym_init *ptr;
252 355
253 356 builtin_fn_type.variadic = 1;
254 357 for (ptr = builtins_table; ptr->name; ptr++) {
255 358 struct symbol *sym;
256 359 sym = create_symbol(stream, ptr->name, SYM_NODE, NS_SYMBOL);
257 360 sym->ctype.base_type = ptr->base_type;
258 361 sym->ctype.modifiers = ptr->modifiers;
259 362 sym->op = ptr->op;
363 + sym->builtin = 1;
260 364 }
365 +}
366 +
367 +static void declare_builtin(const char *name, struct symbol *rtype, int variadic, ...)
368 +{
369 + int stream = 0; // FIXME
370 + struct symbol *sym = create_symbol(stream, name, SYM_NODE, NS_SYMBOL);
371 + struct symbol *fun = alloc_symbol(sym->pos, SYM_FN);
372 + struct symbol *arg;
373 + va_list args;
374 +
375 + sym->ctype.base_type = fun;
376 + sym->ctype.modifiers = MOD_TOPLEVEL;
377 + sym->builtin = 1;
378 +
379 + fun->ctype.base_type = rtype;
380 + fun->variadic = variadic;
381 +
382 + va_start(args, variadic);
383 + while ((arg = va_arg(args, struct symbol *))) {
384 + struct symbol *anode = alloc_symbol(sym->pos, SYM_NODE);
385 + anode->ctype.base_type = arg;
386 + add_symbol(&fun->arguments, anode);
387 + }
388 + va_end(args);
389 +}
390 +
391 +void declare_builtins(void)
392 +{
393 + struct symbol *va_list_ctype = &ptr_ctype;
394 +
395 + declare_builtin("__builtin_abort", &void_ctype, 0, NULL);
396 + declare_builtin("__builtin_abs", &int_ctype , 0, &int_ctype, NULL);
397 + declare_builtin("__builtin_alloca", &ptr_ctype, 0, size_t_ctype, NULL);
398 + declare_builtin("__builtin_alpha_cmpbge", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
399 + declare_builtin("__builtin_alpha_extbl", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
400 + declare_builtin("__builtin_alpha_extwl", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
401 + declare_builtin("__builtin_alpha_insbl", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
402 + declare_builtin("__builtin_alpha_inslh", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
403 + declare_builtin("__builtin_alpha_insql", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
404 + declare_builtin("__builtin_alpha_inswl", &long_ctype, 0, &long_ctype, &long_ctype, NULL);
405 + declare_builtin("__builtin_bcmp", &int_ctype , 0, &const_ptr_ctype, &const_ptr_ctype, size_t_ctype, NULL);
406 + declare_builtin("__builtin_bcopy", &void_ctype, 0, &const_ptr_ctype, &ptr_ctype, size_t_ctype, NULL);
407 + declare_builtin("__builtin_bswap16", &ushort_ctype, 0, &ushort_ctype, NULL);
408 + declare_builtin("__builtin_bswap32", &uint_ctype, 0, &uint_ctype, NULL);
409 + declare_builtin("__builtin_bswap64", &ullong_ctype, 0, &ullong_ctype, NULL);
410 + declare_builtin("__builtin_bzero", &void_ctype, 0, &ptr_ctype, size_t_ctype, NULL);
411 + declare_builtin("__builtin_calloc", &ptr_ctype, 0, size_t_ctype, size_t_ctype, NULL);
412 + declare_builtin("__builtin_clrsb", &int_ctype, 0, &int_ctype, NULL);
413 + declare_builtin("__builtin_clrsbl", &int_ctype, 0, &long_ctype, NULL);
414 + declare_builtin("__builtin_clrsbll", &int_ctype, 0, &llong_ctype, NULL);
415 + declare_builtin("__builtin_clz", &int_ctype, 0, &int_ctype, NULL);
416 + declare_builtin("__builtin_clzl", &int_ctype, 0, &long_ctype, NULL);
417 + declare_builtin("__builtin_clzll", &int_ctype, 0, &llong_ctype, NULL);
418 + declare_builtin("__builtin_ctz", &int_ctype, 0, &int_ctype, NULL);
419 + declare_builtin("__builtin_ctzl", &int_ctype, 0, &long_ctype, NULL);
420 + declare_builtin("__builtin_ctzll", &int_ctype, 0, &llong_ctype, NULL);
421 + declare_builtin("__builtin_exit", &void_ctype, 0, &int_ctype, NULL);
422 + declare_builtin("__builtin_expect", &long_ctype, 0, &long_ctype ,&long_ctype, NULL);
423 + declare_builtin("__builtin_extract_return_addr", &ptr_ctype, 0, &ptr_ctype, NULL);
424 + declare_builtin("__builtin_fabs", &double_ctype, 0, &double_ctype, NULL);
425 + declare_builtin("__builtin_ffs", &int_ctype, 0, &int_ctype, NULL);
426 + declare_builtin("__builtin_ffsl", &int_ctype, 0, &long_ctype, NULL);
427 + declare_builtin("__builtin_ffsll", &int_ctype, 0, &llong_ctype, NULL);
428 + declare_builtin("__builtin_frame_address", &ptr_ctype, 0, &uint_ctype, NULL);
429 + declare_builtin("__builtin_free", &void_ctype, 0, &ptr_ctype, NULL);
430 + declare_builtin("__builtin_huge_val", &double_ctype, 0, NULL);
431 + declare_builtin("__builtin_huge_valf", &float_ctype, 0, NULL);
432 + declare_builtin("__builtin_huge_vall", &ldouble_ctype, 0, NULL);
433 + declare_builtin("__builtin_index", &string_ctype, 0, &const_string_ctype, &int_ctype, NULL);
434 + declare_builtin("__builtin_inf", &double_ctype, 0, NULL);
435 + declare_builtin("__builtin_inff", &float_ctype, 0, NULL);
436 + declare_builtin("__builtin_infl", &ldouble_ctype, 0, NULL);
437 + declare_builtin("__builtin_isfinite", &int_ctype, 1, NULL);
438 + declare_builtin("__builtin_isgreater", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
439 + declare_builtin("__builtin_isgreaterequal", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
440 + declare_builtin("__builtin_isinf", &int_ctype, 1, NULL);
441 + declare_builtin("__builtin_isinf_sign", &int_ctype, 1, NULL);
442 + declare_builtin("__builtin_isless", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
443 + declare_builtin("__builtin_islessequal", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
444 + declare_builtin("__builtin_islessgreater", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
445 + declare_builtin("__builtin_isnan", &int_ctype, 1, NULL);
446 + declare_builtin("__builtin_isnormal", &int_ctype, 1, NULL);
447 + declare_builtin("__builtin_isunordered", &int_ctype, 0, &float_ctype, &float_ctype, NULL);
448 + declare_builtin("__builtin_labs", &long_ctype, 0, &long_ctype, NULL);
449 + declare_builtin("__builtin_llabs", &llong_ctype, 0, &llong_ctype, NULL);
450 + declare_builtin("__builtin_malloc", &ptr_ctype, 0, size_t_ctype, NULL);
451 + declare_builtin("__builtin_memchr", &ptr_ctype, 0, &const_ptr_ctype, &int_ctype, size_t_ctype, NULL);
452 + declare_builtin("__builtin_memcmp", &int_ctype, 0, &const_ptr_ctype, &const_ptr_ctype, size_t_ctype, NULL);
453 + declare_builtin("__builtin_memcpy", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, NULL);
454 + declare_builtin("__builtin_memmove", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, NULL);
455 + declare_builtin("__builtin_mempcpy", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, NULL);
456 + declare_builtin("__builtin_memset", &ptr_ctype, 0, &ptr_ctype, &int_ctype, size_t_ctype, NULL);
457 + declare_builtin("__builtin_nan", &double_ctype, 0, &const_string_ctype, NULL);
458 + declare_builtin("__builtin_nanf", &float_ctype, 0, &const_string_ctype, NULL);
459 + declare_builtin("__builtin_nanl", &ldouble_ctype, 0, &const_string_ctype, NULL);
460 + declare_builtin("__builtin_object_size", size_t_ctype, 0, &const_ptr_ctype, &int_ctype, NULL);
461 + declare_builtin("__builtin_parity", &int_ctype, 0, &uint_ctype, NULL);
462 + declare_builtin("__builtin_parityl", &int_ctype, 0, &ulong_ctype, NULL);
463 + declare_builtin("__builtin_parityll", &int_ctype, 0, &ullong_ctype, NULL);
464 + declare_builtin("__builtin_popcount", &int_ctype, 0, &uint_ctype, NULL);
465 + declare_builtin("__builtin_popcountl", &int_ctype, 0, &ulong_ctype, NULL);
466 + declare_builtin("__builtin_popcountll", &int_ctype, 0, &ullong_ctype, NULL);
467 + declare_builtin("__builtin_prefetch", &void_ctype, 1, &const_ptr_ctype, NULL);
468 + declare_builtin("__builtin_printf", &int_ctype, 1, &const_string_ctype, NULL);
469 + declare_builtin("__builtin_puts", &int_ctype, 0, &const_string_ctype, NULL);
470 + declare_builtin("__builtin_realloc", &ptr_ctype, 0, &ptr_ctype, size_t_ctype, NULL);
471 + declare_builtin("__builtin_return_address", &ptr_ctype, 0, &uint_ctype, NULL);
472 + declare_builtin("__builtin_rindex", &string_ctype, 0, &const_string_ctype, &int_ctype, NULL);
473 + declare_builtin("__builtin_sadd_overflow", &bool_ctype, 0, &int_ctype, &int_ctype, &int_ptr_ctype, NULL);
474 + declare_builtin("__builtin_saddl_overflow", &bool_ctype, 0, &long_ctype, &long_ctype, &long_ptr_ctype, NULL);
475 + declare_builtin("__builtin_saddll_overflow", &bool_ctype, 0, &llong_ctype, &llong_ctype, &llong_ptr_ctype, NULL);
476 + declare_builtin("__builtin_signbit", &int_ctype, 1, NULL);
477 + declare_builtin("__builtin_smul_overflow", &bool_ctype, 0, &int_ctype, &int_ctype, &int_ptr_ctype, NULL);
478 + declare_builtin("__builtin_smull_overflow", &bool_ctype, 0, &long_ctype, &long_ctype, &long_ptr_ctype, NULL);
479 + declare_builtin("__builtin_smulll_overflow", &bool_ctype, 0, &llong_ctype, &llong_ctype, &llong_ptr_ctype, NULL);
480 + declare_builtin("__builtin_snprintf", &int_ctype, 1, &string_ctype, size_t_ctype, &const_string_ctype, NULL);
481 + declare_builtin("__builtin_sprintf", &int_ctype, 1, &string_ctype, &const_string_ctype, NULL);
482 + declare_builtin("__builtin_ssub_overflow", &bool_ctype, 0, &int_ctype, &int_ctype, &int_ptr_ctype, NULL);
483 + declare_builtin("__builtin_ssubl_overflow", &bool_ctype, 0, &long_ctype, &long_ctype, &long_ptr_ctype, NULL);
484 + declare_builtin("__builtin_ssubll_overflow", &bool_ctype, 0, &llong_ctype, &llong_ctype, &llong_ptr_ctype, NULL);
485 + declare_builtin("__builtin_stpcpy", &string_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
486 + declare_builtin("__builtin_stpncpy", &string_ctype, 0, &const_string_ctype, &const_string_ctype, size_t_ctype, NULL);
487 + declare_builtin("__builtin_strcasecmp", &int_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
488 + declare_builtin("__builtin_strcasestr", &string_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
489 + declare_builtin("__builtin_strcat", &string_ctype, 0, &string_ctype, &const_string_ctype, NULL);
490 + declare_builtin("__builtin_strchr", &string_ctype, 0, &const_string_ctype, &int_ctype, NULL);
491 + declare_builtin("__builtin_strcmp", &int_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
492 + declare_builtin("__builtin_strcpy", &string_ctype, 0, &string_ctype, &const_string_ctype, NULL);
493 + declare_builtin("__builtin_strcspn", size_t_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
494 + declare_builtin("__builtin_strdup", &string_ctype, 0, &const_string_ctype, NULL);
495 + declare_builtin("__builtin_strlen", size_t_ctype, 0, &const_string_ctype, NULL);
496 + declare_builtin("__builtin_strncasecmp", &int_ctype, 0, &const_string_ctype, &const_string_ctype, size_t_ctype, NULL);
497 + declare_builtin("__builtin_strncat", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, NULL);
498 + declare_builtin("__builtin_strncmp", &int_ctype, 0, &const_string_ctype, &const_string_ctype, size_t_ctype, NULL);
499 + declare_builtin("__builtin_strncpy", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, NULL);
500 + declare_builtin("__builtin_strndup", &string_ctype, 0, &const_string_ctype, size_t_ctype, NULL);
501 + declare_builtin("__builtin_strnstr", &string_ctype, 0, &const_string_ctype, &const_string_ctype, size_t_ctype, NULL);
502 + declare_builtin("__builtin_strpbrk", &string_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
503 + declare_builtin("__builtin_strrchr", &string_ctype, 0, &const_string_ctype, &int_ctype, NULL);
504 + declare_builtin("__builtin_strspn", size_t_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
505 + declare_builtin("__builtin_strstr", &string_ctype, 0, &const_string_ctype, &const_string_ctype, NULL);
506 + declare_builtin("__builtin_trap", &void_ctype, 0, NULL);
507 + declare_builtin("__builtin_uadd_overflow", &bool_ctype, 0, &uint_ctype, &uint_ctype, &uint_ptr_ctype, NULL);
508 + declare_builtin("__builtin_uaddl_overflow", &bool_ctype, 0, &ulong_ctype, &ulong_ctype, &ulong_ptr_ctype, NULL);
509 + declare_builtin("__builtin_uaddll_overflow", &bool_ctype, 0, &ullong_ctype, &ullong_ctype, &ullong_ptr_ctype, NULL);
510 + declare_builtin("__builtin_umul_overflow", &bool_ctype, 0, &uint_ctype, &uint_ctype, &uint_ptr_ctype, NULL);
511 + declare_builtin("__builtin_umull_overflow", &bool_ctype, 0, &ulong_ctype, &ulong_ctype, &ulong_ptr_ctype, NULL);
512 + declare_builtin("__builtin_umulll_overflow", &bool_ctype, 0, &ullong_ctype, &ullong_ctype, &ullong_ptr_ctype, NULL);
513 + declare_builtin("__builtin_unreachable", &void_ctype, 0, NULL);
514 + declare_builtin("__builtin_usub_overflow", &bool_ctype, 0, &uint_ctype, &uint_ctype, &uint_ptr_ctype, NULL);
515 + declare_builtin("__builtin_usubl_overflow", &bool_ctype, 0, &ulong_ctype, &ulong_ctype, &ulong_ptr_ctype, NULL);
516 + declare_builtin("__builtin_usubll_overflow", &bool_ctype, 0, &ullong_ctype, &ullong_ctype, &ullong_ptr_ctype, NULL);
517 + declare_builtin("__builtin_va_arg_pack_len", size_t_ctype, 0, NULL);
518 + declare_builtin("__builtin_vprintf", &int_ctype, 0, &const_string_ctype, va_list_ctype, NULL);
519 + declare_builtin("__builtin_vsnprintf", &int_ctype, 0, &string_ctype, size_t_ctype, &const_string_ctype, va_list_ctype, NULL);
520 + declare_builtin("__builtin_vsprintf", &int_ctype, 0, &string_ctype, &const_string_ctype, va_list_ctype, NULL);
521 +
522 + declare_builtin("__builtin___memcpy_chk", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, size_t_ctype, NULL);
523 + declare_builtin("__builtin___memmove_chk", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, size_t_ctype, NULL);
524 + declare_builtin("__builtin___mempcpy_chk", &ptr_ctype, 0, &ptr_ctype, &const_ptr_ctype, size_t_ctype, size_t_ctype, NULL);
525 + declare_builtin("__builtin___memset_chk", &ptr_ctype, 0, &ptr_ctype, &int_ctype, size_t_ctype, size_t_ctype, NULL);
526 + declare_builtin("__builtin___snprintf_chk", &int_ctype, 1, &string_ctype, size_t_ctype, &int_ctype , size_t_ctype, &const_string_ctype, NULL);
527 + declare_builtin("__builtin___sprintf_chk", &int_ctype, 1, &string_ctype, &int_ctype, size_t_ctype, &const_string_ctype, NULL);
528 + declare_builtin("__builtin___stpcpy_chk", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, NULL);
529 + declare_builtin("__builtin___strcat_chk", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, NULL);
530 + declare_builtin("__builtin___strcpy_chk", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, NULL);
531 + declare_builtin("__builtin___strncat_chk", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, size_t_ctype, NULL);
532 + declare_builtin("__builtin___strncpy_chk", &string_ctype, 0, &string_ctype, &const_string_ctype, size_t_ctype, size_t_ctype, NULL);
533 + declare_builtin("__builtin___vsnprintf_chk", &int_ctype, 0, &string_ctype, size_t_ctype, &int_ctype, size_t_ctype, &const_string_ctype, va_list_ctype, NULL);
534 + declare_builtin("__builtin___vsprintf_chk", &int_ctype, 0, &string_ctype, &int_ctype, size_t_ctype, &const_string_ctype, va_list_ctype, NULL);
535 +
536 + declare_builtin("__sync_add_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
537 + declare_builtin("__sync_and_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
538 + declare_builtin("__sync_bool_compare_and_swap", &int_ctype, 1, &ptr_ctype, NULL);
539 + declare_builtin("__sync_fetch_and_add", &int_ctype, 1, &ptr_ctype, NULL);
540 + declare_builtin("__sync_fetch_and_and", &int_ctype, 1, &ptr_ctype, NULL);
541 + declare_builtin("__sync_fetch_and_nand", &int_ctype, 1, &ptr_ctype, NULL);
542 + declare_builtin("__sync_fetch_and_or", &int_ctype, 1, &ptr_ctype, NULL);
543 + declare_builtin("__sync_fetch_and_sub", &int_ctype, 1, &ptr_ctype, NULL);
544 + declare_builtin("__sync_fetch_and_xor", &int_ctype, 1, &ptr_ctype, NULL);
545 + declare_builtin("__sync_lock_release", &void_ctype, 1, &ptr_ctype, NULL);
546 + declare_builtin("__sync_lock_test_and_set", &int_ctype, 1, &ptr_ctype, NULL);
547 + declare_builtin("__sync_nand_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
548 + declare_builtin("__sync_or_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
549 + declare_builtin("__sync_sub_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
550 + declare_builtin("__sync_synchronize", &void_ctype, 0, NULL);
551 + declare_builtin("__sync_val_compare_and_swap", &int_ctype, 1, &ptr_ctype, NULL);
552 + declare_builtin("__sync_xor_and_fetch", &int_ctype, 1, &ptr_ctype, NULL);
553 +
554 + // Blackfin-specific stuff
555 + declare_builtin("__builtin_bfin_csync", &void_ctype, 0, NULL);
556 + declare_builtin("__builtin_bfin_ssync", &void_ctype, 0, NULL);
557 + declare_builtin("__builtin_bfin_norm_fr1x32", &int_ctype, 0, &int_ctype, NULL);
261 558 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX