2486 |
2486 |
DO_VFP_cmp(d, float64)
|
2487 |
2487 |
#undef DO_VFP_cmp
|
2488 |
2488 |
|
2489 |
|
/* Helper routines to perform bitwise copies between float and int. */
|
2490 |
|
static inline float32 vfp_itos(uint32_t i)
|
2491 |
|
{
|
2492 |
|
union {
|
2493 |
|
uint32_t i;
|
2494 |
|
float32 s;
|
2495 |
|
} v;
|
2496 |
|
|
2497 |
|
v.i = i;
|
2498 |
|
return v.s;
|
2499 |
|
}
|
2500 |
|
|
2501 |
|
static inline uint32_t vfp_stoi(float32 s)
|
2502 |
|
{
|
2503 |
|
union {
|
2504 |
|
uint32_t i;
|
2505 |
|
float32 s;
|
2506 |
|
} v;
|
2507 |
|
|
2508 |
|
v.s = s;
|
2509 |
|
return v.i;
|
2510 |
|
}
|
2511 |
|
|
2512 |
|
static inline float64 vfp_itod(uint64_t i)
|
2513 |
|
{
|
2514 |
|
union {
|
2515 |
|
uint64_t i;
|
2516 |
|
float64 d;
|
2517 |
|
} v;
|
2518 |
|
|
2519 |
|
v.i = i;
|
2520 |
|
return v.d;
|
2521 |
|
}
|
2522 |
|
|
2523 |
|
static inline uint64_t vfp_dtoi(float64 d)
|
2524 |
|
{
|
2525 |
|
union {
|
2526 |
|
uint64_t i;
|
2527 |
|
float64 d;
|
2528 |
|
} v;
|
2529 |
|
|
2530 |
|
v.d = d;
|
2531 |
|
return v.i;
|
2532 |
|
}
|
2533 |
|
|
2534 |
2489 |
/* Integer to float conversion. */
|
2535 |
|
float32 VFP_HELPER(uito, s)(float32 x, CPUState *env)
|
|
2490 |
float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env)
|
2536 |
2491 |
{
|
2537 |
|
return uint32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
|
|
2492 |
return uint32_to_float32(x, &env->vfp.fp_status);
|
2538 |
2493 |
}
|
2539 |
2494 |
|
2540 |
|
float64 VFP_HELPER(uito, d)(float32 x, CPUState *env)
|
|
2495 |
float64 VFP_HELPER(uito, d)(uint32_t x, CPUState *env)
|
2541 |
2496 |
{
|
2542 |
|
return uint32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
|
|
2497 |
return uint32_to_float64(x, &env->vfp.fp_status);
|
2543 |
2498 |
}
|
2544 |
2499 |
|
2545 |
|
float32 VFP_HELPER(sito, s)(float32 x, CPUState *env)
|
|
2500 |
float32 VFP_HELPER(sito, s)(uint32_t x, CPUState *env)
|
2546 |
2501 |
{
|
2547 |
|
return int32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
|
|
2502 |
return int32_to_float32(x, &env->vfp.fp_status);
|
2548 |
2503 |
}
|
2549 |
2504 |
|
2550 |
|
float64 VFP_HELPER(sito, d)(float32 x, CPUState *env)
|
|
2505 |
float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env)
|
2551 |
2506 |
{
|
2552 |
|
return int32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
|
|
2507 |
return int32_to_float64(x, &env->vfp.fp_status);
|
2553 |
2508 |
}
|
2554 |
2509 |
|
2555 |
2510 |
/* Float to integer conversion. */
|
2556 |
|
float32 VFP_HELPER(toui, s)(float32 x, CPUState *env)
|
|
2511 |
uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env)
|
2557 |
2512 |
{
|
2558 |
2513 |
if (float32_is_any_nan(x)) {
|
2559 |
|
return float32_zero;
|
|
2514 |
return 0;
|
2560 |
2515 |
}
|
2561 |
|
return vfp_itos(float32_to_uint32(x, &env->vfp.fp_status));
|
|
2516 |
return float32_to_uint32(x, &env->vfp.fp_status);
|
2562 |
2517 |
}
|
2563 |
2518 |
|
2564 |
|
float32 VFP_HELPER(toui, d)(float64 x, CPUState *env)
|
|
2519 |
uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env)
|
2565 |
2520 |
{
|
2566 |
2521 |
if (float64_is_any_nan(x)) {
|
2567 |
|
return float32_zero;
|
|
2522 |
return 0;
|
2568 |
2523 |
}
|
2569 |
|
return vfp_itos(float64_to_uint32(x, &env->vfp.fp_status));
|
|
2524 |
return float64_to_uint32(x, &env->vfp.fp_status);
|
2570 |
2525 |
}
|
2571 |
2526 |
|
2572 |
|
float32 VFP_HELPER(tosi, s)(float32 x, CPUState *env)
|
|
2527 |
uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env)
|
2573 |
2528 |
{
|
2574 |
2529 |
if (float32_is_any_nan(x)) {
|
2575 |
|
return float32_zero;
|
|
2530 |
return 0;
|
2576 |
2531 |
}
|
2577 |
|
return vfp_itos(float32_to_int32(x, &env->vfp.fp_status));
|
|
2532 |
return float32_to_int32(x, &env->vfp.fp_status);
|
2578 |
2533 |
}
|
2579 |
2534 |
|
2580 |
|
float32 VFP_HELPER(tosi, d)(float64 x, CPUState *env)
|
|
2535 |
uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env)
|
2581 |
2536 |
{
|
2582 |
2537 |
if (float64_is_any_nan(x)) {
|
2583 |
|
return float32_zero;
|
|
2538 |
return 0;
|
2584 |
2539 |
}
|
2585 |
|
return vfp_itos(float64_to_int32(x, &env->vfp.fp_status));
|
|
2540 |
return float64_to_int32(x, &env->vfp.fp_status);
|
2586 |
2541 |
}
|
2587 |
2542 |
|
2588 |
|
float32 VFP_HELPER(touiz, s)(float32 x, CPUState *env)
|
|
2543 |
uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env)
|
2589 |
2544 |
{
|
2590 |
2545 |
if (float32_is_any_nan(x)) {
|
2591 |
|
return float32_zero;
|
|
2546 |
return 0;
|
2592 |
2547 |
}
|
2593 |
|
return vfp_itos(float32_to_uint32_round_to_zero(x, &env->vfp.fp_status));
|
|
2548 |
return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status);
|
2594 |
2549 |
}
|
2595 |
2550 |
|
2596 |
|
float32 VFP_HELPER(touiz, d)(float64 x, CPUState *env)
|
|
2551 |
uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env)
|
2597 |
2552 |
{
|
2598 |
2553 |
if (float64_is_any_nan(x)) {
|
2599 |
|
return float32_zero;
|
|
2554 |
return 0;
|
2600 |
2555 |
}
|
2601 |
|
return vfp_itos(float64_to_uint32_round_to_zero(x, &env->vfp.fp_status));
|
|
2556 |
return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status);
|
2602 |
2557 |
}
|
2603 |
2558 |
|
2604 |
|
float32 VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
|
|
2559 |
uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
|
2605 |
2560 |
{
|
2606 |
2561 |
if (float32_is_any_nan(x)) {
|
2607 |
|
return float32_zero;
|
|
2562 |
return 0;
|
2608 |
2563 |
}
|
2609 |
|
return vfp_itos(float32_to_int32_round_to_zero(x, &env->vfp.fp_status));
|
|
2564 |
return float32_to_int32_round_to_zero(x, &env->vfp.fp_status);
|
2610 |
2565 |
}
|
2611 |
2566 |
|
2612 |
|
float32 VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
|
|
2567 |
uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
|
2613 |
2568 |
{
|
2614 |
2569 |
if (float64_is_any_nan(x)) {
|
2615 |
|
return float32_zero;
|
|
2570 |
return 0;
|
2616 |
2571 |
}
|
2617 |
|
return vfp_itos(float64_to_int32_round_to_zero(x, &env->vfp.fp_status));
|
|
2572 |
return float64_to_int32_round_to_zero(x, &env->vfp.fp_status);
|
2618 |
2573 |
}
|
2619 |
2574 |
|
2620 |
2575 |
/* floating point conversion */
|
... | ... | |
2637 |
2592 |
}
|
2638 |
2593 |
|
2639 |
2594 |
/* VFP3 fixed point conversion. */
|
2640 |
|
#define VFP_CONV_FIX(name, p, ftype, itype, sign) \
|
2641 |
|
ftype VFP_HELPER(name##to, p)(ftype x, uint32_t shift, CPUState *env) \
|
|
2595 |
#define VFP_CONV_FIX(name, p, fsz, itype, sign) \
|
|
2596 |
float##fsz VFP_HELPER(name##to, p)(uint##fsz##_t x, uint32_t shift, \
|
|
2597 |
CPUState *env) \
|
2642 |
2598 |
{ \
|
2643 |
|
ftype tmp; \
|
2644 |
|
tmp = sign##int32_to_##ftype ((itype##_t)vfp_##p##toi(x), \
|
2645 |
|
&env->vfp.fp_status); \
|
2646 |
|
return ftype##_scalbn(tmp, -(int)shift, &env->vfp.fp_status); \
|
|
2599 |
float##fsz tmp; \
|
|
2600 |
tmp = sign##int32_to_##float##fsz ((itype##_t)x, &env->vfp.fp_status); \
|
|
2601 |
return float##fsz##_scalbn(tmp, -(int)shift, &env->vfp.fp_status); \
|
2647 |
2602 |
} \
|
2648 |
|
ftype VFP_HELPER(to##name, p)(ftype x, uint32_t shift, CPUState *env) \
|
|
2603 |
uint##fsz##_t VFP_HELPER(to##name, p)(float##fsz x, uint32_t shift, \
|
|
2604 |
CPUState *env) \
|
2649 |
2605 |
{ \
|
2650 |
|
ftype tmp; \
|
2651 |
|
if (ftype##_is_any_nan(x)) { \
|
2652 |
|
return ftype##_zero; \
|
|
2606 |
float##fsz tmp; \
|
|
2607 |
if (float##fsz##_is_any_nan(x)) { \
|
|
2608 |
return 0; \
|
2653 |
2609 |
} \
|
2654 |
|
tmp = ftype##_scalbn(x, shift, &env->vfp.fp_status); \
|
2655 |
|
return vfp_ito##p(ftype##_to_##itype##_round_to_zero(tmp, \
|
2656 |
|
&env->vfp.fp_status)); \
|
2657 |
|
}
|
2658 |
|
|
2659 |
|
VFP_CONV_FIX(sh, d, float64, int16, )
|
2660 |
|
VFP_CONV_FIX(sl, d, float64, int32, )
|
2661 |
|
VFP_CONV_FIX(uh, d, float64, uint16, u)
|
2662 |
|
VFP_CONV_FIX(ul, d, float64, uint32, u)
|
2663 |
|
VFP_CONV_FIX(sh, s, float32, int16, )
|
2664 |
|
VFP_CONV_FIX(sl, s, float32, int32, )
|
2665 |
|
VFP_CONV_FIX(uh, s, float32, uint16, u)
|
2666 |
|
VFP_CONV_FIX(ul, s, float32, uint32, u)
|
|
2610 |
tmp = float##fsz##_scalbn(x, shift, &env->vfp.fp_status); \
|
|
2611 |
return float##fsz##_to_##itype##_round_to_zero(tmp, &env->vfp.fp_status); \
|
|
2612 |
}
|
|
2613 |
|
|
2614 |
VFP_CONV_FIX(sh, d, 64, int16, )
|
|
2615 |
VFP_CONV_FIX(sl, d, 64, int32, )
|
|
2616 |
VFP_CONV_FIX(uh, d, 64, uint16, u)
|
|
2617 |
VFP_CONV_FIX(ul, d, 64, uint32, u)
|
|
2618 |
VFP_CONV_FIX(sh, s, 32, int16, )
|
|
2619 |
VFP_CONV_FIX(sl, s, 32, int32, )
|
|
2620 |
VFP_CONV_FIX(uh, s, 32, uint16, u)
|
|
2621 |
VFP_CONV_FIX(ul, s, 32, uint32, u)
|
2667 |
2622 |
#undef VFP_CONV_FIX
|
2668 |
2623 |
|
2669 |
2624 |
/* Half precision conversions. */
|