[tint][ir] Rename Function::StartTarget() to Block() Change-Id: Ib62569e274763d1b50b71d1bd882bb8317073089 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/138380 Reviewed-by: James Price <jrprice@google.com> Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/ir/builder.cc b/src/tint/ir/builder.cc index 2bb295b..2b3c9a4 100644 --- a/src/tint/ir/builder.cc +++ b/src/tint/ir/builder.cc
@@ -48,7 +48,7 @@ Function::PipelineStage stage, std::optional<std::array<uint32_t, 3>> wg_size) { auto* ir_func = ir.values.Create<ir::Function>(return_type, stage, wg_size); - ir_func->SetStartTarget(Block()); + ir_func->SetBlock(Block()); ir.SetName(ir_func, name); return ir_func; }
diff --git a/src/tint/ir/disassembler.cc b/src/tint/ir/disassembler.cc index 629146a..7ff5cf5 100644 --- a/src/tint/ir/disassembler.cc +++ b/src/tint/ir/disassembler.cc
@@ -283,12 +283,12 @@ EmitReturnAttributes(func); - out_ << " -> %b" << IdOf(func->StartTarget()) << " {"; + out_ << " -> %b" << IdOf(func->Block()) << " {"; EmitLine(); { ScopedIndent si(indent_size_); - EmitBlock(func->StartTarget()); + EmitBlock(func->Block()); } Indent() << "}"; EmitLine();
diff --git a/src/tint/ir/from_program.cc b/src/tint/ir/from_program.cc index 8121bab..b6c6586 100644 --- a/src/tint/ir/from_program.cc +++ b/src/tint/ir/from_program.cc
@@ -417,7 +417,7 @@ } ir_func->SetParams(params); - TINT_SCOPED_ASSIGNMENT(current_block_, ir_func->StartTarget()); + TINT_SCOPED_ASSIGNMENT(current_block_, ir_func->Block()); EmitBlock(ast_func->body); // Add a terminator if one was not already created.
diff --git a/src/tint/ir/from_program_test.cc b/src/tint/ir/from_program_test.cc index da99bb8..ecee83b 100644 --- a/src/tint/ir/from_program_test.cc +++ b/src/tint/ir/from_program_test.cc
@@ -62,7 +62,7 @@ ASSERT_EQ(1u, m->functions.Length()); auto* f = m->functions[0]; - ASSERT_NE(f->StartTarget(), nullptr); + ASSERT_NE(f->Block(), nullptr); EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined); @@ -83,7 +83,7 @@ ASSERT_EQ(1u, m->functions.Length()); auto* f = m->functions[0]; - ASSERT_NE(f->StartTarget(), nullptr); + ASSERT_NE(f->Block(), nullptr); EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined); @@ -105,7 +105,7 @@ ASSERT_EQ(1u, m->functions.Length()); auto* f = m->functions[0]; - ASSERT_NE(f->StartTarget(), nullptr); + ASSERT_NE(f->Block(), nullptr); EXPECT_EQ(m->functions[0]->Stage(), Function::PipelineStage::kUndefined);
diff --git a/src/tint/ir/function.h b/src/tint/ir/function.h index a9e1801..0aadc64 100644 --- a/src/tint/ir/function.h +++ b/src/tint/ir/function.h
@@ -120,14 +120,14 @@ /// @returns the function parameters const utils::VectorRef<FunctionParam*> Params() { return params_; } - /// Sets the start target for the function - /// @param target the start target - void SetStartTarget(Block* target) { + /// Sets the root block for the function + /// @param target the root block + void SetBlock(Block* target) { TINT_ASSERT(IR, target != nullptr); - start_target_ = target; + block_ = target; } - /// @returns the function start target - Block* StartTarget() { return start_target_; } + /// @returns the function root block + ir::Block* Block() { return block_; } private: PipelineStage pipeline_stage_; @@ -141,7 +141,7 @@ } return_; utils::Vector<FunctionParam*, 1> params_; - Block* start_target_ = nullptr; + ir::Block* block_ = nullptr; }; utils::StringStream& operator<<(utils::StringStream& out, Function::PipelineStage value);
diff --git a/src/tint/ir/function_test.cc b/src/tint/ir/function_test.cc index 35076df..f5e55d0 100644 --- a/src/tint/ir/function_test.cc +++ b/src/tint/ir/function_test.cc
@@ -55,13 +55,13 @@ ""); } -TEST_F(IR_FunctionTest, Fail_NullStartTarget) { +TEST_F(IR_FunctionTest, Fail_NullBlock) { EXPECT_FATAL_FAILURE( { Module mod; Builder b{mod}; auto* f = b.Function("my_func", mod.Types().void_()); - f->SetStartTarget(nullptr); + f->SetBlock(nullptr); }, ""); }
diff --git a/src/tint/ir/to_program.cc b/src/tint/ir/to_program.cc index d792849..e3a9604 100644 --- a/src/tint/ir/to_program.cc +++ b/src/tint/ir/to_program.cc
@@ -131,7 +131,7 @@ auto name = BindName(fn); auto ret_ty = Type(fn->ReturnType()); - auto* body = Block(fn->StartTarget()); + auto* body = Block(fn->Block()); utils::Vector<const ast::Attribute*, 1> attrs{}; utils::Vector<const ast::Attribute*, 1> ret_attrs{}; return b.Func(name, std::move(params), ret_ty, body, std::move(attrs),
diff --git a/src/tint/ir/transform/add_empty_entry_point.cc b/src/tint/ir/transform/add_empty_entry_point.cc index 3c28e59..5781e93 100644 --- a/src/tint/ir/transform/add_empty_entry_point.cc +++ b/src/tint/ir/transform/add_empty_entry_point.cc
@@ -37,7 +37,7 @@ ir::Builder builder(*ir); auto* ep = builder.Function("unused_entry_point", ir->Types().void_(), Function::PipelineStage::kCompute, std::array{1u, 1u, 1u}); - ep->StartTarget()->Append(builder.Return(ep)); + ep->Block()->Append(builder.Return(ep)); ir->functions.Push(ep); }
diff --git a/src/tint/ir/transform/add_empty_entry_point_test.cc b/src/tint/ir/transform/add_empty_entry_point_test.cc index c5c60a1..567feae 100644 --- a/src/tint/ir/transform/add_empty_entry_point_test.cc +++ b/src/tint/ir/transform/add_empty_entry_point_test.cc
@@ -39,7 +39,7 @@ TEST_F(IR_AddEmptyEntryPointTest, ExistingEntryPoint) { auto* ep = b.Function("main", mod.Types().void_(), Function::PipelineStage::kFragment); - ep->StartTarget()->Append(b.Return(ep)); + ep->Block()->Append(b.Return(ep)); mod.functions.Push(ep); auto* expect = R"(
diff --git a/src/tint/ir/transform/block_decorated_structs_test.cc b/src/tint/ir/transform/block_decorated_structs_test.cc index 2211f99..57722ea 100644 --- a/src/tint/ir/transform/block_decorated_structs_test.cc +++ b/src/tint/ir/transform/block_decorated_structs_test.cc
@@ -31,7 +31,7 @@ TEST_F(IR_BlockDecoratedStructsTest, NoRootBlock) { auto* func = b.Function("foo", ty.void_()); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); mod.functions.Push(func); auto* expect = R"( @@ -54,7 +54,7 @@ auto* func = b.Function("foo", ty.i32()); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* load = block->Append(b.Load(buffer)); block->Append(b.Return(func, load)); mod.functions.Push(func); @@ -88,8 +88,8 @@ b.RootBlock()->Append(buffer); auto* func = b.Function("foo", ty.void_()); - func->StartTarget()->Append(b.Store(buffer, 42_i)); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Store(buffer, 42_i)); + func->Block()->Append(b.Return(func)); mod.functions.Push(func); auto* expect = R"( @@ -122,7 +122,7 @@ auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* access = sb.Access(ty.ptr<storage, i32>(), buffer, 1_u); sb.Store(access, 42_i); sb.Return(func); @@ -168,7 +168,7 @@ auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* val_ptr = sb.Access(i32_ptr, buffer, 0_u); auto* load = sb.Load(val_ptr); auto* elem_ptr = sb.Access(i32_ptr, buffer, 1_u, 3_u); @@ -222,8 +222,8 @@ b.RootBlock()->Append(private_var); auto* func = b.Function("foo", ty.void_()); - func->StartTarget()->Append(b.Store(buffer, private_var)); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Store(buffer, private_var)); + func->Block()->Append(b.Return(func)); mod.functions.Push(func); auto* expect = R"( @@ -268,7 +268,7 @@ root->Append(buffer_c); auto* func = b.Function("foo", ty.void_()); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* load_b = block->Append(b.Load(buffer_b)); auto* load_c = block->Append(b.Load(buffer_c)); block->Append(b.Store(buffer_a, b.Add(ty.i32(), load_b, load_c)));
diff --git a/src/tint/ir/transform/merge_return.cc b/src/tint/ir/transform/merge_return.cc index 4817d04..91f4ab9 100644 --- a/src/tint/ir/transform/merge_return.cc +++ b/src/tint/ir/transform/merge_return.cc
@@ -80,23 +80,23 @@ // Create a boolean variable that can be used to check whether the function is returning. continue_execution = b.Var(ty.ptr<function, bool>()); continue_execution->SetInitializer(b.Constant(true)); - fn->StartTarget()->Prepend(continue_execution); + fn->Block()->Prepend(continue_execution); ir->SetName(continue_execution, "continue_execution"); // Create a variable to hold the return value if needed. if (!fn->ReturnType()->Is<type::Void>()) { return_val = b.Var(ty.ptr(function, fn->ReturnType())); - fn->StartTarget()->Prepend(return_val); + fn->Block()->Prepend(return_val); ir->SetName(return_val, "return_value"); } // Look to see if the function ends with a return - fn_return = tint::As<Return>(fn->StartTarget()->Terminator()); + fn_return = tint::As<Return>(fn->Block()->Terminator()); // Process the function's block. // This will traverse into control instructions that hold returns, and apply the necessary // changes to remove returns. - ProcessBlock(fn->StartTarget()); + ProcessBlock(fn->Block()); // If the function didn't end with a return, add one if (!fn_return) { @@ -279,7 +279,7 @@ /// Adds a final return instruction to the end of @p fn /// @param fn the function void AppendFinalReturn(Function* fn) { - auto fb = b.With(fn->StartTarget()); + auto fb = b.With(fn->Block()); if (return_val) { fb.Return(fn, fb.Load(return_val)); } else {
diff --git a/src/tint/ir/transform/merge_return_test.cc b/src/tint/ir/transform/merge_return_test.cc index bf68eae..071ea0f 100644 --- a/src/tint/ir/transform/merge_return_test.cc +++ b/src/tint/ir/transform/merge_return_test.cc
@@ -32,7 +32,7 @@ func->SetParams({in}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Return(func, sb.Add(ty.i32(), in, 1_i)); auto* src = R"( @@ -59,7 +59,7 @@ func->SetParams({in}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); ifelse->SetResults(b.InstructionResult(ty.i32())); @@ -103,7 +103,7 @@ func->SetParams({in}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* swtch = sb.Switch(in); b.Case(swtch, {Switch::CaseSelector{}})->Append(b.ExitSwitch(swtch)); @@ -158,7 +158,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); auto tb = b.With(ifelse->True()); @@ -214,7 +214,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); sb.Return(func); @@ -268,7 +268,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); auto tb = b.With(ifelse->True()); @@ -334,7 +334,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); ifelse->SetResults(b.InstructionResult(ty.i32())); @@ -401,7 +401,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); ifelse->SetResults(b.InstructionResult(ty.i32())); @@ -468,7 +468,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); auto tb = b.With(ifelse->True()); @@ -526,7 +526,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); auto tb = b.With(ifelse->True()); @@ -605,7 +605,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse = sb.If(cond); sb.Store(global, 42_i); @@ -687,7 +687,7 @@ func->SetParams({condA, condB, condC}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse_outer = sb.If(condA); auto outer_true = b.With(ifelse_outer->True()); @@ -843,7 +843,7 @@ func->SetParams({condA, condB, condC}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse_outer = sb.If(condA); auto outer_true = b.With(ifelse_outer->True()); @@ -974,7 +974,7 @@ func->SetParams({condA, condB, condC}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* ifelse_outer = sb.If(condA); ifelse_outer->SetResults(b.InstructionResult(ty.i32())); @@ -1119,7 +1119,7 @@ auto* func = b.Function("foo", ty.i32()); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* loop = sb.Loop(); loop->Body()->Append(b.Return(func, 42_i)); @@ -1170,7 +1170,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* loop = sb.Loop(); auto lb = b.With(loop->Body()); @@ -1286,7 +1286,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* loop = sb.Loop(); auto lb = b.With(loop->Body()); @@ -1392,7 +1392,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* loop = sb.Loop(); loop->SetResults(b.InstructionResult(ty.i32())); @@ -1506,7 +1506,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* sw = sb.Switch(cond); auto caseA = b.With(b.Case(sw, {Switch::CaseSelector{b.Constant(1_i)}})); @@ -1575,7 +1575,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* sw = sb.Switch(cond); auto caseA = b.With(b.Case(sw, {Switch::CaseSelector{b.Constant(1_i)}})); @@ -1682,7 +1682,7 @@ func->SetParams({cond}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* sw = sb.Switch(cond); sw->SetResults(b.InstructionResult(ty.i32())); // NOLINT: false detection of std::tuple @@ -1765,7 +1765,7 @@ auto* func = b.Function("foo", ty.void_()); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); { auto* loop = sb.Loop(); auto lb = sb.With(loop->Body()); @@ -1831,7 +1831,7 @@ auto* func = b.Function("foo", ty.i32()); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); { auto outer = b.With(sb.If(true)->True()); {
diff --git a/src/tint/ir/transform/var_for_dynamic_index_test.cc b/src/tint/ir/transform/var_for_dynamic_index_test.cc index 785927d..ce0d691 100644 --- a/src/tint/ir/transform/var_for_dynamic_index_test.cc +++ b/src/tint/ir/transform/var_for_dynamic_index_test.cc
@@ -34,7 +34,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.i32(), arr, 1_i)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -58,7 +58,7 @@ auto* func = b.Function("foo", ty.f32()); func->SetParams({mat}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.f32(), mat, 1_i, 0_i)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -83,7 +83,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.ptr<function, i32>(), arr, idx)); auto* load = block->Append(b.Load(access)); block->Append(b.Return(func, load)); @@ -110,7 +110,7 @@ auto* func = b.Function("foo", ty.f32()); func->SetParams({mat, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.ptr<function, f32>(), mat, idx, idx)); auto* load = block->Append(b.Load(access)); block->Append(b.Return(func, load)); @@ -137,7 +137,7 @@ auto* func = b.Function("foo", ty.f32()); func->SetParams({vec, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.f32(), vec, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -162,7 +162,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.i32(), arr, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -189,7 +189,7 @@ auto* func = b.Function("foo", ty.vec2<f32>()); func->SetParams({mat, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.vec2<f32>(), mat, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -216,7 +216,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.i32(), arr, idx, 1_u, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -243,7 +243,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -271,7 +271,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.i32(), arr, 1_u, idx, 2_u, idx)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -305,7 +305,7 @@ auto* func = b.Function("foo", ty.f32()); func->SetParams({str_val, idx}); - auto* block = func->StartTarget(); + auto* block = func->Block(); auto* access = block->Append(b.Access(ty.f32(), str_val, 1_u, idx, 0_u)); block->Append(b.Return(func, access)); mod.functions.Push(func); @@ -341,7 +341,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx_a, idx_b, idx_c}); - auto* block = func->StartTarget(); + auto* block = func->Block(); block->Append(b.Access(ty.i32(), arr, idx_a)); block->Append(b.Access(ty.i32(), arr, idx_b)); auto* access_c = block->Append(b.Access(ty.i32(), arr, idx_c)); @@ -376,7 +376,7 @@ auto* func = b.Function("foo", ty.i32()); func->SetParams({arr, idx_a, idx_b, idx_c}); - auto* block = func->StartTarget(); + auto* block = func->Block(); block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx_a)); block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx_b)); auto* access_c = block->Append(b.Access(ty.i32(), arr, 1_u, 2_u, idx_c));
diff --git a/src/tint/ir/validate.cc b/src/tint/ir/validate.cc index 6687111..34436e3 100644 --- a/src/tint/ir/validate.cc +++ b/src/tint/ir/validate.cc
@@ -161,7 +161,7 @@ } } - void CheckFunction(Function* func) { CheckBlock(func->StartTarget()); } + void CheckFunction(Function* func) { CheckBlock(func->Block()); } void CheckBlock(Block* blk) { TINT_SCOPED_ASSIGNMENT(current_block_, blk);
diff --git a/src/tint/ir/validate_test.cc b/src/tint/ir/validate_test.cc index 080625c..d49f553 100644 --- a/src/tint/ir/validate_test.cc +++ b/src/tint/ir/validate_test.cc
@@ -71,7 +71,7 @@ mod.functions.Push(f); f->SetParams({b.FunctionParam(ty.i32()), b.FunctionParam(ty.f32())}); - f->StartTarget()->Append(b.Return(f)); + f->Block()->Append(b.Return(f)); auto res = ir::Validate(mod); EXPECT_TRUE(res) << res.Failure().str(); @@ -101,7 +101,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.f32(), obj, 1_u, 0_u); sb.Return(f); @@ -115,7 +115,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.ptr<private_, f32>(), obj, 1_u, 0_u); sb.Return(f); @@ -129,7 +129,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.f32(), obj, -1_i); sb.Return(f); @@ -159,7 +159,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.f32(), obj, 1_u, 3_u); sb.Return(f); @@ -193,7 +193,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.ptr<private_, f32>(), obj, 1_u, 3_u); sb.Return(f); @@ -228,7 +228,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.f32(), obj, 1_u); sb.Return(f); @@ -258,7 +258,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.ptr<private_, f32>(), obj, 1_u); sb.Return(f); @@ -294,7 +294,7 @@ f->SetParams({obj, idx}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.i32(), obj, idx); sb.Return(f); @@ -336,7 +336,7 @@ f->SetParams({obj, idx}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.i32(), obj, idx); sb.Return(f); @@ -372,7 +372,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.i32(), obj, 1_u, 1_u); sb.Return(f); @@ -403,7 +403,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.ptr<private_, i32>(), obj, 1_u, 1_u); sb.Return(f); @@ -435,7 +435,7 @@ f->SetParams({obj}); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Access(ty.f32(), obj, 1_u, 1_u); sb.Return(f); @@ -465,7 +465,7 @@ auto* f = b.Function("my_func", ty.void_()); mod.functions.Push(f); - auto sb = b.With(f->StartTarget()); + auto sb = b.With(f->Block()); sb.Return(f); sb.Return(f); @@ -498,8 +498,8 @@ if_->True()->Append(b.Return(f)); if_->False()->Append(b.Return(f)); - f->StartTarget()->Append(if_); - f->StartTarget()->Append(b.Return(f)); + f->Block()->Append(if_); + f->Block()->Append(b.Return(f)); auto res = ir::Validate(mod); ASSERT_FALSE(res);
diff --git a/src/tint/transform/manager_test.cc b/src/tint/transform/manager_test.cc index c1083b2..e578766 100644 --- a/src/tint/transform/manager_test.cc +++ b/src/tint/transform/manager_test.cc
@@ -51,7 +51,7 @@ void Run(ir::Module* mod, const DataMap&, DataMap&) const override { ir::Builder builder(*mod); auto* func = builder.Function("ir_func", mod->Types().Get<type::Void>()); - func->StartTarget()->Append(builder.Return(func)); + func->Block()->Append(builder.Return(func)); mod->functions.Push(func); } }; @@ -68,7 +68,7 @@ ir::Module mod; ir::Builder builder(mod); auto* func = builder.Function("main", mod.Types().Get<type::Void>()); - func->StartTarget()->Append(builder.Return(func)); + func->Block()->Append(builder.Return(func)); builder.ir.functions.Push(func); return mod; }
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir.cc b/src/tint/writer/spirv/ir/generator_impl_ir.cc index fc52fe7..66bcfa9 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir.cc
@@ -376,7 +376,7 @@ TINT_DEFER(current_function_ = Function()); // Emit the body of the function. - EmitBlock(func->StartTarget()); + EmitBlock(func->Block()); // Add the function to the module. module_.PushFunction(current_function_);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc index 1f33350..a01d8d6 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_access_test.cc
@@ -27,7 +27,7 @@ auto* func = b.Function("foo", ty.void_()); func->SetParams({arr_val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Access(ty.i32(), arr_val, 1_u); sb.Return(func); @@ -54,7 +54,7 @@ TEST_F(SpvGeneratorImplTest_Access, Array_Pointer_ConstantIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* arr_var = sb.Var(ty.ptr<function, array<i32, 4>>()); sb.Access(ty.ptr<function, i32>(), arr_var, 1_u); sb.Return(func); @@ -85,7 +85,7 @@ TEST_F(SpvGeneratorImplTest_Access, Array_Pointer_DynamicIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* idx_var = sb.Var(ty.ptr<function, i32>()); auto* idx = sb.Load(idx_var); auto* arr_var = sb.Var(ty.ptr<function, array<i32, 4>>()); @@ -121,7 +121,7 @@ auto* func = b.Function("foo", ty.void_()); func->SetParams({mat_val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Access(ty.vec2(ty.f32()), mat_val, 1_u); sb.Access(ty.f32(), mat_val, 1_u, 0_u); sb.Return(func); @@ -148,7 +148,7 @@ TEST_F(SpvGeneratorImplTest_Access, Matrix_Pointer_ConstantIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* mat_var = sb.Var(ty.ptr<function, mat2x2<f32>>()); sb.Access(ty.ptr<function, vec2<f32>>(), mat_var, 1_u); sb.Access(ty.ptr<function, f32>(), mat_var, 1_u, 0_u); @@ -182,7 +182,7 @@ TEST_F(SpvGeneratorImplTest_Access, Matrix_Pointer_DynamicIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* idx_var = sb.Var(ty.ptr<function, i32>()); auto* idx = sb.Load(idx_var); auto* mat_var = sb.Var(ty.ptr<function, mat2x2<f32>>()); @@ -221,7 +221,7 @@ auto* vec_val = b.FunctionParam(ty.vec4(ty.i32())); func->SetParams({vec_val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Access(ty.i32(), vec_val, 1_u); sb.Return(func); @@ -247,7 +247,7 @@ auto* vec_val = b.FunctionParam(ty.vec4(ty.i32())); func->SetParams({vec_val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* idx_var = sb.Var(ty.ptr<function, i32>()); auto* idx = sb.Load(idx_var); sb.Access(ty.i32(), vec_val, idx); @@ -276,7 +276,7 @@ TEST_F(SpvGeneratorImplTest_Access, Vector_Pointer_ConstantIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* vec_var = sb.Var(ty.ptr<function, vec4<i32>>()); sb.Access(ty.ptr<function, i32>(), vec_var, 1_u); sb.Return(func); @@ -305,7 +305,7 @@ TEST_F(SpvGeneratorImplTest_Access, Vector_Pointer_DynamicIndex) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* idx_var = sb.Var(ty.ptr<function, i32>()); auto* idx = sb.Load(idx_var); auto* vec_var = sb.Var(ty.ptr<function, vec4<i32>>()); @@ -338,7 +338,7 @@ auto* func = b.Function("foo", ty.void_()); func->SetParams({val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* idx_var = sb.Var(ty.ptr<function, i32>()); auto* idx = sb.Load(idx_var); sb.Access(ty.i32(), val, 1_u, 2_u, idx); @@ -381,7 +381,7 @@ auto* func = b.Function("foo", ty.void_()); func->SetParams({str_val}); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Access(ty.i32(), str_val, 1_u); sb.Access(ty.i32(), str_val, 1_u, 2_u); sb.Return(func); @@ -419,7 +419,7 @@ }); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* str_var = sb.Var(ty.ptr(function, str, read_write)); sb.Access(ty.ptr<function, i32>(), str_var, 1_u); sb.Access(ty.ptr<function, i32>(), str_var, 1_u, 2_u);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_binary_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_binary_test.cc index 37b702c..e3b8f56 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_binary_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_binary_test.cc
@@ -37,7 +37,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, MakeScalarType(params.type), MakeScalarValue(params.type), MakeScalarValue(params.type)); sb.Return(func); @@ -51,7 +51,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, MakeVectorType(params.type), MakeVectorValue(params.type), MakeVectorValue(params.type)); sb.Return(func); @@ -87,7 +87,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, MakeScalarType(params.type), MakeScalarValue(params.type), MakeScalarValue(params.type)); sb.Return(func); @@ -101,7 +101,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, MakeVectorType(params.type), MakeVectorValue(params.type), MakeVectorValue(params.type)); sb.Return(func); @@ -129,7 +129,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, ty.bool_(), MakeScalarValue(params.type), MakeScalarValue(params.type)); sb.Return(func); @@ -143,7 +143,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Binary(params.kind, ty.vec2(ty.bool_()), MakeVectorValue(params.type), MakeVectorValue(params.type)); sb.Return(func); @@ -202,7 +202,7 @@ TEST_F(SpvGeneratorImplTest, Binary_Chain) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* a = sb.Subtract(ty.i32(), 1_i, 2_i); sb.Add(ty.i32(), a, a); sb.Return(func);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_builtin_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_builtin_test.cc index ae45e1c..027b83c 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_builtin_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_builtin_test.cc
@@ -38,7 +38,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Call(MakeScalarType(params.type), params.function, MakeScalarValue(params.type)); sb.Return(func); @@ -51,7 +51,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Call(MakeVectorType(params.type), params.function, MakeVectorValue(params.type)); sb.Return(func); @@ -68,7 +68,7 @@ // Test that abs of an unsigned value just folds away. TEST_F(SpvGeneratorImplTest, Builtin_Abs_u32) { auto* func = b.Function("foo", MakeScalarType(kU32)); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* result = sb.Call(MakeScalarType(kU32), builtin::Function::kAbs, MakeScalarValue(kU32)); sb.Return(func, result); @@ -88,7 +88,7 @@ TEST_F(SpvGeneratorImplTest, Builtin_Abs_vec2u) { auto* func = b.Function("foo", MakeVectorType(kU32)); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* result = sb.Call(MakeVectorType(kU32), builtin::Function::kAbs, MakeVectorValue(kU32)); sb.Return(func, result); @@ -115,7 +115,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Call(MakeScalarType(params.type), params.function, MakeScalarValue(params.type), MakeScalarValue(params.type)); sb.Return(func); @@ -129,7 +129,7 @@ auto params = GetParam(); auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Call(MakeVectorType(params.type), params.function, MakeVectorValue(params.type), MakeVectorValue(params.type)); sb.Return(func);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_construct_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_construct_test.cc index 732c6ff..b18f7b5 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_construct_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_construct_test.cc
@@ -29,7 +29,7 @@ b.FunctionParam(ty.i32()), }); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Return(func, sb.Construct(ty.vec4<i32>(), func->Params())); ASSERT_TRUE(IRIsValid()) << Error(); @@ -59,7 +59,7 @@ b.FunctionParam(ty.vec4<f32>()), }); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Return(func, sb.Construct(ty.mat3x4<f32>(), func->Params())); ASSERT_TRUE(IRIsValid()) << Error(); @@ -90,7 +90,7 @@ b.FunctionParam(ty.f32()), }); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Return(func, sb.Construct(ty.array<f32, 4>(), func->Params())); ASSERT_TRUE(IRIsValid()) << Error(); @@ -130,7 +130,7 @@ b.FunctionParam(ty.vec4<f32>()), }); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Return(func, sb.Construct(str, func->Params())); ASSERT_TRUE(IRIsValid()) << Error();
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_function_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_function_test.cc index 81f1091..689dcd7 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_function_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_function_test.cc
@@ -19,7 +19,7 @@ TEST_F(SpvGeneratorImplTest, Function_Empty) { auto* func = b.Function("foo", ty.void_()); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -37,7 +37,7 @@ // Test that we do not emit the same function type more than once. TEST_F(SpvGeneratorImplTest, Function_DeduplicateType) { auto* func = b.Function("foo", ty.void_()); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -52,7 +52,7 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Compute) { auto* func = b.Function("main", ty.void_(), ir::Function::PipelineStage::kCompute, {{32, 4, 1}}); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -71,7 +71,7 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Fragment) { auto* func = b.Function("main", ty.void_(), ir::Function::PipelineStage::kFragment); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -90,7 +90,7 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Vertex) { auto* func = b.Function("main", ty.void_(), ir::Function::PipelineStage::kVertex); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -108,13 +108,13 @@ TEST_F(SpvGeneratorImplTest, Function_EntryPoint_Multiple) { auto* f1 = b.Function("main1", ty.void_(), ir::Function::PipelineStage::kCompute, {{32, 4, 1}}); - f1->StartTarget()->Append(b.Return(f1)); + f1->Block()->Append(b.Return(f1)); auto* f2 = b.Function("main2", ty.void_(), ir::Function::PipelineStage::kCompute, {{8, 2, 16}}); - f2->StartTarget()->Append(b.Return(f2)); + f2->Block()->Append(b.Return(f2)); auto* f3 = b.Function("main3", ty.void_(), ir::Function::PipelineStage::kFragment); - f3->StartTarget()->Append(b.Return(f3)); + f3->Block()->Append(b.Return(f3)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -149,7 +149,7 @@ TEST_F(SpvGeneratorImplTest, Function_ReturnValue) { auto* func = b.Function("foo", ty.i32()); - func->StartTarget()->Append(b.Return(func, i32(42))); + func->Block()->Append(b.Return(func, i32(42))); ASSERT_TRUE(IRIsValid()) << Error(); @@ -174,7 +174,7 @@ mod.SetName(x, "x"); mod.SetName(y, "y"); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* result = sb.Add(i32, x, y); sb.Return(func, result); @@ -204,14 +204,14 @@ foo->SetParams({x, y}); { - auto sb = b.With(foo->StartTarget()); + auto sb = b.With(foo->Block()); auto* result = sb.Add(i32_ty, x, y); sb.Return(foo, result); } auto* bar = b.Function("bar", ty.void_()); { - auto sb = b.With(bar->StartTarget()); + auto sb = b.With(bar->Block()); sb.Call(i32_ty, foo, i32(2), i32(3)); sb.Return(bar); } @@ -245,10 +245,10 @@ TEST_F(SpvGeneratorImplTest, Function_Call_Void) { auto* foo = b.Function("foo", ty.void_()); - foo->StartTarget()->Append(b.Return(foo)); + foo->Block()->Append(b.Return(foo)); auto* bar = b.Function("bar", ty.void_()); - auto sb = b.With(bar->StartTarget()); + auto sb = b.With(bar->Block()); sb.Call(ty.void_(), foo, utils::Empty); sb.Return(bar);
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_if_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_if_test.cc index 62afeda..4802d5b 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_if_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_if_test.cc
@@ -25,8 +25,8 @@ auto* i = b.If(true); i->True()->Append(b.ExitIf(i)); i->False()->Append(b.ExitIf(i)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -56,8 +56,8 @@ tb.Add(ty.i32(), 1_i, 1_i); tb.ExitIf(i); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -92,8 +92,8 @@ fb.Add(ty.i32(), 1_i, 1_i); fb.ExitIf(i); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -125,8 +125,8 @@ i->True()->Append(b.Return(func)); i->False()->Append(b.Return(func)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Unreachable()); + func->Block()->Append(i); + func->Block()->Append(b.Unreachable()); ASSERT_TRUE(IRIsValid()) << Error(); @@ -158,8 +158,8 @@ i->True()->Append(b.ExitIf(i, 10_i)); i->False()->Append(b.ExitIf(i, 20_i)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func, i)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func, i)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -194,8 +194,8 @@ i->True()->Append(b.Return(func, 42_i)); i->False()->Append(b.ExitIf(i, 20_i)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func, i)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func, i)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -230,8 +230,8 @@ i->True()->Append(b.ExitIf(i, 10_i)); i->False()->Append(b.Return(func, 42_i)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func, i)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func, i)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -266,8 +266,8 @@ i->True()->Append(b.ExitIf(i, 10_i, true)); i->False()->Append(b.ExitIf(i, 20_i, false)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func, i->Result(0))); + func->Block()->Append(i); + func->Block()->Append(b.Return(func, i->Result(0))); ASSERT_TRUE(IRIsValid()) << Error(); @@ -304,8 +304,8 @@ i->True()->Append(b.ExitIf(i, 10_i, true)); i->False()->Append(b.ExitIf(i, 20_i, false)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func, i->Result(1))); + func->Block()->Append(i); + func->Block()->Append(b.Return(func, i->Result(1))); generator_.EmitFunction(func); EXPECT_EQ(DumpModule(generator_.Module()), R"(OpName %1 "foo"
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc index 88a25e1..abaee8a 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_loop_test.cc
@@ -27,8 +27,8 @@ loop->Body()->Append(b.Continue(loop)); loop->Continuing()->Append(b.BreakIf(true, loop)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -62,8 +62,8 @@ loop->Body()->Append(b.ExitLoop(loop)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -100,8 +100,8 @@ loop->Body()->Append(b.Continue(loop)); loop->Continuing()->Append(b.NextIteration(loop)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -145,8 +145,8 @@ loop->Body()->Append(b.ExitLoop(loop)); loop->Continuing()->Append(b.NextIteration(loop)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -185,8 +185,8 @@ auto* loop = b.Loop(); loop->Body()->Append(b.Return(func)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Unreachable()); + func->Block()->Append(loop); + func->Block()->Append(b.Unreachable()); ASSERT_TRUE(IRIsValid()) << Error(); @@ -220,8 +220,8 @@ loop->Continuing()->Append(b.BreakIf(result, loop)); - func->StartTarget()->Append(loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -262,8 +262,8 @@ outer_loop->Body()->Append(b.Continue(outer_loop)); outer_loop->Continuing()->Append(b.BreakIf(true, outer_loop)); - func->StartTarget()->Append(outer_loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(outer_loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -311,8 +311,8 @@ outer_loop->Continuing()->Append(inner_loop); outer_loop->Continuing()->Append(b.BreakIf(true, outer_loop)); - func->StartTarget()->Append(outer_loop); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(outer_loop); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -350,7 +350,7 @@ TEST_F(SpvGeneratorImplTest, Loop_Phi_SingleValue) { auto* func = b.Function("foo", ty.void_()); - auto fb = b.With(func->StartTarget()); + auto fb = b.With(func->Block()); auto* l = fb.Loop(); { @@ -411,7 +411,7 @@ TEST_F(SpvGeneratorImplTest, Loop_Phi_MultipleValue) { auto* func = b.Function("foo", ty.void_()); - auto fb = b.With(func->StartTarget()); + auto fb = b.With(func->Block()); auto* l = fb.Loop(); {
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_switch_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_switch_test.cc index c0f32cf..396e0fe 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_switch_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_switch_test.cc
@@ -27,8 +27,8 @@ auto* def_case = b.Case(swtch, utils::Vector{ir::Switch::CaseSelector()}); def_case->Append(b.ExitSwitch(swtch)); - func->StartTarget()->Append(swtch); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(swtch); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -64,8 +64,8 @@ auto* def_case = b.Case(swtch, utils::Vector{ir::Switch::CaseSelector()}); def_case->Append(b.ExitSwitch(swtch)); - func->StartTarget()->Append(swtch); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(swtch); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -108,8 +108,8 @@ ir::Switch::CaseSelector()}); def_case->Append(b.ExitSwitch(swtch)); - func->StartTarget()->Append(swtch); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(swtch); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -149,8 +149,8 @@ auto* def_case = b.Case(swtch, utils::Vector{ir::Switch::CaseSelector()}); def_case->Append(b.Return(func)); - func->StartTarget()->Append(swtch); - func->StartTarget()->Append(b.Unreachable()); + func->Block()->Append(swtch); + func->Block()->Append(b.Unreachable()); ASSERT_TRUE(IRIsValid()) << Error(); @@ -192,8 +192,8 @@ auto* def_case = b.Case(swtch, utils::Vector{ir::Switch::CaseSelector()}); def_case->Append(b.ExitSwitch(swtch)); - func->StartTarget()->Append(swtch); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(swtch); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -236,8 +236,8 @@ auto* case_b = b.Case(s, utils::Vector{ir::Switch::CaseSelector{b.Constant(2_i)}}); case_b->Append(b.ExitSwitch(s, 20_i)); - func->StartTarget()->Append(s); - func->StartTarget()->Append(b.Return(func, s)); + func->Block()->Append(s); + func->Block()->Append(b.Return(func, s)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -275,8 +275,8 @@ auto* case_b = b.Case(s, utils::Vector{ir::Switch::CaseSelector{b.Constant(2_i)}}); case_b->Append(b.ExitSwitch(s, 20_i)); - func->StartTarget()->Append(s); - func->StartTarget()->Append(b.Return(func, s)); + func->Block()->Append(s); + func->Block()->Append(b.Return(func, s)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -314,8 +314,8 @@ auto* case_b = b.Case(s, utils::Vector{ir::Switch::CaseSelector{b.Constant(2_i)}}); case_b->Append(b.ExitSwitch(s, 20_i, false)); - func->StartTarget()->Append(s); - func->StartTarget()->Append(b.Return(func, s->Result(0))); + func->Block()->Append(s); + func->Block()->Append(b.Return(func, s->Result(0))); ASSERT_TRUE(IRIsValid()) << Error(); @@ -357,8 +357,8 @@ auto* case_b = b.Case(s, utils::Vector{ir::Switch::CaseSelector{b.Constant(2_i)}}); case_b->Append(b.ExitSwitch(s, 20_i, false)); - func->StartTarget()->Append(s); - func->StartTarget()->Append(b.Return(func, s->Result(1))); + func->Block()->Append(s); + func->Block()->Append(b.Return(func, s->Result(1))); generator_.EmitFunction(func); EXPECT_EQ(DumpModule(generator_.Module()), R"(OpName %1 "foo"
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_test.cc index ef33bfb..9ec2a47 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_test.cc
@@ -36,8 +36,8 @@ i->True()->Append(b.Return(func, 10_i)); i->False()->Append(b.Return(func, 20_i)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Unreachable()); + func->Block()->Append(i); + func->Block()->Append(b.Unreachable()); ASSERT_TRUE(IRIsValid()) << Error();
diff --git a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc index feb7c63..944d65c 100644 --- a/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc +++ b/src/tint/writer/spirv/ir/generator_impl_ir_var_test.cc
@@ -24,7 +24,7 @@ TEST_F(SpvGeneratorImplTest, FunctionVar_NoInit) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Var(ty.ptr<function, i32>()); sb.Return(func); @@ -47,7 +47,7 @@ TEST_F(SpvGeneratorImplTest, FunctionVar_WithInit) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* v = sb.Var(ty.ptr<function, i32>()); v->SetInitializer(b.Constant(42_i)); @@ -74,7 +74,7 @@ TEST_F(SpvGeneratorImplTest, FunctionVar_Name) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* v = sb.Var(ty.ptr<function, i32>()); sb.Return(func); @@ -109,8 +109,8 @@ i->False()->Append(b.Return(func)); - func->StartTarget()->Append(i); - func->StartTarget()->Append(b.Return(func)); + func->Block()->Append(i); + func->Block()->Append(b.Return(func)); ASSERT_TRUE(IRIsValid()) << Error(); @@ -142,7 +142,7 @@ TEST_F(SpvGeneratorImplTest, FunctionVar_Load) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* store_ty = ty.i32(); auto* v = sb.Var(ty.ptr(function, store_ty)); @@ -169,7 +169,7 @@ TEST_F(SpvGeneratorImplTest, FunctionVar_Store) { auto* func = b.Function("foo", ty.void_()); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); auto* v = sb.Var(ty.ptr<function, i32>()); sb.Store(v, 42_i); sb.Return(func); @@ -273,7 +273,7 @@ v->SetInitializer(b.Constant(42_i)); b.RootBlock()->Append(v); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Load(v); auto* add = sb.Add(store_ty, v, 1_i); sb.Store(v, add); @@ -354,7 +354,7 @@ auto* store_ty = ty.i32(); auto* v = b.RootBlock()->Append(b.Var(ty.ptr(workgroup, store_ty))); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Load(v); auto* add = sb.Add(store_ty, v, 1_i); sb.Store(v, add); @@ -476,7 +476,7 @@ std::array{1u, 1u, 1u}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Load(v); auto* add = sb.Add(ty.i32(), v, 1_i); sb.Store(v, add); @@ -587,7 +587,7 @@ std::array{1u, 1u, 1u}); mod.functions.Push(func); - auto sb = b.With(func->StartTarget()); + auto sb = b.With(func->Block()); sb.Load(v); sb.Return(func);