P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/bmv2/common/options.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_BMV2_COMMON_OPTIONS_H_
9#define BACKENDS_BMV2_COMMON_OPTIONS_H_
10
11#include <getopt.h>
12
13#include "frontends/common/options.h"
14#include "lib/options.h"
15
16namespace P4::BMV2 {
17
18class BMV2Options : public CompilerOptions {
19 public:
21 bool emitExterns = false;
23 std::filesystem::path outputFile;
25 bool loadIRFromJson = false;
26
27 BMV2Options() {
28 registerOption(
29 "--emit-externs", nullptr,
30 [this](const char *) {
31 emitExterns = true;
32 return true;
33 },
34 "[BMv2 back-end] Force externs be emitted by the backend.\n"
35 "The generated code follows the BMv2 JSON specification.");
36 registerOption(
37 "-o", "outfile",
38 [this](const char *arg) {
39 outputFile = arg;
40 return true;
41 },
42 "Write output to outfile");
43 registerOption(
44 "--fromJSON", "file",
45 [this](const char *arg) {
46 loadIRFromJson = true;
47 file = arg;
48 return true;
49 },
50 "Use IR representation from JsonFile dumped previously,"
51 "the compilation starts with reduced midEnd.");
52 }
53};
54
55using BMV2Context = P4CContextWithOptions<BMV2Options>;
56
57} // namespace P4::BMV2
58
59#endif /* BACKENDS_BMV2_COMMON_OPTIONS_H_ */
bool emitExterns
Generate externs.
Definition backends/bmv2/common/options.h:21
std::filesystem::path outputFile
File to output to.
Definition backends/bmv2/common/options.h:23
bool loadIRFromJson
Read from json.
Definition backends/bmv2/common/options.h:25
Definition parser_options.h:170
std::filesystem::path file
file to compile (- for stdin)
Definition parser_options.h:74
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition action.cpp:9