target/riscv: Support Zabha extension
cover target/riscv: Support Zabha extension
Zabha adds support AMO operations for byte and half word. If zacas has been implemented, zabha also adds support amocas.b and amocas.h.
More details is on the specification here:
https://github.com/riscv/riscv-zabha
The implemenation of zabha follows the way of AMOs and zacas.
This patch set is based on these two patch set:
1. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00207.html
2. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00212.html
LIU Zhiwei (6):
target/riscv: Move gen_amo before implement Zabha target/riscv: Add AMO instructions for Zabha target/riscv: Move gen_cmpxchg before adding amocas.[b|h] target/riscv: Add amocas.[b|h] for Zabha target/riscv: Enable zabha for max cpu disas/riscv: Support zabha disassemble
disas/riscv.c | 60 ++++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 22 +++ target/riscv/insn_trans/trans_rva.c.inc | 21 --- target/riscv/insn_trans/trans_rvzabha.c.inc | 145 ++++++++++++++++++++ target/riscv/insn_trans/trans_rvzacas.c.inc | 13 -- target/riscv/translate.c | 36 +++++ 8 files changed, 266 insertions(+), 34 deletions(-) create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc
Signature · 1 line
2.25.1
PATCH 1/6 target/riscv: Move gen_amo before implement Zabha
--- target/riscv/insn_trans/trans_rva.c.inc | 21 --------------------- target/riscv/translate.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-)
target/riscv/insn_trans/trans_rva.c.inc +0 -21
@@ -96,27 +96,6 @@ static bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) return true; } -static bool gen_amo(DisasContext *ctx, arg_atomic *a, - void(*func)(TCGv, TCGv, TCGv, TCGArg, MemOp), - MemOp mop) -{ - TCGv dest = dest_gpr(ctx, a->rd); - TCGv src1, src2 = get_gpr(ctx, a->rs2, EXT_NONE); - - if (ctx->cfg_ptr->ext_zama16b) { - mop |= MO_ATOM_WITHIN16; - } else { - mop |= MO_ALIGN; - } - - decode_save_opc(ctx); - src1 = get_address(ctx, a->rs1, 0); - func(dest, src1, src2, ctx->mem_idx, mop); - - gen_set_gpr(ctx, a->rd, dest); - return true; -} - static bool trans_lr_w(DisasContext *ctx, arg_lr_w *a) { REQUIRE_A_OR_ZALRSC(ctx);
target/riscv/translate.c +21 -0
@@ -1075,6 +1075,27 @@ static bool gen_unary_per_ol(DisasContext *ctx, arg_r2 *a, DisasExtend ext,return gen_unary (ctx, a, ext, f_tl); } +static bool gen_amo (DisasContext *ctx,arg_atomic *a, +void (*func)(TCGv ,TCGv ,TCGv ,TCGArg ,MemOp ), +MemOp mop) +{ +TCGv dest =dest_gpr (ctx, a->rd); +TCGv src1, src2 =get_gpr (ctx, a->rs2,EXT_NONE ); + +if (ctx->cfg_ptr->ext_zama16b) { + mop |=MO_ATOM_WITHIN16 ; + }else { + mop |=MO_ALIGN ; + } + +decode_save_opc (ctx); + src1 =get_address (ctx, a->rs1,0 ); +func (dest, src1, src2, ctx->mem_idx, mop); + +gen_set_gpr (ctx, a->rd, dest); +return true; +} +static uint32_t opcode_at (DisasContextBase *dcbase,target_ulong pc) {DisasContext *ctx =container_of (dcbase, DisasContext, base);
Signature · 1 line
2.25.1
Re: [PATCH 1/6] target/riscv: Move gen_amo before implement Zabha
Quoted 2 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>
Alistair
Quoted 73 lines
--- target/riscv/insn_trans/trans_rva.c.inc | 21 --------------------- target/riscv/translate.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-)target/riscv/insn_trans/trans_rva.c.inc +0
-21@@ -96,27 +96,6 @@ static bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) return true; } -static bool gen_amo(DisasContext *ctx, arg_atomic *a, - void(*func)(TCGv, TCGv, TCGv, TCGArg, MemOp), - MemOp mop) -{ - TCGv dest = dest_gpr(ctx, a->rd); - TCGv src1, src2 = get_gpr(ctx, a->rs2, EXT_NONE); - - if (ctx->cfg_ptr->ext_zama16b) { - mop |= MO_ATOM_WITHIN16; - } else { - mop |= MO_ALIGN; - } - - decode_save_opc(ctx); - src1 = get_address(ctx, a->rs1, 0); - func(dest, src1, src2, ctx->mem_idx, mop); - - gen_set_gpr(ctx, a->rd, dest); - return true; -} - static bool trans_lr_w(DisasContext *ctx, arg_lr_w *a) { REQUIRE_A_OR_ZALRSC(ctx);target/riscv/translate.c +21
-1@@ -1075,6 +1075,27 @@ static bool gen_unary_per_ol(DisasContext *ctx, arg_r2 *a, DisasExtend ext,return gen_unary (ctx, a, ext, f_tl); } +static bool gen_amo (DisasContext *ctx,arg_atomic *a, +void (*func)(TCGv ,TCGv ,TCGv ,TCGArg ,MemOp ), +MemOp mop) +{ +TCGv dest =dest_gpr (ctx, a->rd); +TCGv src1, src2 =get_gpr (ctx, a->rs2,EXT_NONE ); + +if (ctx->cfg_ptr->ext_zama16b) { + mop |=MO_ATOM_WITHIN16 ; + }else { + mop |=MO_ALIGN ; + } + +decode_save_opc (ctx); + src1 =get_address (ctx, a->rs1,0 ); +func (dest, src1, src2, ctx->mem_idx, mop); + +gen_set_gpr (ctx, a->rd, dest); +return true; +} +static uint32_t opcode_at (DisasContextBase *dcbase,target_ulong pc) {DisasContext *ctx =container_of (dcbase, DisasContext, base); --2.25.1
PATCH 2/6 target/riscv: Add AMO instructions for Zabha
In reply to LIU Zhiwei--- target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 20 +++ target/riscv/insn_trans/trans_rvzabha.c.inc | 131 ++++++++++++++++++++ target/riscv/translate.c | 4 +- 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc
target/riscv/cpu_cfg.h +1 -0
@@ -84,6 +84,7 @@ struct RISCVCPUConfig {bool ext_zaamo;bool ext_zacas;bool ext_zama16b; +bool ext_zabha;bool ext_zalrsc;bool ext_zawrs;bool ext_zfa;
target/riscv/insn32.decode +20 -0
@@ -1021,3 +1021,23 @@ amocas_q 00101 . . ..... ..... 100 ..... 0101111 @atom_st # *** Zimop may-be-operation extension *** mop_r_n 1 . 00 .. 0111 .. ..... 100 ..... 0111011 @mop5 mop_rr_n 1 . 00 .. 1 ..... ..... 100 ..... 0111011 @mop3 + +# *** Zabhb Standard Extension *** +amoswap_b 00001 . . ..... ..... 000 ..... 0101111 @atom_st +amoadd_b 00000 . . ..... ..... 000 ..... 0101111 @atom_st +amoxor_b 00100 . . ..... ..... 000 ..... 0101111 @atom_st +amoand_b 01100 . . ..... ..... 000 ..... 0101111 @atom_st +amoor_b 01000 . . ..... ..... 000 ..... 0101111 @atom_st +amomin_b 10000 . . ..... ..... 000 ..... 0101111 @atom_st +amomax_b 10100 . . ..... ..... 000 ..... 0101111 @atom_st +amominu_b 11000 . . ..... ..... 000 ..... 0101111 @atom_st +amomaxu_b 11100 . . ..... ..... 000 ..... 0101111 @atom_st +amoswap_h 00001 . . ..... ..... 001 ..... 0101111 @atom_st +amoadd_h 00000 . . ..... ..... 001 ..... 0101111 @atom_st +amoxor_h 00100 . . ..... ..... 001 ..... 0101111 @atom_st +amoand_h 01100 . . ..... ..... 001 ..... 0101111 @atom_st +amoor_h 01000 . . ..... ..... 001 ..... 0101111 @atom_st +amomin_h 10000 . . ..... ..... 001 ..... 0101111 @atom_st +amomax_h 10100 . . ..... ..... 001 ..... 0101111 @atom_st +amominu_h 11000 . . ..... ..... 001 ..... 0101111 @atom_st +amomaxu_h 11100 . . ..... ..... 001 ..... 0101111 @atom_st
target/riscv/insn_trans/trans_rvzabha.c.inc new file +131 -0
131 lines not on this page · raw message
target/riscv/translate.c +3 -1
@@ -1081,8 +1081,9 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a, {TCGv dest =dest_gpr (ctx, a->rd);TCGv src1, src2 =get_gpr (ctx, a->rs2,EXT_NONE ); +MemOp size = mop &MO_SIZE ; -if (ctx->cfg_ptr->ext_zama16b) { +if (ctx->cfg_ptr->ext_zama16b && size >=MO_32 ) { mop |=MO_ATOM_WITHIN16 ; }else { mop |=MO_ALIGN ;
@@ -1116,6 +1117,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)#include "insn_trans/trans_rvb.c.inc" #include "insn_trans/trans_rvzicond.c.inc" #include "insn_trans/trans_rvzacas.c.inc" +#include "insn_trans/trans_rvzabha.c.inc" #include "insn_trans/trans_rvzawrs.c.inc" #include "insn_trans/trans_rvzicbo.c.inc" #include "insn_trans/trans_rvzimop.c.inc"
Signature · 1 line
2.25.1
Re: [PATCH 2/6] target/riscv: Add AMO instructions for Zabha
Quoted 2 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>
Alistair
Quoted 212 lines
--- target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 20 +++ target/riscv/insn_trans/trans_rvzabha.c.inc | 131 ++++++++++++++++++++ target/riscv/translate.c | 4 +- 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inctarget/riscv/cpu_cfg.h +1
-0@@ -84,6 +84,7 @@ struct RISCVCPUConfig {bool ext_zaamo;bool ext_zacas;bool ext_zama16b; +bool ext_zabha;bool ext_zalrsc;bool ext_zawrs;bool ext_zfa;target/riscv/insn32.decode +20
-0@@ -1021,3 +1021,23 @@ amocas_q 00101 . . ..... ..... 100 ..... 0101111 @atom_st # *** Zimop may-be-operation extension *** mop_r_n 1 . 00 .. 0111 .. ..... 100 ..... 0111011 @mop5 mop_rr_n 1 . 00 .. 1 ..... ..... 100 ..... 0111011 @mop3 + +# *** Zabhb Standard Extension *** +amoswap_b 00001 . . ..... ..... 000 ..... 0101111 @atom_st +amoadd_b 00000 . . ..... ..... 000 ..... 0101111 @atom_st +amoxor_b 00100 . . ..... ..... 000 ..... 0101111 @atom_st +amoand_b 01100 . . ..... ..... 000 ..... 0101111 @atom_st +amoor_b 01000 . . ..... ..... 000 ..... 0101111 @atom_st +amomin_b 10000 . . ..... ..... 000 ..... 0101111 @atom_st +amomax_b 10100 . . ..... ..... 000 ..... 0101111 @atom_st +amominu_b 11000 . . ..... ..... 000 ..... 0101111 @atom_st +amomaxu_b 11100 . . ..... ..... 000 ..... 0101111 @atom_st +amoswap_h 00001 . . ..... ..... 001 ..... 0101111 @atom_st +amoadd_h 00000 . . ..... ..... 001 ..... 0101111 @atom_st +amoxor_h 00100 . . ..... ..... 001 ..... 0101111 @atom_st +amoand_h 01100 . . ..... ..... 001 ..... 0101111 @atom_st +amoor_h 01000 . . ..... ..... 001 ..... 0101111 @atom_st +amomin_h 10000 . . ..... ..... 001 ..... 0101111 @atom_st +amomax_h 10100 . . ..... ..... 001 ..... 0101111 @atom_st +amominu_h 11000 . . ..... ..... 001 ..... 0101111 @atom_st +amomaxu_h 11100 . . ..... ..... 001 ..... 0101111 @atom_sttarget/riscv/insn_trans/trans_rvzabha.c.inc new file +131
-0@@ -0,0 +1,131 @@ +/* + * RISC-V translation routines for the Zabha Standard Extension. + * + * Copyright (c) 2024 Alibaba Group + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#define REQUIRE_ZABHA(ctx) do { \ + if (!ctx->cfg_ptr->ext_zabha) { \ + return false; \ + } \ +} while (0) + +static bool trans_amoswap_b(DisasContext *ctx, arg_amoswap_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_xchg_tl, MO_SB); +} + +static bool trans_amoadd_b(DisasContext *ctx, arg_amoadd_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_add_tl, MO_SB); +} + +static bool trans_amoxor_b(DisasContext *ctx, arg_amoxor_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_xor_tl, MO_SB); +} + +static bool trans_amoand_b(DisasContext *ctx, arg_amoand_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_and_tl, MO_SB); +} + +static bool trans_amoor_b(DisasContext *ctx, arg_amoor_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_or_tl, MO_SB); +} + +static bool trans_amomin_b(DisasContext *ctx, arg_amomin_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smin_tl, MO_SB); +} + +static bool trans_amomax_b(DisasContext *ctx, arg_amomax_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smax_tl, MO_SB); +} + +static bool trans_amominu_b(DisasContext *ctx, arg_amominu_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umin_tl, MO_SB); +} + +static bool trans_amomaxu_b(DisasContext *ctx, arg_amomaxu_b *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, MO_SB); +} + +static bool trans_amoswap_h(DisasContext *ctx, arg_amoswap_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_xchg_tl, MO_TESW); +} + +static bool trans_amoadd_h(DisasContext *ctx, arg_amoadd_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_add_tl, MO_TESW); +} + +static bool trans_amoxor_h(DisasContext *ctx, arg_amoxor_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_xor_tl, MO_TESW); +} + +static bool trans_amoand_h(DisasContext *ctx, arg_amoand_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_and_tl, MO_TESW); +} + +static bool trans_amoor_h(DisasContext *ctx, arg_amoor_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_or_tl, MO_TESW); +} + +static bool trans_amomin_h(DisasContext *ctx, arg_amomin_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smin_tl, MO_TESW); +} + +static bool trans_amomax_h(DisasContext *ctx, arg_amomax_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smax_tl, MO_TESW); +} + +static bool trans_amominu_h(DisasContext *ctx, arg_amominu_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umin_tl, MO_TESW); +} + +static bool trans_amomaxu_h(DisasContext *ctx, arg_amomaxu_h *a) +{ + REQUIRE_ZABHA(ctx); + return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, MO_TESW); +}target/riscv/translate.c +3
-2@@ -1081,8 +1081,9 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a, {TCGv dest =dest_gpr (ctx, a->rd);TCGv src1, src2 =get_gpr (ctx, a->rs2,EXT_NONE ); +MemOp size = mop &MO_SIZE ; -if (ctx->cfg_ptr->ext_zama16b) { +if (ctx->cfg_ptr->ext_zama16b && size >=MO_32 ) { mop |=MO_ATOM_WITHIN16 ; }else { mop |=MO_ALIGN ;@@ -1116,6 +1117,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)#include "insn_trans/trans_rvb.c.inc" #include "insn_trans/trans_rvzicond.c.inc" #include "insn_trans/trans_rvzacas.c.inc" +#include "insn_trans/trans_rvzabha.c.inc" #include "insn_trans/trans_rvzawrs.c.inc" #include "insn_trans/trans_rvzicbo.c.inc" #include "insn_trans/trans_rvzimop.c.inc" --2.25.1
PATCH 3/6 target/riscv: Move gen_cmpxchg before adding amocas.[b|h]
In reply to LIU Zhiwei--- target/riscv/insn_trans/trans_rvzacas.c.inc | 13 ------------- target/riscv/translate.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-)
target/riscv/insn_trans/trans_rvzacas.c.inc +0 -13
@@ -22,19 +22,6 @@ } \ } while (0) -static bool gen_cmpxchg(DisasContext *ctx, arg_atomic *a, MemOp mop) -{ - TCGv dest = get_gpr(ctx, a->rd, EXT_NONE); - TCGv src1 = get_address(ctx, a->rs1, 0); - TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); - - decode_save_opc(ctx); - tcg_gen_atomic_cmpxchg_tl(dest, src1, dest, src2, ctx->mem_idx, mop); - - gen_set_gpr(ctx, a->rd, dest); - return true; -} - static bool trans_amocas_w(DisasContext *ctx, arg_amocas_w *a) { REQUIRE_ZACAS(ctx);
target/riscv/translate.c +13 -0
@@ -1097,6 +1097,19 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a,return true; } +static bool gen_cmpxchg (DisasContext *ctx,arg_atomic *a,MemOp mop) +{ +TCGv dest =get_gpr (ctx, a->rd,EXT_NONE ); +TCGv src1 =get_address (ctx, a->rs1,0 ); +TCGv src2 =get_gpr (ctx, a->rs2,EXT_NONE ); + +decode_save_opc (ctx); +tcg_gen_atomic_cmpxchg_tl (dest, src1, dest, src2, ctx->mem_idx, mop); + +gen_set_gpr (ctx, a->rd, dest); +return true; +} +static uint32_t opcode_at (DisasContextBase *dcbase,target_ulong pc) {DisasContext *ctx =container_of (dcbase, DisasContext, base);
Signature · 1 line
2.25.1
Re: [PATCH 3/6] target/riscv: Move gen_cmpxchg before adding amocas.[b|h]
Quoted 2 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>
Alistair
Quoted 57 lines
--- target/riscv/insn_trans/trans_rvzacas.c.inc | 13 ------------- target/riscv/translate.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-)target/riscv/insn_trans/trans_rvzacas.c.inc +0
-13@@ -22,19 +22,6 @@ } \ } while (0) -static bool gen_cmpxchg(DisasContext *ctx, arg_atomic *a, MemOp mop) -{ - TCGv dest = get_gpr(ctx, a->rd, EXT_NONE); - TCGv src1 = get_address(ctx, a->rs1, 0); - TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); - - decode_save_opc(ctx); - tcg_gen_atomic_cmpxchg_tl(dest, src1, dest, src2, ctx->mem_idx, mop); - - gen_set_gpr(ctx, a->rd, dest); - return true; -} - static bool trans_amocas_w(DisasContext *ctx, arg_amocas_w *a) { REQUIRE_ZACAS(ctx);target/riscv/translate.c +13
-1@@ -1097,6 +1097,19 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a,return true; } +static bool gen_cmpxchg (DisasContext *ctx,arg_atomic *a,MemOp mop) +{ +TCGv dest =get_gpr (ctx, a->rd,EXT_NONE ); +TCGv src1 =get_address (ctx, a->rs1,0 ); +TCGv src2 =get_gpr (ctx, a->rs2,EXT_NONE ); + +decode_save_opc (ctx); +tcg_gen_atomic_cmpxchg_tl (dest, src1, dest, src2, ctx->mem_idx, mop); + +gen_set_gpr (ctx, a->rd, dest); +return true; +} +static uint32_t opcode_at (DisasContextBase *dcbase,target_ulong pc) {DisasContext *ctx =container_of (dcbase, DisasContext, base); --2.25.1
PATCH 4/6 target/riscv: Add amocas.[b|h] for Zabha
In reply to LIU Zhiwei--- target/riscv/insn32.decode | 2 ++ target/riscv/insn_trans/trans_rvzabha.c.inc | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
target/riscv/insn32.decode +2 -0
@@ -1041,3 +1041,5 @@ amomin_h 10000 . . ..... ..... 001 ..... 0101111 @atom_st amomax_h 10100 . . ..... ..... 001 ..... 0101111 @atom_st amominu_h 11000 . . ..... ..... 001 ..... 0101111 @atom_st amomaxu_h 11100 . . ..... ..... 001 ..... 0101111 @atom_st +amocas_b 00101 . . ..... ..... 000 ..... 0101111 @atom_st +amocas_h 00101 . . ..... ..... 001 ..... 0101111 @atom_st
target/riscv/insn_trans/trans_rvzabha.c.inc +14 -0
@@ -129,3 +129,17 @@ static bool trans_amomaxu_h(DisasContext *ctx, arg_amomaxu_h *a) REQUIRE_ZABHA(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, MO_TESW); } + +static bool trans_amocas_b(DisasContext *ctx, arg_amocas_b *a) +{ + REQUIRE_ZACAS(ctx); + REQUIRE_ZABHA(ctx); + return gen_cmpxchg(ctx, a, MO_SB); +} + +static bool trans_amocas_h(DisasContext *ctx, arg_amocas_h *a) +{ + REQUIRE_ZACAS(ctx); + REQUIRE_ZABHA(ctx); + return gen_cmpxchg(ctx, a, MO_ALIGN | MO_TESW); +}
Signature · 1 line
2.25.1
Re: [PATCH 4/6] target/riscv: Add amocas.[b|h] for Zabha
Quoted 2 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>
Alistair
Quoted 41 lines
--- target/riscv/insn32.decode | 2 ++ target/riscv/insn_trans/trans_rvzabha.c.inc | 14 ++++++++++++++ 2 files changed, 16 insertions(+)target/riscv/insn32.decode +2
-0@@ -1041,3 +1041,5 @@ amomin_h 10000 . . ..... ..... 001 ..... 0101111 @atom_st amomax_h 10100 . . ..... ..... 001 ..... 0101111 @atom_st amominu_h 11000 . . ..... ..... 001 ..... 0101111 @atom_st amomaxu_h 11100 . . ..... ..... 001 ..... 0101111 @atom_st +amocas_b 00101 . . ..... ..... 000 ..... 0101111 @atom_st +amocas_h 00101 . . ..... ..... 001 ..... 0101111 @atom_sttarget/riscv/insn_trans/trans_rvzabha.c.inc +14
-1@@ -129,3 +129,17 @@ static bool trans_amomaxu_h(DisasContext *ctx, arg_amomaxu_h *a) REQUIRE_ZABHA(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, MO_TESW); } + +static bool trans_amocas_b(DisasContext *ctx, arg_amocas_b *a) +{ + REQUIRE_ZACAS(ctx); + REQUIRE_ZABHA(ctx); + return gen_cmpxchg(ctx, a, MO_SB); +} + +static bool trans_amocas_h(DisasContext *ctx, arg_amocas_h *a) +{ + REQUIRE_ZACAS(ctx); + REQUIRE_ZABHA(ctx); + return gen_cmpxchg(ctx, a, MO_ALIGN | MO_TESW); +} --2.25.1
PATCH 5/6 target/riscv: Enable zabha for max cpu
In reply to LIU Zhiwei--- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+)
target/riscv/cpu.c +2 -0
@@ -118,6 +118,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zaamo,PRIV_VERSION_1_12_0 , ext_zaamo),ISA_EXT_DATA_ENTRY (zacas,PRIV_VERSION_1_12_0 , ext_zacas),ISA_EXT_DATA_ENTRY (zama16b,PRIV_VERSION_1_12_0 , ext_zama16b), +ISA_EXT_DATA_ENTRY (zabha,PRIV_VERSION_1_12_0 , ext_zabha),ISA_EXT_DATA_ENTRY (zalrsc,PRIV_VERSION_1_12_0 , ext_zalrsc),ISA_EXT_DATA_ENTRY (zawrs,PRIV_VERSION_1_12_0 , ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa),
@@ -1470,6 +1471,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zcmop" , ext_zcmop, false),MULTI_EXT_CFG_BOOL ("zacas" , ext_zacas, false),MULTI_EXT_CFG_BOOL ("zama16b" , ext_zama16b, false), +MULTI_EXT_CFG_BOOL ("zabha" , ext_zabha, false),MULTI_EXT_CFG_BOOL ("zaamo" , ext_zaamo, false),MULTI_EXT_CFG_BOOL ("zalrsc" , ext_zalrsc, false), MULTI_EXT_CFG_BOOL("zawrs", ext_zawrs, true),
Signature · 1 line
2.25.1
Re: [PATCH 5/6] target/riscv: Enable zabha for max cpu
Quoted 10 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>--- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+)target/riscv/cpu.c +0
-0
target/riscv/cpu.c const RISCVIsaExtData isa_edata_arr[] = { · line 121
Quoted 4 lines
target/riscv/cpu.c +1
-0@@ -118,6 +118,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zaamo,PRIV_VERSION_1_12_0 , ext_zaamo),ISA_EXT_DATA_ENTRY (zacas,PRIV_VERSION_1_12_0 , ext_zacas),ISA_EXT_DATA_ENTRY (zama16b,PRIV_VERSION_1_12_0 , ext_zama16b), + ISA_EXT_DATA_ENTRY(zabha, PRIV_VERSION_1_12_0, ext_zabha),
I think this should be place right after zaamo. Thanks,
Daniel
Quoted 11 lines
target/riscv/cpu.c +1
-0ISA_EXT_DATA_ENTRY (zalrsc,PRIV_VERSION_1_12_0 , ext_zalrsc),ISA_EXT_DATA_ENTRY (zawrs,PRIV_VERSION_1_12_0 , ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa),@@ -1470,6 +1471,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zcmop" , ext_zcmop, false),MULTI_EXT_CFG_BOOL ("zacas" , ext_zacas, false),MULTI_EXT_CFG_BOOL ("zama16b" , ext_zama16b, false), +MULTI_EXT_CFG_BOOL ("zabha" , ext_zabha, false),MULTI_EXT_CFG_BOOL ("zaamo" , ext_zaamo, false),MULTI_EXT_CFG_BOOL ("zalrsc" , ext_zalrsc, false), MULTI_EXT_CFG_BOOL("zawrs", ext_zawrs, true),
PATCH 6/6 disas/riscv: Support zabha disassemble
In reply to LIU Zhiwei--- disas/riscv.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
disas/riscv.c +60 -0
@@ -954,6 +954,26 @@ typedef enum { rv_c_mop_11 =923 , rv_c_mop_13 =924 , rv_c_mop_15 =925 , + rv_op_amoswap_b =926 , + rv_op_amoadd_b =927 , + rv_op_amoxor_b =928 , + rv_op_amoor_b =929 , + rv_op_amoand_b =930 , + rv_op_amomin_b =931 , + rv_op_amomax_b =932 , + rv_op_amominu_b =933 , + rv_op_amomaxu_b =934 , + rv_op_amoswap_h =935 , + rv_op_amoadd_h =936 , + rv_op_amoxor_h =937 , + rv_op_amoor_h =938 , + rv_op_amoand_h =939 , + rv_op_amomin_h =940 , + rv_op_amomax_h =941 , + rv_op_amominu_h =942 , + rv_op_amomaxu_h =943 , + rv_op_amocas_b =944 , + rv_op_amocas_h =945 , } rv_op;/* register names */
@@ -2192,6 +2212,26 @@ const rv_opcode_data rvi_opcode_data[] = { { "c.mop.11", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, { "c.mop.13", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, { "c.mop.15", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, + { "amoswap.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoadd.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoxor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoand.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomin.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomax.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amominu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomaxu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoswap.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoadd.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoxor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoand.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomin.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomax.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amominu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomaxu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amocas.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amocas.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, };/* CSR names */
@@ -2923,9 +2963,13 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 11 :switch (((inst >>24 ) &0b11111000 ) | ((inst >>12 ) &0b00000111 )) { +case 0 : op = rv_op_amoadd_b;break ; +case 1 : op = rv_op_amoadd_h;break ;case 2 : op = rv_op_amoadd_w;break ;case 3 : op = rv_op_amoadd_d;break ;case 4 : op = rv_op_amoadd_q;break ; +case 8 : op = rv_op_amoswap_b;break ; +case 9 : op = rv_op_amoswap_h;break ;case 10 : op = rv_op_amoswap_w;break ;case 11 : op = rv_op_amoswap_d;break ;case 12 : op = rv_op_amoswap_q;break ;
@@ -2947,27 +2991,43 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 26 : op = rv_op_sc_w;break ;case 27 : op = rv_op_sc_d;break ;case 28 : op = rv_op_sc_q;break ; +case 32 : op = rv_op_amoxor_b;break ; +case 33 : op = rv_op_amoxor_h;break ;case 34 : op = rv_op_amoxor_w;break ;case 35 : op = rv_op_amoxor_d;break ;case 36 : op = rv_op_amoxor_q;break ; +case 40 : op = rv_op_amocas_b;break ; +case 41 : op = rv_op_amocas_h;break ;case 42 : op = rv_op_amocas_w;break ;case 43 : op = rv_op_amocas_d;break ;case 44 : op = rv_op_amocas_q;break ; +case 64 : op = rv_op_amoor_b;break ; +case 65 : op = rv_op_amoor_h;break ;case 66 : op = rv_op_amoor_w;break ;case 67 : op = rv_op_amoor_d;break ;case 68 : op = rv_op_amoor_q;break ; +case 96 : op = rv_op_amoand_b;break ; +case 97 : op = rv_op_amoand_h;break ;case 98 : op = rv_op_amoand_w;break ;case 99 : op = rv_op_amoand_d;break ;case 100 : op = rv_op_amoand_q;break ; +case 128 : op = rv_op_amomin_b;break ; +case 129 : op = rv_op_amomin_h;break ;case 130 : op = rv_op_amomin_w;break ;case 131 : op = rv_op_amomin_d;break ;case 132 : op = rv_op_amomin_q;break ; +case 160 : op = rv_op_amomax_b;break ; +case 161 : op = rv_op_amomax_h;break ;case 162 : op = rv_op_amomax_w;break ;case 163 : op = rv_op_amomax_d;break ;case 164 : op = rv_op_amomax_q;break ; +case 192 : op = rv_op_amominu_b;break ; +case 193 : op = rv_op_amominu_h;break ;case 194 : op = rv_op_amominu_w;break ;case 195 : op = rv_op_amominu_d;break ;case 196 : op = rv_op_amominu_q;break ; +case 224 : op = rv_op_amomaxu_b;break ; +case 225 : op = rv_op_amomaxu_h;break ;case 226 : op = rv_op_amomaxu_w;break ;case 227 : op = rv_op_amomaxu_d;break ;case 228 : op = rv_op_amomaxu_q;break ;
Signature · 1 line
2.25.1
Re: [PATCH 6/6] disas/riscv: Support zabha disassemble
Quoted 2 lines · LIU Zhiwei
Signed-off-by LIU Zhiwei <[email protected]>
Alistair
Quoted 124 lines
--- disas/riscv.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)disas/riscv.c +60
-1@@ -954,6 +954,26 @@ typedef enum { rv_c_mop_11 =923 , rv_c_mop_13 =924 , rv_c_mop_15 =925 , + rv_op_amoswap_b =926 , + rv_op_amoadd_b =927 , + rv_op_amoxor_b =928 , + rv_op_amoor_b =929 , + rv_op_amoand_b =930 , + rv_op_amomin_b =931 , + rv_op_amomax_b =932 , + rv_op_amominu_b =933 , + rv_op_amomaxu_b =934 , + rv_op_amoswap_h =935 , + rv_op_amoadd_h =936 , + rv_op_amoxor_h =937 , + rv_op_amoor_h =938 , + rv_op_amoand_h =939 , + rv_op_amomin_h =940 , + rv_op_amomax_h =941 , + rv_op_amominu_h =942 , + rv_op_amomaxu_h =943 , + rv_op_amocas_b =944 , + rv_op_amocas_h =945 , } rv_op;/* register names */ @@ -2192,6 +2212,26 @@ const rv_opcode_data rvi_opcode_data[] = { { "c.mop.11", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, { "c.mop.13", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, { "c.mop.15", rv_codec_ci_none, rv_fmt_none, NULL, 0, 0, 0 }, + { "amoswap.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoadd.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoxor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoor.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoand.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomin.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomax.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amominu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomaxu.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoswap.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoadd.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoxor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoor.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amoand.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomin.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomax.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amominu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amomaxu.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amocas.b", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, + { "amocas.h", rv_codec_r_a, rv_fmt_aqrl_rd_rs2_rs1, NULL, 0, 0, 0 }, };/* CSR names */ @@ -2923,9 +2963,13 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 11 :switch (((inst >>24 ) &0b11111000 ) | ((inst >>12 ) &0b00000111 )) { +case 0 : op = rv_op_amoadd_b;break ; +case 1 : op = rv_op_amoadd_h;break ;case 2 : op = rv_op_amoadd_w;break ;case 3 : op = rv_op_amoadd_d;break ;case 4 : op = rv_op_amoadd_q;break ; +case 8 : op = rv_op_amoswap_b;break ; +case 9 : op = rv_op_amoswap_h;break ;case 10 : op = rv_op_amoswap_w;break ;case 11 : op = rv_op_amoswap_d;break ;case 12 : op = rv_op_amoswap_q;break ;@@ -2947,27 +2991,43 @@ static void decode_inst_opcode(rv_decode *dec, rv_isa isa)case 26 : op = rv_op_sc_w;break ;case 27 : op = rv_op_sc_d;break ;case 28 : op = rv_op_sc_q;break ; +case 32 : op = rv_op_amoxor_b;break ; +case 33 : op = rv_op_amoxor_h;break ;case 34 : op = rv_op_amoxor_w;break ;case 35 : op = rv_op_amoxor_d;break ;case 36 : op = rv_op_amoxor_q;break ; +case 40 : op = rv_op_amocas_b;break ; +case 41 : op = rv_op_amocas_h;break ;case 42 : op = rv_op_amocas_w;break ;case 43 : op = rv_op_amocas_d;break ;case 44 : op = rv_op_amocas_q;break ; +case 64 : op = rv_op_amoor_b;break ; +case 65 : op = rv_op_amoor_h;break ;case 66 : op = rv_op_amoor_w;break ;case 67 : op = rv_op_amoor_d;break ;case 68 : op = rv_op_amoor_q;break ; +case 96 : op = rv_op_amoand_b;break ; +case 97 : op = rv_op_amoand_h;break ;case 98 : op = rv_op_amoand_w;break ;case 99 : op = rv_op_amoand_d;break ;case 100 : op = rv_op_amoand_q;break ; +case 128 : op = rv_op_amomin_b;break ; +case 129 : op = rv_op_amomin_h;break ;case 130 : op = rv_op_amomin_w;break ;case 131 : op = rv_op_amomin_d;break ;case 132 : op = rv_op_amomin_q;break ; +case 160 : op = rv_op_amomax_b;break ; +case 161 : op = rv_op_amomax_h;break ;case 162 : op = rv_op_amomax_w;break ;case 163 : op = rv_op_amomax_d;break ;case 164 : op = rv_op_amomax_q;break ; +case 192 : op = rv_op_amominu_b;break ; +case 193 : op = rv_op_amominu_h;break ;case 194 : op = rv_op_amominu_w;break ;case 195 : op = rv_op_amominu_d;break ;case 196 : op = rv_op_amominu_q;break ; +case 224 : op = rv_op_amomaxu_b;break ; +case 225 : op = rv_op_amomaxu_h;break ;case 226 : op = rv_op_amomaxu_w;break ;case 227 : op = rv_op_amomaxu_d;break ;case 228 : op = rv_op_amomaxu_q;break ; --2.25.1
Hi Zhiwei!
Quoted 11 lines · LIU Zhiwei
Zabha adds support AMO operations for byte and half word. If zacas has been implemented, zabha also adds support amocas.b and
amocas.h.More details is on the specification here:
https://github.com/riscv/riscv-zabhaThe implemenation of zabha follows the way of AMOs and zacas.
This patch set is based on these two patch set:
1. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00207.html
2. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00212.html
These 2 series doesn't seem to apply on top of each other, doesn't matter which order I try. Applying zimop/zcmop first, then zama16b:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension error: patch failed: target/riscv/cpu.c:1464 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Support Zama16b extension hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying zama16b first, then zimop/zcmop:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension $ $ git am \[PATCH\ 1_4\]\ target_riscv\:\ Add\ zimop\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml \[PATCH\ 2_4\]\ disas_riscv\:\ Support\ zimop\ disassemble\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml Applying: target/riscv: Add zimop extension error: patch failed: target/riscv/cpu.c:1463 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Add zimop extension
If the series are dependent on each other perhaps it's easier to send everything in a single 11 patches series.
Thanks,
Daniel
Quoted 21 lines
LIU Zhiwei (6):
target/riscv: Movegen_amobefore implement Zabha target/riscv: Add AMO instructions for Zabha target/riscv: Movegen_cmpxchgbefore adding amocas.[b|h] target/riscv: Add amocas.[b|h] for Zabha target/riscv: Enable zabha for max cpu disas/riscv: Support zabha disassembledisas/riscv.c | 60 ++++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 22 +++ target/riscv/insn_trans/trans_rva.c.inc | 21 --- target/riscv/insn_trans/trans_rvzabha.c.inc | 145 ++++++++++++++++++++ target/riscv/insn_trans/trans_rvzacas.c.inc | 13 -- target/riscv/translate.c | 36 +++++ 8 files changed, 266 insertions(+), 34 deletions(-)create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc
Quoted 42 lines · Daniel Henrique Barboza
Hi Zhiwei!
Quoted 11 lines · LIU Zhiwei
Zabha adds support AMO operations for byte and half word. If zacas has been implemented, zabha also adds support amocas.b and
amocas.h.More details is on the specification here:
https://github.com/riscv/riscv-zabhaThe implemenation of zabha follows the way of AMOs and zacas.
This patch set is based on these two patch set:
1. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00207.html
2. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00212.htmlThese 2 series doesn't seem to apply on top of each other, doesn't matter which order I try. Applying zimop/zcmop first, then zama16b:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension error: patch failed: target/riscv/cpu.c:1464 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Support Zama16b extension hint: Use 'git am --show-current-patch=diff' to see the failed patchApplying zama16b first, then zimop/zcmop:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension $ $ git am \[PATCH\ 1_4\]\ target_riscv\:\ Add\ zimop\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml \[PATCH\ 2_4\]\ disas_riscv\:\ Support\ zimop\ disassemble\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml Applying: target/riscv: Add zimop extension error: patch failed: target/riscv/cpu.c:1463 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Add zimop extension
Quoted 2 lines
If the series are dependent on each other perhaps it's easier to send everything in a single 11 patches series.
They don't have dependency on each other. But if we both rebase them to the master branch, they couldn't be merged at the time, as them both modify cpu.h and cpu.c in the same place.
I will send them as a whole patch set(RVA23 patch set) after I fix other issues on implementing the RVA23 profile.
Thanks,
Zhiwei
Quoted 27 lines
Thanks,
Daniel
Quoted 21 lines
LIU Zhiwei (6):
target/riscv: Movegen_amobefore implement Zabha target/riscv: Add AMO instructions for Zabha target/riscv: Movegen_cmpxchgbefore adding amocas.[b|h] target/riscv: Add amocas.[b|h] for Zabha target/riscv: Enable zabha for max cpu disas/riscv: Support zabha disassembledisas/riscv.c | 60 ++++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 22 +++ target/riscv/insn_trans/trans_rva.c.inc | 21 --- target/riscv/insn_trans/trans_rvzabha.c.inc | 145 ++++++++++++++++++++ target/riscv/insn_trans/trans_rvzacas.c.inc | 13 -- target/riscv/translate.c | 36 +++++
8 files changed, 266 insertions(+), 34 deletions(-)create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc
Quoted 42 lines · LIU Zhiwei
Quoted 40 lines · Daniel Henrique Barboza
Hi Zhiwei!
Quoted 11 lines · LIU Zhiwei
Zabha adds support AMO operations for byte and half word. If zacas has been implemented, zabha also adds support amocas.b and
amocas.h.More details is on the specification here:
https://github.com/riscv/riscv-zabhaThe implemenation of zabha follows the way of AMOs and zacas.
This patch set is based on these two patch set:
1. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00207.html
2. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00212.htmlThese 2 series doesn't seem to apply on top of each other, doesn't matter which order I try. Applying zimop/zcmop first, then zama16b:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension error: patch failed: target/riscv/cpu.c:1464 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Support Zama16b extension hint: Use 'git am --show-current-patch=diff' to see the failed patchApplying zama16b first, then zimop/zcmop:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension $ $ git am \[PATCH\ 1_4\]\ target_riscv\:\ Add\ zimop\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml \[PATCH\ 2_4\]\ disas_riscv\:\ Support\ zimop\ disassemble\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml Applying: target/riscv: Add zimop extension error: patch failed: target/riscv/cpu.c:1463 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Add zimop extension
Quoted 8 lines
Quoted 2 lines
If the series are dependent on each other perhaps it's easier to send everything in a single 11 patches series.
They don't have dependency on each other. But if we both rebase them to the master branch, they couldn't be merged at the time, as them both modify
cpu.handcpu.cin the same place.I will send them as a whole patch set(RVA23 patch set) after I fix other issues on implementing the RVA23 profile.
Be aware that we have some RVA23 extensions that are implemented in the ML but not merged no master yet. E.g. sstvala ended up being implemented after some changes I did w.r.t tval and EBREAK. These patches are on riscv-to-apply.next.
Also, I took another look at RVA23 mandatory exts and what we have. I think we're not that far off after these extensions you're adding. What we really seems to be missing is supm and ssnpm.
Thanks,
Daniel
Quoted 32 lines
Thanks,
Zhiwei
Quoted 27 lines
Thanks,
Daniel
Quoted 21 lines
LIU Zhiwei (6):
target/riscv: Movegen_amobefore implement Zabha target/riscv: Add AMO instructions for Zabha target/riscv: Movegen_cmpxchgbefore adding amocas.[b|h] target/riscv: Add amocas.[b|h] for Zabha target/riscv: Enable zabha for max cpu disas/riscv: Support zabha disassembledisas/riscv.c | 60 ++++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 22 +++ target/riscv/insn_trans/trans_rva.c.inc | 21 --- target/riscv/insn_trans/trans_rvzabha.c.inc | 145 ++++++++++++++++++++ target/riscv/insn_trans/trans_rvzacas.c.inc | 13 -- target/riscv/translate.c | 36 +++++
8 files changed, 266 insertions(+), 34 deletions(-)create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc
Quoted 54 lines · Daniel Henrique Barboza
Quoted 51 lines · LIU Zhiwei
Quoted 42 lines · Daniel Henrique Barboza
Hi Zhiwei!
Quoted 11 lines · LIU Zhiwei
Zabha adds support AMO operations for byte and half word. If zacas has been implemented, zabha also adds support amocas.b and
amocas.h.More details is on the specification here:
https://github.com/riscv/riscv-zabhaThe implemenation of zabha follows the way of AMOs and zacas.
This patch set is based on these two patch set:
1. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00207.html
2. https://mail.gnu.org/archive/html/qemu-riscv/2024-05/msg00212.htmlThese 2 series doesn't seem to apply on top of each other, doesn't matter which order I try. Applying zimop/zcmop first, then zama16b:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension error: patch failed: target/riscv/cpu.c:1464 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Support Zama16b extension hint: Use 'git am --show-current-patch=diff' to see the failed patchApplying zama16b first, then zimop/zcmop:
$ git am \[PATCH\ 1_1\]\ target_riscv\:\ Support\ Zama16b\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0613.eml Applying: target/riscv: Support Zama16b extension $ $ git am \[PATCH\ 1_4\]\ target_riscv\:\ Add\ zimop\ extension\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml \[PATCH\ 2_4\]\ disas_riscv\:\ Support\ zimop\ disassemble\ -\ LIU\ Zhiwei\ \<[email protected]\>\ -\ 2024-05-22\ 0329.eml Applying: target/riscv: Add zimop extension error: patch failed: target/riscv/cpu.c:1463 error: target/riscv/cpu.c: patch does not apply Patch failed at 0001 target/riscv: Add zimop extensionQuoted 2 lines
If the series are dependent on each other perhaps it's easier to send everything in a single 11 patches series.
They don't have dependency on each other. But if we both rebase them to the master branch, they couldn't be merged at the time, as them both modify
cpu.handcpu.cin the same place.
Quoted 6 lines
Quoted 1 line
I will send them as a whole patch set(RVA23 patch set) after I fix other issues on implementing the RVA23 profile.
Be aware that we have some RVA23 extensions that are implemented in the ML but not merged no master yet. E.g. sstvala ended up being implemented after some changes I did w.r.t tval and EBREAK. These patches are on riscv-to-apply.next.
Yes. Besides these, there are some missing checks in Smstateen. And we also need add named features for Sh* extensions.
Quoted 4 lines
Also, I took another look at RVA23 mandatory exts and what we have. I think we're not that far off after these extensions you're adding. What we really seems to be missing is supm and ssnpm.
Alexey is working on this. I have some comments and let's wait for his next patch set.
Thanks,
Zhiwei
Quoted 39 lines
Thanks,
Daniel
Quoted 33 lines
Thanks,
Zhiwei
Quoted 28 lines
Thanks,
Daniel
Quoted 22 lines
LIU Zhiwei (6):
target/riscv: Movegen_amobefore implement Zabha target/riscv: Add AMO instructions for Zabha target/riscv: Movegen_cmpxchgbefore adding amocas.[b|h] target/riscv: Add amocas.[b|h] for Zabha target/riscv: Enable zabha for max cpu disas/riscv: Support zabha disassembledisas/riscv.c | 60 ++++++++ target/riscv/cpu.c | 2 + target/riscv/cpu_cfg.h | 1 + target/riscv/insn32.decode | 22 +++ target/riscv/insn_trans/trans_rva.c.inc | 21 --- target/riscv/insn_trans/trans_rvzabha.c.inc | 145
++++++++++++++++++++
target/riscv/insn_trans/trans_rvzacas.c.inc | 13 -- target/riscv/translate.c | 36 +++++8 files changed, 266 insertions(+), 34 deletions(-)create mode 100644 target/riscv/insn_trans/trans_rvzabha.c.inc