Add Zvfbfa extension support
v5 cover Add Zvfbfa extension support
This patch series adds support for the RISC-V Zvfbfa extension, which provides additional BF16 vector compute support.
The isa spec of Zvfbfa extension is not ratified yet, so this patch series is based on the latest draft of the spec (v0.1) and make the Zvfbfa extension as an experimental extension.
The Zvfbfa extension adds a 1-bit field, altfmt, to the vtype CSR in bit position 8.
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.
Specification:
https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adoc
Changes in v5:
- Fix typo in patch 1/5/8
- Remove unnecessary do_bf16_nanbox
Changes in v4:
- Rebase on riscv-to-apply.next (commit 21101a7)
- Update commit message of patch 2 (target/riscv: Add the Zvfbfa extension implied rule)
- Update checking flow of illegal ALTFMT SEW patterns at patch 3 (target/riscv: rvv: Add new VTYPE CSR field - altfmt)
Changes in v3:
- Rebased on riscv-to-apply.next (commit f66f234)
- Fix typo in v2 patch 5 commit message
Changes from v2:
- Removed RFC designation from the series
- Updated commit message for patch 3 (VTYPE CSR field - altfmt) to clearly explain:
* VEDIV field removal (bits 8-9) since EDIV extension is not planned to be part of the base V extension
* ALTFMT field addition at bit 8
* RESERVED field change from bit 10 to bit 9
- Added new patch 4: Introduce reset_ill_vtype helper function to consolidate illegal vtype CSR reset logic
v4: <[email protected]>
v3: <[email protected]>
v2: <[email protected]>
v1: <[email protected]>
rnax
Max Chou (9):
target/riscv: Add cfg properties for Zvfbfa extensions target/riscv: Add the Zvfbfa extension implied rule target/riscv: rvv: Add new VTYPE CSR field - altfmt target/riscv: rvv: Introduce reset_ill_vtype to reset illegal vtype
CSR
target/riscv: Use the tb->cs_base as the extend tb flags target/riscv: Introduce altfmt into DisasContext target/riscv: Introduce BF16 canonical NaN for Zvfbfa extension target/riscv: rvv: Support Zvfbfa vector bf16 operations target/riscv: Expose Zvfbfa extension as an experimental cpu property
include/exec/translation-block.h | 1 + target/riscv/cpu.c | 15 +- target/riscv/cpu.h | 7 +- target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/helper.h | 60 ++ target/riscv/insn_trans/trans_rvv.c.inc | 988 +++++++++++++++--------- target/riscv/internals.h | 1 + target/riscv/tcg/tcg-cpu.c | 15 +- target/riscv/translate.c | 11 + target/riscv/vector_helper.c | 389 +++++++++- 10 files changed, 1088 insertions(+), 400 deletions(-)
Signature · 1 line
2.52.0
PATCH v5 1/9 target/riscv: Add cfg properties for Zvfbfa extensions
The Zvfbfa extension adds more complete BF16 vector compute support and requires the Zve32f and Zfbfmin extensions.
--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/tcg/tcg-cpu.c | 8 ++++++++ 3 files changed, 10 insertions(+)
target/riscv/cpu.c +1 -0
@@ -189,6 +189,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64f,PRIV_VERSION_1_10_0 , ext_zve64f),ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zve64x,PRIV_VERSION_1_10_0 , ext_zve64x), +ISA_EXT_DATA_ENTRY (zvfbfa,PRIV_VERSION_1_13_0 , ext_zvfbfa),ISA_EXT_DATA_ENTRY (zvfbfmin,PRIV_VERSION_1_12_0 , ext_zvfbfmin),ISA_EXT_DATA_ENTRY (zvfbfwma,PRIV_VERSION_1_12_0 , ext_zvfbfwma), ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),
target/riscv/cpu_cfg_fields.h.inc +1 -0
@@ -99,6 +99,7 @@ BOOL_FIELD(ext_zvks) BOOL_FIELD(ext_zvksc) BOOL_FIELD(ext_zvksg) BOOL_FIELD(ext_zmmul) +BOOL_FIELD(ext_zvfbfa) BOOL_FIELD(ext_zvfbfmin) BOOL_FIELD(ext_zvfbfwma) BOOL_FIELD(ext_zvfh)
target/riscv/tcg/tcg-cpu.c +8 -0
@@ -720,6 +720,14 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } +if (cpu->cfg.ext_zvfbfa) { +if (!cpu->cfg.ext_zve32f || !cpu->cfg.ext_zfbfmin) { +error_setg (errp,"Zvfbfa extension requires Zve32f extension " +"and Zfbfmin extension" ); +return ; + } + } +if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {error_setg (errp,"Zdinx/Zhinx/Zhinxmin extensions require Zfinx" );return ;
Signature · 1 line
2.52.0
Re: [PATCH v5 1/9] target/riscv: Add cfg properties for Zvfbfa extensions
Quoted 8 lines · Max Chou
The Zvfbfa extension adds more complete BF16 vector compute support and requires the Zve32f and Zfbfmin extensions.
Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Nutty Liu <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 53 lines
--- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/tcg/tcg-cpu.c | 8 ++++++++ 3 files changed, 10 insertions(+)target/riscv/cpu.c +1
-0@@ -189,6 +189,7 @@ const RISCVIsaExtData isa_edata_arr[] = {ISA_EXT_DATA_ENTRY (zve64f,PRIV_VERSION_1_10_0 , ext_zve64f),ISA_EXT_DATA_ENTRY (zve64d,PRIV_VERSION_1_10_0 , ext_zve64d),ISA_EXT_DATA_ENTRY (zve64x,PRIV_VERSION_1_10_0 , ext_zve64x), +ISA_EXT_DATA_ENTRY (zvfbfa,PRIV_VERSION_1_13_0 , ext_zvfbfa),ISA_EXT_DATA_ENTRY (zvfbfmin,PRIV_VERSION_1_12_0 , ext_zvfbfmin),ISA_EXT_DATA_ENTRY (zvfbfwma,PRIV_VERSION_1_12_0 , ext_zvfbfwma), ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh),target/riscv/cpu_cfg_fields.h.inc +1
-0@@ -99,6 +99,7 @@ BOOL_FIELD(ext_zvks) BOOL_FIELD(ext_zvksc) BOOL_FIELD(ext_zvksg) BOOL_FIELD(ext_zmmul) +BOOL_FIELD(ext_zvfbfa) BOOL_FIELD(ext_zvfbfmin) BOOL_FIELD(ext_zvfbfwma) BOOL_FIELD(ext_zvfh)target/riscv/tcg/tcg-cpu.c +8
-1@@ -720,6 +720,14 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)return ; } +if (cpu->cfg.ext_zvfbfa) { +if (!cpu->cfg.ext_zve32f || !cpu->cfg.ext_zfbfmin) { +error_setg (errp,"Zvfbfa extension requires Zve32f extension " +"and Zfbfmin extension" ); +return ; + } + } +if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfinx) {error_setg (errp,"Zdinx/Zhinx/Zhinxmin extensions require Zfinx" );return ; --2.52.0
PATCH v5 2/9 target/riscv: Add the Zvfbfa extension implied rule
In reply to Max ChouAccording to the Zvfbfa isa spec:
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.
--- target/riscv/cpu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
target/riscv/cpu.c +11 -2
@@ -2619,6 +2619,15 @@ static RISCVCPUImpliedExtsRule SSCTR_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = { + .ext =CPU_CFG_OFFSET (ext_zvfbfa), + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zve32f),CPU_CFG_OFFSET (ext_zfbfmin), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , &RVM_IMPLIED , &RVV_IMPLIED ,NULL
@@ -2632,8 +2641,8 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { &ZHINX_IMPLIED , &ZHINXMIN_IMPLIED , &ZICNTR_IMPLIED , &ZIHPM_IMPLIED , &ZK_IMPLIED , &ZKN_IMPLIED , &ZKS_IMPLIED , &ZVBB_IMPLIED , &ZVE32F_IMPLIED , - &ZVE32X_IMPLIED , &ZVE64D_IMPLIED , &ZVE64F_IMPLIED , - &ZVE64X_IMPLIED , &ZVFBFMIN_IMPLIED , &ZVFBFWMA_IMPLIED , + &ZVE32X_IMPLIED , &ZVE64D_IMPLIED , &ZVE64F_IMPLIED , &ZVE64X_IMPLIED , + &ZVFBFA_IMPLIED , &ZVFBFMIN_IMPLIED , &ZVFBFWMA_IMPLIED , &ZVFH_IMPLIED , &ZVFHMIN_IMPLIED , &ZVKN_IMPLIED , &ZVKNC_IMPLIED , &ZVKNG_IMPLIED , &ZVKNHB_IMPLIED , &ZVKS_IMPLIED, &ZVKSC_IMPLIED, &ZVKSG_IMPLIED, &SSCFG_IMPLIED,
Signature · 1 line
2.52.0
Re: [PATCH v5 2/9] target/riscv: Add the Zvfbfa extension implied rule
Quoted 8 lines · Max Chou
According to the Zvfbfa isa spec:
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Nutty Liu <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 39 lines
--- target/riscv/cpu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)target/riscv/cpu.c +11
-3@@ -2619,6 +2619,15 @@ static RISCVCPUImpliedExtsRule SSCTR_IMPLIED = { }, }; +static RISCVCPUImpliedExtsRule ZVFBFA_IMPLIED = { + .ext =CPU_CFG_OFFSET (ext_zvfbfa), + .implied_multi_exts = { +CPU_CFG_OFFSET (ext_zve32f),CPU_CFG_OFFSET (ext_zfbfmin), + +RISCV_IMPLIED_EXTS_RULE_END + }, +}; +RISCVCPUImpliedExtsRule *riscv_misa_ext_implied_rules[] = { &RVA_IMPLIED , &RVD_IMPLIED , &RVF_IMPLIED , &RVM_IMPLIED , &RVV_IMPLIED ,NULL @@ -2632,8 +2641,8 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[] = { &ZHINX_IMPLIED , &ZHINXMIN_IMPLIED , &ZICNTR_IMPLIED , &ZIHPM_IMPLIED , &ZK_IMPLIED , &ZKN_IMPLIED , &ZKS_IMPLIED , &ZVBB_IMPLIED , &ZVE32F_IMPLIED , - &ZVE32X_IMPLIED , &ZVE64D_IMPLIED , &ZVE64F_IMPLIED , - &ZVE64X_IMPLIED , &ZVFBFMIN_IMPLIED , &ZVFBFWMA_IMPLIED , + &ZVE32X_IMPLIED , &ZVE64D_IMPLIED , &ZVE64F_IMPLIED , &ZVE64X_IMPLIED , + &ZVFBFA_IMPLIED , &ZVFBFMIN_IMPLIED , &ZVFBFWMA_IMPLIED , &ZVFH_IMPLIED , &ZVFHMIN_IMPLIED , &ZVKN_IMPLIED , &ZVKNC_IMPLIED , &ZVKNG_IMPLIED , &ZVKNHB_IMPLIED , &ZVKS_IMPLIED, &ZVKSC_IMPLIED, &ZVKSG_IMPLIED, &SSCFG_IMPLIED, --2.52.0
PATCH v5 3/9 target/riscv: rvv: Add new VTYPE CSR field - altfmt
In reply to Max ChouAccording to the Zvfbfa ISA spec v0.1, the vtype CSR adds a new field:
altfmt for BF16 support.
This update changes the layout of the vtype CSR fields.
- Removed VEDIV field (bits 8-9) since EDIV extension is not planned to be part of the base V extension
- Added ALTFMT field at bit 8
- Changed RESERVED field to start from bit 9 instead of bit 10
When Zvfbfa is disabled, bits 8+ are treated as reserved (preserving existing behavior for altfmt bit). When Zvfbfa is enabled, only bits 9+ are reserved.
Reference:
- https://github.com/riscvarchive/riscv-v-spec/blob/master/ediv.adoc
--- target/riscv/cpu.h | 4 ++-- target/riscv/vector_helper.c | 39 +++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 7 deletions(-)
target/riscv/cpu.h +2 -2
@@ -191,8 +191,8 @@ FIELD(VTYPE, VLMUL, 0, 3) FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) -FIELD(VTYPE, VEDIV, 8, 2) -FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) +FIELD(VTYPE, ALTFMT, 8, 1) +FIELD(VTYPE, RESERVED, 9, sizeof(target_ulong) * 8 - 10) typedef struct PMUCTRState { /* Current value of a counter */
target/riscv/vector_helper.c +34 -5
@@ -33,6 +33,22 @@#include "vector_internals.h" #include <math.h> +static target_ulong vtype_reserved (CPURISCVState *env,target_ulong vtype) +{ +int xlen =riscv_cpu_xlen (env); +target_ulong reserved =0 ; + +if (riscv_cpu_cfg (env)->ext_zvfbfa) { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , + xlen -1 -R_VTYPE_RESERVED_SHIFT ); + }else { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_ALTFMT_SHIFT , + xlen -1 -R_VTYPE_ALTFMT_SHIFT ); + } + +return reserved; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {
@@ -41,12 +57,10 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,uint64_t vlmul =FIELD_EX64 (s2,VTYPE ,VLMUL );uint8_t vsew =FIELD_EX64 (s2,VTYPE ,VSEW );uint16_t sew =8 << vsew; -uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV ); +uint8_t altfmt =FIELD_EX64 (s2,VTYPE ,ALTFMT ); +bool ill_altfmt = true;int xlen =riscv_cpu_xlen (env);bool vill = (s2 >> (xlen -1 )) &0x1 ; -target_ulong reserved = s2 & -MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , - xlen -1 -R_VTYPE_RESERVED_SHIFT );uint16_t vlen = cpu->cfg.vlenb <<3 ;int8_t lmul;
@@ -63,7 +77,22 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, } } -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +switch (vsew) { +case MO_8 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +case MO_16 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +default : +break ; + } + +if (altfmt && ill_altfmt) { + vill = true; + } + +if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) {/* only set vill bit. */ env->vill =1 ; env->vtype =0 ;
Signature · 1 line
2.52.0
Re: [PATCH v5 3/9] target/riscv: rvv: Add new VTYPE CSR field - altfmt
Quoted 14 lines · Max Chou
According to the Zvfbfa ISA spec v0.1, the vtype CSR adds a new field:
altfmt for BF16 support.
This update changes the layout of the vtype CSR fields.- Removed VEDIV field (bits 8-9) since EDIV extension is not planned to be part of the base V extension
- Added ALTFMT field at bit 8
- Changed RESERVED field to start from bit 9 instead of bit 10When Zvfbfa is disabled, bits 8+ are treated as reserved (preserving existing behavior for altfmt bit). When Zvfbfa is enabled, only bits 9+ are reserved.
Quoted 6 lines
Reference:
- https://github.com/riscvarchive/riscv-v-spec/blob/master/ediv.adocReviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 90 lines
--- target/riscv/cpu.h | 4 ++-- target/riscv/vector_helper.c | 39 +++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 7 deletions(-)target/riscv/cpu.h +2
-2@@ -191,8 +191,8 @@ FIELD(VTYPE, VLMUL, 0, 3) FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) -FIELD(VTYPE, VEDIV, 8, 2) -FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) +FIELD(VTYPE, ALTFMT, 8, 1) +FIELD(VTYPE, RESERVED, 9, sizeof(target_ulong) * 8 - 10) typedef struct PMUCTRState { /* Current value of a counter */target/riscv/vector_helper.c +34
-6@@ -33,6 +33,22 @@#include "vector_internals.h" #include <math.h> +static target_ulong vtype_reserved (CPURISCVState *env,target_ulong vtype) +{ +int xlen =riscv_cpu_xlen (env); +target_ulong reserved =0 ; + +if (riscv_cpu_cfg (env)->ext_zvfbfa) { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , + xlen -1 -R_VTYPE_RESERVED_SHIFT ); + }else { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_ALTFMT_SHIFT , + xlen -1 -R_VTYPE_ALTFMT_SHIFT ); + } + +return reserved; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {@@ -41,12 +57,10 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,uint64_t vlmul =FIELD_EX64 (s2,VTYPE ,VLMUL );uint8_t vsew =FIELD_EX64 (s2,VTYPE ,VSEW );uint16_t sew =8 << vsew; -uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV ); +uint8_t altfmt =FIELD_EX64 (s2,VTYPE ,ALTFMT ); +bool ill_altfmt = true;int xlen =riscv_cpu_xlen (env);bool vill = (s2 >> (xlen -1 )) &0x1 ; -target_ulong reserved = s2 & -MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , - xlen -1 -R_VTYPE_RESERVED_SHIFT );uint16_t vlen = cpu->cfg.vlenb <<3 ;int8_t lmul;@@ -63,7 +77,22 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, } } -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +switch (vsew) { +case MO_8 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +case MO_16 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +default : +break ; + } + +if (altfmt && ill_altfmt) { + vill = true; + } + +if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) {/* only set vill bit. */ env->vill =1 ; env->vtype =0 ; --2.52.0
Re: [PATCH v5 3/9] target/riscv: rvv: Add new VTYPE CSR field - altfmt
In reply to Max ChouQuoted 13 lines · Max Chou
According to the Zvfbfa ISA spec v0.1, the vtype CSR adds a new field:
altfmt for BF16 support.
This update changes the layout of the vtype CSR fields.- Removed VEDIV field (bits 8-9) since EDIV extension is not planned to be part of the base V extension
- Added ALTFMT field at bit 8
- Changed RESERVED field to start from bit 9 instead of bit 10When Zvfbfa is disabled, bits 8+ are treated as reserved (preserving existing behavior for altfmt bit). When Zvfbfa is enabled, only bits 9+ are reserved.
Quoted 6 lines
Reference:
- https://github.com/riscvarchive/riscv-v-spec/blob/master/ediv.adocReviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Thanks,
Nutty
Quoted 86 lines
--- target/riscv/cpu.h | 4 ++-- target/riscv/vector_helper.c | 39 +++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 7 deletions(-)target/riscv/cpu.h +2
-2@@ -191,8 +191,8 @@ FIELD(VTYPE, VLMUL, 0, 3) FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) -FIELD(VTYPE, VEDIV, 8, 2) -FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) +FIELD(VTYPE, ALTFMT, 8, 1) +FIELD(VTYPE, RESERVED, 9, sizeof(target_ulong) * 8 - 10) typedef struct PMUCTRState { /* Current value of a counter */target/riscv/vector_helper.c +34
-5@@ -33,6 +33,22 @@#include "vector_internals.h" #include <math.h> +static target_ulong vtype_reserved (CPURISCVState *env,target_ulong vtype) +{ +int xlen =riscv_cpu_xlen (env); +target_ulong reserved =0 ; + +if (riscv_cpu_cfg (env)->ext_zvfbfa) { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , + xlen -1 -R_VTYPE_RESERVED_SHIFT ); + }else { + reserved = vtype &MAKE_64BIT_MASK (R_VTYPE_ALTFMT_SHIFT , + xlen -1 -R_VTYPE_ALTFMT_SHIFT ); + } + +return reserved; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {@@ -41,12 +57,10 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,uint64_t vlmul =FIELD_EX64 (s2,VTYPE ,VLMUL );uint8_t vsew =FIELD_EX64 (s2,VTYPE ,VSEW );uint16_t sew =8 << vsew; -uint8_t ediv =FIELD_EX64 (s2,VTYPE ,VEDIV ); +uint8_t altfmt =FIELD_EX64 (s2,VTYPE ,ALTFMT ); +bool ill_altfmt = true;int xlen =riscv_cpu_xlen (env);bool vill = (s2 >> (xlen -1 )) &0x1 ; -target_ulong reserved = s2 & -MAKE_64BIT_MASK (R_VTYPE_RESERVED_SHIFT , - xlen -1 -R_VTYPE_RESERVED_SHIFT );uint16_t vlen = cpu->cfg.vlenb <<3 ;int8_t lmul;@@ -63,7 +77,22 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, } } -if ((sew > cpu->cfg.elen) || vill || (ediv !=0 ) || (reserved !=0 )) { +switch (vsew) { +case MO_8 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +case MO_16 : + ill_altfmt &= !(cpu->cfg.ext_zvfbfa); +break ; +default : +break ; + } + +if (altfmt && ill_altfmt) { + vill = true; + } + +if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) {/* only set vill bit. */ env->vill =1 ; env->vtype =0 ;
PATCH v5 4/9 target/riscv: rvv: Introduce reset_ill_vtype to reset illegal vtype CSR
In reply to Max ChouReplace the same vill reset flow by reset_ill_vtype function.
--- target/riscv/vector_helper.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
target/riscv/vector_helper.c +11 -10
@@ -49,6 +49,15 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)return reserved; } +static inline void reset_ill_vtype (CPURISCVState *env) +{ +/* only set vill bit. */ + env->vill =1 ; + env->vtype =0 ; + env->vl =0 ; + env->vstart =0 ; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {
@@ -93,11 +102,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; }
@@ -113,11 +118,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if (cpu->cfg.rvv_vsetvl_x0_vill && x0 && (env->vl != vl)) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; }
Signature · 1 line
2.52.0
Re: [PATCH v5 4/9] target/riscv: rvv: Introduce reset_ill_vtype to reset illegal vtype CSR
Quoted 6 lines · Max Chou
Replace the same vill reset flow by
reset_ill_vtypefunction.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 54 lines
--- target/riscv/vector_helper.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)target/riscv/vector_helper.c +11
-11@@ -49,6 +49,15 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)return reserved; } +static inline void reset_ill_vtype (CPURISCVState *env) +{ +/* only set vill bit. */ + env->vill =1 ; + env->vtype =0 ; + env->vl =0 ; + env->vstart =0 ; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {@@ -93,11 +102,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; }@@ -113,11 +118,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if (cpu->cfg.rvv_vsetvl_x0_vill && x0 && (env->vl != vl)) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; } --2.52.0
Re: [PATCH v5 4/9] target/riscv: rvv: Introduce reset_ill_vtype to reset illegal vtype CSR
In reply to Max ChouQuoted 5 lines · Max Chou
Replace the same vill reset flow by
reset_ill_vtypefunction.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Thanks,
Nutty
Quoted 50 lines
--- target/riscv/vector_helper.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)target/riscv/vector_helper.c +11
-10@@ -49,6 +49,15 @@ static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype)return reserved; } +static inline void reset_ill_vtype (CPURISCVState *env) +{ +/* only set vill bit. */ + env->vill =1 ; + env->vtype =0 ; + env->vl =0 ; + env->vstart =0 ; +} +target_ulong HELPER (vsetvl )(CPURISCVState *env,target_ulong s1,target_ulong s2,target_ulong x0) {@@ -93,11 +102,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if ((sew > cpu->cfg.elen) || vill || (vtype_reserved (env, s2) !=0 )) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; }@@ -113,11 +118,7 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, }if (cpu->cfg.rvv_vsetvl_x0_vill && x0 && (env->vl != vl)) { -/* only set vill bit. */ - env->vill =1 ; - env->vtype =0 ; - env->vl =0 ; - env->vstart =0 ; +reset_ill_vtype (env);return 0 ; }
PATCH v5 5/9 target/riscv: Use the tb->cs_base as the extend tb flags
In reply to Max ChouWe have more than 32-bits worth of state per TB, so use the tb->cs_base, which is otherwise unused for RISC-V, as the extend flag.
--- include/exec/translation-block.h | 1 + target/riscv/cpu.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-)
include/exec/translation-block.h +1 -0
@@ -65,6 +65,7 @@ struct TranslationBlock {* arm: an extension of tb->flags, * s390x: instruction data for EXECUTE, * sparc: the next pc of the instruction queue (for delay slots). +* riscv: an extension of tb->flags, */ uint64_t cs_base;
target/riscv/cpu.h +3 -0
@@ -703,6 +703,9 @@ FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1) FIELD(TB_FLAGS, PM_PMM, 29, 2) FIELD(TB_FLAGS, PM_SIGNEXTEND, 31, 1) +FIELD(EXT_TB_FLAGS, MISA_EXT, 0, 32) +FIELD(EXT_TB_FLAGS, ALTFMT, 32, 1) +#ifdef TARGET_RISCV32 #define riscv_cpu_mxl (env) ((void)(env), MXL_RV32)#else
target/riscv/tcg/tcg-cpu.c +6 -1
@@ -104,6 +104,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)RISCVCPU *cpu =env_archcpu (env);RISCVExtStatus fs, vs;uint32_t flags =0 ; +uint64_t ext_flags =0 ;bool pm_signext =riscv_cpu_virt_mem_enabled (env);if (cpu->cfg.ext_zve32x) {
@@ -118,6 +119,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)/* lmul encoded as in DisasContext::lmul */ int8_t lmul =sextract32 (FIELD_EX64 (env->vtype,VTYPE ,VLMUL ),0 ,3 ); +uint8_t altfmt =FIELD_EX64 (env->vtype,VTYPE ,ALTFMT );uint32_t vsew =FIELD_EX64 (env->vtype,VTYPE ,VSEW );uint32_t vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);uint32_t maxsz = vlmax << vsew;
@@ -133,6 +135,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) flags =FIELD_DP32 (flags,TB_FLAGS ,VMA ,FIELD_EX64 (env->vtype,VTYPE ,VMA )); flags =FIELD_DP32 (flags,TB_FLAGS ,VSTART_EQ_ZERO , env->vstart ==0 ); + ext_flags =FIELD_DP64 (ext_flags,EXT_TB_FLAGS ,ALTFMT , altfmt); }else { flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,1 ); }
@@ -189,10 +192,12 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) flags =FIELD_DP32 (flags,TB_FLAGS ,PM_PMM ,riscv_pm_get_pmm (env)); flags =FIELD_DP32 (flags,TB_FLAGS ,PM_SIGNEXTEND , pm_signext); + ext_flags =FIELD_DP64 (ext_flags,EXT_TB_FLAGS ,MISA_EXT , env->misa_ext); +return (TCGTBCPUState ){ .pc = env->xl ==MXL_RV32 ? env->pc &UINT32_MAX : env->pc, .flags = flags, - .cs_base = env->misa_ext, + .cs_base = ext_flags, }; }
Signature · 1 line
2.52.0
Re: [PATCH v5 5/9] target/riscv: Use the tb->cs_base as the extend tb flags
Quoted 68 lines · Max Chou
We have more than 32-bits worth of state per TB, so use the
tb->cs_base, which is otherwise unused for RISC-V, as the extend flag.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>--- include/exec/translation-block.h | 1 + target/riscv/cpu.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-)include/exec/translation-block.h +1
-0@@ -65,6 +65,7 @@ struct TranslationBlock {* arm: an extension of tb->flags, * s390x: instruction data for EXECUTE, * sparc: the next pc of the instruction queue (for delay slots). +* riscv: an extension of tb->flags, */ uint64_t cs_base;target/riscv/cpu.h +3
-0@@ -703,6 +703,9 @@ FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1) FIELD(TB_FLAGS, PM_PMM, 29, 2) FIELD(TB_FLAGS, PM_SIGNEXTEND, 31, 1) +FIELD(EXT_TB_FLAGS, MISA_EXT, 0, 32) +FIELD(EXT_TB_FLAGS, ALTFMT, 32, 1) +#ifdef TARGET_RISCV32 #define riscv_cpu_mxl (env) ((void)(env), MXL_RV32)#else target/riscv/tcg/tcg-cpu.c +3
-0@@ -104,6 +104,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)RISCVCPU *cpu =env_archcpu (env);RISCVExtStatus fs, vs;uint32_t flags =0 ; +uint64_t ext_flags =0 ;bool pm_signext =riscv_cpu_virt_mem_enabled (env);if (cpu->cfg.ext_zve32x) {@@ -118,6 +119,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)/* lmul encoded as in DisasContext::lmul */ int8_t lmul =sextract32 (FIELD_EX64 (env->vtype,VTYPE ,VLMUL ),0 ,3 ); +uint8_t altfmt =FIELD_EX64 (env->vtype,VTYPE ,ALTFMT );uint32_t vsew =FIELD_EX64 (env->vtype,VTYPE ,VSEW );uint32_t vlmax =vext_get_vlmax (cpu->cfg.vlenb, vsew, lmul);uint32_t maxsz = vlmax << vsew;@@ -133,6 +135,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) flags =FIELD_DP32 (flags,TB_FLAGS ,VMA ,FIELD_EX64 (env->vtype,VTYPE ,VMA )); flags =FIELD_DP32 (flags,TB_FLAGS ,VSTART_EQ_ZERO , env->vstart ==0 ); + ext_flags =FIELD_DP64 (ext_flags,EXT_TB_FLAGS ,ALTFMT , altfmt); }else { flags =FIELD_DP32 (flags,TB_FLAGS ,VILL ,1 ); }
target/riscv/tcg/tcg-cpu.c static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) · line 200
Quoted 10 lines
target/riscv/tcg/tcg-cpu.c +3
-1@@ -189,10 +192,12 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) flags =FIELD_DP32 (flags,TB_FLAGS ,PM_PMM ,riscv_pm_get_pmm (env)); flags =FIELD_DP32 (flags,TB_FLAGS ,PM_SIGNEXTEND , pm_signext); + ext_flags =FIELD_DP64 (ext_flags,EXT_TB_FLAGS ,MISA_EXT , env->misa_ext); +return (TCGTBCPUState ){ .pc = env->xl ==MXL_RV32 ? env->pc &UINT32_MAX : env->pc, .flags = flags, - .cs_base = env->misa_ext, + .cs_base = ext_flags,
We need to update the comment in struct TranslationBlock for target_ulong cs_base
Alistair
Quoted 7 lines
target/riscv/tcg/tcg-cpu.c +0
-1}; } --2.52.0
Re: [PATCH v5 5/9] target/riscv: Use the tb->cs_base as the extend tb flags
Quoted 14 lines · Alistair Francis
Quoted 13 lines · Max Chou
We have more than 32-bits worth of state per TB, so use the
tb->cs_base, which is otherwise unused for RISC-V, as the extend flag.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>--- include/exec/translation-block.h | 1 + target/riscv/cpu.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-)
Quoted 13 lines
include/exec/translation-block.h struct TranslationBlock { · line 71
Quoted 12 lines
include/exec/translation-block.h +1
-0@@ -65,6 +65,7 @@ struct TranslationBlock {* arm: an extension of tb->flags, * s390x: instruction data for EXECUTE, * sparc: the next pc of the instruction queue (for delay slots). +* riscv: an extension of tb->flags, */ uint64_t cs_base;
Hi Alistair,
I’m curious to know if you mean adding more details here, such as specifying the bit width for misa (e.g., 32 bits) or the bit width for ALTFMT (e.g., 1 bit).
If so, I’ll include these details in the v6 version.
Thanks,
rnax
Quoted 5 lines
We need to update the comment in
struct TranslationBlockfortarget_ulong cs_baseAlistair
Re: [PATCH v5 5/9] target/riscv: Use the tb->cs_base as the extend tb flags
Quoted 30 lines · Max Chou
Quoted 14 lines · Alistair Francis
Quoted 13 lines · Max Chou
We have more than 32-bits worth of state per TB, so use the
tb->cs_base, which is otherwise unused for RISC-V, as the extend flag.Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>--- include/exec/translation-block.h | 1 + target/riscv/cpu.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-)Quoted 13 lines
include/exec/translation-block.h struct TranslationBlock { · line 71
Quoted 12 lines
include/exec/translation-block.h +1
-0@@ -65,6 +65,7 @@ struct TranslationBlock {* arm: an extension of tb->flags, * s390x: instruction data for EXECUTE, * sparc: the next pc of the instruction queue (for delay slots). +* riscv: an extension of tb->flags, */ uint64_t cs_base;
Quoted 6 lines
Hi Alistair,
I’m curious to know if you mean adding more details here, such as specifying the bit width for misa (e.g., 32 bits) or the bit width for ALTFMT (e.g., 1 bit).
If so, I’ll include these details in the v6 version.
Oh! You did update the comment. Sorry I missed that.
No action required!
Alistair
Quoted 9 lines
Thanks,
rnaxQuoted 5 lines
We need to update the comment in
struct TranslationBlockfortarget_ulong cs_baseAlistair
PATCH v5 6/9 target/riscv: Introduce altfmt into DisasContext
In reply to Max Chou--- target/riscv/translate.c | 3 +++ 1 file changed, 3 insertions(+)
target/riscv/translate.c +3 -0
@@ -101,6 +101,7 @@ typedef struct DisasContext {bool cfg_vta_all_1s;bool vstart_eq_zero;bool vl_eq_vlmax; +bool altfmt;CPUState *cs;TCGv zero;/* actual address width */
@@ -1307,6 +1308,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)RISCVCPUClass *mcc =RISCV_CPU_GET_CLASS (cs);RISCVCPU *cpu =RISCV_CPU (cs);uint32_t tb_flags = ctx->base.tb->flags; +uint64_t ext_tb_flags = ctx->base.tb->cs_base; ctx->pc_save = ctx->base.pc_first; ctx->priv =FIELD_EX32 (tb_flags,TB_FLAGS ,PRIV );
@@ -1326,6 +1328,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->cfg_vta_all_1s = cpu->cfg.rvv_ta_all_1s; ctx->vstart_eq_zero =FIELD_EX32 (tb_flags,TB_FLAGS ,VSTART_EQ_ZERO ); ctx->vl_eq_vlmax =FIELD_EX32 (tb_flags,TB_FLAGS ,VL_EQ_VLMAX ); + ctx->altfmt =FIELD_EX64 (ext_tb_flags,EXT_TB_FLAGS ,ALTFMT ); ctx->misa_mxl_max = mcc->def->misa_mxl_max; ctx->xl =FIELD_EX32 (tb_flags,TB_FLAGS ,XL ); ctx->address_xl =FIELD_EX32 (tb_flags,TB_FLAGS ,AXL );
Signature · 1 line
2.52.0
Re: [PATCH v5 6/9] target/riscv: Introduce altfmt into DisasContext
Quoted 4 lines · Max Chou
Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 36 lines
--- target/riscv/translate.c | 3 +++ 1 file changed, 3 insertions(+)target/riscv/translate.c +3
-1@@ -101,6 +101,7 @@ typedef struct DisasContext {bool cfg_vta_all_1s;bool vstart_eq_zero;bool vl_eq_vlmax; +bool altfmt;CPUState *cs;TCGv zero;/* actual address width */ @@ -1307,6 +1308,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)RISCVCPUClass *mcc =RISCV_CPU_GET_CLASS (cs);RISCVCPU *cpu =RISCV_CPU (cs);uint32_t tb_flags = ctx->base.tb->flags; +uint64_t ext_tb_flags = ctx->base.tb->cs_base; ctx->pc_save = ctx->base.pc_first; ctx->priv =FIELD_EX32 (tb_flags,TB_FLAGS ,PRIV );@@ -1326,6 +1328,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->cfg_vta_all_1s = cpu->cfg.rvv_ta_all_1s; ctx->vstart_eq_zero =FIELD_EX32 (tb_flags,TB_FLAGS ,VSTART_EQ_ZERO ); ctx->vl_eq_vlmax =FIELD_EX32 (tb_flags,TB_FLAGS ,VL_EQ_VLMAX ); + ctx->altfmt =FIELD_EX64 (ext_tb_flags,EXT_TB_FLAGS ,ALTFMT ); ctx->misa_mxl_max = mcc->def->misa_mxl_max; ctx->xl =FIELD_EX32 (tb_flags,TB_FLAGS ,XL ); ctx->address_xl =FIELD_EX32 (tb_flags,TB_FLAGS ,AXL ); --2.52.0
PATCH v5 7/9 target/riscv: Introduce BF16 canonical NaN for Zvfbfa extension
In reply to Max ChouAccording to the Zvfbfa ISA spec (v0.1), improperly NaN-boxed f-register operands must substitute the BF16 canonical NaN instead of the FP16 canonical NaN for some vector floating-point instructions.
--- target/riscv/insn_trans/trans_rvv.c.inc | 18 +++++++++--------- target/riscv/translate.c | 8 ++++++++ 2 files changed, 17 insertions(+), 9 deletions(-)
target/riscv/insn_trans/trans_rvv.c.inc +9 -9
@@ -2319,17 +2319,17 @@ GEN_OPIWI_NARROW_TRANS(vnclip_wi, IMM_ZX, vnclip_wx) */ static void do_nanbox(DisasContext *s, TCGv_i64 out, TCGv_i64 in) { - switch (s->sew) { - case 1: - gen_check_nanbox_h(out, in); - break; - case 2: + if (s->sew == MO_16) { + if (s->altfmt) { + gen_check_nanbox_h_bf16(out, in); + } else { + gen_check_nanbox_h(out, in); + } + } else if (s->sew == MO_32) { gen_check_nanbox_s(out, in); - break; - case 3: + } else if (s->sew == MO_64) { tcg_gen_mov_i64(out, in); - break; - default: + } else { g_assert_not_reached(); } }
target/riscv/translate.c +8 -0
@@ -214,6 +214,14 @@ static void gen_check_nanbox_h(TCGv_i64 out, TCGv_i64 in)tcg_gen_movcond_i64 (TCG_COND_GEU , out, in, t_max, in, t_nan); } +static void gen_check_nanbox_h_bf16 (TCGv_i64 out,TCGv_i64 in) +{ +TCGv_i64 t_max =tcg_constant_i64 (0xffffffffffff0000ull ); +TCGv_i64 t_nan =tcg_constant_i64 (0xffffffffffff7fc0ull ); + +tcg_gen_movcond_i64 (TCG_COND_GEU , out, in, t_max, in, t_nan); +} +static void gen_check_nanbox_s (TCGv_i64 out,TCGv_i64 in) {TCGv_i64 t_max =tcg_constant_i64 (0xffffffff00000000ull );
Signature · 1 line
2.52.0
Re: [PATCH v5 7/9] target/riscv: Introduce BF16 canonical NaN for Zvfbfa extension
Quoted 8 lines · Max Chou
According to the Zvfbfa ISA spec (v0.1), improperly NaN-boxed f-register operands must substitute the BF16 canonical NaN instead of the FP16 canonical NaN for some vector floating-point instructions.
Reviewed-by Daniel Henrique Barboza <[email protected]>Reviewed-by Chao Liu <[email protected]>Signed-off-by Max Chou <[email protected]>
Alistair
Quoted 59 lines
--- target/riscv/insn_trans/trans_rvv.c.inc | 18 +++++++++--------- target/riscv/translate.c | 8 ++++++++ 2 files changed, 17 insertions(+), 9 deletions(-)target/riscv/insn_trans/trans_rvv.c.inc +9
-9@@ -2319,17 +2319,17 @@ GEN_OPIWI_NARROW_TRANS(vnclip_wi, IMM_ZX, vnclip_wx) */ static void do_nanbox(DisasContext *s, TCGv_i64 out, TCGv_i64 in) { - switch (s->sew) { - case 1: - gen_check_nanbox_h(out, in); - break; - case 2: + if (s->sew == MO_16) { + if (s->altfmt) { + gen_check_nanbox_h_bf16(out, in); + } else { + gen_check_nanbox_h(out, in); + } + } else if (s->sew == MO_32) { gen_check_nanbox_s(out, in); - break; - case 3: + } else if (s->sew == MO_64) { tcg_gen_mov_i64(out, in); - break; - default: + } else { g_assert_not_reached(); } }target/riscv/translate.c +8
-1@@ -214,6 +214,14 @@ static void gen_check_nanbox_h(TCGv_i64 out, TCGv_i64 in)tcg_gen_movcond_i64 (TCG_COND_GEU , out, in, t_max, in, t_nan); } +static void gen_check_nanbox_h_bf16 (TCGv_i64 out,TCGv_i64 in) +{ +TCGv_i64 t_max =tcg_constant_i64 (0xffffffffffff0000ull ); +TCGv_i64 t_nan =tcg_constant_i64 (0xffffffffffff7fc0ull ); + +tcg_gen_movcond_i64 (TCG_COND_GEU , out, in, t_max, in, t_nan); +} +static void gen_check_nanbox_s (TCGv_i64 out,TCGv_i64 in) {TCGv_i64 t_max =tcg_constant_i64 (0xffffffff00000000ull ); --2.52.0
PATCH v5 8/9 target/riscv: rvv: Support Zvfbfa vector bf16 operations
In reply to Max ChouAccording to the Zvfbfa ISA spec v0.1, the following vector floating point instructions have different behaviors depend on the ALTFMT and VSEW fields of VTYPE CSR.
When altfmt=1 and SEW=8, all vector floating-point instructions become reserved, except for the following, which are redefined to use the BF16 format for any operand that would otherwise have used the FP16 format:
- vfwcvt.f.x[u].v, vfncvt.x[u].f.w, vfncvt.rtz.x[u].f.w
When altfmt=1 and SEW=16, all vector floating-point instructions become reserved, except for the following, which are redefined to use the BF16 format for any operand that would otherwise have used the FP16 format:
- vfadd.v[vf], vfsub.v[vf], vfmin.v[vf], vfmax.v[vf], vmfeq.v[vf], vmfle.v[vf], vmflt.v[vf], vmfne.v[vf], vmfgt.vf, vmfge.vf, vfmul.v[vf], vfrsub.vf, vfmadd.v[vf], vfnmadd.v[vf], vfmsub.v[vf], vfnmsub.v[vf], vfmacc.v[vf], vfnmacc.v[vf], vfmsac.v[vf], vfnmsac.v[vf], vfwadd.v[vf], vfwsub.v[vf], vfwadd.w[vf], vfwsub.w[vf], vfwmul.v[vf], vfwmacc.v[vf], vfwnmacc.v[vf], vfwmsac.v[vf], vfwnmsac.v[vf], vfwcvt.f.f.v, vfncvt.f.f.w, vfncvt.rod.f.f.w, vfrsqrt7.v, vfrec7.v, vfclass.v
The following instructions marked with * have the same semantics regardless of altfmt.
*- vfmv.f.s,
vfwmaccbf16.v[vf] (only if Zvfbfwma is implemented) vfwcvtbf16.f.f.v (only if Zvfbfmin is implemented) vfncvtbf16.f.f.w (only if Zvfbfmin is implemented)
The following instructions marked with ** differ only in that improperly NaN-boxed f-register operands must substitute the BF16 canonical NaN instead of the FP16 canonical NaN.
**- vfsgnj.v[vf], vfsgnjn.v[vf], vfsgnjx.v[vf], vfslide1up.vf,
vfslide1down.vf, vfmv.v.f, vfmerge.vfm, vfmv.s.f
--- target/riscv/helper.h | 60 ++ target/riscv/insn_trans/trans_rvv.c.inc | 970 +++++++++++++++--------- target/riscv/internals.h | 1 + target/riscv/vector_helper.c | 329 ++++++++ 4 files changed, 989 insertions(+), 371 deletions(-)
target/riscv/helper.h +60 -0
@@ -766,45 +766,60 @@ DEF_HELPER_6(vnclip_wx_b, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vnclip_wx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vnclip_wx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vfadd_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfsub_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfadd_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfsub_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfrsub_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfrsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfrsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfrsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwadd_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwsub_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwadd_wv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwadd_wv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwadd_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwsub_wv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwsub_wv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwsub_wv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwadd_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwsub_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwadd_wf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwadd_wf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwadd_wf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwsub_wf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwsub_wf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwsub_wf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmul_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmul_vv_d, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfdiv_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfdiv_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfdiv_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmul_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmul_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmul_vf_w, void, ptr, ptr, i64, ptr, env, i32)DEF_HELPER_6 (vfmul_vf_d, void, ptr, ptr, i64, ptr, env, i32)
@@ -815,74 +830,98 @@ DEF_HELPER_6(vfrdiv_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfrdiv_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfrdiv_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwmul_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmul_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmul_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwmul_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmul_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmul_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmacc_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmacc_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfnmacc_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmacc_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmsac_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsac_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfnmsac_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsac_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmadd_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfnmadd_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmadd_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmadd_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmadd_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmsub_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfnmsub_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsub_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsub_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfnmsub_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmacc_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmacc_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfnmacc_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmacc_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmsac_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsac_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfnmsac_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsac_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmadd_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfnmadd_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmadd_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmadd_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmadd_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmsub_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfnmsub_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsub_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsub_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfnmsub_vf_d, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwnmacc_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwnmacc_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwnmacc_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwmsac_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfwnmsac_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwnmsac_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwnmsac_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwnmacc_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwnmacc_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwnmacc_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwmsac_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfwnmsac_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfwnmsac_vf_h, void, ptr, ptr, i64, ptr, env, i32)DEF_HELPER_6 (vfwnmsac_vf_w, void, ptr, ptr, i64, ptr, env, i32)
@@ -890,23 +929,29 @@ DEF_HELPER_5(vfsqrt_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfsqrt_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfsqrt_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfrsqrt7_v_h_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrsqrt7_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrsqrt7_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrsqrt7_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfrec7_v_h_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrec7_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrec7_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfrec7_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmin_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmin_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmin_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmin_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmax_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmax_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmax_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfmax_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vfmin_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmin_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmin_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmin_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vfmax_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmax_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfmax_vf_w, void, ptr, ptr, i64, ptr, env, i32)DEF_HELPER_6 (vfmax_vf_d, void, ptr, ptr, i64, ptr, env, i32)
@@ -930,37 +975,48 @@ DEF_HELPER_6(vfsgnjx_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfsgnjx_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vfsgnjx_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmfeq_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfeq_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfeq_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfeq_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vmfne_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfne_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfne_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfne_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vmflt_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmflt_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmflt_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmflt_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vmfle_vv_h_bf16, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfle_vv_h, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfle_vv_w, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vmfle_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vmfeq_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfeq_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfeq_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfeq_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmfne_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfne_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfne_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfne_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmflt_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmflt_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmflt_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmflt_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmfle_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfle_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfle_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfle_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmfgt_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfgt_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfgt_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfgt_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_6(vmfge_vf_h_bf16, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_h, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_w, void, ptr, ptr, i64, ptr, env, i32) DEF_HELPER_6(vmfge_vf_d, void, ptr, ptr, i64, ptr, env, i32) +DEF_HELPER_5(vfclass_v_h_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfclass_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfclass_v_w, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vfclass_v_d, void, ptr, ptr, ptr, env, i32)
@@ -987,18 +1043,22 @@ DEF_HELPER_5(vfwcvt_xu_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_x_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_x_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_xu_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_f_xu_v_b_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_xu_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_xu_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_x_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfwcvt_f_x_v_b_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_x_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_x_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_f_v_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfwcvt_f_f_v_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_xu_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_xu_f_w_b_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_xu_f_w_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_xu_f_w_w, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_x_f_w_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vfncvt_x_f_w_b_bf16, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_x_f_w_h, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vfncvt_x_f_w_w, void, ptr, ptr, ptr, env, i32)DEF_HELPER_5 (vfncvt_f_xu_w_h, void, ptr, ptr, ptr, env, i32)
target/riscv/insn_trans/trans_rvv.c.inc +599 -371
1,260 lines not on this page · raw message
target/riscv/internals.h +1 -0
@@ -72,6 +72,7 @@ FIELD(VDATA, NF, 7, 4)FIELD (VDATA ,WD ,7 ,1 ) /* float point classify helpers */ +target_ulong fclass_h_bf16 (uint64_t frs1);target_ulong fclass_h (uint64_t frs1);target_ulong fclass_s (uint64_t frs1);target_ulong fclass_d (uint64_t frs1);
target/riscv/vector_helper.c +329 -0
835 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v5 9/9 target/riscv: Expose Zvfbfa extension as an experimental cpu property
In reply to Max Chou--- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/riscv/cpu.c +1 -0
@@ -1379,6 +1379,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = {/* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = {MULTI_EXT_CFG_BOOL ("x-svukte" , ext_svukte, false), +MULTI_EXT_CFG_BOOL ("x-zvfbfa" , ext_zvfbfa, false), { }, };
Signature · 1 line
2.52.0
Quoted 7 lines · Max Chou
This patch series adds support for the RISC-V Zvfbfa extension, which provides additional BF16 vector compute support.
The isa spec of Zvfbfa extension is not ratified yet, so this patch series is based on the latest draft of the spec (v0.1) and make the Zvfbfa extension as an experimental extension.
It's not only not ratified, there isn't even a draft spec. A personal GitHub repo without any tags or releases is not enough for us to take this unfortunately.
Quoted 7 lines
The Zvfbfa extension adds a 1-bit field, altfmt, to the vtype CSR in bit position 8.
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.Specification:
https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adoc
Overall this looks ok. Once a draft spec is released we can apply it
Alistair
Quoted 63 lines
Changes in v5:
- Fix typo in patch 1/5/8
- Remove unnecessarydo_bf16_nanboxChanges in v4:
- Rebase on riscv-to-apply.next (commit 21101a7)
- Update commit message of patch 2 (target/riscv: Add the Zvfbfa extension implied rule)
- Update checking flow of illegal ALTFMT SEW patterns at patch 3 (target/riscv: rvv: Add new VTYPE CSR field - altfmt)Changes in v3:
- Rebased on riscv-to-apply.next (commit f66f234)
- Fix typo in v2 patch 5 commit messageChanges from v2:
- Removed RFC designation from the series
- Updated commit message for patch 3 (VTYPE CSR field - altfmt) to clearly explain:
* VEDIV field removal (bits 8-9) since EDIV extension is not planned to be part of the base V extension
* ALTFMT field addition at bit 8
* RESERVED field change from bit 10 to bit 9
- Added new patch 4: Introducereset_ill_vtypehelper function to consolidate illegal vtype CSR reset logicv4: <[email protected]>
v3: <[email protected]>
v2: <[email protected]>
v1: <[email protected]>rnax
Max Chou (9):
target/riscv: Add cfg properties for Zvfbfa extensions target/riscv: Add the Zvfbfa extension implied rule target/riscv: rvv: Add new VTYPE CSR field - altfmt target/riscv: rvv: Introducereset_ill_vtypeto reset illegal vtype
CSR
target/riscv: Use thetb->cs_baseas the extend tb flags target/riscv: Introduce altfmt into DisasContext target/riscv: Introduce BF16 canonical NaN for Zvfbfa extension target/riscv: rvv: Support Zvfbfa vector bf16 operations target/riscv: Expose Zvfbfa extension as an experimental cpu propertyinclude/exec/translation-block.h | 1 + target/riscv/cpu.c | 15 +- target/riscv/cpu.h | 7 +- target/riscv/cpu_cfg_fields.h.inc | 1 + target/riscv/helper.h | 60 ++ target/riscv/insn_trans/trans_rvv.c.inc | 988 +++++++++++++++--------- target/riscv/internals.h | 1 + target/riscv/tcg/tcg-cpu.c | 15 +- target/riscv/translate.c | 11 + target/riscv/vector_helper.c | 389 +++++++++- 10 files changed, 1088 insertions(+), 400 deletions(-)--
2.52.0
Quoted 18 lines · Alistair Francis
Quoted 7 lines · Max Chou
This patch series adds support for the RISC-V Zvfbfa extension, which provides additional BF16 vector compute support.
The isa spec of Zvfbfa extension is not ratified yet, so this patch series is based on the latest draft of the spec (v0.1) and make the Zvfbfa extension as an experimental extension.
It's not only not ratified, there isn't even a draft spec. A personal GitHub repo without any tags or releases is not enough for us to take this unfortunately.
Quoted 5 lines
The Zvfbfa extension adds a 1-bit field, altfmt, to the vtype CSR in bit position 8.
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.
Quoted 7 lines
Quoted 2 lines
Specification:
https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adocOverall this looks ok. Once a draft spec is released we can apply it
Alistair
Hi Alistair,
Thanks for the review. You asked for a pointer to the standalone ISA spec repo for Zvfbfa — I want to explain why that doesn’t exist and where the spec lives instead.
RVIA changed the ISA development workflow: new ISA specifications are no longer developed in standalone repositories. Instead, they are developed as forked branches of the base ISA manual repo (riscv/riscv-isa-manual) and merged into it upon ratification [1].
For Zvfbfa specifically, the official spec artifact under this new workflow is a PR against riscv-isa-manual [2], incorporating the spec text [3]. The PR notes that the spec has passed internal review and ARC review, as documented in the tech-unprivileged list thread [4].
PR #2743 is currently open, meaning ratification is pending but not yet complete. Under the new workflow, merge into main of riscv-isa-manual is the signal that ratification is finalized. If you prefer to wait until that merge happens before applying this patchset, I completely understand. Alternatively, if you are comfortable accepting it as ratification-pending, I am happy to address any remaining technical comments.
Please let me know how you would like to proceed.
References:
[1] https://lists.riscv.org/g/sig-documentation/message/275
[2] https://github.com/riscv/riscv-isa-manual/pull/2743
[3] https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adoc
[4] https://lists.riscv.org/g/tech-unprivileged/message/1031
https://lists.riscv.org/g/tech-unprivileged/message/1085
https://lists.riscv.org/g/tech-unprivileged/message/1109
Best regards,
rnax
Quoted 30 lines · Max Chou
Quoted 18 lines · Alistair Francis
Quoted 7 lines · Max Chou
This patch series adds support for the RISC-V Zvfbfa extension, which provides additional BF16 vector compute support.
The isa spec of Zvfbfa extension is not ratified yet, so this patch series is based on the latest draft of the spec (v0.1) and make the Zvfbfa extension as an experimental extension.
It's not only not ratified, there isn't even a draft spec. A personal GitHub repo without any tags or releases is not enough for us to take this unfortunately.
Quoted 5 lines
The Zvfbfa extension adds a 1-bit field, altfmt, to the vtype CSR in bit position 8.
The Zvfbfa extension requires the Zve32f and Zfbfmin extensions.Quoted 7 lines
Quoted 2 lines
Specification:
https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adocOverall this looks ok. Once a draft spec is released we can apply it
Alistair
Hi Alistair,
Quoted 8 lines
Thanks for the review. You asked for a pointer to the standalone ISA spec repo for Zvfbfa — I want to explain why that doesn’t exist and where the spec lives instead.
RVIA changed the ISA development workflow: new ISA specifications are no longer developed in standalone repositories. Instead, they are developed as forked branches of the base ISA manual repo (riscv/riscv-isa-manual) and merged into it upon ratification [1].
That's fine. The details you point to show forking to a RISC-V org GitHub account. In which case it's still clearly a RISC-V spec, under RVI. As long as it's tagged for draft releases that isn't really any different then before.
Quoted 5 lines
For Zvfbfa specifically, the official spec artifact under this new workflow is a PR against riscv-isa-manual [2], incorporating the spec text [3]. The PR notes that the spec has passed internal review and ARC review, as documented in the tech-unprivileged list thread [4].
The problem here is that there is no version control. If we merge this series and the PR changes then suddenly we are out of sync there is no way to track which version of the draft spec we support.
We need clear versions, like we previously have. For example version 0.7 and then 0.8. Draft versions are ok, but we need a stable target to develop against.
Quoted 8 lines
PR #2743 is currently open, meaning ratification is pending but not yet complete. Under the new workflow, merge into main of riscv-isa-manual is the signal that ratification is finalized. If you prefer to wait until that merge happens before applying this patchset, I completely understand. Alternatively, if you are comfortable accepting it as ratification-pending, I am happy to address any remaining technical comments.
In this case we will have to wait as there is no stable version of the spec to point to.
Alistair
Quoted 14 lines
Please let me know how you would like to proceed.
References:
[1] https://lists.riscv.org/g/sig-documentation/message/275
[2] https://github.com/riscv/riscv-isa-manual/pull/2743
[3] https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfbfa.adoc
[4] https://lists.riscv.org/g/tech-unprivileged/message/1031
https://lists.riscv.org/g/tech-unprivileged/message/1085
https://lists.riscv.org/g/tech-unprivileged/message/1109Best regards,
rnax
Quoted 17 lines · Alistair Francis
The problem here is that there is no version control. If we merge this series and the PR changes then suddenly we are out of sync there is no way to track which version of the draft spec we support.
We need clear versions, like we previously have. For example version 0.7 and then 0.8. Draft versions are ok, but we need a stable target to develop against.
Quoted 8 lines
PR #2743 is currently open, meaning ratification is pending but not yet complete. Under the new workflow, merge into main of riscv-isa-manual is the signal that ratification is finalized. If you prefer to wait until that merge happens before applying this patchset, I completely understand. Alternatively, if you are comfortable accepting it as ratification-pending, I am happy to address any remaining technical comments.
Quoted 5 lines
In this case we will have to wait as there is no stable version of the spec to point to.
Alistair
Hi Alistair,
Thank you for your feedback on the version control and stability of the Zvfbfa specification. I understand your concern about developing against a moving target.
To address the lack of a stable target as you mentioned, I’d like to help bridge this gap. Since this patchset was prepared based on the Zvfbfa version v0.1 and this version has passed the ARC review, I propose we coordinate with the Zvfbfa isa designer to check the specific tag/commit ID of the Zvfbfa v0.1.
If we could create a tag or release for v0.1 (e.g., v0.1/v0.1-draft) within the Zvfbfa repository that explicitly marks the current state of the Zvfbfa spec, would that provide the necessary versioning baseline for you to accept this patchset?
My goal is to ensure QEMU supports a traceable version of the draft spec while respecting the current RVIA development process for this ISA implementation patchset and the followings in the future.
rnax
Quoted 38 lines · Max Chou
Quoted 17 lines · Alistair Francis
The problem here is that there is no version control. If we merge this series and the PR changes then suddenly we are out of sync there is no way to track which version of the draft spec we support.
We need clear versions, like we previously have. For example version 0.7 and then 0.8. Draft versions are ok, but we need a stable target to develop against.
Quoted 8 lines
PR #2743 is currently open, meaning ratification is pending but not yet complete. Under the new workflow, merge into main of riscv-isa-manual is the signal that ratification is finalized. If you prefer to wait until that merge happens before applying this patchset, I completely understand. Alternatively, if you are comfortable accepting it as ratification-pending, I am happy to address any remaining technical comments.
Quoted 5 lines
In this case we will have to wait as there is no stable version of the spec to point to.
Alistair
Hi Alistair,
Thank you for your feedback on the version control and stability of the Zvfbfa specification. I understand your concern about developing against a moving target.
To address the lack of a stable target as you mentioned, I’d like to help bridge this gap. Since this patchset was prepared based on the Zvfbfa version v0.1 and this version has passed the ARC review, I propose we coordinate with the Zvfbfa isa designer to check the specific tag/commit ID of the Zvfbfa v0.1.
Quoted 4 lines
If we could create a tag or release for v0.1 (e.g., v0.1/v0.1-draft) within the Zvfbfa repository that explicitly marks the current state of the Zvfbfa spec, would that provide the necessary versioning baseline for you to accept this patchset?
Yes, that's how things previously worked. Basically I think we just need a tag (that won't be changed) in an official RISC-V repo that we can point to. That way it's easy to say "this is the exact version we used to write the QEMU implementation". Then if there is a version 0.2 we can easily see what has changed and update to match.
With the seemingly infinite number of draft extensions we need something to manage the version and compatibility, and that seems like the best bet.
Posting the draft PDF spec somewhere immutable would also work. We just need to be able to point to something that won't change and represents some sort of "release". So a git commit doesn't seem like enough, we need a "release" that everyone can converge on.
Alistair
Quoted 6 lines
My goal is to ensure QEMU supports a traceable version of the draft spec while respecting the current RVIA development process for this ISA implementation patchset and the followings in the future.
rnax
Quoted 6 lines · Alistair Francis
Yes, that's how things previously worked. Basically I think we just need a tag (that won't be changed) in an official RISC-V repo that we can point to. That way it's easy to say "this is the exact version we used to write the QEMU implementation". Then if there is a version 0.2 we can easily see what has changed and update to match.
Hi Alistair,
The official riscv-isa-manual repository has added a new tag for the frozen Zvfbfa v0.9, as shown below:
https://github.com/riscv/riscv-isa-manual/releases/tag/zvfbfa-0.9
The current v5 implementation fully complies with this frozen specification.
Since the Zvfbfa is frozen, should I prepare a v6 that removes the “x-“ prefix from the zvfbfa property and updates the specification reference ?
Thanks,
rnax
Quoted 10 lines
With the seemingly infinite number of draft extensions we need something to manage the version and compatibility, and that seems like the best bet.
Posting the draft PDF spec somewhere immutable would also work. We just need to be able to point to something that won't change and represents some sort of "release". So a git commit doesn't seem like enough, we need a "release" that everyone can converge on.
Alistair
Quoted 13 lines · Max Chou
Quoted 6 lines · Alistair Francis
Yes, that's how things previously worked. Basically I think we just need a tag (that won't be changed) in an official RISC-V repo that we can point to. That way it's easy to say "this is the exact version we used to write the QEMU implementation". Then if there is a version 0.2 we can easily see what has changed and update to match.
Hi Alistair,
The official riscv-isa-manual repository has added a new tag for the frozen Zvfbfa v0.9, as shown below:
Quoted 8 lines
https://github.com/riscv/riscv-isa-manual/releases/tag/zvfbfa-0.9
The current v5 implementation fully complies with this frozen specification.
Since the Zvfbfa is frozen, should I prepare a v6 that removes the “x-“ prefix from the zvfbfa property and updates the specification reference ?
I think we need a v6 series, usually it's fine to implementation after spec tag is release.
That said, we should defer to Alistair's thoughts on this.
Additionally, my new debug spec series can be sent upstream later (base on the zvfbfa tb ext_flag patch), once zvfbfa ia all ready and pulled.
Thanks,
Chao
Quoted 14 lines
Thanks,
rnaxQuoted 10 lines
With the seemingly infinite number of draft extensions we need something to manage the version and compatibility, and that seems like the best bet.
Posting the draft PDF spec somewhere immutable would also work. We just need to be able to point to something that won't change and represents some sort of "release". So a git commit doesn't seem like enough, we need a "release" that everyone can converge on.
Alistair
Quoted 15 lines · Chao Liu
Quoted 13 lines · Max Chou
Quoted 6 lines · Alistair Francis
Yes, that's how things previously worked. Basically I think we just need a tag (that won't be changed) in an official RISC-V repo that we can point to. That way it's easy to say "this is the exact version we used to write the QEMU implementation". Then if there is a version 0.2 we can easily see what has changed and update to match.
Hi Alistair,
The official riscv-isa-manual repository has added a new tag for the frozen Zvfbfa v0.9, as shown below:
Quoted 8 lines
Quoted 8 lines
https://github.com/riscv/riscv-isa-manual/releases/tag/zvfbfa-0.9
The current v5 implementation fully complies with this frozen specification.
Since the Zvfbfa is frozen, should I prepare a v6 that removes the “x-“ prefix from the zvfbfa property and updates the specification reference ?
Yes please!
Alistair
Quoted 25 lines
I think we need a v6 series, usually it's fine to implementation after spec tag is release.
That said, we should defer to Alistair's thoughts on this.
Additionally, my new debug spec series can be sent upstream later (base on the zvfbfa tb
ext_flagpatch), once zvfbfa ia all ready and pulled.Thanks,
ChaoQuoted 14 lines
Thanks,
rnaxQuoted 10 lines
With the seemingly infinite number of draft extensions we need something to manage the version and compatibility, and that seems like the best bet.
Posting the draft PDF spec somewhere immutable would also work. We just need to be able to point to something that won't change and represents some sort of "release". So a git commit doesn't seem like enough, we need a "release" that everyone can converge on.
Alistair