2020-01-22 08:44:17 +08:00
|
|
|
function(mlir_tablegen ofn)
|
2020-04-01 02:45:59 +08:00
|
|
|
tablegen(MLIR ${ARGV})
|
2020-01-22 08:44:17 +08:00
|
|
|
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
|
|
|
PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2020-02-27 03:50:03 +08:00
|
|
|
# Declare a dialect in the include directory
|
2020-03-25 02:57:13 +08:00
|
|
|
function(add_mlir_dialect dialect dialect_namespace)
|
2020-02-27 03:50:03 +08:00
|
|
|
set(LLVM_TARGET_DEFINITIONS ${dialect}.td)
|
|
|
|
mlir_tablegen(${dialect}.h.inc -gen-op-decls)
|
|
|
|
mlir_tablegen(${dialect}.cpp.inc -gen-op-defs)
|
2020-03-15 11:33:53 +08:00
|
|
|
mlir_tablegen(${dialect}Dialect.h.inc -gen-dialect-decls -dialect=${dialect_namespace})
|
2020-02-27 03:50:03 +08:00
|
|
|
add_public_tablegen_target(MLIR${dialect}IncGen)
|
|
|
|
add_dependencies(mlir-headers MLIR${dialect}IncGen)
|
2020-03-25 02:57:13 +08:00
|
|
|
endfunction()
|
2020-02-27 03:50:03 +08:00
|
|
|
|
2020-03-25 02:57:13 +08:00
|
|
|
# Generate Documentation
|
|
|
|
function(add_mlir_doc doc_filename command output_file output_directory)
|
|
|
|
set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td)
|
2020-04-12 14:29:07 +08:00
|
|
|
tablegen(MLIR ${output_file}.md ${command} "-I${MLIR_MAIN_INCLUDE_DIR}" "-I${MLIR_INCLUDE_DIR}")
|
2020-03-25 02:57:13 +08:00
|
|
|
set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/${output_directory}${output_file}.md)
|
2020-02-27 03:50:03 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${GEN_DOC_FILE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
2020-03-25 02:57:13 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md
|
2020-02-27 03:50:03 +08:00
|
|
|
${GEN_DOC_FILE}
|
2020-03-25 02:57:13 +08:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md)
|
|
|
|
add_custom_target(${output_file}DocGen DEPENDS ${GEN_DOC_FILE})
|
|
|
|
add_dependencies(mlir-doc ${output_file}DocGen)
|
2020-02-27 03:50:03 +08:00
|
|
|
endfunction()
|
|
|
|
|
2020-02-09 11:27:54 +08:00
|
|
|
# Declare a library which can be compiled in libMLIR.so
|
|
|
|
macro(add_mlir_library name)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY MLIR_ALL_LIBS ${name})
|
|
|
|
add_llvm_library(${ARGV})
|
|
|
|
endmacro(add_mlir_library)
|
|
|
|
|
2020-02-27 03:50:03 +08:00
|
|
|
# Declare the library associated with a dialect.
|
|
|
|
function(add_mlir_dialect_library name)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name})
|
2020-02-09 11:27:54 +08:00
|
|
|
add_mlir_library(${ARGV})
|
2020-02-27 03:50:03 +08:00
|
|
|
endfunction(add_mlir_dialect_library)
|
2020-02-27 08:31:14 +08:00
|
|
|
|
|
|
|
# Declare the library associated with a conversion.
|
|
|
|
function(add_mlir_conversion_library name)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY MLIR_CONVERSION_LIBS ${name})
|
2020-02-09 11:27:54 +08:00
|
|
|
add_mlir_library(${ARGV})
|
2020-02-27 08:31:14 +08:00
|
|
|
endfunction(add_mlir_conversion_library)
|
2020-04-11 07:58:39 +08:00
|
|
|
|
|
|
|
# Declare the library associated with a translation.
|
|
|
|
function(add_mlir_translation_library name)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY MLIR_TRANSLATION_LIBS ${name})
|
|
|
|
add_mlir_library(${ARGV})
|
|
|
|
endfunction(add_mlir_translation_library)
|