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).