mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
target/loongarch: Add floating point comparison instruction translation
This includes: - FCMP.cond.{S/D} Signed-off-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220606124333.2060567-12-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
d578ca6cbb
commit
9b7410763a
6 changed files with 139 additions and 0 deletions
|
@ -401,3 +401,63 @@ uint64_t helper_fmuladd_d(CPULoongArchState *env, uint64_t fj,
|
|||
update_fcsr0(env, GETPC());
|
||||
return fd;
|
||||
}
|
||||
|
||||
static uint64_t fcmp_common(CPULoongArchState *env, FloatRelation cmp,
|
||||
uint32_t flags)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
switch (cmp) {
|
||||
case float_relation_less:
|
||||
ret = (flags & FCMP_LT);
|
||||
break;
|
||||
case float_relation_equal:
|
||||
ret = (flags & FCMP_EQ);
|
||||
break;
|
||||
case float_relation_greater:
|
||||
ret = (flags & FCMP_GT);
|
||||
break;
|
||||
case float_relation_unordered:
|
||||
ret = (flags & FCMP_UN);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
update_fcsr0(env, GETPC());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* fcmp_cXXX_s */
|
||||
uint64_t helper_fcmp_c_s(CPULoongArchState *env, uint64_t fj,
|
||||
uint64_t fk, uint32_t flags)
|
||||
{
|
||||
FloatRelation cmp = float32_compare_quiet((uint32_t)fj,
|
||||
(uint32_t)fk, &env->fp_status);
|
||||
return fcmp_common(env, cmp, flags);
|
||||
}
|
||||
|
||||
/* fcmp_sXXX_s */
|
||||
uint64_t helper_fcmp_s_s(CPULoongArchState *env, uint64_t fj,
|
||||
uint64_t fk, uint32_t flags)
|
||||
{
|
||||
FloatRelation cmp = float32_compare((uint32_t)fj,
|
||||
(uint32_t)fk, &env->fp_status);
|
||||
return fcmp_common(env, cmp, flags);
|
||||
}
|
||||
|
||||
/* fcmp_cXXX_d */
|
||||
uint64_t helper_fcmp_c_d(CPULoongArchState *env, uint64_t fj,
|
||||
uint64_t fk, uint32_t flags)
|
||||
{
|
||||
FloatRelation cmp = float64_compare_quiet(fj, fk, &env->fp_status);
|
||||
return fcmp_common(env, cmp, flags);
|
||||
}
|
||||
|
||||
/* fcmp_sXXX_d */
|
||||
uint64_t helper_fcmp_s_d(CPULoongArchState *env, uint64_t fj,
|
||||
uint64_t fk, uint32_t flags)
|
||||
{
|
||||
FloatRelation cmp = float64_compare(fj, fk, &env->fp_status);
|
||||
return fcmp_common(env, cmp, flags);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue