Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LowerClasses] Ensure classes are instantiated by an object. #7072

Merged
merged 3 commits into from
May 23, 2024

Conversation

prithayan
Copy link
Contributor

LowerClass creates an object for a corresponding instance only if the instantiated module has property ports.
But a class can be created for a corresponding module based on other conditions like, if the module is public, or instantiates other classes.
This results in un-instantiated classes that donot correspond to the module hierarchy.
This change ensures that if a class is created for a module, the object is also created from the corresponding instance.
Thus the module hierarchy is also preserved in the om IR.
Downstream tools parsing the IR can assume a single top level class which is required for object model evaluation.

Copy link
Contributor

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

This makes sense to me.

lib/Dialect/FIRRTL/Transforms/LowerClasses.cpp Outdated Show resolved Hide resolved
Comment on lines +894 to +888
bool needsClone = false;
if (auto instance = dyn_cast<InstanceOp>(op))
needsClone = shouldCreateClass(instance.getReferencedModuleNameAttr());
Copy link
Member

Choose a reason for hiding this comment

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

I think you can lookup FModuleLike through InstanceGraph and probably we don't have to change the type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can avoid avoid an unnecessary instance graph lookup, as the module op is not required here. Querying just using the name seems better here.

@prithayan prithayan marked this pull request as ready for review May 22, 2024 22:08
Copy link
Contributor

@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

I think this is good to go.

@prithayan prithayan merged commit cdc6232 into main May 23, 2024
4 checks passed
@prithayan prithayan deleted the dev/pbarua/lower-classes branch May 23, 2024 16:58
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.

3 participants