Skip to content

Commit d977fb3

Browse files
committed
UNRATIFIED RISC-V: Add 'Zvfbfwma' extension
[DO NOT MERGE] Until RISC-V BF16 extensions are frozen/ratified and the final version number is determined, this patch should not be merged upstream. This commit uses unratified version 0.8 as in the latest PDF documentation (instead of possible 1.0 after ratification). This commit adds support for the 'Zvfbfwma' extension, the vector BF16 multiply then FP32 accumlation extension, consisting of two widening multiply-accumulate instructions. This commit is based on the following specification: <riscv/riscv-bfloat16@5578e34> bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets) Add 'Zvfbfwma' -> 'Zvfbfmin' implication. (riscv_supported_std_z_ext): Add 'Zvfbfwma'. (riscv_multi_subset_supports): Add support to INSN_CLASS_ZVFBFWMA. (riscv_multi_subset_supports_ext): Likewise. gas/ChangeLog: * testsuite/gas/riscv/zvfbfwma.s: New test. * testsuite/gas/riscv/zvfbfwma.d: Likewise. include/ChangeLog: * opcode/riscv-opc.h (MATCH_VFWMACCBF16_VF, MASK_VFWMACCBF16_VF, MATCH_VFWMACCBF16_VV, MASK_VFWMACCBF16_VV) New. * opcode/riscv.h (enum riscv_insn_class): Add new instruction class INSN_CLASS_ZVFBFWMA. opcodes/ChangeLog: * riscv-opc.c (riscv_opcodes): Add 'Zvfbfwma' instructions.
1 parent ada50fd commit d977fb3

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
11101110
{"v", "d", check_implicit_always},
11111111
{"v", "zve64d", check_implicit_always},
11121112
{"v", "zvl128b", check_implicit_always},
1113+
{"zvfbfwma", "zvfbfmin", check_implicit_always},
11131114
{"zvfbfmin", "zfbfmin", check_implicit_always},
11141115
{"zvfbfmin", "zve32f", check_implicit_always},
11151116
{"zvfh", "zvfhmin", check_implicit_always},
@@ -1295,6 +1296,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12951296
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12961297
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12971298
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
1299+
{"zvfbfwma", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
12981300
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12991301
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13001302
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2513,6 +2515,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25132515
return riscv_subset_supports (rps, "zvbc");
25142516
case INSN_CLASS_ZVFBFMIN:
25152517
return riscv_subset_supports (rps, "zvfbfmin");
2518+
case INSN_CLASS_ZVFBFWMA:
2519+
return riscv_subset_supports (rps, "zvfbfwma");
25162520
case INSN_CLASS_ZVKG:
25172521
return riscv_subset_supports (rps, "zvkg");
25182522
case INSN_CLASS_ZVKNED:
@@ -2735,6 +2739,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27352739
return _("zvbb");
27362740
case INSN_CLASS_ZVFBFMIN:
27372741
return "zvfbfmin";
2742+
case INSN_CLASS_ZVFBFWMA:
2743+
return "zvfbfwma";
27382744
case INSN_CLASS_ZVBC:
27392745
return _("zvbc");
27402746
case INSN_CLASS_ZVKG:

gas/testsuite/gas/riscv/zvfbfwma.d

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#as: -march=rv32i_zvfbfwma
2+
#objdump: -d
3+
4+
.*:[ ]+file format .*
5+
6+
Disassembly of section .text:
7+
8+
0+000 <target>:
9+
[ ]+[0-9a-f]+:[ ]+ee861257[ ]+vfwmaccbf16.vv[ ]+v4,v8,v12
10+
[ ]+[0-9a-f]+:[ ]+ee865257[ ]+vfwmaccbf16.vf[ ]+v4,v8,fa2
11+
[ ]+[0-9a-f]+:[ ]+ec861257[ ]+vfwmaccbf16.vv[ ]+v4,v8,v12,v0.t
12+
[ ]+[0-9a-f]+:[ ]+ec865257[ ]+vfwmaccbf16.vf[ ]+v4,v8,fa2,v0.t

gas/testsuite/gas/riscv/zvfbfwma.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target:
2+
vfwmaccbf16.vv v4, v8, v12
3+
vfwmaccbf16.vf v4, v8, fa2
4+
vfwmaccbf16.vv v4, v8, v12, v0.t
5+
vfwmaccbf16.vf v4, v8, fa2, v0.t

include/opcode/riscv-opc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,11 @@
21732173
#define MASK_VFNCVTBF16_F_F_W 0xfc0ff07f
21742174
#define MATCH_VFWCVTBF16_F_F_V 0x48069057
21752175
#define MASK_VFWCVTBF16_F_F_V 0xfc0ff07f
2176+
/* Zvfbfwma instructions. */
2177+
#define MATCH_VFWMACCBF16_VF 0xec005057
2178+
#define MASK_VFWMACCBF16_VF 0xfc00707f
2179+
#define MATCH_VFWMACCBF16_VV 0xec001057
2180+
#define MASK_VFWMACCBF16_VV 0xfc00707f
21762181
/* Zvkg instructions. */
21772182
#define MATCH_VGHSH_VV 0xb2002077
21782183
#define MASK_VGHSH_VV 0xfe00707f
@@ -3382,6 +3387,9 @@ DECLARE_INSN(vclmulh_vx, MATCH_VCLMULH_VX, MASK_VCLMULH_VX)
33823387
/* Zvfbfmin instructions. */
33833388
DECLARE_INSN(vfncvtbf16_f_f_w, MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W)
33843389
DECLARE_INSN(vfwcvtbf16_f_f_v, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V)
3390+
/* Zvfbfwma instructions. */
3391+
DECLARE_INSN(vfwmaccbf16_vf, MATCH_VFWMACCBF16_VF, MASK_VFWMACCBF16_VF)
3392+
DECLARE_INSN(vfwmaccbf16_vv, MATCH_VFWMACCBF16_VV, MASK_VFWMACCBF16_VV)
33853393
/* Zvkg instructions. */
33863394
DECLARE_INSN(vghsh_vv, MATCH_VGHSH_VV, MASK_VGHSH_VV)
33873395
DECLARE_INSN(vgmul_vv, MATCH_VGMUL_VV, MASK_VGMUL_VV)

include/opcode/riscv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ enum riscv_insn_class
428428
INSN_CLASS_ZVBB,
429429
INSN_CLASS_ZVBC,
430430
INSN_CLASS_ZVFBFMIN,
431+
INSN_CLASS_ZVFBFWMA,
431432
INSN_CLASS_ZVKG,
432433
INSN_CLASS_ZVKNED,
433434
INSN_CLASS_ZVKNHA_OR_ZVKNHB,

opcodes/riscv-opc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,10 @@ const struct riscv_opcode riscv_opcodes[] =
19301930
{"vfncvtbf16.f.f.w", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W, match_opcode, 0},
19311931
{"vfwcvtbf16.f.f.v", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V, match_opcode, 0},
19321932

1933+
/* Zvfbfwma instructions. */
1934+
{"vfwmaccbf16.vv", 0, INSN_CLASS_ZVFBFWMA, "Vd,Vt,VsVm", MATCH_VFWMACCBF16_VV, MASK_VFWMACCBF16_VV, match_opcode, 0},
1935+
{"vfwmaccbf16.vf", 0, INSN_CLASS_ZVFBFWMA, "Vd,Vt,SVm", MATCH_VFWMACCBF16_VF, MASK_VFWMACCBF16_VF, match_opcode, 0},
1936+
19331937
/* Zvkg instructions. */
19341938
{"vghsh.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt,Vs", MATCH_VGHSH_VV, MASK_VGHSH_VV, match_opcode, 0},
19351939
{"vgmul.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt", MATCH_VGMUL_VV, MASK_VGMUL_VV, match_opcode, 0},

0 commit comments

Comments
 (0)