aarch64_previous_fndecl = NULL;
}
+/* Restore or save the TREE_TARGET_GLOBALS from or to NEW_TREE.
+ Used by aarch64_set_current_function and aarch64_pragma_target_parse to
+ make sure optab availability predicates are recomputed when necessary. */
+
+void
+aarch64_save_restore_target_globals (tree new_tree)
+{
+ if (TREE_TARGET_GLOBALS (new_tree))
+ restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
+ else if (new_tree == target_option_default_node)
+ restore_target_globals (&default_target_globals);
+ else
+ TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
+}
+
/* Implement TARGET_SET_CURRENT_FUNCTION. Unpack the codegen decisions
like tuning and ISA features from the DECL_FUNCTION_SPECIFIC_TARGET
of the function, if such exists. This function may be called multiple
static void
aarch64_set_current_function (tree fndecl)
{
+ if (!fndecl || fndecl == aarch64_previous_fndecl)
+ return;
+
tree old_tree = (aarch64_previous_fndecl
? DECL_FUNCTION_SPECIFIC_TARGET (aarch64_previous_fndecl)
: NULL_TREE);
- tree new_tree = (fndecl
- ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl)
- : NULL_TREE);
-
+ tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
- if (fndecl && fndecl != aarch64_previous_fndecl)
- {
- aarch64_previous_fndecl = fndecl;
- if (old_tree == new_tree)
- ;
+ /* If current function has no attributes but the previous one did,
+ use the default node. */
+ if (!new_tree && old_tree)
+ new_tree = target_option_default_node;
- else if (new_tree)
- {
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
+ /* If nothing to do, return. #pragma GCC reset or #pragma GCC pop to
+ the default have been handled by aarch64_save_restore_target_globals from
+ aarch64_pragma_target_parse. */
+ if (old_tree == new_tree)
+ return;
- else if (old_tree && old_tree != target_option_default_node)
- {
- new_tree = target_option_current_node;
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else if (new_tree == target_option_default_node)
- restore_target_globals (&default_target_globals);
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
- }
+ aarch64_previous_fndecl = fndecl;
- if (!fndecl)
- return;
+ /* First set the target options. */
+ cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
- /* If we turned on SIMD make sure that any vector parameters are re-laid out
- so that they use proper vector modes. */
- if (TARGET_SIMD)
- {
- tree parms = DECL_ARGUMENTS (fndecl);
- for (; parms && parms != void_list_node; parms = TREE_CHAIN (parms))
- {
- if (TREE_CODE (parms) == PARM_DECL
- && VECTOR_TYPE_P (TREE_TYPE (parms))
- && DECL_MODE (parms) != TYPE_MODE (TREE_TYPE (parms)))
- relayout_decl (parms);
- }
- }
+ aarch64_save_restore_target_globals (new_tree);
}
/* Enum describing the various ways we can handle attributes.