-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 support for multiplication #9043
[WGSL] Add support for multiplication #9043
Conversation
@@ -31,6 +31,7 @@ namespace WGSL::AST { | |||
|
|||
enum class BinaryOperation : uint8_t { | |||
Add, | |||
Times, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really named Times in the spec? otherwise I'd just use Multiply or smtg similar, though Myles might have a different opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec doesn't name it AFAICT, but since it's the token and not the operation I was between Times
and Asterisk
, but I saw times in other places. I don't have a strong opinion, but it's also used for pointer dereference, so neither Times
nor Multiply
are very accurate π€·ββοΈ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a related note, we could also move to the model that just uses the character as the token "name", that would avoid having to name tokens, which is probably the hardest part of making these patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly here fwiw, just a thought that popped in my head. I'm sure one of you will figure out a good name/solution for this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just realized I also named the operation Times
π€¦ I was thinking this was the token. I'll rename before landing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like the "unify all binary operators into a single class, and give that class a char m_operator;
model. The different binary operators are not structurally different.
2a6b81d
to
4d9f215
Compare
@@ -31,6 +31,7 @@ namespace WGSL::AST { | |||
|
|||
enum class BinaryOperation : uint8_t { | |||
Add, | |||
Times, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like the "unify all binary operators into a single class, and give that class a char m_operator;
model. The different binary operators are not structurally different.
4d9f215
to
879623b
Compare
EWS run on current version of this PR (hash 879623b)
|
https://bugs.webkit.org/show_bug.cgi?id=251088 <rdar://problem/104600637> Reviewed by Myles C. Maxfield and Dean Jackson. As the title says: add parsing and a new BinaryOperation for multiplication. The lexing will have to change as we add support for comments and other operators, but this will do for now and enables testing more complex shaders. * Source/WebGPU/WGSL/AST/ASTBinaryExpression.h: * Source/WebGPU/WGSL/AST/ASTStringDumper.cpp: (WGSL::AST::StringDumper::visit): * Source/WebGPU/WGSL/Lexer.cpp: (WGSL::Lexer<T>::lex): * Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp: (WGSL::Metal::FunctionDefinitionWriter::visit): * Source/WebGPU/WGSL/Parser.cpp: (WGSL::Parser<Lexer>::parseMultiplicativeExpression): * Source/WebGPU/WGSL/Token.cpp: (WGSL::toString): * Source/WebGPU/WGSL/Token.h: Canonical link: https://commits.webkit.org/259347@main
879623b
to
f10f7a6
Compare
Committed 259347@main (f10f7a6): https://commits.webkit.org/259347@main Reviewed commits have been landed. Closing PR #9043 and removing active labels. |
f10f7a6
879623b
π π§ͺ winπ§ͺ ios-wk2π§ͺ gtk-wk2π§ͺ api-gtkπ π§ͺ jscπ π§ͺ jsc-arm64π§ͺ jsc-mips-tests