P4C
The P4 Compiler
Loading...
Searching...
No Matches
targets/bmv2/table_stepper.h
1/*
2 * SPDX-FileCopyrightText: 2022 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TABLE_STEPPER_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TABLE_STEPPER_H_
9
10#include <vector>
11
12#include "ir/ir.h"
13
14#include "backends/p4tools/modules/testgen/core/small_step/table_stepper.h"
15#include "backends/p4tools/modules/testgen/lib/execution_state.h"
16#include "backends/p4tools/modules/testgen/lib/test_spec.h"
17#include "backends/p4tools/modules/testgen/targets/bmv2/expr_stepper.h"
18#include "backends/p4tools/modules/testgen/targets/bmv2/test_spec.h"
19
21
22class Bmv2V1ModelTableStepper : public TableStepper {
23 private:
30 enum class TableImplementation { standard, selector, profile, constant, skip };
31
33 struct Bmv2V1ModelProperties {
35 const Bmv2V1ModelActionProfile *actionProfile = nullptr;
36
38 const Bmv2V1ModelActionSelector *actionSelector = nullptr;
39
41 std::vector<const IR::Expression *> actionSelectorKeys;
42
44 bool addProfileToState = false;
45
47 TableImplementation implementaton = TableImplementation::standard;
48 } bmv2V1ModelProperties;
49
51 bool checkForActionProfile();
52
54 bool checkForActionSelector();
55
58 void evalTableActionProfile(const std::vector<const IR::ActionListElement *> &tableActionList);
59
62 void evalTableActionSelector(const std::vector<const IR::ActionListElement *> &tableActionList);
63
64 protected:
65 const IR::Expression *computeTargetMatchType(const TableUtils::KeyProperties &keyProperties,
66 TableMatchMap *matches,
67 const IR::Expression *hitCondition) override;
68
70 const std::vector<const IR::ActionListElement *> &tableActionList) override;
71
72 void evalTargetTable(
73 const std::vector<const IR::ActionListElement *> &tableActionList) override;
74
75 public:
76 explicit Bmv2V1ModelTableStepper(Bmv2V1ModelExprStepper *stepper, const IR::P4Table *table);
77};
78
79} // namespace P4::P4Tools::P4Testgen::Bmv2
80
81#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_TABLE_STEPPER_H_ */
Definition targets/bmv2/test_spec.h:153
Definition targets/bmv2/test_spec.h:187
Definition targets/bmv2/expr_stepper.h:23
void evalTargetTable(const std::vector< const IR::ActionListElement * > &tableActionList) override
Definition targets/bmv2/table_stepper.cpp:391
void checkTargetProperties(const std::vector< const IR::ActionListElement * > &tableActionList) override
Definition targets/bmv2/table_stepper.cpp:362
const IR::Expression * computeTargetMatchType(const TableUtils::KeyProperties &keyProperties, TableMatchMap *matches, const IR::Expression *hitCondition) override
Definition targets/bmv2/table_stepper.cpp:43
const IR::P4Table * table
The table for this particular stepper.
Definition core/small_step/table_stepper.h:32
ExprStepper * stepper
Reference to the calling expression stepper.
Definition core/small_step/table_stepper.h:29
Inja.
Definition targets/bmv2/cmd_stepper.cpp:37
KeyProperties define properties of table keys that are useful for execution.
Definition table_utils.h:16