P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
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 BMV2 {
25
27 public:
28 // Externs generation
29 bool emitExterns = false;
30 // file to output to
31 cstring outputFile = nullptr;
32 // read from json
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
64
65} // namespace BMV2
66
67#endif /* BACKENDS_BMV2_COMMON_OPTIONS_H_ */
Definition options.h:26
Definition sharedActionSelectorCheck.h:40
Definition options.h:26
Definition cstring.h:72