P4C
The P4 Compiler
Loading...
Searching...
No Matches
phv_parde_mau_use.h
1
19#ifndef BF_P4C_PHV_PHV_PARDE_MAU_USE_H_
20#define BF_P4C_PHV_PHV_PARDE_MAU_USE_H_
21
22#include "bf-p4c/common/header_stack.h"
23#include "bf-p4c/ir/bitrange.h"
24#include "bf-p4c/ir/gress.h"
25#include "bf-p4c/ir/thread_visitor.h"
26#include "bf-p4c/ir/tofino_write_context.h"
27#include "bf-p4c/phv/phv.h"
28#include "ir/ir.h"
29
30using namespace P4;
31
32namespace PHV {
33class Field;
34} // namespace PHV
35
36class PhvInfo;
37
41
44 FieldIdToRangeMap written_i;
45
48 FieldIdToRangeMap used_alu_i;
49
52 const PHV::Field *,
55 ixbar_read_i;
56
58 ordered_set<const PHV::Field *> learning_reads_i;
59
61 bitvec extracted_i[GRESS_T_COUNT];
62
64 bitvec extracted_from_pkt_i[GRESS_T_COUNT];
65
67 bitvec extracted_from_const_i[GRESS_T_COUNT];
68
70 enum { PARDE = 0, MAU = 1 };
71
72 public:
78
80 bitvec deparser_i[GRESS_T_COUNT];
81 /* | ^- gress */
82 /* == use in deparser */
83
84 explicit Phv_Parde_Mau_Use(const PhvInfo &p) : phv(p) {}
85
88 bool is_referenced(const PHV::Field *f) const;
89
91 bool is_deparsed(const PHV::Field *f) const;
92
94 bool is_used_mau(const PHV::Field *f) const;
95 bool is_used_mau(const PHV::Field *f, le_bitrange range) const;
96
98 bool is_written_mau(const PHV::Field *f) const;
99
101 bool is_used_alu(const PHV::Field *f) const;
102
104 bool is_used_parde(const PHV::Field *f) const;
105
107 bool is_extracted(const PHV::Field *f, std::optional<gress_t> gress = std::nullopt) const;
108
110 bool is_extracted_from_pkt(const PHV::Field *f,
111 std::optional<gress_t> gress = std::nullopt) const;
112
115 std::optional<gress_t> gress = std::nullopt) const;
116
122 bool is_allocation_required(const PHV::Field *f) const;
123
126 bool is_learning(const PHV::Field *f) const { return learning_reads_i.count(f); };
127
132 const PHV::Field *f, le_bitrange range) const;
133
134 protected:
135 const PhvInfo &phv;
136 gress_t thread = INGRESS;
137 bool in_mau = false;
138 bool in_dep = false;
139
140 protected:
141 profile_t init_apply(const IR::Node *) override;
142 bool preorder(const IR::BFN::Parser *) override;
143 bool preorder(const IR::BFN::Extract *) override;
144 bool preorder(const IR::BFN::ParserChecksumWritePrimitive *) override;
145 bool preorder(const IR::BFN::Deparser *) override;
146 bool preorder(const IR::BFN::Digest *) override;
147 bool preorder(const IR::MAU::TableSeq *) override;
148 bool preorder(const IR::MAU::TableKey *) override;
149 bool preorder(const IR::Expression *) override;
150};
151
154class PhvUse : public Phv_Parde_Mau_Use {
155 public:
156 explicit PhvUse(const PhvInfo &p) : Phv_Parde_Mau_Use(p) {}
157
158 private:
159 bool preorder(const IR::BFN::Deparser *d) override;
160 bool preorder(const IR::BFN::DeparserParameter *param) override;
161 void postorder(const IR::BFN::DeparserParameter *param) override;
162 bool preorder(const IR::BFN::Digest *digest) override;
163 void postorder(const IR::BFN::Digest *digest) override;
164};
165
166#endif /* BF_P4C_PHV_PHV_PARDE_MAU_USE_H_ */
Definition node.h:95
Definition visitor.h:400
Definition bitvec.h:120
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition phv_fields.h:154
Definition phv_parde_mau_use.h:38
bool is_learning(const PHV::Field *f) const
Definition phv_parde_mau_use.h:126
bitvec deparser_i[GRESS_T_COUNT]
Fields used in the deparser.
Definition phv_parde_mau_use.h:80
bool is_extracted_from_constant(const PHV::Field *f, std::optional< gress_t > gress=std::nullopt) const
Definition phv_parde_mau_use.cpp:250
bool is_referenced(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:179
profile_t init_apply(const IR::Node *) override
Definition phv_parde_mau_use.cpp:34
bool is_used_alu(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:211
ordered_map< int, ordered_map< unsigned, ordered_set< le_bitrange > > > use_i
Definition phv_parde_mau_use.h:77
bool is_used_mau(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:194
bool is_used_parde(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:222
bool is_allocation_required(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:259
bool is_extracted(const PHV::Field *f, std::optional< gress_t > gress=std::nullopt) const
Definition phv_parde_mau_use.cpp:233
ordered_set< std::pair< const IR::MAU::Table *, const IR::MAU::TableKey * > > ixbar_read(const PHV::Field *f, le_bitrange range) const
Definition phv_parde_mau_use.cpp:264
bool is_extracted_from_pkt(const PHV::Field *f, std::optional< gress_t > gress=std::nullopt) const
Definition phv_parde_mau_use.cpp:241
bool is_written_mau(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:216
bool is_deparsed(const PHV::Field *f) const
Definition phv_parde_mau_use.cpp:188
Definition phv_fields.h:1095
Definition phv_parde_mau_use.h:154
Definition tofino_write_context.h:24
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32