P4C
The P4 Compiler
Loading...
Searching...
No Matches
frontends/common/options.h
1/*
2Copyright 2013-present Barefoot Networks, Inc.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17/* -*-C++-*- */
18
19#ifndef FRONTENDS_COMMON_OPTIONS_H_
20#define FRONTENDS_COMMON_OPTIONS_H_
21
22#include <filesystem>
23
24#include "parser_options.h"
25// for p4::P4RuntimeFormat definition
26#include "control-plane/p4RuntimeTypes.h"
27
28namespace P4 {
29
31 protected:
32 bool validateOptions() const override;
33
34 public:
35 explicit CompilerOptions(std::string_view defaultMessage = "Compile a P4 program");
36
37 // If true, skip frontend passes whose names are contained in
38 // passesToExcludeFrontend vector.
39 bool excludeFrontendPasses = false;
40 bool listFrontendPasses = false;
41 // If true, skip midend passes whose names are contained in
42 // passesToExcludeMidend vector.
43 bool excludeMidendPasses = false;
44 bool listMidendPasses = false;
45 // If true, skip backend passes whose names are contained in
46 // passesToExcludeBackend vector.
47 bool excludeBackendPasses = false;
48 // Strings matched against pass names that should be excluded from frontend
49 // passes.
50 std::vector<cstring> passesToExcludeFrontend;
51 // Strings matched against pass names that should be excluded from midend
52 // passes.
53 std::vector<cstring> passesToExcludeMidend;
54 // Strings matched against pass names that should be excluded from backend
55 // passes.
56 std::vector<cstring> passesToExcludeBackend;
57 // Dump a JSON representation of the IR in the file.
58 std::filesystem::path dumpJsonFile;
59 // Dump and undump the IR tree.
60 bool debugJson = false;
61 // if this flag is true, compile program in non-debug mode.
62 bool ndebug = false;
63 // Write a P4Runtime control plane API description to the specified file.
64 cstring p4RuntimeFile = nullptr;
65 // Write static table entries as a P4Runtime WriteRequest message to the
66 // specified file.
67 cstring p4RuntimeEntriesFile = nullptr;
68 // Write P4Runtime control plane API description to the specified files.
69 cstring p4RuntimeFiles = nullptr;
70 // Write static table entries as a P4Runtime WriteRequest message to the
71 // specified files.
72 cstring p4RuntimeEntriesFiles = nullptr;
73 // Choose format for P4Runtime API description.
74 P4::P4RuntimeFormat p4RuntimeFormat = P4::P4RuntimeFormat::BINARY;
75 // Pretty-print the program in the specified file.
76 std::filesystem::path prettyPrintFile;
77 // Target.
78 cstring target = nullptr;
79 // Architecture.
80 cstring arch = nullptr;
81 // If true, unroll all parser loops inside the midend.
82 bool loopsUnrolling = false;
83
84 // General optimization options -- can be interpreted by backends in various ways
85 int optimizationLevel = 1;
86 bool optimizeDebug = false; // optimize favoring debuggability
87 bool optimizeSize = false; // optimize favoring size
88
89 virtual bool enable_intrinsic_metadata_fix();
90};
91
92} // namespace P4
93
94#endif /* FRONTENDS_COMMON_OPTIONS_H_ */
Definition frontends/common/options.h:30
bool validateOptions() const override
Definition frontends/common/options.cpp:181
Definition parser_options.h:45
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
P4RuntimeFormat
P4Runtime serialization formats.
Definition p4RuntimeTypes.h:23