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 list concatenation parser support. #7512

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

mikeurbach
Copy link
Contributor

This parses list_concat(exp+) into the ListConcatOp. The type of the list is inferred during parsing, and all expressions must be the same. It is a parser error to not concatenate at least one list.

This parses `list_concat(exp+)` into the ListConcatOp. The type of the
list is inferred during parsing, and all expressions must be the
same. It is a parser error to not concatenate at least one list.
return failure();

if (operands.empty())
return emitError(loc, "need at least one List to concatenate");
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 is legal syntactically according to the spec, but for this specific operation, the IR requires at least one operand. It makes the parser simpler to implement by requiring at least one operand and inferring the type from the types of the operands, but if it would be preferable to not require this during parsing (and instead let the op's verifier enforce it), I can change that.

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

LGTM!

Should list_concat support inserting AnyRef casts like done for propassign and List constructor?

I think disallowing it for now is fine, just checking since thought of it.

@mikeurbach
Copy link
Contributor Author

Thanks for the review. Good question about inserting casts... I thought about that, and I can't think of a reason we'd want that today. The automatic casts during list create ops might still make sense in some cases, but really I think we should move away from that. By the time we have list concat ops, we should already be dealing with lists of the same types (and if they're lists of AnyRefs, the casts would be inserted if necessary when the lists were created). I can't think of a use case for concatenating lists of different object types and wanting that to automatically insert the necessary casts to lists of AnyRef type; the frontend should really just handle this.

@mikeurbach mikeurbach merged commit 23371f8 into main Aug 12, 2024
4 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/firrtl-list-concat-parser branch August 12, 2024 18:08
@dtzSiFive
Copy link
Contributor

Thanks for the review. Good question about inserting casts... I thought about that, and I can't think of a reason we'd want that today.

Great! That sounds solid to me (and ty for explanation not quoted above for brevity)!

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