llvm-project/compiler-rt/test/builtins/Unit/aarch64_cpu_features_test.c
Pavel Iliin 568babab7e
[AArch64] Implement __builtin_cpu_supports, compiler-rt tests. (#82378)
The patch complements https://github.com/llvm/llvm-project/pull/68919
and adds AArch64 support for builtin
`__builtin_cpu_supports("feature1+...+featureN")`
which return true if all specified CPU features in argument are
detected. Also compiler-rt aarch64 native run tests for features
detection mechanism were added and 'cpu_model' check was fixed after its
refactor merged https://github.com/llvm/llvm-project/pull/75635 Original
RFC was https://reviews.llvm.org/D153153
2024-02-22 23:33:54 +00:00

18 lines
521 B
C

// REQUIRES: aarch64-target-arch
// REQUIRES: native-run
// RUN: %clang_builtins %s %librt -o %t && %run %t
// REQUIRES: librt_has_aarch64
int main(void) {
if (__builtin_cpu_supports("fp+simd+pmull+sha2+crc")) {
if (__builtin_cpu_supports("fp") && __builtin_cpu_supports("simd") &&
__builtin_cpu_supports("pmull") && __builtin_cpu_supports("sha2") &&
__builtin_cpu_supports("crc")) {
return 0;
} else {
// Something wrong in feature detection
return 1;
}
}
return 0;
}