From f213fe058c0995be67f8e1fb6763e51a222cda23 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 14 Mar 2019 05:45:42 +0000 Subject: [PATCH] [X86] Only define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 in 64-bit mode. Summary: This define should correspond to CMPXCHG16B being available which requires 64-bit mode. I checked and gcc also seems to only define this in 64-bit mode. Reviewers: RKSimon, spatel, efriedma, jyknight, jfb Reviewed By: jfb Subscribers: jfb, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59287 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356118 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets/X86.cpp | 2 +- test/Preprocessor/x86_target_features.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Basic/Targets/X86.cpp b/lib/Basic/Targets/X86.cpp index 236f4f5d55..400589fa52 100644 --- a/lib/Basic/Targets/X86.cpp +++ b/lib/Basic/Targets/X86.cpp @@ -1280,7 +1280,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, } if (CPU >= CK_i586) Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); - if (HasCX16) + if (HasCX16 && getTriple().getArch() == llvm::Triple::x86_64) Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16"); if (HasFloat128) diff --git a/test/Preprocessor/x86_target_features.c b/test/Preprocessor/x86_target_features.c index 2d5369faed..3e4ffe44dd 100644 --- a/test/Preprocessor/x86_target_features.c +++ b/test/Preprocessor/x86_target_features.c @@ -348,9 +348,13 @@ // NOTBM-NOT: #define __TBM__ 1 -// RUN: %clang -target i386-unknown-unknown -march=pentiumpro -mcx16 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MCX16 %s +// RUN: %clang -target i386-unknown-unknown -march=pentiumpro -mcx16 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MCX16-32 %s -// MCX16: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 +// MCX16-32-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 + +// RUN: %clang -target x86_64-unknown-unknown -march=x86-64 -mcx16 -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=MCX16-64 %s + +// MCX16-64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 1 // RUN: %clang -target i386-unknown-unknown -march=atom -mprfchw -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=PRFCHW %s -- 2.40.0