Update Reactor for PPC64 support
This updates LLVMReactor to provide for PPC64 little endian support. It
also adds an #ifdef condition to an assert macro, since
llvm::sys::getHostCPUFeatures will always return false on non-x86 and
ARM Linux platforms per
'third_party/llvm-7.0/llvm/lib/Support/Host.cpp'.
Bug: b/135175069
Signed-off-by: Colin Samples <colin.samples+git@gmail.com>
Change-Id: Idcdafe2f1bd934317ca9da09c99132f814fcf160
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32811
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index 8e2ef39..2f31f64 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -15,9 +15,10 @@
import("../swiftshader.gni")
declare_args() {
- # Subzero produces smaller binaries, but doesn't support ARM64 and MIPS64.
+ # Subzero produces smaller binaries, but doesn't support ARM64, MIPS64, and
+ # PPC64.
use_swiftshader_with_subzero =
- target_cpu != "arm64" && target_cpu != "mips64el"
+ target_cpu != "arm64" && target_cpu != "mips64el" && target_cpu != "ppc64"
supports_llvm = is_linux || is_fuchsia || is_win || is_android || is_mac
}
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 82eefe3..c4e522a 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -912,6 +912,8 @@
#else
static const char arch[] = "mipsel";
#endif
+ #elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ static const char arch[] = "ppc64le";
#else
#error "unknown architecture"
#endif
@@ -919,8 +921,16 @@
llvm::SmallVector<std::string, 8> mattrs;
llvm::StringMap<bool> features;
+
bool ok = llvm::sys::getHostCPUFeatures(features);
+
+ #if defined(__i386__) || defined(__x86_64__) || \
+ (defined(__linux__) && (defined(__arm__) || defined(__aarch64__)))
ASSERT_MSG(ok, "llvm::sys::getHostCPUFeatures returned false");
+ #else
+ (void) ok; // getHostCPUFeatures always returns false on other platforms
+ #endif
+
for (auto &feature : features)
{
if (feature.second) { mattrs.push_back(feature.first()); }