aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/nios2
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/nios2')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-1.c67
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-2.c68
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-1.c22
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-2.c26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-3.c26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-4.c29
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-5.c26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-6.c30
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-7.c33
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-8.c24
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-cmp-1.c53
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-conversion.c66
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-double.c86
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-float.c80
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c10
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-custom.c9
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-io.c26
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-1.c21
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-2.c21
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-1.c64
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-2.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-int-types.c34
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-1.c11
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-2.c11
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-3.c11
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-4.c11
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-nor.c8
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdctl.c8
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c14
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c9
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-2.c9
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stxio.c25
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-trap-insn.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-zero.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl.c7
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2.exp41
37 files changed, 1014 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-1.c
new file mode 100644
index 000000000..49b14ed0c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-1.c
@@ -0,0 +1,67 @@
+/* Check that the GOT pointer is being initialized correctly to allow
+ access to the full 64K maximum GOT size for -fpic, rather than only 32K
+ (which would happen if the GOT pointer points to the base of the GOT,
+ as the GOT16 and CALL16 relocations are signed). */
+
+/* { dg-options "-fpic" } */
+/* { dg-do run { target nios2-*-linux-gnu } } */
+
+extern void abort (void);
+
+static int n = 0;
+
+void
+doit (int m)
+{
+ if (m != n)
+ abort ();
+ n++;
+}
+
+#define X(N) \
+ void f_##N (void) { doit (0x##N); }
+
+#define F(N) f_##N ();
+
+#define A(N) \
+ X(N##0) X(N##1) X(N##2) X(N##3) X(N##4) X(N##5) X(N##6) X(N##7) \
+ X(N##8) X(N##9) X(N##a) X(N##b) X(N##c) X(N##d) X(N##e) X(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define B(N) \
+ A(N##0) A(N##1) A(N##2) A(N##3) A(N##4) A(N##5) A(N##6) A(N##7) \
+ A(N##8) A(N##9) A(N##a) A(N##b) A(N##c) A(N##d) A(N##e) A(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define C(N) \
+ B(N##0) B(N##1) B(N##2) B(N##3) B(N##4) B(N##5) B(N##6) B(N##7) \
+ B(N##8) B(N##9) B(N##a) B(N##b) B(N##c) B(N##d) B(N##e) B(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define D(N) \
+ C(N##0) C(N##1) C(N##2) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) \
+ }
+
+/* This defines 16x16x16x3 leaf functions, requiring something over
+ 48K of GOT space overall. */
+D(0)
+
+int
+main (void)
+{
+ f_0 ();
+ if (n != 16*16*16*3)
+ abort ();
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-2.c
new file mode 100644
index 000000000..7a34d3f6d
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/biggot-2.c
@@ -0,0 +1,68 @@
+/* Check that a program that requires large-GOT support builds and
+ executes without error. This program defines a very large number
+ of leaf functions; compiled with -fPIC, they all require GOT
+ entries, which will overflow the range addressible by 16-bit -fpic
+ offsets by about a factor of 2. */
+
+/* { dg-options "-fPIC" } */
+/* { dg-do run { target nios2-*-linux-gnu } } */
+
+extern void abort (void);
+
+static int n = 0;
+
+void
+doit (int m)
+{
+ if (m != n)
+ abort ();
+ n++;
+}
+
+#define X(N) \
+ void f_##N (void) { doit (0x##N); }
+
+#define F(N) f_##N ();
+
+#define A(N) \
+ X(N##0) X(N##1) X(N##2) X(N##3) X(N##4) X(N##5) X(N##6) X(N##7) \
+ X(N##8) X(N##9) X(N##a) X(N##b) X(N##c) X(N##d) X(N##e) X(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define B(N) \
+ A(N##0) A(N##1) A(N##2) A(N##3) A(N##4) A(N##5) A(N##6) A(N##7) \
+ A(N##8) A(N##9) A(N##a) A(N##b) A(N##c) A(N##d) A(N##e) A(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define C(N) \
+ B(N##0) B(N##1) B(N##2) B(N##3) B(N##4) B(N##5) B(N##6) B(N##7) \
+ B(N##8) B(N##9) B(N##a) B(N##b) B(N##c) B(N##d) B(N##e) B(N##f) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ F(N##8) F(N##9) F(N##a) F(N##b) F(N##c) F(N##d) F(N##e) F(N##f) \
+ }
+
+#define D(N) \
+ C(N##0) C(N##1) C(N##2) C(N##3) C(N##4) C(N##5) C(N##6) C(N##7) \
+ void f_##N (void) { \
+ F(N##0) F(N##1) F(N##2) F(N##3) F(N##4) F(N##5) F(N##6) F(N##7) \
+ }
+
+/* This defines 16x16x16x8 leaf functions, requiring something over
+ 128K of GOT space overall. */
+D(0)
+
+int
+main (void)
+{
+ f_0 ();
+ if (n != 16*16*16*8)
+ abort ();
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-1.c
new file mode 100644
index 000000000..c9afa6829
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-1.c
@@ -0,0 +1,22 @@
+/* Test specification of custom instructions via command-line options. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only -mcustom-fmaxs=246 -mcustom-fmins=247 -mcustom-fsqrts=251" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+ result[2] = sqrtf (operand_a);
+}
+
+/* { dg-final { scan-assembler "custom\\t246, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t247, .* # fmins .*" } } */
+/* { dg-final { scan-assembler "custom\\t251, .* # fsqrts .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-2.c
new file mode 100644
index 000000000..fc7c64370
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-2.c
@@ -0,0 +1,26 @@
+/* Test specification of custom instructions via pragmas. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+#pragma GCC target ("custom-fmaxs=246")
+#pragma GCC target ("custom-fmins=247")
+#pragma GCC target ("custom-fsqrts=251")
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+ result[2] = sqrtf (operand_a);
+}
+
+/* { dg-final { scan-assembler "custom\\t246, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t247, .* # fmins .*" } } */
+/* { dg-final { scan-assembler "custom\\t251, .* # fsqrts .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-3.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-3.c
new file mode 100644
index 000000000..703bc9fa5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-3.c
@@ -0,0 +1,26 @@
+/* Test specification of custom instructions via function attributes. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmaxs=246,custom-fmins=247,custom-fsqrts=251")));
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+ result[2] = sqrtf (operand_a);
+}
+
+/* { dg-final { scan-assembler "custom\\t246, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t247, .* # fmins .*" } } */
+/* { dg-final { scan-assembler "custom\\t251, .* # fsqrts .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-4.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-4.c
new file mode 100644
index 000000000..6c5f2a24b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-4.c
@@ -0,0 +1,29 @@
+/* Test conflict between pragma and attribute specification of custom
+ instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+/* This test case is expected to cause an error because GCC does not know
+ how to merge different custom instruction attribute sets. The extern
+ declaration sees the options specified by both the pragma and the function
+ attribute, but the function definition sees only the pragma options. */
+
+#pragma GCC target ("custom-fmaxs=246")
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmins=247")));
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{ /* { dg-error "conflicting" } */
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-5.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-5.c
new file mode 100644
index 000000000..1dba87a4e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-5.c
@@ -0,0 +1,26 @@
+/* Test that forward declaration and definition don't conflict when used
+ with pragma specification of custom instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+#pragma GCC target ("custom-fmaxs=246,custom-fmins=247")
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result);
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+}
+
+/* { dg-final { scan-assembler "custom\\t246, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t247, .* # fmins .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-6.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-6.c
new file mode 100644
index 000000000..7540c57b2
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-6.c
@@ -0,0 +1,30 @@
+/* Test conflict between pragma and attribute specification of custom
+ instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+/* This test case is expected to cause an error because GCC does not know
+ how to merge different custom instruction attribute sets, even if they
+ do not overlap. */
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmaxs=246")));
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmins=247"))); /* { dg-error "conflicting" } */
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-7.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-7.c
new file mode 100644
index 000000000..6f17336fb
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-7.c
@@ -0,0 +1,33 @@
+/* Test that duplicate declarations with the same custom insn attributes
+ don't cause an error. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+/* This test case is expected to cause an error because GCC does not know
+ how to merge different custom instruction attribute sets, even if they
+ do not overlap. */
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmaxs=246,custom-fmins=247")));
+
+extern void
+custom_fp (float operand_a, float operand_b, float *result)
+ __attribute__ ((target ("custom-fmaxs=246,custom-fmins=247")));
+
+void
+custom_fp (float operand_a, float operand_b, float *result)
+{
+ result[0] = fmaxf (operand_a, operand_b);
+ result[1] = fminf (operand_a, operand_b);
+}
+
+/* { dg-final { scan-assembler "custom\\t246, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t247, .* # fmins .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-8.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-8.c
new file mode 100644
index 000000000..32f8a0414
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-8.c
@@ -0,0 +1,24 @@
+/* Test whitespace skipping in target attributes. */
+
+/* { dg-do compile } */
+
+#pragma GCC target ("custom-fdivs=246")
+#pragma GCC target (" custom-fdivs=246")
+#pragma GCC target ("custom-fdivs =246")
+#pragma GCC target ("custom-fdivs= 246")
+#pragma GCC target ("custom-fdivs=246 ")
+
+#pragma GCC target ("custom-fdivs=246,custom-fabss=247")
+#pragma GCC target ("custom-fdivs=246 ,custom-fabss=247")
+#pragma GCC target ("custom-fdivs=246, custom-fabss=247")
+#pragma GCC target ("custom-fdivs=246 , custom-fabss=247")
+
+void foo (void) __attribute__ ((target ("custom-fcmpnes=226,custom-fcmpeqs=227")));
+void foo (void) __attribute__ ((target ("custom-fcmpnes =226 ,custom-fcmpeqs=227")));
+void foo (void) __attribute__ ((target ("custom-fcmpnes= 226, custom-fcmpeqs=227")));
+void foo (void) __attribute__ ((target (" custom-fcmpnes=226 , custom-fcmpeqs = 227")));
+void foo (void) __attribute__ ((target (" custom-fcmpnes=226 ,custom-fcmpeqs =227 ")));
+
+#pragma GCC target ("custom-fpu-cfg=60-1")
+#pragma GCC target ("custom-fpu-cfg =60-1 ")
+#pragma GCC target (" custom-fpu-cfg= 60-1 ")
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-cmp-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-cmp-1.c
new file mode 100644
index 000000000..b290c41e4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-cmp-1.c
@@ -0,0 +1,53 @@
+/* Test generation of floating-point compare custom instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#pragma GCC target ("custom-frdxhi=40")
+#pragma GCC target ("custom-frdxlo=41")
+#pragma GCC target ("custom-frdy=42")
+#pragma GCC target ("custom-fwrx=43")
+#pragma GCC target ("custom-fwry=44")
+
+#pragma GCC target ("custom-fcmpeqs=200")
+
+int
+test_fcmpeqs (float a, float b)
+{
+ return (a == b);
+}
+
+/* { dg-final { scan-assembler "custom\\t200, .* # fcmpeqs .*" } } */
+
+#pragma GCC target ("custom-fcmpgtd=201")
+
+int
+test_fcmpgtd (double a, double b)
+{
+ return (a > b);
+}
+
+/* { dg-final { scan-assembler "custom\\t201, .* # fcmpgtd .*" } } */
+
+#pragma GCC target ("custom-fcmples=202")
+
+int
+test_fcmples (float a, float b)
+{
+ return (a <= b);
+}
+
+/* { dg-final { scan-assembler "custom\\t202, .* # fcmples .*" } } */
+
+#pragma GCC target ("custom-fcmpned=203")
+
+int
+test_fcmpned (double a, double b)
+{
+ return (a != b);
+}
+
+/* { dg-final { scan-assembler "custom\\t203, .* # fcmpned .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-conversion.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-conversion.c
new file mode 100644
index 000000000..20b215996
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-conversion.c
@@ -0,0 +1,66 @@
+/* Test generation of conversion custom instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only -funsafe-math-optimizations" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+#pragma GCC target ("custom-frdxhi=40")
+#pragma GCC target ("custom-frdxlo=41")
+#pragma GCC target ("custom-frdy=42")
+#pragma GCC target ("custom-fwrx=43")
+#pragma GCC target ("custom-fwry=44")
+
+#pragma GCC target ("custom-fextsd=100")
+#pragma GCC target ("custom-fixdi=101")
+#pragma GCC target ("custom-fixdu=102")
+#pragma GCC target ("custom-fixsi=103")
+#pragma GCC target ("custom-fixsu=104")
+#pragma GCC target ("custom-floatid=105")
+#pragma GCC target ("custom-floatis=106")
+#pragma GCC target ("custom-floatud=107")
+#pragma GCC target ("custom-floatus=108")
+#pragma GCC target ("custom-ftruncds=109")
+
+typedef struct data {
+ double fextsd;
+ int fixdi;
+ unsigned fixdu;
+ int fixsi;
+ unsigned fixsu;
+ double floatid;
+ float floatis;
+ double floatud;
+ float floatus;
+ float ftruncds;
+} data_t;
+
+void
+custom_fp (int i, unsigned u, float f, double d, data_t *out)
+{
+ out->fextsd = (double) f;
+ out->fixdi = (int) d;
+ out->fixdu = (unsigned) d;
+ out->fixsi = (int) f;
+ out->fixsu = (unsigned) f;
+ out->floatid = (double) i;
+ out->floatis = (float) i;
+ out->floatud = (double) u;
+ out->floatus = (float) u;
+ out->ftruncds = (float) d;
+}
+
+/* { dg-final { scan-assembler "custom\\t100, .* # fextsd .*" } } */
+/* { dg-final { scan-assembler "custom\\t101, .* # fixdi .*" } } */
+/* { dg-final { scan-assembler "custom\\t102, .* # fixdu .*" } } */
+/* { dg-final { scan-assembler "custom\\t103, .* # fixsi .*" } } */
+/* { dg-final { scan-assembler "custom\\t104, .* # fixsu .*" } } */
+/* { dg-final { scan-assembler "custom\\t105, .* # floatid .*" } } */
+/* { dg-final { scan-assembler "custom\\t106, .* # floatis .*" } } */
+/* { dg-final { scan-assembler "custom\\t107, .* # floatud .*" } } */
+/* { dg-final { scan-assembler "custom\\t108, .* # floatus .*" } } */
+/* { dg-final { scan-assembler "custom\\t109, .* # ftruncds .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-double.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-double.c
new file mode 100644
index 000000000..d907c572a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-double.c
@@ -0,0 +1,86 @@
+/* Test generation of all double-float custom instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only -funsafe-math-optimizations" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+#pragma GCC target ("custom-frdxhi=40")
+#pragma GCC target ("custom-frdxlo=41")
+#pragma GCC target ("custom-frdy=42")
+#pragma GCC target ("custom-fwrx=43")
+#pragma GCC target ("custom-fwry=44")
+
+#pragma GCC target ("custom-fabsd=100")
+#pragma GCC target ("custom-faddd=101")
+#pragma GCC target ("custom-fatand=102")
+#pragma GCC target ("custom-fcosd=103")
+#pragma GCC target ("custom-fdivd=104")
+#pragma GCC target ("custom-fexpd=105")
+#pragma GCC target ("custom-flogd=106")
+#pragma GCC target ("custom-fmaxd=107")
+#pragma GCC target ("custom-fmind=108")
+#pragma GCC target ("custom-fmuld=109")
+#pragma GCC target ("custom-fnegd=110")
+#pragma GCC target ("custom-fsind=111")
+#pragma GCC target ("custom-fsqrtd=112")
+#pragma GCC target ("custom-fsubd=113")
+#pragma GCC target ("custom-ftand=114")
+#pragma GCC target ("custom-fcmpeqd=200")
+#pragma GCC target ("custom-fcmpged=201")
+#pragma GCC target ("custom-fcmpgtd=202")
+#pragma GCC target ("custom-fcmpled=203")
+#pragma GCC target ("custom-fcmpltd=204")
+#pragma GCC target ("custom-fcmpned=205")
+
+void
+custom_fp (double a, double b, double *fp, int *ip)
+{
+ fp[0] = fabs (a);
+ fp[1] = a + b;
+ fp[2] = atan (a);
+ fp[3] = cos (a);
+ fp[4] = a / b;
+ fp[5] = exp (a);
+ fp[6] = log (a);
+ fp[7] = fmax (a, b);
+ fp[8] = fmin (a, b);
+ fp[9] = a * b;
+ fp[10] = -b;
+ fp[11] = sin (b);
+ fp[12] = sqrt (a);
+ fp[13] = a - b;
+ fp[14] = tan (a);
+ ip[0] = (a == fp[0]);
+ ip[1] = (a >= fp[1]);
+ ip[2] = (a > fp[2]);
+ ip[3] = (a <= fp[3]);
+ ip[4] = (a < fp[4]);
+ ip[5] = (a != fp[5]);
+}
+
+/* { dg-final { scan-assembler "custom\\t100, .* # fabsd .*" } } */
+/* { dg-final { scan-assembler "custom\\t101, .* # faddd .*" } } */
+/* { dg-final { scan-assembler "custom\\t102, .* # fatand .*" } } */
+/* { dg-final { scan-assembler "custom\\t103, .* # fcosd .*" } } */
+/* { dg-final { scan-assembler "custom\\t104, .* # fdivd .*" } } */
+/* { dg-final { scan-assembler "custom\\t105, .* # fexpd .*" } } */
+/* { dg-final { scan-assembler "custom\\t106, .* # flogd .*" } } */
+/* { dg-final { scan-assembler "custom\\t107, .* # fmaxd .*" } } */
+/* { dg-final { scan-assembler "custom\\t108, .* # fmind .*" } } */
+/* { dg-final { scan-assembler "custom\\t109, .* # fmuld .*" } } */
+/* { dg-final { scan-assembler "custom\\t110, .* # fnegd .*" } } */
+/* { dg-final { scan-assembler "custom\\t111, .* # fsind .*" } } */
+/* { dg-final { scan-assembler "custom\\t112, .* # fsqrtd .*" } } */
+/* { dg-final { scan-assembler "custom\\t113, .* # fsubd .*" } } */
+/* { dg-final { scan-assembler "custom\\t114, .* # ftand .*" } } */
+/* { dg-final { scan-assembler "custom\\t200, .* # fcmpeqd .*" } } */
+/* { dg-final { scan-assembler "custom\\t201, .* # fcmpged .*" } } */
+/* { dg-final { scan-assembler "custom\\t202, .* # fcmpgtd .*" } } */
+/* { dg-final { scan-assembler "custom\\t203, .* # fcmpled .*" } } */
+/* { dg-final { scan-assembler "custom\\t204, .* # fcmpltd .*" } } */
+/* { dg-final { scan-assembler "custom\\t205, .* # fcmpned .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-float.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-float.c
new file mode 100644
index 000000000..26919d2f2
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/custom-fp-float.c
@@ -0,0 +1,80 @@
+/* Test generation of all single-float custom instructions. */
+
+/* { dg-do compile } */
+/* { dg-options "-O1 -ffinite-math-only -funsafe-math-optimizations" } */
+
+/* -O1 in the options is significant. Without it FP operations may not be
+ optimized to custom instructions. */
+
+#include <stdio.h>
+#include <math.h>
+
+#pragma GCC target ("custom-fabss=100")
+#pragma GCC target ("custom-fadds=101")
+#pragma GCC target ("custom-fatans=102")
+#pragma GCC target ("custom-fcoss=103")
+#pragma GCC target ("custom-fdivs=104")
+#pragma GCC target ("custom-fexps=105")
+#pragma GCC target ("custom-flogs=106")
+#pragma GCC target ("custom-fmaxs=107")
+#pragma GCC target ("custom-fmins=108")
+#pragma GCC target ("custom-fmuls=109")
+#pragma GCC target ("custom-fnegs=110")
+#pragma GCC target ("custom-fsins=111")
+#pragma GCC target ("custom-fsqrts=112")
+#pragma GCC target ("custom-fsubs=113")
+#pragma GCC target ("custom-ftans=114")
+#pragma GCC target ("custom-fcmpeqs=200")
+#pragma GCC target ("custom-fcmpges=201")
+#pragma GCC target ("custom-fcmpgts=202")
+#pragma GCC target ("custom-fcmples=203")
+#pragma GCC target ("custom-fcmplts=204")
+#pragma GCC target ("custom-fcmpnes=205")
+
+void
+custom_fp (float a, float b, float *fp, int *ip)
+{
+ fp[0] = fabsf (a);
+ fp[1] = a + b;
+ fp[2] = atanf (a);
+ fp[3] = cosf (a);
+ fp[4] = a / b;
+ fp[5] = expf (a);
+ fp[6] = logf (a);
+ fp[7] = fmaxf (a, b);
+ fp[8] = fminf (a, b);
+ fp[9] = a * b;
+ fp[10] = -b;
+ fp[11] = sinf (b);
+ fp[12] = sqrtf (a);
+ fp[13] = a - b;
+ fp[14] = tanf (a);
+ ip[0] = (a == fp[0]);
+ ip[1] = (a >= fp[1]);
+ ip[2] = (a > fp[2]);
+ ip[3] = (a <= fp[3]);
+ ip[4] = (a < fp[4]);
+ ip[5] = (a != fp[5]);
+}
+
+/* { dg-final { scan-assembler "custom\\t100, .* # fabss .*" } } */
+/* { dg-final { scan-assembler "custom\\t101, .* # fadds .*" } } */
+/* { dg-final { scan-assembler "custom\\t102, .* # fatans .*" } } */
+/* { dg-final { scan-assembler "custom\\t103, .* # fcoss .*" } } */
+/* { dg-final { scan-assembler "custom\\t104, .* # fdivs .*" } } */
+/* { dg-final { scan-assembler "custom\\t105, .* # fexps .*" } } */
+/* { dg-final { scan-assembler "custom\\t106, .* # flogs .*" } } */
+/* { dg-final { scan-assembler "custom\\t107, .* # fmaxs .*" } } */
+/* { dg-final { scan-assembler "custom\\t108, .* # fmins .*" } } */
+/* { dg-final { scan-assembler "custom\\t109, .* # fmuls .*" } } */
+/* { dg-final { scan-assembler "custom\\t110, .* # fnegs .*" } } */
+/* { dg-final { scan-assembler "custom\\t111, .* # fsins .*" } } */
+/* { dg-final { scan-assembler "custom\\t112, .* # fsqrts .*" } } */
+/* { dg-final { scan-assembler "custom\\t113, .* # fsubs .*" } } */
+/* { dg-final { scan-assembler "custom\\t114, .* # ftans .*" } } */
+/* { dg-final { scan-assembler "custom\\t200, .* # fcmpeqs .*" } } */
+/* { dg-final { scan-assembler "custom\\t201, .* # fcmpges .*" } } */
+/* { dg-final { scan-assembler "custom\\t202, .* # fcmpgts .*" } } */
+/* { dg-final { scan-assembler "custom\\t203, .* # fcmples .*" } } */
+/* { dg-final { scan-assembler "custom\\t204, .* # fcmplts .*" } } */
+/* { dg-final { scan-assembler "custom\\t205, .* # fcmpnes .*" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c
new file mode 100644
index 000000000..6af6d4f9c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options " " } */
+/* { dg-final { scan-assembler-not "slli" } } */
+
+int x;
+
+void foo(void)
+{
+ x <<= 1;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-custom.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-custom.c
new file mode 100644
index 000000000..18399facc
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-custom.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "custom" } } */
+
+/* This test case used to cause an unrecognizable insn crash. */
+
+void foo (void)
+{
+ int offset = __builtin_custom_in(0x1);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-io.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-io.c
new file mode 100644
index 000000000..58bc83f8a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-builtin-io.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "ldbio" } } */
+/* { dg-final { scan-assembler "ldbuio" } } */
+/* { dg-final { scan-assembler "ldhio" } } */
+/* { dg-final { scan-assembler "ldhuio" } } */
+/* { dg-final { scan-assembler "ldwio" } } */
+/* { dg-final { scan-assembler "stbio" } } */
+/* { dg-final { scan-assembler "sthio" } } */
+/* { dg-final { scan-assembler "stwio" } } */
+
+volatile char b;
+volatile short h;
+volatile int w;
+
+void x ()
+{
+ __builtin_ldbio (&b);
+ __builtin_ldbuio (&b);
+ __builtin_ldhio (&h);
+ __builtin_ldhuio (&h);
+ __builtin_ldwio (&w);
+
+ __builtin_stbio (&b, 42);
+ __builtin_sthio (&h, 43);
+ __builtin_stwio (&w, 44);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-1.c
new file mode 100644
index 000000000..5516a1367
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "ldwio" } } */
+/* { dg-final { scan-assembler-not "stwio" } } */
+
+/* Make sure the default behavior is not to generate I/O variants of
+ the load and stores to foo. */
+
+extern volatile int foo;
+
+int
+read_foo (void)
+{
+ return foo;
+}
+
+void
+write_foo (int x)
+{
+ foo = x;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-2.c
new file mode 100644
index 000000000..239c600ac
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-cache-2.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mno-cache-volatile" } */
+/* { dg-final { scan-assembler "ldwio" } } */
+/* { dg-final { scan-assembler "stwio" } } */
+
+/* Make sure -mno-cache-volatile generates I/O variants of the load and
+ stores to foo. */
+
+extern volatile int foo;
+
+int
+read_foo (void)
+{
+ return foo;
+}
+
+void
+write_foo (int x)
+{
+ foo = x;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-1.c
new file mode 100644
index 000000000..c6e4b517e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-1.c
@@ -0,0 +1,64 @@
+/* { dg-do compile } */
+
+float fres, f1, f2;
+int ires, i1, i2;
+void *pres, *p1, *p2;
+
+void x ()
+{
+ __builtin_custom_n (0);
+ __builtin_custom_ni (1, i1);
+ __builtin_custom_nf (2, f1);
+ __builtin_custom_np (3, p1);
+ __builtin_custom_nii (4, i1, i2);
+ __builtin_custom_nif (5, i1, f2);
+ __builtin_custom_nip (6, i1, p2);
+ __builtin_custom_nfi (7, f1, i2);
+ __builtin_custom_nff (8, f1, f2);
+ __builtin_custom_nfp (9, f1, p2);
+ __builtin_custom_npi (10, p1, i2);
+ __builtin_custom_npf (11, p1, f2);
+ __builtin_custom_npp (12, p1, p2);
+
+ ires = __builtin_custom_in (13+0);
+ ires = __builtin_custom_ini (13+1, i1);
+ ires = __builtin_custom_inf (13+2, f1);
+ ires = __builtin_custom_inp (13+3, p1);
+ ires = __builtin_custom_inii (13+4, i1, i2);
+ ires = __builtin_custom_inif (13+5, i1, f2);
+ ires = __builtin_custom_inip (13+6, i1, p2);
+ ires = __builtin_custom_infi (13+7, f1, i2);
+ ires = __builtin_custom_inff (13+8, f1, f2);
+ ires = __builtin_custom_infp (13+9, f1, p2);
+ ires = __builtin_custom_inpi (13+10, p1, i2);
+ ires = __builtin_custom_inpf (13+11, p1, f2);
+ ires = __builtin_custom_inpp (13+12, p1, p2);
+
+ fres = __builtin_custom_fn (26+0);
+ fres = __builtin_custom_fni (26+1, i1);
+ fres = __builtin_custom_fnf (26+2, f1);
+ fres = __builtin_custom_fnp (26+3, p1);
+ fres = __builtin_custom_fnii (26+4, i1, i2);
+ fres = __builtin_custom_fnif (26+5, i1, f2);
+ fres = __builtin_custom_fnip (26+6, i1, p2);
+ fres = __builtin_custom_fnfi (26+7, f1, i2);
+ fres = __builtin_custom_fnff (26+8, f1, f2);
+ fres = __builtin_custom_fnfp (26+9, f1, p2);
+ fres = __builtin_custom_fnpi (26+10, p1, i2);
+ fres = __builtin_custom_fnpf (26+11, p1, f2);
+ fres = __builtin_custom_fnpp (26+12, p1, p2);
+
+ pres = __builtin_custom_pn (39+0);
+ pres = __builtin_custom_pni (39+1, i1);
+ pres = __builtin_custom_pnf (39+2, f1);
+ pres = __builtin_custom_pnp (39+3, p1);
+ pres = __builtin_custom_pnii (39+4, i1, i2);
+ pres = __builtin_custom_pnif (39+5, i1, f2);
+ pres = __builtin_custom_pnip (39+6, i1, p2);
+ pres = __builtin_custom_pnfi (39+7, f1, i2);
+ pres = __builtin_custom_pnff (39+8, f1, f2);
+ pres = __builtin_custom_pnfp (39+9, f1, p2);
+ pres = __builtin_custom_pnpi (39+10, p1, i2);
+ pres = __builtin_custom_pnpf (39+11, p1, f2);
+ pres = __builtin_custom_pnpp (39+12, p1, p2);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-2.c
new file mode 100644
index 000000000..7f5d21a54
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-custom-2.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+float foo (float) __attribute__ ((target ("custom-fsqrts=128")));
+float foo (float x)
+{
+ return __builtin_custom_fsqrts (x) + __builtin_custom_fnf (128, x);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-int-types.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-int-types.c
new file mode 100644
index 000000000..21b4a02be
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-int-types.c
@@ -0,0 +1,34 @@
+/* Test that various types are all derived from int. */
+/* { dg-do compile } */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+extern size_t a;
+unsigned int a;
+extern unsigned int aa;
+size_t aa;
+
+extern ssize_t b;
+int b;
+extern int bb;
+ssize_t bb;
+
+extern ptrdiff_t c;
+int c;
+extern int cc;
+ptrdiff_t cc;
+
+extern intptr_t d;
+int d;
+extern int dd;
+intptr_t dd;
+
+extern uintptr_t e;
+unsigned int e;
+extern unsigned int ee;
+uintptr_t ee;
+
+
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-1.c
new file mode 100644
index 000000000..b639482bf
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-final { scan-assembler "__muldi3" } } */
+
+long long x, y, z;
+
+void test()
+{
+ x = y * z;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-2.c
new file mode 100644
index 000000000..f93b4e7c5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-2.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-mhw-mulx" } */
+/* { dg-final { scan-assembler-not "__muldi3" } } */
+
+long long x, y, z;
+
+void test()
+{
+ x = y * z;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-3.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-3.c
new file mode 100644
index 000000000..2da74ba6b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-3.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-final { scan-assembler-not "__mulsi3" } } */
+
+int x, y, z;
+
+void test()
+{
+ x = y * z;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-4.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-4.c
new file mode 100644
index 000000000..7794f6d87
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-mul-options-4.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-mno-hw-mul" } */
+/* { dg-final { scan-assembler "__mulsi3" } } */
+
+int x, y, z;
+
+void test()
+{
+ x = y * z;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-nor.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-nor.c
new file mode 100644
index 000000000..3a1911e32
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-nor.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler "nor" } } */
+
+int foo (int x, int y)
+{
+ return ~(x | y);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdctl.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdctl.c
new file mode 100644
index 000000000..6b44d88e6
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdctl.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "rdctl" } } */
+
+int x ()
+{
+ __builtin_rdctl (0);
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c
new file mode 100644
index 000000000..922942ab9
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+volatile int res;
+
+void x ()
+{
+ __builtin_wrctl (0, res);
+ __builtin_wrctl (15, res);
+ __builtin_wrctl (31, res);
+
+ res = __builtin_rdctl (0);
+ res = __builtin_rdctl (15);
+ res = __builtin_rdctl (31);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c
new file mode 100644
index 000000000..415906fc5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fstack-limit-register=et" } */
+/* { dg-final { scan-assembler "bgeu\\tsp, et" } } */
+/* { dg-final { scan-assembler "break\\t3" } } */
+/* check stack checking */
+void test()
+{
+ int a, b, c;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-2.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-2.c
new file mode 100644
index 000000000..b903db5cd
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stack-check-2.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options " " } */
+/* { dg-final { scan-assembler-not "bgeu\\tsp, et" } } */
+/* { dg-final { scan-assembler-not "break\\t3" } } */
+/* check stack checking */
+void test()
+{
+ int a, b, c;
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stxio.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stxio.c
new file mode 100644
index 000000000..af079d641
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-stxio.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+
+void test_stbio (unsigned char* p1, unsigned char* p2)
+{
+ __builtin_stbio (p1, *p2);
+ __builtin_stbio (p2, 0);
+ __builtin_stbio (p2 + 1, 0x80);
+ __builtin_stbio (p2 + 2, 0x7f);
+}
+
+void test_sthio (unsigned short* p1, unsigned short* p2)
+{
+ __builtin_sthio (p1, *p2);
+ __builtin_sthio (p2, 0);
+ __builtin_sthio (p2 + 1, 0x8000);
+ __builtin_sthio (p2 + 2, 0x7fff);
+}
+
+void test_stwio (unsigned int* p1, unsigned int* p2)
+{
+ __builtin_stwio (p1, *p2);
+ __builtin_stwio (p2, 0);
+ __builtin_stwio (p2 + 1, 0x80000000);
+ __builtin_stwio (p2 + 2, 0x7fffffff);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-trap-insn.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-trap-insn.c
new file mode 100644
index 000000000..dd881d166
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-trap-insn.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "break\\t3" } } */
+
+/* Test the nios2 trap instruction */
+void foo(void){
+ __builtin_trap();
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c
new file mode 100644
index 000000000..f32a9ca4e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options " " } */
+/* { dg-final { scan-assembler-not "wrctl\\tctl6, zero" } } */
+
+void foo(void){
+ __builtin_wrctl(6,4);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-zero.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-zero.c
new file mode 100644
index 000000000..93f01b077
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl-zero.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+/* { dg-final { scan-assembler "wrctl\\tctl6, zero" } } */
+
+void foo(void){
+ __builtin_wrctl(6,0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl.c b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl.c
new file mode 100644
index 000000000..5ebdc24b8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2-wrctl.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "" } */
+/* { dg-final { scan-assembler "wrctl" } } */
+
+void foo(void){
+ __builtin_wrctl(6,4);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2.exp b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2.exp
new file mode 100644
index 000000000..4f027048a
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/nios2/nios2.exp
@@ -0,0 +1,41 @@
+# Copyright (C) 2012-2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a Nios II target.
+if ![istarget nios2*-*-*] then {
+ return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish