P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/bmv2/common/options.h
1
/*
2
Copyright 2013-present Barefoot Networks, Inc.
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations 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
24
namespace
P4::BMV2
{
25
26
class
BMV2Options
:
public
CompilerOptions
{
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
63
using
BMV2Context =
P4CContextWithOptions<BMV2Options>
;
64
65
}
// namespace P4::BMV2
66
67
#endif
/* BACKENDS_BMV2_COMMON_OPTIONS_H_ */
P4::BMV2::BMV2Options
Definition
backends/bmv2/common/options.h:26
P4::BMV2::BMV2Options::emitExterns
bool emitExterns
Generate externs.
Definition
backends/bmv2/common/options.h:29
P4::BMV2::BMV2Options::outputFile
std::filesystem::path outputFile
File to output to.
Definition
backends/bmv2/common/options.h:31
P4::BMV2::BMV2Options::loadIRFromJson
bool loadIRFromJson
Read from json.
Definition
backends/bmv2/common/options.h:33
P4::CompilerOptions
Definition
frontends/common/options.h:30
P4::P4CContextWithOptions
Definition
parser_options.h:174
P4::ParserOptions::file
std::filesystem::path file
file to compile (- for stdin)
Definition
parser_options.h:81
P4::BMV2
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition
action.cpp:21
backends
bmv2
common
options.h
Generated by
1.12.0