[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 10/21] target/loongarch: Add floating point arithmetic ins
From: |
Richard Henderson |
Subject: |
Re: [PATCH v5 10/21] target/loongarch: Add floating point arithmetic instruction translation |
Date: |
Tue, 14 Sep 2021 07:15:41 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 9/14/21 6:00 AM, Song Gao wrote:
+static void update_fcsr0_mask(CPULoongArchState *env, uintptr_t pc, int mask)
+{
+ int flags = get_float_exception_flags(&env->fp_status) & (~mask);
+
+ if (!flags) {
+ SET_FP_CAUSE(env->fcsr0, flags);
+ return;
If mask != 0, we may unintentionally leave fp_status.flags != 0, which will then be
incorporated into the next fp operation.
+ }
+
+ flags = ieee_ex_to_loongarch(flags);
+ set_float_exception_flags(0, &env->fp_status);
I think this set should move above the if.
+static bool trans_fmax_s(DisasContext *ctx, arg_fmt_fdfjfk *a)
+{
+ tcg_gen_umax_i64(cpu_fpr[a->fd], cpu_fpr[a->fj], cpu_fpr[a->fk]);
Um, this is an integer operation. You want float32_maxnum.
Likewise for the other min/max operations.
+static bool trans_fabs_s(DisasContext *ctx, arg_fmt_fdfj *a)
+{
+ tcg_gen_ext32u_tl(cpu_fpr[a->fj], cpu_fpr[a->fj]);
You shouldn't be modifying fj.
+ tcg_gen_abs_i64(cpu_fpr[a->fd], cpu_fpr[a->fj]);
This is an integer operation. You want
tcg_gen_andi_i64(cpu_fpr[a->fd], cpu_fpr[a->fj],
MAKE_64BIT_MASK(0, 31));
+static bool trans_fabs_d(DisasContext *ctx, arg_fmt_fdfj *a)
+{
+ tcg_gen_abs_i64(cpu_fpr[a->fd], cpu_fpr[a->fj]);
Similarly.
+/*
+ * LoongArch requires NaN-boxing of narrower width floating point values.
+ * This applies when a 32-bit value is assigned to a 64-bit FP register.
+ */
Um, this comment does not reflect the language in the v1.00 manual.
The actual language says that the upper 32 bits are undefined ("can be any value"). We
should state that here, and then that QEMU chooses to nanbox, because it is most likely to
show guest bugs early.
r~
- [PATCH v5 02/21] target/loongarch: Add core definition, (continued)
- [PATCH v5 02/21] target/loongarch: Add core definition, Song Gao, 2021/09/14
- [PATCH v5 01/21] target/loongarch: Add README, Song Gao, 2021/09/14
- [PATCH v5 03/21] target/loongarch: Add main translation routines, Song Gao, 2021/09/14
- [PATCH v5 06/21] target/loongarch: Add fixed point bit instruction translation, Song Gao, 2021/09/14
- [PATCH v5 05/21] target/loongarch: Add fixed point shift instruction translation, Song Gao, 2021/09/14
- [PATCH v5 07/21] target/loongarch: Add fixed point load/store instruction translation, Song Gao, 2021/09/14
- [PATCH v5 10/21] target/loongarch: Add floating point arithmetic instruction translation, Song Gao, 2021/09/14
- Re: [PATCH v5 10/21] target/loongarch: Add floating point arithmetic instruction translation,
Richard Henderson <=
- [PATCH v5 04/21] target/loongarch: Add fixed point arithmetic instruction translation, Song Gao, 2021/09/14
- [PATCH v5 12/21] target/loongarch: Add floating point conversion instruction translation, Song Gao, 2021/09/14
- [PATCH v5 08/21] target/loongarch: Add fixed point atomic instruction translation, Song Gao, 2021/09/14
- [PATCH v5 09/21] target/loongarch: Add fixed point extra instruction translation, Song Gao, 2021/09/14
- [PATCH v5 13/21] target/loongarch: Add floating point move instruction translation, Song Gao, 2021/09/14
- [PATCH v5 14/21] target/loongarch: Add floating point load/store instruction translation, Song Gao, 2021/09/14
- [PATCH v5 18/21] default-configs: Add loongarch linux-user support, Song Gao, 2021/09/14