[clang] 2784b24 - [M68k] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 29 02:08:42 PST 2022
Author: Brad Smith
Date: 2022-12-29T05:07:35-05:00
New Revision: 2784b243e38f7d526a40838a854554b53ebeb41e
URL: https://github.com/llvm/llvm-project/commit/2784b243e38f7d526a40838a854554b53ebeb41e
DIFF: https://github.com/llvm/llvm-project/commit/2784b243e38f7d526a40838a854554b53ebeb41e.diff
LOG: [M68k] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Fixes #58974
Reviewed By: myhsu, glaubitz, 0x59616e
Differential Revision: https://reviews.llvm.org/D140695
Added:
Modified:
clang/lib/Basic/Targets/M68k.cpp
clang/test/Preprocessor/predefined-arch-macros.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index 48627a8ceff9a..e3215b24a3a5a 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -113,6 +113,12 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts,
default:
break;
}
+
+ if (CPU >= CK_68020) {
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+ }
}
ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const {
diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
index 3d9c14e13eba8..5abcdab7da037 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4313,3 +4313,20 @@
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_R600_FP64
// CHECK_R600_FP64-DAG: #define __R600__ 1
// CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
+
+// Begin M68k tests ----------------
+
+// RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68010 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68020 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68020_ATOMICS
+
+// CHECK_M68K_68000_ATOMICS-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
More information about the cfe-commits
mailing list