Skip to content

Commit f6f7233

Browse files
cmuellneralistair23
authored andcommitted
disas/riscv: Add support for XVentanaCondOps
This patch adds XVentanaCondOps support to the RISC-V disassembler. Co-developed-by: LIU Zhiwei <[email protected]> Acked-by: Alistair Francis <[email protected]> Signed-off-by: Christoph Müllner <[email protected]> Reviewed-by: Daniel Henrique Barboza <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent c859a24 commit f6f7233

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

disas/meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ common_ss.add(when: 'CONFIG_M68K_DIS', if_true: files('m68k.c'))
66
common_ss.add(when: 'CONFIG_MICROBLAZE_DIS', if_true: files('microblaze.c'))
77
common_ss.add(when: 'CONFIG_MIPS_DIS', if_true: files('mips.c', 'nanomips.c'))
88
common_ss.add(when: 'CONFIG_NIOS2_DIS', if_true: files('nios2.c'))
9-
common_ss.add(when: 'CONFIG_RISCV_DIS', if_true: files('riscv.c'))
9+
common_ss.add(when: 'CONFIG_RISCV_DIS', if_true: files(
10+
'riscv.c',
11+
'riscv-xventana.c'
12+
))
1013
common_ss.add(when: 'CONFIG_SH4_DIS', if_true: files('sh4.c'))
1114
common_ss.add(when: 'CONFIG_SPARC_DIS', if_true: files('sparc.c'))
1215
common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('xtensa.c'))

disas/riscv-xventana.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* QEMU RISC-V Disassembler for xventana.
3+
*
4+
* SPDX-License-Identifier: GPL-2.0-or-later
5+
*/
6+
7+
#include "disas/riscv.h"
8+
#include "disas/riscv-xventana.h"
9+
10+
typedef enum {
11+
/* 0 is reserved for rv_op_illegal. */
12+
ventana_op_vt_maskc = 1,
13+
ventana_op_vt_maskcn = 2,
14+
} rv_ventana_op;
15+
16+
const rv_opcode_data ventana_opcode_data[] = {
17+
{ "vt.illegal", rv_codec_illegal, rv_fmt_none, NULL, 0, 0, 0 },
18+
{ "vt.maskc", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
19+
{ "vt.maskcn", rv_codec_r, rv_fmt_rd_rs1_rs2, NULL, 0, 0, 0 },
20+
};
21+
22+
void decode_xventanacondops(rv_decode *dec, rv_isa isa)
23+
{
24+
rv_inst inst = dec->inst;
25+
rv_opcode op = rv_op_illegal;
26+
27+
switch (((inst >> 0) & 0b11)) {
28+
case 3:
29+
switch (((inst >> 2) & 0b11111)) {
30+
case 30:
31+
switch (((inst >> 22) & 0b1111111000) | ((inst >> 12) & 0b0000000111)) {
32+
case 6: op = ventana_op_vt_maskc; break;
33+
case 7: op = ventana_op_vt_maskcn; break;
34+
}
35+
break;
36+
}
37+
break;
38+
}
39+
40+
dec->op = op;
41+
}

disas/riscv-xventana.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* QEMU disassembler -- RISC-V specific header (xventana*).
3+
*
4+
* Copyright (c) 2023 VRULL GmbH
5+
*
6+
* SPDX-License-Identifier: GPL-2.0-or-later
7+
*/
8+
9+
#ifndef DISAS_RISCV_XVENTANA_H
10+
#define DISAS_RISCV_XVENTANA_H
11+
12+
#include "disas/riscv.h"
13+
14+
extern const rv_opcode_data ventana_opcode_data[];
15+
16+
void decode_xventanacondops(rv_decode*, rv_isa);
17+
18+
#endif /* DISAS_RISCV_XVENTANA_H */

disas/riscv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include "target/riscv/cpu_cfg.h"
2323
#include "disas/riscv.h"
2424

25+
/* Vendor extensions */
26+
#include "disas/riscv-xventana.h"
27+
2528
typedef enum {
2629
/* 0 is reserved for rv_op_illegal. */
2730
rv_op_lui = 1,
@@ -4708,6 +4711,7 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, uint64_t pc, rv_inst inst,
47084711
void (*decode_func)(rv_decode *, rv_isa);
47094712
} decoders[] = {
47104713
{ always_true_p, rvi_opcode_data, decode_inst_opcode },
4714+
{ has_XVentanaCondOps_p, ventana_opcode_data, decode_xventanacondops },
47114715
};
47124716

47134717
for (size_t i = 0; i < ARRAY_SIZE(decoders); i++) {

0 commit comments

Comments
 (0)