tint: Optimize sem node lookup

Add a 'NodeID' to each ast::Node which is the sequentially allocated
index of the node. Use this in sem::Info to map the AST node to the
semantic node, instead of using a std::unordered_map.

Optimised very hot code by entirely eliminating map lookups, and
dramatically reducing cache misses (lookups are usually sequentually
ordered).

Timings running
'webgpu:shader,execution,expression,call,builtin,atan2:f32:inputSource="const";vectorize="_undef_"'
with dawn/node, using SwiftShader:

    Without change: 3.22647107s
    With change:    3.10578879s

Bug: tint:1613
Change-Id: I22ec48d933b2e5f9da04494bff4e979e6f7b1982
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96140
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2022-07-18 20:50:02 +00:00 committed by Dawn LUCI CQ
parent 8d73198aca
commit 4a92a3c904
192 changed files with 608 additions and 289 deletions

View File

@ -287,6 +287,7 @@ libtint_source_set("libtint_core_all_src") {
"ast/module.h",
"ast/multisampled_texture.cc",
"ast/multisampled_texture.h",
"ast/node_id.h",
"ast/node.cc",
"ast/node.h",
"ast/override.cc",

View File

@ -157,6 +157,7 @@ set(TINT_LIB_SRCS
ast/module.h
ast/multisampled_texture.cc
ast/multisampled_texture.h
ast/node_id.h
ast/node.cc
ast/node.h
ast/override.cc

View File

@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Alias);
namespace tint::ast {
Alias::Alias(ProgramID pid, const Source& src, const Symbol& n, const Type* subtype)
: Base(pid, src, n), type(subtype) {
Alias::Alias(ProgramID pid, NodeID nid, const Source& src, const Symbol& n, const Type* subtype)
: Base(pid, nid, src, n), type(subtype) {
TINT_ASSERT(AST, type);
}

View File

@ -26,10 +26,11 @@ class Alias final : public Castable<Alias, TypeDecl> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param name the symbol for the alias
/// @param subtype the alias'd type
Alias(ProgramID pid, const Source& src, const Symbol& name, const Type* subtype);
Alias(ProgramID pid, NodeID nid, const Source& src, const Symbol& name, const Type* subtype);
/// Move constructor
Alias(Alias&&);
/// Destructor

View File

@ -38,11 +38,12 @@ std::string SizeExprToString(const Expression* size, const SymbolTable& symbols)
} // namespace
Array::Array(ProgramID pid,
NodeID nid,
const Source& src,
const Type* subtype,
const Expression* cnt,
AttributeList attrs)
: Base(pid, src), type(subtype), count(cnt), attributes(attrs) {}
: Base(pid, nid, src), type(subtype), count(cnt), attributes(attrs) {}
Array::Array(Array&&) = default;

View File

@ -32,12 +32,14 @@ class Array final : public Castable<Array, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param subtype the type of the array elements
/// @param count the number of elements in the array. nullptr represents a
/// runtime-sized array.
/// @param attributes the array attributes
Array(ProgramID pid,
NodeID nid,
const Source& src,
const Type* subtype,
const Expression* count,

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::AssignmentStatement);
namespace tint::ast {
AssignmentStatement::AssignmentStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* l,
const Expression* r)
: Base(pid, src), lhs(l), rhs(r) {
: Base(pid, nid, src), lhs(l), rhs(r) {
TINT_ASSERT(AST, lhs);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
TINT_ASSERT(AST, rhs);

View File

@ -24,11 +24,13 @@ namespace tint::ast {
class AssignmentStatement final : public Castable<AssignmentStatement, Statement> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the assignment statement source
/// @param lhs the left side of the expression
/// @param rhs the right side of the expression
AssignmentStatement(ProgramID program_id,
AssignmentStatement(ProgramID pid,
NodeID nid,
const Source& source,
const Expression* lhs,
const Expression* rhs);

View File

@ -30,7 +30,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Type);
namespace tint::ast {
Type::Type(ProgramID pid, const Source& src) : Base(pid, src) {}
Type::Type(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
Type::Type(Type&&) = default;

View File

@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Atomic);
namespace tint::ast {
Atomic::Atomic(ProgramID pid, const Source& src, const Type* const subtype)
: Base(pid, src), type(subtype) {}
Atomic::Atomic(ProgramID pid, NodeID nid, const Source& src, const Type* const subtype)
: Base(pid, nid, src), type(subtype) {}
std::string Atomic::FriendlyName(const SymbolTable& symbols) const {
std::ostringstream out;

View File

@ -26,9 +26,10 @@ class Atomic final : public Castable<Atomic, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param subtype the pointee type
Atomic(ProgramID pid, const Source& src, const Type* const subtype);
Atomic(ProgramID pid, NodeID nid, const Source& src, const Type* const subtype);
/// Move constructor
Atomic(Atomic&&);
~Atomic() override;

View File

@ -33,8 +33,9 @@ class Attribute : public Castable<Attribute, Node> {
protected:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
Attribute(ProgramID pid, const Source& src) : Base(pid, src) {}
Attribute(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
};
/// A list of attributes

View File

@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BinaryExpression);
namespace tint::ast {
BinaryExpression::BinaryExpression(ProgramID pid,
NodeID nid,
const Source& src,
BinaryOp o,
const Expression* l,
const Expression* r)
: Base(pid, src), op(o), lhs(l), rhs(r) {
: Base(pid, nid, src), op(o), lhs(l), rhs(r) {
TINT_ASSERT(AST, lhs);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
TINT_ASSERT(AST, rhs);

View File

@ -46,12 +46,14 @@ enum class BinaryOp {
class BinaryExpression final : public Castable<BinaryExpression, Expression> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the binary expression source
/// @param op the operation type
/// @param lhs the left side of the expression
/// @param rhs the right side of the expression
BinaryExpression(ProgramID program_id,
BinaryExpression(ProgramID pid,
NodeID nid,
const Source& source,
BinaryOp op,
const Expression* lhs,

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BindingAttribute);
namespace tint::ast {
BindingAttribute::BindingAttribute(ProgramID pid, const Source& src, uint32_t val)
: Base(pid, src), value(val) {}
BindingAttribute::BindingAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
: Base(pid, nid, src), value(val) {}
BindingAttribute::~BindingAttribute() = default;

View File

@ -26,9 +26,10 @@ class BindingAttribute final : public Castable<BindingAttribute, Attribute> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the binding value
BindingAttribute(ProgramID pid, const Source& src, uint32_t value);
BindingAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
~BindingAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BitcastExpression);
namespace tint::ast {
BitcastExpression::BitcastExpression(ProgramID pid,
NodeID nid,
const Source& src,
const Type* t,
const Expression* e)
: Base(pid, src), type(t), expr(e) {
: Base(pid, nid, src), type(t), expr(e) {
TINT_ASSERT(AST, type);
TINT_ASSERT(AST, expr);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);

View File

@ -28,11 +28,13 @@ namespace tint::ast {
class BitcastExpression final : public Castable<BitcastExpression, Expression> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the bitcast expression source
/// @param type the type
/// @param expr the expr
BitcastExpression(ProgramID program_id,
BitcastExpression(ProgramID pid,
NodeID nid,
const Source& source,
const Type* type,
const Expression* expr);

View File

@ -20,8 +20,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BlockStatement);
namespace tint::ast {
BlockStatement::BlockStatement(ProgramID pid, const Source& src, const StatementList& stmts)
: Base(pid, src), statements(std::move(stmts)) {
BlockStatement::BlockStatement(ProgramID pid,
NodeID nid,
const Source& src,
const StatementList& stmts)
: Base(pid, nid, src), statements(std::move(stmts)) {
for (auto* stmt : statements) {
TINT_ASSERT(AST, stmt);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, stmt, program_id);

View File

@ -25,10 +25,14 @@ namespace tint::ast {
class BlockStatement final : public Castable<BlockStatement, Statement> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the block statement source
/// @param statements the statements
BlockStatement(ProgramID program_id, const Source& source, const StatementList& statements);
BlockStatement(ProgramID pid,
NodeID nid,
const Source& source,
const StatementList& statements);
/// Move constructor
BlockStatement(BlockStatement&&);
~BlockStatement() override;

View File

@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Bool);
namespace tint::ast {
Bool::Bool(ProgramID pid, const Source& src) : Base(pid, src) {}
Bool::Bool(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
Bool::Bool(Bool&&) = default;

View File

@ -32,8 +32,9 @@ class Bool final : public Castable<Bool, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
Bool(ProgramID pid, const Source& src);
Bool(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
Bool(Bool&&);
~Bool() override;

View File

@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BoolLiteralExpression);
namespace tint::ast {
BoolLiteralExpression::BoolLiteralExpression(ProgramID pid, const Source& src, bool val)
: Base(pid, src), value(val) {}
BoolLiteralExpression::BoolLiteralExpression(ProgramID pid, NodeID nid, const Source& src, bool val)
: Base(pid, nid, src), value(val) {}
BoolLiteralExpression::~BoolLiteralExpression() = default;

View File

@ -26,9 +26,10 @@ class BoolLiteralExpression final : public Castable<BoolLiteralExpression, Liter
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the bool literals value
BoolLiteralExpression(ProgramID pid, const Source& src, bool value);
BoolLiteralExpression(ProgramID pid, NodeID nid, const Source& src, bool value);
~BoolLiteralExpression() override;
/// Clones this node and all transitive child nodes using the `CloneContext`

View File

@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BreakStatement);
namespace tint::ast {
BreakStatement::BreakStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
BreakStatement::BreakStatement(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
BreakStatement::BreakStatement(BreakStatement&&) = default;

View File

@ -24,8 +24,9 @@ class BreakStatement final : public Castable<BreakStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
BreakStatement(ProgramID pid, const Source& src);
BreakStatement(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
BreakStatement(BreakStatement&&);
~BreakStatement() override;

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BuiltinAttribute);
namespace tint::ast {
BuiltinAttribute::BuiltinAttribute(ProgramID pid, const Source& src, Builtin b)
: Base(pid, src), builtin(b) {}
BuiltinAttribute::BuiltinAttribute(ProgramID pid, NodeID nid, const Source& src, Builtin b)
: Base(pid, nid, src), builtin(b) {}
BuiltinAttribute::~BuiltinAttribute() = default;

View File

@ -27,9 +27,10 @@ class BuiltinAttribute final : public Castable<BuiltinAttribute, Attribute> {
public:
/// constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param builtin the builtin value
BuiltinAttribute(ProgramID pid, const Source& src, Builtin builtin);
BuiltinAttribute(ProgramID pid, NodeID nid, const Source& src, Builtin builtin);
~BuiltinAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -34,10 +34,11 @@ CallExpression::Target ToTarget(const Type* type) {
} // namespace
CallExpression::CallExpression(ProgramID pid,
NodeID nid,
const Source& src,
const IdentifierExpression* name,
ExpressionList a)
: Base(pid, src), target(ToTarget(name)), args(a) {
: Base(pid, nid, src), target(ToTarget(name)), args(a) {
TINT_ASSERT(AST, name);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, name, program_id);
for (auto* arg : args) {
@ -46,8 +47,12 @@ CallExpression::CallExpression(ProgramID pid,
}
}
CallExpression::CallExpression(ProgramID pid, const Source& src, const Type* type, ExpressionList a)
: Base(pid, src), target(ToTarget(type)), args(a) {
CallExpression::CallExpression(ProgramID pid,
NodeID nid,
const Source& src,
const Type* type,
ExpressionList a)
: Base(pid, nid, src), target(ToTarget(type)), args(a) {
TINT_ASSERT(AST, type);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, type, program_id);
for (auto* arg : args) {

View File

@ -33,21 +33,25 @@ namespace tint::ast {
class CallExpression final : public Castable<CallExpression, Expression> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the call expression source
/// @param name the function or type name
/// @param args the arguments
CallExpression(ProgramID program_id,
CallExpression(ProgramID pid,
NodeID nid,
const Source& source,
const IdentifierExpression* name,
ExpressionList args);
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the call expression source
/// @param type the type
/// @param args the arguments
CallExpression(ProgramID program_id,
CallExpression(ProgramID pid,
NodeID nid,
const Source& source,
const Type* type,
ExpressionList args);

View File

@ -20,8 +20,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CallStatement);
namespace tint::ast {
CallStatement::CallStatement(ProgramID pid, const Source& src, const CallExpression* call)
: Base(pid, src), expr(call) {
CallStatement::CallStatement(ProgramID pid,
NodeID nid,
const Source& src,
const CallExpression* call)
: Base(pid, nid, src), expr(call) {
TINT_ASSERT(AST, expr);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);
}

View File

@ -25,9 +25,10 @@ class CallStatement final : public Castable<CallStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node for the statement
/// @param call the function
CallStatement(ProgramID pid, const Source& src, const CallExpression* call);
CallStatement(ProgramID pid, NodeID nid, const Source& src, const CallExpression* call);
/// Move constructor
CallStatement(CallStatement&&);
~CallStatement() override;

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CaseStatement);
namespace tint::ast {
CaseStatement::CaseStatement(ProgramID pid,
NodeID nid,
const Source& src,
CaseSelectorList s,
const BlockStatement* b)
: Base(pid, src), selectors(s), body(b) {
: Base(pid, nid, src), selectors(s), body(b) {
TINT_ASSERT(AST, body);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
for (auto* selector : selectors) {

View File

@ -30,10 +30,12 @@ class CaseStatement final : public Castable<CaseStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param selectors the case selectors
/// @param body the case body
CaseStatement(ProgramID pid,
NodeID nid,
const Source& src,
CaseSelectorList selectors,
const BlockStatement* body);

View File

@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CompoundAssignmentStatement);
namespace tint::ast {
CompoundAssignmentStatement::CompoundAssignmentStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* l,
const Expression* r,
BinaryOp o)
: Base(pid, src), lhs(l), rhs(r), op(o) {
: Base(pid, nid, src), lhs(l), rhs(r), op(o) {
TINT_ASSERT(AST, lhs);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
TINT_ASSERT(AST, rhs);

View File

@ -25,12 +25,14 @@ namespace tint::ast {
class CompoundAssignmentStatement final : public Castable<CompoundAssignmentStatement, Statement> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the compound assignment statement source
/// @param lhs the left side of the expression
/// @param rhs the right side of the expression
/// @param op the binary operator
CompoundAssignmentStatement(ProgramID program_id,
CompoundAssignmentStatement(ProgramID pid,
NodeID nid,
const Source& source,
const Expression* lhs,
const Expression* rhs,

View File

@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Const);
namespace tint::ast {
Const::Const(ProgramID pid,
NodeID nid,
const Source& src,
const Symbol& sym,
const ast::Type* ty,
const Expression* ctor,
AttributeList attrs)
: Base(pid, src, sym, ty, ctor, attrs) {
: Base(pid, nid, src, sym, ty, ctor, attrs) {
TINT_ASSERT(AST, ctor != nullptr);
}

View File

@ -33,13 +33,15 @@ namespace tint::ast {
class Const final : public Castable<Const, Variable> {
public:
/// Create a 'const' creation-time value variable.
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the variable source
/// @param sym the variable symbol
/// @param type the declared variable type
/// @param constructor the constructor expression. Must not be nullptr.
/// @param attributes the variable attributes
Const(ProgramID program_id,
Const(ProgramID pid,
NodeID nid,
const Source& source,
const Symbol& sym,
const ast::Type* type,

View File

@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ContinueStatement);
namespace tint::ast {
ContinueStatement::ContinueStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
ContinueStatement::ContinueStatement(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;

View File

@ -24,8 +24,9 @@ class ContinueStatement final : public Castable<ContinueStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
ContinueStatement(ProgramID pid, const Source& src);
ContinueStatement(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
ContinueStatement(ContinueStatement&&);
~ContinueStatement() override;

View File

@ -28,9 +28,10 @@ bool IsValidDepthDimension(TextureDimension dim) {
} // namespace
DepthMultisampledTexture::DepthMultisampledTexture(ProgramID pid,
NodeID nid,
const Source& src,
TextureDimension d)
: Base(pid, src, d) {
: Base(pid, nid, src, d) {
TINT_ASSERT(AST, IsValidDepthDimension(dim));
}

View File

@ -26,9 +26,10 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param dim the dimensionality of the texture
DepthMultisampledTexture(ProgramID pid, const Source& src, TextureDimension dim);
DepthMultisampledTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
/// Move constructor
DepthMultisampledTexture(DepthMultisampledTexture&&);
~DepthMultisampledTexture() override;

View File

@ -28,8 +28,8 @@ bool IsValidDepthDimension(TextureDimension dim) {
} // namespace
DepthTexture::DepthTexture(ProgramID pid, const Source& src, TextureDimension d)
: Base(pid, src, d) {
DepthTexture::DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension d)
: Base(pid, nid, src, d) {
TINT_ASSERT(AST, IsValidDepthDimension(dim));
}

View File

@ -26,9 +26,10 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param dim the dimensionality of the texture
DepthTexture(ProgramID pid, const Source& src, TextureDimension dim);
DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
/// Move constructor
DepthTexture(DepthTexture&&);
~DepthTexture() override;

View File

@ -20,8 +20,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DisableValidationAttribute);
namespace tint::ast {
DisableValidationAttribute::DisableValidationAttribute(ProgramID pid, DisabledValidation val)
: Base(pid), validation(val) {}
DisableValidationAttribute::DisableValidationAttribute(ProgramID pid,
NodeID nid,
DisabledValidation val)
: Base(pid, nid), validation(val) {}
DisableValidationAttribute::~DisableValidationAttribute() = default;
@ -46,7 +48,8 @@ std::string DisableValidationAttribute::InternalName() const {
}
const DisableValidationAttribute* DisableValidationAttribute::Clone(CloneContext* ctx) const {
return ctx->dst->ASTNodes().Create<DisableValidationAttribute>(ctx->dst->ID(), validation);
return ctx->dst->ASTNodes().Create<DisableValidationAttribute>(
ctx->dst->ID(), ctx->dst->AllocateNodeID(), validation);
}
} // namespace tint::ast

View File

@ -51,9 +51,10 @@ class DisableValidationAttribute final
: public Castable<DisableValidationAttribute, InternalAttribute> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param validation the validation to disable
explicit DisableValidationAttribute(ProgramID program_id, DisabledValidation validation);
explicit DisableValidationAttribute(ProgramID pid, NodeID nid, DisabledValidation validation);
/// Destructor
~DisableValidationAttribute() override;

View File

@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DiscardStatement);
namespace tint::ast {
DiscardStatement::DiscardStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
DiscardStatement::DiscardStatement(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
DiscardStatement::DiscardStatement(DiscardStatement&&) = default;

View File

@ -24,8 +24,9 @@ class DiscardStatement final : public Castable<DiscardStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
DiscardStatement(ProgramID pid, const Source& src);
DiscardStatement(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
DiscardStatement(DiscardStatement&&);
~DiscardStatement() override;

View File

@ -21,7 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Enable);
namespace tint::ast {
Enable::Enable(ProgramID pid, const Source& src, Extension ext) : Base(pid, src), extension(ext) {}
Enable::Enable(ProgramID pid, NodeID nid, const Source& src, Extension ext)
: Base(pid, nid, src), extension(ext) {}
Enable::Enable(Enable&&) = default;

View File

@ -33,9 +33,10 @@ class Enable final : public Castable<Enable, Node> {
public:
/// Create a extension
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param ext the extension
Enable(ProgramID pid, const Source& src, Extension ext);
Enable(ProgramID pid, NodeID nid, const Source& src, Extension ext);
/// Move constructor
Enable(Enable&&);

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Expression);
namespace tint::ast {
Expression::Expression(ProgramID pid, const Source& src) : Base(pid, src) {}
Expression::Expression(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
Expression::Expression(Expression&&) = default;

View File

@ -31,8 +31,9 @@ class Expression : public Castable<Expression, Node> {
protected:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
Expression(ProgramID pid, const Source& src);
Expression(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
Expression(Expression&&);
};

View File

@ -21,8 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ExternalTexture);
namespace tint::ast {
// ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
ExternalTexture::ExternalTexture(ProgramID pid, const Source& src)
: Base(pid, src, ast::TextureDimension::k2d) {}
ExternalTexture::ExternalTexture(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src, ast::TextureDimension::k2d) {}
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;

View File

@ -26,8 +26,9 @@ class ExternalTexture final : public Castable<ExternalTexture, Texture> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
ExternalTexture(ProgramID pid, const Source& src);
ExternalTexture(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
ExternalTexture(ExternalTexture&&);

View File

@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::F16);
namespace tint::ast {
F16::F16(ProgramID pid, const Source& src) : Base(pid, src) {}
F16::F16(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
F16::F16(F16&&) = default;

View File

@ -26,8 +26,9 @@ class F16 : public Castable<F16, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
F16(ProgramID pid, const Source& src);
F16(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
F16(F16&&);
~F16() override;

View File

@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::F32);
namespace tint::ast {
F32::F32(ProgramID pid, const Source& src) : Base(pid, src) {}
F32::F32(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
F32::F32(F32&&) = default;

View File

@ -26,8 +26,9 @@ class F32 final : public Castable<F32, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
F32(ProgramID pid, const Source& src);
F32(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
F32(F32&&);
~F32() override;

View File

@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FallthroughStatement);
namespace tint::ast {
FallthroughStatement::FallthroughStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
FallthroughStatement::FallthroughStatement(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;

View File

@ -24,8 +24,9 @@ class FallthroughStatement final : public Castable<FallthroughStatement, Stateme
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
FallthroughStatement(ProgramID pid, const Source& src);
FallthroughStatement(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
FallthroughStatement(FallthroughStatement&&);
~FallthroughStatement() override;

View File

@ -23,10 +23,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FloatLiteralExpression);
namespace tint::ast {
FloatLiteralExpression::FloatLiteralExpression(ProgramID pid,
NodeID nid,
const Source& src,
double val,
Suffix suf)
: Base(pid, src), value(val), suffix(suf) {}
: Base(pid, nid, src), value(val), suffix(suf) {}
FloatLiteralExpression::~FloatLiteralExpression() = default;

View File

@ -36,10 +36,11 @@ class FloatLiteralExpression final : public Castable<FloatLiteralExpression, Lit
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param val the literal value
/// @param suf the literal suffix
FloatLiteralExpression(ProgramID pid, const Source& src, double val, Suffix suf);
FloatLiteralExpression(ProgramID pid, NodeID nid, const Source& src, double val, Suffix suf);
~FloatLiteralExpression() override;
/// Clones this node and all transitive child nodes using the `CloneContext`

View File

@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ForLoopStatement);
namespace tint::ast {
ForLoopStatement::ForLoopStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Statement* init,
const Expression* cond,
const Statement* cont,
const BlockStatement* b)
: Base(pid, src), initializer(init), condition(cond), continuing(cont), body(b) {
: Base(pid, nid, src), initializer(init), condition(cond), continuing(cont), body(b) {
TINT_ASSERT(AST, body);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, initializer, program_id);

View File

@ -25,14 +25,16 @@ class Expression;
class ForLoopStatement final : public Castable<ForLoopStatement, Statement> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the for loop statement source
/// @param initializer the optional loop initializer statement
/// @param condition the optional loop condition expression
/// @param continuing the optional continuing statement
/// @param body the loop body
ForLoopStatement(ProgramID program_id,
Source const& source,
ForLoopStatement(ProgramID pid,
NodeID nid,
const Source& source,
const Statement* initializer,
const Expression* condition,
const Statement* continuing,

View File

@ -23,6 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Function);
namespace tint::ast {
Function::Function(ProgramID pid,
NodeID nid,
const Source& src,
Symbol sym,
ParameterList parameters,
@ -30,7 +31,7 @@ Function::Function(ProgramID pid,
const BlockStatement* b,
AttributeList attrs,
AttributeList return_type_attrs)
: Base(pid, src),
: Base(pid, nid, src),
symbol(sym),
params(std::move(parameters)),
return_type(return_ty),

View File

@ -35,7 +35,8 @@ namespace tint::ast {
class Function final : public Castable<Function, Node> {
public:
/// Create a function
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the variable source
/// @param symbol the function symbol
/// @param params the function parameters
@ -43,7 +44,8 @@ class Function final : public Castable<Function, Node> {
/// @param body the function body
/// @param attributes the function attributes
/// @param return_type_attributes the return type attributes
Function(ProgramID program_id,
Function(ProgramID pid,
NodeID nid,
const Source& source,
Symbol symbol,
ParameterList params,

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::GroupAttribute);
namespace tint::ast {
GroupAttribute::GroupAttribute(ProgramID pid, const Source& src, uint32_t val)
: Base(pid, src), value(val) {}
GroupAttribute::GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
: Base(pid, nid, src), value(val) {}
GroupAttribute::~GroupAttribute() = default;

View File

@ -26,9 +26,10 @@ class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
public:
/// constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the group value
GroupAttribute(ProgramID pid, const Source& src, uint32_t value);
GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
~GroupAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::I32);
namespace tint::ast {
I32::I32(ProgramID pid, const Source& src) : Base(pid, src) {}
I32::I32(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
I32::I32(I32&&) = default;

View File

@ -26,8 +26,9 @@ class I32 final : public Castable<I32, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
I32(ProgramID pid, const Source& src);
I32(ProgramID pid, NodeID nid, const Source& src);
/// Move constructor
I32(I32&&);
~I32() override;

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdAttribute);
namespace tint::ast {
IdAttribute::IdAttribute(ProgramID pid, const Source& src, uint32_t val)
: Base(pid, src), value(val) {}
IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
: Base(pid, nid, src), value(val) {}
IdAttribute::~IdAttribute() = default;

View File

@ -26,9 +26,10 @@ class IdAttribute final : public Castable<IdAttribute, Attribute> {
public:
/// Create an id attribute.
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param val the numeric id value
IdAttribute(ProgramID pid, const Source& src, uint32_t val);
IdAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val);
~IdAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdentifierExpression);
namespace tint::ast {
IdentifierExpression::IdentifierExpression(ProgramID pid, const Source& src, Symbol sym)
: Base(pid, src), symbol(sym) {
IdentifierExpression::IdentifierExpression(ProgramID pid, NodeID nid, const Source& src, Symbol sym)
: Base(pid, nid, src), symbol(sym) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, symbol, program_id);
TINT_ASSERT(AST, symbol.IsValid());
}

View File

@ -24,9 +24,10 @@ class IdentifierExpression final : public Castable<IdentifierExpression, Express
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param sym the symbol for the identifier
IdentifierExpression(ProgramID pid, const Source& src, Symbol sym);
IdentifierExpression(ProgramID pid, NodeID nid, const Source& src, Symbol sym);
/// Move constructor
IdentifierExpression(IdentifierExpression&&);
~IdentifierExpression() override;

View File

@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IfStatement);
namespace tint::ast {
IfStatement::IfStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* cond,
const BlockStatement* b,
const Statement* else_stmt)
: Base(pid, src), condition(cond), body(b), else_statement(else_stmt) {
: Base(pid, nid, src), condition(cond), body(b), else_statement(else_stmt) {
TINT_ASSERT(AST, condition);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, condition, program_id);
TINT_ASSERT(AST, body);

View File

@ -27,11 +27,13 @@ class IfStatement final : public Castable<IfStatement, Statement> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param condition the if condition
/// @param body the if body
/// @param else_stmt the else statement, or nullptr
IfStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* condition,
const BlockStatement* body,

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IncrementDecrementStatement);
namespace tint::ast {
IncrementDecrementStatement::IncrementDecrementStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* l,
bool inc)
: Base(pid, src), lhs(l), increment(inc) {
: Base(pid, nid, src), lhs(l), increment(inc) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
}

View File

@ -25,10 +25,15 @@ class IncrementDecrementStatement final : public Castable<IncrementDecrementStat
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param lhs the LHS expression
/// @param inc `true` for increment, `false` for decrement
IncrementDecrementStatement(ProgramID pid, const Source& src, const Expression* lhs, bool inc);
IncrementDecrementStatement(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* lhs,
bool inc);
/// Move constructor
IncrementDecrementStatement(IncrementDecrementStatement&&);
~IncrementDecrementStatement() override;

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IndexAccessorExpression);
namespace tint::ast {
IndexAccessorExpression::IndexAccessorExpression(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* obj,
const Expression* idx)
: Base(pid, src), object(obj), index(idx) {
: Base(pid, nid, src), object(obj), index(idx) {
TINT_ASSERT(AST, object);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, object, program_id);
TINT_ASSERT(AST, idx);

View File

@ -23,11 +23,13 @@ namespace tint::ast {
class IndexAccessorExpression final : public Castable<IndexAccessorExpression, Expression> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the index accessor source
/// @param obj the object
/// @param idx the index expression
IndexAccessorExpression(ProgramID program_id,
IndexAccessorExpression(ProgramID pid,
NodeID nid,
const Source& source,
const Expression* obj,
const Expression* idx);

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IntLiteralExpression);
namespace tint::ast {
IntLiteralExpression::IntLiteralExpression(ProgramID pid,
NodeID nid,
const Source& src,
int64_t val,
Suffix suf)
: Base(pid, src), value(val), suffix(suf) {}
: Base(pid, nid, src), value(val), suffix(suf) {}
IntLiteralExpression::~IntLiteralExpression() = default;

View File

@ -34,10 +34,11 @@ class IntLiteralExpression : public Castable<IntLiteralExpression, LiteralExpres
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param val the literal value
/// @param suf the literal suffix
IntLiteralExpression(ProgramID pid, const Source& src, int64_t val, Suffix suf);
IntLiteralExpression(ProgramID pid, NodeID nid, const Source& src, int64_t val, Suffix suf);
~IntLiteralExpression() override;

View File

@ -18,7 +18,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InternalAttribute);
namespace tint::ast {
InternalAttribute::InternalAttribute(ProgramID pid) : Base(pid, Source{}) {}
InternalAttribute::InternalAttribute(ProgramID pid, NodeID nid) : Base(pid, nid, Source{}) {}
InternalAttribute::~InternalAttribute() = default;

View File

@ -28,7 +28,8 @@ class InternalAttribute : public Castable<InternalAttribute, Attribute> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
explicit InternalAttribute(ProgramID program_id);
/// @param nid the unique node identifier
explicit InternalAttribute(ProgramID program_id, NodeID nid);
/// Destructor
~InternalAttribute() override;

View File

@ -23,10 +23,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InterpolateAttribute);
namespace tint::ast {
InterpolateAttribute::InterpolateAttribute(ProgramID pid,
NodeID nid,
const Source& src,
InterpolationType ty,
InterpolationSampling smpl)
: Base(pid, src), type(ty), sampling(smpl) {}
: Base(pid, nid, src), type(ty), sampling(smpl) {}
InterpolateAttribute::~InterpolateAttribute() = default;

View File

@ -33,10 +33,12 @@ class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribu
public:
/// Create an interpolate attribute.
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param type the interpolation type
/// @param sampling the interpolation sampling
InterpolateAttribute(ProgramID pid,
NodeID nid,
const Source& src,
InterpolationType type,
InterpolationSampling sampling);

View File

@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InvariantAttribute);
namespace tint::ast {
InvariantAttribute::InvariantAttribute(ProgramID pid, const Source& src) : Base(pid, src) {}
InvariantAttribute::InvariantAttribute(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
InvariantAttribute::~InvariantAttribute() = default;

View File

@ -26,8 +26,9 @@ class InvariantAttribute final : public Castable<InvariantAttribute, Attribute>
public:
/// constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
InvariantAttribute(ProgramID pid, const Source& src);
InvariantAttribute(ProgramID pid, NodeID nid, const Source& src);
~InvariantAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Let);
namespace tint::ast {
Let::Let(ProgramID pid,
NodeID nid,
const Source& src,
const Symbol& sym,
const ast::Type* ty,
const Expression* ctor,
AttributeList attrs)
: Base(pid, src, sym, ty, ctor, attrs) {
: Base(pid, nid, src, sym, ty, ctor, attrs) {
TINT_ASSERT(AST, ctor != nullptr);
}

View File

@ -30,13 +30,15 @@ namespace tint::ast {
class Let final : public Castable<Let, Variable> {
public:
/// Create a 'let' variable
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the variable source
/// @param sym the variable symbol
/// @param type the declared variable type
/// @param constructor the constructor expression
/// @param attributes the variable attributes
Let(ProgramID program_id,
Let(ProgramID pid,
NodeID nid,
const Source& source,
const Symbol& sym,
const ast::Type* type,

View File

@ -18,7 +18,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LiteralExpression);
namespace tint::ast {
LiteralExpression::LiteralExpression(ProgramID pid, const Source& src) : Base(pid, src) {}
LiteralExpression::LiteralExpression(ProgramID pid, NodeID nid, const Source& src)
: Base(pid, nid, src) {}
LiteralExpression::~LiteralExpression() = default;

View File

@ -29,8 +29,9 @@ class LiteralExpression : public Castable<LiteralExpression, Expression> {
protected:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the input source
LiteralExpression(ProgramID pid, const Source& src);
LiteralExpression(ProgramID pid, NodeID nid, const Source& src);
};
} // namespace tint::ast

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LocationAttribute);
namespace tint::ast {
LocationAttribute::LocationAttribute(ProgramID pid, const Source& src, uint32_t val)
: Base(pid, src), value(val) {}
LocationAttribute::LocationAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
: Base(pid, nid, src), value(val) {}
LocationAttribute::~LocationAttribute() = default;

View File

@ -26,9 +26,10 @@ class LocationAttribute final : public Castable<LocationAttribute, Attribute> {
public:
/// constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param value the location value
LocationAttribute(ProgramID pid, const Source& src, uint32_t value);
LocationAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
~LocationAttribute() override;
/// @returns the WGSL name for the attribute

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LoopStatement);
namespace tint::ast {
LoopStatement::LoopStatement(ProgramID pid,
NodeID nid,
const Source& src,
const BlockStatement* b,
const BlockStatement* cont)
: Base(pid, src), body(b), continuing(cont) {
: Base(pid, nid, src), body(b), continuing(cont) {
TINT_ASSERT(AST, body);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, continuing, program_id);

View File

@ -23,11 +23,13 @@ namespace tint::ast {
class LoopStatement final : public Castable<LoopStatement, Statement> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the loop statement source
/// @param body the body statements
/// @param continuing the continuing statements
LoopStatement(ProgramID program_id,
LoopStatement(ProgramID pid,
NodeID nid,
const Source& source,
const BlockStatement* body,
const BlockStatement* continuing);

View File

@ -20,8 +20,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Matrix);
namespace tint::ast {
Matrix::Matrix(ProgramID pid, const Source& src, const Type* subtype, uint32_t r, uint32_t c)
: Base(pid, src), type(subtype), rows(r), columns(c) {
Matrix::Matrix(ProgramID pid,
NodeID nid,
const Source& src,
const Type* subtype,
uint32_t r,
uint32_t c)
: Base(pid, nid, src), type(subtype), rows(r), columns(c) {
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, subtype, program_id);
TINT_ASSERT(AST, rows > 1);
TINT_ASSERT(AST, rows < 5);

View File

@ -26,13 +26,19 @@ class Matrix final : public Castable<Matrix, Type> {
public:
/// Constructor
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param src the source of this node
/// @param subtype the declared type of the matrix components. May be null for
/// matrix constructors, where the element type will be inferred from
/// the constructor arguments
/// @param rows the number of rows in the matrix
/// @param columns the number of columns in the matrix
Matrix(ProgramID pid, const Source& src, const Type* subtype, uint32_t rows, uint32_t columns);
Matrix(ProgramID pid,
NodeID nid,
const Source& src,
const Type* subtype,
uint32_t rows,
uint32_t columns);
/// Move constructor
Matrix(Matrix&&);
~Matrix() override;

View File

@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::MemberAccessorExpression);
namespace tint::ast {
MemberAccessorExpression::MemberAccessorExpression(ProgramID pid,
NodeID nid,
const Source& src,
const Expression* str,
const IdentifierExpression* mem)
: Base(pid, src), structure(str), member(mem) {
: Base(pid, nid, src), structure(str), member(mem) {
TINT_ASSERT(AST, structure);
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, structure, program_id);
TINT_ASSERT(AST, member);

View File

@ -23,11 +23,13 @@ namespace tint::ast {
class MemberAccessorExpression final : public Castable<MemberAccessorExpression, Expression> {
public:
/// Constructor
/// @param program_id the identifier of the program that owns this node
/// @param pid the identifier of the program that owns this node
/// @param nid the unique node identifier
/// @param source the member accessor expression source
/// @param structure the structure
/// @param member the member
MemberAccessorExpression(ProgramID program_id,
MemberAccessorExpression(ProgramID pid,
NodeID nid,
const Source& source,
const Expression* structure,
const IdentifierExpression* member);

Some files were not shown because too many files have changed in this diff Show More