[PATCH] D110824: [PowerPC] Fix to guard fetch and cas 64-bit builtin versions
Kamau Bridgeman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 30 06:27:05 PDT 2021
kamaub created this revision.
kamaub added reviewers: PowerPC, nemanjai, lei, amyk, stefanp.
Herald added subscribers: shchenz, kbarton.
kamaub requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The builtins: `__compare_and_swaplp`, `__fetch_and_addlp`,
` __fetch_and_andlp`, `__fetch_and_orlp`, `__fetch_and_swaplp` are
64 bit only. This patch ensures the compiler produces an error in 32 bit mode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110824
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc-xlcompat-fetch-cas-64bit-only-error.c
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-cas-64bit-only-error.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-cas-64bit-only-error.c
@@ -0,0 +1,24 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -target-cpu pwr8 \
+// RUN: -verify %s
+
+int test_builtin_ppc_compare_and_swaplp(long a, long b, long c) {
+ return __compare_and_swaplp(&a, &b, c); // expected-error {{this builtin is only available on 64-bit targets}}
+}
+
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
+ __fetch_and_addlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
+}
+
+void test_builtin_ppc_fetch_and_andlp(unsigned long a, unsigned long b) {
+ __fetch_and_andlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
+}
+void test_builtin_ppc_fetch_and_orlp(unsigned long a, unsigned long b) {
+ __fetch_and_orlp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
+}
+
+void test_builtin_ppc_fetch_and_swaplp(unsigned long a, unsigned long b) {
+ __fetch_and_swaplp(&a, b); // expected-error {{this builtin is only available on 64-bit targets}}
+}
+
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3297,6 +3297,11 @@
case PPC::BI__builtin_ppc_addex:
case PPC::BI__builtin_darn:
case PPC::BI__builtin_darn_raw:
+ case PPC::BI__builtin_ppc_compare_and_swaplp:
+ case PPC::BI__builtin_ppc_fetch_and_addlp:
+ case PPC::BI__builtin_ppc_fetch_and_andlp:
+ case PPC::BI__builtin_ppc_fetch_and_orlp:
+ case PPC::BI__builtin_ppc_fetch_and_swaplp:
return true;
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110824.376178.patch
Type: text/x-patch
Size: 1922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210930/931b2b4b/attachment.bin>
More information about the cfe-commits
mailing list