P4C
The P4 Compiler
Loading...
Searching...
No Matches
pack_conflicts.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_PACK_CONFLICTS_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_PACK_CONFLICTS_H_
21
22#include "bf-p4c/lib/assoc.h"
23#include "bf-p4c/mau/action_analysis.h"
24#include "bf-p4c/mau/action_mutex.h"
25#include "bf-p4c/mau/table_dependency_graph.h"
26#include "bf-p4c/mau/table_mutex.h"
27#include "bf-p4c/phv/mau_backtracker.h"
28#include "bf-p4c/phv/phv_fields.h"
29#include "bf-p4c/phv/pragma/pa_no_pack.h"
30#include "ir/ir.h"
31
36class PackConflicts : public PassManager {
37 private:
38 PhvInfo &phv;
39 const DependencyGraph &dg;
40 IgnoreTableDeps ignore;
41 const TablesMutuallyExclusive &mutex;
42 const MauBacktracker &bt;
43 const ActionMutuallyExclusive &amutex;
44 const PragmaNoPack &pa_no_pack;
45 const TableSummary *table_summary;
46
48 size_t totalNumSet = 0;
49
55
56 ordered_map<PHV::FieldSlice, int> fieldslice_to_id;
58 int fieldslice_id_counter = 0;
59 SymBitMatrix fieldslice_no_pack_i;
60
61 profile_t init_apply(const IR::Node *root) override;
62
63 class GatherWrites : public Inspector {
64 PackConflicts &self;
66 bool preorder(const IR::MAU::Action *act) override;
67
69 bool preorder(const IR::BFN::Digest *digest) override;
70
71 public:
72 explicit GatherWrites(PackConflicts &s) : self(s) {}
73 };
75 void end_apply() override;
76
82 void generateNoPackConstraints(const IR::MAU::Table *t1, const IR::MAU::Table *t2);
83
84 void generateNoPackConstraintsForBridgedFields(const IR::MAU::Table *, const IR::MAU::Table *);
85
88 void updateNumPackConstraints();
89
90 public:
92 const MauBacktracker &b, const ActionMutuallyExclusive &a,
93 const PragmaNoPack &no_pack, const TableSummary *table_summary = nullptr)
94 : phv(p),
95 dg(d),
96 mutex(m),
97 bt(b),
98 amutex(a),
99 pa_no_pack(no_pack),
100 table_summary(table_summary) {
101 addPasses({new GatherWrites(*this), &ignore});
102 }
103
104 void removePackConflict(const PHV::FieldSlice &f1, const PHV::FieldSlice &f2);
105
106 void addPackConflict(const PHV::FieldSlice &f1, const PHV::FieldSlice &f2);
107
108 bool hasPackConflict(const PHV::FieldSlice &f1, const PHV::FieldSlice &f2) const;
109
110 bool writtenInSameStageDifferentTable(const IR::MAU::Table *t1, const IR::MAU::Table *t2) const;
111
112 void printNoPackConflicts() const;
113
114 unsigned size() const;
115};
116
117#endif /* BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_PACK_CONFLICTS_H_ */
Definition action_mutex.h:29
Definition mau/table_mutex.h:36
Definition mau_backtracker.h:29
Definition node.h:95
Definition visitor.h:400
Definition ir/pass_manager.h:40
Definition symbitmatrix.h:27
Definition visitor.h:78
Definition ordered_map.h:32
Definition phv_fields.h:898
Definition pack_conflicts.h:36
Definition phv_fields.h:1095
Definition pa_no_pack.h:28
Definition table_summary.h:158
Definition mau/table_mutex.h:110
Definition assoc.h:403
Definition table_dependency_graph.h:52