2019-03-30 05:10:12 +00:00
|
|
|
# MLIR project.
|
2019-07-24 03:09:11 +00:00
|
|
|
set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ) # --src-root
|
2019-03-30 05:10:12 +00:00
|
|
|
set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include ) # --includedir
|
|
|
|
set(MLIR_TABLEGEN_EXE mlir-tblgen)
|
|
|
|
|
|
|
|
set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
function(mlir_tablegen ofn)
|
|
|
|
tablegen(MLIR ${ARGV} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
|
|
|
|
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
|
|
|
PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2019-12-19 21:16:59 +00:00
|
|
|
function(add_mlir_dialect dialect dialect_doc_filename)
|
2019-12-02 17:17:51 +00:00
|
|
|
set(LLVM_TARGET_DEFINITIONS ${dialect}.td)
|
|
|
|
mlir_tablegen(${dialect}.h.inc -gen-op-decls)
|
|
|
|
mlir_tablegen(${dialect}.cpp.inc -gen-op-defs)
|
|
|
|
add_public_tablegen_target(MLIR${dialect}IncGen)
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 00:32:41 +00:00
|
|
|
add_dependencies(mlir-headers MLIR${dialect}IncGen)
|
2019-12-02 17:17:51 +00:00
|
|
|
|
|
|
|
# Generate Dialect Documentation
|
2019-12-19 21:16:59 +00:00
|
|
|
set(LLVM_TARGET_DEFINITIONS ${dialect_doc_filename}.td)
|
|
|
|
tablegen(MLIR ${dialect_doc_filename}.md -gen-op-doc "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
|
|
|
|
set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/Dialects/${dialect_doc_filename}.md)
|
2019-12-02 17:17:51 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${GEN_DOC_FILE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
2019-12-19 21:16:59 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md
|
2019-12-02 17:17:51 +00:00
|
|
|
${GEN_DOC_FILE}
|
2019-12-19 21:16:59 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md)
|
|
|
|
add_custom_target(${dialect_doc_filename}DocGen DEPENDS ${GEN_DOC_FILE})
|
|
|
|
add_dependencies(mlir-doc ${dialect_doc_filename}DocGen)
|
2019-12-02 17:17:51 +00:00
|
|
|
endfunction()
|
|
|
|
|
Add missing mlir-headers target and add tablegen'd deps to it.
Summary:
Prior to this, "ninja install-mlir-headers" failed with an error indicating
the missing target. Verified that from a clean build, the installed
headers include generated files.
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72045
2020-01-01 00:32:41 +00:00
|
|
|
# Installing the headers and docs needs to depend on generating any public
|
|
|
|
# tablegen'd targets.
|
|
|
|
add_custom_target(mlir-headers)
|
|
|
|
set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
|
2019-12-02 17:17:51 +00:00
|
|
|
add_custom_target(mlir-doc)
|
|
|
|
|
2019-03-30 05:10:12 +00:00
|
|
|
# TODO: This is to handle the current static registration, but should be
|
|
|
|
# factored out a bit.
|
|
|
|
function(whole_archive_link target)
|
2019-04-01 17:17:45 +00:00
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
2019-04-23 23:39:15 +00:00
|
|
|
set(link_flags "-L${CMAKE_BINARY_DIR}/lib ")
|
2019-04-01 17:17:45 +00:00
|
|
|
FOREACH(LIB ${ARGN})
|
2019-04-23 23:39:15 +00:00
|
|
|
string(CONCAT link_flags ${link_flags} "-Wl,-force_load ${CMAKE_BINARY_DIR}/lib/lib${LIB}.a ")
|
2019-04-01 17:17:45 +00:00
|
|
|
ENDFOREACH(LIB)
|
2019-05-29 20:47:24 +00:00
|
|
|
elseif(MSVC)
|
|
|
|
FOREACH(LIB ${ARGN})
|
[MLIR] Fix ML IR build on Windows with Visual Studio
Summary: Right now the path for each lib in whole_archive_link when MSVC is used as the compiler is not a full path - and it's not even the correct path when VS is used to build. This patch sets the lib path to a full path using CMAKE_CFG_INTDIR which means the path will be correct regardless of whether ninja, make or VS is used and it will always be a full path.
Reviewers: denis13, jpienaar
Reviewed By: jpienaar
Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, llvm-commits, asmith
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72403
2020-01-08 18:39:20 +00:00
|
|
|
string(CONCAT link_flags ${link_flags} "/WHOLEARCHIVE:${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/${LIB}.lib ")
|
2019-05-29 20:47:24 +00:00
|
|
|
ENDFOREACH(LIB)
|
2019-04-01 17:17:45 +00:00
|
|
|
else()
|
2019-04-20 17:45:59 +00:00
|
|
|
set(link_flags "-L${CMAKE_BINARY_DIR}/lib -Wl,--whole-archive,")
|
2019-04-01 17:17:45 +00:00
|
|
|
FOREACH(LIB ${ARGN})
|
|
|
|
string(CONCAT link_flags ${link_flags} "-l${LIB},")
|
|
|
|
ENDFOREACH(LIB)
|
|
|
|
string(CONCAT link_flags ${link_flags} "--no-whole-archive")
|
|
|
|
endif()
|
2019-03-30 05:10:12 +00:00
|
|
|
set_target_properties(${target} PROPERTIES LINK_FLAGS ${link_flags})
|
|
|
|
endfunction(whole_archive_link)
|
|
|
|
|
2019-06-26 12:16:11 +00:00
|
|
|
# Build the CUDA conversions and run according tests if the NVPTX backend
|
|
|
|
# is available
|
|
|
|
if ("NVPTX" IN_LIST LLVM_TARGETS_TO_BUILD)
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 1)
|
|
|
|
else()
|
|
|
|
set(MLIR_CUDA_CONVERSIONS_ENABLED 0)
|
|
|
|
endif()
|
|
|
|
|
2019-07-04 14:49:52 +00:00
|
|
|
set(MLIR_CUDA_RUNNER_ENABLED 0 CACHE BOOL "Enable building the mlir CUDA runner")
|
|
|
|
|
2019-03-30 05:10:12 +00:00
|
|
|
include_directories( "include")
|
|
|
|
include_directories( ${MLIR_INCLUDE_DIR})
|
|
|
|
|
|
|
|
add_subdirectory(include/mlir)
|
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(tools)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
add_subdirectory(test)
|
2019-04-02 17:02:07 +00:00
|
|
|
|
|
|
|
if( LLVM_INCLUDE_EXAMPLES )
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2019-11-20 05:04:45 +00:00
|
|
|
|
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
|
|
install(DIRECTORY include/mlir include/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
2020-01-06 09:01:59 +00:00
|
|
|
PATTERN "*.def"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.inc"
|
2019-12-29 17:04:09 +00:00
|
|
|
PATTERN "*.td"
|
2019-11-20 05:04:45 +00:00
|
|
|
PATTERN "LICENSE.TXT"
|
|
|
|
)
|
|
|
|
|
|
|
|
install(DIRECTORY ${MLIR_INCLUDE_DIR}/mlir ${MLIR_INCLUDE_DIR}/mlir-c
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT mlir-headers
|
|
|
|
FILES_MATCHING
|
|
|
|
PATTERN "*.h"
|
|
|
|
PATTERN "*.gen"
|
|
|
|
PATTERN "*.inc"
|
|
|
|
PATTERN "CMakeFiles" EXCLUDE
|
|
|
|
PATTERN "config.h" EXCLUDE
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT LLVM_ENABLE_IDE)
|
|
|
|
add_llvm_install_targets(install-mlir-headers
|
|
|
|
DEPENDS mlir-headers
|
|
|
|
COMPONENT mlir-headers)
|
|
|
|
endif()
|
|
|
|
endif()
|