[3/3,nios2] new test cases

Message ID 49147fd3-e6c0-8bb4-a8b2-fe17c5bb3a01@codesourcery.com
State New
Headers show
Series
  • [1/3,nios2] fix code size regressions with constant integer addresses
Related show

Commit Message

Sandra Loosemore Dec. 8, 2017, 4:32 a.m.
I've checked in these new constant-integer address test cases to go with 
the previous two patches in this series.

-Sandra

Patch

Index: gcc/testsuite/gcc.target/nios2/const-addr-1.c
===================================================================
--- gcc/testsuite/gcc.target/nios2/const-addr-1.c	(nonexistent)
+++ gcc/testsuite/gcc.target/nios2/const-addr-1.c	(working copy)
@@ -0,0 +1,19 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "stw\tr., 12816\\(r\[2-9\]\\)" 1 } } */
+/* { dg-final { scan-assembler-times "stw\tr., 12816\\(r0\\)" 1 } } */
+/* { dg-final { scan-assembler-times "stw\tr., 528\\(r0\\)" 1 } } */
+
+/* These functions should not spill to stack.  */
+/* { dg-final { scan-assembler-not "addi\tsp, sp" } } */
+/* { dg-final { scan-assembler-not "spdeci" } } */
+
+#define addr1 ((volatile int *) 0x43210)
+#define addr2 ((volatile int *) 0x3210)
+#define addr3 ((volatile int *) 0x210)
+
+#define SET(l,r) (*(l) = (r))
+
+void foo1 (int x) { SET (addr1, x); }
+void foo2 (int x) { SET (addr2, x); }
+void foo3 (int x) { SET (addr3, x); }
Index: gcc/testsuite/gcc.target/nios2/const-addr-2.c
===================================================================
--- gcc/testsuite/gcc.target/nios2/const-addr-2.c	(nonexistent)
+++ gcc/testsuite/gcc.target/nios2/const-addr-2.c	(working copy)
@@ -0,0 +1,18 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=r1 -mno-cdx -mno-bmx -O2" } */
+/* { dg-final { scan-assembler-times "stwio\tr., 12816\\(r\[2-9\]\\)" 1 } } */
+/* { dg-final { scan-assembler-times "stwio\tr., 12816\\(r0\\)" 1 } } */
+/* { dg-final { scan-assembler-times "stwio\tr., 528\\(r0\\)" 1 } } */
+
+/* These functions should not spill to stack.  */
+/* { dg-final { scan-assembler-not "addi\tsp, sp" } } */
+
+#define addr1 ((volatile int *) 0x43210)
+#define addr2 ((volatile int *) 0x3210)
+#define addr3 ((volatile int *) 0x210)
+
+#define SET(l,r) __builtin_stwio ((l), (r))
+
+void foo1 (int x) { SET (addr1, x); }
+void foo2 (int x) { SET (addr2, x); }
+void foo3 (int x) { SET (addr3, x); }
Index: gcc/testsuite/gcc.target/nios2/const-addr-3.c
===================================================================
--- gcc/testsuite/gcc.target/nios2/const-addr-3.c	(nonexistent)
+++ gcc/testsuite/gcc.target/nios2/const-addr-3.c	(working copy)
@@ -0,0 +1,20 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=r2 -mno-cdx -mno-bmx -O2" } */
+/* { dg-final { scan-assembler-times "stwio\tr., 0\\(r" 2 } } */
+/* { dg-final { scan-assembler-times "stwio\tr., 528\\(r0\\)" 1 } } */
+
+/* These functions should not spill to stack.  */
+/* { dg-final { scan-assembler-not "addi\tsp, sp" } } */
+
+/* On R2, stwio takes only a 12-bit displacement so foo1 and foo2 need
+   to use register indirect addressing.  */
+
+#define addr1 ((volatile int *) 0x43210)
+#define addr2 ((volatile int *) 0x3210)
+#define addr3 ((volatile int *) 0x210)
+
+#define SET(l,r) __builtin_stwio ((l), (r))
+
+void foo1 (int x) { SET (addr1, x); }
+void foo2 (int x) { SET (addr2, x); }
+void foo3 (int x) { SET (addr3, x); }