P4C
The P4 Compiler
Loading...
Searching...
No Matches
payload_gateway.h
1
19#ifndef BF_P4C_MAU_PAYLOAD_GATEWAY_H_
20#define BF_P4C_MAU_PAYLOAD_GATEWAY_H_
21
22#include "backends/tofino/bf-p4c/mau/mau_visitor.h"
23#include "backends/tofino/bf-p4c/phv/phv.h"
24#include "ir/ir.h"
25
26using namespace P4;
27
28class PhvInfo;
29class LayoutChoices;
30
32 public:
33 static constexpr int GATEWAY_ROWS_FOR_ENTRIES = 4;
34 using PayloadArguments = std::vector<const IR::Constant *>;
35
36 private:
37 struct ContainerByte {
38 PHV::Container container;
39 int bit_start;
40
41 bool operator<(const ContainerByte &cb) const {
42 if (container != cb.container) return container < cb.container;
43 return bit_start < cb.bit_start;
44 }
45
46 bool operator==(const ContainerByte &cb) const {
47 return !((*this) < cb) && !(cb < (*this));
48 }
49
50 bool operator!=(const ContainerByte &cb) const { return !((*this) == cb); }
51
52 ContainerByte(PHV::Container c, int bs) : container(c), bit_start(bs) {}
53 };
54
55 const PhvInfo &phv;
56 ordered_set<cstring> candidates;
57
58 static PayloadArguments convert_entry_to_payload_args(const IR::MAU::Table *tbl,
59 const IR::Entry *entry,
60 cstring *act_name);
61 static bitvec determine_instr_address_payload(const IR::MAU::Action *act,
62 const TableResourceAlloc *alloc);
63 static bitvec determine_immediate_payload(const IR::MAU::Action *act, PayloadArguments &entry,
64 const TableResourceAlloc *alloc);
65 static bitvec determine_indirect_addr_payload(const IR::MAU::Action *act,
66 PayloadArguments &payload_args,
67 const IR::MAU::AttachedMemory *at);
68 static bitvec determine_indirect_pfe_payload(const IR::MAU::Action *act,
69 const IR::MAU::AttachedMemory *at);
70 static bitvec determine_meter_type_payload(const IR::MAU::Action *act,
71 const IR::MAU::AttachedMemory *at);
72
73 static bitvec determine_match_group_payload(const IR::MAU::Table *tbl,
74 const TableResourceAlloc *alloc,
75 const IR::MAU::Action *act,
76 std::vector<const IR::Constant *> arguments,
77 int entry_idx);
78
79 public:
80 explicit FindPayloadCandidates(const PhvInfo &p) : phv(p) {}
81 void add_option(const IR::MAU::Table *, LayoutChoices &lc);
82 void clear() { candidates.clear(); }
83 IR::MAU::Table *convert_to_gateway(const IR::MAU::Table *);
84 static bitvec determine_payload(const IR::MAU::Table *tbl, const TableResourceAlloc *alloc,
85 const IR::MAU::Table::Layout *layout);
86};
87
88#endif /* BF_P4C_MAU_PAYLOAD_GATEWAY_H_ */
Definition payload_gateway.h:31
static bitvec determine_payload(const IR::MAU::Table *tbl, const TableResourceAlloc *alloc, const IR::MAU::Table::Layout *layout)
Definition mau/payload_gateway.cpp:571
void add_option(const IR::MAU::Table *, LayoutChoices &lc)
Definition mau/payload_gateway.cpp:173
IR::MAU::Table * convert_to_gateway(const IR::MAU::Table *)
Definition mau/payload_gateway.cpp:206
Definition table_layout.h:83
Definition bitvec.h:120
Definition cstring.h:85
Definition ordered_set.h:32
Definition phv.h:176
Definition phv_fields.h:1095
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition resource.h:37