P4C
The P4 Compiler
Loading...
Searching...
No Matches
targets/bmv2/program_info.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_TARGETS_BMV2_PROGRAM_INFO_H_
8#define BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_PROGRAM_INFO_H_
9
10#include <cstddef>
11
12#include "control-plane/p4RuntimeSerializer.h"
13#include "ir/ir.h"
14#include "lib/cstring.h"
15
16#include "backends/p4tools/modules/testgen/core/program_info.h"
17#include "backends/p4tools/modules/testgen/targets/bmv2/compiler_result.h"
18
20
21class Bmv2V1ModelProgramInfo : public ProgramInfo {
22 private:
26
28 const std::map<int, int> declIdToGress;
29
31 static const IR::Type_Bits PARSER_ERR_BITS;
32
35 std::vector<Continuation::Command> processDeclaration(const IR::Type_Declaration *typeDecl,
36 size_t blockIdx) const;
37
38 public:
41 std::map<int, int> declIdToGress);
42
44 int getGress(const IR::Type_Declaration *) const;
45
47 [[nodiscard]] P4::P4RuntimeAPI getP4RuntimeAPI() const;
48
50 const IR::P4Table *getTableofDirectExtern(const IR::IDeclaration *directExternDecl) const;
51
53 [[nodiscard]] const ArchSpec &getArchSpec() const override;
54
57 const;
58
61 [[nodiscard]] const IR::PathExpression *getBlockParam(cstring blockLabel,
62 size_t paramIndex) const;
63
64 [[nodiscard]] const IR::StateVariable &getTargetInputPortVar() const override;
65
67 static const IR::Expression *getPortConstraint(
68 const IR::StateVariable &portVar,
69 const std::vector<std::pair<int, int>> &permittedPortRanges);
70
71 [[nodiscard]] const IR::StateVariable &getTargetOutputPortVar() const override;
72
73 [[nodiscard]] const IR::Expression *dropIsActive() const override;
74
75 [[nodiscard]] const IR::Type_Bits *getParserErrorType() const override;
76
77 [[nodiscard]] const BMv2V1ModelCompilerResult &getCompilerResult() const override;
78
84 static const IR::Member *getParserParamVar(const IR::P4Parser *parser, const IR::Type *type,
85 size_t paramIndex, cstring paramLabel);
86
88 static const ArchSpec ARCH_SPEC;
89
90 DECLARE_TYPEINFO(Bmv2V1ModelProgramInfo, ProgramInfo);
91};
92
93} // namespace P4::P4Tools::P4Testgen::Bmv2
94
95#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_TARGETS_BMV2_PROGRAM_INFO_H_ */
The Declaration interface, representing objects with names.
Definition declaration.h:17
Specifies a canonical representation of the target pipeline as documented in P4 code.
Definition p4tools/common/lib/arch_spec.h:19
Extends the CompilerResult with information specific to the V1Model running on BMv2.
Definition modules/testgen/targets/bmv2/compiler_result.h:22
static const IR::Expression * getPortConstraint(const IR::StateVariable &portVar, const std::vector< std::pair< int, int > > &permittedPortRanges)
int getGress(const IR::Type_Declaration *) const
Definition targets/bmv2/program_info.cpp:107
Bmv2V1ModelProgramInfo(const BMv2V1ModelCompilerResult &compilerResult, ordered_map< cstring, const IR::Type_Declaration * > inputBlocks, std::map< int, int > declIdToGress)
Definition targets/bmv2/program_info.cpp:39
const IR::P4Table * getTableofDirectExtern(const IR::IDeclaration *directExternDecl) const
Definition targets/bmv2/program_info.cpp:89
const IR::Expression * dropIsActive() const override
Definition targets/bmv2/program_info.cpp:201
const BMv2V1ModelCompilerResult & getCompilerResult() const override
Definition targets/bmv2/program_info.cpp:232
static const ArchSpec ARCH_SPEC
Definition targets/bmv2/program_info.h:88
const IR::StateVariable & getTargetInputPortVar() const override
Definition targets/bmv2/program_info.cpp:189
const ordered_map< cstring, const IR::Type_Declaration * > * getProgrammableBlocks() const
Definition targets/bmv2/program_info.cpp:103
const ArchSpec & getArchSpec() const override
Definition targets/bmv2/program_info.cpp:100
static const IR::Member * getParserParamVar(const IR::P4Parser *parser, const IR::Type *type, size_t paramIndex, cstring paramLabel)
Definition targets/bmv2/program_info.cpp:240
P4::P4RuntimeAPI getP4RuntimeAPI() const
Definition targets/bmv2/program_info.cpp:236
const IR::StateVariable & getTargetOutputPortVar() const override
Definition targets/bmv2/program_info.cpp:195
const IR::PathExpression * getBlockParam(cstring blockLabel, size_t paramIndex) const
Definition targets/bmv2/program_info.cpp:209
Definition cstring.h:85
Definition ordered_map.h:32
Inja.
Definition targets/bmv2/cmd_stepper.cpp:37
Definition p4RuntimeSerializer.h:48