P4C
The P4 Compiler
Loading...
Searching...
No Matches
meta_live_range.h
1
19#ifndef BF_P4C_PHV_ANALYSIS_META_LIVE_RANGE_H_
20#define BF_P4C_PHV_ANALYSIS_META_LIVE_RANGE_H_
21
22#include "backends/tofino/bf-p4c/common/field_defuse.h"
23#include "backends/tofino/bf-p4c/mau/table_dependency_graph.h"
24#include "backends/tofino/bf-p4c/phv/mau_backtracker.h"
25#include "backends/tofino/bf-p4c/phv/phv_fields.h"
26#include "backends/tofino/bf-p4c/phv/phv_parde_mau_use.h"
27#include "backends/tofino/bf-p4c/phv/pragma/phv_pragmas.h"
28#include "ir/ir.h"
29#include "lib/log.h"
30#include "lib/symbitmatrix.h"
31
42 public:
43 // TODO: Should we expose a way of changing the DEP_DIST using a command line flag, as
44 // glass does?
45 static constexpr int DEP_DIST = 2;
48 static constexpr char const *INGRESS_PARSER_ENTRY = "$entry_point.$ingress_tna_entry_point";
51 static constexpr char const *EGRESS_PARSER_ENTRY = "$entry_point.$egress_tna_entry_point";
52
56 static bool notOverlapping(int minStage1, int maxStage1, int minStage2, int maxStage2,
57 int depDist = DEP_DIST);
58
61 static bool notOverlapping(std::pair<int, int> &range1, std::pair<int, int> &range2,
62 int depDist = DEP_DIST);
63
66
68 enum access_t { READ = 1, WRITE = 2 };
69
71 static cstring printAccess(int access);
72
73 private:
74 PhvInfo &phv;
75 const DependencyGraph &dg;
76 FieldDefUse &defuse;
77 const PragmaNoOverlay &noOverlay;
78 const PhvUse &uses;
79
82 const ordered_set<const PHV::Field *> &noInitFields;
84 const ordered_set<const PHV::Field *> &notParsedFields;
86 const ordered_set<const PHV::Field *> &notDeparsedFields;
87
91 SymBitMatrix &overlay;
92
97
100
101 profile_t init_apply(const IR::Node *root) override;
102 bool preorder(const IR::MAU::Table *t) override;
103 void end_apply() override;
104
106 void printLiveRanges() const;
107
109 void setFieldLiveMap(const PHV::Field *f);
110
113 void setPaddingFieldLiveMap(const PHV::Field *f);
114
115 public:
119
123 return livemapUsage;
124 }
125
128 return minStages;
129 }
130
133 if (!minStages.count(stage))
134 BUG("Stage %1% not in the resource-insensitive tabel dependence graph", stage);
135 return minStages.at(stage);
136 }
137
140 bool hasPotentialLiveRangeOverlay(const PHV::Field *f1, const PHV::Field *f2) const {
141 return overlay(f1->id, f2->id);
142 }
143
144 explicit MetadataLiveRange(PhvInfo &p, const DependencyGraph &g, FieldDefUse &f,
145 const PHV::Pragmas &pragmas, const PhvUse &u, const MauBacktracker &)
146 : phv(p),
147 dg(g),
148 defuse(f),
149 noOverlay(pragmas.pa_no_overlay()),
150 uses(u),
151 noInitFields(pragmas.pa_no_init().getFields()),
152 notParsedFields(pragmas.pa_deparser_zero().getNotParsedFields()),
153 notDeparsedFields(pragmas.pa_deparser_zero().getNotDeparsedFields()),
154 overlay(phv.metadata_mutex()) {}
155};
156
157#endif /* BF_P4C_PHV_ANALYSIS_META_LIVE_RANGE_H_ */
Definition mau_backtracker.h:29
Definition meta_live_range.h:41
const ordered_map< int, ordered_set< const IR::MAU::Table * > > & getMinStageMap() const
Definition meta_live_range.h:127
static cstring printAccess(int access)
Definition phv/analysis/meta_live_range.cpp:21
static constexpr char const * EGRESS_PARSER_ENTRY
Definition meta_live_range.h:51
static bool notOverlapping(int minStage1, int maxStage1, int minStage2, int maxStage2, int depDist=DEP_DIST)
Definition phv/analysis/meta_live_range.cpp:39
const ordered_map< int, std::pair< int, int > > & getMetadataLiveMapUsage() const
Definition meta_live_range.h:122
static const ordered_set< cstring > noInitIntrinsicFields
Set of intrinsic metadata fields that must not be initialized.
Definition meta_live_range.h:65
const ordered_set< const IR::MAU::Table * > getTablesInStage(int stage) const
Definition meta_live_range.h:132
const ordered_map< int, std::pair< int, int > > & getMetadataLiveMap() const
Definition meta_live_range.h:118
bool hasPotentialLiveRangeOverlay(const PHV::Field *f1, const PHV::Field *f2) const
Definition meta_live_range.h:140
access_t
Type of access in a unit. OR these together for a Read/Write access (RW=3).
Definition meta_live_range.h:68
static constexpr char const * INGRESS_PARSER_ENTRY
Definition meta_live_range.h:48
Definition visitor.h:400
Definition symbitmatrix.h:27
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition phv_fields.h:154
int id
Unique field ID.
Definition phv_fields.h:164
Definition phv_pragmas.h:46
Definition phv_fields.h:1095
Definition phv_parde_mau_use.h:154
Definition pa_no_overlay.h:33
Definition field_defuse.h:77
Definition table_dependency_graph.h:52