https://github.com/ecnelises created https://github.com/llvm/llvm-project/pull/68681
None >From c1fbd4242c135ecbf91882d0350dc7d4c1e84b69 Mon Sep 17 00:00:00 2001 From: Qiu Chaofan <qiuco...@cn.ibm.com> Date: Tue, 10 Oct 2023 17:50:59 +0800 Subject: [PATCH] [Clang][PowerPC] Support tune directive in target attribute --- clang/lib/Basic/Targets/PPC.h | 2 ++ clang/test/Sema/attr-target.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h index ef667b3d511f0e6..4d62673ba7fb8c5 100644 --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -198,6 +198,8 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo { void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name, bool Enabled) const override; + bool supportsTargetAttributeTune() const override { return true; } + ArrayRef<const char *> getGCCRegNames() const override; ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override; diff --git a/clang/test/Sema/attr-target.c b/clang/test/Sema/attr-target.c index 3416a3d0a6ba134..5328f056507a714 100644 --- a/clang/test/Sema/attr-target.c +++ b/clang/test/Sema/attr-target.c @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -std=c2x %s // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -std=c2x %s // RUN: %clang_cc1 -triple arm-linux-gnu -fsyntax-only -verify -std=c2x %s +// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify -std=c2x %s +// RUN: %clang_cc1 -triple ppc64le-linux-gnu -fsyntax-only -verify -std=c2x %s #ifdef __x86_64__ @@ -61,6 +63,28 @@ int __attribute__((target("tune=cortex-a710,tune=neoverse-n2"))) pear_tree(void) // no warning - branch-protection should work on aarch64 int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; } +#elifdef __powerpc__ + +int __attribute__((target("float128,arch=pwr9"))) foo(void) { return 4; } +//expected-error@+1 {{'target' attribute takes one argument}} +int __attribute__((target())) bar(void) { return 4; } +// no warning, tune is supported for PPC +int __attribute__((target("tune=pwr8"))) baz(void) { return 4; } +//expected-warning@+1 {{unsupported 'fpmath=' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("fpmath=387"))) walrus(void) { return 4; } +//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("float128,arch=hiss"))) meow(void) { return 4; } +// no warning, same as saying 'nothing'. +int __attribute__((target("arch="))) turtle(void) { return 4; } +//expected-warning@+1 {{unknown CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("arch=hiss,arch=woof"))) pine_tree(void) { return 4; } +//expected-warning@+1 {{duplicate 'arch=' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("arch=pwr9,arch=pwr10"))) oak_tree(void) { return 4; } +//expected-warning@+1 {{unsupported 'branch-protection' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("branch-protection=none"))) birch_tree(void) { return 5; } +//expected-warning@+1 {{unknown tune CPU 'hiss' in the 'target' attribute string; 'target' attribute ignored}} +int __attribute__((target("tune=hiss,tune=woof"))) apple_tree(void) { return 4; } + #else // tune is not supported by other targets. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits