diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-10 00:22:25 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-10 00:22:25 +0000 |
commit | 9cfddb70e5959f3c656f6eb99cb737a63dc2a0c8 (patch) | |
tree | 4ed79a7176ee65e1fb619e14384a1bc2dd57d091 /gcc/tree.c | |
parent | 451528dcdf7cb40350106f4a010bf68bc6d83118 (diff) | |
download | gcc-9cfddb70e5959f3c656f6eb99cb737a63dc2a0c8.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94785 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 6afc17f1f46..4e7f7bfcf9b 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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 better way. |