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

#include <container_equivalence.h>

Public Member Functions

 ContainerEquivalenceTracker (const PHV::Allocation &alloc)
 
void exclude (PHV::Container c)
 
std::optional< PHV::Containerfind_equivalent_tried_container (PHV::Container c)
 
void invalidate (PHV::Container c)
 
void set_is_wide_arith ()
 
void set_is_wide_arith_low ()
 

Detailed Description

Keeps track of equivalence classes for the purpose of slice list allocation (for a given set of start constraints). For each class it is sufficient to check the slice list can be allocated only to the first container, if it cannot, checking the other containers is pointless.

Member Function Documentation

◆ exclude()

void PHV::ContainerEquivalenceTracker::exclude ( PHV::Container c)
inline

Never consider this container to be equivalent to any other. Useful to mark containers appearing in exact container constraints

◆ find_equivalent_tried_container()

std::optional< PHV::Container > PHV::ContainerEquivalenceTracker::find_equivalent_tried_container ( PHV::Container c)

When called with a container c, this will return either:

  • std::nullopt if the container is first of its class and should be checked for allocation
  • or a PHV::Container of a container used in some previous call of this function on this instance that is equivalent to c.

◆ invalidate()

void PHV::ContainerEquivalenceTracker::invalidate ( PHV::Container c)

Invalidate this container for the purpose of equivalence. That is, this container will not be considered to be equivalent to other containers any more (its class is removed). This has to be used if the constraints are too complex to evaluate and require recursive allocation of other containers.

◆ set_is_wide_arith()

void PHV::ContainerEquivalenceTracker::set_is_wide_arith ( )
inline

Set that the slice list contains wide arithmetic and therefore the containers can only be equivalent with different containers of the same parity.

◆ set_is_wide_arith_low()

void PHV::ContainerEquivalenceTracker::set_is_wide_arith_low ( )
inline

Set that the slice list contains low part of wide arithmetic. In this case, we can't use equivalence tracking efficiently due to quirks in the metrics which can differ for otherwise equivalent fields if used in wide arithmerics.