Enable SSE2 for Visual Studio builds

Based on the remnants of change #2273.
Adds an auto-detect for ARCH based on the environment.

Change-Id: I4644eae7509f3982a8b385b49beac03675a2e0e8
This commit is contained in:
James Zern 2011-05-31 18:58:01 -07:00
parent af10db4aa4
commit 003417c7c7
3 changed files with 16 additions and 11 deletions

View File

@ -15,14 +15,17 @@ DEPS_PATH = ../../deps
!ENDIF !ENDIF
!IFNDEF ARCH !IFNDEF ARCH
!IFDEF TARGET_CPU !IF ! [ cl 2>&1 | find "x86" > NUL ]
ARCH = $(TARGET_CPU) ARCH = x86
!ELSE IF ! [ cl 2>&1 | find "x64" > NUL ]
ARCH = x64
!ELSE !ELSE
ARCH = x86 !ERROR Unable to auto-detect toolchain architecture! \
If cl.exe is in your PATH rerun nmake with ARCH=<arch>.
!ENDIF !ENDIF
!ENDIF !ENDIF
!IF "$(TARGET_CPU)" == "x86" !IF "$(ARCH)" == "x86"
PLATFORM_LDFLAGS = /SAFESEH PLATFORM_LDFLAGS = /SAFESEH
PLATFORM_SSE2 = /arch:SSE2 PLATFORM_SSE2 = /arch:SSE2
!ENDIF !ENDIF
@ -40,7 +43,7 @@ LNKDLL = link.exe /DLL
LNKLIB = link.exe /lib LNKLIB = link.exe /lib
LNKEXE = link.exe LNKEXE = link.exe
LFLAGS = /nologo /machine:$(ARCH) LFLAGS = /nologo /machine:$(ARCH)
CFLAGS = $(CFLAGS) CFLAGS = $(CFLAGS) $(PLATFORM_SSE2)
CFGSET = FALSE CFGSET = FALSE
!IF "$(OBJDIR)" == "" !IF "$(OBJDIR)" == ""
@ -189,9 +192,6 @@ $(DIRINC):
$(DIRBIN): $(DIRBIN):
@if not exist "$(DIRBIN)" mkdir $(DIRBIN) @if not exist "$(DIRBIN)" mkdir $(DIRBIN)
# Special case - compile with SSE2.
$(DIROBJ)\enc\dsp_sse2.obj: src\enc\dsp_sse2.c
$(CC) $(CFLAGS) $(PLATFORM_SSE2) /Fo"$@" src\enc\dsp_sse2.c
.SUFFIXES: .c .obj .res .exe .SUFFIXES: .c .obj .res .exe
{examples}.c{$(DIROBJ)\examples}.obj: {examples}.c{$(DIROBJ)\examples}.obj:
$(CC) $(CFLAGS) /Fo"$@" $< $(CC) $(CFLAGS) /Fo"$@" $<

View File

@ -685,9 +685,12 @@ static inline void GetCPUInfo(int cpu_info[4], int info_type) {
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
: "a"(info_type)); : "a"(info_type));
} }
#elif defined(_M_IX86) || defined(_M_X64) // Visual C++
#define GetCPUInfo __cpuid
#endif #endif
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__) || \
defined(_M_IX86) || defined(_M_X64)
static int x86CPUInfo(CPUFeature feature) { static int x86CPUInfo(CPUFeature feature) {
int cpu_info[4]; int cpu_info[4];
GetCPUInfo(cpu_info, 1); GetCPUInfo(cpu_info, 1);
@ -753,7 +756,8 @@ void VP8EncDspInit(void) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo) { if (VP8GetCPUInfo) {
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
#if defined(__SSE2__) #if defined(__SSE2__) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(_M_X64)
VP8EncDspInitSSE2(); VP8EncDspInitSSE2();
#endif #endif
} }

View File

@ -9,7 +9,8 @@
// //
// Author: Christian Duvivier (cduvivier@google.com) // Author: Christian Duvivier (cduvivier@google.com)
#if defined(__SSE2__) #if defined(__SSE2__) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(_M_X64)
#include <emmintrin.h> #include <emmintrin.h>
#include "vp8enci.h" #include "vp8enci.h"