P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino/shared_table_stepper.h
1/*******************************************************************************
2 * Copyright (C) 2024 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing,
11 * software distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions
14 * and limitations under the License.
15 *
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 ******************************************************************************/
19
20#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_SHARED_TABLE_STEPPER_H_
21#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_SHARED_TABLE_STEPPER_H_
22
23#include <map>
24#include <vector>
25
26#include "ir/ir.h"
27#include "lib/cstring.h"
28
29#include "backends/p4tools/modules/testgen/core/small_step/table_stepper.h"
30#include "backends/p4tools/modules/testgen/lib/execution_state.h"
31#include "backends/p4tools/modules/testgen/lib/test_spec.h"
32#include "backends/p4tools/modules/testgen/targets/tofino/shared_expr_stepper.h"
33#include "backends/p4tools/modules/testgen/targets/tofino/test_spec.h"
34
35namespace P4::P4Tools::P4Testgen::Tofino {
36
37class TofinoTableStepper : public TableStepper {
38 private:
45 enum class TableImplementation { standard, selector, profile, constant, skip };
46
48 struct TofinoProperties {
50 const TofinoActionProfile *actionProfile = nullptr;
51
53 TofinoActionSelector *actionSelector = nullptr;
54
56 std::vector<const IR::Expression *> actionSelectorKeys;
57
59 bool addProfileToState = false;
60
62 TableImplementation implementaton;
63 } tofinoProperties;
64
66 bool checkForActionProfile();
67
69 bool checkForActionSelector();
70
73 void evalTableActionProfile(const std::vector<const IR::ActionListElement *> &tableActionList);
74
77 void evalTableActionSelector(const std::vector<const IR::ActionListElement *> &tableActionList);
78
79 protected:
80 const IR::Expression *computeTargetMatchType(const TableUtils::KeyProperties &keyProperties,
81 TableMatchMap *matches,
82 const IR::Expression *hitCondition) override;
83
85 const std::vector<const IR::ActionListElement *> &tableActionList) override;
86
87 void evalTargetTable(
88 const std::vector<const IR::ActionListElement *> &tableActionList) override;
89
90 public:
91 explicit TofinoTableStepper(SharedTofinoExprStepper *stepper, const IR::P4Table *table);
92};
93
94} // namespace P4::P4Tools::P4Testgen::Tofino
95
96#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_SHARED_TABLE_STEPPER_H_ */
const IR::P4Table * table
The table for this particular stepper.
Definition core/small_step/table_stepper.h:26
ExprStepper * stepper
Reference to the calling expression stepper.
Definition core/small_step/table_stepper.h:23
Definition tofino/shared_expr_stepper.h:34
Definition targets/tofino/test_spec.h:222
Definition targets/tofino/test_spec.h:255
const IR::Expression * computeTargetMatchType(const TableUtils::KeyProperties &keyProperties, TableMatchMap *matches, const IR::Expression *hitCondition) override
Definition tofino/shared_table_stepper.cpp:45
void evalTargetTable(const std::vector< const IR::ActionListElement * > &tableActionList) override
Definition tofino/shared_table_stepper.cpp:387
void checkTargetProperties(const std::vector< const IR::ActionListElement * > &tableActionList) override
Definition tofino/shared_table_stepper.cpp:358
KeyProperties define properties of table keys that are useful for execution.
Definition table_utils.h:10