Introduce OpOperandAdaptors and emit them from ODS
authorAlex Zinenko <zinenko@google.com>
Mon, 3 Jun 2019 15:03:20 +0000 (08:03 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Tue, 4 Jun 2019 02:26:12 +0000 (19:26 -0700)
commit252de8eca01a54ccac3f9b3aa6b7e104315f6f86
tree2e3b226f421a3089ce0f2b26f9dfa8d51f10ecd5
parent3ea85750585c2779cd97358ad24fd53e11b91da6
Introduce OpOperandAdaptors and emit them from ODS

When manipulating generic operations, such as in dialect conversion /
rewriting, it is often necessary to view a list of Values as operands to an
operation without creating the operation itself.  The absence of such view
makes dialect conversion patterns, among others, to use magic numbers to obtain
specific operands from a list of rewritten values when converting an operation.
Introduce XOpOperandAdaptor classes that wrap an ArrayRef<Value *> and provide
accessor functions identical to those available in XOp.  This makes it possible
for conversions to use these adaptors to address the operands with names rather
than rely on their position in the list.  The adaptors are generated from ODS
together with the actual operation definitions.

This is another step towards making dialect conversion patterns specific for a
given operation.

Illustrate the approach on conversion patterns in the standard to LLVM dialect
conversion.

PiperOrigin-RevId: 251232899
mlir/g3doc/OpDefinitions.md
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/StandardOps/Ops.td
mlir/include/mlir/TableGen/Operator.h
mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp
mlir/lib/TableGen/Operator.cpp
mlir/test/mlir-tblgen/op-decl.td
mlir/test/mlir-tblgen/op-operand.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp