|
| 1 | +# Declare a function to generate ODS with mlir-linalg-ods-yaml-gen |
| 2 | +function(add_linalg_ods_yaml_gen yaml_ast_file output_file) |
| 3 | + set(YAML_AST_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${yaml_ast_file}) |
| 4 | + set(GEN_ODS_FILE ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.yamlgen.td) |
| 5 | + set(GEN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.yamlgen.cpp.inc) |
| 6 | + set_source_files_properties( |
| 7 | + ${GEN_ODS_FILE} |
| 8 | + PROPERTIES GENERATED TRUE) |
| 9 | + set_source_files_properties( |
| 10 | + ${GEN_CPP_FILE} |
| 11 | + PROPERTIES GENERATED TRUE) |
| 12 | + add_custom_command( |
| 13 | + OUTPUT ${GEN_ODS_FILE} ${GEN_CPP_FILE} |
| 14 | + COMMAND ${MLIR_LINALG_ODS_YAML_GEN_EXE} ${YAML_AST_SOURCE} -o-ods-decl=${GEN_ODS_FILE} -o-impl=${GEN_CPP_FILE} |
| 15 | + MAIN_DEPENDENCY |
| 16 | + ${YAML_AST_SOURCE} |
| 17 | + DEPENDS |
| 18 | + ${MLIR_LINALG_ODS_YAML_GEN_EXE} |
| 19 | + ${MLIR_LINALG_ODS_YAML_GEN_TARGET}) |
| 20 | + add_custom_target( |
| 21 | + MLIR${output_file}YamlIncGen |
| 22 | + DEPENDS |
| 23 | + ${MLIR_LINALG_ODS_YAML_GEN_EXE} |
| 24 | + ${MLIR_LINALG_ODS_YAML_GEN_TARGET} |
| 25 | + ${GEN_ODS_FILE} ${GEN_CPP_FILE}) |
| 26 | + list(APPEND LLVM_TARGET_DEPENDS ${GEN_ODS_FILE}) |
| 27 | + set(LLVM_TARGET_DEPENDS ${LLVM_TARGET_DEPENDS} PARENT_SCOPE) |
| 28 | +endfunction() |
| 29 | + |
| 30 | +# NOTE: LLVM_TARGET_DEPENDS gets picked up by tablegen targets to add file |
| 31 | +# level dependencies. This is gross but CMake requires depending on both |
| 32 | +# targets and generated files, and it must be done when the custom target is |
| 33 | +# declared (there is no way to add after the fact). |
| 34 | +set(LLVM_TARGET_DEPENDS "") |
1 | 35 | add_linalg_ods_yaml_gen(LinalgNamedStructuredOps.yaml LinalgNamedStructuredOps)
|
2 |
| -add_public_tablegen_target(MLIRLinalgNamedStructuredOpsYamlIncGen) |
3 | 36 |
|
4 | 37 | # Provide a short name for all external dependency that needs to
|
5 | 38 | # include Linalg in ODS
|
|
0 commit comments