1function(mlir_tablegen ofn) 2 tablegen(MLIR ${ARGV}) 3 set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn} 4 PARENT_SCOPE) 5endfunction() 6 7# Declare a dialect in the include directory 8function(add_mlir_dialect dialect dialect_namespace) 9 set(LLVM_TARGET_DEFINITIONS ${dialect}.td) 10 mlir_tablegen(${dialect}.h.inc -gen-op-decls) 11 mlir_tablegen(${dialect}.cpp.inc -gen-op-defs) 12 mlir_tablegen(${dialect}Dialect.h.inc -gen-dialect-decls -dialect=${dialect_namespace}) 13 add_public_tablegen_target(MLIR${dialect}IncGen) 14 add_dependencies(mlir-headers MLIR${dialect}IncGen) 15endfunction() 16 17# Generate Documentation 18function(add_mlir_doc doc_filename command output_file output_directory) 19 set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td) 20 tablegen(MLIR ${output_file}.md ${command} "-I${MLIR_MAIN_INCLUDE_DIR}" "-I${MLIR_INCLUDE_DIR}") 21 set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/${output_directory}${output_file}.md) 22 add_custom_command( 23 OUTPUT ${GEN_DOC_FILE} 24 COMMAND ${CMAKE_COMMAND} -E copy 25 ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md 26 ${GEN_DOC_FILE} 27 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md) 28 add_custom_target(${output_file}DocGen DEPENDS ${GEN_DOC_FILE}) 29 add_dependencies(mlir-doc ${output_file}DocGen) 30endfunction() 31 32# Declare a library which can be compiled in libMLIR.so 33macro(add_mlir_library name) 34 set_property(GLOBAL APPEND PROPERTY MLIR_ALL_LIBS ${name}) 35 add_llvm_library(${ARGV}) 36endmacro(add_mlir_library) 37 38# Declare the library associated with a dialect. 39function(add_mlir_dialect_library name) 40 set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name}) 41 add_mlir_library(${ARGV}) 42endfunction(add_mlir_dialect_library) 43 44# Declare the library associated with a conversion. 45function(add_mlir_conversion_library name) 46 set_property(GLOBAL APPEND PROPERTY MLIR_CONVERSION_LIBS ${name}) 47 add_mlir_library(${ARGV}) 48endfunction(add_mlir_conversion_library) 49 50# Declare the library associated with a translation. 51function(add_mlir_translation_library name) 52 set_property(GLOBAL APPEND PROPERTY MLIR_TRANSLATION_LIBS ${name}) 53 add_mlir_library(${ARGV}) 54endfunction(add_mlir_translation_library) 55