diff --git a/xls/flows/testdata/ir_wrapper_test_DslxProcsToIrOk.ir b/xls/flows/testdata/ir_wrapper_test_DslxProcsToIrOk.ir index 501d1ae5fc..ec83fbae2f 100644 --- a/xls/flows/testdata/ir_wrapper_test_DslxProcsToIrOk.ir +++ b/xls/flows/testdata/ir_wrapper_test_DslxProcsToIrOk.ir @@ -8,12 +8,12 @@ chan test_package__output(bits[32], id=2, kind=streaming, ops=send_only, flow_co proc __top__foo_0_next() { tok: token = after_all(id=4) - receive.17: (token, bits[32]) = receive(tok, channel=test_package__in_0, id=17) - tok__1: token = tuple_index(receive.17, index=0, id=7, pos=[(0,12,13)]) - receive.18: (token, bits[32]) = receive(tok__1, channel=test_package__in_1, id=18) - a: bits[32] = tuple_index(receive.17, index=1, id=8, pos=[(0,12,18)]) - b: bits[32] = tuple_index(receive.18, index=1, id=12, pos=[(0,13,18)]) - tok__2: token = tuple_index(receive.18, index=0, id=11, pos=[(0,13,13)]) + receive.18: (token, bits[32]) = receive(tok, channel=test_package__in_0, id=18) + tok__1: token = tuple_index(receive.18, index=0, id=7, pos=[(0,12,13)]) + receive.19: (token, bits[32]) = receive(tok__1, channel=test_package__in_1, id=19) + a: bits[32] = tuple_index(receive.18, index=1, id=8, pos=[(0,12,18)]) + b: bits[32] = tuple_index(receive.19, index=1, id=12, pos=[(0,13,18)]) + tok__2: token = tuple_index(receive.19, index=0, id=11, pos=[(0,13,13)]) add.13: bits[32] = add(a, b, id=13, pos=[(0,14,36)]) - tok__3: token = send(tok__2, add.13, channel=test_package__output, id=19) + tok__3: token = send(tok__2, add.13, channel=test_package__output, id=20) } diff --git a/xls/passes/BUILD b/xls/passes/BUILD index 7ccc046cea..8a2e586961 100644 --- a/xls/passes/BUILD +++ b/xls/passes/BUILD @@ -1792,9 +1792,11 @@ cc_library( "//xls/ir:node_util", "//xls/ir:op", "//xls/ir:source_location", + "//xls/ir:state_element", "//xls/ir:type", "//xls/ir:value", "//xls/ir:value_utils", + "@com_google_absl//absl/algorithm:container", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", diff --git a/xls/passes/optimization_pass_pipeline.cc b/xls/passes/optimization_pass_pipeline.cc index fa08cb3089..7246972d19 100644 --- a/xls/passes/optimization_pass_pipeline.cc +++ b/xls/passes/optimization_pass_pipeline.cc @@ -157,6 +157,8 @@ PreInliningPassGroup::PreInliningPassGroup() "pre-inlining passes") { Add(); Add(); + // TODO: google/xls#1795 - Remove once full transition to next-op is complete. + Add(); // At this stage in the pipeline only optimizations up to level 2 should // run. 'opt_level' is the maximum level of optimization which should be run // in the entire pipeline so set the level of the simplification pass to the @@ -225,6 +227,7 @@ class PostInliningOptPassGroup : public OptimizationCompoundPass { Add(); // Simplify the adapter procs before inlining. Add>(); + // TODO(allight): It might be worthwhile to split the pipeline here as well. // Since proc-inlining is being phased out in favor of multi-proc codegen // however this seems unnecessary. @@ -236,8 +239,6 @@ class PostInliningOptPassGroup : public OptimizationCompoundPass { Add(); Add(); Add(); - // TODO(allight): Remove once full transition to next-op is complete. - Add(); Add>(); Add(); diff --git a/xls/passes/proc_inlining_pass.cc b/xls/passes/proc_inlining_pass.cc index cbf7f06578..c1e05dd81d 100644 --- a/xls/passes/proc_inlining_pass.cc +++ b/xls/passes/proc_inlining_pass.cc @@ -24,6 +24,7 @@ #include #include +#include "absl/algorithm/container.h" #include "absl/container/btree_set.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" @@ -49,6 +50,7 @@ #include "xls/ir/op.h" #include "xls/ir/proc.h" #include "xls/ir/source_location.h" +#include "xls/ir/state_element.h" #include "xls/ir/topo_sort.h" #include "xls/ir/type.h" #include "xls/ir/value.h" @@ -1782,6 +1784,95 @@ absl::Status SetProcState(Proc* proc, return absl::OkStatus(); } +absl::Status ConvertToNextStateElements(Proc* proc) { + for (int64_t index = 0; index < proc->GetStateElementCount(); ++index) { + StateElement* state_element = proc->GetStateElement(index); + StateRead* state_read = proc->GetStateRead(index); + const absl::btree_set& nexts = + proc->next_values(state_read); + if (nexts.empty()) { + continue; + } + + // Check that either all or none of the next_value nodes are predicated. + XLS_RET_CHECK(absl::c_all_of(nexts, [&](Next* next) { + return next->predicate().has_value() == + (*nexts.begin())->predicate().has_value(); + })); + const bool predicated = + !nexts.empty() && (*nexts.begin())->predicate().has_value(); + if (!predicated) { + XLS_RET_CHECK_EQ(nexts.size(), 1); + } + + std::vector values; + std::optional> predicates; + values.reserve(nexts.size()); + if (predicated) { + predicates.emplace(); + predicates->reserve(nexts.size()); + } + for (Next* next : nexts) { + values.push_back(next->value()); + if (predicated) { + XLS_RET_CHECK(next->predicate().has_value()); + predicates->push_back(*next->predicate()); + } + } + + Node* next_state; + if (predicated) { + SourceInfo loc = state_read->loc(); + absl::c_reverse(*predicates); + XLS_ASSIGN_OR_RETURN( + Node * selector, + proc->MakeNodeWithName( + loc, *predicates, + absl::StrCat(state_element->name(), "_next_selector"))); + XLS_ASSIGN_OR_RETURN( + next_state, + proc->MakeNodeWithName( + loc, selector, /*cases=*/values, /*default_value=*/state_read, + absl::StrCat(state_element->name(), "_next_state"))); + } else { + next_state = values.front(); + } + + std::vector nexts_to_remove(nexts.begin(), nexts.end()); + for (Next* next : nexts_to_remove) { + XLS_RETURN_IF_ERROR( + next->ReplaceUsesWithNew(absl::Span{}).status()); + XLS_RETURN_IF_ERROR(proc->RemoveNode(next)); + } + XLS_RETURN_IF_ERROR(proc->SetNextStateElement(index, next_state)); + } + + return absl::OkStatus(); +} + +absl::Status ConvertToNextValueNodes(Proc* proc) { + for (int64_t index = 0; index < proc->GetStateElementCount(); ++index) { + StateRead* state_read = proc->GetStateRead(index); + if (proc->GetNextStateElement(index) == state_read) { + continue; + } + + // Nontrivial next-state element; switch it to a next-value node, then + // remove it so we pass verification. + CHECK(proc->next_values(state_read).empty()); + Node* next_value = proc->GetNextStateElement(index); + XLS_RETURN_IF_ERROR( + proc->MakeNodeWithName( + state_read->loc(), state_read, + /*value=*/next_value, + /*predicate=*/std::nullopt, + absl::StrCat(state_read->state_element()->name(), "_next")) + .status()); + XLS_RETURN_IF_ERROR(proc->SetNextStateElement(index, state_read)); + } + return absl::OkStatus(); +} + } // namespace absl::StatusOr ProcInliningPass::RunInternal( @@ -1810,6 +1901,12 @@ absl::StatusOr ProcInliningPass::RunInternal( procs_to_inline.push_back(proc.get()); } + for (Proc* proc : procs_to_inline) { + XLS_RETURN_IF_ERROR(ConvertToNextStateElements(proc)); + } + + VLOG(3) << "After switching to next-state elements:\n" << p->DumpIr(); + { int64_t top_ii = 1; if (top_func_base->GetInitiationInterval().has_value()) { @@ -1952,6 +2049,10 @@ absl::StatusOr ProcInliningPass::RunInternal( VLOG(3) << "After deleting inlined I/O:\n" << p->DumpIr(); + XLS_RETURN_IF_ERROR(ConvertToNextValueNodes(container_proc)); + + VLOG(3) << "After switching back to next-value nodes:\n" << p->DumpIr(); + return true; } diff --git a/xls/passes/proc_inlining_pass_test.cc b/xls/passes/proc_inlining_pass_test.cc index 9a3957a40f..8d30115bd8 100644 --- a/xls/passes/proc_inlining_pass_test.cc +++ b/xls/passes/proc_inlining_pass_test.cc @@ -213,11 +213,10 @@ class ProcInliningPassTest : public IrTestBase { b.SendIf(out, b.TupleIndex(rcv, 0), cnt_last, data); - BValue next_cnt = b.Select(cnt_last, b.Literal(UBits(0, 32)), - b.Add(cnt, b.Literal(UBits(1, 32)))); - BValue next_data = b.Select(cnt_eq_0, b.TupleIndex(rcv, 1), data); - - return b.Build({next_cnt, next_data}); + b.Next(cnt, b.Select(cnt_last, b.Literal(UBits(0, 32)), + b.Add(cnt, b.Literal(UBits(1, 32))))); + b.Next(data, b.Select(cnt_eq_0, b.TupleIndex(rcv, 1), data)); + return b.Build(); } // Make a proc which receives data on channel `in` and sends back twice the @@ -297,16 +296,15 @@ class ProcInliningPassTest : public IrTestBase { BValue rcv_token = b.TupleIndex(rcv, 0); BValue data = b.TupleIndex(rcv, 1, loc, "data"); - BValue next_i = - b.Select(is_last_iteration, zero, b.Add(i, one), loc, "next_i"); + b.Next(i, b.Select(is_last_iteration, zero, b.Add(i, one), loc, "next_i")); BValue updated_accum = b.Select(is_first_iteration, data, b.Add(accum, i), loc, "updated_accum"); - BValue next_accum = - b.Select(is_last_iteration, zero, updated_accum, loc, "next_accum"); + b.Next(accum, + b.Select(is_last_iteration, zero, updated_accum, loc, "next_accum")); b.SendIf(output_ch, rcv_token, is_last_iteration, updated_accum); - return b.Build({next_i, next_accum}); + return b.Build(); } // Make a proc which receives data values `x` and `y` and sends the sum and @@ -384,7 +382,10 @@ class ProcInliningPassTest : public IrTestBase { b.SendIf(out, b.TupleIndex(rcv_x_y, 0), cnt, b.Tuple({x_plus_x_accum, y_plus_y_accum})); - return b.Build({b.Not(cnt), x_plus_x_accum, y_plus_y_accum}); + b.Next(cnt, b.Not(cnt)); + b.Next(x_accum, x_plus_x_accum); + b.Next(y_accum, y_plus_y_accum); + return b.Build(); } // Simple proc that arbitrates between inputs, with lower-index inputs being @@ -890,7 +891,8 @@ TEST_F(ProcInliningPassTest, NestedProcsTrivialInnerLoop) { BValue rcv_from_a = bb.ReceiveIf(a_to_b, bb.Literal(Value::Token()), st); bb.SendIf(b_to_a, bb.TupleIndex(rcv_from_a, 0), bb.Not(st), bb.Literal(UBits(42, 32))); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -933,7 +935,8 @@ TEST_F(ProcInliningPassTest, NestedProcsIota) { ProcBuilder bb("B", p.get()); BValue st = bb.StateElement("st", Value(UBits(42, 32))); bb.Send(b_to_a, bb.Literal(Value::Token()), bb.GetStateParam(0)); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 32)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -973,7 +976,8 @@ TEST_F(ProcInliningPassTest, NestedProcsOddIota) { bb.SendIf(b_to_a, bb.Literal(Value::Token()), bb.BitSlice(bb.GetStateParam(0), /*start=*/0, /*width=*/1), bb.GetStateParam(0)); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 32)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -1031,7 +1035,8 @@ TEST_F(ProcInliningPassTest, SynchronizedNestedProcs) { BValue rcv_from_b = ab.ReceiveIf(b_to_a, send_to_b, ab.GetStateParam(0)); ab.SendIf(ch_out, ab.TupleIndex(rcv_from_b, 0), ab.GetStateParam(0), ab.TupleIndex(rcv_from_b, 1)); - XLS_ASSERT_OK(ab.Build({ab.Not(st)})); + ab.Next(st, ab.Not(st)); + XLS_ASSERT_OK(ab.Build()); } { @@ -1048,7 +1053,8 @@ TEST_F(ProcInliningPassTest, SynchronizedNestedProcs) { BValue rcv_from_a = bb.ReceiveIf(a_to_b, bb.Literal(Value::Token()), st); bb.SendIf(b_to_a, bb.TupleIndex(rcv_from_a, 0), st, bb.Add(bb.TupleIndex(rcv_from_a, 1), bb.Literal(UBits(42, 32)))); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -1472,7 +1478,9 @@ TEST_F(ProcInliningPassTest, DoubleNestedLoops) { BValue rcv_from_c = bb.ReceiveIf(c_to_b, send_to_c, bb.Not(cnt)); bb.SendIf(b_to_a, bb.TupleIndex(rcv_from_c, 0), bb.Not(cnt), bb.TupleIndex(rcv_from_c, 1)); - XLS_ASSERT_OK(bb.Build({bb.Not(cnt), next_accum})); + bb.Next(cnt, bb.Not(cnt)); + bb.Next(accum, next_accum); + XLS_ASSERT_OK(bb.Build()); } { @@ -1504,9 +1512,9 @@ TEST_F(ProcInliningPassTest, DoubleNestedLoops) { cb.SendIf(c_to_b, cb.TupleIndex(rcv_from_b, 0), cnt_eq_3, next_accum); - BValue next_cnt = cb.Add(cnt, cb.Literal(UBits(1, 2))); - - XLS_ASSERT_OK(cb.Build({next_cnt, next_accum})); + cb.Next(cnt, cb.Add(cnt, cb.Literal(UBits(1, 2)))); + cb.Next(accum, next_accum); + XLS_ASSERT_OK(cb.Build()); } // Output is sum of all inputs so far plus 15. @@ -1921,7 +1929,8 @@ TEST_F(ProcInliningPassTest, DelayedReceiveWithDataLossFifoDepth0) { BValue rcv_from_a = bb.ReceiveIf(a_to_b, bb.Literal(Value::Token()), st); bb.SendIf(b_to_a, bb.TupleIndex(rcv_from_a, 0), st, bb.Add(bb.TupleIndex(rcv_from_a, 1), bb.Literal(UBits(42, 32)))); - XLS_ASSERT_OK(bb.Build({bb.Literal(UBits(1, 1))})); + bb.Next(st, bb.Literal(UBits(1, 1))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -1981,7 +1990,8 @@ TEST_F(ProcInliningPassTest, DelayedReceiveWithNoDataLossFifoDepth1Variant0) { BValue rcv_from_a = bb.ReceiveIf(a_to_b, bb.Literal(Value::Token()), st); bb.SendIf(b_to_a, bb.TupleIndex(rcv_from_a, 0), st, bb.Add(bb.TupleIndex(rcv_from_a, 1), bb.Literal(UBits(42, 32)))); - XLS_ASSERT_OK(bb.Build({bb.Literal(UBits(1, 1))})); + bb.Next(st, bb.Literal(UBits(1, 1))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -2040,7 +2050,8 @@ TEST_F(ProcInliningPassTest, DelayedReceiveWithNoDataLossFifoDepth1Variant1) { bb.UGe(st, bb.Literal(UBits(1, 32)))); bb.Send(b_to_a, bb.TupleIndex(rcv_from_a, 0), bb.Add(bb.TupleIndex(rcv_from_a, 1), bb.Literal(UBits(42, 32)))); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 32)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -2097,7 +2108,8 @@ TEST_F(ProcInliningPassTest, DelayedReceiveWithDataLossFifoDepth1) { bb.UGe(st, bb.Literal(UBits(2, 32)))); bb.Send(b_to_a, bb.TupleIndex(rcv_from_a, 0), bb.Add(bb.TupleIndex(rcv_from_a, 1), bb.Literal(UBits(42, 32)))); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 32)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -2157,7 +2169,8 @@ TEST_F(ProcInliningPassTest, DataLoss) { BValue rcv_from_b = ab.ReceiveIf(b_to_a, send_to_b, st); ab.SendIf(ch_out, ab.TupleIndex(rcv_from_b, 0), st, ab.TupleIndex(rcv_from_b, 1)); - XLS_ASSERT_OK(ab.Build({ab.Not(st)})); + ab.Next(st, ab.Not(st)); + XLS_ASSERT_OK(ab.Build()); XLS_ASSERT_OK(MakeLoopbackProc("B", a_to_b, b_to_a, p.get()).status()); @@ -2212,7 +2225,8 @@ TEST_F(ProcInliningPassTest, DataLossDueToReceiveNotActivated) { BValue send0 = ab.SendIf(a_to_b0, ab.TupleIndex(rcv, 0), st, ab.Literal(UBits(0, 32))); ab.Send(a_to_b1, send0, ab.Literal(UBits(0, 32))); - XLS_ASSERT_OK(ab.Build({ab.Literal(UBits(1, 1))}).status()); + ab.Next(st, ab.Literal(UBits(1, 1))); + XLS_ASSERT_OK(ab.Build().status()); } { @@ -2979,7 +2993,8 @@ TEST_F(ProcInliningPassTest, ReceivedValueSentAndNext) { ab.Send(ch_out, ab.TupleIndex(rcv_from_b, 0), ab.Add(ab.TupleIndex(rcv_from_b, 1), st)); - XLS_ASSERT_OK(ab.Build({ab.Identity(rcv_data)}).status()); + ab.Next(st, ab.Identity(rcv_data)); + XLS_ASSERT_OK(ab.Build().status()); } XLS_ASSERT_OK( @@ -3025,7 +3040,8 @@ TEST_F(ProcInliningPassTest, OffsetSendAndReceive) { BValue send_cond = ab.Eq(ab.And(st, ab.Literal(UBits(0xf, 32))), ab.Literal(UBits(0, 32))); ab.SendIf(a_to_b, ab.Literal(Value::Token()), send_cond, st); - XLS_ASSERT_OK(ab.Build({ab.Add(st, ab.Literal(UBits(1, 32)))})); + ab.Next(st, ab.Add(st, ab.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(ab.Build()); } { @@ -3045,7 +3061,8 @@ TEST_F(ProcInliningPassTest, OffsetSendAndReceive) { BValue rcv_token = bb.TupleIndex(rcv, 0); BValue rcv_data = bb.TupleIndex(rcv, 1); bb.SendIf(ch_out, rcv_token, cond, rcv_data); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 32)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 32)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3101,7 +3118,8 @@ TEST_F(ProcInliningPassTest, DISABLED_InliningProducesCycle) { BValue rcv_data = ab.TupleIndex(rcv, 1); BValue send_to_b = ab.Send(a_to_b, rcv_token, rcv_data); ab.Send(ch_out, send_to_b, rcv_data); - XLS_ASSERT_OK(ab.Build({ab.Literal(UBits(1, 1))})); + ab.Next(st, ab.Literal(UBits(1, 1))); + XLS_ASSERT_OK(ab.Build()); } { @@ -3158,7 +3176,8 @@ TEST_F(ProcInliningPassTest, MultipleSends) { BValue input = ab.Receive(ch_in); ab.SendIf(a_to_b, st, ab.Add(input, ab.Literal(UBits(10, 32)))); ab.SendIf(a_to_b, ab.Not(st), input); - XLS_ASSERT_OK(ab.Build({ab.Not(st)})); + ab.Next(st, ab.Not(st)); + XLS_ASSERT_OK(ab.Build()); } XLS_ASSERT_OK(MakeLoopbackProc("B", a_to_b, ch_out, p.get()).status()); @@ -3206,7 +3225,8 @@ TEST_F(ProcInliningPassTest, MultipleSendsInDifferentOrder) { BValue input = ab.Receive(ch_in); ab.SendIf(a_to_b, ab.Not(st), input); ab.SendIf(a_to_b, st, ab.Add(input, ab.Literal(UBits(10, 32)))); - XLS_ASSERT_OK(ab.Build({ab.Not(st)})); + ab.Next(st, ab.Not(st)); + XLS_ASSERT_OK(ab.Build()); } XLS_ASSERT_OK(MakeLoopbackProc("B", a_to_b, ch_out, p.get()).status()); @@ -3257,7 +3277,8 @@ TEST_F(ProcInliningPassTest, MultipleReceivesFifoDepth0) { BValue tmp1 = bb.ReceiveIf(a_to_b, bb.Not(st)); BValue x = bb.Select(st, tmp0, tmp1); bb.Send(ch_out, x); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3306,7 +3327,8 @@ TEST_F(ProcInliningPassTest, MultipleReceivesFifoDepth1) { BValue tmp1 = bb.ReceiveIf(a_to_b, bb.Not(st)); BValue x = bb.Select(st, tmp0, tmp1); bb.Send(ch_out, x); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3363,7 +3385,8 @@ TEST_F(ProcInliningPassTest, MultipleReceivesDoesNotFireEveryTick) { bb.Add(bb.ReceiveIf(a_to_b, st_eq_2), bb.Literal(UBits(2, 32))); BValue x = bb.Select(st, {tmp0, tmp1, tmp2, bb.Literal(UBits(0, 32))}); bb.Send(ch_out, x); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 2)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 2)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3420,7 +3443,8 @@ TEST_F(ProcInliningPassTest, MultipleReceivesDoesNotFireEveryTickFifoDepth0) { bb.Add(bb.ReceiveIf(a_to_b, st_eq_2), bb.Literal(UBits(2, 32))); BValue x = bb.Select(st, {tmp0, tmp1, tmp2, bb.Literal(UBits(0, 32))}); bb.Send(ch_out, x); - XLS_ASSERT_OK(bb.Build({bb.Add(st, bb.Literal(UBits(1, 2)))})); + bb.Next(st, bb.Add(st, bb.Literal(UBits(1, 2)))); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3475,7 +3499,8 @@ TEST_F(ProcInliningPassTest, MultipleSendsAndReceives) { BValue input = ab.Receive(ch_in); ab.SendIf(a_to_b, st, ab.Add(input, ab.Literal(UBits(10, 32)))); ab.SendIf(a_to_b, ab.Not(st), input); - XLS_ASSERT_OK(ab.Build({ab.Not(st)})); + ab.Next(st, ab.Not(st)); + XLS_ASSERT_OK(ab.Build()); } { @@ -3493,7 +3518,8 @@ TEST_F(ProcInliningPassTest, MultipleSendsAndReceives) { BValue tmp1 = bb.ReceiveIf(a_to_b, bb.Not(st)); BValue x = bb.Select(st, tmp0, tmp1); bb.Send(ch_out, x); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3548,7 +3574,8 @@ TEST_F(ProcInliningPassTest, ReceiveIfsWithFalseCondition) { BValue y = bb.ReceiveIf(a_to_b, bb.Not(st)); bb.Send(ch_out0, x); bb.Send(ch_out1, y); - XLS_ASSERT_OK(bb.Build({bb.Not(st)})); + bb.Next(st, bb.Not(st)); + XLS_ASSERT_OK(bb.Build()); } EXPECT_EQ(p->procs().size(), 2); @@ -3627,7 +3654,8 @@ TEST_F(ProcInliningPassTest, ProcsWithNonblockingReceivesWithDroppingProc) { BValue data = b.TupleIndex(recv, 1); b.SendIf(drop_to_arb, recv_token, b.Not(done), data); - XLS_ASSERT_OK(b.Build({b.Literal(UBits(1, /*bit_count=*/1))})); + b.Next(done, b.Literal(UBits(1, 1))); + XLS_ASSERT_OK(b.Build()); } XLS_ASSERT_OK(