P4C
The P4 Compiler
Loading...
Searching...
No Matches
table_utils.h
1/*
2 * SPDX-FileCopyrightText: 2023 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_COMMON_LIB_TABLE_UTILS_H_
8#define BACKENDS_P4TOOLS_COMMON_LIB_TABLE_UTILS_H_
9
10#include "ir/ir.h"
11#include "lib/cstring.h"
12
13namespace P4::P4Tools::TableUtils {
14
16struct KeyProperties {
18 IR::KeyElement const *key;
19
22
24 size_t index;
25
28
32
33 explicit KeyProperties(IR::KeyElement const *key, cstring name, size_t index, cstring matchType,
34 bool isTainted)
36};
37
42
44 bool tableIsTainted = false;
45
47 bool tableIsImmutable = false;
48
50 bool defaultIsImmutable = false;
51
53 std::vector<KeyProperties> resolvedKeys;
54
57 std::map<cstring, int> actionIdMap;
58};
59
62void checkTableImmutability(const IR::P4Table &table, TableProperties &properties);
63
65std::vector<const IR::ActionListElement *> buildTableActionList(const IR::P4Table &table);
66
75bool compareLPMEntries(const IR::Entry *leftIn, const IR::Entry *rightIn, size_t lpmIndex);
76
78const IR::PathExpression *getDefaultActionName(const IR::P4Table &table);
79
83const IR::Expression *computeEntryMatch(const IR::P4Table &table, const IR::Entry &entry,
84 const IR::Key &key);
85
86} // namespace P4::P4Tools::TableUtils
87
88#endif /* BACKENDS_P4TOOLS_COMMON_LIB_TABLE_UTILS_H_ */
Definition cstring.h:85
size_t index
The index of this key within the current table.
Definition table_utils.h:24
bool isTainted
Definition table_utils.h:31
cstring matchType
The match type of this key (exact, ternary, lpm, etc...)
Definition table_utils.h:27
IR::KeyElement const * key
The original key element.
Definition table_utils.h:18
cstring name
The control plane name of the key.
Definition table_utils.h:21
Basic table properties that are set when initializing the TableStepper.
Definition table_utils.h:39
std::map< cstring, int > actionIdMap
Definition table_utils.h:57
bool defaultIsImmutable
Indicates whether the default action can be overridden.
Definition table_utils.h:50
std::vector< KeyProperties > resolvedKeys
Ordered list of key fields with useful properties.
Definition table_utils.h:53
bool tableIsTainted
Whether key expressions of the table contain taint. This makes it difficult to match.
Definition table_utils.h:44
bool tableIsImmutable
Whether the table is constant and can not accept control plane entries.
Definition table_utils.h:47
cstring tableName
Control plane name of the table.
Definition table_utils.h:41