Skip to content

Commit ada50fd

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 adb7578 commit ada50fd

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},
@@ -1292,6 +1294,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12921294
{"zve64d", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12931295
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12941296
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1297+
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
12951298
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12961299
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12971300
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2508,6 +2511,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25082511
return riscv_subset_supports (rps, "zvbb");
25092512
case INSN_CLASS_ZVBC:
25102513
return riscv_subset_supports (rps, "zvbc");
2514+
case INSN_CLASS_ZVFBFMIN:
2515+
return riscv_subset_supports (rps, "zvfbfmin");
25112516
case INSN_CLASS_ZVKG:
25122517
return riscv_subset_supports (rps, "zvkg");
25132518
case INSN_CLASS_ZVKNED:
@@ -2728,6 +2733,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27282733
return _("v' or `zve64d' or `zve64f' or `zve32f");
27292734
case INSN_CLASS_ZVBB:
27302735
return _("zvbb");
2736+
case INSN_CLASS_ZVFBFMIN:
2737+
return "zvfbfmin";
27312738
case INSN_CLASS_ZVBC:
27322739
return _("zvbc");
27332740
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)