OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [m68k/] [math-68881.h] - Diff between revs 38 and 154

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

Rev 38 Rev 154
/******************************************************************\
/******************************************************************\
*                                                                  *
*                                                                  *
*  <math-68881.h>               last modified: 23 May 1992.        *
*  <math-68881.h>               last modified: 23 May 1992.        *
*                                                                  *
*                                                                  *
*  Copyright (C) 1989 by Matthew Self.                             *
*  Copyright (C) 1989 by Matthew Self.                             *
*  You may freely distribute verbatim copies of this software      *
*  You may freely distribute verbatim copies of this software      *
*  provided that this copyright notice is retained in all copies.  *
*  provided that this copyright notice is retained in all copies.  *
*  You may distribute modifications to this software under the     *
*  You may distribute modifications to this software under the     *
*  conditions above if you also clearly note such modifications    *
*  conditions above if you also clearly note such modifications    *
*  with their author and date.                                     *
*  with their author and date.                                     *
*                                                                  *
*                                                                  *
*  Note:  errno is not set to EDOM when domain errors occur for    *
*  Note:  errno is not set to EDOM when domain errors occur for    *
*  most of these functions.  Rather, it is assumed that the        *
*  most of these functions.  Rather, it is assumed that the        *
*  68881's OPERR exception will be enabled and handled             *
*  68881's OPERR exception will be enabled and handled             *
*  appropriately by the operating system.  Similarly, overflow     *
*  appropriately by the operating system.  Similarly, overflow     *
*  and underflow do not set errno to ERANGE.                       *
*  and underflow do not set errno to ERANGE.                       *
*                                                                  *
*                                                                  *
*  Send bugs to Matthew Self (self@bayes.arc.nasa.gov).            *
*  Send bugs to Matthew Self (self@bayes.arc.nasa.gov).            *
*                                                                  *
*                                                                  *
\******************************************************************/
\******************************************************************/
 
 
/* This file is NOT a part of GCC, just distributed with it.  */
/* This file is NOT a part of GCC, just distributed with it.  */
 
 
/* If you find this in GCC,
/* If you find this in GCC,
   please send bug reports to bug-gcc@prep.ai.mit.edu.  */
   please send bug reports to bug-gcc@prep.ai.mit.edu.  */
 
 
/* Changed by Richard Stallman:
/* Changed by Richard Stallman:
   May 1993, add conditional to prevent multiple inclusion.
   May 1993, add conditional to prevent multiple inclusion.
   % inserted before a #.
   % inserted before a #.
   New function `hypot' added.
   New function `hypot' added.
   Nans written in hex to avoid 0rnan.
   Nans written in hex to avoid 0rnan.
   May 1992, use %! for fpcr register.  Break lines before function names.
   May 1992, use %! for fpcr register.  Break lines before function names.
   December 1989, add parens around `&' in pow.
   December 1989, add parens around `&' in pow.
   November 1990, added alternate definition of HUGE_VAL for Sun.  */
   November 1990, added alternate definition of HUGE_VAL for Sun.  */
 
 
/* Changed by Jim Wilson:
/* Changed by Jim Wilson:
   September 1993, Use #undef before HUGE_VAL instead of #ifdef/#endif.  */
   September 1993, Use #undef before HUGE_VAL instead of #ifdef/#endif.  */
 
 
/* Changed by Ian Lance Taylor:
/* Changed by Ian Lance Taylor:
   September 1994, use extern inline instead of static inline.  */
   September 1994, use extern inline instead of static inline.  */
 
 
#ifndef __math_68881
#ifndef __math_68881
#define __math_68881
#define __math_68881
 
 
#include <errno.h>
#include <errno.h>
 
 
#undef HUGE_VAL
#undef HUGE_VAL
#ifdef __sun__
#ifdef __sun__
/* The Sun assembler fails to handle the hex constant in the usual defn.  */
/* The Sun assembler fails to handle the hex constant in the usual defn.  */
#define HUGE_VAL                                                        \
#define HUGE_VAL                                                        \
({                                                                      \
({                                                                      \
  static union { int i[2]; double d; } u = { {0x7ff00000, 0} };          \
  static union { int i[2]; double d; } u = { {0x7ff00000, 0} };          \
  u.d;                                                                  \
  u.d;                                                                  \
})
})
#else
#else
#define HUGE_VAL                                                        \
#define HUGE_VAL                                                        \
({                                                                      \
({                                                                      \
  double huge_val;                                                      \
  double huge_val;                                                      \
                                                                        \
                                                                        \
  __asm ("fmove%.d #0x7ff0000000000000,%0"      /* Infinity */          \
  __asm ("fmove%.d #0x7ff0000000000000,%0"      /* Infinity */          \
         : "=f" (huge_val)                                              \
         : "=f" (huge_val)                                              \
         : /* no inputs */);                                            \
         : /* no inputs */);                                            \
  huge_val;                                                             \
  huge_val;                                                             \
})
})
#endif
#endif
 
 
__inline extern double
__inline extern double
sin (double x)
sin (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fsin%.x %1,%0"
  __asm ("fsin%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
cos (double x)
cos (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fcos%.x %1,%0"
  __asm ("fcos%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
tan (double x)
tan (double x)
{
{
  double value;
  double value;
 
 
  __asm ("ftan%.x %1,%0"
  __asm ("ftan%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
asin (double x)
asin (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fasin%.x %1,%0"
  __asm ("fasin%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
acos (double x)
acos (double x)
{
{
  double value;
  double value;
 
 
  __asm ("facos%.x %1,%0"
  __asm ("facos%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
atan (double x)
atan (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fatan%.x %1,%0"
  __asm ("fatan%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
atan2 (double y, double x)
atan2 (double y, double x)
{
{
  double pi, pi_over_2;
  double pi, pi_over_2;
 
 
  __asm ("fmovecr%.x #0,%0"             /* extended precision pi */
  __asm ("fmovecr%.x #0,%0"             /* extended precision pi */
         : "=f" (pi)
         : "=f" (pi)
         : /* no inputs */ );
         : /* no inputs */ );
  __asm ("fscale%.b #-1,%0"             /* no loss of accuracy */
  __asm ("fscale%.b #-1,%0"             /* no loss of accuracy */
         : "=f" (pi_over_2)
         : "=f" (pi_over_2)
         : "0" (pi));
         : "0" (pi));
  if (x > 0)
  if (x > 0)
    {
    {
      if (y > 0)
      if (y > 0)
        {
        {
          if (x > y)
          if (x > y)
            return atan (y / x);
            return atan (y / x);
          else
          else
            return pi_over_2 - atan (x / y);
            return pi_over_2 - atan (x / y);
        }
        }
      else
      else
        {
        {
          if (x > -y)
          if (x > -y)
            return atan (y / x);
            return atan (y / x);
          else
          else
            return - pi_over_2 - atan (x / y);
            return - pi_over_2 - atan (x / y);
        }
        }
    }
    }
  else
  else
    {
    {
      if (y < 0)
      if (y < 0)
        {
        {
          if (-x > -y)
          if (-x > -y)
            return - pi + atan (y / x);
            return - pi + atan (y / x);
          else
          else
            return - pi_over_2 - atan (x / y);
            return - pi_over_2 - atan (x / y);
        }
        }
      else
      else
        {
        {
          if (-x > y)
          if (-x > y)
            return pi + atan (y / x);
            return pi + atan (y / x);
          else if (y > 0)
          else if (y > 0)
            return pi_over_2 - atan (x / y);
            return pi_over_2 - atan (x / y);
          else
          else
            {
            {
              double value;
              double value;
 
 
              errno = EDOM;
              errno = EDOM;
              __asm ("fmove%.d #0x7fffffffffffffff,%0"  /* quiet NaN */
              __asm ("fmove%.d #0x7fffffffffffffff,%0"  /* quiet NaN */
                     : "=f" (value)
                     : "=f" (value)
                     : /* no inputs */);
                     : /* no inputs */);
              return value;
              return value;
            }
            }
        }
        }
    }
    }
}
}
 
 
__inline extern double
__inline extern double
sinh (double x)
sinh (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fsinh%.x %1,%0"
  __asm ("fsinh%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
cosh (double x)
cosh (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fcosh%.x %1,%0"
  __asm ("fcosh%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
tanh (double x)
tanh (double x)
{
{
  double value;
  double value;
 
 
  __asm ("ftanh%.x %1,%0"
  __asm ("ftanh%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
atanh (double x)
atanh (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fatanh%.x %1,%0"
  __asm ("fatanh%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
exp (double x)
exp (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fetox%.x %1,%0"
  __asm ("fetox%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
expm1 (double x)
expm1 (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fetoxm1%.x %1,%0"
  __asm ("fetoxm1%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
log (double x)
log (double x)
{
{
  double value;
  double value;
 
 
  __asm ("flogn%.x %1,%0"
  __asm ("flogn%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
log1p (double x)
log1p (double x)
{
{
  double value;
  double value;
 
 
  __asm ("flognp1%.x %1,%0"
  __asm ("flognp1%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
log10 (double x)
log10 (double x)
{
{
  double value;
  double value;
 
 
  __asm ("flog10%.x %1,%0"
  __asm ("flog10%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
sqrt (double x)
sqrt (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fsqrt%.x %1,%0"
  __asm ("fsqrt%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
hypot (double x, double y)
hypot (double x, double y)
{
{
  return sqrt (x*x + y*y);
  return sqrt (x*x + y*y);
}
}
 
 
__inline extern double
__inline extern double
pow (double x, double y)
pow (double x, double y)
{
{
  if (x > 0)
  if (x > 0)
    return exp (y * log (x));
    return exp (y * log (x));
  else if (x == 0)
  else if (x == 0)
    {
    {
      if (y > 0)
      if (y > 0)
        return 0.0;
        return 0.0;
      else
      else
        {
        {
          double value;
          double value;
 
 
          errno = EDOM;
          errno = EDOM;
          __asm ("fmove%.d #0x7fffffffffffffff,%0"              /* quiet NaN */
          __asm ("fmove%.d #0x7fffffffffffffff,%0"              /* quiet NaN */
                 : "=f" (value)
                 : "=f" (value)
                 : /* no inputs */);
                 : /* no inputs */);
          return value;
          return value;
        }
        }
    }
    }
  else
  else
    {
    {
      double temp;
      double temp;
 
 
      __asm ("fintrz%.x %1,%0"
      __asm ("fintrz%.x %1,%0"
             : "=f" (temp)                      /* integer-valued float */
             : "=f" (temp)                      /* integer-valued float */
             : "f" (y));
             : "f" (y));
      if (y == temp)
      if (y == temp)
        {
        {
          int i = (int) y;
          int i = (int) y;
 
 
          if ((i & 1) == 0)                      /* even */
          if ((i & 1) == 0)                      /* even */
            return exp (y * log (-x));
            return exp (y * log (-x));
          else
          else
            return - exp (y * log (-x));
            return - exp (y * log (-x));
        }
        }
      else
      else
        {
        {
          double value;
          double value;
 
 
          errno = EDOM;
          errno = EDOM;
          __asm ("fmove%.d #0x7fffffffffffffff,%0"              /* quiet NaN */
          __asm ("fmove%.d #0x7fffffffffffffff,%0"              /* quiet NaN */
                 : "=f" (value)
                 : "=f" (value)
                 : /* no inputs */);
                 : /* no inputs */);
          return value;
          return value;
        }
        }
    }
    }
}
}
 
 
__inline extern double
__inline extern double
fabs (double x)
fabs (double x)
{
{
  double value;
  double value;
 
 
  __asm ("fabs%.x %1,%0"
  __asm ("fabs%.x %1,%0"
         : "=f" (value)
         : "=f" (value)
         : "f" (x));
         : "f" (x));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
ceil (double x)
ceil (double x)
{
{
  int rounding_mode, round_up;
  int rounding_mode, round_up;
  double value;
  double value;
 
 
  __asm volatile ("fmove%.l %!,%0"
  __asm volatile ("fmove%.l %!,%0"
                  : "=dm" (rounding_mode)
                  : "=dm" (rounding_mode)
                  : /* no inputs */ );
                  : /* no inputs */ );
  round_up = rounding_mode | 0x30;
  round_up = rounding_mode | 0x30;
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (round_up));
                  : "dmi" (round_up));
  __asm volatile ("fint%.x %1,%0"
  __asm volatile ("fint%.x %1,%0"
                  : "=f" (value)
                  : "=f" (value)
                  : "f" (x));
                  : "f" (x));
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (rounding_mode));
                  : "dmi" (rounding_mode));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
floor (double x)
floor (double x)
{
{
  int rounding_mode, round_down;
  int rounding_mode, round_down;
  double value;
  double value;
 
 
  __asm volatile ("fmove%.l %!,%0"
  __asm volatile ("fmove%.l %!,%0"
                  : "=dm" (rounding_mode)
                  : "=dm" (rounding_mode)
                  : /* no inputs */ );
                  : /* no inputs */ );
  round_down = (rounding_mode & ~0x10)
  round_down = (rounding_mode & ~0x10)
                | 0x20;
                | 0x20;
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (round_down));
                  : "dmi" (round_down));
  __asm volatile ("fint%.x %1,%0"
  __asm volatile ("fint%.x %1,%0"
                  : "=f" (value)
                  : "=f" (value)
                  : "f" (x));
                  : "f" (x));
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (rounding_mode));
                  : "dmi" (rounding_mode));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
rint (double x)
rint (double x)
{
{
  int rounding_mode, round_nearest;
  int rounding_mode, round_nearest;
  double value;
  double value;
 
 
  __asm volatile ("fmove%.l %!,%0"
  __asm volatile ("fmove%.l %!,%0"
                  : "=dm" (rounding_mode)
                  : "=dm" (rounding_mode)
                  : /* no inputs */ );
                  : /* no inputs */ );
  round_nearest = rounding_mode & ~0x30;
  round_nearest = rounding_mode & ~0x30;
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (round_nearest));
                  : "dmi" (round_nearest));
  __asm volatile ("fint%.x %1,%0"
  __asm volatile ("fint%.x %1,%0"
                  : "=f" (value)
                  : "=f" (value)
                  : "f" (x));
                  : "f" (x));
  __asm volatile ("fmove%.l %0,%!"
  __asm volatile ("fmove%.l %0,%!"
                  : /* no outputs */
                  : /* no outputs */
                  : "dmi" (rounding_mode));
                  : "dmi" (rounding_mode));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
fmod (double x, double y)
fmod (double x, double y)
{
{
  double value;
  double value;
 
 
  __asm ("fmod%.x %2,%0"
  __asm ("fmod%.x %2,%0"
         : "=f" (value)
         : "=f" (value)
         : "0" (x),
         : "0" (x),
           "f" (y));
           "f" (y));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
drem (double x, double y)
drem (double x, double y)
{
{
  double value;
  double value;
 
 
  __asm ("frem%.x %2,%0"
  __asm ("frem%.x %2,%0"
         : "=f" (value)
         : "=f" (value)
         : "0" (x),
         : "0" (x),
           "f" (y));
           "f" (y));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
scalb (double x, int n)
scalb (double x, int n)
{
{
  double value;
  double value;
 
 
  __asm ("fscale%.l %2,%0"
  __asm ("fscale%.l %2,%0"
         : "=f" (value)
         : "=f" (value)
         : "0" (x),
         : "0" (x),
           "dmi" (n));
           "dmi" (n));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
logb (double x)
logb (double x)
{
{
  double exponent;
  double exponent;
 
 
  __asm ("fgetexp%.x %1,%0"
  __asm ("fgetexp%.x %1,%0"
         : "=f" (exponent)
         : "=f" (exponent)
         : "f" (x));
         : "f" (x));
  return exponent;
  return exponent;
}
}
 
 
__inline extern double
__inline extern double
ldexp (double x, int n)
ldexp (double x, int n)
{
{
  double value;
  double value;
 
 
  __asm ("fscale%.l %2,%0"
  __asm ("fscale%.l %2,%0"
         : "=f" (value)
         : "=f" (value)
         : "0" (x),
         : "0" (x),
           "dmi" (n));
           "dmi" (n));
  return value;
  return value;
}
}
 
 
__inline extern double
__inline extern double
frexp (double x, int *exp)
frexp (double x, int *exp)
{
{
  double float_exponent;
  double float_exponent;
  int int_exponent;
  int int_exponent;
  double mantissa;
  double mantissa;
 
 
  __asm ("fgetexp%.x %1,%0"
  __asm ("fgetexp%.x %1,%0"
         : "=f" (float_exponent)        /* integer-valued float */
         : "=f" (float_exponent)        /* integer-valued float */
         : "f" (x));
         : "f" (x));
  int_exponent = (int) float_exponent;
  int_exponent = (int) float_exponent;
  __asm ("fgetman%.x %1,%0"
  __asm ("fgetman%.x %1,%0"
         : "=f" (mantissa)              /* 1.0 <= mantissa < 2.0 */
         : "=f" (mantissa)              /* 1.0 <= mantissa < 2.0 */
         : "f" (x));
         : "f" (x));
  if (mantissa != 0)
  if (mantissa != 0)
    {
    {
      __asm ("fscale%.b #-1,%0"
      __asm ("fscale%.b #-1,%0"
             : "=f" (mantissa)          /* mantissa /= 2.0 */
             : "=f" (mantissa)          /* mantissa /= 2.0 */
             : "0" (mantissa));
             : "0" (mantissa));
      int_exponent += 1;
      int_exponent += 1;
    }
    }
  *exp = int_exponent;
  *exp = int_exponent;
  return mantissa;
  return mantissa;
}
}
 
 
__inline extern double
__inline extern double
modf (double x, double *ip)
modf (double x, double *ip)
{
{
  double temp;
  double temp;
 
 
  __asm ("fintrz%.x %1,%0"
  __asm ("fintrz%.x %1,%0"
         : "=f" (temp)                  /* integer-valued float */
         : "=f" (temp)                  /* integer-valued float */
         : "f" (x));
         : "f" (x));
  *ip = temp;
  *ip = temp;
  return x - temp;
  return x - temp;
}
}
 
 
#endif /* not __math_68881 */
#endif /* not __math_68881 */
 
 

powered by: WebSVN 2.1.0

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