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] Relax ODS defined FIRRTL base subtypes to allow type aliases #5652

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jul 21, 2023

This PR introduces BaseTypeAliasOr helper struct to create a type which accepts both type aliases and a specified type.
Unfortunately this PR makes it hard to use TypedValue<Foo> which is returned by standard ODS generated getters since now the type will become TypedValue<BaseTypeAliasOr<Foo>>.

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.

Looks good to me, mostly mechanical, but this is a major change.
Maybe converting one major .fir lit test to type alias, should be good for this PR. The alias would be dropped at LowerToHW though, until the other PR is merged.

@@ -1042,7 +1042,7 @@ void Emitter::emitExpression(SpecialConstantOp op) {

// NOLINTNEXTLINE(misc-no-recursion)
void Emitter::emitExpression(SubfieldOp op) {
auto type = op.getInput().getType();
BundleType type = op.getInput().getType();
Copy link
Contributor

Choose a reason for hiding this comment

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

The implicit casts are helpful !!

lib/Dialect/FIRRTL/Transforms/InferWidths.cpp Outdated Show resolved Hide resolved
@uenoku uenoku force-pushed the dev/uenoku/type-ods-alias branch 3 times, most recently from f445876 to ff4c119 Compare August 3, 2023 13:48
@@ -46,17 +46,19 @@ circuit test_mod : %[[{"class": "circt.testNT", "data": "a"}]]

; VERILOG-IR: sv.verbatim{{.*}}Standard header to adapt well known macros to our needs
; VERILOG-IR: sv.macro.def @INIT_RANDOM_PROLOG_
type V3 = UInt<1>[3]
type V2 = UInt<1>[2]

module test_mod :
input clock : Clock
input a: UInt<1>
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems type alias for integers is not well supported in HW/Comb. There are still a lot of places where normal llvm casts are used. So i added type alias only for vectors.

@uenoku uenoku changed the title [FIRRTL] Relax ODS defined FIRRTL base types to allow type aliases [FIRRTL] Relax ODS defined FIRRTL base subtypes to allow type aliases Aug 4, 2023
@uenoku uenoku merged commit 6a7b632 into main Aug 4, 2023
5 checks passed
@uenoku uenoku deleted the dev/uenoku/type-ods-alias branch August 4, 2023 10:56
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