[mlir][llvm] Make the import of LLVM IR intrinsics extensible.
authorTobias Gysi <tobias.gysi@nextsilicon.com>
Mon, 2 Jan 2023 10:34:51 +0000 (11:34 +0100)
committerTobias Gysi <tobias.gysi@nextsilicon.com>
Mon, 2 Jan 2023 10:35:44 +0000 (11:35 +0100)
commitcf487cce6f64fe2a397d43108bfdbad01a8754fb
tree212a719b00211f7ecd74392457d22a7b69f088a7
parent86195b8361d98210fc362609aceae324c8bc467a
[mlir][llvm] Make the import of LLVM IR intrinsics extensible.

The revision introduces the LLVMImportDialectInterface to make the
import of LLVM IR intrinsics extensible. It uses a dialect interface
that enables external projects to provide their own conversion functions
for custom intrinsics. These conversion functions can rely on the
ModuleImport class to perform support tasks such as mapping LLVM
values to MLIR values or for converting types between the two worlds.

The implementation largely mirrors the export implementation. One major
difference is the dispatch to the appropriate dialect interface, since
LLVM IR intrinsics have no direct association to an MLIR dialect. The
dialect interfaces thus have to publish the supported intrinsics to
ensure incoming conversion calls are dispatched to the right dialect
interface.

The revision implements the extensible intrinsic import discussed as
part of the "extensible llvm ir import" rfc:
https://discourse.llvm.org/t/rfc-extensible-llvm-ir-import/67256/6

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D140374
15 files changed:
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Target/LLVMIR/Dialect/All.h
mlir/include/mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.h [new file with mode: 0644]
mlir/include/mlir/Target/LLVMIR/Import.h
mlir/include/mlir/Target/LLVMIR/LLVMImportInterface.h [new file with mode: 0644]
mlir/include/mlir/Target/LLVMIR/ModuleImport.h
mlir/include/mlir/Tools/mlir-translate/Translation.h
mlir/lib/Target/LLVMIR/CMakeLists.txt
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/CMakeLists.txt
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp [new file with mode: 0644]
mlir/lib/Target/LLVMIR/ModuleImport.cpp
mlir/lib/Tools/mlir-translate/Translation.cpp
mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp