Skip to content

[clang][AArch64] Add --print-supported-extensions support #65466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

DavidSpickett
Copy link
Collaborator

This follows the RISC-V work done in 4b40ced.

This uses AArch64's target parser instead. We just list the names, without the "+" on them, which matches RISC-V's format.

$ ./bin/clang -target aarch64-linux-gnu --print-supported-extensions
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 154da8aec20719c82235a6957aa6e461f5a5e030)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: <...>
All available -march extensions for AArch64

        aes
        b16b16
        bf16
        brbe
        crc
        crypto
        cssc
        <...>

Since our extensions don't have versions in the same way there's just one column with the name in.

Any extension without a feature name (including the special "none") is not listed as those cannot be passed to -march, they're just for the backend. For example the MTE extension can be added with "+memtag" but MTE2 and MTE3 do not have feature names so they cannot be added to -march.

This does not attempt to tackle the fact that clang allows invalid combinations of AArch64 extensions, it simply lists the possible options. It's still up to the user to ask for something sensible.

Equally, this has no context of what CPU is being selected. Neither does the RISC-V option, the user has to be aware of that.

I've added a target parser test, and a high level clang test that checks RISC-V and AArch64 work and that Intel, that doesn't support this, shows the correct error.

This follows the RISC-V work done in 4b40ced.

This uses AArch64's target parser instead. We just list the names,
without the "+" on them, which matches RISC-V's format.

```
$ ./bin/clang -target aarch64-linux-gnu --print-supported-extensions
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 154da8aec20719c82235a6957aa6e461f5a5e030)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: <...>
All available -march extensions for AArch64

        aes
        b16b16
        bf16
        brbe
        crc
        crypto
        cssc
        <...>
```

Since our extensions don't have versions in the same way there's
just one column with the name in.

Any extension without a feature name (including the special "none")
is not listed as those cannot be passed to -march, they're just
for the backend. For example the MTE extension can be added with
"+memtag" but MTE2 and MTE3 do not have feature names so they
cannot be added to -march.

This does not attempt to tackle the fact that clang allows
invalid combinations of AArch64 extensions, it simply lists the
possible options. It's still up to the user to ask for something
sensible.

Equally, this has no context of what CPU is being selected.
Neither does the RISC-V option, the user has to be aware of that.

I've added a target parser test, and a high level clang test
that checks RISC-V and AArch64 work and that Intel, that doesn't
support this, shows the correct error.
@DavidSpickett DavidSpickett requested review from MaskRay, tmatheson-arm and a team September 6, 2023 11:13
@DavidSpickett DavidSpickett requested a review from a team as a code owner September 6, 2023 11:13
@github-actions github-actions bot added the clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' label Sep 6, 2023
@DavidSpickett
Copy link
Collaborator Author

I've generalised this a bit but mostly kept to what RISC-V did. If we think it's time to completely generalise it then I'll figure that out.

Mostly want to know people are on board with supporting this for AArch64 first.

Copy link
Member

@DanielKristofKiss DanielKristofKiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a NIT, LGTM otherwise.

@DavidSpickett DavidSpickett merged commit 90db419 into llvm:main Sep 11, 2023
@DavidSpickett DavidSpickett deleted the clang-supported-ext branch September 11, 2023 07:25
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
This follows the RISC-V work done in
4b40ced.

This uses AArch64's target parser instead. We just list the names,
without the "+" on them, which matches RISC-V's format.

```
$ ./bin/clang -target aarch64-linux-gnu --print-supported-extensions
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 154da8aec20719c82235a6957aa6e461f5a5e030)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: <...>
All available -march extensions for AArch64

        aes
        b16b16
        bf16
        brbe
        crc
        crypto
        cssc
        <...>
```

Since our extensions don't have versions in the same way there's just
one column with the name in.

Any extension without a feature name (including the special "none") is
not listed as those cannot be passed to -march, they're just for the
backend. For example the MTE extension can be added with "+memtag" but
MTE2 and MTE3 do not have feature names so they cannot be added to
-march.

This does not attempt to tackle the fact that clang allows invalid
combinations of AArch64 extensions, it simply lists the possible
options. It's still up to the user to ask for something sensible.

Equally, this has no context of what CPU is being selected. Neither does
the RISC-V option, the user has to be aware of that.

I've added a target parser test, and a high level clang test that checks
RISC-V and AArch64 work and that Intel, that doesn't support this, shows
the correct error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants