P4C
The P4 Compiler
Loading...
Searching...
No Matches
smart_packing.h
1
19#ifndef SMART_PACKING_H_
20#define SMART_PACKING_H_
21
22#include "bf-p4c/common/field_defuse.h"
23#include "bf-p4c/ir/bitrange.h"
24#include "bf-p4c/mau/table_dependency_graph.h"
25#include "bf-p4c/mau/table_mutex.h"
26#include "bf-p4c/phv/collect_table_keys.h"
27#include "bf-p4c/phv/mau_backtracker.h"
28#include "bf-p4c/phv/phv_fields.h"
29#include "bf-p4c/phv/utils/utils.h"
30#include "bf-p4c/phv/v2/allocator_metrics.h"
31#include "bf-p4c/phv/v2/parser_packing_validator.h"
32#include "bf-p4c/phv/v2/types.h"
33#include "ir/ir.h"
34
35namespace PHV {
36namespace v2 {
37
39 PhvInfo &phv_i;
40 const CollectTableKeys &tables_i;
41 const TablesMutuallyExclusive &table_mutex_i;
42 const FieldDefUse &defuse_i;
43 const DependencyGraph &deps_i;
44 const HasPackConflict has_pack_conflict_i;
45 const ParserPackingValidator *parser_packing_validator_i;
46 const AllocVerifier &can_alloc_i;
47 const MauBacktracker *mau_i;
48 AllocatorMetrics &alloc_metrics;
49
50 bool can_pack(const std::vector<FieldSlice> &slices, const FieldSlice &fs) const;
51
52 struct MergedCluster {
53 SuperCluster *merged;
56 };
57 MergedCluster merge_by_packing(const std::vector<FieldSlice> &packing,
59
62 std::vector<std::pair<const IR::MAU::Table *, std::vector<FieldSlice>>>
63 make_table_key_candidates(const std::list<SuperCluster *> &clusters) const;
64
65 public:
67 const TablesMutuallyExclusive &table_mutex, const FieldDefUse &defuse,
68 const DependencyGraph &deps, HasPackConflict has_pc,
69 const ParserPackingValidator *parser_packing_validator,
70 const AllocVerifier &can_alloc, const MauBacktracker *mau,
71 AllocatorMetrics &alloc_metrics)
72 : phv_i(phv),
73 tables_i(tables),
74 table_mutex_i(table_mutex),
75 defuse_i(defuse),
76 deps_i(deps),
77 has_pack_conflict_i(has_pc),
78 parser_packing_validator_i(parser_packing_validator),
79 can_alloc_i(can_alloc),
80 mau_i(mau),
81 alloc_metrics(alloc_metrics) {}
82
83 std::list<SuperCluster *> pack(const std::list<SuperCluster *> &clusters);
84 static bool may_create_container_conflict(const FieldSlice &a, const FieldSlice &b,
85 const FieldDefUse &defuse,
86 const DependencyGraph &deps,
87 const TablesMutuallyExclusive &table_mutex,
88 int n_stages, const MauBacktracker *mau);
89};
90
91} // namespace v2
92} // namespace PHV
93
94#endif /* SMART_PACKING_H_ */
Definition mau_backtracker.h:29
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition collect_table_keys.h:27
Definition phv_fields.h:898
Definition phv/utils/utils.h:1049
AllocatorMetrics contains metrics useful in tracking Allocator efficiency and debug.
Definition allocator_metrics.h:30
Definition smart_packing.h:38
static bool may_create_container_conflict(const FieldSlice &a, const FieldSlice &b, const FieldDefUse &defuse, const DependencyGraph &deps, const TablesMutuallyExclusive &table_mutex, int n_stages, const MauBacktracker *mau)
Definition smart_packing.cpp:37
std::list< SuperCluster * > pack(const std::list< SuperCluster * > &clusters)
Definition smart_packing.cpp:375
Definition parser_packing_validator.h:42
Definition phv_fields.h:1095
Definition mau/table_mutex.h:110
Definition field_defuse.h:77
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
Definition table_dependency_graph.h:52