Ensure VarRef inherits dtype when varp is set.
Inlining used to set some VarRefs to point to new Var nodes, without updating the dtype of the VarRef to the dtype of the new Var. AstNode::sameTree does identity comparison on the dtype, so some trees that were semantically the same did not compare as such with sameTree because of the dtype. This in turn results in some missed opportunities for combining equivalent SenTree sensitivities when the clock came from outside.
This commit is contained in:
parent
8291ef6537
commit
e609328ebb
14
src/V3Ast.h
14
src/V3Ast.h
|
|
@ -2269,29 +2269,26 @@ private:
|
|||
string m_name; // Name of variable
|
||||
string m_hiername; // Scope converted into name-> for emitting
|
||||
bool m_hierThis; // Hiername points to "this" function
|
||||
void init();
|
||||
|
||||
public:
|
||||
AstNodeVarRef(AstType t, FileLine* fl, const string& name, bool lvalue)
|
||||
: AstNodeMath(t, fl)
|
||||
, m_lvalue(lvalue)
|
||||
, m_varp(NULL)
|
||||
, m_varScopep(NULL)
|
||||
, m_packagep(NULL)
|
||||
, m_name(name)
|
||||
, m_hierThis(false) {
|
||||
init();
|
||||
this->varp(NULL);
|
||||
}
|
||||
AstNodeVarRef(AstType t, FileLine* fl, const string& name, AstVar* varp, bool lvalue)
|
||||
: AstNodeMath(t, fl)
|
||||
, m_lvalue(lvalue)
|
||||
, m_varp(varp)
|
||||
, m_varScopep(NULL)
|
||||
, m_packagep(NULL)
|
||||
, m_name(name)
|
||||
, m_hierThis(false) {
|
||||
// May have varp==NULL
|
||||
init();
|
||||
this->varp(varp);
|
||||
}
|
||||
ASTNODE_BASE_FUNCS(NodeVarRef)
|
||||
virtual bool hasDType() const { return true; }
|
||||
|
|
@ -2303,7 +2300,7 @@ public:
|
|||
bool lvalue() const { return m_lvalue; }
|
||||
void lvalue(bool lval) { m_lvalue = lval; } // Avoid using this; Set in constructor
|
||||
AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable
|
||||
void varp(AstVar* varp) { m_varp = varp; }
|
||||
void varp(AstVar* varp);
|
||||
AstVarScope* varScopep() const { return m_varScopep; }
|
||||
void varScopep(AstVarScope* varscp) { m_varScopep = varscp; }
|
||||
string hiername() const { return m_hiername; }
|
||||
|
|
@ -2943,8 +2940,9 @@ inline bool AstNode::sameGateTree(const AstNode* node2p) const {
|
|||
return sameTreeIter(this, node2p, true, true);
|
||||
}
|
||||
|
||||
inline void AstNodeVarRef::init() {
|
||||
if (m_varp) dtypep(m_varp->dtypep());
|
||||
inline void AstNodeVarRef::varp(AstVar* varp) {
|
||||
m_varp = varp;
|
||||
dtypeFrom(varp);
|
||||
}
|
||||
|
||||
inline bool AstNodeDType::isFourstate() const { return basicp()->isFourstate(); }
|
||||
|
|
|
|||
|
|
@ -443,7 +443,6 @@ private:
|
|||
string newname = varrefp->name() + "__BRA__" + cvtToStr(i + offset) + "__KET__";
|
||||
AstVarXRef* newVarXRefp = new AstVarXRef(nodep->fileline(), newname, "", true);
|
||||
newVarXRefp->varp(newp->modVarp());
|
||||
newVarXRefp->dtypep(newp->modVarp()->dtypep());
|
||||
newp->exprp()->unlinkFrBack()->deleteTree();
|
||||
newp->exprp(newVarXRefp);
|
||||
if (!prevPinp) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue