From a3cd36acff47be80ba1cbf60f556df3f84cdf20c Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 20 Nov 2021 17:34:28 +0100 Subject: [PATCH] Add CMAKE support for cross-compiling to MIPS32 --- cmake/arch.cmake | 2 +- cmake/cc.cmake | 5 +++++ cmake/prebuild.cmake | 30 +++++++++++++++++++++++++++++- cmake/system_check.cmake | 6 ++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/cmake/arch.cmake b/cmake/arch.cmake index 57ee5a4fb..d468eb60b 100644 --- a/cmake/arch.cmake +++ b/cmake/arch.cmake @@ -109,7 +109,7 @@ if (${ARCH} STREQUAL "ia64") endif () endif () -if (MIPS64) +if (MIPS32 OR MIPS64) set(NO_BINARY_MODE 1) endif () diff --git a/cmake/cc.cmake b/cmake/cc.cmake index 0ab1d4c1b..fdbb40ef6 100644 --- a/cmake/cc.cmake +++ b/cmake/cc.cmake @@ -15,6 +15,11 @@ if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "LS if (NO_BINARY_MODE) + if (MIPS32) + set(CCOMMON_OPT "${CCOMMON_OPT} -mabi=32") + set(BINARY_DEFINED 1) + endif () + if (MIPS64) if (BINARY64) set(CCOMMON_OPT "${CCOMMON_OPT} -mabi=64") diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake index d86e10035..259d9c738 100644 --- a/cmake/prebuild.cmake +++ b/cmake/prebuild.cmake @@ -416,7 +416,7 @@ endif () set(ZGEMM_UNROLL_M 4) set(ZGEMM_UNROLL_N 4) set(SYMV_P 16) -elseif ("${TCORE}" STREQUAL "VORTEX") + elseif ("${TCORE}" STREQUAL "VORTEX") file(APPEND ${TARGET_CONF_TEMP} "#define ARMV8\n" "#define L1_CODE_SIZE\t32768\n" @@ -439,6 +439,34 @@ elseif ("${TCORE}" STREQUAL "VORTEX") set(ZGEMM_UNROLL_M 4) set(ZGEMM_UNROLL_N 4) set(SYMV_P 16) + elseif ("${TCORE}" STREQUAL "P5600") + file(APPEND ${TARGET_CONF_TEMP} + "#define L2_SIZE 1048576\n" + "#define DTB_SIZE 4096\n" + "#define DTB_DEFAULT_ENTRIES 64\n") + set(SGEMM_UNROLL_M 2) + set(SGEMM_UNROLL_N 2) + set(DGEMM_UNROLL_M 2) + set(DGEMM_UNROLL_N 2) + set(CGEMM_UNROLL_M 2) + set(CGEMM_UNROLL_N 2) + set(ZGEMM_UNROLL_M 2) + set(ZGEMM_UNROLL_N 2) + set(SYMV_P 16) + elseif ("${TCORE}" MATCHES "MIPS") + file(APPEND ${TARGET_CONF_TEMP} + "#define L2_SIZE 262144\n" + "#define DTB_SIZE 4096\n" + "#define DTB_DEFAULT_ENTRIES 64\n") + set(SGEMM_UNROLL_M 2) + set(SGEMM_UNROLL_N 2) + set(DGEMM_UNROLL_M 2) + set(DGEMM_UNROLL_N 2) + set(CGEMM_UNROLL_M 2) + set(CGEMM_UNROLL_N 2) + set(ZGEMM_UNROLL_M 2) + set(ZGEMM_UNROLL_N 2) + set(SYMV_P 16) elseif ("${TCORE}" STREQUAL "POWER6") file(APPEND ${TARGET_CONF_TEMP} "#define L1_DATA_SIZE 32768\n" diff --git a/cmake/system_check.cmake b/cmake/system_check.cmake index 72c48db37..f71ec4555 100644 --- a/cmake/system_check.cmake +++ b/cmake/system_check.cmake @@ -73,6 +73,8 @@ elseif (${CMAKE_CROSSCOMPILING}) else () set(X86 1) endif() + elseif (${TARGET} STREQUAL "P5600" OR ${TARGET} MATCHES "MIPS.*") + set(MIPS32 1) elseif (${TARGET} STREQUAL "ARMV7") set(ARM 1) else() @@ -88,6 +90,10 @@ elseif(X86) set(ARCH "x86") elseif(PPC) set(ARCH "power") +elseif(MIPS32) + set(ARCH "mips") +elseif(MIPS64) + set(ARCH "mips64") elseif(ARM) set(ARCH "arm") elseif(ARM64)