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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [tg-tests.h] - Blame information for rev 801

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

Line No. Rev Author Line
1 689 jeremybenn
/* Test various type-generic builtins by calling "main_tests()".  */
2
 
3
#define FP_NAN 1
4
#define FP_INFINITE 2
5
#define FP_NORMAL 3
6
#define FP_SUBNORMAL 4
7
#define FP_ZERO 5
8
#define fpclassify(X) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (X))
9
 
10
void __attribute__ ((__noinline__))
11
foo_1 (float f, double d, long double ld,
12
       int res_unord, int res_isnan, int res_isinf,
13
       int res_isinf_sign, int res_isfin, int res_isnorm,
14
       int classification)
15
{
16
  if (__builtin_isunordered (f, 0) != res_unord)
17
    __builtin_abort ();
18
  if (__builtin_isunordered (0, f) != res_unord)
19
    __builtin_abort ();
20
  if (__builtin_isunordered (d, 0) != res_unord)
21
    __builtin_abort ();
22
  if (__builtin_isunordered (0, d) != res_unord)
23
    __builtin_abort ();
24
  if (__builtin_isunordered (ld, 0) != res_unord)
25
    __builtin_abort ();
26
  if (__builtin_isunordered (0, ld) != res_unord)
27
    __builtin_abort ();
28
 
29
  if (__builtin_isnan (f) != res_isnan)
30
    __builtin_abort ();
31
  if (__builtin_isnan (d) != res_isnan)
32
    __builtin_abort ();
33
  if (__builtin_isnan (ld) != res_isnan)
34
    __builtin_abort ();
35
  if (__builtin_isnanf (f) != res_isnan)
36
    __builtin_abort ();
37
  if (__builtin_isnanl (ld) != res_isnan)
38
    __builtin_abort ();
39
 
40
  if (__builtin_isinf (f) != res_isinf)
41
    __builtin_abort ();
42
  if (__builtin_isinf (d) != res_isinf)
43
    __builtin_abort ();
44
  if (__builtin_isinf (ld) != res_isinf)
45
    __builtin_abort ();
46
  if (__builtin_isinff (f) != res_isinf)
47
    __builtin_abort ();
48
  if (__builtin_isinfl (ld) != res_isinf)
49
    __builtin_abort ();
50
 
51
  if (__builtin_isinf_sign (f) != res_isinf_sign)
52
    __builtin_abort ();
53
  if (__builtin_isinf_sign (d) != res_isinf_sign)
54
    __builtin_abort ();
55
  if (__builtin_isinf_sign (ld) != res_isinf_sign)
56
    __builtin_abort ();
57
 
58
  if (__builtin_isnormal (f) != res_isnorm)
59
    __builtin_abort ();
60
  if (__builtin_isnormal (d) != res_isnorm)
61
    __builtin_abort ();
62
  if (__builtin_isnormal (ld) != res_isnorm)
63
    __builtin_abort ();
64
 
65
  if (__builtin_isfinite (f) != res_isfin)
66
    __builtin_abort ();
67
  if (__builtin_isfinite (d) != res_isfin)
68
    __builtin_abort ();
69
  if (__builtin_isfinite (ld) != res_isfin)
70
    __builtin_abort ();
71
 
72
  if (__builtin_finitef (f) != res_isfin)
73
    __builtin_abort ();
74
  if (__builtin_finite (f) != res_isfin)
75
    __builtin_abort ();
76
  if (__builtin_finite (d) != res_isfin)
77
    __builtin_abort ();
78
  if (__builtin_finitel (d) != res_isfin)
79
    __builtin_abort ();
80
  if (__builtin_finitel (ld) != res_isfin)
81
    __builtin_abort ();
82
 
83
  /* Subnormals can abruptly underflow to zero in unsafe math
84
     mode, so bypass testing these numbers if necessary.  */
85
#ifdef UNSAFE
86
  if (classification != FP_SUBNORMAL)
87
#endif
88
    {
89
      if (fpclassify(f) != classification)
90
        __builtin_abort ();
91
      if (fpclassify(d) != classification)
92
        __builtin_abort ();
93
      if (fpclassify(ld) != classification)
94
        __builtin_abort ();
95
    }
96
}
97
 
98
void __attribute__ ((__noinline__))
99
foo (float f, double d, long double ld,
100
     int res_unord, int res_isnan, int res_isinf,
101
     int res_isfin, int res_isnorm, int classification)
102
{
103
  foo_1 (f, d, ld, res_unord, res_isnan, res_isinf, res_isinf, res_isfin, res_isnorm, classification);
104
  /* Try all the values negated as well.  */
105
  foo_1 (-f, -d, -ld, res_unord, res_isnan, res_isinf, -res_isinf, res_isfin, res_isnorm, classification);
106
}
107
 
108
int __attribute__ ((__noinline__))
109
main_tests (void)
110
{
111
  volatile float f;
112
  volatile double d;
113
  volatile long double ld;
114
 
115
  /* Test NaN.  */
116
  f = __builtin_nanf(""); d = __builtin_nan(""); ld = __builtin_nanl("");
117
  foo(f, d, ld, /*unord=*/ 1, /*isnan=*/ 1, /*isinf=*/ 0, /*isfin=*/ 0, /*isnorm=*/ 0, FP_NAN);
118
 
119
  /* Test infinity.  */
120
  f = __builtin_inff(); d = __builtin_inf(); ld = __builtin_infl();
121
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE);
122
 
123
  /* Test zero.  */
124
  f = 0; d = 0; ld = 0;
125
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_ZERO);
126
 
127
  /* Test one.  */
128
  f = 1; d = 1; ld = 1;
129
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL);
130
 
131
  /* Test minimum values.  */
132
  f = __FLT_MIN__; d = __DBL_MIN__; ld = __LDBL_MIN__;
133
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL);
134
 
135
  /* Test subnormal values.  */
136
  f = __FLT_MIN__/2; d = __DBL_MIN__/2; ld = __LDBL_MIN__/2;
137
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_SUBNORMAL);
138
 
139
  /* Test maximum values.  */
140
  f = __FLT_MAX__; d = __DBL_MAX__; ld = __LDBL_MAX__;
141
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL);
142
 
143
  /* Test overflow values.  */
144
  f = __FLT_MAX__*2; d = __DBL_MAX__*2; ld = __LDBL_MAX__*2;
145
  foo(f, d, ld, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE);
146
 
147
  return 0;
148
}

powered by: WebSVN 2.1.0

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