|
| 1 | +#include "mlir/IR/PatternMatch.h" |
| 2 | +#include "llvm/Support/Debug.h" |
| 3 | + |
| 4 | +#define DEBUG_TYPE "pattern-logging-listener" |
| 5 | +#define DBGS() (llvm::dbgs() << "[" << DEBUG_TYPE << "] ") |
| 6 | +#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n") |
| 7 | + |
| 8 | +using namespace mlir; |
| 9 | + |
| 10 | +void RewriterBase::PatternLoggingListener::notifyOperationInserted( |
| 11 | + Operation *op, InsertPoint previous) { |
| 12 | + LDBG(patternName << " | notifyOperationInserted" |
| 13 | + << " | " << op->getName()); |
| 14 | + ForwardingListener::notifyOperationInserted(op, previous); |
| 15 | +} |
| 16 | + |
| 17 | +void RewriterBase::PatternLoggingListener::notifyOperationModified( |
| 18 | + Operation *op) { |
| 19 | + LDBG(patternName << " | notifyOperationModified" |
| 20 | + << " | " << op->getName()); |
| 21 | + ForwardingListener::notifyOperationModified(op); |
| 22 | +} |
| 23 | + |
| 24 | +void RewriterBase::PatternLoggingListener::notifyOperationReplaced( |
| 25 | + Operation *op, Operation *newOp) { |
| 26 | + LDBG(patternName << " | notifyOperationReplaced (with op)" |
| 27 | + << " | " << op->getName() << " | " << newOp->getName()); |
| 28 | + ForwardingListener::notifyOperationReplaced(op, newOp); |
| 29 | +} |
| 30 | + |
| 31 | +void RewriterBase::PatternLoggingListener::notifyOperationReplaced( |
| 32 | + Operation *op, ValueRange replacement) { |
| 33 | + LDBG(patternName << " | notifyOperationReplaced (with values)" |
| 34 | + << " | " << op->getName()); |
| 35 | + ForwardingListener::notifyOperationReplaced(op, replacement); |
| 36 | +} |
| 37 | + |
| 38 | +void RewriterBase::PatternLoggingListener::notifyOperationErased( |
| 39 | + Operation *op) { |
| 40 | + LDBG(patternName << " | notifyOperationErased" |
| 41 | + << " | " << op->getName()); |
| 42 | + ForwardingListener::notifyOperationErased(op); |
| 43 | +} |
| 44 | + |
| 45 | +void RewriterBase::PatternLoggingListener::notifyPatternBegin( |
| 46 | + const Pattern &pattern, Operation *op) { |
| 47 | + LDBG(patternName << " | notifyPatternBegin" |
| 48 | + << " | " << op->getName()); |
| 49 | + ForwardingListener::notifyPatternBegin(pattern, op); |
| 50 | +} |
0 commit comments