[clang] [AArch64] Simplify Clang's description of architecture extensions (PR #79311)
Anatoly Trosinenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 10:29:44 PST 2024
atrosinenko wrote:
I tried adding a few more lines to `clang/test/Preprocessor/aarch64-target-features.c` and turned out, clang accepts `-march=armv8-a+jscvt` but not `-march=armv8-a+dpb`. Brief debugging suggests this is because in the
```cpp
{"dpb", AArch64::AEK_NONE, {}, {}, FEAT_DPB, "+ccpp", 190},
```
line, `Feature` and `NegFeature` fields are empty.
I wonder if there is an overview of all the "feature-related" AArch64 stuff anywhere. As far as I understand, there are several kinds of identifiers:
* feature names defined in the chapter "A2: Armv8-A Architecture Extensions" of the Arm Architecture Reference Manual (such as `FEAT_JSCVT` mentioned in "A2.5: The Armv8.3 architecture extension")
* Function Multi-Versioning CPU features defined in `enum CPUFeatures` (such as `FEAT_JSCVT`)
* `AEK_*` constants defined in `enum ArchExtKind` (such as `AEK_JSCVT`)
* `Name`s defined in the `Extensions` array in AArch64TargetParser.h
* `Feature` / `NegFeature` defined in the same array
* `DependentFeatures` defined in the same array
I guess, each kind of identifiers belongs to one of logical "namespaces". Here is what I see:
* the names of FMV features looks identical to feature names defined in Arm ARM, but the _sets_ of identifiers are different - the former is a strict subset of the latter at best. Obviously, there is a number of features hardly related to compiler development (such as various properties of hardware debug interfaces) and some other are not related to runtime function selection by FMV machinery (or at least the rules are not yet written in ACLE for them). It is just a bit misleading that Arm ARM defines FEAT_PAUTH and this feature is mentioned as AEK_PAUTH, "+pauth" literal, etc. but not as FEAT_PAUTH in the enumeration with constants named `FEAT_*` :)
* after `AEK_*` constants were recently made not restricted by the bitsize of `uint64_t` anymore, these look like the best mirror of `FEAT_*` identifiers defined in Arm ARM (and there is an explicit [naming guideline](https://github.com/llvm/llvm-project/blob/7f409cd82b322038f08a984a07377758e76b0e4c/llvm/include/llvm/TargetParser/AArch64TargetParser.h#L106))
* `Name` fields are used when parsing `-march=...+feature` arguments of Clang. These are kind of user-visible interface
* `Feature`/`NegFeature` and `DependentFeatures` are used when parsing `-target-feature`s passed to `clang -cc1` and are likely to contain string identifiers from the same namespace, according to seemingly the [only in-tree user](https://github.com/llvm/llvm-project/blob/7fdb932c4e78706cec3468a1f149e5a54a865d36/clang/lib/Basic/Targets/AArch64.cpp#L1013) of `DependentFeatures` contents, but duplication like `{"jscvt", AArch64::AEK_JSCVT, "+jsconv", "-jsconv", FEAT_JSCVT, "+fp-armv8,+neon,+jsconv", 210}` (E.Feature additionally listed in E.DependentFeatures) looks redundant
https://github.com/llvm/llvm-project/pull/79311
More information about the cfe-commits
mailing list