From: Mark Mitchell Date: Fri, 25 May 2001 20:00:59 +0000 (+0000) Subject: builtins.def: Encode additional information, such as names and types, here. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1084128584fe3cb13ba54924a80d1647b7f73387;p=gcc.git builtins.def: Encode additional information, such as names and types, here. * builtins.def: Encode additional information, such as names and types, here. * builtin-types.def: New file. * builtins.c (built_in_names): Adjust use of DEF_BUILTIN. (built_in_decls): Likewise. Don't explicitly initialize global data to NULL. (expand_builtin_mathfn): Handle float and long double variants of math builtins. (expand_builtin): Likewise. * c-common.c (c_common_nodes_and_builtins): Make it table-driven. (expand_tree_builtin): Handle long, long long, float, and long double variants of math functions. * c-common.h (c_tree_index): Remove some unused nodes. (void_ftype): Remove. (void_type_ptr): Likewise. (int_ftype_int): Likewise. (ptr_ftype_sizetype): Likewise. * c-decl.c (init_decl_processing): Remove creation of DWARF builtins. * defaults.h (MD_INIT_BUILTINS): Provide default definition. * tree.h (built_in_function): Adjust definition of DEF_BUILTIN. * Makefile.in (c-common.o): Depend on builtin-types.def. * decl.c (init_decl_processing): Tweak. From-SVN: r42583 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e34cc9e1e84..0f074d6ba73 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2001-05-26 Mark + + * builtins.def: Encode additional information, such as names and + types, here. + * builtin-types.def: New file. + * builtins.c (built_in_names): Adjust use of DEF_BUILTIN. + (built_in_decls): Likewise. Don't explicitly initialize global + data to NULL. + (expand_builtin_mathfn): Handle float and long double variants of + math builtins. + (expand_builtin): Likewise. + * c-common.c (c_common_nodes_and_builtins): Make it table-driven. + (expand_tree_builtin): Handle long, long long, float, and long + double variants of math functions. + * c-common.h (c_tree_index): Remove some unused nodes. + (void_ftype): Remove. + (void_type_ptr): Likewise. + (int_ftype_int): Likewise. + (ptr_ftype_sizetype): Likewise. + * c-decl.c (init_decl_processing): Remove creation of DWARF + builtins. + * defaults.h (MD_INIT_BUILTINS): Provide default definition. + * tree.h (built_in_function): Adjust definition of DEF_BUILTIN. + * Makefile.in (c-common.o): Depend on builtin-types.def. + 2001-05-25 Dale Johannesen * config/rs6000/t-darwin: Fix dependencies for darwin.o. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5365bec3d3a..55322cdbb68 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1227,7 +1227,7 @@ s-under: $(GCC_PASSES) c-common.o : c-common.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(OBSTACK_H) \ $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h $(RTL_H) $(GGC_H) \ - $(EXPR_H) $(TM_P_H) + $(EXPR_H) $(TM_P_H) builtin-types.def c-format.o : c-format.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ $(C_COMMON_H) flags.h toplev.h intl.h diagnostic.h diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def new file mode 100644 index 00000000000..dd5c5aebddc --- /dev/null +++ b/gcc/builtin-types.def @@ -0,0 +1,177 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This header provides a declaritive way of describing the types that + are used when declaring builtin functions. + + Before including this header, you must define the following macros: + + DEF_PRIMITIVE_TYPE (ENUM, TYPE) + + The ENUM is an identifier indicating which type is being defined. + TYPE is an expression for a `tree' that represents the type. + + DEF_FUNCTION_TYPE_0 (ENUM, RETURN) + DEF_FUNCTION_TYPE_1 (ENUM, RETURN, ARG1) + DEF_FUNCTION_TYPE_2 (ENUM, RETURN, ARG1, ARG2) + DEF_FUNCTION_TYPE_3 (ENUM, RETURN, ARG1, ARG2, ARG3) + DEF_FUNCTION_TYPE_4 (ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) + + These macros describe function types. ENUM is as above. The + RETURN type is one of the enumerals already defined. ARG1, ARG2, + and ARG3 give the types of the arguments, similarly. + + DEF_FUNCTION_TYPE_VAR_0 (ENUM, RETURN) + DEF_FUNCTION_TYPE_VAR_1 (ENUM, RETURN, ARG1) + DEF_FUNCTION_TYPE_VAR_2 (ENUM, RETURN, ARG1, ARG2) + + Similar, but for function types that take variable arguments. + For example: + + DEF_FUNCTION_TYPE_1 (BT_INT_DOUBLE, BT_INT, BT_DOUBLE) + + describes the type `int ()(double)', using the enumeral + BT_INT_DOUBLE, whereas: + + DEF_FUNCTION_TYPE_VAR_1 (BT_INT_DOUBLE_VAR, BT_INT, BT_DOUBLE) + + describes the type `int ()(double, ...)'. + + DEF_POINTER_TYPE (ENUM, TYPE) + + This macro describes a pointer type. ENUM is as above; TYPE is + the type pointed to. */ + +DEF_PRIMITIVE_TYPE (BT_VOID, void_type_node) +DEF_PRIMITIVE_TYPE (BT_INT, integer_type_node) +DEF_PRIMITIVE_TYPE (BT_UNSIGNED, unsigned_type_node) +DEF_PRIMITIVE_TYPE (BT_LONG, long_integer_type_node) +DEF_PRIMITIVE_TYPE (BT_LONGLONG, long_long_integer_type_node) +DEF_PRIMITIVE_TYPE (BT_FLOAT, float_type_node) +DEF_PRIMITIVE_TYPE (BT_INTMAX, intmax_type_node) +DEF_PRIMITIVE_TYPE (BT_DOUBLE, double_type_node) +DEF_PRIMITIVE_TYPE (BT_LONG_DOUBLE, long_double_type_node) +DEF_PRIMITIVE_TYPE (BT_COMPLEX_FLOAT, complex_float_type_node) +DEF_PRIMITIVE_TYPE (BT_COMPLEX_DOUBLE, complex_double_type_node) +DEF_PRIMITIVE_TYPE (BT_COMPLEX_LONG_DOUBLE, complex_long_double_type_node) + +DEF_PRIMITIVE_TYPE (BT_PTR, ptr_type_node) +DEF_PRIMITIVE_TYPE (BT_CONST_PTR, const_ptr_type_node) +DEF_PRIMITIVE_TYPE (BT_TRAD_PTR, traditional_ptr_type_node) +DEF_PRIMITIVE_TYPE (BT_TRAD_CONST_PTR, traditional_cptr_type_node) +DEF_PRIMITIVE_TYPE (BT_PTRMODE, type_for_mode (ptr_mode, 0)) +DEF_PRIMITIVE_TYPE (BT_SIZE, c_size_type_node) +DEF_PRIMITIVE_TYPE (BT_STRING, string_type_node) +DEF_PRIMITIVE_TYPE (BT_CONST_STRING, const_string_type_node) +DEF_PRIMITIVE_TYPE (BT_LEN, traditional_len_type_node) + +DEF_PRIMITIVE_TYPE (BT_VALIST_REF, va_list_ref_type_node) +DEF_PRIMITIVE_TYPE (BT_VALIST_ARG, va_list_arg_type_node) + +DEF_FUNCTION_TYPE_0 (BT_FN_VOID, BT_VOID) +DEF_FUNCTION_TYPE_0 (BT_FN_PTR, BT_PTR) +DEF_FUNCTION_TYPE_0 (BT_FN_UNSIGNED, BT_UNSIGNED) + +DEF_FUNCTION_TYPE_1 (BT_FN_LONG_LONG, BT_LONG, BT_LONG) +DEF_FUNCTION_TYPE_1 (BT_FN_LONGLONG_LONGLONG, BT_LONGLONG, BT_LONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_INTMAX_INTMAX, BT_INTMAX, BT_INTMAX) +DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT_FLOAT, BT_FLOAT, BT_FLOAT) +DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_DOUBLE, BT_DOUBLE, BT_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_LONG_DOUBLE_LONG_DOUBLE, + BT_LONG_DOUBLE, BT_LONG_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, + BT_COMPLEX_FLOAT, BT_COMPLEX_FLOAT) +DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, + BT_COMPLEX_DOUBLE, BT_COMPLEX_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_COMPLEX_LONG_DOUBLE_COMPLEX_LONG_DOUBLE, + BT_COMPLEX_LONG_DOUBLE, BT_COMPLEX_LONG_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT_COMPLEX_FLOAT, + BT_FLOAT, BT_COMPLEX_FLOAT) +DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_COMPLEX_DOUBLE, + BT_DOUBLE, BT_COMPLEX_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE, + BT_LONG_DOUBLE, BT_COMPLEX_LONG_DOUBLE) +DEF_FUNCTION_TYPE_1 (BT_FN_PTR_UNSIGNED, BT_PTR, BT_UNSIGNED) +DEF_FUNCTION_TYPE_1 (BT_FN_PTR_SIZE, BT_PTR, BT_SIZE) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_INT, BT_INT, BT_INT) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_PTR, BT_INT, BT_PTR) +DEF_FUNCTION_TYPE_1 (BT_FN_VOID_PTR, BT_VOID, BT_PTR) +DEF_FUNCTION_TYPE_1 (BT_FN_LEN_CONST_STRING, BT_LEN, BT_CONST_STRING) +DEF_FUNCTION_TYPE_1 (BT_FN_INT_CONST_STRING, BT_INT, BT_CONST_STRING) +DEF_FUNCTION_TYPE_1 (BT_FN_PTR_PTR, BT_PTR, BT_PTR) +DEF_FUNCTION_TYPE_1 (BT_FN_VOID_VALIST_REF, BT_VOID, BT_VALIST_REF) +DEF_FUNCTION_TYPE_1 (BT_FN_VOID_INT, BT_VOID, BT_INT) + +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_INT, BT_VOID, BT_PTR, BT_INT) +DEF_FUNCTION_TYPE_2 (BT_FN_STRING_STRING_CONST_STRING, + BT_STRING, BT_STRING, BT_CONST_STRING) +DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_CONST_STRING, + BT_INT, BT_CONST_STRING, BT_CONST_STRING) +DEF_FUNCTION_TYPE_2 (BT_FN_STRING_CONST_STRING_CONST_STRING, + BT_STRING, BT_CONST_STRING, BT_CONST_STRING) +DEF_FUNCTION_TYPE_2 (BT_FN_SIZE_CONST_STRING_CONST_STRING, + BT_SIZE, BT_CONST_STRING, BT_CONST_STRING) +DEF_FUNCTION_TYPE_2 (BT_FN_STRING_CONST_STRING_INT, + BT_STRING, BT_CONST_STRING, BT_INT) +DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_PTR, + BT_INT, BT_CONST_STRING, BT_PTR) +DEF_FUNCTION_TYPE_2 (BT_FN_INT_INT_PTR, + BT_INT, BT_INT, BT_PTR) +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTRMODE_PTR, + BT_VOID, BT_PTRMODE, BT_PTR) +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_VALIST_REF_VALIST_ARG, + BT_VOID, BT_VALIST_REF, BT_VALIST_ARG) +DEF_FUNCTION_TYPE_2 (BT_FN_LONG_LONG_LONG, + BT_LONG, BT_LONG, BT_LONG) +DEF_FUNCTION_TYPE_2 (BT_FN_INT_PTR_CONST_STRING, + BT_INT, BT_PTR, BT_CONST_STRING) +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_TRAD_PTR_LEN, + BT_VOID, BT_TRAD_PTR, BT_LEN) + +DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE, + BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE) +DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, + BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_SIZE) +DEF_FUNCTION_TYPE_3 (BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE, + BT_TRAD_PTR, BT_PTR, BT_CONST_PTR, BT_SIZE) +DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, + BT_INT, BT_CONST_PTR, BT_CONST_PTR, BT_SIZE) +DEF_FUNCTION_TYPE_3 (BT_FN_TRAD_PTR_PTR_INT_SIZE, + BT_TRAD_PTR, BT_PTR, BT_INT, BT_SIZE) +DEF_FUNCTION_TYPE_3 (BT_FN_INT_TRAD_CONST_PTR_TRAD_CONST_PTR_LEN, + BT_INT, BT_TRAD_CONST_PTR, BT_TRAD_CONST_PTR, BT_LEN) + +DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR, + BT_SIZE, BT_CONST_PTR, BT_SIZE, BT_SIZE, BT_PTR) + +DEF_FUNCTION_TYPE_VAR_0 (BT_FN_VOID_VAR, BT_VOID) +DEF_FUNCTION_TYPE_VAR_0 (BT_FN_INT_VAR, BT_INT) +DEF_FUNCTION_TYPE_VAR_0 (BT_FN_PTR_VAR, BT_PTR) + +DEF_FUNCTION_TYPE_VAR_1 (BT_FN_VOID_VALIST_REF_VAR, + BT_VOID, BT_VALIST_REF) +DEF_FUNCTION_TYPE_VAR_1 (BT_FN_INT_CONST_STRING_VAR, + BT_INT, BT_CONST_STRING) + +DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_PTR_CONST_STRING_VAR, + BT_INT, BT_PTR, BT_CONST_STRING) + +DEF_POINTER_TYPE (BT_PTR_FN_VOID_VAR, BT_FN_VOID_VAR) +DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, + BT_PTR, BT_PTR_FN_VOID_VAR, BT_PTR, BT_SIZE) diff --git a/gcc/builtins.c b/gcc/builtins.c index 7b4cd7593c9..0d71b292b12 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -57,7 +57,7 @@ Boston, MA 02111-1307, USA. */ const char *const built_in_class_names[4] = {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"}; -#define DEF_BUILTIN(x) STRINGX(x), +#define DEF_BUILTIN(X, N, C, T, LT, B, F, NA) STRINGX(X), const char *const built_in_names[(int) END_BUILTINS] = { #include "builtins.def" @@ -66,12 +66,7 @@ const char *const built_in_names[(int) END_BUILTINS] = /* Setup an array of _DECL trees, make sure each element is initialized to NULL_TREE. */ -#define DEF_BUILTIN(x) NULL_TREE, -tree built_in_decls[(int) END_BUILTINS] = -{ -#include "builtins.def" -}; -#undef DEF_BUILTIN +tree built_in_decls[(int) END_BUILTINS]; tree (*lang_type_promotes_to) PARAMS ((tree)); @@ -1409,11 +1404,17 @@ expand_builtin_mathfn (exp, target, subtarget) switch (DECL_FUNCTION_CODE (fndecl)) { - case BUILT_IN_SIN: + case BUILT_IN_SIN: + case BUILT_IN_SINF: + case BUILT_IN_SINL: builtin_optab = sin_optab; break; - case BUILT_IN_COS: + case BUILT_IN_COS: + case BUILT_IN_COSF: + case BUILT_IN_COSL: builtin_optab = cos_optab; break; - case BUILT_IN_FSQRT: + case BUILT_IN_FSQRT: + case BUILT_IN_SQRTF: + case BUILT_IN_SQRTL: builtin_optab = sqrt_optab; break; default: abort (); @@ -3300,7 +3301,8 @@ expand_builtin (exp, target, subtarget, mode, ignore) set of builtins. */ if (! optimize && ! CALLED_AS_BUILT_IN (fndecl) && (fcode == BUILT_IN_SIN || fcode == BUILT_IN_COS - || fcode == BUILT_IN_FSQRT || fcode == BUILT_IN_MEMSET + || fcode == BUILT_IN_FSQRT || fcode == BUILT_IN_SQRTF + || fcode == BUILT_IN_SQRTL || fcode == BUILT_IN_MEMSET || fcode == BUILT_IN_MEMCPY || fcode == BUILT_IN_MEMCMP || fcode == BUILT_IN_BCMP || fcode == BUILT_IN_BZERO || fcode == BUILT_IN_INDEX || fcode == BUILT_IN_RINDEX @@ -3319,24 +3321,41 @@ expand_builtin (exp, target, subtarget, mode, ignore) switch (fcode) { case BUILT_IN_ABS: + case BUILT_IN_LABS: + case BUILT_IN_LLABS: + case BUILT_IN_IMAXABS: case BUILT_IN_FABS: + case BUILT_IN_FABSF: + case BUILT_IN_FABSL: /* build_function_call changes these into ABS_EXPR. */ abort (); case BUILT_IN_CONJ: + case BUILT_IN_CONJF: + case BUILT_IN_CONJL: case BUILT_IN_CREAL: + case BUILT_IN_CREALF: + case BUILT_IN_CREALL: case BUILT_IN_CIMAG: + case BUILT_IN_CIMAGF: + case BUILT_IN_CIMAGL: /* expand_tree_builtin changes these into CONJ_EXPR, REALPART_EXPR and IMAGPART_EXPR. */ abort (); case BUILT_IN_SIN: + case BUILT_IN_SINF: + case BUILT_IN_SINL: case BUILT_IN_COS: + case BUILT_IN_COSF: + case BUILT_IN_COSL: /* Treat these like sqrt only if unsafe math optimizations are allowed, because of possible accuracy problems. */ if (! flag_unsafe_math_optimizations) break; case BUILT_IN_FSQRT: + case BUILT_IN_SQRTF: + case BUILT_IN_SQRTL: target = expand_builtin_mathfn (exp, target, subtarget); if (target) return target; diff --git a/gcc/builtins.def b/gcc/builtins.def index 1d59d78f824..a6f4f515724 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -19,94 +19,418 @@ along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -DEF_BUILTIN(BUILT_IN_ALLOCA) -DEF_BUILTIN(BUILT_IN_ABS) -DEF_BUILTIN(BUILT_IN_FABS) -DEF_BUILTIN(BUILT_IN_CONJ) -DEF_BUILTIN(BUILT_IN_CREAL) -DEF_BUILTIN(BUILT_IN_CIMAG) -DEF_BUILTIN(BUILT_IN_FFS) -DEF_BUILTIN(BUILT_IN_DIV) -DEF_BUILTIN(BUILT_IN_LDIV) -DEF_BUILTIN(BUILT_IN_FFLOOR) -DEF_BUILTIN(BUILT_IN_FCEIL) -DEF_BUILTIN(BUILT_IN_FMOD) -DEF_BUILTIN(BUILT_IN_FREM) -DEF_BUILTIN(BUILT_IN_MEMCPY) -DEF_BUILTIN(BUILT_IN_MEMCMP) -DEF_BUILTIN(BUILT_IN_MEMSET) -DEF_BUILTIN(BUILT_IN_BZERO) -DEF_BUILTIN(BUILT_IN_BCMP) -DEF_BUILTIN(BUILT_IN_INDEX) -DEF_BUILTIN(BUILT_IN_RINDEX) -DEF_BUILTIN(BUILT_IN_STRCAT) -DEF_BUILTIN(BUILT_IN_STRNCAT) -DEF_BUILTIN(BUILT_IN_STRCPY) -DEF_BUILTIN(BUILT_IN_STRNCPY) -DEF_BUILTIN(BUILT_IN_STRCMP) -DEF_BUILTIN(BUILT_IN_STRNCMP) -DEF_BUILTIN(BUILT_IN_STRLEN) -DEF_BUILTIN(BUILT_IN_STRSTR) -DEF_BUILTIN(BUILT_IN_STRPBRK) -DEF_BUILTIN(BUILT_IN_STRSPN) -DEF_BUILTIN(BUILT_IN_STRCSPN) -DEF_BUILTIN(BUILT_IN_STRCHR) -DEF_BUILTIN(BUILT_IN_STRRCHR) -DEF_BUILTIN(BUILT_IN_FSQRT) -DEF_BUILTIN(BUILT_IN_SIN) -DEF_BUILTIN(BUILT_IN_COS) -DEF_BUILTIN(BUILT_IN_GETEXP) -DEF_BUILTIN(BUILT_IN_GETMAN) -DEF_BUILTIN(BUILT_IN_SAVEREGS) -DEF_BUILTIN(BUILT_IN_CLASSIFY_TYPE) -DEF_BUILTIN(BUILT_IN_NEXT_ARG) -DEF_BUILTIN(BUILT_IN_ARGS_INFO) -DEF_BUILTIN(BUILT_IN_CONSTANT_P) -DEF_BUILTIN(BUILT_IN_FRAME_ADDRESS) -DEF_BUILTIN(BUILT_IN_RETURN_ADDRESS) -DEF_BUILTIN(BUILT_IN_AGGREGATE_INCOMING_ADDRESS) -DEF_BUILTIN(BUILT_IN_APPLY_ARGS) -DEF_BUILTIN(BUILT_IN_APPLY) -DEF_BUILTIN(BUILT_IN_RETURN) -DEF_BUILTIN(BUILT_IN_SETJMP) -DEF_BUILTIN(BUILT_IN_LONGJMP) -DEF_BUILTIN(BUILT_IN_TRAP) - - /* Stdio builtins. */ -DEF_BUILTIN(BUILT_IN_PUTCHAR) -DEF_BUILTIN(BUILT_IN_PUTS) -DEF_BUILTIN(BUILT_IN_PRINTF) -DEF_BUILTIN(BUILT_IN_FPUTC) -DEF_BUILTIN(BUILT_IN_FPUTS) -DEF_BUILTIN(BUILT_IN_FWRITE) -DEF_BUILTIN(BUILT_IN_FPRINTF) +/* Before including this file, you should define a macro: + + DEF_BUILTIN (ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, + FALLBACK_P, NONANSI_P) + + This macro will be called once for each builtin function. The + ENUM will be of type `enum built_in_function', and will indicate + which builtin function is being processed. The NAME of the builtin + function (which will always start with `__builtin_') is a string + literal. The CLASS is of type `enum built_in_class' and indicates + what kind of builtin is being processed. + + Some builtins are actually two separate functions. For example, + for `strcmp' there are two builtin functions; `__builtin_strcmp' + and `strcmp' itself. Both behave identically. Other builtins + define only the `__builtin' variant. If BOTH_P is TRUE, then this + builtin has both variants; otherwise, it is has only the first + variant. + + TYPE indicates the type of the function. The symbols correspond to + enumerals from builtin-types.def. If BOTH_P is true, then LIBTYPE + is the type of the non-`__builtin_' variant. Otherwise, LIBTYPE + should be ignored. + + If FALLBACK_P is true then, if for some reason, the compiler cannot + expand the builtin function directly, it will call the + corresponding library function (which does not have the + `__builtin_' prefix. + + If NONANSI_P is true, then the non-`__builtin_' variant is not an + ANSI/ISO library function, and so we should pretend it does not + exist when compiling in ANSI conformant mode. */ + +/* A GCC builtin (like __builtin_saveregs) is provided by the + compiler, but does not correspond to a function in the standard + library. */ +#undef DEF_GCC_BUILTIN +#define DEF_GCC_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, BT_LAST, \ + false, false, false) + + +/* A fallback builtin is a builtin (like __builtin_puts) that falls + back to the corresopnding library function if necessary -- but + for which we should not introduce the non-`__builtin' variant of + the name. */ +#undef DEF_FALLBACK_BUILTIN +#define DEF_FALLBACK_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + false, true, false) + +/* A library builtin (like __builtin_strchr) is a builtin equivalent + of an ANSI/ISO standard library function. In addition to the + `__builtin' version, we will create a an ordinary version (e.g, + `strchr') as well. If we cannot compute the answer using the + builtin function, we will fall back to the standard library + version. */ +#undef DEF_LIB_BUILTIN +#define DEF_LIB_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + true, true, false) + +/* Like DEF_LIB_BUILTIN, except that a call to the builtin should + never fall back to the library version. */ +#undef DEF_LIB_ALWAYS_BUILTIN +#define DEF_LIB_ALWAYS_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + true, false, true) + +/* Like DEF_LIB_BUILTIN, except that the function is not one that is + specified by ANSI/ISO C. So, when we're being fully conformant we + ignore the version of these builtins that does not begin with + __builtin. */ +#undef DEF_EXT_LIB_BUILTIN +#define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + true, true, true) + +/* Like DEF_LIB_BUILTIN, except that the function is only a part of + the standard in C99 or above. */ +#undef DEF_C99_BUILTIN +#define DEF_C99_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + true, !flag_isoc99, true) + +/* Like DEF_LIB_BUILTIN, except that the function is expanded in the + front-end. */ +#undef DEF_FRONT_END_LIB_BUILTIN +#define DEF_FRONT_END_LIB_BUILTIN(ENUM, NAME, TYPE) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_FRONTEND, TYPE, TYPE, \ + true, true, false) + +/* A built-in that is not currently used. */ +#undef DEF_UNUSED_BUILTIN +#define DEF_UNUSED_BUILTIN(X) \ + DEF_BUILTIN (X, (const char *) NULL, NOT_BUILT_IN, BT_LAST, \ + BT_LAST, false, false, false) + +/* If SMALL_STACK is defined, then `alloca' is only defined in its + `__builtin' form. */ +#if SMALL_STACK +DEF_FALLBACK_BUILTIN(BUILT_IN_ALLOCA, + "__builtin_alloca", + BT_FN_PTR_SIZE) +#else +DEF_EXT_LIB_BUILTIN(BUILT_IN_ALLOCA, + "__builtin_alloca", + BT_FN_PTR_SIZE) +#endif + +DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_ABS, + "__builtin_abs", + BT_FN_INT_INT) +DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_LABS, + "__builtin_labs", + BT_FN_LONG_LONG) + +DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABS, + "__builtin_fabs", + BT_FN_DOUBLE_DOUBLE) +DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSF, + "__builtin_fabsf", + BT_FN_FLOAT_FLOAT) +DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL, + "__builtin_fabsl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + +DEF_C99_BUILTIN(BUILT_IN_LLABS, + "__builtin_llabs", + BT_FN_LONGLONG_LONGLONG) +DEF_C99_BUILTIN(BUILT_IN_IMAXABS, + "__builtin_imaxabs", + BT_FN_INTMAX_INTMAX) +DEF_C99_BUILTIN(BUILT_IN_CONJ, + "__builtin_conj", + BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE) +DEF_C99_BUILTIN(BUILT_IN_CONJF, + "__builtin_conjf", + BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT) +DEF_C99_BUILTIN(BUILT_IN_CONJL, + "__builtin_conjl", + BT_FN_COMPLEX_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) +DEF_C99_BUILTIN(BUILT_IN_CREAL, + "__builtin_creal", + BT_FN_DOUBLE_COMPLEX_DOUBLE) +DEF_C99_BUILTIN(BUILT_IN_CREALF, + "__builtin_crealf", + BT_FN_FLOAT_COMPLEX_FLOAT) +DEF_C99_BUILTIN(BUILT_IN_CREALL, + "__builtin_creall", + BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) +DEF_C99_BUILTIN(BUILT_IN_CIMAG, + "__builtin_cimag", + BT_FN_DOUBLE_COMPLEX_DOUBLE) +DEF_C99_BUILTIN(BUILT_IN_CIMAGF, + "__builtin_cimagf", + BT_FN_FLOAT_COMPLEX_FLOAT) +DEF_C99_BUILTIN(BUILT_IN_CIMAGL, + "__builtin_cimagl", + BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) + +DEF_UNUSED_BUILTIN(BUILT_IN_DIV) +DEF_UNUSED_BUILTIN(BUILT_IN_LDIV) +DEF_UNUSED_BUILTIN(BUILT_IN_FFLOOR) +DEF_UNUSED_BUILTIN(BUILT_IN_FCEIL) +DEF_UNUSED_BUILTIN(BUILT_IN_FMOD) +DEF_UNUSED_BUILTIN(BUILT_IN_FREM) + +/* The system prototypes for `bzero' and `bcmp' functions have many + variations, so don't specify parameters to avoid conflicts. The + expand_* functions check the argument types anyway. */ +DEF_BUILTIN (BUILT_IN_BZERO, + "__builtin_bzero", + BUILT_IN_NORMAL, + BT_FN_VOID_TRAD_PTR_LEN, + BT_FN_VOID_VAR, + true, true, true) +DEF_BUILTIN (BUILT_IN_BCMP, + "__builtin_bcmp", + BUILT_IN_NORMAL, + BT_FN_INT_TRAD_CONST_PTR_TRAD_CONST_PTR_LEN, + BT_FN_INT_VAR, + true, true, true) + +DEF_EXT_LIB_BUILTIN(BUILT_IN_FFS, + "__builtin_ffs", + BT_FN_INT_INT) +DEF_EXT_LIB_BUILTIN(BUILT_IN_INDEX, + "__builtin_index", + BT_FN_STRING_CONST_STRING_INT) +DEF_EXT_LIB_BUILTIN(BUILT_IN_RINDEX, + "__builtin_rindex", + BT_FN_STRING_CONST_STRING_INT) + +DEF_LIB_BUILTIN(BUILT_IN_MEMCPY, + "__builtin_memcpy", + BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE) +DEF_LIB_BUILTIN(BUILT_IN_MEMCMP, + "__builtin_memcmp", + BT_FN_INT_CONST_PTR_CONST_PTR_SIZE) +DEF_LIB_BUILTIN(BUILT_IN_MEMSET, + "__builtin_memset", + BT_FN_TRAD_PTR_PTR_INT_SIZE) + +DEF_LIB_BUILTIN(BUILT_IN_STRCAT, + "__builtin_strcat", + BT_FN_STRING_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRNCAT, + "__builtin_strncat", + BT_FN_STRING_STRING_CONST_STRING_SIZE) +DEF_LIB_BUILTIN(BUILT_IN_STRCPY, + "__builtin_strcpy", + BT_FN_STRING_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRNCPY, + "__builtin_strncpy", + BT_FN_STRING_STRING_CONST_STRING_SIZE) +DEF_LIB_BUILTIN(BUILT_IN_STRCMP, + "__builtin_strcmp", + BT_FN_INT_CONST_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRNCMP, + "__builtin_strncmp", + BT_FN_INT_CONST_STRING_CONST_STRING_SIZE) +DEF_LIB_BUILTIN(BUILT_IN_STRLEN, + "__builtin_strlen", + BT_FN_LEN_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRSTR, + "__builtin_strstr", + BT_FN_STRING_CONST_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRPBRK, + "__builtin_strpbrk", + BT_FN_STRING_CONST_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRSPN, + "__builtin_strspn", + BT_FN_SIZE_CONST_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRCSPN, + "__builtin_strcspn", + BT_FN_SIZE_CONST_STRING_CONST_STRING) +DEF_LIB_BUILTIN(BUILT_IN_STRCHR, + "__builtin_strchr", + BT_FN_STRING_CONST_STRING_INT) +DEF_LIB_BUILTIN(BUILT_IN_STRRCHR, + "__builtin_strrchr", + BT_FN_STRING_CONST_STRING_INT) + +DEF_LIB_BUILTIN(BUILT_IN_FSQRT, + "__builtin_fsqrt", + BT_FN_DOUBLE_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_SIN, + "__builtin_sin", + BT_FN_DOUBLE_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_COS, + "__builtin_cos", + BT_FN_DOUBLE_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_SQRTF, + "__builtin_sqrtf", + BT_FN_FLOAT_FLOAT) +DEF_LIB_BUILTIN(BUILT_IN_SINF, + "__builtin_sinf", + BT_FN_FLOAT_FLOAT) +DEF_LIB_BUILTIN(BUILT_IN_COSF, + "__builtin_cosf", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_SQRTL, + "__builtin_sqrtl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_SINL, + "__builtin_sinl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) +DEF_LIB_BUILTIN(BUILT_IN_COSL, + "__builtin_cosl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + +DEF_UNUSED_BUILTIN(BUILT_IN_GETEXP) +DEF_UNUSED_BUILTIN(BUILT_IN_GETMAN) + +DEF_GCC_BUILTIN(BUILT_IN_SAVEREGS, + "__builtin_saveregs", + BT_FN_PTR_VAR) +DEF_GCC_BUILTIN(BUILT_IN_CLASSIFY_TYPE, + "__builtin_classify_type", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_NEXT_ARG, + "__builtin_next_arg", + BT_FN_PTR_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ARGS_INFO, + "__builtin_args_info", + BT_FN_INT_INT) +DEF_GCC_BUILTIN(BUILT_IN_CONSTANT_P, + "__builtin_constant_p", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_FRAME_ADDRESS, + "__builtin_frame_address", + BT_FN_PTR_UNSIGNED) +DEF_GCC_BUILTIN(BUILT_IN_RETURN_ADDRESS, + "__builtin_return_address", + BT_FN_PTR_UNSIGNED) +DEF_GCC_BUILTIN(BUILT_IN_AGGREGATE_INCOMING_ADDRESS, + "__builtin_aggregate_incoming_address", + BT_FN_PTR_VAR) +DEF_GCC_BUILTIN(BUILT_IN_APPLY_ARGS, + "__builtin_apply_args", + BT_FN_PTR_VAR) +DEF_GCC_BUILTIN(BUILT_IN_APPLY, + "__builtin_apply", + BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE) +DEF_GCC_BUILTIN(BUILT_IN_RETURN, + "__builtin_return", + BT_FN_VOID_PTR) +DEF_GCC_BUILTIN(BUILT_IN_SETJMP, + "__builtin_setjmp", + BT_FN_INT_PTR) +DEF_GCC_BUILTIN(BUILT_IN_LONGJMP, + "__builtin_longjmp", + BT_FN_VOID_PTR_INT) +DEF_GCC_BUILTIN(BUILT_IN_TRAP, + "__builtin_trap", + BT_FN_VOID) + +/* Stdio builtins. */ +DEF_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR, + "__builtin_putchar", + BT_FN_INT_INT) +DEF_FALLBACK_BUILTIN(BUILT_IN_PUTS, + "__builtin_puts", + BT_FN_INT_CONST_STRING) +DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF, + "__builtin_printf", + BT_FN_INT_CONST_STRING_VAR) +DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC, + "__builtin_fputc", + BT_FN_INT_INT_PTR) +/* Declare the __builtin_ style with arguments and the regular style + without them. We rely on stdio.h to supply the arguments for the + regular style declaration since we had to use void* instead of + FILE* in the __builtin_ prototype supplied here. */ +DEF_BUILTIN (BUILT_IN_FPUTS, + "__builtin_fputs", + BUILT_IN_NORMAL, + BT_FN_INT_CONST_STRING_PTR, + BT_FN_INT_VAR, + true, true, false) +DEF_FALLBACK_BUILTIN(BUILT_IN_FWRITE, + "__builtin_fwrite", + BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR) +DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF, + "__builtin_fprintf", + BT_FN_INT_PTR_CONST_STRING_VAR) /* ISO C99 floating point unordered comparisons. */ -DEF_BUILTIN(BUILT_IN_ISGREATER) -DEF_BUILTIN(BUILT_IN_ISGREATEREQUAL) -DEF_BUILTIN(BUILT_IN_ISLESS) -DEF_BUILTIN(BUILT_IN_ISLESSEQUAL) -DEF_BUILTIN(BUILT_IN_ISLESSGREATER) -DEF_BUILTIN(BUILT_IN_ISUNORDERED) - - /* Various hooks for the DWARF 2 __throw routine. */ -DEF_BUILTIN(BUILT_IN_UNWIND_INIT) -DEF_BUILTIN(BUILT_IN_DWARF_CFA) -DEF_BUILTIN(BUILT_IN_DWARF_FP_REGNUM) -DEF_BUILTIN(BUILT_IN_INIT_DWARF_REG_SIZES) -DEF_BUILTIN(BUILT_IN_FROB_RETURN_ADDR) -DEF_BUILTIN(BUILT_IN_EXTRACT_RETURN_ADDR) -DEF_BUILTIN(BUILT_IN_EH_RETURN) -DEF_BUILTIN(BUILT_IN_EH_RETURN_DATA_REGNO) - -DEF_BUILTIN(BUILT_IN_VARARGS_START) -DEF_BUILTIN(BUILT_IN_STDARG_START) -DEF_BUILTIN(BUILT_IN_VA_END) -DEF_BUILTIN(BUILT_IN_VA_COPY) -DEF_BUILTIN(BUILT_IN_EXPECT) - - /* C++ extensions */ -DEF_BUILTIN(BUILT_IN_NEW) -DEF_BUILTIN(BUILT_IN_VEC_NEW) -DEF_BUILTIN(BUILT_IN_DELETE) -DEF_BUILTIN(BUILT_IN_VEC_DELETE) +DEF_GCC_BUILTIN(BUILT_IN_ISGREATER, + "__builtin_isgreater", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ISGREATEREQUAL, + "__builtin_isgreaterequal", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ISLESS, + "__builtin_isless", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ISLESSEQUAL, + "__builtin_islessequal", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ISLESSGREATER, + "__builtin_islessgreater", + BT_FN_INT_VAR) +DEF_GCC_BUILTIN(BUILT_IN_ISUNORDERED, + "__builtin_isunordered", + BT_FN_INT_VAR) + +/* Various hooks for the DWARF 2 __throw routine. */ +DEF_GCC_BUILTIN(BUILT_IN_UNWIND_INIT, + "__builtin_unwind_init", + BT_FN_VOID) +DEF_GCC_BUILTIN(BUILT_IN_DWARF_CFA, + "__builtin_dwarf_cfa", + BT_FN_PTR) +DEF_GCC_BUILTIN(BUILT_IN_DWARF_FP_REGNUM, + "__builtin_dwarf_fp_regnum", + BT_FN_UNSIGNED) +DEF_GCC_BUILTIN(BUILT_IN_INIT_DWARF_REG_SIZES, + "__builtin_init_dwarf_reg_size_table", + BT_FN_VOID_PTR) +DEF_GCC_BUILTIN(BUILT_IN_FROB_RETURN_ADDR, + "__builtin_frob_return_addr", + BT_FN_PTR_PTR) +DEF_GCC_BUILTIN(BUILT_IN_EXTRACT_RETURN_ADDR, + "__builtin_extract_return_addr", + BT_FN_PTR_PTR) +DEF_GCC_BUILTIN(BUILT_IN_EH_RETURN, + "__builtin_eh_return", + BT_FN_VOID_PTRMODE_PTR) +DEF_GCC_BUILTIN(BUILT_IN_EH_RETURN_DATA_REGNO, + "__builtin_eh_return_data_regno", + BT_FN_INT_INT) + +DEF_GCC_BUILTIN(BUILT_IN_VARARGS_START, + "__builtin_varargs_start", + BT_FN_VOID_VALIST_REF) +DEF_GCC_BUILTIN(BUILT_IN_STDARG_START, + "__builtin_stdarg_start", + BT_FN_VOID_VALIST_REF_VAR) +DEF_GCC_BUILTIN(BUILT_IN_VA_END, + "__builtin_va_end", + BT_FN_VOID_VALIST_REF) +DEF_GCC_BUILTIN(BUILT_IN_VA_COPY, + "__builtin_va_copy", + BT_FN_VOID_VALIST_REF_VALIST_ARG) +DEF_GCC_BUILTIN(BUILT_IN_EXPECT, + "__builtin_expect", + BT_FN_LONG_LONG_LONG) + +/* C++ extensions */ +DEF_UNUSED_BUILTIN(BUILT_IN_NEW) +DEF_UNUSED_BUILTIN(BUILT_IN_VEC_NEW) +DEF_UNUSED_BUILTIN(BUILT_IN_DELETE) +DEF_UNUSED_BUILTIN(BUILT_IN_VEC_DELETE) diff --git a/gcc/c-common.c b/gcc/c-common.c index 2906c967fdf..30030c64b26 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -152,14 +152,6 @@ cpp_reader *parse_in; /* Declared in c-lex.h. */ tree default_function_type; - Function types `int (int)', etc. - - tree int_ftype_int; - tree void_ftype; - tree void_ftype_ptr; - tree int_ftype_int; - tree ptr_ftype_sizetype; - A VOID_TYPE node, packaged in a TREE_LIST. tree void_list_node; @@ -2869,33 +2861,42 @@ lang_get_alias_set (t) void c_common_nodes_and_builtins () { + enum builtin_type + { +#define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME, +#define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME, +#define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME, +#define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME, +#define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME, +#define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME, +#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, +#define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME, +#define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME, +#define DEF_POINTER_TYPE(NAME, TYPE) NAME, +#include "builtin-types.def" +#undef DEF_PRIMITIVE_TYPE +#undef DEF_FUNCTION_TYPE_0 +#undef DEF_FUNCTION_TYPE_1 +#undef DEF_FUNCTION_TYPE_2 +#undef DEF_FUNCTION_TYPE_3 +#undef DEF_FUNCTION_TYPE_4 +#undef DEF_FUNCTION_TYPE_VAR_0 +#undef DEF_FUNCTION_TYPE_VAR_1 +#undef DEF_FUNCTION_TYPE_VAR_2 +#undef DEF_POINTER_TYPE + BT_LAST + }; + + typedef enum builtin_type builtin_type; + + tree builtin_types[(int)BT_LAST]; int wchar_type_size; tree array_domain_type; - tree temp; - tree memcpy_ftype, memset_ftype, strlen_ftype; - tree bzero_ftype, bcmp_ftype, puts_ftype, printf_ftype; - tree fputs_ftype, fputc_ftype, fwrite_ftype, fprintf_ftype; - tree endlink, int_endlink, double_endlink, unsigned_endlink; - tree cstring_endlink, sizetype_endlink; - tree ptr_ftype, ptr_ftype_unsigned; - tree void_ftype_any, void_ftype_int, int_ftype_any; - tree double_ftype_double, double_ftype_double_double; - tree float_ftype_float, ldouble_ftype_ldouble; - tree cfloat_ftype_cfloat, cdouble_ftype_cdouble, cldouble_ftype_cldouble; - tree float_ftype_cfloat, double_ftype_cdouble, ldouble_ftype_cldouble; - tree int_ftype_cptr_cptr_sizet, sizet_ftype_cstring_cstring; - tree int_ftype_cstring_cstring, string_ftype_string_cstring; - tree string_ftype_cstring_int, string_ftype_cstring_cstring; - tree string_ftype_string_cstring_sizet, int_ftype_cstring_cstring_sizet; - tree long_ftype_long; - tree longlong_ftype_longlong; - tree intmax_ftype_intmax; /* Either char* or void*. */ tree traditional_ptr_type_node; /* Either const char* or const void*. */ tree traditional_cptr_type_node; tree traditional_len_type_node; - tree traditional_len_endlink; tree va_list_ref_type_node; tree va_list_arg_type_node; @@ -2986,6 +2987,9 @@ c_common_nodes_and_builtins () record_builtin_type (RID_VOID, NULL, void_type_node); + void_zero_node = build_int_2 (0, 0); + TREE_TYPE (void_zero_node) = void_type_node; + void_list_node = build_void_list_node (); /* Make a type to be the domain of a few array types @@ -3005,9 +3009,19 @@ c_common_nodes_and_builtins () int_array_type_node = build_array_type (integer_type_node, array_domain_type); -#ifdef MD_INIT_BUILTINS + string_type_node = build_pointer_type (char_type_node); + const_string_type_node + = build_pointer_type (build_qualified_type + (char_type_node, TYPE_QUAL_CONST)); + + traditional_ptr_type_node = ((flag_traditional && + c_language != clk_cplusplus) + ? string_type_node : ptr_type_node); + traditional_cptr_type_node = ((flag_traditional && + c_language != clk_cplusplus) + ? const_string_type_node : const_ptr_type_node); + MD_INIT_BUILTINS; -#endif /* This is special for C++ so functions can be overloaded. */ wchar_type_node = get_identifier (flag_short_wchar @@ -3033,10 +3047,6 @@ c_common_nodes_and_builtins () wchar_array_type_node = build_array_type (wchar_type_node, array_domain_type); - string_type_node = build_pointer_type (char_type_node); - const_string_type_node - = build_pointer_type (build_type_variant (char_type_node, 1, 0)); - wint_type_node = TREE_TYPE (identifier_global_value (get_identifier (WINT_TYPE))); @@ -3070,564 +3080,141 @@ c_common_nodes_and_builtins () va_list_ref_type_node = build_reference_type (va_list_type_node); } - endlink = void_list_node; - int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink); - double_endlink = tree_cons (NULL_TREE, double_type_node, endlink); - unsigned_endlink = tree_cons (NULL_TREE, unsigned_type_node, endlink); - cstring_endlink = tree_cons (NULL_TREE, const_string_type_node, endlink); - - ptr_ftype = build_function_type (ptr_type_node, NULL_TREE); - ptr_ftype_unsigned = build_function_type (ptr_type_node, unsigned_endlink); - sizetype_endlink = tree_cons (NULL_TREE, TYPE_DOMAIN (sizetype), endlink); - /* We realloc here because sizetype could be int or unsigned. S'ok. */ - ptr_ftype_sizetype = build_function_type (ptr_type_node, sizetype_endlink); - - int_ftype_any = build_function_type (integer_type_node, NULL_TREE); - void_ftype_any = build_function_type (void_type_node, NULL_TREE); - void_ftype = build_function_type (void_type_node, endlink); - void_ftype_int = build_function_type (void_type_node, int_endlink); - void_ftype_ptr - = build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, endlink)); - - float_ftype_float - = build_function_type (float_type_node, - tree_cons (NULL_TREE, float_type_node, endlink)); - - double_ftype_double - = build_function_type (double_type_node, double_endlink); - - ldouble_ftype_ldouble - = build_function_type (long_double_type_node, - tree_cons (NULL_TREE, long_double_type_node, - endlink)); - - double_ftype_double_double - = build_function_type (double_type_node, - tree_cons (NULL_TREE, double_type_node, - double_endlink)); - - cfloat_ftype_cfloat - = build_function_type (complex_float_type_node, - tree_cons (NULL_TREE, complex_float_type_node, - endlink)); - cdouble_ftype_cdouble - = build_function_type (complex_double_type_node, - tree_cons (NULL_TREE, complex_double_type_node, - endlink)); - cldouble_ftype_cldouble - = build_function_type (complex_long_double_type_node, - tree_cons (NULL_TREE, complex_long_double_type_node, - endlink)); - - float_ftype_cfloat - = build_function_type (float_type_node, - tree_cons (NULL_TREE, complex_float_type_node, - endlink)); - double_ftype_cdouble - = build_function_type (double_type_node, - tree_cons (NULL_TREE, complex_double_type_node, - endlink)); - ldouble_ftype_cldouble - = build_function_type (long_double_type_node, - tree_cons (NULL_TREE, complex_long_double_type_node, - endlink)); - - int_ftype_int - = build_function_type (integer_type_node, int_endlink); - - long_ftype_long - = build_function_type (long_integer_type_node, - tree_cons (NULL_TREE, long_integer_type_node, - endlink)); - - longlong_ftype_longlong - = build_function_type (long_long_integer_type_node, - tree_cons (NULL_TREE, long_long_integer_type_node, - endlink)); - - intmax_ftype_intmax - = build_function_type (intmax_type_node, - tree_cons (NULL_TREE, intmax_type_node, - endlink)); - - int_ftype_cptr_cptr_sizet - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, const_ptr_type_node, - tree_cons (NULL_TREE, - const_ptr_type_node, - sizetype_endlink))); - - void_zero_node = build_int_2 (0, 0); - TREE_TYPE (void_zero_node) = void_type_node; - - /* Prototype for strcpy/strcat. */ - string_ftype_string_cstring - = build_function_type (string_type_node, - tree_cons (NULL_TREE, string_type_node, - cstring_endlink)); - - /* Prototype for strncpy/strncat. */ - string_ftype_string_cstring_sizet - = build_function_type (string_type_node, - tree_cons (NULL_TREE, string_type_node, - tree_cons (NULL_TREE, - const_string_type_node, - sizetype_endlink))); - traditional_len_type_node = ((flag_traditional && c_language != clk_cplusplus) ? integer_type_node : sizetype); - traditional_len_endlink = tree_cons (NULL_TREE, traditional_len_type_node, - endlink); - - /* Prototype for strcmp. */ - int_ftype_cstring_cstring - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, const_string_type_node, - cstring_endlink)); - - /* Prototype for strspn/strcspn. */ - sizet_ftype_cstring_cstring - = build_function_type (c_size_type_node, - tree_cons (NULL_TREE, const_string_type_node, - cstring_endlink)); - - /* Prototype for strncmp. */ - int_ftype_cstring_cstring_sizet - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, const_string_type_node, - tree_cons (NULL_TREE, - const_string_type_node, - sizetype_endlink))); - - /* Prototype for strstr, strpbrk, etc. */ - string_ftype_cstring_cstring - = build_function_type (string_type_node, - tree_cons (NULL_TREE, const_string_type_node, - cstring_endlink)); - - /* Prototype for strchr. */ - string_ftype_cstring_int - = build_function_type (string_type_node, - tree_cons (NULL_TREE, const_string_type_node, - int_endlink)); - - /* Prototype for strlen. */ - strlen_ftype - = build_function_type (traditional_len_type_node, cstring_endlink); - - traditional_ptr_type_node = ((flag_traditional && - c_language != clk_cplusplus) - ? string_type_node : ptr_type_node); - traditional_cptr_type_node = ((flag_traditional && - c_language != clk_cplusplus) - ? const_string_type_node : const_ptr_type_node); - /* Prototype for memcpy. */ - memcpy_ftype - = build_function_type (traditional_ptr_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, const_ptr_type_node, - sizetype_endlink))); - - /* Prototype for memset. */ - memset_ftype - = build_function_type (traditional_ptr_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, integer_type_node, - sizetype_endlink))); - - /* Prototype for bzero. */ - bzero_ftype - = build_function_type (void_type_node, - tree_cons (NULL_TREE, traditional_ptr_type_node, - traditional_len_endlink)); - - /* Prototype for bcmp. */ - bcmp_ftype - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, traditional_cptr_type_node, - tree_cons (NULL_TREE, - traditional_cptr_type_node, - traditional_len_endlink))); - - /* Prototype for puts. */ - puts_ftype - = build_function_type (integer_type_node, cstring_endlink); - - /* Prototype for printf. */ - printf_ftype - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, const_string_type_node, +#define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ + builtin_types[(int) ENUM] = VALUE; +#define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ + builtin_types[(int) ENUM] \ + = build_function_type (builtin_types[(int) RETURN], \ + void_list_node); +#define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ + builtin_types[(int) ENUM] \ + = build_function_type (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ + void_list_node)); +#define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ + builtin_types[(int) ENUM] \ + = build_function_type \ + (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG2], \ + void_list_node))); +#define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ + builtin_types[(int) ENUM] \ + = build_function_type \ + (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG2], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG3], \ + void_list_node)))); +#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ + builtin_types[(int) ENUM] \ + = build_function_type \ + (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG2], \ + tree_cons \ + (NULL_TREE, \ + builtin_types[(int) ARG3], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG4], \ + void_list_node))))); +#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ + builtin_types[(int) ENUM] \ + = build_function_type (builtin_types[(int) RETURN], NULL_TREE); +#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ + builtin_types[(int) ENUM] \ + = build_function_type (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ NULL_TREE)); - /* These stdio prototypes are declared using void* in place of - FILE*. They are only used for __builtin_ style calls, regular - style builtin prototypes omit the arguments and merge those - provided by stdio.h. */ - /* Prototype for fwrite. */ - fwrite_ftype - = build_function_type (c_size_type_node, - tree_cons (NULL_TREE, const_ptr_type_node, - tree_cons (NULL_TREE, c_size_type_node, - tree_cons (NULL_TREE, c_size_type_node, - tree_cons (NULL_TREE, ptr_type_node, endlink))))); - - /* Prototype for fputc. */ - fputc_ftype - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, integer_type_node, - tree_cons (NULL_TREE, ptr_type_node, endlink))); - - /* Prototype for fputs. */ - fputs_ftype - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, const_string_type_node, - tree_cons (NULL_TREE, ptr_type_node, endlink))); - - /* Prototype for fprintf. */ - fprintf_ftype - = build_function_type (integer_type_node, - tree_cons (NULL_TREE, ptr_type_node, - tree_cons (NULL_TREE, - const_string_type_node, - NULL_TREE))); - - builtin_function ("__builtin_constant_p", default_function_type, - BUILT_IN_CONSTANT_P, BUILT_IN_NORMAL, NULL); - - builtin_function ("__builtin_return_address", ptr_ftype_unsigned, - BUILT_IN_RETURN_ADDRESS, BUILT_IN_NORMAL, NULL); - - builtin_function ("__builtin_frame_address", ptr_ftype_unsigned, - BUILT_IN_FRAME_ADDRESS, BUILT_IN_NORMAL, NULL); - -#ifdef EH_RETURN_DATA_REGNO - builtin_function ("__builtin_eh_return_data_regno", int_ftype_int, - BUILT_IN_EH_RETURN_DATA_REGNO, BUILT_IN_NORMAL, NULL); -#endif +#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ + builtin_types[(int) ENUM] \ + = build_function_type \ + (builtin_types[(int) RETURN], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG1], \ + tree_cons (NULL_TREE, \ + builtin_types[(int) ARG2], \ + NULL_TREE))); +#define DEF_POINTER_TYPE(ENUM, TYPE) \ + builtin_types[(int) ENUM] \ + = build_pointer_type (builtin_types[(int) TYPE]); +#include "builtin-types.def" +#undef DEF_PRIMITIVE_TYPE +#undef DEF_FUNCTION_TYPE_1 +#undef DEF_FUNCTION_TYPE_2 +#undef DEF_FUNCTION_TYPE_3 +#undef DEF_FUNCTION_TYPE_4 +#undef DEF_FUNCTION_TYPE_VAR_0 +#undef DEF_FUNCTION_TYPE_VAR_1 +#undef DEF_POINTER_TYPE + +#define DEF_BUILTIN(ENUM, NAME, CLASS, \ + TYPE, LIBTYPE, BOTH_P, FALLBACK_P, NONANSI_P) \ + if (NAME) \ + { \ + tree decl; \ + \ + if (strncmp (NAME, "__builtin_", strlen ("__builtin_")) != 0) \ + abort (); \ + \ + if (!BOTH_P) \ + decl = builtin_function (NAME, builtin_types[TYPE], ENUM, \ + CLASS, \ + (FALLBACK_P \ + ? (NAME + strlen ("__builtin_")) \ + : NULL)); \ + else \ + decl = builtin_function_2 (NAME, \ + NAME + strlen ("__builtin_"), \ + builtin_types[TYPE], \ + builtin_types[LIBTYPE], \ + ENUM, \ + CLASS, \ + FALLBACK_P, \ + NONANSI_P, \ + /*noreturn_p=*/0); \ + \ + built_in_decls[(int) ENUM] = decl; \ + } +#include "builtins.def" +#undef DEF_BUILTIN - builtin_function ("__builtin_alloca", ptr_ftype_sizetype, - BUILT_IN_ALLOCA, BUILT_IN_NORMAL, "alloca"); - builtin_function_2 ("__builtin_ffs", "ffs", - int_ftype_int, int_ftype_int, - BUILT_IN_FFS, BUILT_IN_NORMAL, 0, 1, 0); - /* Define alloca as builtin, unless SMALL_STACK. */ -#ifndef SMALL_STACK - builtin_function_2 (NULL, "alloca", NULL_TREE, ptr_ftype_sizetype, - BUILT_IN_ALLOCA, BUILT_IN_NORMAL, 0, 1, 0); -#endif /* Declare _exit and _Exit just to mark them as non-returning. */ - builtin_function_2 (NULL, "_exit", NULL_TREE, void_ftype_int, + builtin_function_2 (NULL, "_exit", NULL_TREE, + builtin_types[BT_FN_VOID_INT], 0, NOT_BUILT_IN, 0, 1, 1); - builtin_function_2 (NULL, "_Exit", NULL_TREE, void_ftype_int, + builtin_function_2 (NULL, "_Exit", NULL_TREE, + builtin_types[BT_FN_VOID_INT], 0, NOT_BUILT_IN, 0, !flag_isoc99, 1); - builtin_function_2 ("__builtin_index", "index", - string_ftype_cstring_int, string_ftype_cstring_int, - BUILT_IN_INDEX, BUILT_IN_NORMAL, 1, 1, 0); - builtin_function_2 ("__builtin_rindex", "rindex", - string_ftype_cstring_int, string_ftype_cstring_int, - BUILT_IN_RINDEX, BUILT_IN_NORMAL, 1, 1, 0); - - /* The system prototypes for these functions have many - variations, so don't specify parameters to avoid conflicts. - The expand_* functions check the argument types anyway. */ - builtin_function_2 ("__builtin_bzero", "bzero", - bzero_ftype, void_ftype_any, - BUILT_IN_BZERO, BUILT_IN_NORMAL, 1, 1, 0); - builtin_function_2 ("__builtin_bcmp", "bcmp", - bcmp_ftype, int_ftype_any, - BUILT_IN_BCMP, BUILT_IN_NORMAL, 1, 1, 0); - - builtin_function_2 ("__builtin_abs", "abs", - int_ftype_int, int_ftype_int, - BUILT_IN_ABS, BUILT_IN_NORMAL, 0, 0, 0); - builtin_function_2 ("__builtin_fabsf", "fabsf", - float_ftype_float, float_ftype_float, - BUILT_IN_FABS, BUILT_IN_NORMAL, 0, 0, 0); - builtin_function_2 ("__builtin_fabs", "fabs", - double_ftype_double, double_ftype_double, - BUILT_IN_FABS, BUILT_IN_NORMAL, 0, 0, 0); - builtin_function_2 ("__builtin_fabsl", "fabsl", - ldouble_ftype_ldouble, ldouble_ftype_ldouble, - BUILT_IN_FABS, BUILT_IN_NORMAL, 0, 0, 0); - builtin_function_2 ("__builtin_labs", "labs", - long_ftype_long, long_ftype_long, - BUILT_IN_ABS, BUILT_IN_NORMAL, 0, 0, 0); - builtin_function_2 ("__builtin_llabs", "llabs", - longlong_ftype_longlong, longlong_ftype_longlong, - BUILT_IN_ABS, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_imaxabs", "imaxabs", - intmax_ftype_intmax, intmax_ftype_intmax, - BUILT_IN_ABS, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - - builtin_function ("__builtin_saveregs", ptr_ftype, BUILT_IN_SAVEREGS, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_classify_type", default_function_type, - BUILT_IN_CLASSIFY_TYPE, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_next_arg", ptr_ftype, BUILT_IN_NEXT_ARG, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_args_info", int_ftype_int, BUILT_IN_ARGS_INFO, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_setjmp", - build_function_type (integer_type_node, - tree_cons (NULL_TREE, ptr_type_node, - endlink)), - BUILT_IN_SETJMP, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_longjmp", - build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, - int_endlink)), - BUILT_IN_LONGJMP, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_trap", void_ftype, BUILT_IN_TRAP, - BUILT_IN_NORMAL, NULL); - - /* ISO C99 IEEE Unordered compares. */ - builtin_function ("__builtin_isgreater", default_function_type, - BUILT_IN_ISGREATER, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_isgreaterequal", default_function_type, - BUILT_IN_ISGREATEREQUAL, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_isless", default_function_type, - BUILT_IN_ISLESS, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_islessequal", default_function_type, - BUILT_IN_ISLESSEQUAL, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_islessgreater", default_function_type, - BUILT_IN_ISLESSGREATER, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_isunordered", default_function_type, - BUILT_IN_ISUNORDERED, BUILT_IN_NORMAL, NULL); - - /* Untyped call and return. */ - builtin_function ("__builtin_apply_args", ptr_ftype, - BUILT_IN_APPLY_ARGS, BUILT_IN_NORMAL, NULL); - - temp = tree_cons (NULL_TREE, - build_pointer_type (build_function_type (void_type_node, - NULL_TREE)), - tree_cons (NULL_TREE, ptr_type_node, sizetype_endlink)); - builtin_function ("__builtin_apply", - build_function_type (ptr_type_node, temp), - BUILT_IN_APPLY, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_return", void_ftype_ptr, - BUILT_IN_RETURN, BUILT_IN_NORMAL, NULL); - - /* Support for varargs.h and stdarg.h. */ - builtin_function ("__builtin_varargs_start", - build_function_type (void_type_node, - tree_cons (NULL_TREE, - va_list_ref_type_node, - endlink)), - BUILT_IN_VARARGS_START, BUILT_IN_NORMAL, NULL); - - builtin_function ("__builtin_stdarg_start", - build_function_type (void_type_node, - tree_cons (NULL_TREE, - va_list_ref_type_node, - NULL_TREE)), - BUILT_IN_STDARG_START, BUILT_IN_NORMAL, NULL); - - builtin_function ("__builtin_va_end", - build_function_type (void_type_node, - tree_cons (NULL_TREE, - va_list_ref_type_node, - endlink)), - BUILT_IN_VA_END, BUILT_IN_NORMAL, NULL); - - builtin_function ("__builtin_va_copy", - build_function_type (void_type_node, - tree_cons (NULL_TREE, - va_list_ref_type_node, - tree_cons (NULL_TREE, - va_list_arg_type_node, - endlink))), - BUILT_IN_VA_COPY, BUILT_IN_NORMAL, NULL); - - /* ??? Ought to be `T __builtin_expect(T, T)' for any type T. */ - builtin_function ("__builtin_expect", - build_function_type (long_integer_type_node, - tree_cons (NULL_TREE, - long_integer_type_node, - tree_cons (NULL_TREE, - long_integer_type_node, - endlink))), - BUILT_IN_EXPECT, BUILT_IN_NORMAL, NULL); - - /* Currently under experimentation. */ - builtin_function_2 ("__builtin_memcpy", "memcpy", - memcpy_ftype, memcpy_ftype, - BUILT_IN_MEMCPY, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_memcmp", "memcmp", - int_ftype_cptr_cptr_sizet, int_ftype_cptr_cptr_sizet, - BUILT_IN_MEMCMP, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_memset", "memset", - memset_ftype, memset_ftype, - BUILT_IN_MEMSET, BUILT_IN_NORMAL, 1, 0, 0); - built_in_decls[BUILT_IN_STRCMP] = - builtin_function_2 ("__builtin_strcmp", "strcmp", - int_ftype_cstring_cstring, int_ftype_cstring_cstring, - BUILT_IN_STRCMP, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strncmp", "strncmp", - int_ftype_cstring_cstring_sizet, - int_ftype_cstring_cstring_sizet, - BUILT_IN_STRNCMP, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strstr", "strstr", - string_ftype_cstring_cstring, string_ftype_cstring_cstring, - BUILT_IN_STRSTR, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strpbrk", "strpbrk", - string_ftype_cstring_cstring, string_ftype_cstring_cstring, - BUILT_IN_STRPBRK, BUILT_IN_NORMAL, 1, 0, 0); - built_in_decls[BUILT_IN_STRCHR] = - builtin_function_2 ("__builtin_strchr", "strchr", - string_ftype_cstring_int, string_ftype_cstring_int, - BUILT_IN_STRCHR, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strrchr", "strrchr", - string_ftype_cstring_int, string_ftype_cstring_int, - BUILT_IN_STRRCHR, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strcpy", "strcpy", - string_ftype_string_cstring, string_ftype_string_cstring, - BUILT_IN_STRCPY, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strncpy", "strncpy", - string_ftype_string_cstring_sizet, - string_ftype_string_cstring_sizet, - BUILT_IN_STRNCPY, BUILT_IN_NORMAL, 1, 0, 0); - built_in_decls[BUILT_IN_STRCAT] = - builtin_function_2 ("__builtin_strcat", "strcat", - string_ftype_string_cstring, - string_ftype_string_cstring, - BUILT_IN_STRCAT, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strncat", "strncat", - string_ftype_string_cstring_sizet, - string_ftype_string_cstring_sizet, - BUILT_IN_STRNCAT, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strspn", "strspn", - sizet_ftype_cstring_cstring, sizet_ftype_cstring_cstring, - BUILT_IN_STRSPN, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_strcspn", "strcspn", - sizet_ftype_cstring_cstring, sizet_ftype_cstring_cstring, - BUILT_IN_STRCSPN, BUILT_IN_NORMAL, 1, 0, 0); - built_in_decls[BUILT_IN_STRLEN] = - builtin_function_2 ("__builtin_strlen", "strlen", - strlen_ftype, strlen_ftype, - BUILT_IN_STRLEN, BUILT_IN_NORMAL, 1, 0, 0); - - builtin_function_2 ("__builtin_sqrtf", "sqrtf", - float_ftype_float, float_ftype_float, - BUILT_IN_FSQRT, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_fsqrt", "sqrt", - double_ftype_double, double_ftype_double, - BUILT_IN_FSQRT, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_sqrtl", "sqrtl", - ldouble_ftype_ldouble, ldouble_ftype_ldouble, - BUILT_IN_FSQRT, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_sinf", "sinf", - float_ftype_float, float_ftype_float, - BUILT_IN_SIN, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_sin", "sin", - double_ftype_double, double_ftype_double, - BUILT_IN_SIN, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_sinl", "sinl", - ldouble_ftype_ldouble, ldouble_ftype_ldouble, - BUILT_IN_SIN, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_cosf", "cosf", - float_ftype_float, float_ftype_float, - BUILT_IN_COS, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_cos", "cos", - double_ftype_double, double_ftype_double, - BUILT_IN_COS, BUILT_IN_NORMAL, 1, 0, 0); - builtin_function_2 ("__builtin_cosl", "cosl", - ldouble_ftype_ldouble, ldouble_ftype_ldouble, - BUILT_IN_COS, BUILT_IN_NORMAL, 1, 0, 0); - - /* ISO C99 complex arithmetic functions. */ - builtin_function_2 ("__builtin_conjf", "conjf", - cfloat_ftype_cfloat, cfloat_ftype_cfloat, - BUILT_IN_CONJ, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_conj", "conj", - cdouble_ftype_cdouble, cdouble_ftype_cdouble, - BUILT_IN_CONJ, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_conjl", "conjl", - cldouble_ftype_cldouble, cldouble_ftype_cldouble, - BUILT_IN_CONJ, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_crealf", "crealf", - float_ftype_cfloat, float_ftype_cfloat, - BUILT_IN_CREAL, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_creal", "creal", - double_ftype_cdouble, double_ftype_cdouble, - BUILT_IN_CREAL, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_creall", "creall", - ldouble_ftype_cldouble, ldouble_ftype_cldouble, - BUILT_IN_CREAL, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_cimagf", "cimagf", - float_ftype_cfloat, float_ftype_cfloat, - BUILT_IN_CIMAG, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_cimag", "cimag", - double_ftype_cdouble, double_ftype_cdouble, - BUILT_IN_CIMAG, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - builtin_function_2 ("__builtin_cimagl", "cimagl", - ldouble_ftype_cldouble, ldouble_ftype_cldouble, - BUILT_IN_CIMAG, BUILT_IN_NORMAL, 0, !flag_isoc99, 0); - - built_in_decls[BUILT_IN_PUTCHAR] = - builtin_function ("__builtin_putchar", int_ftype_int, - BUILT_IN_PUTCHAR, BUILT_IN_NORMAL, "putchar"); - built_in_decls[BUILT_IN_PUTS] = - builtin_function ("__builtin_puts", puts_ftype, - BUILT_IN_PUTS, BUILT_IN_NORMAL, "puts"); - builtin_function_2 ("__builtin_printf", "printf", - printf_ftype, printf_ftype, - BUILT_IN_PRINTF, BUILT_IN_FRONTEND, 1, 0, 0); - builtin_function_2 ("__builtin_fprintf", "fprintf", - fprintf_ftype, fprintf_ftype, - BUILT_IN_FPRINTF, BUILT_IN_FRONTEND, 1, 0, 0); - built_in_decls[BUILT_IN_FWRITE] = - builtin_function ("__builtin_fwrite", fwrite_ftype, - BUILT_IN_FWRITE, BUILT_IN_NORMAL, "fwrite"); - built_in_decls[BUILT_IN_FPUTC] = - builtin_function ("__builtin_fputc", fputc_ftype, - BUILT_IN_FPUTC, BUILT_IN_NORMAL, "fputc"); - /* Declare the __builtin_ style with arguments and the regular style - without them. We rely on stdio.h to supply the arguments for the - regular style declaration since we had to use void* instead of - FILE* in the __builtin_ prototype supplied here. */ - built_in_decls[BUILT_IN_FPUTS] = - builtin_function_2 ("__builtin_fputs", "fputs", - fputs_ftype, int_ftype_any, - BUILT_IN_FPUTS, BUILT_IN_NORMAL, 1, 0, 0); - /* Declare these functions non-returning to avoid spurious "control drops through" warnings. */ builtin_function_2 (NULL, "abort", NULL_TREE, ((c_language == clk_cplusplus) - ? void_ftype : void_ftype_any), + ? builtin_types[BT_FN_VOID] + : builtin_types[BT_FN_VOID_VAR]), 0, NOT_BUILT_IN, 0, 0, 1); builtin_function_2 (NULL, "exit", NULL_TREE, ((c_language == clk_cplusplus) - ? void_ftype_int : void_ftype_any), + ? builtin_types[BT_FN_VOID_INT] + : builtin_types[BT_FN_VOID_VAR]), 0, NOT_BUILT_IN, 0, 0, 1); -#if 0 - /* Support for these has not been written in either expand_builtin - or build_function_call. */ - builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_fmod", double_ftype_double_double, - BUILT_IN_FMOD, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_frem", double_ftype_double_double, - BUILT_IN_FREM, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP, - BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN, - BUILT_IN_NORMAL, NULL); -#endif - main_identifier_node = get_identifier ("main"); /* ??? Perhaps there's a better place to do this. But it is related @@ -3815,22 +3402,33 @@ expand_tree_builtin (function, params, coerced_params) switch (DECL_FUNCTION_CODE (function)) { case BUILT_IN_ABS: + case BUILT_IN_LABS: + case BUILT_IN_LLABS: + case BUILT_IN_IMAXABS: case BUILT_IN_FABS: + case BUILT_IN_FABSL: + case BUILT_IN_FABSF: if (coerced_params == 0) return integer_zero_node; return build_unary_op (ABS_EXPR, TREE_VALUE (coerced_params), 0); case BUILT_IN_CONJ: + case BUILT_IN_CONJF: + case BUILT_IN_CONJL: if (coerced_params == 0) return integer_zero_node; return build_unary_op (CONJ_EXPR, TREE_VALUE (coerced_params), 0); case BUILT_IN_CREAL: + case BUILT_IN_CREALF: + case BUILT_IN_CREALL: if (coerced_params == 0) return integer_zero_node; return build_unary_op (REALPART_EXPR, TREE_VALUE (coerced_params), 0); case BUILT_IN_CIMAG: + case BUILT_IN_CIMAGF: + case BUILT_IN_CIMAGL: if (coerced_params == 0) return integer_zero_node; return build_unary_op (IMAGPART_EXPR, TREE_VALUE (coerced_params), 0); diff --git a/gcc/c-common.h b/gcc/c-common.h index 8a5a7593653..c1b273e6e30 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -148,11 +148,6 @@ enum c_tree_index CTI_C_BOOL_FALSE, CTI_DEFAULT_FUNCTION_TYPE, - CTI_VOID_FTYPE, - CTI_VOID_FTYPE_PTR, - CTI_INT_FTYPE_INT, - CTI_PTR_FTYPE_SIZETYPE, - CTI_G77_INTEGER_TYPE, CTI_G77_UINTEGER_TYPE, CTI_G77_LONGINT_TYPE, @@ -207,10 +202,6 @@ struct c_common_identifier #define const_string_type_node c_global_trees[CTI_CONST_STRING_TYPE] #define default_function_type c_global_trees[CTI_DEFAULT_FUNCTION_TYPE] -#define void_ftype c_global_trees[CTI_VOID_FTYPE] -#define void_ftype_ptr c_global_trees[CTI_VOID_FTYPE_PTR] -#define int_ftype_int c_global_trees[CTI_INT_FTYPE_INT] -#define ptr_ftype_sizetype c_global_trees[CTI_PTR_FTYPE_SIZETYPE] /* g77 integer types, which which must be kept in sync with f/com.h */ #define g77_integer_type_node c_global_trees[CTI_G77_INTEGER_TYPE] diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 758888561a4..75c8f8a3012 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3056,36 +3056,6 @@ init_decl_processing () g77_ulongint_type_node)); } - builtin_function ("__builtin_aggregate_incoming_address", - build_function_type (ptr_type_node, NULL_TREE), - BUILT_IN_AGGREGATE_INCOMING_ADDRESS, - BUILT_IN_NORMAL, NULL); - - /* Hooks for the DWARF 2 __throw routine. */ - builtin_function ("__builtin_unwind_init", - build_function_type (void_type_node, endlink), - BUILT_IN_UNWIND_INIT, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_dwarf_cfa", ptr_ftype_void, - BUILT_IN_DWARF_CFA, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_dwarf_fp_regnum", - build_function_type (unsigned_type_node, endlink), - BUILT_IN_DWARF_FP_REGNUM, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_init_dwarf_reg_size_table", void_ftype_ptr, - BUILT_IN_INIT_DWARF_REG_SIZES, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_frob_return_addr", ptr_ftype_ptr, - BUILT_IN_FROB_RETURN_ADDR, BUILT_IN_NORMAL, NULL); - builtin_function ("__builtin_extract_return_addr", ptr_ftype_ptr, - BUILT_IN_EXTRACT_RETURN_ADDR, BUILT_IN_NORMAL, NULL); - builtin_function - ("__builtin_eh_return", - build_function_type (void_type_node, - tree_cons (NULL_TREE, - type_for_mode (ptr_mode, 0), - tree_cons (NULL_TREE, - ptr_type_node, - endlink))), - BUILT_IN_EH_RETURN, BUILT_IN_NORMAL, NULL); - pedantic_lvalues = pedantic; make_fname_decl = c_make_fname_decl; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index df72dfe3d0a..bf9bd893529 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2001-05-26 Mark Mitchell + + * decl.c (init_decl_processing): Tweak. + 2001-05-24 Mark Mitchell * decl.c (duplicate_decls): Tidy. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c91ba6082ee..06f19cdeb0b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6325,6 +6325,8 @@ void init_decl_processing () { tree fields[20]; + tree void_ftype; + tree void_ftype_ptr; /* Check to see that the user did not specify an invalid combination of command-line options. */ @@ -6452,6 +6454,11 @@ init_decl_processing () vtt_parm_type = build_pointer_type (const_ptr_type_node); lang_type_promotes_to = convert_type_from_ellipsis; + void_ftype = build_function_type (void_type_node, void_list_node); + void_ftype_ptr = build_function_type (void_type_node, + tree_cons (NULL_TREE, + ptr_type_node, + void_list_node)); void_ftype_ptr = build_exception_variant (void_ftype_ptr, empty_except_spec); @@ -6528,13 +6535,19 @@ init_decl_processing () { tree bad_alloc_type_node, newtype, deltype; - + tree ptr_ftype_sizetype; + if (flag_honor_std) push_namespace (std_identifier); bad_alloc_type_node = xref_tag (class_type_node, get_identifier ("bad_alloc"), 1); if (flag_honor_std) pop_namespace (); + ptr_ftype_sizetype + = build_function_type (ptr_type_node, + tree_cons (NULL_TREE, + c_size_type_node, + void_list_node)); newtype = build_exception_variant (ptr_ftype_sizetype, add_exception_specifier (NULL_TREE, bad_alloc_type_node, -1)); diff --git a/gcc/defaults.h b/gcc/defaults.h index 452bdfe44cd..3b8d0a17c49 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -343,5 +343,13 @@ do { \ #define TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER true #endif +/* Define this macro if you have any machine-specific builtin + functions that need to be defined. It should be a C expression + that performs the necessary setup. */ + +#ifndef MD_INIT_BUILTINS +#define MD_INIT_BUILTINS +#endif + #endif /* GCC_DEFAULTS_H */ diff --git a/gcc/tree.h b/gcc/tree.h index bea25d08fc5..838368bb07d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -84,7 +84,7 @@ extern const char *const built_in_class_names[4]; /* Codes that identify the various built in functions so that expand_call can identify them quickly. */ -#define DEF_BUILTIN(x) x, +#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA) ENUM, enum built_in_function { #include "builtins.def"