From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Andrew Waterman <andrew@sifive.com>,
Jim Wilson <jim.wilson.gcc@gmail.com>,
Nelson Chu <nelson@rivosinc.com>,
Kito Cheng <kito.cheng@sifive.com>, Jiawei <jiawei@iscas.ac.cn>
Cc: binutils@sourceware.org
Subject: [REVIEW ONLY 1/3] RISC-V: Base for complex extension implications
Date: Sat, 29 Jul 2023 01:56:18 +0000 [thread overview]
Message-ID: <b1e711cc7648773cc6bd10f61cffde79f54963b7.1690595772.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1690595772.git.research_trasio@irq.a4lg.com>
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 | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index ba5165766b2b..06ac521bdf27 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -1064,11 +1064,25 @@ riscv_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED,
return bfd_reloc_ok;
}
+/* Record all implicit information for the subsets. */
+
+typedef struct riscv_implicit_subset
+{
+ const char *subset_name;
+ const char *implicit_name;
+ /* A function to determine if we need to add the implicit subset. */
+ bool (*check_func) (const riscv_parse_subset_t *,
+ const struct riscv_implicit_subset *,
+ const riscv_subset_t *);
+} riscv_implicit_subset_t;
+
/* Always add the IMPLICIT for the SUBSET. */
static bool
-check_implicit_always (const char *implicit ATTRIBUTE_UNUSED,
- riscv_subset_t *subset ATTRIBUTE_UNUSED)
+check_implicit_always (const riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
+ const riscv_implicit_subset_t *implicit
+ ATTRIBUTE_UNUSED,
+ const riscv_subset_t *subset ATTRIBUTE_UNUSED)
{
return true;
}
@@ -1076,23 +1090,18 @@ check_implicit_always (const char *implicit ATTRIBUTE_UNUSED,
/* Add the IMPLICIT only when the version of SUBSET less than 2.1. */
static bool
-check_implicit_for_i (const char *implicit ATTRIBUTE_UNUSED,
- riscv_subset_t *subset)
+check_implicit_for_i (const riscv_parse_subset_t *rps ATTRIBUTE_UNUSED,
+ const riscv_implicit_subset_t *implicit ATTRIBUTE_UNUSED,
+ const riscv_subset_t *subset)
{
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 *subset_name;
- const char *implicit_name;
- /* A function to determine if we need to add the implicit subset. */
- bool (*check_func) (const char *, riscv_subset_t *);
-};
-static struct riscv_implicit_subset riscv_implicit_subsets[] =
+/* All extension implications. */
+
+static riscv_implicit_subset_t riscv_implicit_subsets[] =
{
{"e", "i", check_implicit_always},
{"i", "zicsr", check_implicit_for_i},
@@ -1900,7 +1909,7 @@ riscv_parse_extensions (riscv_parse_subset_t *rps,
static void
riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
{
- struct riscv_implicit_subset *t = riscv_implicit_subsets;
+ riscv_implicit_subset_t *t = riscv_implicit_subsets;
bool finished = false;
while (!finished)
{
@@ -1912,7 +1921,7 @@ riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
if (riscv_lookup_subset (rps->subset_list, t->subset_name, &subset)
&& !riscv_lookup_subset (rps->subset_list, t->implicit_name,
&implicit_subset)
- && t->check_func (t->implicit_name, subset))
+ && t->check_func (rps, t, subset))
{
riscv_parse_add_subset (rps, t->implicit_name,
RISCV_UNKNOWN_VERSION,
--
2.41.0
next prev parent reply other threads:[~2023-07-29 1:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 1:56 [REVIEW ONLY 0/3] RISC-V: MOCK: Add 'Zce' extension support Tsukasa OI
2023-07-29 1:56 ` Tsukasa OI [this message]
2023-07-29 1:56 ` [REVIEW ONLY 2/3] MOCK: RISC-V: " Tsukasa OI
2023-07-29 1:56 ` [REVIEW ONLY 3/3] MOCK: RISC-V: Tests for 'Zce' implications Tsukasa OI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b1e711cc7648773cc6bd10f61cffde79f54963b7.1690595772.git.research_trasio@irq.a4lg.com \
--to=research_trasio@irq.a4lg.com \
--cc=andrew@sifive.com \
--cc=binutils@sourceware.org \
--cc=jiawei@iscas.ac.cn \
--cc=jim.wilson.gcc@gmail.com \
--cc=kito.cheng@sifive.com \
--cc=nelson@rivosinc.com \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).