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:
parent
11c9656b14
commit
14fc622161
|
@ -24,13 +24,13 @@ namespace ast {
|
|||
CallExpression::CallExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
IdentifierExpression* func,
|
||||
ExpressionList params)
|
||||
: Base(program_id, source), func_(func), params_(params) {
|
||||
ExpressionList args)
|
||||
: Base(program_id, source), func_(func), args_(args) {
|
||||
TINT_ASSERT(AST, func_);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, func_, program_id);
|
||||
for (auto* param : params_) {
|
||||
TINT_ASSERT(AST, param);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, param, program_id);
|
||||
for (auto* arg : args_) {
|
||||
TINT_ASSERT(AST, arg);
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, arg, program_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ CallExpression* CallExpression::Clone(CloneContext* ctx) const {
|
|||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
auto* fn = ctx->Clone(func_);
|
||||
auto p = ctx->Clone(params_);
|
||||
auto p = ctx->Clone(args_);
|
||||
return ctx->dst->create<CallExpression>(src, fn, p);
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ void CallExpression::to_str(const sem::Info& sem,
|
|||
|
||||
make_indent(out, indent + 2);
|
||||
out << "(" << std::endl;
|
||||
for (auto* param : params_)
|
||||
param->to_str(sem, out, indent + 4);
|
||||
for (auto* arg : args_)
|
||||
arg->to_str(sem, out, indent + 4);
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << ")" << std::endl;
|
||||
|
|
|
@ -30,19 +30,19 @@ class CallExpression : public Castable<CallExpression, Expression> {
|
|||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the call expression source
|
||||
/// @param func the function
|
||||
/// @param params the parameters
|
||||
/// @param args the arguments
|
||||
CallExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
IdentifierExpression* func,
|
||||
ExpressionList params);
|
||||
ExpressionList args);
|
||||
/// Move constructor
|
||||
CallExpression(CallExpression&&);
|
||||
~CallExpression() override;
|
||||
|
||||
/// @returns the func
|
||||
IdentifierExpression* func() const { return func_; }
|
||||
/// @returns the parameters
|
||||
const ExpressionList& params() const { return params_; }
|
||||
/// @returns the arguments
|
||||
const ExpressionList& args() const { return args_; }
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
|
@ -62,7 +62,7 @@ class CallExpression : public Castable<CallExpression, Expression> {
|
|||
CallExpression(const CallExpression&) = delete;
|
||||
|
||||
IdentifierExpression* const func_;
|
||||
ExpressionList const params_;
|
||||
ExpressionList const args_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(CallExpressionTest, Creation) {
|
|||
auto* stmt = create<CallExpression>(func, params);
|
||||
EXPECT_EQ(stmt->func(), func);
|
||||
|
||||
const auto& vec = stmt->params();
|
||||
const auto& vec = stmt->args();
|
||||
ASSERT_EQ(vec.size(), 2u);
|
||||
EXPECT_EQ(vec[0], params[0]);
|
||||
EXPECT_EQ(vec[1], params[1]);
|
||||
|
|
|
@ -842,8 +842,8 @@ void Inspector::GenerateSamplerTargets() {
|
|||
continue;
|
||||
}
|
||||
|
||||
auto* t = c->params()[texture_index];
|
||||
auto* s = c->params()[sampler_index];
|
||||
auto* t = c->args()[texture_index];
|
||||
auto* s = c->args()[sampler_index];
|
||||
|
||||
GetOriginatingResources(
|
||||
std::array<const ast::Expression*, 2>{t, s},
|
||||
|
@ -959,7 +959,7 @@ void Inspector::GetOriginatingResources(
|
|||
// Patch all the parameter expressions with their argument
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (auto* param = parameters[i]) {
|
||||
call_exprs[i] = call_expr->params()[param->Index()];
|
||||
call_exprs[i] = call_expr->args()[param->Index()];
|
||||
}
|
||||
}
|
||||
// Now call GetOriginatingResources() with from the callsite
|
||||
|
|
|
@ -71,7 +71,7 @@ TEST_F(SpvParserTest, WorkgroupBarrier) {
|
|||
ASSERT_GT(helper->body()->size(), 0u);
|
||||
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->expr()->params().size(), 0u);
|
||||
EXPECT_EQ(call->expr()->args().size(), 0u);
|
||||
auto* sem_call = program.Sem().Get(call->expr());
|
||||
ASSERT_NE(sem_call, nullptr);
|
||||
auto* intrinsic = sem_call->Target()->As<sem::Intrinsic>();
|
||||
|
@ -105,7 +105,7 @@ TEST_F(SpvParserTest, StorageBarrier) {
|
|||
ASSERT_GT(helper->body()->size(), 0u);
|
||||
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
||||
ASSERT_NE(call, nullptr);
|
||||
EXPECT_EQ(call->expr()->params().size(), 0u);
|
||||
EXPECT_EQ(call->expr()->args().size(), 0u);
|
||||
auto* sem_call = program.Sem().Get(call->expr());
|
||||
ASSERT_NE(sem_call, nullptr);
|
||||
auto* intrinsic = sem_call->Target()->As<sem::Intrinsic>();
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(ParserImplTest, Statement_Call) {
|
|||
|
||||
EXPECT_EQ(c->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(c->params().size(), 0u);
|
||||
EXPECT_EQ(c->args().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_WithParams) {
|
||||
|
@ -54,10 +54,10 @@ TEST_F(ParserImplTest, Statement_Call_WithParams) {
|
|||
|
||||
EXPECT_EQ(c->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(c->params().size(), 3u);
|
||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
||||
EXPECT_TRUE(c->params()[2]->Is<ast::BinaryExpression>());
|
||||
EXPECT_EQ(c->args().size(), 3u);
|
||||
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||
EXPECT_TRUE(c->args()[2]->Is<ast::BinaryExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_WithParams_TrailingComma) {
|
||||
|
@ -73,9 +73,9 @@ TEST_F(ParserImplTest, Statement_Call_WithParams_TrailingComma) {
|
|||
|
||||
EXPECT_EQ(c->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(c->params().size(), 2u);
|
||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
||||
EXPECT_EQ(c->args().size(), 2u);
|
||||
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) {
|
||||
|
|
|
@ -102,7 +102,7 @@ TEST_F(ParserImplTest, SingularExpression_Call_Empty) {
|
|||
|
||||
EXPECT_EQ(c->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||
|
||||
EXPECT_EQ(c->params().size(), 0u);
|
||||
EXPECT_EQ(c->args().size(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, SingularExpression_Call_WithArgs) {
|
||||
|
@ -118,10 +118,10 @@ TEST_F(ParserImplTest, SingularExpression_Call_WithArgs) {
|
|||
|
||||
EXPECT_EQ(c->func()->symbol(), p->builder().Symbols().Get("test"));
|
||||
|
||||
EXPECT_EQ(c->params().size(), 3u);
|
||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
||||
EXPECT_TRUE(c->params()[2]->Is<ast::BinaryExpression>());
|
||||
EXPECT_EQ(c->args().size(), 3u);
|
||||
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||
EXPECT_TRUE(c->args()[2]->Is<ast::BinaryExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, SingularExpression_Call_TrailingComma) {
|
||||
|
@ -133,7 +133,7 @@ TEST_F(ParserImplTest, SingularExpression_Call_TrailingComma) {
|
|||
|
||||
ASSERT_TRUE(e->Is<ast::CallExpression>());
|
||||
auto* c = e->As<ast::CallExpression>();
|
||||
EXPECT_EQ(c->params().size(), 1u);
|
||||
EXPECT_EQ(c->args().size(), 1u);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, SingularExpression_Call_InvalidArg) {
|
||||
|
|
|
@ -2312,7 +2312,7 @@ bool Resolver::TraverseExpressions(ast::Expression* root,
|
|||
} else if (auto* bitcast = expr->As<ast::BitcastExpression>()) {
|
||||
add(bitcast->expr());
|
||||
} else if (auto* call = expr->As<ast::CallExpression>()) {
|
||||
for (auto* arg : call->params()) {
|
||||
for (auto* arg : call->args()) {
|
||||
add(arg);
|
||||
}
|
||||
} else if (auto* type_ctor = expr->As<ast::TypeConstructorExpression>()) {
|
||||
|
@ -2504,8 +2504,8 @@ bool Resolver::ValidateCallStatement(ast::CallStatement* stmt) {
|
|||
bool Resolver::IntrinsicCall(ast::CallExpression* call,
|
||||
sem::IntrinsicType intrinsic_type) {
|
||||
std::vector<const sem::Type*> arg_tys;
|
||||
arg_tys.reserve(call->params().size());
|
||||
for (auto* expr : call->params()) {
|
||||
arg_tys.reserve(call->args().size());
|
||||
for (auto* expr : call->args()) {
|
||||
arg_tys.emplace_back(TypeOf(expr));
|
||||
}
|
||||
|
||||
|
@ -2545,7 +2545,7 @@ bool Resolver::ValidateTextureIntrinsicFunction(
|
|||
auto index =
|
||||
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kOffset);
|
||||
if (index > -1) {
|
||||
auto* param = ast_call->params()[index];
|
||||
auto* param = ast_call->args()[index];
|
||||
if (param->Is<ast::TypeConstructorExpression>()) {
|
||||
auto values = ConstantValueOf(param);
|
||||
if (!values.IsValid()) {
|
||||
|
@ -2639,19 +2639,19 @@ bool Resolver::ValidateFunctionCall(const ast::CallExpression* call,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (call->params().size() != target->parameters.size()) {
|
||||
bool more = call->params().size() > target->parameters.size();
|
||||
if (call->args().size() != target->parameters.size()) {
|
||||
bool more = call->args().size() > target->parameters.size();
|
||||
AddError("too " + (more ? std::string("many") : std::string("few")) +
|
||||
" arguments in call to '" + name + "', expected " +
|
||||
std::to_string(target->parameters.size()) + ", got " +
|
||||
std::to_string(call->params().size()),
|
||||
std::to_string(call->args().size()),
|
||||
call->source());
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < call->params().size(); ++i) {
|
||||
for (size_t i = 0; i < call->args().size(); ++i) {
|
||||
const VariableInfo* param = target->parameters[i];
|
||||
const ast::Expression* arg_expr = call->params()[i];
|
||||
const ast::Expression* arg_expr = call->args()[i];
|
||||
auto* arg_type = TypeOf(arg_expr)->UnwrapRef();
|
||||
|
||||
if (param->type != arg_type) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ bool GeneratorImpl::EmitBreak(ast::BreakStatement*) {
|
|||
}
|
||||
|
||||
bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||
const auto& params = expr->params();
|
||||
const auto& args = expr->args();
|
||||
auto* ident = expr->func();
|
||||
auto* call = builder_.Sem().Get(expr);
|
||||
auto* target = call->Target();
|
||||
|
@ -389,11 +389,11 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
func->Declaration()->decorations())) {
|
||||
// Special function generated by the CalculateArrayLength transform for
|
||||
// calling X.GetDimensions(Y)
|
||||
if (!EmitExpression(out, params[0])) {
|
||||
if (!EmitExpression(out, args[0])) {
|
||||
return false;
|
||||
}
|
||||
out << ".GetDimensions(";
|
||||
if (!EmitExpression(out, params[1])) {
|
||||
if (!EmitExpression(out, args[1])) {
|
||||
return false;
|
||||
}
|
||||
out << ")";
|
||||
|
@ -413,7 +413,7 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
||||
return EmitIsNormalCall(out, expr, intrinsic);
|
||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
||||
return EmitExpression(out, expr->params()[0]);
|
||||
return EmitExpression(out, expr->args()[0]);
|
||||
} else if (intrinsic->IsDataPacking()) {
|
||||
return EmitDataPackingCall(out, expr, intrinsic);
|
||||
} else if (intrinsic->IsDataUnpacking()) {
|
||||
|
@ -431,13 +431,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << name << "(";
|
||||
|
||||
bool first = true;
|
||||
for (auto* param : params) {
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -460,13 +460,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << name << "(";
|
||||
|
||||
bool first = true;
|
||||
for (auto* param : params) {
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -500,8 +500,8 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
|
||||
{
|
||||
ScopedParen sp(pre);
|
||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
||||
auto* arg = expr->params()[i];
|
||||
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||
auto* arg = expr->args()[i];
|
||||
if (i > 0) {
|
||||
pre << ", ";
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
pre << "InterlockedOr";
|
||||
{
|
||||
ScopedParen sp(pre);
|
||||
if (!EmitExpression(pre, expr->params()[0])) {
|
||||
if (!EmitExpression(pre, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
pre << ", 0, " << result;
|
||||
|
@ -557,11 +557,11 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
out << "InterlockedExchange";
|
||||
{
|
||||
ScopedParen sp(out);
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
out << ", ";
|
||||
if (!EmitExpression(out, expr->params()[1])) {
|
||||
if (!EmitExpression(out, expr->args()[1])) {
|
||||
return false;
|
||||
}
|
||||
out << ", " << result;
|
||||
|
@ -569,9 +569,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
return true;
|
||||
}
|
||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||
auto* dest = expr->params()[0];
|
||||
auto* compare_value = expr->params()[1];
|
||||
auto* value = expr->params()[2];
|
||||
auto* dest = expr->args()[0];
|
||||
auto* compare_value = expr->args()[1];
|
||||
auto* value = expr->args()[2];
|
||||
|
||||
std::string compare = UniqueIdentifier("atomic_compare_value");
|
||||
|
||||
|
@ -647,9 +647,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
|
||||
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
||||
ast::CallExpression* expr) {
|
||||
auto* expr_false = expr->params()[0];
|
||||
auto* expr_true = expr->params()[1];
|
||||
auto* expr_cond = expr->params()[2];
|
||||
auto* expr_false = expr->args()[0];
|
||||
auto* expr_true = expr->args()[1];
|
||||
auto* expr_cond = expr->args()[2];
|
||||
ScopedParen paren(out);
|
||||
if (!EmitExpression(out, expr_cond)) {
|
||||
return false;
|
||||
|
@ -673,7 +673,7 @@ bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
|||
bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
||||
ast::CallExpression* expr,
|
||||
const sem::Intrinsic* intrinsic) {
|
||||
if (expr->params().size() == 1) {
|
||||
if (expr->args().size() == 1) {
|
||||
return CallIntrinsicHelper(
|
||||
out, expr, intrinsic,
|
||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||
|
@ -710,11 +710,11 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
|||
// DEPRECATED
|
||||
out << "modf";
|
||||
ScopedParen sp(out);
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
out << ", ";
|
||||
if (!EmitExpression(out, expr->params()[1])) {
|
||||
if (!EmitExpression(out, expr->args()[1])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -723,7 +723,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
|||
bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
||||
ast::CallExpression* expr,
|
||||
const sem::Intrinsic* intrinsic) {
|
||||
if (expr->params().size() == 1) {
|
||||
if (expr->args().size() == 1) {
|
||||
return CallIntrinsicHelper(
|
||||
out, expr, intrinsic,
|
||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||
|
@ -977,7 +977,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
using Usage = sem::ParameterUsage;
|
||||
|
||||
auto parameters = intrinsic->Parameters();
|
||||
auto arguments = expr->params();
|
||||
auto arguments = expr->args();
|
||||
|
||||
// Returns the argument with the given usage
|
||||
auto arg = [&](Usage usage) {
|
||||
|
@ -2726,7 +2726,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
|||
{
|
||||
ScopedParen sp(out);
|
||||
bool first = true;
|
||||
for (auto* arg : call->params()) {
|
||||
for (auto* arg : call->args()) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
|
|
|
@ -551,7 +551,7 @@ bool GeneratorImpl::EmitBreak(ast::BreakStatement*) {
|
|||
}
|
||||
|
||||
bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||
const auto& params = expr->params();
|
||||
const auto& args = expr->args();
|
||||
auto* ident = expr->func();
|
||||
auto* call = builder_.Sem().Get(expr);
|
||||
auto* target = call->Target();
|
||||
|
@ -562,11 +562,11 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
func->Declaration()->decorations())) {
|
||||
// Special function generated by the CalculateArrayLength transform for
|
||||
// calling X.GetDimensions(Y)
|
||||
if (!EmitExpression(out, params[0])) {
|
||||
if (!EmitExpression(out, args[0])) {
|
||||
return false;
|
||||
}
|
||||
out << ".GetDimensions(";
|
||||
if (!EmitExpression(out, params[1])) {
|
||||
if (!EmitExpression(out, args[1])) {
|
||||
return false;
|
||||
}
|
||||
out << ")";
|
||||
|
@ -602,7 +602,7 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
||||
return EmitIsNormalCall(out, expr, intrinsic);
|
||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
||||
return EmitExpression(out, expr->params()[0]);
|
||||
return EmitExpression(out, expr->args()[0]);
|
||||
} else if (intrinsic->IsDataPacking()) {
|
||||
return EmitDataPackingCall(out, expr, intrinsic);
|
||||
} else if (intrinsic->IsDataUnpacking()) {
|
||||
|
@ -620,13 +620,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << name << "(";
|
||||
|
||||
bool first = true;
|
||||
for (auto* param : params) {
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -649,13 +649,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << name << "(";
|
||||
|
||||
bool first = true;
|
||||
for (auto* param : params) {
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -669,8 +669,8 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
std::ostream& out,
|
||||
ast::CallExpression* expr,
|
||||
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
||||
const auto& params = expr->params();
|
||||
auto* offset_arg = builder_.Sem().Get(params[1]);
|
||||
const auto& args = expr->args();
|
||||
auto* offset_arg = builder_.Sem().Get(args[1]);
|
||||
|
||||
uint32_t scalar_offset_value = 0;
|
||||
std::string scalar_offset_expr;
|
||||
|
@ -691,7 +691,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
scalar_offset_expr = UniqueIdentifier("scalar_offset");
|
||||
auto pre = line();
|
||||
pre << "const uint " << scalar_offset_expr << " = (";
|
||||
if (!EmitExpression(pre, params[1])) { // offset
|
||||
if (!EmitExpression(pre, args[1])) { // offset
|
||||
return false;
|
||||
}
|
||||
pre << ") / 4;";
|
||||
|
@ -708,7 +708,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
return result;
|
||||
};
|
||||
auto load_scalar = [&]() {
|
||||
if (!EmitExpression(out, params[0])) { // buffer
|
||||
if (!EmitExpression(out, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
if (scalar_offset_constant) {
|
||||
|
@ -724,7 +724,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
// Has a minimum alignment of 8 bytes, so is either .xy or .zw
|
||||
auto load_vec2 = [&] {
|
||||
if (scalar_offset_constant) {
|
||||
if (!EmitExpression(out, params[0])) { // buffer
|
||||
if (!EmitExpression(out, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
out << "[" << (scalar_offset_value / 4) << "]";
|
||||
|
@ -734,7 +734,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
{
|
||||
auto pre = line();
|
||||
pre << "uint4 " << ubo_load << " = ";
|
||||
if (!EmitExpression(pre, params[0])) { // buffer
|
||||
if (!EmitExpression(pre, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
pre << "[" << scalar_offset_expr << " / 4];";
|
||||
|
@ -746,7 +746,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
|||
};
|
||||
// vec4 has a minimum alignment of 16 bytes, easiest case
|
||||
auto load_vec4 = [&] {
|
||||
if (!EmitExpression(out, params[0])) { // buffer
|
||||
if (!EmitExpression(out, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
if (scalar_offset_constant) {
|
||||
|
@ -808,7 +808,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
|||
std::ostream& out,
|
||||
ast::CallExpression* expr,
|
||||
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
||||
const auto& params = expr->params();
|
||||
const auto& args = expr->args();
|
||||
|
||||
using Op = transform::DecomposeMemoryAccess::Intrinsic::Op;
|
||||
using DataType = transform::DecomposeMemoryAccess::Intrinsic::DataType;
|
||||
|
@ -818,7 +818,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
|||
if (cast) {
|
||||
out << cast << "(";
|
||||
}
|
||||
if (!EmitExpression(out, params[0])) { // buffer
|
||||
if (!EmitExpression(out, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
out << ".Load";
|
||||
|
@ -826,7 +826,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
|||
out << n;
|
||||
}
|
||||
ScopedParen sp(out);
|
||||
if (!EmitExpression(out, params[1])) { // offset
|
||||
if (!EmitExpression(out, args[1])) { // offset
|
||||
return false;
|
||||
}
|
||||
if (cast) {
|
||||
|
@ -868,7 +868,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
|||
|
||||
case Op::kStore: {
|
||||
auto store = [&](int n) {
|
||||
if (!EmitExpression(out, params[0])) { // buffer
|
||||
if (!EmitExpression(out, args[0])) { // buffer
|
||||
return false;
|
||||
}
|
||||
out << ".Store";
|
||||
|
@ -876,12 +876,12 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
|||
out << n;
|
||||
}
|
||||
ScopedParen sp1(out);
|
||||
if (!EmitExpression(out, params[1])) { // offset
|
||||
if (!EmitExpression(out, args[1])) { // offset
|
||||
return false;
|
||||
}
|
||||
out << ", asuint";
|
||||
ScopedParen sp2(out);
|
||||
if (!EmitExpression(out, params[2])) { // value
|
||||
if (!EmitExpression(out, args[2])) { // value
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1057,7 +1057,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
|||
case Op::kAtomicStore: {
|
||||
// HLSL does not have an InterlockedStore, so we emulate it with
|
||||
// InterlockedExchange and discard the returned value
|
||||
auto* value_ty = TypeOf(expr->params()[2])->UnwrapRef();
|
||||
auto* value_ty = TypeOf(expr->args()[2])->UnwrapRef();
|
||||
auto name = UniqueIdentifier("atomicStore");
|
||||
{
|
||||
auto fn = line(&buf);
|
||||
|
@ -1088,7 +1088,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
|||
return name;
|
||||
}
|
||||
case Op::kAtomicCompareExchangeWeak: {
|
||||
auto* value_ty = TypeOf(expr->params()[2])->UnwrapRef();
|
||||
auto* value_ty = TypeOf(expr->args()[2])->UnwrapRef();
|
||||
|
||||
auto name = UniqueIdentifier("atomicCompareExchangeWeak");
|
||||
{
|
||||
|
@ -1151,7 +1151,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
|||
{
|
||||
ScopedParen sp(out);
|
||||
bool first = true;
|
||||
for (auto* arg : expr->params()) {
|
||||
for (auto* arg : expr->args()) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
|
@ -1189,8 +1189,8 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
|
||||
{
|
||||
ScopedParen sp(pre);
|
||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
||||
auto* arg = expr->params()[i];
|
||||
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||
auto* arg = expr->args()[i];
|
||||
if (i > 0) {
|
||||
pre << ", ";
|
||||
}
|
||||
|
@ -1220,7 +1220,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
pre << "InterlockedOr";
|
||||
{
|
||||
ScopedParen sp(pre);
|
||||
if (!EmitExpression(pre, expr->params()[0])) {
|
||||
if (!EmitExpression(pre, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
pre << ", 0, " << result;
|
||||
|
@ -1250,11 +1250,11 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
out << "InterlockedExchange";
|
||||
{
|
||||
ScopedParen sp(out);
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
out << ", ";
|
||||
if (!EmitExpression(out, expr->params()[1])) {
|
||||
if (!EmitExpression(out, expr->args()[1])) {
|
||||
return false;
|
||||
}
|
||||
out << ", " << result;
|
||||
|
@ -1262,9 +1262,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
return true;
|
||||
}
|
||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||
auto* dest = expr->params()[0];
|
||||
auto* compare_value = expr->params()[1];
|
||||
auto* value = expr->params()[2];
|
||||
auto* dest = expr->args()[0];
|
||||
auto* compare_value = expr->args()[1];
|
||||
auto* value = expr->args()[2];
|
||||
|
||||
std::string compare = UniqueIdentifier("atomic_compare_value");
|
||||
|
||||
|
@ -1340,9 +1340,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
|||
|
||||
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
||||
ast::CallExpression* expr) {
|
||||
auto* expr_false = expr->params()[0];
|
||||
auto* expr_true = expr->params()[1];
|
||||
auto* expr_cond = expr->params()[2];
|
||||
auto* expr_false = expr->args()[0];
|
||||
auto* expr_true = expr->args()[1];
|
||||
auto* expr_cond = expr->args()[2];
|
||||
ScopedParen paren(out);
|
||||
if (!EmitExpression(out, expr_cond)) {
|
||||
return false;
|
||||
|
@ -1621,7 +1621,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
using Usage = sem::ParameterUsage;
|
||||
|
||||
auto parameters = intrinsic->Parameters();
|
||||
auto arguments = expr->params();
|
||||
auto arguments = expr->args();
|
||||
|
||||
// Returns the argument with the given usage
|
||||
auto arg = [&](Usage usage) {
|
||||
|
@ -3434,7 +3434,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
|||
{
|
||||
ScopedParen sp(out);
|
||||
bool first = true;
|
||||
for (auto* arg : call->params()) {
|
||||
for (auto* arg : call->args()) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
|
|
|
@ -538,14 +538,14 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << program_->Symbols().NameFor(var->Declaration()->symbol());
|
||||
}
|
||||
|
||||
const auto& params = expr->params();
|
||||
for (auto* param : params) {
|
||||
const auto& args = expr->args();
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
|||
} else {
|
||||
out << "float2(as_type<half2>(";
|
||||
}
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
out << "))";
|
||||
|
@ -598,14 +598,14 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
|||
}
|
||||
case sem::IntrinsicType::kIgnore: {
|
||||
out << "(void) ";
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case sem::IntrinsicType::kLength: {
|
||||
auto* sem = builder_.Sem().Get(expr->params()[0]);
|
||||
auto* sem = builder_.Sem().Get(expr->args()[0]);
|
||||
if (sem->Type()->UnwrapRef()->is_scalar()) {
|
||||
// Emulate scalar overload using fabs(x).
|
||||
name = "fabs";
|
||||
|
@ -614,16 +614,16 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
|||
}
|
||||
|
||||
case sem::IntrinsicType::kDistance: {
|
||||
auto* sem = builder_.Sem().Get(expr->params()[0]);
|
||||
auto* sem = builder_.Sem().Get(expr->args()[0]);
|
||||
if (sem->Type()->UnwrapRef()->is_scalar()) {
|
||||
// Emulate scalar overload using fabs(x - y);
|
||||
out << "fabs";
|
||||
ScopedParen sp(out);
|
||||
if (!EmitExpression(out, expr->params()[0])) {
|
||||
if (!EmitExpression(out, expr->args()[0])) {
|
||||
return false;
|
||||
}
|
||||
out << " - ";
|
||||
if (!EmitExpression(out, expr->params()[1])) {
|
||||
if (!EmitExpression(out, expr->args()[1])) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -642,14 +642,14 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
|||
out << name << "(";
|
||||
|
||||
bool first = true;
|
||||
const auto& params = expr->params();
|
||||
for (auto* param : params) {
|
||||
const auto& args = expr->args();
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -665,8 +665,8 @@ bool GeneratorImpl::EmitAtomicCall(std::ostream& out,
|
|||
out << name;
|
||||
{
|
||||
ScopedParen sp(out);
|
||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
||||
auto* arg = expr->params()[i];
|
||||
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||
auto* arg = expr->args()[i];
|
||||
if (i > 0) {
|
||||
out << ", ";
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ bool GeneratorImpl::EmitAtomicCall(std::ostream& out,
|
|||
return call("atomic_exchange_explicit", true);
|
||||
|
||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||
auto* ptr_ty = TypeOf(expr->params()[0])->UnwrapRef()->As<sem::Pointer>();
|
||||
auto* ptr_ty = TypeOf(expr->args()[0])->UnwrapRef()->As<sem::Pointer>();
|
||||
auto sc = ptr_ty->StorageClass();
|
||||
|
||||
auto func = utils::GetOrCreate(
|
||||
|
@ -765,7 +765,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
|||
using Usage = sem::ParameterUsage;
|
||||
|
||||
auto parameters = intrinsic->Parameters();
|
||||
auto arguments = expr->params();
|
||||
auto arguments = expr->args();
|
||||
|
||||
// Returns the argument with the given usage
|
||||
auto arg = [&](Usage usage) {
|
||||
|
@ -2815,7 +2815,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
|||
{
|
||||
ScopedParen sp(out);
|
||||
bool first = true;
|
||||
for (auto* arg : call->params()) {
|
||||
for (auto* arg : call->args()) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
|
|
|
@ -2251,7 +2251,7 @@ uint32_t Builder::GenerateCallExpression(ast::CallExpression* expr) {
|
|||
ops.push_back(Operand::Int(func_id));
|
||||
|
||||
size_t arg_idx = 0;
|
||||
for (auto* arg : expr->params()) {
|
||||
for (auto* arg : expr->args()) {
|
||||
auto id = GenerateExpression(arg);
|
||||
if (id == 0) {
|
||||
return 0;
|
||||
|
@ -2316,7 +2316,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
|||
// and loads it if necessary. Returns 0 on error.
|
||||
auto get_param_as_value_id = [&](size_t i,
|
||||
bool generate_load = true) -> uint32_t {
|
||||
auto* arg = call->params()[i];
|
||||
auto* arg = call->args()[i];
|
||||
auto* param = intrinsic->Parameters()[i];
|
||||
auto val_id = GenerateExpression(arg);
|
||||
if (val_id == 0) {
|
||||
|
@ -2349,11 +2349,11 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
|||
op = spv::Op::OpAll;
|
||||
break;
|
||||
case IntrinsicType::kArrayLength: {
|
||||
if (call->params().empty()) {
|
||||
if (call->args().empty()) {
|
||||
error_ = "missing param for runtime array length";
|
||||
return 0;
|
||||
}
|
||||
auto* arg = call->params()[0];
|
||||
auto* arg = call->args()[0];
|
||||
|
||||
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||
|
@ -2641,7 +2641,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < call->params().size(); i++) {
|
||||
for (size_t i = 0; i < call->args().size(); i++) {
|
||||
if (auto val_id = get_param_as_value_id(i)) {
|
||||
params.emplace_back(Operand::Int(val_id));
|
||||
} else {
|
||||
|
@ -2663,7 +2663,7 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
|
|||
using Usage = sem::ParameterUsage;
|
||||
|
||||
auto parameters = intrinsic->Parameters();
|
||||
auto arguments = call->params();
|
||||
auto arguments = call->args();
|
||||
|
||||
// Generates the given expression, returning the operand ID
|
||||
auto gen = [&](ast::Expression* expr) {
|
||||
|
@ -3139,18 +3139,18 @@ bool Builder::GenerateAtomicIntrinsic(ast::CallExpression* call,
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32_t pointer_id = GenerateExpression(call->params()[0]);
|
||||
uint32_t pointer_id = GenerateExpression(call->args()[0]);
|
||||
if (pointer_id == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t value_id = 0;
|
||||
if (call->params().size() > 1) {
|
||||
value_id = GenerateExpression(call->params().back());
|
||||
if (call->args().size() > 1) {
|
||||
value_id = GenerateExpression(call->args().back());
|
||||
if (value_id == 0) {
|
||||
return false;
|
||||
}
|
||||
value_id = GenerateLoadIfNeeded(TypeOf(call->params().back()), value_id);
|
||||
value_id = GenerateLoadIfNeeded(TypeOf(call->args().back()), value_id);
|
||||
if (value_id == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3254,12 +3254,12 @@ bool Builder::GenerateAtomicIntrinsic(ast::CallExpression* call,
|
|||
value,
|
||||
});
|
||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||
auto comparator = GenerateExpression(call->params()[1]);
|
||||
auto comparator = GenerateExpression(call->args()[1]);
|
||||
if (comparator == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* value_sem_type = TypeOf(call->params()[2]);
|
||||
auto* value_sem_type = TypeOf(call->args()[2]);
|
||||
|
||||
auto value_type = GenerateTypeIfNeeded(value_sem_type);
|
||||
if (value_type == 0) {
|
||||
|
|
|
@ -215,14 +215,14 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
|||
out << "(";
|
||||
|
||||
bool first = true;
|
||||
const auto& params = expr->params();
|
||||
for (auto* param : params) {
|
||||
const auto& args = expr->args();
|
||||
for (auto* arg : args) {
|
||||
if (!first) {
|
||||
out << ", ";
|
||||
}
|
||||
first = false;
|
||||
|
||||
if (!EmitExpression(out, param)) {
|
||||
if (!EmitExpression(out, arg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue