Commit Graph

524 Commits

Author SHA1 Message Date
dan sinclair c7b66da6ad Cleanup formatting and linter.
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>
2020-06-16 15:02:50 +00:00
David Neto 93e39b451b [spirv-reader] Support ifbreak with other forward edge
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>
2020-06-16 01:03:39 +00:00
David Neto ad2f7ccc55 [spirv-reader] Add Namer::MakeDerivedName
Bug: tint:3
Change-Id: I4dc3049c577049bb4ad0d1e42ec80f7d82cdb4a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23181
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-16 01:02:59 +00:00
David Neto 318ae59f4d [spirv-reader] Update TODOs in test matrix
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>
2020-06-16 01:02:27 +00:00
David Neto b2b0dfefa9 [spirv-reader] Add OpCompositeExtract
Bug: tint:3
Change-Id: I9d8c1cf2545e28ef0ddf89e55ce45ec19c50022a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23161
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-16 01:02:21 +00:00
dan sinclair 6941c5354c [spirv-writer] Allow emitting an array stride.
This CL adds the ability to attach a stride to an array type and have it
emitted during SPIR-V generation.

Bug: tint:5
Change-Id: I9c0f0a6afef6ae6662b64f4da2c150ba3f8da29f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23223
Reviewed-by: David Neto <dneto@google.com>
2020-06-15 20:58:28 +00:00
dan sinclair 7be237aa8f Determine types for module scoped variable constructors.
This CL updates the type determination code to determine the types of
module scoped variable constructors.

Bug: tint:89
Change-Id: Icd5d65409fcf17a0cbf0b34b9919f8d9e1577354
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23220
Reviewed-by: David Neto <dneto@google.com>
2020-06-15 20:55:09 +00:00
David Neto c7d1ac3361 [spirv-reader] Add OpCompositeConstruct
Bug: tint:3
Change-Id: Ibb1a4124e7e7b7a5b95bdd4e7c7e7f1c570e641c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23127
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-12 15:09:56 +00:00
David Neto 0335adbc9a [spirv-reader] First GLSL.std.450 instructions
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>
2020-06-12 15:09:14 +00:00
David Neto 709b62528c [spirv-reader] Add fallthrough
Bug: tint:3
Change-Id: Ib2d337156d419ed13ef9c67aa94ac3ee90f79548
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23041
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-11 20:53:39 +00:00
David Neto 416be308fc [spirv-reader] Add switch-selection
- 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>
2020-06-11 20:39:06 +00:00
Ryan Harrison be45ff5081 Create tint.h for external users
tint.h selectively includes headers depending on what features are enabled. It
is based off of the original sample code, so should give users access to all of
the functionality demonstrated in there.

This is located in include/tint/, so that users can have a pretty include of
tint/tint.h.

BUG=tint:87

Change-Id: I8659c789c154349e4e8e7730dc334da4fb6eba70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23124
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-11 19:35:20 +00:00
David Neto 8ca0aa710d [spirv-reader] Simplify if-selection bookkeeping
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>
2020-06-11 18:11:15 +00:00
David Neto 046c2b7c4c [spirv-reader] remove exclusive_false_head_for
Code cleanup

Bug: tint:3
Change-Id: I8d1c4e8a486b3c3cccb13e0a265269606278fb97
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23080
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-11 14:19:07 +00:00
Ryan Harrison 3f3483be14 Fix BUILD.gn based builds
Change-Id: Iec5c7ee8d6f614f7a7301c023703650d4c4068d3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23061
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-10 19:45:00 +00:00
David Neto 39e83353f0 [spirv-reader] Avoid emitting empty elses
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>
2020-06-09 20:07:48 +00:00
dan sinclair af5df70c7b Add GLSL FindILsb, FindUMsb, FindSMsb and InterpolateAtCentroid.
This CL adds the type determination for the GLSL methods FindILsb,
FindUMsb, FindSMsb and InterpolateAtCentroid.

Change-Id: I2b1e9d021e6799ffe6b5b71c5cca947b8e6ccfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22843
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:26 +00:00
dan sinclair ee39225c0b Add support for GLSL cross.
This CL adds support for the GLSL cross method.

Change-Id: Ib2e83a2ef2e580c6ca257851a76f3f66fa377d6f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22842
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:15 +00:00
dan sinclair 92bb55777c Add GLSL umin, umax, smin and smax support.
This CL adds type determination for the umin, umax, smin and smax GLSL
methods.

Change-Id: Ib301da41baf718e309a940f4a3560088daa10741
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22841
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 23:48:07 +00:00
dan sinclair 5e5fb9cf37 Add ssign and sabs GLSL support.
This CL adds the SSign and SAbs GLSL methods to the type determination.

Change-Id: If0e25cd153bd3aaef1cb031d647a86e98ff917bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22840
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 19:01:07 +00:00
dan sinclair 53352044df Refactor GLSL type determination code.
This Cl cleanups and simplifies the type determination for the GLSL
imports.

Change-Id: I9dd85ac390ef37c91d9493f840f81ceb6736fc06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22820
Reviewed-by: David Neto <dneto@google.com>
2020-06-08 18:49:31 +00:00
David Neto b0d308c9fe [spirv-reader] Emit non-header OpBranchConditional
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>
2020-06-08 18:26:03 +00:00
David Neto bff3b78313 [spirv-reader] Add cases for mergeless OpSwitch
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>
2020-06-08 15:26:18 +00:00
David Neto 783938d173 [spirv-reader] Fix typo in test name
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>
2020-06-08 15:14:22 +00:00
David Neto bdcd04b1a2 [spirv-reader] Check some merge block dominance
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>
2020-06-08 15:14:22 +00:00
David Neto dc8efd4095 [spirv-reader] Add mergeless OpSwitch case
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>
2020-06-08 14:53:34 +00:00
David Neto 5d4c35f96e [spirv-reader] kIfBreak edge counts toward divergence
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>
2020-06-08 14:37:05 +00:00
dan sinclair 7615d9468c [spirv-writer] Cleanup capabilities code.
This CL simplifies the capabilities code in the SPIR-V builder.

Bug: tint:5
Change-Id: Iff99350b2d6a2534c82ea3d47a0a9186d0dcb6ac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22661
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-06-04 17:29:54 +00:00
dan sinclair 65cd5a8e0d [spirv-writer] Add support for outer_product
This CL adds support for generating OpOuterProduct.

Bug: tint:5
Change-Id: Iefbc91807850b7caf5dba393124f97417b7b0b09
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22660
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:17:37 +00:00
dan sinclair 36471fe3eb [spirv-writer] Add support for derivatives.
This CL adds support for generating the various dpdx, dpdy and fwidth
instructions.

Bug: tint:5
Change-Id: I6d12c738b93931d1e740659d9c1871892b801f71
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22625
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:14:43 +00:00
dan sinclair 2cbbb5d7c2 [spirv-writer] Add support for dot call.
This CL adds support for generating OpDot.

Bug: tint:5
Change-Id: I5a77e49ff26ff12b4ed7b2b01665f0928e51a568
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22624
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:06:06 +00:00
dan sinclair 3c3cf3cc21 [spirv-writer] Add support for is_inf
This CL adds support for generating OpIsInf.

Bug: tint:5
Change-Id: Ia208695d78f9914000e893435f37be45adb81022
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22623
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:05:55 +00:00
dan sinclair c31903d2ad [spirv-writer] Add is_nan support.
This Cl adds support for generating OpIsNan.

Bug: tint:5
Change-Id: If35e46c6cb2719771abdd425ff6116b539da0be0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22622
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:05:49 +00:00
dan sinclair 0bcb50b04a [spirv-writer] Add support for all intrinsic.
This CL adds support for generating an OpAll .

Bug: tint:5
Change-Id: I70a92bc68064625324d6c7b59220a901ced76f96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22621
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:05:43 +00:00
dan sinclair 3e7dc82b35 [spirv-writer] Generate any intrinsic
This CL adds the necessary code to generate an OpAny instruction.

Bug: tint:5
Change-Id: I558b2cbf4bade3b4ab17997d24dcffddc32e2b41
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22620
Reviewed-by: David Neto <dneto@google.com>
2020-06-04 17:05:35 +00:00
David Neto 06d49471a0 [spirv-reader] Refactor emission for OpBranch
Bug: tint:3
Change-Id: If1d603990f133f8ba0b3a305f7f7f3db4623e9ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22602
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-04 15:28:10 +00:00
David Neto 3bbc45ded3 [spirv-reader] Update test to show error caught
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>
2020-06-04 15:27:05 +00:00
David Neto 90d6b2d94f [spirv-reader] Update test to show error is caught
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>
2020-06-04 15:26:31 +00:00
dan sinclair ccb699eb00 Remove right shift arithmetic operand.
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>
2020-06-03 16:11:44 +00:00
dan sinclair 2b23e4bd70 Remove unless_stmt
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>
2020-06-03 16:11:37 +00:00
dan sinclair 6bd7061a2e Remove conditional break/continue.
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>
2020-06-03 16:11:28 +00:00
David Neto 27d42ede4e [spirv-reader]: Support OpBranch
Bug: tint:3
Change-Id: I39d03f4fc29c7b60dc09d0bafc3afaec754671a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22425
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-03 13:43:03 +00:00
dan sinclair 579d33c528 Make case selectors an integer value
Change-Id: I819983701ed6cca4eba1a05b4edc5fdff10fa88d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22542
Reviewed-by: David Neto <dneto@google.com>
2020-06-02 20:12:02 +00:00
dan sinclair e009c2058d Add IntLiteral parent for Sint and Uint literals.
This CL adds a parent class for the type types of interger literals for
the cases where we can have either.

Change-Id: I61b540bedd49a6cf5a899e6864e2ea6f140cd2be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22541
Reviewed-by: David Neto <dneto@google.com>
2020-06-02 20:11:54 +00:00
dan sinclair c6f2947ceb Rename the IntLiteral to SintLiteral.
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>
2020-06-02 20:11:44 +00:00
David Neto 1649dfadd7 [spirv-reader] Support unreachable, as a return
Bug: tint:3
Change-Id: Ia1384f84f7851a9e155c1536a624213ef51ee0a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22521
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-02 19:56:07 +00:00
David Neto 91332dc475 [spirv-reader] Support kill
Bug: tint:3
Change-Id: I91472b98c9977a5bdce6fc2ab4880e8312881fcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22500
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-02 19:56:07 +00:00
dan sinclair 1d69915155 Rename case statement conditions to selectors.
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>
2020-06-02 17:18:56 +00:00
David Neto cb48e79fa5 [spirv-reader] Support return, return-value
Bug: tint:3
Change-Id: Iaaf6ace739ac30e7f9f0bd4ddcef209ab1b71ed8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22480
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-02 16:48:27 +00:00
David Neto d8613596e2 [spirv-reader] Emit loop and continuing
Bug: tint:3
Change-Id: Iaced5ee41f6b27ab350432fc1c2cdff6042ba191
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22423
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-02 16:46:51 +00:00
David Neto 468c26b233 [spirv-reader] Emit control flow: if/then/else
Bug: tint:3
Change-Id: Ief0544415f27842913a6234a962d163ecedb48df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21821
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-02 13:25:06 +00:00
dan sinclair e2be489756 Fix merge conflict
Change-Id: Idd941099241e9310fea13932c3ef4fcf5083730a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22441
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-01 19:00:41 +00:00
dan sinclair dadd149d9b [spirv-writer] Add fallthrough support
This CL adds support for the fallthrough statement in a `case` block.

Bug: tint:5
Change-Id: I282643a304846a19212d41bd8bd20a60398bd793
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22220
Reviewed-by: David Neto <dneto@google.com>
2020-06-01 18:56:56 +00:00
dan sinclair 916b408111 [spirv-writer] Add switch support
This CL adds switch support to the SPIR-V writer.

Bug: tint:5
Change-Id: I8a6ad40cb2d344c87abdf842194b60afb1b4c96e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22165
Reviewed-by: David Neto <dneto@google.com>
2020-06-01 18:56:34 +00:00
David Neto 7768f5b308 [spirv-reader] use stack of statement lists
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>
2020-06-01 18:51:06 +00:00
David Neto b83c651654 [spirv-reader] Add problematic CFG case as disabled test
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>
2020-06-01 16:59:24 +00:00
dan sinclair 1aadbd4e47 Add case_selectors update
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>
2020-06-01 16:56:46 +00:00
dan sinclair 59fc026bcf [spirv-writer] Generate kill statements.
This Cl adds preliminary support for generating Kill commands. This may
change in the future if the semantics of kill are set in WGSL to not
match OpKill.

Bug: tint:5
Change-Id: Id466a1b26b37867a26373b93f56d627a0491f47f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22240
Reviewed-by: David Neto <dneto@google.com>
2020-06-01 13:44:43 +00:00
dan sinclair 091b2b5fc8 Updating to match WGSL spec.
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>
2020-06-01 13:44:06 +00:00
dan sinclair 46e959da39 Update intrinsics in the grammar.
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>
2020-06-01 13:43:22 +00:00
dan sinclair 1d2ad81eb9 Update WGSL grammar builtins to match spec.
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>
2020-06-01 13:43:11 +00:00
dan sinclair 0647d23607 [spirv-writer] Remove stpq support.
This CL removes conversion of stpq to indexes for a vector swizzle as
they are not supported by WGSL.

Change-Id: I3fde18a8a4205cae83b32ce2830a6df48a8f22f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22162
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-05-27 13:08:29 +00:00
dan sinclair 5370390096 Remove NOP.
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>
2020-05-26 15:05:54 +00:00
dan sinclair 53f2026fc5 Add if with else continue test.
This Cl adds a test for a continue inside an else case.

Bug: tint:5
Change-Id: If9606b18ff8c2af6eb271aa37c404f36097f592e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22060
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-05-21 17:46:02 +00:00
dan sinclair 615aaed508 [spirv-writer] Fill out cast code.
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>
2020-05-21 13:57:07 +00:00
David Neto 7e5e02f805 [spirv-reader] Support access chain
Bug: tint:3
Change-Id: Ibdb6698c4a97ce66ed533a9bf007bc352a09244e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21641
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-20 20:36:18 +00:00
David Neto 91c5a496d2 [wgsl-writer] Function var decls don't mention storage class
From WGSL decision in https://github.com/gpuweb/gpuweb/issues/654

Change-Id: I570475cf0d069043d70794d7b92626798963bfdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21363
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-20 18:33:54 +00:00
David Neto 1bbc1cb2c1 [spirv-reader] Support null vector, matrix, arr, struct
Bug: tint:3
Change-Id: I2fa25e5d28b965de4a419719e37bc999be8489ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21581
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-19 14:46:41 +00:00
David Neto b275fd2f0e [spirv-reader] Systematic bad construct exit tests
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>
2020-05-19 14:43:19 +00:00
David Neto e3d235662a [spirv-reader] Remove TODO about nested selections
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>
2020-05-19 14:37:10 +00:00
David Neto c02de8fc45 [spirv-reader] remove redundant disabled test
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>
2020-05-19 14:34:27 +00:00
David Neto 9f7297c766 [spirv-reader] Unordered float compares
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>
2020-05-14 21:43:27 +00:00
Ryan Harrison 0bbf1e7460 Small fix for BUILD.gn
Change-Id: I1a43eeebff6d952e76a7247754dc2a89694ab064
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21500
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-05-11 15:45:51 +00:00
David Neto cad427e787 [spirv-reader] Find if-selection internal headers
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>
2020-05-07 20:27:42 +00:00
David Neto d8082d27a3 [spirv-reader] Rename Edge::kToMerge to kIfBreak
Change-Id: I187b88cb68a04e46a16b6391013bdaf148191cc2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21221
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-07 20:20:05 +00:00
David Neto 15fd7366cc [spirv-reader] Classify kSwitchBreak from deep in control flow
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>
2020-05-07 20:20:05 +00:00
dan sinclair 4dfda012b2 Rename brace and bracket to match spec
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>
2020-05-07 19:47:39 +00:00
Ryan Harrison ace7a13662 Fixes to unbreak the BUILD.gn build
Change-Id: I0077bb103fc6940c1af029a65b7069cb6fbec3d9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21201
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-06 21:49:55 +00:00
dan sinclair a4e6858b94 Remove push constants.
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>
2020-05-06 21:48:23 +00:00
David Neto ab56088ae7 [spirv-reader] Classify kSwitchBreak edges
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>
2020-05-06 18:32:38 +00:00
David Neto 920bdcd0aa [spirv-reader] Refine selection construct concept
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>
2020-05-06 18:32:29 +00:00
David Neto 054927d7eb [spirv-reader] Classify CFG edges
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>
2020-05-05 21:17:13 +00:00
dan sinclair b1870eff04 [spirv-writer] Add a LocalSize execution mode.
In SPIR-V a compute entry point requires a WorkGroup Size constant or a
LocalSize execution mode. This CL adds a 1,1,1 execution mode as a
starting point.

Bug: tint:74
Change-Id: Ie5bf639472033dca9ffe333548e7f31d4d318768
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21020
Reviewed-by: David Neto <dneto@google.com>
2020-05-05 14:21:28 +00:00
dan sinclair 2287f33424 [spirv-writer] Add null initializers where needed.
The WGSL spec requires initializers for Output, Private and Function
variables. This CL adds initializers where needed.

Bug: tint:75
Change-Id: Id97f85a67ead2ffc41d6bdd1b71bf7034b04502a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20980
Reviewed-by: David Neto <dneto@google.com>
2020-05-05 14:21:19 +00:00
dan sinclair 5b43c58f02 [spirv-writer] First pass at entry point interface
This CL adds the first simple pass at adding interface variables into
the entry point command. It simply lists all Input/Output module scoped
variables onto all entry points.

Bug: tint:28
Change-Id: I962462d783f3b97bb3da32fd9890ceb90808942b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20963
Reviewed-by: David Neto <dneto@google.com>
2020-05-04 19:42:43 +00:00
dan sinclair 6ca2699eaf Windows fixes.
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>
2020-05-04 18:58:24 +00:00
dan sinclair 253ee1b3ef Fixup IntLiteral names.
This CL fixes the IntLiteral name to contain the type of the literal.
This keeps i32 and u32 from fighting over a given name. Now, the name
ends up being __int__i32_0 instead of __int_0.

Change-Id: Ifb9f0516139d25f34312c75c77318eccbe076ef8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20941
Reviewed-by: David Neto <dneto@google.com>
2020-05-04 18:58:19 +00:00
dan sinclair 6164da26b7 [spirv-writer] Handle load of array accessors if needed.
In some cases the array access must generate a load if there is a
following swizzle. This CL adds the needed load.

Bug: tint:71
Change-Id: Ib6ca6284af993962d9d573b323d54be7ce0e726c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20920
Reviewed-by: David Neto <dneto@google.com>
2020-05-04 17:06:17 +00:00
dan sinclair 8a669aabeb [spirv-builder] Generate load for cast expression.
If the value being casted is a pointer it must be loaded first. This CL
adds the needed load.

Bug: tint:72
Change-Id: Ia019b7976db6b97c811f6424db8fe4f07a3d11f3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20900
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
2020-05-04 17:06:05 +00:00
David Neto c8c10e83df [spirv-writer] Generate load for var initializer, if needed
Change-Id: I609860bb05fae3e6e5eb21a471f869030f384ad0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20721
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-01 19:09:08 +00:00
dan sinclair abd472e45a [spirv-writer] Add start of cast support.
This CL starts support for the cast expression. It adds the i32 to f32
conversion path.

Bug: tint:5
Change-Id: Id1eafc38592060c4b5b91964302d79a847e2edaf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20628
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 19:05:55 +00:00
dan sinclair cf3517812c [spirv-writer] Load array accessors if required.
If an array accessor index is a variable it needs to be loaded before we
can use it to access the array. This CL adds the call to generate the
load for the index.

Bug: tint:5
Change-Id: I74143d2eb746727e857218d54126e1f5fd785bdf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20780
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 19:05:21 +00:00
dan sinclair cf2af15d94 [spirv-writer] Add assignment tests.
This CL adds assignment tests which require evaluating an access chain
to get the thing being written into.

Bug: tint:5
Change-Id: I475173b7b4ef4223de6f4258b8fa920760196b12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20626
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 19:05:14 +00:00
dan sinclair 576c9afab9 [spirv-writer] Add function with body test.
This CL implements the disabled function with body test.

Bug: tint:5
Change-Id: Ia5b2270373fdf734536b77d9dbac41bd35e3218f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20625
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 19:05:03 +00:00
dan sinclair a0b375458d [spirv-writer] Enable FunctionVar_WithNonConstantConstructor
This CL updates and enables the disabled
FunctionVar_WithNonConstantConstructor test.

Bug: tint:5
Change-Id: If45152034968bd81aa3cf7ae76dfdb02598b6e4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20760
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 19:04:56 +00:00
David Neto 540ab2160b [spirv-writer] Fragment shaders use OriginUpperLeft
Fixes a validation error

Change-Id: Ie003ac61a10f87f3d0c42ad8cb162da50c1c416b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20740
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-05-01 19:02:25 +00:00
dan sinclair 7cac245abc [spirv-writer] Handle multi name swizzles.
This CL rebuilds the accessor code to allow generating multi item
swizzles. This requires being able to output the access chain in the
middle of the access chain and then work with the results of that access
chain.

Bug: tint:5
Change-Id: I0687509c9ddec6a2e13d9e3595f04a091ee9af7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20623
Reviewed-by: David Neto <dneto@google.com>
2020-05-01 16:17:03 +00:00
David Neto a1a4800861 [spirv-writer] Avoid branch after dead if/then if/else
Bug: tint:64
Change-Id: I008c449ca634c6410055a65927199fda2d7bbb06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20720
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-30 01:17:46 +00:00
David Neto 9684d8101d [spirv-writer] decorations are annotations
Change-Id: Iaf1c11b2be3fbc2dacda801d1eb32d3e091b76db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20680
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-30 01:16:29 +00:00
David Neto 1be8d7f0d1 [spirv-writer] Declare extension when using vulkan memory model
This fixes one validation error

Change-Id: I13ee67483ea211d394b51ed9ea29b6698af0acc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20622
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-30 01:16:21 +00:00
dan sinclair 4092f2255c [spirv-writer] Split the constructor expression method.
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>
2020-04-29 18:53:23 +00:00
dan sinclair a308ae2a7f [spirv-writer] Stub out more accessor tests
This CL adds more tests to be written for the accessor code.

Bug: tint:5
Change-Id: Ie3a349bfb372dc7f8069d2117bf4fdd48f2da07a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20621
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-29 18:50:21 +00:00
David Neto 8ff8c07ac3 [spirv-reader] Find switch case headers
Bug: tint:3
Change-Id: I66785fd6cbbe1432a4eda3f3258e4b9b0457f303
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20422
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-28 22:12:08 +00:00
dan sinclair 3051bfd6b5 [spirv-writer] Handle building vectors from other vectors.
This Cl updates the composite construction to handle decomposing vectors
into smaller parts before building the composite.

Bug: tint:61
Change-Id: I7e0ac3a5c966dbcdf6429d508a392756f521b756
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20541
Reviewed-by: David Neto <dneto@google.com>
2020-04-28 20:25:21 +00:00
dan sinclair a5bba6037a [spirv-builder] Handle single element swizzle.
This CL adds the code to handle a swizzle of a single element (eg vec.x)

Bug: tint:5
Change-Id: If23979c8b715e6770e75fb72c92a91aec83c5b0d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20502
Reviewed-by: David Neto <dneto@google.com>
2020-04-28 17:31:07 +00:00
dan sinclair 40aa8d64aa [spirv-writer] Generate loads for call parameters.
This CL updates the call code to emit an OpLoad if the parameter being
passed is a pointer.

Bug: tint:5
Change-Id: I19c2ffa1b55697173ded6d5509fecd37442e7966
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20501
Reviewed-by: David Neto <dneto@google.com>
2020-04-28 17:31:00 +00:00
dan sinclair 228392558f [spirv-writer] Add start of break and continue.
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>
2020-04-27 20:32:56 +00:00
David Neto a92c114c1a [spirv-reader] Label control flow constructs
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>
2020-04-27 20:14:08 +00:00
David Neto 195e4fe575 [spirv-reader] Verify order among header, continue, merge
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>
2020-04-27 18:12:50 +00:00
dan sinclair 26ec00a4c2 [spirv-writer] Handle alias struct members.
This CL adds support for alias types in the members of structures.

Bug: tint:5
Change-Id: I22f19b9a57d0f1be0ec4d6299948c1a93766ff9d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20347
Reviewed-by: David Neto <dneto@google.com>
2020-04-27 15:58:55 +00:00
Ryan Harrison d34b210e73 Add fuzzing target to BUILD.gn
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>
2020-04-27 15:31:27 +00:00
David Neto 597f52add2 [spirv-reader] Fix labels in CFG tests
Bug: tint:3
Change-Id: I13c67649d7e630828eeae34a2b4cd5612d5f2217
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20420
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 19:11:43 +00:00
dan sinclair 361e457438 Fixup non-const identifiers in type constructor.
As long as a type constructor is not global the values can be non-const
which means they don't have to be constructors. This CL fixes an issue
where we incorrectly assumed the value was a constructor.

Change-Id: Ib1661830cbb14298ea9254145edd60b74e0dee1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20344
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:41:12 +00:00
dan sinclair b445a9bf80 Unwrap member accessor aliases
The member accessors end up being aliases in a lot of cases because you
can't have a struct that isn't an alias. This Cl unwraps the aliases at
the start of the determination for member accessors.

Change-Id: Ib090ebd6aedd502c2812d95373c19d8eb831a361
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20342
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:40:45 +00:00
dan sinclair e6759029fb Unwrap pointer arguments to imported methods.
Make sure we unwrap pointers in import determination so things like
passing a member of a struct will determine the import correctly.

Change-Id: Id4565351c45e7798664c3368e2dec19b1440492d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20341
Reviewed-by: David Neto <dneto@google.com>
2020-04-24 00:40:12 +00:00
dan sinclair 9eab206e3f [spirv-writer] Test loading and storing to an accessor.
This CL adds load and store tests for a member accessor result.

Bug: tint:5
Change-Id: I5b8da3bb8d3df2c150967c812ffe3eeae3189fa7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20340
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 22:27:15 +00:00
dan sinclair 8eddb78433 Update type determiner to create pointers.
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>
2020-04-23 22:26:52 +00:00
dan sinclair 1a4d90667b [spirv-writer] Add start of single swizzle test case
This CL adds a DISABLED test for the single swizzle case.

Bug: tint:5
Change-Id: I75df147adba4e2e2b7eb6bfd0e0ede951502a73d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20300
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 20:35:32 +00:00
David Neto 742790c8ff Fix nits from review
From review https://dawn-review.googlesource.com/c/tint/+/20080
- single_block_loop -> is_single_block_loop
- better message for internal error for missing block when registering
  merges

Bug: tint:3
Change-Id: Ief8ac5ce8ad7ffe93c28e0e7e2a793d50ce2de6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20345
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 20:28:34 +00:00
David Neto a82384ee97 [spirv-reader] Add ordered float inequalities
Bug: tint:3
Change-Id: I302001a7d368cb09068df1220e81885a813fa247
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20246
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto ce84ac5023 [spirv-reader] Add signed integer inequalities
Bug: tint:3
Change-Id: Ic73491c2a00e5b9fd1aa70c385341ae79666cd1c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20245
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 1c6164363e [spirv-reader] Add unsigned integer inequalities
Bug: tint:3
Change-Id: If50d3816962679a8c199a515e8e0b4cdaf91a88c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20244
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto daf4b3a60d [spirv-reader] Add LogicalEqual LogicalNotEqual
Bug: tint:3
Change-Id: I4925ccf555ea7d0dadcafeb539317a00b1a4b92f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20242
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 592a71c647 [spirv-reader] Test OpLogicalNot, vector case
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>
2020-04-23 20:15:33 +00:00
David Neto c7e8c9c1a9 [spirv-reader] Test position field of BlockInfo
Bug: tint:3
Change-Id: I746b04b545da9dcd7c0b8805f264b67cb59c8a1c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20240
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-23 20:15:33 +00:00
David Neto 0131580407 [spirv-reader] Register merges
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>
2020-04-23 20:15:33 +00:00
Sarah Mashayekhi dd218b050d Assing const As.* functions to type class
Change-Id: I99c588b53f28da119611ef0a5b27820cdaa57fc2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20262
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:51 +00:00
Sarah Mashayekhi cb883a2817 Adding const As.* functions to expresssion class
Change-Id: I57fbe9d5c5054b65d64f1992e5e33dd31dd64a36
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20263
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:32 +00:00
Sarah Mashayekhi 194b6a2fce Adding const As.* functions to statement class
Change-Id: Ie9c0cecfce1ebb7decf377cee7053fb7ae0dee9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20260
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:52:10 +00:00
dan sinclair 88725a0f30 [spirv-writer] Member accessor.
This CL fixes up the member accessor code and adds tests.

Bug: tint:5
Change-Id: I139cb2e853da92e762255e4836daf2b9a437179d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20181
Reviewed-by: David Neto <dneto@google.com>
2020-04-23 13:04:22 +00:00
David Neto 795bebf1f2 [spirv-reader] Check terminators are sane
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>
2020-04-22 17:53:00 +00:00
Ryan Harrison fd1526bd33 Fix type conversions to make Clang 10 happy
Change-Id: I07f30e9bb19e3f7b0486c982bb3c4406a03dd615
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20161
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 17:46:36 +00:00
dan sinclair 20077b7b87 [spirv-writer] Start accessor chain additions.
This Cl adds the code for the ArrayAccessor generation. Some of the
MemberAccessor code is included, but tests are coming in a later Cl.

Bug: tint:5
Change-Id: Id7d006ab4a82c1d31d8036d141c83d0d61f9bea5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20180
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 14:07:05 +00:00
dan sinclair 43f975e71f [spirv-writer] Call the Call expression generator.
This CL adds the missing call for the call expression.

Bug: tint:5
Change-Id: Ia046e2b57ebc56eaf0c3dc330d9f8e81763df8bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20144
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 13:55:25 +00:00
David Neto aa257c068f [spirv-reader] Rename "rspo" to block_order
Bug: tint:3
Change-Id: I2d7e817fd30da98dc20da1be083be7e3cc5dcd89
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20147
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-22 00:27:31 +00:00
dan sinclair c9308dcb75 [spirv-writer] Generate Unary Op expression.
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>
2020-04-22 00:24:11 +00:00
dan sinclair 9a7cc7c73c Add more context to unknown expression error
Change-Id: I16bc118f5d3ec6536890404748fd06eb89a4433e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20142
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:24:03 +00:00
dan sinclair 2287d01233 Generate 3 param GLSL methods.
This CL adds the needed code to handle three parameter methods in the
type determinater.

Bug: tint:5
Change-Id: Id8584fbb1d308de585b59a4034e184b41f5bd74c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20141
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:23:57 +00:00
dan sinclair 21244880f8 Expression results should not be aliases.
This CL updates the expression class to set the alias value instead of
an alias as the result type.

Change-Id: If19ae394a09ba0dc76380514e53a488bbb5a7292
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20140
Reviewed-by: David Neto <dneto@google.com>
2020-04-22 00:23:49 +00:00
David Neto 50e738eca4 [spirv-reader] Test loop block order + nesting
Bug: tint:3
Change-Id: I97915d8e30c1676e1c1340217c5eb732c44f8ef0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20067
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 8e8c291db1 [spirv-reader] Test loop block order
Change-Id: If33d37d2813b1b1e584972d4da7aadbcb345d12f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20066
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto b5d518b68b [spirv-reader] Test block order dup cases
- 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>
2020-04-21 17:44:44 +00:00
David Neto f6def6d572 [spirv-reader] Test nested if, switch
Bug: tint:3
Change-Id: I7b84523b765bd51ea7a65dc2de396a14b80fcc62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20044
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 9cba3e1850 [spirv-reader] Split arithmetic, bit tests
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>
2020-04-21 17:44:44 +00:00
David Neto 6235caaae4 [spirv-reader] Test block order with Kill, Unreachable
Bug: tint:3
Change-Id: Ic8627ca3449ddc7f6abf248b0a461cfbafe77819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20041
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-21 17:44:44 +00:00
David Neto 571eea5a1a [spirv-reader] Compute basic block order
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>
2020-04-21 17:44:44 +00:00
dan sinclair d3d1230062 Add name to GLSL error message
Change-Id: I03b71d81d4975512d57f7383123689e57eba7735
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20065
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:37:23 +00:00
dan sinclair 7025918287 Cleanup some error messages.
This CL makes it clearer where errors are coming from and fixes the
source information on a few type determiner error messages.

Change-Id: I356518ac3004effe005bb7dea147c7fe442ab1a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20063
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:05:42 +00:00
dan sinclair aac5865121 Fixup single element swizzle type determination.
For a swizzle with one element (eg vec.x) the result type is just the
type of the vector, instead of a new vector.

Change-Id: I04ddb22da61db1c3553d465e4e5f9d6b32beae83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20062
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:05:34 +00:00
dan sinclair 54444382a6 Add GLSL distance support.
This CL adds support for the GLSL distance command.

Bug: tint:5
Change-Id: I0934d461ca6d4fca379849d8f41a33fb202c67ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20060
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 13:04:15 +00:00