[tint][ir] Remove default parameters for Operand() and Result()
Change-Id: I7a4c5472208081bd9cef100e611d1d05b67cdfe3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/163244
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/lang/core/ir/access.cc b/src/tint/lang/core/ir/access.cc
index adb651c..c469a5d 100644
--- a/src/tint/lang/core/ir/access.cc
+++ b/src/tint/lang/core/ir/access.cc
@@ -46,7 +46,7 @@
Access::~Access() = default;
Access* Access::Clone(CloneContext& ctx) {
- auto new_result = ctx.Clone(Result());
+ auto new_result = ctx.Clone(Result(0));
auto obj = ctx.Remap(Object());
auto indices = ctx.Remap<Access::kDefaultNumOperands>(Indices());
return ctx.ir.instructions.Create<Access>(new_result, obj, indices);
diff --git a/src/tint/lang/core/ir/binary.cc b/src/tint/lang/core/ir/binary.cc
index c5a8e7c..41c9972 100644
--- a/src/tint/lang/core/ir/binary.cc
+++ b/src/tint/lang/core/ir/binary.cc
@@ -43,7 +43,7 @@
Binary::~Binary() = default;
Binary* Binary::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* lhs = ctx.Remap(LHS());
auto* rhs = ctx.Remap(RHS());
return ctx.ir.instructions.Create<Binary>(new_result, op_, lhs, rhs);
diff --git a/src/tint/lang/core/ir/bitcast.cc b/src/tint/lang/core/ir/bitcast.cc
index 62a40d7..26031a47 100644
--- a/src/tint/lang/core/ir/bitcast.cc
+++ b/src/tint/lang/core/ir/bitcast.cc
@@ -42,7 +42,7 @@
Bitcast::~Bitcast() = default;
Bitcast* Bitcast::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* val = ctx.Remap(Val());
return ctx.ir.instructions.Create<Bitcast>(new_result, val);
}
diff --git a/src/tint/lang/core/ir/construct.cc b/src/tint/lang/core/ir/construct.cc
index d3a81b9..fd67aee 100644
--- a/src/tint/lang/core/ir/construct.cc
+++ b/src/tint/lang/core/ir/construct.cc
@@ -44,7 +44,7 @@
Construct::~Construct() = default;
Construct* Construct::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto args = ctx.Remap<Construct::kDefaultNumOperands>(Args());
return ctx.ir.instructions.Create<Construct>(new_result, args);
}
diff --git a/src/tint/lang/core/ir/convert.cc b/src/tint/lang/core/ir/convert.cc
index 92639f6..4a479de 100644
--- a/src/tint/lang/core/ir/convert.cc
+++ b/src/tint/lang/core/ir/convert.cc
@@ -44,7 +44,7 @@
Convert::~Convert() = default;
Convert* Convert::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* val = ctx.Remap(Args()[0]);
return ctx.ir.instructions.Create<Convert>(new_result, val);
}
diff --git a/src/tint/lang/core/ir/core_builtin_call.cc b/src/tint/lang/core/ir/core_builtin_call.cc
index 3dd8483..33e38b5 100644
--- a/src/tint/lang/core/ir/core_builtin_call.cc
+++ b/src/tint/lang/core/ir/core_builtin_call.cc
@@ -48,7 +48,7 @@
CoreBuiltinCall::~CoreBuiltinCall() = default;
CoreBuiltinCall* CoreBuiltinCall::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto args = ctx.Remap<CoreBuiltinCall::kDefaultNumOperands>(Args());
return ctx.ir.instructions.Create<CoreBuiltinCall>(new_result, func_, args);
}
diff --git a/src/tint/lang/core/ir/instruction.h b/src/tint/lang/core/ir/instruction.h
index 6b54620..886df26 100644
--- a/src/tint/lang/core/ir/instruction.h
+++ b/src/tint/lang/core/ir/instruction.h
@@ -118,7 +118,7 @@
/// @param idx the index of the operand
/// @returns the operand with index @p idx, or `nullptr` if there are no operands or the index
/// is out of bounds.
- const Value* Operand(size_t idx = 0) const {
+ const Value* Operand(size_t idx) const {
auto res = Operands();
return idx < res.Length() ? res[idx] : nullptr;
}
@@ -134,7 +134,7 @@
/// @param idx the index of the result
/// @returns the result with index @p idx, or `nullptr` if there are no results or the index is
/// out of bounds.
- const InstructionResult* Result(size_t idx = 0) const {
+ const InstructionResult* Result(size_t idx) const {
auto res = Results();
return idx < res.Length() ? res[idx] : nullptr;
}
diff --git a/src/tint/lang/core/ir/let.cc b/src/tint/lang/core/ir/let.cc
index e6b2ea3..ddbf9a3 100644
--- a/src/tint/lang/core/ir/let.cc
+++ b/src/tint/lang/core/ir/let.cc
@@ -43,7 +43,7 @@
Let::~Let() = default;
Let* Let::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* val = ctx.Remap(Value());
auto* new_let = ctx.ir.instructions.Create<Let>(new_result, val);
diff --git a/src/tint/lang/core/ir/load.cc b/src/tint/lang/core/ir/load.cc
index 2d63594..ba9f6d3 100644
--- a/src/tint/lang/core/ir/load.cc
+++ b/src/tint/lang/core/ir/load.cc
@@ -49,7 +49,7 @@
Load::~Load() = default;
Load* Load::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* from = ctx.Remap(From());
return ctx.ir.instructions.Create<Load>(new_result, from);
}
diff --git a/src/tint/lang/core/ir/load_vector_element.cc b/src/tint/lang/core/ir/load_vector_element.cc
index 525043b..4db0a53 100644
--- a/src/tint/lang/core/ir/load_vector_element.cc
+++ b/src/tint/lang/core/ir/load_vector_element.cc
@@ -45,7 +45,7 @@
LoadVectorElement::~LoadVectorElement() = default;
LoadVectorElement* LoadVectorElement::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* from = ctx.Remap(From());
auto* index = ctx.Remap(Index());
return ctx.ir.instructions.Create<LoadVectorElement>(new_result, from, index);
diff --git a/src/tint/lang/core/ir/operand_instruction.h b/src/tint/lang/core/ir/operand_instruction.h
index a31a991..2b3f83a 100644
--- a/src/tint/lang/core/ir/operand_instruction.h
+++ b/src/tint/lang/core/ir/operand_instruction.h
@@ -106,14 +106,14 @@
/// @param idx the index of the result
/// @returns the result with index @p idx, or `nullptr` if there are no results or the index is
/// out of bounds.
- InstructionResult* Result(size_t idx = 0) {
+ InstructionResult* Result(size_t idx) {
return idx < results_.Length() ? results_[idx] : nullptr;
}
/// @param idx the index of the result
/// @returns the result with index @p idx, or `nullptr` if there are no results or the index is
/// out of bounds.
- const InstructionResult* Result(size_t idx = 0) const {
+ const InstructionResult* Result(size_t idx) const {
return idx < results_.Length() ? results_[idx] : nullptr;
}
diff --git a/src/tint/lang/core/ir/swizzle.cc b/src/tint/lang/core/ir/swizzle.cc
index 2c10907..1a1e6dc 100644
--- a/src/tint/lang/core/ir/swizzle.cc
+++ b/src/tint/lang/core/ir/swizzle.cc
@@ -53,7 +53,7 @@
Swizzle::~Swizzle() = default;
Swizzle* Swizzle::Clone(CloneContext& ctx) {
- auto* result = ctx.Clone(Result());
+ auto* result = ctx.Clone(Result(0));
auto* obj = ctx.Remap(Object());
return ctx.ir.instructions.Create<Swizzle>(result, obj, indices_);
}
diff --git a/src/tint/lang/core/ir/unary.cc b/src/tint/lang/core/ir/unary.cc
index 2b81d7b..b79a23c 100644
--- a/src/tint/lang/core/ir/unary.cc
+++ b/src/tint/lang/core/ir/unary.cc
@@ -42,7 +42,7 @@
Unary::~Unary() = default;
Unary* Unary::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* val = ctx.Remap(Val());
return ctx.ir.instructions.Create<Unary>(new_result, op_, val);
}
diff --git a/src/tint/lang/core/ir/user_call.cc b/src/tint/lang/core/ir/user_call.cc
index 0407fa9..698cb62 100644
--- a/src/tint/lang/core/ir/user_call.cc
+++ b/src/tint/lang/core/ir/user_call.cc
@@ -46,7 +46,7 @@
UserCall::~UserCall() = default;
UserCall* UserCall::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* target = ctx.Remap(Target());
auto args = ctx.Remap<UserCall::kDefaultNumOperands>(Args());
return ctx.ir.instructions.Create<UserCall>(new_result, target, args);
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index f31c237..a3a83df 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -538,7 +538,7 @@
}
void Validator::CheckVar(const Var* var) {
- if (var->Result() && var->Initializer()) {
+ if (var->Result(0) && var->Initializer()) {
if (var->Initializer()->Type() != var->Result(0)->Type()->UnwrapPtr()) {
AddError(var, InstError(var, "initializer has incorrect type"));
}
diff --git a/src/tint/lang/core/ir/var.cc b/src/tint/lang/core/ir/var.cc
index 9c8cb74..b9a8f91 100644
--- a/src/tint/lang/core/ir/var.cc
+++ b/src/tint/lang/core/ir/var.cc
@@ -50,7 +50,7 @@
Var::~Var() = default;
Var* Var::Clone(CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto* new_var = ctx.ir.instructions.Create<Var>(new_result);
new_var->binding_point_ = binding_point_;
@@ -68,7 +68,7 @@
}
void Var::DestroyIfOnlyAssigned() {
- auto* result = Result();
+ auto* result = Result(0);
if (result->Usages().All([](const Usage& u) { return u.instruction->Is<ir::Store>(); })) {
while (!result->Usages().IsEmpty()) {
auto& usage = *result->Usages().begin();
diff --git a/src/tint/lang/msl/writer/printer/printer.cc b/src/tint/lang/msl/writer/printer/printer.cc
index 1c2f33f..f982e92 100644
--- a/src/tint/lang/msl/writer/printer/printer.cc
+++ b/src/tint/lang/msl/writer/printer/printer.cc
@@ -347,18 +347,18 @@
[&](core::ir::Construct*) { MaybeEmitInstruction(inst); }, //
[&](core::ir::Access*) { MaybeEmitInstruction(inst); }, //
[&](core::ir::CoreBuiltinCall* c) {
- if (c->Result()->Type()->Is<core::type::Void>()) {
+ if (c->Result(0)->Type()->Is<core::type::Void>()) {
auto out = Line();
- EmitValue(out, c->Result());
+ EmitValue(out, c->Result(0));
out << ";";
} else {
MaybeEmitInstruction(inst);
}
}, //
[&](core::ir::UserCall* c) { //
- if (c->Result()->Type()->Is<core::type::Void>()) {
+ if (c->Result(0)->Type()->Is<core::type::Void>()) {
auto out = Line();
- EmitValue(out, c->Result());
+ EmitValue(out, c->Result(0));
out << ";";
} else {
MaybeEmitInstruction(inst);
@@ -371,15 +371,15 @@
// If the instruction is named, we need to emit it. If it is un-named, then we'll use it
// and inline it later.
void MaybeEmitInstruction(const core::ir::Instruction* inst) {
- auto name = ir_.NameOf(inst->Result());
+ auto name = ir_.NameOf(inst->Result(0));
if (!name.IsValid()) {
return;
}
auto out = Line();
- EmitType(out, inst->Result()->Type());
+ EmitType(out, inst->Result(0)->Type());
out << " const " << name.Name() << " = ";
- EmitValue(out, inst->Result());
+ EmitValue(out, inst->Result(0));
out << ";";
}
@@ -394,7 +394,7 @@
[&](const core::ir::Unary* u) { EmitUnary(out, u); }, //
[&](const core::ir::Binary* b) { EmitBinary(out, b); }, //
[&](const core::ir::Let* l) {
- auto name = ir_.NameOf(l->Result());
+ auto name = ir_.NameOf(l->Result(0));
TINT_ASSERT(name.IsValid());
out << name.Name();
}, //
@@ -496,7 +496,7 @@
void EmitVar(core::ir::Var* v) {
auto out = Line();
- auto* ptr = v->Result()->Type()->As<core::type::Pointer>();
+ auto* ptr = v->Result(0)->Type()->As<core::type::Pointer>();
TINT_ASSERT_OR_RETURN(ptr);
auto space = ptr->AddressSpace();
@@ -535,11 +535,11 @@
/// Emit a let instruction
/// @param l the let instruction
void EmitLet(core::ir::Let* l) {
- auto name = ir_.NameOf(l->Result());
+ auto name = ir_.NameOf(l->Result(0));
TINT_ASSERT(name.IsValid());
auto out = Line();
- EmitType(out, l->Result()->Type());
+ EmitType(out, l->Result(0)->Type());
out << " const " << name.Name() << " = ";
EmitValue(out, l->Value());
out << ";";
@@ -742,7 +742,7 @@
/// Emit a bitcast instruction
void EmitBitcast(StringStream& out, const core::ir::Bitcast* b) {
out << "as_type<";
- EmitType(out, b->Result()->Type());
+ EmitType(out, b->Result(0)->Type());
out << ">(";
EmitValue(out, b->Val());
out << ")";
@@ -930,9 +930,9 @@
/// Emit a constructor
void EmitConstruct(StringStream& out, const core::ir::Construct* c) {
Switch(
- c->Result()->Type(),
+ c->Result(0)->Type(),
[&](const core::type::Array*) {
- EmitType(out, c->Result()->Type());
+ EmitType(out, c->Result(0)->Type());
out << "{";
size_t i = 0;
for (auto* arg : c->Args()) {
@@ -960,7 +960,7 @@
out << "}";
},
[&](Default) {
- EmitType(out, c->Result()->Type());
+ EmitType(out, c->Result(0)->Type());
out << "(";
size_t i = 0;
for (auto* arg : c->Args()) {
diff --git a/src/tint/lang/msl/writer/printer/var_test.cc b/src/tint/lang/msl/writer/printer/var_test.cc
index ab15f44..04f9358 100644
--- a/src/tint/lang/msl/writer/printer/var_test.cc
+++ b/src/tint/lang/msl/writer/printer/var_test.cc
@@ -254,9 +254,9 @@
auto* func = b.Function("foo", ty.void_());
b.Append(func->Block(), [&] {
- auto* ld = b.Load(v->Result());
+ auto* ld = b.Load(v->Result(0));
auto* a = b.Var("a", ty.ptr<core::AddressSpace::kFunction, f32>());
- a->SetInitializer(ld->Result());
+ a->SetInitializer(ld->Result(0));
b.Return(func);
});
@@ -281,9 +281,9 @@
auto* func = b.Function("foo", ty.void_());
b.Append(func->Block(), [&] {
- auto* ld = b.Load(v->Result());
+ auto* ld = b.Load(v->Result(0));
auto* a = b.Var("a", ty.ptr<core::AddressSpace::kFunction, f32>());
- a->SetInitializer(ld->Result());
+ a->SetInitializer(ld->Result(0));
b.Return(func);
});
diff --git a/src/tint/lang/spirv/ir/builtin_call.cc b/src/tint/lang/spirv/ir/builtin_call.cc
index dd01293..5503e55 100644
--- a/src/tint/lang/spirv/ir/builtin_call.cc
+++ b/src/tint/lang/spirv/ir/builtin_call.cc
@@ -48,7 +48,7 @@
BuiltinCall::~BuiltinCall() = default;
BuiltinCall* BuiltinCall::Clone(core::ir::CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto new_args = ctx.Clone<BuiltinCall::kDefaultNumOperands>(Args());
return ctx.ir.instructions.Create<BuiltinCall>(new_result, func_, new_args);
}
diff --git a/src/tint/lang/spirv/ir/builtin_call_test.cc b/src/tint/lang/spirv/ir/builtin_call_test.cc
index a48c8fb..4256f26 100644
--- a/src/tint/lang/spirv/ir/builtin_call_test.cc
+++ b/src/tint/lang/spirv/ir/builtin_call_test.cc
@@ -43,8 +43,8 @@
auto* new_b = clone_ctx.Clone(builtin);
EXPECT_NE(builtin, new_b);
- EXPECT_NE(builtin->Result(), new_b->Result());
- EXPECT_EQ(mod.Types().f32(), new_b->Result()->Type());
+ EXPECT_NE(builtin->Result(0), new_b->Result(0));
+ EXPECT_EQ(mod.Types().f32(), new_b->Result(0)->Type());
EXPECT_EQ(BuiltinFn::kArrayLength, new_b->Func());
@@ -62,8 +62,8 @@
auto* builtin = b.Call<BuiltinCall>(mod.Types().f32(), BuiltinFn::kArrayLength);
auto* new_b = clone_ctx.Clone(builtin);
- EXPECT_NE(builtin->Result(), new_b->Result());
- EXPECT_EQ(mod.Types().f32(), new_b->Result()->Type());
+ EXPECT_NE(builtin->Result(0), new_b->Result(0));
+ EXPECT_EQ(mod.Types().f32(), new_b->Result(0)->Type());
EXPECT_EQ(BuiltinFn::kArrayLength, new_b->Func());
diff --git a/src/tint/lang/spirv/writer/helpers/generate_bindings.cc b/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
index 2a9bba2..1cf3b6a 100644
--- a/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
+++ b/src/tint/lang/spirv/writer/helpers/generate_bindings.cc
@@ -62,7 +62,7 @@
group_to_next_binding_number.Add(bp->group, bp->binding + 1);
}
- auto* ptr = var->Result()->Type()->As<core::type::Pointer>();
+ auto* ptr = var->Result(0)->Type()->As<core::type::Pointer>();
auto* ty = ptr->UnwrapPtr();
// Store up the external textures, we'll add them in the next step
diff --git a/src/tint/lang/spirv/writer/if_test.cc b/src/tint/lang/spirv/writer/if_test.cc
index 5dd00ed..321ed89 100644
--- a/src/tint/lang/spirv/writer/if_test.cc
+++ b/src/tint/lang/spirv/writer/if_test.cc
@@ -343,7 +343,7 @@
b.Append(inner->False(), [&] { //
b.ExitIf(inner, 20_i);
});
- b.ExitIf(outer, inner->Result());
+ b.ExitIf(outer, inner->Result(0));
});
b.Append(outer->False(), [&] { //
b.ExitIf(outer, 30_i);
diff --git a/src/tint/lang/spirv/writer/loop_test.cc b/src/tint/lang/spirv/writer/loop_test.cc
index c262b2c..633eb9b 100644
--- a/src/tint/lang/spirv/writer/loop_test.cc
+++ b/src/tint/lang/spirv/writer/loop_test.cc
@@ -460,7 +460,7 @@
b.Append(inner->False(), [&] { //
b.ExitIf(inner, 20_i);
});
- b.Continue(loop, inner->Result());
+ b.Continue(loop, inner->Result(0));
});
auto* cont_param = b.BlockParam(ty.i32());
diff --git a/src/tint/lang/spirv/writer/printer/printer.cc b/src/tint/lang/spirv/writer/printer/printer.cc
index f88b02d..add607e 100644
--- a/src/tint/lang/spirv/writer/printer/printer.cc
+++ b/src/tint/lang/spirv/writer/printer/printer.cc
@@ -781,7 +781,7 @@
continue;
}
- auto* ptr = var->Result()->Type()->As<core::type::Pointer>();
+ auto* ptr = var->Result(0)->Type()->As<core::type::Pointer>();
if (!(ptr->AddressSpace() == core::AddressSpace::kIn ||
ptr->AddressSpace() == core::AddressSpace::kOut)) {
continue;
@@ -789,7 +789,7 @@
// Determine if this IO variable is used by the entry point.
bool used = false;
- for (const auto& use : var->Result()->Usages()) {
+ for (const auto& use : var->Result(0)->Usages()) {
auto* block = use.instruction->Block();
while (block->Parent()) {
block = block->Parent()->Block();
@@ -1010,7 +1010,7 @@
/// Emit an access instruction
/// @param access the access instruction to emit
void EmitAccess(core::ir::Access* access) {
- auto* ty = access->Result()->Type();
+ auto* ty = access->Result(0)->Type();
auto id = Value(access);
OperandList operands = {Type(ty), id, Value(access->Object())};
@@ -1064,7 +1064,7 @@
auto id = Value(binary);
auto lhs = Value(binary->LHS());
auto rhs = Value(binary->RHS());
- auto* ty = binary->Result()->Type();
+ auto* ty = binary->Result(0)->Type();
auto* lhs_ty = binary->LHS()->Type();
// Determine the opcode.
@@ -1210,9 +1210,9 @@
/// Emit a bitcast instruction.
/// @param bitcast the bitcast instruction to emit
void EmitBitcast(core::ir::Bitcast* bitcast) {
- auto* ty = bitcast->Result()->Type();
+ auto* ty = bitcast->Result(0)->Type();
if (ty == bitcast->Val()->Type()) {
- values_.Add(bitcast->Result(), Value(bitcast->Val()));
+ values_.Add(bitcast->Result(0), Value(bitcast->Val()));
return;
}
current_function_.push_inst(spv::Op::OpBitcast,
@@ -1345,8 +1345,8 @@
}
OperandList operands;
- if (!builtin->Result()->Type()->Is<core::type::Void>()) {
- operands = {Type(builtin->Result()->Type()), id};
+ if (!builtin->Result(0)->Type()->Is<core::type::Void>()) {
+ operands = {Type(builtin->Result(0)->Type()), id};
}
for (auto* arg : builtin->Args()) {
operands.push_back(Value(arg));
@@ -1357,19 +1357,19 @@
/// Emit a builtin function call instruction.
/// @param builtin the builtin call instruction to emit
void EmitCoreBuiltinCall(core::ir::CoreBuiltinCall* builtin) {
- auto* result_ty = builtin->Result()->Type();
+ auto* result_ty = builtin->Result(0)->Type();
if (builtin->Func() == core::BuiltinFn::kAbs &&
result_ty->is_unsigned_integer_scalar_or_vector()) {
// abs() is a no-op for unsigned integers.
- values_.Add(builtin->Result(), Value(builtin->Args()[0]));
+ values_.Add(builtin->Result(0), Value(builtin->Args()[0]));
return;
}
if ((builtin->Func() == core::BuiltinFn::kAll ||
builtin->Func() == core::BuiltinFn::kAny) &&
builtin->Args()[0]->Type()->Is<core::type::Bool>()) {
// all() and any() are passthroughs for scalar arguments.
- values_.Add(builtin->Result(), Value(builtin->Args()[0]));
+ values_.Add(builtin->Result(0), Value(builtin->Args()[0]));
return;
}
@@ -1714,12 +1714,12 @@
// If there is just a single argument with the same type as the result, this is an identity
// constructor and we can just pass through the ID of the argument.
if (construct->Args().Length() == 1 &&
- construct->Result()->Type() == construct->Args()[0]->Type()) {
- values_.Add(construct->Result(), Value(construct->Args()[0]));
+ construct->Result(0)->Type() == construct->Args()[0]->Type()) {
+ values_.Add(construct->Result(0), Value(construct->Args()[0]));
return;
}
- OperandList operands = {Type(construct->Result()->Type()), Value(construct)};
+ OperandList operands = {Type(construct->Result(0)->Type()), Value(construct)};
for (auto* arg : construct->Args()) {
operands.push_back(Value(arg));
}
@@ -1729,10 +1729,10 @@
/// Emit a convert instruction.
/// @param convert the convert instruction to emit
void EmitConvert(core::ir::Convert* convert) {
- auto* res_ty = convert->Result()->Type();
+ auto* res_ty = convert->Result(0)->Type();
auto* arg_ty = convert->Args()[0]->Type();
- OperandList operands = {Type(convert->Result()->Type()), Value(convert)};
+ OperandList operands = {Type(convert->Result(0)->Type()), Value(convert)};
for (auto* arg : convert->Args()) {
operands.push_back(Value(arg));
}
@@ -1814,21 +1814,21 @@
/// @param load the load instruction to emit
void EmitLoad(core::ir::Load* load) {
current_function_.push_inst(
- spv::Op::OpLoad, {Type(load->Result()->Type()), Value(load), Value(load->From())});
+ spv::Op::OpLoad, {Type(load->Result(0)->Type()), Value(load), Value(load->From())});
}
/// Emit a load vector element instruction.
/// @param load the load vector element instruction to emit
void EmitLoadVectorElement(core::ir::LoadVectorElement* load) {
auto* vec_ptr_ty = load->From()->Type()->As<core::type::Pointer>();
- auto* el_ty = load->Result()->Type();
+ auto* el_ty = load->Result(0)->Type();
auto* el_ptr_ty = ir_.Types().ptr(vec_ptr_ty->AddressSpace(), el_ty, vec_ptr_ty->Access());
auto el_ptr_id = module_.NextId();
current_function_.push_inst(
spv::Op::OpAccessChain,
{Type(el_ptr_ty), el_ptr_id, Value(load->From()), Value(load->Index())});
current_function_.push_inst(spv::Op::OpLoad,
- {Type(load->Result()->Type()), Value(load), el_ptr_id});
+ {Type(load->Result(0)->Type()), Value(load), el_ptr_id});
}
/// Emit a loop instruction.
@@ -1933,7 +1933,7 @@
void EmitSwizzle(core::ir::Swizzle* swizzle) {
auto id = Value(swizzle);
auto obj = Value(swizzle->Object());
- OperandList operands = {Type(swizzle->Result()->Type()), id, obj, obj};
+ OperandList operands = {Type(swizzle->Result(0)->Type()), id, obj, obj};
for (auto idx : swizzle->Indices()) {
operands.push_back(idx);
}
@@ -1963,7 +1963,7 @@
/// @param unary the unary instruction to emit
void EmitUnary(core::ir::Unary* unary) {
auto id = Value(unary);
- auto* ty = unary->Result()->Type();
+ auto* ty = unary->Result(0)->Type();
spv::Op op = spv::Op::Max;
switch (unary->Op()) {
case core::ir::UnaryOp::kComplement:
@@ -1984,7 +1984,7 @@
/// @param call the user call instruction to emit
void EmitUserCall(core::ir::UserCall* call) {
auto id = Value(call);
- OperandList operands = {Type(call->Result()->Type()), id, Value(call->Target())};
+ OperandList operands = {Type(call->Result(0)->Type()), id, Value(call->Target())};
for (auto* arg : call->Args()) {
operands.push_back(Value(arg));
}
@@ -2045,7 +2045,7 @@
/// @param var the var instruction to emit
void EmitVar(core::ir::Var* var) {
auto id = Value(var);
- auto* ptr = var->Result()->Type()->As<core::type::Pointer>();
+ auto* ptr = var->Result(0)->Type()->As<core::type::Pointer>();
auto* store_ty = ptr->StoreType();
auto ty = Type(ptr);
@@ -2143,7 +2143,7 @@
/// @param let the let instruction to emit
void EmitLet(core::ir::Let* let) {
auto id = Value(let->Value());
- values_.Add(let->Result(), id);
+ values_.Add(let->Result(0), id);
}
/// Emit the OpPhis for the given flow control instruction.
diff --git a/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc b/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
index 7d7bd6c..923a526 100644
--- a/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
+++ b/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
@@ -105,7 +105,7 @@
worklist.Push(builtin);
break;
case core::BuiltinFn::kQuantizeToF16:
- if (builtin->Result()->Type()->Is<core::type::Vector>()) {
+ if (builtin->Result(0)->Type()->Is<core::type::Vector>()) {
worklist.Push(builtin);
}
break;
@@ -178,10 +178,10 @@
TINT_ASSERT_OR_RETURN(replacement);
// Replace the old builtin result with the new value.
- if (auto name = ir.NameOf(builtin->Result())) {
+ if (auto name = ir.NameOf(builtin->Result(0))) {
ir.SetName(replacement, name);
}
- builtin->Result()->ReplaceAllUsesWith(replacement);
+ builtin->Result(0)->ReplaceAllUsesWith(replacement);
builtin->Destroy();
}
}
@@ -213,17 +213,17 @@
// Replace the builtin call with a call to the spirv.array_length intrinsic.
auto* call = b.Call<spirv::ir::BuiltinCall>(
- builtin->Result()->Type(), spirv::BuiltinFn::kArrayLength,
+ builtin->Result(0)->Type(), spirv::BuiltinFn::kArrayLength,
Vector{access->Object(), Literal(u32(const_idx->Value()->ValueAs<uint32_t>()))});
call->InsertBefore(builtin);
- return call->Result();
+ return call->Result(0);
}
/// Handle an atomic*() builtin.
/// @param builtin the builtin call instruction
/// @returns the replacement value
core::ir::Value* Atomic(core::ir::CoreBuiltinCall* builtin) {
- auto* result_ty = builtin->Result()->Type();
+ auto* result_ty = builtin->Result(0)->Type();
auto* pointer = builtin->Args()[0];
auto* memory = [&]() -> core::ir::Value* {
@@ -267,14 +267,14 @@
call->InsertBefore(builtin);
// Compare the original value to the comparator to see if an exchange happened.
- auto* original = call->Result();
+ auto* original = call->Result(0);
auto* compare = b.Equal(ty.bool_(), original, cmp);
compare->InsertBefore(builtin);
// Construct the atomicCompareExchange result structure.
call = b.Construct(
core::type::CreateAtomicCompareExchangeResult(ty, ir.symbols, int_ty),
- Vector{original, compare->Result()});
+ Vector{original, compare->Result(0)});
break;
}
case core::BuiltinFn::kAtomicExchange:
@@ -321,7 +321,7 @@
}
call->InsertBefore(builtin);
- return call->Result();
+ return call->Result(0);
}
/// Handle a `dot()` builtin.
@@ -330,7 +330,7 @@
core::ir::Value* Dot(core::ir::CoreBuiltinCall* builtin) {
// OpDot only supports floating point operands, so we need to polyfill the integer case.
// TODO(crbug.com/tint/1267): If SPV_KHR_integer_dot_product is supported, use that instead.
- if (builtin->Result()->Type()->is_integer_scalar()) {
+ if (builtin->Result(0)->Type()->is_integer_scalar()) {
core::ir::Instruction* sum = nullptr;
auto* v1 = builtin->Args()[0];
@@ -354,10 +354,10 @@
// Replace the builtin call with a call to the spirv.dot intrinsic.
auto args = Vector<core::ir::Value*, 4>(builtin->Args());
- auto* call = b.Call<spirv::ir::BuiltinCall>(builtin->Result()->Type(),
+ auto* call = b.Call<spirv::ir::BuiltinCall>(builtin->Result(0)->Type(),
spirv::BuiltinFn::kDot, std::move(args));
call->InsertBefore(builtin);
- return call->Result();
+ return call->Result(0);
}
/// Handle a `dot4{I,U}8Packed()` builtin.
@@ -365,7 +365,7 @@
/// @returns the replacement value
core::ir::Value* DotPacked4x8(core::ir::CoreBuiltinCall* builtin) {
// Replace the builtin call with a call to the spirv.{s,u}dot intrinsic.
- auto* type = builtin->Result()->Type();
+ auto* type = builtin->Result(0)->Type();
auto is_signed = builtin->Func() == core::BuiltinFn::kDot4I8Packed;
auto inst = is_signed ? spirv::BuiltinFn::kSdot : spirv::BuiltinFn::kUdot;
@@ -374,7 +374,7 @@
auto* call = b.Call<spirv::ir::BuiltinCall>(type, inst, std::move(args));
call->InsertBefore(builtin);
- return call->Result();
+ return call->Result(0);
}
/// Handle a `select()` builtin.
@@ -391,21 +391,21 @@
// If the condition is scalar and the objects are vectors, we need to splat the condition
// into a vector of the same size.
// TODO(jrprice): We don't need to do this if we're targeting SPIR-V 1.4 or newer.
- auto* vec = builtin->Result()->Type()->As<core::type::Vector>();
+ auto* vec = builtin->Result(0)->Type()->As<core::type::Vector>();
if (vec && args[0]->Type()->Is<core::type::Scalar>()) {
Vector<core::ir::Value*, 4> elements;
elements.Resize(vec->Width(), args[0]);
auto* construct = b.Construct(ty.vec(ty.bool_(), vec->Width()), std::move(elements));
construct->InsertBefore(builtin);
- args[0] = construct->Result();
+ args[0] = construct->Result(0);
}
// Replace the builtin call with a call to the spirv.select intrinsic.
- auto* call = b.Call<spirv::ir::BuiltinCall>(builtin->Result()->Type(),
+ auto* call = b.Call<spirv::ir::BuiltinCall>(builtin->Result(0)->Type(),
spirv::BuiltinFn::kSelect, std::move(args));
call->InsertBefore(builtin);
- return call->Result();
+ return call->Result(0);
}
/// ImageOperands represents the optional image operands for an image instruction.
@@ -449,7 +449,7 @@
if (requires_float_lod && operands.lod->Type()->is_integer_scalar()) {
auto* convert = b.Convert(ty.f32(), operands.lod);
convert->InsertBefore(insertion_point);
- operands.lod = convert->Result();
+ operands.lod = convert->Result(0);
}
args.Push(operands.lod);
}
@@ -486,7 +486,7 @@
if (array_idx->Type() != element_ty) {
auto* array_idx_converted = b.Convert(element_ty, array_idx);
array_idx_converted->InsertBefore(insertion_point);
- array_idx = array_idx_converted->Result();
+ array_idx = array_idx_converted->Result(0);
}
// Construct a new coordinate vector.
@@ -494,7 +494,7 @@
auto* coord_ty = ty.vec(element_ty, num_coords + 1);
auto* construct = b.Construct(coord_ty, Vector{coords, array_idx});
construct->InsertBefore(insertion_point);
- return construct->Result();
+ return construct->Result(0);
}
/// Handle a textureSample*() builtin.
@@ -568,7 +568,7 @@
// The first two operands are always the sampled image and then the coordinates, followed by
// the depth reference if used.
Vector<core::ir::Value*, 8> function_args;
- function_args.Push(sampled_image->Result());
+ function_args.Push(sampled_image->Result(0));
function_args.Push(coords);
if (depth) {
function_args.Push(depth);
@@ -584,7 +584,7 @@
b.Call<spirv::ir::BuiltinCall>(result_ty, function, std::move(function_args));
texture_call->InsertBefore(builtin);
- auto* result = texture_call->Result();
+ auto* result = texture_call->Result(0);
// If this is not a depth comparison but we are sampling a depth texture, extract the first
// component to get the scalar f32 that SPIR-V expects.
@@ -592,7 +592,7 @@
texture_ty->IsAnyOf<core::type::DepthTexture, core::type::DepthMultisampledTexture>()) {
auto* extract = b.Access(ty.f32(), result, 0_u);
extract->InsertBefore(builtin);
- result = extract->Result();
+ result = extract->Result(0);
}
return result;
@@ -654,7 +654,7 @@
// The first two operands are always the sampled image and then the coordinates, followed by
// either the depth reference or the component.
Vector<core::ir::Value*, 8> function_args;
- function_args.Push(sampled_image->Result());
+ function_args.Push(sampled_image->Result(0));
function_args.Push(coords);
if (depth) {
function_args.Push(depth);
@@ -666,11 +666,11 @@
AppendImageOperands(operands, function_args, builtin, /* requires_float_lod */ true);
// Call the function.
- auto* result_ty = builtin->Result()->Type();
+ auto* result_ty = builtin->Result(0)->Type();
auto* texture_call =
b.Call<spirv::ir::BuiltinCall>(result_ty, function, std::move(function_args));
texture_call->InsertBefore(builtin);
- return texture_call->Result();
+ return texture_call->Result(0);
}
/// Handle a textureLoad() builtin.
@@ -711,7 +711,7 @@
// Call the builtin.
// The result is always a vec4 in SPIR-V.
- auto* result_ty = builtin->Result()->Type();
+ auto* result_ty = builtin->Result(0)->Type();
bool expects_scalar_result = result_ty->Is<core::type::Scalar>();
if (expects_scalar_result) {
result_ty = ty.vec4(result_ty);
@@ -721,13 +721,13 @@
auto* texture_call =
b.Call<spirv::ir::BuiltinCall>(result_ty, kind, std::move(builtin_args));
texture_call->InsertBefore(builtin);
- auto* result = texture_call->Result();
+ auto* result = texture_call->Result(0);
// If we are expecting a scalar result, extract the first component.
if (expects_scalar_result) {
auto* extract = b.Access(ty.f32(), result, 0_u);
extract->InsertBefore(builtin);
- result = extract->Result();
+ result = extract->Result(0);
}
return result;
@@ -769,7 +769,7 @@
auto* texture_call = b.Call<spirv::ir::BuiltinCall>(
ty.void_(), spirv::BuiltinFn::kImageWrite, std::move(function_args));
texture_call->InsertBefore(builtin);
- return texture_call->Result();
+ return texture_call->Result(0);
}
/// Handle a textureDimensions() builtin.
@@ -805,7 +805,7 @@
}
// Add an extra component to the result vector for arrayed textures.
- auto* result_ty = builtin->Result()->Type();
+ auto* result_ty = builtin->Result(0)->Type();
if (core::type::IsTextureArray(texture_ty->dim())) {
auto* vec = result_ty->As<core::type::Vector>();
result_ty = ty.vec(vec->type(), vec->Width() + 1);
@@ -816,13 +816,13 @@
b.Call<spirv::ir::BuiltinCall>(result_ty, function, std::move(function_args));
texture_call->InsertBefore(builtin);
- auto* result = texture_call->Result();
+ auto* result = texture_call->Result(0);
// Swizzle the first two components from the result for arrayed textures.
if (core::type::IsTextureArray(texture_ty->dim())) {
- auto* swizzle = b.Swizzle(builtin->Result()->Type(), result, {0, 1});
+ auto* swizzle = b.Swizzle(builtin->Result(0)->Type(), result, {0, 1});
swizzle->InsertBefore(builtin);
- result = swizzle->Result();
+ result = swizzle->Result(0);
}
return result;
@@ -855,9 +855,9 @@
texture_call->InsertBefore(builtin);
// Extract the third component to get the number of array layers.
- auto* extract = b.Access(ty.u32(), texture_call->Result(), 2_u);
+ auto* extract = b.Access(ty.u32(), texture_call->Result(0), 2_u);
extract->InsertBefore(builtin);
- return extract->Result();
+ return extract->Result(0);
}
/// Scalarize the vector form of a `quantizeToF16()` builtin.
@@ -874,13 +874,13 @@
for (uint32_t i = 0; i < vec->Width(); i++) {
auto* el = b.Access(ty.f32(), arg, u32(i));
auto* scalar_call = b.Call(ty.f32(), core::BuiltinFn::kQuantizeToF16, el);
- args.Push(scalar_call->Result());
+ args.Push(scalar_call->Result(0));
el->InsertBefore(builtin);
scalar_call->InsertBefore(builtin);
}
auto* construct = b.Construct(vec, std::move(args));
construct->InsertBefore(builtin);
- return construct->Result();
+ return construct->Result(0);
}
};
diff --git a/src/tint/lang/spirv/writer/raise/merge_return.cc b/src/tint/lang/spirv/writer/raise/merge_return.cc
index fa41206..cab47ce 100644
--- a/src/tint/lang/spirv/writer/raise/merge_return.cc
+++ b/src/tint/lang/spirv/writer/raise/merge_return.cc
@@ -244,7 +244,7 @@
// Change the function return to unconditionally load 'return_val' and return it
auto* load = b.Load(return_val);
load->InsertBefore(ret);
- ret->SetValue(load->Result());
+ ret->SetValue(load->Result(0));
}
/// Transforms the return instruction that is found in a control instruction.
diff --git a/src/tint/lang/spirv/writer/raise/pass_matrix_by_pointer.cc b/src/tint/lang/spirv/writer/raise/pass_matrix_by_pointer.cc
index 458c9aa..2fe2e74 100644
--- a/src/tint/lang/spirv/writer/raise/pass_matrix_by_pointer.cc
+++ b/src/tint/lang/spirv/writer/raise/pass_matrix_by_pointer.cc
@@ -95,7 +95,7 @@
// Load from the pointer to get the value.
auto* load = b.Load(new_param);
func->Block()->Prepend(load);
- param->ReplaceAllUsesWith(load->Result());
+ param->ReplaceAllUsesWith(load->Result(0));
// Modify all of the callsites.
func->ForEachUse([&](core::ir::Usage use) {
@@ -121,7 +121,7 @@
local_var->SetInitializer(arg);
local_var->InsertBefore(call);
- call->SetOperand(core::ir::UserCall::kArgsOperandOffset + arg_index, local_var->Result());
+ call->SetOperand(core::ir::UserCall::kArgsOperandOffset + arg_index, local_var->Result(0));
}
};
diff --git a/src/tint/lang/spirv/writer/raise/shader_io.cc b/src/tint/lang/spirv/writer/raise/shader_io.cc
index c44fdee..5ec25d1 100644
--- a/src/tint/lang/spirv/writer/raise/shader_io.cc
+++ b/src/tint/lang/spirv/writer/raise/shader_io.cc
@@ -143,25 +143,25 @@
core::ir::Value* GetInput(core::ir::Builder& builder, uint32_t idx) override {
// Load the input from the global variable declared earlier.
auto* ptr = ty.ptr(core::AddressSpace::kIn, inputs[idx].type, core::Access::kRead);
- auto* from = input_vars[idx]->Result();
+ auto* from = input_vars[idx]->Result(0);
if (inputs[idx].attributes.builtin) {
if (inputs[idx].attributes.builtin.value() == core::BuiltinValue::kSampleMask) {
// SampleMask becomes an array for SPIR-V, so load from the first element.
- from = builder.Access(ptr, input_vars[idx], 0_u)->Result();
+ from = builder.Access(ptr, input_vars[idx], 0_u)->Result(0);
}
}
- return builder.Load(from)->Result();
+ return builder.Load(from)->Result(0);
}
/// @copydoc ShaderIO::BackendState::SetOutput
void SetOutput(core::ir::Builder& builder, uint32_t idx, core::ir::Value* value) override {
// Store the output to the global variable declared earlier.
auto* ptr = ty.ptr(core::AddressSpace::kOut, outputs[idx].type, core::Access::kWrite);
- auto* to = output_vars[idx]->Result();
+ auto* to = output_vars[idx]->Result(0);
if (outputs[idx].attributes.builtin) {
if (outputs[idx].attributes.builtin.value() == core::BuiltinValue::kSampleMask) {
// SampleMask becomes an array for SPIR-V, so store to the first element.
- to = builder.Access(ptr, to, 0_u)->Result();
+ to = builder.Access(ptr, to, 0_u)->Result(0);
}
// Clamp frag_depth values if necessary.
@@ -186,7 +186,7 @@
// Check that there are no push constants in the module already.
for (auto* inst : *ir.root_block) {
if (auto* var = inst->As<core::ir::Var>()) {
- auto* ptr = var->Result()->Type()->As<core::type::Pointer>();
+ auto* ptr = var->Result(0)->Type()->As<core::type::Pointer>();
if (ptr->AddressSpace() == core::AddressSpace::kPushConstant) {
TINT_ICE() << "cannot clamp frag_depth with pre-existing push constants";
}
@@ -204,7 +204,7 @@
// Declare the variable.
auto* var = b.Var("tint_frag_depth_clamp_args", ty.ptr(push_constant, str));
ir.root_block->Append(var);
- module_state.frag_depth_clamp_args = var->Result();
+ module_state.frag_depth_clamp_args = var->Result(0);
}
// Clamp the value.
@@ -213,7 +213,7 @@
auto* frag_depth_max = builder.Access(ty.f32(), args, 1_u);
return builder
.Call(ty.f32(), core::BuiltinFn::kClamp, frag_depth, frag_depth_min, frag_depth_max)
- ->Result();
+ ->Result(0);
}
/// @copydoc ShaderIO::BackendState::NeedsVertexPointSize
diff --git a/src/tint/lang/spirv/writer/raise/var_for_dynamic_index.cc b/src/tint/lang/spirv/writer/raise/var_for_dynamic_index.cc
index 2597941..855ba42 100644
--- a/src/tint/lang/spirv/writer/raise/var_for_dynamic_index.cc
+++ b/src/tint/lang/spirv/writer/raise/var_for_dynamic_index.cc
@@ -94,7 +94,7 @@
}
std::optional<AccessToReplace> ShouldReplace(core::ir::Access* access) {
- if (access->Result()->Type()->Is<core::type::Pointer>()) {
+ if (access->Result(0)->Type()->Is<core::type::Pointer>()) {
// No need to modify accesses into pointer types.
return {};
}
@@ -153,7 +153,7 @@
auto* intermediate_source = builder.Access(to_replace.dynamic_index_source_type,
source_object, partial_access.indices);
intermediate_source->InsertBefore(access);
- return intermediate_source->Result();
+ return intermediate_source->Result(0);
});
}
@@ -163,13 +163,13 @@
core::AddressSpace::kFunction, source_object->Type(), core::Access::kReadWrite));
decl->SetInitializer(source_object);
decl->InsertBefore(access);
- return decl->Result();
+ return decl->Result(0);
});
// Create a new access instruction using the local variable as the source.
Vector<core::ir::Value*, 4> indices{
access->Indices().Offset(to_replace.first_dynamic_index)};
- const core::type::Type* access_type = access->Result()->Type();
+ const core::type::Type* access_type = access->Result(0)->Type();
core::ir::Value* vector_index = nullptr;
if (to_replace.vector_access_type) {
// The old access indexed the element of a vector.
@@ -195,7 +195,7 @@
}
// Replace all uses of the old access instruction with the loaded result.
- access->Result()->ReplaceAllUsesWith(load->Result(0));
+ access->Result(0)->ReplaceAllUsesWith(load->Result(0));
access->ReplaceWith(load);
access->Destroy();
}
diff --git a/src/tint/lang/spirv/writer/switch_test.cc b/src/tint/lang/spirv/writer/switch_test.cc
index b91069a..957d552 100644
--- a/src/tint/lang/spirv/writer/switch_test.cc
+++ b/src/tint/lang/spirv/writer/switch_test.cc
@@ -391,7 +391,7 @@
b.ExitIf(inner, 20_i);
});
- b.ExitSwitch(s, inner->Result());
+ b.ExitSwitch(s, inner->Result(0));
});
auto* case_b = b.Case(s, Vector{b.Constant(2_i)});
diff --git a/src/tint/lang/wgsl/ir/builtin_call.cc b/src/tint/lang/wgsl/ir/builtin_call.cc
index 45cc898..b841a6d 100644
--- a/src/tint/lang/wgsl/ir/builtin_call.cc
+++ b/src/tint/lang/wgsl/ir/builtin_call.cc
@@ -48,7 +48,7 @@
BuiltinCall::~BuiltinCall() = default;
BuiltinCall* BuiltinCall::Clone(core::ir::CloneContext& ctx) {
- auto* new_result = ctx.Clone(Result());
+ auto* new_result = ctx.Clone(Result(0));
auto new_args = ctx.Clone<BuiltinCall::kDefaultNumOperands>(Args());
return ctx.ir.instructions.Create<BuiltinCall>(new_result, fn_, new_args);
}
diff --git a/src/tint/lang/wgsl/reader/lower/lower.cc b/src/tint/lang/wgsl/reader/lower/lower.cc
index d0df2dd..381fad1 100644
--- a/src/tint/lang/wgsl/reader/lower/lower.cc
+++ b/src/tint/lang/wgsl/reader/lower/lower.cc
@@ -191,7 +191,7 @@
b.InsertBefore(call, [&] {
b.Call(ty.void_(), core::BuiltinFn::kWorkgroupBarrier);
auto* load = b.Load(call->Args()[0]);
- call->Result()->ReplaceAllUsesWith(load->Result());
+ call->Result(0)->ReplaceAllUsesWith(load->Result(0));
b.Call(ty.void_(), core::BuiltinFn::kWorkgroupBarrier);
});
break;
@@ -199,7 +199,7 @@
default: {
Vector<core::ir::Value*, 8> args(call->Args());
auto* replacement = mod.instructions.Create<core::ir::CoreBuiltinCall>(
- call->Result(), Convert(call->Func()), std::move(args));
+ call->Result(0), Convert(call->Func()), std::move(args));
call->ReplaceWith(replacement);
call->ClearResults();
break;
diff --git a/src/tint/lang/wgsl/reader/lower/lower_test.cc b/src/tint/lang/wgsl/reader/lower/lower_test.cc
index 6244192..dd05a5d 100644
--- a/src/tint/lang/wgsl/reader/lower/lower_test.cc
+++ b/src/tint/lang/wgsl/reader/lower/lower_test.cc
@@ -85,7 +85,7 @@
b.Append(f->Block(), [&] { //
auto* result = b.InstructionResult(ty.i32());
b.Append(b.ir.instructions.Create<wgsl::ir::BuiltinCall>(
- result, wgsl::BuiltinFn::kWorkgroupUniformLoad, Vector{wgvar->Result()}));
+ result, wgsl::BuiltinFn::kWorkgroupUniformLoad, Vector{wgvar->Result(0)}));
b.Return(f, result);
});
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
index 6dab3c8..9f83536 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
@@ -515,11 +515,11 @@
}
void Var(const core::ir::Var* var) {
- auto* val = var->Result();
+ auto* val = var->Result(0);
auto* ptr = As<core::type::Pointer>(val->Type());
auto ty = Type(ptr->StoreType());
- Symbol name = NameFor(var->Result());
- Bind(var->Result(), name, PtrKind::kRef);
+ Symbol name = NameFor(var->Result(0));
+ Bind(var->Result(0), name, PtrKind::kRef);
Vector<const ast::Attribute*, 4> attrs;
if (auto bp = var->BindingPoint()) {
@@ -548,9 +548,9 @@
}
void Let(const core::ir::Let* let) {
- Symbol name = NameFor(let->Result());
+ Symbol name = NameFor(let->Result(0));
Append(b.Decl(b.Let(name, Expr(let->Value(), PtrKind::kPtr))));
- Bind(let->Result(), name, PtrKind::kPtr);
+ Bind(let->Result(0), name, PtrKind::kPtr);
}
void Store(const core::ir::Store* store) {
@@ -580,11 +580,11 @@
}
}
auto* expr = b.Call(NameFor(c->Target()), std::move(args));
- if (call->Results().IsEmpty() || !call->Result()->IsUsed()) {
+ if (call->Results().IsEmpty() || !call->Result(0)->IsUsed()) {
Append(b.CallStmt(expr));
return;
}
- Bind(c->Result(), expr, PtrKind::kPtr);
+ Bind(c->Result(0), expr, PtrKind::kPtr);
},
[&](const wgsl::ir::BuiltinCall* c) {
if (!disabled_derivative_uniformity_ && RequiresDerivativeUniformity(c->Func())) {
@@ -604,33 +604,33 @@
}
auto* expr = b.Call(c->Func(), std::move(args));
- if (call->Results().IsEmpty() || call->Result()->Type()->Is<core::type::Void>()) {
+ if (call->Results().IsEmpty() || call->Result(0)->Type()->Is<core::type::Void>()) {
Append(b.CallStmt(expr));
return;
}
- Bind(c->Result(), expr, PtrKind::kPtr);
+ Bind(c->Result(0), expr, PtrKind::kPtr);
},
[&](const core::ir::Construct* c) {
- auto ty = Type(c->Result()->Type());
- Bind(c->Result(), b.Call(ty, std::move(args)), PtrKind::kPtr);
+ auto ty = Type(c->Result(0)->Type());
+ Bind(c->Result(0), b.Call(ty, std::move(args)), PtrKind::kPtr);
},
[&](const core::ir::Convert* c) {
- auto ty = Type(c->Result()->Type());
- Bind(c->Result(), b.Call(ty, std::move(args)), PtrKind::kPtr);
+ auto ty = Type(c->Result(0)->Type());
+ Bind(c->Result(0), b.Call(ty, std::move(args)), PtrKind::kPtr);
},
[&](const core::ir::Bitcast* c) {
- auto ty = Type(c->Result()->Type());
- Bind(c->Result(), b.Bitcast(ty, args[0]), PtrKind::kPtr);
+ auto ty = Type(c->Result(0)->Type());
+ Bind(c->Result(0), b.Bitcast(ty, args[0]), PtrKind::kPtr);
},
[&](const core::ir::Discard*) { Append(b.Discard()); }, //
TINT_ICE_ON_NO_MATCH);
}
- void Load(const core::ir::Load* l) { Bind(l->Result(), Expr(l->From())); }
+ void Load(const core::ir::Load* l) { Bind(l->Result(0), Expr(l->From())); }
void LoadVectorElement(const core::ir::LoadVectorElement* load) {
auto* ptr = Expr(load->From());
- Bind(load->Result(), VectorMemberAccess(ptr, load->Index()));
+ Bind(load->Result(0), VectorMemberAccess(ptr, load->Index()));
}
void Unary(const core::ir::Unary* u) {
@@ -643,7 +643,7 @@
expr = b.Negation(Expr(u->Val()));
break;
}
- Bind(u->Result(), expr);
+ Bind(u->Result(0), expr);
}
void Access(const core::ir::Access* a) {
@@ -677,7 +677,7 @@
}, //
TINT_ICE_ON_NO_MATCH);
}
- Bind(a->Result(), expr);
+ Bind(a->Result(0), expr);
}
void Swizzle(const core::ir::Swizzle* s) {
@@ -692,7 +692,7 @@
}
auto* swizzle =
b.MemberAccessor(vec, std::string_view(components.begin(), components.Length()));
- Bind(s->Result(), swizzle);
+ Bind(s->Result(0), swizzle);
}
void Binary(const core::ir::Binary* e) {
@@ -701,7 +701,7 @@
if (rhs && rhs->Type()->Is<core::type::Bool>() &&
rhs->Value()->ValueAs<bool>() == false) {
// expr == false
- Bind(e->Result(), b.Not(Expr(e->LHS())));
+ Bind(e->Result(0), b.Not(Expr(e->LHS())));
return;
}
}
@@ -758,7 +758,7 @@
expr = b.Shr(lhs, rhs);
break;
}
- Bind(e->Result(), expr);
+ Bind(e->Result(0), expr);
}
TINT_BEGIN_DISABLE_WARNING(UNREACHABLE_CODE);
@@ -1076,7 +1076,7 @@
if (i->Results().IsEmpty()) {
return false;
}
- auto* result = i->Result();
+ auto* result = i->Result(0);
if (!result->Type()->Is<core::type::Bool>()) {
return false; // Wrong result type
}
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
index 3de0d4a..d034c0d 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program_test.cc
@@ -1870,11 +1870,11 @@
auto* va = b.Var("a", ty.ptr<function, i32>());
va->SetInitializer(b.Constant(42_i));
- auto* la = b.Load(va)->Result();
+ auto* la = b.Load(va)->Result(0);
auto* vb = b.Var("b", ty.ptr<function, i32>());
vb->SetInitializer(la);
- auto* lb = b.Load(vb)->Result();
+ auto* lb = b.Load(vb)->Result(0);
auto* vc = b.Var("c", ty.ptr<function, i32>());
vc->SetInitializer(lb);
@@ -2671,7 +2671,7 @@
auto* loop = b.Loop();
b.Append(loop->Initializer(), [&] {
- auto* n_0 = b.Call(ty.i32(), fn_n, 0_i)->Result();
+ auto* n_0 = b.Call(ty.i32(), fn_n, 0_i)->Result(0);
auto* i = b.Var("i", ty.ptr<function, i32>());
i->SetInitializer(n_0);
b.NextIteration(loop);
diff --git a/src/tint/lang/wgsl/writer/raise/raise.cc b/src/tint/lang/wgsl/writer/raise/raise.cc
index fe7d32d..cf0f06e 100644
--- a/src/tint/lang/wgsl/writer/raise/raise.cc
+++ b/src/tint/lang/wgsl/writer/raise/raise.cc
@@ -170,7 +170,7 @@
void ReplaceBuiltinFnCall(core::ir::Module& mod, core::ir::CoreBuiltinCall* call) {
Vector<core::ir::Value*, 8> args(call->Args());
auto* replacement = mod.instructions.Create<wgsl::ir::BuiltinCall>(
- call->Result(), Convert(call->Func()), std::move(args));
+ call->Result(0), Convert(call->Func()), std::move(args));
call->ReplaceWith(replacement);
call->ClearResults();
call->Destroy();
@@ -205,7 +205,7 @@
// Replace load with workgroupUniformLoad
auto* replacement = mod.instructions.Create<wgsl::ir::BuiltinCall>(
- load->Result(), wgsl::BuiltinFn::kWorkgroupUniformLoad, Vector{load->From()});
+ load->Result(0), wgsl::BuiltinFn::kWorkgroupUniformLoad, Vector{load->From()});
load->ReplaceWith(replacement);
load->ClearResults();
load->Destroy();
diff --git a/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc b/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
index d4ae049..bc46235 100644
--- a/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
+++ b/src/tint/lang/wgsl/writer/raise/rename_conflicts_test.cc
@@ -1032,7 +1032,7 @@
auto* fn = b.Function("f", ty.i32());
b.Append(fn->Block(), [&] { //
- auto* res = b.Call(ty.i32(), core::BuiltinFn::kMax, 1_i, 2_i)->Result();
+ auto* res = b.Call(ty.i32(), core::BuiltinFn::kMax, 1_i, 2_i)->Result(0);
b.Return(fn, res);
});
@@ -1065,7 +1065,7 @@
auto* fn = b.Function("f", ty.i32());
b.Append(fn->Block(), [&] { //
- auto* res = b.Call(ty.i32(), core::BuiltinFn::kMax, 1_i, 2_i)->Result();
+ auto* res = b.Call(ty.i32(), core::BuiltinFn::kMax, 1_i, 2_i)->Result(0);
b.Return(fn, res);
});