@@ -3,6 +3,10 @@
# Sparc instruction decode definitions.
# Copyright (c) 2023 Richard Henderson <rth@twiddle.net>
+##
+## Major Opcodes 00 and 01 -- branches, call, and sethi.
+##
+
&bcc i a cond cc
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
@@ -14,4 +18,6 @@ BPr 00 a:1 0 cond:3 011 .. - rs1:5 .............. i=%d16
NCP 00 - ---- 111 ---------------------- # CBcc
+SETHI 00 rd:5 100 i:22
+
CALL 01 i:s30
@@ -2868,6 +2868,10 @@ static bool advance_pc(DisasContext *dc)
return true;
}
+/*
+ * Major opcodes 00 and 01 -- branches, call, and sethi
+ */
+
static bool advance_jump_uncond_never(DisasContext *dc, bool annul)
{
if (annul) {
@@ -3040,6 +3044,15 @@ static bool trans_NCP(DisasContext *dc, arg_NCP *a)
#endif
}
+static bool trans_SETHI(DisasContext *dc, arg_SETHI *a)
+{
+ /* Special-case %g0 because that's the canonical nop. */
+ if (a->rd) {
+ gen_store_gpr(dc, a->rd, tcg_constant_tl((uint32_t)a->i << 10));
+ }
+ return advance_pc(dc);
+}
+
#define CHECK_IU_FEATURE(dc, FEATURE) \
if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
goto illegal_insn;
@@ -3060,41 +3073,8 @@ static void disas_sparc_legacy(DisasContext *dc, unsigned int insn)
rd = GET_FIELD(insn, 2, 6);
switch (opc) {
- case 0: /* branches/sethi */
- {
- unsigned int xop = GET_FIELD(insn, 7, 9);
- switch (xop) {
-#ifdef TARGET_SPARC64
- case 0x1: /* V9 BPcc */
- g_assert_not_reached(); /* in decodetree */
- case 0x3: /* V9 BPr */
- g_assert_not_reached(); /* in decodetree */
- case 0x5: /* V9 FBPcc */
- g_assert_not_reached(); /* in decodetree */
-#else
- case 0x7: /* CBN+x */
- g_assert_not_reached(); /* in decodetree */
-#endif
- case 0x2: /* BN+x */
- g_assert_not_reached(); /* in decodetree */
- case 0x6: /* FBN+x */
- g_assert_not_reached(); /* in decodetree */
- case 0x4: /* SETHI */
- /* Special-case %g0 because that's the canonical nop. */
- if (rd) {
- uint32_t value = GET_FIELD(insn, 10, 31);
- TCGv t = gen_dest_gpr(dc, rd);
- tcg_gen_movi_tl(t, value << 10);
- gen_store_gpr(dc, rd, t);
- }
- break;
- case 0x0: /* UNIMPL */
- default:
- goto illegal_insn;
- }
- break;
- }
- break;
+ case 0:
+ goto illegal_insn; /* in decodetree */
case 1:
g_assert_not_reached(); /* in decodetree */
case 2: /* FPU & Logical Operations */
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/sparc/insns.decode | 6 +++++ target/sparc/translate.c | 50 ++++++++++++--------------------------- 2 files changed, 21 insertions(+), 35 deletions(-)