P4C
The P4 Compiler
Loading...
Searching...
No Matches
parser_loops_info.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PARDE_PARSER_LOOPS_INFO_H_
20#define BACKENDS_TOFINO_BF_P4C_PARDE_PARSER_LOOPS_INFO_H_
21
22#include "backends/tofino/bf-p4c/ir/gress.h"
23#include "ir/ir.h"
24#include "lib/cstring.h"
25#include "lib/exceptions.h"
26#include "logging/pass_manager.h"
27
28namespace BFN {
29
30struct ParserPragmas : public Inspector {
31 static bool checkNumArgs(cstring pragma, const IR::Vector<IR::Expression> &exprs,
32 unsigned expected);
33
34 static bool checkGress(cstring pragma, const IR::StringLiteral *gress);
35
36 bool preorder(const IR::Annotation *annot) override;
37
38 std::set<const IR::ParserState *> terminate_parsing;
39 std::map<const IR::ParserState *, unsigned> force_shift;
40 std::map<const IR::ParserState *, unsigned> max_loop_depth;
41
42 std::set<cstring> dont_unroll;
43};
44
51 struct GetMaxLoopDepth;
52
53 ParserLoopsInfo(P4::ReferenceMap *refMap, const IR::BFN::TnaParser *parser,
54 const ParserPragmas &pm);
55
56 const ParserPragmas &parserPragmas;
57
58 std::set<std::set<cstring>> loops;
59 std::map<cstring, int> max_loop_depth;
60 std::set<cstring> has_next; // states that have stack "next" references
61
62 const std::set<cstring> *find_loop(cstring state) const;
63
65 bool has_next_on_loop(cstring state) const;
66
67 bool dont_unroll(cstring state) const;
68
70 bool need_strided_allocation(cstring state) const;
71};
72
73} // namespace BFN
74
75#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_PARSER_LOOPS_INFO_H_ */
Definition vector.h:59
Definition visitor.h:400
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition cstring.h:85
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Definition parser_loops_info.cpp:117
Definition parser_loops_info.h:48
bool need_strided_allocation(cstring state) const
state is on loop that requires strided allocation
Definition parser_loops_info.cpp:224
bool has_next_on_loop(cstring state) const
Returns true if the state is on loop that has "next" reference.
Definition parser_loops_info.cpp:202
Definition parser_loops_info.h:30