[MLIR] Remove TableGen redundant calls to native calls when creating new operations...
authorAlexEichenberger <alexeichenberger@gmail.com>
Mon, 22 Jun 2020 15:10:23 +0000 (08:10 -0700)
committerJacques Pienaar <jpienaar@google.com>
Mon, 22 Jun 2020 15:12:04 +0000 (08:12 -0700)
commit01641197ee0bd3895c756c925723c8c8e03bcb09
tree277d74ed6a2ba979072250abccdeb7257758f613
parentf633b07669030ffaf353c7f3d8a7f4383d348e2f
[MLIR] Remove TableGen redundant calls to native calls when creating new operations in DRR TableGen files

Summary:
Currently, the TableGen rewrite generates redundant native calls in MLIR DRR files. This is a problem as some native calls may involve significant computations (e.g. when performing constant propagation where every values in a large tensor is touched).

The pattern was as follow:

```c++
if (native-call(args)) tblgen_attrs.emplace_back(rewriter, attribute, native-call(args))
```

The replacement pattern compute `native-call(args)` once and then use it both in the `if` condition and the `emplace_back` call.

Differential Revision: https://reviews.llvm.org/D82101
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/lib/Dialect/Test/TestPatterns.cpp
mlir/test/mlir-tblgen/pattern.mlir
mlir/tools/mlir-tblgen/RewriterGen.cpp