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,
|
CallExpression::CallExpression(ProgramID program_id,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
IdentifierExpression* func,
|
IdentifierExpression* func,
|
||||||
ExpressionList params)
|
ExpressionList args)
|
||||||
: Base(program_id, source), func_(func), params_(params) {
|
: Base(program_id, source), func_(func), args_(args) {
|
||||||
TINT_ASSERT(AST, func_);
|
TINT_ASSERT(AST, func_);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, func_, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, func_, program_id);
|
||||||
for (auto* param : params_) {
|
for (auto* arg : args_) {
|
||||||
TINT_ASSERT(AST, param);
|
TINT_ASSERT(AST, arg);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, param, program_id);
|
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
|
// Clone arguments outside of create() call to have deterministic ordering
|
||||||
auto src = ctx->Clone(source());
|
auto src = ctx->Clone(source());
|
||||||
auto* fn = ctx->Clone(func_);
|
auto* fn = ctx->Clone(func_);
|
||||||
auto p = ctx->Clone(params_);
|
auto p = ctx->Clone(args_);
|
||||||
return ctx->dst->create<CallExpression>(src, fn, p);
|
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);
|
make_indent(out, indent + 2);
|
||||||
out << "(" << std::endl;
|
out << "(" << std::endl;
|
||||||
for (auto* param : params_)
|
for (auto* arg : args_)
|
||||||
param->to_str(sem, out, indent + 4);
|
arg->to_str(sem, out, indent + 4);
|
||||||
|
|
||||||
make_indent(out, indent + 2);
|
make_indent(out, indent + 2);
|
||||||
out << ")" << std::endl;
|
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 program_id the identifier of the program that owns this node
|
||||||
/// @param source the call expression source
|
/// @param source the call expression source
|
||||||
/// @param func the function
|
/// @param func the function
|
||||||
/// @param params the parameters
|
/// @param args the arguments
|
||||||
CallExpression(ProgramID program_id,
|
CallExpression(ProgramID program_id,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
IdentifierExpression* func,
|
IdentifierExpression* func,
|
||||||
ExpressionList params);
|
ExpressionList args);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
CallExpression(CallExpression&&);
|
CallExpression(CallExpression&&);
|
||||||
~CallExpression() override;
|
~CallExpression() override;
|
||||||
|
|
||||||
/// @returns the func
|
/// @returns the func
|
||||||
IdentifierExpression* func() const { return func_; }
|
IdentifierExpression* func() const { return func_; }
|
||||||
/// @returns the parameters
|
/// @returns the arguments
|
||||||
const ExpressionList& params() const { return params_; }
|
const ExpressionList& args() const { return args_; }
|
||||||
|
|
||||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||||
/// `ctx`.
|
/// `ctx`.
|
||||||
|
@ -62,7 +62,7 @@ class CallExpression : public Castable<CallExpression, Expression> {
|
||||||
CallExpression(const CallExpression&) = delete;
|
CallExpression(const CallExpression&) = delete;
|
||||||
|
|
||||||
IdentifierExpression* const func_;
|
IdentifierExpression* const func_;
|
||||||
ExpressionList const params_;
|
ExpressionList const args_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
|
|
|
@ -30,7 +30,7 @@ TEST_F(CallExpressionTest, Creation) {
|
||||||
auto* stmt = create<CallExpression>(func, params);
|
auto* stmt = create<CallExpression>(func, params);
|
||||||
EXPECT_EQ(stmt->func(), func);
|
EXPECT_EQ(stmt->func(), func);
|
||||||
|
|
||||||
const auto& vec = stmt->params();
|
const auto& vec = stmt->args();
|
||||||
ASSERT_EQ(vec.size(), 2u);
|
ASSERT_EQ(vec.size(), 2u);
|
||||||
EXPECT_EQ(vec[0], params[0]);
|
EXPECT_EQ(vec[0], params[0]);
|
||||||
EXPECT_EQ(vec[1], params[1]);
|
EXPECT_EQ(vec[1], params[1]);
|
||||||
|
|
|
@ -842,8 +842,8 @@ void Inspector::GenerateSamplerTargets() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* t = c->params()[texture_index];
|
auto* t = c->args()[texture_index];
|
||||||
auto* s = c->params()[sampler_index];
|
auto* s = c->args()[sampler_index];
|
||||||
|
|
||||||
GetOriginatingResources(
|
GetOriginatingResources(
|
||||||
std::array<const ast::Expression*, 2>{t, s},
|
std::array<const ast::Expression*, 2>{t, s},
|
||||||
|
@ -959,7 +959,7 @@ void Inspector::GetOriginatingResources(
|
||||||
// Patch all the parameter expressions with their argument
|
// Patch all the parameter expressions with their argument
|
||||||
for (size_t i = 0; i < N; i++) {
|
for (size_t i = 0; i < N; i++) {
|
||||||
if (auto* param = parameters[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
|
// Now call GetOriginatingResources() with from the callsite
|
||||||
|
|
|
@ -71,7 +71,7 @@ TEST_F(SpvParserTest, WorkgroupBarrier) {
|
||||||
ASSERT_GT(helper->body()->size(), 0u);
|
ASSERT_GT(helper->body()->size(), 0u);
|
||||||
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
||||||
ASSERT_NE(call, nullptr);
|
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());
|
auto* sem_call = program.Sem().Get(call->expr());
|
||||||
ASSERT_NE(sem_call, nullptr);
|
ASSERT_NE(sem_call, nullptr);
|
||||||
auto* intrinsic = sem_call->Target()->As<sem::Intrinsic>();
|
auto* intrinsic = sem_call->Target()->As<sem::Intrinsic>();
|
||||||
|
@ -105,7 +105,7 @@ TEST_F(SpvParserTest, StorageBarrier) {
|
||||||
ASSERT_GT(helper->body()->size(), 0u);
|
ASSERT_GT(helper->body()->size(), 0u);
|
||||||
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
auto* call = helper->body()->get(0)->As<ast::CallStatement>();
|
||||||
ASSERT_NE(call, nullptr);
|
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());
|
auto* sem_call = program.Sem().Get(call->expr());
|
||||||
ASSERT_NE(sem_call, nullptr);
|
ASSERT_NE(sem_call, nullptr);
|
||||||
auto* intrinsic = sem_call->Target()->As<sem::Intrinsic>();
|
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->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) {
|
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->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 3u);
|
EXPECT_EQ(c->args().size(), 3u);
|
||||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||||
EXPECT_TRUE(c->params()[2]->Is<ast::BinaryExpression>());
|
EXPECT_TRUE(c->args()[2]->Is<ast::BinaryExpression>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, Statement_Call_WithParams_TrailingComma) {
|
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->func()->symbol(), p->builder().Symbols().Get("a"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 2u);
|
EXPECT_EQ(c->args().size(), 2u);
|
||||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, Statement_Call_Missing_RightParen) {
|
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->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) {
|
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->func()->symbol(), p->builder().Symbols().Get("test"));
|
||||||
|
|
||||||
EXPECT_EQ(c->params().size(), 3u);
|
EXPECT_EQ(c->args().size(), 3u);
|
||||||
EXPECT_TRUE(c->params()[0]->Is<ast::ConstructorExpression>());
|
EXPECT_TRUE(c->args()[0]->Is<ast::ConstructorExpression>());
|
||||||
EXPECT_TRUE(c->params()[1]->Is<ast::IdentifierExpression>());
|
EXPECT_TRUE(c->args()[1]->Is<ast::IdentifierExpression>());
|
||||||
EXPECT_TRUE(c->params()[2]->Is<ast::BinaryExpression>());
|
EXPECT_TRUE(c->args()[2]->Is<ast::BinaryExpression>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, SingularExpression_Call_TrailingComma) {
|
TEST_F(ParserImplTest, SingularExpression_Call_TrailingComma) {
|
||||||
|
@ -133,7 +133,7 @@ TEST_F(ParserImplTest, SingularExpression_Call_TrailingComma) {
|
||||||
|
|
||||||
ASSERT_TRUE(e->Is<ast::CallExpression>());
|
ASSERT_TRUE(e->Is<ast::CallExpression>());
|
||||||
auto* c = e->As<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) {
|
TEST_F(ParserImplTest, SingularExpression_Call_InvalidArg) {
|
||||||
|
|
|
@ -2312,7 +2312,7 @@ bool Resolver::TraverseExpressions(ast::Expression* root,
|
||||||
} else if (auto* bitcast = expr->As<ast::BitcastExpression>()) {
|
} else if (auto* bitcast = expr->As<ast::BitcastExpression>()) {
|
||||||
add(bitcast->expr());
|
add(bitcast->expr());
|
||||||
} else if (auto* call = expr->As<ast::CallExpression>()) {
|
} else if (auto* call = expr->As<ast::CallExpression>()) {
|
||||||
for (auto* arg : call->params()) {
|
for (auto* arg : call->args()) {
|
||||||
add(arg);
|
add(arg);
|
||||||
}
|
}
|
||||||
} else if (auto* type_ctor = expr->As<ast::TypeConstructorExpression>()) {
|
} 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,
|
bool Resolver::IntrinsicCall(ast::CallExpression* call,
|
||||||
sem::IntrinsicType intrinsic_type) {
|
sem::IntrinsicType intrinsic_type) {
|
||||||
std::vector<const sem::Type*> arg_tys;
|
std::vector<const sem::Type*> arg_tys;
|
||||||
arg_tys.reserve(call->params().size());
|
arg_tys.reserve(call->args().size());
|
||||||
for (auto* expr : call->params()) {
|
for (auto* expr : call->args()) {
|
||||||
arg_tys.emplace_back(TypeOf(expr));
|
arg_tys.emplace_back(TypeOf(expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2545,7 +2545,7 @@ bool Resolver::ValidateTextureIntrinsicFunction(
|
||||||
auto index =
|
auto index =
|
||||||
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kOffset);
|
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kOffset);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
auto* param = ast_call->params()[index];
|
auto* param = ast_call->args()[index];
|
||||||
if (param->Is<ast::TypeConstructorExpression>()) {
|
if (param->Is<ast::TypeConstructorExpression>()) {
|
||||||
auto values = ConstantValueOf(param);
|
auto values = ConstantValueOf(param);
|
||||||
if (!values.IsValid()) {
|
if (!values.IsValid()) {
|
||||||
|
@ -2639,19 +2639,19 @@ bool Resolver::ValidateFunctionCall(const ast::CallExpression* call,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call->params().size() != target->parameters.size()) {
|
if (call->args().size() != target->parameters.size()) {
|
||||||
bool more = call->params().size() > target->parameters.size();
|
bool more = call->args().size() > target->parameters.size();
|
||||||
AddError("too " + (more ? std::string("many") : std::string("few")) +
|
AddError("too " + (more ? std::string("many") : std::string("few")) +
|
||||||
" arguments in call to '" + name + "', expected " +
|
" arguments in call to '" + name + "', expected " +
|
||||||
std::to_string(target->parameters.size()) + ", got " +
|
std::to_string(target->parameters.size()) + ", got " +
|
||||||
std::to_string(call->params().size()),
|
std::to_string(call->args().size()),
|
||||||
call->source());
|
call->source());
|
||||||
return false;
|
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 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();
|
auto* arg_type = TypeOf(arg_expr)->UnwrapRef();
|
||||||
|
|
||||||
if (param->type != arg_type) {
|
if (param->type != arg_type) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx,
|
||||||
// We assume that the argument to `arrayLength` has the form
|
// We assume that the argument to `arrayLength` has the form
|
||||||
// `&resource.array`, which requires that `InlinePointerLets` and
|
// `&resource.array`, which requires that `InlinePointerLets` and
|
||||||
// `Simplify` have been run before this transform.
|
// `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) {
|
if (!param || param->op() != ast::UnaryOp::kAddressOf) {
|
||||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||||
<< "expected form of arrayLength argument to be "
|
<< "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
|
// We can assume that the arrayLength() call has a single argument of
|
||||||
// the form: arrayLength(&X.Y) where X is an expression that resolves
|
// the form: arrayLength(&X.Y) where X is an expression that resolves
|
||||||
// to the storage buffer structure, and Y is the runtime sized array.
|
// 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>();
|
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
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
|
// may refer to a structure holding a runtime array, which cannot be
|
||||||
// loaded. Instead replace X with the underlying storage / uniform
|
// loaded. Instead replace X with the underlying storage / uniform
|
||||||
// buffer variable.
|
// buffer variable.
|
||||||
if (auto access = state.TakeAccess(call_expr->params()[0])) {
|
if (auto access = state.TakeAccess(call_expr->args()[0])) {
|
||||||
ctx.Replace(call_expr->params()[0], [=, &ctx] {
|
ctx.Replace(call_expr->args()[0], [=, &ctx] {
|
||||||
return ctx.CloneWithoutTransform(access.var->Declaration());
|
return ctx.CloneWithoutTransform(access.var->Declaration());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -938,11 +938,11 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||||
// arrayLength(X)
|
// arrayLength(X)
|
||||||
// Don't convert X into a load, this intrinsic actually requires the
|
// Don't convert X into a load, this intrinsic actually requires the
|
||||||
// real pointer.
|
// real pointer.
|
||||||
state.TakeAccess(call_expr->params()[0]);
|
state.TakeAccess(call_expr->args()[0]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (intrinsic->IsAtomic()) {
|
if (intrinsic->IsAtomic()) {
|
||||||
if (auto access = state.TakeAccess(call_expr->params()[0])) {
|
if (auto access = state.TakeAccess(call_expr->args()[0])) {
|
||||||
// atomic___(X)
|
// atomic___(X)
|
||||||
ctx.Replace(call_expr, [=, &ctx, &state] {
|
ctx.Replace(call_expr, [=, &ctx, &state] {
|
||||||
auto* buf = access.var->Declaration();
|
auto* buf = access.var->Declaration();
|
||||||
|
@ -954,8 +954,8 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
|
||||||
access.var->As<sem::VariableUser>());
|
access.var->As<sem::VariableUser>());
|
||||||
|
|
||||||
ast::ExpressionList args{ctx.Clone(buf), offset};
|
ast::ExpressionList args{ctx.Clone(buf), offset};
|
||||||
for (size_t i = 1; i < call_expr->params().size(); i++) {
|
for (size_t i = 1; i < call_expr->args().size(); i++) {
|
||||||
auto* arg = call_expr->params()[i];
|
auto* arg = call_expr->args()[i];
|
||||||
args.emplace_back(ctx.Clone(arg));
|
args.emplace_back(ctx.Clone(arg));
|
||||||
}
|
}
|
||||||
return ctx.dst->Call(func, args);
|
return ctx.dst->Call(func, args);
|
||||||
|
|
|
@ -53,43 +53,43 @@ void ExternalTextureTransform::Run(CloneContext& ctx,
|
||||||
// When a textureLoad or textureSampleLevel has been identified, check
|
// When a textureLoad or textureSampleLevel has been identified, check
|
||||||
// if the first parameter is an external texture.
|
// if the first parameter is an external texture.
|
||||||
if (auto* var =
|
if (auto* var =
|
||||||
sem.Get(call_expr->params()[0])->As<sem::VariableUser>()) {
|
sem.Get(call_expr->args()[0])->As<sem::VariableUser>()) {
|
||||||
if (var->Variable()
|
if (var->Variable()
|
||||||
->Type()
|
->Type()
|
||||||
->UnwrapRef()
|
->UnwrapRef()
|
||||||
->Is<sem::ExternalTexture>()) {
|
->Is<sem::ExternalTexture>()) {
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad &&
|
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad &&
|
||||||
call_expr->params().size() != 2) {
|
call_expr->args().size() != 2) {
|
||||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||||
<< "expected textureLoad call with a texture_external to "
|
<< "expected textureLoad call with a texture_external to "
|
||||||
"have 2 parameters, found "
|
"have 2 parameters, found "
|
||||||
<< call_expr->params().size() << " parameters";
|
<< call_expr->args().size() << " parameters";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intrinsic->Type() ==
|
if (intrinsic->Type() ==
|
||||||
sem::IntrinsicType::kTextureSampleLevel &&
|
sem::IntrinsicType::kTextureSampleLevel &&
|
||||||
call_expr->params().size() != 3) {
|
call_expr->args().size() != 3) {
|
||||||
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
TINT_ICE(Transform, ctx.dst->Diagnostics())
|
||||||
<< "expected textureSampleLevel call with a "
|
<< "expected textureSampleLevel call with a "
|
||||||
"texture_external to have 3 parameters, found "
|
"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
|
// Replace the call with another that has the same parameters in
|
||||||
// addition to a level parameter (always zero for external
|
// addition to a level parameter (always zero for external
|
||||||
// textures).
|
// textures).
|
||||||
auto* exp = ctx.Clone(call_expr->func());
|
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;
|
ast::ExpressionList params;
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad) {
|
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);
|
auto* levelParam = ctx.dst->Expr(0);
|
||||||
params = {externalTextureParam, coordsParam, levelParam};
|
params = {externalTextureParam, coordsParam, levelParam};
|
||||||
} else if (intrinsic->Type() ==
|
} else if (intrinsic->Type() ==
|
||||||
sem::IntrinsicType::kTextureSampleLevel) {
|
sem::IntrinsicType::kTextureSampleLevel) {
|
||||||
auto* samplerParam = ctx.Clone(call_expr->params()[1]);
|
auto* samplerParam = ctx.Clone(call_expr->args()[1]);
|
||||||
auto* coordsParam = ctx.Clone(call_expr->params()[2]);
|
auto* coordsParam = ctx.Clone(call_expr->args()[2]);
|
||||||
auto* levelParam = ctx.dst->Expr(0.0f);
|
auto* levelParam = ctx.dst->Expr(0.0f);
|
||||||
params = {externalTextureParam, samplerParam, coordsParam,
|
params = {externalTextureParam, samplerParam, coordsParam,
|
||||||
levelParam};
|
levelParam};
|
||||||
|
|
|
@ -305,7 +305,7 @@ struct ModuleScopeVarToEntryPointParam::State {
|
||||||
if (is_entry_point && !is_handle && !is_workgroup_matrix) {
|
if (is_entry_point && !is_handle && !is_workgroup_matrix) {
|
||||||
arg = ctx.dst->AddressOf(arg);
|
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 =
|
auto level_idx =
|
||||||
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kLevel);
|
sem::IndexOf(intrinsic->Parameters(), sem::ParameterUsage::kLevel);
|
||||||
|
|
||||||
auto* texture_arg = expr->params()[texture_idx];
|
auto* texture_arg = expr->args()[texture_idx];
|
||||||
auto* coords_arg = expr->params()[coords_idx];
|
auto* coords_arg = expr->args()[coords_idx];
|
||||||
auto* coords_ty = intrinsic->Parameters()[coords_idx]->Type();
|
auto* coords_ty = intrinsic->Parameters()[coords_idx]->Type();
|
||||||
|
|
||||||
// If the level is provided, then we need to clamp this. As the level is
|
// 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;
|
std::function<ast::Expression*()> level_arg;
|
||||||
if (level_idx >= 0) {
|
if (level_idx >= 0) {
|
||||||
level_arg = [&] {
|
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* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
|
||||||
auto* zero = b.Expr(0);
|
auto* zero = b.Expr(0);
|
||||||
auto* max = ctx.dst->Sub(num_levels, 1);
|
auto* max = ctx.dst->Sub(num_levels, 1);
|
||||||
|
@ -253,7 +253,7 @@ struct Robustness::State {
|
||||||
|
|
||||||
// Clamp the array_index argument, if provided
|
// Clamp the array_index argument, if provided
|
||||||
if (array_idx >= 0) {
|
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* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
|
||||||
auto* zero = b.Expr(0);
|
auto* zero = b.Expr(0);
|
||||||
auto* max = ctx.dst->Sub(num_layers, 1);
|
auto* max = ctx.dst->Sub(num_layers, 1);
|
||||||
|
@ -263,7 +263,7 @@ struct Robustness::State {
|
||||||
|
|
||||||
// Clamp the level argument, if provided
|
// Clamp the level argument, if provided
|
||||||
if (level_idx >= 0) {
|
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));
|
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) {
|
bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
auto* ident = expr->func();
|
auto* ident = expr->func();
|
||||||
auto* call = builder_.Sem().Get(expr);
|
auto* call = builder_.Sem().Get(expr);
|
||||||
auto* target = call->Target();
|
auto* target = call->Target();
|
||||||
|
@ -389,11 +389,11 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
func->Declaration()->decorations())) {
|
func->Declaration()->decorations())) {
|
||||||
// Special function generated by the CalculateArrayLength transform for
|
// Special function generated by the CalculateArrayLength transform for
|
||||||
// calling X.GetDimensions(Y)
|
// calling X.GetDimensions(Y)
|
||||||
if (!EmitExpression(out, params[0])) {
|
if (!EmitExpression(out, args[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ".GetDimensions(";
|
out << ".GetDimensions(";
|
||||||
if (!EmitExpression(out, params[1])) {
|
if (!EmitExpression(out, args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ")";
|
out << ")";
|
||||||
|
@ -413,7 +413,7 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
||||||
return EmitIsNormalCall(out, expr, intrinsic);
|
return EmitIsNormalCall(out, expr, intrinsic);
|
||||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
||||||
return EmitExpression(out, expr->params()[0]);
|
return EmitExpression(out, expr->args()[0]);
|
||||||
} else if (intrinsic->IsDataPacking()) {
|
} else if (intrinsic->IsDataPacking()) {
|
||||||
return EmitDataPackingCall(out, expr, intrinsic);
|
return EmitDataPackingCall(out, expr, intrinsic);
|
||||||
} else if (intrinsic->IsDataUnpacking()) {
|
} else if (intrinsic->IsDataUnpacking()) {
|
||||||
|
@ -431,13 +431,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << name << "(";
|
out << name << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,13 +460,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << name << "(";
|
out << name << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,8 +500,8 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedParen sp(pre);
|
ScopedParen sp(pre);
|
||||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||||
auto* arg = expr->params()[i];
|
auto* arg = expr->args()[i];
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
pre << ", ";
|
pre << ", ";
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
pre << "InterlockedOr";
|
pre << "InterlockedOr";
|
||||||
{
|
{
|
||||||
ScopedParen sp(pre);
|
ScopedParen sp(pre);
|
||||||
if (!EmitExpression(pre, expr->params()[0])) {
|
if (!EmitExpression(pre, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pre << ", 0, " << result;
|
pre << ", 0, " << result;
|
||||||
|
@ -557,11 +557,11 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
out << "InterlockedExchange";
|
out << "InterlockedExchange";
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", ";
|
out << ", ";
|
||||||
if (!EmitExpression(out, expr->params()[1])) {
|
if (!EmitExpression(out, expr->args()[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", " << result;
|
out << ", " << result;
|
||||||
|
@ -569,9 +569,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||||
auto* dest = expr->params()[0];
|
auto* dest = expr->args()[0];
|
||||||
auto* compare_value = expr->params()[1];
|
auto* compare_value = expr->args()[1];
|
||||||
auto* value = expr->params()[2];
|
auto* value = expr->args()[2];
|
||||||
|
|
||||||
std::string compare = UniqueIdentifier("atomic_compare_value");
|
std::string compare = UniqueIdentifier("atomic_compare_value");
|
||||||
|
|
||||||
|
@ -647,9 +647,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
|
|
||||||
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
||||||
ast::CallExpression* expr) {
|
ast::CallExpression* expr) {
|
||||||
auto* expr_false = expr->params()[0];
|
auto* expr_false = expr->args()[0];
|
||||||
auto* expr_true = expr->params()[1];
|
auto* expr_true = expr->args()[1];
|
||||||
auto* expr_cond = expr->params()[2];
|
auto* expr_cond = expr->args()[2];
|
||||||
ScopedParen paren(out);
|
ScopedParen paren(out);
|
||||||
if (!EmitExpression(out, expr_cond)) {
|
if (!EmitExpression(out, expr_cond)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -673,7 +673,7 @@ bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
||||||
bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
if (expr->params().size() == 1) {
|
if (expr->args().size() == 1) {
|
||||||
return CallIntrinsicHelper(
|
return CallIntrinsicHelper(
|
||||||
out, expr, intrinsic,
|
out, expr, intrinsic,
|
||||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
|
@ -710,11 +710,11 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
out << "modf";
|
out << "modf";
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", ";
|
out << ", ";
|
||||||
if (!EmitExpression(out, expr->params()[1])) {
|
if (!EmitExpression(out, expr->args()[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -723,7 +723,7 @@ bool GeneratorImpl::EmitModfCall(std::ostream& out,
|
||||||
bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
if (expr->params().size() == 1) {
|
if (expr->args().size() == 1) {
|
||||||
return CallIntrinsicHelper(
|
return CallIntrinsicHelper(
|
||||||
out, expr, intrinsic,
|
out, expr, intrinsic,
|
||||||
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
|
@ -977,7 +977,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||||
using Usage = sem::ParameterUsage;
|
using Usage = sem::ParameterUsage;
|
||||||
|
|
||||||
auto parameters = intrinsic->Parameters();
|
auto parameters = intrinsic->Parameters();
|
||||||
auto arguments = expr->params();
|
auto arguments = expr->args();
|
||||||
|
|
||||||
// Returns the argument with the given usage
|
// Returns the argument with the given usage
|
||||||
auto arg = [&](Usage usage) {
|
auto arg = [&](Usage usage) {
|
||||||
|
@ -2726,7 +2726,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* arg : call->params()) {
|
for (auto* arg : call->args()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,7 +551,7 @@ bool GeneratorImpl::EmitBreak(ast::BreakStatement*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
auto* ident = expr->func();
|
auto* ident = expr->func();
|
||||||
auto* call = builder_.Sem().Get(expr);
|
auto* call = builder_.Sem().Get(expr);
|
||||||
auto* target = call->Target();
|
auto* target = call->Target();
|
||||||
|
@ -562,11 +562,11 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
func->Declaration()->decorations())) {
|
func->Declaration()->decorations())) {
|
||||||
// Special function generated by the CalculateArrayLength transform for
|
// Special function generated by the CalculateArrayLength transform for
|
||||||
// calling X.GetDimensions(Y)
|
// calling X.GetDimensions(Y)
|
||||||
if (!EmitExpression(out, params[0])) {
|
if (!EmitExpression(out, args[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ".GetDimensions(";
|
out << ".GetDimensions(";
|
||||||
if (!EmitExpression(out, params[1])) {
|
if (!EmitExpression(out, args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ")";
|
out << ")";
|
||||||
|
@ -602,7 +602,7 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
} else if (intrinsic->Type() == sem::IntrinsicType::kIsNormal) {
|
||||||
return EmitIsNormalCall(out, expr, intrinsic);
|
return EmitIsNormalCall(out, expr, intrinsic);
|
||||||
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
} else if (intrinsic->Type() == sem::IntrinsicType::kIgnore) {
|
||||||
return EmitExpression(out, expr->params()[0]);
|
return EmitExpression(out, expr->args()[0]);
|
||||||
} else if (intrinsic->IsDataPacking()) {
|
} else if (intrinsic->IsDataPacking()) {
|
||||||
return EmitDataPackingCall(out, expr, intrinsic);
|
return EmitDataPackingCall(out, expr, intrinsic);
|
||||||
} else if (intrinsic->IsDataUnpacking()) {
|
} else if (intrinsic->IsDataUnpacking()) {
|
||||||
|
@ -620,13 +620,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << name << "(";
|
out << name << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,13 +649,13 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << name << "(";
|
out << name << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,8 +669,8 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
std::ostream& out,
|
std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
auto* offset_arg = builder_.Sem().Get(params[1]);
|
auto* offset_arg = builder_.Sem().Get(args[1]);
|
||||||
|
|
||||||
uint32_t scalar_offset_value = 0;
|
uint32_t scalar_offset_value = 0;
|
||||||
std::string scalar_offset_expr;
|
std::string scalar_offset_expr;
|
||||||
|
@ -691,7 +691,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
scalar_offset_expr = UniqueIdentifier("scalar_offset");
|
scalar_offset_expr = UniqueIdentifier("scalar_offset");
|
||||||
auto pre = line();
|
auto pre = line();
|
||||||
pre << "const uint " << scalar_offset_expr << " = (";
|
pre << "const uint " << scalar_offset_expr << " = (";
|
||||||
if (!EmitExpression(pre, params[1])) { // offset
|
if (!EmitExpression(pre, args[1])) { // offset
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pre << ") / 4;";
|
pre << ") / 4;";
|
||||||
|
@ -708,7 +708,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
auto load_scalar = [&]() {
|
auto load_scalar = [&]() {
|
||||||
if (!EmitExpression(out, params[0])) { // buffer
|
if (!EmitExpression(out, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (scalar_offset_constant) {
|
if (scalar_offset_constant) {
|
||||||
|
@ -724,7 +724,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
// Has a minimum alignment of 8 bytes, so is either .xy or .zw
|
// Has a minimum alignment of 8 bytes, so is either .xy or .zw
|
||||||
auto load_vec2 = [&] {
|
auto load_vec2 = [&] {
|
||||||
if (scalar_offset_constant) {
|
if (scalar_offset_constant) {
|
||||||
if (!EmitExpression(out, params[0])) { // buffer
|
if (!EmitExpression(out, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << "[" << (scalar_offset_value / 4) << "]";
|
out << "[" << (scalar_offset_value / 4) << "]";
|
||||||
|
@ -734,7 +734,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
{
|
{
|
||||||
auto pre = line();
|
auto pre = line();
|
||||||
pre << "uint4 " << ubo_load << " = ";
|
pre << "uint4 " << ubo_load << " = ";
|
||||||
if (!EmitExpression(pre, params[0])) { // buffer
|
if (!EmitExpression(pre, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pre << "[" << scalar_offset_expr << " / 4];";
|
pre << "[" << scalar_offset_expr << " / 4];";
|
||||||
|
@ -746,7 +746,7 @@ bool GeneratorImpl::EmitUniformBufferAccess(
|
||||||
};
|
};
|
||||||
// vec4 has a minimum alignment of 16 bytes, easiest case
|
// vec4 has a minimum alignment of 16 bytes, easiest case
|
||||||
auto load_vec4 = [&] {
|
auto load_vec4 = [&] {
|
||||||
if (!EmitExpression(out, params[0])) { // buffer
|
if (!EmitExpression(out, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (scalar_offset_constant) {
|
if (scalar_offset_constant) {
|
||||||
|
@ -808,7 +808,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
||||||
std::ostream& out,
|
std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) {
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
|
|
||||||
using Op = transform::DecomposeMemoryAccess::Intrinsic::Op;
|
using Op = transform::DecomposeMemoryAccess::Intrinsic::Op;
|
||||||
using DataType = transform::DecomposeMemoryAccess::Intrinsic::DataType;
|
using DataType = transform::DecomposeMemoryAccess::Intrinsic::DataType;
|
||||||
|
@ -818,7 +818,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
||||||
if (cast) {
|
if (cast) {
|
||||||
out << cast << "(";
|
out << cast << "(";
|
||||||
}
|
}
|
||||||
if (!EmitExpression(out, params[0])) { // buffer
|
if (!EmitExpression(out, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ".Load";
|
out << ".Load";
|
||||||
|
@ -826,7 +826,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
||||||
out << n;
|
out << n;
|
||||||
}
|
}
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, params[1])) { // offset
|
if (!EmitExpression(out, args[1])) { // offset
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (cast) {
|
if (cast) {
|
||||||
|
@ -868,7 +868,7 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
||||||
|
|
||||||
case Op::kStore: {
|
case Op::kStore: {
|
||||||
auto store = [&](int n) {
|
auto store = [&](int n) {
|
||||||
if (!EmitExpression(out, params[0])) { // buffer
|
if (!EmitExpression(out, args[0])) { // buffer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ".Store";
|
out << ".Store";
|
||||||
|
@ -876,12 +876,12 @@ bool GeneratorImpl::EmitStorageBufferAccess(
|
||||||
out << n;
|
out << n;
|
||||||
}
|
}
|
||||||
ScopedParen sp1(out);
|
ScopedParen sp1(out);
|
||||||
if (!EmitExpression(out, params[1])) { // offset
|
if (!EmitExpression(out, args[1])) { // offset
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", asuint";
|
out << ", asuint";
|
||||||
ScopedParen sp2(out);
|
ScopedParen sp2(out);
|
||||||
if (!EmitExpression(out, params[2])) { // value
|
if (!EmitExpression(out, args[2])) { // value
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1057,7 +1057,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
||||||
case Op::kAtomicStore: {
|
case Op::kAtomicStore: {
|
||||||
// HLSL does not have an InterlockedStore, so we emulate it with
|
// HLSL does not have an InterlockedStore, so we emulate it with
|
||||||
// InterlockedExchange and discard the returned value
|
// 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 name = UniqueIdentifier("atomicStore");
|
||||||
{
|
{
|
||||||
auto fn = line(&buf);
|
auto fn = line(&buf);
|
||||||
|
@ -1088,7 +1088,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
case Op::kAtomicCompareExchangeWeak: {
|
case Op::kAtomicCompareExchangeWeak: {
|
||||||
auto* value_ty = TypeOf(expr->params()[2])->UnwrapRef();
|
auto* value_ty = TypeOf(expr->args()[2])->UnwrapRef();
|
||||||
|
|
||||||
auto name = UniqueIdentifier("atomicCompareExchangeWeak");
|
auto name = UniqueIdentifier("atomicCompareExchangeWeak");
|
||||||
{
|
{
|
||||||
|
@ -1151,7 +1151,7 @@ bool GeneratorImpl::EmitStorageAtomicCall(
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* arg : expr->params()) {
|
for (auto* arg : expr->args()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
@ -1189,8 +1189,8 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedParen sp(pre);
|
ScopedParen sp(pre);
|
||||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||||
auto* arg = expr->params()[i];
|
auto* arg = expr->args()[i];
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
pre << ", ";
|
pre << ", ";
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1220,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
pre << "InterlockedOr";
|
pre << "InterlockedOr";
|
||||||
{
|
{
|
||||||
ScopedParen sp(pre);
|
ScopedParen sp(pre);
|
||||||
if (!EmitExpression(pre, expr->params()[0])) {
|
if (!EmitExpression(pre, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pre << ", 0, " << result;
|
pre << ", 0, " << result;
|
||||||
|
@ -1250,11 +1250,11 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
out << "InterlockedExchange";
|
out << "InterlockedExchange";
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", ";
|
out << ", ";
|
||||||
if (!EmitExpression(out, expr->params()[1])) {
|
if (!EmitExpression(out, expr->args()[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << ", " << result;
|
out << ", " << result;
|
||||||
|
@ -1262,9 +1262,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||||
auto* dest = expr->params()[0];
|
auto* dest = expr->args()[0];
|
||||||
auto* compare_value = expr->params()[1];
|
auto* compare_value = expr->args()[1];
|
||||||
auto* value = expr->params()[2];
|
auto* value = expr->args()[2];
|
||||||
|
|
||||||
std::string compare = UniqueIdentifier("atomic_compare_value");
|
std::string compare = UniqueIdentifier("atomic_compare_value");
|
||||||
|
|
||||||
|
@ -1340,9 +1340,9 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out,
|
||||||
|
|
||||||
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
bool GeneratorImpl::EmitSelectCall(std::ostream& out,
|
||||||
ast::CallExpression* expr) {
|
ast::CallExpression* expr) {
|
||||||
auto* expr_false = expr->params()[0];
|
auto* expr_false = expr->args()[0];
|
||||||
auto* expr_true = expr->params()[1];
|
auto* expr_true = expr->args()[1];
|
||||||
auto* expr_cond = expr->params()[2];
|
auto* expr_cond = expr->args()[2];
|
||||||
ScopedParen paren(out);
|
ScopedParen paren(out);
|
||||||
if (!EmitExpression(out, expr_cond)) {
|
if (!EmitExpression(out, expr_cond)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1621,7 +1621,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||||
using Usage = sem::ParameterUsage;
|
using Usage = sem::ParameterUsage;
|
||||||
|
|
||||||
auto parameters = intrinsic->Parameters();
|
auto parameters = intrinsic->Parameters();
|
||||||
auto arguments = expr->params();
|
auto arguments = expr->args();
|
||||||
|
|
||||||
// Returns the argument with the given usage
|
// Returns the argument with the given usage
|
||||||
auto arg = [&](Usage usage) {
|
auto arg = [&](Usage usage) {
|
||||||
|
@ -3434,7 +3434,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* arg : call->params()) {
|
for (auto* arg : call->args()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,14 +538,14 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << program_->Symbols().NameFor(var->Declaration()->symbol());
|
out << program_->Symbols().NameFor(var->Declaration()->symbol());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
||||||
} else {
|
} else {
|
||||||
out << "float2(as_type<half2>(";
|
out << "float2(as_type<half2>(";
|
||||||
}
|
}
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << "))";
|
out << "))";
|
||||||
|
@ -598,14 +598,14 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
||||||
}
|
}
|
||||||
case sem::IntrinsicType::kIgnore: {
|
case sem::IntrinsicType::kIgnore: {
|
||||||
out << "(void) ";
|
out << "(void) ";
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case sem::IntrinsicType::kLength: {
|
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()) {
|
if (sem->Type()->UnwrapRef()->is_scalar()) {
|
||||||
// Emulate scalar overload using fabs(x).
|
// Emulate scalar overload using fabs(x).
|
||||||
name = "fabs";
|
name = "fabs";
|
||||||
|
@ -614,16 +614,16 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
||||||
}
|
}
|
||||||
|
|
||||||
case sem::IntrinsicType::kDistance: {
|
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()) {
|
if (sem->Type()->UnwrapRef()->is_scalar()) {
|
||||||
// Emulate scalar overload using fabs(x - y);
|
// Emulate scalar overload using fabs(x - y);
|
||||||
out << "fabs";
|
out << "fabs";
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
if (!EmitExpression(out, expr->params()[0])) {
|
if (!EmitExpression(out, expr->args()[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out << " - ";
|
out << " - ";
|
||||||
if (!EmitExpression(out, expr->params()[1])) {
|
if (!EmitExpression(out, expr->args()[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -642,14 +642,14 @@ bool GeneratorImpl::EmitIntrinsicCall(std::ostream& out,
|
||||||
out << name << "(";
|
out << name << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,8 +665,8 @@ bool GeneratorImpl::EmitAtomicCall(std::ostream& out,
|
||||||
out << name;
|
out << name;
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
for (size_t i = 0; i < expr->params().size(); i++) {
|
for (size_t i = 0; i < expr->args().size(); i++) {
|
||||||
auto* arg = expr->params()[i];
|
auto* arg = expr->args()[i];
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ bool GeneratorImpl::EmitAtomicCall(std::ostream& out,
|
||||||
return call("atomic_exchange_explicit", true);
|
return call("atomic_exchange_explicit", true);
|
||||||
|
|
||||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
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 sc = ptr_ty->StorageClass();
|
||||||
|
|
||||||
auto func = utils::GetOrCreate(
|
auto func = utils::GetOrCreate(
|
||||||
|
@ -765,7 +765,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
|
||||||
using Usage = sem::ParameterUsage;
|
using Usage = sem::ParameterUsage;
|
||||||
|
|
||||||
auto parameters = intrinsic->Parameters();
|
auto parameters = intrinsic->Parameters();
|
||||||
auto arguments = expr->params();
|
auto arguments = expr->args();
|
||||||
|
|
||||||
// Returns the argument with the given usage
|
// Returns the argument with the given usage
|
||||||
auto arg = [&](Usage usage) {
|
auto arg = [&](Usage usage) {
|
||||||
|
@ -2815,7 +2815,7 @@ bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
||||||
{
|
{
|
||||||
ScopedParen sp(out);
|
ScopedParen sp(out);
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto* arg : call->params()) {
|
for (auto* arg : call->args()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2251,7 +2251,7 @@ uint32_t Builder::GenerateCallExpression(ast::CallExpression* expr) {
|
||||||
ops.push_back(Operand::Int(func_id));
|
ops.push_back(Operand::Int(func_id));
|
||||||
|
|
||||||
size_t arg_idx = 0;
|
size_t arg_idx = 0;
|
||||||
for (auto* arg : expr->params()) {
|
for (auto* arg : expr->args()) {
|
||||||
auto id = GenerateExpression(arg);
|
auto id = GenerateExpression(arg);
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2316,7 +2316,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
||||||
// and loads it if necessary. Returns 0 on error.
|
// and loads it if necessary. Returns 0 on error.
|
||||||
auto get_param_as_value_id = [&](size_t i,
|
auto get_param_as_value_id = [&](size_t i,
|
||||||
bool generate_load = true) -> uint32_t {
|
bool generate_load = true) -> uint32_t {
|
||||||
auto* arg = call->params()[i];
|
auto* arg = call->args()[i];
|
||||||
auto* param = intrinsic->Parameters()[i];
|
auto* param = intrinsic->Parameters()[i];
|
||||||
auto val_id = GenerateExpression(arg);
|
auto val_id = GenerateExpression(arg);
|
||||||
if (val_id == 0) {
|
if (val_id == 0) {
|
||||||
|
@ -2349,11 +2349,11 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
||||||
op = spv::Op::OpAll;
|
op = spv::Op::OpAll;
|
||||||
break;
|
break;
|
||||||
case IntrinsicType::kArrayLength: {
|
case IntrinsicType::kArrayLength: {
|
||||||
if (call->params().empty()) {
|
if (call->args().empty()) {
|
||||||
error_ = "missing param for runtime array length";
|
error_ = "missing param for runtime array length";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto* arg = call->params()[0];
|
auto* arg = call->args()[0];
|
||||||
|
|
||||||
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
auto* address_of = arg->As<ast::UnaryOpExpression>();
|
||||||
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
|
||||||
|
@ -2641,7 +2641,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call,
|
||||||
return 0;
|
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)) {
|
if (auto val_id = get_param_as_value_id(i)) {
|
||||||
params.emplace_back(Operand::Int(val_id));
|
params.emplace_back(Operand::Int(val_id));
|
||||||
} else {
|
} else {
|
||||||
|
@ -2663,7 +2663,7 @@ bool Builder::GenerateTextureIntrinsic(ast::CallExpression* call,
|
||||||
using Usage = sem::ParameterUsage;
|
using Usage = sem::ParameterUsage;
|
||||||
|
|
||||||
auto parameters = intrinsic->Parameters();
|
auto parameters = intrinsic->Parameters();
|
||||||
auto arguments = call->params();
|
auto arguments = call->args();
|
||||||
|
|
||||||
// Generates the given expression, returning the operand ID
|
// Generates the given expression, returning the operand ID
|
||||||
auto gen = [&](ast::Expression* expr) {
|
auto gen = [&](ast::Expression* expr) {
|
||||||
|
@ -3139,18 +3139,18 @@ bool Builder::GenerateAtomicIntrinsic(ast::CallExpression* call,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pointer_id = GenerateExpression(call->params()[0]);
|
uint32_t pointer_id = GenerateExpression(call->args()[0]);
|
||||||
if (pointer_id == 0) {
|
if (pointer_id == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t value_id = 0;
|
uint32_t value_id = 0;
|
||||||
if (call->params().size() > 1) {
|
if (call->args().size() > 1) {
|
||||||
value_id = GenerateExpression(call->params().back());
|
value_id = GenerateExpression(call->args().back());
|
||||||
if (value_id == 0) {
|
if (value_id == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
value_id = GenerateLoadIfNeeded(TypeOf(call->params().back()), value_id);
|
value_id = GenerateLoadIfNeeded(TypeOf(call->args().back()), value_id);
|
||||||
if (value_id == 0) {
|
if (value_id == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3254,12 +3254,12 @@ bool Builder::GenerateAtomicIntrinsic(ast::CallExpression* call,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
case sem::IntrinsicType::kAtomicCompareExchangeWeak: {
|
||||||
auto comparator = GenerateExpression(call->params()[1]);
|
auto comparator = GenerateExpression(call->args()[1]);
|
||||||
if (comparator == 0) {
|
if (comparator == 0) {
|
||||||
return false;
|
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);
|
auto value_type = GenerateTypeIfNeeded(value_sem_type);
|
||||||
if (value_type == 0) {
|
if (value_type == 0) {
|
||||||
|
|
|
@ -215,14 +215,14 @@ bool GeneratorImpl::EmitCall(std::ostream& out, ast::CallExpression* expr) {
|
||||||
out << "(";
|
out << "(";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
const auto& params = expr->params();
|
const auto& args = expr->args();
|
||||||
for (auto* param : params) {
|
for (auto* arg : args) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
if (!EmitExpression(out, param)) {
|
if (!EmitExpression(out, arg)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue