32 std::map<const IR::P4Control *, ordered_map<const IR::P4Action *, const IR::P4Action *> *> repl;
34 const IR::P4Action *getReplacement(
const IR::P4Action *action,
35 const IR::P4Control *control)
const {
36 auto map = ::get(repl, control);
37 if (map ==
nullptr)
return nullptr;
38 if (map->find(action) != map->end())
return (*map)[action];
41 void addReplacement(
const IR::P4Action *action,
const IR::P4Control *control,
42 const IR::P4Action *replacement) {
43 LOG1(
"Cloning global " << dbp(action) <<
" into " << dbp(replacement) <<
" for "
45 if (repl.find(control) == repl.end())
47 (*repl[control])[action] = replacement;
90 std::map<const IR::P4Action *, ordered_map<const IR::Node *, const IR::P4Action *> *> toInsert;
91 std::map<const IR::PathExpression *, const IR::P4Action *> repl;
94 const IR::P4Action *getActionUser(
const IR::P4Action *action,
const IR::Node *user) {
95 if (toInsert.find(action) == toInsert.end())
return nullptr;
96 auto map = toInsert[action];
98 if (map->find(user) == map->end())
return nullptr;
101 void createReplacement(
const IR::P4Action *original,
const IR::Node *user,
102 const IR::P4Action *replacement) {
103 auto map = toInsert[original];
104 if (map ==
nullptr) {
106 toInsert[original] = map;
108 (*map)[user] = replacement;
111 void setRefReplacement(
const IR::PathExpression *path,
const IR::P4Action *replacement) {
112 LOG1(
"Adding replacement " << dbp(replacement) <<
" used by " << dbp(path));
113 repl[path] = replacement;