[webkit-changes] [WebKit/WebKit] 0eb4e8: [WGSL] Refactor ConstantRewriter

Tadeu Zagallo noreply at github.com
Wed May 31 06:30:00 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0eb4e8349d52a742ea400a944fe328f284cebb9b
      https://github.com/WebKit/WebKit/commit/0eb4e8349d52a742ea400a944fe328f284cebb9b
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-05-31 (Wed, 31 May 2023)

  Changed paths:
    M Source/WebGPU/WGSL/ConstantRewriter.cpp
    M Source/WebGPU/WGSL/ConstantValue.h

  Log Message:
  -----------
  [WGSL] Refactor ConstantRewriter
https://bugs.webkit.org/show_bug.cgi?id=257492
rdar://110008653

Reviewed by Myles C. Maxfield.

The original implementation had a stricter separation between "visiting" and
"evaluating" constants. As I continued to work on the rewriter, that seems like
the wrong approach. Unifying it (similarly to how the type checker works)
simplifies the code and makes it easier to optimize operations on constants
in any context. (e.g. some of the calls to `pow` in the overload.wgsl test were
optimized into the result value)

* Source/WebGPU/WGSL/ConstantRewriter.cpp:
(WGSL::ConstantRewriter::visit):
(WGSL::ConstantRewriter::evaluate):
(WGSL::ConstantRewriter::materialize):
(WGSL::ConstantRewriter::evaluated):
* Source/WebGPU/WGSL/ConstantValue.h:
(WGSL::ConstantArray::ConstantArray):
(WGSL::ConstantVector::ConstantVector):

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




More information about the webkit-changes mailing list