Skip to content

Commit

Permalink
P4_14->16: Include registers referenced by externs in the control tha…
Browse files Browse the repository at this point in the history
…t holds the externs.
  • Loading branch information
Chris Dodd authored and ChrisDodd committed Feb 24, 2017
1 parent a13838f commit 1425339
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 12 additions & 6 deletions frontends/p4/fromv1.0/converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,22 @@ class ComputeCallGraph : public Inspector {
}
}
void postorder(const IR::GlobalRef *gref) override {
auto parent = findContext<IR::ActionFunction>();
BUG_CHECK(parent != nullptr, "%1%: GlobalRef not within action", gref);
const Context *ctxt = nullptr;
cstring caller;
if (auto af = findContext<IR::ActionFunction>()) {
caller = af->name;
} else if (auto di = findContext<IR::Declaration_Instance>()) {
caller = di->name;
} else {
BUG("%1%: GlobalRef not within action or extern", gref); }
if (auto ctr = gref->obj->to<IR::Counter>())
structure->calledCounters.calls(parent->name, ctr->name.name);
structure->calledCounters.calls(caller, ctr->name.name);
else if (auto mtr = gref->obj->to<IR::Meter>())
structure->calledMeters.calls(parent->name, mtr->name.name);
structure->calledMeters.calls(caller, mtr->name.name);
else if (auto reg = gref->obj->to<IR::Register>())
structure->calledRegisters.calls(parent->name, reg->name.name);
structure->calledRegisters.calls(caller, reg->name.name);
else if (auto ext = gref->obj->to<IR::Declaration_Instance>())
structure->calledExterns.calls(parent->name, ext->name.name);
structure->calledExterns.calls(caller, ext->name.name);
}
};

Expand Down
3 changes: 3 additions & 0 deletions frontends/p4/fromv1.0/programStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@ ProgramStructure::convertControl(const IR::V1Control* control, cstring newName)
calledRegisters.getCallees(a, registersToDo);
calledExterns.getCallees(a, externsToDo);
}
for (auto c : externsToDo) {
calledRegisters.getCallees(c, registersToDo);
}
for (auto c : metersToDo) {
auto mtr = meters.get(c);
auto meter = convert(mtr, meters.get(mtr));
Expand Down

0 comments on commit 1425339

Please sign in to comment.