Skip to content

Commit

Permalink
[FIRRTL] Handle either kind of path attribute in LowerClasses.
Browse files Browse the repository at this point in the history
Sometimes the start of a hierarchical path is an InnerRefAttr, and
sometimes the path is just a single FlatSymbolRefAttr. Either way, we
just need the StringAttr refering to the module name. There is a
helper called `root` for this on HierPathOp. But at this point we are
constructing the path to build a HierPathOp, we don't already have
one. So, I've implemented this the same as how `root` is implemented.
  • Loading branch information
mikeurbach committed Mar 16, 2024
1 parent 52a53ca commit afaf4da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ LogicalResult LowerClassesPass::processPaths(
// We will plumb in the basepath from this module.
StringAttr altBasePathModule;
if (needsAltBasePath) {
altBasePathModule = cast<hw::InnerRefAttr>(path.front()).getModule();
altBasePathModule =
TypeSwitch<Attribute, StringAttr>(path.front())
.Case<FlatSymbolRefAttr>([](auto a) { return a.getAttr(); })
.Case<hw::InnerRefAttr>([](auto a) { return a.getModule(); });

pathInfoTable.addAltBasePathRoot(altBasePathModule);
}

Expand Down

0 comments on commit afaf4da

Please sign in to comment.