P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino/bf-p4c/backend.h
1
19#ifndef BF_P4C_BACKEND_H_
20#define BF_P4C_BACKEND_H_
21
22#include "backends/tofino/bf-p4c/bf-p4c-options.h"
23#include "backends/tofino/bf-p4c/common/bridged_packing.h"
24#include "backends/tofino/bf-p4c/logging/phv_logging.h"
25#include "backends/tofino/bf-p4c/mau/finalize_mau_pred_deps_power.h"
26#include "backends/tofino/bf-p4c/mau/jbay_next_table.h"
27#include "backends/tofino/bf-p4c/mau/mau_alloc.h"
28#include "backends/tofino/bf-p4c/mau/table_dependency_graph.h"
29#include "backends/tofino/bf-p4c/mau/table_mutex.h"
30#include "backends/tofino/bf-p4c/mau/table_summary.h"
31#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
32#include "backends/tofino/bf-p4c/parde/decaf.h"
33#include "backends/tofino/bf-p4c/parde/parser_header_sequences.h"
34#include "backends/tofino/bf-p4c/phv/mau_backtracker.h"
35#include "backends/tofino/bf-p4c/phv/phv_fields.h"
36#include "backends/tofino/bf-p4c/phv/phv_parde_mau_use.h"
37#include "backends/tofino/bf-p4c/phv/utils/live_range_report.h"
38#include "bf-p4c-options.h"
39#include "ir/ir.h"
40
41class FieldDefUse;
43
44namespace BFN {
45
46class Backend : public PassManager {
47 BFN_Options options;
48 PhvInfo phv;
49 PhvUse uses;
50 ClotInfo clot;
51 DependencyGraph deps;
52 FieldDefUse defuse;
54 DeparserCopyOpt decaf;
55 // Since both phv allocation or table allocation result may change compilation_state,
56 // compilation_state is moved from table_summary to backend
57 State::state_t compilation_state = State::INITIAL;
59 TableSummary table_summary;
61 MauBacktracker mau_backtracker;
62 TableAllocPass table_alloc;
63 // Primitives Json Node, is populated before instruction adjustment and
64 // passed to AsmOutput to output primitive json file
65 Util::JsonObject primNode;
66 // Dependency Flow Graph Json, is a collection of graphs populated when
67 // passed as a parameter to FindDependencyGraph pass. By default graphs are
68 // generated once before and once after table placement.
69 Util::JsonObject jsonGraph;
70
71 LogFlexiblePacking *flexibleLogging;
72 CollectPhvLoggingInfo *phvLoggingInfo;
73 PhvLogging::CollectDefUseInfo *phvLoggingDefUseInfo;
74 DynamicNextTable nextTblProp;
76 LiveRangeReport *liveRangeReport;
77
78 // Identify the header sequences extracted in the parser
79 ParserHeaderSequences parserHeaderSeqs;
80 // Disable long branches
81 bool longBranchDisabled;
82 // Fields which are zero initialized in the program and have assignments being eliminated. These
83 // fields should have the POV bit set and therefore need to be tracked.
84 std::set<cstring> zeroInitFields;
85 // Fields that need explicit MAU initialization
86 std::set<PHV::FieldRange> mauInitFields;
87
88 protected:
89 profile_t init_apply(const IR::Node *root) override {
91 PhvInfo::resetDarkSpillARA();
92 return PassManager::init_apply(root);
93 }
94
95 void end_apply() override { BFNContext::get().clearBackendOptions(); }
96
97 public:
98 explicit Backend(const BFN_Options &options, int pipe_id);
99
100 BFN_Options &get_options() { return options; }
101
102 const PhvInfo &get_phv() const { return phv; }
103 const ClotInfo &get_clot() const { return clot; }
104 const FieldDefUse &get_defuse() const { return defuse; }
105 const MauPower::FinalizeMauPredDepsPower *get_power_and_mpr() const { return power_and_mpr; }
106 const NextTable *get_nxt_tbl() const { return &nextTblProp; }
107 const TableSummary &get_tbl_summary() const { return table_summary; }
108 const LiveRangeReport *get_live_range_report() const { return liveRangeReport; }
109 const Util::JsonObject &get_prim_json() const { return primNode; }
110 const Util::JsonObject &get_json_graph() const { return jsonGraph; }
111 const LogRepackedHeaders *get_flexible_logging() const {
112 return flexibleLogging->get_flexible_logging();
113 }
114 const CollectPhvLoggingInfo *get_phv_logging() const { return phvLoggingInfo; }
115 const PhvLogging::CollectDefUseInfo *get_phv_logging_defuse_info() const {
116 BUG_CHECK(phvLoggingDefUseInfo, "DefUse info for PHV logging was not initialized");
117 return phvLoggingDefUseInfo;
118 }
119 const ordered_map<cstring, ordered_set<int>> &get_table_alloc() const {
120 return table_summary.getTableAlloc();
121 }
122 const ParserHeaderSequences &get_parser_hdr_seqs() const { return parserHeaderSeqs; }
123};
124
125} // namespace BFN
126
127#endif /* BF_P4C_BACKEND_H_ */
Definition tofino/bf-p4c/backend.h:46
Definition bf-p4c-options.h:28
static BFNContext & get()
Definition bf-p4c-options.cpp:777
void setBackendOptions(BFN_Options *options)
Record options created in the Backend.
Definition bf-p4c-options.cpp:783
void clearBackendOptions()
Clear the backend options.
Definition bf-p4c-options.cpp:789
Definition clot_info.h:41
Definition next_table.h:45
Definition live_range_report.h:29
Definition bridged_packing.h:750
Definition bridged_packing.h:719
Definition mau_backtracker.h:29
Definition finalize_mau_pred_deps_power.h:47
Definition next_table.h:26
Definition node.h:94
Definition ir/pass_manager.h:40
Definition json.h:164
Definition visitor.h:78
Definition ordered_map.h:32
Identify parsed header sequences.
Definition parser_header_sequences.h:42
Definition phv_fields.h:1095
Definition phv_logging.h:157
Definition phv_parde_mau_use.h:154
Definition mau_alloc.h:34
Definition table_summary.h:158
Definition mau/table_mutex.h:110
Top level PassManager.
Definition decaf.h:749
Definition field_defuse.h:77
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Definition phv_logging.h:52
Definition table_dependency_graph.h:52