P4C
The P4 Compiler
Loading...
Searching...
No Matches
ClotInfo Class Reference

Public Member Functions

 ClotInfo (PhvUse &uses)
 
void adjust_clots (const PhvInfo &phv)
 
assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * allocated_slices (const PHV::Field *field) const
 
assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * allocated_slices (const PHV::FieldSlice *slice) const
 
bool allocated_unmodified_undigested (const PHV::Field *field) const
 
bool clot_covers_slice (const Clot *clot, const PHV::FieldSlice *slice) const
 
const std::set< const PHV::Field * > * clot_eligible_fields () const
 Produces the set of CLOT-eligible fields.
 
std::map< const Clot *, std::vector< const IR::BFN::EmitChecksum * > > & clot_to_emit_checksum ()
 
const std::map< const Clot *, std::vector< const IR::BFN::EmitChecksum * > > & clot_to_emit_checksum () const
 
const std::map< const Clot *, std::pair< gress_t, std::set< cstring > >, Clot::Less > & clot_to_parser_states () const
 
const std::vector< Clot * > & clots ()
 
const std::map< const PHV::Field *, std::vector< const IR::BFN::EmitChecksum * > > & field_to_checksum_updates ()
 
const Clotfully_allocated (const PHV::Field *field) const
 
std::set< const Clot *, Clot::Less > * fully_allocated (const PHV::FieldSlice &slice) const
 
std::set< const Clot *, Clot::Less > * fully_allocated (const PHV::FieldSlice *slice) const
 
std::map< int, const PHV::Field * > get_csum_fields (const Clot *clot) const
 
std::map< int, PHV::Containerget_overwrite_containers (const Clot *clot, const PhvInfo &phv) const
 
const ordered_map< std::pair< const IR::BFN::ParserState *, const IR::HeaderStack * >, std::set< unsigned > > & header_stack_elements ()
 
bool is_added_by_mau (cstring h) const
 Determines whether h is a header that might be added by MAU.
 
bool is_checksum (const PHV::Field *field) const
 Determines whether a field is a checksum field.
 
bool is_checksum (const PHV::FieldSlice *slice) const
 
bool is_modified (const PHV::Field *field) const
 
bool is_modified (const PHV::FieldSlice *slice) const
 
bool is_readonly (const PHV::Field *field) const
 
bool is_readonly (const PHV::FieldSlice *slice) const
 
bool is_slice_below_min_offset (const PHV::FieldSlice *slice, int max_packet_bit_offset) const
 
bool is_unused (const PHV::Field *field) const
 
bool is_unused (const PHV::FieldSlice *slice) const
 
void merge_parser_states (gress_t gress, cstring dst_state_name, cstring src_state_name)
 
const Clotparser_state_to_clot (const IR::BFN::LoweredParserState *state, unsigned tag) const
 
const std::set< const Clot * > parser_state_to_clots (const IR::BFN::LoweredParserState *state) const
 
std::map< cstring, std::set< const Clot * > > & parser_state_to_clots (gress_t gress)
 
const std::map< cstring, std::set< const Clot * > > & parser_state_to_clots (gress_t gress) const
 
const ordered_map< const IR::BFN::ParserState *, std::vector< const PHV::Field * > > & parser_state_to_fields () const
 
const ordered_map< const IR::BFN::ParserState *, std::vector< const IR::HeaderStack * > > & parser_state_to_header_stacks () const
 
std::string print (const PhvInfo *phvInfo=nullptr) const
 
cstring sanitize_state_name (cstring state_name, gress_t gress) const
 
assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * slice_clots (const PHV::Field *field) const
 
assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * slice_clots (const PHV::FieldSlice *slice) const
 
bool slice_overwritten (const PhvInfo &phvInfo, const Clot *clot, const PHV::FieldSlice *f) const
 
bool slice_overwritten_by_phv (const PhvInfo &phvInfo, const Clot *clot, const PHV::FieldSlice *f) const
 
Clotwhole_field_clot (const PHV::Field *field) const
 

Public Attributes

CollectParserInfo parserInfo
 
std::set< const PHV::Field * > pov_extracted_without_fields
 

Friends

class AllocateClot
 
class ClotCandidate
 
class CollectClotInfo
 
class GreedyClotAllocator
 

Member Function Documentation

◆ adjust_clots()

void ClotInfo::adjust_clots ( const PhvInfo & phv)

Adjusts all allocated CLOTs so that they neither start nor end with an overwritten field slice. See CLOT allocation adjustment (README.md).

◆ allocated_slices() [1/2]

assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * ClotInfo::allocated_slices ( const PHV::Field * field) const
inline
Returns
nullptr if the field is read-only or modified. Otherwise, if the field is unused, returns a map from each CLOT-allocated slice for the field to its corresponding CLOT.

◆ allocated_slices() [2/2]

assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * ClotInfo::allocated_slices ( const PHV::FieldSlice * slice) const
inline
Returns
nullptr if the field containing the slice is read-only or modified. Otherwise, if the field containing the slice is unused, returns each CLOT-allocated slice that overlaps with the given slice, mapped to its corresponding CLOT.

◆ allocated_unmodified_undigested()

bool ClotInfo::allocated_unmodified_undigested ( const PHV::Field * field) const
inline
Returns
true if field is (1) fully allocated to clot, (2) not modified by MAUs, and (3) not digested. For these fields, it is safe to ignore deparser read to shrink their live ranges, because deparser can emit them directly from clot.

◆ clot_covers_slice()

bool ClotInfo::clot_covers_slice ( const Clot * clot,
const PHV::FieldSlice * slice ) const
Returns
true if the given slice is covered by the given clot.

◆ fully_allocated() [1/3]

const Clot * ClotInfo::fully_allocated ( const PHV::Field * field) const
inline
Returns
the given field's CLOT if the field is unused and is entirely covered in a CLOT. Otherwise, nullptr is returned.

◆ fully_allocated() [2/3]

std::set< const Clot *, Clot::Less > * ClotInfo::fully_allocated ( const PHV::FieldSlice & slice) const
inline
Returns
the given field slice's CLOT allocation if the field containing the slice is unused and the slice is entirely CLOT-allocated. Otherwise, nullptr is returned.

◆ fully_allocated() [3/3]

std::set< const Clot *, Clot::Less > * ClotInfo::fully_allocated ( const PHV::FieldSlice * slice) const
Returns
the given field slice's CLOT allocation if the field containing the slice is unused and the slice is entirely CLOT-allocated. Otherwise, nullptr is returned.

◆ get_csum_fields()

std::map< int, const PHV::Field * > ClotInfo::get_csum_fields ( const Clot * clot) const
Returns
a map from overwrite offsets to corresponding checksum fields.

◆ get_overwrite_containers()

std::map< int, PHV::Container > ClotInfo::get_overwrite_containers ( const Clot * clot,
const PhvInfo & phv ) const
Returns
a map from overwrite offsets to corresponding containers.

◆ is_modified()

bool ClotInfo::is_modified ( const PHV::Field * field) const

Determines whether a field is modified, as defined in CLOT allocator and metric (README.md).

◆ is_readonly()

bool ClotInfo::is_readonly ( const PHV::Field * field) const

Determines whether a field is read-only, as defined in CLOT allocator and metric (README.md).

◆ is_slice_below_min_offset()

bool ClotInfo::is_slice_below_min_offset ( const PHV::FieldSlice * slice,
int max_packet_bit_offset ) const

Returns false if packet offset of the slice is less than hdr_len_adj and if the slice cannot be trimmed to increase its offset.

◆ is_unused()

bool ClotInfo::is_unused ( const PHV::Field * field) const

Determines whether a field is unused, as defined in CLOT allocator and metric (README.md).

◆ merge_parser_states()

void ClotInfo::merge_parser_states ( gress_t gress,
cstring dst_state_name,
cstring src_state_name )

If gress::src_state_name state has CLOT extracts, then add them as gress::dst_state_name extracts as well.

This is because MergeLoweredParserStates merges LoweredParser states, their CLOT extracts need to be merged accordingly so ClotResourcesLogging has correct information for logging.

◆ sanitize_state_name()

cstring ClotInfo::sanitize_state_name ( cstring state_name,
gress_t gress ) const

Sanitizes state name before lookup in the parser_state_to_clots_

If state name is not prefixed with gress, then it will be prefixed If a state is compiler generated auxiliary state (thus containing '.$' substring), then the generated appendix is stripped to regenerate original state name.

◆ slice_clots() [1/2]

assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * ClotInfo::slice_clots ( const PHV::Field * field) const
inline
Returns
the CLOT-allocated slices of the given field, mapped to the CLOTs containing those slices.

◆ slice_clots() [2/2]

assoc::map< const PHV::FieldSlice *, Clot *, PHV::FieldSlice::Greater > * ClotInfo::slice_clots ( const PHV::FieldSlice * slice) const
Returns
the CLOT-allocated slices that overlap with the given slice, mapped to the corresponding CLOTs.

◆ slice_overwritten()

bool ClotInfo::slice_overwritten ( const PhvInfo & phvInfo,
const Clot * clot,
const PHV::FieldSlice * f ) const

Determines whether a field slice in a CLOT will be overwritten by a PHV container or a checksum calculation when deparsed. See CLOT allocator and metric (README.md).

Returns
true when f is a field slice covered by clot and at least part of f will be overwritten by a PHV container or a checksum calculation when deparsed.

◆ slice_overwritten_by_phv()

bool ClotInfo::slice_overwritten_by_phv ( const PhvInfo & phvInfo,
const Clot * clot,
const PHV::FieldSlice * f ) const

Determines whether a field slice in a CLOT will be overwritten by a PHV container when deparsed. See CLOT allocator and metric (README.md).

Returns
true when f is a field slice covered by clot and at least part of f will be overwritten by a PHV container when deparsed.

◆ whole_field_clot()

Clot * ClotInfo::whole_field_clot ( const PHV::Field * field) const
Returns
the CLOT containing the entirety of the given field, or nullptr if no such CLOT exists.

Member Data Documentation

◆ pov_extracted_without_fields

std::set<const PHV::Field *> ClotInfo::pov_extracted_without_fields

A POV is in this set if there is a path through the parser in which the field is not extracted, but its POV bit is set.