[FIRRTL][LOA][NFCI] Use FieldRefCache. (#6215)

This commit is contained in:
Will Dietz 2023-09-28 08:40:49 -05:00 committed by GitHub
parent 0f37de27f2
commit 58a8b18ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/FIRRTLVisitors.h"
#include "circt/Dialect/FIRRTL/FieldRefCache.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
@ -212,6 +213,10 @@ private:
/// List of operations to erase at the end.
SmallVector<Operation *> opsToErase;
/// FieldRef cache. Be careful to only use this for operations
/// in the original IR / not mutated.
FieldRefCache refs;
/// Whether IR was changed.
bool changesMade = false;
};
@ -375,6 +380,8 @@ LogicalResult Visitor::visit(FModuleLike mod) {
mod.erasePorts(portsToErase);
recordChanges(portsToErase.any());
LLVM_DEBUG(refs.printStats(llvm::dbgs()));
return success();
}
@ -409,7 +416,7 @@ LogicalResult Visitor::visitExpr(OpenSubfieldOp op) {
// Chase this to its original root.
// If the FieldRef for this selection has a new home,
// RAUW to that value and this op is dead.
auto resultRef = getFieldRefFromValue(op.getResult());
auto resultRef = refs.getFieldRefFromValue(op.getResult());
auto nonHWForResult = nonHWValues.find(resultRef);
if (nonHWForResult != nonHWValues.end()) {
// If has nonHW portion, RAUW to it.
@ -456,7 +463,7 @@ LogicalResult Visitor::visitExpr(OpenSubindexOp op) {
// Chase this to its original root.
// If the FieldRef for this selection has a new home,
// RAUW to that value and this op is dead.
auto resultRef = getFieldRefFromValue(op.getResult());
auto resultRef = refs.getFieldRefFromValue(op.getResult());
auto nonHWForResult = nonHWValues.find(resultRef);
if (nonHWForResult != nonHWValues.end()) {
// If has nonHW portion, RAUW to it.