52 bitvec headers_always_encountered;
58 headers_live_during_action;
61 size_t get_header_index(
cstring header_name);
62 cstring get_header_name(
size_t header_index);
63 void print_mutually_exclusive_headers();
64 void pretty_print_bitvec(
bitvec bv);
65 void print_header_encounter_info();
66 void print_headers_live_during_action();
78class AddParserHeadersToHeaderMutexMatrix :
public BuildMutex {
80 bitvec headers_encountered;
84 static bool ignore_field(
const PHV::Field *field) {
91 bool preorder(
const IR::MAU::TableSeq *)
override {
return false; }
92 bool preorder(
const IR::BFN::Deparser *)
override {
return false; }
93 void flow_merge(
Visitor &other_)
override;
95 void end_apply()
override;
98 AddParserHeadersToHeaderMutexMatrix(
PhvInfo &phv,
const bitvec &neverOverlay,
100 : BuildMutex(phv, neverOverlay, pragma, ignore_field), header_info(header_info) {}
101 AddParserHeadersToHeaderMutexMatrix *clone()
const override {
102 return new AddParserHeadersToHeaderMutexMatrix(*
this);
124class FindPovAndParserErrorInMau :
public HeaderNameMauInspector {
126 bool &mau_contains_pov_read_write;
127 bool &mau_handles_parser_error;
136 bool is_original_parser_err_field(
const PHV::Field *field);
152 bool preorder(
const IR::Expression *expression)
override;
156 void end_apply()
override;
159 FindPovAndParserErrorInMau(
PhvInfo &phv,
HeaderInfo &headers,
bool &mau_contains_pov_read_write,
160 bool &mau_handles_parser_error)
161 : HeaderNameMauInspector(phv),
162 header_info(headers),
163 mau_contains_pov_read_write(mau_contains_pov_read_write),
164 mau_handles_parser_error(mau_handles_parser_error) {}
207class FindParserHeaderEncounterInfo :
public ParserDominatorBuilder {
216 static bool ignore_field(
const PHV::Field *field) {
219 bitvec get_headers_extracted_in_states(std::set<const IR::BFN::ParserState *> states);
220 bitvec get_surely_not_extracted(std::set<const IR::BFN::ParserState *> not_visited_states);
221 bitvec get_always_extracted();
224 profile_t init_apply(
const IR::Node *root)
override;
225 bool preorder(
const IR::BFN::Extract *extract)
override;
227 void build_header_encounter_maps();
228 void end_apply()
override;
232 : phv(phv), header_info(header_info) {}
298 bool &mau_handles_parser_error;
312 cstring visiting_gateway_row_tag;
313 std::map<cstring, std::set<const IR::Expression *>> visiting_gateway_rows;
314 const IR::MAU::Table *visiting =
nullptr;
317 const PHV::Field *get_phv_field(
const IR::Expression *expression);
318 HeaderState get_header_state(
size_t header_index);
319 HeaderState get_header_state(
cstring header_name);
320 void print_active_headers();
321 std::string get_active_headers();
322 void set_header_state(
size_t header_index, HeaderState value);
323 void set_header_state(
cstring header_name, HeaderState value);
325 bool preorder(
const IR::BFN::Parser *parser)
override {
326 gress = toString(parser->gress);
330 void pre_visit_table_next(
const IR::MAU::Table *tbl,
cstring tag)
override;
332 ExcludeMAUNotMutexHeaders *clone()
const override {
333 return new ExcludeMAUNotMutexHeaders(*
this);
337 bool is_set(
const IR::MAU::Primitive *primitive);
338 bool is_set_header_pov(
const IR::MAU::Primitive *primitive);
339 bool is_set_header_valid(
const IR::MAU::Primitive *primitive);
340 bool is_set_header_invalid(
const IR::MAU::Primitive *primitive);
341 bool is_set_header_pov_to_other_header_pov(
const IR::MAU::Primitive *primitive);
342 void init_active_headers();
343 void init_extracted_headers();
344 void init_not_extracted_headers();
347 bool is_header_pov_lhs_constant_rhs_operation_relation(
const IR::Operation_Relation *op_rel);
348 std::optional<std::pair<cstring, HeaderState>> get_header_to_state_pair_from_operation_relation(
349 const IR::Operation_Relation *op_rel);
350 std::optional<std::pair<const IR::Expression *, cstring>> get_gateway_row();
351 std::vector<std::pair<cstring, HeaderState>>
352 get_all_header_to_state_pairs_from_gateway_row_expression(
const IR::Expression *gre);
353 bool preorder(
const IR::Expression *)
override;
357 void process_set_invalid(
cstring header);
358 void record_modified_where(
int i,
int j);
360 HeaderState state = ACTIVE);
361 void process_is_invalid(
cstring header);
362 void process_is_valid(
cstring header);
365 std::string get_active_headers_change_table(
367 ordered_set<std::pair<cstring, cstring>> mutexes_removed);
368 bool preorder(
const IR::MAU::Action *action)
override;
372 void merge_active_headers(
bitvec other_active_headers);
373 void flow_merge(
Visitor &other_)
override;
376 bool can_preserve_field_mutex(
379 void end_apply()
override;
382 ExcludeMAUNotMutexHeaders(
388 header_info(header_info),
389 mau_handles_parser_error(mau_handles_parser_error),
391 modified_where(modified_where),
392 field_level_optimisation(field_level_optimisation) {}
400class HeaderMutex :
public PassManager {
403 bool mau_contains_pov_read_write;
404 bool mau_handles_parser_error;
411 : field_level_optimisation(phv) {
413 pragmas.pa_no_overlay(), header_info),
415 mau_handles_parser_error),
422 return mau_contains_pov_read_write &&
423 !header_info.mutually_exclusive_headers.empty();
428 pragmas.pa_mutually_exclusive(),
429 modified_where, field_level_optimisation)})});
bool is_deparsed_or_referenced_later(const IR::MAU::Table *table, const PHV::Field *field)
If a PHV field is referenced after a given table or it is deparsed, return true.
Definition header_mutex.cpp:695
Find all tables which have a $valid or $stkvalid table key. If that table has const entries,...
Definition header_mutex.h:240
Definition tofino_write_context.h:24