Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -75,10 +75,13 @@ # FIXME: Turn off exceptions, RTTI: # -fno-exceptions -fno-rtti set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -fno-exceptions -fno-rtti") +elseif (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-") + add_definitions("-D_HAS_EXCEPTIONS=0") +else () + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti") endif () -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti") - # Define the FLAGS for the compilation of isl and imath # # Those are the only C files we have in the repository. Hence, we can just use @@ -139,7 +142,6 @@ add_definitions( -D_GNU_SOURCE ) -add_subdirectory(include) add_subdirectory(lib) add_subdirectory(test) add_subdirectory(tools) @@ -160,10 +162,12 @@ CLANG_FORMAT=${LLVM_BINARY_DIR}/bin/clang-format ${CMAKE_CURRENT_SOURCE_DIR}/utils/check_format.sh ${files}) add_custom_target(polly-check-format DEPENDS formatting) +set_target_properties(polly-check-format PROPERTIES FOLDER "Polly") add_custom_command( OUTPUT formatting-update COMMAND CLANG_FORMAT=${LLVM_BINARY_DIR}/bin/clang-format ${CMAKE_CURRENT_SOURCE_DIR}/utils/update_format.sh ${files}) add_custom_target(polly-update-format DEPENDS formatting-update) +set_target_properties(polly-update-format PROPERTIES FOLDER "Polly") # Set the variable POLLY_LINK_LIBS in the llvm/tools/ dir. set(POLLY_LINK_LIBS ${POLLY_LINK_LIBS} PARENT_SCOPE) Index: cmake/polly_macros.cmake =================================================================== --- cmake/polly_macros.cmake +++ cmake/polly_macros.cmake @@ -18,6 +18,7 @@ set(libkind) endif() add_library( ${name} ${libkind} ${srcs} ) + set_target_properties(${name} PROPERTIES FOLDER "Polly") if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) @@ -38,11 +39,9 @@ endif( LLVM_LINK_COMPONENTS ) if(MSVC) get_target_property(cflag ${name} COMPILE_FLAGS) - if(NOT cflag) - set(cflag "") - endif(NOT cflag) - set(cflag "${cflag} /Za") - set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag}) + if(cflag) + set_target_properties(${name} PROPERTIES COMPILE_FLAGS ${cflag}) + endif() endif(MSVC) install(TARGETS ${name} EXPORT LLVMExports @@ -62,6 +61,7 @@ endif() set(MODULE TRUE) add_polly_library(${name} ${srcs}) + set_target_properties(${name} PROPERTIES FOLDER "Polly") if (GLOBAL_NOT_MODULE) unset (MODULE) endif() Index: include/CMakeLists.txt =================================================================== --- include/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(polly) Index: include/polly/CMakeLists.txt =================================================================== --- include/polly/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -if( MSVC_IDE OR XCODE ) - # Creates a dummy target containing all headers for the benefit of - # Visual Studio users. - file(GLOB_RECURSE headers *.h) - add_library(polly_headers_do_not_build EXCLUDE_FROM_ALL - # We need at least one source file: - ${POLLY_SOURCE_DIR}/lib/Support/GICHelper.cpp - ${headers}) -endif() Index: lib/CMakeLists.txt =================================================================== --- lib/CMakeLists.txt +++ lib/CMakeLists.txt @@ -32,6 +32,7 @@ string(REGEX REPLACE ".*\\\"([^\\\"]*)\\\".*" "\\1" GIT_HEAD_ID "${GITVERSION_H}") elseif () # Unknown revision + # TODO: We could look for a .git and get the revision from HEAD set(GIT_HEAD_ID "UNKNOWN") endif () @@ -45,6 +46,34 @@ # Determine compiler characteristics include(CheckCSourceCompiles) +# Like check_c_source_compiles, but sets the result to either +# 0 (error while compiling) or 1 (compiled successfully) +# Required for compatibility with autotool's AC_CHECK_DECLS +function (check_c_source_compiles_numeric _prog _var) + check_c_source_compiles("${_prog}" "${_var}") + if ("${${_var}}") + set("${_var}" 1 PARENT_SCOPE) + else () + set("${_var}" 0 PARENT_SCOPE) + endif () +endfunction () + +# Check for the existance of a type +function (check_c_type_exists _type _files _variable) + set(_includes "") + foreach (file_name ${_files}) + set(_includes "${_includes}#include<${file_name}>\n") + endforeach() + check_c_source_compiles(" + ${_includes} + ${_type} typeVar; + int main() { + return 0; + } + " ${_variable}) +endfunction () + + check_c_source_compiles(" int func(void) __attribute__((__warn_unused_result__)); int main() { return 0; } @@ -55,29 +84,107 @@ endif () check_c_source_compiles(" + static void foo(void) __attribute__ ((unused)); + int main() { return 0; } + " HAVE___ATTRIBUTE__) + + +check_c_source_compiles_numeric(" #include int main() { ffs(0); return 0; } " HAVE_DECL_FFS) -if (NOT HAVE_DECL_FFS) - set(HAVE_DECL_FFS 0) -endif () -check_c_source_compiles(" +check_c_source_compiles_numeric(" int main() { __builtin_ffs(0); return 0; } " HAVE_DECL___BUILTIN_FFS) -if (NOT HAVE_DECL___BUILTIN_FFS) - set(HAVE_DECL___BUILTIN_FFS 0) + +check_c_source_compiles_numeric(" + #include + int main() { _BitScanForward(NULL, 0); return 0; } + " HAVE_DECL__BITSCANFORWARD) + +if (NOT HAVE_DECL_FFS AND + NOT HAVE_DECL___BUILTIN_FFS AND + NOT HAVE_DECL__BITSCANFORWARD) + message(FATAL_ERROR "No ffs implementation found") +endif () + + +check_c_source_compiles_numeric(" + #include + int main() { strcasecmp(\"\", \"\"); return 0; } + " HAVE_DECL_STRCASECMP) + +check_c_source_compiles_numeric(" + #include + int main() { _stricmp(\"\", \"\"); return 0; } + " HAVE_DECL__STRICMP) + +if (NOT HAVE_DECL_STRCASECMP AND NOT HAVE_DECL__STRICMP) + message(FATAL_ERROR "No strcasecmp implementation found") endif () -check_c_source_compiles(" - static void foo(void) __attribute__ ((unused)); - int main() { return 0; } - " HAVE___ATTRIBUTE__) + +check_c_source_compiles_numeric(" + #include + int main() { strncasecmp(\"\", \"\", 0); return 0; } + " HAVE_DECL_STRNCASECMP) + +check_c_source_compiles_numeric(" + #include + int main() { _strnicmp(\"\", \"\", 0); return 0; } + " HAVE_DECL__STRNICMP) + +if (NOT HAVE_DECL_STRNCASECMP AND NOT HAVE_DECL__STRNICMP) + message(FATAL_ERROR "No strncasecmp implementation found") +endif () + + +check_c_source_compiles_numeric(" + #include + int main() { snprintf((void*)0, 0, \"\"); return 0; } + " HAVE_DECL_SNPRINTF) + +check_c_source_compiles_numeric(" + #include + int main() { _snprintf((void*)0, 0, \"\"); return 0; } + " HAVE_DECL__SNPRINTF) + +if (NOT HAVE_DECL_SNPRINTF AND NOT HAVE_DECL__SNPRINTF) + message(FATAL_ERROR "No snprintf implementation found") +endif () + + +check_c_type_exists(uint8_t "" HAVE_UINT8T) +check_c_type_exists(uint8_t "stdint.h" HAVE_STDINT_H) +check_c_type_exists(uint8_t "inttypes.h" HAVE_INTTYPES_H) +check_c_type_exists(uint8_t "sys/types.h" HAVE_SYS_INTTYPES_H) +if (HAVE_UINT8T) + set(INCLUDE_STDINT_H "") +elseif (HAVE_STDINT_H) + set(INCLUDE_STDINT_H "#include ") +elseif (HAVE_INTTYPES_H) + set(INCLUDE_STDINT_H "#include ") +elseif (HAVE_SYS_INTTYPES_H) + set(INCLUDE_STDINT_H "#include ") +else () + message(FATAL_ERROR "No stdint.h or compatible found") +endif () # Write configure result -configure_file("External/gitversion.h.cmake" "${ISL_BINARY_DIR}/gitversion.h") +# configure_file(... COPYONLY) avoids that the time stamp changes if the file is identical +file(WRITE "${ISL_BINARY_DIR}/gitversion.h.tmp" + "#define GIT_HEAD_ID \"${GIT_HEAD_ID}\"") +configure_file("${ISL_BINARY_DIR}/gitversion.h.tmp" + "${ISL_BINARY_DIR}/gitversion.h" COPYONLY) + +file(WRITE "${ISL_BINARY_DIR}/include/isl/stdint.h.tmp" + "${INCLUDE_STDINT_H}") +configure_file("${ISL_BINARY_DIR}/include/isl/stdint.h.tmp" + "${ISL_BINARY_DIR}/include/isl/stdint.h" COPYONLY) + configure_file("External/isl_config.h.cmake" "${ISL_BINARY_DIR}/isl_config.h") -file(WRITE "${ISL_BINARY_DIR}/include/isl/stdint.h" "#include ") + # ISL files to compile set (ISL_FILES @@ -103,6 +210,7 @@ External/isl/isl_equalities.c External/isl/isl_factorization.c External/isl/isl_farkas.c + External/isl/isl_ffs.c External/isl/isl_flow.c External/isl/isl_fold.c External/isl/isl_hash.c @@ -211,18 +319,25 @@ # Build a monolithic Polly.a and a thin module LLVMPolly.moduleext that links to # that static library. -add_polly_loadable_module(LLVMPolly - Polly.cpp -) +if (MSVC) + # Add dummy target, because loadable modules are not supported on Windows + add_custom_target(LLVMPolly) + set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") +else () + add_polly_loadable_module(LLVMPolly + Polly.cpp + ) + + target_link_libraries(LLVMPolly Polly) + + set_target_properties(LLVMPolly + PROPERTIES + LINKER_LANGUAGE CXX + PREFIX "") +endif () if (TARGET intrinsics_gen) # Check if we are building as part of an LLVM build add_dependencies(Polly intrinsics_gen) endif() -target_link_libraries(LLVMPolly Polly) - -set_target_properties(LLVMPolly - PROPERTIES - LINKER_LANGUAGE CXX - PREFIX "") Index: lib/External/gitversion.h.cmake =================================================================== --- lib/External/gitversion.h.cmake +++ /dev/null @@ -1 +0,0 @@ -#define GIT_HEAD_ID "@GIT_HEAD_ID@" Index: lib/External/isl_config.h.cmake =================================================================== --- lib/External/isl_config.h.cmake +++ lib/External/isl_config.h.cmake @@ -1,8 +1,10 @@ +/* define if your compiler has __attribute__ */ +#cmakedefine HAVE___ATTRIBUTE__ /**/ -/* most gcc compilers know a function __attribute__((__warn_unused_result__)) - */ +/* most gcc compilers know a function __attribute__((__warn_unused_result__)) */ #define GCC_WARN_UNUSED_RESULT @GCC_WARN_UNUSED_RESULT@ + /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ #define HAVE_DECL_FFS @HAVE_DECL_FFS@ @@ -10,8 +12,37 @@ don't. */ #define HAVE_DECL___BUILTIN_FFS @HAVE_DECL___BUILTIN_FFS@ -/* define if your compiler has __attribute__ */ -#cmakedefine HAVE___ATTRIBUTE__ /**/ +/* Define to 1 if you have the declaration of `_BitScanForward', and to 0 if + you don't. */ +#define HAVE_DECL__BITSCANFORWARD @HAVE_DECL__BITSCANFORWARD@ + + +/* Define to 1 if you have the declaration of `strcasecmp', and to 0 if you + don't. */ +#define HAVE_DECL_STRCASECMP @HAVE_DECL_STRCASECMP@ + +/* Define to 1 if you have the declaration of `_stricmp', and to 0 if you + don't. */ +#define HAVE_DECL__STRICMP @HAVE_DECL__STRICMP@ + + +/* Define to 1 if you have the declaration of `strncasecmp', and to 0 if you + don't. */ +#define HAVE_DECL_STRNCASECMP @HAVE_DECL_STRNCASECMP@ + +/* Define to 1 if you have the declaration of `_strnicmp', and to 0 if you + don't. */ +#define HAVE_DECL__STRNICMP @HAVE_DECL__STRNICMP@ + + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF @HAVE_DECL_SNPRINTF@ + +/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you + don't. */ +#define HAVE_DECL__SNPRINTF @HAVE_DECL__SNPRINTF@ + /* use gmp to implement isl_int */ #cmakedefine USE_GMP_FOR_MP Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -46,6 +46,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/${testdir} DEPENDS ${POLLY_TEST_DEPS} COMMENT "Running Polly regression tests in ${testdir}") + set_target_properties(polly-test-${testdir} PROPERTIES FOLDER "Polly") endforeach() add_custom_target(check-polly @@ -56,6 +57,7 @@ ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${POLLY_TEST_DEPS} COMMENT "Running Polly regression tests") + set_target_properties(check-polly PROPERTIES FOLDER "Polly") endif() else (NOT DEFINED LLVM_MAIN_SRC_DIR) @@ -74,7 +76,7 @@ DEPENDS ${POLLY_TEST_DEPS} ) - set_target_properties(check-polly PROPERTIES FOLDER "polly tests") + set_target_properties(check-polly PROPERTIES FOLDER "Polly") endif (NOT DEFINED LLVM_MAIN_SRC_DIR) @@ -84,4 +86,5 @@ # Add a legacy target spelling: polly-test add_custom_target(polly-test) +set_target_properties(polly-test PROPERTIES FOLDER "Polly") add_dependencies(polly-test check-polly)