Skip to content

Commit d076022

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 4f3176f commit d076022

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},
@@ -1297,6 +1298,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12971298
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12981299
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12991300
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
1301+
{"zvfbfwma", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
13001302
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13011303
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
13021304
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2533,6 +2535,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25332535
return riscv_subset_supports (rps, "zvbc");
25342536
case INSN_CLASS_ZVFBFMIN:
25352537
return riscv_subset_supports (rps, "zvfbfmin");
2538+
case INSN_CLASS_ZVFBFWMA:
2539+
return riscv_subset_supports (rps, "zvfbfwma");
25362540
case INSN_CLASS_ZVKG:
25372541
return riscv_subset_supports (rps, "zvkg");
25382542
case INSN_CLASS_ZVKNED:
@@ -2779,6 +2783,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27792783
return _("zvbb");
27802784
case INSN_CLASS_ZVFBFMIN:
27812785
return "zvfbfmin";
2786+
case INSN_CLASS_ZVFBFWMA:
2787+
return "zvfbfwma";
27822788
case INSN_CLASS_ZVBC:
27832789
return _("zvbc");
27842790
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
@@ -3411,6 +3416,9 @@ DECLARE_INSN(vclmulh_vx, MATCH_VCLMULH_VX, MASK_VCLMULH_VX)
34113416
/* Zvfbfmin instructions. */
34123417
DECLARE_INSN(vfncvtbf16_f_f_w, MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W)
34133418
DECLARE_INSN(vfwcvtbf16_f_f_v, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V)
3419+
/* Zvfbfwma instructions. */
3420+
DECLARE_INSN(vfwmaccbf16_vf, MATCH_VFWMACCBF16_VF, MASK_VFWMACCBF16_VF)
3421+
DECLARE_INSN(vfwmaccbf16_vv, MATCH_VFWMACCBF16_VV, MASK_VFWMACCBF16_VV)
34143422
/* Zvkg instructions. */
34153423
DECLARE_INSN(vghsh_vv, MATCH_VGHSH_VV, MASK_VGHSH_VV)
34163424
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
@@ -431,6 +431,7 @@ enum riscv_insn_class
431431
INSN_CLASS_ZVBB,
432432
INSN_CLASS_ZVBC,
433433
INSN_CLASS_ZVFBFMIN,
434+
INSN_CLASS_ZVFBFWMA,
434435
INSN_CLASS_ZVKG,
435436
INSN_CLASS_ZVKNED,
436437
INSN_CLASS_ZVKNHA_OR_ZVKNHB,

opcodes/riscv-opc.c

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

1945+
/* Zvfbfwma instructions. */
1946+
{"vfwmaccbf16.vv", 0, INSN_CLASS_ZVFBFWMA, "Vd,Vt,VsVm", MATCH_VFWMACCBF16_VV, MASK_VFWMACCBF16_VV, match_opcode, 0},
1947+
{"vfwmaccbf16.vf", 0, INSN_CLASS_ZVFBFWMA, "Vd,Vt,SVm", MATCH_VFWMACCBF16_VF, MASK_VFWMACCBF16_VF, match_opcode, 0},
1948+
19451949
/* Zvkg instructions. */
19461950
{"vghsh.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt,Vs", MATCH_VGHSH_VV, MASK_VGHSH_VV, match_opcode, 0},
19471951
{"vgmul.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt", MATCH_VGMUL_VV, MASK_VGMUL_VV, match_opcode, 0},

0 commit comments

Comments
 (0)