From 20622c0194bd034fe857414496a1139d67b53ae4 Mon Sep 17 00:00:00 2001 From: Gordana Cmiljanovic Date: Mon, 5 Nov 2018 15:00:11 +0100 Subject: [PATCH] [MIPS] Add support for 64b MIPS architecture * LLVM reactor backend: requires LLVM 7.0 * Subzero reactor backend: not supported Bug: b/117854176 Change-Id: I7b76ebf854f65c2d111552552bd5a81c049d3b50 Reviewed-on: https://swiftshader-review.googlesource.com/c/22308 Reviewed-by: Nicolas Capens Tested-by: Gordana Cmiljanovic --- BUILD.gn | 12 ++++++++++++ CMakeLists.txt | 7 ++++++- src/Reactor/BUILD.gn | 5 +++-- src/Reactor/LLVMReactor.cpp | 6 +++++- .../llvm-7.0/configs/linux/include/llvm/Config/config.h | 2 ++ .../llvm-7.0/configs/linux/include/llvm/Config/llvm-config.h | 4 ++++ third_party/llvm-7.0/scripts/update.py | 1 + 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 672e51ea7..027adfd76 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -104,6 +104,13 @@ config("swiftshader_config") { "-mhard-float", "-mfp32", ] + } else if (target_cpu == "mips64el" && current_cpu == target_cpu) { + cflags += [ + "-march=mips64el", + "-mcpu=mips64r2", + "-mabi=64", + "-fPIC", + ] } if (is_linux) { @@ -114,6 +121,11 @@ config("swiftshader_config") { "-Wl,--hash-style=sysv", "-mips32r2", ] + } else if (target_cpu == "mips64el") { + ldflags += [ + "-Wl,--hash-style=sysv", + "-mips64r2", + ] } else { ldflags += [ "-Wl,--hash-style=both" ] } diff --git a/CMakeLists.txt b/CMakeLists.txt index fb94ffe0f..0cf0ffcac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,7 @@ macro(set_shared_library_export_map TARGET DIR) # Don't allow symbols to be overridden by another module. set_property(TARGET ${TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -fvisibility=protected") - if(ARCH STREQUAL "mipsel") + if(ARCH STREQUAL "mipsel" OR ARCH STREQUAL "mips64el") # MIPS supports sysv hash-style only. set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--hash-style=sysv") else() @@ -231,6 +231,11 @@ else() set_cpp_flag("-mhard-float") set_cpp_flag("-mfp32") endif() + if(ARCH STREQUAL "mips64el") + set_cpp_flag("-march=mips64r2") + set_cpp_flag("-mabi=64") + set_cpp_flag("-fPIC") + endif() if(LINUX) set_cpp_flag("-DUSE_X11=1") diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn index 1ad06e46e..e05154e35 100644 --- a/src/Reactor/BUILD.gn +++ b/src/Reactor/BUILD.gn @@ -15,8 +15,9 @@ import("../swiftshader.gni") declare_args() { - # Subzero produces smaller binaries, but doesn't support ARM64. - use_swiftshader_with_subzero = (target_cpu != "arm64") + # Subzero produces smaller binaries, but doesn't support ARM64 and MIPS64. + use_swiftshader_with_subzero = + target_cpu != "arm64" && target_cpu != "mips64el" } # Need a separate config to ensure the warnings are added to the end. diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp index f7cbfabd7..6f99e6e9e 100644 --- a/src/Reactor/LLVMReactor.cpp +++ b/src/Reactor/LLVMReactor.cpp @@ -830,7 +830,11 @@ namespace rr #elif defined(__arm__) static const char arch[] = "arm"; #elif defined(__mips__) - static const char arch[] = "mipsel"; + #if defined(__mips64) + static const char arch[] = "mips64el"; + #else + static const char arch[] = "mipsel"; + #endif #else #error "unknown architecture" #endif diff --git a/third_party/llvm-7.0/configs/linux/include/llvm/Config/config.h b/third_party/llvm-7.0/configs/linux/include/llvm/Config/config.h index bedb30641..ff20611c8 100644 --- a/third_party/llvm-7.0/configs/linux/include/llvm/Config/config.h +++ b/third_party/llvm-7.0/configs/linux/include/llvm/Config/config.h @@ -301,6 +301,8 @@ #define LLVM_DEFAULT_TARGET_TRIPLE "aarch64-linux-gnu" #elif defined(__mips__) #define LLVM_DEFAULT_TARGET_TRIPLE "mipsel-linux-gnu" +#elif defined(__mips64) +#define LLVM_DEFAULT_TARGET_TRIPLE "mips64el-linux-gnuabi64" #else #error "unknown architecture" #endif diff --git a/third_party/llvm-7.0/configs/linux/include/llvm/Config/llvm-config.h b/third_party/llvm-7.0/configs/linux/include/llvm/Config/llvm-config.h index 174aca952..0aa109493 100644 --- a/third_party/llvm-7.0/configs/linux/include/llvm/Config/llvm-config.h +++ b/third_party/llvm-7.0/configs/linux/include/llvm/Config/llvm-config.h @@ -31,6 +31,8 @@ #define LLVM_DEFAULT_TARGET_TRIPLE "aarch64-linux-gnu" #elif defined(__mips__) #define LLVM_DEFAULT_TARGET_TRIPLE "mipsel-linux-gnu" +#elif defined(__mips64) +#define LLVM_DEFAULT_TARGET_TRIPLE "mips64el-linux-gnuabi64" #else #error "unknown architecture" #endif @@ -52,6 +54,8 @@ #define LLVM_HOST_TRIPLE "aarch64-linux-gnu" #elif defined(__mips__) #define LLVM_HOST_TRIPLE "mipsel-linux-gnu" +#elif defined(__mips64) +#define LLVM_HOST_TRIPLE "mips64el-linux-gnuabi64" #else #error "unknown architecture" #endif diff --git a/third_party/llvm-7.0/scripts/update.py b/third_party/llvm-7.0/scripts/update.py index 0913ee0ab..1ad1fb9c6 100755 --- a/third_party/llvm-7.0/scripts/update.py +++ b/third_party/llvm-7.0/scripts/update.py @@ -49,6 +49,7 @@ LLVM_TRIPLES = { ('__arm__', 'armv7-linux-gnueabihf'), ('__aarch64__', 'aarch64-linux-gnu'), ('__mips__', 'mipsel-linux-gnu'), + ('__mips64', 'mips64el-linux-gnuabi64'), ], 'darwin': [ ('__x86_64__', 'x86_64-apple-darwin'), -- 2.11.0