aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.target/rx/builtins.c144
1 files changed, 144 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 ();
+}