P4C
The P4 Compiler
Loading...
Searching...
No Matches
asm_hash_output.h
1
19#ifndef BF_P4C_MAU_ASM_HASH_OUTPUT_H_
20#define BF_P4C_MAU_ASM_HASH_OUTPUT_H_
21
22#include <iterator>
23#include <map>
24#include <memory>
25#include <regex>
26#include <string>
27#include <vector>
28
29#include "action_data_bus.h"
30#include "backends/tofino/bf-p4c/common/alias.h"
31#include "backends/tofino/bf-p4c/common/ir_utils.h"
32#include "backends/tofino/bf-p4c/common/slice.h"
33#include "backends/tofino/bf-p4c/ir/tofino_write_context.h"
34#include "backends/tofino/bf-p4c/lib/error_type.h"
35#include "backends/tofino/bf-p4c/mau/asm_format_hash.h"
36#include "backends/tofino/bf-p4c/mau/asm_output.h"
37#include "backends/tofino/bf-p4c/mau/gateway.h"
38#include "backends/tofino/bf-p4c/mau/jbay_next_table.h"
39#include "backends/tofino/bf-p4c/mau/payload_gateway.h"
40#include "backends/tofino/bf-p4c/mau/resource.h"
41#include "backends/tofino/bf-p4c/mau/table_format.h"
42#include "backends/tofino/bf-p4c/parde/asm_output.h"
43#include "backends/tofino/bf-p4c/parde/phase0.h"
44#include "backends/tofino/bf-p4c/phv/asm_output.h"
45#include "boost/range/adaptor/reversed.hpp"
46#include "lib/algorithm.h"
47#include "lib/bitops.h"
48#include "lib/bitrange.h"
49#include "lib/hex.h"
50#include "lib/indent.h"
51#include "lib/stringref.h"
52
53using namespace P4;
54
55void emit_ixbar_gather_map(const PhvInfo &phv, std::multimap<int, Slice> &match_data_map,
56 std::map<le_bitrange, const IR::Constant *> &constant_map,
57 const safe_vector<Slice> &match_data,
58 const safe_vector<const IR::Expression *> &field_list_order,
59 const LTBitMatrix &sym_keys, int &total_size);
60
62 const PhvInfo &phv;
63 std::ostream &out;
64 indent_t indent;
65 int bit;
66 const safe_vector<Slice> &match_data;
67
68 bool preorder(const IR::Concat *c) override;
69 bool preorder(const IR::BFN::SignExtend *c) override;
70 bool preorder(const IR::Constant *) override;
71 bool preorder(const IR::Expression *e) override;
72 bool preorder(const IR::MAU::HashGenExpression *hge) override;
73
74 public:
75 EmitHashExpression(const PhvInfo &phv, std::ostream &out, indent_t indent, int bit,
76 const safe_vector<Slice> &match_data)
77 : phv(phv), out(out), indent(indent), bit(bit), match_data(match_data) {}
78};
79
80void emit_ixbar_match_func(std::ostream &out, indent_t indent, safe_vector<Slice> &match_data,
81 Slice *ghost, le_bitrange hash_bits);
82void emit_ixbar_hash_atcam(std::ostream &out, indent_t indent, safe_vector<Slice> &ghost,
83 const ::IXBar::Use *use, int hash_group);
84void ixbar_hash_exact_bitrange(Slice ghost_slice, int min_way_size, le_bitrange non_rotated_slice,
85 le_bitrange comp_slice, int initial_lo_bit,
86 safe_vector<std::pair<le_bitrange, Slice>> &ghost_positions);
87void ixbar_hash_exact_info(int &min_way_size, int &min_way_slice, const ::IXBar::Use *use,
88 int hash_group, std::map<int, bitvec> &slice_to_select_bits);
89void emit_ixbar_hash_exact(std::ostream &out, indent_t indent, safe_vector<Slice> &match_data,
90 safe_vector<Slice> &ghost, const ::IXBar::Use *use, int hash_group,
91 int &ident_bits_prev_alloc);
92void emit_ixbar_gather_map(const PhvInfo &phv, std::multimap<int, Slice> &match_data_map,
93 std::map<le_bitrange, const IR::Constant *> &constant_map,
94 const safe_vector<Slice> &match_data,
95 const safe_vector<const IR::Expression *> &field_list_order,
96 const LTBitMatrix &sym_keys, int &total_size);
97void emit_ixbar_gather_bytes(const PhvInfo &phv, const safe_vector<::IXBar::Use::Byte> &use,
98 std::map<int, std::map<int, Slice>> &sort,
99 std::map<int, std::map<int, Slice>> &midbytes,
100 const IR::MAU::Table *tbl, bool ternary, bool atcam = false);
101void emit_ixbar_hash_table(int hash_table, safe_vector<Slice> &match_data,
102 safe_vector<Slice> &ghost, const TableMatch *fmt,
103 std::map<int, std::map<int, Slice>> &sort);
104
105#endif /* BF_P4C_MAU_ASM_HASH_OUTPUT_H_ */
Definition asm_hash_output.h:61
Definition visitor.h:400
Definition ltbitmatrix.h:25
Definition indent.h:26
Definition safe_vector.h:27
Definition phv_fields.h:1095
Definition common/asm_output.h:47
Definition mau/asm_output.h:223
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24