This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Allow users-facing feature names in clang target attributes
ClosedPublic

Authored by dmgreen on Nov 8 2022, 1:14 AM.

Details

Summary

D133848 added support for the GCC format of target("..") attributes. The supported formats to match gcc are:

//  "arch=<arch>" - parsed to features as per -march=..
//  "cpu=<cpu>" - parsed to features as per -mcpu=.., with CPU set to <cpu>
//  "tune=<cpu>" - TuneCPU set to <cpu>
//  "+feature", "+nofeature" - Add (or remove) feature.

We also support the existing formats, previously accepted by clang, for compatibility with the existing code and intrinsics code:

//  "feature", "no-feature" - Add (or remove) feature.

The clang formats would accept and use internal feature names ("fullfp16"/"neon"/"sve") as opposed to the user facing names ("fp16"/"simd"/"sve"). Usually they use the same names, but can be different for cases like fp, fullfp16 and mte (among others).

This patch makes the clang format also except the user facing names, by parsing the features through getArchExtFeature. There is a fallback if the name is not recognized (like "fullfp16"), where we add the existing string which should then be checked later for consistency. This allows the internal names to be used as before, so long as they are recognized as internal names. (Note that we currently don't have an implementation of isValidFeatureName. The backend will currently give an error like '-sid' is not a recognized feature for this target (ignoring feature). This should be improved in a later patch once an implementation of isValidFeatureName in clang is present).

Diff Detail

Event Timeline

dmgreen created this revision.Nov 8 2022, 1:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 1:14 AM
dmgreen requested review of this revision.Nov 8 2022, 1:14 AM
This revision is now accepted and ready to land.Nov 8 2022, 2:30 AM
This revision was landed with ongoing or failed builds.Nov 8 2022, 11:30 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 11:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript