OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [rx/] [builtins.c] - Blame information for rev 323

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 323 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-fno-ipa-cp-clone" } */
3
 
4
/* Verify that the RX specific builtin functions work.  */
5
 
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.  */
10
 
11
#include <stdlib.h>
12
#include <stdio.h>
13
 
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.  */
18
 
19
int saturate_add         (int, int)      __attribute__((__noinline__));
20
int exchange             (int, int)      __attribute__((__noinline__));
21
 
22
int
23
half_word_swap (int arg)
24
{
25
  return __builtin_rx_revw (arg);
26
}
27
 
28
int
29
saturate_add (int arg1, int arg2)
30
{
31
  arg1 += arg2;
32
  return __builtin_rx_sat (arg1);
33
}
34
 
35
int
36
exchange (int arg1, int arg2)
37
{
38
  arg1 = __builtin_rx_xchg (arg2);
39
  return arg1;
40
}
41
 
42
long
43
multiply_and_accumulate (long arg1, long arg2, long arg3)
44
{
45
  __builtin_rx_mvtaclo (0);
46
  __builtin_rx_mvtachi (0);
47
 
48
  __builtin_rx_mullo (arg1, arg2);
49
  __builtin_rx_mulhi (arg1, arg2);
50
  __builtin_rx_maclo (arg1, arg3);
51
  __builtin_rx_machi (arg1, arg3);
52
 
53
  __builtin_rx_racw (1);
54
 
55
  arg1 = __builtin_rx_mvfachi ();
56
  arg1 += __builtin_rx_mvfacmi ();
57
 
58
  return arg1;
59
}
60
 
61
int
62
rxround (float arg)
63
{
64
  return __builtin_rx_round (arg);
65
}
66
 
67
/* #define DEBUG 1 */
68
 
69
#ifdef DEBUG
70
#define CHECK_0ARG(func, result)                                        \
71
  if (func () != result)                                                \
72
    {                                                                   \
73
      printf (#func " () fails: %x not %x\n", func (), result);         \
74
      abort ();                                                         \
75
    }
76
 
77
#define CHECK_1ARG(func, arg, result)                                   \
78
  if (func (arg) != result)                                             \
79
    {                                                                   \
80
      printf (#func " (" #arg ") fails: %x not %x\n", func (arg), result); \
81
      abort ();                                                         \
82
    }
83
 
84
#define CHECK_2ARG(func, arg1, arg2, result)                            \
85
  if (func (arg1, arg2) != result)                                      \
86
    {                                                                   \
87
      printf (#func " (" #arg1 "," #arg2 ") fails: %x not %x\n",        \
88
              func (arg1, arg2), result);                               \
89
      abort ();                                                         \
90
    }
91
 
92
#define CHECK_3ARG(func, arg1, arg2, arg3, result)                      \
93
  if (func (arg1, arg2, arg3) != result)                                \
94
    {                                                                   \
95
      printf (#func " (" #arg1 "," #arg2 "," #arg3 ") fails: %x not %x\n",      \
96
              func (arg1, arg2, arg3), result);                         \
97
      abort ();                                                         \
98
    }
99
#else
100
#define CHECK_0ARG(func, result)                                        \
101
  if (func () != result)                                                \
102
    abort ();
103
 
104
#define CHECK_1ARG(func, arg, result)                                   \
105
  if (func (arg) != result)                                             \
106
    abort ();
107
 
108
#define CHECK_2ARG(func, arg1, arg2, result)                            \
109
  if (func (arg1, arg2) != result)                                      \
110
    abort ();
111
 
112
#define CHECK_3ARG(func, arg1, arg2, arg3, result)                      \
113
  if (func (arg1, arg2, arg3) != result)                                \
114
    abort ();
115
#endif
116
 
117
int
118
main (void)
119
{
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);
124
  return 0;
125
}
126
 
127
/* The following builtins are compiled but
128
   not executed because they need OS support.  */
129
 
130
void
131
rxbreak (void)
132
{
133
  __builtin_rx_brk ();
134
}
135
 
136
void
137
interrupt (void)
138
{
139
  __builtin_rx_int (0x12);
140
}
141
 
142
int
143
get_stack_pointer (void)
144
{
145
  return __builtin_rx_mvfc (2);
146
}
147
 
148
void
149
set_stack_pointer (int value)
150
{
151
  __builtin_rx_mvtc (2, value);
152
  __builtin_rx_mvtc (2, 0x1234);
153
}
154
 
155
void
156
wait (void)
157
{
158
  __builtin_rx_wait ();
159
}
160
 
161
void
162
rmpa (int * multiplicand, int * multiplier, int num)
163
{
164
  __builtin_rx_rmpa ();
165
}
166
 
167
void
168
set_interrupts (void)
169
{
170
  __builtin_mvtipl (3);
171
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.