Commit Graph

237 Commits

Author SHA1 Message Date
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