P4C
The P4 Compiler
Loading...
Searching...
No Matches
parser_loops_info.h
1
18
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 "frontends/common/resolveReferences/referenceMap.h"
23#include "ir/ir.h"
24#include "lib/cstring.h"
25
26namespace BFN {
27
28struct ParserPragmas : public Inspector {
29 static bool checkNumArgs(cstring pragma, const IR::Vector<IR::Expression> &exprs,
30 unsigned expected);
31
32 static bool checkGress(cstring pragma, const IR::StringLiteral *gress);
33
34 bool preorder(const IR::Annotation *annot) override;
35
36 std::set<const IR::ParserState *> terminate_parsing;
37 std::map<const IR::ParserState *, unsigned> force_shift;
38 std::map<const IR::ParserState *, unsigned> max_loop_depth;
39
40 std::set<cstring> dont_unroll;
41};
42
46struct ParserLoopsInfo {
49 struct GetMaxLoopDepth;
50
51 ParserLoopsInfo(P4::ReferenceMap *refMap, const IR::BFN::TnaParser *parser,
52 const ParserPragmas &pm);
53
54 const ParserPragmas &parserPragmas;
55
56 std::set<std::set<cstring>> loops;
57 std::map<cstring, int> max_loop_depth;
58 std::set<cstring> has_next; // states that have stack "next" references
59
60 const std::set<cstring> *find_loop(cstring state) const;
61
63 bool has_next_on_loop(cstring state) const;
64
65 bool dont_unroll(cstring state) const;
66
68 bool need_strided_allocation(cstring state) const;
69};
70
71} // namespace BFN
72
73#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_PARSER_LOOPS_INFO_H_ */
Definition vector.h:59
Definition visitor.h:413
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
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:28