Skip to content

Commit bed6836

Browse files
authored
[FIRRTL] Ensure LowerClasses respects alt base path for local paths. (#7690)
We recently started supporting local-only paths in LowerClasses, but this logic erroneously disabled the alternative base path feature for paths whose targets were relocated outside the owning module. In the case that we need an alternative base path for a local target, convert it to a non-local target, so the alternative base path can be correctly prefixed.
1 parent 5f62873 commit bed6836

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,10 @@ PathTracker::processPathTrackers(const AnnoTarget &target) {
657657
// to the start of the annotation's NLA.
658658
InstanceGraphNode *node = instanceGraph.lookup(moduleName);
659659
while (true) {
660-
// If it's not a non-local target, we don't have to append anything.
661-
if (!hierPathOp)
660+
// If it's not a non-local target, we don't have to append anything,
661+
// unless it needs an alternative base path, in which case we do need to
662+
// make a hierarchical path.
663+
if (!hierPathOp && !needsAltBasePath.value())
662664
break;
663665

664666
// If we get to the owning module or the top, we're done.

test/Dialect/FIRRTL/lower-classes.mlir

+6-1
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,20 @@ firrtl.circuit "IntegerArithmetic" {
391391

392392
// CHECK-LABEL: firrtl.circuit "AltBasePath"
393393
firrtl.circuit "AltBasePath" {
394+
// CHECK: hw.hierpath private [[FOO_NLA:@.+]] [@AltBasePath::[[FOO_SYM:@.+]]]
395+
394396
firrtl.class private @Node(in %path: !firrtl.path) {
395397
}
396398

399+
// CHECK: firrtl.module @AltBasePath
400+
// CHECK: firrtl.instance foo sym [[FOO_SYM]]
401+
397402
// CHECK: om.class @OMIR(%basepath: !om.basepath, %alt_basepath_0: !om.basepath)
398403
firrtl.class private @OMIR() {
399404
%node = firrtl.object @Node(in path: !firrtl.path)
400405
%0 = firrtl.object.subfield %node[path] : !firrtl.class<@Node(in path: !firrtl.path)>
401406

402-
// CHECK: om.path_create member_instance %alt_basepath_0
407+
// CHECK: om.path_create member_instance %alt_basepath_0 [[FOO_NLA]]
403408
%1 = firrtl.path member_reference distinct[0]<>
404409
firrtl.propassign %0, %1 : !firrtl.path
405410
}

0 commit comments

Comments
 (0)