Skip to content

Commit f44be17

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 6470808 commit f44be17

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 },
@@ -2518,6 +2521,8 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
25182521
return riscv_subset_supports (rps, "zvbb");
25192522
case INSN_CLASS_ZVBC:
25202523
return riscv_subset_supports (rps, "zvbc");
2524+
case INSN_CLASS_ZVFBFMIN:
2525+
return riscv_subset_supports (rps, "zvfbfmin");
25212526
case INSN_CLASS_ZVKG:
25222527
return riscv_subset_supports (rps, "zvkg");
25232528
case INSN_CLASS_ZVKNED:
@@ -2762,6 +2767,8 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27622767
return _("v' or `zve64d' or `zve64f' or `zve32f");
27632768
case INSN_CLASS_ZVBB:
27642769
return _("zvbb");
2770+
case INSN_CLASS_ZVFBFMIN:
2771+
return "zvfbfmin";
27652772
case INSN_CLASS_ZVBC:
27662773
return _("zvbc");
27672774
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
@@ -3400,6 +3405,9 @@ DECLARE_INSN(vclmul_vv, MATCH_VCLMUL_VV, MASK_VCLMUL_VV)
34003405
DECLARE_INSN(vclmul_vx, MATCH_VCLMUL_VX, MASK_VCLMUL_VX)
34013406
DECLARE_INSN(vclmulh_vv, MATCH_VCLMULH_VV, MASK_VCLMULH_VV)
34023407
DECLARE_INSN(vclmulh_vx, MATCH_VCLMULH_VX, MASK_VCLMULH_VX)
3408+
/* Zvfbfmin instructions. */
3409+
DECLARE_INSN(vfncvtbf16_f_f_w, MATCH_VFNCVTBF16_F_F_W, MASK_VFNCVTBF16_F_F_W)
3410+
DECLARE_INSN(vfwcvtbf16_f_f_v, MATCH_VFWCVTBF16_F_F_V, MASK_VFWCVTBF16_F_F_V)
34033411
/* Zvkg instructions. */
34043412
DECLARE_INSN(vghsh_vv, MATCH_VGHSH_VV, MASK_VGHSH_VV)
34053413
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)