]> oss.titaniummirror.com Git - msp430-gcc.git/blobdiff - gcc/config/fp-bit.h
Imported gcc-4.4.3
[msp430-gcc.git] / gcc / config / fp-bit.h
index ab1817a282659e726667b8925de4c56b9c9f4013..3638cc53f8ffb7bb3924d0deeace9659bfac812a 100644 (file)
@@ -1,30 +1,26 @@
 /* Header file for fp-bit.c.  */
-/* Copyright (C) 2000
-   Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2006, 2009 Free Software Foundation, Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC 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.
+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
+Software Foundation; either version 3, or (at your option) any later
+version.
 
-GNU CC 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.
+GCC 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 GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
 
-/* 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.  */
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
 
 #ifndef GCC_FP_BIT_H
 #define GCC_FP_BIT_H
@@ -35,7 +31,7 @@ Boston, MA 02111-1307, USA.  */
    This avoids the need to pull in the entire fp emulation library
    when only a small number of functions are needed.
 
-   If FINE_GRAINED_LIBRARIES is not defined, then compile every 
+   If FINE_GRAINED_LIBRARIES is not defined, then compile every
    suitable routine.  */
 #ifndef FINE_GRAINED_LIBRARIES
 #define L_pack_df
@@ -87,31 +83,96 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif /* ! FINE_GRAINED_LIBRARIES */
 
+#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106
+# if defined(TFLOAT) || defined(L_sf_to_tf) || defined(L_df_to_tf)
+#  define TMODES
+# endif
+#endif
+
 typedef float SFtype __attribute__ ((mode (SF)));
 typedef float DFtype __attribute__ ((mode (DF)));
+#ifdef TMODES
+typedef float TFtype __attribute__ ((mode (TF)));
+#endif
 
 typedef int HItype __attribute__ ((mode (HI)));
 typedef int SItype __attribute__ ((mode (SI)));
 typedef int DItype __attribute__ ((mode (DI)));
+#ifdef TMODES
+typedef int TItype __attribute__ ((mode (TI)));
+#endif
 
-/* The type of the result of a fp compare */
+/* The type of the result of a floating point comparison.  This must
+   match `__libgcc_cmp_return__' in GCC for the target.  */
 #ifndef CMPtype
-#define CMPtype SItype
+typedef int CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
 #endif
 
 typedef unsigned int UHItype __attribute__ ((mode (HI)));
 typedef unsigned int USItype __attribute__ ((mode (SI)));
 typedef unsigned int UDItype __attribute__ ((mode (DI)));
+#ifdef TMODES
+typedef unsigned int UTItype __attribute__ ((mode (TI)));
+#endif
 
 #define MAX_USI_INT  (~(USItype)0)
 #define MAX_SI_INT   ((SItype) (MAX_USI_INT >> 1))
 #define BITS_PER_SI  (4 * BITS_PER_UNIT)
+#ifdef TMODES
+#define MAX_UDI_INT  (~(UDItype)0)
+#define MAX_DI_INT   ((DItype) (MAX_UDI_INT >> 1))
+#define BITS_PER_DI  (8 * BITS_PER_UNIT)
+#endif
 
 #ifdef FLOAT_ONLY
 #define NO_DI_MODE
 #endif
 
-#ifdef FLOAT
+#ifdef TFLOAT
+# ifndef TMODES
+#  error "TFLOAT requires long double to have 113 bits of mantissa"
+# endif
+
+#      define PREFIXFPDP tp
+#      define PREFIXSFDF tf
+#      define NGARDS 10L /* Is this right? */
+#      define GARDROUND 0x1ff
+#      define GARDMASK  0x3ff
+#      define GARDMSB   0x200
+#      define FRAC_NBITS 128
+
+# if __LDBL_MANT_DIG__ == 113 /* IEEE quad */
+#      define EXPBITS 15
+#      define EXPBIAS 16383
+#      define EXPMAX (0x7fff)
+#      define QUIET_NAN ((TItype)0x8 << 108)
+#      define FRACHIGH  ((TItype)0x8 << 124)
+#      define FRACHIGH2 ((TItype)0xc << 124)
+#      define FRACBITS 112
+# endif
+
+# if __LDBL_MANT_DIG__ == 106 /* IBM extended (double+double) */
+#      define EXPBITS 11
+#      define EXPBIAS 1023
+#      define EXPMAX (0x7ff)
+#      define QUIET_NAN ((TItype)0x8 << (48 + 64))
+#      define FRACHIGH  ((TItype)0x8 << 124)
+#      define FRACHIGH2 ((TItype)0xc << 124)
+#      define FRACBITS 105
+#      define HALFFRACBITS 52
+#      define HALFSHIFT 64
+# endif
+
+#      define pack_d __pack_t
+#      define unpack_d __unpack_t
+#      define __fpcmp_parts __fpcmp_parts_t
+       typedef UTItype fractype;
+       typedef UDItype halffractype;
+       typedef USItype qrtrfractype;
+#define qrtrfractype qrtrfractype
+       typedef TFtype FLO_type;
+       typedef TItype intfrac;
+#elif defined FLOAT
 #      define NGARDS    7L
 #      define GARDROUND 0x3f
 #      define GARDMASK  0x7f
@@ -157,34 +218,59 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
 #endif /* FLOAT */
 
 #ifdef US_SOFTWARE_GOFAST
-#      ifdef FLOAT
+#      ifdef TFLOAT
+#              error "GOFAST TFmode not supported"
+#      elif defined FLOAT
 #              define add              fpadd
 #              define sub              fpsub
 #              define multiply         fpmul
 #              define divide           fpdiv
 #              define compare          fpcmp
+#              define _unord_f2        __unordsf2
 #              define usi_to_float     __floatunsisf
 #              define si_to_float      sitofp
 #              define float_to_si      fptosi
 #              define float_to_usi     fptoui
 #              define negate           __negsf2
 #              define sf_to_df         fptodp
-#              define dptofp           dptofp
-#else
+#              define sf_to_tf         __extendsftf2
+#      else
 #              define add              dpadd
 #              define sub              dpsub
 #              define multiply         dpmul
 #              define divide           dpdiv
 #              define compare          dpcmp
+#              define _unord_f2        __unorddf2
 #              define usi_to_float     __floatunsidf
 #              define si_to_float      litodp
 #              define float_to_si      dptoli
 #              define float_to_usi     dptoul
 #              define negate           __negdf2
 #              define df_to_sf         dptofp
+#              define df_to_tf         __extenddftf2
 #      endif /* FLOAT */
 #else
-#      ifdef FLOAT
+#      ifdef TFLOAT
+#              define add              __addtf3
+#              define sub              __subtf3
+#              define multiply         __multf3
+#              define divide           __divtf3
+#              define compare          __cmptf2
+#              define _eq_f2           __eqtf2
+#              define _ne_f2           __netf2
+#              define _gt_f2           __gttf2
+#              define _ge_f2           __getf2
+#              define _lt_f2           __lttf2
+#              define _le_f2           __letf2
+#              define _unord_f2        __unordtf2
+#              define usi_to_float     __floatunsitf
+#              define si_to_float      __floatsitf
+#              define float_to_si      __fixtfsi
+#              define float_to_usi     __fixunstfsi
+#              define negate           __negtf2
+#              define tf_to_sf         __trunctfsf2
+#              define tf_to_df         __trunctfdf2
+#      elif defined FLOAT
 #              define add              __addsf3
 #              define sub              __subsf3
 #              define multiply         __mulsf3
@@ -203,7 +289,8 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
 #              define float_to_usi     __fixunssfsi
 #              define negate           __negsf2
 #              define sf_to_df         __extendsfdf2
-#else
+#              define sf_to_tf         __extendsftf2
+#      else
 #              define add              __adddf3
 #              define sub              __subdf3
 #              define multiply         __muldf3
@@ -222,6 +309,7 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
 #              define float_to_usi     __fixunsdfsi
 #              define negate           __negdf2
 #              define df_to_sf         __truncdfsf2
+#              define df_to_tf         __extenddftf2
 #      endif /* FLOAT */
 #endif /* US_SOFTWARE_GOFAST */
 
@@ -230,7 +318,7 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
 #endif
 
 /* Preserve the sticky-bit when shifting fractions to the right.  */
-#define LSHIFT(a) { a = (a & 1) | (a >> 1); }
+#define LSHIFT(a, s) { a = (a >> s) | !!(a & (((fractype) 1 << s) - 1)); }
 
 /* numeric parameters */
 /* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
@@ -239,10 +327,15 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
  */
 #define F_D_BITOFF (52+8-(23+7))
 
+#ifdef TMODES
+# define F_T_BITOFF (__LDBL_MANT_DIG__-1+10-(23+7))
+# define D_T_BITOFF (__LDBL_MANT_DIG__-1+10-(52+8))
+#endif
+
 
 #define NORMAL_EXPMIN (-(EXPBIAS)+1)
-#define IMPLICIT_1 (1LL<<(FRACBITS+NGARDS))
-#define IMPLICIT_2 (1LL<<(FRACBITS+1+NGARDS))
+#define IMPLICIT_1 ((fractype)1<<(FRACBITS+NGARDS))
+#define IMPLICIT_2 ((fractype)1<<(FRACBITS+1+NGARDS))
 
 /* common types */
 
@@ -280,7 +373,11 @@ typedef union
   fractype value_raw;
 
 #ifndef FLOAT
+# ifdef qrtrfractype
+  qrtrfractype qwords[4];
+# else
   halffractype words[2];
+# endif
 #endif
 
 #ifdef FLOAT_BIT_ORDER_MISMATCH
@@ -313,84 +410,84 @@ typedef union
 }
 FLO_union_type;
 
-/* Prototypes */
+/* Prototypes */
 
-#if defined(L_pack_df) || defined(L_pack_sf)
-extern FLO_type pack_d (fp_number_type *);
+#if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
+extern FLO_type pack_d (const fp_number_type *);
 #endif
 
 extern void unpack_d (FLO_union_type *, fp_number_type *);
 
-#if defined(L_addsub_sf) || defined(L_addsub_df)
+#if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
 extern FLO_type add (FLO_type, FLO_type);
 extern FLO_type sub (FLO_type, FLO_type);
 #endif
 
-#if defined(L_mul_sf) || defined(L_mul_df)
+#if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
 extern FLO_type multiply (FLO_type, FLO_type);
 #endif
 
-#if defined(L_div_sf) || defined(L_div_df)
+#if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
 extern FLO_type divide (FLO_type, FLO_type);
 #endif
 
 extern int __fpcmp_parts (fp_number_type *, fp_number_type *);
 
-#if defined(L_compare_sf) || defined(L_compare_df)
+#if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compare_tf)
 extern CMPtype compare (FLO_type, FLO_type);
 #endif
 
 #ifndef US_SOFTWARE_GOFAST
 
-#if defined(L_eq_sf) || defined(L_eq_df)
+#if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
 extern CMPtype _eq_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_ne_sf) || defined(L_ne_df)
+#if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
 extern CMPtype _ne_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_gt_sf) || defined(L_gt_df)
+#if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
 extern CMPtype _gt_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_ge_sf) || defined(L_ge_df)
+#if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
 extern CMPtype _ge_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_lt_sf) || defined(L_lt_df)
+#if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
 extern CMPtype _lt_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_le_sf) || defined(L_le_df)
+#if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
 extern CMPtype _le_f2 (FLO_type, FLO_type);
 #endif
 
-#if defined(L_unord_sf) || defined(L_unord_df)
+#if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
 extern CMPtype _unord_f2 (FLO_type, FLO_type);
 #endif
 
 #endif /* ! US_SOFTWARE_GOFAST */
 
-#if defined(L_si_to_sf) || defined(L_si_to_df)
+#if defined(L_si_to_sf) || defined(L_si_to_df) || defined(L_si_to_tf)
 extern FLO_type si_to_float (SItype);
 #endif
 
-#if defined(L_sf_to_si) || defined(L_df_to_si)
+#if defined(L_sf_to_si) || defined(L_df_to_si) || defined(L_tf_to_si)
 extern SItype float_to_si (FLO_type);
 #endif
 
-#if defined(L_sf_to_usi) || defined(L_df_to_usi)
-#ifdef US_SOFTWARE_GOFAST
+#if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
+#if defined(US_SOFTWARE_GOFAST) || defined(L_tf_to_usi)
 extern USItype float_to_usi (FLO_type);
 #endif
 #endif
 
-#if defined(L_usi_to_sf) || defined(L_usi_to_df)
+#if defined(L_usi_to_sf) || defined(L_usi_to_df) || defined(L_usi_to_tf)
 extern FLO_type usi_to_float (USItype);
 #endif
 
-#if defined(L_negate_sf) || defined(L_negate_df)
+#if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
 extern FLO_type negate (FLO_type);
 #endif
 
@@ -403,6 +500,9 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
 #if defined(L_sf_to_df)
 extern DFtype sf_to_df (SFtype);
 #endif
+#if defined(L_sf_to_tf) && defined(TMODES)
+extern TFtype sf_to_tf (SFtype);
+#endif
 #endif /* ! FLOAT_ONLY */
 #endif /* FLOAT */
 
@@ -414,6 +514,25 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
 #if defined(L_df_to_sf)
 extern SFtype df_to_sf (DFtype);
 #endif
+#if defined(L_df_to_tf) && defined(TMODES)
+extern TFtype df_to_tf (DFtype);
+#endif
 #endif /* ! FLOAT */
 
+#ifdef TMODES
+extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
+extern TFtype __make_tp (fp_class_type, unsigned int, int, UTItype);
+#ifdef TFLOAT
+#if defined(L_tf_to_sf)
+extern SFtype tf_to_sf (TFtype);
+#endif
+#if defined(L_tf_to_df)
+extern DFtype tf_to_df (TFtype);
+#endif
+#if defined(L_di_to_tf)
+extern TFtype di_to_df (DItype);
+#endif
+#endif /* TFLOAT */
+#endif /* TMODES */
+
 #endif /* ! GCC_FP_BIT_H */