[FIRRTL][Folds] Fix patterns to use rewriter for RAUW (#7049)

Fix FoldUnusedPorts to use rewriter for RAUW.
Fix FoldReadWritePorts to use rewriter for RAUW.

Detected by -DMLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.

cc #7047.

Fix more RAUW's to use rewriter, inspection.
This commit is contained in:
Will Dietz 2024-05-17 14:14:06 -05:00 committed by GitHub
parent a1a3b6ca78
commit 79148d8138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -1933,9 +1933,7 @@ struct NodeBypass : public mlir::RewritePattern {
if (node.getInnerSym() || !AnnotationSet(node).canBeDeleted() ||
node.use_empty() || node.isForceable())
return failure();
rewriter.startOpModification(node);
node.getResult().replaceAllUsesWith(node.getInput());
rewriter.finalizeOpModification(node);
rewriter.replaceAllUsesWith(node.getResult(), node.getInput());
return success();
}
};
@ -2343,7 +2341,7 @@ static void erasePort(PatternRewriter &rewriter, Value port) {
if (!subfield) {
auto ty = port.getType();
auto reg = rewriter.create<RegOp>(port.getLoc(), ty, getClock());
port.replaceAllUsesWith(reg.getResult());
rewriter.replaceAllUsesWith(port, reg.getResult());
return;
}
}
@ -2525,7 +2523,7 @@ struct FoldUnusedPorts : public mlir::RewritePattern {
if (deadPorts[i])
erasePort(rewriter, port);
else
port.replaceAllUsesWith(newOp.getResult(nextPort++));
rewriter.replaceAllUsesWith(port, newOp.getResult(nextPort++));
}
rewriter.eraseOp(op);
@ -2617,7 +2615,7 @@ struct FoldReadWritePorts : public mlir::RewritePattern {
rewriter.replaceOpWithNewOp<WireOp>(wmodeField, wmodeField.getType());
}
} else {
result.replaceAllUsesWith(newResult);
rewriter.replaceAllUsesWith(result, newResult);
}
}
rewriter.eraseOp(op);