P4C
The P4 Compiler
Loading...
Searching...
No Matches
flattenHeader.h
1/*
2Copyright 2019-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_FLATTENHEADER_H_
18#define CONTROL_PLANE_FLATTENHEADER_H_
19
20#include <vector>
21
22#include "ir/ir.h"
23
24namespace P4 {
25
26class TypeMap;
27
28namespace ControlPlaneAPI {
29
32 private:
33 P4::TypeMap *typeMap;
34 IR::Type_Header *flattenedHeader;
35 std::vector<cstring> nameSegments{};
36 std::vector<const IR::Annotations *> allAnnotations{};
37 bool needsFlattening{false};
38
39 FlattenHeader(P4::TypeMap *typeMap, IR::Type_Header *flattenedHeader);
40
41 void doFlatten(const IR::Type *type);
42
43 cstring makeName(std::string_view sep) const;
44 const IR::Annotations *mergeAnnotations() const;
45
46 public:
50 static const IR::Type_Header *flatten(P4::TypeMap *typeMap, const IR::Type_Header *headerType);
51};
52
53} // namespace ControlPlaneAPI
54
55} // namespace P4
56
57#endif // CONTROL_PLANE_FLATTENHEADER_H_
Flattens a header type "locally", without modifying the IR.
Definition flattenHeader.h:31
static const IR::Type_Header * flatten(P4::TypeMap *typeMap, const IR::Type_Header *headerType)
Definition flattenHeader.cpp:78
Definition typeMap.h:41
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24