Skip to content

Conversation

@djg
Copy link
Contributor

@djg djg commented Nov 4, 2022

4805542

[WGSL] Unify AST node type traits
https://bugs.webkit.org/show_bug.cgi?id=247475
rdar://101943721

Reviewed by Myles C. Maxfield.

Unify WGSL AST node type introspection to use TypeCastTraits, replacing the
".isNodeKind()" call pattern with "is<NodeKind>(...)" to complement
"downcast<NodeKind>(...)".

* Source/WebGPU/WGSL/AST/AST.h:
* Source/WebGPU/WGSL/AST/ASTArrayAccess.h:
* Source/WebGPU/WGSL/AST/ASTAssignmentStatement.h:
* Source/WebGPU/WGSL/AST/ASTAttribute.h:
(WGSL::AST::Attribute::Attribute):
(isType):
(WGSL::AST::Attribute::~Attribute): Deleted.
(WGSL::AST::Attribute::isGroup const): Deleted.
(WGSL::AST::Attribute::isBinding const): Deleted.
(WGSL::AST::Attribute::isStage const): Deleted.
(WGSL::AST::Attribute::isLocation const): Deleted.
(WGSL::AST::Attribute::isBuiltin const): Deleted.
(): Deleted.
* Source/WebGPU/WGSL/AST/ASTBindingAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTCallableExpression.h:
* Source/WebGPU/WGSL/AST/ASTCompoundStatement.h:
* Source/WebGPU/WGSL/AST/ASTDecl.h:
(WGSL::AST::Decl::Decl):
(isType):
(WGSL::AST::Decl::~Decl): Deleted.
(WGSL::AST::Decl::isVariable const): Deleted.
(WGSL::AST::Decl::isStruct const): Deleted.
(WGSL::AST::Decl::isFunction const): Deleted.
* Source/WebGPU/WGSL/AST/ASTExpression.h:
(WGSL::AST::Expression::Expression):
(isTypeOf):
(WGSL::AST::Expression::~Expression): Deleted.
(WGSL::AST::Expression::isBoolLiteral const): Deleted.
(WGSL::AST::Expression::isInt32Literal const): Deleted.
(WGSL::AST::Expression::isUInt32Literal const): Deleted.
(WGSL::AST::Expression::isFloat32Literal const): Deleted.
(WGSL::AST::Expression::isAbstractIntLiteral const): Deleted.
(WGSL::AST::Expression::isAbstractFloatLiteral const): Deleted.
(WGSL::AST::Expression::isIdentifier const): Deleted.
(WGSL::AST::Expression::isArrayAccess const): Deleted.
(WGSL::AST::Expression::isStructureAccess const): Deleted.
(WGSL::AST::Expression::isCallableExpression const): Deleted.
(WGSL::AST::Expression::isUnaryExpression const): Deleted.
* Source/WebGPU/WGSL/AST/ASTFunctionDecl.h:
* Source/WebGPU/WGSL/AST/ASTGlobalDirective.h:
(WGSL::AST::GlobalDirective::GlobalDirective):
* Source/WebGPU/WGSL/AST/ASTGroupAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTIdentifierExpression.h:
* Source/WebGPU/WGSL/AST/ASTLiteralExpressions.h:
* Source/WebGPU/WGSL/AST/ASTLocationAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTNode.h:
(WGSL::AST::Node::Node):
(WGSL::AST::ASTNode::ASTNode): Deleted.
(WGSL::AST::ASTNode::span const): Deleted.
* Source/WebGPU/WGSL/AST/ASTReturnStatement.h:
* Source/WebGPU/WGSL/AST/ASTShaderModule.h:
* Source/WebGPU/WGSL/AST/ASTStageAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTStatement.h:
(WGSL::AST::Statement::Statement):
(isType):
(WGSL::AST::Statement::~Statement): Deleted.
(WGSL::AST::Statement::isCompound const): Deleted.
(WGSL::AST::Statement::isReturn const): Deleted.
(WGSL::AST::Statement::isAssignment const): Deleted.
(WGSL::AST::Statement::isVariable const): Deleted.
* Source/WebGPU/WGSL/AST/ASTStructureAccess.h:
* Source/WebGPU/WGSL/AST/ASTStructureDecl.h:
* Source/WebGPU/WGSL/AST/ASTTypeDecl.h:
(WGSL::AST::TypeDecl::TypeDecl):
(isType):
(WGSL::AST::TypeDecl::~TypeDecl): Deleted.
(WGSL::AST::TypeDecl::isArray const): Deleted.
(WGSL::AST::TypeDecl::isNamed const): Deleted.
(WGSL::AST::TypeDecl::isParameterized const): Deleted.
* Source/WebGPU/WGSL/AST/ASTUnaryExpression.h:
* Source/WebGPU/WGSL/AST/ASTVariableDecl.h:
* Source/WebGPU/WGSL/AST/ASTVariableQualifier.h:
* Source/WebGPU/WGSL/AST/ASTVariableStatement.h:
* Source/WebGPU/WGSL/AST/ASTVisitor.cpp:
(WGSL::AST::Visitor::visit):
* Source/WebGPU/WGSL/Parser.cpp:
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WGSL/ConstLiteralTests.cpp:
(TestWGSLAPI::TEST):
* Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp:
(checkBuiltin):
(checkIntLiteral):
(checkVecType):
(TestWGSLAPI::TEST):

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

6fbed13

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe
✅ 🛠 ios-sim ✅ 🛠 mac-debug ✅ 🛠 gtk ✅ 🛠 wincairo
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🛠 mac-AS-debug ✅ 🧪 gtk-wk2
✅ 🧪 api-ios ✅ 🧪 api-mac ✅ 🧪 api-gtk
✅ 🛠 tv ✅ 🧪 mac-wk1
✅ 🛠 tv-sim ✅ 🧪 mac-wk2
✅ 🛠 watch ✅ 🧪 mac-AS-debug-wk2
✅ 🛠 🧪 unsafe-merge ✅ 🛠 watch-sim ✅ 🧪 mac-wk2-stress

@djg djg self-assigned this Nov 4, 2022
@djg djg added Other WebGPU For bugs in WebGPU labels Nov 4, 2022
@djg djg requested a review from litherum November 4, 2022 03:18
@djg djg requested a review from grorg November 4, 2022 03:18
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.

Maybe this is a silly question, but should we enable RTTI instead of using all these virtual calls?

@djg
Copy link
Contributor Author

djg commented Nov 4, 2022

Maybe this is a silly question, but should we enable RTTI instead of using all these virtual calls?

I don't know. Is linking code compiled with RTTI against code compiled without RTTI allowed?

The typical reason for not using RTTI is that it's not opt-in on a per-class-hierarchy option, so all classes get RTTI information and that data bloats the executable.

@djg djg added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 7, 2022
https://bugs.webkit.org/show_bug.cgi?id=247475
rdar://101943721

Reviewed by Myles C. Maxfield.

Unify WGSL AST node type introspection to use TypeCastTraits, replacing the
".isNodeKind()" call pattern with "is<NodeKind>(...)" to complement
"downcast<NodeKind>(...)".

* Source/WebGPU/WGSL/AST/AST.h:
* Source/WebGPU/WGSL/AST/ASTArrayAccess.h:
* Source/WebGPU/WGSL/AST/ASTAssignmentStatement.h:
* Source/WebGPU/WGSL/AST/ASTAttribute.h:
(WGSL::AST::Attribute::Attribute):
(isType):
(WGSL::AST::Attribute::~Attribute): Deleted.
(WGSL::AST::Attribute::isGroup const): Deleted.
(WGSL::AST::Attribute::isBinding const): Deleted.
(WGSL::AST::Attribute::isStage const): Deleted.
(WGSL::AST::Attribute::isLocation const): Deleted.
(WGSL::AST::Attribute::isBuiltin const): Deleted.
(): Deleted.
* Source/WebGPU/WGSL/AST/ASTBindingAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTBuiltinAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTCallableExpression.h:
* Source/WebGPU/WGSL/AST/ASTCompoundStatement.h:
* Source/WebGPU/WGSL/AST/ASTDecl.h:
(WGSL::AST::Decl::Decl):
(isType):
(WGSL::AST::Decl::~Decl): Deleted.
(WGSL::AST::Decl::isVariable const): Deleted.
(WGSL::AST::Decl::isStruct const): Deleted.
(WGSL::AST::Decl::isFunction const): Deleted.
* Source/WebGPU/WGSL/AST/ASTExpression.h:
(WGSL::AST::Expression::Expression):
(isTypeOf):
(WGSL::AST::Expression::~Expression): Deleted.
(WGSL::AST::Expression::isBoolLiteral const): Deleted.
(WGSL::AST::Expression::isInt32Literal const): Deleted.
(WGSL::AST::Expression::isUInt32Literal const): Deleted.
(WGSL::AST::Expression::isFloat32Literal const): Deleted.
(WGSL::AST::Expression::isAbstractIntLiteral const): Deleted.
(WGSL::AST::Expression::isAbstractFloatLiteral const): Deleted.
(WGSL::AST::Expression::isIdentifier const): Deleted.
(WGSL::AST::Expression::isArrayAccess const): Deleted.
(WGSL::AST::Expression::isStructureAccess const): Deleted.
(WGSL::AST::Expression::isCallableExpression const): Deleted.
(WGSL::AST::Expression::isUnaryExpression const): Deleted.
* Source/WebGPU/WGSL/AST/ASTFunctionDecl.h:
* Source/WebGPU/WGSL/AST/ASTGlobalDirective.h:
(WGSL::AST::GlobalDirective::GlobalDirective):
* Source/WebGPU/WGSL/AST/ASTGroupAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTIdentifierExpression.h:
* Source/WebGPU/WGSL/AST/ASTLiteralExpressions.h:
* Source/WebGPU/WGSL/AST/ASTLocationAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTNode.h:
(WGSL::AST::Node::Node):
(WGSL::AST::ASTNode::ASTNode): Deleted.
(WGSL::AST::ASTNode::span const): Deleted.
* Source/WebGPU/WGSL/AST/ASTReturnStatement.h:
* Source/WebGPU/WGSL/AST/ASTShaderModule.h:
* Source/WebGPU/WGSL/AST/ASTStageAttribute.h: Copied from Source/WebGPU/WGSL/AST/ASTGlobalDirective.h.
* Source/WebGPU/WGSL/AST/ASTStatement.h:
(WGSL::AST::Statement::Statement):
(isType):
(WGSL::AST::Statement::~Statement): Deleted.
(WGSL::AST::Statement::isCompound const): Deleted.
(WGSL::AST::Statement::isReturn const): Deleted.
(WGSL::AST::Statement::isAssignment const): Deleted.
(WGSL::AST::Statement::isVariable const): Deleted.
* Source/WebGPU/WGSL/AST/ASTStructureAccess.h:
* Source/WebGPU/WGSL/AST/ASTStructureDecl.h:
* Source/WebGPU/WGSL/AST/ASTTypeDecl.h:
(WGSL::AST::TypeDecl::TypeDecl):
(isType):
(WGSL::AST::TypeDecl::~TypeDecl): Deleted.
(WGSL::AST::TypeDecl::isArray const): Deleted.
(WGSL::AST::TypeDecl::isNamed const): Deleted.
(WGSL::AST::TypeDecl::isParameterized const): Deleted.
* Source/WebGPU/WGSL/AST/ASTUnaryExpression.h:
* Source/WebGPU/WGSL/AST/ASTVariableDecl.h:
* Source/WebGPU/WGSL/AST/ASTVariableQualifier.h:
* Source/WebGPU/WGSL/AST/ASTVariableStatement.h:
* Source/WebGPU/WGSL/AST/ASTVisitor.cpp:
(WGSL::AST::Visitor::visit):
* Source/WebGPU/WGSL/Parser.cpp:
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WGSL/ConstLiteralTests.cpp:
(TestWGSLAPI::TEST):
* Tools/TestWebKitAPI/Tests/WGSL/ParserTests.cpp:
(checkBuiltin):
(checkIntLiteral):
(checkVecType):
(TestWGSLAPI::TEST):

Canonical link: https://commits.webkit.org/256381@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the wgsl/ast-unify-node-type-traits branch from 6fbed13 to 4805542 Compare November 7, 2022 00:55
@webkit-commit-queue
Copy link
Collaborator

Committed 256381@main (4805542): https://commits.webkit.org/256381@main

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

@webkit-early-warning-system webkit-early-warning-system merged commit 4805542 into WebKit:main Nov 7, 2022
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 7, 2022
@djg djg deleted the wgsl/ast-unify-node-type-traits branch November 7, 2022 02:21
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

Development

Successfully merging this pull request may close these issues.

4 participants