2 /* { dg-options "-fno-ipa-cp-clone" } */
4 /* Verify that the RX specific builtin functions work. */
6 /* IPA CP cloning is disabled because the constant propagation
7 has no understanding of the saturation behaviour of the
8 __builtin_rx_sat function and so it will optimize away the
9 saturation addition test. */
14 /* We need to prevent these functions from being inlined
15 as otherwise gcc will attempt to optimize away their
16 arguments and we need the operations on them in order
17 to correctly set the psw flags. */
19 int saturate_add (int, int) __attribute__((__noinline__));
20 int exchange (int, int) __attribute__((__noinline__));
23 half_word_swap (int arg)
25 return __builtin_rx_revw (arg);
29 saturate_add (int arg1, int arg2)
32 return __builtin_rx_sat (arg1);
36 exchange (int arg1, int arg2)
38 arg1 = __builtin_rx_xchg (arg2);
43 multiply_and_accumulate (long arg1, long arg2, long arg3)
45 __builtin_rx_mvtaclo (0);
46 __builtin_rx_mvtachi (0);
48 __builtin_rx_mullo (arg1, arg2);
49 __builtin_rx_mulhi (arg1, arg2);
50 __builtin_rx_maclo (arg1, arg3);
51 __builtin_rx_machi (arg1, arg3);
53 __builtin_rx_racw (1);
55 arg1 = __builtin_rx_mvfachi ();
56 arg1 += __builtin_rx_mvfacmi ();
64 return __builtin_rx_round (arg);
70 #define CHECK_0ARG(func, result) \
71 if (func () != result) \
73 printf (#func " () fails: %x not %x\n", func (), result); \
77 #define CHECK_1ARG(func, arg, result) \
78 if (func (arg) != result) \
80 printf (#func " (" #arg ") fails: %x not %x\n", func (arg), result); \
84 #define CHECK_2ARG(func, arg1, arg2, result) \
85 if (func (arg1, arg2) != result) \
87 printf (#func " (" #arg1 "," #arg2 ") fails: %x not %x\n", \
88 func (arg1, arg2), result); \
92 #define CHECK_3ARG(func, arg1, arg2, arg3, result) \
93 if (func (arg1, arg2, arg3) != result) \
95 printf (#func " (" #arg1 "," #arg2 "," #arg3 ") fails: %x not %x\n", \
96 func (arg1, arg2, arg3), result); \
100 #define CHECK_0ARG(func, result) \
101 if (func () != result) \
104 #define CHECK_1ARG(func, arg, result) \
105 if (func (arg) != result) \
108 #define CHECK_2ARG(func, arg1, arg2, result) \
109 if (func (arg1, arg2) != result) \
112 #define CHECK_3ARG(func, arg1, arg2, arg3, result) \
113 if (func (arg1, arg2, arg3) != result) \
120 CHECK_1ARG (half_word_swap, 0x12345678, 0x34127856);
121 CHECK_2ARG (saturate_add, 0x80000000, 0x80000000, 0x80000000);
122 CHECK_3ARG (multiply_and_accumulate, 0x111, 0x222, 0x333, 0x70007);
123 CHECK_1ARG (rxround, 0.5, 1);
127 /* The following builtins are compiled but
128 not executed because they need OS support. */
139 __builtin_rx_int (0x12);
143 get_stack_pointer (void)
145 return __builtin_rx_mvfc (2);
149 set_stack_pointer (int value)
151 __builtin_rx_mvtc (2, value);
152 __builtin_rx_mvtc (2, 0x1234);
158 __builtin_rx_wait ();
162 rmpa (int * multiplicand, int * multiplier, int num)
164 __builtin_rx_rmpa ();
168 set_interrupts (void)
170 __builtin_mvtipl (3);