P4C
The P4 Compiler
Loading...
Searching...
No Matches
finalize_physical_liverange.h
1
19#ifndef BF_P4C_PHV_FINALIZE_PHYSICAL_LIVERANGE_H_
20#define BF_P4C_PHV_FINALIZE_PHYSICAL_LIVERANGE_H_
21
22#include "backends/tofino/bf-p4c/common/field_defuse.h"
23#include "backends/tofino/bf-p4c/ir/tofino_write_context.h"
24#include "backends/tofino/bf-p4c/mau/table_mutex.h"
25#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
26#include "backends/tofino/bf-p4c/phv/phv.h"
27#include "backends/tofino/bf-p4c/phv/phv_fields.h"
28#include "backends/tofino/bf-p4c/phv/pragma/pa_no_init.h"
29#include "ir/ir.h"
30
31namespace PHV {
32
40 private:
41 PhvInfo &phv_i;
42 const ClotInfo &clot_i;
43 // used to verify overlapped live ranges for overlaying but non-mutex fields.
44 const TablesMutuallyExclusive &tb_mutex_i;
45 const FieldDefUse &defuse_i;
49 const BFN::HeaderStackInfo *headerStacks = nullptr;
50
58 ordered_map<const PHV::Field *, LiveRange> temp_var_live_ranges_i;
59
60 const PragmaNoInit &pa_no_init;
61
65 void mark_access(const PHV::Field *f, le_bitrange bits, const IR::BFN::Unit *unit,
66 bool is_write, bool allow_unallocated = false);
67
69 void update_liverange(const safe_vector<AllocSlice> &slices, const StageAndAccess &op);
70
71 protected:
73 profile_t init_apply(const IR::Node *root) override {
74 live_ranges_i.clear();
75 tables_i.clear();
76 table_stages_i.clear();
77 temp_var_live_ranges_i.clear();
78
79 return Inspector::init_apply(root);
80 }
81
83 bool preorder(const IR::BFN::Pipe *pipe) override;
84
86 bool preorder(const IR::BFN::ParserState *) override {
87 visitOnce();
88 return true;
89 }
90
91 bool preorder(const IR::BFN::Extract *extract) override;
92
94 bool preorder(const IR::MAU::Table *t) override;
95
97 bool preorder(const IR::Expression *e) override;
98
102 void end_apply() override;
103
104 public:
108 explicit FinalizePhysicalLiverange(PhvInfo &phv, const ClotInfo &clot,
109 const TablesMutuallyExclusive &tb_mutex,
110 const FieldDefUse &defuse, const PragmaNoInit &pa_no_init)
111 : phv_i(phv), clot_i(clot), tb_mutex_i(tb_mutex), defuse_i(defuse), pa_no_init(pa_no_init) {
112 visitDagOnce = false;
113 }
114
117 return temp_var_live_ranges_i;
118 }
119};
120
121} // namespace PHV
122
123#endif /* BF_P4C_PHV_FINALIZE_PHYSICAL_LIVERANGE_H_ */
Definition clot_info.h:41
Definition node.h:94
Definition visitor.h:400
Definition visitor.h:78
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition safe_vector.h:27
Definition phv_fields.h:154
Definition finalize_physical_liverange.h:39
bool preorder(const IR::BFN::Pipe *pipe) override
Sets headerStacks.
Definition finalize_physical_liverange.cpp:88
FinalizePhysicalLiverange(PhvInfo &phv, const ClotInfo &clot, const TablesMutuallyExclusive &tb_mutex, const FieldDefUse &defuse, const PragmaNoInit &pa_no_init)
Definition finalize_physical_liverange.h:108
void end_apply() override
Definition finalize_physical_liverange.cpp:228
profile_t init_apply(const IR::Node *root) override
init_apply clears internal states.
Definition finalize_physical_liverange.h:73
bool preorder(const IR::BFN::ParserState *) override
optimization for visitDagOnce = false: we only need to visit parser state once.
Definition finalize_physical_liverange.h:86
const ordered_map< const PHV::Field *, LiveRange > & unallocated_temp_var_live_ranges() const
Definition finalize_physical_liverange.h:116
Definition phv_fields.h:1095
Definition mau/table_mutex.h:110
Definition tofino_write_context.h:24
Adds the no_init pragma to the specified fields with the specified gress.
Definition pa_no_init.h:35
Definition field_defuse.h:77
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
Metadata about how header stacks are used in the program.
Definition header_stack.h:94