[PATCH] RISC-V: Checking 'm' extension when using RVV.
Christoph Müllner
christoph.muellner@vrull.eu
Wed Jan 22 01:18:06 GMT 2025
On Wed, Jan 22, 2025 at 2:11 AM Jiawei <jiawei@iscas.ac.cn> wrote:
>
>
> 在 2025/1/21 23:55, Christoph Müllner 写道:
> > On Tue, Jan 21, 2025 at 4:23 PM Jiawei <jiawei@iscas.ac.cn> wrote:
> >> This patch add a new extension check when using `v` extension, it
> >> currently should also enable `m` extension to make sure vector length
> >> caculate correct.
> > How to trigger this incorrect calculation?
> > Is there an example?
>
> I found this commit in gcc refer to this, please check it:
>
> https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e589ffb6d78881572ddea21df0d9b6c2641d574d;hp=4cbbce045681c234387d8d56376ea179dc869229
This means that GCC's RISC-V vectorizer backend depends on M.
However, the V extension does not.
And it is possible to write valid assembly files that include V
instructions but no M instructions.
So, if GCC needs M, then it is reasonable that GCC requests M to be enabled.
However, this is independent of Binutils.
>
>
> BR,
>
> Jiawei
>
> >> bfd/ChangeLog:
> >>
> >> * elfxx-riscv.c (riscv_parse_check_conflicts): New check.
> >>
> >> gas/ChangeLog:
> >>
> >> * testsuite/gas/riscv/march-fail-rv64i_v.d: New test.
> >> * testsuite/gas/riscv/march-fail-rv64i_v.l: New test.
> >>
> >> ---
> >> bfd/elfxx-riscv.c | 10 +++++++++-
> >> gas/testsuite/gas/riscv/march-fail-rv64i_v.d | 4 ++++
> >> gas/testsuite/gas/riscv/march-fail-rv64i_v.l | 3 +++
> >> 3 files changed, 16 insertions(+), 1 deletion(-)
> >> create mode 100644 gas/testsuite/gas/riscv/march-fail-rv64i_v.d
> >> create mode 100644 gas/testsuite/gas/riscv/march-fail-rv64i_v.l
> >>
> >> diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
> >> index c9e4b03b17d..150838d3d24 100644
> >> --- a/bfd/elfxx-riscv.c
> >> +++ b/bfd/elfxx-riscv.c
> >> @@ -2123,7 +2123,15 @@ riscv_parse_check_conflicts (riscv_parse_subset_t *rps)
> >> (_("`xtheadvector' is conflict with the `v' extension"));
> >> no_conflict = false;
> >> }
> >> -
> >> + /* We might use a multiplication to calculate the scalable vector length at
> >> + runtime. Therefore, require the M extension. */
> >> + if (riscv_lookup_subset (rps->subset_list, "v", &subset)
> >> + && !riscv_lookup_subset (rps->subset_list, "m", &subset))
> >> + {
> >> + rps->error_handler
> >> + (_("Currently the 'v' implementation requires the 'm' extension"));
> >> + no_conflict = false;
> >> + }
> >> bool support_zve = false;
> >> bool support_zvl = false;
> >> riscv_subset_t *s = rps->subset_list->head;
> >> diff --git a/gas/testsuite/gas/riscv/march-fail-rv64i_v.d b/gas/testsuite/gas/riscv/march-fail-rv64i_v.d
> >> new file mode 100644
> >> index 00000000000..4d14bb4f9a9
> >> --- /dev/null
> >> +++ b/gas/testsuite/gas/riscv/march-fail-rv64i_v.d
> >> @@ -0,0 +1,4 @@
> >> +#as: -march=rv64i_v
> >> +#source: empty.s
> >> +#error_output: march-fail-rv64i_v.l
> >> +
> >> diff --git a/gas/testsuite/gas/riscv/march-fail-rv64i_v.l b/gas/testsuite/gas/riscv/march-fail-rv64i_v.l
> >> new file mode 100644
> >> index 00000000000..5386a942ec5
> >> --- /dev/null
> >> +++ b/gas/testsuite/gas/riscv/march-fail-rv64i_v.l
> >> @@ -0,0 +1,3 @@
> >> +Assembler messages:
> >> +Error: Currently the 'v' implementation requires the 'm' extension
> >> +
> >> --
> >> 2.43.0
> >>
>
More information about the Binutils
mailing list