提交 622465e1 编写于 作者: P Peter Maydell 提交者: Aurelien Jarno

target-arm/helper.c: For float-int conversion helpers pass ints as ints

Correct the argument and return types for the float<->int conversion helper
functions so that integer arguments and return values are declared as
uint32_t/uint64_t, not float32/float64. This allows us to remove the
hand-rolled functions which were doing bitwise copies between the types
via unions.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NNathan Froyd <froydnj@codesourcery.com>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 4a9f9cb2
master openEuler-20.03-LTS openEuler-20.09 openEuler-RISCV stable-0.15 stable-1.0 stable-1.1 stable-1.2 stable-1.3 stable-1.4 stable-1.5 stable-1.6 stable-1.7 stable-2.0 stable-2.1 stable-2.10 stable-2.11 stable-2.12 stable-2.2 stable-2.3 stable-2.4 stable-2.5 stable-2.6 stable-2.7 stable-2.8 stable-2.9 stable-3.0 stable-3.1 stable-4.0 stable-4.1 stable-4.2 v5.1.0-rc2 v5.1.0-rc1 v5.1.0-rc0 v5.0.0 v5.0.0-rc4 v5.0.0-rc3 v5.0.0-rc2 v5.0.0-rc1 v5.0.0-rc0 v4.2.1 v4.2.0 v4.2.0-rc5 v4.2.0-rc4 v4.2.0-rc3 v4.2.0-rc2 v4.2.0-rc1 v4.2.0-rc0 v4.1.1 v4.1.0 v4.1.0-rc5 v4.1.0-rc4 v4.1.0-rc3 v4.1.0-rc2 v4.1.0-rc1 v4.1.0-rc0 v4.0.1 v4.0.0 v4.0.0-rc4 v4.0.0-rc3 v4.0.0-rc2 v4.0.0-rc1 v4.0.0-rc0 v3.1.1.1 v3.1.1 v3.1.0 v3.1.0-rc5 v3.1.0-rc4 v3.1.0-rc3 v3.1.0-rc2 v3.1.0-rc1 v3.1.0-rc0 v3.0.1 v3.0.0 v3.0.0-rc4 v3.0.0-rc3 v3.0.0-rc2 v3.0.0-rc1 v3.0.0-rc0 v2.12.1 v2.12.0 v2.12.0-rc4 v2.12.0-rc3 v2.12.0-rc2 v2.12.0-rc1 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v1.6.1 v1.6.0 v1.6.0-rc3 v1.6.0-rc2 v1.6.0-rc1 v1.6.0-rc0 v1.5.3 v1.5.2 v1.5.1 v1.5.0 v1.5.0-rc3 v1.5.0-rc2 v1.5.0-rc1 v1.5.0-rc0 v1.4.2 v1.4.1 v1.4.0 v1.4.0-rc2 v1.4.0-rc1 v1.4.0-rc0 v1.3.1 v1.3.0 v1.3.0-rc2 v1.3.0-rc1 v1.3.0-rc0 v1.2.2 v1.2.1 v1.2.0 v1.2.0-rc3 v1.2.0-rc2 v1.2.0-rc1 v1.2.0-rc0 v1.1.2 v1.1.1 v1.1.0 v1.1.0-rc4 v1.1.0-rc3 v1.1.0-rc2 v1.1-rc2 v1.1-rc1 v1.1-rc0 v1.0.1 v1.0 v1.0-rc4 v1.0-rc3 v1.0-rc2 v1.0-rc1 v1.0-rc0 v0.15.1 v0.15.0 v0.15.0-rc2 v0.15.0-rc1 v0.15.0-rc0
无相关合并请求
......@@ -2486,135 +2486,90 @@ DO_VFP_cmp(s, float32)
DO_VFP_cmp(d, float64)
#undef DO_VFP_cmp
/* Helper routines to perform bitwise copies between float and int. */
static inline float32 vfp_itos(uint32_t i)
{
union {
uint32_t i;
float32 s;
} v;
v.i = i;
return v.s;
}
static inline uint32_t vfp_stoi(float32 s)
{
union {
uint32_t i;
float32 s;
} v;
v.s = s;
return v.i;
}
static inline float64 vfp_itod(uint64_t i)
{
union {
uint64_t i;
float64 d;
} v;
v.i = i;
return v.d;
}
static inline uint64_t vfp_dtoi(float64 d)
{
union {
uint64_t i;
float64 d;
} v;
v.d = d;
return v.i;
}
/* Integer to float conversion. */
float32 VFP_HELPER(uito, s)(float32 x, CPUState *env)
float32 VFP_HELPER(uito, s)(uint32_t x, CPUState *env)
{
return uint32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
return uint32_to_float32(x, &env->vfp.fp_status);
}
float64 VFP_HELPER(uito, d)(float32 x, CPUState *env)
float64 VFP_HELPER(uito, d)(uint32_t x, CPUState *env)
{
return uint32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
return uint32_to_float64(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(sito, s)(float32 x, CPUState *env)
float32 VFP_HELPER(sito, s)(uint32_t x, CPUState *env)
{
return int32_to_float32(vfp_stoi(x), &env->vfp.fp_status);
return int32_to_float32(x, &env->vfp.fp_status);
}
float64 VFP_HELPER(sito, d)(float32 x, CPUState *env)
float64 VFP_HELPER(sito, d)(uint32_t x, CPUState *env)
{
return int32_to_float64(vfp_stoi(x), &env->vfp.fp_status);
return int32_to_float64(x, &env->vfp.fp_status);
}
/* Float to integer conversion. */
float32 VFP_HELPER(toui, s)(float32 x, CPUState *env)
uint32_t VFP_HELPER(toui, s)(float32 x, CPUState *env)
{
if (float32_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float32_to_uint32(x, &env->vfp.fp_status));
return float32_to_uint32(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(toui, d)(float64 x, CPUState *env)
uint32_t VFP_HELPER(toui, d)(float64 x, CPUState *env)
{
if (float64_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float64_to_uint32(x, &env->vfp.fp_status));
return float64_to_uint32(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(tosi, s)(float32 x, CPUState *env)
uint32_t VFP_HELPER(tosi, s)(float32 x, CPUState *env)
{
if (float32_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float32_to_int32(x, &env->vfp.fp_status));
return float32_to_int32(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(tosi, d)(float64 x, CPUState *env)
uint32_t VFP_HELPER(tosi, d)(float64 x, CPUState *env)
{
if (float64_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float64_to_int32(x, &env->vfp.fp_status));
return float64_to_int32(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(touiz, s)(float32 x, CPUState *env)
uint32_t VFP_HELPER(touiz, s)(float32 x, CPUState *env)
{
if (float32_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float32_to_uint32_round_to_zero(x, &env->vfp.fp_status));
return float32_to_uint32_round_to_zero(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(touiz, d)(float64 x, CPUState *env)
uint32_t VFP_HELPER(touiz, d)(float64 x, CPUState *env)
{
if (float64_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float64_to_uint32_round_to_zero(x, &env->vfp.fp_status));
return float64_to_uint32_round_to_zero(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
uint32_t VFP_HELPER(tosiz, s)(float32 x, CPUState *env)
{
if (float32_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float32_to_int32_round_to_zero(x, &env->vfp.fp_status));
return float32_to_int32_round_to_zero(x, &env->vfp.fp_status);
}
float32 VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
uint32_t VFP_HELPER(tosiz, d)(float64 x, CPUState *env)
{
if (float64_is_any_nan(x)) {
return float32_zero;
return 0;
}
return vfp_itos(float64_to_int32_round_to_zero(x, &env->vfp.fp_status));
return float64_to_int32_round_to_zero(x, &env->vfp.fp_status);
}
/* floating point conversion */
......@@ -2637,33 +2592,33 @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUState *env)
}
/* VFP3 fixed point conversion. */
#define VFP_CONV_FIX(name, p, ftype, itype, sign) \
ftype VFP_HELPER(name##to, p)(ftype x, uint32_t shift, CPUState *env) \
#define VFP_CONV_FIX(name, p, fsz, itype, sign) \
float##fsz VFP_HELPER(name##to, p)(uint##fsz##_t x, uint32_t shift, \
CPUState *env) \
{ \
ftype tmp; \
tmp = sign##int32_to_##ftype ((itype##_t)vfp_##p##toi(x), \
&env->vfp.fp_status); \
return ftype##_scalbn(tmp, -(int)shift, &env->vfp.fp_status); \
float##fsz tmp; \
tmp = sign##int32_to_##float##fsz ((itype##_t)x, &env->vfp.fp_status); \
return float##fsz##_scalbn(tmp, -(int)shift, &env->vfp.fp_status); \
} \
ftype VFP_HELPER(to##name, p)(ftype x, uint32_t shift, CPUState *env) \
uint##fsz##_t VFP_HELPER(to##name, p)(float##fsz x, uint32_t shift, \
CPUState *env) \
{ \
ftype tmp; \
if (ftype##_is_any_nan(x)) { \
return ftype##_zero; \
float##fsz tmp; \
if (float##fsz##_is_any_nan(x)) { \
return 0; \
} \
tmp = ftype##_scalbn(x, shift, &env->vfp.fp_status); \
return vfp_ito##p(ftype##_to_##itype##_round_to_zero(tmp, \
&env->vfp.fp_status)); \
}
VFP_CONV_FIX(sh, d, float64, int16, )
VFP_CONV_FIX(sl, d, float64, int32, )
VFP_CONV_FIX(uh, d, float64, uint16, u)
VFP_CONV_FIX(ul, d, float64, uint32, u)
VFP_CONV_FIX(sh, s, float32, int16, )
VFP_CONV_FIX(sl, s, float32, int32, )
VFP_CONV_FIX(uh, s, float32, uint16, u)
VFP_CONV_FIX(ul, s, float32, uint32, u)
tmp = float##fsz##_scalbn(x, shift, &env->vfp.fp_status); \
return float##fsz##_to_##itype##_round_to_zero(tmp, &env->vfp.fp_status); \
}
VFP_CONV_FIX(sh, d, 64, int16, )
VFP_CONV_FIX(sl, d, 64, int32, )
VFP_CONV_FIX(uh, d, 64, uint16, u)
VFP_CONV_FIX(ul, d, 64, uint32, u)
VFP_CONV_FIX(sh, s, 32, int16, )
VFP_CONV_FIX(sl, s, 32, int32, )
VFP_CONV_FIX(uh, s, 32, uint16, u)
VFP_CONV_FIX(ul, s, 32, uint32, u)
#undef VFP_CONV_FIX
/* Half precision conversions. */
......
......@@ -96,36 +96,36 @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env)
DEF_HELPER_2(vfp_fcvtds, f64, f32, env)
DEF_HELPER_2(vfp_fcvtsd, f32, f64, env)
DEF_HELPER_2(vfp_uitos, f32, f32, env)
DEF_HELPER_2(vfp_uitod, f64, f32, env)
DEF_HELPER_2(vfp_sitos, f32, f32, env)
DEF_HELPER_2(vfp_sitod, f64, f32, env)
DEF_HELPER_2(vfp_touis, f32, f32, env)
DEF_HELPER_2(vfp_touid, f32, f64, env)
DEF_HELPER_2(vfp_touizs, f32, f32, env)
DEF_HELPER_2(vfp_touizd, f32, f64, env)
DEF_HELPER_2(vfp_tosis, f32, f32, env)
DEF_HELPER_2(vfp_tosid, f32, f64, env)
DEF_HELPER_2(vfp_tosizs, f32, f32, env)
DEF_HELPER_2(vfp_tosizd, f32, f64, env)
DEF_HELPER_3(vfp_toshs, f32, f32, i32, env)
DEF_HELPER_3(vfp_tosls, f32, f32, i32, env)
DEF_HELPER_3(vfp_touhs, f32, f32, i32, env)
DEF_HELPER_3(vfp_touls, f32, f32, i32, env)
DEF_HELPER_3(vfp_toshd, f64, f64, i32, env)
DEF_HELPER_3(vfp_tosld, f64, f64, i32, env)
DEF_HELPER_3(vfp_touhd, f64, f64, i32, env)
DEF_HELPER_3(vfp_tould, f64, f64, i32, env)
DEF_HELPER_3(vfp_shtos, f32, f32, i32, env)
DEF_HELPER_3(vfp_sltos, f32, f32, i32, env)
DEF_HELPER_3(vfp_uhtos, f32, f32, i32, env)
DEF_HELPER_3(vfp_ultos, f32, f32, i32, env)
DEF_HELPER_3(vfp_shtod, f64, f64, i32, env)
DEF_HELPER_3(vfp_sltod, f64, f64, i32, env)
DEF_HELPER_3(vfp_uhtod, f64, f64, i32, env)
DEF_HELPER_3(vfp_ultod, f64, f64, i32, env)
DEF_HELPER_2(vfp_uitos, f32, i32, env)
DEF_HELPER_2(vfp_uitod, f64, i32, env)
DEF_HELPER_2(vfp_sitos, f32, i32, env)
DEF_HELPER_2(vfp_sitod, f64, i32, env)
DEF_HELPER_2(vfp_touis, i32, f32, env)
DEF_HELPER_2(vfp_touid, i32, f64, env)
DEF_HELPER_2(vfp_touizs, i32, f32, env)
DEF_HELPER_2(vfp_touizd, i32, f64, env)
DEF_HELPER_2(vfp_tosis, i32, f32, env)
DEF_HELPER_2(vfp_tosid, i32, f64, env)
DEF_HELPER_2(vfp_tosizs, i32, f32, env)
DEF_HELPER_2(vfp_tosizd, i32, f64, env)
DEF_HELPER_3(vfp_toshs, i32, f32, i32, env)
DEF_HELPER_3(vfp_tosls, i32, f32, i32, env)
DEF_HELPER_3(vfp_touhs, i32, f32, i32, env)
DEF_HELPER_3(vfp_touls, i32, f32, i32, env)
DEF_HELPER_3(vfp_toshd, i64, f64, i32, env)
DEF_HELPER_3(vfp_tosld, i64, f64, i32, env)
DEF_HELPER_3(vfp_touhd, i64, f64, i32, env)
DEF_HELPER_3(vfp_tould, i64, f64, i32, env)
DEF_HELPER_3(vfp_shtos, f32, i32, i32, env)
DEF_HELPER_3(vfp_sltos, f32, i32, i32, env)
DEF_HELPER_3(vfp_uhtos, f32, i32, i32, env)
DEF_HELPER_3(vfp_ultos, f32, i32, i32, env)
DEF_HELPER_3(vfp_shtod, f64, i64, i32, env)
DEF_HELPER_3(vfp_sltod, f64, i64, i32, env)
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, env)
DEF_HELPER_3(vfp_ultod, f64, i64, i32, env)
DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env)
DEF_HELPER_2(vfp_fcvt_f32_to_f16, i32, f32, env)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部