From ddc654da1a84c698199ccfc2019865b57ad59582 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 9 May 2025 17:34:48 +0800 Subject: [PATCH] RISC-V: Base for complex extension implications 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/elfxx-riscv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 83e237c2a03..bbadf22d694 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -1148,7 +1148,8 @@ riscv_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED, /* 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,7 +1157,8 @@ 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 @@ -1169,7 +1171,8 @@ 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 *); + bool (*check_func) (riscv_parse_subset_t *, + const riscv_subset_t *); }; /* Please added in order since this table is only run once time. */ static struct riscv_implicit_subset riscv_implicit_subsets[] = @@ -2083,7 +2086,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.47.3