P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/modules/testgen/core/target.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_TARGET_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_TARGET_H_
9
10#include <string>
11
12#include "backends/p4tools/common/compiler/compiler_target.h"
13#include "ir/ir.h"
14#include "ir/solver.h"
15
16#include "backends/p4tools/modules/testgen/core/program_info.h"
17#include "backends/p4tools/modules/testgen/core/small_step/cmd_stepper.h"
18#include "backends/p4tools/modules/testgen/core/small_step/expr_stepper.h"
19#include "backends/p4tools/modules/testgen/core/symbolic_executor/symbolic_executor.h"
20#include "backends/p4tools/modules/testgen/lib/execution_state.h"
21#include "backends/p4tools/modules/testgen/lib/test_backend.h"
22
23namespace P4::P4Tools::P4Testgen {
24
25class TestgenTarget : public CompilerTarget {
26 public:
28 static const TestgenTarget &get();
29
33 static const ProgramInfo *produceProgramInfo(const CompilerResult &compilerResult);
34
36 static TestBackEnd *getTestBackend(const ProgramInfo &programInfo,
37 const TestBackendConfiguration &testBackendConfiguration,
38 SymbolicExecutor &symbex);
39
42 const ProgramInfo &programInfo);
43
46 const ProgramInfo &programInfo);
47
48 protected:
50 [[nodiscard]] const ProgramInfo *produceProgramInfoImpl(
51 const CompilerResult &compilerResult) const;
52
55 const CompilerResult &compilerResult, const IR::Declaration_Instance *mainDecl) const = 0;
56
59 const ProgramInfo &programInfo, const TestBackendConfiguration &testBackendConfiguration,
60 SymbolicExecutor &symbex) const = 0;
61
64 const ProgramInfo &programInfo) const = 0;
65
68 const ProgramInfo &programInfo) const = 0;
69
70 explicit TestgenTarget(const std::string &deviceName, const std::string &archName);
71
73 const IR::P4Program *program) const override;
74
75 [[nodiscard]] ICompileContext *makeContext() const override;
76};
77
78} // namespace P4::P4Tools::P4Testgen
79
80#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_TARGET_H_ */
Provides a higher-level interface for an SMT solver.
Definition solver.h:30
Definition frontends/common/options.h:31
Definition compile_context.h:23
Definition common/compiler/compiler_result.h:20
Implements small-step operational semantics for commands.
Definition core/small_step/cmd_stepper.h:26
Represents state of execution after having reached a program point.
Definition execution_state.h:40
Implements small-step operational semantics for expressions.
Definition core/small_step/expr_stepper.h:26
Stores target-specific information about a P4 program.
Definition core/program_info.h:27
Definition symbolic_executor.h:27
Definition lib/test_backend.h:29
CompilerResultOrError runCompilerImpl(const CompilerOptions &options, const IR::P4Program *program) const override
Definition p4tools/modules/testgen/core/target.cpp:68
virtual ExprStepper * getExprStepperImpl(ExecutionState &state, AbstractSolver &solver, const ProgramInfo &programInfo) const =0
static const ProgramInfo * produceProgramInfo(const CompilerResult &compilerResult)
Definition p4tools/modules/testgen/core/target.cpp:54
virtual TestBackEnd * getTestBackendImpl(const ProgramInfo &programInfo, const TestBackendConfiguration &testBackendConfiguration, SymbolicExecutor &symbex) const =0
virtual CmdStepper * getCmdStepperImpl(ExecutionState &state, AbstractSolver &solver, const ProgramInfo &programInfo) const =0
static CmdStepper * getCmdStepper(ExecutionState &state, AbstractSolver &solver, const ProgramInfo &programInfo)
Provides a CmdStepper implementation for this target.
Definition p4tools/modules/testgen/core/target.cpp:63
static ExprStepper * getExprStepper(ExecutionState &state, AbstractSolver &solver, const ProgramInfo &programInfo)
Provides a ExprStepper implementation for this target.
Definition p4tools/modules/testgen/core/target.cpp:58
virtual const ProgramInfo * produceProgramInfoImpl(const CompilerResult &compilerResult, const IR::Declaration_Instance *mainDecl) const =0
static const TestgenTarget & get()
Definition p4tools/modules/testgen/core/target.cpp:46
ICompileContext * makeContext() const override
Definition p4tools/modules/testgen/core/target.cpp:96
static TestBackEnd * getTestBackend(const ProgramInfo &programInfo, const TestBackendConfiguration &testBackendConfiguration, SymbolicExecutor &symbex)
Returns the test back end associated with this P4Testgen target.
Definition p4tools/modules/testgen/core/target.cpp:48
const ProgramInfo * produceProgramInfoImpl(const CompilerResult &compilerResult) const
Definition p4tools/modules/testgen/core/target.cpp:26
std::optional< std::reference_wrapper< const CompilerResult > > CompilerResultOrError
Definition common/compiler/compiler_result.h:37
Definition phv/solver/action_constraint_solver.cpp:33
Definition test_backend_configuration.h:22