From 27b70f072695ea2b516f4ddb593b61495903af4e Mon Sep 17 00:00:00 2001 From: Sacha Date: Sun, 10 Mar 2013 13:24:05 +1000 Subject: [PATCH] Add MIPS/Loongson support --- CMakeLists.txt | 11 ++++++++++- Common/CPUDetect.cpp | 4 ++-- Common/CommonFuncs.h | 6 +++--- Common/MathUtil.h | 2 +- native | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 084d798d19..0ba3a1bb42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,10 @@ if(BLACKBERRY) set(ARM ON) endif() +if(LOONGSON) + set(MIPS ON) # MIPS + x86 for now +endif() + if(ARM) set(USING_GLES2 ON) else() # Assume x86 @@ -30,6 +34,7 @@ endif() # User-editable options (go into CMakeCache.txt) option(ARM "Set to ON if targeting an ARM processor" ${ARM}) +option(MIPS "Set to ON if targeting a MIPS processor" ${MIPS}) option(X86 "Set to ON if targeting an X86 processor" ${X86}) option(ANDROID "Set to ON if targeting an Android device" ${ANDROID}) option(BLACKBERRY "Set to ON if targeting a Blackberry device" ${BLACKBERRY}) @@ -105,6 +110,10 @@ if(USING_GLES2) add_definitions(-DUSING_GLES2) endif() +if(MIPS) + add_definitions(-DMIPS) +endif() + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG") @@ -127,7 +136,7 @@ if(NOT MSVC) add_definitions(-D_QNX_SOURCE=1 -D_C99=1) endif() - if(X86) + if(X86 AND NOT MIPS) # enable sse2 code generation add_definitions(-msse2) endif() diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index c43c7fc5d7..62176d6c17 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -29,14 +29,14 @@ #undef _interlockedbittestandreset64 #else -#ifndef _M_GENERIC +#if !defined(_M_GENERIC) && !defined(MIPS) #include #endif #if defined __FreeBSD__ #include #include -#else +#elif !defined(MIPS) static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h index e256aab5dd..89631e5e74 100644 --- a/Common/CommonFuncs.h +++ b/Common/CommonFuncs.h @@ -24,7 +24,7 @@ #define SLEEP(x) usleep(x*1000) #endif -#ifdef IOS +#if defined(IOS) || defined(MIPS) #include #endif @@ -51,8 +51,8 @@ template<> struct CompileTimeAssert {}; #ifdef GEKKO #define Crash() #else -// Assume !ARM = x86 -#if !defined(ARM) +// Assume !ARM && !MIPS = x86 +#if !defined(ARM) && !defined(MIPS) #define Crash() {asm ("int $3");} #else #define Crash() {kill( getpid(), SIGINT ) ; } diff --git a/Common/MathUtil.h b/Common/MathUtil.h index 99e6d77a5c..1f594e4a6a 100644 --- a/Common/MathUtil.h +++ b/Common/MathUtil.h @@ -20,7 +20,7 @@ #include "Common.h" -#ifndef ARM +#if !defined(ARM) && !defined(MIPS) #define USE_SSE #endif diff --git a/native b/native index 7bc8374c88..b8100e0238 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 7bc8374c8816efe0fab4a9cd5959ca2d2fcd09d8 +Subproject commit b8100e023858a9b2a217ac7f38cb78cca983b952