P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/bmv2/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#ifndef BACKENDS_BMV2_COMMON_OPTIONS_H_
18#define BACKENDS_BMV2_COMMON_OPTIONS_H_
19
20#include <getopt.h>
21
22#include "frontends/common/options.h"
23
24namespace P4::BMV2 {
25
27 public:
29 bool emitExterns = false;
31 std::filesystem::path outputFile;
33 bool loadIRFromJson = false;
34
35 BMV2Options() {
36 registerOption(
37 "--emit-externs", nullptr,
38 [this](const char *) {
39 emitExterns = true;
40 return true;
41 },
42 "[BMv2 back-end] Force externs be emitted by the backend.\n"
43 "The generated code follows the BMv2 JSON specification.");
44 registerOption(
45 "-o", "outfile",
46 [this](const char *arg) {
47 outputFile = arg;
48 return true;
49 },
50 "Write output to outfile");
51 registerOption(
52 "--fromJSON", "file",
53 [this](const char *arg) {
54 loadIRFromJson = true;
55 file = arg;
56 return true;
57 },
58 "Use IR representation from JsonFile dumped previously,"
59 "the compilation starts with reduced midEnd.");
60 }
61};
62
63using BMV2Context = P4CContextWithOptions<BMV2Options>;
64
65} // namespace P4::BMV2
66
67#endif /* BACKENDS_BMV2_COMMON_OPTIONS_H_ */
Definition backends/bmv2/common/options.h:26
bool emitExterns
Generate externs.
Definition backends/bmv2/common/options.h:29
std::filesystem::path outputFile
File to output to.
Definition backends/bmv2/common/options.h:31
bool loadIRFromJson
Read from json.
Definition backends/bmv2/common/options.h:33
Definition frontends/common/options.h:30
Definition parser_options.h:174
std::filesystem::path file
file to compile (- for stdin)
Definition parser_options.h:81
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition action.cpp:21