Skip to content

Commit 7e0f936

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 2711a42 commit 7e0f936

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},
@@ -1294,6 +1296,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
12941296
{"zve64d", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12951297
{"zvbb", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12961298
{"zvbc", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
1299+
{"zvfbfmin", ISA_SPEC_CLASS_DRAFT, 0, 8, 0 },
12971300
{"zvfh", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12981301
{"zvfhmin", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
12991302
{"zvkg", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -2521,6 +2524,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25212524
return riscv_subset_supports (rps, "zvbb");
25222525
case INSN_CLASS_ZVBC:
25232526
return riscv_subset_supports (rps, "zvbc");
2527+
case INSN_CLASS_ZVFBFMIN:
2528+
return riscv_subset_supports (rps, "zvfbfmin");
25242529
case INSN_CLASS_ZVKG:
25252530
return riscv_subset_supports (rps, "zvkg");
25262531
case INSN_CLASS_ZVKNED:
@@ -2765,6 +2770,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27652770
return _("v' or `zve64d' or `zve64f' or `zve32f");
27662771
case INSN_CLASS_ZVBB:
27672772
return _("zvbb");
2773+
case INSN_CLASS_ZVFBFMIN:
2774+
return "zvfbfmin";
27682775
case INSN_CLASS_ZVBC:
27692776
return _("zvbc");
27702777
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
@@ -3403,6 +3408,9 @@ DECLARE_INSN(vclmul_vv, MATCH_VCLMUL_VV, MASK_VCLMUL_VV)
34033408
DECLARE_INSN(vclmul_vx, MATCH_VCLMUL_VX, MASK_VCLMUL_VX)
34043409
DECLARE_INSN(vclmulh_vv, MATCH_VCLMULH_VV, MASK_VCLMULH_VV)
34053410
DECLARE_INSN(vclmulh_vx, MATCH_VCLMULH_VX, MASK_VCLMULH_VX)
3411+
/* Zvfbfmin instructions. */
3412+
DECLARE_INSN(vfncvtbf16_f_f_w, MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W)
3413+
DECLARE_INSN(vfwcvtbf16_f_f_v, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V)
34063414
/* Zvkg instructions. */
34073415
DECLARE_INSN(vghsh_vv, MATCH_VGHSH_VV, MASK_VGHSH_VV)
34083416
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
@@ -430,6 +430,7 @@ enum riscv_insn_class
430430
INSN_CLASS_ZVEF,
431431
INSN_CLASS_ZVBB,
432432
INSN_CLASS_ZVBC,
433+
INSN_CLASS_ZVFBFMIN,
433434
INSN_CLASS_ZVKG,
434435
INSN_CLASS_ZVKNED,
435436
INSN_CLASS_ZVKNHA_OR_ZVKNHB,

opcodes/riscv-opc.c

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

1941+
/* Zvfbfmin instructions. */
1942+
{"vfncvtbf16.f.f.w", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W, match_opcode, 0},
1943+
{"vfwcvtbf16.f.f.v", 0, INSN_CLASS_ZVFBFMIN, "Vd,VtVm", MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V, match_opcode, 0},
1944+
19411945
/* Zvkg instructions. */
19421946
{"vghsh.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt,Vs", MATCH_VGHSH_VV, MASK_VGHSH_VV, match_opcode, 0},
19431947
{"vgmul.vv", 0, INSN_CLASS_ZVKG, "Vd,Vt", MATCH_VGMUL_VV, MASK_VGMUL_VV, match_opcode, 0},

0 commit comments

Comments
 (0)