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 AnyRef cast operation, and insert during parsing. #6108

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

mikeurbach
Copy link
Contributor

In situations where an object is instantiated and passed to a sink that expects any reference, we need to cast away the object's type to AnyRef type. This adds an operation to accomplish this, and inserts it when necessary in the parser.

In situations where an object is instantiated and passed to a sink
that expects any reference, we need to cast away the object's type to
AnyRef type. This adds an operation to accomplish this, and inserts it
when necessary in the parser.
if (lhsType != rhsType) {
// If the lhs is anyref, and the rhs is a ClassType, insert a cast.
if (isa<AnyRefType>(lhsType) && isa<ClassType>(rhsType))
rhs = builder.create<ObjectAnyRefCastOp>(rhs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is fine to be inserted regardless of IR version, right? Both AnyRefType and ClassType parsers are guarded behind the same 3.2.0 version.

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

It looks good to me!

@mikeurbach mikeurbach merged commit 46d373b into main Sep 13, 2023
5 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/firrtl-any-ref-cast branch September 13, 2023 02:34
@mikeurbach
Copy link
Contributor Author

Thanks for the reviews @uenoku !

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