P4C
The P4 Compiler
Loading...
Searching...
No Matches
core/small_step/cmd_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_CORE_SMALL_STEP_CMD_STEPPER_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SMALL_STEP_CMD_STEPPER_H_
9
10#include <map>
11#include <optional>
12#include <vector>
13
14#include "ir/ir.h"
15#include "ir/solver.h"
16#include "lib/cstring.h"
17
18#include "backends/p4tools/modules/testgen/core/program_info.h"
19#include "backends/p4tools/modules/testgen/core/small_step/abstract_stepper.h"
20#include "backends/p4tools/modules/testgen/lib/continuation.h"
21#include "backends/p4tools/modules/testgen/lib/execution_state.h"
22
23namespace P4::P4Tools::P4Testgen {
24
26class CmdStepper : public AbstractStepper {
27 public:
29
30 bool preorder(const IR::AssignmentStatement *assign) override;
31 bool preorder(const IR::P4Parser *p4parser) override;
32 bool preorder(const IR::P4Control *p4control) override;
33 bool preorder(const IR::EmptyStatement *empty) override;
34 bool preorder(const IR::IfStatement *ifStatement) override;
35 bool preorder(const IR::MethodCallStatement *methodCallStatement) override;
36 bool preorder(const IR::P4Program *program) override;
37 bool preorder(const IR::ParserState *parserState) override;
38 bool preorder(const IR::BlockStatement *block) override;
39 bool preorder(const IR::ExitStatement *e) override;
40 bool preorder(const IR::SwitchStatement *switchStatement) override;
41
42 protected:
46 const Constraint *startParser(const IR::P4Parser *parser, ExecutionState &state);
47
50 virtual std::optional<const Constraint *> startParserImpl(const IR::P4Parser *parser,
51 ExecutionState &state) const = 0;
52
56
61 virtual std::map<Continuation::Exception, Continuation> getExceptionHandlers(
62 const IR::P4Parser *parser, Continuation::Body normalContinuation,
63 const ExecutionState &state) const = 0;
64};
65
66} // namespace P4::P4Tools::P4Testgen
67
68#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SMALL_STEP_CMD_STEPPER_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:30
ExecutionState & state
The state being evaluated.
Definition abstract_stepper.h:55
const ProgramInfo & programInfo
Target-specific information about the P4 program being evaluated.
Definition abstract_stepper.h:52
virtual void initializeTargetEnvironment(ExecutionState &state) const =0
virtual std::map< Continuation::Exception, Continuation > getExceptionHandlers(const IR::P4Parser *parser, Continuation::Body normalContinuation, const ExecutionState &state) const =0
virtual std::optional< const Constraint * > startParserImpl(const IR::P4Parser *parser, ExecutionState &state) const =0
const Constraint * startParser(const IR::P4Parser *parser, ExecutionState &state)
Definition core/small_step/cmd_stepper.cpp:447
A continuation body is a list of commands.
Definition continuation.h:135
Represents state of execution after having reached a program point.
Definition execution_state.h:40
Stores target-specific information about a P4 program.
Definition core/program_info.h:27
IR::Expression Constraint
Represents a constraint that can be shipped to and asserted within a solver.
Definition solver.h:23
Definition phv/solver/action_constraint_solver.cpp:33