19#ifndef BF_P4C_MAU_TABLE_MUTEX_H_
20#define BF_P4C_MAU_TABLE_MUTEX_H_
24#include "backends/tofino/bf-p4c/mau/action_mutex.h"
25#include "backends/tofino/bf-p4c/mau/mau_visitor.h"
26#include "backends/tofino/bf-p4c/mau/resource.h"
27#include "backends/tofino/bf-p4c/mau/table_layout.h"
28#include "lib/ordered_map.h"
29#include "lib/safe_vector.h"
30#include "lib/symbitmatrix.h"
37 using TablePair = std::pair<const IR::MAU::Table *, const IR::MAU::Table *>;
45 std::map<cstring, const IR::MAU::Table *> internal_name_to_table;
46 std::map<cstring, const IR::MAU::Table *> external_name_to_table;
53 auto rv = MauTableInspector::init_apply(node);
54 ignore_dep_map.clear();
55 internal_name_to_table.clear();
56 external_name_to_table.clear();
57 table_to_pragmas.clear();
62 bool preorder(
const IR::MAU::Table *)
override;
65 void end_apply()
override;
71 bool ignore_deps(
const IR::MAU::Table *t1,
const IR::MAU::Table *t2)
const;
112 std::map<int, const IR::MAU::Table *> rev_table_ids;
116 std::map<cstring, const IR::MAU::Table *> name_to_tables;
133 void postorder(
const IR::MAU::Table *tbl)
override;
134 void postorder(
const IR::MAU::TableSeq *seq)
override;
135 bool miss_mutex_action_chain(
const IR::MAU::Table *tbl,
const IR::MAU::Action *default_act,
139 profile_t rv = MauTableInspector::init_apply(root);
142 rev_table_ids.clear();
144 name_to_tables.clear();
148 assert(!table_ids.count(t));
149 rev_table_ids.emplace(table_ids.size(), t);
150 table_ids.emplace(t, table_ids.size());
151 name_to_tables.emplace(t->externalName(), t);
157 bool operator()(
const IR::MAU::Table *a,
const IR::MAU::Table *b)
const;
169 std::map<const IR::MAU::Table *, int> table_ids;
170 std::map<int, const IR::MAU::Table *> rev_table_ids;
173 profile_t rv = MauInspector::init_apply(root);
174 backend_users.clear();
175 table_sharing_attached.clear();
177 rev_table_ids.clear();
178 _mutex_through_ignore.clear();
180 assert(!table_ids.count(t));
181 rev_table_ids.emplace(table_ids.size(), t);
182 table_ids.emplace(t, table_ids.size());
186 bool preorder(
const IR::MAU::AttachedMemory *)
override;
187 bool check_if_can_share(
const IR::MAU::Table *a,
const IR::MAU::Table *b,
188 const IR::MAU::AttachedMemory *am);
189 std::vector<const IR::MAU::Action *> get_indirect_actions(
const IR::MAU::Table *a,
190 const IR::MAU::AttachedMemory *am);
193 bool mutex_through_ignore(
const IR::MAU::Table *a,
const IR::MAU::Table *b)
const;
195 bool if_table_share_attach(
const IR::MAU::Table *a,
const IR::MAU::Table *b)
const;
199 : mutex(m), ignore(i), action_mutex(a), lc(lc) {}
Definition action_mutex.h:29
Definition mau/table_mutex.h:36
safe_vector< TablePair > pairwise_deps_to_ignore() const
In the returned list, each pair of tables should have their dependencies ignored.
Definition mau/table_mutex.cpp:76
bool ignore_deps(const IR::MAU::Table *t1, const IR::MAU::Table *t2) const
Determines whether dependencies between the two given tables should be ignored.
Definition mau/table_mutex.cpp:23
Definition table_layout.h:83
Definition mau_visitor.h:29
Definition mau_visitor.h:39
Definition symbitmatrix.h:27
Definition ordered_map.h:32
Definition safe_vector.h:27
Definition mau/table_mutex.h:160
Definition mau/table_mutex.h:110
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void forAllMatching(const IR::Node *root, Func &&function)
Definition visitor.h:801