mirror of
https://github.com/YosysHQ/yosys
synced 2025-12-19 02:33:44 +00:00
proc_mux: optimize source map locality for index density
This commit is contained in:
parent
72356456a1
commit
a52bf59cb9
1 changed files with 13 additions and 9 deletions
|
|
@ -28,27 +28,31 @@
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
PRIVATE_NAMESPACE_BEGIN
|
PRIVATE_NAMESPACE_BEGIN
|
||||||
|
|
||||||
using SnippetSourceMap = dict<std::pair<int, const RTLIL::CaseRule*>, const Const*>;
|
using SnippetSourceMap = std::vector<dict<const RTLIL::CaseRule*, const Const*>>;
|
||||||
struct SnippetSourceMapBuilder {
|
struct SnippetSourceMapBuilder {
|
||||||
SnippetSourceMap map;
|
SnippetSourceMap map;
|
||||||
void insert(int snippet, const RTLIL::CaseRule* cs, const RTLIL::SyncAction& action) {
|
void insert(int snippet, const RTLIL::CaseRule* cs, const RTLIL::SyncAction& action) {
|
||||||
|
map.resize(std::max(map.size(), (size_t)snippet + 1));
|
||||||
if (action.src.size())
|
if (action.src.size())
|
||||||
map[std::make_pair(snippet, cs)] = &action.src;
|
map[snippet][cs] = &action.src;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
struct SnippetSourceMapper {
|
struct SnippetSourceMapper {
|
||||||
const SnippetSourceMap map;
|
const SnippetSourceMap map;
|
||||||
void try_map_into(pool<std::string>& sources, int snippet, const RTLIL::CaseRule* cs) const {
|
void try_map_into(pool<std::string>& sources, int snippet, const RTLIL::CaseRule* cs) const {
|
||||||
auto src_it = map.find(std::make_pair(snippet, cs));
|
if ((size_t)snippet < map.size()) {
|
||||||
if (src_it != map.end()) {
|
const auto& snippet_map = map[snippet];
|
||||||
sources.insert(src_it->second->decode_string());
|
auto src_it = snippet_map.find(cs);
|
||||||
} else {
|
if (src_it != snippet_map.end()) {
|
||||||
auto cs_src = cs->get_src_attribute();
|
sources.insert(src_it->second->decode_string());
|
||||||
if (cs_src.size()) {
|
return;
|
||||||
sources.insert(cs_src);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto cs_src = cs->get_src_attribute();
|
||||||
|
if (cs_src.size()) {
|
||||||
|
sources.insert(cs_src);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue