Internals: New Hashed/Graph functions towards msg980.

Signed-off-by: Wilson Snyder <[email protected]>
This commit is contained in:
Varun Koyyalagunta
2013-02-19 18:49:36 -05:00
committed by Wilson Snyder
parent 772a3a97eb
commit f2fb77c15a
4 changed files with 36 additions and 3 deletions
+19 -2
View File
@@ -105,12 +105,16 @@ public:
//######################################################################
// Hashed class functions
void V3Hashed::hashAndInsert(AstNode* nodep) {
V3Hashed::iterator V3Hashed::hashAndInsert(AstNode* nodep) {
hash(nodep);
return m_hashMmap.insert(make_pair(nodeHash(nodep), nodep));
}
void V3Hashed::hash(AstNode* nodep) {
UINFO(8," hashI "<<nodep<<endl);
if (!nodep->user4p()) {
HashedVisitor visitor (nodep);
}
m_hashMmap.insert(make_pair(nodeHash(nodep), nodep));
}
bool V3Hashed::sameNodes(AstNode* node1p, AstNode* node2p) {
@@ -189,3 +193,16 @@ V3Hashed::iterator V3Hashed::findDuplicate(AstNode* nodep) {
return end();
}
V3Hashed::iterator V3Hashed::findDuplicate(AstNode* nodep, V3HashedUserCheck* checkp) {
UINFO(8," findD "<<nodep<<endl);
if (!nodep->user4p()) nodep->v3fatalSrc("Called findDuplicate on non-hashed node");
pair <HashMmap::iterator,HashMmap::iterator> eqrange = mmap().equal_range(nodeHash(nodep));
for (HashMmap::iterator eqit = eqrange.first; eqit != eqrange.second; ++eqit) {
AstNode* node2p = eqit->second;
if (nodep != node2p && checkp->check(nodep,node2p) && sameNodes(nodep, node2p)) {
return eqit;
}
}
return end();
}