[PATCH v2 1/2] RISC-V: Base for complex extension implications

Nelson Chu nelson@rivosinc.com
Fri May 9 09:55:15 GMT 2025


Thanks, committed with the following zce patch after passing binutils
testsuites of targets elf32/elf64/linux32/linux64 ;)

Nelson

On Fri, May 9, 2025 at 5:34 PM Kito Cheng <kito.cheng@sifive.com> wrote:

> From: Tsukasa OI <research_trasio@irq.a4lg.com>
>
> Thanks to the commit 48558a5e5471 ("RISC-V: Allow nested implications for
> extensions"), we can write complex extension implications in theory.
> However, to actually do that, we need to pass more information to
> check_func.
>
> For example, we want to imply 'Zcf' from 'F' if and only if the 'Zce'
> extension is also enabled and XLEN is 32.  Passing rps is a way to
> enable this.
>
> This commit prepares for such complex extension implications.
>
> bfd/ChangeLog:
>
>         * elfxx-riscv.c (struct riscv_implicit_subset) Move around and
>         change check_func function prototype.
>         (check_implicit_always): New arguments.
>         (check_implicit_for_i): Likewise.
>         (riscv_implicit_subsets): Add comment for this variable.
>         (riscv_parse_add_implicit_subsets): Call check_func with
>         new arguments.
> ---
>  bfd/elfxx-riscv.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
> index 7b4d108db52..780d64523a9 100644
> --- a/bfd/elfxx-riscv.c
> +++ b/bfd/elfxx-riscv.c
> @@ -1145,10 +1145,22 @@ riscv_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED,
>    return bfd_reloc_ok;
>  }
>
> +/* Record all implicit information for the subsets.  */
> +
> +struct riscv_implicit_subset
> +{
> +  const char *ext;
> +  const char *implicit_exts;
> +  /* A function to determine if we need to add the implicit subset.  */
> +  bool (*check_func) (riscv_parse_subset_t *,
> +                     const riscv_subset_t *);
> +};
> +
>  /* Always add implicit extensions for the SUBSET.  */
>
>  static bool
> -check_implicit_always (riscv_subset_t *subset ATTRIBUTE_UNUSED)
> +check_implicit_always (riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
> +                      const riscv_subset_t *subset ATTRIBUTE_UNUSED)
>  {
>    return true;
>  }
> @@ -1156,21 +1168,14 @@ check_implicit_always (riscv_subset_t *subset
> ATTRIBUTE_UNUSED)
>  /* Add implicit extensions only when the version of SUBSET less than
> 2.1.  */
>
>  static bool
> -check_implicit_for_i (riscv_subset_t *subset)
> +check_implicit_for_i (riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
> +                     const riscv_subset_t *subset ATTRIBUTE_UNUSED)
>  {
>    return (subset->major_version < 2
>           || (subset->major_version == 2
>               && subset->minor_version < 1));
>  }
>
> -/* Record all implicit information for the subsets.  */
> -struct riscv_implicit_subset
> -{
> -  const char *ext;
> -  const char *implicit_exts;
> -  /* A function to determine if we need to add the implicit subsets.  */
> -  bool (*check_func) (riscv_subset_t *);
> -};
>  /* Please added in order since this table is only run once time.  */
>  static struct riscv_implicit_subset riscv_implicit_subsets[] =
>  {
> @@ -2086,7 +2091,7 @@ riscv_parse_add_implicit_subsets
> (riscv_parse_subset_t *rps)
>      {
>        riscv_subset_t *subset = NULL;
>        if (riscv_lookup_subset (rps->subset_list, t->ext, &subset)
> -       && t->check_func (subset))
> +       && t->check_func (rps, subset))
>        riscv_update_subset1 (rps, subset, t->implicit_exts);
>      }
>  }
> --
> 2.34.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250509/43a45c4c/attachment.htm>


More information about the Binutils mailing list