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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [fixed-point/] [binary.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=gnu99" } */
3
 
4
/* N1169 6.5.7 - Bitwise shift operands.
5
   C99 6.5.5 Multiplicative operators.
6
   C99 6.5.6 Additive operators.
7
   C99 6.5.7 Bitwise shift operators.
8
   C99 6.5.8 Relational operators.
9
   C99 6.5.9 Equality operators.
10
   C99 6.5.16 Assignment operators.
11
 
12
   Check binary operators + - * / << >> < <= >= > == != += -= *= /= <<= >>=.  */
13
 
14
extern void abort (void);
15
 
16
#define BINARY(TYPE,POSTFIX) \
17
  { TYPE a = 0.5 ## POSTFIX; \
18
    TYPE b = 0.25 ## POSTFIX; \
19
    if (a + b != 0.75 ## POSTFIX) \
20
      abort(); \
21
    if (a - b != 0.25 ## POSTFIX) \
22
      abort(); \
23
    if (a * b != 0.125 ## POSTFIX) \
24
      abort(); \
25
    if (b / a != 0.5 ## POSTFIX) \
26
      abort(); \
27
    if (b << 1 != a) \
28
      abort(); \
29
    if (a >> 1 != b) \
30
      abort(); \
31
    if (a < b != 0) \
32
      abort(); \
33
    if (a <= b != 0) \
34
      abort(); \
35
    if (a > b != 1) \
36
      abort(); \
37
    if (a >= b != 1) \
38
      abort(); \
39
    if (a == b != 0) \
40
      abort(); \
41
    if (a != b != 1) \
42
      abort(); \
43
    a += b; \
44
    if (a != 0.75 ## POSTFIX) \
45
      abort(); \
46
    a -= b; \
47
    if (a != 0.5 ## POSTFIX) \
48
      abort(); \
49
    a *= b; \
50
    if (a != 0.125 ## POSTFIX) \
51
      abort(); \
52
    a /= b; \
53
    if (a != 0.5 ## POSTFIX) \
54
      abort(); \
55
    a >>= 2; \
56
    if (a != 0.125 ## POSTFIX) \
57
      abort(); \
58
    a <<= 1; \
59
    if (a != 0.25 ## POSTFIX) \
60
      abort(); \
61
  }
62
 
63
#define FRACT_SAT_BINARY(TYPE,POSTFIX) \
64
  { TYPE a = 0.7 ## POSTFIX; \
65
    TYPE b = 0.9 ## POSTFIX; \
66
    if (a + b != 1.0 ## POSTFIX) \
67
      abort(); \
68
    a = -0.7 ## POSTFIX; \
69
    b = -0.9 ## POSTFIX; \
70
    if (a + b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
71
      abort(); \
72
    a = 0.7 ## POSTFIX; \
73
    b = -0.9 ## POSTFIX; \
74
    if (a - b != 1.0 ## POSTFIX) \
75
      abort(); \
76
    a = -0.7 ## POSTFIX; \
77
    b = 0.9 ## POSTFIX; \
78
    if (a - b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
79
      abort(); \
80
    a = -0.5 ## POSTFIX - 0.5 ## POSTFIX; \
81
    if (a * a != 1.0 ## POSTFIX) \
82
      abort(); \
83
    a = 0.8 ## POSTFIX; \
84
    b = 0.5 ## POSTFIX; \
85
    if (a / b != 1.0 ## POSTFIX) \
86
      abort(); \
87
    a = -0.8 ## POSTFIX; \
88
    b = 0.5 ## POSTFIX; \
89
    if (a / b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
90
      abort(); \
91
    a = 0.1 ## POSTFIX; \
92
    if (a << 4 != 1.0 ## POSTFIX) \
93
      abort(); \
94
    a = -0.8 ## POSTFIX; \
95
    if (a << 4 != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
96
      abort(); \
97
  }
98
 
99
#define FRACT_SAT_UNS_BINARY(TYPE,POSTFIX) \
100
  { TYPE a = 0.7 ## POSTFIX; \
101
    TYPE b = 0.9 ## POSTFIX; \
102
    if (a + b != 1.0 ## POSTFIX) \
103
      abort(); \
104
    if (a - b != 0.0 ## POSTFIX) \
105
      abort(); \
106
    if (b / a != 1.0 ## POSTFIX) \
107
      abort(); \
108
    if (a << 1 != 1.0 ## POSTFIX) \
109
      abort(); \
110
  }
111
 
112
int main ()
113
{
114
  BINARY(short _Fract, hr);
115
  BINARY(_Fract, r);
116
  BINARY(long _Fract, lr);
117
  BINARY(long long _Fract, llr);
118
  BINARY(unsigned short _Fract, uhr);
119
  BINARY(unsigned _Fract, ur);
120
  BINARY(unsigned long _Fract, ulr);
121
  BINARY(unsigned long long _Fract, ullr);
122
  BINARY(_Sat short _Fract, hr);
123
  BINARY(_Sat _Fract, r);
124
  BINARY(_Sat long _Fract, lr);
125
  BINARY(_Sat long long _Fract, llr);
126
  BINARY(_Sat unsigned short _Fract, uhr);
127
  BINARY(_Sat unsigned _Fract, ur);
128
  BINARY(_Sat unsigned long _Fract, ulr);
129
  BINARY(_Sat unsigned long long _Fract, ullr);
130
  BINARY(short _Accum, hk);
131
  BINARY(_Accum, k);
132
  BINARY(long _Accum, lk);
133
  BINARY(long long _Accum, llk);
134
  BINARY(unsigned short _Accum, uhk);
135
  BINARY(unsigned _Accum, uk);
136
  BINARY(unsigned long _Accum, ulk);
137
  BINARY(unsigned long long _Accum, ullk);
138
  BINARY(_Sat short _Accum, hk);
139
  BINARY(_Sat _Accum, k);
140
  BINARY(_Sat long _Accum, lk);
141
  BINARY(_Sat long long _Accum, llk);
142
  BINARY(_Sat unsigned short _Accum, uhk);
143
  BINARY(_Sat unsigned _Accum, uk);
144
  BINARY(_Sat unsigned long _Accum, ulk);
145
  BINARY(_Sat unsigned long long _Accum, ullk);
146
 
147
  FRACT_SAT_BINARY(_Sat short _Fract, hr);
148
  FRACT_SAT_BINARY(_Sat _Fract, r);
149
  FRACT_SAT_BINARY(_Sat long _Fract, lr);
150
  FRACT_SAT_BINARY(_Sat long long _Fract, llr);
151
 
152
  FRACT_SAT_UNS_BINARY(_Sat unsigned short _Fract, uhr);
153
  FRACT_SAT_UNS_BINARY(_Sat unsigned _Fract, ur);
154
  FRACT_SAT_UNS_BINARY(_Sat unsigned long _Fract, ulr);
155
  FRACT_SAT_UNS_BINARY(_Sat unsigned long long _Fract, ullr);
156
 
157
  return 0;
158
}

powered by: WebSVN 2.1.0

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