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

[WGSL] Add typing for field access expressions #9743

Conversation

tadeuzagallo
Copy link
Member

@tadeuzagallo tadeuzagallo commented Feb 7, 2023

7b9d9eb

[WGSL] Add typing for field access expressions
https://bugs.webkit.org/show_bug.cgi?id=251842
rdar://105120646

Reviewed by Myles C. Maxfield.

Now that we can infer struct types, add support for access struct members. Support
for accessing vector members will follow in a separate patch.

* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::check):
(WGSL::TypeChecker::visitStructMembers):
(WGSL::TypeChecker::visit):
(WGSL::TypeChecker::inferred):

Canonical link: https://commits.webkit.org/260196@main

977726b

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@tadeuzagallo tadeuzagallo self-assigned this Feb 7, 2023
@tadeuzagallo tadeuzagallo added the WebGPU For bugs in WebGPU label Feb 7, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 7, 2023
Copy link
Contributor

@litherum litherum left a comment

Choose a reason for hiding this comment

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

Right, super straightforward.

Comment on lines 231 to 232
if (std::holds_alternative<Struct>(*baseType)) {
auto& structType = std::get<Struct>(*baseType);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This feels like the pattern in WGSL::AST that is written:

    if (is<Struct>(*baseType)) {
        auto& structType = downcast<Struct>(*baseType);

I would like to err on the side of consistency in the compiler. (Also, after looking at built times with -ftime-trace, I hate how slow std::variants are to compile)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I can refactor to match that in a separate commit. (Just because it's already used in several other places in the type checker)

@tadeuzagallo tadeuzagallo force-pushed the eng/WGSL-Add-typing-for-field-access-expressions branch from 1d2abec to 977726b Compare February 13, 2023 10:51
@tadeuzagallo tadeuzagallo added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Feb 13, 2023
https://bugs.webkit.org/show_bug.cgi?id=251842
rdar://105120646

Reviewed by Myles C. Maxfield.

Now that we can infer struct types, add support for access struct members. Support
for accessing vector members will follow in a separate patch.

* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::check):
(WGSL::TypeChecker::visitStructMembers):
(WGSL::TypeChecker::visit):
(WGSL::TypeChecker::inferred):

Canonical link: https://commits.webkit.org/260196@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WGSL-Add-typing-for-field-access-expressions branch from 977726b to 7b9d9eb Compare February 13, 2023 13:32
@webkit-commit-queue
Copy link
Collaborator

Committed 260196@main (7b9d9eb): https://commits.webkit.org/260196@main

Reviewed commits have been landed. Closing PR #9743 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 13, 2023
@webkit-commit-queue webkit-commit-queue merged commit 7b9d9eb into WebKit:main Feb 13, 2023
webkit-early-warning-system pushed a commit to tadeuzagallo/WebKit that referenced this pull request Feb 13, 2023
https://bugs.webkit.org/show_bug.cgi?id=251843
<rdar://problem/105121069>

Reviewed by Myles C. Maxfield.

Continuing from WebKit#9743, expand the typing for field access expressions to also
work with vectors.

* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visit):
(WGSL::TypeChecker::vectorFieldAccess):

Canonical link: https://commits.webkit.org/260200@main
@tadeuzagallo tadeuzagallo deleted the eng/WGSL-Add-typing-for-field-access-expressions branch May 17, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebGPU For bugs in WebGPU
Projects
None yet
6 participants