diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-03 23:45:56 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-03 23:45:56 +0000 |
commit | fe644b69d013e77c7fc2db2a9863969d4f564561 (patch) | |
tree | a2cb1398bd46b8decaea84f1b7de8c7cd35e6046 /gcc/testsuite/gcc.target/nios2 | |
parent | 90079d10dd355193fe289fa0bfcb0d7be880d45a (diff) | |
parent | 04e0495a6da35f3b0bcedbd75908cb6e9ba8ff8f (diff) | |
download | gcc-fe644b69d013e77c7fc2db2a9863969d4f564561.tar.gz |
Merge in trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@206327 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.target/nios2')
35 files changed, 879 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/nios2/custom-fp-1.c b/gcc/testsuite/gcc.target/nios2/custom-fp-1.c new file mode 100644 index 00000000000..c9afa682977 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-2.c b/gcc/testsuite/gcc.target/nios2/custom-fp-2.c new file mode 100644 index 00000000000..fc7c643705e --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-3.c b/gcc/testsuite/gcc.target/nios2/custom-fp-3.c new file mode 100644 index 00000000000..703bc9fa5bd --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-4.c b/gcc/testsuite/gcc.target/nios2/custom-fp-4.c new file mode 100644 index 00000000000..6c5f2a24be4 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-5.c b/gcc/testsuite/gcc.target/nios2/custom-fp-5.c new file mode 100644 index 00000000000..1dba87a4e44 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-6.c b/gcc/testsuite/gcc.target/nios2/custom-fp-6.c new file mode 100644 index 00000000000..7540c57b282 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-7.c b/gcc/testsuite/gcc.target/nios2/custom-fp-7.c new file mode 100644 index 00000000000..6f17336fbb9 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-8.c b/gcc/testsuite/gcc.target/nios2/custom-fp-8.c new file mode 100644 index 00000000000..32f8a041479 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-cmp-1.c b/gcc/testsuite/gcc.target/nios2/custom-fp-cmp-1.c new file mode 100644 index 00000000000..b290c41e475 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-conversion.c b/gcc/testsuite/gcc.target/nios2/custom-fp-conversion.c new file mode 100644 index 00000000000..20b2159960e --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-double.c b/gcc/testsuite/gcc.target/nios2/custom-fp-double.c new file mode 100644 index 00000000000..d907c572af1 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/custom-fp-float.c b/gcc/testsuite/gcc.target/nios2/custom-fp-float.c new file mode 100644 index 00000000000..26919d2f20e --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c b/gcc/testsuite/gcc.target/nios2/nios2-ashlsi3-one_shift.c new file mode 100644 index 00000000000..6af6d4f9cb0 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-builtin-custom.c b/gcc/testsuite/gcc.target/nios2/nios2-builtin-custom.c new file mode 100644 index 00000000000..18399facc00 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-builtin-io.c b/gcc/testsuite/gcc.target/nios2/nios2-builtin-io.c new file mode 100644 index 00000000000..58bc83f8abc --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-cache-1.c b/gcc/testsuite/gcc.target/nios2/nios2-cache-1.c new file mode 100644 index 00000000000..5516a1367ca --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-cache-2.c b/gcc/testsuite/gcc.target/nios2/nios2-cache-2.c new file mode 100644 index 00000000000..239c600ac56 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-custom-1.c b/gcc/testsuite/gcc.target/nios2/nios2-custom-1.c new file mode 100644 index 00000000000..c6e4b517e71 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-custom-2.c b/gcc/testsuite/gcc.target/nios2/nios2-custom-2.c new file mode 100644 index 00000000000..7f5d21a5440 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-int-types.c b/gcc/testsuite/gcc.target/nios2/nios2-int-types.c new file mode 100644 index 00000000000..21b4a02be9f --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-mul-options-1.c b/gcc/testsuite/gcc.target/nios2/nios2-mul-options-1.c new file mode 100644 index 00000000000..b639482bfa6 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-mul-options-2.c b/gcc/testsuite/gcc.target/nios2/nios2-mul-options-2.c new file mode 100644 index 00000000000..f93b4e7c585 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-mul-options-3.c b/gcc/testsuite/gcc.target/nios2/nios2-mul-options-3.c new file mode 100644 index 00000000000..2da74ba6b3b --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-mul-options-4.c b/gcc/testsuite/gcc.target/nios2/nios2-mul-options-4.c new file mode 100644 index 00000000000..7794f6d8756 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-nor.c b/gcc/testsuite/gcc.target/nios2/nios2-nor.c new file mode 100644 index 00000000000..3a1911e326d --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-rdctl.c b/gcc/testsuite/gcc.target/nios2/nios2-rdctl.c new file mode 100644 index 00000000000..6b44d88e65a --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c b/gcc/testsuite/gcc.target/nios2/nios2-rdwrctl-1.c new file mode 100644 index 00000000000..922942ab980 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-stack-check-1.c b/gcc/testsuite/gcc.target/nios2/nios2-stack-check-1.c new file mode 100644 index 00000000000..415906fc5ee --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-stack-check-2.c b/gcc/testsuite/gcc.target/nios2/nios2-stack-check-2.c new file mode 100644 index 00000000000..b903db5cdc4 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-stxio.c b/gcc/testsuite/gcc.target/nios2/nios2-stxio.c new file mode 100644 index 00000000000..af079d641c7 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-trap-insn.c b/gcc/testsuite/gcc.target/nios2/nios2-trap-insn.c new file mode 100644 index 00000000000..dd881d166c8 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c b/gcc/testsuite/gcc.target/nios2/nios2-wrctl-not-zero.c new file mode 100644 index 00000000000..f32a9ca4e50 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-wrctl-zero.c b/gcc/testsuite/gcc.target/nios2/nios2-wrctl-zero.c new file mode 100644 index 00000000000..93f01b07708 --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2-wrctl.c b/gcc/testsuite/gcc.target/nios2/nios2-wrctl.c new file mode 100644 index 00000000000..5ebdc24b8be --- /dev/null +++ b/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/testsuite/gcc.target/nios2/nios2.exp b/gcc/testsuite/gcc.target/nios2/nios2.exp new file mode 100644 index 00000000000..4f027048a9f --- /dev/null +++ b/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 |