📄 900-nios2.patch
字号:
+USItype+float_to_usi (FLO_type arg_a)+{+ fp_number_type a;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &a);++ if (iszero (&a))+ return 0;+ if (isnan (&a))+ return 0;+ /* it is a negative number */+ if (a.sign)+ return 0;+ /* get reasonable MAX_USI_INT... */+ if (isinf (&a))+ return MAX_USI_INT;+ /* it is a number, but a small one */+ if (a.normal_exp < 0)+ return 0;+ if (a.normal_exp > BITS_PER_SI - 1)+ return MAX_USI_INT;+ else if (a.normal_exp > (FRACBITS + NGARDS))+ return a.fraction.ll << (a.normal_exp - (FRACBITS + NGARDS));+ else+ return a.fraction.ll >> ((FRACBITS + NGARDS) - a.normal_exp);+}+#endif /* US_SOFTWARE_GOFAST */+#endif /* L_sf_to_usi || L_df_to_usi */++#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)+FLO_type+negate (FLO_type arg_a)+{+ fp_number_type a;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &a);++ flip_sign (&a);+ return pack_d (&a);+}+#endif /* L_negate_sf || L_negate_df */++#ifdef FLOAT++#if defined(L_make_sf)+SFtype+__make_fp(fp_class_type class,+ unsigned int sign,+ int exp, + USItype frac)+{+ fp_number_type in;++ in.class = class;+ in.sign = sign;+ in.normal_exp = exp;+ in.fraction.ll = frac;+ return pack_d (&in);+}+#endif /* L_make_sf */++#ifndef FLOAT_ONLY++/* This enables one to build an fp library that supports float but not double.+ Otherwise, we would get an undefined reference to __make_dp.+ This is needed for some 8-bit ports that can't handle well values that+ are 8-bytes in size, so we just don't support double for them at all. */++#if defined(L_sf_to_df)+DFtype+sf_to_df (SFtype arg_a)+{+ fp_number_type in;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ return __make_dp (in.class, in.sign, in.normal_exp,+ ((UDItype) in.fraction.ll) << F_D_BITOFF);+}+#endif /* L_sf_to_df */++#if defined(L_sf_to_tf) && defined(TMODES)+TFtype+sf_to_tf (SFtype arg_a)+{+ fp_number_type in;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ return __make_tp (in.class, in.sign, in.normal_exp,+ ((UTItype) in.fraction.ll) << F_T_BITOFF);+}+#endif /* L_sf_to_df */++#endif /* ! FLOAT_ONLY */+#endif /* FLOAT */++#ifndef FLOAT++extern SFtype __make_fp (fp_class_type, unsigned int, int, USItype);++#if defined(L_make_df)+DFtype+__make_dp (fp_class_type class, unsigned int sign, int exp, UDItype frac)+{+ fp_number_type in;++ in.class = class;+ in.sign = sign;+ in.normal_exp = exp;+ in.fraction.ll = frac;+ return pack_d (&in);+}+#endif /* L_make_df */++#if defined(L_df_to_sf)+SFtype+df_to_sf (DFtype arg_a)+{+ fp_number_type in;+ USItype sffrac;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ sffrac = in.fraction.ll >> F_D_BITOFF;++ /* We set the lowest guard bit in SFFRAC if we discarded any non+ zero bits. */+ if ((in.fraction.ll & (((USItype) 1 << F_D_BITOFF) - 1)) != 0)+ sffrac |= 1;++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_df_to_sf */++#if defined(L_df_to_tf) && defined(TMODES) \+ && !defined(FLOAT) && !defined(TFLOAT)+TFtype+df_to_tf (DFtype arg_a)+{+ fp_number_type in;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ return __make_tp (in.class, in.sign, in.normal_exp,+ ((UTItype) in.fraction.ll) << D_T_BITOFF);+}+#endif /* L_sf_to_df */++#ifdef TFLOAT+#if defined(L_make_tf)+TFtype+__make_tp(fp_class_type class,+ unsigned int sign,+ int exp, + UTItype frac)+{+ fp_number_type in;++ in.class = class;+ in.sign = sign;+ in.normal_exp = exp;+ in.fraction.ll = frac;+ return pack_d (&in);+}+#endif /* L_make_tf */++#if defined(L_tf_to_df)+DFtype+tf_to_df (TFtype arg_a)+{+ fp_number_type in;+ UDItype sffrac;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ sffrac = in.fraction.ll >> D_T_BITOFF;++ /* We set the lowest guard bit in SFFRAC if we discarded any non+ zero bits. */+ if ((in.fraction.ll & (((UTItype) 1 << D_T_BITOFF) - 1)) != 0)+ sffrac |= 1;++ return __make_dp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_tf_to_df */++#if defined(L_tf_to_sf)+SFtype+tf_to_sf (TFtype arg_a)+{+ fp_number_type in;+ USItype sffrac;+ FLO_union_type au;++ au.value = arg_a;+ unpack_d (&au, &in);++ sffrac = in.fraction.ll >> F_T_BITOFF;++ /* We set the lowest guard bit in SFFRAC if we discarded any non+ zero bits. */+ if ((in.fraction.ll & (((UTItype) 1 << F_T_BITOFF) - 1)) != 0)+ sffrac |= 1;++ return __make_fp (in.class, in.sign, in.normal_exp, sffrac);+}+#endif /* L_tf_to_sf */+#endif /* TFLOAT */++#endif /* ! FLOAT */+#endif /* !EXTENDED_FLOAT_STUBS */diff --git a/gcc/config/nios2/nios2-fp-bit.c b/gcc/config/nios2/nios2-fp-bit.cnew file mode 100644index 0000000..839ffcc--- /dev/null+++ b/gcc/config/nios2/nios2-fp-bit.c@@ -0,0 +1,1655 @@+#define FLOAT+#ifndef __nios2_big_endian__+#define FLOAT_BIT_ORDER_MISMATCH+#endif+/* This is a software floating point library which can be used+ for targets without hardware floating point. + Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004+ Free Software Foundation, Inc.++This file 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 Software Foundation; either version 2, or (at your option) any+later version.++In addition to the permissions in the GNU General Public License, the+Free Software Foundation gives you unlimited permission to link the+compiled version of this file with other programs, and to distribute+those programs without any restriction coming from the use of this+file. (The General Public License restrictions do apply in other+respects; for example, they cover modification of the file, and+distribution when not linked into another program.)++This file is distributed in the hope that it will be useful, but+WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; see the file COPYING. If not, write to+the Free Software Foundation, 59 Temple Place - Suite 330,+Boston, MA 02111-1307, USA. */++/* As a special exception, if you link this library with other files,+ some of which are compiled with GCC, to produce an executable,+ this library does not by itself cause the resulting executable+ to be covered by the GNU General Public License.+ This exception does not however invalidate any other reasons why+ the executable file might be covered by the GNU General Public License. */++/* This implements IEEE 754 format arithmetic, but does not provide a+ mechanism for setting the rounding mode, or for generating or handling+ exceptions.++ The original code by Steve Chamberlain, hacked by Mark Eichin and Jim+ Wilson, all of Cygnus Support. */++/* The intended way to use this file is to make two copies, add `#define FLOAT'+ to one copy, then compile both copies and add them to libgcc.a. */++#include "tconfig.h"+#include "coretypes.h"+#include "tm.h"+#include "config/fp-bit.h"++/* The following macros can be defined to change the behavior of this file:+ FLOAT: Implement a `float', aka SFmode, fp library. If this is not+ defined, then this file implements a `double', aka DFmode, fp library.+ FLOAT_ONLY: Used with FLOAT, to implement a `float' only library, i.e.+ don't include float->double conversion which requires the double library.+ This is useful only for machines which can't support doubles, e.g. some+ 8-bit processors.+ CMPtype: Specify the type that floating point compares should return.+ This defaults to SItype, aka int.+ US_SOFTWARE_GOFAST: This makes all entry points use the same names as the+ US Software goFast library.+ _DEBUG_BITFLOAT: This makes debugging the code a little easier, by adding+ two integers to the FLO_union_type.+ NO_DENORMALS: Disable handling of denormals.+ NO_NANS: Disable nan and infinity handling+ SMALL_MACHINE: Useful when operations on QIs and HIs are faster+ than on an SI */++/* We don't currently support extended floats (long doubles) on machines+ without hardware to deal with them.++ These stubs are just to keep the linker from complaining about unresolved+ references which can be pulled in from libio & libstdc++, even if the+ user isn't using long doubles. However, they may generate an unresolved+ external to abort if abort is not used by the function, and the stubs+ are referenced from within libc, since libgcc goes before and after the+ system library. */++#ifdef DECLARE_LIBRARY_RENAMES+ DECLARE_LIBRARY_RENAMES+#endif++#ifdef EXTENDED_FLOAT_STUBS+extern void abort (void);+void __extendsfxf2 (void) { abort(); }+void __extenddfxf2 (void) { abort(); }+void __truncxfdf2 (void) { abort(); }+void __truncxfsf2 (void) { abort(); }+void __fixxfsi (void) { abort(); }+void __floatsixf (void) { abort(); }+void __addxf3 (void) { abort(); }+void __subxf3 (void) { abort(); }+void __mulxf3 (void) { abort(); }+void __divxf3 (void) { abort(); }+void __negxf2 (void) { abort(); }+void __eqxf2 (void) { abort(); }+void __nexf2 (void) { abort(); }+void __gtxf2 (void) { abort(); }+void __gexf2 (void) { abort(); }+void __lexf2 (void) { abort(); }+void __ltxf2 (void) { abort(); }++void __extendsftf2 (void) { abort(); }+void __extenddftf2 (void) { abort(); }+void __trunctfdf2 (void) { abort(); }+void __trunctfsf2 (void) { abort(); }+void __fixtfsi (void) { abort(); }+void __floatsitf (void) { abort(); }+void __addtf3 (void) { abort(); }+void __subtf3 (void) { abort(); }+void __multf3 (void) { abort(); }+void __divtf3 (void) { abort(); }+void __negtf2 (void) { abort(); }+void __eqtf2 (void) { abort(); }+void __netf2 (void) { abort(); }+void __gttf2 (void) { abort(); }+void __getf2 (void) { abort(); }+void __letf2 (void) { abort(); }+void __lttf2 (void) { abort(); }+#else /* !EXTENDED_FLOAT_STUBS, rest of file */++/* IEEE "special" number predicates */++#ifdef NO_NANS++#define nan() 0+#define isnan(x) 0+#define isinf(x) 0+#else++#if defined L_thenan_sf+const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined L_thenan_df+const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined L_thenan_tf+const fp_number_type __thenan_tf = { CLASS_SNAN, 0, 0, {(fractype) 0} };+#elif defined TFLOAT+extern const fp_number_type __thenan_tf;+#elif defined FLOAT+extern const fp_number_type __thenan_sf;+#else+extern const fp_number_type __thenan_df;+#endif++INLINE+static fp_number_type *+nan (void)+{+ /* Discard the const qualifier... */+#ifdef TFLOAT+ return (fp_number_type *) (& __thenan_tf);+#elif defined FLOAT + return (fp_number_type *) (& __thenan_sf);+#else+ return (fp_number_type *) (& __thenan_df);+#endif+}++INLINE+static int+isnan ( fp_number_type * x)+{+ return x->class == CLASS_SNAN || x->class == CLASS_QNAN;+}++INLINE+static int+isinf ( fp_number_type * x)+{+ return x->class == CLASS_INFINITY;+}++#endif /* NO_NANS */++INLINE+static int+iszero ( fp_number_type * x)+{+ return x->class == CLASS_ZERO;+}++INLINE +static void+flip_sign ( fp_number_type * x)+{+ x->sign = !x->sign;+}++extern FLO_type pack_d ( fp_number_type * );++#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)+FLO_type+pack_d ( fp_number_type * src)+{+ FLO_union_type dst;+ fractype fraction = src->fraction.ll; /* wasn't unsigned before? */+ int sign = src->sign;+ int exp = 0;++ if (LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS) && (isnan (src) || isinf (src)))+ {+ /* We can't represent these values accurately. By using the+ largest possible magnitude, we guarantee that the conversion+ of infinity is at least as big as any finite number. */+ exp = EXPMAX;+ fraction = ((fractype) 1 << FRACBITS) - 1;+ }+ else if (isnan (src))+ {+ exp = EXPMAX;+ if (src->class == CLASS_QNAN || 1)+ {+#ifdef QUIET_NAN_NEGATED+ fraction |= QUIET_NAN - 1;+#else+ fraction |= QUIET_NAN;+#endif+ }+ }+ else if (isinf (src))+ {+ exp = EXPMAX;+ fraction = 0;+ }+ else if (iszero (src))+ {+ exp = 0;+ fraction = 0;+ }+ else if (fraction == 0)+ {+ exp = 0;+ }+ else+ {+ if (src->normal_exp < NORMAL_EXPMIN)+ {+#ifdef NO_DENORMALS+ /* Go straight to a zero representation if denormals are not+ supported. The denormal handling would be harmless but+ isn't unnecessary. */+ exp = 0;+ fraction = 0;+#else /* NO_DENORMALS */+ /* This number's exponent is too low to fit into the bits+ available in the number, so we'll store 0 in the exponent and+ shift the fraction to the right to make up for it. */++ int shift = NORMAL_EXPMIN - src->normal_exp;++ exp = 0;++ if (shift > FRAC_NBITS - NGARDS)+ {+ /* No point shifting, since it's more that 64 out. */+ fraction = 0;+ }+ else+ {+ int lowbit = (fraction & (((fractype)1 << shift) - 1)) ? 1 : 0;+ fraction = (fraction >> shift) | lowbit;+ }+ if ((fraction & GARDMASK) == GARDMSB)+ {+ if ((fraction & (1 << NGARDS)))+ fraction += GARDROUND + 1;+ }+ else+ {+ /* Add to the guards to round up. */+ fraction += GARDROUND;+ }+ /* Perhaps the rounding means we now need to change the+ exponent, because the fraction is no longer denormal. */+ if (fraction >= IMPLICIT_1)+ {+ exp += 1;+ }+ fraction >>= NGARDS;+#endif /* NO_DENORMALS */+ }+ else if (!LARGEST_EXPONENT_IS_NORMAL (FRAC_NBITS)+ && src->normal_exp > EXPBIAS)+ {+ exp = EXPMAX;+ fraction = 0;+ }+ else+ {+ exp = src->normal_exp + EXPBIAS;+ if (!ROUND_TOWARDS_ZERO)+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -