Commit Graph

60 Commits

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