diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-17 02:02:08 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-17 02:02:08 +0000 |
commit | 43e2d3be4f47f17838ddc7f98e2c6e87cefb59fd (patch) | |
tree | df5b1eab0ed6952e5bf3b44a3f604f1b97de876f /gcc/real.c | |
parent | 3713a25b77dfb726d5477e2c24ec4921a5cc5877 (diff) | |
download | gcc-43e2d3be4f47f17838ddc7f98e2c6e87cefb59fd.tar.gz |
* real.c (do_fix_trunc): New.
(real_arithmetic): Call it.
* simplify-rtx.c (simplify_unary_operation): Handle FIX
with a floating-point result mode.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57223 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r-- | gcc/real.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/real.c b/gcc/real.c index 5859f0ff878..dd9f9be4f98 100644 --- a/gcc/real.c +++ b/gcc/real.c @@ -174,6 +174,8 @@ static void do_divide PARAMS ((struct real_value *, const struct real_value *, const struct real_value *)); static int do_compare PARAMS ((const struct real_value *, const struct real_value *, int)); +static void do_fix_trunc PARAMS ((struct real_value *, + const struct real_value *)); static const struct real_value * ten_to_ptwo PARAMS ((int)); static const struct real_value * real_digit PARAMS ((int)); @@ -1013,6 +1015,34 @@ do_compare (a, b, nan_result) return (a->sign ? -ret : ret); } +/* Return A truncated to an integral value toward zero. */ + +void +do_fix_trunc (r, a) + struct real_value *r; + const struct real_value *a; +{ + *r = *a; + + switch (a->class) + { + case rvc_zero: + case rvc_inf: + case rvc_nan: + break; + + case rvc_normal: + if (r->exp <= 0) + get_zero (r, r->sign); + else if (r->exp < SIGNIFICAND_BITS) + clear_significand_below (r, SIGNIFICAND_BITS - r->exp); + break; + + default: + abort (); + } +} + /* Perform the binary or unary operation described by CODE. For a unary operation, leave OP1 NULL. */ @@ -1073,6 +1103,10 @@ real_arithmetic (tr, icode, top0, top1) r->sign = 0; break; + case FIX_TRUNC_EXPR: + do_fix_trunc (r, op0); + break; + default: abort (); } |