summaryrefslogtreecommitdiff
path: root/mlir/tools
diff options
context:
space:
mode:
authorSergio Afonso <safonsof@amd.com>2023-03-13 12:51:18 +0000
committerSergio Afonso <safonsof@amd.com>2023-03-21 12:54:26 +0000
commit0e9523efda8a4ad95ecb1d5b5e65e10bcc3711f5 (patch)
tree52af06f42e6aa1a6786dced7e864cf775ba1c3cb /mlir/tools
parentcdccea8eb3b739ce11c2bab7b9c561b5a80abbf7 (diff)
downloadllvm-0e9523efda8a4ad95ecb1d5b5e65e10bcc3711f5.tar.gz
[mlir] Support lowering of dialect attributes attached to top-level modules
This patch supports the processing of dialect attributes attached to top-level module-type operations during MLIR-to-LLVMIR lowering. This approach modifies the `mlir::translateModuleToLLVMIR()` function to call `ModuleTranslation::convertOperation()` on the top-level operation, after its body has been lowered. This, in turn, will get the `LLVMTranslationDialectInterface` object associated to that operation's dialect before trying to use it for lowering prior to processing dialect attributes attached to the operation. Since there are no `LLVMTranslationDialectInterface`s for the builtin and GPU dialects, which define their own module-type operations, this patch also adds and registers them. The requirement for always calling `mlir::registerBuiltinDialectTranslation()` before any translation of MLIR to LLVM IR where builtin module operations are present is introduced. The purpose of these new translation interfaces is to succeed when processing module-type operations, allowing the lowering process to continue and to prevent the introduction of failures related to not finding such interfaces. Differential Revision: https://reviews.llvm.org/D145932
Diffstat (limited to 'mlir/tools')
-rw-r--r--mlir/tools/mlir-cpu-runner/CMakeLists.txt1
-rw-r--r--mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt1
-rw-r--r--mlir/tools/mlir-vulkan-runner/CMakeLists.txt1
3 files changed, 3 insertions, 0 deletions
diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
index 092ef1b0b7c7..c2ab62ee93a5 100644
--- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
@@ -11,6 +11,7 @@ add_mlir_tool(mlir-cpu-runner
llvm_update_compile_flags(mlir-cpu-runner)
target_link_libraries(mlir-cpu-runner PRIVATE
MLIRAnalysis
+ MLIRBuiltinToLLVMIRTranslation
MLIRExecutionEngine
MLIRIR
MLIRJitRunner
diff --git a/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
index 60951adf8620..789c94be4452 100644
--- a/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
@@ -17,6 +17,7 @@ if (MLIR_ENABLE_SPIRV_CPU_RUNNER)
${conversion_libs}
MLIRAnalysis
MLIRArithDialect
+ MLIRBuiltinToLLVMIRTranslation
MLIRExecutionEngine
MLIRFuncDialect
MLIRGPUOps
diff --git a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
index 4f64117c296f..a24ac080d746 100644
--- a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
@@ -57,6 +57,7 @@ if (MLIR_ENABLE_VULKAN_RUNNER)
${conversion_libs}
MLIRAnalysis
MLIRArithDialect
+ MLIRBuiltinToLLVMIRTranslation
MLIRExecutionEngine
MLIRFuncDialect
MLIRGPUOps