forked from OSchip/llvm-project
NFC: Update the Operation 'walk' methods to use llvm::function_ref instead of std::function.
PiperOrigin-RevId: 256099638
This commit is contained in:
parent
479a3e0613
commit
25f29e1b15
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ®ion : getRegions())
|
||||
region.walk(callback);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue