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

[FIRRTL] Add containTypeAlias to type storage and define getAnonymousType #5493

Merged
merged 2 commits into from
Jul 2, 2023

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jun 27, 2023

This adds anonymousType to type storages and define getAnonymousType to provide a convenient way to get structural information. Also add containsTypeAlias to recursive type prop.

@uenoku uenoku force-pushed the dev/uenoku/get-anonymous-type branch from 87598b5 to 448adb0 Compare June 27, 2023 16:07
@uenoku uenoku changed the title [FIRRTL] Add anonymousType to type storage and define getAnonymousType [FIRRTL] Add containTypeAlias to type storage and define getAnonymousType Jun 28, 2023
@uenoku uenoku requested a review from prithayan June 28, 2023 17:45
This adds `anonymousType` to type storages and define `getAnonymousType`.
Also add `containsTypeAlias` to recurisve type prop.
@uenoku uenoku force-pushed the dev/uenoku/get-anonymous-type branch from 448adb0 to e67a8b7 Compare June 29, 2023 00:32
Copy link
Contributor

@prithayan prithayan 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 one change required, other minor comments.

return impl->anonymousType;

// If this type is already anonymous, use it and remember for next time.
if (!impl->props.containsTypeAlias) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it makes a difference, but this could be the first check and just return *this without setting the anonymousType, maybe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that makes sense and I agree. I implemented in a consistent way to getPassiveType implementation so I'd like to prioritize the consistency here. I think it's better to change the style at the same time. Thank you for the suggestion!

return impl->anonymousType;

// If this type is already anonymous, return it and remember for next time.
if (impl->elementType.getRecursiveTypeProperties().containsTypeAlias)
Copy link
Contributor

Choose a reason for hiding this comment

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

The not is missing on the check ?

Suggested change
if (impl->elementType.getRecursiveTypeProperties().containsTypeAlias)
if (!impl->elementType.getRecursiveTypeProperties().containsTypeAlias)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also same comment, maybe check this and early return, without setting the cached type.

Copy link
Member Author

Choose a reason for hiding this comment

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

The not is missing on the check ?

Totally, great catch. Thanks!

/// Return this type with any type aliases recursively removed from itself.
FIRRTLBaseType FEnumType::getAnonymousType() {
if (!this->containsTypeAlias())
return *this;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems better.

Copy link
Member Author

@uenoku uenoku Jun 30, 2023

Choose a reason for hiding this comment

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

Sorry, I changed to the other implementation for the consistency. Thank you for pointing out!

@uenoku uenoku force-pushed the dev/uenoku/get-anonymous-type branch from c5fb0c5 to ea63f98 Compare June 30, 2023 11:35
@uenoku uenoku merged commit 431d106 into main Jul 2, 2023
@uenoku uenoku deleted the dev/uenoku/get-anonymous-type branch July 11, 2023 12:51
calebmkim pushed a commit to andrewb1999/circt that referenced this pull request Jul 12, 2023
…sType` (llvm#5493)

This adds `anonymousType` to type storages of bundle/vector/enum/alias type and define `getAnonymousType` to FIRTRLBaseType. Also add `containsTypeAlias` to recursive type prop.
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.

2 participants