P4C
The P4 Compiler
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
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
29 protected:
30 bool validateOptions() const override;
31
32 public:
33 explicit CompilerOptions(std::string_view defaultMessage = "Compile a P4 program");
34
35 // If true, skip frontend passes whose names are contained in
36 // passesToExcludeFrontend vector.
37 bool excludeFrontendPasses = false;
38 bool listFrontendPasses = false;
39 // If true, skip midend passes whose names are contained in
40 // passesToExcludeMidend vector.
41 bool excludeMidendPasses = false;
42 bool listMidendPasses = false;
43 // If true, skip backend passes whose names are contained in
44 // passesToExcludeBackend vector.
45 bool excludeBackendPasses = false;
46 // Strings matched against pass names that should be excluded from frontend
47 // passes.
48 std::vector<cstring> passesToExcludeFrontend;
49 // Strings matched against pass names that should be excluded from midend
50 // passes.
51 std::vector<cstring> passesToExcludeMidend;
52 // Strings matched against pass names that should be excluded from backend
53 // passes.
54 std::vector<cstring> passesToExcludeBackend;
55 // Dump a JSON representation of the IR in the file.
56 std::filesystem::path dumpJsonFile;
57 // Dump and undump the IR tree.
58 bool debugJson = false;
59 // if this flag is true, compile program in non-debug mode.
60 bool ndebug = false;
61 // Write a P4Runtime control plane API description to the specified file.
62 cstring p4RuntimeFile = nullptr;
63 // Write static table entries as a P4Runtime WriteRequest message to the
64 // specified file.
65 cstring p4RuntimeEntriesFile = nullptr;
66 // Write P4Runtime control plane API description to the specified files.
67 cstring p4RuntimeFiles = nullptr;
68 // Write static table entries as a P4Runtime WriteRequest message to the
69 // specified files.
70 cstring p4RuntimeEntriesFiles = nullptr;
71 // Choose format for P4Runtime API description.
72 P4::P4RuntimeFormat p4RuntimeFormat = P4::P4RuntimeFormat::BINARY;
73 // Pretty-print the program in the specified file.
74 std::filesystem::path prettyPrintFile;
75 // Target.
76 cstring target = nullptr;
77 // Architecture.
78 cstring arch = nullptr;
79 // If true, unroll all parser loops inside the midend.
80 bool loopsUnrolling = false;
81
82 // General optimization options -- can be interpreted by backends in various ways
83 int optimizationLevel = 1;
84 bool optimizeDebug = false; // optimize favoring debuggability
85 bool optimizeSize = false; // optimize favoring size
86
87 virtual bool enable_intrinsic_metadata_fix();
88};
89#endif /* FRONTENDS_COMMON_OPTIONS_H_ */
Definition frontends/common/options.h:28
bool validateOptions() const override
Definition frontends/common/options.cpp:179
Definition parser_options.h:40
Definition cstring.h:80
P4RuntimeFormat
P4Runtime serialization formats.
Definition p4RuntimeTypes.h:23