[PowerPC] Improve consistency in use of __ppc__, __powerpc__, etc.
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 26 Jul 2013 21:39:15 +0000 (21:39 +0000)
committerBill Schmidt <wschmidt@linux.vnet.ibm.com>
Fri, 26 Jul 2013 21:39:15 +0000 (21:39 +0000)
Both GCC and LLVM will implicitly define __ppc__ and __powerpc__ for
all PowerPC targets, whether 32- or 64-bit.  They will both implicitly
define __ppc64__ and __powerpc64__ for 64-bit PowerPC targets, and not
for 32-bit targets.  We cannot be sure that all other possible
compilers used to compile Clang/LLVM define both __ppc__ and
__powerpc__, for example, so it is best to check for both when relying
on either inside the Clang/LLVM code base.

This patch makes sure we always check for both variants.  In addition,
it fixes one unnecessary check in lib/Target/PowerPC/PPCJITInfo.cpp.
(At least one of __ppc__ and __powerpc__ should always be defined when
compiling for a PowerPC target, no matter which compiler is used, so
testing for them is unnecessary.)

There are some places in the compiler that check for other variants,
like __POWERPC__ and _POWER, and I have left those in place.  There is
no need to add them elsewhere.  This seems to be in Apple-specific
code, and I won't take a chance on breaking it.

There is no intended change in behavior; thus, no test cases are
added.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187248 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Unix/Memory.inc
lib/Target/PowerPC/PPCJITInfo.cpp
unittests/ADT/BitVectorTest.cpp
unittests/ADT/PackedVectorTest.cpp
unittests/ExecutionEngine/JIT/MultiJITTest.cpp

index 58fda420eb624ab4572e0aa88d7ad33acc19cfeb..73f586ff4a895c7f6404e7d62ec75fe804719526 100644 (file)
@@ -310,14 +310,14 @@ void Memory::InvalidateInstructionCache(const void *Addr,
 // icache invalidation for PPC and ARM.
 #if defined(__APPLE__)
 
-#  if (defined(__POWERPC__) || defined (__ppc__) || \
+#  if (defined(__POWERPC__) || defined (__ppc__) || defined (__powerpc__) \
      defined(_POWER) || defined(_ARCH_PPC)) || defined(__arm__)
   sys_icache_invalidate(const_cast<void *>(Addr), Len);
 #  endif
 
 #else
 
-#  if (defined(__POWERPC__) || defined (__ppc__) || \
+#  if (defined(__POWERPC__) || defined (__ppc__) || defined (__powerpc__) || \
        defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
   const size_t LineSize = 32;
 
index 18f4adf839e3ccad8f69f656310624c0a10d5617..71c8f1db1c75e63404d3e52fea6a4ab5248df04a 100644 (file)
@@ -71,7 +71,7 @@ static void EmitBranchToAt(uint64_t At, uint64_t To, bool isCall, bool is64Bit){
 extern "C" void PPC32CompilationCallback();
 extern "C" void PPC64CompilationCallback();
 
-#if (!defined(__ppc__) && !defined(__powerpc__)) || defined(__powerpc64__) || defined(__ppc64__)
+#if defined(__powerpc64__) || defined(__ppc64__)
 void PPC32CompilationCallback() {
   llvm_unreachable("This is not a 32bit PowerPC, you can't execute this!");
 }
@@ -356,8 +356,8 @@ TargetJITInfo::StubLayout PPCJITInfo::getStubLayout() {
   return Result;
 }
 
-#if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
-defined(__APPLE__)
+#if (defined(__POWERPC__) || defined (__ppc__) || defined(__powerpc__) || \
+defined(_POWER)) && defined(__APPLE__)
 extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
 #endif
 
index d7cde891fb5624e1dd93ed9650ca7481ebeb46ec..4d3223e418d80e9a557b2a639e49b28810cde3d4 100644 (file)
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 // Some of these tests fail on PowerPC for unknown reasons.
-#ifndef __ppc__
+#if !defined(__ppc__) && !defined(__powerpc__)
 
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallBitVector.h"
index 55b5d8d049ddd544dbcaea4bd3fa69270472a7bf..b6a7e58301249dfb739adb415dd7ca52d47c5d63 100644 (file)
@@ -9,7 +9,7 @@
 
 // BitVectorTest tests fail on PowerPC for unknown reasons, so disable this
 // as well since it depends on a BitVector.
-#ifndef __ppc__
+#if !defined(__ppc__) && !defined(__powerpc__)
 
 #include "llvm/ADT/PackedVector.h"
 #include "gtest/gtest.h"
index 4018cd5ce2f2c94408650514a031557f60e49df7..29689b71a24844b2f6523e943d8f9508c660d2f5 100644 (file)
@@ -21,7 +21,8 @@ using namespace llvm;
 namespace {
 
 // ARM, PowerPC and SystemZ tests disabled pending fix for PR10783.
-#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__)
+#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__) && \
+  !defined(__ppc__)
 
 bool LoadAssemblyInto(Module *M, const char *assembly) {
   SMDiagnostic Error;