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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [fp-int-convert.h] - Diff between revs 149 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
/* Test floating-point conversions.  */
/* Test floating-point conversions.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
 
 
#include <limits.h>
#include <limits.h>
extern void abort (void);
extern void abort (void);
extern void exit (int);
extern void exit (int);
 
 
/* Not all platforms support TImode integers; logic as in
/* Not all platforms support TImode integers; logic as in
   gcc.dg/titype-1.c.  */
   gcc.dg/titype-1.c.  */
#if defined(__LP64__) && !defined(__hppa__)
#if defined(__LP64__) && !defined(__hppa__)
typedef int TItype __attribute__ ((mode (TI)));
typedef int TItype __attribute__ ((mode (TI)));
typedef unsigned int UTItype __attribute__ ((mode (TI)));
typedef unsigned int UTItype __attribute__ ((mode (TI)));
#else
#else
typedef long TItype;
typedef long TItype;
typedef unsigned long UTItype;
typedef unsigned long UTItype;
#endif
#endif
 
 
/* TEST_I_F(I, U, F, P) tests conversions between the pair of signed
/* TEST_I_F(I, U, F, P) tests conversions between the pair of signed
   and unsigned integer types I and U and the floating-point type F,
   and unsigned integer types I and U and the floating-point type F,
   where P is the binary precision of the floating point type.  We
   where P is the binary precision of the floating point type.  We
   test conversions of the values 0, 1, 0x7...f, 0x8...0, 0xf...f.  We
   test conversions of the values 0, 1, 0x7...f, 0x8...0, 0xf...f.  We
   also test conversions of values half way inbetween two
   also test conversions of values half way inbetween two
   representable values (rounding both ways), just above half way, and
   representable values (rounding both ways), just above half way, and
   just below half way.  */
   just below half way.  */
#define TEST_I_F(I, U, F, P)                                    \
#define TEST_I_F(I, U, F, P)                                    \
do {                                                            \
do {                                                            \
  TEST_I_F_VAL (I, F, (I)0, 1);                                  \
  TEST_I_F_VAL (I, F, (I)0, 1);                                  \
  TEST_I_F_VAL (I, F, (I)1, 1);                                 \
  TEST_I_F_VAL (I, F, (I)1, 1);                                 \
  TEST_I_F_VAL (I, F, (I)(((U)~(U)0) >> 1), P_OK1 (P, I));       \
  TEST_I_F_VAL (I, F, (I)(((U)~(U)0) >> 1), P_OK1 (P, I));       \
  TEST_I_F_VAL (I, F, (I)(U)~(((U)~(U)0) >> 1), 1);              \
  TEST_I_F_VAL (I, F, (I)(U)~(((U)~(U)0) >> 1), 1);              \
  TEST_I_F_VAL (I, F, (I)(U)~(U)0, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, (I)(U)~(U)0, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, HVAL0S (P, I), P_OK (P, I));              \
  TEST_I_F_VAL (I, F, HVAL0S (P, I), P_OK (P, I));              \
  TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL0S (P, I) - 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL0S (P, I) - 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL1S (P, I), P_OK (P, I));              \
  TEST_I_F_VAL (I, F, HVAL1S (P, I), P_OK (P, I));              \
  TEST_I_F_VAL (I, F, HVAL1S (P, I) + 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL1S (P, I) + 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I));          \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I), P_OK (P, I));             \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I), P_OK (P, I));             \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) + 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) + 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I), P_OK (P, I));             \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I), P_OK (P, I));             \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) - 1, P_OK (P, I));         \
  TEST_I_F_VAL (I, F, -HVAL1S (P, I) - 1, P_OK (P, I));         \
  TEST_I_F_VAL (U, F, (U)0, 1);                                  \
  TEST_I_F_VAL (U, F, (U)0, 1);                                  \
  TEST_I_F_VAL (U, F, (U)1, 1);                                 \
  TEST_I_F_VAL (U, F, (U)1, 1);                                 \
  TEST_I_F_VAL (U, F, (U)(((U)~(U)0) >> 1), P_OK1 (P, U));       \
  TEST_I_F_VAL (U, F, (U)(((U)~(U)0) >> 1), P_OK1 (P, U));       \
  TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1);         \
  TEST_I_F_VAL (U, F, (U)~(((U)~(U)0) >> 1), 1);         \
  TEST_I_F_VAL (U, F, (U)~(U)0, P_OK (P, U));                    \
  TEST_I_F_VAL (U, F, (U)~(U)0, P_OK (P, U));                    \
  TEST_I_F_VAL (U, F, HVAL0U (P, U), P_OK (P, U));              \
  TEST_I_F_VAL (U, F, HVAL0U (P, U), P_OK (P, U));              \
  TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL0U (P, U) - 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL0U (P, U) - 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U));              \
  TEST_I_F_VAL (U, F, HVAL1U (P, U), P_OK (P, U));              \
  TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL1U (P, U) + 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U));          \
  TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U));          \
} while (0)
} while (0)
 
 
#define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT)
#define P_OK(P, T) ((P) >= sizeof(T) * CHAR_BIT)
#define P_OK1(P, T) ((P) >= sizeof(T) * CHAR_BIT - 1)
#define P_OK1(P, T) ((P) >= sizeof(T) * CHAR_BIT - 1)
#define HVAL0U(P, U) (U)(P_OK (P, U)                                     \
#define HVAL0U(P, U) (U)(P_OK (P, U)                                     \
                         ? (U)1                                          \
                         ? (U)1                                          \
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
                            + ((U)1 << (sizeof(U) * CHAR_BIT - 1 - P))))
                            + ((U)1 << (sizeof(U) * CHAR_BIT - 1 - P))))
#define HVAL1U(P, U) (U)(P_OK (P, U)                                     \
#define HVAL1U(P, U) (U)(P_OK (P, U)                                     \
                         ? (U)1                                          \
                         ? (U)1                                          \
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
                         : (((U)1 << (sizeof(U) * CHAR_BIT - 1))         \
                            + ((U)3 << (sizeof(U) * CHAR_BIT - 1 - P))))
                            + ((U)3 << (sizeof(U) * CHAR_BIT - 1 - P))))
#define HVAL0S(P, S) (S)(P_OK1 (P, S)                                    \
#define HVAL0S(P, S) (S)(P_OK1 (P, S)                                    \
                         ? (S)1                                          \
                         ? (S)1                                          \
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
                            + ((S)1 << (sizeof(S) * CHAR_BIT - 2 - P))))
                            + ((S)1 << (sizeof(S) * CHAR_BIT - 2 - P))))
#define HVAL1S(P, S) (S)(P_OK1 (P, S)                                    \
#define HVAL1S(P, S) (S)(P_OK1 (P, S)                                    \
                         ? (S)1                                          \
                         ? (S)1                                          \
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
                         : (((S)1 << (sizeof(S) * CHAR_BIT - 2))         \
                            + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P))))
                            + ((S)3 << (sizeof(S) * CHAR_BIT - 2 - P))))
 
 
#define TEST_I_F_VAL(IT, FT, VAL, PREC_OK)              \
#define TEST_I_F_VAL(IT, FT, VAL, PREC_OK)              \
do {                                                    \
do {                                                    \
  static volatile IT ivin, ivout;                       \
  static volatile IT ivin, ivout;                       \
  static volatile FT fv1, fv2;                          \
  static volatile FT fv1, fv2;                          \
  ivin = (VAL);                                         \
  ivin = (VAL);                                         \
  fv1 = (VAL);                                          \
  fv1 = (VAL);                                          \
  fv2 = ivin;                                           \
  fv2 = ivin;                                           \
  ivout = fv2;                                          \
  ivout = fv2;                                          \
  if (ivin != (VAL)                                     \
  if (ivin != (VAL)                                     \
      || ((PREC_OK) && ivout != ivin)                   \
      || ((PREC_OK) && ivout != ivin)                   \
      || ((PREC_OK) && ivout != (VAL))                  \
      || ((PREC_OK) && ivout != (VAL))                  \
      || fv1 != (VAL) || fv2 != (VAL) || fv1 != fv2)    \
      || fv1 != (VAL) || fv2 != (VAL) || fv1 != fv2)    \
    abort ();                                           \
    abort ();                                           \
} while (0)
} while (0)
 
 

powered by: WebSVN 2.1.0

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