P4C
The P4 Compiler
Loading...
Searching...
No Matches
allocate_temps_and_finalize_liverange.h
1
19#ifndef BF_P4C_PHV_ALLOCATE_TEMPS_AND_FINALIZE_LIVERANGE_H_
20#define BF_P4C_PHV_ALLOCATE_TEMPS_AND_FINALIZE_LIVERANGE_H_
21
22#include "backends/tofino/bf-p4c/common/field_defuse.h"
23#include "backends/tofino/bf-p4c/mau/table_summary.h"
24#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
25#include "backends/tofino/bf-p4c/phv/phv_parde_mau_use.h"
26#include "ir/ir.h"
27
28namespace PHV {
29
30// TODO (Yumin): Enhance logs during PHV::AllocateTempsAndFinalizeLiverange to indentify
31// and log these conditions in phv logs where a field mutex is not consistent with a table mutex
32//
33// Two non-mutex fields, f_a and f_b, are overlaid in B0.
34// f_a's live range: [-1w, 4r]
35// f_b's live range: [3w, 7r]
36// It's not a BUG, because when the table t_a that writes f_a are mutex
37// with table t_b that reads f_b, hence they will not cause read / write violations
38//
39// stage 3 stage 4
40// |---- t_a writes B0
41// ---|
42// |--------------------- t_b reads B0
43//
44
46 PhvInfo &phv_i;
47 const ClotInfo &clot_i;
48 const FieldDefUse &defuse_i;
49 const TableSummary &ts_i;
50
51 public:
52 AllocateTempsAndFinalizeLiverange(PhvInfo &phv, const ClotInfo &clot, const FieldDefUse &defuse,
53 const ::TableSummary &ts);
54};
55
56// For programs exceeding available stages for Tofino HW i.e. (12 for Tofino1 & 20 for Tofino2), it
57// is necessary to have a bfa and whatever logs / json can be generated for a better debug
58// experience.
59//
60// For such compilation, max stage is greater than allowed stages hence the deparser stages is the
61// new max stage + 1. Currently live range checks are performed on each field slice, hence we add a
62// Pass here UpdateDeparserStage to indicate that the deparser stage has exceeded. Live range checks
63// are also updated to check the presence of this condition and validate live range.
64//
65// NOTES:
66// - This pass is only for Alt Phv Alloc compilation as bfa is always generated in
67// such conditions for a standard compilation, hence this also brings parity with the standard
68// compilation. Also the parent pass AllocateTempsAndFinalizeLiverange is only applicable to Alt
69// - This pass is only triggered when compilation has failed.
70// - When we reach this stage of compilation (AllocateTempsAndFinalizeLiverange) it is guaranteed to
71// have exceeded stages if failed as any other Table Placement error would cause a fatal error in
72// TableSummary earlier.
73//
74// Workflow:
75//
76// Alt-Phv-Alloc Enabled
77// |
78// Table Placement exceeds stages
79// |
80// Table Summary (issues warning)
81// |
82// AllocateTempsAndFinalizeLiverange triggered
83// |
84// Has TP Failed? -> Yes
85// | |
86// NO UpdateDeparserStage
87// | (set isPhysicalDeparserStageExceeded)
88// v |
89// FinalizePhysicalLiverange
90// (check isPhysicalDeparserStageExceeded and allow larger deparser stage)
91//
93 PhvInfo &phv_i;
94
95 void end_apply() override;
96
97 public:
98 explicit UpdateDeparserStage(PhvInfo &phv) : phv_i(phv) {}
99};
100
101} // namespace PHV
102
103#endif /* BF_P4C_PHV_ALLOCATE_TEMPS_AND_FINALIZE_LIVERANGE_H_ */
Definition clot_info.h:41
Definition visitor.h:400
Definition ir/pass_manager.h:40
Definition allocate_temps_and_finalize_liverange.h:45
Definition allocate_temps_and_finalize_liverange.h:92
Definition phv_fields.h:1095
Definition table_summary.h:158
Definition field_defuse.h:77
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32