8#ifndef CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
9#define CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
11#include "lib/cstring.h"
12#include "p4RuntimeArchHandler.h"
13#include "typeSpecConverter.h"
34const p4rt_id_t INVALID_ID = ::p4::config::v1::P4Ids::UNSPECIFIED;
40bool isHidden(
const IR::IAnnotated *node);
61 std::set<cstring> symbols;
71 unsigned instances = 0;
74 std::map<cstring, SuffixNode *> edges;
79 SuffixNode *suffixesRoot =
new SuffixNode;
99 template <
typename Func>
100 static P4RuntimeSymbolTable *
create(Func function) {
104 auto *symbols =
new P4RuntimeSymbolTable();
108 for (
auto &table : symbols->symbolTables) {
109 symbols->computeIdsForSymbols(table.first);
116 const IR::ToplevelBlock *evaluatedProgram,
125 std::optional<p4rt_id_t>
id = std::nullopt)
override;
147 p4rt_id_t tryToAssignId(std::optional<p4rt_id_t>
id);
167 template <
typename ConstructIdFunc>
168 std::optional<p4rt_id_t> probeForId(
const uint32_t sourceValue, ConstructIdFunc constructId) {
169 uint32_t value = sourceValue;
170 while (assignedIds.find(constructId(value)) != assignedIds.end()) {
172 if (value == sourceValue) {
178 return constructId(value);
183 static uint32_t jenkinsOneAtATimeHash(
const char *key,
size_t length);
188 std::set<p4rt_id_t> assignedIds;
191 using SymbolTable = std::map<cstring, p4rt_id_t>;
192 std::map<P4RuntimeSymbolType, SymbolTable> symbolTables{};
197 P4SymbolSuffixSet suffixSet;
201 const IR::ControlBlock *controlBlock, ReferenceMap *refMap,
205 const IR::ExternBlock *externBlock);
208 const IR::TableBlock *tableBlock);
Definition p4RuntimeArchHandler.h:130
Definition p4RuntimeSymbolTable.h:84
p4rt_id_t getId(P4RuntimeSymbolType type, const IR::IDeclaration *declaration) const override
Definition p4RuntimeSymbolTable.cpp:186
void add(P4RuntimeSymbolType type, const IR::IDeclaration *declaration) override
Add a @type symbol, extracting the name and id from @declaration.
Definition p4RuntimeSymbolTable.cpp:169
cstring getAlias(cstring name) const override
Definition p4RuntimeSymbolTable.cpp:206
static P4RuntimeSymbolTable * create(Func function)
Definition p4RuntimeSymbolTable.h:100
Definition p4RuntimeArchHandler.h:100
Definition p4RuntimeArchHandler.h:54
The Declaration interface, representing objects with names.
Definition declaration.h:17
Class used to encode maps from paths to declarations.
Definition referenceMap.h:67
TODO(antonin): High level goals of the generator go here!!
Definition dpdk/control-plane/bfruntime_arch_handler.h:44
std::optional< p4rt_id_t > getIdAnnotation(const IR::IAnnotated *node)
Definition p4RuntimeSymbolTable.cpp:28
bool isControllerHeader(const IR::Type_Header *type)
Definition p4RuntimeSymbolTable.cpp:20
bool isHidden(const IR::IAnnotated *node)
Definition p4RuntimeSymbolTable.cpp:24
Definition constantParsing.h:22
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition p4RuntimeSymbolTable.h:52
void addSymbol(const cstring &symbol)
Adds @symbol's suffixes to the set if it's not already present.
Definition p4RuntimeSymbolTable.cpp:327