[MLIR] Migrate PatternLoggingListener to the standard LDBG output (#150686)

This commit is contained in:
Mehdi Amini 2025-07-25 21:51:07 +02:00 committed by GitHub
parent fd65b2097b
commit 2f8c926d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,50 +1,48 @@
#include "mlir/IR/PatternMatch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#define DEBUG_TYPE "pattern-logging-listener"
#define DBGS() (llvm::dbgs() << "[" << DEBUG_TYPE << "] ")
#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
using namespace mlir;
void RewriterBase::PatternLoggingListener::notifyOperationInserted(
Operation *op, InsertPoint previous) {
LDBG(patternName << " | notifyOperationInserted"
<< " | " << op->getName());
LDBG() << patternName << " | notifyOperationInserted"
<< " | " << op->getName();
ForwardingListener::notifyOperationInserted(op, previous);
}
void RewriterBase::PatternLoggingListener::notifyOperationModified(
Operation *op) {
LDBG(patternName << " | notifyOperationModified"
<< " | " << op->getName());
LDBG() << patternName << " | notifyOperationModified"
<< " | " << op->getName();
ForwardingListener::notifyOperationModified(op);
}
void RewriterBase::PatternLoggingListener::notifyOperationReplaced(
Operation *op, Operation *newOp) {
LDBG(patternName << " | notifyOperationReplaced (with op)"
<< " | " << op->getName() << " | " << newOp->getName());
LDBG() << patternName << " | notifyOperationReplaced (with op)"
<< " | " << op->getName() << " | " << newOp->getName();
ForwardingListener::notifyOperationReplaced(op, newOp);
}
void RewriterBase::PatternLoggingListener::notifyOperationReplaced(
Operation *op, ValueRange replacement) {
LDBG(patternName << " | notifyOperationReplaced (with values)"
<< " | " << op->getName());
LDBG() << patternName << " | notifyOperationReplaced (with values)"
<< " | " << op->getName();
ForwardingListener::notifyOperationReplaced(op, replacement);
}
void RewriterBase::PatternLoggingListener::notifyOperationErased(
Operation *op) {
LDBG(patternName << " | notifyOperationErased"
<< " | " << op->getName());
LDBG() << patternName << " | notifyOperationErased"
<< " | " << op->getName();
ForwardingListener::notifyOperationErased(op);
}
void RewriterBase::PatternLoggingListener::notifyPatternBegin(
const Pattern &pattern, Operation *op) {
LDBG(patternName << " | notifyPatternBegin"
<< " | " << op->getName());
LDBG() << patternName << " | notifyPatternBegin"
<< " | " << op->getName();
ForwardingListener::notifyPatternBegin(pattern, op);
}