Skip to content

[IRGen] Add getEnumTag and injectEnumTag builtins #70327

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

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Dec 8, 2023

This adds 2 new builtins, one that calls the getEnumTag vwt function on a generic type and another that injects the given tag into some generic value. These are unsafe operations that assume the value passed in as T is an enum type.

@Azoy
Copy link
Contributor Author

Azoy commented Dec 8, 2023

@swift-ci please test

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

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

lgtm!

@@ -1968,6 +1968,26 @@ static ValueDecl *getPackLength(ASTContext &ctx, Identifier id) {
return builder.build(id);
}

static ValueDecl *getGetEnumTag(ASTContext &ctx, Identifier id) {
BuiltinFunctionBuilder builder(ctx, /* genericParamCount */ 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to use the getBuiltinFunction infrastructure here.

@Azoy
Copy link
Contributor Author

Azoy commented Dec 11, 2023

@swift-ci please test

@Azoy Azoy force-pushed the inject-get-enum-tag-builtins branch from 4f8dc15 to 0ed4a19 Compare December 11, 2023 18:59
@Azoy
Copy link
Contributor Author

Azoy commented Dec 11, 2023

@swift-ci please test

@Azoy
Copy link
Contributor Author

Azoy commented Dec 11, 2023

@swift-ci please test Linux

1 similar comment
@Azoy
Copy link
Contributor Author

Azoy commented Dec 12, 2023

@swift-ci please test Linux

@Azoy Azoy merged commit f365316 into swiftlang:main Dec 13, 2023
@Azoy Azoy deleted the inject-get-enum-tag-builtins branch December 13, 2023 00:07
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