summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2015-02-24 01:31:45 +0100
committerPierre Bourdon <delroth@gmail.com>2015-02-24 01:31:45 +0100
commitb8edd8aedc75ae4e2abd8c5558af94e98c7bebcb (patch)
treec6832e8ac25a78ed769b5b76a1d9e19d5b6e2b27 /Source/Core
parent7a61bd5519ccc7a648376f4c6b9a5ab2ca3c75da (diff)
parentdaf4aa09471a0113315fa49aa8409bfc9ba947fd (diff)
Merge pull request #2101 from Tilka/intrinsics
Clean up the intrinsics #ifdef mess with a common header
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Atomic_Win32.h2
-rw-r--r--Source/Core/Common/Common.h16
-rw-r--r--Source/Core/Common/CommonFuncs.h18
-rw-r--r--Source/Core/Common/Hash.cpp6
-rw-r--r--Source/Core/Common/Intrinsics.h51
-rw-r--r--Source/Core/Common/x64CPUDetect.cpp8
-rw-r--r--Source/Core/Common/x64FPURoundMode.cpp7
-rw-r--r--Source/Core/Core/DSP/DSPHWInterface.cpp5
-rw-r--r--Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp3
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp3
-rw-r--r--Source/Core/VideoBackends/OGL/TextureCache.cpp4
-rw-r--r--Source/Core/VideoCommon/TextureDecoder_x64.cpp8
-rw-r--r--Source/Core/VideoCommon/VertexLoaderX64.cpp7
13 files changed, 62 insertions, 76 deletions
diff --git a/Source/Core/Common/Atomic_Win32.h b/Source/Core/Common/Atomic_Win32.h
index ee763aaea2..17afb8c8cc 100644
--- a/Source/Core/Common/Atomic_Win32.h
+++ b/Source/Core/Common/Atomic_Win32.h
@@ -6,10 +6,10 @@
#pragma once
-#include <intrin.h>
#include <Windows.h>
#include "Common/Common.h"
+#include "Common/Intrinsics.h"
// Atomic operations are performed in a single step by the CPU. It is
// impossible for other threads to see the operation "half-done."
diff --git a/Source/Core/Common/Common.h b/Source/Core/Common/Common.h
index 1dcf4a7ce4..29dbbec1ce 100644
--- a/Source/Core/Common/Common.h
+++ b/Source/Core/Common/Common.h
@@ -129,22 +129,6 @@ private:
// wxWidgets does not have a true dummy macro for this.
#define _trans(a) a
-#if defined _M_GENERIC
-# define _M_SSE 0x0
-#elif defined __GNUC__
-# if defined __SSE4_2__
-# define _M_SSE 0x402
-# elif defined __SSE4_1__
-# define _M_SSE 0x401
-# elif defined __SSSE3__
-# define _M_SSE 0x301
-# elif defined __SSE3__
-# define _M_SSE 0x300
-# endif
-#elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008
-# define _M_SSE 0x402
-#endif
-
// Host communication.
enum HOST_COMM
{
diff --git a/Source/Core/Common/CommonFuncs.h b/Source/Core/Common/CommonFuncs.h
index 7a7a19a7b4..bb11f87dc4 100644
--- a/Source/Core/Common/CommonFuncs.h
+++ b/Source/Core/Common/CommonFuncs.h
@@ -34,24 +34,6 @@ struct ArraySizeImpl : public std::extent<T>
#define b32(x) (b16(x) | (b16(x) >>16) )
#define ROUND_UP_POW2(x) (b32(x - 1) + 1)
-#ifndef __GNUC_PREREQ
- #define __GNUC_PREREQ(a, b) 0
-#endif
-
-#if (defined __GNUC__ && !__GNUC_PREREQ(4,9)) && \
- !defined __SSSE3__ && defined _M_X86
-#include <emmintrin.h>
-static __inline __m128i __attribute__((__always_inline__))
-_mm_shuffle_epi8(__m128i a, __m128i mask)
-{
- __m128i result;
- __asm__("pshufb %1, %0"
- : "=x" (result)
- : "xm" (mask), "0" (a));
- return result;
-}
-#endif
-
#ifndef _WIN32
#include <errno.h>
diff --git a/Source/Core/Common/Hash.cpp b/Source/Core/Common/Hash.cpp
index 63caced040..7efc4549d7 100644
--- a/Source/Core/Common/Hash.cpp
+++ b/Source/Core/Common/Hash.cpp
@@ -4,11 +4,9 @@
#include <algorithm>
#include "Common/CommonFuncs.h"
-#include "Common/Hash.h"
-#if _M_SSE >= 0x402
#include "Common/CPUDetect.h"
-#include <nmmintrin.h>
-#endif
+#include "Common/Hash.h"
+#include "Common/Intrinsics.h"
static u64 (*ptrHashFunction)(const u8 *src, u32 len, u32 samples) = &GetMurmurHash3;
diff --git a/Source/Core/Common/Intrinsics.h b/Source/Core/Common/Intrinsics.h
new file mode 100644
index 0000000000..911692e6de
--- /dev/null
+++ b/Source/Core/Common/Intrinsics.h
@@ -0,0 +1,51 @@
+// Copyright 2015 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#ifdef _M_X86
+
+#ifdef _MSC_VER
+#include <intrin.h>
+#else
+#include <x86intrin.h>
+#endif
+
+#ifndef __GNUC_PREREQ
+#define __GNUC_PREREQ(maj, min) 0
+#endif
+
+#if defined __GNUC__ && !__GNUC_PREREQ(4, 9) && !defined __SSSE3__
+// GCC <= 4.8 only enables intrinsics based on the command-line.
+// GCC >= 4.9 always declares all intrinsics.
+// We only want to require SSE2 and thus compile with -msse2,
+// so define the one post-SSE2 intrinsic that we dispatch at runtime.
+static __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+_mm_shuffle_epi8(__m128i a, __m128i mask)
+{
+ __m128i result;
+ __asm__("pshufb %1, %0"
+ : "=x" (result)
+ : "xm" (mask), "0" (a));
+ return result;
+}
+#endif
+
+#if defined _M_GENERIC
+# define _M_SSE 0
+#elif _MSC_VER || __INTEL_COMPILER
+# define _M_SSE 0x402
+#elif defined __GNUC__
+# if defined __SSE4_2__
+# define _M_SSE 0x402
+# elif defined __SSE4_1__
+# define _M_SSE 0x401
+# elif defined __SSSE3__
+# define _M_SSE 0x301
+# elif defined __SSE3__
+# define _M_SSE 0x300
+# endif
+#endif
+
+#endif // _M_X86
diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp
index 8ad8046c8b..d4d3eba05e 100644
--- a/Source/Core/Common/x64CPUDetect.cpp
+++ b/Source/Core/Common/x64CPUDetect.cpp
@@ -7,13 +7,9 @@
#include "Common/CommonTypes.h"
#include "Common/CPUDetect.h"
+#include "Common/Intrinsics.h"
-#ifdef _WIN32
-#include <intrin.h>
-#else
-
-//#include <config/i386/cpuid.h>
-#include <xmmintrin.h>
+#ifndef _WIN32
#if defined __FreeBSD__
#include <sys/types.h>
diff --git a/Source/Core/Common/x64FPURoundMode.cpp b/Source/Core/Common/x64FPURoundMode.cpp
index 90143d7e13..b04579b850 100644
--- a/Source/Core/Common/x64FPURoundMode.cpp
+++ b/Source/Core/Common/x64FPURoundMode.cpp
@@ -7,12 +7,7 @@
#include "Common/CommonTypes.h"
#include "Common/CPUDetect.h"
#include "Common/FPURoundMode.h"
-
-#ifdef _WIN32
-# include <mmintrin.h>
-#else
-# include <xmmintrin.h>
-#endif
+#include "Common/Intrinsics.h"
namespace FPURoundMode
{
diff --git a/Source/Core/Core/DSP/DSPHWInterface.cpp b/Source/Core/Core/DSP/DSPHWInterface.cpp
index fc133484b8..b9d41f8c1e 100644
--- a/Source/Core/Core/DSP/DSPHWInterface.cpp
+++ b/Source/Core/Core/DSP/DSPHWInterface.cpp
@@ -25,6 +25,7 @@
#include "Common/Atomic.h"
#include "Common/CPUDetect.h"
+#include "Common/Intrinsics.h"
#include "Common/MemoryUtil.h"
#include "Common/Thread.h"
@@ -36,10 +37,6 @@
#include "Core/DSP/DSPInterpreter.h"
#include "Core/DSP/DSPTables.h"
-#if _M_SSE >= 0x301 && !(defined __GNUC__ && !defined __SSSE3__)
-#include <tmmintrin.h>
-#endif
-
static void gdsp_do_dma();
void gdsp_ifx_init()
diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
index d5e3646f18..3f2c86a0e2 100644
--- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
+++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp
@@ -9,6 +9,7 @@
#include <string>
#include "Common/Common.h"
+#include "Common/Intrinsics.h"
#include "Common/StdMakeUnique.h"
#include "Common/StringUtil.h"
#include "Core/PatchEngine.h"
@@ -135,11 +136,9 @@ ps_adds1
#ifdef _WIN32
#include <windows.h>
-#include <intrin.h>
#else
#include <memory>
#include <stdint.h>
-#include <x86intrin.h>
#if defined(__clang__)
#if !__has_builtin(__builtin_ia32_rdtsc)
diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
index dfda1c3917..6246dfa2ae 100644
--- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
+++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp
@@ -2,9 +2,8 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <emmintrin.h>
-
#include "Common/CommonTypes.h"
+#include "Common/Intrinsics.h"
#include "Common/MathUtil.h"
#include "Core/HW/MMIO.h"
diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp
index e579909a9d..bfed930245 100644
--- a/Source/Core/VideoBackends/OGL/TextureCache.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp
@@ -6,10 +6,6 @@
#include <fstream>
#include <vector>
-#ifdef _WIN32
-#include <intrin.h>
-#endif
-
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Hash.h"
diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
index 9d0b75582f..4a1f0a36a6 100644
--- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp
+++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp
@@ -8,18 +8,12 @@
#include "Common/Common.h"
//#include "VideoCommon.h" // to get debug logs
#include "Common/CPUDetect.h"
+#include "Common/Intrinsics.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/VideoConfig.h"
-#if _M_SSE >= 0x401
-#include <smmintrin.h>
-#include <emmintrin.h>
-#elif _M_SSE >= 0x301 && !(defined __GNUC__ && !defined __SSSE3__)
-#include <tmmintrin.h>
-#endif
-
// This avoids a harmless warning from a system header in Clang;
// see http://llvm.org/bugs/show_bug.cgi?id=16093
#if defined(__clang__) && (__clang_major__ * 100 + __clang_minor__ < 304)
diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp
index 5c962095bd..ae6623db90 100644
--- a/Source/Core/VideoCommon/VertexLoaderX64.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp
@@ -1,10 +1,5 @@
-#ifdef _MSC_VER
-#include <intrin.h>
-#else
-#include <x86intrin.h>
-#endif
-
#include "Common/CPUDetect.h"
+#include "Common/Intrinsics.h"
#include "Common/JitRegister.h"
#include "Common/x64ABI.h"
#include "VideoCommon/VertexLoaderX64.h"