P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino/shared_expr_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_EXPR_STEPPER_H_
21#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_SHARED_EXPR_STEPPER_H_
22
23#include "ir/ir.h"
24#include "ir/solver.h"
25
26#include "backends/p4tools/modules/testgen/core/program_info.h"
27#include "backends/p4tools/modules/testgen/core/small_step/expr_stepper.h"
28#include "backends/p4tools/modules/testgen/lib/execution_state.h"
29
30namespace P4::P4Tools::P4Testgen::Tofino {
31
32/* This unit contains expression operations that are shared between Tofino 1 and 2. The purpose is
33 * to avoid excessive code duplication. */
34class SharedTofinoExprStepper : public ExprStepper {
35 protected:
37 int advanceSize) const override;
38
40 const ExecutionState &state, const IR::Expression *advanceExpr,
41 const IR::Expression *restrictions) const override;
42
43 /* ======================================================================================
44 * (Direct)Meter.execute
45 * See also: https://wiki.ith.intel.com/display/BXDCOMPILER/Meters
46 * ====================================================================================== */
48 /* ======================================================================================
49 * DirectCount.count
50 * See also:
51 * https://wiki.ith.intel.com/pages/viewpage.action?pageId=1981604291#Externs-_sk26xix6q9fxCounters
52 * ====================================================================================== */
54 /* ======================================================================================
55 * Checksum.update
56 * Calculate the checksum for a given list of fields.
57 * @param data : List of fields contributing to the checksum value.
58 * @param zeros_as_ones : encode all-zeros value as all-ones.
59 * ====================================================================================== */
61 /* ======================================================================================
62 * Mirror.emit
63 * Sends copy of the packet to a specified destination.
64 * See also:
65 * https://wiki.ith.intel.com/display/BXDCOMPILER/Externs#Externs-Mirror
66 * ====================================================================================== */
67 // TODO: Currently implemented as no-op. We rely on the fact that when mirroring is not
68 // configured by the control plane the mirrored packets are discarded and hence not seen
69 // by the STF/PTF test.
71
72 /* ======================================================================================
73 * RegisterAction.execute
74 * See also: https://wiki.ith.intel.com/display/BXDCOMPILER/Stateful+ALU
75 * ====================================================================================== */
76 static const ExternMethodImpls<SharedTofinoExprStepper>::MethodImpl REGISTER_ACTION_EXECUTE;
77 /* ======================================================================================
78 * DirectRegisterAction.execute
79 * Currently, this function is almost identical to RegisterAction.execute. The only
80 * difference is the amount of expected type arguments.
81 * ====================================================================================== */
83 DIRECT_REGISTER_ACTION_EXECUTE;
84
85 // Provides implementations of Tofino externs.
86 static const ExternMethodImpls<SharedTofinoExprStepper> SHARED_TOFINO_EXTERN_METHOD_IMPLS;
87
88 public:
89 SharedTofinoExprStepper(ExecutionState &state, AbstractSolver &solver,
91 : ExprStepper(state, solver, programInfo) {}
92
93 void evalExternMethodCall(const ExternInfo &externInfo) override;
94
95 bool preorder(const IR::P4Table *table) override;
96};
97
98} // namespace P4::P4Tools::P4Testgen::Tofino
99
100#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_TOFINO_SHARED_EXPR_STEPPER_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:24
ExecutionState & state
The state being evaluated.
Definition abstract_stepper.h:49
const ProgramInfo & programInfo
Target-specific information about the P4 program being evaluated.
Definition abstract_stepper.h:46
Represents state of execution after having reached a program point.
Definition execution_state.h:34
Encapsulates a set of extern method implementations.
Definition core/small_step/expr_stepper.h:27
Definition core/small_step/expr_stepper.h:173
Definition extern_info.h:14
Stores target-specific information about a P4 program.
Definition core/program_info.h:21
PacketCursorAdvanceInfo calculateSuccessfulParserAdvance(const ExecutionState &state, int advanceSize) const override
Definition tofino/shared_expr_stepper.cpp:63
PacketCursorAdvanceInfo calculateAdvanceExpression(const ExecutionState &state, const IR::Expression *advanceExpr, const IR::Expression *restrictions) const override
Definition tofino/shared_expr_stepper.cpp:85
void evalExternMethodCall(const ExternInfo &externInfo) override
Definition tofino/shared_expr_stepper.cpp:1392
Definition phv/solver/action_constraint_solver.cpp:33