Internals: Refactor AstCFunc internals (#6280) (#6578)

- Delete 'finalsp'. It was used in one place, basically unnecessary and
  safe to remove.
- Make 'argsp' a 'List[AstVar]'. This held before. It holds the function
  argument and return variables.
- Replace 'intitsp' with 'varsp' and make it into 'List[AstVar]' to hold
  the function local variables. This was most of its use before. The few
  places we inserted statements here now moved into 'stmtsp' by
  inserting at the front of the list.
This commit is contained in:
Geza Lore
2025-10-21 16:37:32 +01:00
committed by GitHub
parent c471323601
commit ec91158130
15 changed files with 89 additions and 85 deletions
+10 -4
View File
@@ -164,11 +164,17 @@ class ClockVisitor final : public VNVisitor {
//========== Move sampled assignments
void visit(AstVarScope* nodep) override {
AstVar* varp = nodep->varp();
AstVar* const varp = nodep->varp();
if (varp->valuep() && varp->name().substr(0, strlen("__Vsampled")) == "__Vsampled") {
m_evalp->addInitsp(new AstAssign{
nodep->fileline(), new AstVarRef{nodep->fileline(), nodep, VAccess::WRITE},
VN_AS(varp->valuep()->unlinkFrBack(), NodeExpr)});
FileLine* const flp = nodep->fileline();
AstNodeExpr* const rhsp = VN_AS(varp->valuep()->unlinkFrBack(), NodeExpr);
AstVarRef* const lhsp = new AstVarRef{flp, nodep, VAccess::WRITE};
AstAssign* const assignp = new AstAssign{flp, lhsp, rhsp};
if (AstNode* const stmtsp = m_evalp->stmtsp()) {
stmtsp->addHereThisAsNext(assignp);
} else {
m_evalp->addStmtsp(assignp);
}
varp->direction(VDirection::NONE); // Restore defaults
varp->primaryIO(false);
}