diff mbox

[ARM] attribute target (thumb,arm) [6/6] respin (5th)

Message ID 5559A5B4.7050007@st.com
State New
Headers show

Commit Message

Christian Bruel May 18, 2015, 8:41 a.m. UTC
On 05/06/2015 04:29 PM, Christian Bruel wrote:
> Implement the -mflip-thump option. Undocumented for internal testing
> only. This option artificially inserts alternative attribute thumb/modes
> on functions.
>
> This close the patch set. Thanks for your review,
>
> Christian
>

to close the series. redo patch rebased.

Comments

Kyrill Tkachov June 9, 2015, 10:04 a.m. UTC | #1
Hi Christian,


On 18/05/15 09:41, Christian Bruel wrote:
> On 05/06/2015 04:29 PM, Christian Bruel wrote:
>> >Implement the -mflip-thump option. Undocumented for internal testing
>> >only. This option artificially inserts alternative attribute thumb/modes
>> >on functions.
>> >
>> >This close the patch set. Thanks for your review,
>> >
>> >Christian
>> >
> to close the series. redo patch rebased.
>   

<snip>

>   static bool
> diff '--exclude=.svn' -ruN gnu_trunk.p5/gcc/gcc/config/arm/arm.opt gnu_trunk.p6/gcc/gcc/config/arm/arm.opt
> --- gnu_trunk.p5/gcc/gcc/config/arm/arm.opt	2015-05-18 10:20:26.545835080 +0200
> +++ gnu_trunk.p6/gcc/gcc/config/arm/arm.opt	2015-05-13 13:13:11.014686529 +0200
> @@ -122,6 +122,10 @@
>   EnumValue
>   Enum(float_abi_type) String(hard) Value(ARM_FLOAT_ABI_HARD)
>   
> +mflip-thumb
> +Target Report Var(TARGET_FLIP_THUMB)
> +Switch ARM/Thumb modes on alternating functions for compiler testing

How about adding 'Undocumented' to the properties here?

Can we also get a test or two just to sanity check the option?
Otherwise the patch looks ok to me.

Thanks,
Kyrill
Christian Bruel June 9, 2015, 10:27 a.m. UTC | #2
On 06/09/2015 12:04 PM, Kyrill Tkachov wrote:
> Hi Christian,
>
>
> On 18/05/15 09:41, Christian Bruel wrote:
>> On 05/06/2015 04:29 PM, Christian Bruel wrote:
>>>> Implement the -mflip-thump option. Undocumented for internal testing
>>>> only. This option artificially inserts alternative attribute thumb/modes
>>>> on functions.
>>>>
>>>> This close the patch set. Thanks for your review,
>>>>
>>>> Christian
>>>>
>> to close the series. redo patch rebased.
>>
>
> <snip>
>
>>    static bool
>> diff '--exclude=.svn' -ruN gnu_trunk.p5/gcc/gcc/config/arm/arm.opt gnu_trunk.p6/gcc/gcc/config/arm/arm.opt
>> --- gnu_trunk.p5/gcc/gcc/config/arm/arm.opt	2015-05-18 10:20:26.545835080 +0200
>> +++ gnu_trunk.p6/gcc/gcc/config/arm/arm.opt	2015-05-13 13:13:11.014686529 +0200
>> @@ -122,6 +122,10 @@
>>    EnumValue
>>    Enum(float_abi_type) String(hard) Value(ARM_FLOAT_ABI_HARD)
>>
>> +mflip-thumb
>> +Target Report Var(TARGET_FLIP_THUMB)
>> +Switch ARM/Thumb modes on alternating functions for compiler testing
>
> How about adding 'Undocumented' to the properties here?

OK,

>
> Can we also get a test or two just to sanity check the option?

sure, I have on stage a few chunks to improve the testsuite score with 
this option. I will pass on a -mflip option sanity check in the same review.

> Otherwise the patch looks ok to me.
>

many thanks,

Christian

> Thanks,
> Kyrill
>
diff mbox

Patch

2014-09-23  Christian Bruel  <christian.bruel@st.com>

	* config/arm/arm.c (add_attribute, arm_insert_attributes): New functions
	(TARGET_INSERT_ATTRIBUTES): Define.
	(thumb_flipper): New var.
	* config/arm/arm.opt (-mflip-thumb): New switch.

diff '--exclude=.svn' -ruN gnu_trunk.p5/gcc/gcc/config/arm/arm.c gnu_trunk.p6/gcc/gcc/config/arm/arm.c
--- gnu_trunk.p5/gcc/gcc/config/arm/arm.c	2015-05-18 10:20:26.501834998 +0200
+++ gnu_trunk.p6/gcc/gcc/config/arm/arm.c	2015-05-13 13:44:46.250285706 +0200
@@ -99,6 +99,7 @@ 
 #include "tm-constrs.h"
 #include "rtl-iter.h"
 #include "sched-int.h"
+#include "tree.h"
 
 /* Forward definitions of types.  */
 typedef struct minipool_node    Mnode;
@@ -233,6 +234,7 @@ 
 
 static void arm_file_end (void);
 static void arm_file_start (void);
+static void arm_insert_attributes (tree, tree *);
 
 static void arm_setup_incoming_varargs (cumulative_args_t, machine_mode,
 					tree, int *, int);
@@ -391,6 +393,9 @@ 
 #undef  TARGET_ATTRIBUTE_TABLE
 #define TARGET_ATTRIBUTE_TABLE arm_attribute_table
 
+#undef  TARGET_INSERT_ATTRIBUTES
+#define TARGET_INSERT_ATTRIBUTES arm_insert_attributes
+
 #undef TARGET_ASM_FILE_START
 #define TARGET_ASM_FILE_START arm_file_start
 #undef TARGET_ASM_FILE_END
@@ -2790,6 +2795,10 @@ 
     max_insns_skipped = current_tune->max_insns_skipped;
 }
 
+/* True if -mflip-thumb should next add an attribute for the default
+   mode, false if it should next add an attribute for the opposite mode.  */
+static GTY(()) bool thumb_flipper;
+
 /* Options after initial target override.  */
 static GTY(()) tree init_optimize;
 
@@ -3367,6 +3376,9 @@ 
      options.  */
   target_option_default_node = target_option_current_node
     = build_target_option_node (&global_options);
+
+  /* Init initial mode for testing.  */
+  thumb_flipper = TARGET_THUMB;
 }
 
 static void
@@ -29455,6 +29467,52 @@ 
   return build_target_option_node (opts);
 }
 
+static void 
+add_attribute  (const char * mode, tree *attributes)
+{
+  size_t len = strlen (mode);
+  tree value = build_string (len, mode);
+
+  TREE_TYPE (value) = build_array_type (char_type_node,
+					build_index_type (size_int (len)));
+
+  *attributes = tree_cons (get_identifier ("target"),
+			   build_tree_list (NULL_TREE, value),
+			   *attributes);
+}
+
+/* For testing. Insert thumb or arm modes alternatively on functions.  */
+
+static void
+arm_insert_attributes (tree fndecl, tree * attributes)
+{
+  const char *mode;
+
+  if (! TARGET_FLIP_THUMB)
+    return;
+
+  if (TREE_CODE (fndecl) != FUNCTION_DECL || DECL_EXTERNAL(fndecl)
+      || DECL_BUILT_IN (fndecl) || DECL_ARTIFICIAL (fndecl))
+   return;
+
+  /* Nested definitions must inherit mode.  */
+  if (current_function_decl)
+   {
+     mode = TARGET_THUMB ? "thumb" : "arm";      
+     add_attribute (mode, attributes);
+     return;
+   }
+
+  /* If there is already a setting don't change it.  */
+  if (lookup_attribute ("target", *attributes) != NULL)
+    return;
+
+  mode = thumb_flipper ? "thumb" : "arm";
+  add_attribute (mode, attributes);
+
+  thumb_flipper = !thumb_flipper;
+}
+
 /* Hook to validate attribute((target("string"))).  */
 
 static bool
diff '--exclude=.svn' -ruN gnu_trunk.p5/gcc/gcc/config/arm/arm.opt gnu_trunk.p6/gcc/gcc/config/arm/arm.opt
--- gnu_trunk.p5/gcc/gcc/config/arm/arm.opt	2015-05-18 10:20:26.545835080 +0200
+++ gnu_trunk.p6/gcc/gcc/config/arm/arm.opt	2015-05-13 13:13:11.014686529 +0200
@@ -122,6 +122,10 @@ 
 EnumValue
 Enum(float_abi_type) String(hard) Value(ARM_FLOAT_ABI_HARD)
 
+mflip-thumb
+Target Report Var(TARGET_FLIP_THUMB)
+Switch ARM/Thumb modes on alternating functions for compiler testing
+
 mfp16-format=
 Target RejectNegative Joined Enum(arm_fp16_format_type) Var(arm_fp16_format) Init(ARM_FP16_FORMAT_NONE)
 Specify the __fp16 floating-point format