Skip to content

Commit 24e0f41

Browse files
committed
UNRATIFIED RISC-V: Add 'Zvfbfmin' 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 'Zvfbfmin' extension, the vector BF16 conversion only extension, consisting of two narrowing / widening conversion instructions between BF16 and FP32. This commit is based on the following specification: <riscv/riscv-bfloat16@5578e34> bfd/ChangeLog: * elfxx-riscv.c (riscv_implicit_subsets) Add implications 'Zvfbfmin' -> 'Zfbfmin' and 'Zve32f'. (riscv_supported_std_z_ext): Add 'Zvfbfmin'. (riscv_multi_subset_supports): Add support to INSN_CLASS_ZVFBFMIN. (riscv_multi_subset_supports_ext): Likewise. gas/ChangeLog: * testsuite/gas/riscv/zvfbfmin.s: New test. * testsuite/gas/riscv/zvfbfmin.d: Likewise. include/ChangeLog: * opcode/riscv-opc.h (MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V) New. * opcode/riscv.h (enum riscv_insn_class): Add new instruction class INSN_CLASS_ZVFBFMIN. opcodes/ChangeLog: * riscv-opc.c (riscv_opcodes): Add 'Zvfbfmin' instructions.
1 parent 4b7ed53 commit 24e0f41

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

bfd/elfxx-riscv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ 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+
{"zvfbfmin", "zfbfmin", check_implicit_always},
1114+
{"zvfbfmin", "zve32f", check_implicit_always},
11131115
{"zvfh", "zvfhmin", check_implicit_always},
11141116
{"zvfh", "zfhmin", check_implicit_always},
11151117
{"zvfhmin", "zve32f", check_implicit_always},
@@ -1291,6 +1293,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12911293
{"zve64d", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12921294
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12931295
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1296+
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
12941297
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12951298
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12961299
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2507,6 +2510,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25072510
return riscv_subset_supports (rps, "zvbb");
25082511
case INSN_CLASS_ZVBC:
25092512
return riscv_subset_supports (rps, "zvbc");
2513+
case INSN_CLASS_ZVFBFMIN:
2514+
return riscv_subset_supports (rps, "zvfbfmin");
25102515
case INSN_CLASS_ZVKG:
25112516
return riscv_subset_supports (rps, "zvkg");
25122517
case INSN_CLASS_ZVKNED:
@@ -2727,6 +2732,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27272732
return _("v' or `zve64d' or `zve64f' or `zve32f");
27282733
case INSN_CLASS_ZVBB:
27292734
return _("zvbb");
2735+
case INSN_CLASS_ZVFBFMIN:
2736+
return "zvfbfmin";
27302737
case INSN_CLASS_ZVBC:
27312738
return _("zvbc");
27322739
case INSN_CLASS_ZVKG:

gas/testsuite/gas/riscv/zvfbfmin.d

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#as: -march=rv32i_zvfbfmin
2+
#objdump: -d
3+
4+
.*:[ ]+file format .*
5+
6+
Disassembly of section .text:
7+
8+
0+000 <target>:
9+
[ ]+[0-9a-f]+:[ ]+4a8e9257[ ]+vfncvtbf16\.f\.f\.w[ ]+v4,v8
10+
[ ]+[0-9a-f]+:[ ]+488e9257[ ]+vfncvtbf16\.f\.f\.w[ ]+v4,v8,v0\.t
11+
[ ]+[0-9a-f]+:[ ]+4a869257[ ]+vfwcvtbf16\.f\.f\.v[ ]+v4,v8
12+
[ ]+[0-9a-f]+:[ ]+48869257[ ]+vfwcvtbf16\.f\.f\.v[ ]+v4,v8,v0\.t

gas/testsuite/gas/riscv/zvfbfmin.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target:
2+
vfncvtbf16.f.f.w v4, v8
3+
vfncvtbf16.f.f.w v4, v8, v0.t
4+
vfwcvtbf16.f.f.v v4, v8
5+
vfwcvtbf16.f.f.v v4, v8, v0.t

include/opcode/riscv-opc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,11 @@
21682168
#define MASK_VCLMULH_VV 0xfc00707f
21692169
#define MATCH_VCLMULH_VX 0x34006057
21702170
#define MASK_VCLMULH_VX 0xfc00707f
2171+
/* Zvfbfmin instructions. */
2172+
#define MATCH_VFNCVTBF16_F_F_W 0x480e9057
2173+
#define MASK_VFNCVTBF16_F_F_W 0xfc0ff07f
2174+
#define MATCH_VFWCVTBF16_F_F_V 0x48069057
2175+
#define MASK_VFWCVTBF16_F_F_V 0xfc0ff07f
21712176
/* Zvkg instructions. */
21722177
#define MATCH_VGHSH_VV 0xb2002077
21732178
#define MASK_VGHSH_VV 0xfe00707f
@@ -3374,6 +3379,9 @@ DECLARE_INSN(vclmul_vv, MATCH_VCLMUL_VV, MASK_VCLMUL_VV)
33743379
DECLARE_INSN(vclmul_vx, MATCH_VCLMUL_VX, MASK_VCLMUL_VX)
33753380
DECLARE_INSN(vclmulh_vv, MATCH_VCLMULH_VV, MASK_VCLMULH_VV)
33763381
DECLARE_INSN(vclmulh_vx, MATCH_VCLMULH_VX, MASK_VCLMULH_VX)
3382+
/* Zvfbfmin instructions. */
3383+
DECLARE_INSN(vfncvtbf16_f_f_w, MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W)
3384+
DECLARE_INSN(vfwcvtbf16_f_f_v, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V)
33773385
/* Zvkg instructions. */
33783386
DECLARE_INSN(vghsh_vv, MATCH_VGHSH_VV, MASK_VGHSH_VV)
33793387
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
@@ -427,6 +427,7 @@ enum riscv_insn_class
427427
INSN_CLASS_ZVEF,
428428
INSN_CLASS_ZVBB,
429429
INSN_CLASS_ZVBC,
430+
INSN_CLASS_ZVFBFMIN,
430431
INSN_CLASS_ZVKG,
431432
INSN_CLASS_ZVKNED,
432433
INSN_CLASS_ZVKNHA_OR_ZVKNHB,

opcodes/riscv-opc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,10 @@ const struct riscv_opcode riscv_opcodes[] =
19261926
{"vclmulh.vv", 0, INSN_CLASS_ZVBC, "Vd,Vt,VsVm", MATCH_VCLMULH_VV, MASK_VCLMULH_VV, match_opcode, 0},
19271927
{"vclmulh.vx", 0, INSN_CLASS_ZVBC, "Vd,Vt,sVm", MATCH_VCLMULH_VX, MASK_VCLMULH_VX, match_opcode, 0},
19281928

1929+
/* Zvfbfmin instructions. */
1930+
{"vfncvtbf16.f.f.w", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W, match_opcode, 0},
1931+
{"vfwcvtbf16.f.f.v", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V, match_opcode, 0},
1932+
19291933
/* Zvkg instructions. */
19301934
{"vghsh.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt,Vs", MATCH_VGHSH_VV, MASK_VGHSH_VV, match_opcode, 0},
19311935
{"vgmul.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt", MATCH_VGMUL_VV, MASK_VGMUL_VV, match_opcode, 0},

0 commit comments

Comments
 (0)