[clang] f70d17f - [LoongArch] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 5 17:21:31 PST 2023
Author: Brad Smith
Date: 2023-01-05T20:21:22-05:00
New Revision: f70d17fc2c10381682123c5f8766bd59c27dfbdd
URL: https://github.com/llvm/llvm-project/commit/f70d17fc2c10381682123c5f8766bd59c27dfbdd
DIFF: https://github.com/llvm/llvm-project/commit/f70d17fc2c10381682123c5f8766bd59c27dfbdd.diff
LOG: [LoongArch] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros
Reviewed By: SixWeining, MaskRay
Differential Revision: https://reviews.llvm.org/D141070
Added:
Modified:
clang/lib/Basic/Targets/LoongArch.cpp
clang/test/Preprocessor/init-loongarch.c
clang/test/Preprocessor/predefined-arch-macros.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp
index 75e3d503ad24..5ac94864cebb 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -158,6 +158,12 @@ void LoongArchTargetInfo::getTargetDefines(const LangOptions &Opts,
} else if (ABI == "lp64s" || ABI == "ilp32s") {
Builder.defineMacro("__loongarch_soft_float");
}
+
+ 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");
+ if (GRLen == 64)
+ Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
}
static constexpr Builtin::Info BuiltinInfo[] = {
diff --git a/clang/test/Preprocessor/init-loongarch.c b/clang/test/Preprocessor/init-loongarch.c
index b7b84d42d4ec..686c9681361e 100644
--- a/clang/test/Preprocessor/init-loongarch.c
+++ b/clang/test/Preprocessor/init-loongarch.c
@@ -81,6 +81,9 @@
// LA32: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
// LA32: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
// LA32: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
// LA32: #define __ILP32__ 1
// LA32: #define __INT16_C_SUFFIX__
// LA32: #define __INT16_FMTd__ "hd"
@@ -394,6 +397,10 @@
// LA64: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
// LA64: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
// LA64: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
// LA64: #define __INT16_C_SUFFIX__
// LA64: #define __INT16_FMTd__ "hd"
// LA64: #define __INT16_FMTi__ "hi"
diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
index 259ce1b47171..1b1afd6c2238 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4372,3 +4372,20 @@
// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin LoongArch tests ----------------
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch32-unknown-linux-gnu \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_LA32_ATOMICS
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch64-unknown-linux-gnu \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_LA64_ATOMICS
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
More information about the cfe-commits
mailing list