P4C
The P4 Compiler
Loading...
Searching...
No Matches
finalize_stage_allocation.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_FINALIZE_STAGE_ALLOCATION_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_FINALIZE_STAGE_ALLOCATION_H_
21
22#include "bf-p4c/common/field_defuse.h"
23#include "bf-p4c/mau/table_dependency_graph.h"
24#include "bf-p4c/phv/phv_fields.h"
25
29 private:
30 // Deparser stage for each gress.
31 int deparser_stage[3] = {0, 0, 0};
32 int dep_stage_overall = -1;
33 bool preorder(const IR::MAU::Table *tbl) override;
34 void end_apply() override;
35
36 public:
37 int getDeparserStage(gress_t gress) const { return deparser_stage[gress]; }
38
39 int getDeparserStage() const { return dep_stage_overall; }
40};
41
43
51 private:
52 PhvInfo &phv;
53 const FieldDefUse &defuse;
54 const DependencyGraph &dg;
55 const CalcMaxPhysicalStages &depStages;
56
57 // Map of field to its allocated slices.
59
60 // Map of container to the stages where it is read.
61 ordered_map<PHV::Container, bitvec> containerToReadStages;
62
63 // Map of container to the stages where it is written.
64 ordered_map<PHV::Container, bitvec> containerToWriteStages;
65
66 PHV::StageAndAccess parserMin;
67 PHV::StageAndAccess deparserMax;
68
69 profile_t init_apply(const IR::Node *root) override;
70 bool preorder(const IR::MAU::Table *tbl) override;
71 void end_apply() override;
72
73 void updateAllocation(PHV::Field *f);
74
75 public:
76 explicit UpdateFieldAllocation(PhvInfo &p, const FieldDefUse &u, const DependencyGraph &d,
77 const CalcMaxPhysicalStages &s)
78 : phv(p), defuse(u), dg(d), depStages(s) {}
79};
80
82 public:
86
87 private:
88 CalcMaxPhysicalStages depStages;
89
90 public:
91 static void summarizeUseDefs(const PhvInfo &phv, const DependencyGraph &dg,
92 const FieldDefUse::LocPairSet &refs,
93 StageFieldEntry &stageToTables, bool &usedInParser,
94 bool &usedInDeparser, bool usePhysicalStages = true);
95
96 explicit FinalizeStageAllocation(PhvInfo &p, const FieldDefUse &u, const DependencyGraph &d);
97};
98
99#endif /* BACKENDS_TOFINO_BF_P4C_PHV_FINALIZE_STAGE_ALLOCATION_H_ */
Definition finalize_stage_allocation.h:28
Definition finalize_stage_allocation.h:81
Definition node.h:95
Definition visitor.h:400
Definition ir/pass_manager.h:40
Definition visitor.h:78
Definition ordered_map.h:32
Definition phv_fields.h:154
Definition phv_fields.h:1095
Definition finalize_stage_allocation.h:50
Definition field_defuse.h:77
Definition table_dependency_graph.h:52