This CL adds support for handling uniform data. Currently the uniform is
added to a buffer where the number is the binding value. This will need
to be updated to accept the correct mapping from the embedder.
Bug: tint:8
Change-Id: Icccccbe599a9555defa6136e384745f4093df020
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25104
Reviewed-by: David Neto <dneto@google.com>
Old way:
- struct decorated with BufferBlock
- Uniform storage class
New way
- struct decorated with Block
- StorageBuffer storage class
Also fixes the result type for an access chain.
Bug: tint:99
Change-Id: I2324ba94bb19b369d206313de798bdfec6099fe0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24605
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Emits it as a module-level variable. Deconstruct and throw away
the gl_PerVertex struct.
Not handled: unusual patterns that are technically valid but
which don't occur in practice:
- loading, storing, or producing intermediate values of the whole structure.
- multiple definitions of the per-vertex structure (e.g. if someone had
put both a vertex shader and a tessellation shader in the same
module.)
Bug: tint:3, tint:99
Change-Id: I3ad9ff6ab780a002367f01f385bfa7d6ddba6db9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24880
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL adds a `_stride_` into the array type name to differentiate an
array of 8 elements and a runtime array of stride 8.
Bug: tint:102
Change-Id: Iaf10fe5957acde16a9ccdf2a0fd8a83e47bb57bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24962
Reviewed-by: David Neto <dneto@google.com>
Take the type of a const-definition (or a write to a hoisted variable)
from the generated expression rather than the directly-converted type
from the SPIR-V ID.
This prepares the way for remapping storage buffers from
Uniform/BufferBlock to StorageBuffer/Block representation.
Bug: tint:99
Change-Id: I6104d8ad96312053562468a3cdb247932c1cb6cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24604
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Use the fact that in WGSL the scope corresponding to the loop construct
encloses the scope for its associated continue construct.
In our construct data structure, the two are adjacent but not
overlapping.
This improvement means that when a definition is in a loop construct,
but used only in the loop or associated continue construct, then no
hoisting is required.
Bug: tint:3
Change-Id: I8d33b8f76303ab2868306847e846b4c26899e746
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24420
Reviewed-by: dan sinclair <dsinclair@google.com>
When we hoist a variable out of a continue construct, put it
in associated loop construct, if it exists. This reduces its
lifetime in WGSL, and easier to understand as a code reader.
Change-Id: I8f0cc37640bfe67874cbc27b55029e79e9a8992c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24321
Reviewed-by: dan sinclair <dsinclair@google.com>
The special case is not "single-block-loop" but rather the
case where a continue target is also its own loop header.
This can occur for single-block loops and multi-block loops.
Bug: tint:3
Change-Id: I4af1410793caf8b26a1f781e221fc0b395f07aa3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24320
Reviewed-by: dan sinclair <dsinclair@google.com>
For each OpPhi, make a variable to carry values from predecessor blocks
to the OpPhi. Declare the variable at the smallest scope enclosing all
the predecessor blocks (where we write to it), and the OpPhi (where we
read from it).
Bug: tint:3
Change-Id: I7898b4b903d9ee1a25a7466e3c5aaf6840550e2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24181
Reviewed-by: dan sinclair <dsinclair@google.com>
Compensate for the fact that dominance does not correspond
exactly to scoping. A definition can dominate a use, but when mapped
in a naive way to constant definitiion and its use, the definition
name goes out of scope by the time you reach the use.
This is correct for storable types.
Bug: tint:3
Change-Id: I03e6c5ba68393151485ed4cdbe6b2b3d7773d1ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24141
Reviewed-by: dan sinclair <dsinclair@google.com>
Avoid sinking expensive operations into control flow such as loops.
The heuristic way to achieve that is to avoid moving combinatorial
values across *any* structured construct boundaries.
Bug: tint:3
Change-Id: I91502b01166a0db64c0e652331591850df75f9d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24140
Reviewed-by: dan sinclair <dsinclair@google.com>
The process of passing the module through this reader, the WGSL semantics,
and the SPIR-V writer will sanitize the module such that the end result
should satisfy SPV_ENV_WEBGPU_0 requirements.
Being more forgiving about the input SPIR-V will be a quality-of-life
improvement.
Bug: tint:3
Change-Id: Ib54cbf729b9e078d797a1ef31422bad497daa5a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23942
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
This CL adds the basis of the Metal Shading Language backend.
Bug: tint:8
Change-Id: I85976250eb41ac12203a5db116444e993c3d09d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23700
Reviewed-by: David Neto <dneto@google.com>
Use the shortcut for zero-values: a type constructor without
any parameters. Scalars still use plain literals like false, 1u, 1.0.
Change-Id: Ie436f1af28cbab0b4c87a07b057deb04632eb534
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23680
Reviewed-by: dan sinclair <dsinclair@google.com>
When a type alias is created, map the SPIR-V type ID to the
type alias, not the underlying type. Only unpack the alias as
needed when inspecting the content structure to make values.
Bug: tint:3
Change-Id: I11011ddd190d89c81d3323f684a5e13f17dde09d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23582
Reviewed-by: dan sinclair <dsinclair@google.com>
This Cl updates the system to allow zero initializers. This allows:
```
var a : vec3<f32> = vec3<f32>();
```
Bug: tint:34
Change-Id: I84d6b431914c4ddf112ed375fae028d912f4a080
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23660
Reviewed-by: David Neto <dneto@google.com>
TODOs in the test file are or were in the function_arithmetic_test.cc
Change-Id: I679dbf0019e12e26488ccc310dfb03a535628e0b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23462
Reviewed-by: dan sinclair <dsinclair@google.com>
When parsing the `u` in `1024u` we were not advancing the lexer to the
next token which would give parse errors.
Change-Id: I8473b55992ff01d24f9d961878afa6b54d855e68
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23460
Reviewed-by: David Neto <dneto@google.com>
This CL cleans up various formatting and lint errors.
Change-Id: Ieee14db90e36acc8b469d58abb84fcf3595321bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23224
Reviewed-by: David Neto <dneto@google.com>
Add a guard variable for flow control within that if-selection.
Also, the premerge blocks are always surrounded by an if-selection,
to ensure we cause reconvergence at the end of the original if-selection
construct, just like in the original SPIR-V.
Bug: tint:3
Change-Id: I614c6840e539bf9a338058beb5b6f70484e3320a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23182
Reviewed-by: dan sinclair <dsinclair@google.com>
We've already written those tests.
Bug: tint:3
Change-Id: Ic836be43b5f1220e3563e4d27abd9b5e2ab54460
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23180
Reviewed-by: dan sinclair <dsinclair@google.com>
This supports the extended instructions used by the compute_boids
example.
Bug: tint:3
Change-Id: I364c343217139e489377dd2a9330058114023caa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23126
Reviewed-by: dan sinclair <dsinclair@google.com>
- Avoid redundant switch-break.
WGSL does an implicit break at the end of a switch case, because
it has fallthrough.
TODO: Emit fallthrough
Bug: tint:3
Change-Id: Ida44b13181a01a2c1459c0447dac496ba5b97ffc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22961
Reviewed-by: dan sinclair <dsinclair@google.com>
In BlockInfo, remove the backpointers from true-head, false-head, and
premerge-head to the if-selection header block.
Convert the forward references from if-selection to its internal heads
from pointers to IDs.
Bug: tint:3
Change-Id: Ic931df519795e14374bff4f60ad37a4b32f79c91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23140
Reviewed-by: dan sinclair <dsinclair@google.com>
Produce less noise in ASTs for a common case.
Also test that an empty continuing construct doesn't show up in the
AST. That's currently handled by the AST code. We want to keep this
behaviour even if the AST implementation changes. Right now
code change is needed when emitting the start of a continuing
construct.
Bug: tint:3
Change-Id: I96a12087e305c64647561f65d87acda907ae9c42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22844
Reviewed-by: dan sinclair <dsinclair@google.com>
This emits the equivalent of break-if, break-unless, continue-if,
continue-unless. But we do it via a regular if-then-else.
Adds a test matrix.
Adds all required tests except for those needing OpSwitch.
Bug: tint:3
Change-Id: I960a40aa00f95f394a92a099c8b12104010ad49f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22603
Reviewed-by: dan sinclair <dsinclair@google.com>
This is a bit pathological.
Bug: tint:3
Change-Id: I448796c712049f88cef9a592c218d94a0daddb75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22760
Reviewed-by: dan sinclair <dsinclair@google.com>
Prefix should match a method name on FunctionEmitter
Bug: tint:3
Change-Id: I0af9fb33210d09a59e5cacdade986668fe685682
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22681
Reviewed-by: dan sinclair <dsinclair@google.com>
A merge block must be dominated by its own header.
This CL checks the cases where that fails because the
merge block is also the:
- the default or case header for a switch (a different header)
- the true-head, false-head, or premerge-head for an if-selection
with a different header
Bug: tint:3
Change-Id: I6dd1fae162e9d33bd9a0b43d3ca9558cebed058b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22680
Reviewed-by: dan sinclair <dsinclair@google.com>
This is a bit pathological.
Bug: tint:3
Change-Id: I820d7d1bfd298a22be6c6014e7d4d00f1097759e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22740
Reviewed-by: dan sinclair <dsinclair@google.com>
This fixes the pathological cases nobody wants, and arguably
should be added to the SPIR-V spec.
If we really really want to support these cases, we can revisit.
Bug: tint:3
Change-Id: I0a75490d451676caa0933e3761098ba1fe3f8b60
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22664
Reviewed-by: dan sinclair <dsinclair@google.com>
This is the case where a block can't be a "continue block"
for more than one header. It can only be a continue block for
the innermost loop it's inside of.
Bug: tint:3
Change-Id: Ic19ca544ab8a30cb1ff16d2c828abb260facba90
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22601
Reviewed-by: dan sinclair <dsinclair@google.com>
In this example, a branch escapes an if-selection.
This is caught by ClassifyCFGEdges
Bug: tint:3
Change-Id: I5586e8bb5f9de0cdf57ad46708fcee12cd31f6aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22600
Reviewed-by: dan sinclair <dsinclair@google.com>
The `>>>` symbol was folded into the `>>` symbol in WGSL. This CL
removes `>>>` from Tint.
Change-Id: I9d900de9a6026a8099796b94aad44483f0c6813f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22582
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
The `unless` statement was removed from the WGSL grammar so remove it
from Tint.
Change-Id: I31a185f5c5e3e88b667caea1c9a88aee80c0b810
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22581
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL removes the conditional forms of the break and continue
statements as they are no longer in the WGSL spec.
Change-Id: I46224d6cb5ce706cfc95d35ab0a4eea46abf62a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22580
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This Cl clarifies that IntLiteral is a signed value, which matches with
the usage of UintLiteral.
Change-Id: Ic8f0e2382cb66eb6b09daed096886dcc55e6b0f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22540
Reviewed-by: David Neto <dneto@google.com>
The name conditions isn't quite correct for the case statement. This CL
updates the code to use selectors instead of conditions.
Change-Id: I98b8050b11e2328f97e4443469572ab47d7c1555
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22520
Reviewed-by: David Neto <dneto@google.com>
This is preparation for emitting nested control flow.
Bug: tint:3
Change-Id: I90fc7edba8cb9937f722e6f5e94c7f222d34c403
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21801
Reviewed-by: dan sinclair <dsinclair@google.com>
In this case, a basic block is a continue target
for both an outer loop and is also for itself as a
single-block loop.
Bug: Tint:3
Change-Id: If361004a4b871966674ca972922c45e712ce7c9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22420
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL adds the missing case_selectors option from the grammar updates.
Change-Id: Ia6c110e917dd574711d396fb34ad53a2a67cf1fe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22306
Reviewed-by: David Neto <dneto@google.com>
This CL updates a few names, addeds a return_stmt method and re-orders
some code to closer match the current WGSL specification.
Change-Id: I388be1c22d5d10229fdfcdb2ff929c410f5ae638
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22305
Reviewed-by: David Neto <dneto@google.com>
The intrinsic methods were removed from the WGSL grammar and are treated
as builtin functions. This Cl updates Tint to match.
Bug: tint:41
Change-Id: I3f9ff6c17f1ca57ad159d883fd5a966657caeb4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22301
Reviewed-by: David Neto <dneto@google.com>
This CL removes the builtin_decoration from the parser in favour of
using IDENT tokens for builtins. We still convert to an enum in the
parser and validate the value provided.
Bug: tint:41
Change-Id: If5dc3844e3325c75951e7b320c123cf66cb8e106
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22300
Reviewed-by: David Neto <dneto@google.com>
The NOP command was added for complete SPIR-V bijectivity which is no
longer a goal of WGSL. The NOP command has been removed from the spec,
so remove from Tint.
Change-Id: Ic640d9d3b987a19668dc169ff549444921c5bbb8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22160
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This Cl adds tests for more of the cast code along with adding a few
missing cast cases.
Bug: tint:5
Change-Id: I417d46661bb310f27329f3e2459b76aa61a49d31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22040
Reviewed-by: David Neto <dneto@google.com>
Do so systmatically. Before we had tested some as a side effect
of other objectives.
Fix the error message for when we have a bad exit from a loop construct
that bypasses not only the continue construct but the loop merge block
itself.
Bug: tint:3
Change-Id: Iaf8fc9bcd3162002aa906efa90a244ef5f439911
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21580
Reviewed-by: dan sinclair <dsinclair@google.com>
Remove TOOD about special code for finding badly nested selections.
This is already adequately covered by the dominance-violation checks,
and related tests:
ClassifyCFGEdges_DomViolation_BeforeIfToSelectionInterior
ClassifyCFGEdges_DomViolation_BeforeSwitchToSelectionInterior
ClassifyCFGEdges_DomViolation_BeforeLoopToLoopBodyInterior
ClassifyCFGEdges_DomViolation_BeforeContinueToContinueInterior
ClassifyCFGEdges_DomViolation_AfterContinueToContinueInterior
Bug: tint:3
Change-Id: I8c547474d1422a54078d748b39a7d22a500d5d1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21482
Reviewed-by: dan sinclair <dsinclair@google.com>
ClassifyCFGEdges_Forward_LoopToContinue is already covered via
ClassifyCFGEdges_LoopContinue_LoopBodyToContinue and ...ConditionalFromNestedIf
and other LoopContinue cases
Bug: tint:3
Change-Id: I4a89a82c0c9a08939036a20f13932c18e1f90df6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21560
Reviewed-by: dan sinclair <dsinclair@google.com>
Unordered float compares are not supported directly by WGSL.
Translate them as negated ordered compares.
Bug: tint:3
Change-Id: I4fea7c924054cffc9a39a8be3b3d9f088d302114
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21540
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Finds the "then", the "else", and "premerge" nodes.
The premerge node, if it exists, is the first block where
the normal forward flow of the "then" and "else" clauses
converge, but before the merge block.
Finds error case where there a block has both an if-break
edge and a forward-to-premerge. There is no good way
to model that in a high level language.
Bug: tint:3
Change-Id: I759fc539f3480e38d091041db6a9abd15f3df769
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21240
Reviewed-by: dan sinclair <dsinclair@google.com>
This also refactors break detection.
Bug: tint:3
Change-Id: I3a3e01c8d76d7c6fc2a14b3dbff136acd487e802
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21220
Reviewed-by: dan sinclair <dsinclair@google.com>
The names for brace and bracket got flipped in the spec, update Tint to
match.
Change-Id: Ifbad5f239834b77b9aa27ef21b9d704cab742f4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21260
Reviewed-by: David Neto <dneto@google.com>
Push constants won't be supported by WebGPU. This CL removes them from
Tint.
For the SPIR-V reader case, this means the push constant will cause a
unknown storage class error.
Bug: tint:19
Change-Id: I10b09ce589b6b370fc828af0cd56e6213c5bc694
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21180
Reviewed-by: David Neto <dneto@google.com>
These used to be classified as kToMerge
Bug: tint:3
Change-Id: I63fb286c371582676e5943a3082c0614b9c8d5d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21081
Reviewed-by: dan sinclair <dsinclair@google.com>
Distinguish between selections constructs starting with with
OpBranchConditional and those starting with OpSwitch.
We'll use this in a followup CL to track break from a switch.
Bug: tint:3
Change-Id: I8d000cb42325535a4937c84f83a83c98a9b8d4c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21080
Reviewed-by: dan sinclair <dsinclair@google.com>
Classify CFG edges:
- loop backedge
- a structured exit:
- loop break
- loop continue
- selection break
- fallthrough
- forward (any of the rest)
Also error out when there should have been a merge instruction.
(More than one unique fallthrough or forward edge).
Includes lots of tests.
Bug: tint:3
Change-Id: I70f27680bdf098213056522abf04ac58a6b478ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20481
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL fixes up some issues which give compile errors when building
with Visual Studio.
Change-Id: Ib76644d869dd2adccd579621d18804d84b65a74c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20940
Reviewed-by: David Neto <dneto@google.com>
This CL splits the TypeConstructor code out of the generic
ConstructorExpression to make the code separation clearer.
Bug: tint:5
Change-Id: I441955c3b09a30b2d02f542f4b7c8e80ff8d9d86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20640
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL adds the beginning of break and continue support. The
conditional versions are not supported, just the non-conditional.
Bug: tint:5
Change-Id: I84418cffd3e29dc011c4313bf9aa3da4833c009f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20500
Reviewed-by: David Neto <dneto@google.com>
Label basic blocks with:
- their nearest enclosing structured control flow constructs.
- their nearest enclosing continue construct, if any
- their nearest enclosing loop construct, if any
A construct consists of a span of blocks in the computed block order.
It knows its parent construct, if any, and its nesting depth.
Bug: tint:3
Change-Id: Ia945706e8ea2435d6c40fb4e36dc2daeeb9780d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20421
Reviewed-by: dan sinclair <dsinclair@google.com>
This is gives us the fundamental ordering of blocks in relation
to a structured construct.
Bug: tint:3
Change-Id: I76eb39403131305398808c33ce4cee256a1c23c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20266
Reviewed-by: dan sinclair <dsinclair@google.com>
TEST=Built fuzzer in local checkout of Chromium with tint integrated.
BUG=dawn:14
Change-Id: I84aacd41f893070c3af40f5e640361e177689f9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20343
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL updates the type determiner such that variable result types
end up wrapped inside pointers, constants do not. The result of Member
and Array accessors are also pointers if the source was a pointer.
Change-Id: I6694367daf6ba1db929e54a975dfea8404fca40c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20265
Reviewed-by: David Neto <dneto@google.com>
Also, list remaining logical instructions to be tested
Bug: tint:3
Change-Id: I48dda1d3637bc7c4d75358e26fb9de8f0c6f0bb6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20261
Reviewed-by: dan sinclair <dsinclair@google.com>
Record header/merge cross-links, and single_block_loop attribute of BlockInfo.
Also checks that they are sane: only target blocks in the same function.
Bug: tint:3
Change-Id: I715f7ed354a556e92d58a4c9ba6f306c746c3641
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20080
Reviewed-by: dan sinclair <dsinclair@google.com>
Each basic block must have a terminator, and if the terminator branches
to another block, that block must name a label in the same function.
Bug: tint:3
Change-Id: If22bece6a8041fef362c02b05e4dfee999a3e5bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20046
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL adds the code to generate the negation and not operators.
Bug: tint:5
Change-Id: Ibb4d374586e1415a2a678e375c64ba69bbc20367
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20143
Reviewed-by: David Neto <dneto@google.com>
- branch-conditional where both targets are the same
- switch where the default target is the same as a case target
Bug: tint:3
Change-Id: If5a3e1fead43ae3d528341f3e54dcae959d9eb8c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20061
Reviewed-by: dan sinclair <dsinclair@google.com>
Separate them into different test files, to match SPIR-V spec sections
Bug: tint:3
Change-Id: I89fe76230740da060d57ac23870069a5483b2d7d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20043
Reviewed-by: dan sinclair <dsinclair@google.com>
Test non-nested sequences and selections.
Bug: tint:3
Change-Id: Ibbbcd428d701d9e7d4da1682f94c2bdbef00121b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19920
Reviewed-by: dan sinclair <dsinclair@google.com>
Fix bad merge around emission of OpBitcast.
Change-Id: Iacc5ba1c3940745e4b2c46878bbc416397ec555f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20047
Reviewed-by: David Neto <dneto@google.com>
Also, it's not clear if OpSRem has a direct mapping.
Bug: tint:3
Change-Id: Ie7834253cf14109fbebd2ece8e18d9899b29753b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19881
Reviewed-by: dan sinclair <dsinclair@google.com>
(I expect that) the WGSL signed division operator expects both operands
to be signed and the result will also be signed.
When the operands of a SPIR-V OpSDiv is unsigned, then wrap
the operand in an as-cast to the corresponding signed type.
When the result type of a SPIR-V OpSDiv instruction is unsigned,
we have to wrap the generated WGSL operator with an as-cast to
that unsigned type.
This first CL addresses OpSDiv. We'll address other operations in future CLs.
Bug: tint:3
Change-Id: If3849ceb44b21db87c1efd2c6a2cd63c6d648c88
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19800
Reviewed-by: dan sinclair <dsinclair@google.com>
The AST only wants expressions, not their result types.
But the SPIR-V reader wants to track the AST type as well.
So introduce a TypedExpression concept for internal use.
Bug: tint:3
Change-Id: Ia832f7422440ef0e8e04630cdca98cae20e18921
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20040
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL renames the parts of the identifier to segments and then adds a
path() and name() methods to get the respective parts of the identifier.
Change-Id: I1a365df7cb83ac0dd3d6be9ec6ccb83bfc73dd91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19762
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
BUG=dawn:16
Change-Id: I1da30fed82a310007674801e3b1e853b25d5b573
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19640
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This CL cleans up some lint errors.
Change-Id: Ibfe9768cc4272d015a35a8d7edde0390b8fc66a5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19504
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL removes the premerge statement and replaces it with a `premerge`
reserved word.
Change-Id: Ic9bc13878ed26e1733eb65dd1ba30d9bef095cb6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19380
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL removes the regardless statement and turns `regardless` into a
reserved word.
Change-Id: I50c521111b90dbadddaeb36674e8c40205186076
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19361
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Also adds generic support for generating a combinatorial value
as a const definition.
Bug: tint:3
Change-Id: Idae758d146264491679710967e48ea270436be91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19107
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL converts a few more std::vector<std::unique_ptr<foo>>'s to
FooList aliases.
Change-Id: If0dd672f11beaeabd9e89e82903c2174b11be6e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19103
Reviewed-by: David Neto <dneto@google.com>
If a non-const variable in a function has a kNone storage class we
update it to kFunction. If there is a storage class other then kFunction
we emit an error.
Bug: tint:5
Change-Id: If45eb91bd0a0095e625eb1d0e1d1e361c784e35d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19102
Reviewed-by: David Neto <dneto@google.com>
This CL adds the relational add expression to the spirv writer.
Bug: tint:5
Change-Id: Ideed225c63e60f53a019b79803809f8e973299c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18605
Reviewed-by: David Neto <dneto@google.com>
Tests FunctionEmitter directly.
This is mostly refactoring to be able to selectively run parts of the
parsing flow, and to access relevant internal data.
Bug: tint:3
Change-Id: Ic2b166a2e9623a7e30e6769806088d12e78dcf45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18704
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL completes a few of the DISABLED tests.
Change-Id: I38806fb9381240d6e3da700f1fb2dac5f899ca6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19000
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Match the more common usage for the expression type.
Bug: tint:37
Change-Id: Ia5d48a0444742ec4e304ea1036e499b3d7cad682
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18981
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL adds various using statements for the
std::vector<std::unique_ptr<CLASS>> constructs found in the AST.
Change-Id: Ic9a2357cd73b2aafd99e961a38727f2f9874cde5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18920
Reviewed-by: David Neto <dneto@google.com>
VS2017 took issue with treating size_t and uint32_t the same. It also
couldn't find various alphanumeric is* functions without the <cctype>
header. Gcc complainted about a variable potentially used uninitialized.
Change-Id: I452b68c6597bae254f32e5a350656e65c8934b6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18901
Reviewed-by: dan sinclair <dsinclair@google.com>
Fix typos in SPIR-V IDs that were causing the optimizer to assert
out when building up its internal data structures.
Bug: tint:3
Change-Id: I27210623b0d3d241dbd6afe6bef63e88a02b390e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18640
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL removes a std::move which triggers a -Wpessimizing-move error
Change-Id: I378f32a808a86a0944a4bb41f243b7416c10a9fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18602
Reviewed-by: dan sinclair <dsinclair@google.com>
Only emit functions that have bodies.
Don't emit their bodies yet.
Emit them so that callees precede callers.
Bug: tint:3
Change-Id: Ia67ba2fe1d47c7c7d5c290d1d4fc5256fa293b51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18620
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL renames VariableStatement to VariableDeclStatement to make it
clearer what it was modeling.
Bug: tint:25
Change-Id: Idd0d27fad7cc402f286e1abad74092c9d1961d91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18341
Reviewed-by: David Neto <dneto@google.com>
This Cl updates the names of the initializer expressions to be clearer.
* InitializerExpression -> ConstructorExpression
* ConstInitializerExpression -> ScalarConstructorExpression
* TypeInitializerExpression -> TypeConstructorExpression
Bug: tint:26
Change-Id: Ib046497f589cc65d1d64bc172015588348feeffe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18340
Reviewed-by: David Neto <dneto@google.com>
Handle as many member decorations as the Tint AST can express right now.
See crbug.com/tint/30
Bug: tint:3
Change-Id: I6d04f1beb438b3d952a76886fbd9c6b7ea701d81
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18160
Reviewed-by: dan sinclair <dsinclair@google.com>
Bug: tint:3
Change-Id: I9655ddbe48f2660f88be68bc52c9467d805043ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18080
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Add a Context::Reset method to clear state.
Hide the member behind an accessor.
Change-Id: Iafb7c39249f66f70c5a99a8ed1c69f2c0238834f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17742
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL updates the SPIR-V writer to generate the OpConstantTrue,
OpConstantFalse and OpConstant instructions.
Bug: tint:5
Change-Id: I660554c491e4eb569e3902fce0973fae3f27e6c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17820
Reviewed-by: David Neto <dneto@google.com>
This CL moves all test files to the anonymous namespace.
Change-Id: Ie5ae0efe907c03eeb441e90f31c976844172b594
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17900
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL fixes up several documentation and linter warnings.
Change-Id: Ic367ba1937f20dfe47a8c8e4035c17e8a3d0f2e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17880
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL updates the SPIR-V writer to emit the OpTypeFunction and
OpFunction instructions.
Bug: tint:5
Change-Id: I85ead161ca37304a977213257a825ff268d29f2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17741
Reviewed-by: David Neto <dneto@google.com>
This Cl replaces the TypeManager singleton with a context object.
Bug: tint:29
Change-Id: Ia662709db1b562c34955633977ce4363f28f238e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17780
Reviewed-by: David Neto <dneto@google.com>
This CL adds a helper to emit a block of statements from the WGSL
writer.
Change-Id: I6fe62d894882c0a0fdc8865967bfa4887f3a65a3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17761
Reviewed-by: David Neto <dneto@google.com>
For now, it only handles scalar types
Bug: tint:3
Change-Id: Ic20e18a4f80790e6cd10d4c06dd2abfd8f67a304
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17700
Reviewed-by: dan sinclair <dsinclair@google.com>
Define the ID targeted by the entry point. Do this to avoid
asserts in the optimizer code
Bug: tint:3
Change-Id: Idbd4c8a058f2d51ff44696d2029502044d01b424
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17562
Reviewed-by: dan sinclair <dsinclair@google.com>
A Namer is a place for saving and looking up names
based on SPIR-V IDs.
Bug: tint:3
Change-Id: I6aeb2f5f7ba63c2e0a816dcbac88f964beafabc6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17284
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL extends the build options to Tint to make the various readers
and writers all optional.
Change-Id: I913e1830b1bb2243eff5deb4b8079ba592dd52e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16801
Reviewed-by: David Neto <dneto@google.com>
This CL creates the skeleton for the SPIR-V writer.
Bug: tint:5
Change-Id: I849d8766d32d48314a51096710272f9821e2c1c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16641
Reviewed-by: David Neto <dneto@google.com>
It will always use the "std::glsl" import name.
Remember all the IDs of such imports.
Never add more than one GLSL.std.450 import to the AST.
Also refactor the Assemble test helper into its own file.
Bug: tint:3
Change-Id: I5b2b70ea0f00d44aacf553aa009756dff2a4cecf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16662
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL marks the specific `bool` test as NOLINT in fail_stream to stop
the linter from emitting errors.
Change-Id: Ifa3d9b0a2e0f06bcd0d48cbe79f8dbe91fe7b4ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17061
Reviewed-by: David Neto <dneto@google.com>
For convenience, use the SPIRV-Tools' optimizer representation.
Bug: tint:3
Change-Id: I1b046209584e1e907045d496b0f8d7b36fca79bd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16660
Reviewed-by: dan sinclair <dsinclair@google.com>
Use the SPIRV-Tools validator, with the WebGPU0 environment.
Bug: tint:3
Change-Id: Id1132d209fd939ed68587034761e97da9b35b21d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16821
Reviewed-by: dan sinclair <dsinclair@google.com>
The parser impl saves a copy of the SPIR-V binary.
Bug: tint:3
Change-Id: I5d61c87123c0bcb417d0c7004e0ef4e3c8fbb027
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16642
Reviewed-by: dan sinclair <dsinclair@google.com>
- spv parser just errors out for now
- link against SPIRV-Tools-opt
- Fixe CMake variable TINT_ENABLE_SPV_PARSER --> TINT_BUILD_SPV_PARSER
Bug: tint:3
Change-Id: Ie4ef9b03e001fca3cc11f65a425612755857feac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16600
Reviewed-by: dan sinclair <dsinclair@google.com>
This CL adds tests for decorated variable and updates the API to be
slightly nicer.
Bug: tint:11
Change-Id: I0bd5b8b6e6f682dc9d405e02e51d5dbcaeccc5f3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16465
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>