From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: laurent@vivier.eu, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v5 20/24] target/m68k: Merge gen_store_fp, gen_store_mode_fp
Date: Wed, 7 May 2025 14:12:55 -0700 [thread overview]
Message-ID: <20250507211300.9735-21-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250507211300.9735-1-richard.henderson@linaro.org>
This enables the exceptions raised by the actual store
to be reflected as a failure.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/m68k/translate.c | 107 ++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 54 deletions(-)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 711f1477c8..af5b20989c 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -902,53 +902,6 @@ static void gen_fp_move(TCGv_ptr dest, TCGv_ptr src)
tcg_gen_st_i64(t64, dest, offsetof(FPReg, l.lower));
}
-static void gen_store_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp,
- int index)
-{
- TCGv tmp;
- TCGv_i64 t64;
-
- t64 = tcg_temp_new_i64();
- tmp = tcg_temp_new();
- switch (opsize) {
- case OS_BYTE:
- case OS_WORD:
- case OS_LONG:
- gen_helper_reds32(tmp, tcg_env, fp);
- tcg_gen_qemu_st_tl(tmp, addr, index, opsize | MO_TE);
- break;
- case OS_SINGLE:
- gen_helper_redf32(tmp, tcg_env, fp);
- tcg_gen_qemu_st_tl(tmp, addr, index, MO_TEUL);
- break;
- case OS_DOUBLE:
- gen_helper_redf64(t64, tcg_env, fp);
- tcg_gen_qemu_st_i64(t64, addr, index, MO_TEUQ);
- break;
- case OS_EXTENDED:
- if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
- gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
- break;
- }
- tcg_gen_ld16u_i32(tmp, fp, offsetof(FPReg, l.upper));
- tcg_gen_shli_i32(tmp, tmp, 16);
- tcg_gen_qemu_st_i32(tmp, addr, index, MO_TEUL);
- tcg_gen_addi_i32(tmp, addr, 4);
- tcg_gen_ld_i64(t64, fp, offsetof(FPReg, l.lower));
- tcg_gen_qemu_st_i64(t64, tmp, index, MO_TEUQ);
- break;
- case OS_PACKED:
- /*
- * unimplemented data type on 68040/ColdFire
- * FIXME if needed for another FPU
- */
- gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
- break;
- default:
- g_assert_not_reached();
- }
-}
-
static bool gen_load_fp(DisasContext *s, uint16_t insn, int opsize,
TCGv_ptr fp, int index)
{
@@ -1088,12 +1041,13 @@ static bool gen_load_fp(DisasContext *s, uint16_t insn, int opsize,
return true;
}
-static bool gen_store_mode_fp(DisasContext *s, uint16_t insn, int opsize,
- TCGv_ptr fp, int index)
+static bool gen_store_fp(DisasContext *s, uint16_t insn, int opsize,
+ TCGv_ptr fp, int index)
{
int mode = extract32(insn, 3, 3);
int reg0 = REG(insn, 0);
- TCGv reg, addr;
+ TCGv reg, addr, tmp;
+ TCGv_i64 t64;
switch (mode) {
case 0: /* Data register direct. */
@@ -1127,10 +1081,55 @@ static bool gen_store_mode_fp(DisasContext *s, uint16_t insn, int opsize,
gen_addr_fault(s);
return false;
}
- gen_store_fp(s, opsize, addr, fp, index);
- return true;
+ break;
+
+ default:
+ g_assert_not_reached();
}
- g_assert_not_reached();
+
+ switch (opsize) {
+ case OS_BYTE:
+ case OS_WORD:
+ case OS_LONG:
+ tmp = tcg_temp_new();
+ gen_helper_reds32(tmp, tcg_env, fp);
+ tcg_gen_qemu_st_tl(tmp, addr, index, opsize | MO_TE);
+ break;
+ case OS_SINGLE:
+ tmp = tcg_temp_new();
+ gen_helper_redf32(tmp, tcg_env, fp);
+ tcg_gen_qemu_st_tl(tmp, addr, index, MO_TEUL);
+ break;
+ case OS_DOUBLE:
+ t64 = tcg_temp_new_i64();
+ gen_helper_redf64(t64, tcg_env, fp);
+ tcg_gen_qemu_st_i64(t64, addr, index, MO_TEUQ);
+ break;
+ case OS_EXTENDED:
+ if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
+ gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
+ return false;
+ }
+ tmp = tcg_temp_new();
+ t64 = tcg_temp_new_i64();
+ tcg_gen_ld16u_i32(tmp, fp, offsetof(FPReg, l.upper));
+ tcg_gen_shli_i32(tmp, tmp, 16);
+ tcg_gen_qemu_st_i32(tmp, addr, index, MO_TEUL);
+ tcg_gen_addi_i32(addr, addr, 4);
+ tcg_gen_ld_i64(t64, fp, offsetof(FPReg, l.lower));
+ tcg_gen_qemu_st_i64(t64, addr, index, MO_TEUQ);
+ break;
+ case OS_PACKED:
+ /*
+ * unimplemented data type on 68040/ColdFire
+ * FIXME if needed for another FPU
+ */
+ gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
+ return false;
+ default:
+ g_assert_not_reached();
+ }
+ return true;
}
typedef struct {
@@ -4889,7 +4888,7 @@ DISAS_INSN(fpu)
case 3: /* fmove out */
cpu_src = gen_fp_ptr(REG(ext, 7));
opsize = ext_opsize(ext, 10);
- if (gen_store_mode_fp(s, insn, opsize, cpu_src, IS_USER(s))) {
+ if (gen_store_fp(s, insn, opsize, cpu_src, IS_USER(s))) {
gen_helper_ftst(tcg_env, cpu_src);
}
return;
--
2.43.0
next prev parent reply other threads:[~2025-05-07 21:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 21:12 [PATCH v5 00/24] target/m68k: fpu improvements Richard Henderson
2025-05-07 21:12 ` [PATCH v5 01/24] target/m68k: Add FPSR exception bit defines Richard Henderson
2025-05-07 21:12 ` [PATCH v5 02/24] target/m68k: Restore fp rounding mode on vm load Richard Henderson
2025-05-07 21:12 ` [PATCH v5 03/24] target/m68k: Keep FPSR up-to-date Richard Henderson
2025-05-07 21:12 ` [PATCH v5 04/24] target/m68k: Update FPSR.EXC Richard Henderson
2025-05-07 21:12 ` [PATCH v5 05/24] target/m68k: Update FPSR for FMOVECR Richard Henderson
2025-05-07 21:12 ` [PATCH v5 06/24] target/m68k: Introduce M68K_FEATURE_FPU_PACKED_DECIMAL Richard Henderson
2025-05-07 21:12 ` [PATCH v5 07/24] target/m68k: Merge gen_ea into SRC_EA and DEST_EA Richard Henderson
2025-05-07 21:12 ` [PATCH v5 08/24] target/m68k: Use g_assert_not_reached in gen_lea_mode and gen_ea_mode Richard Henderson
2025-05-07 21:12 ` [PATCH v5 09/24] target/m68k: Use OS_UNSIZED in LEA, PEA, JMP Richard Henderson
2025-05-07 21:12 ` [PATCH v5 10/24] target/m68k: Move pre-dec/post-inc to gen_lea_mode Richard Henderson
2025-05-07 21:12 ` [PATCH v5 11/24] target/m68k: Split gen_ea_mode for load/store Richard Henderson
2025-05-07 21:12 ` [PATCH v5 12/24] target/m68k: Remove env argument to gen_lea_indexed Richard Henderson
2025-05-07 21:12 ` [PATCH v5 13/24] target/m68k: Remove env argument to gen_lea_mode Richard Henderson
2025-05-07 21:12 ` [PATCH v5 14/24] target/m68k: Remove env argument to gen_load_mode Richard Henderson
2025-05-07 21:12 ` [PATCH v5 15/24] target/m68k: Remove env argument to gen_store_mode Richard Henderson
2025-05-07 21:12 ` [PATCH v5 16/24] target/m68k: Remove env argument to gen_ea_mode_fp Richard Henderson
2025-05-07 21:12 ` [PATCH v5 17/24] target/m68k: Split gen_ea_mode_fp for load/store Richard Henderson
2025-05-07 21:12 ` [PATCH v5 18/24] target/m68k: Move gen_addr_fault into gen_{load, store}_mode_fp Richard Henderson
2025-05-07 21:12 ` [PATCH v5 19/24] target/m68k: Merge gen_load_fp, gen_load_mode_fp Richard Henderson
2025-05-07 21:12 ` Richard Henderson [this message]
2025-05-07 21:12 ` [PATCH v5 21/24] target/m68k: Implement packed decimal real loads and stores Richard Henderson
2025-05-10 16:36 ` Andreas Schwab
2025-05-11 17:20 ` Richard Henderson
2025-05-07 21:12 ` [PATCH v5 22/24] tests/tcg/m68k: Add packed decimal tests Richard Henderson
2025-05-07 21:12 ` [PATCH v5 23/24] target/m68k: Make vmstate variables static Richard Henderson
2025-05-07 21:12 ` [PATCH v5 24/24] target/m68k: Implement FPIAR Richard Henderson
2025-05-07 21:28 ` [PATCH v5 00/24] target/m68k: fpu improvements Helge Deller
2025-05-08 21:39 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250507211300.9735-21-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=laurent@vivier.eu \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).