8#ifndef CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
9#define CONTROL_PLANE_P4RUNTIMESYMBOLTABLE_H_
13#include "lib/cstring.h"
14#include "p4RuntimeArchHandler.h"
15#include "typeSpecConverter.h"
36const p4rt_id_t INVALID_ID = ::p4::config::v1::P4Ids::UNSPECIFIED;
42bool isHidden(
const IR::IAnnotated *node);
63 std::set<cstring> symbols;
73 unsigned instances = 0;
76 std::map<cstring, std::shared_ptr<SuffixNode>> edges;
81 std::shared_ptr<SuffixNode> suffixesRoot = std::make_shared<SuffixNode>();
101 template <
typename Func>
102 static std::unique_ptr<P4RuntimeSymbolTable>
create(Func function) {
106 auto symbols = std::unique_ptr<P4RuntimeSymbolTable>(
new P4RuntimeSymbolTable());
110 for (
auto &table : symbols->symbolTables) {
111 symbols->computeIdsForSymbols(table.first);
117 static std::unique_ptr<P4RuntimeSymbolTable> generateSymbols(
118 const IR::P4Program *program,
const IR::ToplevelBlock *evaluatedProgram,
126 std::optional<p4rt_id_t>
id = std::nullopt)
override;
148 p4rt_id_t tryToAssignId(std::optional<p4rt_id_t>
id);
168 template <
typename ConstructIdFunc>
169 std::optional<p4rt_id_t> probeForId(
const uint32_t sourceValue, ConstructIdFunc constructId) {
170 uint32_t value = sourceValue;
171 while (assignedIds.find(constructId(value)) != assignedIds.end()) {
173 if (value == sourceValue) {
179 return constructId(value);
184 static uint32_t jenkinsOneAtATimeHash(
const char *key,
size_t length);
189 std::set<p4rt_id_t> assignedIds;
192 using SymbolTable = std::map<cstring, p4rt_id_t>;
193 std::map<P4RuntimeSymbolType, SymbolTable> symbolTables{};
198 P4SymbolSuffixSet suffixSet;
202 const IR::ControlBlock *controlBlock, ReferenceMap *refMap,
206 const IR::ExternBlock *externBlock);
209 const IR::TableBlock *tableBlock);
Definition p4RuntimeArchHandler.h:130
Definition p4RuntimeSymbolTable.h:86
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
static std::unique_ptr< P4RuntimeSymbolTable > create(Func function)
Definition p4RuntimeSymbolTable.h:102
cstring getAlias(cstring name) const override
Definition p4RuntimeSymbolTable.cpp:206
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:58
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:13
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition p4RuntimeSymbolTable.h:54
void addSymbol(const cstring &symbol)
Adds @symbol's suffixes to the set if it's not already present.
Definition p4RuntimeSymbolTable.cpp:327