P4C
The P4 Compiler
Loading...
Searching...
No Matches
controls.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_GRAPHS_CONTROLS_H_
9#define BACKENDS_GRAPHS_CONTROLS_H_
10
11#include "graphs.h"
12
13namespace P4::graphs {
14
15class ControlGraphs : public Graphs {
16 public:
18 public:
19 Graph *pushBack(Graph &currentSubgraph, const cstring &name);
20 Graph *popBack();
21 Graph *getSubgraph() const;
22 cstring getName(const cstring &name) const;
23 bool isEmpty() const;
24
25 private:
26 std::vector<cstring> names{};
27 std::vector<Graph *> subgraphs{};
28 };
29
30 ControlGraphs(P4::ReferenceMap *refMap, P4::TypeMap *typeMap, std::filesystem::path graphsDir);
31
32 bool preorder(const IR::PackageBlock *block) override;
33 bool preorder(const IR::ControlBlock *block) override;
34 bool preorder(const IR::P4Control *cont) override;
35 bool preorder(const IR::BlockStatement *statement) override;
36 bool preorder(const IR::IfStatement *statement) override;
37 bool preorder(const IR::SwitchStatement *statement) override;
38 bool preorder(const IR::MethodCallStatement *statement) override;
39 bool preorder(const IR::BaseAssignmentStatement *statement) override;
40 bool preorder(const IR::ReturnStatement *) override;
41 bool preorder(const IR::ExitStatement *) override;
42 bool preorder(const IR::P4Table *table) override;
43 bool preorder(const IR::Key *key) override;
44 bool preorder(const IR::P4Action *action) override;
45
46 std::vector<Graph *> controlGraphsArray{};
47
48 private:
49 P4::ReferenceMap *refMap;
50 P4::TypeMap *typeMap;
51 const cstring graphsDir;
52 Parents return_parents{};
56 ControlStack controlStack{};
57 std::optional<cstring> instanceName{};
58};
59
60} // namespace P4::graphs
61
62#endif /* BACKENDS_GRAPHS_CONTROLS_H_ */
Class used to encode maps from paths to declarations.
Definition referenceMap.h:67
Definition typeMap.h:32
Definition cstring.h:85
Definition graphs.h:88
Definition controls.cpp:19