diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/constids.inc | 2 | ||||
-rw-r--r-- | kernel/hashlib.h | 34 | ||||
-rw-r--r-- | kernel/rtlil.cc | 5 |
3 files changed, 36 insertions, 5 deletions
diff --git a/kernel/constids.inc b/kernel/constids.inc index 68a5782fd..27b652e24 100644 --- a/kernel/constids.inc +++ b/kernel/constids.inc @@ -29,6 +29,7 @@ X(B) X(BI) X(blackbox) X(B_SIGNED) +X(bugpoint_keep) X(B_WIDTH) X(C) X(cells_not_processed) @@ -199,6 +200,7 @@ X(wand) X(whitebox) X(WIDTH) X(wildcard_port_conns) +X(wiretype) X(wor) X(WORDS) X(WR_ADDR) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 97fadea0e..592d6e577 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -642,6 +642,7 @@ protected: entry_t() { } entry_t(const K &udata, int next) : udata(udata), next(next) { } + entry_t(K &&udata, int next) : udata(std::move(udata)), next(next) { } }; std::vector<int> hashtable; @@ -745,11 +746,24 @@ protected: int do_insert(const K &value, int &hash) { if (hashtable.empty()) { - entries.push_back(entry_t(value, -1)); + entries.emplace_back(value, -1); do_rehash(); hash = do_hash(value); } else { - entries.push_back(entry_t(value, hashtable[hash])); + entries.emplace_back(value, hashtable[hash]); + hashtable[hash] = entries.size() - 1; + } + return entries.size() - 1; + } + + int do_insert(K &&rvalue, int &hash) + { + if (hashtable.empty()) { + entries.emplace_back(std::forward<K>(rvalue), -1); + do_rehash(); + hash = do_hash(rvalue); + } else { + entries.emplace_back(std::forward<K>(rvalue), hashtable[hash]); hashtable[hash] = entries.size() - 1; } return entries.size() - 1; @@ -847,6 +861,22 @@ public: return std::pair<iterator, bool>(iterator(this, i), true); } + std::pair<iterator, bool> insert(K &&rvalue) + { + int hash = do_hash(rvalue); + int i = do_lookup(rvalue, hash); + if (i >= 0) + return std::pair<iterator, bool>(iterator(this, i), false); + i = do_insert(std::forward<K>(rvalue), hash); + return std::pair<iterator, bool>(iterator(this, i), true); + } + + template<typename... Args> + std::pair<iterator, bool> emplace(Args&&... args) + { + return insert(K(std::forward<Args>(args)...)); + } + int erase(const K &key) { int hash = do_hash(key); diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2aefe30b1..196e301b6 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -2619,16 +2619,15 @@ void RTLIL::Cell::setParam(RTLIL::IdString paramname, RTLIL::Const value) const RTLIL::Const &RTLIL::Cell::getParam(RTLIL::IdString paramname) const { - static const RTLIL::Const empty; const auto &it = parameters.find(paramname); if (it != parameters.end()) return it->second; if (module && module->design) { RTLIL::Module *m = module->design->module(type); if (m) - return m->parameter_default_values.at(paramname, empty); + return m->parameter_default_values.at(paramname); } - return empty; + throw std::out_of_range("Cell::getParam()"); } void RTLIL::Cell::sort() |