Skip to content

Commit 71c5b10

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 24e0f41 commit 71c5b10

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},
@@ -1294,6 +1295,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12941295
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12951296
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12961297
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
1298+
{"zvfbfwma", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
12971299
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12981300
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12991301
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2512,6 +2514,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25122514
return riscv_subset_supports (rps, "zvbc");
25132515
case INSN_CLASS_ZVFBFMIN:
25142516
return riscv_subset_supports (rps, "zvfbfmin");
2517+
case INSN_CLASS_ZVFBFWMA:
2518+
return riscv_subset_supports (rps, "zvfbfwma");
25152519
case INSN_CLASS_ZVKG:
25162520
return riscv_subset_supports (rps, "zvkg");
25172521
case INSN_CLASS_ZVKNED:
@@ -2734,6 +2738,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27342738
return _("zvbb");
27352739
case INSN_CLASS_ZVFBFMIN:
27362740
return "zvfbfmin";
2741+
case INSN_CLASS_ZVFBFWMA:
2742+
return "zvfbfwma";
27372743
case INSN_CLASS_ZVBC:
27382744
return _("zvbc");
27392745
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)