aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/rx
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/rx')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c144
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/i272091.c27
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/interrupts.c58
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/pack.c25
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/packed-struct.c55
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/rx-abi-function-tests.c159
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/rx.exp43
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/zero-width-bitfield.c32
8 files changed, 543 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c
new file mode 100644
index 000000000..d503ed3ef
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c
@@ -0,0 +1,144 @@
+/* { dg-do run } */
+
+/* Verify that the RX specific builtin functions work. */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/* We need to prevent these functions from being inlined
+ as otherwise gcc will attempt to optimize away their
+ arguments and we need the operations on them in order
+ to correctly set the psw flags. */
+
+int saturate_add (int, int) __attribute__((__noinline__));
+int exchange (int, int) __attribute__((__noinline__));
+
+int
+half_word_swap (int arg)
+{
+ return __builtin_rx_revw (arg);
+}
+
+long
+multiply_and_accumulate (long arg1, long arg2, long arg3)
+{
+ __builtin_rx_mvtaclo (0);
+ __builtin_rx_mvtachi (0);
+
+ __builtin_rx_mullo (arg1, arg2);
+ __builtin_rx_mulhi (arg1, arg2);
+ __builtin_rx_maclo (arg1, arg3);
+ __builtin_rx_machi (arg1, arg3);
+
+ __builtin_rx_racw (1);
+
+ arg1 = __builtin_rx_mvfachi ();
+ arg1 += __builtin_rx_mvfacmi ();
+
+ return arg1;
+}
+
+int
+rxround (float arg)
+{
+ return __builtin_rx_round (arg);
+}
+
+/* #define DEBUG 1 */
+
+#ifdef DEBUG
+#define CHECK_0ARG(func, result) \
+ if (func () != result) \
+ { \
+ printf (#func " () fails: %x not %x\n", func (), result); \
+ abort (); \
+ }
+
+#define CHECK_1ARG(func, arg, result) \
+ if (func (arg) != result) \
+ { \
+ printf (#func " (" #arg ") fails: %x not %x\n", func (arg), result); \
+ abort (); \
+ }
+
+#define CHECK_2ARG(func, arg1, arg2, result) \
+ if (func (arg1, arg2) != result) \
+ { \
+ printf (#func " (" #arg1 "," #arg2 ") fails: %x not %x\n", \
+ func (arg1, arg2), result); \
+ abort (); \
+ }
+
+#define CHECK_3ARG(func, arg1, arg2, arg3, result) \
+ if (func (arg1, arg2, arg3) != result) \
+ { \
+ printf (#func " (" #arg1 "," #arg2 "," #arg3 ") fails: %x not %x\n", \
+ func (arg1, arg2, arg3), result); \
+ abort (); \
+ }
+#else
+#define CHECK_0ARG(func, result) \
+ if (func () != result) \
+ abort ();
+
+#define CHECK_1ARG(func, arg, result) \
+ if (func (arg) != result) \
+ abort ();
+
+#define CHECK_2ARG(func, arg1, arg2, result) \
+ if (func (arg1, arg2) != result) \
+ abort ();
+
+#define CHECK_3ARG(func, arg1, arg2, arg3, result) \
+ if (func (arg1, arg2, arg3) != result) \
+ abort ();
+#endif
+
+int
+main (void)
+{
+ CHECK_1ARG (half_word_swap, 0x12345678, 0x34127856);
+ CHECK_3ARG (multiply_and_accumulate, 0x111, 0x222, 0x333, 0x70007);
+ CHECK_1ARG (rxround, 0.5, 1);
+ return 0;
+}
+
+/* The following builtins are compiled but
+ not executed because they need OS support. */
+
+void
+rxbreak (void)
+{
+ __builtin_rx_brk ();
+}
+
+void
+interrupt (void)
+{
+ __builtin_rx_int (0x12);
+}
+
+int
+get_stack_pointer (void)
+{
+ return __builtin_rx_mvfc (2);
+}
+
+void
+set_stack_pointer (int value)
+{
+ __builtin_rx_mvtc (2, value);
+ __builtin_rx_mvtc (2, 0x1234);
+}
+
+void
+wait (void)
+{
+ __builtin_rx_wait ();
+}
+
+void
+rmpa (int * multiplicand, int * multiplier, int num)
+{
+ __builtin_rx_rmpa ();
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/i272091.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/i272091.c
new file mode 100644
index 000000000..39da57632
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/i272091.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-msmall-data-limit=100" } */
+
+double a=6.76,b=7.34,c=0.54;
+double x_1= 45.46;
+static double SD_1;
+static double SD_init = 45.54;
+double DD_1;
+double DD_init=769.0;
+
+
+int main()
+{
+ volatile double x,y,z;
+
+ x = 56.76;
+ y = 4.5645;
+
+ z = x + y;
+ z = x - 4.65;
+ z = 4.566 - x;
+ z = x * y;
+ b = 8;
+ c = 34;
+ return 0;
+}
+
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/interrupts.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/interrupts.c
new file mode 100644
index 000000000..cdc4903de
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/interrupts.c
@@ -0,0 +1,58 @@
+/* { dg-do compile } */
+/* { dg-options "-mint-register=3 -msave-acc-in-interrupts" } */
+
+/* Verify that the RX specific function attributes work. */
+
+void fast_interrupt (void) __attribute__((__fast_interrupt__));
+void interrupt (void) __attribute__((__interrupt__));
+int naked (int) __attribute__((__naked__));
+
+int flag = 0;
+
+/* Fast interrupt handler. Only uses registers marked as fixed
+ by the -fixed-xxx gcc command line option. Returns via RTFI. */
+
+void
+fast_interrupt (void)
+{
+ flag = 1;
+}
+
+/* Interrupt handler. Must preserve any register it uses, even
+ call clobbered ones. Returns via RTE. */
+
+void
+interrupt (void)
+{
+ switch (flag)
+ {
+ case 0:
+ flag = -1;
+ break;
+ case 1:
+ case 2:
+ case 4:
+ flag = flag - 2;
+ break;
+ case 5:
+ case 7:
+ case 6:
+ flag ^= 3;
+ break;
+ default:
+ naked (flag * 2);
+ break;
+ }
+}
+
+/* Naked function. The programmer must supply the function's
+ prologue and epilogue instructions. */
+
+int
+naked (int arg)
+{
+ flag = arg;
+}
+
+/* { dg-final { scan-assembler "rtfi" } } */
+/* { dg-final { scan-assembler "rte" } } */
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/pack.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/pack.c
new file mode 100644
index 000000000..ce13b5021
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/pack.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+
+typedef unsigned short INT16U;
+
+typedef struct tst_2
+{
+ INT16U f0; /* [+0] */
+ INT16U * f1; /* [+2] */
+ INT16U f2; /* [+6] */
+ INT16U * f3; /* [+8] */
+} __attribute__ ((__packed__)) t2;
+
+#include <stddef.h>
+#include <stdlib.h>
+
+int main (void)
+{
+ if (offsetof (t2, f1) != 2)
+ abort ();
+ if (offsetof (t2, f2) != 6)
+ abort ();
+ if (offsetof (t2, f3) != 8)
+ abort ();
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/packed-struct.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/packed-struct.c
new file mode 100644
index 000000000..8c2a4345b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/packed-struct.c
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+
+struct unpacked
+{
+ int i;
+ char c;
+};
+
+#pragma pack(1)
+
+struct packed
+{
+ int i;
+ char c;
+};
+
+struct packed_contains_unpacked
+{
+ char c;
+ struct unpacked uuuu; /* This should generate an error message. */
+}; /* { dg-error "unpacked structure/union inside a packed struct" "XFAILed until patch for generic GCC structure layout code is accepted" { xfail rx-*-* } } */
+
+union contains_unpacked
+{
+ char c;
+ struct unpacked uuuu; /* This should not. */
+};
+
+struct packed_contains_packed
+{
+ char c;
+ struct packed ppppp; /* This should not. */
+};
+
+#pragma pack()
+
+struct unpacked_contains_packed
+{
+ char c;
+ struct packed p;
+};
+
+struct unpacked_contains_unpacked
+{
+ char c;
+ struct unpacked u;
+};
+
+
+int s1 = sizeof (struct unpacked);
+int s2 = sizeof (struct packed);
+int s3 = sizeof (struct packed_contains_unpacked);
+int s4 = sizeof (struct packed_contains_packed);
+int s5 = sizeof (struct unpacked_contains_packed);
+int s6 = sizeof (struct unpacked_contains_unpacked);
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/rx-abi-function-tests.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/rx-abi-function-tests.c
new file mode 100644
index 000000000..e07ff71a0
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/rx-abi-function-tests.c
@@ -0,0 +1,159 @@
+/* { dg-do run } */
+/* { dg-options "-msim" } */
+/* Note: The -msim above is actually there to override the default
+ options which include -ansi -pendantic and -Wlong-long... */
+
+extern int printf (const char *, ...);
+extern void exit (int);
+extern void abort (void);
+
+extern signed long _COM_CONVf32s (float);
+extern unsigned long _COM_CONVf32u (float);
+extern float _COM_CONV32sf (signed long);
+extern float _COM_CONV32uf (unsigned long);
+extern float _COM_ADDf (float, float);
+extern float _COM_SUBf (float, float);
+extern float _COM_MULf (float, float);
+extern float _COM_DIVf (float, float);
+extern int _COM_CMPLTf (float, float);
+
+extern long long _COM_MUL64 (long long, long long);
+extern signed long long _COM_DIV64s (long long, long long);
+extern unsigned long long _COM_DIV64u (unsigned long long, unsigned long long);
+extern long long _COM_SHLL64 (long long, int);
+extern long long _COM_SHLR64 (long long, int);
+extern long long _COM_SHAR64 (long long, int);
+extern signed long long _COM_CONVf64s (float);
+extern unsigned long long _COM_CONVf64u (float);
+extern signed long long _COM_CONVd64s (double);
+extern unsigned long long _COM_CONVd64u (double);
+extern float _COM_CONV64sf (signed long long);
+extern float _COM_CONV64uf (unsigned long long);
+extern double _COM_CONV64sd (signed long long);
+extern double _COM_CONV64ud (unsigned long long);
+extern signed long long _COM_MOD64s (long long, long long);
+extern unsigned long long _COM_MOD64u (unsigned long long, unsigned long long);
+extern int _COM_CMPLT64s (long long, long long);
+extern int _COM_CMPLT64u (unsigned long long, unsigned long long);
+extern int _COM_CMPGT64s (long long, long long);
+extern int _COM_CMPGT64u (unsigned long long, unsigned long long);
+extern int _COM_CMPLE64s (long long, long long);
+extern int _COM_CMPLE64u (unsigned long long, unsigned long long);
+extern int _COM_CMPGE64s (long long, long long);
+extern int _COM_CMPGE64u (unsigned long long, unsigned long long);
+extern int _COM_CMPEQ64 (long long, long long);
+extern int _COM_CMPNE64 (long long, long long);
+
+extern double _COM_ADDd (double, double);
+extern double _COM_SUBd (double, double);
+extern double _COM_MULd (double, double);
+extern double _COM_DIVd (double, double);
+extern signed long _COM_CONVd32s (double);
+extern unsigned long _COM_CONVd32u (double);
+extern double _COM_CONV32sd (signed long);
+extern double _COM_CONV32ud (unsigned long);
+extern double _COM_CONVfd (float);
+extern float _COM_CONVdf (double);
+extern double _COM_NEGd (double);
+
+
+/* #define DEBUG 1 */
+
+#ifdef DEBUG
+# define TEST1(func,arg1,result) if (func (arg1) != result) printf ("fail: " #func " (" #arg1 ") returns %x rather than " #result "\n", func (arg1))
+# define TEST2(func,arg1,arg2,result) if (func (arg1, arg2) != result) printf ("fail: " #func " (" #arg1 ", " #arg2 ") returns %x rather than " #result "\n", func (arg1, arg2))
+# define TEST_CMP(func, low_arg, high_arg, lt_result, eq_result, gt_result) \
+ do \
+ { \
+ int res; \
+ \
+ if ((res = func (low_arg, high_arg)) != lt_result) printf ("fail: " #func " (" #low_arg ", " #high_arg ") returns %d rather than %d\n", res, lt_result); \
+ if ((res = func (high_arg, low_arg)) != gt_result) printf ("fail: " #func " (" #high_arg ", " #low_arg ") returns %d rather than %d\n", res, gt_result); \
+ if ((res = func (low_arg, low_arg)) != eq_result) printf ("fail: " #func " (" #low_arg ", " #low_arg ") returns %d rather than %d\n", res, eq_result); \
+ } \
+ while (0)
+#else
+# define TEST1(func,arg1,result) if (func (arg1) != result) abort ()
+# define TEST2(func,arg1,arg2,result) if (func (arg1, arg2) != result) abort ()
+# define TEST_CMP(func,low,high,lt_res,eq_res,gt_res) \
+ if ( (func (low, high) != lt_res) \
+ || (func (high, low) != gt_res) \
+ || (func (low, low) != eq_res)) \
+ abort ();
+#endif
+
+
+int
+main (void)
+{
+#ifdef DEBUG
+ printf ("Tests starting\n");
+#endif
+
+ TEST1 (_COM_CONVf32s, -2.0f, -2);
+ TEST1 (_COM_CONVf32u, -2.0f, (unsigned) -2);
+ TEST1 (_COM_CONV32sf, -2, -2.0f);
+ TEST1 (_COM_CONV32uf, 2, 2.0f);
+ TEST2 (_COM_ADDf, 1.0f, 2.0f, 3.0f);
+ TEST2 (_COM_SUBf, 3.0f, 2.0f, 1.0f);
+ TEST2 (_COM_MULf, 2.0f, 3.0f, 6.0f);
+ TEST2 (_COM_DIVf, 6.0f, 2.0f, 3.0f);
+ TEST_CMP (_COM_CMPLTf, 1.0f, 2.0f, 1, 0, 0);
+ TEST_CMP (_COM_CMPGTf, 1.0f, 2.0f, 0, 0, 1);
+ TEST_CMP (_COM_CMPLEf, 1.0f, 2.0f, 1, 1, 0);
+ TEST_CMP (_COM_CMPGEf, 1.0f, 2.0f, 0, 1, 1);
+ TEST_CMP (_COM_CMPEQf, 1.0f, 2.0f, 0, 1, 0);
+ TEST_CMP (_COM_CMPNEf, 1.0f, 2.0f, 1, 0, 1);
+
+
+ TEST2 (_COM_MUL64, 2LL, 4LL, 8LL);
+ TEST2 (_COM_DIV64s, 6LL, 3LL, 2LL);
+ TEST2 (_COM_DIV64u, 6ULL, 3ULL, 2ULL);
+ TEST2 (_COM_SHLL64, 6LL, 3, 48LL);
+ TEST2 (_COM_SHLR64, 8LL, 2, 2LL);
+ TEST2 (_COM_SHAR64, -1LL, 2, -1LL);
+ TEST1 (_COM_CONVf64s, -2.0f, -2LL);
+ TEST1 (_COM_CONVf64u, 2.0f, 2ULL);
+ TEST1 (_COM_CONVd64s, -2.0, -2LL);
+ TEST1 (_COM_CONVd64u, 2.0, 2ULL);
+ TEST1 (_COM_CONV64sf, -2LL, -2.0f);
+ TEST1 (_COM_CONV64uf, 2ULL, 2.0f);
+ TEST1 (_COM_CONV64sd, -2LL, -2.0);
+ TEST1 (_COM_CONV64ud, 2ULL, 2.0);
+ TEST2 (_COM_MOD64s, 4LL, 3LL, 1LL);
+ TEST2 (_COM_MOD64u, 4ULL, 3ULL, 1ULL);
+ TEST_CMP (_COM_CMPLT64s, 1LL, 2LL, 1, 0, 0);
+ TEST_CMP (_COM_CMPLT64u, 1ULL, 2ULL, 1, 0, 0);
+ TEST_CMP (_COM_CMPGT64s, 1LL, 2LL, 0, 0, 1);
+ TEST_CMP (_COM_CMPGT64u, 1ULL, 2ULL, 0, 0, 1);
+ TEST_CMP (_COM_CMPLE64s, 1LL, 2LL, 1, 1, 0);
+ TEST_CMP (_COM_CMPLE64u, 1ULL, 2ULL, 1, 1, 0);
+ TEST_CMP (_COM_CMPGE64s, 1LL, 2LL, 0, 1, 1);
+ TEST_CMP (_COM_CMPGE64u, 1ULL, 2ULL, 0, 1, 1);
+ TEST_CMP (_COM_CMPEQ64, 1LL, 2LL, 0, 1, 0);
+ TEST_CMP (_COM_CMPNE64, 1LL, 2LL, 1, 0, 1);
+
+
+ TEST2 (_COM_ADDd, 1.0, 2.0, 3.0);
+ TEST2 (_COM_SUBd, 3.0, 2.0, 1.0);
+ TEST2 (_COM_MULd, 2.0, 3.0, 6.0);
+ TEST2 (_COM_DIVd, 6.0, 2.0, 3.0);
+ TEST1 (_COM_CONVd32s, -2.0, -2);
+ TEST1 (_COM_CONVd32u, -2.0, (unsigned) -2);
+ TEST1 (_COM_CONV32sd, -2, -2.0);
+ TEST1 (_COM_CONV32ud, 2, 2.0);
+ TEST1 (_COM_CONVfd, 2.0f, 2.0);
+ TEST1 (_COM_CONVdf, 2.0, 2.0f);
+ TEST1 (_COM_NEGd, -2.0, 2.0);
+ TEST_CMP (_COM_CMPLTd, 1.0, 2.0, 1, 0, 0);
+ TEST_CMP (_COM_CMPGTd, 1.0, 2.0, 0, 0, 1);
+ TEST_CMP (_COM_CMPLEd, 1.0, 2.0, 1, 1, 0);
+ TEST_CMP (_COM_CMPGEd, 1.0, 2.0, 0, 1, 1);
+ TEST_CMP (_COM_CMPEQd, 1.0, 2.0, 0, 1, 0);
+ TEST_CMP (_COM_CMPNEd, 1.0, 2.0, 1, 0, 1);
+
+#ifdef DEBUG
+ printf ("Tests finished\n");
+#endif
+ exit (0);
+}
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/rx.exp b/gcc-4.9/gcc/testsuite/gcc.target/rx/rx.exp
new file mode 100644
index 000000000..159add18b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/rx.exp
@@ -0,0 +1,43 @@
+# Copyright (C) 2008-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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't the right target.
+if { ![istarget rx-*-*] } 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 ""
+}
+
+# Initialize `dg'.
+dg-init
+
+# Find all tests
+set tests [lsort [find $srcdir/$subdir *.\[cS\]]]
+
+# Main loop.
+gcc-dg-runtest $tests $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/rx/zero-width-bitfield.c b/gcc-4.9/gcc/testsuite/gcc.target/rx/zero-width-bitfield.c
new file mode 100644
index 000000000..26cf5a2b5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.target/rx/zero-width-bitfield.c
@@ -0,0 +1,32 @@
+/* { dg-do run { xfail rx-*-* } } */
+/* { dg-skip-if "skipped until patch for generic zero=width bit-field handling is accepted" { rx-*-* } { "*" } { "" } } */
+/* { dg-options "-msim" } */
+/* Note: The -msim abiove is actually there to override the default
+ options which do not allow the GCC extension of zero-width bitfields. */
+
+extern void abort (void);
+extern void exit (int);
+
+struct S_zero
+{
+ int f1: 4;
+ int f2: 0;
+ short f3: 4;
+} S_zero;
+
+struct S_norm
+{
+ int f1: 4;
+ short f3: 4;
+} S_norm;
+
+
+int
+main (void)
+{
+ if (sizeof (S_zero) != 4 || sizeof (S_norm) != 8)
+ abort ();
+
+ exit (0);
+ return 0;
+}