Revision 5500b06c target-arm/helper.c
b/target-arm/helper.c | ||
---|---|---|
2526 | 2526 |
DO_VFP_cmp(d, float64) |
2527 | 2527 |
#undef DO_VFP_cmp |
2528 | 2528 |
|
2529 |
/* Integer to float conversion. */ |
|
2530 |
float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env) |
|
2531 |
{ |
|
2532 |
return uint32_to_float32(x, &env->vfp.fp_status); |
|
2533 |
} |
|
2529 |
/* Integer to float and float to integer conversions */ |
|
2534 | 2530 |
|
2535 |
float64 VFP_HELPER(uito, d)(uint32_t x, CPUState *env) |
|
2536 |
{ |
|
2537 |
return uint32_to_float64(x, &env->vfp.fp_status); |
|
2538 |
} |
|
2539 |
|
|
2540 |
float32 VFP_HELPER(sito, s)(uint32_t x, CPUState *env) |
|
2541 |
{ |
|
2542 |
return int32_to_float32(x, &env->vfp.fp_status); |
|
2543 |
} |
|
2544 |
|
|
2545 |
float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env) |
|
2546 |
{ |
|
2547 |
return int32_to_float64(x, &env->vfp.fp_status); |
|
2548 |
} |
|
2549 |
|
|
2550 |
/* Float to integer conversion. */ |
|
2551 |
uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env) |
|
2552 |
{ |
|
2553 |
if (float32_is_any_nan(x)) { |
|
2554 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2555 |
return 0; |
|
2556 |
} |
|
2557 |
return float32_to_uint32(x, &env->vfp.fp_status); |
|
2558 |
} |
|
2559 |
|
|
2560 |
uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env) |
|
2561 |
{ |
|
2562 |
if (float64_is_any_nan(x)) { |
|
2563 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2564 |
return 0; |
|
2565 |
} |
|
2566 |
return float64_to_uint32(x, &env->vfp.fp_status); |
|
2567 |
} |
|
2568 |
|
|
2569 |
uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env) |
|
2570 |
{ |
|
2571 |
if (float32_is_any_nan(x)) { |
|
2572 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2573 |
return 0; |
|
2574 |
} |
|
2575 |
return float32_to_int32(x, &env->vfp.fp_status); |
|
2576 |
} |
|
2577 |
|
|
2578 |
uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env) |
|
2579 |
{ |
|
2580 |
if (float64_is_any_nan(x)) { |
|
2581 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2582 |
return 0; |
|
2583 |
} |
|
2584 |
return float64_to_int32(x, &env->vfp.fp_status); |
|
2531 |
#define CONV_ITOF(name, fsz, sign) \ |
|
2532 |
float##fsz HELPER(name)(uint32_t x, void *fpstp) \ |
|
2533 |
{ \ |
|
2534 |
float_status *fpst = fpstp; \ |
|
2535 |
return sign##int32_to_##float##fsz(x, fpst); \ |
|
2585 | 2536 |
} |
2586 | 2537 |
|
2587 |
uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env) |
|
2588 |
{ |
|
2589 |
if (float32_is_any_nan(x)) { |
|
2590 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2591 |
return 0; |
|
2592 |
} |
|
2593 |
return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status); |
|
2538 |
#define CONV_FTOI(name, fsz, sign, round) \ |
|
2539 |
uint32_t HELPER(name)(float##fsz x, void *fpstp) \ |
|
2540 |
{ \ |
|
2541 |
float_status *fpst = fpstp; \ |
|
2542 |
if (float##fsz##_is_any_nan(x)) { \ |
|
2543 |
float_raise(float_flag_invalid, fpst); \ |
|
2544 |
return 0; \ |
|
2545 |
} \ |
|
2546 |
return float##fsz##_to_##sign##int32##round(x, fpst); \ |
|
2594 | 2547 |
} |
2595 | 2548 |
|
2596 |
uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env) |
|
2597 |
{ |
|
2598 |
if (float64_is_any_nan(x)) { |
|
2599 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2600 |
return 0; |
|
2601 |
} |
|
2602 |
return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status); |
|
2603 |
} |
|
2549 |
#define FLOAT_CONVS(name, p, fsz, sign) \ |
|
2550 |
CONV_ITOF(vfp_##name##to##p, fsz, sign) \ |
|
2551 |
CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ |
|
2552 |
CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) |
|
2604 | 2553 |
|
2605 |
uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env) |
|
2606 |
{ |
|
2607 |
if (float32_is_any_nan(x)) { |
|
2608 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2609 |
return 0; |
|
2610 |
} |
|
2611 |
return float32_to_int32_round_to_zero(x, &env->vfp.fp_status); |
|
2612 |
} |
|
2554 |
FLOAT_CONVS(si, s, 32, ) |
|
2555 |
FLOAT_CONVS(si, d, 64, ) |
|
2556 |
FLOAT_CONVS(ui, s, 32, u) |
|
2557 |
FLOAT_CONVS(ui, d, 64, u) |
|
2613 | 2558 |
|
2614 |
uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env) |
|
2615 |
{ |
|
2616 |
if (float64_is_any_nan(x)) { |
|
2617 |
float_raise(float_flag_invalid, &env->vfp.fp_status); |
|
2618 |
return 0; |
|
2619 |
} |
|
2620 |
return float64_to_int32_round_to_zero(x, &env->vfp.fp_status); |
|
2621 |
} |
|
2559 |
#undef CONV_ITOF |
|
2560 |
#undef CONV_FTOI |
|
2561 |
#undef FLOAT_CONVS |
|
2622 | 2562 |
|
2623 | 2563 |
/* floating point conversion */ |
2624 | 2564 |
float64 VFP_HELPER(fcvtd, s)(float32 x, CPUState *env) |
... | ... | |
2641 | 2581 |
|
2642 | 2582 |
/* VFP3 fixed point conversion. */ |
2643 | 2583 |
#define VFP_CONV_FIX(name, p, fsz, itype, sign) \ |
2644 |
float##fsz VFP_HELPER(name##to, p)(uint##fsz##_t x, uint32_t shift, \
|
|
2645 |
CPUState *env) \
|
|
2584 |
float##fsz HELPER(vfp_##name##to##p)(uint##fsz##_t x, uint32_t shift, \
|
|
2585 |
void *fpstp) \
|
|
2646 | 2586 |
{ \ |
2587 |
float_status *fpst = fpstp; \ |
|
2647 | 2588 |
float##fsz tmp; \ |
2648 |
tmp = sign##int32_to_##float##fsz ((itype##_t)x, &env->vfp.fp_status); \
|
|
2649 |
return float##fsz##_scalbn(tmp, -(int)shift, &env->vfp.fp_status); \
|
|
2589 |
tmp = sign##int32_to_##float##fsz((itype##_t)x, fpst); \
|
|
2590 |
return float##fsz##_scalbn(tmp, -(int)shift, fpst); \
|
|
2650 | 2591 |
} \ |
2651 |
uint##fsz##_t VFP_HELPER(to##name, p)(float##fsz x, uint32_t shift, \
|
|
2652 |
CPUState *env) \
|
|
2592 |
uint##fsz##_t HELPER(vfp_to##name##p)(float##fsz x, uint32_t shift, \
|
|
2593 |
void *fpstp) \
|
|
2653 | 2594 |
{ \ |
2595 |
float_status *fpst = fpstp; \ |
|
2654 | 2596 |
float##fsz tmp; \ |
2655 | 2597 |
if (float##fsz##_is_any_nan(x)) { \ |
2656 |
float_raise(float_flag_invalid, &env->vfp.fp_status); \
|
|
2598 |
float_raise(float_flag_invalid, fpst); \
|
|
2657 | 2599 |
return 0; \ |
2658 | 2600 |
} \ |
2659 |
tmp = float##fsz##_scalbn(x, shift, &env->vfp.fp_status); \
|
|
2660 |
return float##fsz##_to_##itype##_round_to_zero(tmp, &env->vfp.fp_status); \
|
|
2601 |
tmp = float##fsz##_scalbn(x, shift, fpst); \
|
|
2602 |
return float##fsz##_to_##itype##_round_to_zero(tmp, fpst); \
|
|
2661 | 2603 |
} |
2662 | 2604 |
|
2663 | 2605 |
VFP_CONV_FIX(sh, d, 64, int16, ) |
Also available in: Unified diff