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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [fp-int-convert.h] - Blame information for rev 853

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test floating-point conversions.  */
2
/* Origin: Joseph Myers <joseph@codesourcery.com> */
3
 
4
#include <limits.h>
5
extern void abort (void);
6
extern void exit (int);
7
 
8
/* Not all platforms support TImode integers; logic as in
9
   gcc.dg/titype-1.c.  */
10
#if defined(__LP64__) && !defined(__hppa__)
11
typedef int TItype __attribute__ ((mode (TI)));
12
typedef unsigned int UTItype __attribute__ ((mode (TI)));
13
#else
14
typedef long TItype;
15
typedef unsigned long UTItype;
16
#endif
17
 
18
/* TEST_I_F(I, U, F, P) tests conversions between the pair of signed
19
   and unsigned integer types I and U and the floating-point type F,
20
   where P is the binary precision of the floating point type.  We
21
   test conversions of the values 0, 1, 0x7...f, 0x8...0, 0xf...f.  We
22
   also test conversions of values half way inbetween two
23
   representable values (rounding both ways), just above half way, and
24
   just below half way.  */
25
#define TEST_I_F(I, U, F, P)                                    \
26
do {                                                            \
27
  TEST_I_F_VAL (I, F, (I)0, 1);                                  \
28
  TEST_I_F_VAL (I, F, (I)1, 1);                                 \
29
  TEST_I_F_VAL (I, F, (I)(((U)~(U)0) >> 1), P_OK1 (P, I));       \
30
  TEST_I_F_VAL (I, F, (I)(U)~(((U)~(U)0) >> 1), 1);              \
31
  TEST_I_F_VAL (I, F, (I)(U)~(U)0, P_OK (P, I));         \
32
  TEST_I_F_VAL (I, F, HVAL0S (P, I), P_OK (P, I));              \
33
  TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I));          \
34
  TEST_I_F_VAL (I, F, HVAL0S (P, I) - 1, P_OK (P, I));          \
35
  TEST_I_F_VAL (I, F, HVAL1S (P, I), P_OK (P, I));              \
36
  TEST_I_F_VAL (I, F, HVAL1S (P, I) + 1, P_OK (P, I));          \
37
  TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I));          \
38
  TEST_I_F_VAL (I, F, -HVAL0S (P, I), P_OK (P, I));             \
39
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) + 1, P_OK (P, I));         \
40
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I));         \
41
  TEST_I_F_VAL (I, F, -HVAL1S (P, I), P_OK (P, I));             \
42
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I));         \
43
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) - 1, P_OK (P, I));         \
44
  TEST_I_F_VAL (U, F, (U)0, 1);                                  \
45
  TEST_I_F_VAL (U, F, (U)1, 1);                                 \
46
  TEST_I_F_VAL (U, F, (U)(((U)~(U)0) >> 1), P_OK1 (P, U));       \
47
  TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1);         \
48
  TEST_I_F_VAL (U, F, (U)~(U)0, P_OK (P, U));                    \
49
  TEST_I_F_VAL (U, F, HVAL0U (P, U), P_OK (P, U));              \
50
  TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U));          \
51
  TEST_I_F_VAL (U, F, HVAL0U (P, U) - 1, P_OK (P, U));          \
52
  TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U));              \
53
  TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U));          \
54
  TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U));          \
55
} while (0)
56
 
57
#define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT)
58
#define P_OK1(P, T) ((P) >= sizeof(T) * CHAR_BIT - 1)
59
#define HVAL0U(P, U) (U)(P_OK (P, U)                                     \
60
                         ? (U)1                                          \
61
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
62
                            + ((U)1 << (sizeof(U) * CHAR_BIT - 1 - P))))
63
#define HVAL1U(P, U) (U)(P_OK (P, U)                                     \
64
                         ? (U)1                                          \
65
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
66
                            + ((U)3 << (sizeof(U) * CHAR_BIT - 1 - P))))
67
#define HVAL0S(P, S) (S)(P_OK1 (P, S)                                    \
68
                         ? (S)1                                          \
69
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
70
                            + ((S)1 << (sizeof(S) * CHAR_BIT - 2 - P))))
71
#define HVAL1S(P, S) (S)(P_OK1 (P, S)                                    \
72
                         ? (S)1                                          \
73
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
74
                            + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P))))
75
 
76
#define TEST_I_F_VAL(IT, FT, VAL, PREC_OK)              \
77
do {                                                    \
78
  static volatile IT ivin, ivout;                       \
79
  static volatile FT fv1, fv2;                          \
80
  ivin = (VAL);                                         \
81
  fv1 = (VAL);                                          \
82
  fv2 = ivin;                                           \
83
  ivout = fv2;                                          \
84
  if (ivin != (VAL)                                     \
85
      || ((PREC_OK) && ivout != ivin)                   \
86
      || ((PREC_OK) && ivout != (VAL))                  \
87
      || fv1 != (VAL) || fv2 != (VAL) || fv1 != fv2)    \
88
    abort ();                                           \
89
} while (0)

powered by: WebSVN 2.1.0

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