P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
removeExits.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 MIDEND_REMOVEEXITS_H_
18#define MIDEND_REMOVEEXITS_H_
19
20#include "frontends/p4/removeReturns.h"
21
22namespace P4 {
23
35 TypeMap *typeMap;
36 // In this class "Return" (inherited from RemoveReturns) should be read as "Exit"
37 std::set<const IR::Node *> callsExit; // actions, tables
38 void callExit(const IR::Node *node);
39
40 public:
41 DoRemoveExits(ReferenceMap *refMap, TypeMap *typeMap)
42 : DoRemoveReturns(refMap, "hasExited"), typeMap(typeMap) {
43 visitDagOnce = false;
44 CHECK_NULL(typeMap);
45 setName("DoRemoveExits");
46 }
47
48 const IR::Node *preorder(IR::ExitStatement *action) override;
49 const IR::Node *preorder(IR::P4Table *table) override;
50
51 const IR::Node *preorder(IR::BlockStatement *statement) override;
52 const IR::Node *preorder(IR::IfStatement *statement) override;
53 const IR::Node *preorder(IR::SwitchStatement *statement) override;
54 const IR::Node *preorder(IR::AssignmentStatement *statement) override;
55 const IR::Node *preorder(IR::MethodCallStatement *statement) override;
56
57 const IR::Node *preorder(IR::P4Action *action) override;
58 const IR::Node *preorder(IR::P4Control *control) override;
59};
60
61class RemoveExits : public PassManager {
62 public:
63 RemoveExits(ReferenceMap *refMap, TypeMap *typeMap, TypeChecking *typeChecking = nullptr) {
64 if (!typeChecking) typeChecking = new TypeChecking(refMap, typeMap);
65 passes.push_back(typeChecking);
66 passes.push_back(new DoRemoveExits(refMap, typeMap));
67 setName("RemoveExits");
68 }
69};
70
71} // namespace P4
72
73#endif /* MIDEND_REMOVEEXITS_H_ */
Definition removeExits.h:34
Definition removeReturns.h:59
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition removeExits.h:61
Definition typeChecker.h:60
Definition typeMap.h:42
Definition applyOptionsPragmas.cpp:24