summaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-23 10:28:06 +0000
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-23 10:28:06 +0000
commit46f8e3b0dc1cbb88c7dde984d0f0c2ce8935011d (patch)
treeefd8e61a3d2ff9dcff5eb5bf03e25922191f7df5 /gcc/attribs.c
parente22d2ad745ca3d2ac08936833a802ffc161fc89b (diff)
downloadgcc-46f8e3b0dc1cbb88c7dde984d0f0c2ce8935011d.tar.gz
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
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c36
1 files changed, 36 insertions, 0 deletions
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))