This CL updates the `workgroup_size` attribute to use `expression`
values instead of `primary_expression`.
Bug: tint:1633
Change-Id: I0afbabd8ee61943469f04a55d56f85920563e2da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99960
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
With the old grammar elements removed, rename the new elements and
drop the `maybe_` prefixes.
Bug: tint:1633
Change-Id: Iafe223546f8af1ddd8a4b60572a106160a226b72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99921
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL moves all the grammar rules to use the new
`maybe_expression` rules. All of the old `expression` rules
are removed.
Bug: tint:1633
Change-Id: I29637a4c6fcd200650a2b57011b6539c66be942a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99920
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL removes `VariableBindingPoint`. The `Variable` object has a
`has_binding_point` method added which returns true if there is
_both_ a `Group` and `Binding` attribute. Code has all been updated
to use the `sem::BindingPoint` which is populated during the resolve.
Bug: tint:1633
Change-Id: I79a0da662be61d5fb1c1b61342ab239cc4c66809
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100240
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
STL std::hash<T*> implementations have a tendency of just reinterpreting the
pointer as a size_t. This is fast, but produces a bad hash, as most pointers
tend to be 4 or 16 byte aligned. The lack of entropy in the LSBs causes
clustering of hashmap slots. Use tint::utils::Hasher to get better hashes.
Change-Id: Ife768d573cd1875e746ca9d77a4ac19e43b06aca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99281
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
For fewer heap allocations, faster lookups.
Also use a generational counter to cache `ListTransforms` map lookups between clones. Reduces repeated map lookups in super-hot code.
Change-Id: I34865bb39c756129be845b1eb6255ce436e275f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99280
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Do less work for single-value hashes.
Specialize pointer hashing to improve hash quality.
Change-Id: I2f3839d15754543735728814c7f54a5e7ac81569
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99282
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
`HashCodeOf()` sets two bits in the mask to `1`.
We can check for two bits set, after masking, to quickly eliminate impossible Is() tests.
Change-Id: I8d9c1ece87b714e83bd292d02e02274d42e143ef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92664
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
* Walk the sem type list, instead of all AST nodes to just find the
types.
* Walk the AST global list, instead of all declarations, then filtering
to globals.
* Use the ast::IsHostSharable() helper where possible.
* Only lookup the sem node once instead of twice, per global.
* Use the new utils::Hashmap and utils::Hashset containers instead of
std::unordered_map and std::unordered_set.
Change-Id: Idb47c855ae9dfd27515774a89cedb7ed06e07035
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100140
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
With the updated WGSL grammar the `@align` attribute takes an
expression instead of a value. This CL updates the internal data
structures to store an expression instead of an integer value.
The parser still only parses integers, they're just turned into
`IntLiteralExpressions` at the moment.
Bug: tint:1633
Change-Id: If34901798ed6ceaced354bc06ae9b6df875b700e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99980
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL updates the `type_decl` and `primary_expression` rules
to the new WGSL grammar.
Bug: tint:1633
Change-Id: Ifc457e01f43fe33e083fc8f9e316fdd02bfd87c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99881
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL adds the missing checks and tests for `==` and `!=` into
the `relational_expression.post.unary_expression` grammar elements.
Bug: tint:1633
Change-Id: Ib5fbb42994ea12af133ca531989421fddc2393f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99940
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Currently when peeking, if there is placeholder then anything after
the `peek(0)` will be off by 1 position as the placeholder will
end up included in the index count.
This CL updates the peek routine to correctly skip over any
placeholder element between the current index and the requested
peek token.
Bug: tint:1633
Change-Id: Idd2905cc3b9c0a0dcbbcc94c0f6dd349b569ec3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99900
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL adds a let unittest with a complex constructor. The test
verifies the entire statement is parsed.
Bug: tint:1633
Change-Id: I56bb7c009efb5668aa41c9b7ec80dcde65c4ec40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99863
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
With the upcoming expression changes we need to put parenthesis around
boolean expressions which mix `&&` and `||`.
Bug: tint:1633
Change-Id: I7a304e5a23998d9977630c2d4466312be7ae169e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99862
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL fixes the shift_expression to call the higher level math
expression instead of multiplicative_expression. This allows addition
in shift expressions along with multiplicative expressions.
Bug: tint:1633
Change-Id: I29414bfa540bff612110d5ea16c5c89222a5eb6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99861
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL updates the `expression` grammar element with the WGSL
spec.
Bug: tint:1633
Change-Id: Iad1f16f5d73cf4d9ba53ef638aaad73418712403
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99822
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Previously, we would get a use-after-free if you dropped the instance
before an adapter created from it. This CL fixes up the lifetimes
such that Device refs Adapter refs Instance. Instance uses a
cycle-breaking refcount so that it releases internal refs to its
adapters when the last external ref is dropped.
Bug: none
Change-Id: I5304ec86f425247d4c45ca342fda393cc19689e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99820
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This CL adds the `relational_expression.post.unary_expression` grammar
rule into the WGSL parser. A `shift_expression` helper and a
`relational_expression` helper are also added.
Note, the two helpers have `maybe_` as name prefixes. This will be
dropped when the old parser path is removed which current uses the
other versions of those names.
Bug: tint:1633
Change-Id: I6431edfe8fdb9f5a6eea804a7d6fa9a4982ea04e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99761
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL adds the `shift_expression.post.unary_expression` grammar
rule into the WGSL parser.
Bug: tint:1633
Change-Id: I833ddb05399afe8c792bd0b1abf3eda7f1d114e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99760
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL updates a few parser comments to match spec.
Bug: tint:1633
Change-Id: I8cde5ea9a85f0ca58b914d2741ad131d1fa374c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99700
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Currently triggers a bunch of simultaneous program writers, sharing the
same program.
Bug: tint:1651
Change-Id: I9114a3072fb14182f72d5823fa8120088c2ab167
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99802
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL adds the `element_count_expression` and the requisite math
expression parsing to support along with tests.
Bug: tint:1633
Change-Id: I54ab37339754217f417f69dcd6140adbc14cbf83
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99560
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
crbug.com/tint/1580 has been implemented for some time.
Remove the bodge to handle constant value lets.
Bug: tint:1580
Change-Id: I9a71ed8f91b6c9925fa0557bcb4c95d90461421f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99704
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Expand the Option argument paradigm to:
* Remove the requirement to always pass a 'type' parameter. Type inferencing is the easier, and increasingly common way to declare a variable, so this prevents a whole lot of `nullptr` smell which negatively impacts readability.
* Accept attributes directly as arguments, removing the `utils::Vector{ ... }` smell.
Rename `ProgramBuilder::VarOptionals` to `VarOptions`, and add equivalent `LetOptions`, `ConstOptions` and `OverrideOptions`.
Clean up all the calls to `Var()`, `Let()`, `Const()` and `Override()`:
* Use the `Group()` and `Binding()` helpers where possible
* Removing `nullptr` type arguments
* Replace attribute vectors with the list of attributes.
* Remove already-defaulted `ast::StorageClass::kNone` arguments.
* Remove already-defaulted `ast::Access::kUndefined` arguments.
Finally, remove the `GroupAndBinding()` helper, which only existed because you needed to pass attributes as a vector.
Change-Id: I8890e4eb0ffac9f9df2207b28a6f02a163e34d96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99580
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
These tests used to be flaky, and now fail consistently after jobs
is set to 1 instead of 4. Suppressing so parallelization can be
disabled to make test results more consistent.
Bug: chromium:1353938
Change-Id: Ia99445ddd43d55d7ac3f67dd8e177b0fd34d51f3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99762
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>