[clang] [RISCV] Allow YAML file to control multilib selection (PR #98856)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 09:10:13 PDT 2024
ArcaneNibble wrote:
> Have you, using this patch, managed to reimplement the hardcoded multilib behaviour?
I did some experimenting and managed to implement something very close (especially using the fake flag hack mentioned in the forums):
```yaml
MultilibVersion: 1.0
Groups:
- Name: rv32_group
Type: Exclusive
- Name: rv64_group
Type: Exclusive
Variants:
- Dir: rv32i/ilp32
Flags:
- "--target=riscv32-unknown-none-elf"
- "-mabi=ilp32"
Group: rv32_group
- Dir: rv32im/ilp32
Flags:
- "--target=riscv32-unknown-none-elf"
- "-mabi=ilp32"
- "--XXX-fake-flag-yaml-has-m"
Group: rv32_group
- Dir: rv32iac/ilp32
Flags:
- "--target=riscv32-unknown-none-elf"
- "-mabi=ilp32"
- "--XXX-fake-flag-yaml-has-a"
- "--XXX-fake-flag-yaml-has-c"
Group: rv32_group
- Dir: .
Flags:
- "--target=riscv32-unknown-none-elf"
- "-mabi=ilp32"
- "--XXX-fake-flag-yaml-has-m"
- "--XXX-fake-flag-yaml-has-a"
- "--XXX-fake-flag-yaml-has-c"
Group: rv32_group
- Dir: rv32imafc/ilp32f
Flags:
- "--target=riscv32-unknown-none-elf"
- "-mabi=ilp32f"
- "--XXX-fake-flag-yaml-has-m"
- "--XXX-fake-flag-yaml-has-a"
- "--XXX-fake-flag-yaml-has-f"
- "--XXX-fake-flag-yaml-has-c"
Group: rv32_group
- Dir: .
Flags:
- "--target=riscv64-unknown-none-elf"
- "-mabi=lp64"
- "--XXX-fake-flag-yaml-has-m"
- "--XXX-fake-flag-yaml-has-a"
- "--XXX-fake-flag-yaml-has-c"
Group: rv64_group
- Dir: rv64imafdc/lp64d
Flags:
- "--target=riscv64-unknown-none-elf"
- "-mabi=lp64d"
- "--XXX-fake-flag-yaml-has-m"
- "--XXX-fake-flag-yaml-has-a"
- "--XXX-fake-flag-yaml-has-f"
- "--XXX-fake-flag-yaml-has-d"
- "--XXX-fake-flag-yaml-has-c"
Group: rv64_group
Mappings:
- Match: -march=.*_a[0-9]+p[0-9]+(_.*|$)
Flags: [--XXX-fake-flag-yaml-has-a]
- Match: -march=.*_c[0-9]+p[0-9]+(_.*|$)
Flags: [--XXX-fake-flag-yaml-has-c]
- Match: -march=.*_d[0-9]+p[0-9]+(_.*|$)
Flags: [--XXX-fake-flag-yaml-has-d]
- Match: -march=.*_f[0-9]+p[0-9]+(_.*|$)
Flags: [--XXX-fake-flag-yaml-has-f]
- Match: -march=.*_m[0-9]+p[0-9]+(_.*|$)
Flags: [--XXX-fake-flag-yaml-has-m]
```
The most notable missing feature that I discovered while doing this is that it impossible (or at least very difficult) to test for _non-presence_ of flags (the hardcoded logic will not match anything if specifying e.g. `-march=rv32iac_zicsr` (which may in and of itself be a bug / unintended) but this YAML implementation will). This isn't a problem in many cases because variants are tried in sequential order, but I can foresee it becoming a huge mess given more conflicting/mutually-exclusive variants.
https://github.com/llvm/llvm-project/pull/98856
More information about the cfe-commits
mailing list