NFC: Update the Operation 'walk' methods to use llvm::function_ref instead of std::function.

PiperOrigin-RevId: 256099638
This commit is contained in:
River Riddle 2019-07-01 22:35:06 -07:00 committed by jpienaar
parent 479a3e0613
commit 25f29e1b15
9 changed files with 15 additions and 15 deletions

View File

@ -241,10 +241,10 @@ public:
/// Walk the operations in this block in postorder, calling the callback for
/// each operation.
void walk(const std::function<void(Operation *)> &callback);
void walk(llvm::function_ref<void(Operation *)> callback);
/// Specialization of walk to only visit operations of 'OpTy'.
template <typename OpTy> void walk(std::function<void(OpTy)> callback) {
template <typename OpTy> void walk(llvm::function_ref<void(OpTy)> callback) {
walk([&](Operation *opInst) {
if (auto op = dyn_cast<OpTy>(opInst))
callback(op);
@ -254,7 +254,7 @@ public:
/// Walk the operations in the specified [begin, end) range of this block in
/// postorder, calling the callback for each operation.
void walk(Block::iterator begin, Block::iterator end,
const std::function<void(Operation *)> &callback);
llvm::function_ref<void(Operation *)> callback);
//===--------------------------------------------------------------------===//
// Other

View File

@ -161,10 +161,10 @@ public:
/// Walk the operations in the function in postorder, calling the callback for
/// each operation.
void walk(const std::function<void(Operation *)> &callback);
void walk(llvm::function_ref<void(Operation *)> callback);
/// Specialization of walk to only visit operations of 'OpTy'.
template <typename OpTy> void walk(std::function<void(OpTy)> callback) {
template <typename OpTy> void walk(llvm::function_ref<void(OpTy)> callback) {
walk([&](Operation *opInst) {
if (auto op = dyn_cast<OpTy>(opInst))
callback(op);

View File

@ -143,12 +143,12 @@ public:
/// Walk the operation in postorder, calling the callback for each nested
/// operation(including this one).
void walk(const std::function<void(Operation *)> &callback) {
void walk(llvm::function_ref<void(Operation *)> callback) {
state->walk(callback);
}
/// Specialization of walk to only visit operations of 'OpTy'.
template <typename OpTy> void walk(std::function<void(OpTy)> callback) {
template <typename OpTy> void walk(llvm::function_ref<void(OpTy)> callback) {
walk([&](Operation *opInst) {
if (auto op = dyn_cast<OpTy>(opInst))
callback(op);

View File

@ -424,10 +424,10 @@ public:
/// Walk this operation in postorder, calling the callback for each operation
/// including this one.
void walk(const std::function<void(Operation *)> &callback);
void walk(llvm::function_ref<void(Operation *)> callback);
/// Specialization of walk to only visit operations of 'T'.
template <typename T> void walk(std::function<void(T)> callback) {
template <typename T> void walk(llvm::function_ref<void(T)> callback) {
walk([&](Operation *op) {
if (auto derivedOp = dyn_cast<T>(op))
callback(derivedOp);

View File

@ -117,7 +117,7 @@ public:
/// Walk the operations in this block in postorder, calling the callback for
/// each operation.
void walk(const std::function<void(Operation *)> &callback);
void walk(llvm::function_ref<void(Operation *)> callback);
/// Displays the CFG in a window. This is for use from the debugger and
/// depends on Graphviz to generate the graph.

View File

@ -233,14 +233,14 @@ Block *Block::getSinglePredecessor() {
// Operation Walkers
//===----------------------------------------------------------------------===//
void Block::walk(const std::function<void(Operation *)> &callback) {
void Block::walk(llvm::function_ref<void(Operation *)> callback) {
walk(begin(), end(), callback);
}
/// Walk the operations in the specified [begin, end) range of this block,
/// calling the callback for each operation.
void Block::walk(Block::iterator begin, Block::iterator end,
const std::function<void(Operation *)> &callback) {
llvm::function_ref<void(Operation *)> callback) {
for (auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
op.walk(callback);
}

View File

@ -188,7 +188,7 @@ void Function::addEntryBlock() {
entry->addArguments(impl->type.getInputs());
}
void Function::walk(const std::function<void(Operation *)> &callback) {
void Function::walk(llvm::function_ref<void(Operation *)> callback) {
getBody().walk(callback);
}

View File

@ -298,7 +298,7 @@ void Operation::replaceUsesOfWith(Value *from, Value *to) {
// Operation Walkers
//===----------------------------------------------------------------------===//
void Operation::walk(const std::function<void(Operation *)> &callback) {
void Operation::walk(llvm::function_ref<void(Operation *)> callback) {
// Visit any internal operations.
for (auto &region : getRegions())
region.walk(callback);

View File

@ -173,7 +173,7 @@ bool Region::isIsolatedFromAbove(llvm::Optional<Location> noteLoc) {
/// Walk the operations in this block in postorder, calling the callback for
/// each operation.
void Region::walk(const std::function<void(Operation *)> &callback) {
void Region::walk(llvm::function_ref<void(Operation *)> callback) {
for (auto &block : *this)
block.walk(callback);
}