[mlir:OpFormatGen] Add Support for `$_ctxt` in the transformer.
authorSean Silva <silvasean@google.com>
Tue, 15 Jun 2021 00:28:01 +0000 (17:28 -0700)
committerSean Silva <silvasean@google.com>
Tue, 15 Jun 2021 01:02:55 +0000 (18:02 -0700)
commit853a614864754cd4b000f03a7ab8fbba103d6177
tree5ed95212b4e2a5b342c05fe9d2a3e7c769b88380
parent312011899ac3c48a77f4c5a069000f8aa93a8873
[mlir:OpFormatGen] Add Support for `$_ctxt` in the transformer.

This is useful for "build tuple" type ops. In my case, in npcomp, I have
an op:

```
// Result type is `!torch.tuple<!torch.tensor, !torch.tensor>`.
torch.prim.TupleConstruct %0, %1 : !torch.tensor, !torch.tensor
```

and the context is required for the `Torch::TupleType::get` call (for
the case of an empty tuple).

The handling of these FmtContext's in the code is pretty ad-hoc -- I didn't
attempt to rationalize it and just made a targeted fix. As someone
unfamiliar with the code I had a hard time seeing how to more broadly fix
the situation.

Differential Revision: https://reviews.llvm.org/D104274
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/op-format.mlir
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpFormatGen.cpp