diff options
author | Michael Meissner <gnu@the-meissners.org> | 2008-08-30 23:50:40 +0000 |
---|---|---|
committer | Michael Meissner <meissner@gcc.gnu.org> | 2008-08-30 23:50:40 +0000 |
commit | 5779e7133d84c5873249bb643d9852f314022f0b (patch) | |
tree | b3ee120a2ecf25d00fba24415c8566f83135a110 /gcc/cp | |
parent | 0257eee5bd4700647061f61b13a2f89b2a4b4f28 (diff) | |
download | gcc-5779e7133d84c5873249bb643d9852f314022f0b.zip gcc-5779e7133d84c5873249bb643d9852f314022f0b.tar.gz gcc-5779e7133d84c5873249bb643d9852f314022f0b.tar.bz2 |
Change attribute((option(...))) to attribute((target(...))); Do not allocate tree nodes on x86 for builtins until we generate code for the ISA; Delete hot/cold functions changing optimization; Make C++ support target specific functions; Add #pragma GCC {push_options,pop_options,reset_options} instead of #pragma GCC {target,optimize} {push,reset,pop}
From-SVN: r139812
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl.c | 52 |
4 files changed, 66 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7802e7e..30c6aa6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +2008-08-29 Michael Meissner <gnu@the-meissners.org> + + * decl.c (builtin_function_1): Take a bool argument to decide + whether to use pushdecl or pushdecl_top_level. + (duplicate_decls): Copy function specific target and optimization + options on duplicate declarations. + (cxx_builtin_function): Update builtin_function_1 call. + (cxx_builtin_function_ext_scope): New function, guarantee that the + declaration is done at global scope. + + * cp-objcp-common.h (LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE): New + macro, define builtin function hook for delayed machine specific + builtins. + + * cp-tree.h (cxx_builtin_function_ext_scope): Add declaration. + 2008-08-30 Jason Merrill <jason@redhat.com> PR c++/37288 diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 1121eb0..a7d4f89 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -86,6 +86,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, #define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group #undef LANG_HOOKS_BUILTIN_FUNCTION #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function +#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE +#define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE cxx_builtin_function_ext_scope #undef LANG_HOOKS_TYPE_HASH_EQ #define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq #undef LANG_HOOKS_MISSING_NORETURN_OK_P diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 72963f0..37bed91 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4364,6 +4364,7 @@ extern tree register_dtor_fn (tree); extern tmpl_spec_kind current_tmpl_spec_kind (int); extern tree cp_fname_init (const char *, tree *); extern tree cxx_builtin_function (tree decl); +extern tree cxx_builtin_function_ext_scope (tree decl); extern tree check_elaborated_type_specifier (enum tag_types, tree, bool); extern void warn_extern_redeclared_static (tree, tree); extern const char *cxx_comdat_group (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0d4dced..5a5a41f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -66,7 +66,7 @@ static tree grok_reference_init (tree, tree, tree, tree *); static tree grokvardecl (tree, tree, const cp_decl_specifier_seq *, int, int, tree); static void record_unknown_type (tree, const char *); -static tree builtin_function_1 (tree, tree); +static tree builtin_function_1 (tree, tree, bool); static tree build_library_fn_1 (tree, enum tree_code, tree); static int member_function_or_else (tree, tree, enum overload_flags); static void bad_specifiers (tree, const char *, int, int, int, int, @@ -1764,6 +1764,20 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (TREE_DEPRECATED (newdecl)) TREE_DEPRECATED (olddecl) = 1; + /* Preserve function specific target and optimization options */ + if (TREE_CODE (newdecl) == FUNCTION_DECL) + { + if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl) + && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl)) + DECL_FUNCTION_SPECIFIC_TARGET (newdecl) + = DECL_FUNCTION_SPECIFIC_TARGET (olddecl); + + if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl) + && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)) + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl) + = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl); + } + /* Merge the initialization information. */ if (DECL_INITIAL (newdecl) == NULL_TREE && DECL_INITIAL (olddecl) != NULL_TREE) @@ -3497,7 +3511,7 @@ cp_make_fname_decl (tree id, int type_dep) } static tree -builtin_function_1 (tree decl, tree context) +builtin_function_1 (tree decl, tree context, bool is_global) { tree id = DECL_NAME (decl); const char *name = IDENTIFIER_POINTER (id); @@ -3518,7 +3532,10 @@ builtin_function_1 (tree decl, tree context) DECL_CONTEXT (decl) = context; - pushdecl (decl); + if (is_global) + pushdecl_top_level (decl); + else + pushdecl (decl); /* A function in the user's namespace should have an explicit declaration before it is used. Mark the built-in function as @@ -3551,11 +3568,36 @@ cxx_builtin_function (tree decl) { tree decl2 = copy_node(decl); push_namespace (std_identifier); - builtin_function_1 (decl2, std_node); + builtin_function_1 (decl2, std_node, false); + pop_namespace (); + } + + return builtin_function_1 (decl, NULL_TREE, false); +} + +/* Like cxx_builtin_function, but guarantee the function is added to the global + scope. This is to allow function specific options to add new machine + dependent builtins when the target ISA changes via attribute((target(...))) + which saves space on program startup if the program does not use non-generic + ISAs. */ + +tree +cxx_builtin_function_ext_scope (tree decl) +{ + + tree id = DECL_NAME (decl); + const char *name = IDENTIFIER_POINTER (id); + /* All builtins that don't begin with an '_' should additionally + go in the 'std' namespace. */ + if (name[0] != '_') + { + tree decl2 = copy_node(decl); + push_namespace (std_identifier); + builtin_function_1 (decl2, std_node, true); pop_namespace (); } - return builtin_function_1 (decl, NULL_TREE); + return builtin_function_1 (decl, NULL_TREE, true); } /* Generate a FUNCTION_DECL with the typical flags for a runtime library |