public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, AArch64]  Update insv_1.c test for Big Endian
@ 2013-06-24 15:57 Ian Bolton
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Bolton @ 2013-06-24 15:57 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

Hi,

The insv_1.c test case I added recently was not compatible with big endian.
I attempted to fix with #ifdefs but dejagnu thinks all dg directives in a
file, regardless of #ifdefs, are applicable, so I had to instead make a
new test and add a new effective target to show when each test is supported.
 
I've tested these two tests on little and big.  All was OK.

OK for trunk?

Cheers,
Ian


2013-06-24  Ian Bolton  <ian.bolton@arm.com>

	* gcc.target/config/aarch64/insv_1.c: Update to show it doesn't work
	on big endian.
	* gcc.target/config/aarch64/insv_2.c: New test for big endian.
	* lib/target-supports.exp: Define aarch64_little_endian.

[-- Attachment #2: aarch64-insv-test-fix-patch-v2.txt --]
[-- Type: text/plain, Size: 3098 bytes --]

diff --git a/gcc/testsuite/gcc.target/aarch64/insv_1.c b/gcc/testsuite/gcc.target/aarch64/insv_1.c
index bc8928d..6e3c7f0 100644
--- a/gcc/testsuite/gcc.target/aarch64/insv_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/insv_1.c
@@ -1,5 +1,6 @@
-/* { dg-do run } */
+/* { dg-do run { target aarch64*-*-* } } */
 /* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_little_endian } */
 
 extern void abort (void);
 
diff --git a/gcc/testsuite/gcc.target/aarch64/insv_2.c b/gcc/testsuite/gcc.target/aarch64/insv_2.c
new file mode 100644
index 0000000..a7691a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/insv_2.c
@@ -0,0 +1,85 @@
+/* { dg-do run { target aarch64*-*-* } } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_big_endian } */
+
+extern void abort (void);
+
+typedef struct bitfield
+{
+  unsigned short eight: 8;
+  unsigned short four: 4;
+  unsigned short five: 5;
+  unsigned short seven: 7;
+  unsigned int sixteen: 16;
+} bitfield;
+
+bitfield
+bfi1 (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 56, 8" } } */
+  a.eight = 3;
+  return a;
+}
+
+bitfield
+bfi2 (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfi\tx\[0-9\]+, x\[0-9\]+, 43, 5" } } */
+  a.five = 7;
+  return a;
+}
+
+bitfield
+movk (bitfield a)
+{
+  /* { dg-final { scan-assembler "movk\tx\[0-9\]+, 0x1d6b, lsl 16" } } */
+  a.sixteen = 7531;
+  return a;
+}
+
+bitfield
+set1 (bitfield a)
+{
+  /* { dg-final { scan-assembler "orr\tx\[0-9\]+, x\[0-9\]+, 272678883688448" } } */
+  a.five = 0x1f;
+  return a;
+}
+
+bitfield
+set0 (bitfield a)
+{
+  /* { dg-final { scan-assembler "and\tx\[0-9\]+, x\[0-9\]+, -272678883688449" } } */
+  a.five = 0;
+  return a;
+}
+
+
+int
+main (int argc, char** argv)
+{
+  static bitfield a;
+  bitfield b = bfi1 (a);
+  bitfield c = bfi2 (b);
+  bitfield d = movk (c);
+
+  if (d.eight != 3)
+    abort ();
+
+  if (d.five != 7)
+    abort ();
+
+  if (d.sixteen != 7531)
+    abort ();
+
+  d = set1 (d);
+  if (d.five != 0x1f)
+    abort ();
+
+  d = set0 (d);
+  if (d.five != 0)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index a80078a..aca4215 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2105,6 +2105,15 @@ proc check_effective_target_aarch64_big_endian { } {
     }]
 }
 
+# Return 1 if this is a AArch64 target supporting little endian
+proc check_effective_target_aarch64_little_endian { } {
+    return [check_no_compiler_messages aarch64_little_endian assembly {
+        #if !defined(__aarch64__) || defined(__AARCH64EB__)
+        #error FOO
+        #endif
+    }]
+}
+
 # Return 1 is this is an arm target using 32-bit instructions
 proc check_effective_target_arm32 { } {
     return [check_no_compiler_messages arm32 assembly {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, AArch64] Update insv_1.c test for Big Endian
       [not found] <51c86c7a.a564420a.5b34.3ce6SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2013-07-02  9:16 ` Marcus Shawcroft
  0 siblings, 0 replies; 2+ messages in thread
From: Marcus Shawcroft @ 2013-07-02  9:16 UTC (permalink / raw)
  To: Ian Bolton; +Cc: gcc-patches

On 24 June 2013 16:57, Ian Bolton <ian.bolton@arm.com> wrote:

> 2013-06-24  Ian Bolton  <ian.bolton@arm.com>
>
>         * gcc.target/config/aarch64/insv_1.c: Update to show it doesn't work
>         on big endian.
>         * gcc.target/config/aarch64/insv_2.c: New test for big endian.
>         * lib/target-supports.exp: Define aarch64_little_endian.

OK
/Marcus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-02  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-24 15:57 [PATCH, AArch64] Update insv_1.c test for Big Endian Ian Bolton
     [not found] <51c86c7a.a564420a.5b34.3ce6SMTPIN_ADDED_BROKEN@mx.google.com>
2013-07-02  9:16 ` Marcus Shawcroft

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).