OSDN Git Service

Correct test results for avoid-bool-define fix
[pf3gnuchains/gcc-fork.git] / gcc / builtins.def
1 /* This file contains the definitions and documentation for the
2    builtins used in the GNU compiler.
3    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* Before including this file, you should define a macro:
23
24      DEF_BUILTIN (ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P,
25                   FALLBACK_P, NONANSI_P)
26
27    This macro will be called once for each builtin function.  The
28    ENUM will be of type `enum built_in_function', and will indicate
29    which builtin function is being processed.  The NAME of the builtin
30    function (which will always start with `__builtin_') is a string
31    literal.  The CLASS is of type `enum built_in_class' and indicates
32    what kind of builtin is being processed.
33
34    Some builtins are actually two separate functions.  For example,
35    for `strcmp' there are two builtin functions; `__builtin_strcmp'
36    and `strcmp' itself.  Both behave identically.  Other builtins
37    define only the `__builtin' variant.  If BOTH_P is TRUE, then this
38    builtin has both variants; otherwise, it is has only the first
39    variant.
40
41    TYPE indicates the type of the function.  The symbols correspond to
42    enumerals from builtin-types.def.  If BOTH_P is true, then LIBTYPE
43    is the type of the non-`__builtin_' variant.  Otherwise, LIBTYPE
44    should be ignored.
45
46    If FALLBACK_P is true then, if for some reason, the compiler cannot
47    expand the builtin function directly, it will call the
48    corresponding library function (which does not have the
49    `__builtin_' prefix.
50
51    If NONANSI_P is true, then the non-`__builtin_' variant is not an
52    ANSI/ISO library function, and so we should pretend it does not
53    exist when compiling in ANSI conformant mode.  */
54    
55 /* A GCC builtin (like __builtin_saveregs) is provided by the
56    compiler, but does not correspond to a function in the standard
57    library.  */
58 #undef DEF_GCC_BUILTIN
59 #define DEF_GCC_BUILTIN(ENUM, NAME, TYPE)                       \
60   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, BT_LAST,      \
61                false, false, false)
62
63
64 /* A fallback builtin is a builtin (like __builtin_puts) that falls
65    back to the corresopnding library function if necessary -- but
66    for which we should not introduce the non-`__builtin' variant of
67    the name.  */
68 #undef DEF_FALLBACK_BUILTIN                             
69 #define DEF_FALLBACK_BUILTIN(ENUM, NAME, TYPE)          \
70   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
71                false, true, false)
72
73 /* A library builtin (like __builtin_strchr) is a builtin equivalent
74    of an ANSI/ISO standard library function.  In addition to the
75    `__builtin' version, we will create a an ordinary version (e.g,
76    `strchr') as well.  If we cannot compute the answer using the
77    builtin function, we will fall back to the standard library
78    version. */
79 #undef DEF_LIB_BUILTIN                                  
80 #define DEF_LIB_BUILTIN(ENUM, NAME, TYPE)               \
81   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
82                true, true, false)
83
84 /* Like DEF_LIB_BUILTIN, except that a call to the builtin should
85    never fall back to the library version.  */
86 #undef DEF_LIB_ALWAYS_BUILTIN                           
87 #define DEF_LIB_ALWAYS_BUILTIN(ENUM, NAME, TYPE)        \
88   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
89                true, false, true)
90
91 /* Like DEF_LIB_BUILTIN, except that the function is not one that is
92    specified by ANSI/ISO C.  So, when we're being fully conformant we
93    ignore the version of these builtins that does not begin with
94    __builtin.  */
95 #undef DEF_EXT_LIB_BUILTIN                              
96 #define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE)           \
97   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
98                true, true, true)
99
100 /* Like DEF_LIB_BUILTIN, except that the function is only a part of
101    the standard in C99 or above.  */
102 #undef DEF_C99_BUILTIN                                  
103 #define DEF_C99_BUILTIN(ENUM, NAME, TYPE)               \
104   DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
105                true, !flag_isoc99, true)
106
107 /* Like DEF_LIB_BUILTIN, except that the function is expanded in the
108    front-end.  */
109 #undef DEF_FRONT_END_LIB_BUILTIN                        
110 #define DEF_FRONT_END_LIB_BUILTIN(ENUM, NAME, TYPE)             \
111   DEF_BUILTIN (ENUM, NAME, BUILT_IN_FRONTEND, TYPE, TYPE,       \
112                true, true, false)
113
114 /* A built-in that is not currently used.  */
115 #undef DEF_UNUSED_BUILTIN                                       
116 #define DEF_UNUSED_BUILTIN(X)                                   \
117   DEF_BUILTIN (X, (const char *) NULL, NOT_BUILT_IN, BT_LAST,   \
118                BT_LAST, false, false, false)
119
120 /* If SMALL_STACK is defined, then `alloca' is only defined in its
121    `__builtin' form.  */
122 #if SMALL_STACK  
123 DEF_FALLBACK_BUILTIN(BUILT_IN_ALLOCA,
124                      "__builtin_alloca",
125                      BT_FN_PTR_SIZE)
126 #else
127 DEF_EXT_LIB_BUILTIN(BUILT_IN_ALLOCA,
128                     "__builtin_alloca",
129                     BT_FN_PTR_SIZE)
130 #endif
131
132 DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_ABS,
133                        "__builtin_abs",
134                        BT_FN_INT_INT)
135 DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_LABS,
136                        "__builtin_labs",
137                        BT_FN_LONG_LONG)
138
139 DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABS,
140                        "__builtin_fabs",
141                        BT_FN_DOUBLE_DOUBLE)
142 DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSF,
143                        "__builtin_fabsf",
144                        BT_FN_FLOAT_FLOAT)
145 DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL,
146                        "__builtin_fabsl",
147                        BT_FN_LONG_DOUBLE_LONG_DOUBLE)
148
149 DEF_C99_BUILTIN(BUILT_IN_LLABS,
150                 "__builtin_llabs",
151                 BT_FN_LONGLONG_LONGLONG)
152 DEF_C99_BUILTIN(BUILT_IN_IMAXABS,
153                 "__builtin_imaxabs",
154                 BT_FN_INTMAX_INTMAX)
155 DEF_C99_BUILTIN(BUILT_IN_CONJ,
156                 "__builtin_conj",
157                 BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE)
158 DEF_C99_BUILTIN(BUILT_IN_CONJF,
159                 "__builtin_conjf",
160                 BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT)
161 DEF_C99_BUILTIN(BUILT_IN_CONJL,
162                 "__builtin_conjl",
163                 BT_FN_COMPLEX_LONG_DOUBLE_COMPLEX_LONG_DOUBLE)
164 DEF_C99_BUILTIN(BUILT_IN_CREAL,
165                 "__builtin_creal",
166                 BT_FN_DOUBLE_COMPLEX_DOUBLE)
167 DEF_C99_BUILTIN(BUILT_IN_CREALF,
168                 "__builtin_crealf",
169                 BT_FN_FLOAT_COMPLEX_FLOAT)
170 DEF_C99_BUILTIN(BUILT_IN_CREALL,
171                 "__builtin_creall",
172                 BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE)
173 DEF_C99_BUILTIN(BUILT_IN_CIMAG,
174                 "__builtin_cimag",
175                 BT_FN_DOUBLE_COMPLEX_DOUBLE)
176 DEF_C99_BUILTIN(BUILT_IN_CIMAGF,
177                 "__builtin_cimagf",
178                 BT_FN_FLOAT_COMPLEX_FLOAT)
179 DEF_C99_BUILTIN(BUILT_IN_CIMAGL,
180                 "__builtin_cimagl",
181                 BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE)
182
183 DEF_UNUSED_BUILTIN(BUILT_IN_DIV)
184 DEF_UNUSED_BUILTIN(BUILT_IN_LDIV)
185 DEF_UNUSED_BUILTIN(BUILT_IN_FFLOOR)
186 DEF_UNUSED_BUILTIN(BUILT_IN_FCEIL)
187 DEF_UNUSED_BUILTIN(BUILT_IN_FMOD)
188 DEF_UNUSED_BUILTIN(BUILT_IN_FREM)
189
190 /* The system prototypes for `bzero' and `bcmp' functions have many
191    variations, so don't specify parameters to avoid conflicts.  The
192    expand_* functions check the argument types anyway.  */
193 DEF_BUILTIN (BUILT_IN_BZERO,
194              "__builtin_bzero",
195              BUILT_IN_NORMAL,
196              BT_FN_VOID_TRAD_PTR_LEN, 
197              BT_FN_VOID_VAR,
198              true, true, true)
199 DEF_BUILTIN (BUILT_IN_BCMP,
200              "__builtin_bcmp",
201              BUILT_IN_NORMAL,
202              BT_FN_INT_TRAD_CONST_PTR_TRAD_CONST_PTR_LEN,
203              BT_FN_INT_VAR,
204              true, true, true)
205
206 DEF_EXT_LIB_BUILTIN(BUILT_IN_FFS,
207                     "__builtin_ffs",
208                     BT_FN_INT_INT)
209 DEF_EXT_LIB_BUILTIN(BUILT_IN_INDEX,
210                     "__builtin_index",
211                     BT_FN_STRING_CONST_STRING_INT)
212 DEF_EXT_LIB_BUILTIN(BUILT_IN_RINDEX,
213                     "__builtin_rindex",
214                     BT_FN_STRING_CONST_STRING_INT)
215
216 DEF_LIB_BUILTIN(BUILT_IN_MEMCPY,
217                 "__builtin_memcpy",
218                 BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE)
219 DEF_LIB_BUILTIN(BUILT_IN_MEMCMP,
220                 "__builtin_memcmp",
221                 BT_FN_INT_CONST_PTR_CONST_PTR_SIZE)
222 DEF_LIB_BUILTIN(BUILT_IN_MEMSET,
223                 "__builtin_memset",
224                 BT_FN_TRAD_PTR_PTR_INT_SIZE)
225
226 DEF_LIB_BUILTIN(BUILT_IN_STRCAT,
227                 "__builtin_strcat",
228                 BT_FN_STRING_STRING_CONST_STRING)
229 DEF_LIB_BUILTIN(BUILT_IN_STRNCAT,
230                 "__builtin_strncat",
231                 BT_FN_STRING_STRING_CONST_STRING_SIZE)
232 DEF_LIB_BUILTIN(BUILT_IN_STRCPY,
233                 "__builtin_strcpy",
234                 BT_FN_STRING_STRING_CONST_STRING)
235 DEF_LIB_BUILTIN(BUILT_IN_STRNCPY,
236                 "__builtin_strncpy",
237                 BT_FN_STRING_STRING_CONST_STRING_SIZE)
238 DEF_LIB_BUILTIN(BUILT_IN_STRCMP,
239                 "__builtin_strcmp",
240                 BT_FN_INT_CONST_STRING_CONST_STRING)
241 DEF_LIB_BUILTIN(BUILT_IN_STRNCMP,
242                 "__builtin_strncmp",
243                 BT_FN_INT_CONST_STRING_CONST_STRING_SIZE)
244 DEF_LIB_BUILTIN(BUILT_IN_STRLEN,
245                 "__builtin_strlen",
246                 BT_FN_LEN_CONST_STRING)
247 DEF_LIB_BUILTIN(BUILT_IN_STRSTR,
248                 "__builtin_strstr",
249                 BT_FN_STRING_CONST_STRING_CONST_STRING)
250 DEF_LIB_BUILTIN(BUILT_IN_STRPBRK,
251                 "__builtin_strpbrk",
252                 BT_FN_STRING_CONST_STRING_CONST_STRING)
253 DEF_LIB_BUILTIN(BUILT_IN_STRSPN,
254                 "__builtin_strspn",
255                 BT_FN_SIZE_CONST_STRING_CONST_STRING)
256 DEF_LIB_BUILTIN(BUILT_IN_STRCSPN,
257                 "__builtin_strcspn",
258                 BT_FN_SIZE_CONST_STRING_CONST_STRING)
259 DEF_LIB_BUILTIN(BUILT_IN_STRCHR,
260                 "__builtin_strchr",
261                 BT_FN_STRING_CONST_STRING_INT)
262 DEF_LIB_BUILTIN(BUILT_IN_STRRCHR,
263                 "__builtin_strrchr",
264                 BT_FN_STRING_CONST_STRING_INT)
265
266 DEF_LIB_BUILTIN(BUILT_IN_FSQRT,
267                 "__builtin_fsqrt",
268                 BT_FN_DOUBLE_DOUBLE)
269 DEF_LIB_BUILTIN(BUILT_IN_SIN,
270                 "__builtin_sin",
271                 BT_FN_DOUBLE_DOUBLE)
272 DEF_LIB_BUILTIN(BUILT_IN_COS,
273                 "__builtin_cos",
274                 BT_FN_DOUBLE_DOUBLE)
275 DEF_LIB_BUILTIN(BUILT_IN_SQRTF,
276                 "__builtin_sqrtf",
277                 BT_FN_FLOAT_FLOAT)
278 DEF_LIB_BUILTIN(BUILT_IN_SINF,
279                 "__builtin_sinf",
280                 BT_FN_FLOAT_FLOAT)
281 DEF_LIB_BUILTIN(BUILT_IN_COSF,
282                 "__builtin_cosf",
283                 BT_FN_LONG_DOUBLE_LONG_DOUBLE)
284 DEF_LIB_BUILTIN(BUILT_IN_SQRTL,
285                 "__builtin_sqrtl",
286                 BT_FN_LONG_DOUBLE_LONG_DOUBLE)
287 DEF_LIB_BUILTIN(BUILT_IN_SINL,
288                 "__builtin_sinl",
289                 BT_FN_LONG_DOUBLE_LONG_DOUBLE)
290 DEF_LIB_BUILTIN(BUILT_IN_COSL,
291                 "__builtin_cosl",
292                 BT_FN_LONG_DOUBLE_LONG_DOUBLE)
293
294 DEF_UNUSED_BUILTIN(BUILT_IN_GETEXP)
295 DEF_UNUSED_BUILTIN(BUILT_IN_GETMAN)
296
297 DEF_GCC_BUILTIN(BUILT_IN_SAVEREGS,
298                 "__builtin_saveregs",
299                 BT_FN_PTR_VAR)
300 DEF_GCC_BUILTIN(BUILT_IN_CLASSIFY_TYPE,
301                 "__builtin_classify_type",
302                 BT_FN_INT_VAR)
303 DEF_GCC_BUILTIN(BUILT_IN_NEXT_ARG,
304                 "__builtin_next_arg",
305                 BT_FN_PTR_VAR)
306 DEF_GCC_BUILTIN(BUILT_IN_ARGS_INFO,
307                 "__builtin_args_info",
308                 BT_FN_INT_INT)
309 DEF_GCC_BUILTIN(BUILT_IN_CONSTANT_P, 
310                 "__builtin_constant_p", 
311                 BT_FN_INT_VAR)
312 DEF_GCC_BUILTIN(BUILT_IN_FRAME_ADDRESS,
313                 "__builtin_frame_address",
314                 BT_FN_PTR_UNSIGNED)
315 DEF_GCC_BUILTIN(BUILT_IN_RETURN_ADDRESS, 
316                 "__builtin_return_address",
317                 BT_FN_PTR_UNSIGNED)
318 DEF_GCC_BUILTIN(BUILT_IN_AGGREGATE_INCOMING_ADDRESS,
319                 "__builtin_aggregate_incoming_address",
320                 BT_FN_PTR_VAR)
321 DEF_GCC_BUILTIN(BUILT_IN_APPLY_ARGS,
322                 "__builtin_apply_args",
323                 BT_FN_PTR_VAR)
324 DEF_GCC_BUILTIN(BUILT_IN_APPLY,
325                 "__builtin_apply",
326                 BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE)
327 DEF_GCC_BUILTIN(BUILT_IN_RETURN,
328                 "__builtin_return",
329                 BT_FN_VOID_PTR)
330 DEF_GCC_BUILTIN(BUILT_IN_SETJMP,
331                 "__builtin_setjmp",
332                 BT_FN_INT_PTR)
333 DEF_GCC_BUILTIN(BUILT_IN_LONGJMP,
334                 "__builtin_longjmp",
335                 BT_FN_VOID_PTR_INT)
336 DEF_GCC_BUILTIN(BUILT_IN_TRAP,
337                 "__builtin_trap",
338                 BT_FN_VOID)
339
340 /* Stdio builtins.  */
341 DEF_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR,
342                     "__builtin_putchar",
343                      BT_FN_INT_INT)
344 DEF_FALLBACK_BUILTIN(BUILT_IN_PUTS,
345                      "__builtin_puts",
346                      BT_FN_INT_CONST_STRING)
347 DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF,
348                           "__builtin_printf",
349                           BT_FN_INT_CONST_STRING_VAR)
350 DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC,
351                      "__builtin_fputc",
352                      BT_FN_INT_INT_PTR)
353 /* Declare the __builtin_ style with arguments and the regular style
354    without them.  We rely on stdio.h to supply the arguments for the
355    regular style declaration since we had to use void* instead of
356    FILE* in the __builtin_ prototype supplied here.  */
357 DEF_BUILTIN (BUILT_IN_FPUTS,
358              "__builtin_fputs",
359              BUILT_IN_NORMAL,
360              BT_FN_INT_CONST_STRING_PTR,
361              BT_FN_INT_VAR,
362              true, true, false)
363 DEF_FALLBACK_BUILTIN(BUILT_IN_FWRITE,
364                      "__builtin_fwrite",
365                      BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR)
366 DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
367                          "__builtin_fprintf",
368                          BT_FN_INT_PTR_CONST_STRING_VAR)
369
370   /* ISO C99 floating point unordered comparisons.  */
371 DEF_GCC_BUILTIN(BUILT_IN_ISGREATER, 
372                 "__builtin_isgreater",
373                 BT_FN_INT_VAR)
374 DEF_GCC_BUILTIN(BUILT_IN_ISGREATEREQUAL,
375                 "__builtin_isgreaterequal",
376                 BT_FN_INT_VAR)
377 DEF_GCC_BUILTIN(BUILT_IN_ISLESS,
378                 "__builtin_isless",
379                 BT_FN_INT_VAR)
380 DEF_GCC_BUILTIN(BUILT_IN_ISLESSEQUAL,
381                 "__builtin_islessequal",
382                 BT_FN_INT_VAR)
383 DEF_GCC_BUILTIN(BUILT_IN_ISLESSGREATER,
384                 "__builtin_islessgreater",
385                 BT_FN_INT_VAR)
386 DEF_GCC_BUILTIN(BUILT_IN_ISUNORDERED,
387                 "__builtin_isunordered",
388                 BT_FN_INT_VAR)
389
390 /* Various hooks for the DWARF 2 __throw routine.  */
391 DEF_GCC_BUILTIN(BUILT_IN_UNWIND_INIT,
392                 "__builtin_unwind_init",
393                 BT_FN_VOID)
394 DEF_GCC_BUILTIN(BUILT_IN_DWARF_CFA,
395                 "__builtin_dwarf_cfa",
396                 BT_FN_PTR)
397 DEF_GCC_BUILTIN(BUILT_IN_DWARF_FP_REGNUM,
398                 "__builtin_dwarf_fp_regnum",
399                 BT_FN_UNSIGNED)
400 DEF_GCC_BUILTIN(BUILT_IN_INIT_DWARF_REG_SIZES,
401                 "__builtin_init_dwarf_reg_size_table",
402                 BT_FN_VOID_PTR)
403 DEF_GCC_BUILTIN(BUILT_IN_FROB_RETURN_ADDR,
404                 "__builtin_frob_return_addr",
405                 BT_FN_PTR_PTR)
406 DEF_GCC_BUILTIN(BUILT_IN_EXTRACT_RETURN_ADDR,
407                 "__builtin_extract_return_addr",
408                 BT_FN_PTR_PTR)
409 DEF_GCC_BUILTIN(BUILT_IN_EH_RETURN,
410                 "__builtin_eh_return",
411                 BT_FN_VOID_PTRMODE_PTR)
412 DEF_GCC_BUILTIN(BUILT_IN_EH_RETURN_DATA_REGNO,
413                 "__builtin_eh_return_data_regno",
414                 BT_FN_INT_INT)
415
416 DEF_GCC_BUILTIN(BUILT_IN_VARARGS_START,
417                 "__builtin_varargs_start",
418                 BT_FN_VOID_VALIST_REF)
419 DEF_GCC_BUILTIN(BUILT_IN_STDARG_START,
420                 "__builtin_stdarg_start",
421                 BT_FN_VOID_VALIST_REF_VAR)
422 DEF_GCC_BUILTIN(BUILT_IN_VA_END,
423                 "__builtin_va_end",
424                 BT_FN_VOID_VALIST_REF)
425 DEF_GCC_BUILTIN(BUILT_IN_VA_COPY,
426                 "__builtin_va_copy",
427                 BT_FN_VOID_VALIST_REF_VALIST_ARG)
428 DEF_GCC_BUILTIN(BUILT_IN_EXPECT,
429                 "__builtin_expect",
430                 BT_FN_LONG_LONG_LONG)
431
432 /* C++ extensions */
433 DEF_UNUSED_BUILTIN(BUILT_IN_NEW)
434 DEF_UNUSED_BUILTIN(BUILT_IN_VEC_NEW)
435 DEF_UNUSED_BUILTIN(BUILT_IN_DELETE)
436 DEF_UNUSED_BUILTIN(BUILT_IN_VEC_DELETE)