Skip to content

Commit 626b119

Browse files
allightcopybara-github
authored andcommitted
Add Trace and Cover handling to ProcTestUtils.
Implement HandleTrace and HandleCover methods in the ProcTestUtils class. Trace nodes are cloned with updated operands. Cover nodes are cloned and their labels are modified to include the activation index. PiperOrigin-RevId: 861804730
1 parent b6274e9 commit 626b119

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

xls/ir/proc_testutils.cc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,25 @@ class UnrollProcVisitor final : public DfsVisitorWithDefault {
9292
return absl::OkStatus();
9393
}
9494

95+
absl::Status HandleTrace(Trace* t) override {
96+
XLS_RETURN_IF_ERROR(fb_.GetError());
97+
std::vector<Node*> new_ops{fb_.Literal(Value::Token()).node()};
98+
for (Node* v : t->operands().subspan(1)) {
99+
new_ops.push_back(values_[{v, activation_}].node());
100+
}
101+
XLS_ASSIGN_OR_RETURN(Node * new_node,
102+
t->CloneInNewFunction(new_ops, fb_.function()));
103+
values_[{t, activation_}] = BValue(new_node, &fb_);
104+
return absl::OkStatus();
105+
}
106+
absl::Status HandleCover(Cover* c) override {
107+
XLS_RETURN_IF_ERROR(DefaultHandler(c));
108+
Cover* new_cover = values_[{c, activation_}].node()->As<Cover>();
109+
new_cover->set_label(
110+
absl::StrFormat("%s_act%d_cover", c->GetName(), activation_));
111+
return absl::OkStatus();
112+
}
95113
// Asserts are kept around but the token argument is just dropped.
96-
// TODO(allight): Should we handle trace/cover the same way?
97114
absl::Status HandleAssert(Assert* n) override {
98115
XLS_RETURN_IF_ERROR(fb_.GetError());
99116
std::vector<Node*> new_ops{fb_.Literal(Value::Token()).node(),
@@ -175,11 +192,6 @@ class UnrollProcVisitor final : public DfsVisitorWithDefault {
175192
return absl::OkStatus();
176193
}
177194

178-
absl::Status HandleCover(Cover* c) override {
179-
return absl::UnimplementedError(
180-
"UnrollProcVisitor: cover is not supported");
181-
}
182-
183195
absl::Status HandleAfterAll(AfterAll* aa) override {
184196
XLS_RETURN_IF_ERROR(fb_.GetError());
185197
// TODO: https://github.com/google/xls/issues/1375 - It would be nice to

0 commit comments

Comments
 (0)