replace helper-op cleanup with canonicalization
clean up PIM pattern naming remove unused ValueMap.hpp
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/IR/Value.h"
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
template <typename T>
|
||||
class AutoCleaningValueMap : public mlir::RewriterBase::ForwardingListener {
|
||||
public:
|
||||
llvm::DenseMap<mlir::Value, T> map;
|
||||
|
||||
AutoCleaningValueMap(mlir::OpBuilder::Listener listener)
|
||||
: ForwardingListener(&listener) {}
|
||||
|
||||
void notifyOperationErased(mlir::Operation* op) override {
|
||||
for (mlir::Value result : op->getResults())
|
||||
map.erase(result);
|
||||
}
|
||||
|
||||
void notifyBlockErased(mlir::Block* block) override {
|
||||
for (mlir::BlockArgument arg : block->getArguments())
|
||||
map.erase(arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class NotErasableValueMap : public mlir::RewriterBase::ForwardingListener {
|
||||
public:
|
||||
llvm::DenseMap<mlir::Value, T> map;
|
||||
|
||||
NotErasableValueMap(mlir::OpBuilder::Listener listener)
|
||||
: ForwardingListener(&listener) {}
|
||||
|
||||
void notifyOperationErased(mlir::Operation* op) override {
|
||||
for (mlir::Value result : op->getResults())
|
||||
assert("Value contained in NotErasableValueMap can't be erased" && !map.contains(result));
|
||||
}
|
||||
|
||||
void notifyBlockErased(mlir::Block* block) override {
|
||||
for (mlir::BlockArgument arg : block->getArguments())
|
||||
assert("Value contained in NotErasableValueMap can't be erased" && !map.contains(arg));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user