diff --git a/CMakeLists.txt b/CMakeLists.txt
index de7706e16c..6ab769034c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,14 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
add_definitions(-DPPSSPP)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_ARCH_64 1)
+ add_definitions(-D_ARCH_64=1)
+else()
+ set(_ARCH_32 1)
+ add_definitions(-D_ARCH_32=1)
+endif()
+
# Detect CPU from CMAKE configuration. Toolchains should set this up
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
set(ARM ON)
@@ -14,6 +22,9 @@ endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv7")
set(ARMV7 ON)
endif()
+if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^x86" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
+ set(X86 ON)
+endif()
# Remove soon?
set(USE_FFMPEG ON)
@@ -22,9 +33,6 @@ if(ARM OR SIMULATOR)
set(USING_EGL ON)
set(MOBILE_DEVICE ON)
endif()
-if (NOT ARM) # Assume x86
- set(X86 ON)
-endif()
include(CheckIncludeFile)
check_include_file(/opt/vc/include/bcm_host.h RPI)
@@ -54,7 +62,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
if (X86 AND NOT MIPS)
- if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ if(_ARCH_64)
add_definitions(-D_M_X64)
else()
add_definitions(-D_M_IX86)
diff --git a/Common/Common.h b/Common/Common.h
index 5bb181534a..827074b388 100644
--- a/Common/Common.h
+++ b/Common/Common.h
@@ -32,9 +32,6 @@
#if !defined(ARM)
#define ARM
#endif
-#endif
-
-#if defined(ARM)
#define _M_ARM32
#endif
@@ -107,13 +104,6 @@ private:
#ifndef MAX_PATH
#define MAX_PATH PATH_MAX
#endif
-#ifdef _LP64
-#define _M_X64 1
-#else
-#ifndef _M_ARM32
-#define _M_IX86 1
-#endif
-#endif
#define __forceinline inline __attribute__((always_inline))
#define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x
diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj
index 6df341d135..058134de48 100644
--- a/Common/Common.vcxproj
+++ b/Common/Common.vcxproj
@@ -70,7 +70,7 @@
Use
Level3
Disabled
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
stdafx.h
MultiThreadedDebugDLL
../native
@@ -95,7 +95,7 @@
Disabled
stdafx.h
MultiThreadedDebugDLL
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
../native
NotSet
Fast
@@ -119,7 +119,7 @@
MaxSpeed
true
true
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
stdafx.h
false
StreamingSIMDExtensions2
@@ -146,7 +146,7 @@
MaxSpeed
true
true
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
stdafx.h
../native
false
@@ -258,4 +258,4 @@
-
\ No newline at end of file
+
diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h
index 049aa8c42b..2d26de15de 100644
--- a/Common/CommonFuncs.h
+++ b/Common/CommonFuncs.h
@@ -31,8 +31,7 @@ template<> struct CompileTimeAssert {};
#include
#include
-// Assume !ARM && !MIPS = x86
-#if !defined(ARM) && !defined(MIPS)
+#if defined(_M_IX86) || defined(_M_X86)
#define Crash() {asm ("int $3");}
#else
#define Crash() {kill(getpid(), SIGINT);}
diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj
index b2c9d6ae0e..7cd30f5fdc 100644
--- a/Core/Core.vcxproj
+++ b/Core/Core.vcxproj
@@ -71,7 +71,7 @@
Level3
Disabled
..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86\include;../common;..;../native;../native/ext/glew;../ext/zlib
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
StreamingSIMDExtensions2
Fast
true
@@ -91,7 +91,7 @@
Level3
Disabled
..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\include;../common;..;../native;../native/ext/glew;../ext/zlib
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
NotSet
Fast
false
@@ -117,7 +117,7 @@
false
StreamingSIMDExtensions2
Fast
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
Speed
MultiThreadedDLL
true
@@ -151,7 +151,7 @@
Speed
false
true
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
false
@@ -657,4 +657,4 @@
-
\ No newline at end of file
+
diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp
index 517864d46a..cfa30e7c80 100644
--- a/Core/MemMap.cpp
+++ b/Core/MemMap.cpp
@@ -124,7 +124,7 @@ static MemoryView views[] =
static const int num_views = sizeof(views) / sizeof(MemoryView);
inline static bool CanIgnoreView(const MemoryView &view) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
// Basically, 32-bit platforms can ignore views that are masked out anyway.
return (view.flags & MV_MIRROR_PREVIOUS) && (view.virtual_address & ~MEMVIEW32_MASK) != 0;
#else
diff --git a/Core/MemMap.h b/Core/MemMap.h
index ab826c7ab3..7af28ab061 100644
--- a/Core/MemMap.h
+++ b/Core/MemMap.h
@@ -93,7 +93,7 @@ enum
SCRATCHPAD_SIZE = 0x00004000,
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
// This wraparound should work for PSP too.
MEMVIEW32_MASK = 0x3FFFFFFF,
#endif
@@ -157,7 +157,7 @@ u64 Read_U64(const u32 _Address);
#endif
inline u8* GetPointerUnchecked(const u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return (u8 *)(base + (address & MEMVIEW32_MASK));
#else
return (u8 *)(base + address);
@@ -175,7 +175,7 @@ void WriteUnchecked_U32(const u32 _Data, const u32 _Address);
#else
inline u32 ReadUnchecked_U32(const u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return *(u32_le *)(base + (address & MEMVIEW32_MASK));
#else
return *(u32_le *)(base + address);
@@ -183,7 +183,7 @@ inline u32 ReadUnchecked_U32(const u32 address) {
}
inline u16 ReadUnchecked_U16(const u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return *(u16_le *)(base + (address & MEMVIEW32_MASK));
#else
return *(u16_le *)(base + address);
@@ -191,7 +191,7 @@ inline u16 ReadUnchecked_U16(const u32 address) {
}
inline u8 ReadUnchecked_U8(const u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return (*(u8 *)(base + (address & MEMVIEW32_MASK)));
#else
return (*(u8 *)(base + address));
@@ -199,7 +199,7 @@ inline u8 ReadUnchecked_U8(const u32 address) {
}
inline void WriteUnchecked_U32(u32 data, u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
*(u32_le *)(base + (address & MEMVIEW32_MASK)) = data;
#else
*(u32_le *)(base + address) = data;
@@ -207,7 +207,7 @@ inline void WriteUnchecked_U32(u32 data, u32 address) {
}
inline void WriteUnchecked_U16(u16 data, u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
*(u16_le *)(base + (address & MEMVIEW32_MASK)) = data;
#else
*(u16_le *)(base + address) = data;
@@ -215,7 +215,7 @@ inline void WriteUnchecked_U16(u16 data, u32 address) {
}
inline void WriteUnchecked_U8(u8 data, u32 address) {
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
(*(u8 *)(base + (address & MEMVIEW32_MASK))) = data;
#else
(*(u8 *)(base + address)) = data;
@@ -325,7 +325,7 @@ struct PSPPointer
inline T &operator*() const
{
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return *(T *)(Memory::base + (ptr & Memory::MEMVIEW32_MASK));
#else
return *(T *)(Memory::base + ptr);
@@ -334,7 +334,7 @@ struct PSPPointer
inline T &operator[](int i) const
{
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return *((T *)(Memory::base + (ptr & Memory::MEMVIEW32_MASK)) + i);
#else
return *((T *)(Memory::base + ptr) + i);
@@ -343,7 +343,7 @@ struct PSPPointer
inline T *operator->() const
{
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return (T *)(Memory::base + (ptr & Memory::MEMVIEW32_MASK));
#else
return (T *)(Memory::base + ptr);
@@ -412,7 +412,7 @@ struct PSPPointer
inline operator T*()
{
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return (T *)(Memory::base + (ptr & Memory::MEMVIEW32_MASK));
#else
return (T *)(Memory::base + ptr);
@@ -421,7 +421,7 @@ struct PSPPointer
inline operator const T*() const
{
-#if defined(_M_IX86) || defined(_M_ARM32)
+#ifdef _ARCH_32
return (const T *)(Memory::base + (ptr & Memory::MEMVIEW32_MASK));
#else
return (const T *)(Memory::base + ptr);
diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj
index 3805dd6357..6309cf2f37 100644
--- a/GPU/GPU.vcxproj
+++ b/GPU/GPU.vcxproj
@@ -88,7 +88,7 @@
Level3
Disabled
../common;..;../native;../native/ext/glew;
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
StreamingSIMDExtensions2
Fast
true
@@ -110,7 +110,7 @@
true
false
false
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)
true
@@ -126,7 +126,7 @@
false
StreamingSIMDExtensions2
Fast
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
Speed
true
false
@@ -151,7 +151,7 @@
false
true
false
- USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
+ USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)
true
@@ -293,4 +293,4 @@
-
\ No newline at end of file
+
diff --git a/Qt/Common.pro b/Qt/Common.pro
index ca8b0481d5..78ae82b794 100644
--- a/Qt/Common.pro
+++ b/Qt/Common.pro
@@ -12,7 +12,7 @@ arm {
$$P/Common/ArmThunk.cpp
HEADERS += $$P/Common/ArmEmitter.h
}
-else {
+i86 {
SOURCES += $$P/Common/ABI.cpp \
$$P/Common/CPUDetect.cpp \
$$P/Common/Thunk.cpp \
diff --git a/Qt/Platform/ArchDetection.pri b/Qt/Platform/ArchDetection.pri
index 13c09b92c1..1feeb17047 100644
--- a/Qt/Platform/ArchDetection.pri
+++ b/Qt/Platform/ArchDetection.pri
@@ -8,15 +8,18 @@ contains(QT_ARCH, ".*86.*")|contains(QMAKE_TARGET.arch, ".*86.*") {
else: QMAKE_ALLFLAGS += /arch:SSE2
CONFIG += i86
- contains(QT_ARCH, x86_64)|contains(QMAKE_TARGET.arch, x86_64): PLATFORM_ARCH = x86_64
- else: PLATFORM_ARCH = x86
-
- # Fix 32-bit/64-bit defines
- equals(PLATFORM_ARCH, x86_64): DEFINES += _M_X64
- else: DEFINES += _M_IX86
+ contains(QT_ARCH, x86_64)|contains(QMAKE_TARGET.arch, x86_64) {
+ PLATFORM_ARCH = x86_64
+ DEFINES += _M_X64 _ARCH_64
+ }
+ else {
+ PLATFORM_ARCH = x86
+ DEFINES += _M_IX86 _ARCH_32
+ }
} else:contains(QT_ARCH, ".*arm.*")|contains(QMAKE_TARGET.arch, ".*arm.*") {
- DEFINES += ARM
+ DEFINES += ARM _ARCH_32
CONFIG += arm
+
# Will need to see how QT_ARCH and QMAKE_TARGET.arch are populated for various ARM platforms.
symbian: PLATFORM_ARCH="armv6"
else {
@@ -27,12 +30,19 @@ contains(QT_ARCH, ".*86.*")|contains(QMAKE_TARGET.arch, ".*86.*") {
QMAKE_ALLFLAGS_DEBUG += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -ftree-vectorize
QMAKE_ALLFLAGS_RELEASE += -march=armv7-a -mtune=cortex-a8 -mfpu=neon -ftree-vectorize
}
- # TODO: armv8?
+ # TODO: aarch32/64?
} else {
# Generic
- warning("You are using an untested arch. Only x86 and ARM CPUs are supported")
+ warning("You are using an untested arch $${QT_ARCH}. Only x86 and ARM CPUs are supported")
+ # For now MIPS is both generic and mips
+ contains(QT_ARCH, ".*mips.*") {
+ DEFINES += MIPS
+ CONFIG += mips
+ PLATFORM_ARCH="mips32"
+ }
DEFINES += GENERIC_ARCH
CONFIG += generic
+ DEFINES += _ARCH_32
}