Commit Graph

1685 Commits

Author SHA1 Message Date
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
Ryan Harrison 7d60a4c544 Fix nit in PRESUBMIT.py
Change-Id: Icc197948e387a75a05ca92f918b0b459e3c8d01f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22583
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-03 16:12:09 +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
Ryan Harrison e76f4dac06 Adding PRESUBMIT.py with a bunch of checks turned on
This CL does not retroactively fix violations of the checks, so as new
code is added unrelated failures may appear from older code in the same
file.

Removed the headers= line from CPPLINT.cfg, since it was adding an
extension,.hpp, that we don't use for headers and it is not supported on
all platforms.

BUG=tint:1

Change-Id: I9b2d096cf6c69d1456c857a2fdcd7e7da3fd747b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22544
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-06-03 13:41:41 +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