Add a new OpAsmOpInterface to allow for ops to directly hook into the AsmPrinter.
authorRiver Riddle <riverriddle@google.com>
Wed, 20 Nov 2019 18:19:01 +0000 (10:19 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 20 Nov 2019 18:45:45 +0000 (10:45 -0800)
commiteb418559ef29716cc34c891c93490c38ac5ea1dd
treebe1e4ac3d32e5df31b8668785ba15f92fe1895a9
parent3c055957de7e47e53d3ee8f5ab283cdb5c0ea535
Add a new OpAsmOpInterface to allow for ops to directly hook into the AsmPrinter.

This interface provides more fine-grained hooks into the AsmPrinter than the dialect interface, allowing for operations to define the asm name to use for results directly on the operations themselves. The hook is also expanded to enable defining named result "groups". Get a special name to use when printing the results of this operation.
The given callback is invoked with a specific result value that starts a
result "pack", and the name to give this result pack. To signal that a
result pack should use the default naming scheme, a None can be passed
in instead of the name.

For example, if you have an operation that has four results and you want
to split these into three distinct groups you could do the following:

  setNameFn(getResult(0), "first_result");
  setNameFn(getResult(1), "middle_results");
  setNameFn(getResult(3), ""); // use the default numbering.

This would print the operation as follows:

  %first_result, %middle_results:2, %0 = "my.op" ...

PiperOrigin-RevId: 281546873
12 files changed:
mlir/include/mlir/CMakeLists.txt
mlir/include/mlir/Dialect/StandardOps/Ops.h
mlir/include/mlir/Dialect/StandardOps/Ops.td
mlir/include/mlir/IR/CMakeLists.txt [new file with mode: 0644]
mlir/include/mlir/IR/OpAsmInterface.td [new file with mode: 0644]
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/Dialect/StandardOps/Ops.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/CMakeLists.txt
mlir/test/IR/parser.mlir
mlir/test/lib/TestDialect/TestDialect.cpp
mlir/test/lib/TestDialect/TestOps.td