Changeset 8b863a62 in mainline for uspace/lib/softfloat


Ignore:
Timestamp:
2014-04-16T17:14:06Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f857e8b
Parents:
dba3e2c (diff), 70b570c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Location:
uspace/lib/softfloat
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softfloat/Makefile

    rdba3e2c r8b863a62  
    3030USPACE_PREFIX = ../..
    3131LIBRARY = libsoftfloat
     32MATH = y
    3233
    3334SOURCES = \
     
    3940        mul.c \
    4041        comparison.c \
    41         conversion.c \
    42         other.c
     42        conversion.c
    4343
    4444include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/softfloat/conversion.c

    rdba3e2c r8b863a62  
    217217                result.parts.exp = 0;
    218218               
    219                 exp *= -1;     
     219                exp *= -1;
    220220                if (exp > FLOAT32_FRACTION_SIZE) {
    221221                        /* FIXME: underflow */
     
    891891}
    892892
    893 
    894893float64 uint64_to_float64(uint64_t i)
    895894{
  • uspace/lib/softfloat/sftypes.h

    rdba3e2c r8b863a62  
    3434 */
    3535
    36 #ifndef __SFTYPES_H__
    37 #define __SFTYPES_H__
    38 
    39 #include <byteorder.h>
    40 #include <stdint.h>
    41 
    42 /*
    43  * For recognizing NaNs or infinity use specialized comparison
    44  * functions, comparing with these constants is not sufficient.
    45  */
    46 
    47 #define FLOAT32_NAN     UINT32_C(0x7FC00001)
    48 #define FLOAT32_SIGNAN  UINT32_C(0x7F800001)
    49 #define FLOAT32_INF     UINT32_C(0x7F800000)
    50 
    51 #define FLOAT64_NAN     UINT64_C(0x7FF8000000000001)
    52 #define FLOAT64_SIGNAN  UINT64_C(0x7FF0000000000001)
    53 #define FLOAT64_INF     UINT64_C(0x7FF0000000000000)
    54 
    55 #define FLOAT96_NAN_HI     UINT64_C(0x7FFF80000000)
    56 #define FLOAT96_NAN_LO     UINT32_C(0x00010000)
    57 #define FLOAT96_SIGNAN_HI  UINT64_C(0x7FFF00000000)
    58 #define FLOAT96_SIGNAN_LO  UINT32_C(0x00010000)
    59 
    60 #define FLOAT128_NAN_HI     UINT64_C(0x7FFF800000000000)
    61 #define FLOAT128_NAN_LO     UINT64_C(0x0000000000000001)
    62 #define FLOAT128_SIGNAN_HI  UINT64_C(0x7FFF000000000000)
    63 #define FLOAT128_SIGNAN_LO  UINT64_C(0x0000000000000001)
    64 #define FLOAT128_INF_HI     UINT64_C(0x7FFF000000000000)
    65 #define FLOAT128_INF_LO     UINT64_C(0x0000000000000000)
    66 
    67 #define FLOAT32_FRACTION_SIZE   23
    68 #define FLOAT64_FRACTION_SIZE   52
    69 #define FLOAT96_FRACTION_SIZE   64
    70 #define FLOAT128_FRACTION_SIZE  112
    71 #define FLOAT128_FRAC_HI_SIZE   48
    72 #define FLOAT128_FRAC_LO_SIZE   64
    73 
    74 #define FLOAT32_HIDDEN_BIT_MASK      UINT32_C(0x800000)
    75 #define FLOAT64_HIDDEN_BIT_MASK      UINT64_C(0x10000000000000)
    76 #define FLOAT128_HIDDEN_BIT_MASK_HI  UINT64_C(0x1000000000000)
    77 #define FLOAT128_HIDDEN_BIT_MASK_LO  UINT64_C(0x0000000000000000)
    78 
    79 #define FLOAT32_MAX_EXPONENT   0xFF
    80 #define FLOAT64_MAX_EXPONENT   0x7FF
    81 #define FLOAT96_MAX_EXPONENT   0x7FFF
    82 #define FLOAT128_MAX_EXPONENT  0x7FFF
    83 
    84 #define FLOAT32_BIAS   0x7F
    85 #define FLOAT64_BIAS   0x3FF
    86 #define FLOAT96_BIAS   0x3FFF
    87 #define FLOAT128_BIAS  0x3FFF
    88 
    89 #if defined(__BE__)
    90 
    91 typedef union {
    92         uint32_t bin;
    93        
    94         struct {
    95                 uint32_t sign : 1;
    96                 uint32_t exp : 8;
    97                 uint32_t fraction : 23;
    98         } parts __attribute__((packed));
    99 } float32;
    100 
    101 typedef union {
    102         uint64_t bin;
    103        
    104         struct {
    105                 uint64_t sign : 1;
    106                 uint64_t exp : 11;
    107                 uint64_t fraction : 52;
    108         } parts __attribute__((packed));
    109 } float64;
    110 
    111 typedef union {
    112         struct {
    113                 uint64_t hi;
    114                 uint32_t lo;
    115         } bin __attribute__((packed));
    116        
    117         struct {
    118                 uint64_t padding : 16;
    119                 uint64_t sign : 1;
    120                 uint64_t exp : 15;
    121                 uint64_t fraction : 64;
    122         } parts __attribute__((packed));
    123 } float96;
    124 
    125 typedef union {
    126         struct {
    127                 uint64_t hi;
    128                 uint64_t lo;
    129         } bin __attribute__((packed));
    130        
    131         struct {
    132                 uint64_t sign : 1;
    133                 uint64_t exp : 15;
    134                 uint64_t frac_hi : 48;
    135                 uint64_t frac_lo : 64;
    136         } parts __attribute__((packed));
    137 } float128;
    138 
    139 #elif defined(__LE__)
    140 
    141 typedef union {
    142         uint32_t bin;
    143        
    144         struct {
    145                 uint32_t fraction : 23;
    146                 uint32_t exp : 8;
    147                 uint32_t sign : 1;
    148         } parts __attribute__((packed));
    149 } float32;
    150 
    151 typedef union {
    152         uint64_t bin;
    153        
    154         struct {
    155                 uint64_t fraction : 52;
    156                 uint64_t exp : 11;
    157                 uint64_t sign : 1;
    158         } parts __attribute__((packed));
    159 } float64;
    160 
    161 typedef union {
    162         struct {
    163                 uint32_t lo;
    164                 uint64_t hi;
    165         } bin __attribute__((packed));
    166        
    167         struct {
    168                 uint64_t fraction : 64;
    169                 uint64_t exp : 15;
    170                 uint64_t sign : 1;
    171                 uint64_t padding : 16;
    172         } parts __attribute__((packed));
    173 } float96;
    174 
    175 typedef union {
    176         struct {
    177                 uint64_t lo;
    178                 uint64_t hi;
    179         } bin __attribute__((packed));
    180        
    181         struct {
    182                 uint64_t frac_lo : 64;
    183                 uint64_t frac_hi : 48;
    184                 uint64_t exp : 15;
    185                 uint64_t sign : 1;
    186         } parts __attribute__((packed));
    187 } float128;
    188 
    189 #else
    190         #error Unknown endianess
    191 #endif
    192 
    193 typedef union {
    194         float val;
    195        
    196 #if defined(FLOAT_SIZE_32)
    197         float32 data;
    198 #elif defined(FLOAT_SIZE_64)
    199         float64 data;
    200 #elif defined(FLOAT_SIZE_96)
    201         float96 data;
    202 #elif defined(FLOAT_SIZE_128)
    203         float128 data;
    204 #else
    205         #error Unsupported float size
    206 #endif
    207 } float_t;
    208 
    209 typedef union {
    210         double val;
    211        
    212 #if defined(DOUBLE_SIZE_32)
    213         float32 data;
    214 #elif defined(DOUBLE_SIZE_64)
    215         float64 data;
    216 #elif defined(DOUBLE_SIZE_96)
    217         float96 data;
    218 #elif defined(DOUBLE_SIZE_128)
    219         float128 data;
    220 #else
    221         #error Unsupported double size
    222 #endif
    223 } double_t;
    224 
    225 typedef union {
    226         long double val;
    227        
    228 #if defined(LONG_DOUBLE_SIZE_32)
    229         float32 data;
    230 #elif defined(LONG_DOUBLE_SIZE_64)
    231         float64 data;
    232 #elif defined(LONG_DOUBLE_SIZE_96)
    233         float96 data;
    234 #elif defined(LONG_DOUBLE_SIZE_128)
    235         float128 data;
    236 #else
    237         #error Unsupported long double size
    238 #endif
    239 } long_double_t;
    240 
     36#ifndef SOFTFLOAT_SFTYPES_H__
     37#define SOFTFLOAT_SFTYPES_H__
     38
     39#include <mathtypes.h>
    24140
    24241#if defined(INT_SIZE_8)
     
    602401#define ullong_to_long_double  CONCAT(from_ullong, _to_long_double)
    603402
    604 
    605403#endif
    606404
  • uspace/lib/softfloat/softfloat.c

    rdba3e2c r8b863a62  
    4444#include "conversion.h"
    4545#include "comparison.h"
    46 #include "other.h"
    4746
    4847/* Arithmetic functions */
     
    12651264}
    12661265
     1266float __aeabi_d2f(double a)
     1267{
     1268        return __truncdfsf2(a);
     1269}
     1270
     1271double __aeabi_f2d(float a)
     1272{
     1273        return __extendsfdf2(a);
     1274}
     1275
     1276
     1277float __aeabi_i2f(int i)
     1278{
     1279        return __floatsisf(i);
     1280}
     1281
     1282float __aeabi_ui2f(int i)
     1283{
     1284        return __floatunsisf(i);
     1285}
     1286
    12671287double __aeabi_i2d(int i)
    12681288{
     
    12751295}
    12761296
     1297double __aeabi_l2d(long long i)
     1298{
     1299        return __floattidf(i);
     1300}
     1301
     1302float __aeabi_l2f(long long i)
     1303{
     1304        return __floattisf(i);
     1305}
     1306
     1307float __aeabi_ul2f(unsigned long long u)
     1308{
     1309        return __floatuntisf(u);
     1310}
     1311
    12771312int __aeabi_f2iz(float a)
    12781313{
     
    12801315}
    12811316
     1317int __aeabi_f2uiz(float a)
     1318{
     1319        return __fixunssfsi(a);
     1320}
     1321
    12821322int __aeabi_d2iz(double a)
    12831323{
     
    12901330}
    12911331
     1332long long __aeabi_d2lz(double a)
     1333{
     1334        return __fixdfti(a);
     1335}
     1336
     1337int __aeabi_fcmpge(float a, float b)
     1338{
     1339        return __gesf2(a, b);
     1340}
     1341
     1342int __aeabi_fcmpgt(float a, float b)
     1343{
     1344        return __gtsf2(a, b);
     1345}
     1346
     1347int __aeabi_fcmplt(float a, float b)
     1348{
     1349        return __ltsf2(a, b);
     1350}
     1351
     1352int __aeabi_fcmpeq(float a, float b)
     1353{
     1354        return __eqsf2(a, b);
     1355}
     1356
    12921357int __aeabi_dcmpge(double a, double b)
    12931358{
     
    13031368{
    13041369        return __ltdf2(a, b);
     1370}
     1371
     1372int __aeabi_dcmple(double a, double b)
     1373{
     1374        return __ledf2(a, b);
    13051375}
    13061376
  • uspace/lib/softfloat/softfloat.h

    rdba3e2c r8b863a62  
    204204
    205205/* ARM EABI */
     206extern float __aeabi_d2f(double);
     207extern double __aeabi_f2d(float);
     208extern float __aeabi_i2f(int);
     209extern float __aeabi_ui2f(int);
    206210extern double __aeabi_i2d(int);
    207211extern double __aeabi_ui2d(unsigned int);
     212extern double __aeabi_l2d(long long);
     213extern float __aeabi_l2f(long long);
     214extern float __aeabi_ul2f(unsigned long long);
    208215extern unsigned int __aeabi_d2uiz(double);
     216extern long long __aeabi_d2lz(double);
    209217
    210218extern int __aeabi_f2iz(float);
     219extern int __aeabi_f2uiz(float);
    211220extern int __aeabi_d2iz(double);
     221
     222extern int __aeabi_fcmpge(float, float);
     223extern int __aeabi_fcmpgt(float, float);
     224extern int __aeabi_fcmplt(float, float);
     225extern int __aeabi_fcmpeq(float, float);
    212226
    213227extern int __aeabi_dcmpge(double, double);
    214228extern int __aeabi_dcmpgt(double, double);
    215229extern int __aeabi_dcmplt(double, double);
     230extern int __aeabi_dcmple(double, double);
    216231extern int __aeabi_dcmpeq(double, double);
    217232
Note: See TracChangeset for help on using the changeset viewer.