summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-08 04:26:12 +0000
committersandra <sandra@138bc75d-0d04-0410-961f-82ee72b054a4>2017-12-08 04:26:12 +0000
commitd0eb0042803cc188f72f2693501f49b7ea8864a2 (patch)
tree6132eeca2d4799107202375264b8f3d0897e7b0e
parenteaf0bf7ea622f49e52264506c5395fb26d5e3d9e (diff)
downloadgcc-d0eb0042803cc188f72f2693501f49b7ea8864a2.tar.gz
2017-12-07 Sandra Loosemore <sandra@codesourcery.com>
gcc/testsuite/ * gcc.target/nios2/const-addr-1.c: New. * gcc.target/nios2/const-addr-2.c: New. * gcc.target/nios2/const-addr-3.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255494 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/nios2/const-addr-1.c19
-rw-r--r--gcc/testsuite/gcc.target/nios2/const-addr-2.c18
-rw-r--r--gcc/testsuite/gcc.target/nios2/const-addr-3.c20
4 files changed, 63 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 564a301e700..9d4f1c81609 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-07 Sandra Loosemore <sandra@codesourcery.com>
+
+ * gcc.target/nios2/const-addr-1.c: New.
+ * gcc.target/nios2/const-addr-2.c: New.
+ * gcc.target/nios2/const-addr-3.c: New.
+
2017-12-08 Jakub Jelinek <jakub@redhat.com>
PR target/83252
diff --git a/gcc/testsuite/gcc.target/nios2/const-addr-1.c b/gcc/testsuite/gcc.target/nios2/const-addr-1.c
new file mode 100644
index 00000000000..3a25df4ee4a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nios2/const-addr-1.c
@@ -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); }
diff --git a/gcc/testsuite/gcc.target/nios2/const-addr-2.c b/gcc/testsuite/gcc.target/nios2/const-addr-2.c
new file mode 100644
index 00000000000..da78ce85f6b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nios2/const-addr-2.c
@@ -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); }
diff --git a/gcc/testsuite/gcc.target/nios2/const-addr-3.c b/gcc/testsuite/gcc.target/nios2/const-addr-3.c
new file mode 100644
index 00000000000..73b25e71cd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nios2/const-addr-3.c
@@ -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); }