Internals: Refactor AstNodeBlock representation (#6280) (#6588)

Internals: Refactor AstNodeBlock representation (#6280)

AstNodeBlock now has 2 child lists: 'declsp' to hold declarations within
the block, and 'stmtsp' to hold the procedural statements.

AstBegin is then just a simple subtype of AstNodeBlock.

AstFork is a proper superset of AstNodeBlock (and also AstBegin), and
adds 'forksp' which hold the parallel statements. Having the sequential
'stmtsp' in AstFork is required to properly implement variable
initializers in fork blocks (IEEE 1800-2023 9.3.2), this makes that
clear, while also separating the non AstNodeStmt declarations
(for #6280). The actual fork branches in 'AstFork::forkps()' are all
AstBegin nodes. This is required as lowering stages will introduce
additional statements in each parallel branch. (We used to wrap AstFork
statements into AstBegin in 3 different places, now they always are
AstBegin and this is enforced via the type checker/V3Broken).

Also fixes incorrect disabling of forked processes from within the `fork`.
This commit is contained in:
Geza Lore
2025-10-24 14:00:07 +01:00
committed by GitHub
parent 65c5071246
commit d864057a60
25 changed files with 467 additions and 379 deletions
+2 -1
View File
@@ -142,10 +142,11 @@ private:
void visit(AstFork* nodep) override {
if (m_ignoreRemaining) return;
const VisitBase vb{this, nodep};
iterateAndNextConstNull(nodep->stmtsp());
uint32_t totalCount = m_stackSize;
VL_RESTORER(m_ignoreRemaining);
// Sum counts in each statement
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
for (AstNode* stmtp = nodep->forksp(); stmtp; stmtp = stmtp->nextp()) {
reset();
iterateConst(stmtp);
totalCount += m_stackSize;