P4C
The P4 Compiler
Loading...
Searching...
No Matches
controls.h
1/*
2Copyright 2013-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 BACKENDS_GRAPHS_CONTROLS_H_
18#define BACKENDS_GRAPHS_CONTROLS_H_
19
20#include "graphs.h"
21
22namespace P4::graphs {
23
24class ControlGraphs : public Graphs {
25 public:
27 public:
28 Graph *pushBack(Graph &currentSubgraph, const cstring &name);
29 Graph *popBack();
30 Graph *getSubgraph() const;
31 cstring getName(const cstring &name) const;
32 bool isEmpty() const;
33
34 private:
35 std::vector<cstring> names{};
36 std::vector<Graph *> subgraphs{};
37 };
38
39 ControlGraphs(P4::ReferenceMap *refMap, P4::TypeMap *typeMap, std::filesystem::path graphsDir);
40
41 bool preorder(const IR::PackageBlock *block) override;
42 bool preorder(const IR::ControlBlock *block) override;
43 bool preorder(const IR::P4Control *cont) override;
44 bool preorder(const IR::BlockStatement *statement) override;
45 bool preorder(const IR::IfStatement *statement) override;
46 bool preorder(const IR::SwitchStatement *statement) override;
47 bool preorder(const IR::MethodCallStatement *statement) override;
48 bool preorder(const IR::AssignmentStatement *statement) override;
49 bool preorder(const IR::ReturnStatement *) override;
50 bool preorder(const IR::ExitStatement *) override;
51 bool preorder(const IR::P4Table *table) override;
52 bool preorder(const IR::Key *key) override;
53 bool preorder(const IR::P4Action *action) override;
54
55 std::vector<Graph *> controlGraphsArray{};
56
57 private:
58 P4::ReferenceMap *refMap;
59 P4::TypeMap *typeMap;
60 const cstring graphsDir;
61 Parents return_parents{};
65 ControlStack controlStack{};
66 std::optional<cstring> instanceName{};
67};
68
69} // namespace P4::graphs
70
71#endif /* BACKENDS_GRAPHS_CONTROLS_H_ */
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition typeMap.h:41
Definition cstring.h:85
Definition controls.h:24
Definition graphs.h:97
Definition controls.cpp:30