P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino/bf-p4c/backend.h
1
18
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 "ir/ir.h"
39
40class FieldDefUse;
42
43namespace BFN {
44
45class Backend : public PassManager {
46 BFN_Options options;
47 PhvInfo phv;
48 PhvUse uses;
49 ClotInfo clot;
50 DependencyGraph deps;
51 FieldDefUse defuse;
53 DeparserCopyOpt decaf;
54 // Since both phv allocation or table allocation result may change compilation_state,
55 // compilation_state is moved from table_summary to backend
56 State::state_t compilation_state = State::INITIAL;
58 TableSummary table_summary;
60 MauBacktracker mau_backtracker;
61 TableAllocPass table_alloc;
62 // Primitives Json Node, is populated before instruction adjustment and
63 // passed to AsmOutput to output primitive json file
64 Util::JsonObject primNode;
65 // Dependency Flow Graph Json, is a collection of graphs populated when
66 // passed as a parameter to FindDependencyGraph pass. By default graphs are
67 // generated once before and once after table placement.
68 Util::JsonObject jsonGraph;
69
70 LogFlexiblePacking *flexibleLogging;
71 CollectPhvLoggingInfo *phvLoggingInfo;
72 PhvLogging::CollectDefUseInfo *phvLoggingDefUseInfo;
73 DynamicNextTable nextTblProp;
75 LiveRangeReport *liveRangeReport;
76
77 // Identify the header sequences extracted in the parser
78 ParserHeaderSequences parserHeaderSeqs;
79 // Disable long branches
80 bool longBranchDisabled;
81 // Fields which are zero initialized in the program and have assignments being eliminated. These
82 // fields should have the POV bit set and therefore need to be tracked.
83 std::set<cstring> zeroInitFields;
84 // Fields that need explicit MAU initialization
85 std::set<PHV::FieldRange> mauInitFields;
86
87 protected:
88 profile_t init_apply(const IR::Node *root) override {
90 PhvInfo::resetDarkSpillARA();
91 return PassManager::init_apply(root);
92 }
93
94 void end_apply() override { BFNContext::get().clearBackendOptions(); }
95
96 public:
97 explicit Backend(const BFN_Options &options, int pipe_id);
98
99 BFN_Options &get_options() { return options; }
100
101 const PhvInfo &get_phv() const { return phv; }
102 const ClotInfo &get_clot() const { return clot; }
103 const FieldDefUse &get_defuse() const { return defuse; }
104 const MauPower::FinalizeMauPredDepsPower *get_power_and_mpr() const { return power_and_mpr; }
105 const NextTable *get_nxt_tbl() const { return &nextTblProp; }
106 const TableSummary &get_tbl_summary() const { return table_summary; }
107 const LiveRangeReport *get_live_range_report() const { return liveRangeReport; }
108 const Util::JsonObject &get_prim_json() const { return primNode; }
109 const Util::JsonObject &get_json_graph() const { return jsonGraph; }
110 const LogRepackedHeaders *get_flexible_logging() const {
111 return flexibleLogging->get_flexible_logging();
112 }
113 const CollectPhvLoggingInfo *get_phv_logging() const { return phvLoggingInfo; }
114 const PhvLogging::CollectDefUseInfo *get_phv_logging_defuse_info() const {
115 BUG_CHECK(phvLoggingDefUseInfo, "DefUse info for PHV logging was not initialized");
116 return phvLoggingDefUseInfo;
117 }
118 const ordered_map<cstring, ordered_set<int>> &get_table_alloc() const {
119 return table_summary.getTableAlloc();
120 }
121 const ParserHeaderSequences &get_parser_hdr_seqs() const { return parserHeaderSeqs; }
122};
123
124} // namespace BFN
125
126#endif /* BF_P4C_BACKEND_H_ */
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:751
Definition bridged_packing.h:720
Definition mau_backtracker.h:29
Definition finalize_mau_pred_deps_power.h:47
Definition next_table.h:26
Definition node.h:94
Definition json.h:165
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