| 1 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c2x %s |
| 2 |
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -std=c2x %s |
| 3 |
// RUN: %clang_cc1 -triple arm-linux-gnu -fsyntax-only -verify -std=c2x %s |
| 4 |
// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify -std=c2x %s |
| 5 |
// RUN: %clang_cc1 -triple ppc64le-linux-gnu -fsyntax-only -verify -std=c2x %s |
| 6 |
|
| 7 |
#ifdef __x86_64__ |
| 8 |
|
| 9 |
int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; } |
| 10 |
//expected-error@+1 {{'target' attribute takes one argument}} |
| 11 |
int __attribute__((target())) bar(void) { return 4; } |
| 12 |
// no warning, tune is supported for x86 |
| 13 |
int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; } |
| 14 |
//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}} |
| 15 |
int __attribute__((target("fpmath=387"))) walrus(void) { return 4; } |
| 16 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 17 |
int __attribute__((target("avx,sse4.2,arch=hiss"))) meow(void) { return 4; } |
| 18 |
//expected-warning@+1 {{unsupported 'woof' in the 'target' attribute string; 'target' attribute ignored}} |
| 19 |
int __attribute__((target("woof"))) bark(void) { return 4; } |
| 20 |
// no warning, same as saying 'nothing'. |
| 21 |
int __attribute__((target("arch="))) turtle(void) { return 4; } |
| 22 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 23 |
int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; } |
| 24 |
//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}} |
| 25 |
int __attribute__((target("arch=ivybridge,arch=haswell"))) oak_tree(void) { return 4; } |
| 26 |
//expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}} |
| 27 |
int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; } |
| 28 |
//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 29 |
int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; } |
| 30 |
|
| 31 |
//expected-warning@+1 {{unsupported 'x86-64' in the 'target' attribute string}} |
| 32 |
void __attribute__((target("x86-64"))) baseline(void) {} |
| 33 |
//expected-warning@+1 {{unsupported 'x86-64-v2' in the 'target' attribute string}} |
| 34 |
void __attribute__((target("x86-64-v2"))) v2(void) {} |
| 35 |
|
| 36 |
int __attribute__((target("sha"))) good_target_but_not_for_fmv() { return 5; } |
| 37 |
|
| 38 |
#elifdef __aarch64__ |
| 39 |
|
| 40 |
int __attribute__((target("sve,arch=armv8-a"))) foo(void) { return 4; } |
| 41 |
//expected-error@+1 {{'target' attribute takes one argument}} |
| 42 |
int __attribute__((target())) bar(void) { return 4; } |
| 43 |
// no warning, tune is supported for aarch64 |
| 44 |
int __attribute__((target("tune=cortex-a710"))) baz(void) { return 4; } |
| 45 |
//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}} |
| 46 |
int __attribute__((target("fpmath=387"))) walrus(void) { return 4; } |
| 47 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 48 |
int __attribute__((target("sve,cpu=hiss"))) meow(void) { return 4; } |
| 49 |
// FIXME: We currently have no implementation of isValidFeatureName, so this is not noticed as an error. |
| 50 |
int __attribute__((target("woof"))) bark(void) { return 4; } |
| 51 |
// FIXME: Same |
| 52 |
int __attribute__((target("arch=armv8-a+woof"))) buff(void) { return 4; } |
| 53 |
// FIXME: Same |
| 54 |
int __attribute__((target("+noway"))) noway(void) { return 4; } |
| 55 |
// no warning, same as saying 'nothing'. |
| 56 |
int __attribute__((target("arch="))) turtle(void) { return 4; } |
| 57 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 58 |
int __attribute__((target("cpu=hiss,cpu=woof"))) pine_tree(void) { return 4; } |
| 59 |
//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}} |
| 60 |
int __attribute__((target("arch=armv8.1-a,arch=armv8-a"))) oak_tree(void) { return 4; } |
| 61 |
//expected-warning@+1 {{duplicate 'cpu=' in the 'target' attribute string; 'target' attribute ignored}} |
| 62 |
int __attribute__((target("cpu=cortex-a710,cpu=neoverse-n2"))) apple_tree(void) { return 4; } |
| 63 |
//expected-warning@+1 {{duplicate 'tune=' in the 'target' attribute string; 'target' attribute ignored}} |
| 64 |
int __attribute__((target("tune=cortex-a710,tune=neoverse-n2"))) pear_tree(void) { return 4; } |
| 65 |
// no warning - branch-protection should work on aarch64 |
| 66 |
int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; } |
| 67 |
|
| 68 |
#elifdef __powerpc__ |
| 69 |
|
| 70 |
int __attribute__((target("float128,arch=pwr9"))) foo(void) { return 4; } |
| 71 |
//expected-error@+1 {{'target' attribute takes one argument}} |
| 72 |
int __attribute__((target())) bar(void) { return 4; } |
| 73 |
// no warning, tune is supported for PPC |
| 74 |
int __attribute__((target("tune=pwr8"))) baz(void) { return 4; } |
| 75 |
//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}} |
| 76 |
int __attribute__((target("fpmath=387"))) walrus(void) { return 4; } |
| 77 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 78 |
int __attribute__((target("float128,arch=hiss"))) meow(void) { return 4; } |
| 79 |
// no warning, same as saying 'nothing'. |
| 80 |
int __attribute__((target("arch="))) turtle(void) { return 4; } |
| 81 |
//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 82 |
int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; } |
| 83 |
//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}} |
| 84 |
int __attribute__((target("arch=pwr9,arch=pwr10"))) oak_tree(void) { return 4; } |
| 85 |
//expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}} |
| 86 |
int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; } |
| 87 |
//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} |
| 88 |
int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; } |
| 89 |
|
| 90 |
#else |
| 91 |
|
| 92 |
// tune is not supported by other targets. |
| 93 |
//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}} |
| 94 |
int __attribute__((target("tune=hiss"))) baz(void) { return 4; } |
| 95 |
|
| 96 |
#endif |