comparison gcc/config/riscv/multilib-generator @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # RISC-V multilib list generator. 3 # RISC-V multilib list generator.
4 # Copyright (C) 2011-2018 Free Software Foundation, Inc. 4 # Copyright (C) 2011-2020 Free Software Foundation, Inc.
5 # Contributed by Andrew Waterman (andrew@sifive.com). 5 # Contributed by Andrew Waterman (andrew@sifive.com).
6 # 6 #
7 # This file is part of GCC. 7 # This file is part of GCC.
8 # 8 #
9 # GCC is free software; you can redistribute it and/or modify 9 # GCC is free software; you can redistribute it and/or modify
34 arches = collections.OrderedDict() 34 arches = collections.OrderedDict()
35 abis = collections.OrderedDict() 35 abis = collections.OrderedDict()
36 required = [] 36 required = []
37 reuse = [] 37 reuse = []
38 38
39 canonical_order = "mafdgqlcbjtpvn"
40
41 def arch_canonicalize(arch):
42 # TODO: Support Z, S, H, or X extensions.
43 # TODO: Support implied extensions, e.g. D implied F in latest spec.
44 # TODO: Support extension version.
45 new_arch = ""
46 if arch[:5] in ['rv32e', 'rv32i', 'rv32g', 'rv64i', 'rv64g']:
47 new_arch = arch[:5]
48 else:
49 raise Exception("Unexpected arch: `%s`" % arch[:5])
50
51 # Find any Z, S, H or X
52 long_ext_prefixes = ['z', 's', 'h', 'x']
53 long_ext_prefixes_idx = map(lambda x: arch.find(x), long_ext_prefixes)
54
55 # Filter out any non-existent index.
56 long_ext_prefixes_idx = list(filter(lambda x: x != -1, long_ext_prefixes_idx))
57 if long_ext_prefixes_idx:
58 first_long_ext_idx = min(long_ext_prefixes_idx)
59 long_exts = arch[first_long_ext_idx:]
60 std_exts = arch[5:first_long_ext_idx]
61 else:
62 long_exts = ""
63 std_exts = arch[5:]
64
65 # Put extensions in canonical order.
66 for ext in canonical_order:
67 if ext in std_exts:
68 new_arch += ext
69
70 # Concat rest of the multi-char extensions.
71 new_arch += long_exts
72 return new_arch
73
39 for cfg in sys.argv[1:]: 74 for cfg in sys.argv[1:]:
40 (arch, abi, extra, ext) = cfg.split('-') 75 (arch, abi, extra, ext) = cfg.split('-')
41 arches[arch] = 1 76 arches[arch] = 1
42 abis[abi] = 1 77 abis[abi] = 1
43 extra = list(filter(None, extra.split(','))) 78 extra = list(filter(None, extra.split(',')))
44 ext = list(filter(None, ext.split(','))) 79 ext = list(filter(None, ext.split(',')))
45 alts = sum([[x] + [x + y for y in ext] for x in [arch] + extra], []) 80 alts = sum([[x] + [x + y for y in ext] for x in [arch] + extra], [])
81 # TODO: We should expand g to imadzifencei once we support newer spec.
46 alts = alts + [x.replace('imafd', 'g') for x in alts if 'imafd' in x] 82 alts = alts + [x.replace('imafd', 'g') for x in alts if 'imafd' in x]
83 alts = list(map(arch_canonicalize, alts))
47 for alt in alts[1:]: 84 for alt in alts[1:]:
48 arches[alt] = 1 85 arches[alt] = 1
49 reuse.append('march.%s/mabi.%s=march.%s/mabi.%s' % (arch, abi, alt, abi)) 86 reuse.append('march.%s/mabi.%s=march.%s/mabi.%s' % (arch, abi, alt, abi))
50 required.append('march=%s/mabi=%s' % (arch, abi)) 87 required.append('march=%s/mabi=%s' % (arch, abi))
51 88