Commit c6a912da by Richard Henderson

builtins.c (DEF_BUILTIN): Add COND argument.

        * builtins.c (DEF_BUILTIN): Add COND argument.
        * tree.h (DEF_BUILTIN): Likewise.
        * builtins.def (DEF_GCC_BUILTIN, DEF_LIB_BUILTIN, DEF_EXT_LIB_BUILTIN,
        DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C99_C90RES_BUILTIN): Update to
        match.
        (DEF_BUILTIN_STUB): New.
        (BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_INIT_TRAMPOLINE,
        BUILT_IN_ADJUST_TRAMPOLINE, BUILT_IN_NONLOCAL_GOTO,
        BUILT_IN_PROFILE_FUNC_ENTER, BUILT_IN_PROFILE_FUNC_EXIT): Use it.
        * c-common.c (DEF_BUILTIN): Add COND argument.
        * tree.c (local_define_builtin): New.
        (build_common_builtin_nodes): New.
ada/
        * utils.c (gnat_define_builtin): Remove.
        (gnat_install_builtins): Use build_common_builtin_nodes.
fortran/
        * f95-lang.c (gfc_init_builtin_functions): Call
        build_common_builtin_nodes; do not define any functions handled
        by it.
java/
        * builtins.c (initialize_builtins): Call build_common_builtin_nodes.
        * decl.c (java_init_decl_processing): Initialize const_ptr_type_node.
treelang/
        * treetree.c (treelang_init_decl_processing): Call
        build_common_builtin_nodes.

From-SVN: r94785
parent af977719
2005-02-09 Richard Henderson <rth@redhat.com>
* builtins.c (DEF_BUILTIN): Add COND argument.
* tree.h (DEF_BUILTIN): Likewise.
* builtins.def (DEF_GCC_BUILTIN, DEF_LIB_BUILTIN, DEF_EXT_LIB_BUILTIN,
DEF_C94_BUILTIN, DEF_C99_BUILTIN, DEF_C99_C90RES_BUILTIN): Update to
match.
(DEF_BUILTIN_STUB): New.
(BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_INIT_TRAMPOLINE,
BUILT_IN_ADJUST_TRAMPOLINE, BUILT_IN_NONLOCAL_GOTO,
BUILT_IN_PROFILE_FUNC_ENTER, BUILT_IN_PROFILE_FUNC_EXIT): Use it.
* c-common.c (DEF_BUILTIN): Add COND argument.
* tree.c (local_define_builtin): New.
(build_common_builtin_nodes): New.
2005-02-09 Roger Sayle <roger@eyesopen.com> 2005-02-09 Roger Sayle <roger@eyesopen.com>
* fold-const.c (fold_strip_sign_ops): New function to simplify a * fold-const.c (fold_strip_sign_ops): New function to simplify a
......
2005-02-09 Richard Henderson <rth@redhat.com>
* utils.c (gnat_define_builtin): Remove.
(gnat_install_builtins): Use build_common_builtin_nodes.
2005-02-09 Arnaud Charlet <charlet@adacore.com> 2005-02-09 Arnaud Charlet <charlet@adacore.com>
* a-rbtgso.adb, a-crbtgo.ads, a-crbtgo.adb, a-crbtgk.ads, * a-rbtgso.adb, a-crbtgo.ads, a-crbtgo.adb, a-crbtgk.ads,
......
...@@ -118,7 +118,6 @@ struct language_function GTY(()) ...@@ -118,7 +118,6 @@ struct language_function GTY(())
int unused; int unused;
}; };
static void gnat_define_builtin (const char *, tree, int, const char *, bool);
static void gnat_install_builtins (void); static void gnat_install_builtins (void);
static tree merge_sizes (tree, tree, tree, bool, bool); static tree merge_sizes (tree, tree, tree, bool, bool);
static tree compute_related_constant (tree, tree); static tree compute_related_constant (tree, tree);
...@@ -405,110 +404,13 @@ gnat_init_decl_processing (void) ...@@ -405,110 +404,13 @@ gnat_init_decl_processing (void)
gnat_install_builtins (); gnat_install_builtins ();
} }
/* Define a builtin function. This is temporary and is just being done
to initialize *_built_in_decls for the middle-end. We'll want
to do full builtin processing soon. */
static void
gnat_define_builtin (const char *name, tree type,
int function_code, const char *library_name, bool const_p)
{
tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
if (library_name)
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
make_decl_rtl (decl);
gnat_pushdecl (decl, Empty);
DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL;
DECL_FUNCTION_CODE (decl) = function_code;
TREE_READONLY (decl) = const_p;
implicit_built_in_decls[function_code] = decl;
built_in_decls[function_code] = decl;
}
/* Install the builtin functions the middle-end needs. */ /* Install the builtin functions the middle-end needs. */
static void static void
gnat_install_builtins () gnat_install_builtins ()
{ {
tree ftype; /* Builtins used by generic optimizers. */
tree tmp; build_common_builtin_nodes ();
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
ftype = build_function_type (long_integer_type_node, tmp);
gnat_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
"__builtin_expect", true);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
ftype = build_function_type (ptr_void_type_node, tmp);
gnat_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
"memcpy", false);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
ftype = build_function_type (integer_type_node, tmp);
gnat_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
"memcmp", false);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
ftype = build_function_type (integer_type_node, tmp);
gnat_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
"memset", false);
tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp);
gnat_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ, "clz", true);
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp);
gnat_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL, "clzl", true);
tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp);
gnat_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL, "clzll",
true);
/* The init_trampoline and adjust_trampoline builtins aren't used directly.
They are inserted during lowering of nested functions. */
tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, tmp);
ftype = build_function_type (void_type_node, tmp);
gnat_define_builtin ("__builtin_init_trampoline", ftype,
BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", false);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
ftype = build_function_type (ptr_void_type_node, tmp);
gnat_define_builtin ("__builtin_adjust_trampoline", ftype,
BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", true);
/* The stack_save, stack_restore, and alloca builtins aren't used directly.
They are inserted during gimplification to implement variable sized stack
allocation. */
ftype = build_function_type (ptr_void_type_node, void_list_node);
gnat_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
"stack_save", false);
tmp = tree_cons (NULL_TREE, ptr_void_type_node, void_list_node);
ftype = build_function_type (void_type_node, tmp);
gnat_define_builtin ("__builtin_stack_restore", ftype,
BUILT_IN_STACK_RESTORE, "stack_restore", false);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
ftype = build_function_type (ptr_void_type_node, tmp);
gnat_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
"alloca", false);
/* Target specific builtins, such as the AltiVec family on ppc. */ /* Target specific builtins, such as the AltiVec family on ppc. */
targetm.init_builtins (); targetm.init_builtins ();
......
...@@ -59,7 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -59,7 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
const char *const built_in_class_names[4] const char *const built_in_class_names[4]
= {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"}; = {"NOT_BUILT_IN", "BUILT_IN_FRONTEND", "BUILT_IN_MD", "BUILT_IN_NORMAL"};
#define DEF_BUILTIN(X, N, C, T, LT, B, F, NA, AT, IM) #X, #define DEF_BUILTIN(X, N, C, T, LT, B, F, NA, AT, IM, COND) #X,
const char *const built_in_names[(int) END_BUILTINS] = const char *const built_in_names[(int) END_BUILTINS] =
{ {
#include "builtins.def" #include "builtins.def"
......
...@@ -69,7 +69,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -69,7 +69,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#undef DEF_GCC_BUILTIN #undef DEF_GCC_BUILTIN
#define DEF_GCC_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_GCC_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, BT_LAST, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, BT_LAST, \
false, false, false, ATTRS, true) false, false, false, ATTRS, true, true)
/* A library builtin (like __builtin_strchr) is a builtin equivalent /* A library builtin (like __builtin_strchr) is a builtin equivalent
of an ANSI/ISO standard library function. In addition to the of an ANSI/ISO standard library function. In addition to the
...@@ -80,7 +80,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -80,7 +80,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#undef DEF_LIB_BUILTIN #undef DEF_LIB_BUILTIN
#define DEF_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, false, ATTRS, true) true, true, false, ATTRS, true, true)
/* Like DEF_LIB_BUILTIN, except that the function is not one that is /* 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 specified by ANSI/ISO C. So, when we're being fully conformant we
...@@ -89,21 +89,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -89,21 +89,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#undef DEF_EXT_LIB_BUILTIN #undef DEF_EXT_LIB_BUILTIN
#define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_EXT_LIB_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, true, ATTRS, false) true, true, true, ATTRS, false, true)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of /* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C94 or above. */ the standard in C94 or above. */
#undef DEF_C94_BUILTIN #undef DEF_C94_BUILTIN
#define DEF_C94_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_C94_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, !flag_isoc94, ATTRS, TARGET_C99_FUNCTIONS) true, true, !flag_isoc94, ATTRS, TARGET_C99_FUNCTIONS, true)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of /* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C99 or above. */ the standard in C99 or above. */
#undef DEF_C99_BUILTIN #undef DEF_C99_BUILTIN
#define DEF_C99_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_C99_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS) true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS, true)
/* Builtin that is specified by C99 and C90 reserve the name for future use. /* Builtin that is specified by C99 and C90 reserve the name for future use.
We can still recognize the builtin in C90 mode but we can't produce it We can still recognize the builtin in C90 mode but we can't produce it
...@@ -111,7 +111,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -111,7 +111,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#undef DEF_C99_C90RES_BUILTIN #undef DEF_C99_C90RES_BUILTIN
#define DEF_C99_C90RES_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ #define DEF_C99_C90RES_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS) true, true, !flag_isoc99, ATTRS, TARGET_C99_FUNCTIONS, true)
/* Allocate the enum and the name for a builtin, but do not actually
define it here at all. */
#undef DEF_BUILTIN_STUB
#define DEF_BUILTIN_STUB(ENUM, NAME) \
DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, 0, 0, false, false, \
false, 0, false, false)
/* Define an attribute list for math functions that are normally /* Define an attribute list for math functions that are normally
"impure" because some of them may write into global memory for "impure" because some of them may write into global memory for
...@@ -610,8 +617,6 @@ DEF_GCC_BUILTIN (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN ...@@ -610,8 +617,6 @@ DEF_GCC_BUILTIN (BUILT_IN_RETURN, "return", BT_FN_VOID_PTR, ATTR_NORETURN
DEF_GCC_BUILTIN (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_RETURN_ADDRESS, "return_address", BT_FN_PTR_UINT, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_SAVEREGS, "saveregs", BT_FN_PTR_VAR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_SETJMP, "setjmp", BT_FN_INT_PTR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_STACK_SAVE, "stack_save", BT_FN_PTR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_STACK_RESTORE, "stack_restore", BT_FN_VOID_PTR, ATTR_NULL)
DEF_GCC_BUILTIN (BUILT_IN_STDARG_START, "stdarg_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_STDARG_START, "stdarg_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL)
DEF_EXT_LIB_BUILTIN (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_3_4) DEF_EXT_LIB_BUILTIN (BUILT_IN_STRFMON, "strfmon", BT_FN_SSIZE_STRING_SIZE_CONST_STRING_VAR, ATTR_FORMAT_STRFMON_3_4)
DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR, ATTR_FORMAT_STRFTIME_3_0) DEF_LIB_BUILTIN (BUILT_IN_STRFTIME, "strftime", BT_FN_SIZE_STRING_SIZE_CONST_STRING_CONST_PTR, ATTR_FORMAT_STRFTIME_3_0)
...@@ -623,12 +628,16 @@ DEF_GCC_BUILTIN (BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, ATTR_N ...@@ -623,12 +628,16 @@ DEF_GCC_BUILTIN (BUILT_IN_VA_END, "va_end", BT_FN_VOID_VALIST_REF, ATTR_N
DEF_GCC_BUILTIN (BUILT_IN_VA_START, "va_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_VA_START, "va_start", BT_FN_VOID_VALIST_REF_VAR, ATTR_NULL)
DEF_EXT_LIB_BUILTIN (BUILT_IN__EXIT, "_exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN__EXIT, "_exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST) DEF_C99_BUILTIN (BUILT_IN__EXIT2, "_Exit", BT_FN_VOID_INT, ATTR_NORETURN_NOTHROW_LIST)
DEF_GCC_BUILTIN (BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
DEF_GCC_BUILTIN (BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", BT_FN_PTR_PTR, ATTR_CONST_NOTHROW_LIST) /* Implementing nested functions. */
DEF_GCC_BUILTIN (BUILT_IN_NONLOCAL_GOTO, "nonlocal_goto", BT_FN_PTR_PTR, ATTR_NORETURN_NOTHROW_LIST) DEF_BUILTIN_STUB (BUILT_IN_INIT_TRAMPOLINE, "__builtin_init_trampoline")
DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline")
DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto")
/* Implementing variable sized local variables. */
DEF_BUILTIN_STUB (BUILT_IN_STACK_SAVE, "__builtin_stack_save")
DEF_BUILTIN_STUB (BUILT_IN_STACK_RESTORE, "__builtin_stack_restore")
/* Profiling hooks. */ /* Profiling hooks. */
DEF_GCC_BUILTIN (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter")
BT_FN_VOID, ATTR_NULL) DEF_BUILTIN_STUB (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit")
DEF_GCC_BUILTIN (BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit",
BT_FN_VOID, ATTR_NULL)
...@@ -3199,9 +3199,9 @@ c_common_nodes_and_builtins (void) ...@@ -3199,9 +3199,9 @@ c_common_nodes_and_builtins (void)
c_init_attributes (); c_init_attributes ();
#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, \ #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT) \ NONANSI_P, ATTRS, IMPLICIT, COND) \
if (NAME) \ if (NAME && COND) \
{ \ { \
tree decl; \ tree decl; \
\ \
...@@ -3234,6 +3234,8 @@ c_common_nodes_and_builtins (void) ...@@ -3234,6 +3234,8 @@ c_common_nodes_and_builtins (void)
#include "builtins.def" #include "builtins.def"
#undef DEF_BUILTIN #undef DEF_BUILTIN
build_common_builtin_nodes ();
targetm.init_builtins (); targetm.init_builtins ();
if (flag_mudflap) if (flag_mudflap)
mudflap_init (); mudflap_init ();
......
2005-02-09 Richard Henderson <rth@redhat.com>
* f95-lang.c (gfc_init_builtin_functions): Call
build_common_builtin_nodes; do not define any functions handled
by it.
2005-02-08 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de> 2005-02-08 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* expr.c (gfc_copy_expr): Don't copy 'op1' and 'op2' for * expr.c (gfc_copy_expr): Don't copy 'op1' and 'op2' for
......
...@@ -794,8 +794,7 @@ gfc_init_builtin_functions (void) ...@@ -794,8 +794,7 @@ gfc_init_builtin_functions (void)
BUILT_IN_CABS, "cabs", true); BUILT_IN_CABS, "cabs", true);
gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
BUILT_IN_CABSF, "cabsf", true); BUILT_IN_CABSF, "cabsf", true);
gfc_define_builtin ("__builtin_copysign", mfunc_double[1], gfc_define_builtin ("__builtin_copysign", mfunc_double[1],
BUILT_IN_COPYSIGN, "copysign", true); BUILT_IN_COPYSIGN, "copysign", true);
gfc_define_builtin ("__builtin_copysignf", mfunc_float[1], gfc_define_builtin ("__builtin_copysignf", mfunc_float[1],
...@@ -809,61 +808,28 @@ gfc_init_builtin_functions (void) ...@@ -809,61 +808,28 @@ gfc_init_builtin_functions (void)
/* Other builtin functions we use. */ /* Other builtin functions we use. */
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
ftype = build_function_type (long_integer_type_node, tmp);
gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
"__builtin_expect", true);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp);
ftype = build_function_type (pvoid_type_node, tmp);
gfc_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
"memcpy", false);
tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp); ftype = build_function_type (integer_type_node, tmp);
gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ, "clz", true); gfc_define_builtin ("__builtin_clz", ftype, BUILT_IN_CLZ,
"__builtin_clz", true);
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node); tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp); ftype = build_function_type (integer_type_node, tmp);
gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL, "clzl", true); gfc_define_builtin ("__builtin_clzl", ftype, BUILT_IN_CLZL,
"__builtin_clzl", true);
tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node); tmp = tree_cons (NULL_TREE, long_long_integer_type_node, void_list_node);
ftype = build_function_type (integer_type_node, tmp); ftype = build_function_type (integer_type_node, tmp);
gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL, "clzll", true); gfc_define_builtin ("__builtin_clzll", ftype, BUILT_IN_CLZLL,
"__builtin_clzll", true);
tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp); tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, pvoid_type_node, tmp); tmp = tree_cons (NULL_TREE, long_integer_type_node, tmp);
ftype = build_function_type (void_type_node, tmp); ftype = build_function_type (long_integer_type_node, tmp);
gfc_define_builtin ("__builtin_init_trampoline", ftype, gfc_define_builtin ("__builtin_expect", ftype, BUILT_IN_EXPECT,
BUILT_IN_INIT_TRAMPOLINE, "init_trampoline", false); "__builtin_expect", true);
tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
ftype = build_function_type (pvoid_type_node, tmp);
gfc_define_builtin ("__builtin_adjust_trampoline", ftype,
BUILT_IN_ADJUST_TRAMPOLINE, "adjust_trampoline", true);
/* The stack_save, stack_restore, and alloca builtins aren't used directly.
They are inserted during gimplification to implement variable sized
stack allocation. */
ftype = build_function_type (pvoid_type_node, void_list_node);
gfc_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
"stack_save", false);
tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
ftype = build_function_type (void_type_node, tmp);
gfc_define_builtin ("__builtin_stack_restore", ftype, BUILT_IN_STACK_RESTORE,
"stack_restore", false);
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
ftype = build_function_type (pvoid_type_node, tmp);
gfc_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
"alloca", false);
build_common_builtin_nodes ();
targetm.init_builtins (); targetm.init_builtins ();
} }
......
2005-02-09 Richard Henderson <rth@redhat.com>
* builtins.c (initialize_builtins): Call build_common_builtin_nodes.
* decl.c (java_init_decl_processing): Initialize const_ptr_type_node.
2005-02-08 Marcin Dalecki <martin@dalecki.de> 2005-02-08 Marcin Dalecki <martin@dalecki.de>
* expr.c (add_type_assertion): Use the proper enumeration type, * expr.c (add_type_assertion): Use the proper enumeration type,
......
...@@ -216,6 +216,8 @@ initialize_builtins (void) ...@@ -216,6 +216,8 @@ initialize_builtins (void)
double_ftype_double, "_ZN4java4lang4Math4sqrtEd"); double_ftype_double, "_ZN4java4lang4Math4sqrtEd");
define_builtin (BUILT_IN_TAN, "__builtin_tan", define_builtin (BUILT_IN_TAN, "__builtin_tan",
double_ftype_double, "_ZN4java4lang4Math3tanEd"); double_ftype_double, "_ZN4java4lang4Math3tanEd");
build_common_builtin_nodes ();
} }
/* If the call matches a builtin, return the /* If the call matches a builtin, return the
......
...@@ -692,7 +692,11 @@ java_init_decl_processing (void) ...@@ -692,7 +692,11 @@ java_init_decl_processing (void)
void_type_node = make_node (VOID_TYPE); void_type_node = make_node (VOID_TYPE);
pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node)); pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
layout_type (void_type_node); /* Uses size_zero_node */ layout_type (void_type_node); /* Uses size_zero_node */
ptr_type_node = build_pointer_type (void_type_node); ptr_type_node = build_pointer_type (void_type_node);
const_ptr_type_node
= build_pointer_type (build_type_variant (void_type_node, 1, 0));
t = make_node (VOID_TYPE); t = make_node (VOID_TYPE);
layout_type (t); /* Uses size_zero_node */ layout_type (t); /* Uses size_zero_node */
return_address_type_node = build_pointer_type (t); return_address_type_node = build_pointer_type (t);
......
...@@ -5782,6 +5782,124 @@ build_common_tree_nodes_2 (int short_double) ...@@ -5782,6 +5782,124 @@ build_common_tree_nodes_2 (int short_double)
} }
} }
/* A subroutine of build_common_builtin_nodes. Define a builtin function. */
static void
local_define_builtin (const char *name, tree type, enum built_in_function code,
const char *library_name, int ecf_flags)
{
tree decl;
decl = lang_hooks.builtin_function (name, type, code, BUILT_IN_NORMAL,
library_name, NULL_TREE);
if (ecf_flags & ECF_CONST)
TREE_READONLY (decl) = 1;
if (ecf_flags & ECF_PURE)
DECL_IS_PURE (decl) = 1;
if (ecf_flags & ECF_NORETURN)
TREE_THIS_VOLATILE (decl) = 1;
if (ecf_flags & ECF_NOTHROW)
TREE_NOTHROW (decl) = 1;
if (ecf_flags & ECF_MALLOC)
DECL_IS_MALLOC (decl) = 1;
built_in_decls[code] = decl;
implicit_built_in_decls[code] = decl;
}
/* Call this function after instantiating all builtins that the language
front end cares about. This will build the rest of the builtins that
are relied upon by the tree optimizers and the middle-end. */
void
build_common_builtin_nodes (void)
{
tree tmp, ftype;
if (built_in_decls[BUILT_IN_MEMCPY] == NULL
|| built_in_decls[BUILT_IN_MEMMOVE] == NULL)
{
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
ftype = build_function_type (ptr_type_node, tmp);
if (built_in_decls[BUILT_IN_MEMCPY] == NULL)
local_define_builtin ("__builtin_memcpy", ftype, BUILT_IN_MEMCPY,
"memcpy", ECF_NOTHROW);
if (built_in_decls[BUILT_IN_MEMMOVE] == NULL)
local_define_builtin ("__builtin_memmove", ftype, BUILT_IN_MEMMOVE,
"memmove", ECF_NOTHROW);
}
if (built_in_decls[BUILT_IN_MEMCMP] == NULL)
{
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
tmp = tree_cons (NULL_TREE, const_ptr_type_node, tmp);
ftype = build_function_type (ptr_type_node, tmp);
local_define_builtin ("__builtin_memcmp", ftype, BUILT_IN_MEMCMP,
"memcmp", ECF_PURE | ECF_NOTHROW);
}
if (built_in_decls[BUILT_IN_MEMSET] == NULL)
{
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, integer_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
ftype = build_function_type (ptr_type_node, tmp);
local_define_builtin ("__builtin_memset", ftype, BUILT_IN_MEMSET,
"memset", ECF_NOTHROW);
}
if (built_in_decls[BUILT_IN_ALLOCA] == NULL)
{
tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
ftype = build_function_type (ptr_type_node, tmp);
local_define_builtin ("__builtin_alloca", ftype, BUILT_IN_ALLOCA,
"alloca", ECF_NOTHROW | ECF_MALLOC);
}
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
ftype = build_function_type (void_type_node, tmp);
local_define_builtin ("__builtin_init_trampoline", ftype,
BUILT_IN_INIT_TRAMPOLINE,
"__builtin_init_trampoline", ECF_NOTHROW);
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
ftype = build_function_type (ptr_type_node, tmp);
local_define_builtin ("__builtin_adjust_trampoline", ftype,
BUILT_IN_ADJUST_TRAMPOLINE,
"__builtin_adjust_trampoline",
ECF_CONST | ECF_NOTHROW);
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
tmp = tree_cons (NULL_TREE, ptr_type_node, tmp);
ftype = build_function_type (void_type_node, tmp);
local_define_builtin ("__builtin_nonlocal_goto", ftype,
BUILT_IN_NONLOCAL_GOTO,
"__builtin_nonlocal_goto",
ECF_NORETURN | ECF_NOTHROW);
ftype = build_function_type (ptr_type_node, void_list_node);
local_define_builtin ("__builtin_stack_save", ftype, BUILT_IN_STACK_SAVE,
"__builtin_stack_save", ECF_NOTHROW);
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
ftype = build_function_type (void_type_node, tmp);
local_define_builtin ("__builtin_stack_restore", ftype,
BUILT_IN_STACK_RESTORE,
"__builtin_stack_restore", ECF_NOTHROW);
ftype = build_function_type (void_type_node, void_list_node);
local_define_builtin ("__builtin_profile_func_enter", ftype,
BUILT_IN_PROFILE_FUNC_ENTER, "profile_func_enter", 0);
local_define_builtin ("__builtin_profile_func_exit", ftype,
BUILT_IN_PROFILE_FUNC_EXIT, "profile_func_exit", 0);
}
/* HACK. GROSS. This is absolutely disgusting. I wish there was a /* HACK. GROSS. This is absolutely disgusting. I wish there was a
better way. better way.
......
...@@ -182,7 +182,7 @@ extern const char *const built_in_class_names[4]; ...@@ -182,7 +182,7 @@ extern const char *const built_in_class_names[4];
/* Codes that identify the various built in functions /* Codes that identify the various built in functions
so that expand_call can identify them quickly. */ so that expand_call can identify them quickly. */
#define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM) ENUM, #define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) ENUM,
enum built_in_function enum built_in_function
{ {
#include "builtins.def" #include "builtins.def"
...@@ -3591,6 +3591,7 @@ extern int real_minus_onep (tree); ...@@ -3591,6 +3591,7 @@ extern int real_minus_onep (tree);
extern void init_ttree (void); extern void init_ttree (void);
extern void build_common_tree_nodes (bool, bool); extern void build_common_tree_nodes (bool, bool);
extern void build_common_tree_nodes_2 (int); extern void build_common_tree_nodes_2 (int);
extern void build_common_builtin_nodes (void);
extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int); extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);
extern tree build_range_type (tree, tree, tree); extern tree build_range_type (tree, tree, tree);
extern HOST_WIDE_INT int_cst_value (tree); extern HOST_WIDE_INT int_cst_value (tree);
......
2005-02-09 Richard Henderson <rth@redhat.com>
* treetree.c (treelang_init_decl_processing): Call
build_common_builtin_nodes.
2005-02-06 Joseph S. Myers <joseph@codesourcery.com> 2005-02-06 Joseph S. Myers <joseph@codesourcery.com>
* treelang.texi: Don't use local treelang version number. Don't * treelang.texi: Don't use local treelang version number. Don't
...@@ -5,7 +10,7 @@ ...@@ -5,7 +10,7 @@
2005-02-01 James A. Morrison <phython@gcc.gnu.org> 2005-02-01 James A. Morrison <phython@gcc.gnu.org>
* (lex.l): Undef LINEMAP_POSITION_FOR_COLUMN before defining it. * lex.l: Undef LINEMAP_POSITION_FOR_COLUMN before defining it.
2005-02-01 James A. Morrison <phython@gcc.gnu.org> 2005-02-01 James A. Morrison <phython@gcc.gnu.org>
......
...@@ -1209,7 +1209,7 @@ treelang_init_decl_processing (void) ...@@ -1209,7 +1209,7 @@ treelang_init_decl_processing (void)
tree_push_type_decl (get_identifier ("long double"), long_double_type_node); tree_push_type_decl (get_identifier ("long double"), long_double_type_node);
tree_push_type_decl (get_identifier ("void"), void_type_node); tree_push_type_decl (get_identifier ("void"), void_type_node);
/* Add any target-specific builtin functions. */ build_common_builtin_nodes ();
(*targetm.init_builtins) (); (*targetm.init_builtins) ();
pedantic_lvalues = pedantic; pedantic_lvalues = pedantic;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment