P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/modules/smith/targets/tofino/target.h
1#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_TOFINO_TARGET_H_
2#define BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_TOFINO_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::Tofino {
16
18 protected:
19 explicit AbstractTofinoSmithTarget(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 *generateIngressParserBlock() const;
31 [[nodiscard]] IR::P4Control *generateIngressBlock() const;
32 [[nodiscard]] IR::P4Control *generateIngressDeparserBlock() const;
33 [[nodiscard]] IR::P4Parser *generateEgressParserBlock() const;
34 [[nodiscard]] IR::P4Control *generateEgressBlock() const;
35 [[nodiscard]] IR::P4Control *generateEgressDeparserBlock() const;
36
37 public:
39 static void make();
40
41 [[nodiscard]] int writeTargetPreamble(std::ostream *ostream) const override;
42
43 [[nodiscard]] const IR::P4Program *generateP4Program() const override;
44
45 [[nodiscard]] DeclarationGenerator &declarationGenerator() const override {
46 return *_declarationGenerator;
47 }
48
49 [[nodiscard]] ExpressionGenerator &expressionGenerator() const override {
50 return *_expressionGenerator;
51 }
52
53 [[nodiscard]] StatementGenerator &statementGenerator() const override {
54 return *_statementGenerator;
55 }
56
57 [[nodiscard]] ParserGenerator &parserGenerator() const override { return *_parserGenerator; }
58
59 [[nodiscard]] TableGenerator &tableGenerator() const override { return *_tableGenerator; }
60
61 private:
63};
64
65} // namespace P4::P4Tools::P4Smith::Tofino
66
67#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_TARGETS_TOFINO_TARGET_H_ */
Definition declarations.h:13
Definition common/expressions.h:48
Definition p4tools/modules/smith/common/parser.h:12
Definition p4tools/modules/smith/core/target.h:17
Definition p4tools/modules/smith/targets/tofino/target.h:17
Definition p4tools/modules/smith/targets/tofino/target.h:22
static void make()
Registers this target.
Definition p4tools/modules/smith/targets/tofino/target.cpp:41
int writeTargetPreamble(std::ostream *ostream) const override
Definition p4tools/modules/smith/targets/tofino/target.cpp:537