P4C
The P4 Compiler
Loading...
Searching...
No Matches
core/program_info.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_PROGRAM_INFO_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_PROGRAM_INFO_H_
3
4#include <cstddef>
5#include <optional>
6
7#include "backends/p4tools/common/compiler/reachability.h"
8#include "backends/p4tools/common/lib/arch_spec.h"
9#include "ir/ir.h"
10#include "lib/castable.h"
11#include "lib/rtti.h"
12#include "midend/coverage.h"
13
14#include "backends/p4tools/modules/testgen/core/compiler_result.h"
15#include "backends/p4tools/modules/testgen/lib/concolic.h"
16#include "backends/p4tools/modules/testgen/lib/continuation.h"
17
18namespace P4::P4Tools::P4Testgen {
19
21class ProgramInfo : public ICastable {
22 private:
25 std::reference_wrapper<const TestgenCompilerResult> compilerResult;
26
27 protected:
28 explicit ProgramInfo(const TestgenCompilerResult &compilerResult);
29
33
35 std::vector<Continuation::Command> pipelineSequence;
36
38 std::optional<const IR::Expression *> targetConstraints = std::nullopt;
39
42
43 public:
44 ProgramInfo(const ProgramInfo &) = default;
45
46 ProgramInfo(ProgramInfo &&) = default;
47
48 ProgramInfo &operator=(const ProgramInfo &) = default;
49
50 ProgramInfo &operator=(ProgramInfo &&) = default;
51
52 ~ProgramInfo() override = default;
53
57 // The arch map needs to be public to be subclassed.
59 [[nodiscard]] virtual const ArchSpec &getArchSpec() const = 0;
60
62 [[nodiscard]] const std::vector<Continuation::Command> *getPipelineSequence() const;
63
66 [[nodiscard]] std::optional<const IR::Expression *> getTargetConstraints() const;
67
69 [[nodiscard]] virtual const IR::StateVariable &getTargetInputPortVar() const = 0;
70
72 [[nodiscard]] virtual const IR::StateVariable &getTargetOutputPortVar() const = 0;
73
76 [[nodiscard]] virtual const IR::Expression *dropIsActive() const = 0;
77
81 virtual const IR::Expression *createTargetUninitialized(const IR::Type *type,
82 bool forceTaint) const;
83
85 [[nodiscard]] const P4::Coverage::CoverageSet &getCoverableNodes() const;
86
88 [[nodiscard]] const ConcolicMethodImpls *getConcolicMethodImpls() const;
89
90 // @returns the width of the parser error for this specific target.
91 [[nodiscard]] virtual const IR::Type_Bits *getParserErrorType() const = 0;
92
95 [[nodiscard]] cstring getCanonicalBlockName(cstring programBlockName) const;
96
99 [[nodiscard]] virtual const TestgenCompilerResult &getCompilerResult() const;
100
102 [[nodiscard]] const IR::P4Program &getP4Program() const;
103
105 [[nodiscard]] const NodesCallGraph &getCallGraph() const;
106
113 void produceCopyInOutCall(const IR::Parameter *param, size_t paramIdx,
114 const ArchSpec::ArchMember *archMember,
115 std::vector<Continuation::Command> *copyIns,
116 std::vector<Continuation::Command> *copyOuts) const;
117
118 DECLARE_TYPEINFO(ProgramInfo);
119};
120
121} // namespace P4::P4Tools::P4Testgen
122
123#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_CORE_PROGRAM_INFO_H_ */
Definition castable.h:36
Specifies a canonical representation of the target pipeline as documented in P4 code.
Definition p4tools/common/lib/arch_spec.h:13
An ArchMember represents a construct in the pipe. It has a name and parameters.
Definition p4tools/common/lib/arch_spec.h:16
Definition reachability.h:27
Encapsulates a set of concolic method implementations.
Definition lib/concolic.h:33
Stores target-specific information about a P4 program.
Definition core/program_info.h:21
ordered_map< cstring, cstring > blockMap
Maps the programmable blocks in the P4 program to their canonical counterpart.
Definition core/program_info.h:41
const P4::Coverage::CoverageSet & getCoverableNodes() const
Getter to access coverableNodes.
Definition core/program_info.cpp:35
std::optional< const IR::Expression * > targetConstraints
The constraints imposed by the target.
Definition core/program_info.h:38
virtual const IR::Expression * dropIsActive() const =0
virtual const IR::StateVariable & getTargetOutputPortVar() const =0
std::vector< Continuation::Command > pipelineSequence
The execution sequence of the P4 program.
Definition core/program_info.h:35
virtual const IR::Expression * createTargetUninitialized(const IR::Type *type, bool forceTaint) const
Definition core/program_info.cpp:23
virtual const ArchSpec & getArchSpec() const =0
const NodesCallGraph & getCallGraph() const
Definition core/program_info.cpp:43
void produceCopyInOutCall(const IR::Parameter *param, size_t paramIdx, const ArchSpec::ArchMember *archMember, std::vector< Continuation::Command > *copyIns, std::vector< Continuation::Command > *copyOuts) const
Definition core/program_info.cpp:67
ConcolicMethodImpls concolicMethodImpls
Definition core/program_info.h:32
const std::vector< Continuation::Command > * getPipelineSequence() const
Definition core/program_info.cpp:51
const IR::P4Program & getP4Program() const
Definition core/program_info.cpp:41
cstring getCanonicalBlockName(cstring programBlockName) const
Definition core/program_info.cpp:59
virtual const TestgenCompilerResult & getCompilerResult() const
Definition core/program_info.cpp:39
std::optional< const IR::Expression * > getTargetConstraints() const
Definition core/program_info.cpp:55
virtual const IR::StateVariable & getTargetInputPortVar() const =0
const ConcolicMethodImpls * getConcolicMethodImpls() const
Definition core/program_info.cpp:47
Extends the CompilerResult with the associated P4RuntimeApi.
Definition modules/testgen/core/compiler_result.h:11
Definition cstring.h:85
Definition ordered_map.h:32
std::set< const IR::Node *, SourceIdCmp > CoverageSet
Definition coverage.h:39