target/riscv: Add the implied rules for G and B extensions
v4 cover target/riscv: Add the implied rules for G and B extensions
From: Frank Chang <[email protected]>
Add the implied rules for G and B extensions to enable the implied extensions.
Changelog:
v4: Add 'target/riscv' to cover-letter subject prefix.
v3: Keep riscv_cpu_validate_g() and riscv_cpu_validate_b() but remove
the auto-enables as the implied extensions can be enabled by the implied rules.
v2: Remove riscv_cpu_validate_g() and riscv_cpu_validate_b() as the
implied extensions can be enabled by the implied rules.
Frank Chang (1):
target/riscv: Add standard B extension implied rule
Jim Shu (1):
target/riscv: Add the implied rule for G extension
target/riscv/cpu.c | 26 ++++++++++++++++++++++++- target/riscv/tcg/tcg-cpu.c | 39 +++++++------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-)
--
2.43.0
PATCH v4 1/2 target/riscv: Add the implied rule for G extension
From: Jim Shu <[email protected]>
Add the missing implied rule from G to imafd_zicsr_zifencei. We can also remove the auto-enables in riscv_cpu_validate_g() as IMAFD, Zicsr, Zifencei extensions can be enabled by the implied rule.
--- target/riscv/cpu.c | 14 +++++++++++++- target/riscv/tcg/tcg-cpu.c | 21 ++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-)
target/riscv/cpu.c +13 -1
@@ -2094,6 +2094,18 @@ static RISCVCPUImpliedExtsRule RVV_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule RVG_IMPLIED = { + .is_misa = true, + .ext =RVG , + .implied_misa_exts =RVI |RVM |RVA |RVF |RVD , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zicsr), +CPU_CFG_OFFSET (ext_zifencei), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zcb), .implied_multi_exts = {
@@ -2501,7 +2513,7 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , - &RVM_IMPLIED , &RVV_IMPLIED ,NULL + &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED ,NULL };RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
target/riscv/tcg/tcg-cpu.c +4 -17
@@ -496,30 +496,17 @@ static void riscv_cpu_validate_g(RISCVCPU *cpu)continue ; } -if (!cpu_misa_ext_is_user_set (bit)) { -riscv_cpu_write_misa_bit (cpu, bit, true); -continue ; - } -if (send_warn) {warn_report (warn_msg,riscv_get_misa_ext_name (bit)); } } -if (!cpu->cfg.ext_zicsr) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zicsr))) { - cpu->cfg.ext_zicsr = true; - }else if (send_warn) { -warn_report (warn_msg,"zicsr" ); - } +if (!cpu->cfg.ext_zicsr && send_warn) { +warn_report (warn_msg,"zicsr" ); } -if (!cpu->cfg.ext_zifencei) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zifencei))) { - cpu->cfg.ext_zifencei = true; - }else if (send_warn) { -warn_report (warn_msg,"zifencei" ); - } +if (!cpu->cfg.ext_zifencei && send_warn) { +warn_report (warn_msg,"zifencei" ); } }
Signature · 1 line
2.43.0
Re: [PATCH v4 1/2] target/riscv: Add the implied rule for G extension
Quoted 9 lines · On Thu, May 28, 2026 at 3:43 PM <[email protected]> wrote:
From: Jim Shu <[email protected]>
Add the missing implied rule from G to
imafd_zicsr_zifencei. We can also remove the auto-enables inriscv_cpu_validate_g()as IMAFD, Zicsr, Zifencei extensions can be enabled by the implied rule.Signed-off-by Jim Shu <[email protected]>Reviewed-by Frank Chang <[email protected]>
Alistair
Quoted 80 lines
--- target/riscv/cpu.c | 14 +++++++++++++- target/riscv/tcg/tcg-cpu.c | 21 ++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-)target/riscv/cpu.c +13
-1@@ -2094,6 +2094,18 @@ static RISCVCPUImpliedExtsRule RVV_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule RVG_IMPLIED = { + .is_misa = true, + .ext =RVG , + .implied_misa_exts =RVI |RVM |RVA |RVF |RVD , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zicsr), +CPU_CFG_OFFSET (ext_zifencei), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zcb), .implied_multi_exts = {@@ -2501,7 +2513,7 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , - &RVM_IMPLIED , &RVV_IMPLIED ,NULL + &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED ,NULL };RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {target/riscv/tcg/tcg-cpu.c +4
-18@@ -496,30 +496,17 @@ static void riscv_cpu_validate_g(RISCVCPU *cpu)continue ; } -if (!cpu_misa_ext_is_user_set (bit)) { -riscv_cpu_write_misa_bit (cpu, bit, true); -continue ; - } -if (send_warn) {warn_report (warn_msg,riscv_get_misa_ext_name (bit)); } } -if (!cpu->cfg.ext_zicsr) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zicsr))) { - cpu->cfg.ext_zicsr = true; - }else if (send_warn) { -warn_report (warn_msg,"zicsr" ); - } +if (!cpu->cfg.ext_zicsr && send_warn) { +warn_report (warn_msg,"zicsr" ); } -if (!cpu->cfg.ext_zifencei) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zifencei))) { - cpu->cfg.ext_zifencei = true; - }else if (send_warn) { -warn_report (warn_msg,"zifencei" ); - } +if (!cpu->cfg.ext_zifencei && send_warn) { +warn_report (warn_msg,"zifencei" ); } } --2.43.0
PATCH v4 2/2 target/riscv: Add standard B extension implied rule
In reply to [email protected]From: Frank Chang <[email protected]>
Add the missing implied rule for standard B extension. Standard B extension implies Zba, Zbb, Zbs extensions. We can also remove the auto-enables in riscv_cpu_validate_b() as Zba, Zbb, Zbs extensions can be enabled by the implied rule.
RISC-V B spec: https://github.com/riscv/riscv-b
--- target/riscv/cpu.c | 14 +++++++++++++- target/riscv/tcg/tcg-cpu.c | 18 +++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
target/riscv/cpu.c +13 -1
@@ -2106,6 +2106,17 @@ static RISCVCPUImpliedExtsRule RVG_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule RVB_IMPLIED = { + .is_misa = true, + .ext =RVB , + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zba),CPU_CFG_OFFSET (ext_zbb), +CPU_CFG_OFFSET (ext_zbs), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +static RISCVCPUImpliedExtsRule ZCB_IMPLIED = { .ext =CPU_CFG_OFFSET (ext_zcb), .implied_multi_exts = {
@@ -2513,7 +2524,8 @@ static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = {RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , - &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED ,NULL + &RVM_IMPLIED , &RVV_IMPLIED , &RVG_IMPLIED , + &RVB_IMPLIED ,NULL };RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = {
target/riscv/tcg/tcg-cpu.c +3 -15
@@ -515,27 +515,15 @@ static void riscv_cpu_validate_b(RISCVCPU *cpu)const char *warn_msg ="RVB mandates disabled extension %s" ;if (!cpu->cfg.ext_zba) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zba))) { - cpu->cfg.ext_zba = true; - }else { -warn_report (warn_msg,"zba" ); - } +warn_report (warn_msg,"zba" ); }if (!cpu->cfg.ext_zbb) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zbb))) { - cpu->cfg.ext_zbb = true; - }else { -warn_report (warn_msg,"zbb" ); - } +warn_report (warn_msg,"zbb" ); }if (!cpu->cfg.ext_zbs) { -if (!cpu_cfg_ext_is_user_set (CPU_CFG_OFFSET (ext_zbs))) { - cpu->cfg.ext_zbs = true; - }else { -warn_report (warn_msg,"zbs" ); - } +warn_report (warn_msg,"zbs" ); } }
Signature · 1 line
2.43.0
Alistair Francis
AppliedQuoted 13 lines · On Thu, May 28, 2026 at 3:43 PM <[email protected]> wrote:
From: Frank Chang <[email protected]>
Add the implied rules for G and B extensions to enable the implied extensions.
Changelog:
v4: Add 'target/riscv' to cover-letter subject prefix.v3: Keep
riscv_cpu_validate_g()andriscv_cpu_validate_b()but remove
the auto-enables as the implied extensions can be enabled by the implied rules.
Quoted 8 lines
v2: Remove
riscv_cpu_validate_g()andriscv_cpu_validate_b()as the
implied extensions can be enabled by the implied rules.Frank Chang (1):
target/riscv: Add standard B extension implied ruleJim Shu (1):
target/riscv: Add the implied rule for G extension
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 9 lines
target/riscv/cpu.c | 26 ++++++++++++++++++++++++- target/riscv/tcg/tcg-cpu.c | 39 +++++++------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-)--
2.43.0