97 lines · c
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c2x %s2// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -std=c2x %s3// RUN: %clang_cc1 -triple arm-linux-gnu -fsyntax-only -verify -std=c2x %s4// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify -std=c2x %s5// RUN: %clang_cc1 -triple ppc64le-linux-gnu -fsyntax-only -verify -std=c2x %s6 7#ifdef __x86_64__8 9int __attribute__((target("avx,sse4.2,arch=ivybridge"))) foo(void) { return 4; }10//expected-error@+1 {{'target' attribute takes one argument}}11int __attribute__((target())) bar(void) { return 4; }12// no warning, tune is supported for x8613int __attribute__((target("tune=sandybridge"))) baz(void) { return 4; }14//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}15int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }16//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}17int __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}}19int __attribute__((target("woof"))) bark(void) { return 4; }20// no warning, same as saying 'nothing'.21int __attribute__((target("arch="))) turtle(void) { return 4; }22//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}23int __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}}25int __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}}27int __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}}29int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }30 31//expected-warning@+1 {{unsupported 'x86-64' in the 'target' attribute string}}32void __attribute__((target("x86-64"))) baseline(void) {}33//expected-warning@+1 {{unsupported 'x86-64-v2' in the 'target' attribute string}}34void __attribute__((target("x86-64-v2"))) v2(void) {}35 36int __attribute__((target("sha"))) good_target_but_not_for_fmv() { return 5; }37 38#elifdef __aarch64__39 40int __attribute__((target("sve,arch=armv8-a"))) foo(void) { return 4; }41//expected-error@+1 {{'target' attribute takes one argument}}42int __attribute__((target())) bar(void) { return 4; }43// no warning, tune is supported for aarch6444int __attribute__((target("tune=cortex-a710"))) baz(void) { return 4; }45//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}46int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }47//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}48int __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.50int __attribute__((target("woof"))) bark(void) { return 4; }51// FIXME: Same52int __attribute__((target("arch=armv8-a+woof"))) buff(void) { return 4; }53// FIXME: Same54int __attribute__((target("+noway"))) noway(void) { return 4; }55// no warning, same as saying 'nothing'.56int __attribute__((target("arch="))) turtle(void) { return 4; }57//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}58int __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}}60int __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}}62int __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}}64int __attribute__((target("tune=cortex-a710,tune=neoverse-n2"))) pear_tree(void) { return 4; }65// no warning - branch-protection should work on aarch6466int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; }67 68#elifdef __powerpc__69 70int __attribute__((target("float128,arch=pwr9"))) foo(void) { return 4; }71//expected-error@+1 {{'target' attribute takes one argument}}72int __attribute__((target())) bar(void) { return 4; }73// no warning, tune is supported for PPC74int __attribute__((target("tune=pwr8"))) baz(void) { return 4; }75//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}}76int __attribute__((target("fpmath=387"))) walrus(void) { return 4; }77//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}78int __attribute__((target("float128,arch=hiss"))) meow(void) { return 4; }79// no warning, same as saying 'nothing'.80int __attribute__((target("arch="))) turtle(void) { return 4; }81//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}}82int __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}}84int __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}}86int __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}}88int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; }89 90#else91 92// tune is not supported by other targets.93//expected-warning@+1 {{unsupported 'tune=' in the 'target' attribute string; 'target' attribute ignored}}94int __attribute__((target("tune=hiss"))) baz(void) { return 4; }95 96#endif97