[PATCH] D132034: [AArch64] Alter most of arm_neon.h to be target-based, not preprocessor based.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 08:23:01 PDT 2022


dmgreen created this revision.
dmgreen added reviewers: sdesmalen, simon_tatham, stuij, efriedma, t.p.northover.
Herald added subscribers: ctetreau, kristof.beyls.
Herald added a project: All.
dmgreen requested review of this revision.

Similar to D131064 <https://reviews.llvm.org/D131064>, this alters most of the intrinsics in arm_neon.h to be target based, not preprocessor based. The intrinsics that are changed are the ones with obvious target features (fp16, fp16fml, cryptos, i8mm and bf16). The ones that are not yet altered are the ones without target features like rdma (8.1) and complex (8.3). Those will be switched in a followup patch that allows targeting architecture versions.

The existing ArchGuard in arm_neon.td is split into ArchGuard that still adds ifdef defines (for example for intrinsics that require __aarch64__), and TargetGuards for intrinsics dependant on target features. From there the TargetGuards are used in two ways:

- For intrinsics emitted as functions, `__attribute__((target("TargetGuard")))` is added to the definition of the function. Along with the existing always_inline intrinsic, this will give a compile time error if the function is used in a context where the target feature is not available.
- For intrinsics emitted as macros, the __builtins are emitted into arm_neon.inc using TARGET_BUILTIN as opposed to BUILTIN, which includes the target feature and gives an error if the builtin is found in a function without the required features, similar to arm_sve.h.

The second method requires that the intrinsics be separable from the existing _v intrinsics used in other types. For example __builtin_neon_splat_lane_bf16 is used as opposed to __builtin_neon_splat_lane_v. There are some adjustments to the CGBuiltin to account for intrinsics that can be treated similarly, except for their
target features.


https://reviews.llvm.org/D132034

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/Sema/aarch64-neon-target.c
  clang/test/Sema/arm-neon-target.c
  clang/utils/TableGen/NeonEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132034.453276.patch
Type: text/x-patch
Size: 106682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220817/a5537530/attachment.bin>


More information about the llvm-commits mailing list