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
28
class
CalcMaxPhysicalStages
:
public
Inspector
{
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
42
class
FinalizeStageAllocation
;
43
50
class
UpdateFieldAllocation
:
public
Inspector
{
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.
58
ordered_map<const PHV::Field *, std::vector<PHV::AllocSlice>
> fieldToSlicesMap;
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
81
class
FinalizeStageAllocation
:
public
PassManager
{
82
public
:
83
using
TableExprRanges
=
ordered_map<const IR::MAU::Table *, ordered_set<le_bitrange>
>;
84
using
StageFieldEntry
=
ordered_map<int, TableExprRanges>
;
85
using
StageFieldUse
=
ordered_map<const PHV::Field *, StageFieldEntry>
;
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_ */
CalcMaxPhysicalStages
Definition
finalize_stage_allocation.h:28
FinalizeStageAllocation
Definition
finalize_stage_allocation.h:81
P4::IR::Node
Definition
node.h:95
P4::Inspector
Definition
visitor.h:400
P4::PassManager
Definition
ir/pass_manager.h:40
P4::Visitor::profile_t
Definition
visitor.h:78
P4::ordered_map
Definition
ordered_map.h:32
P4::ordered_set< locpair >
PHV::Field
Definition
phv_fields.h:154
PhvInfo
Definition
phv_fields.h:1095
UpdateFieldAllocation
Definition
finalize_stage_allocation.h:50
FieldDefUse
Definition
field_defuse.h:77
DependencyGraph
Definition
table_dependency_graph.h:52
backends
tofino
bf-p4c
phv
finalize_stage_allocation.h
Generated by
1.12.0