[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

John Paul Adrian Glaubitz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 23 01:58:54 PDT 2021


glaubitz updated this revision to Diff 332567.
glaubitz edited the summary of this revision.
Herald added subscribers: arichardson, emaste.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98574/new/

https://reviews.llvm.org/D98574

Files:
  clang/lib/Basic/Targets/Sparc.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===================================================================
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN:     -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN:     -target sparc-sun-solaris \
@@ -3557,12 +3552,10 @@
 // RUN:     -target sparcv9-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN:     -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===================================================================
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
       Builder.defineMacro("__sparcv8__");
       break;
     case CG_V9:
-      Builder.defineMacro("__sparcv9");
-      Builder.defineMacro("__sparcv9__");
       Builder.defineMacro("__sparc_v9__");
       break;
     }
@@ -239,13 +237,25 @@
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
                                          MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
-  // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
+  switch (getTriple().getOS()) {
+  case llvm::Triple::Linux:
+    Builder.defineMacro("__sparc_v9__");
+    break;
+  case llvm::Triple::FreeBSD:
+  case llvm::Triple::NetBSD:
     Builder.defineMacro("__sparc64__");
     Builder.defineMacro("__sparc_v9__");
+    Builder.defineMacro("__sparcv9");
+    break;
+  case llvm::Triple::OpenBSD:
+    Builder.defineMacro("__sparc64__");
     Builder.defineMacro("__sparcv9__");
+    Builder.defineMacro("__sparc_v9__");
+    break;
+  case llvm::Triple::Solaris:
+    Builder.defineMacro("__sparcv9");
+    break;
   }
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98574.332567.patch
Type: text/x-patch
Size: 3038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210323/75aae9bd/attachment-0001.bin>


More information about the cfe-commits mailing list