[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 13/90] target/sparc: Move BPr to decodetree
From: |
Richard Henderson |
Subject: |
[PATCH v2 13/90] target/sparc: Move BPr to decodetree |
Date: |
Mon, 16 Oct 2023 23:11:27 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sparc/insns.decode | 3 ++
target/sparc/translate.c | 70 ++++++++++++++++-----------------------
2 files changed, 32 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 7e14070322..a3c86b22d1 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -1331,14 +1331,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,
@@ -1352,16 +1351,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));
@@ -1401,24 +1390,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) {
@@ -3061,6 +3032,31 @@ static bool do_bpcc(DisasContext *dc, arg_bcc *a)
TRANS(BPcc, 64, do_bpcc, a)
TRANS(Bicc, ALL, do_bpcc, a)
+static bool trans_BPr(DisasContext *dc, arg_BPr *a)
+{
+ target_long target;
+ DisasCompare cmp;
+
+ if (!avail_64(dc)) {
+ return false;
+ }
+ if (gen_tcg_cond_reg[a->cond] == TCG_COND_NEVER) {
+ return false;
+ }
+
+ target = dc->pc + a->i * 4;
+ if (unlikely(AM_CHECK(dc))) {
+ target &= 0xffffffffULL;
+ }
+
+ 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 = dc->pc + a->i * 4;
@@ -3104,15 +3100,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 v2 00/90] target/sparc: Convert to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 01/90] target/sparc: Clear may_lookup for npc == DYNAMIC_PC, Richard Henderson, 2023/10/17
- [PATCH v2 02/90] target/sparc: Implement check_align inline, Richard Henderson, 2023/10/17
- [PATCH v2 03/90] target/sparc: Avoid helper_raise_exception in helper_st_asi, Richard Henderson, 2023/10/17
- [PATCH v2 04/90] target/sparc: Set TCG_GUEST_DEFAULT_MO, Richard Henderson, 2023/10/17
- [PATCH v2 06/90] target/sparc: Define features via cpu-feature.h.inc, Richard Henderson, 2023/10/17
- [PATCH v2 05/90] configs: Enable MTTCG for sparc, sparc64, Richard Henderson, 2023/10/17
- [PATCH v2 07/90] target/sparc: Use CPU_FEATURE_BIT_* for cpu properties, Richard Henderson, 2023/10/17
- [PATCH v2 10/90] target/sparc: Define AM_CHECK for sparc32, Richard Henderson, 2023/10/17
- [PATCH v2 13/90] target/sparc: Move BPr to decodetree,
Richard Henderson <=
- [PATCH v2 15/90] target/sparc: Merge gen_cond with only caller, Richard Henderson, 2023/10/17
- [PATCH v2 11/90] target/sparc: Move CALL to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 09/90] target/sparc: Add decodetree infrastructure, Richard Henderson, 2023/10/17
- [PATCH v2 12/90] target/sparc: Move BPcc and Bicc to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 14/90] target/sparc: Move FBPfcc and FBfcc to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 16/90] target/sparc: Merge gen_fcond with only caller, Richard Henderson, 2023/10/17
- [PATCH v2 18/90] target/sparc: Pass DisasCompare to advance_jump_cond, Richard Henderson, 2023/10/17
- [PATCH v2 19/90] target/sparc: Move SETHI to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 20/90] target/sparc: Move Tcc to decodetree, Richard Henderson, 2023/10/17
- [PATCH v2 17/90] target/sparc: Merge gen_branch_[an] with only caller, Richard Henderson, 2023/10/17