Add support for early exit walk methods.
authorRiver Riddle <riverriddle@google.com>
Fri, 30 Aug 2019 19:47:24 +0000 (12:47 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Fri, 30 Aug 2019 19:47:53 +0000 (12:47 -0700)
commit037742cdf2b9794941958a985e8a0d2023aaa70d
tree105ffd387ea19e6c2d6226de2e07ba018423289f
parent4f6c29223ee5395dd955cefafce6f03ed99170e0
Add support for early exit walk methods.

This is done by providing a walk callback that returns a WalkResult. This result is either `advance` or `interrupt`. `advance` means that the walk should continue, whereas `interrupt` signals that the walk should stop immediately. An example is shown below:

auto result = op->walk([](Operation *op) {
  if (some_invariant)
    return WalkResult::interrupt();
  return WalkResult::advance();
});

if (result.wasInterrupted())
  ...;

PiperOrigin-RevId: 266436700
mlir/include/mlir/IR/Block.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/Operation.h
mlir/include/mlir/IR/Region.h
mlir/include/mlir/IR/Visitors.h
mlir/lib/Analysis/Utils.cpp
mlir/lib/IR/Visitors.cpp
mlir/lib/Transforms/Utils/LoopFusionUtils.cpp