Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/IR/Visitors.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | for (auto &block : region) { | ||||
walk(&nestedOp, callback, order); | walk(&nestedOp, callback, order); | ||||
} | } | ||||
} | } | ||||
if (order == WalkOrder::PostOrder) | if (order == WalkOrder::PostOrder) | ||||
callback(op); | callback(op); | ||||
} | } | ||||
void detail::walk(Operation *op, StringRef name, | |||||
function_ref<void(Operation *)> callback, WalkOrder order) { | |||||
OperationName opName(name, op->getContext()); | |||||
auto wrapperFn = [&](Operation *op) { | |||||
if (op->getName() == opName) | |||||
callback(op); | |||||
}; | |||||
walk(op, wrapperFn, order); | |||||
} | |||||
/// Walk all of the regions/blocks/operations nested under and including the | /// Walk all of the regions/blocks/operations nested under and including the | ||||
/// given operation. These functions walk operations until an interrupt result | /// given operation. These functions walk operations until an interrupt result | ||||
/// is returned by the callback. Walks on regions, blocks and operations may | /// is returned by the callback. Walks on regions, blocks and operations may | ||||
/// also be skipped if the callback returns a skip result. Regions, blocks and | /// also be skipped if the callback returns a skip result. Regions, blocks and | ||||
/// operations at the same nesting level are visited in lexicographical order. | /// operations at the same nesting level are visited in lexicographical order. | ||||
/// The walk order for enclosing regions, blocks and operations with respect to | /// The walk order for enclosing regions, blocks and operations with respect to | ||||
/// their nested ones is specified by 'order'. A callback on a block or | /// their nested ones is specified by 'order'. A callback on a block or | ||||
/// operation is allowed to erase that block or operation if either: | /// operation is allowed to erase that block or operation if either: | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | for (auto &block : region) { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (order == WalkOrder::PostOrder) | if (order == WalkOrder::PostOrder) | ||||
return callback(op); | return callback(op); | ||||
return WalkResult::advance(); | return WalkResult::advance(); | ||||
} | } | ||||
WalkResult detail::walk(Operation *op, StringRef name, | |||||
function_ref<WalkResult(Operation *)> callback, | |||||
WalkOrder order) { | |||||
OperationName opName(name, op->getContext()); | |||||
auto wrapperFn = [&](Operation *op) -> WalkResult { | |||||
if (op->getName() == opName) | |||||
return callback(op); | |||||
return WalkResult::advance(); | |||||
}; | |||||
return walk(op, function_ref<WalkResult(Operation *)>(wrapperFn), order); | |||||
} |