P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4RuntimeAnnotations.h
1/*
2Copyright 2018-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 CONTROL_PLANE_P4RUNTIMEANNOTATIONS_H_
18#define CONTROL_PLANE_P4RUNTIMEANNOTATIONS_H_
19
20#include "frontends/p4/parseAnnotations.h"
21#include "ir/ir.h"
22
23namespace P4 {
24
25namespace ControlPlaneAPI {
26
29 public:
32 "P4Runtime", false,
33 {
34 PARSE("controller_header"_cs, StringLiteral),
35 PARSE_EMPTY("hidden"_cs),
36 PARSE("id"_cs, Constant),
37 PARSE("brief"_cs, StringLiteral),
38 PARSE("description"_cs, StringLiteral),
39 PARSE_KV_LIST("platform_property"_cs),
40 // These annotations are architecture-specific in theory, but
41 // given that they are "reserved" by the P4Runtime
42 // specification, I don't really have any qualms about adding
43 // them here. I don't think it is possible to just run a
44 // different ParseAnnotations pass in the constructor of the
45 // architecture-specific P4RuntimeArchHandlerIface
46 // implementation, since ParseAnnotations modifies the
47 // program. I don't really like the possible alternatives
48 // either: 1) modify the P4RuntimeArchHandlerIface interface
49 // so that each implementation can provide a custom
50 // ParseAnnotations instance, or 2) run a ParseAnnotations
51 // pass "locally" (in this case on action profile instances
52 // since these annotations are for them).
53 PARSE("max_group_size"_cs, Constant),
54 PARSE("selector_size_semantics"_cs, StringLiteral),
55 PARSE("max_member_weight"_cs, Constant),
56 {"p4runtime_translation"_cs, &ParseAnnotations::parseP4rtTranslationAnnotation},
57 }) {}
58};
59
60} // namespace ControlPlaneAPI
61
62} // namespace P4
63
64#endif // CONTROL_PLANE_P4RUNTIMEANNOTATIONS_H_
Parses P4Runtime-specific annotations.
Definition p4RuntimeAnnotations.h:28
Definition parseAnnotations.h:114
ParseAnnotations(bool warn=false)
Produces a pass that rewrites the spec-defined annotations.
Definition parseAnnotations.h:126
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24