17#ifndef CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
18#define CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
20#include "lib/cstring.h"
21#include "p4RuntimeArchHandler.h"
22#include "typeSpecConverter.h"
41namespace ControlPlaneAPI {
43const p4rt_id_t INVALID_ID = ::p4::config::v1::P4Ids::UNSPECIFIED;
70 std::set<cstring> symbols;
80 unsigned instances = 0;
83 std::map<cstring, SuffixNode *> edges;
88 SuffixNode *suffixesRoot =
new SuffixNode;
108 template <
typename Func>
117 for (
auto &table : symbols->symbolTables) {
118 symbols->computeIdsForSymbols(table.first);
125 const IR::ToplevelBlock *evaluatedProgram,
134 std::optional<p4rt_id_t>
id = std::nullopt)
override;
156 p4rt_id_t tryToAssignId(std::optional<p4rt_id_t>
id);
176 template <
typename ConstructIdFunc>
177 std::optional<p4rt_id_t> probeForId(
const uint32_t sourceValue, ConstructIdFunc constructId) {
178 uint32_t value = sourceValue;
179 while (assignedIds.find(constructId(value)) != assignedIds.end()) {
181 if (value == sourceValue) {
187 return constructId(value);
192 static uint32_t jenkinsOneAtATimeHash(
const char *key,
size_t length);
197 std::set<p4rt_id_t> assignedIds;
200 using SymbolTable = std::map<cstring, p4rt_id_t>;
201 std::map<P4RuntimeSymbolType, SymbolTable> symbolTables{};
206 P4SymbolSuffixSet suffixSet;
209void collectControlSymbols(P4RuntimeSymbolTable &symbols, P4RuntimeArchHandlerIface *archHandler,
210 const IR::ControlBlock *controlBlock, ReferenceMap *refMap,
213void collectExternSymbols(P4RuntimeSymbolTable &symbols, P4RuntimeArchHandlerIface *archHandler,
214 const IR::ExternBlock *externBlock);
216void collectTableSymbols(P4RuntimeSymbolTable &symbols, P4RuntimeArchHandlerIface *archHandler,
217 const IR::TableBlock *tableBlock);
219void collectParserSymbols(P4RuntimeSymbolTable &symbols,
const IR::ParserBlock *parserBlock);
Definition p4RuntimeArchHandler.h:139
Definition p4RuntimeSymbolTable.h:93
p4rt_id_t getId(P4RuntimeSymbolType type, const IR::IDeclaration *declaration) const override
Definition p4RuntimeSymbolTable.cpp:192
void add(P4RuntimeSymbolType type, const IR::IDeclaration *declaration) override
Add a @type symbol, extracting the name and id from @declaration.
Definition p4RuntimeSymbolTable.cpp:175
cstring getAlias(cstring name) const override
Definition p4RuntimeSymbolTable.cpp:212
static P4RuntimeSymbolTable * create(Func function)
Definition p4RuntimeSymbolTable.h:109
Definition p4RuntimeArchHandler.h:109
Definition p4RuntimeArchHandler.h:63
The Declaration interface, representing objects with names.
Definition declaration.h:26
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
std::optional< p4rt_id_t > getIdAnnotation(const IR::IAnnotated *node)
Definition p4RuntimeSymbolTable.cpp:34
bool isHidden(const IR::Node *node)
Definition p4RuntimeSymbolTable.cpp:32
bool isControllerHeader(const IR::Type_Header *type)
Definition p4RuntimeSymbolTable.cpp:28
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition p4RuntimeSymbolTable.h:61
void addSymbol(const cstring &symbol)
Adds @symbol's suffixes to the set if it's not already present.
Definition p4RuntimeSymbolTable.cpp:333