Commit ea976606 by Alexandre Oliva Committed by Alexandre Oliva

fp-bit.h: Define macros for TFmode floating-point constants in IEEE quad TFmode type.

* config/fp-bit.h: Define macros for TFmode floating-point
constants in IEEE quad TFmode type.  Declare functions according
to L_ macros.
(TMODES): Define if __LDBL_MANT_DIG__ is 113.
(TFtype, TItype, UTItype): Define if TMODES is defined.
(MAX_UDI_INT, MAX_DI_INT, BITS_PER_DI): Likewise.
(F_T_BITOFF, D_T_BITOFF): Define.
(IMPLICIT_1, IMPLICIT_2): Cast constants to types that are
guaranteed to be wide enough.
* config/fp-bit.c: Check for L_ macros for tf functions.
(__thenan_tf): New.
(nan): Adjust.
(pack_d, unpack_d): Support IEEE 854 quad type.
(_fpmul_parts): Support TFmode.  Compute exponent adjustment
from FRAC_NBITS, FRAC_BITS and NGARDS.
(usi_to_float): Cast constants to be shifted to fractype
instead of assuming long long is wide enough.
(sf_to_tf, df_to_tf, __make_tp, tf_to_df, tf_to_sf): New.

From-SVN: r61835
parent fd7fd61e
2003-01-26 Alexandre Oliva <aoliva@redhat.com>
* config/fp-bit.h: Define macros for TFmode floating-point
constants in IEEE quad TFmode type. Declare functions according
to L_ macros.
(TMODES): Define if __LDBL_MANT_DIG__ is 113.
(TFtype, TItype, UTItype): Define if TMODES is defined.
(MAX_UDI_INT, MAX_DI_INT, BITS_PER_DI): Likewise.
(F_T_BITOFF, D_T_BITOFF): Define.
(IMPLICIT_1, IMPLICIT_2): Cast constants to types that are
guaranteed to be wide enough.
* config/fp-bit.c: Check for L_ macros for tf functions.
(__thenan_tf): New.
(nan): Adjust.
(pack_d, unpack_d): Support IEEE 854 quad type.
(_fpmul_parts): Support TFmode. Compute exponent adjustment
from FRAC_NBITS, FRAC_BITS and NGARDS.
(usi_to_float): Cast constants to be shifted to fractype
instead of assuming long long is wide enough.
(sf_to_tf, df_to_tf, __make_tp, tf_to_df, tf_to_sf): New.
2003-01-26 Andreas Jaeger <aj@suse.de> 2003-01-26 Andreas Jaeger <aj@suse.de>
* df.c: Remove prototype of unused function df_regno_rtl_debug. * df.c: Remove prototype of unused function df_regno_rtl_debug.
......
/* This is a software floating point library which can be used /* This is a software floating point library which can be used
for targets without hardware floating point. for targets without hardware floating point.
Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify it This file is free software; you can redistribute it and/or modify it
...@@ -132,6 +132,10 @@ void __lttf2 (void) { abort(); } ...@@ -132,6 +132,10 @@ void __lttf2 (void) { abort(); }
const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} }; const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };
#elif defined L_thenan_df #elif defined L_thenan_df
const fp_number_type __thenan_df = { CLASS_SNAN, 0, 0, {(fractype) 0} }; 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 #elif defined FLOAT
extern const fp_number_type __thenan_sf; extern const fp_number_type __thenan_sf;
#else #else
...@@ -143,7 +147,9 @@ static fp_number_type * ...@@ -143,7 +147,9 @@ static fp_number_type *
nan (void) nan (void)
{ {
/* Discard the const qualifier... */ /* Discard the const qualifier... */
#ifdef FLOAT #ifdef TFLOAT
return (fp_number_type *) (& __thenan_tf);
#elif defined FLOAT
return (fp_number_type *) (& __thenan_sf); return (fp_number_type *) (& __thenan_sf);
#else #else
return (fp_number_type *) (& __thenan_df); return (fp_number_type *) (& __thenan_df);
...@@ -182,7 +188,7 @@ flip_sign ( fp_number_type * x) ...@@ -182,7 +188,7 @@ flip_sign ( fp_number_type * x)
extern FLO_type pack_d ( fp_number_type * ); extern FLO_type pack_d ( fp_number_type * );
#if defined(L_pack_df) || defined(L_pack_sf) #if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
FLO_type FLO_type
pack_d ( fp_number_type * src) pack_d ( fp_number_type * src)
{ {
...@@ -324,18 +330,29 @@ pack_d ( fp_number_type * src) ...@@ -324,18 +330,29 @@ pack_d ( fp_number_type * src)
#endif #endif
#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT) #if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
#ifdef TFLOAT
{
qrtrfractype tmp1 = dst.words[0];
qrtrfractype tmp2 = dst.words[1];
dst.words[0] = dst.words[3];
dst.words[1] = dst.words[2];
dst.words[2] = tmp2;
dst.words[3] = tmp1;
}
#else
{ {
halffractype tmp = dst.words[0]; halffractype tmp = dst.words[0];
dst.words[0] = dst.words[1]; dst.words[0] = dst.words[1];
dst.words[1] = tmp; dst.words[1] = tmp;
} }
#endif #endif
#endif
return dst.value; return dst.value;
} }
#endif #endif
#if defined(L_unpack_df) || defined(L_unpack_sf) #if defined(L_unpack_df) || defined(L_unpack_sf) || defined(L_unpack_tf)
void void
unpack_d (FLO_union_type * src, fp_number_type * dst) unpack_d (FLO_union_type * src, fp_number_type * dst)
{ {
...@@ -349,8 +366,15 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) ...@@ -349,8 +366,15 @@ unpack_d (FLO_union_type * src, fp_number_type * dst)
#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT) #if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
FLO_union_type swapped; FLO_union_type swapped;
#ifdef TFLOAT
swapped.words[0] = src->words[3];
swapped.words[1] = src->words[2];
swapped.words[2] = src->words[1];
swapped.words[3] = src->words[0];
#else
swapped.words[0] = src->words[1]; swapped.words[0] = src->words[1];
swapped.words[1] = src->words[0]; swapped.words[1] = src->words[0];
#endif
src = &swapped; src = &swapped;
#endif #endif
...@@ -359,7 +383,7 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) ...@@ -359,7 +383,7 @@ unpack_d (FLO_union_type * src, fp_number_type * dst)
exp = src->bits.exp; exp = src->bits.exp;
sign = src->bits.sign; sign = src->bits.sign;
#else #else
fraction = src->value_raw & ((((fractype)1) << FRACBITS) - (fractype)1); fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1);
exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1); exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1);
sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1; sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1;
#endif #endif
...@@ -429,7 +453,7 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) ...@@ -429,7 +453,7 @@ unpack_d (FLO_union_type * src, fp_number_type * dst)
} }
#endif /* L_unpack_df || L_unpack_sf */ #endif /* L_unpack_df || L_unpack_sf */
#if defined(L_addsub_sf) || defined(L_addsub_df) #if defined(L_addsub_sf) || defined(L_addsub_df) || defined(L_addsub_tf)
static fp_number_type * static fp_number_type *
_fpadd_parts (fp_number_type * a, _fpadd_parts (fp_number_type * a,
fp_number_type * b, fp_number_type * b,
...@@ -613,7 +637,7 @@ sub (FLO_type arg_a, FLO_type arg_b) ...@@ -613,7 +637,7 @@ sub (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_addsub_sf || L_addsub_df */ #endif /* L_addsub_sf || L_addsub_df */
#if defined(L_mul_sf) || defined(L_mul_df) #if defined(L_mul_sf) || defined(L_mul_df) || defined(L_mul_tf)
static inline __attribute__ ((__always_inline__)) fp_number_type * static inline __attribute__ ((__always_inline__)) fp_number_type *
_fpmul_parts ( fp_number_type * a, _fpmul_parts ( fp_number_type * a,
fp_number_type * b, fp_number_type * b,
...@@ -662,7 +686,7 @@ _fpmul_parts ( fp_number_type * a, ...@@ -662,7 +686,7 @@ _fpmul_parts ( fp_number_type * a,
/* Calculate the mantissa by multiplying both numbers to get a /* Calculate the mantissa by multiplying both numbers to get a
twice-as-wide number. */ twice-as-wide number. */
{ {
#if defined(NO_DI_MODE) #if defined(NO_DI_MODE) || defined(TFLOAT)
{ {
fractype x = a->fraction.ll; fractype x = a->fraction.ll;
fractype ylow = b->fraction.ll; fractype ylow = b->fraction.ll;
...@@ -725,13 +749,9 @@ _fpmul_parts ( fp_number_type * a, ...@@ -725,13 +749,9 @@ _fpmul_parts ( fp_number_type * a,
#endif #endif
} }
tmp->normal_exp = a->normal_exp + b->normal_exp; tmp->normal_exp = a->normal_exp + b->normal_exp
+ FRAC_NBITS - (FRACBITS + NGARDS);
tmp->sign = a->sign != b->sign; tmp->sign = a->sign != b->sign;
#ifdef FLOAT
tmp->normal_exp += 2; /* ??????????????? */
#else
tmp->normal_exp += 4; /* ??????????????? */
#endif
while (high >= IMPLICIT_2) while (high >= IMPLICIT_2)
{ {
tmp->normal_exp++; tmp->normal_exp++;
...@@ -805,7 +825,7 @@ multiply (FLO_type arg_a, FLO_type arg_b) ...@@ -805,7 +825,7 @@ multiply (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_mul_sf || L_mul_df */ #endif /* L_mul_sf || L_mul_df */
#if defined(L_div_sf) || defined(L_div_df) #if defined(L_div_sf) || defined(L_div_df) || defined(L_div_tf)
static inline __attribute__ ((__always_inline__)) fp_number_type * static inline __attribute__ ((__always_inline__)) fp_number_type *
_fpdiv_parts (fp_number_type * a, _fpdiv_parts (fp_number_type * a,
fp_number_type * b) fp_number_type * b)
...@@ -915,7 +935,8 @@ divide (FLO_type arg_a, FLO_type arg_b) ...@@ -915,7 +935,8 @@ divide (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_div_sf || L_div_df */ #endif /* L_div_sf || L_div_df */
#if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) #if defined(L_fpcmp_parts_sf) || defined(L_fpcmp_parts_df) \
|| defined(L_fpcmp_parts_tf)
/* according to the demo, fpcmp returns a comparison with 0... thus /* according to the demo, fpcmp returns a comparison with 0... thus
a<b -> -1 a<b -> -1
a==b -> 0 a==b -> 0
...@@ -1000,7 +1021,7 @@ __fpcmp_parts (fp_number_type * a, fp_number_type * b) ...@@ -1000,7 +1021,7 @@ __fpcmp_parts (fp_number_type * a, fp_number_type * b)
} }
#endif #endif
#if defined(L_compare_sf) || defined(L_compare_df) #if defined(L_compare_sf) || defined(L_compare_df) || defined(L_compoare_tf)
CMPtype CMPtype
compare (FLO_type arg_a, FLO_type arg_b) compare (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1022,7 +1043,7 @@ compare (FLO_type arg_a, FLO_type arg_b) ...@@ -1022,7 +1043,7 @@ compare (FLO_type arg_a, FLO_type arg_b)
/* These should be optimized for their specific tasks someday. */ /* These should be optimized for their specific tasks someday. */
#if defined(L_eq_sf) || defined(L_eq_df) #if defined(L_eq_sf) || defined(L_eq_df) || defined(L_eq_tf)
CMPtype CMPtype
_eq_f2 (FLO_type arg_a, FLO_type arg_b) _eq_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1043,7 +1064,7 @@ _eq_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1043,7 +1064,7 @@ _eq_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_eq_sf || L_eq_df */ #endif /* L_eq_sf || L_eq_df */
#if defined(L_ne_sf) || defined(L_ne_df) #if defined(L_ne_sf) || defined(L_ne_df) || defined(L_ne_tf)
CMPtype CMPtype
_ne_f2 (FLO_type arg_a, FLO_type arg_b) _ne_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1064,7 +1085,7 @@ _ne_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1064,7 +1085,7 @@ _ne_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_ne_sf || L_ne_df */ #endif /* L_ne_sf || L_ne_df */
#if defined(L_gt_sf) || defined(L_gt_df) #if defined(L_gt_sf) || defined(L_gt_df) || defined(L_gt_tf)
CMPtype CMPtype
_gt_f2 (FLO_type arg_a, FLO_type arg_b) _gt_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1085,7 +1106,7 @@ _gt_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1085,7 +1106,7 @@ _gt_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_gt_sf || L_gt_df */ #endif /* L_gt_sf || L_gt_df */
#if defined(L_ge_sf) || defined(L_ge_df) #if defined(L_ge_sf) || defined(L_ge_df) || defined(L_ge_tf)
CMPtype CMPtype
_ge_f2 (FLO_type arg_a, FLO_type arg_b) _ge_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1105,7 +1126,7 @@ _ge_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1105,7 +1126,7 @@ _ge_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_ge_sf || L_ge_df */ #endif /* L_ge_sf || L_ge_df */
#if defined(L_lt_sf) || defined(L_lt_df) #if defined(L_lt_sf) || defined(L_lt_df) || defined(L_lt_tf)
CMPtype CMPtype
_lt_f2 (FLO_type arg_a, FLO_type arg_b) _lt_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1126,7 +1147,7 @@ _lt_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1126,7 +1147,7 @@ _lt_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_lt_sf || L_lt_df */ #endif /* L_lt_sf || L_lt_df */
#if defined(L_le_sf) || defined(L_le_df) #if defined(L_le_sf) || defined(L_le_df) || defined(L_le_tf)
CMPtype CMPtype
_le_f2 (FLO_type arg_a, FLO_type arg_b) _le_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1149,7 +1170,7 @@ _le_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1149,7 +1170,7 @@ _le_f2 (FLO_type arg_a, FLO_type arg_b)
#endif /* ! US_SOFTWARE_GOFAST */ #endif /* ! US_SOFTWARE_GOFAST */
#if defined(L_unord_sf) || defined(L_unord_df) #if defined(L_unord_sf) || defined(L_unord_df) || defined(L_unord_tf)
CMPtype CMPtype
_unord_f2 (FLO_type arg_a, FLO_type arg_b) _unord_f2 (FLO_type arg_a, FLO_type arg_b)
{ {
...@@ -1167,7 +1188,7 @@ _unord_f2 (FLO_type arg_a, FLO_type arg_b) ...@@ -1167,7 +1188,7 @@ _unord_f2 (FLO_type arg_a, FLO_type arg_b)
} }
#endif /* L_unord_sf || L_unord_df */ #endif /* L_unord_sf || L_unord_df */
#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)
FLO_type FLO_type
si_to_float (SItype arg_a) si_to_float (SItype arg_a)
{ {
...@@ -1195,7 +1216,7 @@ si_to_float (SItype arg_a) ...@@ -1195,7 +1216,7 @@ si_to_float (SItype arg_a)
else else
in.fraction.ll = arg_a; in.fraction.ll = arg_a;
while (in.fraction.ll < (1LL << (FRACBITS + NGARDS))) while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
{ {
in.fraction.ll <<= 1; in.fraction.ll <<= 1;
in.normal_exp -= 1; in.normal_exp -= 1;
...@@ -1205,7 +1226,7 @@ si_to_float (SItype arg_a) ...@@ -1205,7 +1226,7 @@ si_to_float (SItype arg_a)
} }
#endif /* L_si_to_sf || L_si_to_df */ #endif /* L_si_to_sf || L_si_to_df */
#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)
FLO_type FLO_type
usi_to_float (USItype arg_a) usi_to_float (USItype arg_a)
{ {
...@@ -1222,12 +1243,12 @@ usi_to_float (USItype arg_a) ...@@ -1222,12 +1243,12 @@ usi_to_float (USItype arg_a)
in.normal_exp = FRACBITS + NGARDS; in.normal_exp = FRACBITS + NGARDS;
in.fraction.ll = arg_a; in.fraction.ll = arg_a;
while (in.fraction.ll > (1LL << (FRACBITS + NGARDS))) while (in.fraction.ll > ((fractype)1 << (FRACBITS + NGARDS)))
{ {
in.fraction.ll >>= 1; in.fraction.ll >>= 1;
in.normal_exp += 1; in.normal_exp += 1;
} }
while (in.fraction.ll < (1LL << (FRACBITS + NGARDS))) while (in.fraction.ll < ((fractype)1 << (FRACBITS + NGARDS)))
{ {
in.fraction.ll <<= 1; in.fraction.ll <<= 1;
in.normal_exp -= 1; in.normal_exp -= 1;
...@@ -1237,7 +1258,7 @@ usi_to_float (USItype arg_a) ...@@ -1237,7 +1258,7 @@ usi_to_float (USItype arg_a)
} }
#endif #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)
SItype SItype
float_to_si (FLO_type arg_a) float_to_si (FLO_type arg_a)
{ {
...@@ -1265,8 +1286,8 @@ float_to_si (FLO_type arg_a) ...@@ -1265,8 +1286,8 @@ float_to_si (FLO_type arg_a)
} }
#endif /* L_sf_to_si || L_df_to_si */ #endif /* L_sf_to_si || L_df_to_si */
#if defined(L_sf_to_usi) || defined(L_df_to_usi) #if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
#ifdef US_SOFTWARE_GOFAST #if defined US_SOFTWARE_GOFAST || defined(L_tf_to_usi)
/* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines, /* While libgcc2.c defines its own __fixunssfsi and __fixunsdfsi routines,
we also define them for GOFAST because the ones in libgcc2.c have the we also define them for GOFAST because the ones in libgcc2.c have the
wrong names and I'd rather define these here and keep GOFAST CYG-LOC's wrong names and I'd rather define these here and keep GOFAST CYG-LOC's
...@@ -1305,7 +1326,7 @@ float_to_usi (FLO_type arg_a) ...@@ -1305,7 +1326,7 @@ float_to_usi (FLO_type arg_a)
#endif /* US_SOFTWARE_GOFAST */ #endif /* US_SOFTWARE_GOFAST */
#endif /* L_sf_to_usi || L_df_to_usi */ #endif /* L_sf_to_usi || L_df_to_usi */
#if defined(L_negate_sf) || defined(L_negate_df) #if defined(L_negate_sf) || defined(L_negate_df) || defined(L_negate_tf)
FLO_type FLO_type
negate (FLO_type arg_a) negate (FLO_type arg_a)
{ {
...@@ -1361,6 +1382,21 @@ sf_to_df (SFtype arg_a) ...@@ -1361,6 +1382,21 @@ sf_to_df (SFtype arg_a)
} }
#endif /* L_sf_to_df */ #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_ONLY */
#endif /* FLOAT */ #endif /* FLOAT */
...@@ -1404,5 +1440,84 @@ df_to_sf (DFtype arg_a) ...@@ -1404,5 +1440,84 @@ df_to_sf (DFtype arg_a)
} }
#endif /* L_df_to_sf */ #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 /* ! FLOAT */
#endif /* !EXTENDED_FLOAT_STUBS */ #endif /* !EXTENDED_FLOAT_STUBS */
/* Header file for fp-bit.c. */ /* Header file for fp-bit.c. */
/* Copyright (C) 2000 /* Copyright (C) 2000, 2002, 2003
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -87,12 +87,22 @@ Boston, MA 02111-1307, USA. */ ...@@ -87,12 +87,22 @@ Boston, MA 02111-1307, USA. */
#endif #endif
#endif /* ! FINE_GRAINED_LIBRARIES */ #endif /* ! FINE_GRAINED_LIBRARIES */
#if __LDBL_MANT_DIG__ == 113
# define TMODES
#endif
typedef float SFtype __attribute__ ((mode (SF))); typedef float SFtype __attribute__ ((mode (SF)));
typedef float DFtype __attribute__ ((mode (DF))); typedef float DFtype __attribute__ ((mode (DF)));
#ifdef TMODES
typedef float TFtype __attribute__ ((mode (TF)));
#endif
typedef int HItype __attribute__ ((mode (HI))); typedef int HItype __attribute__ ((mode (HI)));
typedef int SItype __attribute__ ((mode (SI))); typedef int SItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI))); 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 fp compare */
#ifndef CMPtype #ifndef CMPtype
...@@ -102,16 +112,56 @@ typedef int DItype __attribute__ ((mode (DI))); ...@@ -102,16 +112,56 @@ typedef int DItype __attribute__ ((mode (DI)));
typedef unsigned int UHItype __attribute__ ((mode (HI))); typedef unsigned int UHItype __attribute__ ((mode (HI)));
typedef unsigned int USItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef unsigned int UDItype __attribute__ ((mode (DI))); 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_USI_INT (~(USItype)0)
#define MAX_SI_INT ((SItype) (MAX_USI_INT >> 1)) #define MAX_SI_INT ((SItype) (MAX_USI_INT >> 1))
#define BITS_PER_SI (4 * BITS_PER_UNIT) #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 #ifdef FLOAT_ONLY
#define NO_DI_MODE #define NO_DI_MODE
#endif #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
# 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 NGARDS 7L
# define GARDROUND 0x3f # define GARDROUND 0x3f
# define GARDMASK 0x7f # define GARDMASK 0x7f
...@@ -157,7 +207,9 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -157,7 +207,9 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
#endif /* FLOAT */ #endif /* FLOAT */
#ifdef US_SOFTWARE_GOFAST #ifdef US_SOFTWARE_GOFAST
# ifdef FLOAT # ifdef TFLOAT
# error "GOFAST TFmode not supported"
# elif defined FLOAT
# define add fpadd # define add fpadd
# define sub fpsub # define sub fpsub
# define multiply fpmul # define multiply fpmul
...@@ -170,8 +222,8 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -170,8 +222,8 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
# define float_to_usi fptoui # define float_to_usi fptoui
# define negate __negsf2 # define negate __negsf2
# define sf_to_df fptodp # define sf_to_df fptodp
# define dptofp dptofp # define sf_to_tf __extendsftf2
#else # else
# define add dpadd # define add dpadd
# define sub dpsub # define sub dpsub
# define multiply dpmul # define multiply dpmul
...@@ -184,9 +236,30 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -184,9 +236,30 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
# define float_to_usi dptoul # define float_to_usi dptoul
# define negate __negdf2 # define negate __negdf2
# define df_to_sf dptofp # define df_to_sf dptofp
# define df_to_tf __extenddftf2
# endif /* FLOAT */ # endif /* FLOAT */
#else #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 add __addsf3
# define sub __subsf3 # define sub __subsf3
# define multiply __mulsf3 # define multiply __mulsf3
...@@ -205,7 +278,8 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -205,7 +278,8 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
# define float_to_usi __fixunssfsi # define float_to_usi __fixunssfsi
# define negate __negsf2 # define negate __negsf2
# define sf_to_df __extendsfdf2 # define sf_to_df __extendsfdf2
#else # define sf_to_tf __extendsftf2
# else
# define add __adddf3 # define add __adddf3
# define sub __subdf3 # define sub __subdf3
# define multiply __muldf3 # define multiply __muldf3
...@@ -224,6 +298,7 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -224,6 +298,7 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
# define float_to_usi __fixunsdfsi # define float_to_usi __fixunsdfsi
# define negate __negdf2 # define negate __negdf2
# define df_to_sf __truncdfsf2 # define df_to_sf __truncdfsf2
# define df_to_tf __extenddftf2
# endif /* FLOAT */ # endif /* FLOAT */
#endif /* US_SOFTWARE_GOFAST */ #endif /* US_SOFTWARE_GOFAST */
...@@ -241,10 +316,15 @@ typedef unsigned int UDItype __attribute__ ((mode (DI))); ...@@ -241,10 +316,15 @@ typedef unsigned int UDItype __attribute__ ((mode (DI)));
*/ */
#define F_D_BITOFF (52+8-(23+7)) #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 NORMAL_EXPMIN (-(EXPBIAS)+1)
#define IMPLICIT_1 (1LL<<(FRACBITS+NGARDS)) #define IMPLICIT_1 ((fractype)1<<(FRACBITS+NGARDS))
#define IMPLICIT_2 (1LL<<(FRACBITS+1+NGARDS)) #define IMPLICIT_2 ((fractype)1<<(FRACBITS+1+NGARDS))
/* common types */ /* common types */
...@@ -282,7 +362,11 @@ typedef union ...@@ -282,7 +362,11 @@ typedef union
fractype value_raw; fractype value_raw;
#ifndef FLOAT #ifndef FLOAT
# ifdef qrtrfractype
qrtrfractype qwords[4];
# else
halffractype words[2]; halffractype words[2];
# endif
#endif #endif
#ifdef FLOAT_BIT_ORDER_MISMATCH #ifdef FLOAT_BIT_ORDER_MISMATCH
...@@ -317,82 +401,82 @@ FLO_union_type; ...@@ -317,82 +401,82 @@ FLO_union_type;
/* Prototypes */ /* Prototypes */
#if defined(L_pack_df) || defined(L_pack_sf) #if defined(L_pack_df) || defined(L_pack_sf) || defined(L_pack_tf)
extern FLO_type pack_d (fp_number_type *); extern FLO_type pack_d (fp_number_type *);
#endif #endif
extern void unpack_d (FLO_union_type *, fp_number_type *); 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 add (FLO_type, FLO_type);
extern FLO_type sub (FLO_type, FLO_type); extern FLO_type sub (FLO_type, FLO_type);
#endif #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); extern FLO_type multiply (FLO_type, FLO_type);
#endif #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); extern FLO_type divide (FLO_type, FLO_type);
#endif #endif
extern int __fpcmp_parts (fp_number_type *, fp_number_type *); 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); extern CMPtype compare (FLO_type, FLO_type);
#endif #endif
#ifndef US_SOFTWARE_GOFAST #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); extern CMPtype _eq_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _ne_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _gt_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _ge_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _lt_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _le_f2 (FLO_type, FLO_type);
#endif #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); extern CMPtype _unord_f2 (FLO_type, FLO_type);
#endif #endif
#endif /* ! US_SOFTWARE_GOFAST */ #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); extern FLO_type si_to_float (SItype);
#endif #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); extern SItype float_to_si (FLO_type);
#endif #endif
#if defined(L_sf_to_usi) || defined(L_df_to_usi) #if defined(L_sf_to_usi) || defined(L_df_to_usi) || defined(L_tf_to_usi)
#ifdef US_SOFTWARE_GOFAST #ifdef US_SOFTWARE_GOFAST
extern USItype float_to_usi (FLO_type); extern USItype float_to_usi (FLO_type);
#endif #endif
#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); extern FLO_type usi_to_float (USItype);
#endif #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); extern FLO_type negate (FLO_type);
#endif #endif
...@@ -405,6 +489,9 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype); ...@@ -405,6 +489,9 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
#if defined(L_sf_to_df) #if defined(L_sf_to_df)
extern DFtype sf_to_df (SFtype); extern DFtype sf_to_df (SFtype);
#endif #endif
#if defined(L_sf_to_tf) && defined(TMODES)
extern TFtype sf_to_tf (SFtype);
#endif
#endif /* ! FLOAT_ONLY */ #endif /* ! FLOAT_ONLY */
#endif /* FLOAT */ #endif /* FLOAT */
...@@ -416,6 +503,24 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype); ...@@ -416,6 +503,24 @@ extern DFtype __make_dp (fp_class_type, unsigned int, int, UDItype);
#if defined(L_df_to_sf) #if defined(L_df_to_sf)
extern SFtype df_to_sf (DFtype); extern SFtype df_to_sf (DFtype);
#endif #endif
#if defined(L_df_to_tf) && defined(TMODES)
extern TFtype df_to_tf (DFtype);
#endif
#endif /* ! FLOAT */ #endif /* ! FLOAT */
#ifdef TMODES
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 */ #endif /* ! GCC_FP_BIT_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment