19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_ADD_INITIALIZATION_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_ADD_INITIALIZATION_H_
22#include "bf-p4c/common/field_defuse.h"
23#include "bf-p4c/common/map_tables_to_actions.h"
24#include "bf-p4c/mau/add_always_run.h"
25#include "bf-p4c/mau/table_dependency_graph.h"
26#include "bf-p4c/mau/table_mutex.h"
27#include "bf-p4c/phv/analysis/meta_live_range.h"
28#include "bf-p4c/phv/finalize_stage_allocation.h"
29#include "bf-p4c/phv/phv_fields.h"
41 fieldExpressions.clear();
42 return Inspector::init_apply(root);
49 bool preorder(
const IR::Expression *expr)
override;
54 const IR::Expression *getExpr(
const PHV::Field *field)
const {
55 BUG_CHECK(fieldExpressions.count(field->
id),
"Missing IR::Expression mapping of %1%",
57 return fieldExpressions.at(field->
id)->clone();
77 const IR::Node *apply_visitor(
const IR::Node *root,
const char * =
nullptr)
override;
94 const std::vector<PHV::AllocSlice> getInitsForAction(
const IR::MAU::Action *act)
const {
95 std::vector<PHV::AllocSlice> empty;
96 if (!actionInits.count(act))
return empty;
97 return actionInits.at(act);
111 void computeInitInstruction(
const PHV::AllocSlice &slice,
const IR::MAU::Action *act);
118 int prior_max_stage,
int post_min_stage,
bool init_from_zero);
122 bool use_same_containers(
PHV::AllocSlice alloc_sl, IR::MAU::Table *&ara_tbl);
129 cstring getKey(
const IR::MAU::Table *tbl,
const IR::MAU::Action *act)
const {
130 return (tbl->name +
"." + act->name);
134 void end_apply()
override;
138 static int ARA_table_id;
141 : phv(p), tableActionsMap(m), fieldToExpr(e), dg(g) {}
144 const IR::MAU::Table *tbl,
const IR::MAU::Action *act)
const;
176 void end_apply()
override;
181 void noteDependencies(
185 void addDepsForDarkInitialization();
186 void addDepsForSetsOfAllocSlices(
const std::vector<PHV::AllocSlice> &alloc_slices,
188 const StageFieldUse &fieldReads,
bool checkBitsOverlap =
true);
192 void accountUses(
int min_stage,
int max_stage,
const PHV::AllocSlice &alloc,
200 : phv(p), dg(g), actionsMap(a), fieldsForInit(i), defuse(d), liverange(r), tableMutex(m) {}
202 bool isInitTable(
const IR::MAU::Table *tbl)
const {
return initTableNames.count(tbl->name); }
212 IR::Node *preorder(IR::MAU::Table *tbl)
override {
213 if (dep.isInitTable(tbl)) {
214 tbl->has_dark_init =
true;
215 LOG2(
"\tDark initialization table: " << tbl->name);
Definition add_initialization.h:228
Definition add_initialization.h:101
Definition add_initialization.h:159
Definition add_initialization.h:67
Definition add_initialization.h:35
const IR::MAU::Instruction * generateInitInstruction(const PHV::AllocSlice &slice) const
Definition add_initialization.cpp:31
Definition map_tables_to_actions.h:29
Definition add_initialization.h:209
Definition ir/pass_manager.h:40
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition slice_alloc.h:136
Definition phv_fields.h:154
int id
Unique field ID.
Definition phv_fields.h:164
cstring name
Definition phv_fields.h:161
Definition phv_fields.h:1095
Definition mau/table_mutex.h:110
Definition field_defuse.h:77
Definition table_dependency_graph.h:52