2019-10-09 07:25:59 +08:00
|
|
|
# Flags to link with LLVM/MLIR libraries
|
2019-10-30 01:57:56 +08:00
|
|
|
|
|
|
|
# Path to LLVM source folder.
|
|
|
|
if(DEFINED ENV{LLVM_SRC})
|
|
|
|
set(LLVM_SRC $ENV{LLVM_SRC})
|
|
|
|
if(EXISTS ${LLVM_SRC})
|
|
|
|
message(STATUS "LLVM_SRC " ${LLVM_SRC})
|
2019-10-09 07:25:59 +08:00
|
|
|
else()
|
|
|
|
message(
|
2019-10-30 01:57:56 +08:00
|
|
|
FATAL_ERROR "The path specified by LLVM_SRC does not exist: "
|
|
|
|
${LLVM_SRC})
|
2019-10-09 07:25:59 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2019-10-30 01:57:56 +08:00
|
|
|
message(FATAL_ERROR "env variable LLVM_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
|
|
|
|
if(DEFINED ENV{LLVM_BUILD})
|
|
|
|
set(LLVM_BUILD $ENV{LLVM_BUILD})
|
|
|
|
if(EXISTS ${LLVM_BUILD})
|
|
|
|
message(STATUS "LLVM_BUILD " ${LLVM_BUILD})
|
|
|
|
else()
|
|
|
|
message(
|
|
|
|
FATAL_ERROR "The path specified by LLVM_BUILD does not exist: "
|
|
|
|
${LLVM_BUILD})
|
|
|
|
endif()
|
2019-10-09 07:25:59 +08:00
|
|
|
else()
|
2019-10-30 01:57:56 +08:00
|
|
|
message(FATAL_ERROR "env variable LLVM_BUILD not set")
|
2019-10-09 07:25:59 +08:00
|
|
|
endif()
|
|
|
|
|
2019-10-30 01:57:56 +08:00
|
|
|
# LLVM project lib folder
|
|
|
|
set(LLVM_PROJECT_LIB ${LLVM_BUILD}/lib)
|
|
|
|
|
|
|
|
# Include paths for MLIR
|
|
|
|
set(LLVM_SRC_INCLUDE_PATH ${LLVM_SRC}/include)
|
|
|
|
set(LLVM_BIN_INCLUDE_PATH ${LLVM_BUILD}/include)
|
|
|
|
set(MLIR_SRC_INCLUDE_PATH ${LLVM_SRC}/projects/mlir/include)
|
|
|
|
set(MLIR_BIN_INCLUDE_PATH ${LLVM_BUILD}/projects/mlir/include)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
|
|
|
set(MLIR_INCLUDE_PATHS
|
|
|
|
${LLVM_SRC_INCLUDE_PATH};${LLVM_BIN_INCLUDE_PATH};${MLIR_SRC_INCLUDE_PATH};${MLIR_BIN_INCLUDE_PATH})
|
|
|
|
include_directories(${MLIR_INCLUDE_PATHS})
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_ANALYSIS
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRAnalysis
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_IR NAMES MLIRIR PATHS ${LLVM_PROJECT_LIB} NO_DEFAULT_PATH)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_PARSER
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRParser
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_PASS
|
|
|
|
NAMES MLIRPass
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
find_library(MLIR_LIB_TRANSFORMS
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRTransforms
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_VECTOR_OPS
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRVectorOps
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_SUPPORT
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRSupport
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_STANDARD_OPS
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES MLIRStandardOps
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
find_library(MLIR_LIB_OPT_MAIN
|
|
|
|
NAMES MLIROptMain
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
find_library(MLIR_LLVM_IR
|
|
|
|
NAMES MLIRLLVMIR
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
find_library(LLVM_LIB_SUPPORT
|
2019-10-09 07:25:59 +08:00
|
|
|
NAMES LLVMSupport
|
|
|
|
PATHS ${LLVM_PROJECT_LIB}
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
|
2019-11-04 23:58:48 +08:00
|
|
|
# Threading libraries required due to parallel pass execution.
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2019-10-09 07:25:59 +08:00
|
|
|
set(MLIRLIBS
|
2019-11-04 23:58:48 +08:00
|
|
|
${MLIR_LIB_ANALYSIS}
|
|
|
|
${MLIR_LIB_IR}
|
|
|
|
${MLIR_LIB_PARSER}
|
|
|
|
${MLIR_LIB_PASS}
|
|
|
|
${MLIR_LIB_TRANSFORMS}
|
|
|
|
${MLIR_LIB_VECTOR_OPS}
|
|
|
|
${MLIR_LIB_STANDARD_OPS}
|
|
|
|
${MLIR_LIB_OPT_MAIN}
|
|
|
|
${MLIR_LIB_SUPPORT}
|
|
|
|
|
|
|
|
${MLIR_LIB_ANALYSIS}
|
|
|
|
${MLIR_LIB_IR}
|
|
|
|
${MLIR_LIB_PARSER}
|
|
|
|
${MLIR_LIB_PASS}
|
|
|
|
${MLIR_LIB_TRANSFORMS}
|
|
|
|
${MLIR_LIB_VECTOR_OPS}
|
|
|
|
${MLIR_LIB_STANDARD_OPS}
|
|
|
|
${MLIR_LIB_OPT_MAIN}
|
|
|
|
${MLIR_LIB_SUPPORT}
|
|
|
|
|
|
|
|
${LLVM_LIB_SUPPORT}
|
|
|
|
Threads::Threads)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
|
|
|
# Set up TableGen environment.
|
2019-10-30 01:57:56 +08:00
|
|
|
include(${LLVM_BUILD}/lib/cmake/llvm/TableGen.cmake)
|
2019-10-09 07:25:59 +08:00
|
|
|
|
|
|
|
function(onnf_tablegen ofn)
|
|
|
|
tablegen(MLIR
|
|
|
|
${ARGV}
|
|
|
|
"-I${MLIR_SRC_INCLUDE_PATH}"
|
|
|
|
"-I${MLIR_BIN_INCLUDE_PATH}")
|
|
|
|
set(TABLEGEN_OUTPUT
|
|
|
|
${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
|
|
|
PARENT_SCOPE)
|
|
|
|
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
|
|
|
|
PROPERTY IMPORTED_LOCATION
|
2019-10-30 01:57:56 +08:00
|
|
|
${LLVM_BUILD}/bin/mlir-tblgen)
|
2019-10-09 07:25:59 +08:00
|
|
|
set(MLIR_TABLEGEN_EXE mlir-tblgen)
|
2019-11-04 23:58:48 +08:00
|
|
|
|