* support LLVM trunk

* guard with USE_LLVM in if condition for c++14

* GREATER_EQUAL -> GREATER
This commit is contained in:
Yizhi Liu 2019-09-08 02:43:29 +08:00 коммит произвёл GitHub
Родитель 6604593bef
Коммит 8c50469c6d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -90,15 +90,13 @@ if(MSVC)
endforeach(flag_var) endforeach(flag_var)
endif() endif()
else(MSVC) else(MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message("Build in Debug mode") message("Build in Debug mode")
set(CMAKE_C_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_C_FLAGS} -rdynamic") set(CMAKE_C_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_C_FLAGS} -rdynamic")
set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS} -rdynamic") set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fPIC ${CMAKE_CXX_FLAGS} -rdynamic")
else() else()
set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-O2 -Wall -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC ${CMAKE_CXX_FLAGS}")
if (HIDE_PRIVATE_SYMBOLS) if (HIDE_PRIVATE_SYMBOLS)
message("Hide private symbols...") message("Hide private symbols...")
set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS "-fvisibility=hidden ${CMAKE_C_FLAGS}")
@ -245,6 +243,19 @@ include(cmake/modules/contrib/Sort.cmake)
include(cmake/modules/contrib/NNPack.cmake) include(cmake/modules/contrib/NNPack.cmake)
include(cmake/modules/contrib/HybridDump.cmake) include(cmake/modules/contrib/HybridDump.cmake)
if(NOT MSVC)
include(CheckCXXCompilerFlag)
if(NOT USE_LLVM STREQUAL "OFF" AND TVM_LLVM_VERSION GREATER 91)
check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14)
message(STATUS "Build with c++14")
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
else()
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
message(STATUS "Build with c++11")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
endif()
endif()
add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_topi SHARED ${TOPI_SRCS}) add_library(tvm_topi SHARED ${TOPI_SRCS})
add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) add_library(tvm_runtime SHARED ${RUNTIME_SRCS})

Просмотреть файл

@ -423,8 +423,13 @@ void CodeGenLLVM::GetAlignment(Type t,
std::unique_ptr<CodeGenLLVM::DebugInfo> std::unique_ptr<CodeGenLLVM::DebugInfo>
CodeGenLLVM::CreateDebugInfo(llvm::Module* module) { CodeGenLLVM::CreateDebugInfo(llvm::Module* module) {
#if TVM_LLVM_VERSION >= 100
auto debug_info = std::make_unique<CodeGenLLVM::DebugInfo>();
debug_info->di_builder_ = std::make_unique<llvm::DIBuilder>(*module);
#else
auto debug_info = llvm::make_unique<CodeGenLLVM::DebugInfo>(); auto debug_info = llvm::make_unique<CodeGenLLVM::DebugInfo>();
debug_info->di_builder_ = llvm::make_unique<llvm::DIBuilder>(*module); debug_info->di_builder_ = llvm::make_unique<llvm::DIBuilder>(*module);
#endif
// TODO(tulloch): pass this information through relay::Span classes to the LoweredFunc instance? // TODO(tulloch): pass this information through relay::Span classes to the LoweredFunc instance?
debug_info->file_ = debug_info->di_builder_->createFile("model.tvm", "/tmp/"); debug_info->file_ = debug_info->di_builder_->createFile("model.tvm", "/tmp/");
debug_info->compilation_unit_ = debug_info->di_builder_->createCompileUnit( debug_info->compilation_unit_ = debug_info->di_builder_->createCompileUnit(