34 std::map<const IR::P4Control *, ordered_map<const IR::P4Action *, const IR::P4Action *> *> repl;
36 const IR::P4Action *getReplacement(
const IR::P4Action *action,
37 const IR::P4Control *control)
const {
38 auto map = ::P4::get(repl, control);
39 if (map ==
nullptr)
return nullptr;
40 if (map->find(action) != map->end())
return (*map)[action];
43 void addReplacement(
const IR::P4Action *action,
const IR::P4Control *control,
44 const IR::P4Action *replacement) {
45 LOG1(
"Cloning global " << dbp(action) <<
" into " << dbp(replacement) <<
" for "
47 if (repl.find(control) == repl.end())
49 (*repl[control])[action] = replacement;
88 std::map<const IR::P4Action *, ordered_map<const IR::Node *, const IR::P4Action *> *> toInsert;
89 std::map<const IR::PathExpression *, const IR::P4Action *> repl;
92 const IR::P4Action *getActionUser(
const IR::P4Action *action,
const IR::Node *user) {
93 if (toInsert.find(action) == toInsert.end())
return nullptr;
94 auto map = toInsert[action];
96 if (map->find(user) == map->end())
return nullptr;
99 void createReplacement(
const IR::P4Action *original,
const IR::Node *user,
100 const IR::P4Action *replacement) {
101 auto map = toInsert[original];
102 if (map ==
nullptr) {
104 toInsert[original] = map;
106 (*map)[user] = replacement;
109 void setRefReplacement(
const IR::PathExpression *path,
const IR::P4Action *replacement) {
110 LOG1(
"Adding replacement " << dbp(replacement) <<
" used by " << dbp(path));
111 repl[path] = replacement;
Visitor mixin for looking up names in enclosing scopes from the Visitor::Context.
Definition resolveReferences.h:35
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24