[mlir] LLVM dialect: Generate conversions between EnumAttrCase and LLVM API
authorAlex Zinenko <zinenko@google.com>
Mon, 27 Jan 2020 13:49:34 +0000 (14:49 +0100)
committerAlex Zinenko <zinenko@google.com>
Thu, 30 Jan 2020 20:54:56 +0000 (21:54 +0100)
commiteb67bd78dc1865fce0c35f241f62cf65f4452e3e
treebc258078a682046a6d9321cef2658abd43b4ce3e
parent5be2ca29217ad977f2479bfc530127c7fb418963
[mlir] LLVM dialect: Generate conversions between EnumAttrCase and LLVM API

Summary:
MLIR materializes various enumeration-based LLVM IR operands as enumeration
attributes using ODS. This requires bidirectional conversion between different
but very similar enums, currently hardcoded. Extend the ODS modeling of
LLVM-specific enumeration attributes to include the name of the corresponding
enum in the LLVM C++ API as well as the names of specific enumerants. Use this
new information to automatically generate the conversion functions between enum
attributes and LLVM API enums in the two-way conversion between the LLVM
dialect and LLVM IR proper.

Differential Revision: https://reviews.llvm.org/D73468
mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp