[Mlir-commits] [mlir] 8eb4b3e - [CMake][MLIR][Linalg] Adding variable to specify tablegen file dependencies.

Tobias Gysi llvmlistbot at llvm.org
Thu Jul 1 11:54:52 PDT 2021


Author: Tobias Gysi
Date: 2021-07-01T18:54:30Z
New Revision: 8eb4b3e2be008fc3455b3c2820b1b55d2a5c25f0

URL: https://github.com/llvm/llvm-project/commit/8eb4b3e2be008fc3455b3c2820b1b55d2a5c25f0
DIFF: https://github.com/llvm/llvm-project/commit/8eb4b3e2be008fc3455b3c2820b1b55d2a5c25f0.diff

LOG: [CMake][MLIR][Linalg] Adding variable to specify tablegen file dependencies.

Synchronizing multiple custom targets requires not only target but also
file dependencies. Building Linalg involves running yaml-gen followed by
tablegen. Currently, these custom targets are only synchronized using a
target dependency resulting in issues in specific incremental build
setups (https://llvm.discourse.group/t/missing-build-cmake-tblgen-dependency/3727/10).

This patch introduces a novel LLVM_TARGET_DEPENDS variable to the
TableGen.cmake file to provide a way to specify file dependencies.
Additionally, it adapts the Linalg CMakeLists.txt to introduce the
necessary file dependency between yaml-gen and tablegen.

Differential Revision: https://reviews.llvm.org/D105272

Added: 
    

Modified: 
    llvm/cmake/modules/TableGen.cmake
    mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 5f07acc1f6922..5e9e2674405ee 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -1,4 +1,5 @@
-# LLVM_TARGET_DEFINITIONS must contain the name of the .td file to process.
+# LLVM_TARGET_DEFINITIONS must contain the name of the .td file to process,
+# while LLVM_TARGET_DEPENDS may contain additional file dependencies.
 # Extra parameters for `tblgen' may come after `ofn' parameter.
 # Adds the name of the generated file to TABLEGEN_OUTPUT.
 
@@ -104,6 +105,7 @@ function(tablegen project ofn)
     DEPENDS ${${project}_TABLEGEN_TARGET} ${${project}_TABLEGEN_EXE}
       ${local_tds} ${global_tds}
     ${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
+    ${LLVM_TARGET_DEPENDS}
     COMMENT "Building ${ofn}..."
     )
 

diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
index 6056c5e5259e8..4e3727839329d 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
@@ -25,6 +25,10 @@ function(add_linalg_ods_tc_gen tc_filename output_file)
     ${MLIR_LINALG_ODS_GEN_EXE}
     ${MLIR_LINALG_ODS_GEN_TARGET}
     ${GEN_ODS_FILE} ${GEN_CPP_FILE})
+  # Setup the file dependencies needed for the subsequent tablegen step.
+  # TODO: Once there is only one way of generating named ops remove this parent
+  # scope manipulation and implement the tablegen generation in the same scope.
+  set(LLVM_TARGET_DEPENDS ${LLVM_TARGET_DEPENDS} ${GEN_ODS_FILE} PARENT_SCOPE)
 endfunction()
 
 # Declare a function to generate ODS with mlir-linalg-ods-yaml-gen
@@ -52,10 +56,17 @@ function(add_linalg_ods_yaml_gen yaml_ast_file output_file)
     ${MLIR_LINALG_ODS_YAML_GEN_EXE}
     ${MLIR_LINALG_ODS_YAML_GEN_TARGET}
     ${GEN_ODS_FILE} ${GEN_CPP_FILE})
+  # Setup the file dependencies needed for the subsequent tablegen step.
+  # TODO: Once there is only one way of generating named ops remove this parent
+  # scope manipulation and implement the tablegen generation in the same scope.
+  set(LLVM_TARGET_DEPENDS ${LLVM_TARGET_DEPENDS} ${GEN_ODS_FILE} PARENT_SCOPE)
 endfunction()
 
 # TODO: Delete tc generation and replace with the YAML variant once all ops are
-# ported.
+# ported. At the same time, move the YAML and TableGen generation to the same
+# scope to avoid the at a distance dependency manipulation via
+# LLVM_TARGET_DEPENDS.
+set(LLVM_TARGET_DEPENDS "")
 add_linalg_ods_tc_gen(LinalgNamedStructuredOpsSpec.tc LinalgNamedStructuredOps)
 add_linalg_ods_yaml_gen(LinalgNamedStructuredOps.yaml LinalgNamedStructuredOps)
 


        


More information about the Mlir-commits mailing list