P4C
The P4 Compiler
Loading...
Searching...
No Matches
table_phv_constraints.h
1
19#ifndef BF_P4C_PHV_TABLE_PHV_CONSTRAINTS_H_
20#define BF_P4C_PHV_TABLE_PHV_CONSTRAINTS_H_
21
22#include "backends/tofino/bf-p4c/mau/mau_visitor.h"
23#include "backends/tofino/bf-p4c/phv/action_phv_constraints.h"
24#include "backends/tofino/bf-p4c/phv/analysis/pack_conflicts.h"
25#include "backends/tofino/bf-p4c/phv/phv_fields.h"
26#include "backends/tofino/bf-p4c/phv/pragma/pa_container_size.h"
27#include "backends/tofino/bf-p4c/phv/utils/slice_alloc.h"
28#include "ir/ir.h"
29
41 private:
42 static constexpr unsigned BITS_IN_BYTE = 8;
43 static constexpr unsigned TERNARY_MATCH_KEY_BITS_THRESHOLD = 64;
44 static constexpr unsigned MAX_EXACT_MATCH_KEY_BYTES = 128;
45 static constexpr size_t MAX_TERNARY_MATCH_KEY_BITS = (44 * 12) - 4;
46
47 PhvInfo &phv;
48
49 profile_t init_apply(const IR::Node *root) override;
50 bool preorder(IR::MAU::Table *tbl) override;
51 void end_apply() override;
52
53 bool isATCAM(IR::MAU::Table *tbl) const;
54 bool isTernary(IR::MAU::Table *tbl) const;
55
56 void calculateTernaryMatchKeyConstraints(const IR::MAU::Table *tbl) const;
57
58 public:
59 explicit TernaryMatchKeyConstraints(PhvInfo &p) : phv(p) {}
60};
61
63 private:
64 PhvInfo &phv;
65 const ActionPhvConstraints &actions;
66 PackConflicts &pack;
67
68 bool preorder(const IR::MAU::Action *action) override;
69
70 public:
73 : phv(p), actions(a), pack(c) {}
74};
75
81 public:
83 addPasses({new TernaryMatchKeyConstraints(p), new CollectForceImmediateFields(p, a, c)});
84 }
85};
98 private:
99 const PhvInfo &phv;
102
103 profile_t init_apply(const IR::Node *root) override;
104 void end_apply() override;
105 bool preorder(const IR::MAU::Table *tbl) override;
106 int getNumberOfEntriesInTable(const IR::MAU::Table *tbl);
107 int getFieldSlicePackScore(const PHV::AllocSlice &slice, const PHV::AllocSlice &slice2) const;
108
109 public:
110 explicit TableFieldPackOptimization(PhvInfo &p) : phv(p) {}
111
113 const ordered_set<PHV::AllocSlice> &slices) const;
114 std::list<PHV::FieldSlice> getPackCandidate(const PHV::FieldSlice &fs) const;
115};
116
117#endif /* BF_P4C_PHV_TABLE_PHV_CONSTRAINTS_H_ */
Definition action_phv_constraints.h:107
Definition table_phv_constraints.h:62
Definition mau_visitor.h:29
Definition mau_visitor.h:45
Definition node.h:94
Definition ir/pass_manager.h:40
Definition visitor.h:78
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition slice_alloc.h:136
Definition phv_fields.h:898
Definition pack_conflicts.h:36
Definition phv_fields.h:1095
Definition table_phv_constraints.h:97
int getPackScore(const ordered_set< PHV::AllocSlice > &parent, const ordered_set< PHV::AllocSlice > &slices) const
Definition table_phv_constraints.cpp:272
std::list< PHV::FieldSlice > getPackCandidate(const PHV::FieldSlice &fs) const
Definition table_phv_constraints.cpp:308
Definition table_phv_constraints.h:80
Definition table_phv_constraints.h:40