Commit Graph

33 Commits

Author SHA1 Message Date
Ben Clayton 207b5e2de1 Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes:
* They don't derive from ast::Node
* They're deduplicated by the type manager
* None of the types have an Source - they have no lexical declaration point
* The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type.
* We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree.

Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory.

The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module.

Bug: tint:390
Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2021-01-21 15:42:10 +00:00
dan sinclair b5839939e1 Cleanup code using RegisterSymbol
This CL goes through and converts things which call RegisterSymbol to
use the helper builders. Several variables are also updated to use the
helper as it will need RegisterSymbol in the near future.

Change-Id: Ib5a8e8be54c1eaad123384fab09f6625421d9fcd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35880
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-16 21:38:40 +00:00
Ben Clayton 1523f5c276 Start cleaning up tests (3/N)
Remove Source{} with ast::Builder::create<>
Use Builder helpers where possible

Change-Id: I7b3188fa8239bf11e88ff6b396a57c23d76a3152
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-14 22:30:57 +00:00
Ben Clayton db5ce658b5 Remove BlockStatement::append()
Bug: tint:396
Bug: tint:390
Change-Id: I3b558a8961f9890f24d1aa3d6647ec095e5fe1cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35421
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-14 20:25:27 +00:00
dan sinclair 24bbbbb25f Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name
will be removed in a future CL when the symbol is used everywhere.

Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-14 16:01:37 +00:00
Ben Clayton bbefff63a3 ast: Remove statement constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 11:58:44 +00:00
dan sinclair 4226b6a1d8 Add Symbol to alias.
This CL adds a Symbol alongside the name in the Alias type. The name
will be removed in a future CL.

Change-Id: I23fa77566cc7a2aead783b64c34c0cc3195df24b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35461
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:35:03 +00:00
dan sinclair a41132fcd8 Add a symbol to the Function AST node.
This Cl adds a Symbol representing the function name to the function
AST. The symbol is added alongside the name for now. When all usages of
the function name are removed then the string version will be removed
from the constructor.

Change-Id: Ib2450e5fe531e988b25bb7d2937acc6af2187871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35220
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-11 18:24:53 +00:00
Ben Clayton a80511e021 ast: Merge DecoratedVariable into Variable
Remove all Variable setters (with exception to set_storage_class() which is called by the TypeDeterminer)

Bug: tint:390
Change-Id: I172667e21e2b02e85dcea6703aa1e608ec718250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35015
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-11 13:07:02 +00:00
Ben Clayton 321e5a9d7e ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:08:07 +00:00
Ben Clayton 234b7de460 ast/function: Remove [set|add]_decorations()
Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:45:14 +00:00
Ben Clayton c15d0a73ee Unrevert "[ast] Remove unused constructors and setters".
Hopefully the trybot issue is now resolved.

This reverts commit 5792783e72,
unreverting commit 4d28b27935.

Change-Id: I2855bf17c5025a3d349e7fce16fdca342517aad3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 18:48:58 +00:00
dan sinclair 5792783e72 Revert "[ast] Remove unused constructors and setters."
This reverts commit 4d28b27935.

Reason for revert: Seeing weird build breakage ...

Original change's description:
> [ast] Remove unused constructors and setters.
>
> This CL removes unused default constructors and various set methods
> from the AST classes where they are not longer required.
>
> Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com

Change-Id: I9d5bf6fd6d47131650c964cad4e17a1cbe86b040
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34682
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 15:18:59 +00:00
dan sinclair 4d28b27935 [ast] Remove unused constructors and setters.
This CL removes unused default constructors and various set methods
from the AST classes where they are not longer required.

Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 14:31:38 +00:00
Ben Clayton f1b0e1ee57 ast/type: Remove Type suffix from all types
They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.

Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 03ae9a397f Cleanup: Remove unnecessary namespace prefixes
No need to prefix with `ast::` when you're in the ast namespace already.

Change-Id: Iac6cd3a215c05a80ee2035d582500f1d6c882a06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34320
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 4bfe461646 Big cleanup now that AST nodes are raw pointers
Remove all redundant std::move()s. I've also removed calls to
std::move() in tests, even if they act as an optimization. This is for
two reasons:
(a) Performance is not important for testing, and this helps with
    readability.
(b) A whole bunch tests were relying on std::move() clearing vectors so
    they can be repopulated and used again. This is undefined behavior:

> Objects of types defined in the C++ standard library may be moved from
> (12.8). Move operations may be explicitly specified or implicitly
> generated. Unless otherwise specified, such moved-from objects shall
> be placed in a valid but unspecified state.

All of these UB cases have been fixed.

Removed all duplicate variables left over from:
  `auto* foo_ptr = foo.get()`
which became:
  `auto* foo_ptr = foo`

Bug: tint:322
Change-Id: Ibd08a2379671382320fd4d8da296ccc6a378b8af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32900
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:41:47 +00:00
Ben Clayton b053acf796 Replace use of std::unique_ptr<T> with T* for AST nodes
This is a minimal effort to fix up the code. There's substantial code
cleanup which can now be done, which is done in the next change.

Bug: tint:322
Change-Id: Iafcf5e814837d9534889e8c21333de4931a19cfa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32864
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:31:07 +00:00
Ben Clayton b29b09fba6 ast: Add body parameter to ast::Function constructors
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: Iddb5605b9bc0de80ad2710ced0e429f89410af2f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32675
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 01:13:04 +00:00
Ben Clayton 327b1c7cd3 ast tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I0e68992963f52e432d4d485feae1123f35732552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32664
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 22:03:58 +00:00
Ben Clayton 10d5c6a6b6 ast: Have all tests derive from new TestHelper
It doesn't actually do anything (yet), but will hold the context and
a helper for constructing AST nodes.

Bug: tint:322
Change-Id: Ic7ba92bf39abf64ff2ac51d81c8a6338f5eff608
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-13 21:58:28 +00:00
dan sinclair 7156d3e314 [wgsl-reader] Add parsing of named structs.
This CL adds the parsing of structs with names. The parsing of type
aliased structs remains to allow for migration to the new system. The
named struct format is always emitted.

Bug: tint:175
Change-Id: Ic0579dedbd2dd0edc7dfd30bc2ec02972091e718
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30341
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-19 15:31:47 +00:00
dan sinclair 481ecff293 [ast] Require StructType to have a name
This CL moves the StructType name into the constructor of the struct
type instead of receiving through an accessor. The |set_name| accessor
is removed as it should not be needed anymore. All call sites have been
updated.

The vertex pulling transform was fixed to correctly register an alias
for the structure being created so it will be emitted.

Bug: tint:175
Change-Id: I8802931d9bdbc6c2f12982eea9032931939d195c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30280
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-15 17:54:13 +00:00
dan sinclair b4fee2f824 Update builtin methods.
This CL removes the import mechanism, the identifier paths and updates
all of the standard library methods to be builtins.

Bug: tint:242
Change-Id: If09b98a155ae49ced3986ba2c9b517a060693006
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28720
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-22 19:42:13 +00:00
dan sinclair 5f8126271d Remove EntryPoint.
This CL removes the EntryPoint node and transitions everything to the
stage decoration.

Change-Id: Ib2840155905c8fa60ff35870f0c4b6705efb73ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28705
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-22 14:53:03 +00:00
dan sinclair df415a8919 [msl-writer] Generate entry point functions.
This CL generates entry point functions and duplicate functions as
needed to call from the entry points.

Bug: tint:8
Change-Id: I8092ce463248e7a887c26ae05b0774e8fa21ab94
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24764
Reviewed-by: David Neto <dneto@google.com>
2020-07-15 18:04:11 +00:00
dan sinclair a2eb8c52b2 [msl-writer] Generate input/output structs
This CL adds generation of the input/output structures for entry points.

Bug: tint:8
Change-Id: I93942496bcea0a2eea944e5e1cd0baf383530f5e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24721
Reviewed-by: David Neto <dneto@google.com>
2020-07-14 20:37:20 +00:00
Ryan Harrison 0a196c13c8 Adding support for testing BUILD.gn
BUG=tint:50

Change-Id: Ie19a1af6a97a49a67dcc7474991c960b986ddebe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19782
Reviewed-by: David Neto <dneto@google.com>
2020-04-17 13:18:20 +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 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
David Neto 0afb943ebf add ast::Module::to_str
This makes it easier to see the bug.

Bug: tint:22
Change-Id: Ic5acc0b8299ef31eb73b49863bc42ac09de6e9bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17203
Reviewed-by: dan sinclair <dsinclair@google.com>
2020-03-18 20:09:44 +00:00
Dan Sinclair 3eaf827cc8 More module IsValid tests
Bug: tint:11
Change-Id: I1ce2b930f3dbf40791fa68963037e7b9f122658f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16664
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-03-16 14:17:52 +00:00
Dan Sinclair 6e581895a5 Initial commit 2020-03-02 15:47:43 -05:00