Commit Graph

18 Commits

Author SHA1 Message Date
Austin Eng 86a617f110 Add InsertBraces: true to .clang-format
Bug: none
Change-Id: I4b4f2a4abfea7adcea406f458bc4e4a13b0e8c43
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-05-19 20:08:19 +00:00
Zhaoming Jiang 62bfd318ae tint: Implement `f16` keyword in Tint frontend
This patch:
1. Add the `f16` WGSL extension.
2. Add `f16` as keyword, and remove it from reserved word list.
3. Add ast::f16 and sem::f16, and implement validation that using `f16`
   type must be with `f16` extension enabled.
4. Add `Number<NumberKindF16>` for f16 literal and constant, and add
   `ast::FloatLiteralExpression::Suffix::kH`.
5. Add placeholder in all writer which report error when try to emit f16
   type.

Bugs: tint:1473, tint:1502
Change-Id: Ifb363beeb2699ed7cac57e07227d1b2cfa8050b4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89922
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-05-13 12:01:11 +00:00
Ben Clayton 824e824709 tint: Rename float / int literal tokens
Rename:
• kFloatFLiteral -> kFloatLiteral_F
• kIntILiteral   -> kIntLiteral_I
• kIntULiteral   -> kIntLiteral_U

As suggested in review:
https://dawn-review.googlesource.com/c/dawn/+/89031/comments/b37253a3_e830b482

Bug: tint:1504
Change-Id: I4120f2904d8614152d4c804c226c9710f2ef8653
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89661
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-10 22:26:04 +00:00
Ben Clayton 41285aa578 tint: Lex different tokens for float suffixes
Generate different tokens for:
• 'f' suffixed float literals
• unsuffixed integer literals

'f' and unsuffixed are currently both treated as f32 by the resolver,
but this is the first step to supporting abstract floats.

Bug: tint:1504
Change-Id: Id3b1fe420b6eb8901f88d6a5de06ef4f54aa3edf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89031
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-05-10 14:55:34 +00:00
Ben Clayton f693488bff tint: Lex three types of integer literal
Generate different tokens for:
• 'i' suffixed integer literals
• 'u' suffixed integer literals
• no-suffix integer literals

'i' and no-suffix are currently both treated as i32, but this is the
first step to supporting abstract integers.

Bug: tint:1504
Change-Id: Ib94652e0c829d7879ff594ff7efd279cb05010e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88841
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-05-04 21:01:12 +00:00
dan sinclair 41e4d9a34c Consistent formatting for Dawn/Tint.
This CL updates the clang format files to have a single shared format
between Dawn and Tint. The major changes are tabs are 4 spaces, lines
are 100 columns and namespaces are not indented.

Bug: dawn:1339
Change-Id: I4208742c95643998d9fd14e77a9cc558071ded39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87603
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-01 14:40:55 +00:00
Zhaoming Jiang 3b1e30a496 tint: Add `i` suffix and validate UInt literal non-negative
In this patch, `i` suffix for SInt literal is added, making `-234i`
valid. Meanwhile, validation of UInt literal must not be negative is
add, making `-42u` invalid with proper error message.

Bugs: tint:1514, tint:1515
Change-Id: Idd0e9ae5649a62e7d348c29f95c2570049653bd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-04-27 10:48:12 +00:00
Zhaoming Jiang 7098d3d692 tint: Add enable directive for extensions
In this CL the enable directive is implemented.
1. Add AST node for enable directive, assign a ExtensionKind (enum) for
each supported extension.
2. Use an unorder_set in ast::Module to record all required extensions'
kind.
3. Provide inspector methods for getting names of used extension, and
getting all used enable directives' extension names and location.
4. For different writer, the extension nodes are handled in different
ways. MSL and HLSL writers will just ignore the extension nodes, while
SPIRV and GLSL writers will emit corresponding code.
5. Implement unittests and end2end test for enable directive and
inspector, using a reserved extension name `InternalExtensionForTesting`.

Bug: tint:1472
Change-Id: I40cb4061554deb477bc2005d7e38c9718385f825
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-04-27 02:27:52 +00:00
Antonio Maiorano 25775308a9 Implement support for Unicode Pattern_White_Space
Bug: tint:1505
Bug: tint:1513
Change-Id: I40fa29c766dc35213e0846071322523e7fc81b79
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86402
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-04-25 19:49:01 +00:00
Antonio Maiorano eba0e85c33 tint: make Lexer use line breaks from Source::File
Before this change, we duplicated line break parsing in both
Source::File and Lexer. This change makes it so that the Lexer no longer
looks for line breaks, instead relying on Source::File for this info.
This de-duplication will also help in implementing the latest spec
changes with respect to line breaks (CRLF vs CR, etc).

Bug: tint:1505
Bug: tint:1513
Change-Id: Ifa820f75ede7e82822525282127e05d2fea047e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87604
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-04-22 15:34:21 +00:00
dan sinclair 30a03d9eed Condense namespaces in tint/reader/wgsl.
This PR condenses the namespaces in the tint/reader/wgsl folder.

Change-Id: Ic9f668402f10f02eecf5a8eaf0625558957391d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86032
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-07 17:55:04 +00:00
James Price 555c256344 wgsl: Add support for compound assignment
Implemented in both the reader and writer with E2E tests. Other
backends detect compound assignment and ICE for now.

Bug: tint:1325
Change-Id: Ie3f51e03627a38b12bd1513c4bcf1bebb3282863
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74363
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price 7d38b88d77 Remove support for the elseif keyword
This was deprecated in M99 and can now be removed.

Fixed: tint:1289
Change-Id: I6513360c5615609a3cc36ae28d5ef8ebddece710
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83964
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-21 16:09:17 +00:00
James Price 6bd90d666e Remove support for [[attribute]] syntax
Fixed: tint:1382
Change-Id: I7bebeb59fd0a57a69929e9bf5aa768ae1ff8a33d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83961
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-21 16:09:17 +00:00
James Price 453d5ae84e Terminate line comments with \v, \f, and \r
The WGSL spec says that line comments are terminated by any blankspace
other than a space or a horizontal tab.

Also rename is_whitespace to is_blankspace and tighten up the
definition to only include the characters listed in the WGSL spec.

Change-Id: I4fee0175980ab70e9baf107a6e79ab5c2e4f906d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83920
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-03-16 21:45:44 +00:00
Ben Clayton 64b775419d Error on invalid UTF-8 sequences
Invalid UTF-8 was being best-effort consumed, which given the right sequence of brokenness, could end up with diagnostic locations referring to bytes beyond the end of a line.

Improve the UTF-8 decoding so that it can detect when multi-byte codepoints are missing the high-bit being set.
Actually detect this in a lexer, and parser and produce errors.

Bug: tint:1437
Bug: chromium:1305648
Change-Id: I459f0df840b4ce8c4f5f82363f93602bf8326984
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83540
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-03-15 16:18:03 +00:00
Antonio Maiorano b86895da5f Fix assert in MSVC debug builds when parsing unicode
On MSVC debug builds (VS 2022), running Tint against the
"unicode\identifiers.wgsl" test was triggering the following assert:

```
Program: C:\src\tint\out\build\x64-Debug\tint.exe
File: minkernel\crts\ucrt\src\appcrt\convert\isctype.cpp
Line: 36

Expression: c >= -1 && c <= 255
```

std::isdigit, isxdigit, and isspace specify that the behaviour is
undefined if the argument's value is neither representable as unsigned
char nor equal to EOF. For example, see:
https://en.cppreference.com/w/cpp/string/byte/isdigit. As suggested on
cppreference, to safely use these functions, we should first convert the
char argument to unsigned char.

Bug: tint:1437
Change-Id: I80e061820cfd87aca51758ae2e3b59306b157b04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/83180
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-03-09 18:48:28 +00:00
Ryan Harrison dbc13af287 tint->dawn: Shuffle source tree in preperation of merging repos
docs/    -> docs/tint/
fuzzers/ -> src/tint/fuzzers/
samples/ -> src/tint/cmd/
src/     -> src/tint/
test/    -> test/tint/

BUG=tint:1418,tint:1433

Change-Id: Id2aa79f989aef3245b80ef4aa37a27ff16cd700b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80482
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-02-21 15:19:07 +00:00