1 // Added by JE - 05-12-2009. Inline assembler instructions
2 // have been changed to Intel format and (in the case of
3 // cpuid) was replaced by the equivalent VC++ system call).
5 #if defined (COMPILER_MSVC) || defined (COMPILER_MINGW)
7 #define _XOPEN_SOURCE 600
10 #include <intrin.h> // Added by JE - 05-12-2009
14 #include <pbd/error.h>
23 unsigned long cpuflags = 0;
27 #ifndef USE_X86_64_ASM
31 // Get CPU lfags using Microsof function
32 // It works for both 64 and 32 bit systems
33 // no need to use assembler for getting info from register, this function does this for us
36 cpuflags = cpuInfo[3];
38 if (cpuflags & (1<<25)) {
39 _flags = Flags (_flags | (HasSSE|HasFlushToZero) );
42 if (cpuflags & (1<<26)) {
43 _flags = Flags (_flags | HasSSE2);
46 if (cpuflags & (1 << 24)) {
49 // allocate alligned buffer
50 fxbuf = (char **) malloc (sizeof (char *));
52 *fxbuf = (char *) malloc (512);
55 // Verify that fxbuf is correctly aligned
56 unsigned long long buf_addr = (unsigned long long)(void*)fxbuf;
57 if ((0 == buf_addr) || (buf_addr % 16))
58 error << _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg;
61 memset(*fxbuf, 0, 512); // Initialize the buffer !!! Added by JE - 12-12-2009
63 #if defined (COMPILER_MINGW)
71 asm( ".intel_syntax noprefix\n" );
78 asm( ".att_syntax prefix\n" );
81 #elif defined (COMPILER_MSVC)
87 uint32_t mxcsr_mask = *((uint32_t*) &fxbuf[28]);
89 /* if the mask is zero, set its default value (from intel specs) */
91 if (mxcsr_mask == 0) {
95 if (mxcsr_mask & (1<<6)) {
96 _flags = Flags (_flags | HasDenormalsAreZero);
109 #else // !COMPILER_MSVC
110 const char* pbd_fpu = "original pbd/fpu.cc takes precedence over this file";
111 #endif // COMPILER_MSVC