2019-10-30 01:57:56 +08:00
|
|
|
# Path to LLVM source folder.
|
2020-01-07 04:59:19 +08:00
|
|
|
if(DEFINED ENV{LLVM_PROJ_SRC})
|
|
|
|
set(LLVM_PROJ_SRC $ENV{LLVM_PROJ_SRC})
|
|
|
|
if(EXISTS ${LLVM_PROJ_SRC})
|
|
|
|
message(STATUS "LLVM_PROJ_SRC " ${LLVM_PROJ_SRC})
|
2019-10-09 07:25:59 +08:00
|
|
|
else()
|
2020-01-07 04:59:19 +08:00
|
|
|
message(FATAL_ERROR "The path specified by LLVM_PROJ_SRC does not exist: "
|
|
|
|
${LLVM_PROJ_SRC})
|
2019-10-09 07:25:59 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2020-01-07 04:59:19 +08:00
|
|
|
message(FATAL_ERROR "env variable LLVM_PROJ_SRC not set")
|
2019-10-09 07:25:59 +08:00
|
|
|
endif()
|
|
|
|
|
2019-10-30 01:57:56 +08:00
|
|
|
# Path to LLVM build folder
|
2020-01-07 04:59:19 +08:00
|
|
|
if(DEFINED ENV{LLVM_PROJ_BUILD})
|
|
|
|
set(LLVM_PROJ_BUILD $ENV{LLVM_PROJ_BUILD})
|
|
|
|
if(EXISTS ${LLVM_PROJ_BUILD})
|
|
|
|
message(STATUS "LLVM_PROJ_BUILD " ${LLVM_PROJ_BUILD})
|
2019-10-30 01:57:56 +08:00
|
|
|
else()
|
2020-01-07 04:59:19 +08:00
|
|
|
message(FATAL_ERROR "The path specified by LLVM_PROJ_BUILD does not exist: "
|
|
|
|
${LLVM_PROJ_BUILD})
|
2019-10-30 01:57:56 +08:00
|
|
|
endif()
|
2019-10-09 07:25:59 +08:00
|
|
|
else()
|
2020-01-07 04:59:19 +08:00
|
|
|
message(FATAL_ERROR "env variable LLVM_PROJ_BUILD not set")
|
2019-10-09 07:25:59 +08:00
|
|
|
endif()
|
|
|
|
|
2019-10-30 01:57:56 +08:00
|
|
|
# LLVM project lib folder
|
2020-04-19 22:11:24 +08:00
|
|
|
if (ENV{LLVM_PROJECT_LIB})
|
|
|
|
set(LLVM_PROJECT_LIB $ENV{LLVM_PROJECT_LIB})
|
|
|
|
else()
|
|
|
|
if(MSVC)
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(LLVM_PROJECT_LIB ${LLVM_PROJ_BUILD}/${CMAKE_BUILD_TYPE}/lib)
|
|
|
|
else()
|
|
|
|
set(LLVM_PROJECT_LIB ${LLVM_PROJ_BUILD}/release/lib)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(LLVM_PROJECT_LIB ${LLVM_PROJ_BUILD}/lib)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
message(STATUS "LLVM_PROJECT_LIB:" ${LLVM_PROJECT_LIB})
|
|
|
|
|
|
|
|
# LLVM project bin folder
|
|
|
|
if (ENV{LLVM_PROJ_BIN})
|
|
|
|
set(LLVM_PROJ_BIN $ENV{LLVM_PROJ_BIN})
|
|
|
|
else()
|
|
|
|
if(MSVC)
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(LLVM_PROJ_BIN ${LLVM_PROJ_BUILD}/${CMAKE_BUILD_TYPE}/bin)
|
|
|
|
else()
|
|
|
|
set(LLVM_PROJ_BIN ${LLVM_PROJ_BUILD}/Release/bin)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(LLVM_PROJ_BIN ${LLVM_PROJ_BUILD}/bin)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
message(STATUS "LLVM_PROJ_BIN:" ${LLVM_PROJ_BIN})
|
2019-10-30 01:57:56 +08:00
|
|
|
|
|
|
|
# Include paths for MLIR
|
2020-01-07 04:59:19 +08:00
|
|
|
set(LLVM_SRC_INCLUDE_PATH ${LLVM_PROJ_SRC}/llvm/include)
|
|
|
|
set(LLVM_BIN_INCLUDE_PATH ${LLVM_PROJ_BUILD}/include)
|
|
|
|
set(MLIR_SRC_INCLUDE_PATH ${LLVM_PROJ_SRC}/mlir/include)
|
|
|
|
set(MLIR_BIN_INCLUDE_PATH ${LLVM_PROJ_BUILD}/tools/mlir/include)
|
2020-04-19 22:11:24 +08:00
|
|
|
set(MLIR_TOOLS_DIR ${LLVM_PROJ_BIN})
|
2019-11-19 08:37:58 +08:00
|
|
|
|
2020-04-19 22:11:24 +08:00
|
|
|
# ONNX-MLIR tools folder
|
|
|
|
if(MSVC)
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(ONNX_MLIR_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
|
|
|
|
else()
|
|
|
|
set(ONNX_MLIR_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin/Release)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(ONNX_MLIR_TOOLS_DIR ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
endif()
|
|
|
|
message(STATUS "ONNX_MLIR_TOOLS_DIR:" ${ONNX_MLIR_TOOLS_DIR})
|
2020-03-21 00:04:22 +08:00
|
|
|
set(ONNX_MLIR_LIT_TEST_SRC_DIR ${ONNX_MLIR_SRC_ROOT}/test/mlir)
|
2020-03-17 21:16:33 +08:00
|
|
|
set(ONNX_MLIR_LIT_TEST_BUILD_DIR ${CMAKE_BINARY_DIR}/test/mlir)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
2019-11-19 08:37:58 +08:00
|
|
|
set(
|
2019-11-28 11:56:34 +08:00
|
|
|
MLIR_INCLUDE_PATHS
|
|
|
|
${LLVM_SRC_INCLUDE_PATH};${LLVM_BIN_INCLUDE_PATH};${MLIR_SRC_INCLUDE_PATH};${MLIR_BIN_INCLUDE_PATH}
|
|
|
|
)
|
2019-10-09 07:25:59 +08:00
|
|
|
include_directories(${MLIR_INCLUDE_PATHS})
|
|
|
|
|
2020-04-14 17:40:05 +08:00
|
|
|
# Force BUILD_SHARED_LIBS to be the same as LLVM build
|
|
|
|
file(STRINGS ${LLVM_PROJ_BUILD}/CMakeCache.txt shared REGEX BUILD_SHARED_LIBS)
|
|
|
|
string(REGEX REPLACE "BUILD_SHARED_LIBS:BOOL=" "" shared ${shared})
|
|
|
|
set(BUILD_SHARED_LIBS ${shared} CACHE BOOL "" FORCE)
|
|
|
|
message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
# Threading libraries required due to parallel pass execution.
|
|
|
|
find_package(Threads REQUIRED)
|
2020-04-14 17:40:05 +08:00
|
|
|
# libcurses and libz required by libLLVMSupport
|
2020-04-19 22:11:24 +08:00
|
|
|
if(MSVC)
|
|
|
|
if(DEFINED ENV{CURSES_LIB_PATH})
|
|
|
|
find_library(CURSES_LIBRARIES
|
|
|
|
NAMES pdcurses
|
|
|
|
PATHS $ENV{CURSES_LIB_PATH}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
if(CURSES_LIBRARIES)
|
|
|
|
message(STATUS "CURSES_LIBRARIES: ${CURSES_LIBRARIES}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Could not find curses library at $ENV{CURSES_LIB_PATH}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Expected CURSES_LIB_PATH environment variable to be set to location of pdcurses.lib")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
find_package(Curses REQUIRED)
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set output library path
|
|
|
|
if(MSVC)
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
|
|
set(ONNX_MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
|
|
|
|
else()
|
|
|
|
set(ONNX_MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/Release)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(ONNX_MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
|
|
|
endif()
|
2019-11-04 23:58:48 +08:00
|
|
|
|
2019-11-27 02:55:44 +08:00
|
|
|
function(find_mlir_lib lib)
|
|
|
|
find_library(${lib}
|
2019-11-28 11:56:34 +08:00
|
|
|
NAMES ${lib}
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
2020-04-14 17:40:05 +08:00
|
|
|
if(${${lib}} STREQUAL ${lib}-NOTFOUND)
|
2020-04-16 14:38:52 +08:00
|
|
|
message(FATAL_ERROR "${lib} not found, did you forget to build llvm-project?")
|
2020-04-14 17:40:05 +08:00
|
|
|
endif()
|
2019-11-27 02:55:44 +08:00
|
|
|
endfunction(find_mlir_lib)
|
|
|
|
|
2020-04-27 17:03:56 +08:00
|
|
|
find_mlir_lib(MLIRAffineOps)
|
2020-08-14 12:52:48 +08:00
|
|
|
find_mlir_lib(MLIRAffineUtils)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRAffineToStandard)
|
2020-04-27 17:03:56 +08:00
|
|
|
find_mlir_lib(MLIRAffineTransforms)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRAnalysis)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(MLIRCallInterfaces)
|
|
|
|
find_mlir_lib(MLIRControlFlowInterfaces)
|
2020-08-14 12:52:48 +08:00
|
|
|
find_mlir_lib(MLIRCopyOpInterface)
|
2019-12-20 00:28:06 +08:00
|
|
|
find_mlir_lib(MLIRDialect)
|
2020-02-20 07:15:02 +08:00
|
|
|
find_mlir_lib(MLIREDSC)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRExecutionEngine)
|
2020-08-20 00:57:40 +08:00
|
|
|
find_mlir_lib(MLIRInferTypeOpInterface)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRIR)
|
|
|
|
find_mlir_lib(MLIRLLVMIR)
|
2020-02-20 07:15:02 +08:00
|
|
|
find_mlir_lib(MLIRLoopAnalysis)
|
2020-05-20 15:45:42 +08:00
|
|
|
find_mlir_lib(MLIRSCFToStandard)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(MLIRLoopLikeInterface)
|
2020-06-26 01:36:39 +08:00
|
|
|
find_mlir_lib(MLIRLinalgOps)
|
|
|
|
find_mlir_lib(MLIRLinalgEDSC)
|
|
|
|
find_mlir_lib(MLIRLinalgAnalysis)
|
|
|
|
find_mlir_lib(MLIRLinalgTransforms)
|
|
|
|
find_mlir_lib(MLIRLinalgUtils)
|
2020-05-20 15:45:42 +08:00
|
|
|
find_mlir_lib(MLIRSCF)
|
2020-07-10 06:12:57 +08:00
|
|
|
find_mlir_lib(MLIRSCFTransforms)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(MLIRLLVMIRTransforms)
|
|
|
|
find_mlir_lib(MLIRMlirOptMain)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRParser)
|
|
|
|
find_mlir_lib(MLIRPass)
|
|
|
|
find_mlir_lib(MLIRStandardOps)
|
2020-08-14 12:52:48 +08:00
|
|
|
find_mlir_lib(MLIRStandardOpsTransforms)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRStandardToLLVM)
|
2020-05-20 15:45:42 +08:00
|
|
|
find_mlir_lib(MLIRSideEffectInterfaces)
|
2019-11-27 02:55:44 +08:00
|
|
|
find_mlir_lib(MLIRTargetLLVMIR)
|
|
|
|
find_mlir_lib(MLIRTransforms)
|
|
|
|
find_mlir_lib(MLIRTransformUtils)
|
|
|
|
find_mlir_lib(MLIRSupport)
|
2020-08-20 00:57:40 +08:00
|
|
|
find_mlir_lib(MLIRShape)
|
|
|
|
find_mlir_lib(MLIRShapeToStandard)
|
|
|
|
find_mlir_lib(MLIRShapeToSCF)
|
|
|
|
find_mlir_lib(MLIRSideEffectInterfaces)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(MLIROpenMP)
|
2020-02-20 07:15:02 +08:00
|
|
|
find_mlir_lib(MLIROptLib)
|
2020-07-07 21:26:00 +08:00
|
|
|
find_mlir_lib(MLIRTableGen)
|
2019-11-28 11:56:34 +08:00
|
|
|
find_mlir_lib(MLIRTargetLLVMIRModuleTranslation)
|
|
|
|
find_mlir_lib(MLIRTargetLLVMIR)
|
|
|
|
find_mlir_lib(MLIRTransformUtils)
|
|
|
|
find_mlir_lib(MLIRTranslation)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(MLIRVector)
|
2020-08-14 12:52:48 +08:00
|
|
|
find_mlir_lib(MLIRVectorInterfaces)
|
2020-07-10 06:12:57 +08:00
|
|
|
find_mlir_lib(MLIRVectorToLLVM)
|
|
|
|
find_mlir_lib(MLIRVectorToSCF)
|
2020-06-26 01:36:39 +08:00
|
|
|
find_mlir_lib(MLIRMlirOptMain)
|
|
|
|
find_mlir_lib(MLIRAffineEDSC)
|
|
|
|
find_mlir_lib(MLIRLinalgEDSC)
|
|
|
|
find_mlir_lib(MLIRViewLikeInterface)
|
2020-08-14 12:52:48 +08:00
|
|
|
find_mlir_lib(MLIRPresburger)
|
2019-11-27 02:55:44 +08:00
|
|
|
|
|
|
|
find_mlir_lib(LLVMCore)
|
|
|
|
find_mlir_lib(LLVMSupport)
|
|
|
|
find_mlir_lib(LLVMAsmParser)
|
|
|
|
find_mlir_lib(LLVMBinaryFormat)
|
|
|
|
find_mlir_lib(LLVMRemarks)
|
|
|
|
find_mlir_lib(LLVMIRReader)
|
|
|
|
find_mlir_lib(LLVMTransformUtils)
|
|
|
|
find_mlir_lib(LLVMBitstreamReader)
|
2019-11-28 11:56:34 +08:00
|
|
|
find_mlir_lib(LLVMAnalysis)
|
|
|
|
find_mlir_lib(LLVMBitWriter)
|
|
|
|
find_mlir_lib(LLVMBitReader)
|
|
|
|
find_mlir_lib(LLVMMC)
|
|
|
|
find_mlir_lib(LLVMMCParser)
|
|
|
|
find_mlir_lib(LLVMObject)
|
|
|
|
find_mlir_lib(LLVMProfileData)
|
|
|
|
find_mlir_lib(LLVMDemangle)
|
2020-04-02 00:38:34 +08:00
|
|
|
find_mlir_lib(LLVMFrontendOpenMP)
|
2019-11-28 11:56:34 +08:00
|
|
|
|
2020-04-14 17:40:05 +08:00
|
|
|
set(MLIRLibs
|
2020-06-19 00:21:27 +08:00
|
|
|
${MLIRAffineToStandard}
|
|
|
|
${MLIRAffineOps}
|
2020-08-14 12:52:48 +08:00
|
|
|
${MLIRAffineUtils}
|
|
|
|
${MLIRCopyOpInterface}
|
2020-06-19 00:21:27 +08:00
|
|
|
${MLIRLLVMIR}
|
|
|
|
${MLIRStandardOps}
|
2020-08-14 12:52:48 +08:00
|
|
|
${MLIRStandardOpsTransforms}
|
2020-06-19 00:21:27 +08:00
|
|
|
${MLIRStandardToLLVM}
|
|
|
|
${MLIRTransforms}
|
|
|
|
${MLIRSCFToStandard}
|
|
|
|
${MLIRVector}
|
2020-08-14 12:52:48 +08:00
|
|
|
${MLIRVectorInterfaces}
|
2020-07-10 06:12:57 +08:00
|
|
|
${MLIRVectorToLLVM}
|
|
|
|
${MLIRVectorToSCF}
|
2020-06-19 00:21:27 +08:00
|
|
|
${MLIRSCF}
|
|
|
|
${MLIRIR}
|
2020-04-14 17:40:05 +08:00
|
|
|
${MLIRLLVMIR}
|
|
|
|
${MLIROptLib}
|
|
|
|
${MLIRParser}
|
|
|
|
${MLIRPass}
|
|
|
|
${MLIRTargetLLVMIR}
|
|
|
|
${MLIRTargetLLVMIRModuleTranslation}
|
|
|
|
${MLIRTransforms}
|
|
|
|
${MLIRTransformUtils}
|
2020-04-27 17:03:56 +08:00
|
|
|
${MLIRAffineOps}
|
2019-12-23 09:33:33 +08:00
|
|
|
${MLIRAffineToStandard}
|
2020-04-27 17:03:56 +08:00
|
|
|
${MLIRAffineTransforms}
|
2019-12-23 09:33:33 +08:00
|
|
|
${MLIRAnalysis}
|
2020-04-02 00:38:34 +08:00
|
|
|
${MLIRCallInterfaces}
|
|
|
|
${MLIRControlFlowInterfaces}
|
2019-12-23 09:33:33 +08:00
|
|
|
${MLIRDialect}
|
2020-02-20 07:15:02 +08:00
|
|
|
${MLIREDSC}
|
2019-12-23 09:33:33 +08:00
|
|
|
${MLIRExecutionEngine}
|
|
|
|
${MLIRIR}
|
2020-04-02 00:38:34 +08:00
|
|
|
${MLIRLLVMIRTransforms}
|
2020-05-20 15:45:42 +08:00
|
|
|
${MLIRSCFToStandard}
|
|
|
|
${MLIRSCF}
|
2020-07-10 06:12:57 +08:00
|
|
|
${MLIRSCFTransforms}
|
2020-02-20 07:15:02 +08:00
|
|
|
${MLIRLoopAnalysis}
|
2020-04-02 00:38:34 +08:00
|
|
|
${MLIRLoopLikeInterface}
|
|
|
|
${MLIROpenMP}
|
2020-02-20 07:15:02 +08:00
|
|
|
${MLIRMlirOptMain}
|
2020-05-20 15:45:42 +08:00
|
|
|
${MLIRSideEffectInterfaces}
|
2019-12-23 09:33:33 +08:00
|
|
|
${MLIRStandardOps}
|
|
|
|
${MLIRStandardToLLVM}
|
2020-04-14 17:40:05 +08:00
|
|
|
${MLIRTranslation}
|
2020-09-09 23:12:01 +08:00
|
|
|
${MLIRSupport}
|
2020-06-26 01:36:39 +08:00
|
|
|
${MLIRLinalgOps}
|
|
|
|
${MLIRLinalgEDSC}
|
|
|
|
${MLIRLinalgAnalysis}
|
|
|
|
${MLIRLinalgTransforms}
|
|
|
|
${MLIRLinalgUtils}
|
|
|
|
${MLIRAffineEDSC}
|
|
|
|
${MLIRLinalgEDSC}
|
|
|
|
${MLIRViewLikeInterface}
|
2020-08-14 12:52:48 +08:00
|
|
|
${MLIRPresburger}
|
2020-08-20 00:57:40 +08:00
|
|
|
${MLIRShape}
|
|
|
|
${MLIRShapeToStandard}
|
|
|
|
${MLIRShapeToSCF}
|
|
|
|
${MLIRInferTypeOpInterface}
|
2020-04-14 17:40:05 +08:00
|
|
|
# strict order verified
|
|
|
|
${LLVMBitWriter}
|
|
|
|
${LLVMObject}
|
|
|
|
${LLVMBitReader}
|
|
|
|
# strict order verified
|
|
|
|
${LLVMFrontendOpenMP}
|
|
|
|
${LLVMTransformUtils}
|
|
|
|
${LLVMAnalysis}
|
|
|
|
# strict order verified
|
|
|
|
${LLVMAsmParser}
|
|
|
|
${LLVMCore}
|
|
|
|
# strict order not yet verified
|
|
|
|
${LLVMRemarks}
|
|
|
|
${LLVMMCParser}
|
|
|
|
${LLVMMC}
|
|
|
|
${LLVMProfileData}
|
|
|
|
${LLVMBinaryFormat}
|
|
|
|
${LLVMBitstreamReader}
|
|
|
|
${LLVMIRReader}
|
|
|
|
${LLVMMLIRTableGen}
|
|
|
|
${LLVMSupport}
|
|
|
|
${LLVMDemangle}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
2020-04-19 22:11:24 +08:00
|
|
|
${CURSES_LIBRARIES}
|
|
|
|
${ZLIB_LIBRARIES})
|
2019-11-27 02:55:44 +08:00
|
|
|
|
2019-11-19 08:37:58 +08:00
|
|
|
set(LLVM_CMAKE_DIR
|
2020-01-07 04:59:19 +08:00
|
|
|
"${LLVM_PROJ_BUILD}/lib/cmake/llvm"
|
2019-11-28 11:56:34 +08:00
|
|
|
CACHE PATH "Path to LLVM cmake modules")
|
2019-11-19 08:37:58 +08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
|
|
|
|
include(AddLLVM)
|
|
|
|
include(TableGen)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
function(onnx_mlir_tablegen ofn)
|
2019-10-09 07:25:59 +08:00
|
|
|
tablegen(MLIR
|
2019-11-28 11:56:34 +08:00
|
|
|
${ARGV}
|
|
|
|
"-I${MLIR_SRC_INCLUDE_PATH}"
|
2020-03-20 22:40:51 +08:00
|
|
|
"-I${MLIR_BIN_INCLUDE_PATH}"
|
|
|
|
"-I${ONNX_MLIR_SRC_ROOT}")
|
2019-10-09 07:25:59 +08:00
|
|
|
set(TABLEGEN_OUTPUT
|
2019-11-28 11:56:34 +08:00
|
|
|
${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
|
|
|
PARENT_SCOPE)
|
2019-10-09 07:25:59 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Import the pre-built mlir TableGen as an imported exetuable. It is required by
|
|
|
|
# the LLVM TableGen command to have the TableGen target so that changes to the
|
|
|
|
# table gen utility itself can be detected and cause re-compilation of .td file.
|
|
|
|
add_executable(mlir-tblgen IMPORTED)
|
|
|
|
set_property(TARGET mlir-tblgen
|
2020-04-19 22:11:24 +08:00
|
|
|
PROPERTY IMPORTED_LOCATION ${LLVM_PROJ_BIN}/mlir-tblgen)
|
2019-10-09 07:25:59 +08:00
|
|
|
set(MLIR_TABLEGEN_EXE mlir-tblgen)
|
2020-02-11 03:18:54 +08:00
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
# Add a dialect used by ONNX MLIR and copy the generated operation
|
2020-02-11 03:18:54 +08:00
|
|
|
# documentation to the desired places.
|
|
|
|
# c.f. https://github.com/llvm/llvm-project/blob/e298e216501abf38b44e690d2b28fc788ffc96cf/mlir/CMakeLists.txt#L11
|
2020-03-17 21:16:33 +08:00
|
|
|
function(add_onnx_mlir_dialect_doc dialect dialect_tablegen_file)
|
2020-02-11 03:18:54 +08:00
|
|
|
# Generate Dialect Documentation
|
|
|
|
set(LLVM_TARGET_DEFINITIONS ${dialect_tablegen_file})
|
2020-03-17 21:16:33 +08:00
|
|
|
onnx_mlir_tablegen(${dialect}.md -gen-op-doc)
|
2020-04-09 23:37:04 +08:00
|
|
|
set(GEN_DOC_FILE ${ONNX_MLIR_BIN_ROOT}/docs/Dialects/${dialect}.md)
|
2020-02-11 03:18:54 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${GEN_DOC_FILE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${dialect}.md
|
|
|
|
${GEN_DOC_FILE}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${dialect}.md)
|
|
|
|
add_custom_target(${dialect}DocGen DEPENDS ${GEN_DOC_FILE})
|
2020-03-17 21:16:33 +08:00
|
|
|
add_dependencies(onnx-mlir-doc ${dialect}DocGen)
|
2020-02-11 03:18:54 +08:00
|
|
|
endfunction()
|
|
|
|
|
2020-03-17 21:16:33 +08:00
|
|
|
add_custom_target(onnx-mlir-doc)
|