Commit Graph

2908 Commits

Author SHA1 Message Date
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
Ryan Harrison 9459dbf3ab Use the correct pop pragma
BUG=tint:43

Change-Id: If0f6ff0b65af4c66fe7114eb7160e93ef060fbf9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19104
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-04-08 18:52:53 +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
dan sinclair a32315cb73 Fixup the contributing file.
The CONTRIBUTING was written before the decision to use the
dawn-reviews. This CL updates to the correct information.

Bug: tint:36
Change-Id: I7e15572a3ed4bc4bbaaba8972e84eeda111d953f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18921
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-04-06 18:43:20 +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
dan sinclair 2c18339745 Add depot tools to the requirements section.
The depot_tools install was mentioned in the building section but was
missing from requirements. This CL fixes that oversight.

Bug: tint:35
Change-Id: I6900ba8916d26dc03bd001bde96561a468a2fb75
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18900
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-04-06 15:19:47 +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