From afaf4da94e7cfded68684c9629146ce05e445217 Mon Sep 17 00:00:00 2001 From: Mike Urbach Date: Sat, 16 Mar 2024 16:57:49 -0700 Subject: [PATCH] [FIRRTL] Handle either kind of path attribute in LowerClasses. 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. --- lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp b/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp index f0e54d3e1e1c..47e11ca2abf3 100644 --- a/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp +++ b/lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp @@ -384,7 +384,11 @@ LogicalResult LowerClassesPass::processPaths( // We will plumb in the basepath from this module. StringAttr altBasePathModule; if (needsAltBasePath) { - altBasePathModule = cast(path.front()).getModule(); + altBasePathModule = + TypeSwitch(path.front()) + .Case([](auto a) { return a.getAttr(); }) + .Case([](auto a) { return a.getModule(); }); + pathInfoTable.addAltBasePathRoot(altBasePathModule); }