[PATCH] D137617: [AArch64] Allow users-facing feature names in clang target attributes

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 01:14:59 PST 2022


dmgreen created this revision.
dmgreen added reviewers: danielkiss, ilinpv, simon_tatham, efriedma, stuij.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
dmgreen requested review of this revision.

D133848 <https://reviews.llvm.org/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).


https://reviews.llvm.org/D137617

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-targetattr.c
  clang/test/Sema/aarch64-fp16-target.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137617.473903.patch
Type: text/x-patch
Size: 4169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221108/a8eaef1d/attachment.bin>


More information about the llvm-commits mailing list