target/mips: Convert nanoMIPS LSA opcode to decodetree
cover target/mips: Convert nanoMIPS LSA opcode to decodetree
Yet another 2 patches extracted from an old branch I'm rebasing. Trivial decodetree conversion of LSA, however this introduce the basis to convert nanoMIPS opcodes.
Philippe Mathieu-Daudé (2):
target/mips: Introduce decode tree bindings for nanoMIPS ISA target/mips: Convert nanoMIPS LSA opcode to decodetree
target/mips/tcg/translate.h | 2 ++ target/mips/tcg/nanomips16.decode | 8 ++++++++ target/mips/tcg/nanomips32.decode | 16 +++++++++++++++ target/mips/tcg/nanomips_translate.c | 26 ++++++++++++++++++++++++ target/mips/tcg/nanomips_translate.c.inc | 16 +++++++-------- target/mips/tcg/meson.build | 3 +++ 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 target/mips/tcg/nanomips16.decode create mode 100644 target/mips/tcg/nanomips32.decode create mode 100644 target/mips/tcg/nanomips_translate.c
Signature · 1 line
2.45.2
PATCH 1/2 target/mips: Introduce decode tree bindings for nanoMIPS ISA
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the nanoMIPS decodetree configs for the 16-bit and 32-bit instructions.
--- target/mips/tcg/translate.h | 2 ++ target/mips/tcg/nanomips16.decode | 8 ++++++++ target/mips/tcg/nanomips32.decode | 8 ++++++++ target/mips/tcg/nanomips_translate.c | 14 ++++++++++++++ target/mips/tcg/nanomips_translate.c.inc | 7 +++++++ target/mips/tcg/meson.build | 3 +++ 6 files changed, 42 insertions(+) create mode 100644 target/mips/tcg/nanomips16.decode create mode 100644 target/mips/tcg/nanomips32.decode create mode 100644 target/mips/tcg/nanomips_translate.c
target/mips/tcg/translate.h +2 -0
@@ -222,6 +222,8 @@ bool decode_ase_mxu(DisasContext *ctx, uint32_t insn);bool decode_64bit_enabled (DisasContext *ctx);/* decodetree generated */ +bool decode_isa_nanomips16 (DisasContext *ctx,uint16_t insn); +bool decode_isa_nanomips32 (DisasContext *ctx,uint32_t insn);bool decode_isa_rel6 (DisasContext *ctx,uint32_t insn);bool decode_ase_msa (DisasContext *ctx,uint32_t insn);bool decode_ext_txx9 (DisasContext *ctx,uint32_t insn);
target/mips/tcg/nanomips16.decode new file +8 -0
@@ -0,0 +1,8 @@ +# nanoMIPS32 16-bit instruction set extensions +# +# Copyright (C) 2021 Philippe Mathieu-Daudé +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Reference: nanoMIPS32 Instruction Set Technical Reference Manual +# (Document Number: MD01247)
target/mips/tcg/nanomips32.decode new file +8 -0
@@ -0,0 +1,8 @@ +# nanoMIPS32 32-bit instruction set extensions +# +# Copyright (C) 2021 Philippe Mathieu-Daudé +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Reference: nanoMIPS32 Instruction Set Technical Reference Manual +# (Document Number: MD01247)
target/mips/tcg/nanomips_translate.c new file +14 -0
@@ -0,0 +1,14 @@ +/* +* MIPS emulation for QEMU - nanoMIPS translation routines +* +* Copyright (c) 2021 Philippe Mathieu-Daudé <[email protected]> +* +* SPDX-License-Identifier: LGPL-2.1-or-later +*/ + +#include "qemu/osdep.h" +#include "translate.h" + +/* Include the auto-generated decoders. */ +#include "decode-nanomips16.c.inc" +#include "decode-nanomips32.c.inc"
target/mips/tcg/nanomips_translate.c.inc +7 -0
@@ -4482,6 +4482,13 @@ static int decode_isa_nanomips(CPUMIPSState *env, DisasContext *ctx) return 2; } + if (decode_isa_nanomips16(ctx, ctx->opcode)) { + return 2; + } + if (decode_isa_nanomips32(ctx, ctx->opcode)) { + return 4; + } + op = extract32(ctx->opcode, 10, 6); switch (op) { case NM_P16_MV:
target/mips/tcg/meson.build +3 -0
@@ -1,5 +1,7 @@ gen = [ decodetree.process('rel6.decode', extra_args: ['--decode=decode_isa_rel6']), + decodetree.process('nanomips16.decode', extra_args: ['--decode=decode_isa_nanomips16', '--insnwidth=16']), + decodetree.process('nanomips32.decode', extra_args: ['--decode=decode_isa_nanomips32']), decodetree.process('msa.decode', extra_args: '--decode=decode_ase_msa'), decodetree.process('tx79.decode', extra_args: '--static-decode=decode_tx79'), decodetree.process('vr54xx.decode', extra_args: '--decode=decode_ext_vr54xx'),
@@ -18,6 +20,7 @@ mips_ss.add(files( 'lmmi_helper.c', 'msa_helper.c', 'msa_translate.c', + 'nanomips_translate.c', 'op_helper.c', 'rel6_translate.c', 'translate.c',
Signature · 1 line
2.45.2
Re: [PATCH 1/2] target/mips: Introduce decode tree bindings for nanoMIPS ISA
Quoted 15 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé<[email protected]>
Introduce the nanoMIPS decodetree configs for the 16-bit and 32-bit instructions.
Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/mips/tcg/translate.h | 2 ++ target/mips/tcg/nanomips16.decode | 8 ++++++++ target/mips/tcg/nanomips32.decode | 8 ++++++++ target/mips/tcg/nanomips_translate.c | 14 ++++++++++++++ target/mips/tcg/nanomips_translate.c.inc | 7 +++++++ target/mips/tcg/meson.build | 3 +++ 6 files changed, 42 insertions(+)
Quoted 3 lines
create mode 100644 target/mips/tcg/nanomips16.decode create mode 100644 target/mips/tcg/nanomips32.decode create mode 100644
target/mips/tcg/nanomips_translate.c
r~
PATCH 2/2 target/mips: Convert nanoMIPS LSA opcode to decodetree
In reply to Philippe Mathieu-DaudéFrom: Philippe Mathieu-Daudé <[email protected]>
Simply call the generic gen_lsa() helper, taking care to substract 1 to the shift field.
--- 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(-)
target/mips/tcg/nanomips32.decode +8 -0
@@ -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
target/mips/tcg/nanomips_translate.c +12 -0
@@ -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); + +return true; +}
target/mips/tcg/nanomips_translate.c.inc +0 -9
@@ -399,7 +399,6 @@ enum { /* POOL32A7 instruction pool */ enum { NM_P_LSX = 0x00, - NM_LSA = 0x01, NM_EXTW = 0x03, NM_POOL32AXF = 0x07, };
@@ -3625,14 +3624,6 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx) case NM_P_LSX: gen_p_lsx(ctx, rd, rs, rt); break; - case NM_LSA: - /* - * In nanoMIPS, the shift field directly encodes the shift - * amount, meaning that the supported shift values are in - * the range 0 to 3 (instead of 1 to 4 in MIPSR6). - */ - gen_lsa(ctx, rd, rt, rs, extract32(ctx->opcode, 9, 2) - 1); - break; case NM_EXTW: gen_ext(ctx, 32, rd, rs, rt, extract32(ctx->opcode, 6, 5)); break;
Signature · 1 line
2.45.2
Quoted 39 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
Simply call the generic
gen_lsa()helper, taking care to substract 1 to the shift field.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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(-)target/mips/tcg/nanomips32.decode +8
-0@@ -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 @lsatarget/mips/tcg/nanomips_translate.c +2
-0@@ -9,6 +9,18 @@#include "qemu/osdep.h" #include "translate.h" +static inline int minus_1 (DisasContext *ctx,int x) +{
target/mips/tcg/nanomips_translate.c line 23
Quoted 10 lines
target/mips/tcg/nanomips_translate.c +7
-0+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~
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
Simply call the generic
gen_lsa()helper, taking care to substract 1 to the shift field.Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
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(-)target/mips/tcg/nanomips_translate.c +5
-0@@ -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. */
Quoted 8 lines
target/mips/tcg/nanomips_translate.c line 23
Quoted 6 lines
target/mips/tcg/nanomips_translate.c +4
-0#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.
Yeah I thought the same while rebasing ...
Quoted 1 line
Surely it would be better for other callers to pass extract(...) + 1?
... but was too lazy to do the changes :p
Quoted 4 lines
r~
Quoted 9 lines
Yet another 2 patches extracted from an old branch I'm rebasing. Trivial decodetree conversion of LSA, however this introduce the basis to convert nanoMIPS opcodes.
Philippe Mathieu-Daudé (2):
target/mips: Introduce decode tree bindings for nanoMIPS ISA target/mips: Convert nanoMIPS LSA opcode to decodetree
For the entire series: