|
AllocResult | alloc_stride (const ScoreContext &ctx, const Allocation &alloc, const std::vector< FieldSlice > &stride, const ContainerGroupsBySize &groups, AllocatorMetrics &alloc_metrics) const |
|
const AllocError * | check_container_scope_constraints (const Allocation &alloc, const std::vector< AllocSlice > &candidates, const Container &c) const |
|
std::set< PHV::Size > | compute_valid_container_sizes (const SuperCluster *sc) const |
|
const AllocError * | is_container_bytes_ok (const Allocation &alloc, const std::vector< AllocSlice > &candidates, const Container &c) const |
|
const AllocError * | is_container_gress_ok (const Allocation &alloc, const AllocSlice &sl, const Container &c) const |
|
const AllocError * | is_container_solitary_ok (const Allocation &alloc, const AllocSlice &candidate, const Container &c) const |
|
const AllocError * | is_container_type_ok (const AllocSlice &sl, const Container &c) const |
| CONSTRAINT CHECKING Functions common to trivial and greedy allocation.
|
|
const AllocError * | is_container_write_mode_ok (const Allocation &alloc, const AllocSlice &sl, const Container &c) const |
|
std::vector< const SuperCluster::SliceList * > * | make_alloc_order (const ScoreContext &ctx, const SuperCluster *sc, const PHV::Size width) const |
|
Transaction | make_speculated_alloc (const ScoreContext &ctx, const Allocation &alloc, const SuperCluster *sc, const std::vector< AllocSlice > &candidates, const Container &candidates_cont) const |
|
std::vector< int > | make_start_positions (const ScoreContext &ctx, const SuperCluster::SliceList *sl, const PHV::Size width) const |
|
std::optional< Transaction > | try_hints (const ScoreContext &ctx, const Allocation &alloc, const ContainerGroup &group, const ActionSourceCoPackMap &action_hints_map, ordered_set< PHV::FieldSlice > &allocated, ScAllocAlignment &hint_enforced_alignments, AllocatorMetrics &alloc_metrics) const |
|
SomeContScopeAllocResult | try_slices_adapter (const ScoreContext &ctx, const Allocation &alloc, const FieldSliceAllocStartMap &fs_starts, const ContainerGroup &group, std::optional< Container > c, AllocatorMetrics &alloc_metrics) const |
|
ContScopeAllocResult | try_slices_to_container (const ScoreContext &ctx, const Allocation &alloc, const FieldSliceAllocStartMap &fs_starts, const Container &c, AllocatorMetrics &alloc_metrics, const bool skip_mau_checks=false) const |
|
SomeContScopeAllocResult | try_slices_to_container_group (const ScoreContext &ctx, const Allocation &alloc, const FieldSliceAllocStartMap &fs_starts, const ContainerGroup &group, AllocatorMetrics &alloc_metrics) const |
|
AllocResult | try_super_cluster_to_container_group (const ScoreContext &ctx, const Allocation &alloc, const SuperCluster *sc, const ContainerGroup &group, AllocatorMetrics &alloc_metrics) const |
|
AllocResult | try_wide_arith_slices_to_container_group (const ScoreContext &ctx, const Allocation &alloc, const ScAllocAlignment &alignment, const SuperCluster::SliceList *lo, const SuperCluster::SliceList *hi, const ContainerGroup &group, AllocatorMetrics &alloc_metrics) const |
|
const AllocError * | verify_can_pack (const ScoreContext &ctx, const Allocation &alloc, const SuperCluster *sc, const std::vector< AllocSlice > &candidates, const Container &c, ActionSourceCoPackMap &co_pack_hints) const |
|
AllocatorBase contains all reusable functions for PHV allocation, mostly 3 categories: (1) constraint checking functions that their names usually start with is_. (2) helper functions starts with make_* or compute_*. (3) allocation functions: const-qualified functions that returns an AllocResult.
ALLOCATION functions common to trivial and greedy allocation.
Try to allocate sc
, without further slicing, to groups
. Premise: (1) DO NOT pass fully clot-allocated clusters to this function. If does, fields will be double-allocated. (2) DO NOT pass deparser-zero-candidate cluster to this function, because they will not be allocated to zero containers, Unless the correctness of their allocation does not matter, e.g., in trivial allocator, as they are not referenced in MAU.
Try to allocate fieldslices with starting positions defined in fs_starts
to container c
. Various container-level constraints will be checked. When skip_mau_checks
are true, mau-related checks will be skipped, e.g., verify_can_pack. It should only be true when allocator is trying to allocate stride clusters. Premises without BUG_CHECK: (1) fs_starts
contains all field slices that needs to be allocated to c
. They should never exceed the width of the container, i.e., max_i(start_i + size_i) < c.width(). (2) allocating to c
will not violate pa_container_size pragma specified on field slices in fs_starts:
(3) if there were wide_arithmetic slices, if lo(hi), c
must have even(odd) index. Also caller needs to allocate them to adjacent even-odd pair containers. (4) if deparsed/exact_container, total number of bits must be equal to the width of c
. (5) field slices of an aligned cluster, including slices that have already been allocated in alloc
, and slices to be allcoated in fs_starts
, must have the same starting index in container. This function, and all the functions this function will invoke, will not check this constraint. Failed to respect this rule will get an action analysis error in later passes.
- Returns
- error in AllocResult if (1) not enough space: <1> non-mutex bits occupied or has non-mutex solitary field. <2> uninitialized read + extracted. (2) cannot pack into container. (3) when container is mocha/dark/tphv, not all field slices are be valid to be allocated to the container type of
c
. (4) violate pa_container_type. (5) container gress match (6) parserGroupGress match, all containers must have same write mode. (7) deparser group must be the same. (8) solitary fields are not packed with other fields except for paddings fields. (9) fields in fs_starts
will not violate parser extraction constraints. (5) field max container bytes constraints. NOTE: alloc slices of ignore_alloc field slices will not be generated. Possible ErrorCode: (1) NOT_ENOUGH_SPACE (2) ACTION_CANNOT_BE_SYNTHESIZED (3) *all kinds of container scope static error codes, e.g. gress, container type mismatch..