25 std::map<const IR::P4Control *, ordered_map<const IR::P4Action *, const IR::P4Action *> *> repl;
27 const IR::P4Action *getReplacement(
const IR::P4Action *action,
28 const IR::P4Control *control)
const {
29 auto map = ::P4::get(repl, control);
30 if (map ==
nullptr)
return nullptr;
31 if (map->find(action) != map->end())
return (*map)[action];
34 void addReplacement(
const IR::P4Action *action,
const IR::P4Control *control,
35 const IR::P4Action *replacement) {
36 LOG1(
"Cloning global " << dbp(action) <<
" into " << dbp(replacement) <<
" for "
38 if (repl.find(control) == repl.end())
40 (*repl[control])[action] = replacement;
79 std::map<const IR::P4Action *, ordered_map<const IR::Node *, const IR::P4Action *> *> toInsert;
80 std::map<const IR::PathExpression *, const IR::P4Action *> repl;
83 const IR::P4Action *getActionUser(
const IR::P4Action *action,
const IR::Node *user) {
84 if (toInsert.find(action) == toInsert.end())
return nullptr;
85 auto map = toInsert[action];
87 if (map->find(user) == map->end())
return nullptr;
90 void createReplacement(
const IR::P4Action *original,
const IR::Node *user,
91 const IR::P4Action *replacement) {
92 auto map = toInsert[original];
95 toInsert[original] = map;
97 (*map)[user] = replacement;
100 void setRefReplacement(
const IR::PathExpression *path,
const IR::P4Action *replacement) {
101 LOG1(
"Adding replacement " << dbp(replacement) <<
" used by " << dbp(path));
102 repl[path] = replacement;
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13