19#ifndef BF_P4C_MAU_DYNHASH_H_
20#define BF_P4C_MAU_DYNHASH_H_
24#include <boost/range/irange.hpp>
26#include "bf-p4c/mau/input_xbar.h"
27#include "bf-p4c/mau/tofino/input_xbar.h"
28#include "bf-p4c/phv/phv_fields.h"
30#include "lib/cstring.h"
32#include "lib/ordered_map.h"
33#include "mau_visitor.h"
42 if (stage != hfl.stage)
return stage < hfl.stage;
43 return hash_group < hfl.hash_group;
47 return stage == hfl.stage && hash_group != hfl.hash_group;
50 bool operator!=(
const HashFuncLoc &hfl)
const {
return !(*
this == hfl); }
52 HashFuncLoc(
int s,
int hg) : stage(s), hash_group(hg) {}
55using NameToHashGen = std::map<cstring, const IR::MAU::HashGenExpression *>;
57 std::map<cstring, safe_vector<std::pair<HashFuncLoc, const Tofino::IXBar::HashDistIRUse *>>>;
58using AllocToHashUse = std::map<HashFuncLoc, safe_vector<const Tofino::IXBar::HashDistIRUse *>>;
61 NameToHashGen &verify_hash_gen;
64 auto rv = MauInspector::init_apply(node);
65 verify_hash_gen.clear();
69 bool preorder(
const IR::MAU::HashGenExpression *)
override;
76 const NameToHashGen &verify_hash_gen;
77 HashGenToAlloc &hash_gen_alloc;
80 auto rv = MauInspector::init_apply(node);
81 hash_gen_alloc.clear();
85 bool preorder(
const IR::MAU::Table *)
override;
89 : verify_hash_gen(vhg), hash_gen_alloc(hga) {}
94static const unsigned fieldListHandleBase = (0x21 << 24);
96static const unsigned dynHashHandleBase = (0x8 << 24);
97static const unsigned algoHandleBase = (0x23 << 24);
98extern unsigned fieldListHandle;
99extern unsigned dynHashHandle;
100extern unsigned algoHandle;
101static std::map<cstring, unsigned> algoHandles;
106 const NameToHashGen &verify_hash_gen;
107 const HashGenToAlloc &hash_gen_alloc;
108 bool all_placed =
true;
110 bool preorder(
const IR::MAU::Table *tbl)
override;
112 const cstring field_list_name,
const IR::NameList *algorithms,
113 int hash_width = -1);
115 void end_apply()
override;
118 const std::map<cstring, cstring> &fieldNames,
120 void gen_algo_json(
Util::JsonObject *_dhc,
const IR::MAU::HashGenExpression *hge);
122 cstring alg_name,
bool &is_default);
124 int &hash_bit_width);
125 void gen_field_list_json(
Util::JsonObject *_field_list,
const IR::MAU::HashGenExpression *hge,
126 std::map<cstring, cstring> &fieldNames);
127 void gen_hash_dist_json(
cstring dyn_hash_name);
131 const HashGenToAlloc &hga)
132 : phv(p), _dynHashNode(_dhn), verify_hash_gen(vhg), hash_gen_alloc(hga) {}
139 NameToHashGen verify_hash_gen;
140 HashGenToAlloc hash_gen_alloc;
142 friend std::ostream &operator<<(std::ostream &out,
const DynamicHashJson &dyn);
Definition mau_visitor.h:29
Definition ir/pass_manager.h:40
Definition phv_fields.h:1095
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition input_xbar.h:191
Definition hash_function.h:28
Definition tofino/input_xbar.h:192