[mlir][llvm] Make the import of LLVM IR metadata extensible.
authorTobias Gysi <tobias.gysi@nextsilicon.com>
Tue, 3 Jan 2023 12:46:08 +0000 (13:46 +0100)
committerTobias Gysi <tobias.gysi@nextsilicon.com>
Tue, 3 Jan 2023 13:47:25 +0000 (14:47 +0100)
commit0cf066392f685f251102d2e7c29178a755f867fe
tree538485c3793fd85879f46efb179a1ace140f7d51
parent25c338ccb6e2acac8ed782ad229974c464126216
[mlir][llvm] Make the import of LLVM IR metadata extensible.

This revision extends the LLVMImportDialectInterface to make the import
of LLVM IR instruction-level metadata extensible. It extends the
signature of the existing dialect interface to provide a method to
import specific metadata kinds and attach them to the imported
operation. The conversion function can rely on the ModuleImport class
to perform support tasks.

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

The interface method names changed a bit compared to the suggested
design. The hook to set the instruction level metadata is now called
setMetadataAttrs and takes the metadata kind as an additional parameter.
We do not hand in the original LLVM IR instruction since it is not used
at this point. Importing named module-level meta data can be added in a
later stage after gaining some experience with this extension mechanism.

Depends on D140374

Reviewed By: ftynse, Dinistro

Differential Revision: https://reviews.llvm.org/D140556
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/include/mlir/Target/LLVMIR/LLVMImportInterface.h
mlir/include/mlir/Target/LLVMIR/ModuleImport.h
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
mlir/lib/Target/LLVMIR/ModuleImport.cpp
mlir/test/Target/LLVMIR/Import/import-failure.ll
mlir/test/Target/LLVMIR/Import/profiling-metadata.ll [new file with mode: 0644]
mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp