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] Implement alias-aware type casts #5417

Merged
merged 5 commits into from
Jun 22, 2023
Merged

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jun 16, 2023

This implements type_isa/type_cast/type_dyn_cast/type_dyn_cast_or_null. When a given type is an alias, these casts will visit its inner type recursively. These type casts can be used anywhere and if the requested type is non-base type or FIRRTLBaseType itself, then it will optimized in the compile time.

This commit adds minimal changes BaseTypeAliasType for base type alias.
 Implement storage and methods for FIRRTLBaseType and FieldIDTypeInterface.

This doesn't include recursive property chagnes and
`FIRRTLBaseType::getAnonnymousType` whcih requires more broader changes.
@uenoku uenoku requested a review from prithayan June 16, 2023 16:05
@uenoku uenoku force-pushed the dev/uenoku/implement-type-cast branch 4 times, most recently from f4ff2d0 to 6f9cecd Compare June 20, 2023 15:12
This implements `type_isa/type_cast/type_dyn_cast/type_dyn_cast_or_null`.
When a given type is an alias, these casts will visit its inner type recursively.
These type casts can be used anywhere and if the requested type is
non-base type or FIRRTLBaseType itself, then it will optimized in the
compile time,
@uenoku uenoku force-pushed the dev/uenoku/implement-type-cast branch from 6f9cecd to 9987245 Compare June 20, 2023 15:23
Base automatically changed from dev/uenoku/add-type-alias to main June 21, 2023 15:49
@uenoku uenoku force-pushed the dev/uenoku/implement-type-cast branch from 2037106 to bbb4acd Compare June 22, 2023 12:48
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.

Sorry for the delayed review, unit tests are great.

include/circt/Dialect/FIRRTL/FIRRTLTypes.h Outdated Show resolved Hide resolved
Co-authored-by: Prithayan Barua <prithayan@gmail.com>
@uenoku uenoku merged commit a4aabbc into main Jun 22, 2023
5 checks passed
@uenoku uenoku deleted the dev/uenoku/implement-type-cast branch June 22, 2023 17:29
uenoku added a commit that referenced this pull request Jul 19, 2023
This PR mechanically replaces type casts with `firrtl::type*` casts which strips outer most type aliases. Also replace TypeSwitch with FIRRTLTypeSwitch.

Unlike #5167, this PR just replaces all the casts in FIRRTL dialect with `firrtl::type_*` because it's tedious to think about whether or not `firrtl::type_cast` is necessary. Since type casts introduced by #5417 automatically eliminate unnecessary look up for type aliases at the compile time, there is no runtime regression because of that.
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.

None yet

2 participants