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

#include <utils.h>

Inheritance diagram for PHV::Transaction:
[legend]

Public Member Functions

 Transaction (const Allocation &parent)
 Constructor.
 
virtual ~Transaction ()
 Destructor declaration. Does nothing but quiets warnings.
 
const_iterator begin () const override
 
void clearTransactionStatus ()
 Clears any allocation added to this transaction.
 
bool contains (PHV::Container c) const override
 
const_iterator end () const override
 
void foreach_slice (const PHV::Field *f, std::function< void(const AllocSlice &)> cb) const override
 
ordered_map< PHV::Container, ContainerStatusget_actual_diff () const
 Returns the actual diff of outstanding writes in this view.
 
const ordered_map< gress_t, ordered_map< const IR::MAU::Table *, std::set< const IR::MAU::Table * > > > & getARAedges () const
 
const ordered_map< const PHV::Field *, FieldStatus > & getFieldStatus () const
 
std::optional< ActionSetgetInitPoints (const AllocSlice &slice) const override
 
ActionSet getInitPointsForField (const PHV::Field *f) const override
 
const ordered_map< const IR::MAU::Action *, ordered_set< const PHV::Field * > > & getInitWrites () const
 
const ordered_set< const PHV::Field * > getMetadataInits (const IR::MAU::Action *act) const override
 
const ordered_map< AllocSlice, ActionSet > & getMetaInitPoints () const
 
const AllocationgetParent () const
 Returns the allocation that this transaction is based on.
 
const ContainerStatusgetStatus (const PHV::Container &c) const override
 
FieldStatus getStatus (const PHV::Field *f) const override
 
cstring getTransactionDiff () const
 
const ordered_map< PHV::Container, ContainerStatus > & getTransactionStatus () const
 Returns the outstanding writes in this view.
 
cstring getTransactionSummary () const
 
bool isDarkReadAvailable (PHV::Container c, unsigned minStage, unsigned maxStage) const override
 
bool isDarkWriteAvailable (PHV::Container c, unsigned minStage, unsigned maxStage) const override
 
void printMetaInitPoints () const
 
size_t size () const override
 
- Public Member Functions inherited from PHV::Allocation
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< AvailableSpotavailable_spots () const
 Return a set of available spots of this allocation.
 
virtual MutuallyLiveSlices byteSlicesByLiveness (const PHV::Container c, const AllocSlice &sl, const PragmaNoInit &noInit) const
 
Transactionclone (const Allocation &parent) const
 Extract the child from the parent transaction and return a cloned version of the difference.
 
cstring commit (Transaction &view)
 
virtual GressAssignment deparserGroupGress (PHV::Container c) const
 
int empty_containers (PHV::Size size) const
 
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
 
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
 
const ordered_map< const IR::BFN::ParserState *, std::set< PHV::Container > > & getParserStateToContainers (const PhvInfo &phv, const MapFieldToParserStates &field_to_parser_states) const
 
const ordered_set< unsigned > getTagalongCollectionsUsed () const
 
virtual GressAssignment gress (const PHV::Container &c) 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)
 
ordered_set< PHV::AllocSliceslices (const PHV::Field *f) const
 
ordered_set< PHV::AllocSliceslices (const PHV::Field *f, int stage, PHV::FieldUse access) const
 
ordered_set< PHV::AllocSliceslices (const PHV::Field *f, le_bitrange range) const
 
ordered_set< PHV::AllocSliceslices (const PHV::Field *f, le_bitrange range, int stage, PHV::FieldUse access) const
 
ordered_set< AllocSliceslices (PHV::Container c) const
 
ordered_set< AllocSliceslices (PHV::Container c, int stage, PHV::FieldUse access) const
 
ordered_set< AllocSliceslices (PHV::Container c, le_bitrange range) const
 
ordered_set< AllocSliceslices (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< MutuallyLiveSlicesslicesByLiveness (PHV::Container c) const
 
virtual cstring toString () const
 

Additional Inherited Members

- Public Types inherited from PHV::Allocation
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>
 
- Protected Member Functions inherited from PHV::Allocation
 Allocation (const PhvInfo &phv, const PhvUse &uses, bool isTrivial=false)
 
ordered_map< AllocSlice, ActionSet > & get_meta_init_points () const
 
- Protected Attributes inherited from PHV::Allocation
ordered_map< gress_t, ordered_map< const IR::MAU::Table *, std::set< const IR::MAU::Table * > > > ara_edges
 
ordered_map< PHV::Container, ContainerStatuscontainer_status_i
 
assoc::hash_map< PHV::Size, ordered_map< ContainerAllocStatus, int > > count_by_status_i
 
ordered_map< PHV::Container, bitvecdark_containers_read_allocated_i
 
ordered_map< PHV::Container, bitvecdark_containers_write_allocated_i
 
ordered_map< const PHV::Field *, FieldStatusfield_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, ActionSetmeta_init_points_i
 
const PhvInfophv_i
 
ordered_map< const IR::BFN::ParserState *, std::set< PHV::Container > > state_to_containers_i
 parser state to containers
 
const PhvUseuses_i
 

Detailed Description

A Transaction allows for speculative allocation that can later be rolled back. Writes are cached in the Transaction and merged into its parent Allocation with Allocation::commit; until that point, writes are only reflected in the Transaction but not its parent Allocation.

Reads on a Transaction read values allocated to the Transaction as well as those of its parent Allocation.

Note that "writes" (i.e. calls to allocation) do not overwrite existing allocation but rather add to it.

Member Function Documentation

◆ begin()

PHV::Allocation::const_iterator PHV::Transaction::begin ( ) const
overridevirtual

Iterate through container-->allocation slices.

Warning
not yet implemented.

Implements PHV::Allocation.

◆ contains()

bool PHV::Transaction::contains ( PHV::Container c) const
inlineoverridevirtual
Returns
true if this allocation owns c.

Implements PHV::Allocation.

◆ end()

PHV::Allocation::const_iterator PHV::Transaction::end ( ) const
overridevirtual

Iterate through container-->allocation slices.

Warning
not yet implemented.

Implements PHV::Allocation.

◆ foreach_slice()

void PHV::Transaction::foreach_slice ( const PHV::Field * f,
std::function< void(const AllocSlice &)> cb ) const
overridevirtual

Implements PHV::Allocation.

◆ getARAedges()

const ordered_map< gress_t, ordered_map< const IR::MAU::Table *, std::set< const IR::MAU::Table * > > > & PHV::Transaction::getARAedges ( ) const
inline
Returns
the map of source tables to the set of target tables connected through the ARA overlays

◆ getInitPoints()

std::optional< PHV::ActionSet > PHV::Transaction::getInitPoints ( const AllocSlice & slice) const
overridevirtual
Returns
the set of actions in which slice must be initialized for live range shrinking.

Reimplemented from PHV::Allocation.

◆ getInitPointsForField()

ActionSet PHV::Transaction::getInitPointsForField ( const PHV::Field * f) const
inlineoverridevirtual
Returns
the set of actions in which field f is initialized to enable live range shrinking.

Reimplemented from PHV::Allocation.

◆ getInitWrites()

const ordered_map< const IR::MAU::Action *, ordered_set< const PHV::Field * > > & PHV::Transaction::getInitWrites ( ) const
inline
Returns
a map of actions to the fields that must be initialized in that action for the allocation to be valid.

◆ getMetadataInits()

const ordered_set< const PHV::Field * > PHV::Transaction::getMetadataInits ( const IR::MAU::Action * act) const
inlineoverridevirtual
Returns
the set of fields that must be initialized in action act.

Reimplemented from PHV::Allocation.

◆ getMetaInitPoints()

const ordered_map< AllocSlice, ActionSet > & PHV::Transaction::getMetaInitPoints ( ) const
inline
Returns
a map of all the AllocSlices and the various actions where these slices must be initialized, for the PHV allocation represented by the current transaction.

◆ getStatus() [1/2]

const PHV::Allocation::ContainerStatus * PHV::Transaction::getStatus ( const PHV::Container & c) const
overridevirtual

Uniform abstraction for accessing a container state.

Returns
the ContainerStatus of this allocation, if present. Failing that, check its ancestors. If has no status yet, return nullptr.

Implements PHV::Allocation.

◆ getStatus() [2/2]

PHV::Allocation::FieldStatus PHV::Transaction::getStatus ( const PHV::Field * f) const
overridevirtual

Uniform abstraction for accessing field state.

Returns
the FieldStatus of this allocation, if present. Failing that, check its ancestors. If f has no status yet, return an empty FieldStatus.

Implements PHV::Allocation.

◆ getTransactionDiff()

cstring PHV::Transaction::getTransactionDiff ( ) const
Returns
a difference between the transaction and the parent.

◆ getTransactionSummary()

cstring PHV::Transaction::getTransactionSummary ( ) const
Returns
a summary of status of each container allocated in this transaction.

◆ isDarkReadAvailable()

bool PHV::Transaction::isDarkReadAvailable ( PHV::Container c,
unsigned minStage,
unsigned maxStage ) const
inlineoverridevirtual
Returns
false if a dark container is used for the read half cycle in between stages minStage and maxStage for either this transaction or its parent.

Reimplemented from PHV::Allocation.

◆ isDarkWriteAvailable()

bool PHV::Transaction::isDarkWriteAvailable ( PHV::Container c,
unsigned minStage,
unsigned maxStage ) const
inlineoverridevirtual
Returns
false if a dark container is used for the write half cycle in between stages minStage and maxStage for either this transaction or its parent.

Reimplemented from PHV::Allocation.

◆ printMetaInitPoints()

void PHV::Transaction::printMetaInitPoints ( ) const

Pretty print all the metadata initialization actions for the current transaction (including all the parent transactions). Not used anywhere explicitly, but do not remove because calls to this function make debugging easy.

◆ size()

size_t PHV::Transaction::size ( ) const
inlineoverridevirtual
Returns
number of containers owned by this allocation.

Implements PHV::Allocation.