P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
setHeaders.h
1/*
2Copyright 2017 VMware, 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 FRONTENDS_P4_SETHEADERS_H_
18#define FRONTENDS_P4_SETHEADERS_H_
19
20#include "frontends/common/resolveReferences/resolveReferences.h"
21#include "frontends/p4/typeChecking/typeChecker.h"
22#include "ir/ir.h"
23
24namespace P4 {
48class DoSetHeaders final : public Transform {
49 ReferenceMap *refMap;
50 TypeMap *typeMap;
51
52 bool containsHeaderType(const IR::Type *type);
53 void generateSetValid(const IR::Expression *dest, const IR::Expression *src,
54 const IR::Type *destType, IR::Vector<IR::StatOrDecl> *insert);
55
56 public:
57 DoSetHeaders(ReferenceMap *refMap, TypeMap *typeMap) : refMap(refMap), typeMap(typeMap) {
58 CHECK_NULL(refMap);
59 CHECK_NULL(typeMap);
60 setName("DoSetHeaders");
61 }
62 const IR::Node *postorder(IR::AssignmentStatement *assign) override;
63};
64
65class SetHeaders final : public PassManager {
66 public:
67 SetHeaders(ReferenceMap *refMap, TypeMap *typeMap) {
68 passes.push_back(new P4::TypeChecking(refMap, typeMap));
69 passes.push_back(new P4::DoSetHeaders(refMap, typeMap));
70 setName("SetHeaders");
71 }
72};
73
74} // namespace P4
75
76#endif /* FRONTENDS_P4_SETHEADERS_H_ */
Definition externInstance.h:33
Definition setHeaders.h:48
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition setHeaders.h:65
Definition typeChecker.h:60
Definition typeMap.h:42
Definition applyOptionsPragmas.cpp:24