Commit Graph

1446 Commits

Author SHA1 Message Date
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
dan sinclair 2ee4a7e0c9 Add Remaining 2 parameter GLSL float methods.
This CL adds conversions for the remaining GLSL methods which accept
two float parameters.

Bug: tint:5
Change-Id: I545567f67baaae62d5a85d3d7cacc64571d7a8e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20020
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 12:58:35 +00:00
dan sinclair 37d62c9291 Add GLSL Atan2 support.
This CL adds support for the Atan2 GLSL command.

Bug: tint:5
Change-Id: I724e94ffb6d93136a9976b4949320f60075618ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19961
Reviewed-by: David Neto <dneto@google.com>
2020-04-21 12:55:06 +00:00
David Neto 90bbafa125 [spirv-reader] Fix build
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>
2020-04-20 22:09:26 +00:00
dan sinclair 652a4b9871 Add support for GLSL length.
This CL adds support for the GLSL length command.

Bug: tint:5
Change-Id: I2704bc04e493fb3aef8e5cd58039b6b863cc80f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20001
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 21:09:14 +00:00
David Neto 89af8a23cc [spirv-reader] Add OpBitcast
Bug: tint:3
Change-Id: I51f4521edeacf9e7c4d8dbf4a1832295b1705550
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19886
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 21:06:43 +00:00
David Neto b4c49680b5 [spirv-reader] Add OpNot
Bug: tint:3
Change-Id: I4fe2f7ba0e8597ac5bed1e4817e3ccc38dc06a82
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19885
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 21:06:43 +00:00
David Neto 00feb1ca60 [spirv-reader] Add OpLogicalNot
Bug: tint:3
Change-Id: I5565133c47a34be3ed9e10b97aa5dfca0eace502
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19884
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 21:06:43 +00:00
David Neto 6eb498d669 [spirv-reader] Add OpFNegate
Bug: tint:3
Change-Id: I081df8fd37750917ae15667954d1b3fabb799010
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19883
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 21:06:43 +00:00
David Neto 6584028bb4 [spirv-reader] Add OpSNegate
Bug: tint:3
Change-Id: Id396319dd32216a71e21464d41bb2f2545929207
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19882
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 21:06:43 +00:00
David Neto e150e0f13e [spirv-reader] Test OpSMod
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>
2020-04-20 21:06:43 +00:00
David Neto 4f10a256d5 [spirv-reader] Fix OpSDiv operand and result signedness
(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>
2020-04-20 21:06:43 +00:00
David Neto b572d53bf2 [spirv-reader] Internally, generate typed expressions
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>
2020-04-20 21:06:43 +00:00
David Neto 53b5730dfc [ast] Avoid useless empty check
Change-Id: I7c12b78dc06e13becc45c3df7c23929d1fa6a86c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20000
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-20 18:36:29 +00:00
dan sinclair 3df2044e36 Add GLSL normalize method.
This CL adds type determinater support for Normalize.

Bug: tint:5
Change-Id: Idbea41942172f8404122b7a756ccf1ec5aad2af8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19950
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:51:18 +00:00
dan sinclair a49328f60e Add support for GLSL exp, exp2, log, log2, sqrt and inversesqrt
This CL adds type determiner support for the Exp, Exp2, Log, Log2, Sqrt
and InverseSqrt GLSL methods.

Bug: tint:5
Change-Id: I3b9e799a8ebe5e8c96c1daf07131feae40e0c54e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19949
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:49:50 +00:00
dan sinclair 132b2daa19 Add GLSL trig methods.
This CL adds support for the GLSL trig functions.
 * sin
 * cos
 * tan
 * asin
 * acos
 * atan
 * sinh
 * cosh
 * tanh
 * asinh
 * acosh
 * atanh

Bug: tint:5
Change-Id: I38c8bf45c3aeeef81711de3a3eca6a9339af146c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19948
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:49:43 +00:00
dan sinclair b90a56fb66 Add GLSL Radians and Degrees methods.
This CL adds support to the type determiner for the GLSL Radians and
Degrees methods. We use the general float calls for this because we only
support FP32 and have plans for FP16. Other floating point sizes are not
supported but we have no support for them..

Bug: tint:5
Change-Id: I38f0551ce5f9ed7dd31496f13880697cd1f21ba4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19947
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:49:33 +00:00
dan sinclair 7b55da5f80 Add GLSL Fract support.
This CL adds Fract into the type determiner.

Bug: tint:5
Change-Id: I616d3259ca903b82339f49317f27966265c3f1d5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19946
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:49:07 +00:00
dan sinclair f1c7f0c779 Add GLSL Ceil support.
This CL adds Ceil support to the type determiner

Bug: tint:5
Change-Id: Iba785dbea412cc94f9b0faa3e6d38f02453d5215
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19945
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:48:56 +00:00
dan sinclair d0f0edf8b6 Add GLSL Floor support.
This CL adds Floor into the type determination

Bug: tint:5
Change-Id: I2b9013e073458fbe9f8a9ff657582a715f91c480
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19944
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:48:26 +00:00
dan sinclair e9661fbe9b Add GLSL FSign support
This CL adds FSign to the type determination.

Bug: tint:5
Change-Id: I8e3a7e94f367c4aaa510e72f774097946382a968
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19943
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:48:20 +00:00
dan sinclair de50e5298d Add GLSL FAbs support
This CL adds FAbs to the type determinator.

Bug: tint:5
Change-Id: I9793f5d469eb5a70f2a024c325e098ed9ca8ea7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19942
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:48:13 +00:00
dan sinclair fa5a66f192 Add GLSL Trunc support.
This CL adds type determination for the Trunc method.

Bug: tint:5
Change-Id: I4f23dad7725f1f076fbbc7da8687de42a02cc482
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19941
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:48:03 +00:00
dan sinclair ca1723e990 Add GLSL RoundEven support
This CL adds support for the GLSL RoundEven command in type
determination.

Bug: tint:5
Change-Id: I956ea9532785a42fe51a24b5121ce47cfbc78242
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19940
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:47:55 +00:00
dan sinclair fd5d4ca16c [spirv-writer] Add preliminary support for GLSL methods
This CL adds the type determination and builder code to support
outputting the GLSL Round call.

Bug: tint:5
Change-Id: I84dadebaf19aee3361fb13b5f32ce1a9f1b0c421
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19923
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:46:18 +00:00
dan sinclair d4d87edc85 Fixup merge conflict.
Change-Id: I4f04677b1c9a4a29157d2940352042802ef88979
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19960
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 15:21:21 +00:00
dan sinclair 50714622b4 Cleanup IdentifierExpression API.
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>
2020-04-20 14:21:00 +00:00
dan sinclair b950e80a59 [type-determiner] Move ast::Module to constructor.
This CL moves the ast::Module to be provided to the type determiner
constructor so we can access it for things like the imports.

Change-Id: I110fffe669a8a007461bf84d30d85d70405e37be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19761
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:20:01 +00:00
dan sinclair cd077b01a9 Add module to the type determiner test helper
This CL updates the type determiner test helper to have a ast::Module
and updates all tests to use the module. The tests have all be updated
to consistently use the type determiner provided by the helper as well.

Change-Id: If47a873c439e5a5019e21679cba957d4c762f4e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19780
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:19:04 +00:00
dan sinclair ccb52dc547 [type-determiner] Determine call parameter types.
This CL adds type determination for the call parameters.

Bug: tint:5
Change-Id: I488718bd7a4c1f2304a1c17554b8354d184dc159
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19760
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:18:54 +00:00
dan sinclair 6ad9f5d1ed [spirv-writer] Move module to SPIR-V builder constructor
This CL moves the ast::Module to the constructor of the SPIR-V builder
class. This allows access to things like the ast::Import from the
builder class.

Bug: tint:5
Change-Id: I0d61b164c1274d006e124dde2cc11f41a2385fc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19922
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:18:44 +00:00
dan sinclair c954788b59 Move type methods to type class
This CL moves the checks for different types into the type class so it
can be used in both the type determinater and the SPIR-V builder.

Change-Id: I9142adaf5fc1d6048792645d7892f8d8900fcf59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19921
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:07:43 +00:00
dan sinclair 6866cb7677 [spirv-writer] Add initial loop support.
This CL adds the initial generation of a loop construct into the
spirv-writer. This does not support break or continue yet.

Bug: tint:5
Change-Id: I41f5d9b634a1a4120f880c4143feacc7e58e2147
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19620
Reviewed-by: David Neto <dneto@google.com>
2020-04-20 14:07:29 +00:00
David Neto 340a51e787 Add required overrides for virtual destructors
Fixes build on macOS

TBR=rharrison@google.com

Change-Id: I22e463b76074b499187a472649c46ef1b17c77cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19880
Reviewed-by: David Neto <dneto@google.com>
2020-04-17 15:52:49 +00:00
Ryan Harrison 0a196c13c8 Adding support for testing BUILD.gn
BUG=tint:50

Change-Id: Ie19a1af6a97a49a67dcc7474991c960b986ddebe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19782
Reviewed-by: David Neto <dneto@google.com>
2020-04-17 13:18:20 +00:00
dan sinclair 366b74c364 [spirv-writer] Add binary multiplication.
This CL adds binary multiplication generation to the SPIR-V writer.

Bug: tint:5
Change-Id: I668d24035e947c51a9737549fd0841a4e8af1331
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19700
Reviewed-by: David Neto <dneto@google.com>
2020-04-16 14:14:11 +00:00
Ryan Harrison 460345d993 Add support for WGSL writing to BUILD.gn
BUG=tint:49

Change-Id: I4473176d4177a719b7b2659f765b6b467ac43c84
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19682
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 20:54:10 +00:00
Ryan Harrison 0caab67e6e Add support for WGSL reading to BUILD.gn
BUG=tint:47

Change-Id: Ic50421f4dc712c614cf5783027ba273b53b2bd83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19681
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 20:47:55 +00:00
Ryan Harrison 2b45a52cdf Add support for SPIRV writing to BUILD.gn
BUG=tint:48

Change-Id: I6b92bb372b783ad4498fdc4817d0893851b0bb90
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19680
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 20:37:02 +00:00
Ryan Harrison d1cf8a8ba5 Add support for SPIRV reading to BUILD.gn
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>
2020-04-15 20:35:38 +00:00
David Neto ac3213b4ad [spirv-reader] Add UMod, SMod, FMod
Bug: tint:3
Change-Id: Idd0e5bbc51e05782d3f918e4ffeb83eab52d87d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19565
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 14:02:37 +00:00
David Neto badf99be5d [spirv-reader] Add ISub, IMul, UDiv, SDiv
Bug: tint:3
Change-Id: Id2c9d91742f8bdc712d2dfbda5f4883379a29470
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19564
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 14:00:57 +00:00
David Neto d4c8ab967b [spirv-reader] Add FOrdEqual, FOrdNotEqual
Unordered equality and inequality is not yet in WGSL
https://github.com/gpuweb/gpuweb/issues/706

Bug: tint:3
Change-Id: I45761ee490829f180110c578283bf136a185de9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19563
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 13:59:31 +00:00
David Neto da0a4e9c91 [spirv-reader] Add logical and, logical or
Bug: tint:3
Change-Id: Ia2bde9644a8e3cdd5871570354a380f968760711
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19562
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 13:58:17 +00:00
David Neto fae8368dfe [spirv-reader] Add bitwise operators
Bug: tint:3
Change-Id: I4ebaafcf2a234dd6c217241f0fb0dd6ee5684a7a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19561
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-15 13:57:20 +00:00
David Neto 641208c2b1 [spirv-reader] Add shift operators
Bug: tint:3
Change-Id: I96ba69d35b072712f8c912fd258bca1f32ab5482
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19560
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 21:02:17 +00:00
David Neto 11d9ac1ee1 [spirv-reader] Add INotEqual
Bug: tint:3
Change-Id: I5de89c15dfdcab1b454e2698244f51b0e2deb4ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19541
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 20:56:14 +00:00
David Neto bd2965858a [spirv-reader] Support OpIEqual
Bug: tint:3
Change-Id: I8d87711dcc0ffd1de3cd4a4874a8bf225c676b30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19540
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 20:56:07 +00:00
dan sinclair dc48af981a [spirv-writer] Add shift operators.
This CL adds generation for the OpShiftLeftLogical, OpShiftRightLogical
and OpShiftRightArithmetic expressions.

Bug: tint:5
Change-Id: I3436453350fc9afd3528b1ae238682b7abc6d636
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19508
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 20:48:42 +00:00
dan sinclair 87a3f86155 [spirv-writer] Add divide generation.
This CL adds generation for the OpFDiv, OpSDiv and OpUDiv SPIR-V
instructions.

Bug: tint:5
Change-Id: I9fd875f453dd71857b192a2dad56149bae52caf5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19507
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 20:32:20 +00:00
dan sinclair e7c23721b9 [spirv-writer] Add modulo generation.
This CL adds support for generating the OpSMod, OpUMod and OpFMod SPIR-V
instructions.

Bug: tint:5
Change-Id: I9e2183535ba24a2d0bb4257dd797a62151fe04a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19506
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 20:32:14 +00:00
dan sinclair 35c0d4bbe1 [spirv-writer] Add subtracting generation.
This CL adds generation of the OpFSub and OpISub SPIR-V commands from
the subtraction binary expression.

Bug: tint:5
Change-Id: Ia25a855a972057a4cac70d538946e176e0a0e5c3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19505
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 20:32:07 +00:00
dan sinclair 266a32954e Cleanup lint errors.
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>
2020-04-14 18:16:08 +00:00
dan sinclair f963128c88 [spirv-writer] Add elseif support.
This CL adds support for having elseif statements after an if statement.

Bug: tint:5
Change-Id: I3cd3c5bddaa57c998b1a3fbee7bd87536533301d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19500
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 16:53:27 +00:00
dan sinclair 631a7ac72b [spirv-writer] Add else support.
This CL adds the start of support for else statements.

Bug: tint:5
Change-Id: I742fd4582bfee4f31715b94b7aea6cf8383f4e22
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19412
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 16:47:12 +00:00
dan sinclair 79448a34a0 [spirv-writer] Simple if statements.
This CL adds the code to generate simple if statements.

Bug: tint:5
Change-Id: Ied42ad8b3632d7926ac646d1aa21e190a7a2c07e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19411
Reviewed-by: David Neto <dneto@google.com>
2020-04-14 16:40:30 +00:00
David Neto 74d97e7282 [spirv-reader] Add FDiv
Change-Id: Ie24bb91276340afd77009165af471ce0f53cca39
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19503
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 16:27:26 +00:00
David Neto 5ef27afbfb [spirv-reader] Add FMul
Bug: tint:3
Change-Id: I2f7f9f451889d394b22bc297d511ee5fe92b7a85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19502
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 16:27:01 +00:00
David Neto 31d9036769 [spirv-reader] Add FSub
Bug: tint:3
Change-Id: I6e79e19bf5feb9e0223d770f718a0d0bd9b5b147
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19501
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 16:26:29 +00:00
David Neto 79797490d8 [spirv-reader] Support OpFAdd
Bug: tint:3
Change-Id: I22a6ff13d3777544101fa8334d598e5a2524caec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19223
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 16:16:09 +00:00
dan sinclair a51d697f8c [spirv-writer] Handle output of bitwise xor.
This CL adds bitwise xor support to the spirv writer.

Bug: tint:5
Change-Id: I011283ef12840d25c882b95fc664f2b0dc6003da
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19410
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:04:22 +00:00
dan sinclair 2de7cb978d [spirv-writer] Handle bitwise or expression.
This CL adds output of the bitwise or command.

Bug: tint:5
Change-Id: Iad9bafaa0a8394494615922c14c2d33d2d5701bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19409
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:04:11 +00:00
dan sinclair f95862b806 [spirv-writer] Handle binary and expression.
This CL updates the binary expression to handle the bitwise and command.

Bug: tint:5
Change-Id: I64d53d6aaa1de2fd9ec7959bf084f30736146d78
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19408
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:04:03 +00:00
dan sinclair f558809b54 [spirv-writer] Add binary greater than equal comparison.
This CL adds generation for the binary greater than or equal comparison.

Bug: tint:5
Change-Id: I5c81b7d142d29f388800d8b576ec69dc260b243e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19407
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:55 +00:00
dan sinclair d7e2add6f3 [spirv-writer] Add binary less than equal.
This CL adds generation for the less than equal binary operator.

Bug: tint:5
Change-Id: Ic9d0eb107079c29b2ca1b0eb088e3b2eb7531e1e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19406
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:47 +00:00
dan sinclair 6b9587b697 [spirv-writer] Add binary greater than comparison.
This CL adds the binary greater then comparison output.

Bug: tint:5
Change-Id: I86fa90b3d98f3ee81174edafb188c445b94f9d29
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19405
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:39 +00:00
dan sinclair f30c212987 [spirv-writer] Add binary less than comparison
This CL adds support for the less than comparison operator.

Bug: tint:5
Change-Id: Ibfca48652ff0817bacd2badca183cb87f8c8ed31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19404
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:31 +00:00
dan sinclair 0d0d0b290d [spirv-writer] Add binary not equal.
This CL adds support for the not equal comparison.

Bug: tint:5
Change-Id: Idb91a02b546e49d67d6dc8570c754e611643a1f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19403
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:24 +00:00
dan sinclair 07aead8570 [spirv-writer] Adding binary equals generation
This CL adds generation for a == operator.

Bug: tint:5
Change-Id: Ib27836a42153f3732927234cfa9aed342d0f9ac1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19402
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 15:03:13 +00:00
dan sinclair e9e925d0a0 [spirv-writer] Convert binary tests to parameterized.
This CL changes the binary tests to be paramaterized to make it easier
to add more tests.

Bug: tint:5
Change-Id: Ib4edb3c368c0cba3252dd139841dd5f1be4bc34c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19401
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-14 14:47:10 +00:00
dan sinclair a28bcceb15 Remove premerge.
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>
2020-04-14 14:46:58 +00:00
dan sinclair efb5d4e10f Remove regardless.
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>
2020-04-14 14:46:51 +00:00
David Neto 2a3e79cf8c [spirv-reader] Store to module-scope variables
Bug: tint:3
Change-Id: Ib4dbb976268999529c2a1c55531aa8293e565b9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19222
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-14 14:23:59 +00:00
dan sinclair b39dabd0cd Run formatter
TBR=dneto@google.com

Change-Id: Idccbc5eeec6d763cdacd8d050bb396a0c897c7ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19400
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-12 19:47:16 +00:00
dan sinclair fa3944c3dd [spirv-writer] Add simple identifier support.
This Cl adds the start of issuing loads for IdentifierExpressions. This
does not handle the more complicated cases around pointers and
OpAccessChain yet.

Bug: tint:5
Change-Id: Ic858a7d9200399e3066ca92cd5c130bbe527de76
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19100
Reviewed-by: David Neto <dneto@google.com>
2020-04-12 18:21:59 +00:00
David Neto 3743c5ee65 [spirv-reader] Support IAdd
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>
2020-04-09 20:45:31 +00:00
Ryan Harrison 4d32be4f1b Remove suppressing [chromium-style] errors
Lots of little style nits needed to be fixed for this work.

BUG=tint:44

Change-Id: Ibb45d9e3f6795ee0c09f5eca994bb28e20979d97
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19221
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-09 18:52:06 +00:00
David Neto 1234633b32 [spirv-reader] Handle OpLoad
Bug: tint:3
Change-Id: I25fdf086e49426240a771b70306b417cd8012777
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19140
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-09 13:29:17 +00:00
David Neto a1a86007c9 [spirv-reader] Emit stores
Bug: tint:3
Change-Id: Ibda57e58ac13abb650eb0f3e01adbd40b439a82b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19120
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 20:06:26 +00:00
dan sinclair 7456f4258a Better type determiner errors.
This CL adds the source info into the type determiner errors so they
will include line and column number if available. If the line number is
0 then it's considered the source info is missing and it is not emitted.

Add line and colummn to type determiner errors

Change-Id: I18764a71db80082fd31c8509c5e9b193800f1d95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19105
Reviewed-by: David Neto <dneto@google.com>
2020-04-08 19:58:35 +00:00
dan sinclair d5dea224e0 Convert vectors to list aliases
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>
2020-04-08 19:58:28 +00:00
dan sinclair ee8ae04472 Set function storage class in type determiner.
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>
2020-04-08 19:58:20 +00:00
dan sinclair 719bfe01bf [spirv-writer] Add relational add
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>
2020-04-08 17:18:20 +00:00
David Neto 2c60b4c2cc [spirv-reader] use Function storage class on function vars
Change-Id: I22c76ea8bce7d050411b9dd0e283abe1dae8bc6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19101
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 17:18:07 +00:00
David Neto d877e8b084 [spirv-reader] Start emitting expression
Bug: tint:3
Change-Id: I2e2fe41c43abbcbbc941968c0115d703f6bff501
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18822
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 14:24:18 +00:00
David Neto ec322349e2 [spirv-reader] Emit module-scope var initializers
Bug: tint:3
Change-Id: Ifadd7616945e2392d6705746b295448a21366b0f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18821
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 14:24:06 +00:00
David Neto 4194d0f948 [spirv-reader] Emit function variable initializers
Bug: tint:3
Change-Id: I1c7fa2c282e6dd95ea048df83f608d4462150394
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18820
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 14:23:42 +00:00
David Neto 4fa1ceb094 [spirv-reader] Emit function vars, no initializers
Bug: tint:3
Change-Id: I64a4a2c675e5440766ffc814867e6cf247d14c13
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18706
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-07 20:25:03 +00:00
David Neto 753cdc75c4 [spirv-reader] Test EmitFunctionDeclaration
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>
2020-04-07 19:56:02 +00:00
David Neto 574bce6746 [spirv-reader] Split function emission into parts
Bug: tint:3
Change-Id: Ifedf4e00c7d89641496330ab20bf797f656c761c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18703
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-07 19:55:54 +00:00
David Neto e70e10953b [spirv-reader] Refactor function emission
Create a FunctionEmitter class.
Move ParserImpl::Name to Namer::Name, and add tests.

Bug: tint:3
Change-Id: I271e8c75f6f5a0edf9d94fe0a4af5a022afac708
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18702
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-07 19:54:52 +00:00
dan sinclair cd543df18d Add missing memory include
Change-Id: Icab0d32f199d4b0f95e2c1ebcd9ae9ea9ec7b61c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19020
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-04-07 19:42:40 +00:00
dan sinclair 0e9d9ed60f Fill in some disabled tests
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>
2020-04-07 19:27:49 +00:00
dan sinclair 1c9b486d6e Rename RelationalExpression to BinaryExpression.
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>
2020-04-07 19:27:41 +00:00
dan sinclair 327ed1bf8a Add missing break, continue and return tests.
This CL adds tests for break, continue and return without attached
expressions.

Bug: tint:5
Change-Id: I8c4221e787af95f5597db3ea4e42b38962223bf4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18980
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-04-07 19:27:21 +00:00
dan sinclair 0e2576250a Add unary op expresison type determination.
This CL adds type determination for the unary op expression.

Bug: tint:5
Change-Id: I5b9c0c80bb48527f1f26febb2310f9640e5f7849
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18850
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 19:27:11 +00:00
dan sinclair 8dcfd108a9 Add type determination for unary method.
This CL adds the type determination for the unary method expression.

Bug: tint:5
Change-Id: I9f94a79b9715cf74e37c74eb1a612ca84b3c241f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18849
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 19:27:00 +00:00
dan sinclair b173056fca Add unary derivative type determination.
This Cl adds the type determination for unary derivative expressions.

Bug: tint:5
Change-Id: I44ad22733ce6b94e4b6d77b432024bacc110e8af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18848
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 19:26:49 +00:00
dan sinclair 9b97802d99 Add relational expression type determination.
This CL adds the type determination for each of the relation types in
the relational expression.

Bug: tint:5
Change-Id: I15e8dae2f90cc4a0f720692f5addb944b26811ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18847
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 19:26:39 +00:00
dan sinclair 8ee1d22882 Add type determination for member accessor.
This Cl adds the member accessor type determination for both structures
and vector swizzles.

Bug: tint:5
Change-Id: I1172db29d8cbed2d9e0ae228ebc3a818d4930b7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18846
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 16:41:33 +00:00
dan sinclair 4e8079544a Add cast expression type determination.
This CL adds the type determination for cast expressions.

Bug: tint:5
Change-Id: I35ae28e3b70c554cd48c6abcd78d95c2ba7211fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18845
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 16:41:23 +00:00
dan sinclair 3ca8746ebd Add type determination for call expressions.
This CL adds the type determination for call expressions.

Bug: tint:5
Change-Id: Ibe08f90ec3905dd1e2169f6e69d1d74943720819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18844
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 16:41:10 +00:00
dan sinclair a01777c2d9 Add type determination for as expression.
This CL adds the as expression type determination.

Bug: tint:5
Change-Id: I84a06df67844c75112c745f65a2c8102f8677f62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18843
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:57:52 +00:00
dan sinclair 973bd6a7b4 Add array accessor type determination.
This Cl adds type determination for an array accessor for arrays,
vectors and matrices.

Bug: tint:5
Change-Id: Ifce539338fd1f9b539c13970f115a4dbc207ff5a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18842
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:57:42 +00:00
dan sinclair cab0e73b31 Add type determination for IdentifierExpression.
This CL adds the type determination for identifier expressions.
Namespaced identifiers are not determined yet.

Bug: tint:5
Change-Id: Id8f39ad122cef0349393de4d429a6d971b2a7ce8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18841
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:57:27 +00:00
dan sinclair ca893e3200 This CL adds type determination for the variable declaration statements.
This Cl adds variable declaration type determination.

Bug: tint:5
Change-Id: I3dc19af470f9403dadc230f1bf2b597bb1fe4fee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18840
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:57:12 +00:00
dan sinclair 9a84e5eb47 Add type determination for the unless statement
This CL adds type determination for Unless statements.

Bug: tint:5
Change-Id: I0e8721d3c282ca8dcf9e7954f309c14e437b5272
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18839
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:56:57 +00:00
dan sinclair 18b3285b5b Add type determination for switch statements.
This CL adds the type determination code for the switch statements.

Bug: tint:5
Change-Id: I96efd96016c03137ef471e3f220e21e7f53d11ba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18838
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:56:45 +00:00
dan sinclair bf0fff8438 Add type determination for return statement.
This CL adds the type determination code for the return statements.

Bug: tint:5
Change-Id: I0300fe0c66e7b8c25d1dc0ed22aef8cc469567be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18837
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:56:24 +00:00
dan sinclair 45540b9dbd Add type determination for the regardless statement.
This CL adds the type determination code for the Regardless statement.

Bug: tint:5
Change-Id: I8485800f3e19130101917d8175e8111aa196828c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18836
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:56:08 +00:00
dan sinclair bc71edaab3 Add type determination for loop.
This CL adds the type determination for loop statements.

Bug: tint:5
Change-Id: If49cacb732e8911085657bac8b568e97ee801c82
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18835
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:55:51 +00:00
dan sinclair 91c44a5685 Add If statement type determination.
This CL adds the type determination code for if statements.

Bug: tint:5
Change-Id: Idfe4d62be56ffb7e8a8de197e8710ff119dd4368
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18834
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:55:25 +00:00
dan sinclair 1913fc9d3b Handle fallthrough, kill and nop in type determination.
These statements have no expressions to determine so they just return
true.

Bug: tint:5
Change-Id: I639bce9c254c12357ac3a1d2a9cfaaee437716c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18833
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:54:59 +00:00
dan sinclair 0cf685f728 Add else statement type determination.
This CL adds type determination for else statements.

Bug: tint:5
Change-Id: Ie859edbc08c191da0a04407c5f56b413a48f1791
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18832
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:54:37 +00:00
dan sinclair aec965e4a1 Add continue statement type determination.
This CL adds type determination for the continue statement.

Bug: tint:5
Change-Id: Ie63994146978d8783f131299b576fc46a10878ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18831
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:54:29 +00:00
dan sinclair 6010b29f65 Add case type determination
This CL adds type determination for case statements.

Bug: tint:5
Change-Id: I353232bd68a524a09de60fa73256b51d2be51c57
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18830
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:54:20 +00:00
dan sinclair b7ea6e2f72 Add break statement type determination.
This CL adds type determination for break statements.

Bug: tint:5
Change-Id: I5ca74a848ffd12fe404676910b08ea7518451eaf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18829
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:54:10 +00:00
dan sinclair 6c498fc0f8 Add assignment statement type determination.
This CL adds type determination for the assignment statements.

Bug: tint:5
Change-Id: Ica0e59a459bfedc0c649d279f93a31b188c27736
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18828
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:47:23 +00:00
dan sinclair b7edc4c765 Add type determination for constructors.
This CL adds type determination for the ScalarConstructorExpression and
TypeConstructorExpression.

Bug: tint:5
Change-Id: I46299140785eb420c3801de470d6423c25e9c700
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18827
Reviewed-by: David Neto <dneto@google.com>
2020-04-07 12:46:30 +00:00
dan sinclair 417a90d2ee Add stub definitions to the type determiner.
This adds enough infrastructure to type determiner to start building
out the statement and expression determination.

Bug: tint:5
Change-Id: I5e095cf652b5e3358e6fbabd66dd703348950857
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18826
Reviewed-by: David Neto <dneto@google.com>
2020-04-06 21:07:41 +00:00
dan sinclair d0479d22ea Add RelationalExpression helpers.
This CL adds helper methods to the RelationalExpression to determine the
type of relation.

Bug: tint:5
Change-Id: I232c3a2e9f27a7efb91735516ee7e9cfc97882ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18825
Reviewed-by: David Neto <dneto@google.com>
2020-04-06 19:55:33 +00:00
dan sinclair 3ffec80c63 Add list helpers
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>
2020-04-06 19:37:37 +00:00
dan sinclair a71e1a50c8 Add result_type into ast::Expression
This CL adds a result_type into the expression to hold the computed
result type for the expression.

Bug: tint:5
Change-Id: I5f2ee35e520f918828cf8cf7bc6fdf6a1b5ebd5f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18824
Reviewed-by: David Neto <dneto@google.com>
2020-04-06 18:44:09 +00:00
dan sinclair fa9dbf0dda Add type determiner infrastructure.
This CL adds the Context object, variable ScopeStack and a Function map
into the type determiner.

The sample app is also updated to verify the module produced before
passing to the type determiner.

Bug: tint:5
Change-Id: Ib4af4e4305ee8a306f48e1bd328eaf3ad006fd9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18823
Reviewed-by: David Neto <dneto@google.com>
2020-04-06 18:43:56 +00:00
Greg Roth 8229360312 Fix compiles on VS2017 and GCC
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>
2020-04-06 17:16:56 +00:00
David Neto a3c8944c18 Fix comment about function variables
Change-Id: Ic639b8f93140363ce273d06b6b052658ea2b1c27
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18705
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-06 14:56:33 +00:00
dan sinclair c2d97ae6c8 Move the variable stack to a common class.
This Cl extracts the variable stack from the SPIR-V builder and makes it
available as a general class.

Change-Id: I3505d7cc4ec34f78bbc3360b064fa99479fd97d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18701
Reviewed-by: David Neto <dneto@google.com>
2020-04-03 02:35:23 +00:00
David Neto 0e92735d25 ast::Variable is also used for formal parameters
Change-Id: Ie69fc400741fa9aadd0409eaf1aeb27762f17d0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18700
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-02 13:21:08 +00:00
David Neto afd66c9eed Clarify ast::Variable as both "var" and "const"
Describe the use of the term "type" in this class.

Change-Id: Iad41c9c49ff2145f278bf7e7a601da0e5492301c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17980
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-02 12:26:29 +00:00
David Neto cc39bae42c [spirv-reader] Fix SPIR-V assembly, re-enable test
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>
2020-04-02 03:22:53 +00:00
David Neto 3038e6ee36 [spirv-writer] Fix: need #include <functional>
TBR=dsinclair@google.com

Change-Id: I4b328ea1ab4532aacb4bcbdff2a99e2480a58071
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18603
Reviewed-by: David Neto <dneto@google.com>
2020-04-02 02:47:08 +00:00
dan sinclair cfe4f13b1b [spirv-writer] Add assignment statements
This Cl adds assignment statement generation to the SPIR-V writer.

Bug: tint:5
Change-Id: I17876c0211e4b4e061d39e08fc6a433098252f38
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18621
Reviewed-by: David Neto <dneto@google.com>
2020-04-02 02:41:30 +00:00
dan sinclair 66df06817f [spirv-reader] Fix copy elision
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>
2020-04-02 02:35:21 +00:00
dan sinclair 43178d016c [spirv-writer] Add identifier expressions
This Cl adds the code to convert an identifer expression into an ID.

Bug: tint:5
Change-Id: Id6cb08404f091fd4d89c3f7f9292c9de2eb4fa65
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18601
Reviewed-by: David Neto <dneto@google.com>
2020-04-01 23:44:11 +00:00
dan sinclair baaf989452 [spirv-writer] Add function variables
This Cl adds function variables to the SPIR-V output. This requires some
refactoring to split function instructions and variables apart in the
builder.

Bug: tint:5
Change-Id: I4d0045f5a02311cf9a2803929c66c648278e3734
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18600
Reviewed-by: David Neto <dneto@google.com>
2020-04-01 23:40:53 +00:00
David Neto 790b2f6b32 [spirv-reader] Start adding functions
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>
2020-04-01 21:21:21 +00:00
David Neto 84f70c0a90 [spirv-reader] Emit module-scope builtin vars
Bug: tint:3
Change-Id: I47ed2e9ed97fd7c45a5aa060a9a6aeaca88092cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18500
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-01 17:56:18 +00:00
David Neto e0bcb544ac [spirv-reader] Convert builtin enums
Bug: tint:3
Change-Id: I1d94daab782e6e576f4b5a1c7c8816074d3ff307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18480
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-01 17:56:05 +00:00
David Neto 06faf3bd5b [spirv-reader] Emit module-scope variables
Bug: tint:3
Change-Id: I54f35022c86d6c8df635bf86cc7bf39327674f6e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18460
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-01 17:55:57 +00:00
David Neto 269a2c6a91 [spirv-reader] Convert pointer type
Bug: tint:3
Change-Id: Ibba1472a1aa3f1399e9596ee6662a29121d88eca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18420
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-01 13:22:34 +00:00
dan sinclair 73e1ef825e [spirv-writer] Fix global constant emitting
This CL fixes the emitting of global constants to use the correct
`OpConstantComposite` call when adding to the types section. A TODO is
added to generate `OpCompositeConstruct` when we need to generate
initializers inside functions.

Bug: tint:5
Change-Id: I1bbf6c68e21b546d6a643b4c99c7d2c9317bfcbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18440
Reviewed-by: David Neto <dneto@google.com>
2020-03-31 21:15:51 +00:00
dan sinclair a085c7bbe2 Documentation fixes
Change-Id: I8359c402819ed475663385b3bd850f0ae209cdf4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18421
Reviewed-by: David Neto <dneto@google.com>
2020-03-31 21:15:40 +00:00
David Neto 0534957e78 [spirv-reader] Convert storage class
Bug: tint:3
Change-Id: Ifb543228a6b32f9afb6c61718a168a0bca4aed14
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18402
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-31 20:15:55 +00:00
David Neto a7640d6d4c [spir-reader] Emit alias types (named types)
Bug: tint:3
Change-Id: I4882160d9fe533d956f29ca15e65bf99eb80f5df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18360
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-31 20:02:36 +00:00
dan sinclair 4493d13d49 Fixup shorten64-to-32 warning
Change-Id: I2995d11693f6f49f67b7d3a11dde8e3fdc8dc549
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18401
Reviewed-by: David Neto <dneto@google.com>
2020-03-31 17:45:41 +00:00
dan sinclair e49bd5eeb4 Rename VariableStatement to VariableDeclStatement.
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>
2020-03-30 22:46:48 +00:00
dan sinclair a322f5ddfa Update initializer names.
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>
2020-03-30 22:46:06 +00:00
David Neto e68c9b4075 [spirv-reader] Convert struct types
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>
2020-03-30 21:14:28 +00:00
David Neto 4da4c696e2 [spirv-reader] Get decorations
Bug: tint:3
Change-Id: Idfd49c5bfc8629c17f42f954d65c881865548b8a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18140
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-30 21:09:59 +00:00
dan sinclair 8ae34868cf [spirv-writer] Generate return statements
This CL adds the code to generate OpReturn and OpReturnValue statements.

Bug: tint:5
Change-Id: Ia4e4f6eb3f8b182be0caea88147d23fe4b6e341c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18300
Reviewed-by: David Neto <dneto@google.com>
2020-03-30 20:03:24 +00:00
dan sinclair 5cd08fd72a [spirv-writer] Add initializer generation.
This CL adds generation for the ConstInitializer and TypeInitializer
expression. The global variable method has been extended to output the
constant and variable initializers.

Bug: tint:5
Change-Id: I2b3783d0e5a8bbf7a6aba9cf6e154910568bdb5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18241
Reviewed-by: David Neto <dneto@google.com>
2020-03-30 20:01:38 +00:00
David Neto b020cd900e [wgsl-writer] Restore huggie-style braces
Change-Id: Ieec33cccbfeb2589d1292103001f0de5267e02bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18040
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-30 19:56:59 +00:00
dan sinclair 15cbc98a8c [spirv-writer] Start global variable output
This CL starts adding global variable output to the SPIR-V writer. This
does not handle constants or initializers at this point.

Bug: tint:5
Change-Id: Id06533b2ec1f61feadf66f3e43a484f6f3765546
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17922
Reviewed-by: David Neto <dneto@google.com>
2020-03-30 19:49:01 +00:00
David Neto 5556b4acdd ast::Literal constructor is explicit
Fixes a lint issue

Change-Id: I98225fe5bf966c6fbf9b3b0c88e3d4dcc6a91cca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18041
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-28 00:44:50 +00:00
David Neto a8bcec3ac1 [spirv-reader] Add TODO for ArrayStride
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>
2020-03-27 21:11:05 +00:00
David Neto 48442a6cee Fix compilation errors
Change-Id: I4cb46d93559089894d8cecb4ff24b87d208b0f85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18021
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 17:20:20 +00:00
dan sinclair 136fa11d53 Fixup compilation issues with type manager.
This CL fixes up some issues with the type manager.

TBR=dneto@google.com

Change-Id: I2d05935f26490fd8d20b1b6b1b61692a45e4a0f3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17940
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-27 01:50:13 +00:00
David Neto 288674904d [reader-spirv] Convert array, runtime array types
Bug: tint:3
Change-Id: If0d7d38cc777bce3d86dfd83669c1572331d4ed6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17800
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-27 00:49:03 +00:00
David Neto a8cd18e9e7 Context object owns a TypeManager
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>
2020-03-27 00:47:16 +00:00
dan sinclair 20145170fc [spirv-writer] Generate pointer types
This CL adds the type generation for OpTypePointer.

Bug: tint:5
Change-Id: I9cfe6c4fbd9173df925421f278abd1afbda50fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17840
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 00:47:03 +00:00
dan sinclair 083def41c0 [spirv-writer] Add array type generation.
This CL adds generation of OpTypeArray and OpTypeRuntimeArray to the
SPIR-V writer.

Bug: tint:5
Change-Id: If3764ddb2499b8a196039521b8d9f80842626bcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17821
Reviewed-by: David Neto <dneto@google.com>
2020-03-27 00:46:43 +00:00
dan sinclair 113fb07071 [spirv-writer] Generate constants
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>
2020-03-27 00:45:34 +00:00
dan sinclair bf46de42ad [spirv-writer] Emit struct names
This CL changes the struct generation to emit the `OpName` for the
struct instead of doing it in a separate type alias pass. The struct
name was the only thing that needed to be output in the type alias pass
and this makes sure it's only emitted if used.

Bug: tint:5
Change-Id: I7389a3cd61812171fceeaae99253610152aa523d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17860
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-03-26 15:49:06 +00:00
dan sinclair 989cee6d33 Move tests into anonymous namespace.
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>
2020-03-26 15:31:43 +00:00
dan sinclair f26d9a8f26 Cleanup doc and lint warnings.
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>
2020-03-26 15:31:36 +00:00
dan sinclair 33d34650e8 [spirv-writer] Emit function signatures.
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>
2020-03-25 19:43:20 +00:00
dan sinclair 9981b63fa4 Use a context object instead of a singleton
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>
2020-03-25 19:16:36 +00:00
dan sinclair 0984214d8b [wgsl-writer] Add statement writer helper.
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>
2020-03-25 18:54:01 +00:00
dan sinclair 235ceebe37 Add type manager synchronization comment.
This Cl adds a comment about the type manager being a singleton and
synchronization requirements.

Change-Id: I91618516b26c18aa6b47e7e564b4b3a8eecc1009
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17740
Reviewed-by: David Neto <dneto@google.com>
2020-03-25 15:56:43 +00:00
David Neto 5e6d033a9e [reader-spirv] Convert vector, matrix types
Bug: tint:3
Change-Id: I4857d36da65fce7a413258f33d7dc4f3d9501c9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17702
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-25 14:33:45 +00:00
David Neto 71e1d81654 Add reader::spirv::ParserImpl::ConvertType
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>
2020-03-24 21:42:16 +00:00
dan sinclair 69b9c1b8e0 [spirv-writer] Generate struct types
This CL adds generation of Struct types to the SPIR-V writer.

Bug: tint:5
Change-Id: Ibcabf7b1a688026297de682f4825d5195d8007d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17701
Reviewed-by: David Neto <dneto@google.com>
2020-03-24 21:40:10 +00:00
David Neto 6cd52e30ef Fix typo
Change-Id: Ic5845cff3e6e708ce88670f3d6038e339a94f33e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17660
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-24 19:55:29 +00:00
dan sinclair 7a480f4313 [spirv-writer] Start emitting types
This CL starts the emitting of SPIR-V types. This CL adds code to emit
the `AliasType`, `BoolType`, `F32Type`, `I32Type`, `MatrixType`,
`U32Type`, `VectorType` and `VoidType`.

Bug: tint:5
Change-Id: Ic13026ca9006fc0a253d019b1a6dd984ae992fba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17561
Reviewed-by: David Neto <dneto@google.com>
2020-03-24 15:03:29 +00:00
David Neto 7c6e8ded7d reader::spirv: Fix entry point test fixture name
Bug: tint:3
Change-Id: Ie7cd4f4f45b7be527b8d38a3dd76fac860a65ad8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17563
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-03-24 14:39:02 +00:00
David Neto a65ea31910 reader::spirv fix entry point tests
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>
2020-03-24 12:46:20 +00:00
David Neto a14fec951e readers::spirv: Emit entry points
Bug: tint:3
Change-Id: I66b99ad6ecb3f409f9df7bfa9aa6c4da65e3f66b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17582
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 22:54:36 +00:00
David Neto 14cfcd707d Add conversion of SpvExecutionModel
Bug: tint:3
Change-Id: I2b1a12beea9343ab3a8db50308e2f6fd790c654b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17581
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 22:53:42 +00:00
David Neto 1ae8e85144 reader::spirv::Parser: register user names
Bug: tint:3
Change-Id: I4391aa733079d24fb19ff2cba9f612406e63a203
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17580
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 21:40:23 +00:00
dan sinclair dc200f7d1d Add SPIR-V dump to the SPIR-V generator
This Cl adds utility classes to dump out SPIR-V disassembly of the
builder and instructions.

Bug: tint:5
Change-Id: Ib4c57025ac63cb0be456bd819461c98ffa94367f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17560
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 20:59:12 +00:00
dan sinclair 781a4acb6f Generate errors from the SPIR-V builder.
This Cl adds error messages into the SPIR-V generator.

Bug: tint:5
Change-Id: I45c0d286dd8ec251773ff5e036322090647d780c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17521
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 20:07:34 +00:00
dan sinclair 248170ae44 Generate entry point instructions in SPIR-V writer.
This CL updates the SPIR-V generator to create entry point instructions.

Bug: tint:5
Change-Id: I04394bd508c0871ae9563cc811b4e49e42c2bb3a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17322
Reviewed-by: David Neto <dneto@google.com>
2020-03-23 18:08:41 +00:00
David Neto 23dceb46fc Add reader::spv::ResolveMemberNamesForStruct
Bug: tint:3
Change-Id: If778e98416c19c518261c68d4afdfdc99724967f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17440
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:48:03 +00:00
David Neto ad90ee2ec3 Add reader::spirv:SuggestSanitizedMemberName
Also reader::spirv::GetMemberName

Bug: tint:3
Change-Id: I4cf2dce0703eb17a9d49452294ed0c28ea158a07
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17423
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:45:57 +00:00
David Neto ca8e6dd48d Add reader::spv::SuggestSanitizedName
Bug: tint:3
Change-Id: Ie53bbb7a0b2523a2098b485b6a5bb3d5fa4e52f9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17422
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:45:01 +00:00
David Neto 8af12f7503 Add reader::spv::Namer::FindUnusedDerivedName
Bug: tint:3
Change-Id: I0a0e5646d7bcdc89fdaaf8b956dd61ed6148c7e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17421
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:43:41 +00:00
David Neto bd1d142134 Add reader::spv::Namer::Sanitize
Bug: tint:3
Change-Id: I4d554755dacecac0f2dacf191d85f8e339e87923
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17420
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-23 16:42:21 +00:00
dan sinclair 7b7ff741c5 Generate OpExtInstImport
This CL updates the SPIR-V generator to only create the GLSL import if
it's requested.

Bug: tint:5
Change-Id: I96a9100adf0a0c59dcdd82c12ac27c566ea2663f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17341
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:27:05 +00:00
David Neto d854fc1543 Rename method RegisterExtendedInstructionImports
Bug: tint:3
Change-Id: If92bd97f9a71bd676ba40430fd736cf721c38747
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17360
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-20 19:24:48 +00:00
David Neto be4c89a4d2 Add reader::spirv::Namer
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>
2020-03-20 19:24:23 +00:00
dan sinclair 3740fd2d46 Emit functions.
This Cl adds functions to the WGSL generator.

Bug: tint:4
Change-Id: Ibc7d27597c6c0d63c82931d0fa016856359d21b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17340
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:09:04 +00:00
dan sinclair c574295a42 Emit If statements.
This CL adds emitting of if statements to the WGSL generator.

Bug: tint:4
Change-Id: Ie79b40779a028dd40eac99c5459c971ead6cc43e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17286
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:08:56 +00:00
dan sinclair eaf2689a44 Emit else statements.
This Cl updates the WGSL writer to generate else statements.

Bug: tint:4
Change-Id: I72f6bbb6a2ab00bec3933083fd12c5da1a3dd5f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17285
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:08:07 +00:00
dan sinclair 0d00402124 Emit loop statement.
This CL emits the loop statement from the WGSL generator.

Bug: tint:4
Change-Id: I45be066ed306a71df053f7e61e6201a10a3d1056
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17283
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:07:00 +00:00
dan sinclair 5f64aee763 Emit switch statements.
This CL updates the WGSL generator to output switch statements.

Bug: tint:4
Change-Id: I4450b10932960691c76e76869105ade01fdd5a79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17282
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:06:52 +00:00
dan sinclair 4202d7d016 Emit variable statements
This Cl updates the WGSL writer to output variable statements.

Bug: tint:4
Change-Id: Ic557ea0c1b366644a8496dd43e4cfd85b9e8a84f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17281
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:06:45 +00:00
dan sinclair 187f9165a5 Emit Unless statement.
This CL adds unless statement to the WGSL generator.

Bug: tint:4
Change-Id: Id171cb1438d290938f1da946c23992bdae688359
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17280
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:32 +00:00
dan sinclair b42c76c47d Emit regardless.
This Cl updates the WGSL writer to emit the regardless statement.

Bug: tint:4
Change-Id: Iab35f3f0d956bd6cdd1411a06b4ca022147b0f87
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17261
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:22 +00:00
dan sinclair 2a6e275057 Emit Return statements.
This CL adds emitting return statements into the WGSL writer.

Bug: tint:4
Change-Id: Ia2331f7c20e3a3e3af1aa1553cef83bec315eae3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17260
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:10 +00:00
dan sinclair c083af83ea Add Kill, Nop and Fallthrough to WGSL writer
This CL adds the Kill, Nop and Fallthrough statements to the WGSL
writer.

Bug: tint:4
Change-Id: Ic0c635cfa7ca4c3195c593b119f9436ffeb1f9dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17201
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:05:02 +00:00
dan sinclair 17686fc57c Emit WGSL continue statement.
This Cl adds support for emitting the WGSL continue statement.

Bug: tint:4
Change-Id: I20f87d46e707bdd7ae2a517983e779988892c445
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17200
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:04:54 +00:00
dan sinclair 37f4fb0f75 Emit case statement
This CL adds case statements to the WGSL generator.

Bug: tint:4
Change-Id: Ic7945646d79b7c3e9e1cb1cf57d1633a28f45fc0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17180
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:04:45 +00:00
dan sinclair bf5ab65e98 Emit WGSL Break statement.
This CL adds emitting of the break statement to the WGSL writer.

Bug: tint:4
Change-Id: Iceae8cf8c1c77d63455621ea23f566af57c9e717
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17163
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:02:05 +00:00
dan sinclair 7f9d570a5a Emit assignment statement.
This CL updates the WGSL writer to emit the assignment statement nodes.

Bug: tint:4
Change-Id: I8a52f4e96c61ecb9e97cd3da41f4a1aa718e8d37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17162
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:57 +00:00
dan sinclair daff3e2616 Emit UnaryOp expression.
This CL updates the WGSL generator to emit the UnaryOpExpression node.

Bug: tint:4
Change-Id: I54046b5238a45994f7a4ed27941bd22b0c75f836
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17161
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:47 +00:00
dan sinclair 09671ab6f1 Emit UnaryMethod expressions.
This CL updates the WGSL generator to output UnaryMethodExpression
nodes.

Bug: tint:4
Change-Id: If43c0e5c12a967f08cc23e816d292353490404cf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17160
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:38 +00:00
dan sinclair cbabfa8ca1 Emit UnaryDerivative in WGSL writer.
This CL updates the WGSL writer to emit the unary derivative expression.

Bug: tint:4
Change-Id: I18c0fd56d88f98a6c5d37e176d98ab7b3077a50c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17120
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:29 +00:00
dan sinclair 49568e162d Emit relation expressions.
This CL updates the WGSL writer to emit the relational expressions.

Bug: tint:4
Change-Id: I2b2f5e40f2091ce2b7715773f3811aed7ed61f6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17100
Reviewed-by: David Neto <dneto@google.com>
2020-03-20 19:01:19 +00:00
dan sinclair 2c56dd9099 Emit member accessor in WGSL generator.
This CL adds MemberAccessor handling into the WGSL generator.

Bug: tint:4
Change-Id: Ib84f9ca1969fec48f167433af957dc1ed4de3415
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17063
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:55:19 +00:00
dan sinclair 62a2002b4e Emit Cast expression.
This CL adds Cast Expression emission to the WGSL generator.

Bug: tint:4
Change-Id: Ib48290d53423be5770cfb8f1b5f1ccb93b53a4df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17062
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:53:30 +00:00
dan sinclair c80d5ed70a Add WGSL writer support for call.
This CL adds call expressions to the WGSL writer support.

Bug: tint:4
Change-Id: I1caa2f5f81ac2e2ab89755c1721e96d44c331853
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17060
Reviewed-by: David Neto <dneto@google.com>
2020-03-19 02:51:27 +00:00
dan sinclair cd49b59c78 Add generation of the 'as' expression.
This CL adds 'as' generation into the WGSL generator.

Bug: tint:4
Change-Id: Ica9e615e30aae1882681d8da74b26a51cff6dc30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16880
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:33:00 +00:00
David Neto 4a19eeff2c Fixing include-what-you-use in SPIR-V parser
Change-Id: If9eeb92dd50bd88e3dcc8b0a8966812a96a153a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17287
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-18 20:32:49 +00:00
dan sinclair 8347687117 Split WGSL generator tests to individual files.
This makes it easier to find and track tests as the generator grows.

Bug: tint:4
Change-Id: I9660e459f3ffd33f3048a331f23623318af013e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16840
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:10:44 +00:00
David Neto 0afb943ebf add ast::Module::to_str
This makes it easier to see the bug.

Bug: tint:22
Change-Id: Ic5acc0b8299ef31eb73b49863bc42ac09de6e9bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17203
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-18 20:09:44 +00:00
dan sinclair 9d9d7cd29d Add ArrayAccessor to output expressions.
This CL extends the WGSL writer to output ArrayAccessorExpression the
initializers are also output so we can test the array[5] syntax..

Bug: tint:4
Change-Id: I560ca6af4d714e13b136f6ded2fb3329e309c9ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16820
Reviewed-by: David Neto <dneto@google.com>
2020-03-18 20:05:44 +00:00
dan sinclair 4b71b9ed2b Expand build flags for Tint.
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>
2020-03-18 14:08:48 +00:00
dan sinclair e4392c9ab5 Create SPIR-V writer skeleton.
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>
2020-03-17 21:00:22 +00:00
dan sinclair 3040f618a5 Remove assert in test.
The `assert` will compile out in Release builds so we don't actually
parse the module, which means we're always testing against an empty
module and the tests fail.

Bug: tint:22
Change-Id: I49a1f8fc8ec6231a65f4f17e385cff576c4f0d06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17204
Reviewed-by: David Neto <dneto@google.com>
2020-03-17 20:38:18 +00:00
David Neto 881cdede29 Fix include guards for SPV -> SPIRV
Bug: tint:3
Change-Id: I34a7c8e7dd0116968d2614441b3bcb81d7e5c4e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17202
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:08:25 +00:00
David Neto 4df5d409c4 Rename tint::reader::spv -> tint::reader::spirv
Bug: tint:3
Change-Id: Iabee55bc75f60c04d00cd1560721def903052359
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17001
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:08:06 +00:00
David Neto 4e7f7da729 Rename reader/spv to reader/spirv
Bug: tint:3
Change-Id: I7707e2f9e51c1574e5dde18c83957573671dac70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17000
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-17 20:07:41 +00:00
David Neto 3ac99398b5 spv: Parse OpExtInst for GLSL.std.450
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>
2020-03-17 16:14:10 +00:00
dan sinclair c83578038a Disable lint warnings in fail stream test.
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>
2020-03-17 16:13:31 +00:00
Dan Sinclair 45d585f5ae Add unit test for VariableStatement.
This CL adds unit tests for the VariableStatement AST element.

Bug: tint:11
Change-Id: I36d1b134e4c1c93ee414c29e8bb8d5e7e9704da6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16760
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:59:46 +00:00
Dan Sinclair 1e31f161db Add Variable test for invalid initializer.
This CL adds a test to the variable AST node to verify the initializer
is valid.

Bug: tint:11
Change-Id: I95553e8572124e8e2e861b451003e5c9bf6358f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16743
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:59:06 +00:00
Dan Sinclair 02d94b2903 Add UnlessStatement tests.
This CL adds tests for the UnlessStatement AST elements.

Bug: tint:11
Change-Id: Icd003e81925d60c6681e447be2f1a5610564eda7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16742
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:57:16 +00:00
Dan Sinclair 750d0e7bd1 Add unit tests for UnaryOpExpression
This CL adds unit tests for the UnaryOpExpression AST element.

Bug: tint:11
Change-Id: I086d167c3b2ef0764a45a41268222254adba4017
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16741
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:25:02 +00:00
Dan Sinclair 8584c6f7fe Add unit tests for UnaryMethodExpression.
This CL adds unit tests for the UnaryMethodExpression AST element.

Bug: tint:11
Change-Id: I5e99bb15f1333c1fa7ff34efafd86739c6a1d662
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16740
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 14:20:11 +00:00
Dan Sinclair f4434cd403 Add UnaryDerivativeExpression tests
This CL adds tests for the UnaryDerivativeExpression AST element.

Bug: tint:11
Change-Id: Ieabfdcb7940aedc58a3455b74c0ddb508b4859ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16673
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:54:38 +00:00
Dan Sinclair 5ced2178a6 Add TypeInitializerExpression tests
This CL adds unit tests for the TypeInitializerExpression AST element.

Bug: tint:11
Change-Id: I92790563c995038cc5a09afd03e84496b8f41487
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16672
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:54:07 +00:00
Dan Sinclair 43aab39237 Add SwitchStatement tests
This CL adds tests to the SwitchStatement AST element.

Bug: tint:11
Change-Id: I3e12667d14ab31cc15f6ea8595847f9daf55dc46
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16682
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:53:41 +00:00
Dan Sinclair 097c3a544d Add more StructMember tests.
This Cl adds more IsValid tests to the StructMember AST node.

Bug: tint:11
Change-Id: I7fec6fb5e96f025735fd444c74f97d4ded8b3ae6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16671
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:53:06 +00:00
Dan Sinclair 7c44407cd3 Add Struct IsValid tests.
This Cl adds tests for the Struct::IsValid to make sure struct members
are also valid.

Bug: tint:11
Change-Id: I49d9f1dd6a6d2da8c49a273466316a849e1d28cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16670
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:52:21 +00:00
Dan Sinclair 0cef04193d Add SetDecoration to_str test
This CL adds a test for the set decorations to_str method.

Bug: tint:11
Change-Id: I06396c1bf59c90aad6a6851cf9695fbee42546a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16669
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:51:55 +00:00
Dan Sinclair 7267a851bf Add ReturnStatement test
This CL adds tests for the ReturnStatement AST node.

Bug: tint:11
Change-Id: Ib20e38e67e07e0ae03d359619cc260bc8d6e3a3b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16668
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:51:29 +00:00
Dan Sinclair 33306e1fd1 Add RelationalExpression tests
This CL adds test for the RelationalExpression AST node.

Bug: tint:11
Change-Id: Id16e97110423dd9d987b045325696227df0d2913
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16667
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:48:36 +00:00
Dan Sinclair baaa2af393 Add tests for RegardlessStatement
This CL adds the test for the RegardlessStatement AST element.

Bug: tint:11
Change-Id: Ide4a126e4fa68e84238985d1379dd80123aea5a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16666
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-17 03:42:02 +00:00
Dan Sinclair 9964846c98 Add tests for NopStatement.
This CL adds tests for the NopStatement AST node.

Bug: tint:11
Change-Id: I890b7f6bc6347ba4f5a67334385feffd24079d5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16665
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 14:31:58 +00:00
Dan Sinclair 3eaf827cc8 More module IsValid tests
Bug: tint:11
Change-Id: I1ce2b930f3dbf40791fa68963037e7b9f122658f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16664
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 14:17:52 +00:00
Dan Sinclair f300756eff Add MemberAccessorExpression tests
This CL adds unit tests for the MemberArrayExpression.

Bug: tint:11
Change-Id: I790d27018b516b3b2b79b6ed892c1a0e00b65818
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16681
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 14:17:28 +00:00
Dan Sinclair c99fdb84b5 Add LoopStatement AST tests
This CL adds tests for the loop statement AST node.

Bug: tint: 11
Change-Id: I32a3e1d4d40d21e00f4022bd1a2d03ba2ef4f404
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16563
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 13:58:53 +00:00
Dan Sinclair baca71db9a Add LocationDecoration ToStr test.
Bug: tint:11
Change-Id: I8327d2f3961e4d8d74c6339b66ba36218126e63e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16562
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 13:47:24 +00:00
Dan Sinclair ce6f648b9b Add KillStatement AST tests
This CL adds tests for the KillStatement AST element.

Bug: tint:11
Change-Id: I1388051ca0639ddaf6b3f2bd2fa5ea8e492b114c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16561
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 13:40:11 +00:00
Dan Sinclair bb521c0b24 Add tests for if statement AST
This CL adds tests for the if statement AST node.

Bug: tint:11
Change-Id: Ice3f281e1dfd72d76f43767f7b3040af862f4a58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16540
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 13:39:44 +00:00
Dan Sinclair 3d1e69767a Add identifier expression tests
This CL adds tests for the identifier expression AST node.

Bug: tint:11
Change-Id: Ie7dd4f1de3d8a23ac7e878285564d8c5fc9e1250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16502
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 13:26:10 +00:00
David Neto 9bb0dc543d spv: Build internal representation of the SPIR-V
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>
2020-03-13 20:21:45 +00:00
David Neto e5dc367a7e spv: reject invalid SPIR-V
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>
2020-03-13 20:18:06 +00:00
David Neto 1ae7c7dba9 Add SPIR-V parser impl
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>
2020-03-13 20:14:33 +00:00
dan sinclair 306a2f8381 Add IdentifierExpression to WGSL writer.
This CL extends the WGSL writer to output IdentiferExpression and fills
out the variable with initializer test case and implementation.

Bug: tint:4
Change-Id: I9db9affb5ec4c4c109488f60bbc81bf3a96eee35
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16744
Reviewed-by: David Neto <dneto@google.com>
2020-03-12 12:43:05 +00:00
dan sinclair d9e9ff3be5 Start WGSL writer
This CL is the start of a WGSL writer.

Bug: tint:4
Change-Id: Ib2c2580d9e50c36664088556d9b8feec76935211
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16560
Reviewed-by: David Neto <dneto@google.com>
2020-03-12 12:40:01 +00:00
David Neto ab0cdaf652 Add a FailStream error reporting helper
Bug: tint:3
Change-Id: Ie0bb2365a7dd6b2a5e9d0960593fac7586b02922
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16640
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-10 22:54:46 +00:00
David Neto f814bdc52a Add stub unit tests for spv parser
Bug: tint:3
Change-Id: I6957cddbdadbcf493fc8f1e3dbe0c6d9037dc56b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16620
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-10 22:54:31 +00:00
David Neto bbd8987e71 Instantiate a stubbed SPIR-V parser if file ends in .spv
- 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>
2020-03-10 22:54:12 +00:00
Dan Sinclair 49faa4c8d7 Add function tests
This CL adds tests for the function node.

Bug: tint:11
Change-Id: I10b1fb73ae93bf90162948ab42e2a74d4aca7987
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16501
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 19:19:28 +00:00
Dan Sinclair 9c48ddb917 Add fallthrough statement tests
This CL adds tests for the fallthrough statement.

Bug: tint:11
Change-Id: I1bc8677e00aa9eb446a096bd2600104550480d77
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16500
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 19:19:18 +00:00
Dan Sinclair cc9d7851e1 Add builtin decoration to_str test.
This CL adds a test for the to_str method of the BuiltinDecoration.

Bug: tint:11
Change-Id: Ia350058fc4f551d62195527f0a6b86751ba92b8c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16481
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 19:19:06 +00:00
Dan Sinclair d70d07c5b9 Add binding decoration to string test
This CL adds a test for the binding decoration to_str method.

Bug: tint:11
Change-Id: Id9d16bdb68c4b68fb8bd67dae898f8b7a17ee6c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16468
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 19:18:51 +00:00
Dan Sinclair 89b2aa1207 Extend entry point to str testing
This CL adds more tests for the entry point to str method.

Bug: tint:11
Change-Id: I54bb349d606d05221d649215b7b2c6477cca6819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16480
Reviewed-by: David Neto <dneto@google.com>
2020-03-10 19:18:29 +00:00
Dan Sinclair 18747b657a Extend array accessor validity checks
This Cl extends the array accessor to verify the sub expressions are
also valid.

Bug: tint:11
Change-Id: Ieaa9643e07deaa8c406743c3bbb6fbe3ca9cb1ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16467
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 19:11:35 +00:00
Dan Sinclair adb80f005a Add else statement AST tests
This CL adds tests for the else statement AST node.

Bug: tint:11
Change-Id: I30c024775d188223d5a3875ee973ffc8ac78c645
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16466
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-10 17:48:25 +00:00
Dan Sinclair 3a1368dead Add DecoratedVariable tests
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>
2020-03-10 17:47:56 +00:00
Dan Sinclair b893115c17 Add ContinueStatement unit test
This CL adds tests for the continue statement AST node.

Bug: tint:11
Change-Id: I6339947c338b4b035f7947cb45e33bf2dcb6fe3e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16464
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-09 13:23:22 +00:00
Dan Sinclair f981455a1c Add ConstInitializerExpression tests
This CL adds unit tests for the const initializer expression.

Bug: tint:11
Change-Id: I9fb9dd77447ac20921997614816cd75272d4e05a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16463
Reviewed-by: David Neto <dneto@google.com>
2020-03-06 21:18:50 +00:00
Dan Sinclair 11be14076b Add cast expression tests
This CL adds unit tests for the cast expression AST element.

Bug: tint:11
Change-Id: Ia5d82a00ef2a4c16d6591095b7674f1c14a33c5f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16462
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-03-06 21:18:19 +00:00
Dan Sinclair a659b2113d Add case statement tests
This Cl adds tests for the case statement class.

Change-Id: I585fdff9631ed44e6fb297328ed164297f5fa8f3
Bug: tint:11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16421
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-06 14:28:01 +00:00
Dan Sinclair 00cf5a4894 Add test for call expression
This CL adds unit tests for the call expression. The IsValid method is
extended to verify none of the provided parameters are a nullptr.

Change-Id: I5dfd3ec1f086ef02ab965218a1d8610a1c212628
Bug: tint:11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16360
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-05 20:35:57 +00:00
Dan Sinclair 51c811bfa8 Add BreakStatement test
This CL adds unit tests for the break statement.

Change-Id: I78300ea6661e9c331795aedd344ac74c63dd8e25
Bug: tint:11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16342
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-05 20:29:13 +00:00
Dan Sinclair 796f65fb70 Add test for assignment statement.
This CL adds unit tests for the assignment statement methods.

Change-Id: I4aea8f22b530bf43b7dfdc2b82b5414cf6590fea
Bug: tint:11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16341
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-05 20:20:39 +00:00
Dan Sinclair 91e57dd7d8 Add unit tests for AsExpression
This CL adds unit tests for the as expression and fixes up a few issues
along the way.

Change-Id: I4591f31c1a48ea5580a87a129c728ef3c9be2c7c
Bug: tint:11
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16340
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-05 16:35:40 +00:00
dan sinclair 19e26f2fec Move build_module into an anonymous namespace
This CL moves build_module into an anonymous namespace which fixes up a
build warning about missing prototypes.

Change-Id: I8b2f427e32e7851c24492099103565ab0119f4fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16503
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-05 16:35:25 +00:00
Sarah Mashayekhi 462dd675e1 v-0001: Only allowed import is GLSL.std.450
Bug: tint:10

Change-Id: I566ff378c4cd72febc0a73434b5dfe1039ef2c42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16420
Reviewed-by: Dan Sinclair <dsinclair@google.com>
Commit-Queue: Dan Sinclair <dsinclair@google.com>
2020-03-04 20:51:29 +00:00
Dan Sinclair e4b68bafda Add unit test for ArrayAccessorExpression
This CL adds unit tests for the array accessor expression class.

Change-Id: I97a7b366a2303b071040164cbcda404fe0592d90
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16281
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@google.com>
2020-03-03 14:09:27 +00:00
Dan Sinclair 6e581895a5 Initial commit 2020-03-02 15:47:43 -05:00