This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, ARM]: Add TARGET_OPTION[RESTORE,SAVE,PRINT] hooks


Hi,

This patch uses TARGET_OPTION_RESTORE and SAVE to switch the attribute target dependent params between functions.

This is more efficient than arm_option_params_internal, and prepares the ground for the other machine target attributes.

No regressions. OK for trunk ?

many thanks

Christian

2015-09-02  Christian Bruel  <christian.bruel@st.com>

	PR target/52144
	* config/arm/arm.c (TARGET_OPTION_PRINT, TARGET_OPTION_SAVE)
	(TARGET_OPTION_RESTORE): New hooks defined with...
	(arm_option_print, arm_function_specific_save)
	(arm_function_specific_restore) New functions.
	(arm_set_current_function): Move arm_option_params_internal call...
	(arm_valid_target_attribute_tree): here.
	* config/arm/arm.opt (min_anchor_offset, max_anchor_offset)
	(max_insns_skipped): New TargetSave variables.

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 227366)
+++ gcc/config/arm/arm.c	(working copy)
@@ -245,9 +245,14 @@
 static void arm_expand_builtin_va_start (tree, rtx);
 static tree arm_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *);
 static void arm_option_override (void);
+static void arm_option_print (FILE *, int, struct cl_target_option *);
 static void arm_set_current_function (tree);
 static bool arm_can_inline_p (tree, tree);
 static bool arm_valid_target_attribute_p (tree, tree, tree, int);
+static void arm_function_specific_save (struct cl_target_option *,
+					struct gcc_options *);
+static void arm_function_specific_restore (struct gcc_options *,
+					   struct cl_target_option *);
 static unsigned HOST_WIDE_INT arm_shift_truncation_mask (machine_mode);
 static bool arm_macro_fusion_p (void);
 static bool arm_cannot_copy_insn_p (rtx_insn *);
@@ -405,6 +410,9 @@
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE arm_option_override
 
+#undef TARGET_OPTION_PRINT
+#define TARGET_OPTION_PRINT arm_option_print
+
 #undef  TARGET_COMP_TYPE_ATTRIBUTES
 #define TARGET_COMP_TYPE_ATTRIBUTES arm_comp_type_attributes
 
@@ -426,6 +434,12 @@
 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
 #define TARGET_OPTION_VALID_ATTRIBUTE_P arm_valid_target_attribute_p
 
+#undef TARGET_OPTION_SAVE
+#define TARGET_OPTION_SAVE arm_function_specific_save
+
+#undef TARGET_OPTION_RESTORE
+#define TARGET_OPTION_RESTORE arm_function_specific_restore
+
 #undef TARGET_SCHED_REORDER
 #define TARGET_SCHED_REORDER arm_sched_reorder
 
@@ -29462,8 +29476,37 @@
 	TREE_TARGET_GLOBALS (new_tree)
 	  = save_target_globals_default_opts ();
     }
+}
 
-  arm_option_params_internal (&global_options);
+/* TARGET_OPTION_PRINT hook.  */
+
+static void
+arm_option_print (FILE *file, int indent, struct cl_target_option *ptr)
+{
+  int flags = ptr->x_target_flags;
+
+  if (TARGET_THUMB_P (flags))
+    fprintf (file, "%*sselected thumb arch \n", indent, "");
+  else
+    fprintf (file, "%*sselected arm arch\n", indent, "");
+}
+
+static void
+arm_function_specific_save (struct cl_target_option *ptr,
+			    struct gcc_options *opts)
+{
+  ptr->min_anchor_offset = targetm.min_anchor_offset;
+  ptr->max_anchor_offset = targetm.max_anchor_offset;
+  ptr->max_insns_skipped = max_insns_skipped;
+}
+
+static void
+arm_function_specific_restore (struct gcc_options *opts,
+			       struct cl_target_option *ptr)
+{
+  targetm.min_anchor_offset = ptr->min_anchor_offset;
+  targetm.max_anchor_offset = ptr->max_anchor_offset;
+  max_insns_skipped = ptr->max_insns_skipped;
 }
 
 /* Hook to determine if one function can safely inline another.  */
@@ -29538,6 +29581,7 @@
 
   /* Do any overrides, such as global options arch=xxx.  */
   arm_option_override_internal (opts, opts_set);
+  arm_option_params_internal (opts);
 
   return build_target_option_node (opts);
 }
Index: gcc/config/arm/arm.opt
===================================================================
--- gcc/config/arm/arm.opt	(revision 227366)
+++ gcc/config/arm/arm.opt	(working copy)
@@ -281,3 +281,13 @@
 masm-syntax-unified
 Target Report Var(inline_asm_unified) Init(0) Save
 Assume unified syntax for Thumb inline assembly code.
+
+;; Definitions to add to the cl_target_option structure
+TargetSave
+HOST_WIDE_INT min_anchor_offset
+
+TargetSave
+HOST_WIDE_INT max_anchor_offset
+
+TargetSave
+int max_insns_skipped


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]