qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@sifive.com>
To: qemu-riscv@nongnu.org
Cc: qemu-devel@nongnu.org,
	Bastian Koppelmann <kbastian@mail.uni-paderborn.de>,
	Peer Adelt <peer.adelt@hni.uni-paderborn.de>
Subject: [Qemu-devel] [PATCH v7 03/35] target/riscv: Convert RVXI branch insns to decodetree
Date: Wed, 13 Feb 2019 07:53:42 -0800	[thread overview]
Message-ID: <20190213155414.22285-4-palmer@sifive.com> (raw)
In-Reply-To: <20190213155414.22285-1-palmer@sifive.com>

From: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>

Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Signed-off-by: Peer Adelt <peer.adelt@hni.uni-paderborn.de>
---
 target/riscv/insn32.decode              | 19 ++++++++++
 target/riscv/insn_trans/trans_rvi.inc.c | 49 +++++++++++++++++++++++++
 target/riscv/translate.c                | 12 +-----
 3 files changed, 69 insertions(+), 11 deletions(-)

diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
index 44d4e922b6fa..81f56c16b45f 100644
--- a/target/riscv/insn32.decode
+++ b/target/riscv/insn32.decode
@@ -17,14 +17,33 @@
 # this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Fields:
+%rs2       20:5
+%rs1       15:5
 %rd        7:5
 
 # immediates:
+%imm_i    20:s12
+%imm_b    31:s1 7:1 25:6 8:4     !function=ex_shift_1
+%imm_j    31:s1 12:8 20:1 21:10  !function=ex_shift_1
 %imm_u    12:s20                 !function=ex_shift_12
 
+# Argument sets:
+&b    imm rs2 rs1
+
 # Formats 32:
+@i       ............    ..... ... ..... .......         imm=%imm_i     %rs1 %rd
+@b       .......   ..... ..... ... ..... ....... &b      imm=%imm_b %rs2 %rs1
 @u       ....................      ..... .......         imm=%imm_u          %rd
+@j       ....................      ..... .......         imm=%imm_j          %rd
 
 # *** RV32I Base Instruction Set ***
 lui      ....................       ..... 0110111 @u
 auipc    ....................       ..... 0010111 @u
+jal      ....................       ..... 1101111 @j
+jalr     ............     ..... 000 ..... 1100111 @i
+beq      ....... .....    ..... 000 ..... 1100011 @b
+bne      ....... .....    ..... 001 ..... 1100011 @b
+blt      ....... .....    ..... 100 ..... 1100011 @b
+bge      ....... .....    ..... 101 ..... 1100011 @b
+bltu     ....... .....    ..... 110 ..... 1100011 @b
+bgeu     ....... .....    ..... 111 ..... 1100011 @b
diff --git a/target/riscv/insn_trans/trans_rvi.inc.c b/target/riscv/insn_trans/trans_rvi.inc.c
index 9885a8d27551..bcf20def50eb 100644
--- a/target/riscv/insn_trans/trans_rvi.inc.c
+++ b/target/riscv/insn_trans/trans_rvi.inc.c
@@ -33,3 +33,52 @@ static bool trans_auipc(DisasContext *ctx, arg_auipc *a)
     }
     return true;
 }
+
+static bool trans_jal(DisasContext *ctx, arg_jal *a)
+{
+    gen_jal(ctx, a->rd, a->imm);
+    return true;
+}
+
+static bool trans_jalr(DisasContext *ctx, arg_jalr *a)
+{
+    gen_jalr(ctx, OPC_RISC_JALR, a->rd, a->rs1, a->imm);
+    return true;
+}
+
+static bool trans_beq(DisasContext *ctx, arg_beq *a)
+{
+    gen_branch(ctx, OPC_RISC_BEQ, a->rs1, a->rs2, a->imm);
+    return true;
+}
+
+static bool trans_bne(DisasContext *ctx, arg_bne *a)
+{
+    gen_branch(ctx, OPC_RISC_BNE, a->rs1, a->rs2, a->imm);
+    return true;
+}
+
+static bool trans_blt(DisasContext *ctx, arg_blt *a)
+{
+    gen_branch(ctx, OPC_RISC_BLT, a->rs1, a->rs2, a->imm);
+    return true;
+}
+
+static bool trans_bge(DisasContext *ctx, arg_bge *a)
+{
+    gen_branch(ctx, OPC_RISC_BGE, a->rs1, a->rs2, a->imm);
+    return true;
+}
+
+static bool trans_bltu(DisasContext *ctx, arg_bltu *a)
+{
+    gen_branch(ctx, OPC_RISC_BLTU, a->rs1, a->rs2, a->imm);
+    return true;
+}
+
+static bool trans_bgeu(DisasContext *ctx, arg_bgeu *a)
+{
+
+    gen_branch(ctx, OPC_RISC_BGEU, a->rs1, a->rs2, a->imm);
+    return true;
+}
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 4076f28b3c8b..c5bcfd6b9756 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1880,6 +1880,7 @@ static void decode_RV32_64C(DisasContext *ctx)
     {                                         \
         return imm << amount;                 \
     }
+EX_SH(1)
 EX_SH(12)
 
 bool decode_insn32(DisasContext *ctx, uint32_t insn);
@@ -1908,17 +1909,6 @@ static void decode_RV32_64G(DisasContext *ctx)
     imm = GET_IMM(ctx->opcode);
 
     switch (op) {
-    case OPC_RISC_JAL:
-        imm = GET_JAL_IMM(ctx->opcode);
-        gen_jal(ctx, rd, imm);
-        break;
-    case OPC_RISC_JALR:
-        gen_jalr(ctx, MASK_OP_JALR(ctx->opcode), rd, rs1, imm);
-        break;
-    case OPC_RISC_BRANCH:
-        gen_branch(ctx, MASK_OP_BRANCH(ctx->opcode), rs1, rs2,
-                   GET_B_IMM(ctx->opcode));
-        break;
     case OPC_RISC_LOAD:
         gen_load(ctx, MASK_OP_LOAD(ctx->opcode), rd, rs1, imm);
         break;
-- 
2.18.1

  parent reply	other threads:[~2019-02-13 15:55 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 15:53 [Qemu-devel] [PATCH v7 00/35] target/riscv: Convert to decodetree Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 01/35] target/riscv: Move CPURISCVState pointer to DisasContext Palmer Dabbelt
2019-02-13 16:18   ` Bastian Koppelmann
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 02/35] target/riscv: Activate decodetree and implemnt LUI & AUIPC Palmer Dabbelt
2019-02-13 15:53 ` Palmer Dabbelt [this message]
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 04/35] target/riscv: Convert RV32I load/store insns to decodetree Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 05/35] target/riscv: Convert RV64I " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 06/35] target/riscv: Convert RVXI arithmetic " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 07/35] target/riscv: Convert RVXI fence " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 08/35] target/riscv: Convert RVXI csr " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 09/35] target/riscv: Convert RVXM " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 10/35] target/riscv: Convert RV32A " Palmer Dabbelt
2019-02-15 12:09   ` Bastian Koppelmann
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 11/35] target/riscv: Convert RV64A " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 12/35] target/riscv: Convert RV32F " Palmer Dabbelt
2019-02-15 12:11   ` Bastian Koppelmann
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 13/35] target/riscv: Convert RV64F " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 14/35] target/riscv: Convert RV32D " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 15/35] target/riscv: Convert RV64D " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 16/35] target/riscv: Convert RV priv " Palmer Dabbelt
2019-02-15 12:13   ` Bastian Koppelmann
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 17/35] target/riscv: Convert quadrant 0 of RVXC " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 18/35] target/riscv: Convert quadrant 1 " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 19/35] target/riscv: Convert quadrant 2 " Palmer Dabbelt
2019-02-13 15:53 ` [Qemu-devel] [PATCH v7 20/35] target/riscv: Remove gen_jalr() Palmer Dabbelt
2019-02-15 12:14   ` Bastian Koppelmann
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 21/35] target/riscv: Remove manual decoding from gen_branch() Palmer Dabbelt
2019-02-15 12:15   ` Bastian Koppelmann
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 22/35] target/riscv: Remove manual decoding from gen_load() Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 23/35] target/riscv: Remove manual decoding from gen_store() Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 24/35] target/riscv: Move gen_arith_imm() decoding into trans_* functions Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 25/35] target/riscv: make ADD/SUB/OR/XOR/AND insn use arg lists Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 26/35] target/riscv: Remove shift and slt insn manual decoding Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 27/35] target/riscv: Remove manual decoding of RV32/64M insn Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 28/35] target/riscv: Rename trans_arith to gen_arith Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 29/35] target/riscv: Remove gen_system() Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 30/35] target/riscv: Remove decode_RV32_64G() Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 31/35] target/riscv: Convert @cs_2 insns to share translation functions Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 32/35] target/riscv: Convert @cl_d, @cl_w, @cs_d, @cs_w insns Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 33/35] target/riscv: Splice fsw_sd and flw_ld for riscv32 vs riscv64 Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 34/35] target/riscv: Splice remaining compressed insn pairs " Palmer Dabbelt
2019-02-13 15:54 ` [Qemu-devel] [PATCH v7 35/35] target/riscv: Remaining rvc insn reuse 32 bit translators Palmer Dabbelt
2019-02-15 12:36 ` [Qemu-devel] [PATCH v7 00/35] target/riscv: Convert to decodetree no-reply
2019-02-15 12:40 ` no-reply
2019-02-15 13:07 ` no-reply
2019-02-15 13:11 ` no-reply
2019-02-15 13:13 ` Bastian Koppelmann
2019-02-15 13:38 ` no-reply
2019-02-15 13:42 ` no-reply
2019-02-15 14:11 ` no-reply
2019-02-15 14:42 ` no-reply
2019-02-15 15:14 ` no-reply
2019-02-15 15:45 ` no-reply
2019-02-15 16:39 ` no-reply
2019-02-15 16:42 ` no-reply
2019-02-15 17:11 ` no-reply
2019-02-20 17:02 ` Bastian Koppelmann
2019-02-21 17:23   ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213155414.22285-4-palmer@sifive.com \
    --to=palmer@sifive.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=peer.adelt@hni.uni-paderborn.de \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).