[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 14/94] target/sparc: Move BPr to decodetree
From: |
Richard Henderson |
Subject: |
[PATCH v5 14/94] target/sparc: Move BPr to decodetree |
Date: |
Sun, 22 Oct 2023 16:28:12 -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 | 3 ++
target/sparc/translate.c | 63 ++++++++++++++-------------------------
2 files changed, 25 insertions(+), 41 deletions(-)
diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index 15cd975f4e..838f4cdb1d 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -7,4 +7,7 @@
BPcc 00 a:1 cond:4 001 cc:1 0 - i:s19 &bcc
Bicc 00 a:1 cond:4 010 i:s22 &bcc cc=0
+%d16 20:s2 0:14
+BPr 00 a:1 0 cond:3 011 .. - rs1:5 .............. i=%d16
+
CALL 01 i:s30
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index 92ea6bab6b..2d08c81821 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -1336,14 +1336,13 @@ static void gen_fcond(TCGv r_dst, unsigned int cc,
unsigned int cond)
}
}
-#ifdef TARGET_SPARC64
// Inverted logic
-static const int gen_tcg_cond_reg[8] = {
- -1,
+static const TCGCond gen_tcg_cond_reg[8] = {
+ TCG_COND_NEVER, /* reserved */
TCG_COND_NE,
TCG_COND_GT,
TCG_COND_GE,
- -1,
+ TCG_COND_NEVER, /* reserved */
TCG_COND_EQ,
TCG_COND_LE,
TCG_COND_LT,
@@ -1357,16 +1356,6 @@ static void gen_compare_reg(DisasCompare *cmp, int cond,
TCGv r_src)
cmp->c2 = tcg_constant_tl(0);
}
-static void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src)
-{
- DisasCompare cmp;
- gen_compare_reg(&cmp, cond, r_src);
-
- /* The interface is to return a boolean in r_dst. */
- tcg_gen_setcond_tl(cmp.cond, r_dst, cmp.c1, cmp.c2);
-}
-#endif
-
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc)
{
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29));
@@ -1406,24 +1395,6 @@ static void do_fbranch(DisasContext *dc, int32_t offset,
uint32_t insn, int cc)
}
#ifdef TARGET_SPARC64
-static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
- TCGv r_reg)
-{
- unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29));
- target_ulong target = dc->pc + offset;
-
- if (unlikely(AM_CHECK(dc))) {
- target &= 0xffffffffULL;
- }
- flush_cond(dc);
- gen_cond_reg(cpu_cond, cond, r_reg);
- if (a) {
- gen_branch_a(dc, target);
- } else {
- gen_branch_n(dc, target);
- }
-}
-
static void gen_op_fcmps(int fccno, TCGv_i32 r_rs1, TCGv_i32 r_rs2)
{
switch (fccno) {
@@ -3063,6 +3034,24 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a)
TRANS(Bicc, ALL, do_bpcc, a)
TRANS(BPcc, 64, do_bpcc, a)
+static bool trans_BPr(DisasContext *dc, arg_BPr *a)
+{
+ target_long target = address_mask_i(dc, dc->pc + a->i * 4);
+ DisasCompare cmp;
+
+ if (!avail_64(dc)) {
+ return false;
+ }
+ if (gen_tcg_cond_reg[a->cond] == TCG_COND_NEVER) {
+ return false;
+ }
+
+ flush_cond(dc);
+ gen_compare_reg(&cmp, a->cond, gen_load_gpr(dc, a->rs1));
+ tcg_gen_setcond_tl(cmp.cond, cpu_cond, cmp.c1, cmp.c2);
+ return advance_jump_cond(dc, a->a, target);
+}
+
static bool trans_CALL(DisasContext *dc, arg_CALL *a)
{
target_long target = address_mask_i(dc, dc->pc + a->i * 4);
@@ -3102,15 +3091,7 @@ static void disas_sparc_legacy(DisasContext *dc,
unsigned int insn)
case 0x1: /* V9 BPcc */
g_assert_not_reached(); /* in decodetree */
case 0x3: /* V9 BPr */
- {
- target = GET_FIELD_SP(insn, 0, 13) |
- (GET_FIELD_SP(insn, 20, 21) << 14);
- target = sign_extend(target, 16);
- target <<= 2;
- cpu_src1 = get_src1(dc, insn);
- do_branch_reg(dc, target, insn, cpu_src1);
- goto jmp_insn;
- }
+ g_assert_not_reached(); /* in decodetree */
case 0x5: /* V9 FBPcc */
{
int cc = GET_FIELD_SP(insn, 20, 21);
--
2.34.1
- [PATCH v5 03/94] target/sparc: Avoid helper_raise_exception in helper_st_asi, (continued)
- [PATCH v5 03/94] target/sparc: Avoid helper_raise_exception in helper_st_asi, Richard Henderson, 2023/10/22
- [PATCH v5 02/94] target/sparc: Implement check_align inline, Richard Henderson, 2023/10/22
- [PATCH v5 05/94] configs: Enable MTTCG for sparc, sparc64, Richard Henderson, 2023/10/22
- [PATCH v5 06/94] target/sparc: Define features via cpu-feature.h.inc, Richard Henderson, 2023/10/22
- [PATCH v5 07/94] target/sparc: Use CPU_FEATURE_BIT_* for cpu properties, Richard Henderson, 2023/10/22
- [PATCH v5 04/94] target/sparc: Set TCG_GUEST_DEFAULT_MO, Richard Henderson, 2023/10/22
- [PATCH v5 01/94] target/sparc: Clear may_lookup for npc == DYNAMIC_PC, Richard Henderson, 2023/10/22
- [PATCH v5 08/94] target/sparc: Remove sparcv7 cpu features, Richard Henderson, 2023/10/22
- [PATCH v5 11/94] target/sparc: Define AM_CHECK for sparc32, Richard Henderson, 2023/10/22
- [PATCH v5 09/94] target/sparc: Partition cpu features, Richard Henderson, 2023/10/22
- [PATCH v5 14/94] target/sparc: Move BPr to decodetree,
Richard Henderson <=
- [PATCH v5 22/94] target/sparc: Move RDASR, STBAR, MEMBAR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 25/94] target/sparc: Move RDTBR, FLUSHW to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 17/94] target/sparc: Merge gen_fcond with only caller, Richard Henderson, 2023/10/22
- [PATCH v5 12/94] target/sparc: Move CALL to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 15/94] target/sparc: Move FBPfcc and FBfcc to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 18/94] target/sparc: Merge gen_branch_[an] with only caller, Richard Henderson, 2023/10/22
- [PATCH v5 26/94] target/sparc: Move WRASR to decodetree, Richard Henderson, 2023/10/22
- [PATCH v5 30/94] target/sparc: Remove cpu_wim, Richard Henderson, 2023/10/22
- [PATCH v5 32/94] target/sparc: Remove cpu_hintp, cpu_htba, cpu_hver, cpu_ssr, cpu_ver, Richard Henderson, 2023/10/22
- [PATCH v5 29/94] target/sparc: Move WRTBR, WRHPR to decodetree, Richard Henderson, 2023/10/22