diff options
author | Michael Meissner <meissner@gcc.gnu.org> | 2008-07-23 10:28:06 +0000 |
---|---|---|
committer | Michael Meissner <meissner@gcc.gnu.org> | 2008-07-23 10:28:06 +0000 |
commit | ab442df7fb453434d80a779844fe1a10c0c802ab (patch) | |
tree | efd8e61a3d2ff9dcff5eb5bf03e25922191f7df5 /gcc/attribs.c | |
parent | 5295185c3150a8d31685dc44248aa058246bbe73 (diff) | |
download | gcc-ab442df7fb453434d80a779844fe1a10c0c802ab.zip gcc-ab442df7fb453434d80a779844fe1a10c0c802ab.tar.gz gcc-ab442df7fb453434d80a779844fe1a10c0c802ab.tar.bz2 |
Add ability to set target options (ix86 only) and optimization options on a function specific basis
From-SVN: r138075
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r-- | gcc/attribs.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c index 3c60e8b..ba6a9e2 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "langhooks.h" #include "hashtab.h" +#include "c-common.h" static void init_attributes (void); @@ -232,6 +233,41 @@ decl_attributes (tree *node, tree attributes, int flags) if (!attributes_initialized) init_attributes (); + /* If this is a function and the user used #pragma GCC optimize, add the + options to the attribute((optimize(...))) list. */ + if (TREE_CODE (*node) == FUNCTION_DECL && current_optimize_pragma) + { + tree cur_attr = lookup_attribute ("optimize", attributes); + tree opts = copy_list (current_optimize_pragma); + + if (! cur_attr) + attributes + = tree_cons (get_identifier ("optimize"), opts, attributes); + else + TREE_VALUE (cur_attr) = chainon (opts, TREE_VALUE (cur_attr)); + } + + if (TREE_CODE (*node) == FUNCTION_DECL + && optimization_current_node != optimization_default_node + && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)) + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node; + + /* If this is a function and the user used #pragma GCC option, add the + options to the attribute((option(...))) list. */ + if (TREE_CODE (*node) == FUNCTION_DECL + && current_option_pragma + && targetm.target_option.valid_attribute_p (*node, NULL_TREE, + current_option_pragma, 0)) + { + tree cur_attr = lookup_attribute ("option", attributes); + tree opts = copy_list (current_option_pragma); + + if (! cur_attr) + attributes = tree_cons (get_identifier ("option"), opts, attributes); + else + TREE_VALUE (cur_attr) = chainon (opts, TREE_VALUE (cur_attr)); + } + targetm.insert_attributes (*node, &attributes); for (a = attributes; a; a = TREE_CHAIN (a)) |