P4C
The P4 Compiler
|
#include <action_packing_validator_interface.h>
Classes | |
struct | Result |
Public Member Functions | |
virtual Result | can_pack (const ordered_set< const SuperCluster::SliceList * > &slice_lists, const ordered_set< const SuperCluster::SliceList * > &can_be_further_split={}, const bool loose_mode=false) const =0 |
PackingValidator is an interface type of classes that have a can_pack function to verify whether the packing will violate any constraint.
|
pure virtual |
can_pack returns Result with code::OK if slice_lists
can be allocated to containers without being further split, and allocation will not violate action PHV constraints. If can_be_split_further
is not empty, this function will further check that when slice_lists
are allocated to containers without further split, can can_be_split_further
be split and allocated successfully, by checking whether slices in the same byte (must be packed in one container) will violate any action phv constraint. contract: both slice_lists
and can_be_split_further
must contain fine-sliced PHV::Fieldslices, that any operation will only read or write one PHV::FieldSlice. All Slicelists in a super cluster satisfy this constraint. contract: no overlapping slice between slice_lists
and can_be_further_split
. when
loose_mode is true, instructions are allowed to overwrite bytes of destination container that has unwritten fields slices. Although it usually means that the action cannot be be synthesized because live bits will be corrupted. However, because dest can be split further later to avoid corruption, it is sometimes useful to use loose_mode so that caller can solve the problem in a divide-and-conquer way.
Implemented in PHV::legacy::ActionPackingValidator, and PHV::v2::ActionPackingValidator.