[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 27/94] target/sparc: Move WRPSR, SAVED, RESTORED to decodetree
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v5 27/94] target/sparc: Move WRPSR, SAVED, RESTORED to decodetree |
|
Date: |
Sun, 22 Oct 2023 16:28:25 -0700 |
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/insns.decode | 10 +++++++
target/sparc/translate.c | 62 ++++++++++++++++++---------------------
2 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index 118f0f1f17..45cf47a32f 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -85,6 +85,16 @@ RDHPR_htba 10 rd:5 101001 00101 0 0000000000000
RDHPR_hver 10 rd:5 101001 00110 0 0000000000000
RDHPR_hstick_cmpr 10 rd:5 101001 11111 0 0000000000000
+{
+ WRPSR 10 00000 110001 ..... . ............. @n_r_ri
+ SAVED 10 00000 110001 00000 0 0000000000000
+}
+RESTORED 10 00001 110001 00000 0 0000000000000
+# UA2005 ALLCLEAN
+# UA2005 OTHERW
+# UA2005 NORMALW
+# UA2005 INVALW
+
{
RDWIM 10 rd:5 101010 00000 0 0000000000000
RDPR_tpc 10 rd:5 101010 00000 0 0000000000000
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 83716307f6..58ea3b2ba7 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -39,11 +39,14 @@
#ifdef TARGET_SPARC64
# define gen_helper_rdpsr(D, E) qemu_build_not_reached()
# define gen_helper_power_down(E) qemu_build_not_reached()
+# define gen_helper_wrpsr(E, S) qemu_build_not_reached()
#else
# define gen_helper_clear_softint(E, S) qemu_build_not_reached()
# define gen_helper_flushw(E) qemu_build_not_reached()
# define gen_helper_rdccr(D, E) qemu_build_not_reached()
# define gen_helper_rdcwp(D, E) qemu_build_not_reached()
+# define gen_helper_restored(E) qemu_build_not_reached()
+# define gen_helper_saved(E) qemu_build_not_reached()
# define gen_helper_set_softint(E, S) qemu_build_not_reached()
# define gen_helper_tick_get_count(D, E, T, C) qemu_build_not_reached()
# define gen_helper_wrccr(E, S) qemu_build_not_reached()
@@ -3745,6 +3748,32 @@ static void do_wrpowerdown(DisasContext *dc, TCGv src)
TRANS(WRPOWERDOWN, POWERDOWN, do_wr_special, a, supervisor(dc), do_wrpowerdown)
+static void do_wrpsr(DisasContext *dc, TCGv src)
+{
+ gen_helper_wrpsr(tcg_env, src);
+ tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
+ dc->cc_op = CC_OP_FLAGS;
+ dc->base.is_jmp = DISAS_EXIT;
+}
+
+TRANS(WRPSR, 32, do_wr_special, a, supervisor(dc), do_wrpsr)
+
+static bool do_saved_restored(DisasContext *dc, bool saved)
+{
+ if (!supervisor(dc)) {
+ return raise_priv(dc);
+ }
+ if (saved) {
+ gen_helper_saved(tcg_env);
+ } else {
+ gen_helper_restored(tcg_env);
+ }
+ return advance_pc(dc);
+}
+
+TRANS(SAVED, 64, do_saved_restored, true)
+TRANS(RESTORED, 64, do_saved_restored, false)
+
static bool trans_NOP_v7(DisasContext *dc, arg_NOP_v7 *a)
{
/*
@@ -4419,39 +4448,6 @@ static void disas_sparc_legacy(DisasContext *dc,
unsigned int insn)
case 0x30:
goto illegal_insn; /* WRASR in decodetree */
#if !defined(CONFIG_USER_ONLY)
- case 0x31: /* wrpsr, V9 saved, restored */
- {
- if (!supervisor(dc))
- goto priv_insn;
-#ifdef TARGET_SPARC64
- switch (rd) {
- case 0:
- gen_helper_saved(tcg_env);
- break;
- case 1:
- gen_helper_restored(tcg_env);
- break;
- case 2: /* UA2005 allclean */
- case 3: /* UA2005 otherw */
- case 4: /* UA2005 normalw */
- case 5: /* UA2005 invalw */
- // XXX
- default:
- goto illegal_insn;
- }
-#else
- cpu_tmp0 = tcg_temp_new();
- tcg_gen_xor_tl(cpu_tmp0, cpu_src1, cpu_src2);
- gen_helper_wrpsr(tcg_env, cpu_tmp0);
- tcg_gen_movi_i32(cpu_cc_op, CC_OP_FLAGS);
- dc->cc_op = CC_OP_FLAGS;
- save_state(dc);
- gen_op_next_insn();
- tcg_gen_exit_tb(NULL, 0);
- dc->base.is_jmp = DISAS_NORETURN;
-#endif
- }
- break;
case 0x32: /* wrwim, V9 wrpr */
{
if (!supervisor(dc))
--
2.34.1
- [PATCH v5 34/94] target/sparc: Move ADDC to decodetree, (continued)
- [PATCH v5 34/94] target/sparc: Move ADDC to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 16/94] target/sparc: Merge gen_cond with only caller, Richard Henderson, 2023/10/22
- [PATCH v5 20/94] target/sparc: Move SETHI to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 21/94] target/sparc: Move Tcc to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 19/94] target/sparc: Pass DisasCompare to advance_jump_cond, Richard Henderson, 2023/10/22
- [PATCH v5 24/94] target/sparc: Move RDWIM, RDPR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 31/94] target/sparc: Remove cpu_tick_cmpr, cpu_stick_cmpr, cpu_hstick_cmpr, Richard Henderson, 2023/10/22
- [PATCH v5 36/94] target/sparc: Move UMUL, SMUL to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 38/94] target/sparc: Move UDIVX, SDIVX to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 23/94] target/sparc: Move RDPSR, RDHPR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 27/94] target/sparc: Move WRPSR, SAVED, RESTORED to decodetree,
Richard Henderson <=
- [PATCH v5 28/94] target/sparc: Move WRWIM, WRPR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 35/94] target/sparc: Move MULX to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 37/94] target/sparc: Move SUBC to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 39/94] target/sparc: Move UDIV, SDIV to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 40/94] target/sparc: Move TADD, TSUB, MULS to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 41/94] target/sparc: Move SLL, SRL, SRA to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 45/94] target/sparc: Move JMPL, RETT, RETURN to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 42/94] target/sparc: Move MOVcc, MOVR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 46/94] target/sparc: Move FLUSH, SAVE, RESTORE to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 44/94] target/sparc: Convert remaining v8 coproc insns to decodetree, Richard Henderson, 2023/10/22