fold solve-before assoc check into the pair loop

This commit is contained in:
Yilou Wang 2026-07-12 00:16:06 +02:00
parent 401dda07ae
commit 793d2d0381
1 changed files with 12 additions and 10 deletions

View File

@ -2162,19 +2162,15 @@ class ConstraintExprVisitor final : public VNVisitor {
// Generate solveBefore() calls for each (lhs, rhs) variable pair.
// Do NOT iterate children -- these are variable references, not constraint expressions.
FileLine* const fl = nodep->fileline();
for (AstNodeExpr* const listp : {nodep->lhssp(), nodep->rhssp()}) {
for (AstNodeExpr* ep = listp; ep; ep = VN_CAST(ep->nextp(), NodeExpr)) {
if (VN_IS(ep->dtypep()->skipRefp(), AssocArrayDType)) {
ep->v3warn(E_UNSUPPORTED,
"Unsupported: 'solve ... before' with associative array");
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
return;
}
}
}
AstNodeModule* const genModp = VN_AS(m_genp->user2p(), NodeModule);
for (AstNodeExpr* lhsp = nodep->lhssp(); lhsp; lhsp = VN_CAST(lhsp->nextp(), NodeExpr)) {
if (VN_IS(lhsp->dtypep()->skipRefp(), AssocArrayDType)) {
lhsp->v3warn(E_UNSUPPORTED,
"Unsupported: 'solve ... before' with associative array");
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
return;
}
AstNodeExpr* const lhsTestp = buildSolveBeforeNameExpr(fl, lhsp);
if (!lhsTestp) {
lhsp->v3fatalSrc("Unexpected expression type in solve...before lhs");
@ -2183,6 +2179,12 @@ class ConstraintExprVisitor final : public VNVisitor {
VL_DO_DANGLING(lhsTestp->deleteTree(), lhsTestp);
for (AstNodeExpr* rhsp = nodep->rhssp(); rhsp;
rhsp = VN_CAST(rhsp->nextp(), NodeExpr)) {
if (VN_IS(rhsp->dtypep()->skipRefp(), AssocArrayDType)) {
rhsp->v3warn(E_UNSUPPORTED,
"Unsupported: 'solve ... before' with associative array");
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
return;
}
AstNodeExpr* const rhsNamep = buildSolveBeforeNameExpr(fl, rhsp);
if (!rhsNamep) {
rhsp->v3fatalSrc("Unexpected expression type in solve...before rhs");