47class ElimActionRun :
public PassManager {
51 const IR::P4Table *tbl;
52 const IR::Type_Enum *action_tags;
53 const IR::Declaration_Variable *action_run;
54 std::map<cstring, cstring> actions;
55 explicit atinfo_t(
const IR::P4Table *t) : tbl(t) {}
58 std::map<cstring, atinfo_t> actionRunTables;
59 std::map<cstring, atinfo_t *> actionsToModify;
60 std::map<const IR::Statement *, IR::Vector<IR::StatOrDecl> *> prepend_statement;
67 explicit ActionTableUse(ElimActionRun &s) : self(s) {}
69 bool preorder(
const IR::P4Parser *)
override {
return false; }
70 bool preorder(
const IR::P4Action *)
override {
return false; }
71 bool preorder(
const IR::Function *)
override {
return false; }
73 void postorder(
const IR::Member *)
override;
80 explicit RewriteActionRun(ElimActionRun &s) : self(s) {}
82 const IR::P4Parser *preorder(IR::P4Parser *p)
override {
86 const IR::Function *preorder(IR::Function *f)
override {
91 const IR::Expression *postorder(IR::Member *)
override;
92 const IR::P4Action *preorder(IR::P4Action *)
override;
93 const IR::SwitchCase *postorder(IR::SwitchCase *)
override;
94 const IR::Node *postorder(IR::Statement *)
override;
95 const IR::P4Control *postorder(IR::P4Control *)
override;
96 const IR::P4Program *postorder(IR::P4Program *)
override;
100 ElimActionRun() : actionTableUse(*
this) {
101 addPasses({&actionTableUse,
new PassIf([
this]() {
return !actionRunTables.empty(); },
104 new RewriteActionRun(*
this),
105 [
this]() { actionRunTables.clear(); },
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