19#ifndef BF_P4C_PHV_V2_COPACKER_H_
20#define BF_P4C_PHV_V2_COPACKER_H_
22#include "bf-p4c/phv/action_source_tracker.h"
23#include "bf-p4c/phv/utils/utils.h"
24#include "bf-p4c/phv/v2/utils_v2.h"
33 std::optional<PHV::Container>
container = std::nullopt;
48std::ostream &operator<<(std::ostream &,
const SrcPackVec &);
49std::ostream &operator<<(std::ostream &,
const SrcPackVec *);
62std::ostream &operator<<(std::ostream &,
const CoPackHint &);
63std::ostream &operator<<(std::ostream &,
const CoPackHint *);
76 bool ok()
const {
return err ==
nullptr; }
88 using DestSrcsKv = std::pair<AllocSlice, safe_vector<SourceOp>>;
91 struct CoPackHintOrErr {
94 bool ok()
const {
return err ==
nullptr; }
95 explicit CoPackHintOrErr(
const AllocError *err) : err(err) {}
96 explicit CoPackHintOrErr(
const CoPackHint *c) : hint(c) {}
100 std::optional<int> get_decided_start_index(
const FieldSlice &fs)
const;
104 const int new_fs_start_index,
const Container &c)
const;
107 bool skip_source_packing(
const FieldSlice &fs)
const;
120 const IR::MAU::Action *action,
const DestSrcsMap &writes,
126 CoPackHintOrErr gen_whole_container_set_copack(
const Allocation &allocated_tx,
127 const IR::MAU::Action *action,
140 CoPackHintOrErr gen_move_copack(
const Allocation &allocated_tx,
const IR::MAU::Action *action,
152 const std::vector<AllocSlice> &slices,
const Container &c)
const;
ActionSourceTracker collects all source-to-destination for all field slices.
Definition action_source_tracker.h:49
Definition phv/utils/utils.h:117
Definition phv_fields.h:898
Definition phv/utils/utils.h:1049
CoPacker is the method that compute and generates copack constraints.
Definition copacker.h:80
CoPackResult gen_copack_hints(const Allocation &allocated_tx, const std::vector< AllocSlice > &slices, const Container &c) const
Definition copacker.cpp:486
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
cstring reason
reason of this copack constraint.
Definition copacker.h:60
bool required
true if this packing is the only option and required.
Definition copacker.h:58
std::vector< SrcPackVec * > pack_sources
1 or 2 source packing vector.
Definition copacker.h:56
Result type that either has some copack hints, or an error.
Definition copacker.h:73
Definition utils_v2.h:134
FieldSliceAllocStartMap fs_starts
field slices and their starting indexes.
Definition copacker.h:36
std::optional< PHV::Container > container
pack to this container.
Definition copacker.h:33
size_t size() const
Definition copacker.h:46
bool empty() const
Definition copacker.h:43