P4C
The P4 Compiler
Loading...
Searching...
No Matches
resource.h
1
19#ifndef BF_P4C_MAU_RESOURCE_H_
20#define BF_P4C_MAU_RESOURCE_H_
21
22/* clang-format off */
23
24#include <map>
25
26#include "backends/tofino/bf-p4c/lib/autoclone.h"
27#include "backends/tofino/bf-p4c/mau/action_data_bus.h"
28#include "backends/tofino/bf-p4c/mau/instruction_memory.h"
29#include "backends/tofino/bf-p4c/mau/memories.h"
30#include "backends/tofino/bf-p4c/mau/table_format.h"
31#include "backends/tofino/bf-p4c/mau/tofino/input_xbar.h"
32#include "ir/ir.h"
33#include "lib/safe_vector.h"
34
35using namespace P4;
36
38 // TODO: Currently we only have a std::map for the UniqueId objects for Memories. This would
39 // make sense to eventually move to IXBar::Use, and even potentially
40 // ActionFormat::Use/ActionDataBus::Use for the different types of allocations
41 autoclone_ptr<IXBar::Use> match_ixbar, gateway_ixbar, proxy_hash_ixbar, action_ixbar,
42 selector_ixbar, salu_ixbar, meter_ixbar;
43 TableFormat::Use table_format;
44 std::map<UniqueId, Memories::Use> memuse;
45 ActionData::Format::Use action_format;
46 MeterALU::Format::Use meter_format;
47 autoclone_ptr<ActionDataBus::Use> action_data_xbar, meter_xbar;
48 InstructionMemory::Use instr_mem;
49 LayoutOption layout_option;
50
51 // only relevant to tofino 1/2
53
54 TableResourceAlloc *clone() const { return new TableResourceAlloc(*this); }
55 TableResourceAlloc *rename(const IR::MAU::Table *tbl, int stage_table = -1,
56 int logical_table = -1);
57
58 void clear_ixbar() {
59 match_ixbar.reset();
60 gateway_ixbar.reset();
61 proxy_hash_ixbar.reset();
62 selector_ixbar.reset();
63 salu_ixbar.reset();
64 meter_ixbar.reset();
65 hash_dists.clear();
66 }
67 void clear() {
68 clear_ixbar();
69 table_format.clear();
70 memuse.clear();
71 action_format.clear();
72 action_data_xbar.reset();
73 instr_mem.clear();
74 meter_format.clear();
75 meter_xbar.reset();
76 }
77 void toJSON(P4::JSONGenerator &json) const { json << "null"; }
78 static TableResourceAlloc *fromJSON(P4::JSONLoader &) { return nullptr; }
79
80 void merge_instr(const TableResourceAlloc *);
81 bool has_tind() const;
83 int rng_unit() const;
84 int findBytesOnIxbar(const PHV::FieldSlice &) const;
85
86 ::IXBar::Use *find_ixbar(IXBar::Use::type_t type) const;
87};
88
89std::ostream &operator<<(std::ostream &, const TableResourceAlloc &);
90
91/* clang-format on */
92
93#endif /* BF_P4C_MAU_RESOURCE_H_ */
Definition table_layout.h:34
Definition json_generator.h:36
Definition json_loader.h:38
Definition safe_vector.h:27
Definition phv_fields.h:898
Definition autoclone.h:31
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition action_format.h:979
Definition input_xbar.h:191
Definition instruction_memory.h:111
Definition attached_output.h:42
Definition table_format.h:108
Definition resource.h:37
safe_vector< int > hash_dist_immed_units() const
Definition resource.cpp:76
int rng_unit() const
Definition resource.cpp:96
TableResourceAlloc * rename(const IR::MAU::Table *tbl, int stage_table=-1, int logical_table=-1)
Definition resource.cpp:21
bool has_tind() const
Definition resource.cpp:57