Commit 0a1d6a4c by Kito Cheng

RISC-V: Handle multi-letter extension for multilib-generator

 - The order of multi-lib config could be wrong if multi-ltter are
   used, e.g. `./multilib-generator rv32izfh-ilp32--c`, would expect
   rv32ic_zfh/ilp32 reuse rv32i_zfh/ilp32, however the multi-ltter is not
   handled correctly, it will generate reuse rule for rv32izfhc/ilp32
   which is invalid arch configuration.

 - Remove re-use rule gen for g/imafd, because we canonicalize the -march at
   gcc driver too, so we don't need handle 'g' for multilib now.

gcc/ChangeLog:

	* config/riscv/multilib-generator (arch_canonicalize): Handle
	multi-letter extension.
	Using underline as separator between different extensions.
parent e0a6deae
...@@ -39,12 +39,12 @@ reuse = [] ...@@ -39,12 +39,12 @@ reuse = []
canonical_order = "mafdgqlcbjtpvn" canonical_order = "mafdgqlcbjtpvn"
def arch_canonicalize(arch): def arch_canonicalize(arch):
# TODO: Support Z, S, H, or X extensions.
# TODO: Support implied extensions, e.g. D implied F in latest spec. # TODO: Support implied extensions, e.g. D implied F in latest spec.
# TODO: Support extension version. # TODO: Support extension version.
new_arch = "" new_arch = ""
if arch[:5] in ['rv32e', 'rv32i', 'rv32g', 'rv64i', 'rv64g']: if arch[:5] in ['rv32e', 'rv32i', 'rv32g', 'rv64i', 'rv64g']:
new_arch = arch[:5] # TODO: We should expand g to imadzifencei once we support newer spec.
new_arch = arch[:5].replace("g", "imafd")
else: else:
raise Exception("Unexpected arch: `%s`" % arch[:5]) raise Exception("Unexpected arch: `%s`" % arch[:5])
...@@ -56,30 +56,44 @@ def arch_canonicalize(arch): ...@@ -56,30 +56,44 @@ def arch_canonicalize(arch):
long_ext_prefixes_idx = list(filter(lambda x: x != -1, long_ext_prefixes_idx)) long_ext_prefixes_idx = list(filter(lambda x: x != -1, long_ext_prefixes_idx))
if long_ext_prefixes_idx: if long_ext_prefixes_idx:
first_long_ext_idx = min(long_ext_prefixes_idx) first_long_ext_idx = min(long_ext_prefixes_idx)
long_exts = arch[first_long_ext_idx:] long_exts = arch[first_long_ext_idx:].split("_")
std_exts = arch[5:first_long_ext_idx] std_exts = arch[5:first_long_ext_idx]
else: else:
long_exts = "" long_exts = []
std_exts = arch[5:] std_exts = arch[5:]
# 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))
# Multi-letter extension must be in lexicographic order.
long_exts = sorted(filter(lambda x:len(x) != 1, long_exts))
# Put extensions in canonical order. # Put extensions in canonical order.
for ext in canonical_order: for ext in canonical_order:
if ext in std_exts: if ext in std_exts:
new_arch += ext new_arch += ext
# Check every extension is processed.
for ext in std_exts:
if ext == '_':
continue
if ext not in canonical_order:
raise Exception("Unsupported extension `%s`" % ext)
# Concat rest of the multi-char extensions. # Concat rest of the multi-char extensions.
new_arch += long_exts if long_exts:
new_arch += "_" + "_".join(long_exts)
return new_arch return new_arch
for cfg in sys.argv[1:]: for cfg in sys.argv[1:]:
(arch, abi, extra, ext) = cfg.split('-') (arch, abi, extra, ext) = cfg.split('-')
arch = arch_canonicalize (arch)
arches[arch] = 1 arches[arch] = 1
abis[abi] = 1 abis[abi] = 1
extra = list(filter(None, extra.split(','))) extra = list(filter(None, extra.split(',')))
ext = list(filter(None, ext.split(','))) ext = list(filter(None, ext.split(',')))
alts = sum([[x] + [x + y for y in ext] for x in [arch] + extra], []) alts = sum([[x] + [x + "_" + y for y in ext] for x in [arch] + extra], [])
# TODO: We should expand g to imadzifencei once we support newer spec.
alts = alts + [x.replace('imafd', 'g') for x in alts if 'imafd' in x]
alts = list(map(arch_canonicalize, alts)) alts = list(map(arch_canonicalize, alts))
for alt in alts[1:]: for alt in alts[1:]:
arches[alt] = 1 arches[alt] = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment