P4C
The P4 Compiler
Loading...
Searching...
No Matches
phv/asm_output.h
1
19#ifndef BF_P4C_PHV_ASM_OUTPUT_H_
20#define BF_P4C_PHV_ASM_OUTPUT_H_
21
22#include <iosfwd>
23
24#include "bf-p4c/common/field_defuse.h"
25#include "bf-p4c/mau/table_summary.h"
26#include "bf-p4c/phv/phv.h"
27#include "bf-p4c/phv/phv_fields.h"
28#include "bf-p4c/phv/utils/live_range_report.h"
29#include "lib/ordered_set.h"
30
32 const PhvInfo &phv;
33 const FieldDefUse &defuse;
34 const TableSummary &tbl_summary;
35 const LiveRangeReport *live_range_report;
36 bool have_ghost;
37
38 struct FieldUse {
39 cstring name;
40 gress_t gress;
41 int live_start;
42 int live_end;
43 bool parsed;
44 bool deparsed;
45 ordered_set<cstring> mutex_fields;
46 FieldUse(cstring n, gress_t g, int s, int e, bool p, bool d, ordered_set<cstring> m)
47 : name(n),
48 gress(g),
49 live_start(s),
50 live_end(e),
51 parsed(p),
52 deparsed(d),
53 mutex_fields(m) {}
54 std::string get_live_stage(int stage, int maxStages) {
55 if (stage == -1) return "parser";
56 if (stage >= maxStages) return "deparser";
57 return std::to_string(stage);
58 }
59 std::string get_live_start(int maxStages) {
60 return (parsed ? "parser" : get_live_stage(live_start, maxStages));
61 }
62 std::string get_live_end(int maxStages) {
63 return (deparsed ? "deparser" : get_live_stage(live_end, maxStages));
64 }
65 };
66
69 typedef std::map<PHV::Container, FieldUses> LiveRangePerContainer[2];
70 void getLiveRanges(LiveRangePerContainer &c) const;
71
72 void emit_gress(std::ostream &out, gress_t gress) const;
73 friend std::ostream &operator<<(std::ostream &, const PhvAsmOutput &);
74
75 std::map<int, PHV::FieldUse> processUseDefSet(const FieldDefUse::LocPairSet &,
76 PHV::FieldUse) const;
77
78 public:
79 explicit PhvAsmOutput(const PhvInfo &p, const FieldDefUse &defuse,
80 const TableSummary &tbl_summary, const LiveRangeReport *live_range_report,
81 bool have_ghost = false);
82};
83
84#endif /* BF_P4C_PHV_ASM_OUTPUT_H_ */
Definition live_range_report.h:29
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition phv.h:248
Definition phv/asm_output.h:31
PhvAsmOutput(const PhvInfo &p, const FieldDefUse &defuse, const TableSummary &tbl_summary, const LiveRangeReport *live_range_report, bool have_ghost=false)
Definition phv/asm_output.cpp:32
Definition phv_fields.h:1095
Definition table_summary.h:158
Definition field_defuse.h:77