-
Notifications
You must be signed in to change notification settings - Fork 298
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
Conversation
87598b5
to
448adb0
Compare
getAnonymousType
getAnonymousType
This adds `anonymousType` to type storages and define `getAnonymousType`. Also add `containsTypeAlias` to recurisve type prop.
448adb0
to
e67a8b7
Compare
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
lib/Dialect/FIRRTL/FIRRTLTypes.cpp
Outdated
return impl->anonymousType; | ||
|
||
// If this type is already anonymous, return it and remember for next time. | ||
if (impl->elementType.getRecursiveTypeProperties().containsTypeAlias) |
There was a problem hiding this comment.
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 ?
if (impl->elementType.getRecursiveTypeProperties().containsTypeAlias) | |
if (!impl->elementType.getRecursiveTypeProperties().containsTypeAlias) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
lib/Dialect/FIRRTL/FIRRTLTypes.cpp
Outdated
/// Return this type with any type aliases recursively removed from itself. | ||
FIRRTLBaseType FEnumType::getAnonymousType() { | ||
if (!this->containsTypeAlias()) | ||
return *this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems better.
There was a problem hiding this comment.
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!
c5fb0c5
to
ea63f98
Compare
…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.
This adds
anonymousType
to type storages and definegetAnonymousType
to provide a convenient way to get structural information. Also addcontainsTypeAlias
to recursive type prop.