Skip to content

target/riscv: Convert to decodetree

Palmer Dabbelt qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v7 Latest35 patches 9 repliesIn review

Changes in v7 from the cover letter

- Rebased on top of riscv-for-master-4.0-sf1, which contains a refactoring of the original translation code.
- Added handling of mstatus.fs to the floating-point routines.

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/35target/riscv: Move CPURISCVState pointer to DisasContexttarget/riscv/translate.c+4 -31 reply
2/35target/riscv: Activate decodetree and implemnt LUI & AUIPCtarget/riscv/Makefile.objs target/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c +1 more+92 -140 replies
3/35target/riscv: Convert RVXI branch insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+69 -110 replies
4/35target/riscv: Convert RV32I load/store insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c+58 -00 replies
5/35target/riscv: Convert RV64I load/store insns to decodetreetarget/riscv/Makefile.objs target/riscv/insn32-64.decode target/riscv/insn_trans/trans_rvi.inc.c +1 more+50 -100 replies
6/35target/riscv: Convert RVXI arithmetic insns to decodetreetarget/riscv/insn32-64.decode target/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c +1 more+206 -90 replies
7/35target/riscv: Convert RVXI fence insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+21 -120 replies
8/35target/riscv: Convert RVXI csr insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+88 -420 replies
9/35target/riscv: Convert RVXM insns to decodetreetarget/riscv/insn32-64.decode target/riscv/insn32.decode target/riscv/insn_trans/trans_rvm.inc.c +1 more+118 -90 replies
10/35target/riscv: Convert RV32A insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rva.inc.c target/riscv/translate.c+167 -01 reply
11/35target/riscv: Convert RV64A insns to decodetreetarget/riscv/insn32-64.decode target/riscv/insn_trans/trans_rva.inc.c target/riscv/translate.c+71 -1440 replies
12/35target/riscv: Convert RV32F insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvf.inc.c target/riscv/translate.c+389 -01 reply
13/35target/riscv: Convert RV64F insns to decodetreetarget/riscv/insn32-64.decode target/riscv/insn_trans/trans_rvf.inc.c+63 -10 replies
14/35target/riscv: Convert RV32D insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvd.inc.c target/riscv/translate.c+364 -00 replies
15/35target/riscv: Convert RV64D insns to decodetreetarget/riscv/insn32-64.decode target/riscv/insn_trans/trans_rvd.inc.c target/riscv/translate.c+85 -6000 replies
16/35target/riscv: Convert RV priv insns to decodetreetarget/riscv/insn32.decode target/riscv/insn_trans/trans_privileged.inc.c target/riscv/translate.c+126 -561 reply
17/35target/riscv: Convert quadrant 0 of RVXC insns to decodetreetarget/riscv/Makefile.objs target/riscv/insn16.decode target/riscv/insn_trans/trans_rvc.inc.c +1 more+154 -380 replies
18/35target/riscv: Convert quadrant 1 of RVXC insns to decodetreetarget/riscv/insn16.decode target/riscv/insn_trans/trans_rvc.inc.c target/riscv/translate.c+195 -1170 replies
19/35target/riscv: Convert quadrant 2 of RVXC insns to decodetreetarget/riscv/insn16.decode target/riscv/insn_trans/trans_rvc.inc.c target/riscv/translate.c+134 -810 replies
20/35target/riscv: Remove gen_jalr()target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+27 -391 reply
21/35target/riscv: Remove manual decoding from gen_branch()target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+33 -601 reply
22/35target/riscv: Remove manual decoding from gen_load()target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+25 -160 replies
23/35target/riscv: Remove manual decoding from gen_store()target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+24 -110 replies
24/35target/riscv: Move gen_arith_imm() decoding into trans_* functionstarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+108 -1000 replies
25/35target/riscv: make ADD/SUB/OR/XOR/AND insn use arg liststarget/riscv/insn32.decode target/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+34 -300 replies
26/35target/riscv: Remove shift and slt insn manual decodingtarget/riscv/insn_trans/trans_rvi.inc.c target/riscv/translate.c+81 -710 replies
27/35target/riscv: Remove manual decoding of RV32/64M insntarget/riscv/insn_trans/trans_rvm.inc.c target/riscv/translate.c+164 -2110 replies
28/35target/riscv: Rename trans_arith to gen_arithtarget/riscv/insn_trans/trans_rvi.inc.c target/riscv/insn_trans/trans_rvm.inc.c target/riscv/translate.c+18 -180 replies
29/35target/riscv: Remove gen_system()target/riscv/translate.c+0 -340 replies
30/35target/riscv: Remove decode_RV32_64G()target/riscv/translate.c+1 -200 replies
31/35target/riscv: Convert @cs_2 insns to share translation functionstarget/riscv/Makefile.objs target/riscv/insn16-64.decode target/riscv/insn16.decode +2 more+54 -590 replies
32/35target/riscv: Convert @cl_d, @cl_w, @cs_d, @cs_w insnstarget/riscv/insn16.decode target/riscv/insn32.decode target/riscv/insn_trans/trans_rvc.inc.c+12 -350 replies
33/35target/riscv: Splice fsw_sd and flw_ld for riscv32 vs riscv64target/riscv/Makefile.objs target/riscv/insn16-32.decode target/riscv/insn16-64.decode +3 more+31 -2080 replies
34/35target/riscv: Splice remaining compressed insn pairs for riscv32 vs riscv64target/riscv/insn16-32.decode target/riscv/insn16-64.decode target/riscv/insn16.decode +2 more+16 -510 replies
35/35target/riscv: Remaining rvc insn reuse 32 bit translatorstarget/riscv/insn16.decode target/riscv/insn_trans/trans_rvc.inc.c+17 -680 replies

Reviews trailers per patch

All 35 patches have a Reviewed-by or Acked-by.

PatchAlistair FrancisRichard HendersonPalmer DabbeltBastian Koppelmann
SeriesT-b
1/35R-b R-b R-b
2/35A-b R-b
3/35A-b R-b R-b
4/35A-b R-b
5/35A-b R-b
6/35A-b R-b
7/35A-b R-b
8/35A-b R-b
9/35A-b R-b
10/35A-b R-b
11/35A-b R-b
12/35A-b R-b
13/35A-b R-b
14/35A-b R-b
15/35A-b R-b
16/35A-b R-b
17/35R-b
18/35R-b
19/35R-b
20/35A-b R-b
21/35R-b
22/35R-b
23/35R-b
24/35R-b
25/35R-b
26/35R-b
27/35R-b
28/35R-b
29/35R-b
30/35R-b
31/35R-b
32/35R-b
33/35R-b
34/35R-b
35/35R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v7 thread

Cover letter [Qemu-devel] [PATCH v7 00/35] target/riscv: Convert to decodetree

Palmer: I caused some merge conflicts in Bastian's patch set so I figured I'd attempt to clean these up. As far as I'm concerned v6 was good to go, but since the merge conflicts were fairly extensive (if somewhat mechanical) I'd like to pass the baton back to Bastian here for at least a sanity check.

Hi,

this patchset converts the RISC-V decoder to decodetree in four major steps:

1) Convert 32-bit instructions to decodetree [Patch 1-16]:
Many of the gen_* functions are called by the decode functions for 16-bit and 32-bit functions. If we move translation code from the gen_* functions to the generated trans_* functions of decode-tree, we get a lot of duplication. Therefore, we mostly generate calls to the old gen_* function which are properly replaced after step 2).

Each of the trans_ functions are grouped into files corresponding to their ISA extension, e.g. addi which is in RV32I is translated in the file 'trans_rvi.inc.c'.

2) Convert 16-bit instructions to decodetree [Patch 17-19]:
All 16 bit instructions have a direct mapping to a 32 bit instruction. Thus, we convert the arguments in the 16 bit trans_ function to the arguments of the corresponding 32 bit instruction and call the 32 bit trans_ function.

3) Remove old manual decoding in gen_* function [Patch 20-30]:
this move all manual translation code into the trans_* instructions of decode tree, such that we can remove the old decode_* functions.

4) Simplify RVC by reusing as much as possible from the RVG decoder as suggested by Richard. [Patch 31-35]

full tree available at
https://github.com/palmer-dabbelt/qemu/tree/riscv-dt-v7

Cheers,
Bastian

v6 -> v7:
- Rebased on top of riscv-for-master-4.0-sf1, which contains a refactoring of the original translation code.
- Added handling of mstatus.fs to the floating-point routines.

v5 -> v6:
- fixed funky indentation