Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mikeurbach
Copy link
Contributor

We stated in a comment that we copy the leading part of the hierarchical path from the owning module to the start of the annotation's NLA. But we never actually did that, so this adds (back) that logic.

Fixes #7125.

This turns the multiple-instantiation error into a warning in
ResolvePaths and LowerClasses. In real designs coming from Chisel
today, we are not yet able to enforce single instantiation. This was
never a requirement of the original way that we handled hierarchical
paths in EmitOMIR, so this removes the requirement for now. Adding it
back is tracked in #7128.

With this change, the ResolvePaths logic was simplified to stop trying
to disambiguate paths in some cases, and instead allow the annotations
to simply convey the user's requested local or hierarchical path. In
LowerClasses, if there are multiple instances, this means we have
ambiguity. In practice, this logic will produce the same outputs as
EmitOMIR, once we fix #7125.
@mikeurbach
Copy link
Contributor Author

This is orthogonal to, but stacked on #7129.

InstanceRecord *inst = *node->usesBegin();
path.push_back(
OpAnnoTarget(inst->getInstance<InstanceOp>())
.getNLAReference(namespaces[inst->getParent()->getModule()]));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the inner symbol namespace here from the current instances parent, so we can't use moduleNamespace, since that's not the right namespace. This is why I added the full inner symbol namespace collection as an instance variable. I think this should be safe, but wanted to call it out.

// Copy the leading part of the hierarchical path from the owning module
// to the start of the annotation's NLA.
InstanceGraphNode *node = instanceGraph.lookup(moduleName);
while (true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this patch, I have just added a fresh instance graph walk up for each hierpath op. We could coordinate this with the walk in getOrComputeAltBasePath, but then we'd need to update the state to cache the array of paths as well. In large designs, I didn't observe any noticeable performance regression from this.

We stated in a comment that we copy the leading part of the
hierarchical path from the owning module to the start of the
annotation's NLA. But we never actually did that, so this adds (back)
that logic.

Fixes #7125.
@mikeurbach mikeurbach force-pushed the mikeurbach/lower-classes-path-middle branch from 7c1b550 to 16f1d93 Compare June 4, 2024 21:23
Base automatically changed from mikeurbach/path-check-simplification to main June 4, 2024 23:59
@mikeurbach mikeurbach merged commit d00a1d2 into main Jun 5, 2024
@mikeurbach mikeurbach deleted the mikeurbach/lower-classes-path-middle branch June 5, 2024 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIRRTL] LowerClasses doesn't actually copy the leading part of the path from the owning module to the start of the NLA

1 participant