[Mlir-commits] [mlir] aca240b - [mlir] Fix cross-compilation (Linalg ODS gen)

Alex Zinenko llvmlistbot at llvm.org
Mon Jan 18 02:58:04 PST 2021


Author: Vladislav Vinogradov
Date: 2021-01-18T11:57:55+01:00
New Revision: aca240b4f69e908b31e30b7ccece3c5b1d58426e

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

LOG: [mlir] Fix cross-compilation (Linalg ODS gen)

Use cross-compilation approach for `mlir-linalg-ods-gen` application
similar to TblGen tools.

Reviewed By: nicolasvasilache

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

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
    mlir/tools/CMakeLists.txt
    mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 2cf37753ea5c..cbae5fd54823 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -98,6 +98,7 @@ include_directories( ${MLIR_INCLUDE_DIR})
 # MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
 # from another directory like tools
 add_subdirectory(tools/mlir-tblgen)
+add_subdirectory(tools/mlir-linalg-ods-gen)
 
 add_subdirectory(include/mlir)
 add_subdirectory(lib)

diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
index fe67dcb7a660..09db72806565 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
@@ -11,17 +11,19 @@ function(add_linalg_ods_gen tc_filename output_file)
     PROPERTIES GENERATED TRUE)
   add_custom_command(
     OUTPUT ${GEN_ODS_FILE} ${GEN_CPP_FILE}
-    COMMAND mlir-linalg-ods-gen -gen-ods-decl ${TC_SOURCE} > ${GEN_ODS_FILE}
-    COMMAND mlir-linalg-ods-gen -gen-impl ${TC_SOURCE} > ${GEN_CPP_FILE}
+    COMMAND ${MLIR_LINALG_ODS_GEN_EXE} -gen-ods-decl ${TC_SOURCE} > ${GEN_ODS_FILE}
+    COMMAND ${MLIR_LINALG_ODS_GEN_EXE} -gen-impl ${TC_SOURCE} > ${GEN_CPP_FILE}
     MAIN_DEPENDENCY
     ${TC_SOURCE}
     DEPENDS
-    mlir-linalg-ods-gen
+    ${MLIR_LINALG_ODS_GEN_EXE}
+    ${MLIR_LINALG_ODS_GEN_TARGET}
     VERBATIM)
   add_custom_target(
     MLIR${output_file}IncGen
     DEPENDS
-    mlir-linalg-ods-gen
+    ${MLIR_LINALG_ODS_GEN_EXE}
+    ${MLIR_LINALG_ODS_GEN_TARGET}
     ${GEN_ODS_FILE} ${GEN_CPP_FILE})
 endfunction()
 

diff  --git a/mlir/tools/CMakeLists.txt b/mlir/tools/CMakeLists.txt
index ab59514ef6a7..3a60ae25548e 100644
--- a/mlir/tools/CMakeLists.txt
+++ b/mlir/tools/CMakeLists.txt
@@ -1,10 +1,9 @@
 add_subdirectory(mlir-cuda-runner)
 add_subdirectory(mlir-cpu-runner)
-add_subdirectory(mlir-linalg-ods-gen)
 add_subdirectory(mlir-opt)
 add_subdirectory(mlir-reduce)
 add_subdirectory(mlir-rocm-runner)
 add_subdirectory(mlir-shlib)
 add_subdirectory(mlir-spirv-cpu-runner)
 add_subdirectory(mlir-translate)
-add_subdirectory(mlir-vulkan-runner)
\ No newline at end of file
+add_subdirectory(mlir-vulkan-runner)

diff  --git a/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt b/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
index bc9a0c1f310a..7a0f79798268 100644
--- a/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
+++ b/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
@@ -10,3 +10,18 @@ target_link_libraries(mlir-linalg-ods-gen PRIVATE
   MLIRSupport
   MLIRIR
   )
+
+set(MLIR_LINALG_ODS_GEN_EXE mlir-linalg-ods-gen PARENT_SCOPE)
+set(MLIR_LINALG_ODS_GEN_TARGET mlir-linalg-ods-gen PARENT_SCOPE)
+
+if(LLVM_USE_HOST_TOOLS)
+  build_native_tool(mlir-linalg-ods-gen MLIR_LINALG_ODS_GEN_EXE DEPENDS mlir-linalg-ods-gen)
+  set(MLIR_LINALG_ODS_GEN_EXE ${MLIR_LINALG_ODS_GEN_EXE} PARENT_SCOPE)
+
+  add_custom_target(mlir-linalg-ods-gen-host DEPENDS ${MLIR_LINALG_ODS_GEN_EXE})
+  set(MLIR_LINALG_ODS_GEN_TARGET mlir-linalg-ods-gen-host DEPENDS PARENT_SCOPE)
+
+  if(NOT LLVM_BUILD_UTILS)
+    set_target_properties(mlir-linalg-ods-gen PROPERTIES EXCLUDE_FROM_ALL ON)
+  endif()
+endif()


        


More information about the Mlir-commits mailing list