P4C
The P4 Compiler
Loading...
Searching...
No Matches
live_range_report.h
1
19#ifndef BF_P4C_PHV_UTILS_LIVE_RANGE_REPORT_H_
20#define BF_P4C_PHV_UTILS_LIVE_RANGE_REPORT_H_
21
22#include "bf-p4c/common/field_defuse.h"
23#include "bf-p4c/mau/table_summary.h"
24#include "bf-p4c/phv/phv.h"
25#include "bf-p4c/phv/phv_fields.h"
26#include "ir/ir.h"
27#include "lib/log.h"
28
29class LiveRangeReport : public Inspector {
30 private:
31 static constexpr unsigned READ = PHV::FieldUse::READ;
32 static constexpr unsigned WRITE = PHV::FieldUse::WRITE;
33 static constexpr unsigned LIVE = PHV::FieldUse::LIVE;
34
35 const PhvInfo &phv;
36 const TableSummary &alloc;
37 const FieldDefUse &defuse;
38
39 std::map<int, int> stageToReadBits;
40 std::map<int, int> stageToWriteBits;
41 std::map<int, int> stageToAccessBits;
42 std::map<int, int> stageToLiveBits;
43
44 int maxStages = -1;
45
47 LiveMap livemap;
48
49 std::map<const PHV::Field *, const PHV::Field *> aliases;
50
51 profile_t init_apply(const IR::Node *root) override;
52
53 std::map<int, PHV::FieldUse> processUseDefSet(const FieldDefUse::LocPairSet &defuseSet,
54 PHV::FieldUse useDef) const;
55
56 void setFieldLiveMap(const PHV::Field *f);
57
58 std::vector<std::string> createStatRow(std::string title, const std::map<int, int> &data) const;
59
60 cstring printFieldLiveness();
61 cstring printBitStats() const;
62 cstring printAliases() const;
63
64 public:
65 explicit LiveRangeReport(const PhvInfo &p, const TableSummary &t, const FieldDefUse &d)
66 : phv(p), alloc(t), defuse(d) {}
67
68 const LiveMap &get_livemap() const { return livemap; }
69 int get_max_stages() const { return maxStages; }
70};
71
72#endif /* BF_P4C_PHV_UTILS_LIVE_RANGE_REPORT_H_ */
Definition live_range_report.h:29
Definition node.h:95
Definition visitor.h:400
Definition visitor.h:78
Definition cstring.h:85
Definition ordered_map.h:32
Definition phv_fields.h:154
Definition phv.h:248
Definition phv_fields.h:1095
Definition table_summary.h:158
Definition field_defuse.h:77