mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
target/riscv: rvk: add support for zknd/zkne extension in RV32
- add aes32esmi, aes32esi, aes32dsmi and aes32dsi instructions Co-authored-by: Zewen Ye <lustrew@foxmail.com> Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn> Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220423023510.30794-7-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
c29da5a7fe
commit
68d19b58f4
6 changed files with 196 additions and 1 deletions
71
target/riscv/insn_trans/trans_rvk.c.inc
Normal file
71
target/riscv/insn_trans/trans_rvk.c.inc
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* RISC-V translation routines for the Zk[nd,ne,nh,sed,sh] Standard Extension.
|
||||
*
|
||||
* Copyright (c) 2021 Ruibo Lu, luruibo2000@163.com
|
||||
* Copyright (c) 2021 Zewen Ye, lustrew@foxmail.com
|
||||
*
|
||||
* 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_ZKND(ctx) do { \
|
||||
if (!ctx->cfg_ptr->ext_zknd) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REQUIRE_ZKNE(ctx) do { \
|
||||
if (!ctx->cfg_ptr->ext_zkne) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static bool gen_aes32_sm4(DisasContext *ctx, arg_k_aes *a,
|
||||
void (*func)(TCGv, TCGv, TCGv, TCGv))
|
||||
{
|
||||
TCGv shamt = tcg_constant_tl(a->shamt);
|
||||
TCGv dest = dest_gpr(ctx, a->rd);
|
||||
TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE);
|
||||
TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE);
|
||||
|
||||
func(dest, src1, src2, shamt);
|
||||
gen_set_gpr(ctx, a->rd, dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool trans_aes32esmi(DisasContext *ctx, arg_aes32esmi *a)
|
||||
{
|
||||
REQUIRE_32BIT(ctx);
|
||||
REQUIRE_ZKNE(ctx);
|
||||
return gen_aes32_sm4(ctx, a, gen_helper_aes32esmi);
|
||||
}
|
||||
|
||||
static bool trans_aes32esi(DisasContext *ctx, arg_aes32esi *a)
|
||||
{
|
||||
REQUIRE_32BIT(ctx);
|
||||
REQUIRE_ZKNE(ctx);
|
||||
return gen_aes32_sm4(ctx, a, gen_helper_aes32esi);
|
||||
}
|
||||
|
||||
static bool trans_aes32dsmi(DisasContext *ctx, arg_aes32dsmi *a)
|
||||
{
|
||||
REQUIRE_32BIT(ctx);
|
||||
REQUIRE_ZKND(ctx);
|
||||
return gen_aes32_sm4(ctx, a, gen_helper_aes32dsmi);
|
||||
}
|
||||
|
||||
static bool trans_aes32dsi(DisasContext *ctx, arg_aes32dsi *a)
|
||||
{
|
||||
REQUIRE_32BIT(ctx);
|
||||
REQUIRE_ZKND(ctx);
|
||||
return gen_aes32_sm4(ctx, a, gen_helper_aes32dsi);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue