Skip to content

Commit

Permalink
[FIRRTL] Make PathInfoTable a struct in LowerClasses, NFC.
Browse files Browse the repository at this point in the history
To handle more complex situations, we will soon need to track some
more information related to paths. This carves out PathInfoTable as a
struct so we can add more fields for use in the same places as the
existing map.
  • Loading branch information
mikeurbach committed Mar 13, 2024
1 parent 52f4828 commit e438ac0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ struct PathInfo {
};

/// Maps a FIRRTL path id to the lowered PathInfo.
using PathInfoTable = DenseMap<DistinctAttr, PathInfo>;
struct PathInfoTable {
// The table mapping DistinctAttrs to PathInfo structs.
DenseMap<DistinctAttr, PathInfo> table;
};

/// The suffix to append to lowered module names.
static constexpr StringRef kClassNameSuffix = "_Class";
Expand Down Expand Up @@ -216,7 +219,7 @@ LogicalResult LowerClassesPass::processPaths(
}
}

auto [it, inserted] = pathInfoTable.try_emplace(id);
auto [it, inserted] = pathInfoTable.table.try_emplace(id);
auto &pathInfo = it->second;
if (!inserted) {
auto diag =
Expand Down Expand Up @@ -1036,7 +1039,7 @@ struct PathOpConversion : public OpConversionPattern<firrtl::PathOp> {
ConversionPatternRewriter &rewriter) const override {
auto *context = op->getContext();
auto pathType = om::PathType::get(context);
auto pathInfo = pathInfoTable.lookup(op.getTarget());
auto pathInfo = pathInfoTable.table.lookup(op.getTarget());

// The 0'th argument is the base path.
auto basePath = op->getBlock()->getArgument(0);
Expand Down

0 comments on commit e438ac0

Please sign in to comment.