r367281 - [PowerPC] [Clang] Add platform guards to PPC vector intrinsics headers

Qiu Chaofan via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 19:18:11 PDT 2019


Author: chaofan
Date: Mon Jul 29 19:18:11 2019
New Revision: 367281

URL: http://llvm.org/viewvc/llvm-project?rev=367281&view=rev
Log:
[PowerPC] [Clang] Add platform guards to PPC vector intrinsics headers

Move the platform check out of PPC Linux toolchain code and add platform guards
to the intrinsic headers, since they are supported currently only on 64-bit
PowerPC targets.

Reviewed By: Jinsong Ji

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

Modified:
    cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp
    cfe/trunk/lib/Headers/ppc_wrappers/emmintrin.h
    cfe/trunk/lib/Headers/ppc_wrappers/mm_malloc.h
    cfe/trunk/lib/Headers/ppc_wrappers/mmintrin.h
    cfe/trunk/lib/Headers/ppc_wrappers/xmmintrin.h

Modified: cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp?rev=367281&r1=367280&r2=367281&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/PPCLinux.cpp Mon Jul 29 19:18:11 2019
@@ -16,10 +16,7 @@ using namespace llvm::opt;
 
 void PPCLinuxToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
                                                   ArgStringList &CC1Args) const {
-  // PPC wrapper headers are implementation of x86 intrinsics on PowerPC, which
-  // is not supported on PPC32 platform.
-  if (getArch() != llvm::Triple::ppc &&
-      !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+  if (!DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
       !DriverArgs.hasArg(options::OPT_nobuiltininc)) {
     const Driver &D = getDriver();
     SmallString<128> P(D.ResourceDir);

Modified: cfe/trunk/lib/Headers/ppc_wrappers/emmintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ppc_wrappers/emmintrin.h?rev=367281&r1=367280&r2=367281&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/ppc_wrappers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/ppc_wrappers/emmintrin.h Mon Jul 29 19:18:11 2019
@@ -35,6 +35,8 @@
 #ifndef EMMINTRIN_H_
 #define EMMINTRIN_H_
 
+#if defined(__linux__) && defined(__ppc64__)
+
 #include <altivec.h>
 
 /* We need definitions from the SSE header files.  */
@@ -2315,4 +2317,8 @@ _mm_castsi128_pd(__m128i __A)
   return (__m128d) __A;
 }
 
+#else
+#include_next <emmintrin.h>
+#endif /* defined(__linux__) && defined(__ppc64__) */
+
 #endif /* EMMINTRIN_H_ */

Modified: cfe/trunk/lib/Headers/ppc_wrappers/mm_malloc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ppc_wrappers/mm_malloc.h?rev=367281&r1=367280&r2=367281&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/ppc_wrappers/mm_malloc.h (original)
+++ cfe/trunk/lib/Headers/ppc_wrappers/mm_malloc.h Mon Jul 29 19:18:11 2019
@@ -10,6 +10,8 @@
 #ifndef _MM_MALLOC_H_INCLUDED
 #define _MM_MALLOC_H_INCLUDED
 
+#if defined(__linux__) && defined(__ppc64__)
+
 #include <stdlib.h>
 
 /* We can't depend on <stdlib.h> since the prototype of posix_memalign
@@ -41,4 +43,8 @@ _mm_free (void * ptr)
   free (ptr);
 }
 
+#else
+#include_next <mm_malloc.h>
+#endif
+
 #endif /* _MM_MALLOC_H_INCLUDED */

Modified: cfe/trunk/lib/Headers/ppc_wrappers/mmintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ppc_wrappers/mmintrin.h?rev=367281&r1=367280&r2=367281&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/ppc_wrappers/mmintrin.h (original)
+++ cfe/trunk/lib/Headers/ppc_wrappers/mmintrin.h Mon Jul 29 19:18:11 2019
@@ -35,6 +35,8 @@
 #ifndef _MMINTRIN_H_INCLUDED
 #define _MMINTRIN_H_INCLUDED
 
+#if defined(__linux__) && defined(__ppc64__)
+
 #include <altivec.h>
 /* The Intel API is flexible enough that we must allow aliasing with other
    vector types, and their scalar components.  */
@@ -1440,4 +1442,9 @@ extern __inline __m64
   return (res.as_m64);
 #endif
 }
+
+#else
+#include_next <mmintrin.h>
+#endif /* defined(__linux__) && defined(__ppc64__) */
+
 #endif /* _MMINTRIN_H_INCLUDED */

Modified: cfe/trunk/lib/Headers/ppc_wrappers/xmmintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ppc_wrappers/xmmintrin.h?rev=367281&r1=367280&r2=367281&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/ppc_wrappers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/ppc_wrappers/xmmintrin.h Mon Jul 29 19:18:11 2019
@@ -34,6 +34,8 @@
 #ifndef _XMMINTRIN_H_INCLUDED
 #define _XMMINTRIN_H_INCLUDED
 
+#if defined(__linux__) && defined(__ppc64__)
+
 /* Define four value permute mask */
 #define _MM_SHUFFLE(w,x,y,z) (((w) << 6) | ((x) << 4) | ((y) << 2) | (z))
 
@@ -1835,4 +1837,8 @@ do {									\
 /* For backward source compatibility.  */
 //# include <emmintrin.h>
 
+#else
+#include_next <xmmintrin.h>
+#endif /* defined(__linux__) && defined(__ppc64__) */
+
 #endif /* _XMMINTRIN_H_INCLUDED */




More information about the cfe-commits mailing list