Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P4_14->16 fix for externs and registers #330

Merged
merged 3 commits into from
Feb 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,6 @@ check-%:

recheck-%:
@$(MAKE) recheck TESTS="$(filter $*/%, $(TESTS) $(EXTRA_TESTS))"

check-ifail:
@$(MAKE) check TESTS="$(IFAIL_TESTS)"
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