Skip to content

Commit

Permalink
collects decls from parser and control block (#3392)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamleshbhalui authored Jun 27, 2022
1 parent da63f29 commit 45014a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions backends/dpdk/dpdkArch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,10 @@ const IR::Node *IfStatementUnroll::postorder(IR::SwitchStatement *sw) {
code_block->push_back(i);

auto control = findOrigCtxt<IR::P4Control>();
auto parser = findOrigCtxt<IR::P4Parser>();

for (auto d : unroller->decl)
injector.collect(control, nullptr, d);
injector.collect(control, parser, d);
if (unroller->root) {
sw->expression = unroller->root;
}
Expand All @@ -929,9 +930,9 @@ const IR::Node *IfStatementUnroll::postorder(IR::IfStatement *i) {
code_block->push_back(i);

auto control = findOrigCtxt<IR::P4Control>();

auto parser = findOrigCtxt<IR::P4Parser>();
for (auto d : unroller->decl)
injector.collect(control, nullptr, d);
injector.collect(control, parser, d);
if (unroller->root) {
i->condition = unroller->root;
}
Expand All @@ -944,6 +945,11 @@ const IR::Node *IfStatementUnroll::postorder(IR::P4Control *a) {
return injector.inject_control(control, a);
}

const IR::Node *IfStatementUnroll::postorder(IR::P4Parser *a) {
auto parser = getOriginal();
return injector.inject_parser(parser, a);
}

// TODO(GordonWuCn): simplify with a postorder visitor if it is a statement,
// return the expression, else introduce a temporary for the current expression
// and return the temporary in a pathexpression.
Expand Down
1 change: 1 addition & 0 deletions backends/dpdk/dpdkArch.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class IfStatementUnroll : public Transform {
const IR::Node *postorder(IR::SwitchStatement *a) override;
const IR::Node *postorder(IR::IfStatement *a) override;
const IR::Node *postorder(IR::P4Control *a) override;
const IR::Node *postorder(IR::P4Parser *a) override;
};

/* Assume one logical expression looks like this: a && (b + c > d), this pass
Expand Down

0 comments on commit 45014a7

Please sign in to comment.