diff options
-rw-r--r-- | volk/CMakeLists.txt | 1 | ||||
-rw-r--r-- | volk/gen/make_cpuid_c.py | 22 | ||||
-rw-r--r-- | volk/lib/CMakeLists.txt | 37 |
3 files changed, 32 insertions, 28 deletions
diff --git a/volk/CMakeLists.txt b/volk/CMakeLists.txt index 2423fc922..41d5723ab 100644 --- a/volk/CMakeLists.txt +++ b/volk/CMakeLists.txt @@ -33,6 +33,7 @@ set(LIBVER 0.0.0) set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) #location for custom "Modules" + ######################################################################## # Dependencies setup ######################################################################## diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py index eb88dcd7f..7281f45a3 100644 --- a/volk/gen/make_cpuid_c.py +++ b/volk/gen/make_cpuid_c.py @@ -30,7 +30,11 @@ HEADER_TEMPL = """\ struct VOLK_CPU volk_cpu; -#if defined(__i386__) || (__x86_64__) +#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) +# define VOLK_CPU_x86 +#endif + +#if defined(VOLK_CPU_x86) //implement get cpuid for gcc compilers using a copy of cpuid.h #if defined(__GNUC__) @@ -40,32 +44,32 @@ struct VOLK_CPU volk_cpu; //implement get cpuid for MSVC compilers using __cpuid intrinsic #elif defined(_MSC_VER) #include <intrin.h> -#define cpuid(op, r) __cpuid(r, op) +#define cpuid_x86(op, r) __cpuid(r, op) #else #error "A get cpuid for volk is not available on this compiler..." #endif static inline unsigned int cpuid_eax(unsigned int op) { - unsigned int regs[4]; + int regs[4]; cpuid_x86 (op, regs); return regs[0]; } static inline unsigned int cpuid_ebx(unsigned int op) { - unsigned int regs[4]; + int regs[4]; cpuid_x86 (op, regs); return regs[1]; } static inline unsigned int cpuid_ecx(unsigned int op) { - unsigned int regs[4]; + int regs[4]; cpuid_x86 (op, regs); return regs[2]; } static inline unsigned int cpuid_edx(unsigned int op) { - unsigned int regs[4]; + int regs[4]; cpuid_x86 (op, regs); return regs[3]; } @@ -103,7 +107,7 @@ def make_cpuid_c(dom) : if no_test: tempstring = tempstring + """\ int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) +#if defined(VOLK_CPU_x86) return 1; #else return 0; @@ -115,7 +119,7 @@ int i_can_has_%s () { elif op == "1": tempstring = tempstring + """\ int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) +#if defined(VOLK_CPU_x86) unsigned int e%sx = cpuid_e%sx (%s); return ((e%sx >> %s) & 1) == %s; #else @@ -128,7 +132,7 @@ int i_can_has_%s () { elif op == "0x80000001": tempstring = tempstring + """\ int i_can_has_%s () { -#if defined(__i386__) || (__x86_64__) +#if defined(VOLK_CPU_x86) unsigned int extended_fct_count = cpuid_eax(0x80000000); if (extended_fct_count < 0x80000001) return %s^1; diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 317899de1..b6a8599a2 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -16,6 +16,18 @@ # ######################################################################## +# Setup the compiler name +######################################################################## +set(COMPILER_NAME ${CMAKE_C_COMPILER_ID}) +if(MSVC) #its not set otherwise + set(COMPILER_NAME MSVC) +endif() + +if(NOT DEFINED COMPILER_NAME) + message(FATAL_ERROR "COMPILER_NAME undefined. Volk build may not support this compiler.") +endif() + +######################################################################## # Parse the arches xml file: # Test each arch to see if the compiler supports the flag. # If the test passes append the arch to the available list. @@ -33,9 +45,9 @@ execute_process( foreach(thing ${compiler_lines}) string(REGEX REPLACE "," ";" thing_list ${thing}) - list(FIND thing_list ${CMAKE_C_COMPILER_ID} check_val) + list(FIND thing_list ${COMPILER_NAME} check_val) if(NOT ("${check_val}" STREQUAL "-1")) - string(REGEX REPLACE "${CMAKE_C_COMPILER_ID}," ";" filter_string ${thing}) + string(REGEX REPLACE "${COMPILER_NAME}," ";" filter_string ${thing}) endif() endforeach() @@ -50,7 +62,7 @@ execute_process( foreach(thing ${compiler_prefixes}) string(REGEX REPLACE "," ";" thing_list ${thing}) - list(FIND thing_list ${CMAKE_C_COMPILER_ID} check_val) + list(FIND thing_list ${COMPILER_NAME} check_val) if(NOT ("${check_val}" STREQUAL "-1")) list(GET thing_list "1" prefix) endif() @@ -98,20 +110,7 @@ macro(compiler_filter name flag) set(${name}_flag "${prefix}${filtered_flag}") endmacro() -#This macro sets the ${arch}_flag variable, -#filters through specialized compiler remappings -#MACRO(set_arch_flag name flag) -# compiler_filter(${name} ${flag}) -# IF(MSVC AND ${flag} STREQUAL "mmmx") -# SET(${name}_flag "/arch:SSE") #no /arch:MMX -# ELSEIF(MSVC AND ${flag} STREQUAL "msse") -# SET(${name}_flag "/arch:SSE") -# ELSEIF(MSVC AND ${flag} STREQUAL "sse2") -# SET(${name}_flag "/arch:SSE2") -# ELSE() -# SET(${name}_flag -${flag}) -# ENDIF() -#ENDMACRO(set_arch_flag) + @@ -122,7 +121,7 @@ macro(handle_arch name flag overrule overrule_val) #handle overrule if("${${overrule}}" STREQUAL "${overrule_val}") set(have_${name} FALSE) - message("${name} overruled") + message(STATUS "${name} overruled") #handle special case for none flag elseif(${flag} STREQUAL "none") set(have_${name} TRUE) @@ -304,7 +303,7 @@ set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/volk_machines.c PROPERTIES COMPILE_DEFINITIONS "${machine_defs}") -if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") +if(MSVC) #add compatibility includes for stdint types include_directories(${CMAKE_SOURCE_DIR}/msvc) #compile the sources as C++ due to the lack of complex.h under MSVC |