mirror of https://github.com/llvm/circt.git
[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:
parent
a1a3b6ca78
commit
79148d8138
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue