35 #include "softfloat_orig.h"
36 #include "internals.h"
37 #include "specialize.h"
43 softfloat_round_near_even ,
44 softfloat_round_minMag,
47 softfloat_round_near_maxMag ,
56 return softfloat_exceptionFlags&0x1f;
60 float32_t v1f{v1},v2f{v2};
62 softfloat_exceptionFlags=0;
63 float32_t r =f32_add(v1f, v2f);
68 float32_t v1f{v1},v2f{v2};
70 softfloat_exceptionFlags=0;
71 float32_t r=f32_sub(v1f, v2f);
76 float32_t v1f{v1},v2f{v2};
78 softfloat_exceptionFlags=0;
79 float32_t r=f32_mul(v1f, v2f);
84 float32_t v1f{v1},v2f{v2};
86 softfloat_exceptionFlags=0;
87 float32_t r=f32_div(v1f, v2f);
94 softfloat_exceptionFlags=0;
95 float32_t r=f32_sqrt(v1f);
100 float32_t v1f{v1},v2f{v2};
101 softfloat_exceptionFlags=0;
103 bool snan = softfloat_isSigNaNF32UI(v1) || softfloat_isSigNaNF32UI(v2);
107 if(snan) softfloat_raiseFlags(softfloat_flag_invalid);
110 return f32_eq(v1f,v2f )?1:0;
113 softfloat_raiseFlags(softfloat_flag_invalid);
116 return f32_le(v1f,v2f )?1:0;
119 softfloat_raiseFlags(softfloat_flag_invalid);
122 return f32_lt(v1f,v2f )?1:0;
131 softfloat_exceptionFlags=0;
135 uint_fast32_t res = f32_to_i32(v1f,
rmm_map[
mode&0x7],
true);
139 uint_fast32_t res = f32_to_ui32(v1f,
rmm_map[
mode&0x7],
true);
155 softfloat_exceptionFlags=0;
156 float32_t res = softfloat_mulAddF32(v1, v2, v3, op&0x1);
157 if(op>1) res.v ^= 1ULL<<31;
162 softfloat_exceptionFlags = 0;
163 bool v1_nan = (v1 & defaultNaNF32UI) == defaultNaNF32UI;
164 bool v2_nan = (v2 & defaultNaNF32UI) == defaultNaNF32UI;
165 bool v1_snan = softfloat_isSigNaNF32UI(v1);
166 bool v2_snan = softfloat_isSigNaNF32UI(v2);
167 if (v1_snan || v2_snan) softfloat_raiseFlags(softfloat_flag_invalid);
168 if (v1_nan || v1_snan)
169 return (v2_nan || v2_snan) ? defaultNaNF32UI : v2;
171 if (v2_nan || v2_snan)
174 if ((v1 & 0x7fffffff) == 0 && (v2 & 0x7fffffff) == 0) {
175 return op == 0 ? ((v1 & 0x80000000) ? v1 : v2) : ((v1 & 0x80000000) ? v2 : v1);
177 float32_t v1f{ v1 }, v2f{ v2 };
178 return op == 0 ? (f32_lt(v1f, v2f) ? v1 : v2) : (f32_lt(v1f, v2f) ? v2 : v1);
192 uint_fast16_t infOrNaN = expF32UI( uiA ) == 0xFF;
193 uint_fast16_t subnormalOrZero = expF32UI( uiA ) == 0;
194 bool sign = signF32UI( uiA );
195 bool fracZero = fracF32UI( uiA ) == 0;
196 bool isNaN = isNaNF32UI( uiA );
197 bool isSNaN = softfloat_isSigNaNF32UI( uiA );
200 (
sign && infOrNaN && fracZero ) << 0 |
201 (
sign && !infOrNaN && !subnormalOrZero ) << 1 |
202 (
sign && subnormalOrZero && !fracZero ) << 2 |
203 (
sign && subnormalOrZero && fracZero ) << 3 |
204 ( !
sign && infOrNaN && fracZero ) << 7 |
205 ( !
sign && !infOrNaN && !subnormalOrZero ) << 6 |
206 ( !
sign && subnormalOrZero && !fracZero ) << 5 |
207 ( !
sign && subnormalOrZero && fracZero ) << 4 |
208 ( isNaN && isSNaN ) << 8 |
209 ( isNaN && !isSNaN ) << 9;
214 bool nan = (v1 & defaultNaNF64UI)==defaultNaNF64UI;
216 return defaultNaNF32UI;
218 float32_t res = f64_to_f32(float64_t{v1});
224 bool nan = (v1 & defaultNaNF32UI)==defaultNaNF32UI;
226 return defaultNaNF64UI;
229 float64_t res = f32_to_f64(float32_t{v1});
236 bool snan = softfloat_isSigNaNF32UI(v1);
237 float64_t v1f{v1},v2f{v2};
239 softfloat_exceptionFlags=0;
240 float64_t r =f64_add(v1f, v2f);
247 float64_t v1f{v1},v2f{v2};
249 softfloat_exceptionFlags=0;
250 float64_t r=f64_sub(v1f, v2f);
255 float64_t v1f{v1},v2f{v2};
257 softfloat_exceptionFlags=0;
258 float64_t r=f64_mul(v1f, v2f);
263 float64_t v1f{v1},v2f{v2};
265 softfloat_exceptionFlags=0;
266 float64_t r=f64_div(v1f, v2f);
273 softfloat_exceptionFlags=0;
274 float64_t r=f64_sqrt(v1f);
279 float64_t v1f{v1},v2f{v2};
280 softfloat_exceptionFlags=0;
282 bool snan = softfloat_isSigNaNF64UI(v1) || softfloat_isSigNaNF64UI(v2);
286 if(snan) softfloat_raiseFlags(softfloat_flag_invalid);
289 return f64_eq(v1f,v2f )?1:0;
292 softfloat_raiseFlags(softfloat_flag_invalid);
295 return f64_le(v1f,v2f )?1:0;
298 softfloat_raiseFlags(softfloat_flag_invalid);
301 return f64_lt(v1f,v2f )?1:0;
310 softfloat_exceptionFlags=0;
314 int64_t res = f64_to_i64(v1f,
rmm_map[
mode&0x7],
true);
334 softfloat_exceptionFlags=0;
335 float64_t res = softfloat_mulAddF64(v1, v2, v3, op&0x1);
336 if(op>1) res.v ^= 1ULL<<63;
341 softfloat_exceptionFlags = 0;
342 bool v1_nan = (v1 & defaultNaNF64UI) == defaultNaNF64UI;
343 bool v2_nan = (v2 & defaultNaNF64UI) == defaultNaNF64UI;
344 bool v1_snan = softfloat_isSigNaNF64UI(v1);
345 bool v2_snan = softfloat_isSigNaNF64UI(v2);
346 if (v1_snan || v2_snan) softfloat_raiseFlags(softfloat_flag_invalid);
347 if (v1_nan || v1_snan)
348 return (v2_nan || v2_snan) ? defaultNaNF64UI : v2;
350 if (v2_nan || v2_snan)
358 float64_t v1f{ v1 }, v2f{ v2 };
360 (f64_lt(v1f, v2f) ? v1 : v2) :
361 (f64_lt(v1f, v2f) ? v2 : v1);
375 uint_fast16_t infOrNaN = expF64UI( uiA ) == 0x7FF;
376 uint_fast16_t subnormalOrZero = expF64UI( uiA ) == 0;
377 bool sign = signF64UI( uiA );
378 bool fracZero = fracF64UI( uiA ) == 0;
379 bool isNaN = isNaNF64UI( uiA );
380 bool isSNaN = softfloat_isSigNaNF64UI( uiA );
383 (
sign && infOrNaN && fracZero ) << 0 |
384 (
sign && !infOrNaN && !subnormalOrZero ) << 1 |
385 (
sign && subnormalOrZero && !fracZero ) << 2 |
386 (
sign && subnormalOrZero && fracZero ) << 3 |
387 ( !
sign && infOrNaN && fracZero ) << 7 |
388 ( !
sign && !infOrNaN && !subnormalOrZero ) << 6 |
389 ( !
sign && subnormalOrZero && !fracZero ) << 5 |
390 ( !
sign && subnormalOrZero && fracZero ) << 4 |
391 ( isNaN && isSNaN ) << 8 |
392 ( isNaN && !isSNaN ) << 9;
397 softfloat_exceptionFlags=0;
415 softfloat_exceptionFlags=0;
438 if((
v & mask) != mask)
__DEVICE__ int min(int __a, int __b)
__DEVICE__ int max(int __a, int __b)
__DEVICE__ double nan(const char *)
static __inline__ uint32_t
static __inline__ uint64_t
static __inline__ int32_t
static __inline__ uint8_t
uint64_t fsel_d(uint64_t v1, uint64_t v2, uint32_t op)
uint64_t fmul_d(uint64_t v1, uint64_t v2, uint8_t mode)
uint64_t fdiv_d(uint64_t v1, uint64_t v2, uint8_t mode)
uint32_t fclass_s(uint32_t v1)
uint32_t fmadd_s(uint32_t v1, uint32_t v2, uint32_t v3, uint32_t op, uint8_t mode)
uint64_t fcvt_d(uint64_t v1, uint32_t op, uint8_t mode)
uint64_t fadd_d(uint64_t v1, uint64_t v2, uint8_t mode)
uint64_t fconv_f2d(uint32_t v1, uint8_t mode)
uint32_t fdiv_s(uint32_t v1, uint32_t v2, uint8_t mode)
uint32_t fconv_d2f(uint64_t v1, uint8_t mode)
uint32_t fmul_s(uint32_t v1, uint32_t v2, uint8_t mode)
uint32_t unbox_s(uint64_t v)
uint32_t fcvt_s(uint32_t v1, uint32_t op, uint8_t mode)
uint32_t fsqrt_s(uint32_t v1, uint8_t mode)
const uint32_t quiet_nan32
uint64_t fclass_d(uint64_t v1)
uint64_t fsub_d(uint64_t v1, uint64_t v2, uint8_t mode)
uint64_t fcvt_32_64(uint32_t v1, uint32_t op, uint8_t mode)
uint32_t fcvt_64_32(uint64_t v1, uint32_t op, uint8_t mode)
uint32_t fsel_s(uint32_t v1, uint32_t v2, uint32_t op)
uint32_t fsub_s(uint32_t v1, uint32_t v2, uint8_t mode)
uint32_t fcmp_s(uint32_t v1, uint32_t v2, uint32_t op)
uint64_t fcmp_d(uint64_t v1, uint64_t v2, uint32_t op)
uint32_t fadd_s(uint32_t v1, uint32_t v2, uint8_t mode)
uint64_t fsqrt_d(uint64_t v1, uint8_t mode)
uint64_t fmadd_d(uint64_t v1, uint64_t v2, uint64_t v3, uint32_t op, uint8_t mode)
float __ovld __cnfn sign(float x)
Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = +0.0, or -1.0 if x < 0.