P4C
The P4 Compiler
Loading...
Searching...
No Matches
empty_controls.h
1
19#ifndef BF_P4C_MAU_EMPTY_CONTROLS_H_
20#define BF_P4C_MAU_EMPTY_CONTROLS_H_
21
22#include "mau_visitor.h"
23
24using namespace P4;
25
27 const IR::MAU::Table *postorder(IR::MAU::Table *tbl) override {
28 if (tbl->next.count("$default"_cs)) {
29 auto def = tbl->next.at("$default"_cs);
30 if (def->tables.empty()) tbl->next.erase("$default"_cs);
31 } else {
32 for (auto it = tbl->next.begin(); it != tbl->next.end();) {
33 if (it->second->tables.empty())
34 it = tbl->next.erase(it);
35 else
36 ++it;
37 }
38 }
39 if (tbl->conditional_gateway_only() && tbl->next.empty()) return nullptr;
40 return tbl;
41 }
42};
43
44#endif /* BF_P4C_MAU_EMPTY_CONTROLS_H_ */
Definition mau_visitor.h:55
Definition empty_controls.h:26
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24