Revision 5500b06c

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, )
b/target-arm/helper.h
96 96
DEF_HELPER_2(vfp_fcvtds, f64, f32, env)
97 97
DEF_HELPER_2(vfp_fcvtsd, f32, f64, env)
98 98

  
99
DEF_HELPER_2(vfp_uitos, f32, i32, env)
100
DEF_HELPER_2(vfp_uitod, f64, i32, env)
101
DEF_HELPER_2(vfp_sitos, f32, i32, env)
102
DEF_HELPER_2(vfp_sitod, f64, i32, env)
103

  
104
DEF_HELPER_2(vfp_touis, i32, f32, env)
105
DEF_HELPER_2(vfp_touid, i32, f64, env)
106
DEF_HELPER_2(vfp_touizs, i32, f32, env)
107
DEF_HELPER_2(vfp_touizd, i32, f64, env)
108
DEF_HELPER_2(vfp_tosis, i32, f32, env)
109
DEF_HELPER_2(vfp_tosid, i32, f64, env)
110
DEF_HELPER_2(vfp_tosizs, i32, f32, env)
111
DEF_HELPER_2(vfp_tosizd, i32, f64, env)
112

  
113
DEF_HELPER_3(vfp_toshs, i32, f32, i32, env)
114
DEF_HELPER_3(vfp_tosls, i32, f32, i32, env)
115
DEF_HELPER_3(vfp_touhs, i32, f32, i32, env)
116
DEF_HELPER_3(vfp_touls, i32, f32, i32, env)
117
DEF_HELPER_3(vfp_toshd, i64, f64, i32, env)
118
DEF_HELPER_3(vfp_tosld, i64, f64, i32, env)
119
DEF_HELPER_3(vfp_touhd, i64, f64, i32, env)
120
DEF_HELPER_3(vfp_tould, i64, f64, i32, env)
121
DEF_HELPER_3(vfp_shtos, f32, i32, i32, env)
122
DEF_HELPER_3(vfp_sltos, f32, i32, i32, env)
123
DEF_HELPER_3(vfp_uhtos, f32, i32, i32, env)
124
DEF_HELPER_3(vfp_ultos, f32, i32, i32, env)
125
DEF_HELPER_3(vfp_shtod, f64, i64, i32, env)
126
DEF_HELPER_3(vfp_sltod, f64, i64, i32, env)
127
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, env)
128
DEF_HELPER_3(vfp_ultod, f64, i64, i32, env)
99
DEF_HELPER_2(vfp_uitos, f32, i32, ptr)
100
DEF_HELPER_2(vfp_uitod, f64, i32, ptr)
101
DEF_HELPER_2(vfp_sitos, f32, i32, ptr)
102
DEF_HELPER_2(vfp_sitod, f64, i32, ptr)
103

  
104
DEF_HELPER_2(vfp_touis, i32, f32, ptr)
105
DEF_HELPER_2(vfp_touid, i32, f64, ptr)
106
DEF_HELPER_2(vfp_touizs, i32, f32, ptr)
107
DEF_HELPER_2(vfp_touizd, i32, f64, ptr)
108
DEF_HELPER_2(vfp_tosis, i32, f32, ptr)
109
DEF_HELPER_2(vfp_tosid, i32, f64, ptr)
110
DEF_HELPER_2(vfp_tosizs, i32, f32, ptr)
111
DEF_HELPER_2(vfp_tosizd, i32, f64, ptr)
112

  
113
DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr)
114
DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr)
115
DEF_HELPER_3(vfp_touhs, i32, f32, i32, ptr)
116
DEF_HELPER_3(vfp_touls, i32, f32, i32, ptr)
117
DEF_HELPER_3(vfp_toshd, i64, f64, i32, ptr)
118
DEF_HELPER_3(vfp_tosld, i64, f64, i32, ptr)
119
DEF_HELPER_3(vfp_touhd, i64, f64, i32, ptr)
120
DEF_HELPER_3(vfp_tould, i64, f64, i32, ptr)
121
DEF_HELPER_3(vfp_shtos, f32, i32, i32, ptr)
122
DEF_HELPER_3(vfp_sltos, f32, i32, i32, ptr)
123
DEF_HELPER_3(vfp_uhtos, f32, i32, i32, ptr)
124
DEF_HELPER_3(vfp_ultos, f32, i32, i32, ptr)
125
DEF_HELPER_3(vfp_shtod, f64, i64, i32, ptr)
126
DEF_HELPER_3(vfp_sltod, f64, i64, i32, ptr)
127
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
128
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
129 129

  
130 130
DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env)
131 131
DEF_HELPER_2(vfp_fcvt_f32_to_f16, i32, f32, env)
b/target-arm/translate.c
977 977
        tcg_gen_movi_i32(cpu_F1s, 0);
978 978
}
979 979

  
980
static inline void gen_vfp_uito(int dp)
981
{
982
    if (dp)
983
        gen_helper_vfp_uitod(cpu_F0d, cpu_F0s, cpu_env);
984
    else
985
        gen_helper_vfp_uitos(cpu_F0s, cpu_F0s, cpu_env);
986
}
987

  
988
static inline void gen_vfp_sito(int dp)
989
{
990
    if (dp)
991
        gen_helper_vfp_sitod(cpu_F0d, cpu_F0s, cpu_env);
992
    else
993
        gen_helper_vfp_sitos(cpu_F0s, cpu_F0s, cpu_env);
994
}
995

  
996
static inline void gen_vfp_toui(int dp)
997
{
998
    if (dp)
999
        gen_helper_vfp_touid(cpu_F0s, cpu_F0d, cpu_env);
1000
    else
1001
        gen_helper_vfp_touis(cpu_F0s, cpu_F0s, cpu_env);
980
#define VFP_GEN_ITOF(name) \
981
static inline void gen_vfp_##name(int dp, int neon) \
982
{ \
983
    TCGv statusptr = tcg_temp_new_i32(); \
984
    int offset; \
985
    if (neon) { \
986
        offset = offsetof(CPUState, vfp.standard_fp_status); \
987
    } else { \
988
        offset = offsetof(CPUState, vfp.fp_status); \
989
    } \
990
    tcg_gen_addi_i32(statusptr, cpu_env, offset); \
991
    if (dp) { \
992
        gen_helper_vfp_##name##d(cpu_F0d, cpu_F0s, statusptr); \
993
    } else { \
994
        gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \
995
    } \
996
    tcg_temp_free_i32(statusptr); \
1002 997
}
1003 998

  
1004
static inline void gen_vfp_touiz(int dp)
1005
{
1006
    if (dp)
1007
        gen_helper_vfp_touizd(cpu_F0s, cpu_F0d, cpu_env);
1008
    else
1009
        gen_helper_vfp_touizs(cpu_F0s, cpu_F0s, cpu_env);
1010
}
999
VFP_GEN_ITOF(uito)
1000
VFP_GEN_ITOF(sito)
1001
#undef VFP_GEN_ITOF
1011 1002

  
1012
static inline void gen_vfp_tosi(int dp)
1013
{
1014
    if (dp)
1015
        gen_helper_vfp_tosid(cpu_F0s, cpu_F0d, cpu_env);
1016
    else
1017
        gen_helper_vfp_tosis(cpu_F0s, cpu_F0s, cpu_env);
1003
#define VFP_GEN_FTOI(name) \
1004
static inline void gen_vfp_##name(int dp, int neon) \
1005
{ \
1006
    TCGv statusptr = tcg_temp_new_i32(); \
1007
    int offset; \
1008
    if (neon) { \
1009
        offset = offsetof(CPUState, vfp.standard_fp_status); \
1010
    } else { \
1011
        offset = offsetof(CPUState, vfp.fp_status); \
1012
    } \
1013
    tcg_gen_addi_i32(statusptr, cpu_env, offset); \
1014
    if (dp) { \
1015
        gen_helper_vfp_##name##d(cpu_F0s, cpu_F0d, statusptr); \
1016
    } else { \
1017
        gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, statusptr); \
1018
    } \
1019
    tcg_temp_free_i32(statusptr); \
1018 1020
}
1019 1021

  
1020
static inline void gen_vfp_tosiz(int dp)
1021
{
1022
    if (dp)
1023
        gen_helper_vfp_tosizd(cpu_F0s, cpu_F0d, cpu_env);
1024
    else
1025
        gen_helper_vfp_tosizs(cpu_F0s, cpu_F0s, cpu_env);
1026
}
1022
VFP_GEN_FTOI(toui)
1023
VFP_GEN_FTOI(touiz)
1024
VFP_GEN_FTOI(tosi)
1025
VFP_GEN_FTOI(tosiz)
1026
#undef VFP_GEN_FTOI
1027 1027

  
1028 1028
#define VFP_GEN_FIX(name) \
1029
static inline void gen_vfp_##name(int dp, int shift) \
1029
static inline void gen_vfp_##name(int dp, int shift, int neon) \
1030 1030
{ \
1031 1031
    TCGv tmp_shift = tcg_const_i32(shift); \
1032
    if (dp) \
1033
        gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, tmp_shift, cpu_env);\
1034
    else \
1035
        gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, tmp_shift, cpu_env);\
1032
    TCGv statusptr = tcg_temp_new_i32(); \
1033
    int offset; \
1034
    if (neon) { \
1035
        offset = offsetof(CPUState, vfp.standard_fp_status); \
1036
    } else { \
1037
        offset = offsetof(CPUState, vfp.fp_status); \
1038
    } \
1039
    tcg_gen_addi_i32(statusptr, cpu_env, offset); \
1040
    if (dp) { \
1041
        gen_helper_vfp_##name##d(cpu_F0d, cpu_F0d, tmp_shift, statusptr); \
1042
    } else { \
1043
        gen_helper_vfp_##name##s(cpu_F0s, cpu_F0s, tmp_shift, statusptr); \
1044
    } \
1036 1045
    tcg_temp_free_i32(tmp_shift); \
1046
    tcg_temp_free_i32(statusptr); \
1037 1047
}
1038 1048
VFP_GEN_FIX(tosh)
1039 1049
VFP_GEN_FIX(tosl)
......
3183 3193
                            gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env);
3184 3194
                        break;
3185 3195
                    case 16: /* fuito */
3186
                        gen_vfp_uito(dp);
3196
                        gen_vfp_uito(dp, 0);
3187 3197
                        break;
3188 3198
                    case 17: /* fsito */
3189
                        gen_vfp_sito(dp);
3199
                        gen_vfp_sito(dp, 0);
3190 3200
                        break;
3191 3201
                    case 20: /* fshto */
3192 3202
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3193 3203
                          return 1;
3194
                        gen_vfp_shto(dp, 16 - rm);
3204
                        gen_vfp_shto(dp, 16 - rm, 0);
3195 3205
                        break;
3196 3206
                    case 21: /* fslto */
3197 3207
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3198 3208
                          return 1;
3199
                        gen_vfp_slto(dp, 32 - rm);
3209
                        gen_vfp_slto(dp, 32 - rm, 0);
3200 3210
                        break;
3201 3211
                    case 22: /* fuhto */
3202 3212
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3203 3213
                          return 1;
3204
                        gen_vfp_uhto(dp, 16 - rm);
3214
                        gen_vfp_uhto(dp, 16 - rm, 0);
3205 3215
                        break;
3206 3216
                    case 23: /* fulto */
3207 3217
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3208 3218
                          return 1;
3209
                        gen_vfp_ulto(dp, 32 - rm);
3219
                        gen_vfp_ulto(dp, 32 - rm, 0);
3210 3220
                        break;
3211 3221
                    case 24: /* ftoui */
3212
                        gen_vfp_toui(dp);
3222
                        gen_vfp_toui(dp, 0);
3213 3223
                        break;
3214 3224
                    case 25: /* ftouiz */
3215
                        gen_vfp_touiz(dp);
3225
                        gen_vfp_touiz(dp, 0);
3216 3226
                        break;
3217 3227
                    case 26: /* ftosi */
3218
                        gen_vfp_tosi(dp);
3228
                        gen_vfp_tosi(dp, 0);
3219 3229
                        break;
3220 3230
                    case 27: /* ftosiz */
3221
                        gen_vfp_tosiz(dp);
3231
                        gen_vfp_tosiz(dp, 0);
3222 3232
                        break;
3223 3233
                    case 28: /* ftosh */
3224 3234
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3225 3235
                          return 1;
3226
                        gen_vfp_tosh(dp, 16 - rm);
3236
                        gen_vfp_tosh(dp, 16 - rm, 0);
3227 3237
                        break;
3228 3238
                    case 29: /* ftosl */
3229 3239
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3230 3240
                          return 1;
3231
                        gen_vfp_tosl(dp, 32 - rm);
3241
                        gen_vfp_tosl(dp, 32 - rm, 0);
3232 3242
                        break;
3233 3243
                    case 30: /* ftouh */
3234 3244
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3235 3245
                          return 1;
3236
                        gen_vfp_touh(dp, 16 - rm);
3246
                        gen_vfp_touh(dp, 16 - rm, 0);
3237 3247
                        break;
3238 3248
                    case 31: /* ftoul */
3239 3249
                        if (!arm_feature(env, ARM_FEATURE_VFP3))
3240 3250
                          return 1;
3241
                        gen_vfp_toul(dp, 32 - rm);
3251
                        gen_vfp_toul(dp, 32 - rm, 0);
3242 3252
                        break;
3243 3253
                    default: /* undefined */
3244 3254
                        printf ("rn:%d\n", rn);
......
5251 5261
                    tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, pass));
5252 5262
                    if (!(op & 1)) {
5253 5263
                        if (u)
5254
                            gen_vfp_ulto(0, shift);
5264
                            gen_vfp_ulto(0, shift, 1);
5255 5265
                        else
5256
                            gen_vfp_slto(0, shift);
5266
                            gen_vfp_slto(0, shift, 1);
5257 5267
                    } else {
5258 5268
                        if (u)
5259
                            gen_vfp_toul(0, shift);
5269
                            gen_vfp_toul(0, shift, 1);
5260 5270
                        else
5261
                            gen_vfp_tosl(0, shift);
5271
                            gen_vfp_tosl(0, shift, 1);
5262 5272
                    }
5263 5273
                    tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, pass));
5264 5274
                }
......
6071 6081
                            gen_helper_rsqrte_f32(cpu_F0s, cpu_F0s, cpu_env);
6072 6082
                            break;
6073 6083
                        case NEON_2RM_VCVT_FS: /* VCVT.F32.S32 */
6074
                            gen_vfp_sito(0);
6084
                            gen_vfp_sito(0, 1);
6075 6085
                            break;
6076 6086
                        case NEON_2RM_VCVT_FU: /* VCVT.F32.U32 */
6077
                            gen_vfp_uito(0);
6087
                            gen_vfp_uito(0, 1);
6078 6088
                            break;
6079 6089
                        case NEON_2RM_VCVT_SF: /* VCVT.S32.F32 */
6080
                            gen_vfp_tosiz(0);
6090
                            gen_vfp_tosiz(0, 1);
6081 6091
                            break;
6082 6092
                        case NEON_2RM_VCVT_UF: /* VCVT.U32.F32 */
6083
                            gen_vfp_touiz(0);
6093
                            gen_vfp_touiz(0, 1);
6084 6094
                            break;
6085 6095
                        default:
6086 6096
                            /* Reserved op values were caught by the

Also available in: Unified diff