P4C
The P4 Compiler
Loading...
Searching...
No Matches
merge_lowered_parser_states.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_MERGE_LOWERED_PARSER_STATES_H_
20#define BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_MERGE_LOWERED_PARSER_STATES_H_
21
22#include "backends/tofino/bf-p4c/logging/phv_logging.h"
23#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
24#include "backends/tofino/bf-p4c/parde/lowered/compute_lowered_parser_ir.h"
25#include "backends/tofino/bf-p4c/parde/parde_visitor.h"
26#include "backends/tofino/bf-p4c/parde/parser_info.h"
27
28namespace Parde::Lowered {
29
37 const CollectLoweredParserInfo &parser_info;
38 const ComputeLoweredParserIR &computed;
39 ClotInfo &clot;
41
43 const ComputeLoweredParserIR &computed, ClotInfo &c,
45 : parser_info(pi), computed(computed), clot(c), defuseInfo(defuseInfo) {}
46
47 // Compares all fields in two LoweredParserMatch objects
48 // except for the match values. Essentially returns if both
49 // LoweredParserMatch do the same things when matching.
50 //
51 // Equivalent to IR::BFN::LoweredParserMatch::operator==(IR::BFN::LoweredParserMatch const & a)
52 // but considering the loop fields and with the value fields masked off.
53 bool compare_match_operations(const IR::BFN::LoweredParserMatch *a,
54 const IR::BFN::LoweredParserMatch *b);
55
56 const IR::BFN::LoweredParserMatch *get_unconditional_match(
57 const IR::BFN::LoweredParserState *state);
58
60 int byteDelta = 0;
61 bool oob = false;
62
63 explicit RightShiftPacketRVal(int byteDelta) : byteDelta(byteDelta) {}
64
65 bool preorder(IR::BFN::LoweredPacketRVal *rval) override;
66 };
67
68 // Checksum also needs the masks to be shifted
69 struct RightShiftCsumMask : public Modifier {
70 int byteDelta = 0;
71 bool oob = false;
72 bool swapMalform = false;
73
74 explicit RightShiftCsumMask(int byteDelta) : byteDelta(byteDelta) {}
75
76 bool preorder(IR::BFN::LoweredParserChecksum *csum) override;
77 };
78
79 bool can_merge(const IR::BFN::LoweredParserMatch *a, const IR::BFN::LoweredParserMatch *b);
80
81 void do_merge(IR::BFN::LoweredParserMatch *match, const IR::BFN::LoweredParserMatch *next);
82
83 // do not merge loopback state for now, need to maitain loopback pointer TODO
84 bool is_loopback_state(cstring state);
85
86 IR::Node *preorder(IR::BFN::LoweredParserMatch *match) override;
87};
88
89} // namespace Parde::Lowered
90
91#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_MERGE_LOWERED_PARSER_STATES_H_ */
Definition clot_info.h:41
Definition node.h:94
Definition visitor.h:372
Definition cstring.h:85
Definition phv_logging.h:157
Combines the high-level parser IR and the results of PHV allocation to produce a low-level,...
Definition compute_lowered_parser_ir.h:37
After parser lowering, we have converted the parser IR from P4 semantic (action->match) to HW semanti...
Definition merge_lowered_parser_states.h:36
Definition parde_visitor.h:90
Definition lower_parser.cpp:72
Definition merge_lowered_parser_states.h:69
Definition merge_lowered_parser_states.h:59