P4C
The P4 Compiler
Loading...
Searching...
No Matches
attached_output.h
1
19#ifndef BF_P4C_MAU_ATTACHED_OUTPUT_H_
20#define BF_P4C_MAU_ATTACHED_OUTPUT_H_
21
22#include "bf-p4c/mau/action_format.h"
23
24class LayoutChoices;
25
26namespace MeterALU {
27
28using namespace P4;
29using OperationsPerAction = std::map<cstring, safe_vector<ActionData::ALUOperation *>>;
31using AttachedToTableMap =
33
34class Format : public MauInspector {
35 const PhvInfo &phv;
36 AttachedToTableMap attached_to_table_map;
37 OperationsPerTable operations_per_table;
38 LayoutChoices &layout_choices;
39
40 public:
41 // Per table
42 struct Use {
44 std::map<cstring, safe_vector<ActionData::ALUPosition>> alu_positions;
46 ActionData::BusInputs table_bus_inputs = {{bitvec(), bitvec(), bitvec()}};
48 ActionData::BusInputs meter_alu_bus_inputs = {{bitvec(), bitvec(), bitvec()}};
49
50 safe_vector<const ActionData::ALUPosition *> all_alu_positions() const {
52 for (auto &act : alu_positions)
53 for (auto &pos : act.second) rv.push_back(&pos);
54 return rv;
55 }
56 void clear() {
57 alu_positions.clear();
60 }
61
62 bool contains_adb_slot(ActionData::SlotType_t type, int start_byte) const;
63 };
64
65 private:
66 profile_t init_apply(const IR::Node *node) override {
67 auto rv = MauInspector::init_apply(node);
68 operations_per_table.clear();
69 attached_to_table_map.clear();
70 return rv;
71 }
72
73 void create_meter_alu(ActionData::ALUOperation &alu, ActionAnalysis::ActionParam &read,
74 le_bitrange container_bits);
75 void create_alu_ops_for_action(ActionAnalysis::ContainerActionsMap &ca_map, cstring action_name,
76 OperationsPerAction &ops_per_action);
77 bool preorder(const IR::MAU::Table *tbl) override;
78 void build_use(OperationsPerAction &ops_per_action, Use *use);
79 void end_apply() override;
80
81 public:
82 Format(const PhvInfo &p, LayoutChoices &l) : phv(p), layout_choices(l) {}
83};
84
85} // namespace MeterALU
86
87#endif /* BF_P4C_MAU_ATTACHED_OUTPUT_H_ */
Definition action_format.h:485
Definition table_layout.h:83
Definition mau_visitor.h:29
Definition attached_output.h:34
Definition node.h:95
Definition bitvec.h:120
Definition cstring.h:85
Definition ordered_map.h:32
Definition safe_vector.h:27
Definition phv_fields.h:1095
Definition attached_output.cpp:24
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition action_analysis.h:65
Definition attached_output.h:42
std::map< cstring, safe_vector< ActionData::ALUPosition > > alu_positions
Definition attached_output.h:44
ActionData::BusInputs table_bus_inputs
Definition attached_output.h:46
bool contains_adb_slot(ActionData::SlotType_t type, int start_byte) const
Definition attached_output.cpp:63
ActionData::BusInputs meter_alu_bus_inputs
Definition attached_output.h:48