forked from github/verilator
Internals: Rename V3Hashed functions for future commit. No functional change.
This commit is contained in:
parent
cf2ac30f66
commit
9e58ede480
@ -902,12 +902,12 @@ void GateVisitor::optimizeElimVar(AstVarScope* varscp, AstNode* substp, AstNode*
|
||||
//######################################################################
|
||||
// Auxiliary hash class for GateDedupeVarVisitor
|
||||
|
||||
class GateDedupeHash : public V3HashedUserCheck {
|
||||
class GateDedupeHash : public V3HashedUserSame {
|
||||
private:
|
||||
// NODE STATE
|
||||
// Ast*::user2p -> parent AstNodeAssign* for this rhsp
|
||||
// Ast*::user3p -> AstActive* of assign, for check() in test for duplicate
|
||||
// Ast*::user5p -> AstNode* of assign if condition, for check() in test for duplicate
|
||||
// Ast*::user3p -> AstActive* of assign, for isSame() in test for duplicate
|
||||
// Ast*::user5p -> AstNode* of assign if condition, for isSame() in test for duplicate
|
||||
// AstUser2InUse m_inuser2; (Allocated for use in GateVisitor)
|
||||
AstUser3InUse m_inuser3;
|
||||
// AstUser4InUse m_inuser4; (Allocated for use in V3Hashed)
|
||||
@ -930,7 +930,7 @@ private:
|
||||
return node1p == node2p || sameHash(node1p, node2p);
|
||||
}
|
||||
public:
|
||||
bool check(AstNode* node1p, AstNode* node2p) {
|
||||
bool isSame(AstNode* node1p, AstNode* node2p) {
|
||||
return same(node1p->user3p(), node2p->user3p())
|
||||
&& same(node1p->user5p(), node2p->user5p())
|
||||
&& node1p->user2p()->type() == node2p->user2p()->type();
|
||||
|
@ -193,27 +193,16 @@ void V3Hashed::dumpFile(const string& filename, bool tree) {
|
||||
}
|
||||
}
|
||||
|
||||
V3Hashed::iterator V3Hashed::findDuplicate(AstNode* nodep) {
|
||||
UINFO(8," findD "<<nodep<<endl);
|
||||
UASSERT_OBJ(nodep->user4p(), nodep, "Called findDuplicate on non-hashed node");
|
||||
std::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 && sameNodes(nodep, node2p)) {
|
||||
return eqit;
|
||||
}
|
||||
}
|
||||
return end();
|
||||
}
|
||||
|
||||
V3Hashed::iterator V3Hashed::findDuplicate(AstNode* nodep, V3HashedUserCheck* checkp) {
|
||||
V3Hashed::iterator V3Hashed::findDuplicate(AstNode* nodep, V3HashedUserSame* checkp) {
|
||||
UINFO(8," findD "<<nodep<<endl);
|
||||
UASSERT_OBJ(nodep->user4p(), nodep, "Called findDuplicate on non-hashed node");
|
||||
std::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)) {
|
||||
if (nodep != node2p
|
||||
&& (!checkp || checkp->isSame(nodep, node2p))
|
||||
&& sameNodes(nodep, node2p)) {
|
||||
return eqit;
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ public:
|
||||
|
||||
//============================================================================
|
||||
|
||||
struct V3HashedUserCheck {
|
||||
struct V3HashedUserSame {
|
||||
// Functor for V3Hashed::findDuplicate
|
||||
virtual bool check(AstNode*, AstNode*) = 0;
|
||||
V3HashedUserCheck() {}
|
||||
virtual ~V3HashedUserCheck() {}
|
||||
virtual bool isSame(AstNode*, AstNode*) = 0;
|
||||
V3HashedUserSame() {}
|
||||
virtual ~V3HashedUserSame() {}
|
||||
};
|
||||
|
||||
class V3Hashed : public VHashedBase {
|
||||
@ -76,8 +76,8 @@ public:
|
||||
void hash(AstNode* nodep); // Only hash the node
|
||||
bool sameNodes(AstNode* node1p, AstNode* node2p); // After hashing, and tell if identical
|
||||
void erase(iterator it); // Remove node from structures
|
||||
iterator findDuplicate(AstNode* nodep); // Return duplicate in hash, if any
|
||||
iterator findDuplicate(AstNode* nodep, V3HashedUserCheck* checkp); // Extra user checks for sameness
|
||||
// Return duplicate in hash, if any, with optional user check for sameness
|
||||
iterator findDuplicate(AstNode* nodep, V3HashedUserSame* checkp=NULL);
|
||||
AstNode* iteratorNodep(iterator it) { return it->second; }
|
||||
void dumpFile(const string& filename, bool tree);
|
||||
void dumpFilePrefixed(const string& nameComment, bool tree=false);
|
||||
|
Loading…
Reference in New Issue
Block a user