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.
This commit is contained in:
Ryan Houdek 2014-07-30 20:58:16 -05:00
parent e726f82344
commit 06ccc0121f
1 changed files with 14 additions and 3 deletions

View File

@ -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 )