82 typedef std::pair<const IR::BFN::Unit *, const IR::Expression *>
locpair;
85 enum VisitMode { VisitJustReads, VisitJustWrites, VisitAll };
87 VisitMode mode = VisitAll;
110 LocPairSet &parser_zero_inits;
117 static const LocPairSet emptyset;
132 std::vector<info> defuse;
133 class ClearBeforeEgress;
134 class CollectAliasDestinations;
136 profile_t init_apply(
const IR::Node *root)
override;
137 void end_apply(
const IR::Node *root)
override;
138 void end_apply()
override;
139 void collect_uninitalized();
140 void check_conflicts(
const info &read,
int when);
141 void read(
const PHV::Field *, std::optional<le_bitrange>,
const IR::BFN::Unit *,
142 const IR::Expression *,
bool);
143 void read(
const IR::HeaderRef *,
const IR::BFN::Unit *,
const IR::Expression *,
bool);
144 void write(
const PHV::Field *, std::optional<le_bitrange>,
const IR::BFN::Unit *,
145 const IR::Expression *,
bool);
146 void write(
const IR::HeaderRef *,
const IR::BFN::Unit *,
const IR::Expression *,
bool);
148 info &field(
int id) {
return field(phv.field(
id)); }
150 bool preorder(
const IR::BFN::Pipe *p)
override;
151 bool preorder(
const IR::BFN::Parser *p)
override;
152 void postorder(
const IR::BFN::Parser *p)
override;
153 bool preorder(
const IR::BFN::ParserState *ps)
override;
154 void postorder(
const IR::BFN::ParserState *ps)
override;
155 bool preorder(
const IR::BFN::LoweredParser *p)
override;
156 bool preorder(
const IR::MAU::Table *t)
override;
157 void postorder(
const IR::MAU::Table *t)
override;
158 bool preorder(
const IR::MAU::Primitive *prim)
override;
159 bool preorder(
const IR::MAU::Action *p)
override;
160 bool preorder(
const IR::MAU::StatefulAlu *prim)
override;
161 bool preorder(
const IR::Expression *e)
override;
162 bool preorder(
const IR::BFN::AbstractDeparser *d)
override;
163 void postorder(
const IR::BFN::AbstractDeparser *d)
override;
165 void flow_merge(
Visitor &)
override;
169 void shadow_previous_ranges(FieldDefUse::info &,
le_bitrange &);
170 friend std::ostream &operator<<(std::ostream &,
const FieldDefUse::info &);
171 friend void dump(
const FieldDefUse::info &);
172 friend std::ostream &operator<<(std::ostream &,
const FieldDefUse &);
173 std::ostream &dotgraph(std::ostream &)
const;
179 uses(*new
std::remove_reference<decltype(uses)>::type),
180 defs(*new
std::remove_reference<decltype(defs)>::type),
181 ixbar_refs(*new
std::remove_reference<decltype(ixbar_refs)>::type),
182 located_uses(*new
std::remove_reference<decltype(located_uses)>::type),
183 located_defs(*new
std::remove_reference<decltype(located_defs)>::type),
184 output_deps(*new
std::remove_reference<decltype(output_deps)>::type),
185 parser_zero_inits(*new
std::remove_reference<decltype(parser_zero_inits)>::type),
186 uninitialized_fields(*new
std::remove_reference<decltype(uninitialized_fields)>::type) {
188 visitDagOnce =
false;
189 BackwardsCompatibleBroken =
true;
195 const LocPairSet &getDefs(
locpair use)
const {
196 return defs.count(use) ? defs.at(use) : emptyset;
198 const LocPairSet &getDefs(
const IR::BFN::Unit *u,
const IR::Expression *e)
const {
201 const LocPairSet &getDefs(
const Visitor *v,
const IR::Expression *e)
const {
202 return getDefs(
locpair(v->findOrigCtxt<IR::BFN::Unit>(), e));
208 if (located_defs.count(fid)) defsnuses |= located_defs.at(fid);
209 if (located_uses.count(fid)) defsnuses |= located_uses.at(fid);
221 return located_defs.count(fid) ? located_defs.at(fid) : emptyset;
226 LocPairSet getParserDefs(
const PHV::Field *f, std::optional<le_bitrange> bits)
const;
231 const LocPairSet &getUses(
locpair def)
const {
232 return uses.count(def) ? uses.at(def) : emptyset;
234 const LocPairSet &getUses(
const IR::BFN::Unit *u,
const IR::Expression *e)
const {
237 const LocPairSet &getUses(
const Visitor *v,
const IR::Expression *e)
const {
238 return getUses(
locpair(v->findOrigCtxt<IR::BFN::Unit>(), e));
242 return located_uses.count(fid) ? located_uses.at(fid) : emptyset;
248 return output_deps.count(def) ? output_deps.at(def) : emptyset;
250 const LocPairSet &
getOutputDeps(
const IR::BFN::Unit *u,
const IR::Expression *e)
const {
258 return uninitialized_fields;
262 if (ixbar_refs.count(
info)) {
263 LOG4(
"\t ixbar_refs:" << ixbar_refs.size());
266 if (!ixbar_refs.count(
info)) {
267 LOG5(
"\t\t ixbar_refs for expression " <<
info.second <<
" not found for unit "
269 <<
", but assuming it is non-dark");
273 return ixbar_refs.at(
info);
276 bool hasUninitializedRead(
int fid)
const {
278 auto *expr = def.second;
280 if (getUses(def).size() > 0)
return true;
287 bool hasUseAt(
const PHV::Field *f,
const IR::BFN::Unit *u)
const;
288 bool hasDefAt(
const PHV::Field *f,
const IR::BFN::Unit *u)
const;
289 bool hasDefInParser(
const PHV::Field *f, std::optional<le_bitrange> bits)
const;
291 return hasDefInParser(fs.
field(), fs.
range());
Definition tofino_write_context.h:24
void info(const int kind, const char *format, const T *node, Args &&...args)
Report info messages of type kind. Requires that the node argument have source info.
Definition lib/error.h:148