On 11/11/24 14:44, Philippe Mathieu-Daudé wrote:
From: Philippe Mathieu-Daudé <f4...@amsat.org>
Simply call the generic gen_lsa() helper, taking care
to substract 1 to the shift field.
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
target/mips/tcg/nanomips32.decode | 8 ++++++++
target/mips/tcg/nanomips_translate.c | 12 ++++++++++++
target/mips/tcg/nanomips_translate.c.inc | 9 ---------
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/target/mips/tcg/nanomips32.decode
b/target/mips/tcg/nanomips32.decode
index 9cecf1e13d..11bf5cd6c4 100644
--- a/target/mips/tcg/nanomips32.decode
+++ b/target/mips/tcg/nanomips32.decode
@@ -6,3 +6,11 @@
#
# Reference: nanoMIPS32 Instruction Set Technical Reference Manual
# (Document Number: MD01247)
+
+&r rs rt rd sa
+
+%lsa_u2 9:2 !function=minus_1
+
+@lsa ...... rt:5 rs:5 rd:5 .. --- ... ... &r sa=%lsa_u2
+
+LSA 001000 ..... ..... ..... .. ... 001 111 @lsa
diff --git a/target/mips/tcg/nanomips_translate.c
b/target/mips/tcg/nanomips_translate.c
index c148c13ed9..9a6db4a828 100644
--- a/target/mips/tcg/nanomips_translate.c
+++ b/target/mips/tcg/nanomips_translate.c
@@ -9,6 +9,18 @@
#include "qemu/osdep.h"
#include "translate.h"
+static inline int minus_1(DisasContext *ctx, int x)
+{
+ return x - 1;
+}
+
/* Include the auto-generated decoders. */
#include "decode-nanomips16.c.inc"
#include "decode-nanomips32.c.inc"
+
+static bool trans_LSA(DisasContext *ctx, arg_r *a)
+{
+ gen_lsa(ctx, a->rd, a->rt, a->rs, a->sa);
I think decoding shift-amount - 1 is misleading.
Surely it would be better for other callers to pass extract(...) + 1?
r~