From: Weiming Zhao Date: Mon, 30 Sep 2013 22:51:32 +0000 (+0000) Subject: Fix PR 12730: Add _GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for ARM X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8712ded79d0e80e6a4158682f78626637ad90a7a;p=clang Fix PR 12730: Add _GCC_HAVE_SYNC_COMPARE_AND_SWAP macros for ARM git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191707 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 3ee9cd48b5..9c26521b72 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3862,6 +3862,13 @@ public: if (CPUArch.startswith("8")) Builder.defineMacro("__ARM_FEATURE_CRC32"); + + if (CPUArch[0] >= '6' && CPUArch != "6M") { + 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"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); + } } virtual void getTargetBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) const { diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c index 94671f3335..11449f930e 100644 --- a/test/Preprocessor/predefined-macros.c +++ b/test/Preprocessor/predefined-macros.c @@ -44,3 +44,21 @@ // CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 // CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 // CHECK-SYNC_CAS_I586: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +// +// RUN: %clang_cc1 %s -E -dM -o - -triple armv6 -target-cpu arm1136j-s \ +// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_ARM +// CHECK-SYNC_CAS_ARM: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +// CHECK-SYNC_CAS_ARM: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +// CHECK-SYNC_CAS_ARM: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +// CHECK-SYNC_CAS_ARM: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +// +// RUN: %clang_cc1 %s -E -dM -o - -triple armv7 -target-cpu cortex-a8 \ +// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_ARMv7 +// CHECK-SYNC_CAS_ARMv7: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +// CHECK-SYNC_CAS_ARMv7: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +// CHECK-SYNC_CAS_ARMv7: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +// CHECK-SYNC_CAS_ARMv7: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +// +// RUN: %clang_cc1 %s -E -dM -o - -triple armv6 -target-cpu cortex-m0 \ +// RUN: | FileCheck %s --check-prefix=CHECK-SYNC_CAS_ARMv6 +// CHECK-SYNC_CAS_ARMv6-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP