target/riscv: Add XVentanaCondOps and supporting infrastructure changes
Subsystems (2)
v3 cover target/riscv: Add XVentanaCondOps and supporting infrastructure changes
In adding our first X-extension (i.e., vendor-defined) on RISC-V with XVentanaCondOps, we need to add a few instructure improvements to make it easier to add similar vendor-defined extensions in the future:
- refactor access to the cfg->ext_* fields by making a pointer to the cfg structure (as cfg_ptr) available via DisasContext
- add a table-based list of decoders to invoke, each being guarded by a guard/predicate-function, that can be used to either add vendor extensions, large extensions or override (by listing the decoder before the one for standard extensions) patterns to handle errata
Changes in v3:
- (new patch) refactor 'struct RISCVCPUConfig'
- (new patch) copy pointer to element cfg into DisasContext
- (new patch) test extension-availability through cfg_ptr in DisasContext, removing the fields that have been copied into DisasContext directly
- (new patch) change Zb[abcs] implementation to use cfg_ptr (copied into DisasContext) instead of going throuhg RISCV_CPU
- expose only the DisasContext* to predicate functions
- mark the table of decoder functions as static
- drop the inline from always_true_p, until the need arises (i.e., someone finds a use for it and calls it directly)
- rewrite to drop the 'handled' temporary in iterating over the decoder table, removing the assignment in the condition of the if
- rename to trans_xventanacondops.c.inc (i.e. with the '.c')
- (in MATERIALISE_EXT_PREDICATE) don't annotate the predicate function for testing the availability of individual extensions as 'inline' and don't make CPURISCVState* visible to these predicate functions
- add a MAINTAINERS entry for XVentanaCondOps
Changes in v2:
- (new patch) iterate over a table of guarded decoder functions
- Split off decode table into XVentanaCondOps.decode
- Wire up XVentanaCondOps in the decoder-table
Philipp Tomsich (7):
target/riscv: refactor (anonymous struct) RISCVCPU.cfg into 'struct
RISCVCPUConfig'
target/riscv: riscv_tr_init_disas_context: copy pointer-to-cfg into
cfg_ptr
target/riscv: access configuration through cfg_ptr in DisasContext target/riscv: access cfg structure through DisasContext target/riscv: iterate over a table of decoders target/riscv: Add XVentanaCondOps custom extension target/riscv: add a MAINTAINERS entry for XVentanaCondOps
MAINTAINERS | 7 ++ target/riscv/XVentanaCondOps.decode | 25 +++++ target/riscv/cpu.c | 3 + target/riscv/cpu.h | 79 ++++++------- target/riscv/insn_trans/trans_rvb.c.inc | 8 +- target/riscv/insn_trans/trans_rvi.c.inc | 2 +- target/riscv/insn_trans/trans_rvv.c.inc | 104 +++++++++--------- target/riscv/insn_trans/trans_rvzfh.c.inc | 4 +- .../insn_trans/trans_xventanacondops.c.inc | 39 +++++++ target/riscv/meson.build | 1 + target/riscv/translate.c | 62 +++++++---- 11 files changed, 218 insertions(+), 116 deletions(-) create mode 100644 target/riscv/XVentanaCondOps.decode create mode 100644 target/riscv/insn_trans/trans_xventanacondops.c.inc
Signature · 1 line
2.33.1
PATCH v3 1/7 target/riscv: refactor (anonymous struct) RISCVCPU.cfg into 'struct RISCVCPUConfig'
---
Changes in v3:
- (new patch) refactor 'struct RISCVCPUConfig'
target/riscv/cpu.h | 76 ++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 37 deletions(-)
target/riscv/cpu.h +39 -37
@@ -303,6 +303,44 @@ struct RISCVCPUClass {DeviceReset parent_reset; }; +struct RISCVCPUConfig { +bool ext_i; +bool ext_e; +bool ext_g; +bool ext_m; +bool ext_a; +bool ext_f; +bool ext_d; +bool ext_c; +bool ext_s; +bool ext_u; +bool ext_h; +bool ext_j; +bool ext_v; +bool ext_zba; +bool ext_zbb; +bool ext_zbc; +bool ext_zbs; +bool ext_counters; +bool ext_ifencei; +bool ext_icsr; +bool ext_zfh; +bool ext_zfhmin; +bool ext_zve32f; +bool ext_zve64f; + +char *priv_spec; +char *user_spec; +char *bext_spec; +char *vext_spec; +uint16_t vlen; +uint16_t elen; +bool mmu; +bool pmp; +bool epmp; +uint64_t resetvec; +}; +/** * RISCVCPU: * @env: #CPURISCVState
@@ -320,43 +358,7 @@ struct RISCVCPU {char *dyn_vreg_xml;/* Configuration Settings */ -struct { -bool ext_i; -bool ext_e; -bool ext_g; -bool ext_m; -bool ext_a; -bool ext_f; -bool ext_d; -bool ext_c; -bool ext_s; -bool ext_u; -bool ext_h; -bool ext_j; -bool ext_v; -bool ext_zba; -bool ext_zbb; -bool ext_zbc; -bool ext_zbs; -bool ext_counters; -bool ext_ifencei; -bool ext_icsr; -bool ext_zfh; -bool ext_zfhmin; -bool ext_zve32f; -bool ext_zve64f; - -char *priv_spec; -char *user_spec; -char *bext_spec; -char *vext_spec; -uint16_t vlen; -uint16_t elen; -bool mmu; -bool pmp; -bool epmp; -uint64_t resetvec; - } cfg; +struct RISCVCPUConfig cfg; };static inline int riscv_has_ext (CPURISCVState *env,target_ulong ext)
Signature · 1 line
2.33.1
Re: [PATCH v3 1/7] target/riscv: refactor (anonymous struct) RISCVCPU.cfg into 'struct RISCVCPUConfig'
Quoted 1 line · Philipp Tomsich
+ struct RISCVCPUConfig cfg;
Coding style says use a typedef for the struct.
Otherwise,
r~
PATCH v3 2/7 target/riscv: riscv_tr_init_disas_context: copy pointer-to-cfg into cfg_ptr
In reply to Philipp TomsichAs the number of extensions is growing, copying them individiually into the DisasContext will scale less and less... instead we populate a pointer to the RISCVCPUConfig structure in the DisasContext.
This adds an extra indirection when checking for the availability of an extension (compared to copying the fields into DisasContext). While not a performance problem today, we can always (shallow) copy the entire structure into the DisasContext (instead of putting a pointer to it) if this is ever deemed necessary.
---
Changes in v3:
- (new patch) copy pointer to element cfg into DisasContext
target/riscv/translate.c | 2 ++ 1 file changed, 2 insertions(+)
target/riscv/translate.c +2 -0
@@ -76,6 +76,7 @@ typedef struct DisasContext {int frm;RISCVMXL ol;bool virt_enabled; +const struct RISCVCPUConfig *cfg_ptr;bool ext_ifencei;bool ext_zfh;bool ext_zfhmin;
@@ -908,6 +909,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)#endif ctx->misa_ext = env->misa_ext; ctx->frm =-1 ;/* unknown rounding mode */ + ctx->cfg_ptr = &(cpu->cfg); ctx->ext_ifencei = cpu->cfg.ext_ifencei; ctx->ext_zfh = cpu->cfg.ext_zfh; ctx->ext_zfhmin = cpu->cfg.ext_zfhmin;
Signature · 1 line
2.33.1
Re: [PATCH v3 2/7] target/riscv: riscv_tr_init_disas_context: copy pointer-to-cfg into cfg_ptr
Quoted 13 lines · Philipp Tomsich
As the number of extensions is growing, copying them individiually into the DisasContext will scale less and less... instead we populate a pointer to the RISCVCPUConfig structure in the DisasContext.
This adds an extra indirection when checking for the availability of an extension (compared to copying the fields into DisasContext). While not a performance problem today, we can always (shallow) copy the entire structure into the DisasContext (instead of putting a pointer to it) if this is ever deemed necessary.
Signed-off-by Philipp Tomsich<[email protected]>Suggested-by Richard Henderson<[email protected]>
Quoted 7 lines
---
Changes in v3:
- (new patch) copy pointer to element cfg into DisasContexttarget/riscv/translate.c | 2 ++ 1 file changed, 2 insertions(+)
r~
PATCH v3 3/7 target/riscv: access configuration through cfg_ptr in DisasContext
In reply to Philipp TomsichThe implementation in trans_{rvi,rvv,rvzfh}.c.inc accesses the shallow copies (in DisasContext) of some of the elements available in the RISCVCPUConfig structure. This commit redirects accesses to use the cfg_ptr copied into DisasContext and removes the shallow copies.
---
Changes in v3:
- (new patch) test extension-availability through cfg_ptr in DisasContext, removing the fields that have been copied into DisasContext directly
target/riscv/insn_trans/trans_rvi.c.inc | 2 +- target/riscv/insn_trans/trans_rvv.c.inc | 104 +++++++++++----------- target/riscv/insn_trans/trans_rvzfh.c.inc | 4 +- target/riscv/translate.c | 14 --- 4 files changed, 55 insertions(+), 69 deletions(-)
target/riscv/insn_trans/trans_rvi.c.inc +1 -1
@@ -806,7 +806,7 @@ static bool trans_fence(DisasContext *ctx, arg_fence *a) static bool trans_fence_i(DisasContext *ctx, arg_fence_i *a) { - if (!ctx->ext_ifencei) { + if (!ctx->cfg_ptr->ext_ifencei) { return false; }
target/riscv/insn_trans/trans_rvv.c.inc +52 -52
416 lines not on this page · raw message
target/riscv/insn_trans/trans_rvzfh.c.inc +2 -2
@@ -17,13 +17,13 @@ */ #define REQUIRE_ZFH(ctx) do { \ - if (!ctx->ext_zfh) { \ + if (!ctx->cfg_ptr->ext_zfh) { \ return false; \ } \ } while (0) #define REQUIRE_ZFH_OR_ZFHMIN(ctx) do { \ - if (!(ctx->ext_zfh || ctx->ext_zfhmin)) { \ + if (!(ctx->cfg_ptr->ext_zfh || ctx->cfg_ptr->ext_zfhmin)) { \ return false; \ } \ } while (0)
target/riscv/translate.c +0 -14
@@ -77,11 +77,6 @@ typedef struct DisasContext {RISCVMXL ol;bool virt_enabled;const struct RISCVCPUConfig *cfg_ptr; -bool ext_ifencei; -bool ext_zfh; -bool ext_zfhmin; -bool ext_zve32f; -bool ext_zve64f;bool hlsx;/* vector extension */ bool vill;
@@ -99,8 +94,6 @@ typedef struct DisasContext {*/ int8_t lmul;uint8_t sew; -uint16_t vlen; -uint16_t elen;target_ulong vstart;bool vl_eq_vlmax;uint8_t ntemp;
@@ -910,13 +903,6 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->misa_ext = env->misa_ext; ctx->frm =-1 ;/* unknown rounding mode */ ctx->cfg_ptr = &(cpu->cfg); - ctx->ext_ifencei = cpu->cfg.ext_ifencei; - ctx->ext_zfh = cpu->cfg.ext_zfh; - ctx->ext_zfhmin = cpu->cfg.ext_zfhmin; - ctx->ext_zve32f = cpu->cfg.ext_zve32f; - ctx->ext_zve64f = cpu->cfg.ext_zve64f; - ctx->vlen = cpu->cfg.vlen; - ctx->elen = cpu->cfg.elen; ctx->mstatus_hs_fs =FIELD_EX32 (tb_flags,TB_FLAGS ,MSTATUS_HS_FS ); ctx->mstatus_hs_vs =FIELD_EX32 (tb_flags,TB_FLAGS ,MSTATUS_HS_VS ); ctx->hlsx =FIELD_EX32 (tb_flags,TB_FLAGS ,HLSX );
Signature · 1 line
2.33.1
Re: [PATCH v3 3/7] target/riscv: access configuration through cfg_ptr in DisasContext
Quoted 15 lines · Philipp Tomsich
The implementation in trans_{rvi,rvv,rvzfh}.c.inc accesses the shallow copies (in DisasContext) of some of the elements available in the RISCVCPUConfig structure. This commit redirects accesses to use the
cfg_ptrcopied into DisasContext and removes the shallow copies.Signed-off-by Philipp Tomsich<[email protected]>Suggested-by Richard Henderson<[email protected]>---
Changes in v3:
- (new patch) test extension-availability throughcfg_ptrin DisasContext, removing the fields that have been copied into DisasContext directly
Quoted 5 lines
target/riscv/insn_trans/trans_rvi.c.inc | 2 +- target/riscv/insn_trans/trans_rvv.c.inc | 104 +++++++++++----------- target/riscv/insn_trans/trans_rvzfh.c.inc | 4 +- target/riscv/translate.c | 14 --- 4 files changed, 55 insertions(+), 69 deletions(-)
r~
PATCH v3 4/7 target/riscv: access cfg structure through DisasContext
In reply to Philipp TomsichThe Zb[abcs] support code still uses the RISCV_CPU macros to access the configuration information (i.e., check whether an extension is available/enabled). Now that we provide this information directly from DisasContext, we can access this directly via the cfg_ptr field.
---
Changes in v3:
- (new patch) change Zb[abcs] implementation to use cfg_ptr (copied into DisasContext) instead of going throuhg RISCV_CPU
target/riscv/insn_trans/trans_rvb.c.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/riscv/insn_trans/trans_rvb.c.inc +4 -4
@@ -19,25 +19,25 @@ */ #define REQUIRE_ZBA(ctx) do { \ - if (!RISCV_CPU(ctx->cs)->cfg.ext_zba) { \ + if (ctx->cfg_ptr->ext_zba) { \ return false; \ } \ } while (0) #define REQUIRE_ZBB(ctx) do { \ - if (!RISCV_CPU(ctx->cs)->cfg.ext_zbb) { \ + if (ctx->cfg_ptr->ext_zbb) { \ return false; \ } \ } while (0) #define REQUIRE_ZBC(ctx) do { \ - if (!RISCV_CPU(ctx->cs)->cfg.ext_zbc) { \ + if (ctx->cfg_ptr->ext_zbc) { \ return false; \ } \ } while (0) #define REQUIRE_ZBS(ctx) do { \ - if (!RISCV_CPU(ctx->cs)->cfg.ext_zbs) { \ + if (ctx->cfg_ptr->ext_zbs) { \ return false; \ } \ } while (0)
Signature · 1 line
2.33.1
Re: [PATCH v3 4/7] target/riscv: access cfg structure through DisasContext
Quoted 8 lines · Philipp Tomsich
The Zb[abcs] support code still uses the
RISCV_CPUmacros to access the configuration information (i.e., check whether an extension is available/enabled). Now that we provide this information directly from DisasContext, we can access this directly via thecfg_ptrfield.Signed-off-by Philipp Tomsich<[email protected]>Suggested-by Richard Henderson<[email protected]>
Quoted 8 lines
---
Changes in v3:
- (new patch) change Zb[abcs] implementation to usecfg_ptr(copied into DisasContext) instead of going throuhgRISCV_CPUtarget/riscv/insn_trans/trans_rvb.c.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
r~
PATCH v3 5/7 target/riscv: iterate over a table of decoders
In reply to Philipp TomsichTo split up the decoder into multiple functions (both to support vendor-specific opcodes in separate files and to simplify maintenance of orthogonal extensions), this changes decode_op to iterate over a table of decoders predicated on guard functions.
This commit only adds the new structure and the table, allowing for the easy addition of additional decoders in the future.
---
Changes in v3:
- expose only the DisasContext* to predicate functions
- mark the table of decoder functions as static
- drop the inline from always_true_p, until the need arises (i.e., someone finds a use for it and calls it directly)
- rewrite to drop the 'handled' temporary in iterating over the decoder table, removing the assignment in the condition of the if
Changes in v2:
- (new patch) iterate over a table of guarded decoder functions
target/riscv/translate.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
target/riscv/translate.c +28 -6
@@ -111,6 +111,11 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext)return ctx->misa_ext & ext; } +static bool always_true_p (DisasContext *ctx __attribute__((__unused__))) +{ +return true; +} +#ifdef TARGET_RISCV32 #define get_xl (ctx) MXL_RV32#elif defined(CONFIG_USER_ONLY )
@@ -855,16 +860,26 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)static void decode_opc (CPURISCVState *env,DisasContext *ctx,uint16_t opcode) { -/* check for compressed insn */ +/* +* A table with predicate (i.e., guard) functions and decoder functions +* that are tested in-order until a decoder matches onto the opcode. +*/ +static const struct { +bool (*guard_func)(DisasContext *); +bool (*decode_func)(DisasContext *,uint32_t ); + } decoders[] = { + { always_true_p, decode_insn32 }, + }; + +/* Check for compressed insn */ if (extract16 (opcode,0 ,2 ) !=3 ) {if (!has_ext (ctx,RVC )) {gen_exception_illegal (ctx); }else { ctx->opcode = opcode; ctx->pc_succ_insn = ctx->base.pc_next +2 ; -if (!decode_insn16 (ctx, opcode)) { -gen_exception_illegal (ctx); - } +if (decode_insn16 (ctx, opcode)) +return ; } }else {uint32_t opcode32 = opcode;
@@ -873,10 +888,17 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) ctx->base.pc_next + 2)); ctx->opcode = opcode32; ctx->pc_succ_insn = ctx->base.pc_next +4 ; -if (!decode_insn32 (ctx, opcode32)) { -gen_exception_illegal (ctx); + +for (size_t i =0 ; i <ARRAY_SIZE (decoders); ++i) { +if (!decoders[i].guard_func (ctx)) +continue ; + +if (decoders[i].decode_func (ctx, opcode32)) +return ; } } + +gen_exception_illegal (ctx); }static void riscv_tr_init_disas_context (DisasContextBase *dcbase,CPUState *cs)
Signature · 1 line
2.33.1
Re: [PATCH v3 5/7] target/riscv: iterate over a table of decoders
Quoted 5 lines · Philipp Tomsich
target/riscv/translate.c +2
-3-if (!decode_insn16 (ctx, opcode)) { -gen_exception_illegal (ctx); - } +if (decode_insn16 (ctx, opcode)) +return ;
...
target/riscv/translate.c static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) · line 897
Quoted 9 lines
target/riscv/translate.c +7
-2-if (!decode_insn32 (ctx, opcode32)) { -gen_exception_illegal (ctx); + +for (size_t i =0 ; i <ARRAY_SIZE (decoders); ++i) { +if (!decoders[i].guard_func (ctx)) +continue ; + +if (decoders[i].decode_func (ctx, opcode32)) +return ;
Missing braces, per style. Otherwise,
r~
PATCH v3 6/7 target/riscv: Add XVentanaCondOps custom extension
In reply to Philipp TomsichThis adds the decoder and translation for the XVentanaCondOps custom
extension (vendor-defined by Ventana Micro Systems), which is
documented at https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf
This commit then also adds a guard-function (has_XVentanaCondOps_p) and the decoder function to the table of decoders, enabling the support for the XVentanaCondOps extension.
---
Changes in v3:
- rename to trans_xventanacondops.c.inc (i.e. with the '.c')
- (in MATERIALISE_EXT_PREDICATE) don't annotate the predicate function for testing the availability of individual extensions as 'inline' and don't make CPURISCVState* visible to these predicate functions
Changes in v2:
- Split off decode table into XVentanaCondOps.decode
- Wire up XVentanaCondOps in the decoder-table
target/riscv/XVentanaCondOps.decode | 25 ++++++++++++ target/riscv/cpu.c | 3 ++ target/riscv/cpu.h | 3 ++ .../insn_trans/trans_xventanacondops.c.inc | 39 +++++++++++++++++++ target/riscv/meson.build | 1 + target/riscv/translate.c | 12 ++++++ 6 files changed, 83 insertions(+) create mode 100644 target/riscv/XVentanaCondOps.decode create mode 100644 target/riscv/insn_trans/trans_xventanacondops.c.inc
target/riscv/XVentanaCondOps.decode new file +25 -0
@@ -0,0 +1,25 @@ +# +# RISC-V translation routines for the XVentanaCondOps extension +# +# Copyright (c) 2022 Dr. Philipp Tomsich, [email protected] +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Reference: VTx-family custom instructions +# Custom ISA extensions for Ventana Micro Systems RISC-V cores +# (https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf) + +# Fields +%rs2 20:5 +%rs1 15:5 +%rd 7:5 + +# Argument sets +&r rd rs1 rs2 !extern + +# Formats +@r ....... ..... ..... ... ..... ....... &r %rs2 %rs1 %rd + +# *** RV64 Custom-3 Extension *** +vt_maskc 0000000 ..... ..... 110 ..... 1111011 @r +vt_maskcn 0000000 ..... ..... 111 ..... 1111011 @r
target/riscv/cpu.c +3 -0
@@ -734,6 +734,9 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("zbc" ,RISCVCPU , cfg.ext_zbc, true),DEFINE_PROP_BOOL ("zbs" ,RISCVCPU , cfg.ext_zbs, true), +/* Vendor-specific custom extensions */ +DEFINE_PROP_BOOL ("xventanacondops" ,RISCVCPU , cfg.ext_XVentanaCondOps, false), +/* These are experimental so mark with 'x-' */ DEFINE_PROP_BOOL("x-j", RISCVCPU, cfg.ext_j, false),/* ePMP 0.9.3 */
target/riscv/cpu.h +3 -0
@@ -329,6 +329,9 @@ struct RISCVCPUConfig {bool ext_zve32f;bool ext_zve64f; +/* Vendor-specific custom extensions */ +bool ext_XVentanaCondOps; +char *priv_spec;char *user_spec;char *bext_spec;
target/riscv/insn_trans/trans_xventanacondops.c.inc new file +39 -0
@@ -0,0 +1,39 @@ +/* + * RISC-V translation routines for the XVentanaCondOps extension. + * + * Copyright (c) 2021-2022 VRULL GmbH. + * + * 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/>. + */ + +static bool gen_condmask(DisasContext *ctx, arg_r *a, TCGCond cond) +{ + 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); + + tcg_gen_movcond_tl(cond, dest, src2, ctx->zero, src1, ctx->zero); + + gen_set_gpr(ctx, a->rd, dest); + return true; +} + +static bool trans_vt_maskc(DisasContext *ctx, arg_r *a) +{ + return gen_condmask(ctx, a, TCG_COND_NE); +} + +static bool trans_vt_maskcn(DisasContext *ctx, arg_r *a) +{ + return gen_condmask(ctx, a, TCG_COND_EQ); +}
target/riscv/meson.build +1 -0
@@ -4,6 +4,7 @@ dir = meson.current_source_dir() gen = [ decodetree.process('insn16.decode', extra_args: ['--static-decode=decode_insn16', '--insnwidth=16']), decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), + decodetree.process('XVentanaCondOps.decode', extra_args: '--static-decode=decode_XVentanaCodeOps'), ] riscv_ss = ss.source_set()
target/riscv/translate.c +12 -0
@@ -116,6 +116,14 @@ static bool always_true_p(DisasContext *ctx __attribute__((__unused__)))return true; } +#define MATERIALISE_EXT_PREDICATE (ext) \ + static bool has_ ## ext ## _p(DisasContext *ctx) \ + { \ + return ctx->cfg_ptr->ext_ ## ext ; \ + } + +MATERIALISE_EXT_PREDICATE (XVentanaCondOps); +#ifdef TARGET_RISCV32 #define get_xl (ctx) MXL_RV32#elif defined(CONFIG_USER_ONLY )
@@ -854,9 +862,12 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)#include "insn_trans/trans_rvb.c.inc" #include "insn_trans/trans_rvzfh.c.inc" #include "insn_trans/trans_privileged.c.inc" +#include "insn_trans/trans_xventanacondops.c.inc" /* Include the auto-generated decoder for 16 bit insn */ #include "decode-insn16.c.inc" +/* Include decoders for factored-out extensions */ +#include "decode-XVentanaCondOps.c.inc" static void decode_opc (CPURISCVState *env,DisasContext *ctx,uint16_t opcode) {
@@ -869,6 +880,7 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)bool (*decode_func)(DisasContext *,uint32_t ); } decoders[] = { { always_true_p, decode_insn32 }, + { has_XVentanaCondOps_p, decode_XVentanaCodeOps }, }; /* Check for compressed insn */
Signature · 1 line
2.33.1
Re: [PATCH v3 6/7] target/riscv: Add XVentanaCondOps custom extension
Quoted 11 lines · Philipp Tomsich
This adds the decoder and translation for the XVentanaCondOps custom
extension (vendor-defined by Ventana Micro Systems), which is
documented athttps://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdfThis commit then also adds a guard-function (
has_XVentanaCondOps_p) and the decoder function to the table of decoders, enabling the support for the XVentanaCondOps extension.Signed-off-by Philipp Tomsich<[email protected]>---
r~
PATCH v3 7/7 target/riscv: add a MAINTAINERS entry for XVentanaCondOps
In reply to Philipp TomsichThe XVentanaCondOps extension is supported by VRULL on behalf of the Ventana Micro. Add myself as a point-of-contact.
---
Changes in v3:
- add a MAINTAINERS entry for XVentanaCondOps
MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -286,6 +286,13 @@ F: include/hw/riscv/ F: linux-user/host/riscv32/ F: linux-user/host/riscv64/ +RISC-V XVentanaCondOps extension +M: Philipp Tomsich <[email protected]> +L: [email protected] +S: Supported +F: target/riscv/XVentanaCondOps.decode +F: target/riscv/insn_trans/trans_xventanacondops.c.inc + RENESAS RX CPUs R: Yoshinori Sato <[email protected]> S: Orphan
Signature · 1 line
2.33.1
Re: [PATCH v3 7/7] target/riscv: add a MAINTAINERS entry for XVentanaCondOps
Quoted 6 lines · Philipp Tomsich
The XVentanaCondOps extension is supported by VRULL on behalf of the Ventana Micro. Add myself as a point-of-contact.
Signed-off-by Philipp Tomsich<[email protected]>---
r~