Commit Graph

504 Commits

Author SHA1 Message Date
dan sinclair 369b0b4618 Remove old src/include folder
This CL removes the src/include folder which was used to forward old
header includes to the new include/ location. The various BUILD rules
which referred to these folders are also removed.

Bug: dawn:1275
Change-Id: Ic0bdc8cf900833af25199ee3e41708953c7c1eec
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94026
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-18 16:16:11 +00:00
dan sinclair 889a499ef4 Remove test/tint/BUILD.gn.
This Cl moves the contents of the test/tint/BUILD.gn file into the
src/tint/BUILD.gn file. This moves the tests into the same build file as
what is being tested. This is more in line with how the CMakeLists.txt
file is setup.

This removes the need to update 2 BUILD.gn files when adding new files
and tests to tint.

Bug: tint:1517
Change-Id: I9beb8a8bff7c10ac875647246ad4362f7e60f7da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94040
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-06-17 13:01:59 +00:00
Corentin Wallez 6efd54e2ae Move samples/ under src/dawn/samples/
Bug: dawn:1339
Change-Id: I897df9889da62e4505ea98a780bd481e7855ec73
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86307
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-04-11 16:40:00 +00:00
Corentin Wallez b28d6c8e1c Remove lintcpp from presubmits since it fails on all Dawn files
Also fixes some other lint issues.

Bug: dawn:1339
Change-Id: I19a212218db3249191deedc671fc6e36991ecad8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86061
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-04-07 11:36:06 +00:00
Ryan Harrison e87ac76f7d Merge remote-tracking branch 'tint/main' into HEAD
Integrates Tint repo into Dawn

KIs:
- Building docs for Tint is turned off, because it fails due to lack
  of annotations in Dawn source files.
- Dawn CQ needs to be updated to run Tint specific tests
- Significant post-merge cleanup needed

R=bclayton,cwallez
BUG=dawn:1339

Change-Id: I6c9714a0030934edd6c51f3cac4684dcd59d1ea3
2022-04-06 15:37:27 -04: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
Austin Eng e710706858 Remove old src/tests/BUILD.gn
Bug: dawn:1275
Change-Id: I1da086fb291551b0a437411b13285a097557e7de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/80060
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-10 19:41:24 +00:00
Austin Eng 189b0cec37 tint->dawn: Move src/dawn_tests -> src/dawn/tests
Bug: dawn:1275
Change-Id: I79f2aeb0c54a74dd5becd90c46792705a28e87da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2022-02-09 14:54:31 +00:00
Ben Clayton c6ccd539e8 tint->dawn: Move src/fuzzers/dawn -> src/dawn/fuzzers
This has already been moved once, but with more consideration, there's far less fuzzer-related stuff to put in the same root directory here.

Bug: dawn:1275
Change-Id: Ic4bb556d9a9f104293cca3316cae84b66a6362b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79104
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:48:05 +00:00
Ben Clayton a6750751c7 tint->dawn: Move examples -> samples/dawn
Bug: dawn:1275
Change-Id: I4824aaabc2c2b55a609a6e1370959394b93463b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79103
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-04 18:35:55 +00:00
Ben Clayton 818001d32e tint->dawn: Move src/dawn_native -> src/dawn/native
Bug: dawn:1275
Change-Id: Ic60a00107a015bc677ff929c492f1085ffc38482
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79083
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2022-02-04 17:07:46 +00:00
Ben Clayton 1a4185b742 Move src/fuzzers to src/fuzzers/dawn
As part of the tint -> dawn merge.

Bug: tint:1275
Change-Id: I0ebb8afe9971c21ca90f90f246edcfde01d5f4bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-02-01 16:45:12 +00:00
Austin Eng 63f65465f5 Add a build target for a webgpu_dawn library
This library binds directly to dawn_native and implements
webgpu.h. It may be built as a single library so it can
be easily used in other projects.

Bug: dawn:1220
Change-Id: I73be8c6455922fa526efd1600446cc46b07e82ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53887
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-12-09 20:03:48 +00:00
Corentin Wallez 9496f28775 BUILD.gn: Remove the temporary group with Dawn migrated.
Bug: dawn:706
Change-Id: I60aa97845cdfce263afc34947c597ceb5b8e6fb0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44861
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-03-17 07:41:03 +00:00
Corentin Wallez 717fbbf183 BUILD.gn: use public_deps for the proxy group.
Otherwise the public_configs of the proxied targets don't correctly get
propagated, causing Dawn to fail compilation due to missing include
directories.

Bug: 706
Change-Id: Ib8acfb06105e77ad005c3900975e8173d85dcf32
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44680
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 10:40:01 +00:00
Corentin Wallez 5929a04316 Split BUILD.gn into per-subdirectory BUILD.gns
This will allow Tint's dependent to depend on libtint without GN
discovering Tint's test and try to build them. In particular it will
help use Tint in Dawn in Skia's standalone build which doesn't have
//testing.

Bug: dawn:706
Change-Id: Idd28662b89aa75df7704eaae205328dce0b96fef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44540
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2021-03-15 08:43:11 +00:00
James Price 95d4077648 Flatten ast::Decoration class hierarchy
Remove the decoration groupings (Array, Function, Struct,
StructMember, Type, Variable), such that all *Decoration classes now
subclass ast::Decoration directly. This allows for decorations to be
used in multiple places; for example, builtin decorations are now
valid for both variables and struct members.

Checking that decoration lists only contain decorations that are valid
for the node that they are attached to is now done inside the
validator.

Change-Id: Ie8c0e53e5730a7dedea50a1dec8f26f9e7b00e8d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44320
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-03-11 17:39:32 +00:00
James Price a0d48382cb [spirv-writer] Handle entry point parameters
Add a sanitizing transform to hoist entry point parameters out as
global variables.

Bug: tint:509
Change-Id: Ic18f69386a58d82ee11571fa9ec0c54cb5bdf2cf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44083
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-11 15:57:21 +00:00
Ben Clayton 2c41f4fbdf Resolver: Split tests into multiple files
Try and make sense of the huge number of tests we have.

Rename tests so they have a consistent naming style.

Change-Id: I0c089d5945778a8718480a1a2f854435e7b0e79a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44162
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:12:57 +00:00
Ben Clayton 786cea419d Add resolver::TestHelper
First step in splitting out resolver tests into multiple files

Change-Id: I58c66ad5e348a50b3e028dff5749cfacb273ea62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44161
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:10:27 +00:00
Ben Clayton 5f0ea11365 Rename TypeDeterminer to Resolver
Move out of the src root and into its own subdirectory
Rename methods to remove the 'Determine' prefix.

Fixed: tint:529
Change-Id: Idf89d647780f8a2e7495c1c9e6c402e00ad45b7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44041
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-09 10:54:37 +00:00
Ben Clayton 13ee0fbdf3 Move msl_test.cc to correct source_set
Should fix dawn's autorollers

Change-Id: I6d46af611a3fc699eabeec92b395d9df48cc03fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44040
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-03-05 15:02:45 +00:00
Ben Clayton 97b92178c5 writer/msl: Remove the renaming logic
This is now entirely handled as transforms.

Bug: tint:273
Change-Id: Ib3c0db7b5ecf024b6ae2aed7788e4b582d07c4ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43983
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-04 23:24:05 +00:00
Ben Clayton 37d2b35d59 transform::Msl: Rename reserved keywords
This change begins the work to move the reserved keyword remapping out of the writer and into the sanitizer transform.

If the transform::Renamer is in use, then these symbols should never have to be remapped - however for debugging purposes it is often nice to be able to emit code that isn't entirely mangled.

The logic in the msl writer will be removed as a followup change

Bug: tint:273
Change-Id: I76af03ff80388a48d9dd80a5b5fdfe21f3c8e7a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43982
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 23:03:25 +00:00
Ben Clayton f25d51977a Move IntrinsicType parsing to semantic/intrinsic.h
Keeps the enum / parse / print code all together.

Change-Id: I78e5e15b6a97d3aec619a94e4390ecc4a77ab478
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43980
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-04 23:00:46 +00:00
Ben Clayton d1781fd0af Remove tint::Namer
Replaced with tint::transform::Rename and was never used.

Bug: tint:273
Change-Id: Icf0b19b389377f3c9a6efcf3ca232ba294775f9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43981
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-03-04 21:00:15 +00:00
Ben Clayton e18a18bc1c Add transform::Renamer
Renames symbols.
Currently only supports renaming to a symbol with a monotonic increasing suffix.

Change-Id: I7ae67a7b1740ac0e83c1821643cf7b8b1959f84d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42842
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-04 11:12:45 +00:00
James Price 9062f13202 Rename test file for consistency
We use _test.cc for everything else, so this makes globbing for test
sources simpler.

Change-Id: I6d1a3ad0f3bbeaabe981fbce66967de7e2f9e4d5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43481
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-01 22:51:39 +00:00
Ben Clayton 767df5f03b Fix infinite spin in wgsl parser
If the parser hits a `maximum parser recursive depth reached` situation, then we need to try and resynchronize the parser.

If we fail to do this, then the synchronized_ flag may remain true, and the parser will believe progress is still being made.
In this situation the parser may try to reparse the same token, forever.

By calling sync_to() we either find the end of the block, and forward progress can be made, or synchronized_ is set to false, and the parser can error out cleanly.

Add test case from fuzzer report.

Fixed: chromium:1180128
Change-Id: I893077677fd3dfbd4b9b400cd32db842b06db500
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42029
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-19 20:01:43 +00:00
Ben Clayton 89036852cc Don't build test_main.cc in chromium builds
Chromium has its own test main() entrypoint.

To ensure that Chromium doesn't panic about memory leaks with the tests that exercise the ICE cases, we have to explicitly call the FreeInternalCompilerErrors() functions in these tests (at least until I can add this to end of Chromium's test main() function)

Change-Id: I2ea5109fcdb5f68f56a19709a1ec35ed72c0f760
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42025
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-18 20:23:09 +00:00
Ben Clayton 41085503e1 Add hlsl::TestHelperBase::Validate()
Looks for DXC on PATH.
If found, it will invoke DXC with the shader program generated by the writer to verify the shader can compile.

Change-Id: Iad8b4021bac16d01214b500ddb89b5f743927ce9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41943
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 16:19:09 +00:00
Ben Clayton ce7e18e87c Add tint::Command
Command is a helper used by tests for executing a process with a number of arguments and an optional stdin string, and then collecting and returning the process's stdout and stderr output as strings.

Will be used to invoke HLSL and MSL shader compilers to verify our test generated code actually compiles.

Change-Id: I5cd4ca63af9aaa29be7448bb4fa8422e6d42a8ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41942
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 15:49:08 +00:00
Ben Clayton a87fda9225 Add tint::TmpFile
TmpFile constructs a temporary file that can be written to, and is automatically deleted on destruction.

Will be used to create a temporary source file for verifying generated HLSL and MSL against their shader compilers.

Change-Id: Ieaa6f257b93f4f2193dafe6297603816f6964928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41941
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-18 15:39:00 +00:00
Ben Clayton 6b4924fb0e Add TINT_UNREACHABLE() and TINT_ICE() helper macros
Appends an error message with the tint compiler source location to the
provided diagnositic list, and then calls the global error handler if
one is set.
Tests and the sample app now register an error handler to print the
diagnostic list to stderr and abort when NDEBUG is not defined.

All uses of assert(false) have been fixed up to use these macros.

Change-Id: I2f63e51ed86ac23883301d280070bd1a357c6cb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-17 20:13:34 +00:00
Ben Clayton f81df124f6 Add utils/unique_vector.h from TypeDeterminer
Add tests.

Change-Id: I064fbbe2387ebe980776ee99ed2ff48d6ea5d5b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41621
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-17 13:10:49 +00:00
Ben Clayton 4b9e7f92b9 transform::Hlsl: Hoist array initializers out of expressions
Move these into a separate const variable declaration statement just above the before the use of the array initializer.
HLSL does not allow array initializers as part of a sub-expression

Fixed: tint:406
Change-Id: I98f93f2eca172865691831011c852de5e57c5ad6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41484
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-02-16 23:21:51 +00:00
James Price ea9e471e30 [spirv-writer] Add support for sample index/mask builtins
Use a sanitizing transform to convert scalar `sample_mask_{in,out}`
variables to single element arrays.

Add the `SampleRateShading` capability if the `sample_index` builtin
is used.

Bug: tint:372
Change-Id: Id7280e3ddb21e0a098d83587d123c97e3c34fa1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41662
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-02-16 21:44:13 +00:00
Ben Clayton f97b9c9310 Add semantic::Statement
Add Stmt() accessor on all semantic::Expressions so the owning statement can be retrieved.

Change-Id: I5d584335a6d137fdeab0b8d74a161fcae9b46080
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41545
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-02-16 18:45:45 +00:00
James Price c8fa020a5e Add missing WGSL writer test files to BUILD.gn
These files were added in dfd1714, but only added to CMakeLists.txt.

Change-Id: I775e8fef68b2f4900a6c562533512f0eda01b795
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41700
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-16 14:39:48 +00:00
Ben Clayton faca02d438 IntrinsicTable: Fix a number of TODOs
And add tests for IntrinsicTable.

Drop all the type unwrapping - be precise:
* Display the actual argument types in the signature mismatch message
* Only dereference pointer arguments if the parameter does not expect a pointer

Correctly match access control on storage types

Note that I was mistaken in tint:486 - the TypeDeterminer is resolving identifiers to variables correctly as pointer types. The confustion here was probably due to all the UnwrapAll() calls, which have now all gone.

Fixed: tint:486
Change-Id: I239eabd1fedfc082566c4af616ccfc58786cae25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41280
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:34:25 +00:00
Ben Clayton 2101c35f3b Stub sanitizer transforms for the hlsl, msl & spirv writers
These transforms will perform work to massage the Program into something consumable by the given writer.

Change-Id: I8989e8d4bc1a9cae7ce1f8764c8f3811db3bd04d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41483
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-10 21:22:03 +00:00
Ben Clayton 59d24735d0 Add IntrinsicTable
Provides a centeralized table for all intrinsic overloads.

IntrinsicTable::Lookup() takes the intrinsic type and list of arguments, returning either the matched overload, or a sensible error message.

The validator has expectations that the TypeDeterminer resolves the return type of an intrinsic call, even when the signature doesn't match. To handle this, create semantic::Intrinsic nodes even when the overload fails to match. A significant portion of the Validator's logic for handling intrinsics can be removed (future change).

There are a number of benefits to migrating the TypeDeterminer and Validator over to the IntrinsicTable:
* There's far less intrininsic-bespoke code to maintain (no more duplicate `kIntrinsicData` tables in TypeDeterminer and Validator).
* Adding or adjusting an intrinsic overload involves adding or adjusting a single Register() line.
* Error messages give helpful suggestions for related overloads when given incorrect arguments.
* Error messages are consistent for all intrinsics.
* Error messages are far more understandable than those produced by the TypeDeterminer.
* Further improvements on the error messages produced by the IntrinsicTable will benefit _all_ the intrinsics and their overloads.
* The IntrinsicTable generates correct parameter information, including whether parameters are pointers or not.
* The IntrinsicTable will help with implementing autocomplete for a language server

Change-Id: I4bfa88533396b0b372aef41a62fe47b738531aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40504
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 22:42:54 +00:00
Ben Clayton 599d8f8c0d Rename intrinsic.cc to sem_intrinsic.
For consistency with the other .cc file names in this directory.
The reason we need the sem_ prefix is because all the tint lib code is compiled as a single target, and .GN cannot cope with .cc files with the same file name, even if they're in different directories.
This could be fixed by building each directory as a separate target, but we have circular dependencies that currently make this impossible.

Change-Id: I2f1379ff11dd863f81662449f73d67832f0a8a4e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40501
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-08 20:11:22 +00:00
Ben Clayton 2ddb1783c5 Add semantic::CallTarget, have Function derive from it
CallTarget holds parameter information. This is simple to extract from an ast::Function.
CallTarget will also be used for intrinsics, which can be overloaded. CallTarget will hold the resolved overload parameter signature.

Bug: tint:361
Change-Id: I4dadc4a99293f12ede9e9cbd9132ba5f9b9830ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40284
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-08 19:13:19 +00:00
Ben Clayton c1052a4971 Add semantic::MemberAccessorExpression, use it.
Pull the mutable 'is_swizzled' semantic field from ast::MemberAccessorExpression and into a new semantic::MemberAccessorExpression node.
Have the TypeDeterminer create these semantic::MemberAccessorExpression nodes.

Bug: tint:390
Change-Id: I8fc6e36dabb417190528536a94d027af54059222
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40142
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 23:55:56 +00:00
Ben Clayton 1618f4be4e Add semantic::Call, IntrinsicCall, TextureIntrinsicCall, use them.
semantic::Call derives from semantic::Expression, and Type() is the return type of the function
Pull the mutable semantic field from ast::Identifier and into a new semantic nodes.
Have the TypeDeterminer create these new semantic nodes.

Note: This change also fixes the node that holds the semantic information for a call.
Previously this was on the identifier, and this is now correctly on the CallExpression.
The identifier of the CallExpression should resolve to the target function, not the return type.
Functions can currently be represented as a type, and the identifier of a CallExpression now has no semantic information.

Bug: tint:390
Change-Id: I03521da5634815d35022f45ba521372cbbdb6bc7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40065
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 21:02:25 +00:00
Ben Clayton b17aea159c Add semantic::Variable, use it.
Pull the mutable semantic field from ast::Variable and into a new semantic::Variable node.
Have the TypeDeterminer create these semantic::Variable nodes.

Bug: tint:390
Change-Id: Ia13f5e7b065941ed66ea5a86c6ccb288071feff3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/40063
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-02-03 17:51:09 +00:00
Ben Clayton 87c78ddabc Add semantic::Function, use it.
Pull the mutable semantic fields from ast::Function and into a new semantic::Function node.
Have the TypeDeterminer create these semantic::Function nodes.

Bug: tint:390
Change-Id: I237b1bed8709dd9a3cfa24d85d48fc77b7e532da
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39902
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-02-03 16:43:20 +00:00
Nicolas Capens dd988bca84 GN: add a default build target
This target is built when no specific target is specified on the command
line. It avoids building all available targets. Specifically, the
optional use of LLVM as a JIT-compiler by SwiftShader was dominating
compile times.

See the GN reference for details:
https://gn.googlesource.com/gn/+/master/docs/reference.md#the-all-and-default-rules

For now, it's equivalent to the "all" target. Note the latter is an
explicit target, not the implicit one mentioned in the reference.

Bug: swiftshader:157
Change-Id: Ifd2750921a9cfc0163858da77a81c9eb33002fb2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39580
Auto-Submit: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2021-02-02 17:03:30 +00:00
Alan Baker e809fb3ae5 Refactor unnecessary builtin checks
* Move unnecessary builtin checks out of type determination and into
  validation
  * Type determination now uses a bare minimum of information for most
    builtins
  * Validation now does majority of checking of builtins
* Added const qualifier to type accessors

Change-Id: Id11b739770af904a9b7afe0b1c2de50e1428a165
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39540
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-02-01 15:33:13 +00:00