[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 38/90] target/sparc: Move MOVcc, MOVR to decodetree
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v3 38/90] target/sparc: Move MOVcc, MOVR to decodetree |
|
Date: |
Fri, 20 Oct 2023 22:31:06 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/insns.decode | 4 ++
target/sparc/translate.c | 116 ++++++++++++++++++++------------------
2 files changed, 64 insertions(+), 56 deletions(-)
diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index c2a44e0130..8f4881a776 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -209,3 +209,7 @@ Tcc_r 10 0 cond:4 111010 rs1:5 0 cc:1 0000000 rs2:5
# Bits [10:8] are reserved and the OSA2011 manual says they must be 0.
Tcc_i_v9 10 0 cond:4 111010 rs1:5 1 cc:1 0 000 i:8
}
+
+MOVcc 10 rd:5 101100 1 cond:4 imm:1 cc:1 0 rs2_or_imm:s11
+MOVfcc 10 rd:5 101100 0 cond:4 imm:1 cc:2 rs2_or_imm:s11
+MOVR 10 rd:5 101111 rs1:5 imm:1 cond:3 rs2_or_imm:s10
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index a8e40b4220..feeaebae93 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -4427,6 +4427,64 @@ TRANS(SLL_i, ALL, do_shift_i, a, true, true)
TRANS(SRL_i, ALL, do_shift_i, a, false, true)
TRANS(SRA_i, ALL, do_shift_i, a, false, false)
+static TCGv gen_rs2_or_imm(DisasContext *dc, bool imm, int rs2_or_imm)
+{
+ /* For simplicity, we under-decoded the rs2 form. */
+ if (!imm && rs2_or_imm & ~0x1f) {
+ return NULL;
+ }
+ if (imm || rs2_or_imm == 0) {
+ return tcg_constant_tl(rs2_or_imm);
+ } else {
+ return cpu_regs[rs2_or_imm];
+ }
+}
+
+static bool do_mov_cond(DisasContext *dc, DisasCompare *cmp, int rd, TCGv src2)
+{
+ TCGv dst = gen_load_gpr(dc, rd);
+
+ tcg_gen_movcond_tl(cmp->cond, dst, cmp->c1, cmp->c2, src2, dst);
+ gen_store_gpr(dc, rd, dst);
+ return advance_pc(dc);
+}
+
+static bool trans_MOVcc(DisasContext *dc, arg_MOVcc *a)
+{
+ TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm);
+ DisasCompare cmp;
+
+ if (src2 == NULL) {
+ return false;
+ }
+ gen_compare(&cmp, a->cc, a->cond, dc);
+ return do_mov_cond(dc, &cmp, a->rd, src2);
+}
+
+static bool trans_MOVfcc(DisasContext *dc, arg_MOVfcc *a)
+{
+ TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm);
+ DisasCompare cmp;
+
+ if (src2 == NULL) {
+ return false;
+ }
+ gen_fcompare(&cmp, a->cc, a->cond);
+ return do_mov_cond(dc, &cmp, a->rd, src2);
+}
+
+static bool trans_MOVR(DisasContext *dc, arg_MOVR *a)
+{
+ TCGv src2 = gen_rs2_or_imm(dc, a->imm, a->rs2_or_imm);
+ DisasCompare cmp;
+
+ if (src2 == NULL) {
+ return false;
+ }
+ gen_compare_reg(&cmp, a->cond, gen_load_gpr(dc, a->rs1));
+ return do_mov_cond(dc, &cmp, a->rd, src2);
+}
+
#define CHECK_IU_FEATURE(dc, FEATURE) \
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
goto illegal_insn;
@@ -4799,66 +4857,12 @@ static void disas_sparc_legacy(DisasContext *dc,
unsigned int insn)
goto illegal_insn; /* WRTBR, WRHPR in decodetree */
#ifdef TARGET_SPARC64
case 0x2c: /* V9 movcc */
- {
- int cc = GET_FIELD_SP(insn, 11, 12);
- int cond = GET_FIELD_SP(insn, 14, 17);
- DisasCompare cmp;
- TCGv dst;
-
- if (insn & (1 << 18)) {
- if (cc == 0) {
- gen_compare(&cmp, 0, cond, dc);
- } else if (cc == 2) {
- gen_compare(&cmp, 1, cond, dc);
- } else {
- goto illegal_insn;
- }
- } else {
- gen_fcompare(&cmp, cc, cond);
- }
-
- /* The get_src2 above loaded the normal 13-bit
- immediate field, not the 11-bit field we have
- in movcc. But it did handle the reg case. */
- if (IS_IMM) {
- simm = GET_FIELD_SPs(insn, 0, 10);
- tcg_gen_movi_tl(cpu_src2, simm);
- }
-
- dst = gen_load_gpr(dc, rd);
- tcg_gen_movcond_tl(cmp.cond, dst,
- cmp.c1, cmp.c2,
- cpu_src2, dst);
- gen_store_gpr(dc, rd, dst);
- break;
- }
+ case 0x2f: /* V9 movr */
+ goto illegal_insn; /* in decodetree */
case 0x2e: /* V9 popc */
tcg_gen_ctpop_tl(cpu_dst, cpu_src2);
gen_store_gpr(dc, rd, cpu_dst);
break;
- case 0x2f: /* V9 movr */
- {
- int cond = GET_FIELD_SP(insn, 10, 12);
- DisasCompare cmp;
- TCGv dst;
-
- gen_compare_reg(&cmp, cond, cpu_src1);
-
- /* The get_src2 above loaded the normal 13-bit
- immediate field, not the 10-bit field we have
- in movr. But it did handle the reg case. */
- if (IS_IMM) {
- simm = GET_FIELD_SPs(insn, 0, 9);
- tcg_gen_movi_tl(cpu_src2, simm);
- }
-
- dst = gen_load_gpr(dc, rd);
- tcg_gen_movcond_tl(cmp.cond, dst,
- cmp.c1, cmp.c2,
- cpu_src2, dst);
- gen_store_gpr(dc, rd, dst);
- break;
- }
#endif
default:
goto illegal_insn;
--
2.34.1
- [PATCH v3 16/90] target/sparc: Merge gen_fcond with only caller, (continued)
- [PATCH v3 16/90] target/sparc: Merge gen_fcond with only caller, Richard Henderson, 2023/10/21
- [PATCH v3 18/90] target/sparc: Pass DisasCompare to advance_jump_cond, Richard Henderson, 2023/10/21
- [PATCH v3 19/90] target/sparc: Move SETHI to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 20/90] target/sparc: Move Tcc to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 30/90] target/sparc: Move ADDC to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 21/90] target/sparc: Move RDASR, STBAR, MEMBAR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 27/90] target/sparc: Move WRWIM, WRPR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 28/90] target/sparc: Move WRTBR, WRHPR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 31/90] target/sparc: Move MULX to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 33/90] target/sparc: Move SUBC to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 38/90] target/sparc: Move MOVcc, MOVR to decodetree,
Richard Henderson <=
- [PATCH v3 23/90] target/sparc: Move RDWIM, RDPR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 36/90] target/sparc: Move TADD, TSUB, MULS to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 26/90] target/sparc: Move WRPSR, SAVED, RESTORED to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 22/90] target/sparc: Move RDPSR, RDHPR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 24/90] target/sparc: Move RDTBR, FLUSHW to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 25/90] target/sparc: Move WRASR to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 29/90] target/sparc: Move basic arithmetic to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 32/90] target/sparc: Move UMUL, SMUL to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 37/90] target/sparc: Move SLL, SRL, SRA to decodetree, Richard Henderson, 2023/10/21
- [PATCH v3 34/90] target/sparc: Move UDIVX, SDIVX to decodetree, Richard Henderson, 2023/10/21