P4C
The P4 Compiler
Loading...
Searching...
No Matches
PHV::RotationalCluster Class Reference

#include <utils.h>

Inheritance diagram for PHV::RotationalCluster:
[legend]

Public Member Functions

 RotationalCluster (ordered_set< PHV::AlignedCluster * > clusters)
 
size_t aggregate_size () const override
 
const AlignedClustercluster (const PHV::FieldSlice &slice) const
 
const ordered_set< AlignedCluster * > & clusters () const
 
bool contains (const PHV::Field *f) const override
 
bool contains (const PHV::FieldSlice &slice) const override
 
bool deparsed () const override
 
int exact_containers () const override
 
gress_t gress () const override
 
int max_width () const override
 
int num_constraints () const override
 
bool okIn (PHV::Kind kind) const override
 
bool operator== (const RotationalCluster &other) const
 Semantic equality.
 
std::optional< SliceResult< RotationalCluster > > slice (int pos) const
 
const ordered_set< PHV::FieldSlice > & slices () const
 
- Public Member Functions inherited from PHV::ClusterStats

Additional Inherited Members

- Public Attributes inherited from PHV::ClusterStats
int uid = nextId++
 

Detailed Description

A rotational cluster holds groups of clusters that must be placed in the same MAU group at rotationally-equivalent alignments.

Member Function Documentation

◆ aggregate_size()

size_t PHV::RotationalCluster::aggregate_size ( ) const
inlineoverridevirtual
Returns
the aggregate size of all slices in all clusters in this group.

Implements PHV::ClusterStats.

◆ cluster()

const AlignedCluster & PHV::RotationalCluster::cluster ( const PHV::FieldSlice & slice) const
inline
Returns
the cluster containing slice.
Warning
fails catastrophicaly if slice is not in any cluster in this group.

◆ clusters()

const ordered_set< AlignedCluster * > & PHV::RotationalCluster::clusters ( ) const
inline
Returns
the aligned clusters in this group.

◆ contains() [1/2]

bool PHV::RotationalCluster::contains ( const PHV::Field * f) const
overridevirtual
Returns
true if this cluster contains f.

Implements PHV::ClusterStats.

◆ contains() [2/2]

bool PHV::RotationalCluster::contains ( const PHV::FieldSlice & slice) const
overridevirtual
Returns
true if this cluster contains slice.

Implements PHV::ClusterStats.

◆ deparsed()

bool PHV::RotationalCluster::deparsed ( ) const
inlineoverridevirtual
Returns
true if any slice in the cluster is deparsed (either to the wire or the TM).

Implements PHV::ClusterStats.

◆ exact_containers()

int PHV::RotationalCluster::exact_containers ( ) const
inlineoverridevirtual
Returns
the number of clusters in this group with the exact_containers constraint.

Implements PHV::ClusterStats.

◆ gress()

gress_t PHV::RotationalCluster::gress ( ) const
inlineoverridevirtual
Returns
the gress requirement of this cluster.

Implements PHV::ClusterStats.

◆ max_width()

int PHV::RotationalCluster::max_width ( ) const
inlineoverridevirtual
Returns
the width of the maximum slice in any cluster in this group.

Implements PHV::ClusterStats.

◆ num_constraints()

int PHV::RotationalCluster::num_constraints ( ) const
inlineoverridevirtual
Returns
the sum of constraints of all clusters in this group.

Implements PHV::ClusterStats.

◆ okIn()

bool PHV::RotationalCluster::okIn ( PHV::Kind kind) const
overridevirtual
Returns
true if this cluster can be assigned to containers of kind kind.

Implements PHV::ClusterStats.

◆ slice()

std::optional< PHV::SliceResult< PHV::RotationalCluster > > PHV::RotationalCluster::slice ( int pos) const

Slices all AlignedClusters in this cluster at the relative field bit pos. For example, if a cluster contains a field slice [3..7] and pos == 2, then slice will produce two clusters, one with [3..4] and the other with [5..7].

If pos is larger than the size of a field slice in this cluster, then the slice is placed entirely in the lo cluster. If pos is larger than all field sizes, then the hi cluster will not contain any fields.

Parameters
posthe position to split, i.e. the first bit of the upper slice. pos must be non-negative.
Returns
a pair of (lo, hi) clusters if the cluster can be split at pos or std::nullopt otherwise.

◆ slices()

const ordered_set< PHV::FieldSlice > & PHV::RotationalCluster::slices ( ) const
inline
Returns
the slices in the aligned clusters in this group.