resolver: remove Behaviours from sem::ValueExpression
An expression effectively only has a Next behaviour,
so there is no need to explicitly represent it.
The behaviors_ property was needed when there was a Discard
behaviour, but that has been removed from WGSL
Fixed: 452713220
Change-Id: I6a6a6964e63f565c3388c71d4afc77df5a31ca2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/267316
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 0190622..a1f084c5 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -1188,7 +1188,6 @@
return false;
}
sem->SetCondition(cond);
- sem->Behaviors() = cond->Behaviors();
sem->Behaviors().Remove(sem::Behavior::kNext);
Mark(stmt->body);
@@ -1282,7 +1281,6 @@
return false;
}
sem->SetCondition(cond);
- behaviors.Add(cond->Behaviors());
}
if (auto* continuing = stmt->continuing) {
@@ -1324,7 +1322,6 @@
return false;
}
sem->SetCondition(cond);
- behaviors.Add(cond->Behaviors());
Mark(stmt->body);
@@ -1698,7 +1695,6 @@
}
auto* load = b.create<sem::Load>(expr, current_statement_, expr->Stage());
- load->Behaviors() = expr->Behaviors();
b.Sem().Replace(expr->Declaration(), load);
// Register the load for the alias analysis.
@@ -1748,7 +1744,6 @@
}
auto* m = b.create<sem::Materialize>(expr, current_statement_, concrete_ty, materialized_val);
- m->Behaviors() = expr->Behaviors();
b.Sem().Replace(decl, m);
return m;
}
@@ -1898,7 +1893,6 @@
}
auto* sem = b.create<sem::IndexAccessorExpression>(
expr, ty, stage, obj, idx, current_statement_, std::move(val), obj->RootIdentifier());
- sem->Behaviors() = idx->Behaviors() + obj->Behaviors();
return sem;
}
@@ -1917,7 +1911,6 @@
Vector<const sem::ValueExpression*, 8> args;
args.Reserve(expr->args.Length());
auto args_stage = core::EvaluationStage::kConstant;
- sem::Behaviors arg_behaviors;
for (size_t i = 0; i < expr->args.Length(); i++) {
auto* arg = sem_.GetVal(expr->args[i]);
if (!arg) {
@@ -1925,9 +1918,7 @@
}
args.Push(arg);
args_stage = core::EarliestStage(args_stage, arg->Stage());
- arg_behaviors.Add(arg->Behaviors());
}
- arg_behaviors.Remove(sem::Behavior::kNext);
// ctor_or_conv is a helper for building either a sem::ValueConstructor or
// sem::ValueConversion call for a CtorConvIntrinsic with an optional template argument type.
@@ -2193,7 +2184,7 @@
target, //
[&](const sem::FunctionExpression* fn_expr) {
return FunctionCall(expr, const_cast<sem::Function*>(fn_expr->Function()),
- std::move(args), arg_behaviors);
+ std::move(args));
},
[&](const sem::TypeExpression* ty_expr) {
return Switch(
@@ -3123,8 +3114,7 @@
sem::Call* Resolver::FunctionCall(const ast::CallExpression* expr,
sem::Function* target,
- VectorRef<const sem::ValueExpression*> args_in,
- sem::Behaviors arg_behaviors) {
+ VectorRef<const sem::ValueExpression*> args_in) {
Vector<const sem::ValueExpression*, 8> args = std::move(args_in);
if (!MaybeMaterializeAndLoadArguments(args, target)) {
return nullptr;
@@ -3138,8 +3128,6 @@
target->AddCallSite(call);
- call->Behaviors() = arg_behaviors + target->Behaviors();
-
if (!validator_.FunctionCall(call, current_statement_)) {
return nullptr;
}
@@ -3523,7 +3511,6 @@
// from the pointer expression.
auto* load =
b.create<sem::Load>(obj_expr, current_statement_, obj_expr->Stage());
- load->Behaviors() = obj_expr->Behaviors();
b.Sem().Replace(obj_expr->Declaration(), load);
// Register the load for the alias analysis.
@@ -3638,8 +3625,6 @@
}
auto* sem = b.create<sem::ValueExpression>(expr, res_ty, stage, current_statement_, value);
- sem->Behaviors() = lhs->Behaviors() + rhs->Behaviors();
-
return sem;
}
@@ -3740,7 +3725,6 @@
auto* sem =
b.create<sem::ValueExpression>(unary, ty, stage, current_statement_, value, root_ident);
- sem->Behaviors() = expr->Behaviors();
return sem;
}
@@ -4457,8 +4441,6 @@
return false;
}
}
- behaviors.Add(expr->Behaviors() - sem::Behavior::kNext);
-
value_ty = expr->Type();
} else {
value_ty = b.create<core::type::Void>();
@@ -4481,7 +4463,10 @@
if (!cond) {
return false;
}
- behaviors = cond->Behaviors() - sem::Behavior::kNext;
+ // Each case clause will contribute behaviours. Switches must
+ // have at least a default clause, so we'll always end up with
+ // a non-empty behaviour set.
+ behaviors = behaviors - sem::Behavior::kNext;
auto* cond_ty = cond->Type();
@@ -4567,10 +4552,6 @@
current_compound_statement_->AddDecl(variable->As<sem::LocalVariable>());
- if (auto* ctor = variable->Initializer()) {
- sem->Behaviors() = ctor->Behaviors();
- }
-
return validator_.LocalVariable(variable);
});
}
@@ -4602,12 +4583,6 @@
return false;
}
- auto& behaviors = sem->Behaviors();
- behaviors = rhs->Behaviors();
- if (!is_phony_assignment) {
- behaviors.Add(lhs->Behaviors());
- }
-
if (!is_phony_assignment) {
RegisterStore(lhs);
}
@@ -4634,7 +4609,6 @@
return false;
}
sem->SetCondition(cond);
- sem->Behaviors() = cond->Behaviors();
sem->Behaviors().Add(sem::Behavior::kBreak);
return validator_.BreakIfStatement(sem, current_statement_);
@@ -4644,8 +4618,7 @@
sem::Statement* Resolver::CallStatement(const ast::CallStatement* stmt) {
auto* sem = b.create<sem::Statement>(stmt, current_compound_statement_, current_function_);
return StatementScope(stmt, sem, [&] {
- if (auto* expr = ValueExpression(stmt->expr)) {
- sem->Behaviors() = expr->Behaviors();
+ if (ValueExpression(stmt->expr)) {
return true;
}
return false;
@@ -4668,8 +4641,6 @@
RegisterStore(lhs);
- sem->Behaviors() = rhs->Behaviors() + lhs->Behaviors();
-
auto stage = core::EarliestStage(lhs->Stage(), rhs->Stage());
auto overload = intrinsic_table_.Lookup(stmt->op, lhs->Type()->UnwrapRef(),
@@ -4722,8 +4693,6 @@
if (!lhs) {
return false;
}
- sem->Behaviors() = lhs->Behaviors();
-
RegisterStore(lhs);
return validator_.IncrementDecrementStatement(stmt);
diff --git a/src/tint/lang/wgsl/resolver/resolver.h b/src/tint/lang/wgsl/resolver/resolver.h
index 01a31f1..f572551e 100644
--- a/src/tint/lang/wgsl/resolver/resolver.h
+++ b/src/tint/lang/wgsl/resolver/resolver.h
@@ -293,8 +293,7 @@
sem::Function* Function(const ast::Function*);
sem::Call* FunctionCall(const ast::CallExpression*,
sem::Function* target,
- VectorRef<const sem::ValueExpression*> args,
- sem::Behaviors arg_behaviors);
+ VectorRef<const sem::ValueExpression*> args);
sem::Expression* Identifier(const ast::IdentifierExpression*);
template <size_t N>
sem::Call* BuiltinCall(const ast::CallExpression*,
diff --git a/src/tint/lang/wgsl/sem/value_expression.h b/src/tint/lang/wgsl/sem/value_expression.h
index fb6f58d..672cea1 100644
--- a/src/tint/lang/wgsl/sem/value_expression.h
+++ b/src/tint/lang/wgsl/sem/value_expression.h
@@ -77,12 +77,6 @@
/// @return the root identifier of this expression, or nullptr
const Variable* RootIdentifier() const { return root_identifier_; }
- /// @return the behaviors of this statement
- const sem::Behaviors& Behaviors() const { return behaviors_; }
-
- /// @return the behaviors of this statement
- sem::Behaviors& Behaviors() { return behaviors_; }
-
/// @return the inner expression node if this is a Materialize, otherwise this.
const ValueExpression* UnwrapMaterialize() const;
@@ -100,7 +94,6 @@
const core::type::Type* const type_;
const core::EvaluationStage stage_;
const core::constant::Value* const constant_;
- sem::Behaviors behaviors_{sem::Behavior::kNext};
};
} // namespace tint::sem