diff --git a/xls/ir/channel.cc b/xls/ir/channel.cc index 14007fd0a0..b24b5802eb 100644 --- a/xls/ir/channel.cc +++ b/xls/ir/channel.cc @@ -304,4 +304,11 @@ std::string ChannelReference::ToString() const { absl::StrJoin(keyword_strs, " ")); } +std::string ChannelRefToString(ChannelRef ref) { + if (std::holds_alternative(ref)) { + return std::get(ref)->ToString(); + } + return std::get(ref)->ToString(); +} + } // namespace xls diff --git a/xls/ir/channel.h b/xls/ir/channel.h index b5e2852b1e..dec80485f6 100644 --- a/xls/ir/channel.h +++ b/xls/ir/channel.h @@ -449,6 +449,7 @@ std::string_view ChannelRefName(ChannelRef ref); Type* ChannelRefType(ChannelRef ref); ChannelKind ChannelRefKind(ChannelRef ref); std::optional ChannelRefStrictness(ChannelRef ref); +std::string ChannelRefToString(ChannelRef ref); } // namespace xls diff --git a/xls/ir/ir_matcher.cc b/xls/ir/ir_matcher.cc index 81cb135839..eb843faae4 100644 --- a/xls/ir/ir_matcher.cc +++ b/xls/ir/ir_matcher.cc @@ -40,6 +40,7 @@ #include "xls/ir/node.h" #include "xls/ir/nodes.h" #include "xls/ir/op.h" +#include "xls/ir/proc.h" #include "xls/ir/type.h" #include "xls/ir/value.h" @@ -65,33 +66,25 @@ void NameMatcherInternal::DescribeNegationTo(std::ostream* os) const { } // namespace internal bool ChannelMatcher::MatchAndExplain( - const ::xls::Channel* channel, - ::testing::MatchResultListener* listener) const { - if (channel == nullptr) { - return false; - } - *listener << channel->ToString(); - if (id_.has_value() && channel->id() != id_.value()) { - *listener << absl::StreamFormat(" has incorrect id (%d), expected: %d", - channel->id(), id_.value()); - return false; - } + ::xls::ChannelRef channel, ::testing::MatchResultListener* listener) const { + *listener << ChannelRefToString(channel); if (name_.has_value() && - !name_->MatchAndExplain(std::string{channel->name()}, listener)) { + !name_->MatchAndExplain(std::string{ChannelRefName(channel)}, listener)) { return false; } - if (kind_.has_value() && channel->kind() != kind_.value()) { - *listener << absl::StreamFormat(" has incorrect kind (%s), expected: %s", - ChannelKindToString(channel->kind()), - ChannelKindToString(kind_.value())); + if (kind_.has_value() && ChannelRefKind(channel) != kind_.value()) { + *listener << absl::StreamFormat( + " has incorrect kind (%s), expected: %s", + ChannelKindToString(ChannelRefKind(channel)), + ChannelKindToString(kind_.value())); return false; } if (type_string_.has_value() && - channel->type()->ToString() != type_string_.value()) { + ChannelRefType(channel)->ToString() != type_string_.value()) { *listener << absl::StreamFormat(" has incorrect type (%s), expected: %s", - channel->type()->ToString(), + ChannelRefType(channel)->ToString(), type_string_.value()); return false; } @@ -100,9 +93,6 @@ bool ChannelMatcher::MatchAndExplain( void ChannelMatcher::DescribeTo(::std::ostream* os) const { std::vector pieces; - if (id_.has_value()) { - pieces.push_back(absl::StrFormat("id=%d", id_.value())); - } if (name_.has_value()) { std::stringstream ss; ss << "name=\""; @@ -382,16 +372,17 @@ bool TupleIndexMatcher::MatchAndExplain( } static bool MatchChannel( - std::string_view channel, Package* package, - const ::testing::Matcher& channel_matcher, + std::string_view channel, ::xls::Proc* proc, ::xls::Direction direction, + const ::testing::Matcher<::xls::ChannelRef>& channel_matcher, ::testing::MatchResultListener* listener) { - absl::StatusOr<::xls::Channel*> channel_status = package->GetChannel(channel); + absl::StatusOr<::xls::ChannelRef> channel_status = + proc->GetChannelRef(channel, direction); if (!channel_status.ok()) { *listener << " has an invalid channel name: " << channel; return false; } - ::xls::Channel* ch = channel_status.value(); - return channel_matcher.MatchAndExplain(ch, listener); + ::xls::ChannelRef ch_ref = channel_status.value(); + return channel_matcher.MatchAndExplain(ch_ref, listener); } static std::string_view GetChannelName(const Node* node) { @@ -413,7 +404,18 @@ bool ChannelNodeMatcher::MatchAndExplain( if (!channel_matcher_.has_value()) { return true; } - return MatchChannel(GetChannelName(node), node->package(), + Direction direction; + if (node->Is<::xls::Send>()) { + direction = Direction::kSend; + } else if (node->Is<::xls::Receive>()) { + direction = Direction::kReceive; + } else { + LOG(FATAL) << absl::StrFormat( + "Expected send or receive node, got node `%s` with op `%s`", + node->GetName(), OpToString(node->op())); + } + return MatchChannel(GetChannelName(node), + node->function_base()->AsProcOrDie(), direction, channel_matcher_.value(), listener); } diff --git a/xls/ir/ir_matcher.h b/xls/ir/ir_matcher.h index 03d8c8b0d3..bad6fd2831 100644 --- a/xls/ir/ir_matcher.h +++ b/xls/ir/ir_matcher.h @@ -653,89 +653,74 @@ inline ::testing::Matcher TupleIndex( // which communicate over channels (e.g., send and receive). Supported forms: // // m::Channel(/*name=*/"foo"); -// m::Channel(/*id=*/42); -// m::Channel(ChannelKind::kPort); +// m::Channel(ChannelKind::kStreaming); // m::Channel(node->GetType()); // m::ChannelWithType("bits[32]"); // -class ChannelMatcher - : public ::testing::MatcherInterface { +class ChannelMatcher : public ::testing::MatcherInterface<::xls::ChannelRef> { public: - ChannelMatcher(std::optional id, - std::optional<::testing::Matcher> name, + ChannelMatcher(std::optional<::testing::Matcher> name, std::optional kind, std::optional type_string) - : id_(id), - name_(std::move(name)), - kind_(kind), - type_string_(type_string) {} + : name_(std::move(name)), kind_(kind), type_string_(type_string) {} - bool MatchAndExplain(const ::xls::Channel* channel, + bool MatchAndExplain(::xls::ChannelRef channel, ::testing::MatchResultListener* listener) const override; void DescribeTo(::std::ostream* os) const override; protected: - std::optional id_; std::optional<::testing::Matcher> name_; std::optional kind_; std::optional type_string_; }; -inline ::testing::Matcher Channel() { - return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, std::nullopt, std::nullopt, std::nullopt)); -} - -inline ::testing::Matcher Channel( - std::optional id) { +inline ::testing::Matcher<::xls::ChannelRef> Channel() { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - id, std::nullopt, std::nullopt, std::nullopt)); + std::nullopt, std::nullopt, std::nullopt)); } template -inline ::testing::Matcher Channel( - std::optional id, T name, - std::optional kind = std::nullopt, - std::optional type_ = std::nullopt) +inline ::testing::Matcher<::xls::ChannelRef> Channel( + T name, std::optional kind, + std::optional type_) requires(std::is_convertible_v) { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - id, std::string{name}, kind, + std::string{name}, kind, type_.has_value() ? std::optional(type_.value()->ToString()) : std::nullopt)); } template -inline ::testing::Matcher Channel(T name) +inline ::testing::Matcher<::xls::ChannelRef> Channel(T name) requires(std::is_convertible_v) { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, internal::NameMatcherInternal(std::string_view{name}), - std::nullopt, std::nullopt)); + internal::NameMatcherInternal(std::string_view{name}), std::nullopt, + std::nullopt)); } -inline ::testing::Matcher Channel( +inline ::testing::Matcher<::xls::ChannelRef> Channel( const ::testing::Matcher& matcher) { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, matcher, std::nullopt, std::nullopt)); + matcher, std::nullopt, std::nullopt)); } -inline ::testing::Matcher Channel(ChannelKind kind) { - return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, std::nullopt, kind, std::nullopt)); +inline ::testing::Matcher<::xls::ChannelRef> Channel(ChannelKind kind) { + return ::testing::MakeMatcher( + new ::xls::op_matchers::ChannelMatcher(std::nullopt, kind, std::nullopt)); } -inline ::testing::Matcher Channel( - const ::xls::Type* type_) { +inline ::testing::Matcher<::xls::ChannelRef> Channel(const ::xls::Type* type_) { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, std::nullopt, std::nullopt, type_->ToString())); + std::nullopt, std::nullopt, type_->ToString())); } -inline ::testing::Matcher ChannelWithType( +inline ::testing::Matcher<::xls::ChannelRef> ChannelWithType( std::string_view type_string) { return ::testing::MakeMatcher(new ::xls::op_matchers::ChannelMatcher( - std::nullopt, std::nullopt, std::nullopt, type_string)); + std::nullopt, std::nullopt, type_string)); } // Abstract base class for matchers of nodes which use channels. @@ -743,7 +728,7 @@ class ChannelNodeMatcher : public NodeMatcher { public: ChannelNodeMatcher( Op op, absl::Span> operands, - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : NodeMatcher(op, operands), channel_matcher_(std::move(channel_matcher)) {} @@ -752,34 +737,34 @@ class ChannelNodeMatcher : public NodeMatcher { void DescribeTo(::std::ostream* os) const override; private: - std::optional<::testing::Matcher> channel_matcher_; + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher_; }; // Send matcher. Supported forms: // // EXPECT_THAT(foo, m::Send()); -// EXPECT_THAT(foo, m::Send(m::Channel(42))); +// EXPECT_THAT(foo, m::Send(m::Channel("foo"))); // EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(), -// m::Channel(42))); +// m::Channel("bar"))); // EXPECT_THAT(foo, m::Send(/*token=*/m::Param(), /*data=*/m::Param(), // /*predicate=*/m::Param(), -// m::Channel(42))); +// m::Channel("bazz"))); class SendMatcher : public ChannelNodeMatcher { public: explicit SendMatcher( - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher(Op::kSend, {}, std::move(channel_matcher)) {} explicit SendMatcher( ::testing::Matcher token, ::testing::Matcher data, - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher(Op::kSend, {std::move(token), std::move(data)}, std::move(channel_matcher)) {} explicit SendMatcher( ::testing::Matcher token, ::testing::Matcher data, ::testing::Matcher predicate, - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher( Op::kSend, {std::move(token), std::move(data), std::move(predicate)}, @@ -787,7 +772,7 @@ class SendMatcher : public ChannelNodeMatcher { }; inline ::testing::Matcher Send( - std::optional<::testing::Matcher> channel_matcher = + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher = std::nullopt) { return ::xls::op_matchers::SendMatcher(std::move(channel_matcher)); } @@ -795,7 +780,7 @@ inline ::testing::Matcher Send( inline ::testing::Matcher Send( ::testing::Matcher token, ::testing::Matcher data, - std::optional<::testing::Matcher> channel_matcher = + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher = std::nullopt) { return ::xls::op_matchers::SendMatcher(std::move(token), std::move(data), std::move(channel_matcher)); @@ -805,7 +790,7 @@ inline ::testing::Matcher Send( ::testing::Matcher token, ::testing::Matcher data, ::testing::Matcher predicate, - std::optional<::testing::Matcher> channel_matcher = + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher = std::nullopt) { return ::xls::op_matchers::SendMatcher(std::move(token), std::move(data), std::move(predicate), @@ -822,31 +807,31 @@ inline ::testing::Matcher Send( class ReceiveMatcher : public ChannelNodeMatcher { public: explicit ReceiveMatcher( - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher(Op::kReceive, {}, std::move(channel_matcher)) {} explicit ReceiveMatcher( ::testing::Matcher token, - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher(Op::kReceive, {std::move(token)}, std::move(channel_matcher)) {} explicit ReceiveMatcher( ::testing::Matcher token, ::testing::Matcher predicate, - std::optional<::testing::Matcher> channel_matcher) + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher) : ChannelNodeMatcher(Op::kReceive, {std::move(token), std::move(predicate)}, std::move(channel_matcher)) {} }; inline ::testing::Matcher Receive( - std::optional<::testing::Matcher> channel_matcher = + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher = std::nullopt) { return ::xls::op_matchers::ReceiveMatcher(std::move(channel_matcher)); } inline ::testing::Matcher Receive( ::testing::Matcher token, - std::optional<::testing::Matcher> channel_matcher = + std::optional<::testing::Matcher<::xls::ChannelRef>> channel_matcher = std::nullopt) { return ::xls::op_matchers::ReceiveMatcher(std::move(token), std::move(channel_matcher)); @@ -855,7 +840,7 @@ inline ::testing::Matcher Receive( inline ::testing::Matcher Receive( ::testing::Matcher token, ::testing::Matcher predicate, - ::testing::Matcher channel_matcher) { + ::testing::Matcher<::xls::ChannelRef> channel_matcher) { return ::xls::op_matchers::ReceiveMatcher( std::move(token), std::move(predicate), channel_matcher); } diff --git a/xls/ir/ir_matcher_test.cc b/xls/ir/ir_matcher_test.cc index 41876c25ad..e70b5ca161 100644 --- a/xls/ir/ir_matcher_test.cc +++ b/xls/ir/ir_matcher_test.cc @@ -363,15 +363,41 @@ TEST(IrMatchersTest, SendOps) { XLS_ASSERT_OK(b.Build({b.AfterAll({send, send_if}), state}).status()); EXPECT_THAT(send.node(), m::Send()); - EXPECT_THAT(send.node(), m::Send(m::Channel(42))); + EXPECT_THAT(send.node(), m::Send(m::Channel("ch42"))); EXPECT_THAT(send.node(), m::Send(m::Name("my_token"), m::Name("my_state"), - m::Channel(42))); + m::Channel("ch42"))); EXPECT_THAT(send.node(), m::Send(m::ChannelWithType("bits[32]"))); EXPECT_THAT(send_if.node(), m::Send()); - EXPECT_THAT(send_if.node(), m::Send(m::Channel(123))); + EXPECT_THAT(send_if.node(), m::Send(m::Channel("ch123"))); EXPECT_THAT(send_if.node(), m::Send(m::Name("my_token"), m::Name("my_state"), - m::Literal(), m::Channel(123))); + m::Literal(), m::Channel("ch123"))); + EXPECT_THAT(send_if.node(), m::Send(m::ChannelWithType("bits[32]"))); +} + +TEST(IrMatchersTest, ProcScopedChannels) { + Package p("p"); + ProcBuilder b(NewStyleProc(), "test_proc", &p); + auto my_token = b.StateElement("my_token", Value::Token()); + auto state = b.StateElement("my_state", Value(UBits(333, 32))); + XLS_ASSERT_OK_AND_ASSIGN(ChannelReferences ch42, + b.AddChannel("ch42", p.GetBitsType(32))); + XLS_ASSERT_OK_AND_ASSIGN(SendChannelReference * ch123, + b.AddOutputChannel("ch123", p.GetBitsType(32))); + auto send = b.Send(ch42.send_ref, my_token, state); + auto send_if = b.SendIf(ch123, my_token, b.Literal(UBits(1, 1)), {state}); + XLS_ASSERT_OK(b.Build({b.AfterAll({send, send_if}), state}).status()); + + EXPECT_THAT(send.node(), m::Send()); + EXPECT_THAT(send.node(), m::Send(m::Channel("ch42"))); + EXPECT_THAT(send.node(), m::Send(m::Name("my_token"), m::Name("my_state"), + m::Channel("ch42"))); + EXPECT_THAT(send.node(), m::Send(m::ChannelWithType("bits[32]"))); + + EXPECT_THAT(send_if.node(), m::Send()); + EXPECT_THAT(send_if.node(), m::Send(m::Channel("ch123"))); + EXPECT_THAT(send_if.node(), m::Send(m::Name("my_token"), m::Name("my_state"), + m::Literal(), m::Channel("ch123"))); EXPECT_THAT(send_if.node(), m::Send(m::ChannelWithType("bits[32]"))); } @@ -403,7 +429,7 @@ TEST(IrMatchersTest, ReceiveOps) { .status()); EXPECT_THAT(receive.node(), m::Receive()); - EXPECT_THAT(receive.node(), m::Receive(m::Channel(42))); + EXPECT_THAT(receive.node(), m::Receive(m::Channel("ch42"))); EXPECT_THAT(receive.node(), m::Receive(m::Name("my_token"), m::Channel("ch42"))); EXPECT_THAT(receive.node(), m::Receive(m::Name("my_token"), @@ -411,7 +437,7 @@ TEST(IrMatchersTest, ReceiveOps) { EXPECT_THAT(receive.node(), m::Receive(m::ChannelWithType("bits[32]"))); EXPECT_THAT(receive_if.node(), m::Receive()); - EXPECT_THAT(receive_if.node(), m::Receive(m::Channel(123))); + EXPECT_THAT(receive_if.node(), m::Receive(m::Channel("ch123"))); EXPECT_THAT(receive_if.node(), m::Receive(m::Name("my_token"), m::Literal(), m::Channel("ch123"))); EXPECT_THAT(receive_if.node(), @@ -419,8 +445,6 @@ TEST(IrMatchersTest, ReceiveOps) { EXPECT_THAT(receive_if.node(), m::Receive(m::ChannelWithType("bits[32]"))); // Mismatch conditions. - EXPECT_THAT(Explain(receive.node(), m::Receive(m::Channel(444))), - HasSubstr("has incorrect id (42), expected: 444")); EXPECT_THAT(Explain(receive.node(), m::Receive(m::Channel("foobar"))), HasSubstr("ch42 has incorrect name, expected: foobar.")); EXPECT_THAT( diff --git a/xls/ir/proc.cc b/xls/ir/proc.cc index e35e4d330a..f5b60066c7 100644 --- a/xls/ir/proc.cc +++ b/xls/ir/proc.cc @@ -625,6 +625,14 @@ absl::StatusOr Proc::GetChannel(std::string_view name) { "No channel with name `%s` in proc `%s`", name, this->name())); } +absl::StatusOr Proc::GetChannelRef(std::string_view name, + Direction direction) { + if (is_new_style_proc()) { + return GetChannelReference(name, direction); + } + return package()->GetChannel(name); +} + bool Proc::ChannelIsOwnedByProc(Channel* channel) { CHECK(is_new_style_proc()); auto it = channels_.find(channel->name()); diff --git a/xls/ir/proc.h b/xls/ir/proc.h index b859a7a2ed..7360663c91 100644 --- a/xls/ir/proc.h +++ b/xls/ir/proc.h @@ -247,9 +247,15 @@ class Proc : public FunctionBase { absl::StatusOr AddChannel( std::unique_ptr channel); - // Returns the channel with the given name defined in the proc. + // Returns the channel with the given name defined in the proc. Only can be + // called for new style procs. absl::StatusOr GetChannel(std::string_view name); + // Returns the ChannelRef referring to the global channel or proc-scoped + // channel (new-style procs) with the given name. + absl::StatusOr GetChannelRef(std::string_view name, + Direction direction); + bool ChannelIsOwnedByProc(Channel* channel); // Add input/output channels to the interfacce of the proc. diff --git a/xls/passes/ram_rewrite_pass_test.cc b/xls/passes/ram_rewrite_pass_test.cc index 89fbfdf7d4..2a48b1c597 100644 --- a/xls/passes/ram_rewrite_pass_test.cc +++ b/xls/passes/ram_rewrite_pass_test.cc @@ -838,13 +838,11 @@ TEST_F(RamRewritePassTest, SingleAbstractTo1RWRewriteProcScoped) { EXPECT_THAT(Run(p.get(), ram_rewrites), IsOkAndHolds(true)); EXPECT_EQ(p->procs().size(), 1); - XLS_ASSERT_OK_AND_ASSIGN(ChannelReference * req_ref, - proc->GetSendChannelReference("ram_1rw_req")); - EXPECT_EQ(req_ref->type()->ToString(), - "(bits[10], bits[32], (), (), bits[1], bits[1])"); - XLS_ASSERT_OK_AND_ASSIGN(ChannelReference * resp_ref, - proc->GetReceiveChannelReference("ram_1rw_resp")); - EXPECT_EQ(resp_ref->type()->ToString(), "(bits[32])"); + EXPECT_THAT(proc->GetSendChannelReference("ram_1rw_req"), + IsOkAndHolds(m::ChannelWithType( + "(bits[10], bits[32], (), (), bits[1], bits[1])"))); + EXPECT_THAT(proc->GetReceiveChannelReference("ram_1rw_resp"), + IsOkAndHolds(m::ChannelWithType("(bits[32])"))); } TEST_F(RamRewritePassTest, SingleAbstractTo1R1WRewriteProcScoped) { @@ -888,21 +886,15 @@ TEST_F(RamRewritePassTest, SingleAbstractTo1R1WRewriteProcScoped) { EXPECT_THAT(Run(p.get(), ram_rewrites), IsOkAndHolds(true)); EXPECT_EQ(p->procs().size(), 1); - XLS_ASSERT_OK_AND_ASSIGN(ChannelReference * read_req_ref, - proc->GetSendChannelReference("ram_1r1w_read_req")); - EXPECT_EQ(read_req_ref->type()->ToString(), "(bits[10], ())"); - XLS_ASSERT_OK_AND_ASSIGN( - ChannelReference * read_resp_ref, - proc->GetReceiveChannelReference("ram_1r1w_read_resp")); - EXPECT_EQ(read_resp_ref->type()->ToString(), "(bits[32])"); - - XLS_ASSERT_OK_AND_ASSIGN(ChannelReference * write_req_ref, - proc->GetSendChannelReference("ram_1r1w_write_req")); - EXPECT_EQ(write_req_ref->type()->ToString(), "(bits[10], bits[32], ())"); - XLS_ASSERT_OK_AND_ASSIGN( - ChannelReference * write_resp_ref, - proc->GetReceiveChannelReference("ram_1r1w_write_completion")); - EXPECT_EQ(write_resp_ref->type()->ToString(), "()"); + EXPECT_THAT(proc->GetSendChannelReference("ram_1r1w_read_req"), + IsOkAndHolds(m::ChannelWithType("(bits[10], ())"))); + EXPECT_THAT(proc->GetReceiveChannelReference("ram_1r1w_read_resp"), + IsOkAndHolds(m::ChannelWithType("(bits[32])"))); + + EXPECT_THAT(proc->GetSendChannelReference("ram_1r1w_write_req"), + IsOkAndHolds(m::ChannelWithType("(bits[10], bits[32], ())"))); + EXPECT_THAT(proc->GetReceiveChannelReference("ram_1r1w_write_completion"), + IsOkAndHolds(m::ChannelWithType("()"))); } } // namespace diff --git a/xls/passes/useless_io_removal_pass_test.cc b/xls/passes/useless_io_removal_pass_test.cc index 7880d7c847..6852a7f4a3 100644 --- a/xls/passes/useless_io_removal_pass_test.cc +++ b/xls/passes/useless_io_removal_pass_test.cc @@ -170,8 +170,9 @@ TEST_F(UselessIORemovalPassTest, RemoveReceiveIfLiteralFalse) { EXPECT_EQ(proc->node_count(), 8); EXPECT_THAT(Run(p.get()), IsOkAndHolds(true)); EXPECT_EQ(proc->node_count(), 8); - auto tuple = m::Tuple(m::TupleIndex(m::Receive(m::Param("tkn"), channel), 0), - m::Literal(0)); + auto tuple = m::Tuple( + m::TupleIndex(m::Receive(m::Param("tkn"), m::Channel("test_channel")), 0), + m::Literal(0)); EXPECT_THAT(proc->GetNextStateElement(0), m::TupleIndex(tuple, 0)); EXPECT_THAT(proc->GetNextStateElement(1), m::TupleIndex(tuple, 1)); } @@ -214,7 +215,7 @@ TEST_F(UselessIORemovalPassTest, RemoveReceivePredIfLiteralTrue) { EXPECT_EQ(proc->node_count(), 6); EXPECT_THAT(Run(p.get()), IsOkAndHolds(true)); EXPECT_EQ(proc->node_count(), 5); - auto tuple = m::Receive(m::Param("tkn"), channel); + auto tuple = m::Receive(m::Param("tkn"), m::Channel("test_channel")); EXPECT_THAT(proc->GetNextStateElement(0), m::TupleIndex(tuple, 0)); EXPECT_THAT(proc->GetNextStateElement(1), m::TupleIndex(tuple, 1)); }