cmake: By default optimize for current arch

Note: it requires GCC 4.7. Otherwise use -DDISABLE_ADVANCE_SIMD=OFF to restore
previous behavior. It will impact Ubuntu precise (12.04)
This commit is contained in:
Gregory Hainaut 2014-10-26 14:36:34 +01:00
parent fa3db52cf7
commit 679fa65b84
3 changed files with 17 additions and 2 deletions

View File

@ -37,6 +37,7 @@ for ARG in "$@"; do
--wx28 ) flags+=(-DWX28_API=TRUE) ;;
--wx30 ) flags+=(-DWX28_API=FALSE) ;;
--64-bit-dont-work ) flags+=(-D64BIT_BUILD_DONT_WORK=TRUE) ;;
--no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;;
*)
# Unknown option
@ -58,6 +59,7 @@ for ARG in "$@"; do
echo "--gles : Replace openGL backend of GSdx by openGLES3"
echo
echo "--64-bit-dont-work : Don't use it!"
echo "--no-simd : Only allow sse2"
exit 1
esac
done

View File

@ -64,6 +64,7 @@ option(USE_ASAN "Enable address sanitizer")
# Select the architecture
#-------------------------------------------------------------------------------
option(64BIT_BUILD_DONT_WORK "Enable a x86_64 build instead of cross compiling (WARNING: NOTHING WORK)" OFF)
option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF)
# Architecture bitness detection
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@ -99,7 +100,11 @@ if(_ARCH_64 AND 64BIT_BUILD_DONT_WORK)
# x86_64 requires -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(ARCH_FLAG "-m64 -msse -msse2")
if (DISABLE_ADVANCE_SIMD)
set(ARCH_FLAG "-m64 -msse -msse2")
else()
set(ARCH_FLAG "-m64 -march=native -fabi-version=6")
endif()
add_definitions(-D_ARCH_64=1 -D_M_X86=1 -D_M_X86_64=1)
set(_ARCH_64 1)
set(_M_X86 1)
@ -127,7 +132,13 @@ else()
# - Only plugins. No package will link to them.
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
set(ARCH_FLAG "-m32 -msse -msse2 -march=i686")
if (DISABLE_ADVANCE_SIMD)
set(ARCH_FLAG "-m32 -msse -msse2 -march=i686")
else()
# AVX requires some fix of the ABI (mangling) (default 2)
# Note: V6 requires GCC 4.7
set(ARCH_FLAG "-m32 -march=native -fabi-version=6")
endif()
add_definitions(-D_ARCH_32=1 -D_M_X86=1 -D_M_X86_32=1)
set(_ARCH_32 1)
set(_M_X86 1)

View File

@ -92,6 +92,7 @@ set(GSdxSources
GSDrawScanline.cpp
GSDrawScanlineCodeGenerator.cpp
GSDrawScanlineCodeGenerator.x86.avx.cpp
GSDrawScanlineCodeGenerator.x86.avx2.cpp
GSDrawScanlineCodeGenerator.x64.cpp
GSDrawScanlineCodeGenerator.x86.cpp
GSDrawScanlineCodeGenerator.x64.avx.cpp
@ -109,6 +110,7 @@ set(GSdxSources
GSSetting.cpp
GSSetupPrimCodeGenerator.cpp
GSSetupPrimCodeGenerator.x86.avx.cpp
GSSetupPrimCodeGenerator.x86.avx2.cpp
GSSetupPrimCodeGenerator.x64.avx.cpp
GSSetupPrimCodeGenerator.x86.cpp
GSSetupPrimCodeGenerator.x64.cpp