Skip to content

Commit 239af8c

Browse files
committed
RISC-V: Make "fli.h" available to 'Zvfh' + 'Zfa'
The documentation of the 'Zfa' extension states that "fli.h" is available "if the Zfh or Zvfh extension is implemented" (both the latest and the oldest editions are checked). This fact was not reflected in Binutils ('Zvfh' implies 'Zfhmin', not full 'Zfh' extension and "fli.h" required 'Zfh' and 'Zfa' extensions). This commit makes "fli.h" also available when both 'Zfa' and 'Zvfh' extensions are implemented. bfd/ChangeLog: * elfxx-riscv.c (riscv_multi_subset_supports): Add new instruction class handling. (riscv_multi_subset_supports_ext): Likewise. gas/ChangeLog: * testsuite/gas/riscv/zfa-zvfh.s: New test. * testsuite/gas/riscv/zfa-zvfh.d: Ditto. include/ChangeLog: * opcode/riscv.h (enum riscv_insn_class): Add new instruction class. opcodes/ChangeLog: * riscv-opc.c (riscv_opcodes): Change instruction class of "fli.h" from INSN_CLASS_ZFH_AND_ZFA to new INSN_CLASS_ZFH_OR_ZVFH_AND_ZFA.
1 parent 2266f86 commit 239af8c

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

bfd/elfxx-riscv.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,10 @@ riscv_multi_subset_supports (riscv_parse_subset_t *rps,
24632463
case INSN_CLASS_ZFH_AND_ZFA:
24642464
return riscv_subset_supports (rps, "zfh")
24652465
&& riscv_subset_supports (rps, "zfa");
2466+
case INSN_CLASS_ZFH_OR_ZVFH_AND_ZFA:
2467+
return (riscv_subset_supports (rps, "zfh")
2468+
|| riscv_subset_supports (rps, "zvfh"))
2469+
&& riscv_subset_supports (rps, "zfa");
24662470
case INSN_CLASS_ZBA:
24672471
return riscv_subset_supports (rps, "zba");
24682472
case INSN_CLASS_ZBB:
@@ -2704,6 +2708,17 @@ riscv_multi_subset_supports_ext (riscv_parse_subset_t *rps,
27042708
return "zfh";
27052709
else
27062710
return "zfa";
2711+
case INSN_CLASS_ZFH_OR_ZVFH_AND_ZFA:
2712+
if (!riscv_subset_supports (rps, "zfa"))
2713+
{
2714+
if (!riscv_subset_supports (rps, "zfh")
2715+
&& !riscv_subset_supports (rps, "zvfh"))
2716+
return _("zfh' and `zfa', or `zvfh' and `zfa");
2717+
else
2718+
return "zfa";
2719+
}
2720+
else
2721+
return _("zfh' or `zvfh");
27072722
case INSN_CLASS_ZBA:
27082723
return "zba";
27092724
case INSN_CLASS_ZBB:

gas/testsuite/gas/riscv/zfa-zvfh.d

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#as: -march=rv32iq_zfa_zvfh
2+
#objdump: -d
3+
4+
.*:[ ]+file format .*
5+
6+
Disassembly of section .text:
7+
8+
0+000 <target>:
9+
[ ]+[0-9a-f]+:[ ]+f41c00d3[ ]+fli\.h[ ]+ft1,0x1p\+3
10+
[ ]+[0-9a-f]+:[ ]+f41c80d3[ ]+fli\.h[ ]+ft1,0x1p\+4
11+
[ ]+[0-9a-f]+:[ ]+f41d00d3[ ]+fli\.h[ ]+ft1,0x1p\+7
12+
[ ]+[0-9a-f]+:[ ]+f41d80d3[ ]+fli\.h[ ]+ft1,0x1p\+8
13+
[ ]+[0-9a-f]+:[ ]+f41e00d3[ ]+fli\.h[ ]+ft1,0x1p\+15
14+
[ ]+[0-9a-f]+:[ ]+f41e80d3[ ]+fli\.h[ ]+ft1,0x1p\+16
15+
[ ]+[0-9a-f]+:[ ]+f41f00d3[ ]+fli\.h[ ]+ft1,inf
16+
[ ]+[0-9a-f]+:[ ]+f41f80d3[ ]+fli\.h[ ]+ft1,nan

gas/testsuite/gas/riscv/zfa-zvfh.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
target:
2+
# fli.h is available on (('Zfh' || 'Zvfh') && 'Zfa')
3+
fli.h ft1, 8.0
4+
fli.h ft1, 0x1p4
5+
fli.h ft1, 128.0
6+
fli.h ft1, 0x1p8
7+
fli.h ft1, 32768.0
8+
fli.h ft1, 0x1p16
9+
fli.h ft1, inf
10+
fli.h ft1, nan

include/opcode/riscv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ enum riscv_insn_class
409409
INSN_CLASS_D_AND_ZFA,
410410
INSN_CLASS_Q_AND_ZFA,
411411
INSN_CLASS_ZFH_AND_ZFA,
412+
INSN_CLASS_ZFH_OR_ZVFH_AND_ZFA,
412413
INSN_CLASS_ZBA,
413414
INSN_CLASS_ZBB,
414415
INSN_CLASS_ZBC,

opcodes/riscv-opc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ const struct riscv_opcode riscv_opcodes[] =
990990
{"fli.s", 0, INSN_CLASS_ZFA, "D,Wfv", MATCH_FLI_S, MASK_FLI_S, match_opcode, 0 },
991991
{"fli.d", 0, INSN_CLASS_D_AND_ZFA, "D,Wfv", MATCH_FLI_D, MASK_FLI_D, match_opcode, 0 },
992992
{"fli.q", 0, INSN_CLASS_Q_AND_ZFA, "D,Wfv", MATCH_FLI_Q, MASK_FLI_Q, match_opcode, 0 },
993-
{"fli.h", 0, INSN_CLASS_ZFH_AND_ZFA, "D,Wfv", MATCH_FLI_H, MASK_FLI_H, match_opcode, 0 },
993+
{"fli.h", 0, INSN_CLASS_ZFH_OR_ZVFH_AND_ZFA, "D,Wfv", MATCH_FLI_H, MASK_FLI_H, match_opcode, 0 },
994994
{"fminm.s", 0, INSN_CLASS_ZFA, "D,S,T", MATCH_FMINM_S, MASK_FMINM_S, match_opcode, 0 },
995995
{"fmaxm.s", 0, INSN_CLASS_ZFA, "D,S,T", MATCH_FMAXM_S, MASK_FMAXM_S, match_opcode, 0 },
996996
{"fminm.d", 0, INSN_CLASS_D_AND_ZFA, "D,S,T", MATCH_FMINM_D, MASK_FMINM_D, match_opcode, 0 },

0 commit comments

Comments
 (0)