Internals: Cleanup VL_RESTORER format in V3LinkLValue. No functional change.

This commit is contained in:
Wilson Snyder 2024-11-04 23:55:39 -05:00
parent 4e71f359bf
commit eaaf91c82b

View File

@ -32,13 +32,15 @@ VL_DEFINE_DEBUG_FUNCTIONS;
class LinkLValueVisitor final : public VNVisitor { class LinkLValueVisitor final : public VNVisitor {
// NODE STATE // NODE STATE
// STATE // STATE - for current visit position (use VL_RESTORER)
bool m_setContinuously = false; // Set that var has some continuous assignment bool m_setContinuously = false; // Set that var has some continuous assignment
bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified.
bool m_setForcedByCode = false; // Set that var is the target of an AstAssignForce/AstRelease bool m_setForcedByCode = false; // Set that var is the target of an AstAssignForce/AstRelease
bool m_setIfRand = false; // Update VarRefs if var declared as rand bool m_setIfRand = false; // Update VarRefs if var declared as rand
bool m_inInitialStatic = false; // Set if inside AstInitialStatic bool m_inInitialStatic = false; // Set if inside AstInitialStatic
bool m_inFunc = false; // Set if inside AstNodeFTask bool m_inFunc = false; // Set if inside AstNodeFTask
// STATE - TODO
bool m_setStrengthSpecified = false; // Set that var has assignment with strength specified.
VAccess m_setRefLvalue; // Set VarRefs to lvalues for pin assignments VAccess m_setRefLvalue; // Set VarRefs to lvalues for pin assignments
// VISITs // VISITs
@ -137,75 +139,57 @@ class LinkLValueVisitor final : public VNVisitor {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
VL_RESTORER(m_setContinuously); VL_RESTORER(m_setContinuously);
VL_RESTORER(m_setForcedByCode); VL_RESTORER(m_setForcedByCode);
{ m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; m_setContinuously = false;
m_setContinuously = false; m_setForcedByCode = true;
m_setForcedByCode = true; iterateAndNextNull(nodep->lhsp());
iterateAndNextNull(nodep->lhsp());
}
} }
void visit(AstFireEvent* nodep) override { void visit(AstFireEvent* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->operandp());
iterateAndNextNull(nodep->operandp());
}
} }
void visit(AstCastDynamic* nodep) override { void visit(AstCastDynamic* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->fromp());
iterateAndNextNull(nodep->fromp()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->top());
iterateAndNextNull(nodep->top());
}
} }
void visit(AstFError* nodep) override { void visit(AstFError* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->filep()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->strp());
iterateAndNextNull(nodep->strp());
}
} }
void visit(AstFGetS* nodep) override { void visit(AstFGetS* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->filep()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->strgp());
iterateAndNextNull(nodep->strgp());
}
} }
void visit(AstFRead* nodep) override { void visit(AstFRead* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->filep()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->memp());
iterateAndNextNull(nodep->memp());
}
} }
void visit(AstFScanF* nodep) override { void visit(AstFScanF* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->filep()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->exprsp());
iterateAndNextNull(nodep->exprsp());
}
} }
void visit(AstFUngetC* nodep) override { void visit(AstFUngetC* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->filep());
iterateAndNextNull(nodep->filep()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->rhsp());
iterateAndNextNull(nodep->rhsp());
}
} }
void visit(AstSScanF* nodep) override { void visit(AstSScanF* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->exprsp());
iterateAndNextNull(nodep->exprsp());
}
} }
void visit(AstSysIgnore* nodep) override { void visit(AstSysIgnore* nodep) override {
// Can't know if lvalue or not; presume not // Can't know if lvalue or not; presume not
@ -213,46 +197,36 @@ class LinkLValueVisitor final : public VNVisitor {
} }
void visit(AstRand* nodep) override { void visit(AstRand* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ if (!nodep->urandom()) m_setRefLvalue = VAccess::WRITE;
if (!nodep->urandom()) m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->seedp());
iterateAndNextNull(nodep->seedp());
}
} }
void visit(AstReadMem* nodep) override { void visit(AstReadMem* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->memp());
iterateAndNextNull(nodep->memp()); m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->filenamep());
iterateAndNextNull(nodep->filenamep()); iterateAndNextNull(nodep->lsbp());
iterateAndNextNull(nodep->lsbp()); iterateAndNextNull(nodep->msbp());
iterateAndNextNull(nodep->msbp());
}
} }
void visit(AstTestPlusArgs* nodep) override { void visit(AstTestPlusArgs* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->searchp());
iterateAndNextNull(nodep->searchp());
}
} }
void visit(AstValuePlusArgs* nodep) override { void visit(AstValuePlusArgs* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->searchp());
iterateAndNextNull(nodep->searchp()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->outp());
iterateAndNextNull(nodep->outp());
}
} }
void visit(AstSFormat* nodep) override { void visit(AstSFormat* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->lhsp());
iterateAndNextNull(nodep->lhsp()); m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->fmtp());
iterateAndNextNull(nodep->fmtp());
}
} }
void visit(AstNodeDistBiop* nodep) override { void visit(AstNodeDistBiop* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
@ -271,13 +245,11 @@ class LinkLValueVisitor final : public VNVisitor {
} }
void prepost_visit(AstNodeTriop* nodep) { void prepost_visit(AstNodeTriop* nodep) {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->lhsp());
iterateAndNextNull(nodep->lhsp()); iterateAndNextNull(nodep->rhsp());
iterateAndNextNull(nodep->rhsp()); m_setRefLvalue = VAccess::WRITE;
m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->thsp());
iterateAndNextNull(nodep->thsp());
}
} }
void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } void visit(AstPreAdd* nodep) override { prepost_visit(nodep); }
void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } void visit(AstPostAdd* nodep) override { prepost_visit(nodep); }
@ -287,38 +259,33 @@ class LinkLValueVisitor final : public VNVisitor {
// Nodes that change LValue state // Nodes that change LValue state
void visit(AstSel* nodep) override { void visit(AstSel* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ iterateAndNextNull(nodep->fromp());
iterateAndNextNull(nodep->fromp()); // Only set lvalues on the from
// Only set lvalues on the from m_setRefLvalue = VAccess::NOCHANGE;
m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->lsbp());
iterateAndNextNull(nodep->lsbp()); iterateAndNextNull(nodep->widthp());
iterateAndNextNull(nodep->widthp());
}
} }
void visit(AstNodeSel* nodep) override { void visit(AstNodeSel* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ // Only set lvalues on the from // Only set lvalues on the from
iterateAndNextNull(nodep->fromp()); iterateAndNextNull(nodep->fromp());
m_setRefLvalue = VAccess::NOCHANGE; m_setRefLvalue = VAccess::NOCHANGE;
iterateAndNextNull(nodep->bitp()); iterateAndNextNull(nodep->bitp());
}
} }
void visit(AstCellArrayRef* nodep) override { void visit(AstCellArrayRef* nodep) override {
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ // selp is not an lvalue // selp is not an lvalue
m_setRefLvalue = VAccess::NOCHANGE; m_setRefLvalue = VAccess::NOCHANGE;
iterateAndNextNull(nodep->selp()); iterateAndNextNull(nodep->selp());
}
} }
void visit(AstNodePreSel* nodep) override { void visit(AstNodePreSel* nodep) override {
if (AstSelBit* const selbitp = VN_CAST(nodep, SelBit)) selbitp->access(m_setRefLvalue); if (AstSelBit* const selbitp = VN_CAST(nodep, SelBit)) selbitp->access(m_setRefLvalue);
VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setRefLvalue);
{ // Only set lvalues on the from // Only set lvalues on the from
iterateAndNextNull(nodep->fromp()); iterateAndNextNull(nodep->fromp());
m_setRefLvalue = VAccess::NOCHANGE; m_setRefLvalue = VAccess::NOCHANGE;
iterateAndNextNull(nodep->rhsp()); iterateAndNextNull(nodep->rhsp());
iterateAndNextNull(nodep->thsp()); iterateAndNextNull(nodep->thsp());
}
} }
void visit(AstMemberSel* nodep) override { void visit(AstMemberSel* nodep) override {
if (m_setRefLvalue != VAccess::NOCHANGE) { if (m_setRefLvalue != VAccess::NOCHANGE) {