P4C
The P4 Compiler
Loading...
Searching...
No Matches
clot_candidate.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_CLOT_CANDIDATE_H_
20#define BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_CLOT_CANDIDATE_H_
21
22#include "bf-p4c/lib/cmp.h"
23#include "clot_info.h"
24#include "pseudoheader.h"
25
26using StatePair = std::pair<const IR::BFN::ParserState *, const IR::BFN::ParserState *>;
28
30
31class ClotCandidate : public LiftLess<ClotCandidate> {
32 public:
33 const Pseudoheader *pseudoheader;
34 PovBitSet pov_bits;
35
36 private:
39 // Invariant: field slices are extracted in the same set of parser states.
40 const std::vector<const FieldSliceExtractInfo *> extract_infos;
41
44 std::vector<unsigned> can_start_indices_;
45
48 std::vector<unsigned> can_end_indices_;
49
54 std::map<const IR::BFN::ParserState *, bitvec> parser_state_to_checksum_bits;
55 std::set<const PHV::FieldSlice *> checksum_slices;
56 unsigned checksum_bits;
57
62 std::map<const IR::BFN::ParserState *, bitvec> parser_state_to_modified_bits;
63 std::set<const PHV::FieldSlice *> modified_slices;
64 unsigned modified_bits;
65
70 std::map<const IR::BFN::ParserState *, bitvec> parser_state_to_readonly_bits;
71 std::set<const PHV::FieldSlice *> readonly_slices;
72 unsigned readonly_bits;
73
78 std::map<const IR::BFN::ParserState *, bitvec> parser_state_to_unused_bits;
79 std::set<const PHV::FieldSlice *> unused_slices;
80 unsigned unused_bits;
81
82 std::map<const IR::BFN::ParserState *, unsigned> parser_state_to_size_in_bits;
83
84 static unsigned nextId;
85
86 public:
87 const unsigned id;
88
90 unsigned max_size_in_bits() const;
91
93 unsigned size_in_bits(const IR::BFN::ParserState *parser_state) const;
94
100
105
106 ClotCandidate(const ClotInfo &clotInfo, const Pseudoheader *pseudoheader,
107 const std::vector<const FieldSliceExtractInfo *> &extract_infos,
108 bool afterAllocatedClot = false, bool beforeAllocatedClot = false);
109
112
114 gress_t thread() const;
115
118
120 unsigned bit_in_byte_offset() const;
121
122 const std::vector<const FieldSliceExtractInfo *> &extracts() const;
123
126 const std::vector<unsigned> &can_start_indices() const;
127
130 const std::vector<unsigned> &can_end_indices() const;
131
140 const std::map<unsigned, StatePairSet> byte_gaps(const CollectParserInfo &parserInfo,
141 const ClotCandidate *other) const;
142
147
149 bool operator<(const ClotCandidate &other) const;
150
151 std::string print() const;
152};
153
154#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_CLOT_CANDIDATE_H_ */
Definition clot_candidate.h:31
const ordered_map< const IR::BFN::ParserState *, unsigned > & state_bit_offsets() const
The state-relative offsets, in bits, of the first extract in the candidate.
Definition clot_candidate.cpp:120
ordered_set< const IR::BFN::ParserState * > states() const
The parser states containing this candidate's extracts.
Definition clot_candidate.cpp:114
const std::vector< unsigned > & can_start_indices() const
Definition clot_candidate.cpp:133
unsigned max_size_in_bits() const
The maximum length of the candidate, in bits.
Definition clot_candidate.cpp:24
gress_t thread() const
The pipe thread for the extracts in this candidate.
Definition clot_candidate.cpp:118
bool operator<(const ClotCandidate &other) const
Lexicographic order according to (number of unused bits, number of read-only bits,...
Definition clot_candidate.cpp:186
bool beforeAllocatedClot
Definition clot_candidate.h:104
bool afterAllocatedClot
Definition clot_candidate.h:99
const std::vector< unsigned > & can_end_indices() const
Definition clot_candidate.cpp:135
unsigned bit_in_byte_offset() const
The bit-in-byte offset of the first extract in the candidate.
Definition clot_candidate.cpp:125
unsigned size_in_bits(const IR::BFN::ParserState *parser_state) const
The length of the candidate for a given parser state, in bits.
Definition clot_candidate.cpp:36
const ClotCandidate * mark_adjacencies(bool afterAllocatedClot, bool beforeAllocatedClot) const
Definition clot_candidate.cpp:171
const std::map< unsigned, StatePairSet > byte_gaps(const CollectParserInfo &parserInfo, const ClotCandidate *other) const
Definition clot_candidate.cpp:137
Definition clot_info.h:41
Holds information relating to a field slice's extract.
Definition field_slice_extract_info.h:31
Implements comparisons correctly.
Definition field_slice_set.h:25
Definition cmp.h:55
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition pseudoheader.h:27