[all-commits] [llvm/llvm-project] b3ee7f: [mlir][OpDefGen] Add support for generating local ...

River Riddle via All-commits all-commits at lists.llvm.org
Mon Dec 14 14:26:50 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b3ee7f1f312dd41a0ac883d78b71c14d96e78939
      https://github.com/llvm/llvm-project/commit/b3ee7f1f312dd41a0ac883d78b71c14d96e78939
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-12-14 (Mon, 14 Dec 2020)

  Changed paths:
    M mlir/include/mlir/TableGen/Constraint.h
    M mlir/test/mlir-tblgen/predicate.td
    M mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

  Log Message:
  -----------
  [mlir][OpDefGen] Add support for generating local functions for shared utilities

This revision adds a new `StaticVerifierFunctionEmitter` class that emits local static functions in the .cpp file for shared operation verification. This class deduplicates shared operation verification code by emitting static functions alongside the op definitions. These methods are local to the definition file, and are invoked within the operation verify methods. The first bit of shared verification is for the type constraints used when verifying operands and results. An example is shown below:

```
static LogicalResult localVerify(...) {
  ...
}

LogicalResult OpA::verify(...) {
  if (failed(localVerify(...)))
    return failure();
  ...
}

LogicalResult OpB::verify(...) {
  if (failed(localVerify(...)))
    return failure();
  ...
}
```

This allowed for saving >400kb of code size from a downstream TensorFlow project (~15% of MLIR code size).

Differential Revision: https://reviews.llvm.org/D91381




More information about the All-commits mailing list