Support disable dotted references (#6154)

This commit is contained in:
Ryszard Rozak
2025-07-09 16:59:26 -04:00
committed by GitHub
parent 8ba7cec15b
commit 8b3a6ba542
26 changed files with 384 additions and 50 deletions
+28 -20
View File
@@ -337,33 +337,41 @@ class LinkJumpVisitor final : public VNVisitor {
}
void visit(AstDisable* nodep) override {
UINFO(8, " DISABLE " << nodep);
iterateChildren(nodep);
AstNodeBlock* blockp = nullptr;
for (AstNodeBlock* const stackp : vlstd::reverse_view(m_blockStack)) {
UINFO(9, " UNDERBLK " << stackp);
if (stackp->name() == nodep->name()) {
blockp = stackp;
break;
AstNode* const targetp = nodep->targetp();
UASSERT_OBJ(targetp, nodep, "Unlinked disable statement");
if (VN_IS(targetp, Task)) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: disabling task by name");
} else if (VN_IS(targetp, Fork)) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: disabling fork by name");
} else if (AstBegin* const beginp = VN_CAST(targetp, Begin)) {
const std::string targetName = beginp->name();
bool aboveBlock = false;
for (AstNodeBlock* const stackp : vlstd::reverse_view(m_blockStack)) {
UINFO(9, " UNDERBLK " << stackp);
if (stackp->name() == targetName) {
aboveBlock = true;
break;
}
}
}
// if (debug() >= 9) { UINFO(0, "\n"); blockp->dumpTree("- labeli: "); }
if (!blockp) {
nodep->v3warn(E_UNSUPPORTED,
"disable isn't underneath a begin with name: " << nodep->prettyNameQ());
} else if (AstBegin* const beginp = VN_CAST(blockp, Begin)) {
if (beginp->user3()) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: disabling block that contains a fork");
if (aboveBlock) {
if (beginp->user3()) {
nodep->v3warn(E_UNSUPPORTED,
"Unsupported: disabling block that contains a fork");
} else {
// Jump to the end of the named block
AstJumpLabel* const labelp = findAddLabel(beginp, false);
nodep->addNextHere(new AstJumpGo{nodep->fileline(), labelp});
}
} else {
// Jump to the end of the named block
AstJumpLabel* const labelp = findAddLabel(beginp, false);
nodep->addNextHere(new AstJumpGo{nodep->fileline(), labelp});
nodep->v3warn(E_UNSUPPORTED, "disable isn't underneath a begin with name: '"
<< targetName << "'");
}
} else {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: disabling fork by name");
nodep->v3fatalSrc("Disable linked with node of unhandled type "
<< targetp->prettyTypeName());
}
nodep->unlinkFrBack();
VL_DO_DANGLING(pushDeletep(nodep), nodep);
// if (debug() >= 9) { UINFO(0, "\n"); beginp->dumpTree("- labelo: "); }
}
void visit(AstVarRef* nodep) override {
if (m_loopInc && nodep->varp()) nodep->varp()->usedLoopIdx(true);