Changeset c0c38c7c in mainline for uspace/lib/softfloat/mul.c


Ignore:
Timestamp:
2015-03-14T21:36:44Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7f9d97f3
Parents:
2c7fdaa
Message:

software floating point overhaul
use proper type mapping
fix cosine calculation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softfloat/mul.c

    r2c7fdaa rc0c38c7c  
    3434 */
    3535
    36 #include "sftypes.h"
    3736#include "mul.h"
    3837#include "comparison.h"
     
    6261                        return result;
    6362                }
     63               
    6464                if (is_float32_signan(b)) { /* TODO: fix SigNaN */
    6565                        result.parts.fraction = b.parts.fraction;
     
    6767                        return result;
    6868                }
     69               
    6970                /* set NaN as result */
    7071                result.bin = FLOAT32_NAN;
     
    7879                        return result;
    7980                }
     81               
    8082                result.parts.fraction = a.parts.fraction;
    8183                result.parts.exp = a.parts.exp;
     
    8991                        return result;
    9092                }
     93               
    9194                result.parts.fraction = b.parts.fraction;
    9295                result.parts.exp = b.parts.exp;
     
    106109        }
    107110       
    108         if (exp < 0) { 
     111        if (exp < 0) {
    109112                /* FIXME: underflow */
    110113                /* return signed zero */
     
    164167                /* denormalized number */
    165168                frac1 >>= 1; /* denormalize */
     169               
    166170                while ((frac1 > 0) && (exp < 0)) {
    167171                        frac1 >>= 1;
    168172                        ++exp;
    169173                }
     174               
    170175                if (frac1 == 0) {
    171176                        /* FIXME : underflow */
     
    175180                }
    176181        }
     182       
    177183        result.parts.exp = exp;
    178184        result.parts.fraction = frac1 & ((1 << FLOAT32_FRACTION_SIZE) - 1);
     
    380386}
    381387
     388#ifdef float32_t
     389
     390float32_t __mulsf3(float32_t a, float32_t b)
     391{
     392        float32_u ua;
     393        ua.val = a;
     394       
     395        float32_u ub;
     396        ub.val = b;
     397       
     398        float32_u res;
     399        res.data = mul_float32(ua.data, ub.data);
     400       
     401        return res.val;
     402}
     403
     404float32_t __aeabi_fmul(float32_t a, float32_t b)
     405{
     406        float32_u ua;
     407        ua.val = a;
     408       
     409        float32_u ub;
     410        ub.val = b;
     411       
     412        float32_u res;
     413        res.data = mul_float32(ua.data, ub.data);
     414       
     415        return res.val;
     416}
     417
     418#endif
     419
     420#ifdef float64_t
     421
     422float64_t __muldf3(float64_t a, float64_t b)
     423{
     424        float64_u ua;
     425        ua.val = a;
     426       
     427        float64_u ub;
     428        ub.val = b;
     429       
     430        float64_u res;
     431        res.data = mul_float64(ua.data, ub.data);
     432       
     433        return res.val;
     434}
     435
     436float64_t __aeabi_dmul(float64_t a, float64_t b)
     437{
     438        float64_u ua;
     439        ua.val = a;
     440       
     441        float64_u ub;
     442        ub.val = b;
     443       
     444        float64_u res;
     445        res.data = mul_float64(ua.data, ub.data);
     446       
     447        return res.val;
     448}
     449
     450#endif
     451
     452#ifdef float128_t
     453
     454float128_t __multf3(float128_t a, float128_t b)
     455{
     456        float128_u ua;
     457        ua.val = a;
     458       
     459        float128_u ub;
     460        ub.val = b;
     461       
     462        float128_u res;
     463        res.data = mul_float128(ua.data, ub.data);
     464       
     465        return res.val;
     466}
     467
     468void _Qp_mul(float128_t *c, float128_t *a, float128_t *b)
     469{
     470        *c = __multf3(*a, *b);
     471}
     472
     473#endif
     474
    382475/** @}
    383476 */
Note: See TracChangeset for help on using the changeset viewer.