17#ifndef BACKENDS_BMV2_COMMON_PROGRAMSTRUCTURE_H_
18#define BACKENDS_BMV2_COMMON_PROGRAMSTRUCTURE_H_
20#include "ir/visitor.h"
21#include "lib/ordered_set.h"
28enum class BlockConverted {
52 std::vector<const IR::Declaration_Variable *>
variables;
58 std::map<const IR::StructField *, cstring> scalarMetadataFields;
78 void postorder(
const IR::ParameterList *paramList)
override;
79 void postorder(
const IR::P4Action *action)
override;
80 void postorder(
const IR::Declaration_Variable *decl)
override;
81 void postorder(
const IR::Type_Error *errors)
override;
82 void postorder(
const IR::Declaration_MatchKind *kind)
override;
94 CHECK_NULL(resourceMap);
97 bool preorder(
const IR::ControlBlock *control)
override {
98 resourceMap->emplace(control->container, control);
99 for (
auto cv : control->constantValue) {
100 resourceMap->emplace(
cv.first,
cv.second);
103 for (
auto c : control->container->controlLocals) {
104 if (
c->is<IR::InstantiatedBlock>()) {
105 resourceMap->emplace(
c, control->getValue(
c));
111 bool preorder(
const IR::ParserBlock *parser)
override {
112 resourceMap->emplace(parser->container, parser);
113 for (
auto cv : parser->constantValue) {
114 resourceMap->emplace(
cv.first,
cv.second);
115 if (
cv.second->is<IR::Block>()) {
120 for (
auto c : parser->container->parserLocals) {
121 if (
c->is<IR::InstantiatedBlock>()) {
122 resourceMap->emplace(
c, parser->getValue(
c));
128 bool preorder(
const IR::TableBlock *table)
override {
129 resourceMap->emplace(table->container, table);
130 for (
auto cv : table->constantValue) {
131 resourceMap->emplace(
cv.first,
cv.second);
132 if (
cv.second->is<IR::Block>()) {
139 bool preorder(
const IR::PackageBlock *package)
override {
140 for (
auto cv : package->constantValue) {
141 if (
cv.second->is<IR::Block>()) {
148 bool preorder(
const IR::ToplevelBlock *tlb)
override {
149 auto package = tlb->getMain();
Definition programStructure.h:89
Definition programStructure.h:71
Definition programStructure.h:40
ResourceMap resourceMap
map IR node to compile-time allocated resource blocks.
Definition programStructure.h:66
ordered_map< const IR::P4Action *, unsigned > ids
For each action its json id.
Definition programStructure.h:50
std::set< cstring > match_kinds
All match kinds.
Definition programStructure.h:64
ordered_map< const IR::Parameter *, unsigned > index
Definition programStructure.h:46
ordered_map< const IR::IDeclaration *, unsigned int > errorCodesMap
All error codes.
Definition programStructure.h:54
std::vector< const IR::Declaration_Variable * > variables
All local variables.
Definition programStructure.h:52
ordered_map< const IR::P4Action *, const IR::P4Control * > actions
Map action to parent control.
Definition programStructure.h:43
ordered_set< const IR::Parameter * > nonActionParameters
Parameters of controls/parsers.
Definition programStructure.h:48
DirectMeterMap directMeterMap
All the direct meters.
Definition programStructure.h:60
ordered_map< cstring, const IR::P4Table * > directCounterMap
All the direct counters.
Definition programStructure.h:62
Definition sharedActionSelectorCheck.h:40
Definition ordered_map.h:30