Fixed: tint:383
Change-Id: I101370a82379363a4fb1f725e010eedc2da059ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35042
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
This CL strips the context object out of Tint.
Change-Id: Id0dcb9c557b217c03a8d9ac08fc9fe1c799f3fdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34742
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);
is a less-idiomatic way of writing:
EXPECT_EQ(xxx, yyy);
The latter also provides a diff when two strings do not match.
Refactor these to:
auto got = xxx;
auto expect = yyy;
EXPECT_EQ(got, expect);
So that the error message clearly shows which one is the generated, and which one is the reference.
Change-Id: I299204a615aa3e68cd82d19ce892ab33aabe2f08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35006
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
instead of transform-in-place.
This is a public API breaking change, so I've added the `DAWN_USE_NEW_TINT_TRANSFORM_API` define which is used by Dawn to know which API to use.
As we're going to have to go through the effort of an API breaking change, use this as an opportunity to rename Transformer to Transform, and remove 'Transform' from each of the transforms themselves (they're already in the transform namespace).
Bug: tint:390
Bug: tint:389
Change-Id: I1017507524b76bb4ffd26b95e550ef53ddc891c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34800
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Transformers will be moving to a transform-on-copy model, instead of transform-in-place.
Rework the tests to handle this.
Bug: tint:390
Change-Id: Id53a0ba0bd365472940d116bd686e450a29e5028
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34571
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Will be used by the transforms
Change-Id: Id4cece30f1ef4cbeb7cf4d7ca8d0e775b4ab4c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34570
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
ReplaceAll() registers `replacer` to be called whenever the Clone() method is called with a type that matches (or derives from) the type of the first parameter of `replacer`.
`replacer` must be function-like with the signature: `T* (T*)`, where `T` is a type deriving from CastableBase.
If `replacer` returns a nullptr then Clone() will attempt the next registered replacer function that matches the object type. If no replacers match the object type, or all returned nullptr then Clone() will call `T::Clone()` to clone the object.
Example:
```
// Replace all ast::UintLiterals with the number 42
CloneCtx ctx(mod);
ctx.ReplaceAll([&] (ast::UintLiteral* in) {
return ctx.mod->create<ast::UintLiteral>(ctx.Clone(in->type()), 42);
});
auto* out = ctx.Clone(tree);
```
This is to be used by Transforms that want to replace parts of the AST on clone.
Bug: tint:390
Change-Id: I80a0e58aa3711f309f58a504f6b6a06f6c546ea1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34568
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Prefix the fully-qualified Unique name in TINT_INSTANTIATE_CLASS_ID with :: as there might (however unlikely) be a nested 'tint' namespace.
Move the test structures in castable_test back into the anonymous namespace. This means `TINT_INSTANTIATE_CLASS_ID` needs to sit outside the anonymous namespace, but prevents global namespace pollution.
Change-Id: I035e9568c081fee120726106dc2150c4990c3881
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34567
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Contains some intimidating template magic for inferring the first parameter type of a function or function-like.
Will be used by the CloneContext for transforming the AST while cloning.
Bug: tint:390
Change-Id: I432059d13e65fa0f0f3e52588eb43abe9a4efadd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34566
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
EmitVertexPointSizeTransform is a Transformer that adds a PointSize builtin global output variable to the module which is assigned 1.0 as the new first statement for all vertex stage entry points.
If the module does not contain a vertex pipeline stage entry point then then this transformer is a no-op.
Bug: tint:321
Change-Id: I0e01236339d9fa1ceab3622af0931a1199c33b99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34561
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL removes all internal usage of the Context object. It is still
accepted as a parameter until we update Dawn, but all usage is removed.
The namer has been removed from the SPIR-V backend with this change and
the emitted names reverted to their non-modified version.
Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL updates the SPIRV-Reader to not require set methods for various
AST expressions.
Change-Id: Ieb9a8fcc1746d3051e5b663559127ca63b45a388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34642
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
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>
We're seeing some chrome bots fail unittests in ways that suspiciously
look like dynamic casts are doing Wrong Things.
The ClassID::Of() logic depends on the linker folding away duplicate
compilation unit definitions based on ODR rules. If we were to somehow
end up with different definitions, then we'd have two or more different
ClassIDs for the same T type - leading to issues similar to what we're
seeing.
I'm not entirely sure why/how this could happen - and we've so far been
entirely unable to locally reproduce - but it _might_ have something to
do with the goma cache.
In an attempt to work around this, move the static symbol definition out
of a header-local-static and into the .cc file for each of the types.
Change-Id: If914d3045b9dac6fbe8824dac71153a768cfceb9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34563
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
When handling OpCompositeExtract, the SPIRV reader uses a
stack-allocated U32 type instead of one heap allocated by the
type manager. This causes type determination later to dereference
a garbage address.
Change-Id: I7d60b6dbf8310e53565d7db47eac4dd92b1bbfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34684
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
The new module clone tests require the WGSL reader and writer in order
to function. This Cl adds those dependencies to the BUILD.gn file.
Change-Id: I34cd9a7de13a99145bad1f559c23d181f4fb7739
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34683
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
This fixes the build when using gcc.
Change-Id: I98b9afcf0b40b692e46f92dc4b71583e41877281
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34681
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
We've been using |blah| in various places to markup code, however this is not doxygen markup. So instead:
* If the code links to a parameter, use `blah`.
* If the code links to a member field, use #blah.
* If the code links to a method use blah().
* If the code is somewhere unlinkable use `blah`.
Change-Id: Idac748a4c2531b5bae77e1a335e3d3ef6fab48b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33787
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
The AST clone fuzzer was accidentally named the same as the
SPIRV-Reader fuzzer. This Cl renames to fixup the conflict.
Change-Id: I757163718dc4e2097564427f4ac9f97a6cba9d55
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34680
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
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>
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>
This enables usage with DAWN_TRY_ASSIGN in Dawn in simplify error
handling.
Bug: tint:306
Change-Id: I91a96b6670341943c26d9972058ecc3ad8162db0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34640
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This CL adds the Move constructor to castable base as the default one is
deleted due to the defined destructor and the Node subclass defines a
Move constructor.
Change-Id: I0eaac140719e74adfab1aeccf6ea663faff031e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34580
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Both OpImageRead and OpImageFetch map to WGSL textureLoad.
Bug: tint:109
Change-Id: I3c99840c2e62c52dcaaf7177773a3c972de90cc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34425
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
This CL updates the WGSL-Reader to remove the decoration keywords as
they are no longer reserved in the spec. The old `::` token is removed
as well as namespaces don't exist anymore.
Change-Id: I1dfa16c1d7e4866f6c2f9ea7b4f93a48ff5a23d7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34481
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This assert is only enforcing that the input is valid, not that it is
safe. This should be deferred until validation.
Bug: dawn:578
Change-Id: I083a62292ff7ca0fc35080d8c66dabf3188c7bca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34480
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Deep-clones all `Node`s and `Type`s into a new module.
Instead of writing a million standalone tests that'll only ever test the
existing fields of each type, I've opted to write the tests using
wgsl<->ast<->wgsl conversion. This means the tests require the enabling
of TINT_BUILD_WGSL_READER and TINT_BUILD_WGSL_WRITER, but I believe this
is much easier to maintain.
I'm aware there are probably gaps in the tests, and that even full
coverage is likely to rapidly rot, so I've also added
fuzzers/tint_ast_clone_fuzzer.cc - a fuzzer based test that ensures that
all AST modules can be cloned with identical reproduction.
I've run this across 100 cores of a 3990x for 4 hours, fixing the
single issue it detected.
Note: Expressions do not currently clone their `TypeManager` determined
types. This is for two reasons:
(a) This initial CL is mahoosive enough.
(b) I'm uncertain whether we actually want to clone this info, or to
re-run the `TypeDeterminer` after each AST transform. Maybe it should
be optional. Time will tell.
Fixed: tint:307
Change-Id: Id90fab06aaa740c805d12b66f3f11d1f452c6805
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33300
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
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>
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>