P4C
The P4 Compiler
Toggle main menu visibility
Main Page
P4C Repository Organization
Getting Started
P4C Intermediate Representation (IR)
Frontend
Midend
Backends
Behavioral Model Backend
DPDK Backend
eBPF Backend
TC Backend
uBPF Backend
P4test Backend
Graphs Backend
p4fmt (P4 Formatter)
P4Tools
P4Smith
P4Testgen
Contribute to the P4 Compiler Project
Releases
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
w
x
z
Functions
a
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
w
x
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Typedefs
Enumerations
Enumerator
Related Symbols
•
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
Loading...
Searching...
No Matches
finalize_stage_allocation.h
1
18
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 "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/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
};
28
class
CalcMaxPhysicalStages
:
public
Inspector
{
…
};
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
};
50
class
UpdateFieldAllocation :
public
Inspector
{
…
};
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
};
81
class
FinalizeStageAllocation :
public
PassManager {
…
};
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:94
P4::Inspector
Definition
visitor.h:413
P4::Visitor::profile_t
Definition
visitor.h:78
P4::ordered_map
Definition
ordered_map.h:32
PHV::Field
Definition
phv_fields.h:154
PhvInfo
Definition
phv_fields.h:1095
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.13.0