P4C
The P4 Compiler
Loading...
Searching...
No Matches
applyOptionsPragmas.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 FRONTENDS_COMMON_APPLYOPTIONSPRAGMAS_H_
9#define FRONTENDS_COMMON_APPLYOPTIONSPRAGMAS_H_
10
11#include <optional>
12#include <vector>
13
14#include "ir/ir.h"
15#include "ir/visitor.h"
16#include "lib/cstring.h"
17
18namespace P4 {
19
23 public:
24 using CommandLineOptions = std::vector<const char *>;
25
26 virtual std::optional<CommandLineOptions> tryToParse(const IR::Annotation *annotation) = 0;
27};
28
45class ApplyOptionsPragmas : public Inspector {
46 public:
47 explicit ApplyOptionsPragmas(IOptionPragmaParser &parser);
48
49 bool preorder(const IR::Annotation *annotation) override;
50 void end_apply() override;
51
52 private:
53 IOptionPragmaParser &parser;
54 IOptionPragmaParser::CommandLineOptions options;
55};
56
69class P4COptionPragmaParser : public IOptionPragmaParser {
70 bool supportCommandLinePragma;
71
72 public:
73 std::optional<CommandLineOptions> tryToParse(const IR::Annotation *annotation) override;
74
75 explicit P4COptionPragmaParser(bool supportCommandLinePragma)
76 : supportCommandLinePragma(supportCommandLinePragma) {}
77
78 private:
79 std::optional<CommandLineOptions> parseDiagnostic(const IR::Annotation *annotation);
80};
81
82} // namespace P4
83
84#endif /* FRONTENDS_COMMON_APPLYOPTIONSPRAGMAS_H_ */
Definition applyOptionsPragmas.h:22
Definition visitor.h:418
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13