mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-15 03:35:40 +00:00
proc_mux: optimize source map locality for index density
(cherry picked from commit b3aea1b5d2)
This commit is contained in:
parent
6bd2609f34
commit
e5ef56f1e8
1 changed files with 13 additions and 9 deletions
|
|
@ -28,27 +28,31 @@
|
|||
USING_YOSYS_NAMESPACE
|
||||
PRIVATE_NAMESPACE_BEGIN
|
||||
|
||||
using SnippetSourceMap = dict<std::pair<int, const RTLIL::CaseRule*>, TwineRef>;
|
||||
using SnippetSourceMap = std::vector<dict<const RTLIL::CaseRule*, TwineRef>>;
|
||||
struct SnippetSourceMapBuilder {
|
||||
SnippetSourceMap map;
|
||||
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 != Twine::Null)
|
||||
map[std::make_pair(snippet, cs)] = action.src;
|
||||
map[snippet][cs] = action.src;
|
||||
}
|
||||
|
||||
};
|
||||
struct SnippetSourceMapper {
|
||||
const SnippetSourceMap map;
|
||||
void try_map_into(pool<TwineRef>& sources, int snippet, const RTLIL::CaseRule* cs) const {
|
||||
auto src_it = map.find(std::make_pair(snippet, cs));
|
||||
if (src_it != map.end()) {
|
||||
sources.insert(src_it->second);
|
||||
} else {
|
||||
TwineRef cs_src = cs->src_id();
|
||||
if (cs_src != Twine::Null) {
|
||||
sources.insert(cs_src);
|
||||
if ((size_t)snippet < map.size()) {
|
||||
const auto& snippet_map = map[snippet];
|
||||
auto src_it = snippet_map.find(cs);
|
||||
if (src_it != snippet_map.end()) {
|
||||
sources.insert(src_it->second);
|
||||
return;
|
||||
}
|
||||
}
|
||||
TwineRef cs_src = cs->src_id();
|
||||
if (cs_src != Twine::Null) {
|
||||
sources.insert(cs_src);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue