int
main()
{
- float f;
- int i;
+ unsigned int _eax,_ebx,_ecx,_edx;
+ unsigned int level = 0;
+
/* Test gcc inline asm for x86 */
- asm("fld %1\nfistpl %0\n" : "=m" (*&i) : "f" (f));
+#if defined (__x86_64__) || defined (_M_X64)
+ __asm__("push %%rbx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "pop %%rbx \n\t"
+ : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
+#else
+ __asm__("push %%ebx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "pop %%ebx \n\t"
+ : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
+#endif
+
return 0;
}
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src/gmxlib/gmx_detectcpu.c
COMPILE_DEFINITIONS "@GCC_INLINE_ASM_DEFINE@ -I${CMAKE_SOURCE_DIR}/include -DGMX_DETECTCPU_STANDALONE"
- RUN_OUTPUT_VARIABLE OUTPUT_TMP ARGS "-acceleration")
+ RUN_OUTPUT_VARIABLE OUTPUT_TMP
+ COMPILE_OUTPUT_VARIABLE GMX_DETECTCPU_COMPILE_OUTPUT
+ ARGS "-acceleration")
+
+ if(NOT GMX_DETECTCPU_COMPILED)
+ message(WARNING "Cannot compile CPU detection code, which means no optimization.")
+ message(STATUS "Compile output: ${GMX_DETECTCPU_COMPILE_OUTPUT}")
+ set(OUTPUT_TMP "None")
+ endif(NOT GMX_DETECTCPU_COMPILED)
+
string(STRIP "@OUTPUT_TMP@" OUTPUT_ACC)
message(STATUS "Detecting best acceleration for this CPU - @OUTPUT_ACC@")
MESSAGE(STATUS "Checking for GCC x86 inline asm")
TRY_COMPILE(${VARIABLE} "${CMAKE_BINARY_DIR}"
- "${CMAKE_SOURCE_DIR}/cmake/TestInlineASM_gcc_x86.c")
+ "${CMAKE_SOURCE_DIR}/cmake/TestInlineASM_gcc_x86.c"
+ OUTPUT_VARIABLE INLINE_ASM_COMPILE_OUTPUT)
if(${VARIABLE})
MESSAGE(STATUS "Checking for GCC x86 inline asm - supported")
set(${VARIABLE} 0 CACHE INTERNAL "Result of test for GCC x86 inline asm" FORCE)
endif(${VARIABLE})
-
ENDIF(NOT DEFINED ${VARIABLE})
ENDMACRO(GMX_TEST_INLINE_ASM_GCC_X86 VARIABLE)
unsigned int * edx)
{
unsigned int _eax,_ebx,_ecx,_edx;
- int CPUInfo[4];
int rc;
#ifdef _MSC_VER
+ int CPUInfo[4];
+
/* MSVC */
__cpuid(CPUInfo,level);
* but there might be more options added in the future.
*/
/* tested on 32 & 64 GCC, and Intel icc. */
- __asm__("cpuid" : "=a"(_eax), "=b"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
-
+#if defined (__x86_64__) || defined (_M_X64)
+ __asm__("push %%rbx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "pop %%rbx \n\t"
+ : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
+#else
+ __asm__("push %%ebx \n\t"
+ "cpuid \n\t"
+ "movl %%ebx, %1 \n\t"
+ "pop %%ebx \n\t"
+ : "=a"(_eax), "=r"(_ebx), "=c"(_ecx), "=d"(_edx) : "0"(level));
+#endif
+
rc = 0;
#endif
/* If you end up having a compiler that really doesn't understand this and
{
int max_stdfn,max_extfn;
unsigned int eax,ebx,ecx,edx;
- char str[GMX_DETECTCPU_STRLEN];
- char * p;
detectcpu_common_x86(data);
{
int max_stdfn;
unsigned int eax,ebx,ecx,edx;
- char str[GMX_DETECTCPU_STRLEN];
- char * p;
detectcpu_common_x86(data);
gmx_detectcpu_vendorid_t i,vendor;
/* Register data used on x86 */
unsigned int eax,ebx,ecx,edx;
- unsigned int * p;
char vendorstring[13];
/* Set default first */
{
gmx_detectcpu_t data;
gmx_detectcpu_acceleration_t acc;
- char str[1024];
int i,cnt;
if(argc<2)