P4C
The P4 Compiler
Loading...
Searching...
No Matches
path_linearizer.h
1
19#ifndef BF_P4C_MIDEND_PATH_LINEARIZER_H_
20#define BF_P4C_MIDEND_PATH_LINEARIZER_H_
21
22#include <optional>
23#include <vector>
24
25#include "ir/ir.h"
26
27namespace BFN {
28
53struct LinearPath {
54 std::vector<const IR::Expression *> components;
55 cstring to_cstring();
56 cstring to_cstring(cstring, bool);
57};
58
75struct PathLinearizer : public Inspector {
76 std::optional<LinearPath> linearPath;
77
78 private:
79 profile_t init_apply(const IR::Node *root) override;
80 void postorder(const IR::Path *) override;
81 void postorder(const IR::PathExpression *path) override;
82 void postorder(const IR::ConcreteHeaderRef *href) override;
83 void postorder(const IR::Member *member) override;
84 void postorder(const IR::Slice *slice) override;
85 void postorder(const IR::ArrayIndex *array) override;
86 bool preorder(const IR::HeaderOrMetadata *href) override;
87 bool preorder(const IR::Constant *) override;
88 void postorder(const IR::Node *node) override;
89 void end_apply() override;
90
91 public:
92 static cstring convert(const IR::Expression *expr) {
93 PathLinearizer linearizer;
94 expr->apply(linearizer);
95 return linearizer.linearPath->to_cstring();
96 }
97};
98
99} // namespace BFN
100
101#endif /* BF_P4C_MIDEND_PATH_LINEARIZER_H_ */
Definition node.h:94
Definition visitor.h:400
Definition visitor.h:78
Definition cstring.h:85
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Definition path_linearizer.h:53
Definition path_linearizer.h:75