17#ifndef BACKENDS_TC_PNAPROGRAMSTRUCTURE_H_
18#define BACKENDS_TC_PNAPROGRAMSTRUCTURE_H_
20#include "backends/common/programStructure.h"
21#include "frontends/common/resolveReferences/referenceMap.h"
22#include "frontends/p4/typeMap.h"
24#include "lib/cstring.h"
43 unsigned scalars_width = 0;
44 unsigned error_width = 32;
45 unsigned bool_width = 1;
66 std::vector<const IR::ExternBlock *> globals;
70 : refMap(refMap), typeMap(typeMap) {
75 std::set<cstring> non_pipeline_controls;
76 std::set<cstring> pipeline_controls;
78 bool hasVisited(
const IR::Type_StructLike *st) {
79 if (
auto h = st->to<IR::Type_Header>())
80 return header_types.count(h->getName());
81 else if (
auto s = st->to<IR::Type_Struct>())
82 return metadata_types.count(s->getName());
83 else if (
auto u = st->to<IR::Type_HeaderUnion>())
84 return header_union_types.count(u->getName());
99 return (!strcmp(ptName,
"pna_main_parser_input_metadata_t") ||
100 !strcmp(ptName,
"pna_main_input_metadata_t") ||
101 !strcmp(ptName,
"pna_main_output_metadata_t"));
110 CHECK_NULL(structure);
113 void modelError(
const char *format,
const IR::INode *node) {
115 (
cstring(format) +
"\nAre you using an up-to-date 'pna.p4'?").c_str(),
119 bool preorder(
const IR::ToplevelBlock *block)
override;
120 bool preorder(
const IR::PackageBlock *block)
override;
121 bool preorder(
const IR::ExternBlock *block)
override;
124 structure->block_type.clear();
125 structure->globals.clear();
126 return Inspector::init_apply(root);
137 : refMap(refMap), typeMap(typeMap), pinfo(pinfo) {
141 setName(
"InspectPnaProgram");
144 void postorder(
const IR::P4Parser *p)
override;
145 void postorder(
const IR::P4Control *c)
override;
146 void postorder(
const IR::Declaration_Instance *di)
override;
148 bool isHeaders(
const IR::Type_StructLike *st);
149 void addTypesAndInstances(
const IR::Type_StructLike *type,
bool meta);
150 void addHeaderType(
const IR::Type_StructLike *st);
151 void addHeaderInstance(
const IR::Type_StructLike *st,
cstring name);
152 bool preorder(
const IR::Declaration_Variable *dv)
override;
153 bool preorder(
const IR::Parameter *parameter)
override;
Definition backends/common/programStructure.h:32
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition tc/pnaProgramStructure.h:130
Definition tc/pnaProgramStructure.h:105
bool preorder(const IR::ToplevelBlock *block) override
Definition tc/pnaProgramStructure.cpp:221
Definition tc/pnaProgramStructure.h:34
static bool isStandardMetadata(cstring ptName)
Definition tc/pnaProgramStructure.h:98
static bool isCounterMetadata(cstring ptName)
Definition tc/pnaProgramStructure.h:92
Definition ordered_map.h:32
This file defines functions for the pass to generate the introspection file.
Definition tc/backend.cpp:24
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51