提交 b7ee8c6a 编写于 作者: M Max Filippov 提交者: Blue Swirl

target-xtensa: implement FP0 conversions

These are FP to integer and integer to FP conversion opcodes.
See ISA, 4.3.10 for more details.

Note that ISA description for utrunc.s is currently incorrect and will
be fixed in future revisions.
Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 0b6df838
......@@ -44,5 +44,9 @@ DEF_HELPER_3(sub_s, f32, env, f32, f32)
DEF_HELPER_3(mul_s, f32, env, f32, f32)
DEF_HELPER_4(madd_s, f32, env, f32, f32, f32)
DEF_HELPER_4(msub_s, f32, env, f32, f32, f32)
DEF_HELPER_FLAGS_3(ftoi, TCG_CALL_CONST | TCG_CALL_PURE, i32, f32, i32, i32)
DEF_HELPER_FLAGS_3(ftoui, TCG_CALL_CONST | TCG_CALL_PURE, i32, f32, i32, i32)
DEF_HELPER_3(itof, f32, env, i32, i32)
DEF_HELPER_3(uitof, f32, env, i32, i32)
#include "def-helper.h"
......@@ -821,3 +821,40 @@ float32 HELPER(msub_s)(CPUXtensaState *env, float32 a, float32 b, float32 c)
return float32_muladd(b, c, a, float_muladd_negate_product,
&env->fp_status);
}
uint32_t HELPER(ftoi)(float32 v, uint32_t rounding_mode, uint32_t scale)
{
float_status fp_status = {0};
set_float_rounding_mode(rounding_mode, &fp_status);
return float32_to_int32(
float32_scalbn(v, scale, &fp_status), &fp_status);
}
uint32_t HELPER(ftoui)(float32 v, uint32_t rounding_mode, uint32_t scale)
{
float_status fp_status = {0};
float32 res;
set_float_rounding_mode(rounding_mode, &fp_status);
res = float32_scalbn(v, scale, &fp_status);
if (float32_is_neg(v) && !float32_is_any_nan(v)) {
return float32_to_int32(res, &fp_status);
} else {
return float32_to_uint32(res, &fp_status);
}
}
float32 HELPER(itof)(CPUXtensaState *env, uint32_t v, uint32_t scale)
{
return float32_scalbn(int32_to_float32(v, &env->fp_status),
(int32_t)scale, &env->fp_status);
}
float32 HELPER(uitof)(CPUXtensaState *env, uint32_t v, uint32_t scale)
{
return float32_scalbn(uint32_to_float32(v, &env->fp_status),
(int32_t)scale, &env->fp_status);
}
......@@ -1933,6 +1933,54 @@ static void disas_xtensa_insn(DisasContext *dc)
cpu_FR[RRR_R], cpu_FR[RRR_S], cpu_FR[RRR_T]);
break;
case 8: /*ROUND.Sf*/
case 9: /*TRUNC.Sf*/
case 10: /*FLOOR.Sf*/
case 11: /*CEIL.Sf*/
case 14: /*UTRUNC.Sf*/
gen_window_check1(dc, RRR_R);
{
static const unsigned rounding_mode_const[] = {
float_round_nearest_even,
float_round_to_zero,
float_round_down,
float_round_up,
[6] = float_round_to_zero,
};
TCGv_i32 rounding_mode = tcg_const_i32(
rounding_mode_const[OP2 & 7]);
TCGv_i32 scale = tcg_const_i32(RRR_T);
if (OP2 == 14) {
gen_helper_ftoui(cpu_R[RRR_R], cpu_FR[RRR_S],
rounding_mode, scale);
} else {
gen_helper_ftoi(cpu_R[RRR_R], cpu_FR[RRR_S],
rounding_mode, scale);
}
tcg_temp_free(rounding_mode);
tcg_temp_free(scale);
}
break;
case 12: /*FLOAT.Sf*/
case 13: /*UFLOAT.Sf*/
gen_window_check1(dc, RRR_S);
{
TCGv_i32 scale = tcg_const_i32(-RRR_T);
if (OP2 == 13) {
gen_helper_uitof(cpu_FR[RRR_R], cpu_env,
cpu_R[RRR_S], scale);
} else {
gen_helper_itof(cpu_FR[RRR_R], cpu_env,
cpu_R[RRR_S], scale);
}
tcg_temp_free(scale);
}
break;
case 15: /*FP1OP*/
switch (RRR_T) {
case 0: /*MOV.Sf*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册