r294197 - [SystemZ] Provide predefined __ARCH__ and __VX__ macros
Ulrich Weigand via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 6 09:04:22 PST 2017
Author: uweigand
Date: Mon Feb 6 11:04:22 2017
New Revision: 294197
URL: http://llvm.org/viewvc/llvm-project?rev=294197&view=rev
Log:
[SystemZ] Provide predefined __ARCH__ and __VX__ macros
GCC 7 will predefine two new macros on s390x:
- __ARCH__ indicates the ISA architecture level
- __VX__ indicates that the vector facility is available
This adds those macros to clang as well to ensure continued
compatibility with GCC.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=294197&r1=294196&r2=294197&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 6 11:04:22 2017
@@ -7037,6 +7037,15 @@ public:
Builder.defineMacro("__zarch__");
Builder.defineMacro("__LONG_DOUBLE_128__");
+ const std::string ISARev = llvm::StringSwitch<std::string>(CPU)
+ .Cases("arch8", "z10", "8")
+ .Cases("arch9", "z196", "9")
+ .Cases("arch10", "zEC12", "10")
+ .Cases("arch11", "z13", "11")
+ .Default("");
+ if (!ISARev.empty())
+ Builder.defineMacro("__ARCH__", ISARev);
+
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");
@@ -7044,6 +7053,8 @@ public:
if (HasTransactionalExecution)
Builder.defineMacro("__HTM__");
+ if (HasVector)
+ Builder.defineMacro("__VX__");
if (Opts.ZVector)
Builder.defineMacro("__VEC__", "10301");
}
Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=294197&r1=294196&r2=294197&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Mon Feb 6 11:04:22 2017
@@ -2035,35 +2035,76 @@
// Begin SystemZ/GCC/Linux tests ----------------
//
+// RUN: %clang -march=arch8 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
// RUN: %clang -march=z10 -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
-// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_Z10
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH8
//
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
-// CHECK_SYSTEMZ_Z10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
-// CHECK_SYSTEMZ_Z10: #define __LONG_DOUBLE_128__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390__ 1
-// CHECK_SYSTEMZ_Z10: #define __s390x__ 1
-// CHECK_SYSTEMZ_Z10: #define __zarch__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __ARCH__ 8
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH8: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH8: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH8: #define __zarch__ 1
//
-// RUN: %clang -march=zEC12 -E -dM %s -o - 2>&1 \
+// RUN: %clang -march=arch9 -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
-// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+// RUN: %clang -march=z196 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH9
+//
+// CHECK_SYSTEMZ_ARCH9: #define __ARCH__ 9
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH9: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH9: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH9: #define __zarch__ 1
+//
// RUN: %clang -march=arch10 -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
-// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZEC12
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH10
+// RUN: %clang -march=zEC12 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH10
//
-// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
-// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
-// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
-// CHECK_SYSTEMZ_ZEC12: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
-// CHECK_SYSTEMZ_ZEC12: #define __HTM__ 1
-// CHECK_SYSTEMZ_ZEC12: #define __LONG_DOUBLE_128__ 1
-// CHECK_SYSTEMZ_ZEC12: #define __s390__ 1
-// CHECK_SYSTEMZ_ZEC12: #define __s390x__ 1
-// CHECK_SYSTEMZ_ZEC12: #define __zarch__ 1
+// CHECK_SYSTEMZ_ARCH10: #define __ARCH__ 10
+// CHECK_SYSTEMZ_ARCH10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH10: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH10: #define __HTM__ 1
+// CHECK_SYSTEMZ_ARCH10: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH10: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH10: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH10: #define __zarch__ 1
+//
+// RUN: %clang -march=arch11 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH11
+// RUN: %clang -march=z13 -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ARCH11
+//
+// CHECK_SYSTEMZ_ARCH11: #define __ARCH__ 11
+// CHECK_SYSTEMZ_ARCH11: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_SYSTEMZ_ARCH11: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_SYSTEMZ_ARCH11: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_SYSTEMZ_ARCH11: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+// CHECK_SYSTEMZ_ARCH11: #define __HTM__ 1
+// CHECK_SYSTEMZ_ARCH11: #define __LONG_DOUBLE_128__ 1
+// CHECK_SYSTEMZ_ARCH11: #define __VX__ 1
+// CHECK_SYSTEMZ_ARCH11: #define __s390__ 1
+// CHECK_SYSTEMZ_ARCH11: #define __s390x__ 1
+// CHECK_SYSTEMZ_ARCH11: #define __zarch__ 1
//
// RUN: %clang -mhtm -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
@@ -2071,6 +2112,12 @@
//
// CHECK_SYSTEMZ_HTM: #define __HTM__ 1
//
+// RUN: %clang -mvx -E -dM %s -o - 2>&1 \
+// RUN: -target s390x-unknown-linux \
+// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_VX
+//
+// CHECK_SYSTEMZ_VX: #define __VX__ 1
+//
// RUN: %clang -fzvector -E -dM %s -o - 2>&1 \
// RUN: -target s390x-unknown-linux \
// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR
More information about the cfe-commits
mailing list