From 46f8e3b0dc1cbb88c7dde984d0f0c2ce8935011d Mon Sep 17 00:00:00 2001 From: meissner Date: Wed, 23 Jul 2008 10:28:06 +0000 Subject: Add ability to set target options (ix86 only) and optimization options on a function specific basis git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138075 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/attribs.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gcc/attribs.c') diff --git a/gcc/attribs.c b/gcc/attribs.c index 3c60e8bd967..ba6a9e294c8 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)) -- cgit v1.2.1