tint/transform: Refactor transforms

Replace the ShouldRun() method with Apply() which will do the
transformation if it needs to be done, otherwise returns
'SkipTransform'.

This reduces a bunch of duplicated scanning between the old ShouldRun()
and Transform().

This change also adjusts code style to make the transforms more
consistent.

Change-Id: I9a6b10cb8b4ed62676b12ef30fb7764d363386c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107681
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-11-03 08:41:19 +00:00
committed by Dawn LUCI CQ
parent de6db384aa
commit c6b381495d
111 changed files with 2132 additions and 2205 deletions

View File

@@ -23,6 +23,7 @@
#include "src/tint/ast/access.h"
#include "src/tint/ast/address_space.h"
#include "src/tint/ast/parameter.h"
#include "src/tint/sem/binding_point.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/parameter_usage.h"
@@ -212,6 +213,11 @@ class Parameter final : public Castable<Parameter, Variable> {
/// Destructor
~Parameter() override;
/// @returns the AST declaration node
const ast::Parameter* Declaration() const {
return static_cast<const ast::Parameter*>(Variable::Declaration());
}
/// @return the index of the parmeter in the function
uint32_t Index() const { return index_; }