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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [config/] [rs6000/] [ppc64-fp.c] - Diff between revs 154 and 816

Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
/* Functions needed for soft-float on powerpc64-linux, copied from
/* Functions needed for soft-float on powerpc64-linux, copied from
   libgcc2.c with macros expanded to force the use of specific types.
   libgcc2.c with macros expanded to force the use of specific types.
 
 
   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
   2000, 2001, 2002, 2003, 2004, 2006  Free Software Foundation, Inc.
   2000, 2001, 2002, 2003, 2004, 2006  Free Software Foundation, Inc.
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
Software Foundation; either version 2, or (at your option) any later
version.
version.
 
 
In addition to the permissions in the GNU General Public License, the
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
and to distribute those combinations without any restriction coming
from the use of this file.  (The General Public License restrictions
from the use of this file.  (The General Public License restrictions
do apply in other respects; for example, they cover modification of
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
the file, and distribution when not linked into a combine
executable.)
executable.)
 
 
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to the Free
along with GCC; see the file COPYING.  If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.  */
02110-1301, USA.  */
 
 
#if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__)
#if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__)
#define TMODES
#define TMODES
#include "config/fp-bit.h"
#include "config/fp-bit.h"
 
 
extern DItype __fixtfdi (TFtype);
extern DItype __fixtfdi (TFtype);
extern DItype __fixdfdi (DFtype);
extern DItype __fixdfdi (DFtype);
extern DItype __fixsfdi (SFtype);
extern DItype __fixsfdi (SFtype);
extern USItype __fixunsdfsi (DFtype);
extern USItype __fixunsdfsi (DFtype);
extern USItype __fixunssfsi (SFtype);
extern USItype __fixunssfsi (SFtype);
extern TFtype __floatditf (DItype);
extern TFtype __floatditf (DItype);
extern TFtype __floatunditf (UDItype);
extern TFtype __floatunditf (UDItype);
extern DFtype __floatdidf (DItype);
extern DFtype __floatdidf (DItype);
extern DFtype __floatundidf (UDItype);
extern DFtype __floatundidf (UDItype);
extern SFtype __floatdisf (DItype);
extern SFtype __floatdisf (DItype);
extern SFtype __floatundisf (UDItype);
extern SFtype __floatundisf (UDItype);
extern DItype __fixunstfdi (TFtype);
extern DItype __fixunstfdi (TFtype);
 
 
static DItype local_fixunssfdi (SFtype);
static DItype local_fixunssfdi (SFtype);
static DItype local_fixunsdfdi (DFtype);
static DItype local_fixunsdfdi (DFtype);
 
 
DItype
DItype
__fixtfdi (TFtype a)
__fixtfdi (TFtype a)
{
{
  if (a < 0)
  if (a < 0)
    return - __fixunstfdi (-a);
    return - __fixunstfdi (-a);
  return __fixunstfdi (a);
  return __fixunstfdi (a);
}
}
 
 
DItype
DItype
__fixdfdi (DFtype a)
__fixdfdi (DFtype a)
{
{
  if (a < 0)
  if (a < 0)
    return - local_fixunsdfdi (-a);
    return - local_fixunsdfdi (-a);
  return local_fixunsdfdi (a);
  return local_fixunsdfdi (a);
}
}
 
 
DItype
DItype
__fixsfdi (SFtype a)
__fixsfdi (SFtype a)
{
{
  if (a < 0)
  if (a < 0)
    return - local_fixunssfdi (-a);
    return - local_fixunssfdi (-a);
  return local_fixunssfdi (a);
  return local_fixunssfdi (a);
}
}
 
 
USItype
USItype
__fixunsdfsi (DFtype a)
__fixunsdfsi (DFtype a)
{
{
  if (a >= - (DFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
  if (a >= - (DFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
    return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
    return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
                       - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1);
                       - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1);
  return (SItype) a;
  return (SItype) a;
}
}
 
 
USItype
USItype
__fixunssfsi (SFtype a)
__fixunssfsi (SFtype a)
{
{
  if (a >= - (SFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
  if (a >= - (SFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
    return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
    return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1))
                       - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1);
                       - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1);
  return (SItype) a;
  return (SItype) a;
}
}
 
 
TFtype
TFtype
__floatditf (DItype u)
__floatditf (DItype u)
{
{
  DFtype dh, dl;
  DFtype dh, dl;
 
 
  dh = (SItype) (u >> (sizeof (SItype) * 8));
  dh = (SItype) (u >> (sizeof (SItype) * 8));
  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return (TFtype) dh + (TFtype) dl;
  return (TFtype) dh + (TFtype) dl;
}
}
 
 
TFtype
TFtype
__floatunditf (UDItype u)
__floatunditf (UDItype u)
{
{
  DFtype dh, dl;
  DFtype dh, dl;
 
 
  dh = (USItype) (u >> (sizeof (SItype) * 8));
  dh = (USItype) (u >> (sizeof (SItype) * 8));
  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return (TFtype) dh + (TFtype) dl;
  return (TFtype) dh + (TFtype) dl;
}
}
 
 
DFtype
DFtype
__floatdidf (DItype u)
__floatdidf (DItype u)
{
{
  DFtype d;
  DFtype d;
 
 
  d = (SItype) (u >> (sizeof (SItype) * 8));
  d = (SItype) (u >> (sizeof (SItype) * 8));
  d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return d;
  return d;
}
}
 
 
DFtype
DFtype
__floatundidf (UDItype u)
__floatundidf (UDItype u)
{
{
  DFtype d;
  DFtype d;
 
 
  d = (USItype) (u >> (sizeof (SItype) * 8));
  d = (USItype) (u >> (sizeof (SItype) * 8));
  d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return d;
  return d;
}
}
 
 
SFtype
SFtype
__floatdisf (DItype u)
__floatdisf (DItype u)
{
{
  DFtype f;
  DFtype f;
 
 
  if (53 < (sizeof (DItype) * 8)
  if (53 < (sizeof (DItype) * 8)
      && 53 > ((sizeof (DItype) * 8) - 53 + 24))
      && 53 > ((sizeof (DItype) * 8) - 53 + 24))
    {
    {
      if (! (- ((DItype) 1 << 53) < u
      if (! (- ((DItype) 1 << 53) < u
             && u < ((DItype) 1 << 53)))
             && u < ((DItype) 1 << 53)))
        {
        {
          if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1))
          if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1))
            {
            {
              u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1);
              u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1);
              u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53));
              u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53));
            }
            }
        }
        }
    }
    }
  f = (SItype) (u >> (sizeof (SItype) * 8));
  f = (SItype) (u >> (sizeof (SItype) * 8));
  f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return (SFtype) f;
  return (SFtype) f;
}
}
 
 
SFtype
SFtype
__floatundisf (UDItype u)
__floatundisf (UDItype u)
{
{
  DFtype f;
  DFtype f;
 
 
  if (53 < (sizeof (DItype) * 8)
  if (53 < (sizeof (DItype) * 8)
      && 53 > ((sizeof (DItype) * 8) - 53 + 24))
      && 53 > ((sizeof (DItype) * 8) - 53 + 24))
    {
    {
      if (u >= ((UDItype) 1 << 53))
      if (u >= ((UDItype) 1 << 53))
        {
        {
          if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1))
          if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1))
            {
            {
              u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1);
              u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1);
              u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53));
              u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53));
            }
            }
        }
        }
    }
    }
  f = (USItype) (u >> (sizeof (SItype) * 8));
  f = (USItype) (u >> (sizeof (SItype) * 8));
  f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1));
  f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
  f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1));
 
 
  return (SFtype) f;
  return (SFtype) f;
}
}
 
 
DItype
DItype
__fixunstfdi (TFtype a)
__fixunstfdi (TFtype a)
{
{
  if (a < 0)
  if (a < 0)
    return 0;
    return 0;
 
 
  /* Compute high word of result, as a flonum.  */
  /* Compute high word of result, as a flonum.  */
  const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8)));
  const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8)));
  /* Convert that to fixed (but not to DItype!),
  /* Convert that to fixed (but not to DItype!),
     and shift it into the high word.  */
     and shift it into the high word.  */
  UDItype v = (USItype) b;
  UDItype v = (USItype) b;
  v <<= (sizeof (SItype) * 8);
  v <<= (sizeof (SItype) * 8);
  /* Remove high part from the TFtype, leaving the low part as flonum.  */
  /* Remove high part from the TFtype, leaving the low part as flonum.  */
  a -= (TFtype) v;
  a -= (TFtype) v;
  /* Convert that to fixed (but not to DItype!) and add it in.
  /* Convert that to fixed (but not to DItype!) and add it in.
     Sometimes A comes out negative.  This is significant, since
     Sometimes A comes out negative.  This is significant, since
     A has more bits than a long int does.  */
     A has more bits than a long int does.  */
  if (a < 0)
  if (a < 0)
    v -= (USItype) (-a);
    v -= (USItype) (-a);
  else
  else
    v += (USItype) a;
    v += (USItype) a;
  return v;
  return v;
}
}
 
 
/* This version is needed to prevent recursion; fixunsdfdi in libgcc
/* This version is needed to prevent recursion; fixunsdfdi in libgcc
   calls fixdfdi, which in turn calls calls fixunsdfdi.  */
   calls fixdfdi, which in turn calls calls fixunsdfdi.  */
 
 
static DItype
static DItype
local_fixunsdfdi (DFtype a)
local_fixunsdfdi (DFtype a)
{
{
  USItype hi, lo;
  USItype hi, lo;
 
 
  hi = a / (((UDItype) 1) << (sizeof (SItype) * 8));
  hi = a / (((UDItype) 1) << (sizeof (SItype) * 8));
  lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8)));
  lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8)));
  return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;
  return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;
}
}
 
 
/* This version is needed to prevent recursion; fixunssfdi in libgcc
/* This version is needed to prevent recursion; fixunssfdi in libgcc
   calls fixsfdi, which in turn calls calls fixunssfdi.  */
   calls fixsfdi, which in turn calls calls fixunssfdi.  */
 
 
static DItype
static DItype
local_fixunssfdi (SFtype original_a)
local_fixunssfdi (SFtype original_a)
{
{
  DFtype a = original_a;
  DFtype a = original_a;
  USItype hi, lo;
  USItype hi, lo;
 
 
  hi = a / (((UDItype) 1) << (sizeof (SItype) * 8));
  hi = a / (((UDItype) 1) << (sizeof (SItype) * 8));
  lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8)));
  lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8)));
  return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;
  return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;
}
}
 
 
#endif /* __powerpc64__ */
#endif /* __powerpc64__ */
 
 

powered by: WebSVN 2.1.0

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