diff mbox

[ARM] Clean up arm_option_params_internals macro settings for attribute/pragma targets

Message ID 55F68DD6.7080102@st.com
State New
Headers show

Commit Message

Christian Bruel Sept. 14, 2015, 9:05 a.m. UTC
Hi,

Prior sending the remaining target attributes, I'd like to simplify a 
few chunks (thinko) that were unnecessary complicated :  The options 
checks in arm_option_params_internal can't be from another context than 
global_options.

Also add TARGET_OPTION_PRINT, small enough chunk to slip here I hope.

Testing OK,

Thanks

Christian

Comments

Kyrylo Tkachov Sept. 15, 2015, 9:42 a.m. UTC | #1
Hi Christian,

On 14/09/15 10:05, Christian Bruel wrote:
> Hi,
>
> Prior sending the remaining target attributes, I'd like to simplify a
> few chunks (thinko) that were unnecessary complicated :  The options
> checks in arm_option_params_internal can't be from another context than
> global_options.

Hmmm... I agree. TARGET_SET_CURRENT_FUNCTION will restore
the target options node into the global options and call
arm_option_params_internal, which can assume it operates
on the global options.

This patch is ok but...

>
> Also add TARGET_OPTION_PRINT, small enough chunk to slip here I hope.

Please split this out into a separate patch with a separate ChangeLog entry.
Such a patch is pre-approved as long as the implementation of TARGET_OPTION_PRINT
is the same as in this patch.

Thanks,
Kyrill

>
> Testing OK,
>
> Thanks
>
> Christian
>
Christian Bruel Sept. 16, 2015, 6:58 a.m. UTC | #2
On 09/15/2015 11:42 AM, Kyrill Tkachov wrote:
> Hi Christian,
>
> On 14/09/15 10:05, Christian Bruel wrote:
>> Hi,
>>
>> Prior sending the remaining target attributes, I'd like to simplify a
>> few chunks (thinko) that were unnecessary complicated :  The options
>> checks in arm_option_params_internal can't be from another context than
>> global_options.
>
> Hmmm... I agree. TARGET_SET_CURRENT_FUNCTION will restore
> the target options node into the global options and call
> arm_option_params_internal, which can assume it operates
> on the global options.
>
> This patch is ok but...
>
>>
>> Also add TARGET_OPTION_PRINT, small enough chunk to slip here I hope.
>
> Please split this out into a separate patch with a separate ChangeLog entry.
> Such a patch is pre-approved as long as the implementation of TARGET_OPTION_PRINT
> is the same as in this patch.
>
> Thanks,
> Kyrill
>

OK Committed @ resp r227794 and r227795
>>
>> Testing OK,
>>
>> Thanks
>>
>> Christian
>>
>
diff mbox

Patch

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

	PR target/52144
	* config/arm/arm.c (TARGET_OPTION_PRINT): Define.
	(arm_option_print): New function.
	(arm_option_params_internal): Remove opts parameter.
	(arm_cpu_builtins): Declare static. Remove flags parameter.
	* config/arm/arm.h (TARGET_32BIT_P, TARGET_ARM_QBIT_P)
	(TARGET_ARM_SAT_P, TARGET_IDIV_P, TARGET_HAVE_LDREX_P)
	(TARGET_HAVE_LDREXBH_P, TARGET_HAVE_LDREXD_P, TARGET_ARM_FEATURE_LDREX_P)
	(TARGET_DSP_MULTIPLY_P, TARGET_INT_SIMD_P): Redefine macros with:
	(TARGET_ARM_SAT, TARGET_IDIV, TARGET_HAVE_LDREX)
	(TARGET_HAVE_LDREXBH, TARGET_HAVE_LDREXD, TARGET_ARM_FEATURE_LDREX)
	(TARGET_DSP_MULTIPLY, TARGET_INT_SIMD): Remove macros.
	* gcc/config/arm/arm-protos.h (arm_cpu_builtins): Remove declaration.

diff -ruN gnu_trunk.ref/gcc/gcc/config/arm/arm.c gnu_trunk.p0/gcc/gcc/config/arm/arm.c
--- gnu_trunk.ref/gcc/gcc/config/arm/arm.c	2015-09-10 12:23:00.015177694 +0200
+++ gnu_trunk.p0/gcc/gcc/config/arm/arm.c	2015-09-10 14:27:28.931847219 +0200
@@ -245,6 +245,7 @@ 
 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);
@@ -405,6 +406,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
 
@@ -2751,15 +2755,14 @@ 
     error ("-mslow-flash-data only supports non-pic code on armv7-m targets");
 }
 
-/* Set params depending on attributes and optimization options.  */
+/* Recompute the global settings depending on target attribute options.  */
+
 static void
-arm_option_params_internal (struct gcc_options *opts)
+arm_option_params_internal (void)
 {
-  int flags = opts->x_target_flags;
-
- /* If we are not using the default (ARM mode) section anchor offset
+  /* If we are not using the default (ARM mode) section anchor offset
      ranges, then set the correct ranges now.  */
-  if (TARGET_THUMB1_P (flags))
+  if (TARGET_THUMB1)
     {
       /* Thumb-1 LDR instructions cannot have negative offsets.
          Permissible positive offset ranges are 5-bit (for byte loads),
@@ -2769,7 +2772,7 @@ 
       targetm.min_anchor_offset = 0;
       targetm.max_anchor_offset = 127;
     }
-  else if (TARGET_THUMB2_P (flags))
+  else if (TARGET_THUMB2)
     {
       /* The minimum is set such that the total size of the block
          for a particular anchor is 248 + 1 + 4095 bytes, which is
@@ -2790,14 +2793,13 @@ 
       max_insns_skipped = 6;
 
       /* For THUMB2, we limit the conditional sequence to one IT block.  */
-      if (TARGET_THUMB2_P (flags))
-        max_insns_skipped = opts->x_arm_restrict_it ? 1 : 4;
+      if (TARGET_THUMB2)
+        max_insns_skipped = arm_restrict_it ? 1 : 4;
     }
   else
     /* When -mrestrict-it is in use tone down the if-conversion.  */
-    max_insns_skipped
-      = (TARGET_THUMB2_P (opts->x_target_flags) && opts->x_arm_restrict_it)
-         ? 1 : current_tune->max_insns_skipped;
+    max_insns_skipped = (TARGET_THUMB2 && arm_restrict_it)
+      ? 1 : current_tune->max_insns_skipped;
 }
 
 /* True if -mflip-thumb should next add an attribute for the default
@@ -3385,7 +3387,7 @@ 
 
   arm_option_override_internal (&global_options, &global_options_set);
   arm_option_check_internal (&global_options);
-  arm_option_params_internal (&global_options);
+  arm_option_params_internal ();
 
   /* Register global variables with the garbage collector.  */
   arm_add_gc_roots ();
@@ -29482,7 +29484,20 @@ 
 	  = save_target_globals_default_opts ();
     }
 
-  arm_option_params_internal (&global_options);
+  arm_option_params_internal ();
+}
+
+/* Implement TARGET_OPTION_PRINT.  */
+
+static void
+arm_option_print (FILE *file, int indent, struct cl_target_option *ptr)
+{
+  int flags = ptr->x_target_flags;
+
+  fprintf (file, "%*sselected arch %s\n", indent, "",
+	   TARGET_THUMB2_P (flags) ? "thumb2" :
+	   TARGET_THUMB_P (flags) ? "thumb1" :
+	   "arm");
 }
 
 /* Hook to determine if one function can safely inline another.  */
@@ -29501,7 +29516,7 @@ 
    go over the list.  */
 
 static bool
-arm_valid_target_attribute_rec (tree args,  struct gcc_options *opts)
+arm_valid_target_attribute_rec (tree args, struct gcc_options *opts)
 {
   if (TREE_CODE (args) == TREE_LIST)
     {
diff -ruN gnu_trunk.ref/gcc/gcc/config/arm/arm-c.c gnu_trunk.p0/gcc/gcc/config/arm/arm-c.c
--- gnu_trunk.ref/gcc/gcc/config/arm/arm-c.c	2015-08-04 15:03:44.901846719 +0200
+++ gnu_trunk.p0/gcc/gcc/config/arm/arm-c.c	2015-09-10 13:17:25.026353687 +0200
@@ -62,15 +62,12 @@ 
     cpp_undef (pfile, name); 
 } 
 
-void
-arm_cpu_builtins (struct cpp_reader* pfile, int flags)
+static void
+arm_cpu_builtins (struct cpp_reader* pfile)
 {
-  def_or_undef_macro (pfile, "__ARM_FEATURE_DSP",
-		      TARGET_DSP_MULTIPLY_P (flags));
-  def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT",
-		      TARGET_ARM_QBIT_P (flags)); 
-  def_or_undef_macro (pfile, "__ARM_FEATURE_SAT",
-		      TARGET_ARM_SAT_P (flags));
+  def_or_undef_macro (pfile, "__ARM_FEATURE_DSP", TARGET_DSP_MULTIPLY);
+  def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT", TARGET_ARM_QBIT); 
+  def_or_undef_macro (pfile, "__ARM_FEATURE_SAT", TARGET_ARM_SAT);
   if (TARGET_CRYPTO)
     builtin_define ("__ARM_FEATURE_CRYPTO");
   if (unaligned_access)
@@ -78,19 +75,19 @@ 
   if (TARGET_CRC32)
     builtin_define ("__ARM_FEATURE_CRC32");
 
-  def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT_P (flags)); 
+  def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT); 
 
-  if (TARGET_ARM_FEATURE_LDREX_P (flags))
+  if (TARGET_ARM_FEATURE_LDREX)
     builtin_define_with_int_value ("__ARM_FEATURE_LDREX", 
-				   TARGET_ARM_FEATURE_LDREX_P (flags));
+				   TARGET_ARM_FEATURE_LDREX);
   else
     cpp_undef (pfile, "__ARM_FEATURE_LDREX");
 
   def_or_undef_macro (pfile, "__ARM_FEATURE_CLZ",
-		      ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB_P (flags))
+		      ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB)
 		       || TARGET_ARM_ARCH_ISA_THUMB >=2));
 
-  def_or_undef_macro (pfile, "__ARM_FEATURE_SIMD32", TARGET_INT_SIMD_P (flags));
+  def_or_undef_macro (pfile, "__ARM_FEATURE_SIMD32", TARGET_INT_SIMD);
 
   builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
 				 flag_short_enums ? 1 : 4);
@@ -108,12 +105,12 @@ 
     builtin_define ("__ARM_ARCH_ISA_ARM");
   builtin_define ("__APCS_32__");
 
-  def_or_undef_macro (pfile, "__thumb__", TARGET_THUMB_P (flags));
-  def_or_undef_macro (pfile, "__thumb2__", TARGET_THUMB2_P (flags));
+  def_or_undef_macro (pfile, "__thumb__", TARGET_THUMB);
+  def_or_undef_macro (pfile, "__thumb2__", TARGET_THUMB2);
   if (TARGET_BIG_END)
-    def_or_undef_macro (pfile, "__THUMBEB__", TARGET_THUMB_P (flags));
+    def_or_undef_macro (pfile, "__THUMBEB__", TARGET_THUMB);
   else
-    def_or_undef_macro (pfile, "__THUMBEL__", TARGET_THUMB_P (flags));
+    def_or_undef_macro (pfile, "__THUMBEL__", TARGET_THUMB);
 
   if (TARGET_ARM_ARCH_ISA_THUMB)
     builtin_define_with_int_value ("__ARM_ARCH_ISA_THUMB",
@@ -181,8 +177,8 @@ 
       builtin_define ("__ARM_EABI__");
     }
 
-  def_or_undef_macro (pfile, "__ARM_ARCH_EXT_IDIV__", TARGET_IDIV_P (flags));
-  def_or_undef_macro (pfile, "__ARM_FEATURE_IDIV", TARGET_IDIV_P (flags));
+  def_or_undef_macro (pfile, "__ARM_ARCH_EXT_IDIV__", TARGET_IDIV);
+  def_or_undef_macro (pfile, "__ARM_FEATURE_IDIV", TARGET_IDIV);
 
   def_or_undef_macro (pfile, "__ARM_ASM_SYNTAX_UNIFIED__", inline_asm_unified);
 }
@@ -193,7 +189,7 @@ 
   builtin_assert ("cpu=arm");
   builtin_assert ("machine=arm");
 
-  arm_cpu_builtins (pfile, target_flags);
+  arm_cpu_builtins (pfile);
 }
 
 /* Hook to validate the current #pragma GCC target and set the arch custom
@@ -245,7 +241,8 @@ 
       cpp_opts->warn_unused_macros = 0;
 
       /* Update macros.  */
-      arm_cpu_builtins (parse_in, cur_opt->x_target_flags);
+      gcc_assert (cur_opt->x_target_flags == target_flags);
+      arm_cpu_builtins (parse_in);
 
       cpp_opts->warn_unused_macros = saved_warn_unused_macros;
     }
diff -ruN gnu_trunk.ref/gcc/gcc/config/arm/arm.h gnu_trunk.p0/gcc/gcc/config/arm/arm.h
--- gnu_trunk.ref/gcc/gcc/config/arm/arm.h	2015-09-09 09:50:00.487357918 +0200
+++ gnu_trunk.p0/gcc/gcc/config/arm/arm.h	2015-09-09 16:37:26.224135630 +0200
@@ -160,8 +160,6 @@ 
 #define TARGET_THUMB1			(TARGET_THUMB && !arm_arch_thumb2)
 /* Arm or Thumb-2 32-bit code.  */
 #define TARGET_32BIT			(TARGET_ARM || arm_arch_thumb2)
-#define TARGET_32BIT_P(flags)		(TARGET_ARM_P (flags) \
-					 || arm_arch_thumb2)
 /* 32-bit Thumb-2 code.  */
 #define TARGET_THUMB2			(TARGET_THUMB && arm_arch_thumb2)
 /* Thumb-1 only.  */
@@ -222,21 +220,17 @@ 
 
 
 /* Q-bit is present.  */
-#define TARGET_ARM_QBIT_P(flags) \
-  (TARGET_32BIT_P (flags) && arm_arch5e && (arm_arch_notm || arm_arch7))
-#define TARGET_ARM_QBIT TARGET_ARM_QBIT_P(target_flags)
+#define TARGET_ARM_QBIT \
+  (TARGET_32BIT && arm_arch5e && (arm_arch_notm || arm_arch7))
 /* Saturation operation, e.g. SSAT.  */
-#define TARGET_ARM_SAT_P(flags) \
-  (TARGET_32BIT_P (flags) && arm_arch6 && (arm_arch_notm || arm_arch7))
-#define TARGET_ARM_SAT TARGET_ARM_SAT_P(target_flags)
+#define TARGET_ARM_SAT \
+  (TARGET_32BIT && arm_arch6 && (arm_arch_notm || arm_arch7))
 /* "DSP" multiply instructions, eg. SMULxy.  */
-#define TARGET_DSP_MULTIPLY_P(flags) \
-  (TARGET_32BIT_P (flags) && arm_arch5e && (arm_arch_notm || arm_arch7em))
-#define TARGET_DSP_MULTIPLY TARGET_DSP_MULTIPLY_P(target_flags)
+#define TARGET_DSP_MULTIPLY \
+  (TARGET_32BIT && arm_arch5e && (arm_arch_notm || arm_arch7em))
 /* Integer SIMD instructions, and extend-accumulate instructions.  */
-#define TARGET_INT_SIMD_P(flags) \
-  (TARGET_32BIT_P (flags) && arm_arch6 && (arm_arch_notm || arm_arch7em))
-#define TARGET_INT_SIMD TARGET_INT_SIMD_P(target_flags)
+#define TARGET_INT_SIMD \
+  (TARGET_32BIT && arm_arch6 && (arm_arch_notm || arm_arch7em))
 
 /* Should MOVW/MOVT be used in preference to a constant pool.  */
 #define TARGET_USE_MOVT \
@@ -259,30 +253,21 @@ 
 #define TARGET_HAVE_MEMORY_BARRIER (TARGET_HAVE_DMB || TARGET_HAVE_DMB_MCR)
 
 /* Nonzero if this chip supports ldrex and strex */
-#define TARGET_HAVE_LDREX_P(flags) ((arm_arch6 && TARGET_ARM_P (flags)) \
-				    || arm_arch7)
-#define TARGET_HAVE_LDREX	  TARGET_HAVE_LDREX_P (target_flags) 
+#define TARGET_HAVE_LDREX        ((arm_arch6 && TARGET_ARM) || arm_arch7)
 
 /* Nonzero if this chip supports ldrex{bh} and strex{bh}.  */
-#define TARGET_HAVE_LDREXBH_P(flags) ((arm_arch6k && TARGET_ARM_P (flags)) \
-				      || arm_arch7)
-#define TARGET_HAVE_LDREXBH	     TARGET_HAVE_LDREXBH_P (target_flags)
+#define TARGET_HAVE_LDREXBH ((arm_arch6k && TARGET_ARM) || arm_arch7)
 
 /* Nonzero if this chip supports ldrexd and strexd.  */
-#define TARGET_HAVE_LDREXD_P(flags) (((arm_arch6k && TARGET_ARM_P (flags)) \
-				      || arm_arch7) && arm_arch_notm)
-#define TARGET_HAVE_LDREXD	    TARGET_HAVE_LDREXD_P (target_flags)
-				
+#define TARGET_HAVE_LDREXD (((arm_arch6k && TARGET_ARM) \
+			     || arm_arch7) && arm_arch_notm)
 
 /* Nonzero if this chip supports load-acquire and store-release.  */
 #define TARGET_HAVE_LDACQ	(TARGET_ARM_ARCH >= 8)
 
 /* Nonzero if integer division instructions supported.  */
-#define TARGET_IDIV_P(flags)	((TARGET_ARM_P (flags) && arm_arch_arm_hwdiv) \
-				 || (TARGET_THUMB2_P (flags)                  \
-				     && arm_arch_thumb_hwdiv))
-#define TARGET_IDIV             TARGET_IDIV_P (target_flags)		
-
+#define TARGET_IDIV	((TARGET_ARM && arm_arch_arm_hwdiv)	\
+			 || (TARGET_THUMB2 && arm_arch_thumb_hwdiv))
 
 /* Nonzero if disallow volatile memory access in IT block.  */
 #define TARGET_NO_VOLATILE_CE		(arm_arch_no_volatile_ce)
@@ -2220,11 +2205,6 @@ 
    | (TARGET_HAVE_LDREXBH ? 3 : 0)				\
    | (TARGET_HAVE_LDREXD ? 8 : 0))
 
-#define TARGET_ARM_FEATURE_LDREX_P(flags)			\
-  ((TARGET_HAVE_LDREX_P (flags) ? 4 : 0)			\
-   | (TARGET_HAVE_LDREXBH_P (flags) ? 3 : 0)			\
-   | (TARGET_HAVE_LDREXD_P (flags) ? 8 : 0))
-
 /* Set as a bit mask indicating the available widths of hardware floating
    point types.  Where bit 1 indicates 16-bit support, bit 2 indicates
    32-bit support, bit 3 indicates 64-bit support.  */
diff -ruN gnu_trunk.ref/gcc/gcc/config/arm/arm-protos.h gnu_trunk.p0/gcc/gcc/config/arm/arm-protos.h
--- gnu_trunk.ref/gcc/gcc/config/arm/arm-protos.h	2015-08-27 09:00:14.551410593 +0200
+++ gnu_trunk.p0/gcc/gcc/config/arm/arm-protos.h	2015-09-09 16:47:06.061384724 +0200
@@ -340,7 +340,6 @@ 
 extern void arm_lang_object_attributes_init (void);
 extern void arm_register_target_pragmas (void);
 extern void arm_cpu_cpp_builtins (struct cpp_reader *);
-extern void arm_cpu_builtins (struct cpp_reader *, int);
 
 extern bool arm_is_constant_pool_ref (rtx);