P4C
The P4 Compiler
Loading...
Searching...
No Matches
compiler_target.h
1#ifndef BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_TARGET_H_
2#define BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_TARGET_H_
3
4#include <string>
5
6#include "backends/p4tools/common/compiler/compiler_result.h"
7#include "backends/p4tools/common/compiler/context.h"
8#include "backends/p4tools/common/compiler/midend.h"
9#include "backends/p4tools/common/core/target.h"
10#include "frontends/common/options.h"
11#include "frontends/common/parser_options.h"
12#include "frontends/p4/frontend.h"
13#include "ir/ir.h"
14#include "lib/compile_context.h"
15
16namespace P4::P4Tools {
17
19class CompilerTarget : public Target {
20 public:
26 std::string_view toolName);
27
32 std::string_view toolName, const std::string &source);
33
34 private:
39 std::string_view toolName, const IR::P4Program *);
40
41 protected:
44 const IR::P4Program *) const;
45
49 static const IR::P4Program *runParser(const ParserOptions &options);
50
54 const IR::P4Program *runFrontend(const CompilerOptions &options,
55 const IR::P4Program *program) const;
56
58 [[nodiscard]] virtual MidEnd mkMidEnd(const CompilerOptions &options) const;
59
61 [[nodiscard]] virtual P4::FrontEnd mkFrontEnd() const;
62
66 const IR::P4Program *runMidEnd(const CompilerOptions &options,
67 const IR::P4Program *program) const;
68
69 explicit CompilerTarget(std::string_view toolName, const std::string &deviceName,
70 const std::string &archName);
71
72 private:
74 static const CompilerTarget &get(std::string_view toolName);
75};
76
77} // namespace P4::P4Tools
78
79#endif /* BACKENDS_P4TOOLS_COMMON_COMPILER_COMPILER_TARGET_H_ */
Definition frontends/common/options.h:30
Definition frontends/p4/frontend.h:69
Encapsulates the details of invoking the P4 compiler for a target device and architecture.
Definition compiler_target.h:19
virtual MidEnd mkMidEnd(const CompilerOptions &options) const
A factory method for providing a target-specific mid end implementation.
Definition compiler_target.cpp:86
const IR::P4Program * runMidEnd(const CompilerOptions &options, const IR::P4Program *program) const
Definition compiler_target.cpp:93
const IR::P4Program * runFrontend(const CompilerOptions &options, const IR::P4Program *program) const
Definition compiler_target.cpp:66
static const IR::P4Program * runParser(const ParserOptions &options)
Definition compiler_target.cpp:58
static CompilerResultOrError runCompiler(const CompilerOptions &options, std::string_view toolName)
Definition compiler_target.cpp:16
virtual CompilerResultOrError runCompilerImpl(const CompilerOptions &options, const IR::P4Program *) const
Definition compiler_target.cpp:43
virtual P4::FrontEnd mkFrontEnd() const
A factory method for providing a target-specific front end implementation.
Definition compiler_target.cpp:84
Definition p4tools/common/compiler/midend.h:24
Definition p4tools/common/core/target.h:19
std::string toolName
The name of the tool supported by this instance.
Definition p4tools/common/core/target.h:57
Definition parser_options.h:47
Definition common/compiler/compiler_result.cpp:3
std::optional< std::reference_wrapper< const CompilerResult > > CompilerResultOrError
Definition common/compiler/compiler_result.h:31