From 4a70aa7a627c0b918ce1da75c0dbe088539e420f Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Fri, 16 Oct 2020 16:36:45 +0800 Subject: [PATCH] RISC-V: Handle implied extension in multilib-generator - -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 8f4df183db2..f444d0ebc74 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.30.2