* [committed] RISC-V: Handle implied extension in multilib-generator
@ 2020-10-16 8:54 Kito Cheng
0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2020-10-16 8:54 UTC (permalink / raw)
To: gcc-patches, kito.cheng; +Cc: Kito Cheng
- -march has handle implied extension for a while, so I think
multilib-generator should handle this well too.
- Currently only add rule for D imply F.
gcc/ChangeLog:
* config/riscv/multilib-generator (IMPLIED_EXT): New.
(arch_canonicalize): Update comment and handle implied extensions.
---
gcc/config/riscv/multilib-generator | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/gcc/config/riscv/multilib-generator b/gcc/config/riscv/multilib-generator
index 8f4df183db21..f444d0ebc746 100755
--- a/gcc/config/riscv/multilib-generator
+++ b/gcc/config/riscv/multilib-generator
@@ -38,8 +38,14 @@ reuse = []
canonical_order = "mafdgqlcbjtpvn"
+#
+# IMPLIED_EXT(ext) -> implied extension list.
+#
+IMPLIED_EXT = {
+ "d" : ["f"],
+}
+
def arch_canonicalize(arch):
- # TODO: Support implied extensions, e.g. D implied F in latest spec.
# TODO: Support extension version.
new_arch = ""
if arch[:5] in ['rv32e', 'rv32i', 'rv32g', 'rv64i', 'rv64g']:
@@ -57,14 +63,24 @@ def arch_canonicalize(arch):
if long_ext_prefixes_idx:
first_long_ext_idx = min(long_ext_prefixes_idx)
long_exts = arch[first_long_ext_idx:].split("_")
- std_exts = arch[5:first_long_ext_idx]
+ std_exts = list(arch[5:first_long_ext_idx])
else:
long_exts = []
- std_exts = arch[5:]
+ std_exts = list(arch[5:])
+
+ #
+ # Handle implied extensions.
+ #
+ for ext in std_exts + long_exts:
+ if ext in IMPLIED_EXT:
+ implied_exts = IMPLIED_EXT[ext]
+ for implied_ext in implied_exts:
+ if implied_ext not in std_exts + long_exts:
+ long_exts.append(implied_ext)
# Single letter extension might appear in the long_exts list,
# becasue we just append extensions list to the arch string.
- std_exts += "".join(filter(lambda x:len(x) == 1, long_exts))
+ std_exts += list(filter(lambda x:len(x) == 1, long_exts))
# Multi-letter extension must be in lexicographic order.
long_exts = sorted(filter(lambda x:len(x) != 1, long_exts))
--
2.28.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-16 8:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 8:54 [committed] RISC-V: Handle implied extension in multilib-generator Kito Cheng
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).