P4C
The P4 Compiler
|
#include <utils.h>
Public Types | |
using | const_iterator = ordered_set<PHV::FieldSlice>::const_iterator |
Public Member Functions | |
template<typename Iterable > | |
AlignedCluster (PHV::Kind kind, Iterable slices) | |
size_t | aggregate_size () const override |
std::optional< unsigned > | alignment () const |
const_iterator | begin () const |
bool | contains (const PHV::Field *f) const override |
bool | contains (const PHV::FieldSlice &slice) const override |
bool | deparsed () const override |
const_iterator | end () const |
int | exact_containers () const override |
gress_t | gress () const override |
int | id () const |
PHV::Kind | kind () |
int | max_width () const override |
int | num_constraints () const override |
bool | okIn (PHV::Kind kind) const override |
bool | operator== (const AlignedCluster &other) const |
std::optional< SliceResult< AlignedCluster > > | slice (int pos) const |
const ordered_set< PHV::FieldSlice > & | slices () const |
bitvec | validContainerStart (PHV::Size container_size) const |
Public Member Functions inherited from PHV::ClusterStats |
Static Public Member Functions | |
static bitvec | validContainerStart (PHV::FieldSlice slice, PHV::Size container_size) |
Valid start positions for slice in container_size sized containers. | |
Additional Inherited Members | |
Public Attributes inherited from PHV::ClusterStats | |
int | uid = nextId++ |
An AlignedCluster groups slices that are involved in the same MAU operations and, therefore, must be placed at the same alignment in containers in the same MAU container group.
For example, suppose a P4 program includes the following operations:
a = b + c; d = e + a;
Fields a, b, c, d, and e must start at the same bit position and be placed in the same MAU container group.
Note that the set
instruction (which translates to the deposit_field
ALU operation) is a special case, because deposit_field
can optionally rotate its source operand; hence, the operands do not need to be aligned.
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
inline |
|
overridevirtual |
f
. Implements PHV::ClusterStats.
|
overridevirtual |
slice
. Implements PHV::ClusterStats.
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
inline |
|
inline |
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
inlineoverridevirtual |
Implements PHV::ClusterStats.
|
overridevirtual |
kind
. Implements PHV::ClusterStats.
bool PHV::AlignedCluster::operator== | ( | const AlignedCluster & | other | ) | const |
Two aligned clusters are equivalent if they contain the same slices and can be assigned to the same kind of PHV containers.
std::optional< PHV::SliceResult< PHV::AlignedCluster > > PHV::AlignedCluster::slice | ( | int | pos | ) | const |
Slices 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.
pos | the position to split, i.e. the first bit of the upper slice. pos must be non-negative. |
pos
or std::nullopt otherwise.
|
inline |
Combines AlignedCluster::alignment() and AlignedCluster::validContainerStartRange(container_size
) to compute the valid lo bit positions where slices of this cluster can be placed in containers of size container_size
, or std::nullopt if no valid start positions exist or if any slice is too large to fit in containers of container_size
.
If any slice in this cluster has the deparsed_bottom_bits
constraint, then the bitvec will be [0, 0], or empty if any slice cannot be started at container bit 0.