| 1 |
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
int check_all_feature() { |
| 4 |
if (__builtin_cpu_supports("rng+flagm+flagm2+fp16fml+dotprod+sm4")) |
| 5 |
return 1; |
| 6 |
else if (__builtin_cpu_supports("rdm+lse+fp+simd+crc+sha1+sha2+sha3")) |
| 7 |
return 2; |
| 8 |
else if (__builtin_cpu_supports("aes+pmull+fp16+dit+dpb+dpb2+jscvt")) |
| 9 |
return 3; |
| 10 |
else if (__builtin_cpu_supports("fcma+rcpc+rcpc2+rcpc3+frintts+dgh")) |
| 11 |
return 4; |
| 12 |
else if (__builtin_cpu_supports("i8mm+bf16+ebf16+rpres+sve+sve-bf16")) |
| 13 |
return 5; |
| 14 |
else if (__builtin_cpu_supports("sve-ebf16+sve-i8mm+f32mm+f64mm")) |
| 15 |
return 6; |
| 16 |
else if (__builtin_cpu_supports("sve2+sve2-aes+sve2-pmull128")) |
| 17 |
return 7; |
| 18 |
else if (__builtin_cpu_supports("sve2-bitperm+sve2-sha3+sve2-sm4")) |
| 19 |
return 8; |
| 20 |
else if (__builtin_cpu_supports("sme+memtag+memtag2+memtag3+sb")) |
| 21 |
return 9; |
| 22 |
else if (__builtin_cpu_supports("predres+ssbs+ssbs2+bti+ls64+ls64_v")) |
| 23 |
return 10; |
| 24 |
else if (__builtin_cpu_supports("ls64_accdata+wfxt+sme-f64f64")) |
| 25 |
return 11; |
| 26 |
else if (__builtin_cpu_supports("sme-i16i64+sme2")) |
| 27 |
return 12; |
| 28 |
else |
| 29 |
return 0; |
| 30 |
} |
| 31 |
|
| 32 |
// CHECK-LABEL: define dso_local i32 @neon_code() #1 |
| 33 |
int __attribute__((target("simd"))) neon_code() { return 1; } |
| 34 |
|
| 35 |
// CHECK-LABEL: define dso_local i32 @sve_code() #2 |
| 36 |
int __attribute__((target("sve"))) sve_code() { return 2; } |
| 37 |
|
| 38 |
// CHECK-LABEL: define dso_local i32 @code() #0 |
| 39 |
int code() { return 3; } |
| 40 |
|
| 41 |
// CHECK-LABEL: define dso_local i32 @test_versions() #0 |
| 42 |
int test_versions() { |
| 43 |
if (__builtin_cpu_supports("sve")) |
| 44 |
return sve_code(); |
| 45 |
else if (__builtin_cpu_supports("simd")) |
| 46 |
return neon_code(); |
| 47 |
else |
| 48 |
return code(); |
| 49 |
} |
| 50 |
// CHECK: attributes #0 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 51 |
// CHECK: attributes #1 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon" } |
| 52 |
// CHECK: attributes #2 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+sve" } |