[AIX] Define __HOS_AIX__ macro
authorJake Egan <Jake.Egan@ibm.com>
Fri, 6 Aug 2021 14:39:47 +0000 (10:39 -0400)
committerJake Egan <Jake.Egan@ibm.com>
Fri, 6 Aug 2021 14:40:13 +0000 (10:40 -0400)
%%%
This patch defines __HOS_AIX__ macro for AIX in case of a cross compiler implementation.
%%%
Tested with SPEC.

Reviewed By: cebowleratibm

Differential Revision: https://reviews.llvm.org/D107242

clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/host-aix.c [new file with mode: 0644]
clang/test/Preprocessor/not-host-aix.c [new file with mode: 0644]

index a888e22..4ee7282 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -304,6 +305,11 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__LONGDOUBLE64");
   }
 
+  if (llvm::Triple(llvm::sys::getProcessTriple()).isOSAIX() &&
+      getTriple().isOSAIX()) {
+    Builder.defineMacro("__HOS_AIX__");
+  }
+
   // Define this for elfv2 (64-bit only) or 64-bit darwin.
   if (ABI == "elfv2" ||
       (getTriple().getOS() == llvm::Triple::Darwin && PointerWidth == 64))
diff --git a/clang/test/Preprocessor/host-aix.c b/clang/test/Preprocessor/host-aix.c
new file mode 100644 (file)
index 0000000..81d594b
--- /dev/null
@@ -0,0 +1,3 @@
+// REQUIRES: system-aix
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX %s
+// PPC-AIX:#define __HOS_AIX__ 1
diff --git a/clang/test/Preprocessor/not-host-aix.c b/clang/test/Preprocessor/not-host-aix.c
new file mode 100644 (file)
index 0000000..d6a2d22
--- /dev/null
@@ -0,0 +1,3 @@
+// UNSUPPORTED: system-aix
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX %s
+// PPC-AIX-NOT:#define __HOS_AIX__ 1