19#ifndef BF_P4C_PHV_V2_PARSER_PACKING_VALIDATOR_H_
20#define BF_P4C_PHV_V2_PARSER_PACKING_VALIDATOR_H_
22#include "backends/tofino/bf-p4c/common/field_defuse.h"
23#include "backends/tofino/bf-p4c/lib/assoc.h"
24#include "backends/tofino/bf-p4c/parde/parser_info.h"
25#include "backends/tofino/bf-p4c/phv/parser_packing_validator_interface.h"
26#include "backends/tofino/bf-p4c/phv/phv_fields.h"
27#include "backends/tofino/bf-p4c/phv/pragma/phv_pragmas.h"
28#include "backends/tofino/bf-p4c/phv/v2/utils_v2.h"
44 using StateExtract = std::pair<const IR::BFN::ParserState *, const IR::BFN::Extract *>;
52 mutable bool is_trivial_pass =
false;
53 mutable bool is_trivial_alloc =
false;
54 std::set<FieldRange> &mauInitFields;
59 std::vector<const IR::BFN::ParserPrimitive *>>
67 bool parser_zero_init(
const Field *f)
const {
68 return (defuse_i.hasUninitializedRead(f->
id) && !pa_no_init_i.
getFields().count(f));
72 bool allow_clobber(
const Field *f)
const;
75 bool is_parser_error(
const Field *f)
const;
78 const AllocError *will_buf_extract_clobber_the_other(
79 const FieldSlice &fs,
const StateExtract &state_extract,
const int cont_idx,
81 const int other_cont_idx,
bool add_mau_inits)
const;
84 const AllocError *will_a_extracts_clobber_b(
const FieldSliceStart &a,
const FieldSliceStart &b,
85 bool add_mau_inits)
const;
91 std::set<FieldRange> &mauInitFields)
94 parser_info_i(parser_info),
96 pa_no_init_i(pa_no_init),
97 mauInitFields(mauInitFields) {}
102 bool add_mau_inits =
false)
const;
107 bool add_mau_inits =
false)
const override;
110 void set_trivial_pass(
bool trivial)
const;
112 void set_trivial_alloc(
bool trivial)
const;
Definition ordered_map.h:32
Definition phv_fields.h:154
int id
Unique field ID.
Definition phv_fields.h:164
Definition phv_fields.h:898
Definition parser_packing_validator_interface.h:26
Definition parser_packing_validator.h:42
const AllocError * can_pack(const FieldSliceStart &a, const FieldSliceStart &b, bool add_mau_inits=false) const
Definition parser_packing_validator.cpp:260
Definition phv_fields.h:1095
const ordered_set< const PHV::Field * > & getFields() const
Definition pa_no_init.h:61
Adds the no_init pragma to the specified fields with the specified gress.
Definition pa_no_init.h:35
Definition field_defuse.h:77
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
Map field to the parser states in which they are extracted or assigned from checksums.
Definition phv_fields.h:1755