From: Christian Bruel <christian.bruel@st.com>
To: Kyrill Tkachov <kyrylo.tkachov@foss.arm.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>
Subject: Re: [PATCH, ARM] (commited) attribute target (thumb,arm) [6/6] respin (5th)
Date: Mon, 22 Jun 2015 08:05:00 -0000 [thread overview]
Message-ID: <5587BC61.4020005@st.com> (raw)
In-Reply-To: <5576BA3C.2020101@foss.arm.com>
[-- Attachment #1: Type: text/plain, Size: 296 bytes --]
Hello,
> 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
>
I've committed the attached patch. Sorry for the delay sorting out the
false failures.
Christian
[-- Attachment #2: commited.patch --]
[-- Type: text/x-patch, Size: 4952 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (revision 224720)
+++ ChangeLog (revision 224722)
@@ -1,3 +1,11 @@
+2015-06-22 Christian Bruel <christian.bruel@st.com>
+
+ PR target/52144
+ * 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.
+
2015-06-22 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
Index: testsuite/gcc.target/arm/flip-thumb.c
===================================================================
--- testsuite/gcc.target/arm/flip-thumb.c (revision 0)
+++ testsuite/gcc.target/arm/flip-thumb.c (revision 224722)
@@ -0,0 +1,24 @@
+/* Check -mflip-thumb. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mflip-thumb -mno-restrict-it" } */
+/* { dg-final { scan-assembler ".arm" } } */
+/* { dg-final { scan-assembler-times ".thumb_func" 1} } */
+
+int
+foo(int a)
+{
+ return a ? 1 : 5;
+}
+
+int
+bar(int a)
+{
+ return a ? 1 : 5;
+}
+
+/* { dg-final { scan-assembler-times "ite" 1 { target { arm_thumb2_ok } } } } */
+
+
+
+
+
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 224720)
+++ testsuite/ChangeLog (revision 224722)
@@ -1,3 +1,8 @@
+2015-06-22 Christian Bruel <christian.bruel@st.com>
+
+ PR target/52144
+ * gcc.target/arm/flip-thumb.c: New test.
+
2015-06-22 Jan Hubicka <hubicka@ucw.cz>
Martin Liska <mliska@suse.cz>
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c (revision 224720)
+++ config/arm/arm.c (revision 224722)
@@ -84,6 +84,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;
@@ -218,6 +219,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);
@@ -376,6 +378,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
@@ -2792,6 +2797,10 @@
? 1 : 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;
@@ -3369,6 +3378,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
@@ -29459,6 +29471,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
Index: config/arm/arm.opt
===================================================================
--- config/arm/arm.opt (revision 224720)
+++ config/arm/arm.opt (revision 224722)
@@ -122,6 +122,10 @@
EnumValue
Enum(float_abi_type) String(hard) Value(ARM_FLOAT_ABI_HARD)
+mflip-thumb
+Target Report Var(TARGET_FLIP_THUMB) Undocumented
+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
prev parent reply other threads:[~2015-06-22 7:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 14:29 [PATCH, ARM] attribute target (thumb,arm) [6/6] respin (4th) Christian Bruel
2015-05-18 8:42 ` [PATCH, ARM] attribute target (thumb,arm) [6/6] respin (5th) Christian Bruel
2015-06-09 10:08 ` Kyrill Tkachov
2015-06-09 10:40 ` Christian Bruel
2015-06-22 8:05 ` Christian Bruel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5587BC61.4020005@st.com \
--to=christian.bruel@st.com \
--cc=Ramana.Radhakrishnan@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kyrylo.tkachov@foss.arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).