Limit multilib-gen-gen to more-useful ISA combinations

This commit is contained in:
Luke Wren 2023-11-30 05:32:39 +00:00
parent e8b4578b40
commit d4212f8976
1 changed files with 37 additions and 12 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Generate a multilib configure line for riscv-gnu-toolchain with all # Generate a multilib configure line for riscv-gnu-toolchain with all useful
# combinations of extensions supported by both Hazard3 and mainline GCC # combinations of extensions supported by both Hazard3 and mainline GCC
# (currently GCC 13.2). Use as: # (currently GCC 13.2). Use as:
# ./configure ... --with-multilib-generator="$(path/to/multilib-gen-gen.py)" # ./configure ... --with-multilib-generator="$(path/to/multilib-gen-gen.py)"
@ -11,21 +11,46 @@ options = [
"m", "m",
"a", "a",
"c", "c",
"_zicsr", "zicsr",
"_zifencei", "zifencei",
"_zba", "zba",
"_zbb", "zbb",
"_zbc", "zbc",
"_zbs", "zbs",
"_zbkb" "zbkb"
] ]
# The relationship here is: do not build for LHS except when *all of* RHS is
# also present. This cuts down on the number of configurations whilst
# hopefully preserving ones that are useful for Hazard3 development.
depends_on = {
"zbb": ["m" ],
"zba": ["m" ],
"zbkb": ["zbb" ],
"zbs": ["zbb", ],
"zbc": ["zba", "zbb", "zbs"],
"zifencei": ["zicsr" ],
}
l = [] l = []
for i in range(2 ** len(options)): for i in range(2 ** len(options)):
isa = base isa = base
for j in range(len(options)): violates_dependencies = False
if i & (1 << j): for j in (j for j in range(len(options)) if i & (1 << j)):
isa += options[j] opt = options[j]
l.append(isa + abi) if opt in depends_on:
for dep in depends_on[opt]:
if not (i & (1 << options.index(dep))):
violates_dependencies = True
break
if violates_dependencies:
break
if len(opt) > 1:
isa += "_"
isa += opt
if not violates_dependencies:
l.append(isa + abi)
assert((base + abi) in l)
print(";".join(l)) print(";".join(l))