This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by dmgreen on Aug 17 2022, 8:22 AM.

Details

Summary

Similar to 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.

Diff Detail

Event Timeline

dmgreen created this revision.Aug 17 2022, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 8:22 AM
dmgreen requested review of this revision.Aug 17 2022, 8:22 AM
Matt added a subscriber: Matt.Aug 17 2022, 1:59 PM
This revision is now accepted and ready to land.Sep 26 2022, 1:40 PM
dmgreen edited the summary of this revision. (Show Details)Oct 11 2022, 12:31 AM
This revision was landed with ongoing or failed builds.Oct 11 2022, 1:09 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2022, 1:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript