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

#include <allocate_phv.h>

Public Member Functions

 FieldPackingOpportunity (const std::list< PHV::SuperCluster * > &sorted_clusters, const ActionPhvConstraints &actions, const PhvUse &uses, const FieldDefUse &defuse, const SymBitMatrix &mutex)
 sorted_clusters is a list of clusters that we will allocated, in this order.
 
int nOpportunities (const PHV::Field *f) const
 How many fields, after f is allocated, can be packed with f.
 
int nOpportunitiesAfter (const PHV::Field *f1, const PHV::Field *f2) const
 

Detailed Description

For each field, calculate the possible packing opportunities, if they are allocated in the given order, with fields that are allocated later than it. This object must be created after sorting superclusters, because it takes the sorted clusters to construct.

Member Function Documentation

◆ nOpportunitiesAfter()

int FieldPackingOpportunity::nOpportunitiesAfter ( const PHV::Field * f1,
const PHV::Field * f2 ) const

How many fields, after f1 is allocated and f2 is not packed with it, can be packed with f1. This is used to decide the priority of this packing, less opportunities, more priority. For example, if f2 can be packed with f1 and f1', but if not packed with f1, there is no opportunities for f1 to be packed with, while there is a lot of opportunities for f1', then packing f1 and f2 may be a better choice.