P4C
The P4 Compiler
|
#include <utils.h>
Classes | |
struct | AvailableSpot |
Available bits of this allocation. More... | |
struct | ConditionalConstraintData |
struct | ContainerStatus |
Public Types | |
using | ConditionalConstraint = ordered_map<PHV::FieldSlice, ConditionalConstraintData> |
using | ConditionalConstraints = ordered_map<int, ConditionalConstraint> |
using | const_iterator = ordered_map<PHV::Container, ContainerStatus>::const_iterator |
enum class | ContainerAllocStatus { EMPTY , PARTIAL , FULL } |
enum class | ExtractSource { NONE , PACKET , NON_PACKET } |
using | FieldStatus = ordered_set<AllocSlice> |
using | GressAssignment = std::optional<gress_t> |
using | LiveRangeShrinkingMap = ordered_map<const PHV::Field *, ActionSet> |
using | MutuallyLiveSlices = ordered_set<AllocSlice> |
Public Member Functions | |
void | addARAedge (gress_t grs, const IR::MAU::Table *src, const IR::MAU::Table *dst) const |
Add a pair of tables in the ara_edges for a new ARA table. | |
bool | addDarkAllocation (const AllocSlice &slice) |
virtual void | addMetadataInitialization (AllocSlice slice, LiveRangeShrinkingMap initNodes) |
virtual ContainerAllocStatus | alloc_status (PHV::Container c) const |
virtual void | allocate (const AllocSlice slice, LiveRangeShrinkingMap *initNodes=nullptr, bool singleGressParserGroup=false) |
std::set< AvailableSpot > | available_spots () const |
Return a set of available spots of this allocation. | |
virtual const_iterator | begin () const =0 |
Iterate through container-->allocation slices. | |
virtual MutuallyLiveSlices | byteSlicesByLiveness (const PHV::Container c, const AllocSlice &sl, const PragmaNoInit &noInit) const |
Transaction * | clone (const Allocation &parent) const |
Extract the child from the parent transaction and return a cloned version of the difference. | |
cstring | commit (Transaction &view) |
virtual bool | contains (PHV::Container c) const =0 |
virtual GressAssignment | deparserGroupGress (PHV::Container c) const |
int | empty_containers (PHV::Size size) const |
virtual const_iterator | end () const =0 |
void | foreach_slice (const PHV::Field *f, le_bitrange range, int stage, PHV::FieldUse access, std::function< void(const AllocSlice &)> cb) const |
void | foreach_slice (const PHV::Field *f, le_bitrange range, std::function< void(const AllocSlice &)> cb) const |
virtual void | foreach_slice (const PHV::Field *f, std::function< void(const AllocSlice &)> cb) const =0 |
void | foreach_slice (PHV::Container c, int stage, PHV::FieldUse access, std::function< void(const AllocSlice &)> cb) const |
void | foreach_slice (PHV::Container c, le_bitrange range, int stage, PHV::FieldUse access, std::function< void(const AllocSlice &)> cb) const |
void | foreach_slice (PHV::Container c, le_bitrange range, std::function< void(const AllocSlice &)> cb) const |
void | foreach_slice (PHV::Container c, std::function< void(const AllocSlice &)> cb) const |
const ordered_map< gress_t, ordered_map< const IR::MAU::Table *, std::set< const IR::MAU::Table * > > > & | getARAedges () const |
virtual std::optional< ActionSet > | getInitPoints (const AllocSlice &slice) const |
virtual ActionSet | getInitPointsForField (const PHV::Field *f) const |
virtual const ordered_set< const PHV::Field * > | getMetadataInits (const IR::MAU::Action *act) const |
const ordered_map< const IR::BFN::ParserState *, std::set< PHV::Container > > & | getParserStateToContainers (const PhvInfo &phv, const MapFieldToParserStates &field_to_parser_states) const |
virtual const ContainerStatus * | getStatus (const PHV::Container &c) const =0 |
virtual FieldStatus | getStatus (const PHV::Field *f) const =0 |
const ordered_set< unsigned > | getTagalongCollectionsUsed () const |
virtual GressAssignment | gress (const PHV::Container &c) const |
virtual bool | isDarkReadAvailable (PHV::Container c, unsigned minStage, unsigned maxStage) const |
virtual bool | isDarkWriteAvailable (PHV::Container c, unsigned minStage, unsigned maxStage) const |
virtual MutuallyLiveSlices | liverange_overlapped_slices (const PHV::Container c, const std::vector< AllocSlice > &slices) const |
virtual Transaction | makeTransaction () const |
Create a Transaction based on this Allocation. | |
virtual ExtractSource | parserExtractGroupSource (PHV::Container c) const |
virtual GressAssignment | parserGroupGress (PHV::Container c) const |
std::string | printARAedges () const |
virtual void | removeAllocatedSlice (const ordered_set< PHV::AllocSlice > &slices) |
virtual size_t | size () const =0 |
ordered_set< PHV::AllocSlice > | slices (const PHV::Field *f) const |
ordered_set< PHV::AllocSlice > | slices (const PHV::Field *f, int stage, PHV::FieldUse access) const |
ordered_set< PHV::AllocSlice > | slices (const PHV::Field *f, le_bitrange range) const |
ordered_set< PHV::AllocSlice > | slices (const PHV::Field *f, le_bitrange range, int stage, PHV::FieldUse access) const |
ordered_set< AllocSlice > | slices (PHV::Container c) const |
ordered_set< AllocSlice > | slices (PHV::Container c, int stage, PHV::FieldUse access) const |
ordered_set< AllocSlice > | slices (PHV::Container c, le_bitrange range) const |
ordered_set< AllocSlice > | slices (PHV::Container c, le_bitrange range, int stage, PHV::FieldUse access) const |
virtual MutuallyLiveSlices | slicesByLiveness (const PHV::Container c, const AllocSlice &sl) const |
virtual MutuallyLiveSlices | slicesByLiveness (const PHV::Container c, std::vector< AllocSlice > &slices) const |
virtual std::vector< MutuallyLiveSlices > | slicesByLiveness (PHV::Container c) const |
virtual cstring | toString () const |
Protected Member Functions | |
Allocation (const PhvInfo &phv, const PhvUse &uses, bool isTrivial=false) | |
ordered_map< AllocSlice, ActionSet > & | get_meta_init_points () const |
Protected Attributes | |
ordered_map< gress_t, ordered_map< const IR::MAU::Table *, std::set< const IR::MAU::Table * > > > | ara_edges |
ordered_map< PHV::Container, ContainerStatus > | container_status_i |
assoc::hash_map< PHV::Size, ordered_map< ContainerAllocStatus, int > > | count_by_status_i |
ordered_map< PHV::Container, bitvec > | dark_containers_read_allocated_i |
ordered_map< PHV::Container, bitvec > | dark_containers_write_allocated_i |
ordered_map< const PHV::Field *, FieldStatus > | field_status_i |
DarkInitMap | init_map_i |
Initialization information about allocating to dark containers during certain stages. | |
ordered_map< const IR::MAU::Action *, ordered_set< const PHV::Field * > > | init_writes_i |
bool | isTrivial |
ordered_map< AllocSlice, ActionSet > | meta_init_points_i |
const PhvInfo * | phv_i |
ordered_map< const IR::BFN::ParserState *, std::set< PHV::Container > > | state_to_containers_i |
parser state to containers | |
const PhvUse * | uses_i |
Friends | |
class | AllocationReport |
class | Transaction |
Keep track of the allocation of field slices to container slices, as well as the gress assignment of containers. Support speculative allocation and rollbacks with the Transaction mechanism.
struct PHV::Allocation::ContainerStatus |
This struct tracks PHV container state that can change during the course of allocation, such as the thread to which this container must be assigned, or the field slices that have been allocated to it. Because PHV allocation queries container status many, many times, this struct also contains a derived alloc_status
, which summarizes the state of the container.
Class Members | ||
---|---|---|
ContainerAllocStatus | alloc_status | |
GressAssignment | deparserGroupGress | |
GressAssignment | gress | |
ExtractSource | parserExtractGroupSource | |
GressAssignment | parserGroupGress | |
ordered_set< AllocSlice > | slices |
bool PHV::Allocation::addDarkAllocation | ( | const AllocSlice & | slice | ) |
Add slice
allocated to a dark container to the current Allocation object.
|
virtual |
Uniform convenience abstraction for adding a metadata initialization node to the allocation object.
|
virtual |
c
and fails if c
is not present.
|
virtual |
Assign @slice to @slice.container, updating the gress information of the container and its MAU group if necessary. Fails if the gress of @slice.field does not match any gress in the MAU group.
Note that this adds new slices but does not remove or overwrite existing slices.
Assign slice
to slice.container
, updating the gress information of the container and its MAU group if necessary. Fails if the gress of slice.field
does not match any gress in the MAU group.
|
pure virtual |
Iterate through container-->allocation slices.
Implemented in PHV::ConcreteAllocation, and PHV::Transaction.
cstring PHV::Allocation::commit | ( | Transaction & | view | ) |
Update this allocation with any new allocation in view
. Note that this may add new slices but does not remove or overwrite existing slices.
|
pure virtual |
c
. Implemented in PHV::ConcreteAllocation, and PHV::Transaction.
|
virtual |
c's
deparser group, if any. If a container holds deparsed fields, then its gress must match that of its deparser group. int PHV::Allocation::empty_containers | ( | PHV::Size | size | ) | const |
size
.
|
pure virtual |
Implemented in PHV::Transaction.
|
inlineprotected |
|
inline |
|
virtual |
slice
must be initialized for overlay enabled by live range shrinking. Reimplemented in PHV::Transaction.
|
virtual |
f
. Reimplemented in PHV::Transaction.
|
virtual |
act
. Reimplemented in PHV::Transaction.
const ordered_map< const IR::BFN::ParserState *, std::set< PHV::Container > > & PHV::Allocation::getParserStateToContainers | ( | const PhvInfo & | phv, |
const MapFieldToParserStates & | field_to_parser_states ) const |
|
pure virtual |
Uniform abstraction for accessing a container state.
has
no status yet, return nullptr. Implemented in PHV::ConcreteAllocation, and PHV::Transaction.
|
pure virtual |
Uniform abstraction for accessing field state.
f
has no status yet, return an empty FieldStatus. Implemented in PHV::ConcreteAllocation, and PHV::Transaction.
const ordered_set< unsigned > PHV::Allocation::getTagalongCollectionsUsed | ( | ) | const |
|
virtual |
and
fails if is
not present.
|
inlinevirtual |
Reimplemented in PHV::Transaction.
|
inlinevirtual |
Reimplemented in PHV::Transaction.
|
virtual |
c
with any of the candidate slice in slices
, i.e., not mutex and liverange not disjoint.
|
virtual |
Create a Transaction based on this Allocation.
|
virtual |
c's
parser extract group. All containers in a group must have the same source.
|
virtual |
c's
parser group, if any. If a container holds extracted fields, then its gress must match that of its parser group.
|
pure virtual |
Implemented in PHV::ConcreteAllocation, and PHV::Transaction.
|
inline |
f
in this Allocation. May be empty (if f
is not allocated) or contain slices that do not fully cover all bits of f
(if f
is only partially allocated). ordered_set< PHV::AllocSlice > PHV::Allocation::slices | ( | const PHV::Field * | f, |
le_bitrange | range ) const |
f
that include any part of range
in the field portion of the allocated slice. May be empty (if f
is not allocated) or contain slices that do not fully cover all bits of f
(if f
is only partially allocated). ordered_set< PHV::AllocSlice > PHV::Allocation::slices | ( | PHV::Container | c | ) | const |
c
. ordered_set< PHV::AllocSlice > PHV::Allocation::slices | ( | PHV::Container | c, |
int | stage, | ||
PHV::FieldUse | access ) const |
c
and valid in the stage stage
. ordered_set< PHV::AllocSlice > PHV::Allocation::slices | ( | PHV::Container | c, |
le_bitrange | range ) const |
c
that overlap with range
.
|
virtual |
c
that are all live at the same time as sl
The previous function (slicesByLiveness(c)) constructs a vector of sets of slices that are live in the container at the same time; the same slice may be found in multiple sets in this case. By contrast, slicesByLiveness(c, sl) uses the mutex_i member to determine all the field slices that are not mutually exclusive with the candidate slice, and returns a set of all such slices. For example, suppose the following slices are allocated to a container c:where f2 and f3 are overlaid and hence mutex_i(f2, f3) = true. If slice sl is f1[0:3], such that mutex_i(f1, f2) = false and mutex_i(f1, f3) = false, a call to slicesByLiveness(c, f1[0:3]) would return the set {f2[0:3], f3[0:3]}.
|
virtual |
The allocation manager keeps a list of combinations of slices that are live in the container at the same time, as well as the thread assignment of the container (if any). For example, suppose the following slices are allocated to a container c:
c[0:3]<–f1[0:3] c[4:7]<–f2[0:3] c[4:7]<–f3[0:3]
where f2 and f3 are overlaid. There are then two sets of slices that are live in the container at the same time:
c[0:3]<–f1[0:3] c[4:7]<–f2[0:3]
and
c[0:3]<–f1[0:3] c[4:7]<–f3[0:3]
When analyzing cohabit constraints, it's important to only compare fields that are live.
Note that the same slice may appear in more than one list.
that
can be live at the same time.
|
virtual |
|
mutableprotected |
For each gress keep track of potential control flow edges implied from/to AlwaysRunAction tables
|
mutableprotected |
Dark containers allocated in this allocation mapped to the stages that they are allocated to. The read map captures the allocation from the perspective of a read of that container while the write map captures the allocation from the perspective of a write to that container.
|
mutableprotected |
Structure that remembers actions at which metadata initialization for various fields has been added.
|
mutableprotected |
Structure that remembers the actions at which metadata fields need to be initialized for a particular allocation object.