On 11/26/24 08:00, Philippe Mathieu-Daudé wrote:
Once the xlat() and simm7() helpers are added,
the decoding is trivial.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
target/mips/tcg/micromips16.decode | 9 +++++++++
target/mips/tcg/micromips_translate.c | 19 +++++++++++++++++++
target/mips/tcg/micromips_translate.c.inc | 12 +-----------
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/target/mips/tcg/micromips16.decode
b/target/mips/tcg/micromips16.decode
index d341da16b04..fdc3b131c9c 100644
--- a/target/mips/tcg/micromips16.decode
+++ b/target/mips/tcg/micromips16.decode
@@ -9,3 +9,12 @@
# (Document Number: MD00582)
# microMIPS64 Instruction Set
# (Document Number: MD00594)
+
+&rd_imm rd imm
+
+%xlat_rd 7:3 !function=xlat
+%simm7 0:7 !function=simm7
Hmm... simm7 sounds like sign-extended imm7, which this is not.
The encoding appears unique to LI16? Perhaps just li16_imm7?
+
+@rd_imm7 ...... ... ....... &rd_imm rd=%xlat_rd
imm=%simm7
You need not define separate formats when they are one-off.
+
+LI 111011 ... ....... @rd_imm7 # LI16
diff --git a/target/mips/tcg/micromips_translate.c
b/target/mips/tcg/micromips_translate.c
index f0b5dbf655d..198eb466057 100644
--- a/target/mips/tcg/micromips_translate.c
+++ b/target/mips/tcg/micromips_translate.c
@@ -9,11 +9,23 @@
#include "qemu/osdep.h"
#include "translate.h"
+static int xlat(DisasContext *ctx, int x)
+{
+ static const int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 };
+
+ return map[x];
+}
+
static inline int plus_1(DisasContext *ctx, int x)
{
return x + 1;
}
+static inline int simm7(DisasContext *ctx, int x)
+{
+ return x == 0x7f ? -1 : x;
+}
Don't mark inline.
Otherwise,
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
r~