P4C
The P4 Compiler
Loading...
Searching...
No Matches
action_source_tracker.h
1
19#ifndef BF_P4C_PHV_ACTION_SOURCE_TRACKER_H_
20#define BF_P4C_PHV_ACTION_SOURCE_TRACKER_H_
21
22#include <optional>
23
24#include "backends/tofino/bf-p4c/mau/action_analysis.h"
25#include "backends/tofino/bf-p4c/phv/phv_fields.h"
26#include "ir/ir.h"
27
28namespace PHV {
29
31struct SourceOp {
32 enum class OpType { move, bitwise, whole_container };
33 OpType t = OpType::move;
34 bool ad_or_const = false;
35 std::optional<PHV::FieldSlice> phv_src = std::nullopt;
36
40 SourceOp slice(int start, int len) const;
41};
42
43std::ostream &operator<<(std::ostream &out, const SourceOp &src);
44
47
50 const PhvInfo &phv;
51 const ReductionOrInfo &red_info;
52
63
64 private:
65 void clear() { sources.clear(); };
66
68 void add_sources(const IR::MAU::Action *act,
69 const ActionAnalysis::FieldActionsMap &instructions);
70
72 profile_t init_apply(const IR::Node *root) override {
73 clear();
74 return Inspector::init_apply(root);
75 }
76
78 bool preorder(const IR::MAU::Action *act) override;
79
81 void end_apply() override;
82
83 public:
84 explicit ActionSourceTracker(const PhvInfo &phv, const ReductionOrInfo &ri)
85 : phv(phv), red_info(ri) {}
86
90
91 friend std::ostream &operator<<(std::ostream &out, const ActionSourceTracker &tracker);
92};
93
94std::ostream &operator<<(std::ostream &out, const ActionClassifiedSources &sources);
95std::ostream &operator<<(std::ostream &out, const ActionSourceTracker &tracker);
96
97} // namespace PHV
98
99#endif /* BF_P4C_PHV_ACTION_SOURCE_TRACKER_H_ */
Definition node.h:94
Definition visitor.h:400
Definition visitor.h:78
Definition ordered_map.h:32
ActionSourceTracker collects all source-to-destination for all field slices.
Definition action_source_tracker.h:49
ActionClassifiedSources get_sources(const PHV::FieldSlice &fs) const
Definition phv/action_source_tracker.cpp:137
Definition phv_fields.h:898
Definition phv_fields.h:1095
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
SourceOp represents a source operand.
Definition action_source_tracker.h:31
SourceOp slice(int start, int len) const
Definition phv/action_source_tracker.cpp:45
Definition reduction_or.h:47