mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
disas/riscv: Add support for XThead* instructions
Support for emulating XThead* instruction has been added recently. This patch adds support for these instructions to the RISC-V disassembler. Co-developed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu> Message-Id: <20230612111034.3955227-9-christoph.muellner@vrull.eu> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
committed by
Alistair Francis
parent
f6f72338d8
commit
318df7238b
@@ -8,6 +8,7 @@ common_ss.add(when: 'CONFIG_MIPS_DIS', if_true: files('mips.c', 'nanomips.c'))
|
||||
common_ss.add(when: 'CONFIG_NIOS2_DIS', if_true: files('nios2.c'))
|
||||
common_ss.add(when: 'CONFIG_RISCV_DIS', if_true: files(
|
||||
'riscv.c',
|
||||
'riscv-xthead.c',
|
||||
'riscv-xventana.c'
|
||||
))
|
||||
common_ss.add(when: 'CONFIG_SH4_DIS', if_true: files('sh4.c'))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* QEMU disassembler -- RISC-V specific header (xthead*).
|
||||
*
|
||||
* Copyright (c) 2023 VRULL GmbH
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef DISAS_RISCV_XTHEAD_H
|
||||
#define DISAS_RISCV_XTHEAD_H
|
||||
|
||||
#include "disas/riscv.h"
|
||||
|
||||
extern const rv_opcode_data xthead_opcode_data[];
|
||||
|
||||
void decode_xtheadba(rv_decode *, rv_isa);
|
||||
void decode_xtheadbb(rv_decode *, rv_isa);
|
||||
void decode_xtheadbs(rv_decode *, rv_isa);
|
||||
void decode_xtheadcmo(rv_decode *, rv_isa);
|
||||
void decode_xtheadcondmov(rv_decode *, rv_isa);
|
||||
void decode_xtheadfmemidx(rv_decode *, rv_isa);
|
||||
void decode_xtheadfmv(rv_decode *, rv_isa);
|
||||
void decode_xtheadmac(rv_decode *, rv_isa);
|
||||
void decode_xtheadmemidx(rv_decode *, rv_isa);
|
||||
void decode_xtheadmempair(rv_decode *, rv_isa);
|
||||
void decode_xtheadsync(rv_decode *, rv_isa);
|
||||
|
||||
#endif /* DISAS_RISCV_XTHEAD_H */
|
||||
@@ -18,11 +18,13 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/bitops.h"
|
||||
#include "disas/dis-asm.h"
|
||||
#include "target/riscv/cpu_cfg.h"
|
||||
#include "disas/riscv.h"
|
||||
|
||||
/* Vendor extensions */
|
||||
#include "disas/riscv-xthead.h"
|
||||
#include "disas/riscv-xventana.h"
|
||||
|
||||
typedef enum {
|
||||
@@ -3869,6 +3871,26 @@ static uint32_t operand_zcmp_rlist(rv_inst inst)
|
||||
return ((inst << 56) >> 60);
|
||||
}
|
||||
|
||||
static uint32_t operand_imm6(rv_inst inst)
|
||||
{
|
||||
return (inst << 38) >> 60;
|
||||
}
|
||||
|
||||
static uint32_t operand_imm2(rv_inst inst)
|
||||
{
|
||||
return (inst << 37) >> 62;
|
||||
}
|
||||
|
||||
static uint32_t operand_immh(rv_inst inst)
|
||||
{
|
||||
return (inst << 32) >> 58;
|
||||
}
|
||||
|
||||
static uint32_t operand_imml(rv_inst inst)
|
||||
{
|
||||
return (inst << 38) >> 58;
|
||||
}
|
||||
|
||||
static uint32_t calculate_stack_adj(rv_isa isa, uint32_t rlist, uint32_t spimm)
|
||||
{
|
||||
int xlen_bytes_log2 = isa == rv64 ? 3 : 2;
|
||||
@@ -4233,6 +4255,38 @@ static void decode_inst_operands(rv_decode *dec, rv_isa isa)
|
||||
case rv_codec_zcmt_jt:
|
||||
dec->imm = operand_tbl_index(inst);
|
||||
break;
|
||||
case rv_codec_r2_imm5:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
dec->imm = operand_rs2(inst);
|
||||
break;
|
||||
case rv_codec_r2:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
break;
|
||||
case rv_codec_r2_imm6:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
dec->imm = operand_imm6(inst);
|
||||
break;
|
||||
case rv_codec_r_imm2:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
dec->rs2 = operand_rs2(inst);
|
||||
dec->imm = operand_imm2(inst);
|
||||
break;
|
||||
case rv_codec_r2_immhl:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
dec->imm = operand_immh(inst);
|
||||
dec->imm1 = operand_imml(inst);
|
||||
break;
|
||||
case rv_codec_r2_imm2_imm5:
|
||||
dec->rd = operand_rd(inst);
|
||||
dec->rs1 = operand_rs1(inst);
|
||||
dec->imm = sextract32(operand_rs2(inst), 0, 5);
|
||||
dec->imm1 = operand_imm2(inst);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4446,6 +4500,10 @@ static void format_inst(char *buf, size_t buflen, size_t tab, rv_decode *dec)
|
||||
snprintf(tmp, sizeof(tmp), "%u", ((uint32_t)dec->imm & 0b11111));
|
||||
append(buf, tmp, buflen);
|
||||
break;
|
||||
case 'j':
|
||||
snprintf(tmp, sizeof(tmp), "%d", dec->imm1);
|
||||
append(buf, tmp, buflen);
|
||||
break;
|
||||
case 'o':
|
||||
snprintf(tmp, sizeof(tmp), "%d", dec->imm);
|
||||
append(buf, tmp, buflen);
|
||||
@@ -4711,6 +4769,17 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst,
|
||||
void (*decode_func)(rv_decode *, rv_isa);
|
||||
} decoders[] = {
|
||||
{ always_true_p, rvi_opcode_data, decode_inst_opcode },
|
||||
{ has_xtheadba_p, xthead_opcode_data, decode_xtheadba },
|
||||
{ has_xtheadbb_p, xthead_opcode_data, decode_xtheadbb },
|
||||
{ has_xtheadbs_p, xthead_opcode_data, decode_xtheadbs },
|
||||
{ has_xtheadcmo_p, xthead_opcode_data, decode_xtheadcmo },
|
||||
{ has_xtheadcondmov_p, xthead_opcode_data, decode_xtheadcondmov },
|
||||
{ has_xtheadfmemidx_p, xthead_opcode_data, decode_xtheadfmemidx },
|
||||
{ has_xtheadfmv_p, xthead_opcode_data, decode_xtheadfmv },
|
||||
{ has_xtheadmac_p, xthead_opcode_data, decode_xtheadmac },
|
||||
{ has_xtheadmemidx_p, xthead_opcode_data, decode_xtheadmemidx },
|
||||
{ has_xtheadmempair_p, xthead_opcode_data, decode_xtheadmempair },
|
||||
{ has_xtheadsync_p, xthead_opcode_data, decode_xtheadsync },
|
||||
{ has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
|
||||
};
|
||||
|
||||
|
||||
@@ -159,6 +159,12 @@ typedef enum {
|
||||
rv_codec_zcmp_cm_pushpop,
|
||||
rv_codec_zcmp_cm_mv,
|
||||
rv_codec_zcmt_jt,
|
||||
rv_codec_r2_imm5,
|
||||
rv_codec_r2,
|
||||
rv_codec_r2_imm6,
|
||||
rv_codec_r_imm2,
|
||||
rv_codec_r2_immhl,
|
||||
rv_codec_r2_imm2_imm5,
|
||||
} rv_codec;
|
||||
|
||||
/* structures */
|
||||
@@ -185,6 +191,7 @@ typedef struct {
|
||||
uint64_t inst;
|
||||
const rv_opcode_data *opcode_data;
|
||||
int32_t imm;
|
||||
int32_t imm1;
|
||||
uint16_t op;
|
||||
uint8_t codec;
|
||||
uint8_t rd;
|
||||
@@ -283,5 +290,10 @@ enum {
|
||||
#define rv_fmt_push_rlist "O\tx,-i"
|
||||
#define rv_fmt_pop_rlist "O\tx,i"
|
||||
#define rv_fmt_zcmt_index "O\ti"
|
||||
#define rv_fmt_rd_rs1_rs2_imm "O\t0,1,2,i"
|
||||
#define rv_fmt_frd_rs1_rs2_imm "O\t3,1,2,i"
|
||||
#define rv_fmt_rd_rs1_immh_imml "O\t0,1,i,j"
|
||||
#define rv_fmt_rd_rs1_immh_imml_addr "O\t0,(1),i,j"
|
||||
#define rv_fmt_rd2_imm "O\t0,2,(1),i"
|
||||
|
||||
#endif /* DISAS_RISCV_H */
|
||||
|
||||
@@ -157,6 +157,17 @@ static inline bool has_xthead_p(const RISCVCPUConfig *cfg)
|
||||
return cfg->ext_ ## ext ; \
|
||||
}
|
||||
|
||||
MATERIALISE_EXT_PREDICATE(xtheadba)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadbb)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadbs)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadcmo)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadcondmov)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadfmemidx)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadfmv)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadmac)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadmemidx)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadmempair)
|
||||
MATERIALISE_EXT_PREDICATE(xtheadsync)
|
||||
MATERIALISE_EXT_PREDICATE(XVentanaCondOps)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user