Skip to content

Commit 3887be1

Browse files
committed
proc_mux: optimize source map locality for index density
1 parent 31618a7 commit 3887be1

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

passes/proc/proc_mux.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,31 @@
2828
USING_YOSYS_NAMESPACE
2929
PRIVATE_NAMESPACE_BEGIN
3030

31-
using SnippetSourceMap = dict<std::pair<int, const RTLIL::CaseRule*>, const Const*>;
31+
using SnippetSourceMap = std::vector<dict<const RTLIL::CaseRule*, const Const*>>;
3232
struct SnippetSourceMapBuilder {
3333
SnippetSourceMap map;
3434
void insert(int snippet, const RTLIL::CaseRule* cs, const RTLIL::SyncAction& action) {
35+
map.resize(snippet + 1);
3536
if (action.src.size())
36-
map[std::make_pair(snippet, cs)] = &action.src;
37+
map[snippet][cs] = &action.src;
3738
}
3839

3940
};
4041
struct SnippetSourceMapper {
4142
const SnippetSourceMap map;
4243
void try_map_into(pool<std::string>& sources, int snippet, const RTLIL::CaseRule* cs) const {
43-
auto src_it = map.find(std::make_pair(snippet, cs));
44-
if (src_it != map.end()) {
45-
sources.insert(src_it->second->decode_string());
46-
} else {
47-
auto cs_src = cs->get_src_attribute();
48-
if (cs_src.size()) {
49-
sources.insert(cs_src);
44+
if ((size_t)snippet < map.size()) {
45+
const auto& snippet_map = map[snippet];
46+
auto src_it = snippet_map.find(cs);
47+
if (src_it != snippet_map.end()) {
48+
sources.insert(src_it->second->decode_string());
49+
return;
5050
}
5151
}
52+
auto cs_src = cs->get_src_attribute();
53+
if (cs_src.size()) {
54+
sources.insert(cs_src);
55+
}
5256
}
5357

5458
};

0 commit comments

Comments
 (0)