P4C
The P4 Compiler
Loading...
Searching...
No Matches
small_step.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SMALL_STEP_SMALL_STEP_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SMALL_STEP_SMALL_STEP_H_
3
4#include <cstdint>
5#include <functional>
6#include <optional>
7#include <utility>
8#include <vector>
9
10#include "backends/p4tools/common/compiler/reachability.h"
11#include "ir/node.h"
12#include "ir/solver.h"
13#include "midend/coverage.h"
14
15#include "backends/p4tools/modules/testgen/core/program_info.h"
16#include "backends/p4tools/modules/testgen/lib/execution_state.h"
17
18namespace P4::P4Tools::P4Testgen {
19
23 friend class CommandVisitor;
24
25 public:
28 struct Branch {
29 const Constraint *constraint;
30
31 ExecutionStateReference nextState;
32
33 P4::Coverage::CoverageSet potentialNodes;
34
36 explicit Branch(ExecutionState &nextState);
37
40 Branch(std::optional<const Constraint *> c, const ExecutionState &prevState,
41 ExecutionState &nextState);
42
45 Branch(std::optional<const Constraint *> c, const ExecutionState &prevState,
46 ExecutionState &nextState, P4::Coverage::CoverageSet potentialNodes);
47 };
48
49 using Result = std::vector<Branch> *;
50
53 static constexpr uint64_t MAX_GUARD_VIOLATIONS = 100;
54
55 private:
57 const ProgramInfo &programInfo;
58
61
63 uint64_t violatedGuardConditions = 0;
64
66 ReachabilityEngine *reachabilityEngine = nullptr;
67
68 using REngineType = std::pair<ReachabilityResult, std::vector<SmallStepEvaluator::Branch> *>;
69
70 static void renginePostprocessing(ReachabilityResult &result,
71 std::vector<SmallStepEvaluator::Branch> *branches);
72
73 REngineType renginePreprocessing(SmallStepEvaluator &stepper, const ExecutionState &nextState,
74 const IR::Node *node);
75
76 public:
77 Result step(ExecutionState &state);
78
80};
81
82} // namespace P4::P4Tools::P4Testgen
83
84#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_SMALL_STEP_SMALL_STEP_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:24
Definition node.h:94
Definition small_step.cpp:112
Represents state of execution after having reached a program point.
Definition execution_state.h:34
Stores target-specific information about a P4 program.
Definition core/program_info.h:21
static constexpr uint64_t MAX_GUARD_VIOLATIONS
Definition small_step.h:53
Definition reachability.h:159
std::set< const IR::Node *, SourceIdCmp > CoverageSet
Definition coverage.h:39
IR::Expression Constraint
Represents a constraint that can be shipped to and asserted within a solver.
Definition solver.h:17
Definition phv/solver/action_constraint_solver.cpp:33
Branch(ExecutionState &nextState)
Simple branch without any constraint.
Definition small_step.cpp:33