P4C
The P4 Compiler
Loading...
Searching...
No Matches
compute_lowered_parser_ir.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_COMPUTE_LOWERED_PARSER_IR_H_
20#define BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_COMPUTE_LOWERED_PARSER_IR_H_
21
22#include "backends/tofino/bf-p4c/parde/allocate_parser_checksum.h"
23#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
24#include "backends/tofino/bf-p4c/parde/count_strided_header_refs.h"
25#include "backends/tofino/bf-p4c/parde/parde_visitor.h"
26
27namespace Parde::Lowered {
28
39 const PhvInfo &phv, ClotInfo &clotInfo, const AllocateParserChecksums &checksumAlloc,
40 std::map<gress_t, std::set<PHV::Container>> &origParserZeroInitContainers)
41 : phv(phv),
42 clotInfo(clotInfo),
43 checksumAlloc(checksumAlloc),
44 origParserZeroInitContainers(origParserZeroInitContainers) {
45 // Initialize the map from high-level parser states to low-level parser
46 // states so that null, which represents the end of the parser program
47 // in the high-level IR, is mapped to null, which conveniently enough
48 // means the same thing in the lowered IR.
49 loweredStates[nullptr] = nullptr;
50 }
51
52 std::map<const IR::BFN::ParserState *, const IR::BFN::LoweredParserState *> loweredStates;
53 std::set<const IR::BFN::LoweredParserState *> dontMergeStates;
54
55 const IR::BFN::ContainerRef *igParserError = nullptr;
56 const IR::BFN::ContainerRef *egParserError = nullptr;
57 unsigned egressMetaOpt = 0;
58 unsigned egressMetaSize = 0; // in bytes
59
60 private:
61 profile_t init_apply(const IR::Node *node) override;
62
63 bool preorder(const IR::Type_Header *type) override;
64
66 const IR::BFN::Parser *parser, const IR::BFN::ParserState *state,
67 const std::vector<const IR::BFN::ParserChecksumPrimitive *> &checksums);
68
69 unsigned int rangeToInt(const IR::BFN::PacketRVal *range);
70
74 IR::BFN::LoweredParserChecksum *lowerParserChecksum(
75 const IR::BFN::Parser *parser, const IR::BFN::ParserState *state, cstring name,
76 std::vector<const IR::BFN::ParserChecksumPrimitive *> &checksums);
77
78 unsigned getOffsetIncAmt(const IR::BFN::ParserState *state);
79
80 void postorder(const IR::BFN::ParserState *state) override;
81
82 void end_apply() override;
83
84 const PhvInfo &phv;
85 ClotInfo &clotInfo;
86 const AllocateParserChecksums &checksumAlloc;
87 std::map<gress_t, std::set<PHV::Container>> &origParserZeroInitContainers;
88 // Maps clot tag to checksum unit whose output will be deposited in that CLOT for each gress
89 std::map<gress_t, std::map<unsigned, unsigned>> clotTagToCsumUnit;
90};
91
92} // namespace Parde::Lowered
93
94#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_LOWERED_COMPUTE_LOWERED_PARSER_IR_H_ */
Definition allocate_parser_checksum.h:149
Definition clot_info.h:41
Definition node.h:94
Definition vector.h:59
Definition cstring.h:85
Definition phv_fields.h:1095
Combines the high-level parser IR and the results of PHV allocation to produce a low-level,...
Definition compute_lowered_parser_ir.h:37
Definition parde_visitor.h:66
Definition lower_parser.cpp:72