From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gcc-patches@gcc.gnu.org
Cc: noamca@mellanox.com, Claudiu.Zissulescu@synopsys.com,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 02/10] gcc/arc: Add -munaligned-access option for nps400
Date: Fri, 04 Mar 2016 13:26:00 -0000 [thread overview]
Message-ID: <fd374f0ed35f1c2d6e6dab4dfa20fa74933d3af7.1457097757.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1457097757.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1457097757.git.andrew.burgess@embecosm.com>
New option for nps400 arc (-munaligned-access) that allows GCC to
generate unaligned accesses, the option is off by default. Turning this
option on will update the value for STRICT_ALIGNMENT.
gcc/ChangeLog:
* config/arc/arc.h (ARC_NPS400): Define if not already defined.
(UNALIGNED_ACCESS_DEFAULT): Define, if not already defined.
(STRICT_ALIGNMENT): Make use of unaligned_access var.
* config/arc/arc.c (arc_expand_movmem): Take STRICT_ALIGNMENT into
account.
* config/arc/arc.opt: (munaligned-access): New option.
* config/arc/t-nps400: Add munaligned-access to the multilib list.
gcc/testsuite/ChangeLog:
* gcc.target/arc/setmem-1.c: New file.
* gcc.target/arc/setmem-2.c: New file.
* gcc.target/arc/setmem-3.c: New file.
* gcc.target/arc/setmem-4.c: New file.
---
gcc/ChangeLog.NPS400 | 11 +++++++++++
gcc/config/arc/arc.c | 4 ++--
gcc/config/arc/arc.h | 19 +++++++++++++++----
gcc/config/arc/arc.opt | 4 ++++
gcc/config/arc/t-nps400 | 2 +-
gcc/testsuite/ChangeLog.NPS400 | 6 ++++++
gcc/testsuite/gcc.target/arc/setmem-1.c | 13 +++++++++++++
gcc/testsuite/gcc.target/arc/setmem-2.c | 18 ++++++++++++++++++
gcc/testsuite/gcc.target/arc/setmem-3.c | 13 +++++++++++++
gcc/testsuite/gcc.target/arc/setmem-4.c | 18 ++++++++++++++++++
10 files changed, 101 insertions(+), 7 deletions(-)
create mode 100644 gcc/testsuite/ChangeLog.NPS400
create mode 100644 gcc/testsuite/gcc.target/arc/setmem-1.c
create mode 100644 gcc/testsuite/gcc.target/arc/setmem-2.c
create mode 100644 gcc/testsuite/gcc.target/arc/setmem-3.c
create mode 100644 gcc/testsuite/gcc.target/arc/setmem-4.c
diff --git a/gcc/ChangeLog.NPS400 b/gcc/ChangeLog.NPS400
index 286f2dd..0281640 100644
--- a/gcc/ChangeLog.NPS400
+++ b/gcc/ChangeLog.NPS400
@@ -1,3 +1,14 @@
+2016-02-02 Joern Rennecke <joern.rennecke@embecosm.com>
+ Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * config/arc/arc.h (ARC_NPS400): Define if not already defined.
+ (UNALIGNED_ACCESS_DEFAULT): Define, if not already defined.
+ (STRICT_ALIGNMENT): Make use of unaligned_access var.
+ * config/arc/arc.c (arc_expand_movmem): Take STRICT_ALIGNMENT into
+ account.
+ * config/arc/arc.opt: (munaligned-access): New option.
+ * config/arc/t-nps400: Add munaligned-access to the multilib list.
+
2016-02-01 Andrew Burgess <andrew.burgess@embecosm.com>
* config.gcc: Add support for arc*-mellanox-* nps400 targets.
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index d60db50..35bb44a 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -7137,7 +7137,7 @@ arc_expand_movmem (rtx *operands)
HOST_WIDE_INT size;
int align = INTVAL (operands[3]);
unsigned n_pieces;
- int piece = align;
+ int piece = STRICT_ALIGNMENT ? align : 4;
rtx store[2];
rtx tmpx[2];
int i;
@@ -7146,7 +7146,7 @@ arc_expand_movmem (rtx *operands)
return false;
size = INTVAL (operands[2]);
/* move_by_pieces_ninsns is static, so we can't use it. */
- if (align >= 4)
+ if (align >= 4 || !STRICT_ALIGNMENT)
{
if (TARGET_LL64)
n_pieces = (size + 4) / 8U + ((size >> 1) & 1) + (size & 1);
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index 21c049f..1cb59ec 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -62,6 +62,10 @@ along with GCC; see the file COPYING3. If not see
#undef ASM_APP_OFF
#undef CC1_SPEC
+#ifndef ARC_NPS400
+#define ARC_NPS400 0
+#endif
+
/* Names to predefine in the preprocessor for this target machine. */
#define TARGET_CPU_CPP_BUILTINS() \
do { \
@@ -309,6 +313,10 @@ along with GCC; see the file COPYING3. If not see
#define MULTILIB_DEFAULTS { "mARC700" }
#endif
+#ifndef UNALIGNED_ACCESS_DEFAULT
+#define UNALIGNED_ACCESS_DEFAULT 0
+#endif
+
/* Target machine storage layout. */
/* We want zero_extract to mean the same
@@ -416,10 +424,13 @@ if (GET_MODE_CLASS (MODE) == MODE_INT \
/* Set this nonzero if move instructions will actually fail to work
when given unaligned data. */
-/* On the ARC the lower address bits are masked to 0 as necessary. The chip
- won't croak when given an unaligned address, but the insn will still fail
- to produce the correct result. */
-#define STRICT_ALIGNMENT 1
+/* On most ARC cores the lower address bits are masked to 0 as necessary,
+ the chip won't croak when given an unaligned address, but the insn will
+ still fail to produce the correct result. */
+/* The NPS400 ARC variant supports unaligned access. Although not without
+ cost, this is still fast enough that we can justify keeping
+ SLOW_UNALIGNED_ACCESS off. */
+#define STRICT_ALIGNMENT (!unaligned_access)
/* Layout of source language data types. */
diff --git a/gcc/config/arc/arc.opt b/gcc/config/arc/arc.opt
index 2227b75..f8e062c 100644
--- a/gcc/config/arc/arc.opt
+++ b/gcc/config/arc/arc.opt
@@ -456,3 +456,7 @@ Enum(arc_fpu) String(fpus_all) Value(FPU_SP | FPU_SC | FPU_SF | FPU_SD)
EnumValue
Enum(arc_fpu) String(fpud_all) Value(FPU_SP | FPU_SC | FPU_SF | FPU_SD | FPU_DP | FPU_DC | FPU_DF | FPU_DD)
+
+munaligned-access
+Target Report Var(unaligned_access) Init(UNALIGNED_ACCESS_DEFAULT) Condition(ARC_NPS400)
+Enable unaligned word and halfword accesses to packed data.
diff --git a/gcc/config/arc/t-nps400 b/gcc/config/arc/t-nps400
index e332e24..2d96b78 100644
--- a/gcc/config/arc/t-nps400
+++ b/gcc/config/arc/t-nps400
@@ -18,4 +18,4 @@
# with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-MULTILIB_OPTIONS=
+MULTILIB_OPTIONS=munaligned-access
diff --git a/gcc/testsuite/ChangeLog.NPS400 b/gcc/testsuite/ChangeLog.NPS400
new file mode 100644
index 0000000..b49dc1a
--- /dev/null
+++ b/gcc/testsuite/ChangeLog.NPS400
@@ -0,0 +1,6 @@
+2016-02-03 Joern Rennecke <joern.rennecke@embecosm.com>
+
+ * gcc.target/arc/setmem-1.c: New file.
+ * gcc.target/arc/setmem-2.c: New file.
+ * gcc.target/arc/setmem-3.c: New file.
+ * gcc.target/arc/setmem-4.c: New file.
diff --git a/gcc/testsuite/gcc.target/arc/setmem-1.c b/gcc/testsuite/gcc.target/arc/setmem-1.c
new file mode 100644
index 0000000..926974e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/setmem-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target arc*-mellanox-* } } */
+/* { dg-options "-O2 -munaligned-access" } */
+
+extern void *memcpy (void *, const void *, __SIZE_TYPE__);
+
+void
+f (char *d)
+{
+ static const char a[] = "abcdefghijklmnopqrstuvwxyz";
+ memcpy (d, a, 20);
+}
+/* { dg-final { scan-assembler-not "stb" } } */
+/* { dg-final { scan-assembler-not "memcpy" } } */
diff --git a/gcc/testsuite/gcc.target/arc/setmem-2.c b/gcc/testsuite/gcc.target/arc/setmem-2.c
new file mode 100644
index 0000000..a034fbd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/setmem-2.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target arc*-mellanox-* } } */
+/* { dg-options "-O2 -munaligned-access" } */
+
+extern void *memcpy (void *, const void *, __SIZE_TYPE__);
+
+void
+f (char *d)
+{
+ static const char a[] =
+ {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z',
+ };
+ memcpy (d, a, 20);
+}
+/* { dg-final { scan-assembler-not "stb" } } */
+/* { dg-final { scan-assembler-not "memcpy" } } */
diff --git a/gcc/testsuite/gcc.target/arc/setmem-3.c b/gcc/testsuite/gcc.target/arc/setmem-3.c
new file mode 100644
index 0000000..660d924
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/setmem-3.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target arc*-mellanox-* } } */
+/* { dg-options "-O2 -munaligned-access" } */
+
+extern void *memcpy (void *, const void *, __SIZE_TYPE__);
+
+void
+f (char *d)
+{
+ const char a[26] = "abcdefghijklmnopqrstuvwxyz";
+ memcpy (d, a, 20);
+}
+/* { dg-final { scan-assembler-not "stb" } } */
+/* { dg-final { scan-assembler-not "memcpy" } } */
diff --git a/gcc/testsuite/gcc.target/arc/setmem-4.c b/gcc/testsuite/gcc.target/arc/setmem-4.c
new file mode 100644
index 0000000..b5c1ee6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/setmem-4.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target arc*-mellanox-* } } */
+/* { dg-options "-O2 -munaligned-access" } */
+
+extern void *memcpy (void *, const void *, __SIZE_TYPE__);
+
+void
+f (char *d)
+{
+ const char a[26] =
+ {
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
+ 'u', 'v', 'w', 'x', 'y', 'z',
+ };
+ memcpy (d, a, 20);
+}
+/* { dg-final { scan-assembler-not "stb" } } */
+/* { dg-final { scan-assembler-not "memcpy" } } */
--
2.6.4
next prev parent reply other threads:[~2016-03-04 13:26 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 13:25 [PATCH 00/10] ARC: Add support for NPS400 variant Andrew Burgess
2016-03-04 13:25 ` [PATCH 01/10] gcc: Add support for mellanox nps400 arc variant Andrew Burgess
2016-03-04 13:26 ` Andrew Burgess [this message]
2016-03-04 13:26 ` [PATCH 10/10] gcc/arc: Add __NPS400__ define for nps400 targets Andrew Burgess
2016-03-04 13:26 ` [PATCH 07/10] gcc/arc: Add nps400 bitops support Andrew Burgess
2016-03-04 13:26 ` [PATCH 04/10] gcc/arc: Replace rI constraint with r & Cm2 for ld and update insns Andrew Burgess
2016-03-04 13:26 ` [PATCH 09/10] gcc/arc: Add an nps400 specific testcase Andrew Burgess
2016-03-04 13:26 ` [PATCH 03/10] gcc/arc: generate jump tables in code section for nps400 Andrew Burgess
2016-03-04 13:26 ` [PATCH 08/10] gcc/arc: Mask integer 'L' operands to 32-bit Andrew Burgess
2016-03-04 13:26 ` [PATCH 05/10] gcc/arc: convert some constraints to define_constraint Andrew Burgess
2016-03-04 13:26 ` [PATCH 06/10] gcc/arc: Add support for nps400 cmem xld/xst instructions Andrew Burgess
2016-04-21 11:39 ` [PATCHv2 3/7] gcc/arc: convert some constraints to define_constraint Andrew Burgess
2016-04-28 17:16 ` Joern Wolfgang Rennecke
2016-04-21 11:39 ` [PATCHv2 0/7] ARC: Add support for nps400 variant Andrew Burgess
2016-04-28 15:31 ` Joern Wolfgang Rennecke
2016-04-28 16:55 ` Joern Wolfgang Rennecke
2016-04-29 9:04 ` Claudiu Zissulescu
2016-04-29 10:22 ` Andrew Burgess
2016-04-29 22:17 ` Andrew Burgess
2016-05-02 9:02 ` Claudiu Zissulescu
2016-05-03 10:56 ` Andrew Burgess
2016-05-12 11:30 ` Claudiu Zissulescu
2016-06-14 18:46 ` Joern Wolfgang Rennecke
2016-06-14 23:38 ` [PATCH 0/2] Arc fixes and genrecog warning fix Andrew Burgess
2016-06-14 23:38 ` [PATCH 2/2] gcc/genrecog: Don't warn for missing mode on special predicates Andrew Burgess
2016-06-15 18:08 ` Richard Sandiford
2016-06-30 13:38 ` Andrew Burgess
2016-07-04 8:47 ` Richard Sandiford
2016-07-06 19:43 ` Andrew Burgess
2016-07-13 22:19 ` Jeff Law
2016-06-14 23:38 ` [PATCH 1/2] gcc/arc: New peephole2 and little endian arc test fixes Andrew Burgess
2016-11-16 11:44 ` [PATCHv2 0/7] ARC: Add support for nps400 variant Claudiu Zissulescu
2016-04-21 11:39 ` [PATCHv2 2/7] gcc/arc: Replace rI constraint with r & Cm2 for ld and update insns Andrew Burgess
2016-04-28 17:07 ` Joern Wolfgang Rennecke
2016-04-29 11:59 ` Andrew Burgess
2016-04-29 12:09 ` Joern Wolfgang Rennecke
2016-04-21 11:40 ` [PATCHv2 6/7] gcc/arc: Mask integer 'L' operands to 32-bit Andrew Burgess
2016-04-28 19:09 ` Joern Wolfgang Rennecke
2016-04-21 11:40 ` [PATCHv2 1/7] gcc/arc: Add support for nps400 cpu type Andrew Burgess
2016-04-28 17:07 ` Joern Wolfgang Rennecke
2016-04-21 11:40 ` [PATCHv2 4/7] gcc/arc: Add support for nps400 cmem xld/xst instructions Andrew Burgess
2016-04-28 18:23 ` Joern Wolfgang Rennecke
2016-04-21 11:40 ` [PATCHv2 7/7] gcc/arc: Add an nps400 specific testcase Andrew Burgess
2016-04-28 19:14 ` Joern Wolfgang Rennecke
2016-04-21 11:40 ` [PATCHv2 5/7] gcc/arc: Add nps400 bitops support Andrew Burgess
2016-04-28 18:50 ` Joern Wolfgang Rennecke
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=fd374f0ed35f1c2d6e6dab4dfa20fa74933d3af7.1457097757.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=Claudiu.Zissulescu@synopsys.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=noamca@mellanox.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).