From 06ccc0121f467f1a9c89d49e86821f4f277fa26d Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 30 Jul 2014 20:58:16 -0500 Subject: [PATCH] Support grabbing the MXCSR mask on x86_64. Instead of using some dynamic code to grab the FXSave information, use an intrinsic if on at least MSVC 2012. With GCC just use a bit of ASM, and if on MSVC 2010 or older, use the old crappy method. This method can be removed once MSVC 2010 support is dropped and mandate at least MSVC 2012 minimum. --- common/src/x86emitter/cpudetect.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/x86emitter/cpudetect.cpp b/common/src/x86emitter/cpudetect.cpp index dbf1191870..b05533a890 100644 --- a/common/src/x86emitter/cpudetect.cpp +++ b/common/src/x86emitter/cpudetect.cpp @@ -53,12 +53,22 @@ void x86capabilities::SIMD_EstablishMXCSRmask() MXCSR_Mask.bitmask = 0xFFFF; // SSE2 features added } - - if( !CanEmitShit() ) return; - +#ifdef _M_X86_64 +#ifdef _MSC_VER + // Use the intrinsic that is provided with MSVC 2012 + _fxsave(&targetFXSAVE); +#else + // GCC path is supported since GCC 4.6.x + __asm __volatile ("fxsave %0" : "+m" (targetFXSAVE)); +#endif +#else + // Grab the MXCSR mask the x86_32 way. + // // the fxsave buffer must be 16-byte aligned to avoid GPF. I just save it to an // unused portion of recSSE, since it has plenty of room to spare. + if( !CanEmitShit() ) return; + HostSys::MemProtectStatic( recSSE, PageAccess_ReadWrite() ); xSetPtr( recSSE ); @@ -68,6 +78,7 @@ void x86capabilities::SIMD_EstablishMXCSRmask() HostSys::MemProtectStatic( recSSE, PageAccess_ExecOnly() ); CallAddress( recSSE ); +#endif u32 result = (u32&)targetFXSAVE[28]; // bytes 28->32 are the MXCSR_Mask. if( result != 0 )