diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index 62176d6c17..55d380123f 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -37,53 +37,37 @@ #include #include #elif !defined(MIPS) -static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +void __cpuid(int regs[4], int cpuid_leaf) { -#if defined _M_GENERIC - (*eax) = (*ebx) = (*ecx) = (*edx) = 0; -#elif defined _LP64 - // Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to - // restored at the end of the asm block. - __asm__ ( - "cpuid;" - "movl %%ebx,%1;" - : "=a" (*eax), - "=S" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "a" (*eax) - : "rbx" - ); -#else - __asm__ ( - "cpuid;" - "movl %%ebx,%1;" - : "=a" (*eax), - "=S" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "a" (*eax) - : "ebx" - ); + int eax, ebx, ecx, edx; + asm volatile ( +#if defined(__i386__) + "pushl %%ebx;\n\t" #endif -} -#endif /* defined __FreeBSD__ */ + "movl %4, %%eax;\n\t" + "cpuid;\n\t" + "movl %%eax, %0;\n\t" + "movl %%ebx, %1;\n\t" + "movl %%ecx, %2;\n\t" + "movl %%edx, %3;\n\t" +#if defined(__i386__) + "popl %%ebx;\n\t" +#endif + :"=m" (eax), "=m" (ebx), "=m" (ecx), "=m" (edx) + :"r" (cpuid_leaf) + :"%eax", +#if !defined(__i386__) + "%ebx", +#endif + "%ecx", "%edx"); -static void __cpuid(int info[4], int x) -{ -#if defined __FreeBSD__ - do_cpuid((unsigned int)x, (unsigned int*)info); -#else - unsigned int eax = x, ebx = 0, ecx = 0, edx = 0; - do_cpuid(&eax, &ebx, &ecx, &edx); - info[0] = eax; - info[1] = ebx; - info[2] = ecx; - info[3] = edx; -#endif + regs[0] = eax; + regs[1] = ebx; + regs[2] = ecx; + regs[3] = edx; } +#endif #endif #include "Common.h" diff --git a/Common/Common.h b/Common/Common.h index 16b0fd342f..6504c9b613 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -29,6 +29,12 @@ #pragma warning (disable:4100) #endif +#ifdef __arm__ +#if !defined(ARM) +#define ARM +#endif +#endif + #if defined(ARM) #define _M_ARM32 #endif diff --git a/Common/CommonTypes.h b/Common/CommonTypes.h index 8b31eea6e7..0904383fa6 100644 --- a/Common/CommonTypes.h +++ b/Common/CommonTypes.h @@ -23,6 +23,12 @@ #ifndef _COMMONTYPES_H_ #define _COMMONTYPES_H_ +#ifdef __arm__ +#if !defined(ARM) +#define ARM +#endif +#endif + #ifdef _WIN32 typedef unsigned __int8 u8; diff --git a/Common/Log.h b/Common/Log.h index c01835df7d..f0c87936e6 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -17,6 +17,12 @@ #pragma once +#ifdef __arm__ +#if !defined(ARM) +#define ARM +#endif +#endif + #define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself. #define ERROR_LEVEL 2 // Important errors. #define WARNING_LEVEL 3 // Something is suspicious. diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index f2e57473b9..86e499bd10 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -387,4 +387,4 @@ void Jit::Comp_DoNothing(u32 op) { } // mov eax, [table+eax] // mov dreg, [eax+offreg] -} +} \ No newline at end of file diff --git a/Core/MIPS/JitCommon/JitCommon.h b/Core/MIPS/JitCommon/JitCommon.h index a8630e6fbe..d992a1e50d 100644 --- a/Core/MIPS/JitCommon/JitCommon.h +++ b/Core/MIPS/JitCommon/JitCommon.h @@ -17,6 +17,8 @@ #pragma once +#include "Common/Common.h" + #if defined(ARM) #include "../ARM/ArmJit.h" #else diff --git a/Core/MIPS/MIPSInt.cpp b/Core/MIPS/MIPSInt.cpp index 8d423db81f..1b5b4e346d 100644 --- a/Core/MIPS/MIPSInt.cpp +++ b/Core/MIPS/MIPSInt.cpp @@ -19,6 +19,7 @@ #include +#include "Common/Common.h" #include "../Core.h" #include "MIPS.h" #include "MIPSInt.h" diff --git a/android/jni/Android.mk b/android/jni/Android.mk index b7f7982c22..97994acc10 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := ppsspp_jni NATIVE := ../../native SRC := ../.. -LOCAL_CFLAGS := -DUSE_PROFILER -DARM -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O2 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math +LOCAL_CFLAGS := -DUSE_PROFILER -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O2 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math # yes, it's really CPPFLAGS for C++ LOCAL_CPPFLAGS := -std=gnu++0x LOCAL_C_INCLUDES := \ @@ -43,13 +43,81 @@ LOCAL_LDLIBS := -lz -lGLESv2 -ldl -llog # $(SRC)/Core/EmuThread.cpp \ +# http://software.intel.com/en-us/articles/getting-started-on-optimizing-ndk-project-for-multiple-cpu-architectures + + +ifeq ($(TARGET_ARCH_ABI),x86) + +LOCAL_CFLAGS := $(LOCAL_CFLAGS) -D_M_IX86 + +ARCH_FILES := \ + $(SRC)/Common/ABI.cpp \ + $(SRC)/Common/x64Emitter.cpp \ + $(SRC)/Common/CPUDetect.cpp \ + $(SRC)/Common/Thunk.cpp \ + $(SRC)/Core/MIPS/x86/JitCache.cpp \ + $(SRC)/Core/MIPS/x86/CompALU.cpp \ + $(SRC)/Core/MIPS/x86/CompBranch.cpp \ + $(SRC)/Core/MIPS/x86/CompFPU.cpp \ + $(SRC)/Core/MIPS/x86/CompLoadStore.cpp \ + $(SRC)/Core/MIPS/x86/CompVFPU.cpp \ + $(SRC)/Core/MIPS/x86/Asm.cpp \ + $(SRC)/Core/MIPS/x86/Jit.cpp \ + $(SRC)/Core/MIPS/x86/RegCache.cpp \ + $(SRC)/Core/MIPS/x86/RegCacheFPU.cpp +endif + +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) + +LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DARM -DARMV7 + +ARCH_FILES := \ + $(SRC)/Common/ArmEmitter.cpp \ + $(SRC)/Common/ArmCPUDetect.cpp \ + $(SRC)/Common/ArmThunk.cpp \ + $(SRC)/Core/MIPS/ARM/ArmJitCache.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompALU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompBranch.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompFPU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompLoadStore.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompVFPU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmAsm.cpp \ + $(SRC)/Core/MIPS/ARM/ArmJit.cpp \ + $(SRC)/Core/MIPS/ARM/ArmRegCache.cpp \ + $(SRC)/Core/MIPS/ARM/ArmRegCacheFPU.cpp \ + ArmEmitterTest.cpp \ + +endif + +ifeq ($(TARGET_ARCH_ABI),armeabi) + +LOCAL_CFLAGS := $(LOCAL_CFLAGS) -DARM + +ARCH_FILES := \ + $(SRC)/Common/ArmEmitter.cpp \ + $(SRC)/Common/ArmCPUDetect.cpp \ + $(SRC)/Common/ArmThunk.cpp \ + $(SRC)/Core/MIPS/ARM/ArmJitCache.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompALU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompBranch.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompFPU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompLoadStore.cpp \ + $(SRC)/Core/MIPS/ARM/ArmCompVFPU.cpp \ + $(SRC)/Core/MIPS/ARM/ArmAsm.cpp \ + $(SRC)/Core/MIPS/ARM/ArmJit.cpp \ + $(SRC)/Core/MIPS/ARM/ArmRegCache.cpp \ + $(SRC)/Core/MIPS/ARM/ArmRegCacheFPU.cpp \ + ArmEmitterTest.cpp \ + +endif + LOCAL_SRC_FILES := \ + $(ARCH_FILES) \ NativeApp.cpp \ EmuScreen.cpp \ MenuScreens.cpp \ UIShader.cpp \ GamepadEmu.cpp \ - ArmEmitterTest.cpp \ TestRunner.cpp \ ui_atlas.cpp \ $(SRC)/native/android/app-android.cpp \ @@ -62,9 +130,6 @@ LOCAL_SRC_FILES := \ $(SRC)/ext/libkirk/kirk_engine.c \ $(SRC)/ext/snappy/snappy-c.cpp \ $(SRC)/ext/snappy/snappy.cpp \ - $(SRC)/Common/ArmEmitter.cpp \ - $(SRC)/Common/ArmCPUDetect.cpp \ - $(SRC)/Common/ArmThunk.cpp \ $(SRC)/Common/LogManager.cpp \ $(SRC)/Common/MemArena.cpp \ $(SRC)/Common/MemoryUtil.cpp \ @@ -179,16 +244,6 @@ LOCAL_SRC_FILES := \ $(SRC)/Core/MIPS/MIPSCodeUtils.cpp \ $(SRC)/Core/MIPS/MIPSDebugInterface.cpp \ $(SRC)/Core/MIPS/JitCommon/JitCommon.cpp \ - $(SRC)/Core/MIPS/ARM/ArmJitCache.cpp \ - $(SRC)/Core/MIPS/ARM/ArmCompALU.cpp \ - $(SRC)/Core/MIPS/ARM/ArmCompBranch.cpp \ - $(SRC)/Core/MIPS/ARM/ArmCompFPU.cpp \ - $(SRC)/Core/MIPS/ARM/ArmCompLoadStore.cpp \ - $(SRC)/Core/MIPS/ARM/ArmCompVFPU.cpp \ - $(SRC)/Core/MIPS/ARM/ArmAsm.cpp \ - $(SRC)/Core/MIPS/ARM/ArmJit.cpp \ - $(SRC)/Core/MIPS/ARM/ArmRegCache.cpp \ - $(SRC)/Core/MIPS/ARM/ArmRegCacheFPU.cpp \ $(SRC)/Core/Util/BlockAllocator.cpp \ $(SRC)/Core/Util/ppge_atlas.cpp \ $(SRC)/Core/Util/PPGeDraw.cpp \ diff --git a/android/jni/Application.mk b/android/jni/Application.mk index d18d3a46ff..e2988a7571 100644 --- a/android/jni/Application.mk +++ b/android/jni/Application.mk @@ -1,4 +1,4 @@ APP_STL := stlport_static -APP_ABI := armeabi-v7a armeabi +APP_ABI := armeabi-v7a armeabi x86 #APP_ABI := armeabi-v7a diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index b58160f2e9..203a212d8f 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -50,7 +50,9 @@ #include "MenuScreens.h" #include "UIShader.h" +#ifdef ARM #include "ArmEmitterTest.h" +#endif Texture *uiTexture; @@ -162,7 +164,7 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo *app_dir_name = "ppsspp"; *landscape = true; -#if defined(ANDROID) +#if defined(ARM) && defined(ANDROID) ArmEmitterTest(); #endif } diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index a710d02017..9426d002db 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -15,4 +15,4 @@ public class PpssppActivity extends NativeActivity { { return false; } -} \ No newline at end of file +} diff --git a/native b/native index b73af1e9c4..4fef50245d 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit b73af1e9c441e6667ab2f05df31cee90ce0cae2a +Subproject commit 4fef50245deeb14253372704684586aa85e9e21f