P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/modules/smith/targets/generic/target.h
1#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_GENERIC_TARGET_H_
2#define BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_GENERIC_TARGET_H_
3
4#include <ostream>
5#include <string>
6
7#include "backends/p4tools/modules/smith/common/declarations.h"
8#include "backends/p4tools/modules/smith/common/expressions.h"
9#include "backends/p4tools/modules/smith/common/parser.h"
10#include "backends/p4tools/modules/smith/common/statements.h"
11#include "backends/p4tools/modules/smith/common/table.h"
12#include "backends/p4tools/modules/smith/core/target.h"
13#include "ir/ir.h"
14
15namespace P4::P4Tools::P4Smith::Generic {
16
18 protected:
19 explicit AbstractGenericSmithTarget(const std::string &deviceName, const std::string &archName);
20};
21
23 private:
24 DeclarationGenerator *_declarationGenerator = new DeclarationGenerator(*this);
25 ExpressionGenerator *_expressionGenerator = new ExpressionGenerator(*this);
26 StatementGenerator *_statementGenerator = new StatementGenerator(*this);
27 ParserGenerator *_parserGenerator = new ParserGenerator(*this);
28 TableGenerator *_tableGenerator = new TableGenerator(*this);
29
30 [[nodiscard]] IR::P4Parser *generateParserBlock() const;
31 [[nodiscard]] IR::P4Control *generateIngressBlock() const;
32 [[nodiscard]] static IR::Declaration_Instance *generateMainPackage();
33
34 [[nodiscard]] IR::Type_Parser *generateParserBlockType() const;
35 [[nodiscard]] IR::Type_Control *generateIngressBlockType() const;
36 [[nodiscard]] IR::Type_Package *generatePackageType() const;
37
38 public:
40 static void make();
41
42 // Retrieve the singleton instance for the current target.
43 [[nodiscard]] static GenericCoreSmithTarget *getInstance();
44
45 [[nodiscard]] int writeTargetPreamble(std::ostream *ostream) const override;
46
47 [[nodiscard]] const IR::P4Program *generateP4Program() const override;
48
49 [[nodiscard]] DeclarationGenerator &declarationGenerator() const override {
50 return *_declarationGenerator;
51 }
52
53 [[nodiscard]] ExpressionGenerator &expressionGenerator() const override {
54 return *_expressionGenerator;
55 }
56
57 [[nodiscard]] StatementGenerator &statementGenerator() const override {
58 return *_statementGenerator;
59 }
60
61 [[nodiscard]] ParserGenerator &parserGenerator() const override { return *_parserGenerator; }
62
63 [[nodiscard]] TableGenerator &tableGenerator() const override { return *_tableGenerator; }
64
65 private:
67};
68
69} // namespace P4::P4Tools::P4Smith::Generic
70
71#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_GENERIC_TARGET_H_ */
Definition declarations.h:13
Definition common/expressions.h:48
Definition p4tools/modules/smith/targets/generic/target.h:17
Definition p4tools/modules/smith/targets/generic/target.h:22
int writeTargetPreamble(std::ostream *ostream) const override
Definition p4tools/modules/smith/targets/generic/target.cpp:171
static void make()
Registers this target.
Definition p4tools/modules/smith/targets/generic/target.cpp:40
Definition p4tools/modules/smith/common/parser.h:12
Definition p4tools/modules/smith/core/target.h:17