mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
ast: Rename CallExpression::params() to args()
Arguments are the values passed to a function. Parameters receive arguments. Fixed: tint:811 Change-Id: I82fe71aa795b8b365bc78981e84c86b419eb3eb2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66263 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
11c9656b14
commit
14fc622161
@@ -106,7 +106,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx,
|
||||
// We assume that the argument to `arrayLength` has the form
|
||||
// `&resource.array`, which requires that `InlinePointerLets` and
|
||||
// `Simplify` have been run before this transform.
|
||||
auto* param = call_expr->params()[0]->As<ast::UnaryOpExpression>();
|
||||
auto* param = call_expr->args()[0]->As<ast::UnaryOpExpression>();
|
||||
if (!param || param->op() != ast::UnaryOp::kAddressOf) {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected form of arrayLength argument to be "
|
||||
|
||||
@@ -134,7 +134,7 @@ void CalculateArrayLength::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
// We can assume that the arrayLength() call has a single argument of
|
||||
// the form: arrayLength(&X.Y) where X is an expression that resolves
|
||||
// to the storage buffer structure, and Y is the runtime sized array.
|
||||
auto* arg = call_expr->params()[0];
|
||||
auto* arg = call_expr->args()[0];
|
||||
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
|
||||
@@ -927,8 +927,8 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
// may refer to a structure holding a runtime array, which cannot be
|
||||
// loaded. Instead replace X with the underlying storage / uniform
|
||||
// buffer variable.
|
||||
if (auto access = state.TakeAccess(call_expr->params()[0])) {
|
||||
ctx.Replace(call_expr->params()[0], [=, &ctx] {
|
||||
if (auto access = state.TakeAccess(call_expr->args()[0])) {
|
||||
ctx.Replace(call_expr->args()[0], [=, &ctx] {
|
||||
return ctx.CloneWithoutTransform(access.var->Declaration());
|
||||
});
|
||||
}
|
||||
@@ -938,11 +938,11 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
// arrayLength(X)
|
||||
// Don't convert X into a load, this intrinsic actually requires the
|
||||
// real pointer.
|
||||
state.TakeAccess(call_expr->params()[0]);
|
||||
state.TakeAccess(call_expr->args()[0]);
|
||||
continue;
|
||||
}
|
||||
if (intrinsic->IsAtomic()) {
|
||||
if (auto access = state.TakeAccess(call_expr->params()[0])) {
|
||||
if (auto access = state.TakeAccess(call_expr->args()[0])) {
|
||||
// atomic___(X)
|
||||
ctx.Replace(call_expr, [=, &ctx, &state] {
|
||||
auto* buf = access.var->Declaration();
|
||||
@@ -954,8 +954,8 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||
access.var->As<sem::VariableUser>());
|
||||
|
||||
ast::ExpressionList args{ctx.Clone(buf), offset};
|
||||
for (size_t i = 1; i < call_expr->params().size(); i++) {
|
||||
auto* arg = call_expr->params()[i];
|
||||
for (size_t i = 1; i < call_expr->args().size(); i++) {
|
||||
auto* arg = call_expr->args()[i];
|
||||
args.emplace_back(ctx.Clone(arg));
|
||||
}
|
||||
return ctx.dst->Call(func, args);
|
||||
|
||||
@@ -53,43 +53,43 @@ void ExternalTextureTransform::Run(CloneContext& ctx,
|
||||
// When a textureLoad or textureSampleLevel has been identified, check
|
||||
// if the first parameter is an external texture.
|
||||
if (auto* var =
|
||||
sem.Get(call_expr->params()[0])->As<sem::VariableUser>()) {
|
||||
sem.Get(call_expr->args()[0])->As<sem::VariableUser>()) {
|
||||
if (var->Variable()
|
||||
->Type()
|
||||
->UnwrapRef()
|
||||
->Is<sem::ExternalTexture>()) {
|
||||
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad &&
|
||||
call_expr->params().size() != 2) {
|
||||
call_expr->args().size() != 2) {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected textureLoad call with a texture_external to "
|
||||
"have 2 parameters, found "
|
||||
<< call_expr->params().size() << " parameters";
|
||||
<< call_expr->args().size() << " parameters";
|
||||
}
|
||||
|
||||
if (intrinsic->Type() ==
|
||||
sem::IntrinsicType::kTextureSampleLevel &&
|
||||
call_expr->params().size() != 3) {
|
||||
call_expr->args().size() != 3) {
|
||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||
<< "expected textureSampleLevel call with a "
|
||||
"texture_external to have 3 parameters, found "
|
||||
<< call_expr->params().size() << " parameters";
|
||||
<< call_expr->args().size() << " parameters";
|
||||
}
|
||||
|
||||
// Replace the call with another that has the same parameters in
|
||||
// addition to a level parameter (always zero for external
|
||||
// textures).
|
||||
auto* exp = ctx.Clone(call_expr->func());
|
||||
auto* externalTextureParam = ctx.Clone(call_expr->params()[0]);
|
||||
auto* externalTextureParam = ctx.Clone(call_expr->args()[0]);
|
||||
|
||||
ast::ExpressionList params;
|
||||
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad) {
|
||||
auto* coordsParam = ctx.Clone(call_expr->params()[1]);
|
||||
auto* coordsParam = ctx.Clone(call_expr->args()[1]);
|
||||
auto* levelParam = ctx.dst->Expr(0);
|
||||
params = {externalTextureParam, coordsParam, levelParam};
|
||||
} else if (intrinsic->Type() ==
|
||||
sem::IntrinsicType::kTextureSampleLevel) {
|
||||
auto* samplerParam = ctx.Clone(call_expr->params()[1]);
|
||||
auto* coordsParam = ctx.Clone(call_expr->params()[2]);
|
||||
auto* samplerParam = ctx.Clone(call_expr->args()[1]);
|
||||
auto* coordsParam = ctx.Clone(call_expr->args()[2]);
|
||||
auto* levelParam = ctx.dst->Expr(0.0f);
|
||||
params = {externalTextureParam, samplerParam, coordsParam,
|
||||
levelParam};
|
||||
|
||||
@@ -305,7 +305,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
||||
if (is_entry_point && !is_handle && !is_workgroup_matrix) {
|
||||
arg = ctx.dst->AddressOf(arg);
|
||||
}
|
||||
ctx.InsertBack(call->params(), arg);
|
||||
ctx.InsertBack(call->args(), arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ struct Robustness::State {
|
||||
auto level_idx =
|
||||
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kLevel);
|
||||
|
||||
auto* texture_arg = expr->params()[texture_idx];
|
||||
auto* coords_arg = expr->params()[coords_idx];
|
||||
auto* texture_arg = expr->args()[texture_idx];
|
||||
auto* coords_arg = expr->args()[coords_idx];
|
||||
auto* coords_ty = intrinsic->Parameters()[coords_idx]->Type();
|
||||
|
||||
// If the level is provided, then we need to clamp this. As the level is
|
||||
@@ -229,7 +229,7 @@ struct Robustness::State {
|
||||
std::function<ast::Expression*()> level_arg;
|
||||
if (level_idx >= 0) {
|
||||
level_arg = [&] {
|
||||
auto* arg = expr->params()[level_idx];
|
||||
auto* arg = expr->args()[level_idx];
|
||||
auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_levels, 1);
|
||||
@@ -253,7 +253,7 @@ struct Robustness::State {
|
||||
|
||||
// Clamp the array_index argument, if provided
|
||||
if (array_idx >= 0) {
|
||||
auto* arg = expr->params()[array_idx];
|
||||
auto* arg = expr->args()[array_idx];
|
||||
auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
|
||||
auto* zero = b.Expr(0);
|
||||
auto* max = ctx.dst->Sub(num_layers, 1);
|
||||
@@ -263,7 +263,7 @@ struct Robustness::State {
|
||||
|
||||
// Clamp the level argument, if provided
|
||||
if (level_idx >= 0) {
|
||||
auto* arg = expr->params()[level_idx];
|
||||
auto* arg = expr->args()[level_idx];
|
||||
ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user