Hi,
When working in the KVM Vector support, adding support for the 'vlenb'
register, I noticed that we have a *LOT* of code that uses 'vlenb', in a
far greater amount than 'vlen', and we resort to do 'vlen >> 3' every
time we need 'vlenb'. The conclusion is that we're storing the wrong
state - we should store 'vlenb' instead.
We can't just get rid of the 'vlen' property since it has been exposed
to users already, but what we can do is to change our internal
representation. Users will keep setting 'vlen' but we'll store it as
'vlenb' internally.
To fully remove 'vlen' we need to either use 'vlenb' to retrieve it
(i.e. vlen = vlenb << 3), if we can't help but use 'vlenb', or try to
rework the logic to avoid using vlenb. This was the case of patch 12,
where we avoid using 'vlen' to calculate 'vlmax' in a condition where
vl_eq_vlmax is true.
There was a minor performance gain after these changes, in particular
after patch 07. Performance gain isn't our goal here, but at least we
have evidence that we're not making the emulation slower with these
changes.
Patches based on Alistair's riscv-to-apply.next.
Daniel Henrique Barboza (13):
target/riscv: add 'vlenb' field in cpu->cfg
target/riscv/csr.c: use 'vlenb' instead of 'vlen'
target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'
target/riscv/insn_trans/trans_rvbf16.c.inc: use cpu->cfg.vlenb
target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb'
target/riscv/insn_trans/trans_rvvk.c.inc: use 'vlenb'
target/riscv/vector_helper.c: use 'vlenb'
target/riscv/vector_helper.c: use vlenb in HELPER(vsetvl)
target/riscv/cpu.h: use 'vlenb' in vext_get_vlmax()
target/riscv/insn_trans/trans_rvv.c.inc: use 'vlenb' in MAXSZ()
trans_rvv.c.inc: remove vlmax arg from vec_element_loadx()
trans_rvv.c.inc: use cpu_vl in trans_vrgather_vi()
target/riscv/cpu.c: remove cpu->cfg.vlen
target/riscv/cpu.c | 12 +-
target/riscv/cpu.h | 3 +-
target/riscv/cpu_cfg.h | 2 +-
target/riscv/csr.c | 4 +-
target/riscv/gdbstub.c | 6 +-
target/riscv/insn_trans/trans_rvbf16.c.inc | 12 +-
target/riscv/insn_trans/trans_rvv.c.inc | 200 +++++++++++----------
target/riscv/insn_trans/trans_rvvk.c.inc | 16 +-
target/riscv/tcg/tcg-cpu.c | 4 +-
target/riscv/vector_helper.c | 27 +--
10 files changed, 155 insertions(+), 131 deletions(-)
--
2.43.0