📄 ppc64-fp.c
字号:
/* Functions needed for soft-float on powerpc64-linux, copied from libgcc2.c with macros expanded to force the use of specific types. Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.This file is part of GCC.GCC is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the FreeSoftware Foundation; either version 2, or (at your option) any laterversion.In addition to the permissions in the GNU General Public License, theFree Software Foundation gives you unlimited permission to link thecompiled version of this file into combinations with other programs,and to distribute those combinations without any restriction comingfrom the use of this file. (The General Public License restrictionsdo apply in other respects; for example, they cover modification ofthe file, and distribution when not linked into a combineexecutable.)GCC is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with GCC; see the file COPYING. If not, write to the FreeSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA02111-1307, USA. */#if defined(__powerpc64__)#include "config/fp-bit.h"extern DItype __fixtfdi (TFtype);extern DItype __fixdfdi (DFtype);extern DItype __fixsfdi (SFtype);extern USItype __fixunsdfsi (DFtype);extern USItype __fixunssfsi (SFtype);extern TFtype __floatditf (DItype);extern DFtype __floatdidf (DItype);extern SFtype __floatdisf (DItype);extern DItype __fixunstfdi (TFtype);static DItype local_fixunssfdi (SFtype);static DItype local_fixunsdfdi (DFtype);DItype__fixtfdi (TFtype a){ if (a < 0) return - __fixunstfdi (-a); return __fixunstfdi (a);}DItype__fixdfdi (DFtype a){ if (a < 0) return - local_fixunsdfdi (-a); return local_fixunsdfdi (a);}DItype__fixsfdi (SFtype a){ if (a < 0) return - local_fixunssfdi (-a); return local_fixunssfdi (a);}USItype__fixunsdfsi (DFtype a){ if (a >= - (DFtype) (- ((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); return (SItype) a;}USItype__fixunssfsi (SFtype a){ if (a >= - (SFtype) (- ((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); return (SItype) a;}TFtype__floatditf (DItype u){ DFtype dh, dl; dh = (SItype) (u >> (sizeof (SItype) * 8)); dh *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); dl = (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); return (TFtype) dh + (TFtype) dl;}DFtype__floatdidf (DItype u){ DFtype d; d = (SItype) (u >> (sizeof (SItype) * 8)); d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); return d;}SFtype__floatdisf (DItype u){ DFtype f; if (53 < (sizeof (DItype) * 8) && 53 > ((sizeof (DItype) * 8) - 53 + 24)) { if (! (- ((DItype) 1 << 53) < u && u < ((DItype) 1 << 53))) { 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)); } } } f = (SItype) (u >> (sizeof (SItype) * 8)); f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); return (SFtype) f;}DItype__fixunstfdi (TFtype a){ if (a < 0) return 0; /* Compute high word of result, as a flonum. */ const TFtype b = (a / (((UDItype) 1) << (sizeof (SItype) * 8))); /* Convert that to fixed (but not to DItype!), and shift it into the high word. */ UDItype v = (USItype) b; v <<= (sizeof (SItype) * 8); /* Remove high part from the TFtype, leaving the low part as flonum. */ a -= (TFtype) v; /* Convert that to fixed (but not to DItype!) and add it in. Sometimes A comes out negative. This is significant, since A has more bits than a long int does. */ if (a < 0) v -= (USItype) (-a); else v += (USItype) a; return v;}/* This version is needed to prevent recursion; fixunsdfdi in libgcc calls fixdfdi, which in turn calls calls fixunsdfdi. */static DItypelocal_fixunsdfdi (DFtype a){ USItype hi, lo; hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;}/* This version is needed to prevent recursion; fixunssfdi in libgcc calls fixsfdi, which in turn calls calls fixunssfdi. */static DItypelocal_fixunssfdi (SFtype original_a){ DFtype a = original_a; USItype hi, lo; hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); return ((UDItype) hi << (sizeof (SItype) * 8)) | lo;}#endif /* __powerpc64__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -