P4C
The P4 Compiler
Loading...
Searching...
No Matches
phv_analysis.h
1
26#ifndef BF_P4C_PHV_PHV_ANALYSIS_H_
27#define BF_P4C_PHV_PHV_ANALYSIS_H_
28
29#include "backends/tofino/bf-p4c/bf-p4c-options.h"
30#include "backends/tofino/bf-p4c/common/field_defuse.h"
31#include "backends/tofino/bf-p4c/common/map_tables_to_actions.h"
32#include "backends/tofino/bf-p4c/logging/pass_manager.h"
33#include "backends/tofino/bf-p4c/logging/phv_logging.h"
34#include "backends/tofino/bf-p4c/mau/action_mutex.h"
35#include "backends/tofino/bf-p4c/mau/table_dependency_graph.h"
36#include "backends/tofino/bf-p4c/mau/table_flow_graph.h"
37#include "backends/tofino/bf-p4c/mau/table_mutex.h"
38#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
39#include "backends/tofino/bf-p4c/parde/decaf.h"
40#include "backends/tofino/bf-p4c/phv/action_phv_constraints.h"
41#include "backends/tofino/bf-p4c/phv/action_source_tracker.h"
42#include "backends/tofino/bf-p4c/phv/allocate_phv.h"
43#include "backends/tofino/bf-p4c/phv/analysis/critical_path_clusters.h"
44#include "backends/tofino/bf-p4c/phv/analysis/dark_live_range.h"
45#include "backends/tofino/bf-p4c/phv/analysis/dominator_tree.h"
46#include "backends/tofino/bf-p4c/phv/analysis/live_range_shrinking.h"
47#include "backends/tofino/bf-p4c/phv/analysis/meta_live_range.h"
48#include "backends/tofino/bf-p4c/phv/analysis/non_mocha_dark_fields.h"
49#include "backends/tofino/bf-p4c/phv/analysis/pack_conflicts.h"
50#include "backends/tofino/bf-p4c/phv/analysis/parser_critical_path.h"
51#include "backends/tofino/bf-p4c/phv/collect_strided_headers.h"
52#include "backends/tofino/bf-p4c/phv/collect_table_keys.h"
53#include "backends/tofino/bf-p4c/phv/fieldslice_live_range.h"
54#include "backends/tofino/bf-p4c/phv/make_clusters.h"
55#include "backends/tofino/bf-p4c/phv/mau_backtracker.h"
56#include "backends/tofino/bf-p4c/phv/phv_parde_mau_use.h"
57#include "backends/tofino/bf-p4c/phv/pragma/phv_pragmas.h"
58#include "backends/tofino/bf-p4c/phv/utils/tables_to_ids.h"
59#include "backends/tofino/bf-p4c/phv/v2/phv_kit.h"
60#include "backends/tofino/bf-p4c/phv/v2/table_replay_friendly_constraints.h"
61
65 private:
66 PhvInfo &phv_i;
67 PhvUse &uses_i;
68 const ClotInfo &clot_i;
69 FieldDefUse &defuse_i;
70 DependencyGraph &deps_i;
71 const BFN_Options &options_i;
73 MauBacktracker &table_alloc;
74 // alt-phv-alloc ONLY
75 // collect information about which field is allocated to what containers at the end of
76 // phv analysis
77 PHV::v2::CollectPHVAllocationResult phv_allocation_result;
78 // alt-phv-alloc ONLY
79 // Based on the feedback from table summary after table replay failed, it adds phv container
80 // size constraints so that table replay can progress.
81 PHV::v2::TableReplayFriendlyPhvConstraints table_replay_phv_constr;
83 PHV::Pragmas pragmas;
85 MapFieldToParserStates field_to_parser_states;
87 CalcParserCriticalPath parser_critical_path;
89 CalcCriticalPathClusters critical_path_clusters;
91 TablesMutuallyExclusive table_mutex;
93 ActionMutuallyExclusive action_mutex;
95 PackConflicts pack_conflicts;
97 ActionPhvConstraints action_constraints;
101 BuildDominatorTree domTree;
103 MapTablesToActions tableActionsMap;
105 MetadataLiveRange meta_live_range;
106 // Gets fields that are not mocha and/or dark compatible.
107 NonMochaDarkFields non_mocha_dark;
110 DarkOverlay dark_live_range;
112 LiveRangeShrinking meta_init;
114 Clustering clustering;
116 MapTablesToIDs table_ids;
118 CollectStridedHeaders strided_headers;
119 CollectParserInfo parser_info;
120 // table key properties.
121 PHV::CollectTableKeys tb_keys;
122 // physical live ranges of field slices.
123 PHV::FieldSliceLiveRangeDB physical_liverange_db;
124 // sources of any field slices classified by actions.
125 PHV::ActionSourceTracker source_tracker;
126 // allocation settings.
127 PHV::AllocSetting settings;
128 // Collect field packing that table/ixbar would benefit from.
129 TableFieldPackOptimization tablePackOpt;
130
131 // a collection class of above passe.
132 PHV::AllocUtils utils;
133
134 // Similar as AllocUtils but only used by v2::allocator.
135 PHV::v2::PhvKit kit;
136
137 AllocatePHV allocate_phv;
138 std::list<const PHV::SuperCluster *> unallocated;
139
140 public:
141 PHV_AnalysisPass(const BFN_Options &options, PhvInfo &phv, PhvUse &uses, const ClotInfo &clot,
142 FieldDefUse &defuse, DependencyGraph &deps, const DeparserCopyOpt &decaf,
143 MauBacktracker &alloc, CollectPhvLoggingInfo *phvLoggingInfo,
144 std::set<PHV::FieldRange> &mauInitFields, const TableSummary &table_summary);
145
146 Visitor *make_incremental_alloc_pass(const ordered_set<PHV::Field *> &temp_vars);
147
148 void set_trivial_alloc(bool enable) { settings.trivial_alloc = enable; }
149 void set_no_code_change(bool enable) { settings.no_code_change = enable; }
150 void set_physical_liverange_overlay(bool enable) {
151 settings.physical_liverange_overlay = enable;
152 }
153 void set_physical_stage_trivial(bool enable) { settings.physical_stage_trivial = enable; }
154 const bool &get_limit_tmp_creation() { return settings.limit_tmp_creation; }
155 const PHV::Pragmas &get_pragmas() { return pragmas; }
156 void end_apply() override;
157};
158
159#endif /* BF_P4C_PHV_PHV_ANALYSIS_H_ */
Definition action_mutex.h:29
Definition action_phv_constraints.h:107
Definition allocate_phv.h:813
Definition bf-p4c-options.h:28
Definition dominator_tree.h:32
Definition critical_path_clusters.h:38
Definition parser_critical_path.h:131
Definition clot_info.h:41
Builds "clusters" of field slices that must be placed in the same group.
Definition make_clusters.h:67
Definition dark_live_range.h:389
Definition live_range_shrinking.h:183
Definition backends/tofino/bf-p4c/logging/pass_manager.h:36
Definition map_tables_to_actions.h:29
Definition tables_to_ids.h:22
Definition mau_backtracker.h:29
Definition meta_live_range.h:41
Definition non_mocha_dark_fields.h:29
Definition visitor.h:75
Definition ordered_map.h:32
Definition ordered_set.h:32
ActionSourceTracker collects all source-to-destination for all field slices.
Definition action_source_tracker.h:49
Definition collect_table_keys.h:27
Definition fieldslice_live_range.h:152
Definition phv_pragmas.h:46
Definition table_replay_friendly_constraints.h:99
Definition table_replay_friendly_constraints.h:45
Definition phv_analysis.h:64
Definition pack_conflicts.h:36
Definition phv_fields.h:1095
Definition phv_parde_mau_use.h:154
Definition table_phv_constraints.h:97
Definition table_summary.h:158
Definition mau/table_mutex.h:110
Top level PassManager.
Definition decaf.h:749
Definition field_defuse.h:77
bool trivial_alloc
Definition alloc_setting.h:30
Definition alloc_setting.h:25
Definition phv_logging.h:52
Collects header stacks that require strided allocation (in a parser loop).
Definition collect_strided_headers.h:28
Definition table_dependency_graph.h:52
Map field to the parser states in which they are extracted or assigned from checksums.
Definition phv_fields.h:1755
Definition allocate_phv.h:55
Definition phv_kit.h:46