8#ifndef BACKENDS_TC_INTROSPECTION_H_
9#define BACKENDS_TC_INTROSPECTION_H_
11#include "frontends/p4/parseAnnotations.h"
12#include "frontends/p4/parserCallGraph.h"
15#include "lib/nullstream.h"
17#include "tcAnnotations.h"
24using namespace P4::literals;
26struct IntrospectionInfo {
30 schemaVersion =
nullptr;
31 pipelineName =
nullptr;
33 void initIntrospectionInfo(IR::TCPipeline *tcPipeline) {
34 schemaVersion =
"1.0.0"_cs;
35 pipelineName = tcPipeline->pipelineName;
39struct KeyFieldAttributes {
45 unsigned int bitwidth;
46 KeyFieldAttributes() {
58 Annotation() { name =
nullptr; }
59 explicit Annotation(
cstring n) { name = n; }
65 unsigned int dataType;
66 unsigned int bitwidth;
74enum ActionScope { TableOnly, DefaultOnly, TableAndDefault };
76struct ActionAttributes {
87 scope = TableAndDefault;
93struct TableAttributes {
97 unsigned int tentries;
105 permissions =
nullptr;
114struct ExternInstancesAttributes {
119 ExternInstancesAttributes() {
126struct ExternAttributes {
133 permissions =
nullptr;
139class IntrospectionGenerator :
public Inspector {
140 IR::TCPipeline *tcPipeline;
148 IntrospectionGenerator(IR::TCPipeline *tcPipeline,
P4::ReferenceMap *refMap,
150 : tcPipeline(tcPipeline), refMap(refMap), typeMap(typeMap) {}
151 void postorder(
const IR::P4Table *t);
157 void collectTableInfo();
158 void collectExternInfo();
159 void collectKeyInfo(
const IR::Key *k,
struct TableAttributes *tableinfo);
160 void collectActionInfo(
const IR::ActionList *actionlist,
struct TableAttributes *tableinfo,
161 const IR::P4Table *p4table,
const IR::TCTable *table);
164 bool serializeIntrospectionJson(std::ostream &destination);
165 std::optional<cstring> checkValidTcType(
const IR::StringLiteral *sl);
The Declaration interface, representing objects with names.
Definition declaration.h:17
Class used to encode maps from paths to declarations.
Definition referenceMap.h:67
Definition lib/json.h:128
Definition lib/json.h:177
Definition ordered_map.h:32
Definition safe_vector.h:18
This file defines functions for the pass to generate the introspection file.
Definition tc/backend.cpp:17
Definition introspection.h:76
Definition introspection.h:126
Definition introspection.h:39
Definition introspection.h:93