Internals: Remove redundant AstNode::addNextStmt

This commit is contained in:
Geza Lore 2025-10-21 10:42:03 +01:00
parent cf275b6e58
commit 8daae7336d
4 changed files with 3 additions and 21 deletions

View File

@ -825,9 +825,6 @@ public:
void swapWith(AstNode* bp); void swapWith(AstNode* bp);
void relink(VNRelinker* linkerp); // Generally use linker->relink() instead void relink(VNRelinker* linkerp); // Generally use linker->relink() instead
void cloneRelinkNode() { cloneRelink(); } void cloneRelinkNode() { cloneRelink(); }
// Iterate and insert - assumes tree format
virtual void addNextStmt(AstNode* newp,
AstNode* belowp); // When calling, "this" is second argument
// METHODS - Iterate on a tree // METHODS - Iterate on a tree
AstNode* cloneTree(bool cloneNextLink, AstNode* cloneTree(bool cloneNextLink,

View File

@ -38,8 +38,6 @@ protected:
public: public:
ASTGEN_MEMBERS_AstNodeStmt; ASTGEN_MEMBERS_AstNodeStmt;
// METHODS // METHODS
void addNextStmt(AstNode* newp,
AstNode* belowp) override; // Stop statement searchback here
void dump(std::ostream& str = std::cout) const override; void dump(std::ostream& str = std::cout) const override;
void dumpJson(std::ostream& str = std::cout) const override; void dumpJson(std::ostream& str = std::cout) const override;
}; };

View File

@ -1528,20 +1528,6 @@ AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) {
return varScopep; return varScopep;
} }
//======================================================================
// Special walking tree inserters
void AstNode::addNextStmt(AstNode* newp, AstNode*) {
UASSERT_OBJ(backp(), newp, "Can't find current statement to addNextStmt");
// Look up; virtual call will find where to put it
this->backp()->addNextStmt(newp, this);
}
void AstNodeStmt::addNextStmt(AstNode* newp, AstNode*) {
// Insert newp after current node
this->addNextHere(newp);
}
//====================================================================== //======================================================================
// Per-type Debugging // Per-type Debugging

View File

@ -114,7 +114,8 @@ class UnknownVisitor final : public VNVisitor {
AstVar* const varp AstVar* const varp
= new AstVar{fl, VVarType::MODULETEMP, m_lvboundNames.get(prep), prep->dtypep()}; = new AstVar{fl, VVarType::MODULETEMP, m_lvboundNames.get(prep), prep->dtypep()};
m_modp->addStmtsp(varp); m_modp->addStmtsp(varp);
AstNode* const abovep = prep->backp(); // Grab above point before we replace 'prep' AstNode* stmtp = prep->backp(); // Grab above point before we replace 'prep'
while (!VN_IS(stmtp, NodeStmt)) stmtp = stmtp->backp();
prep->replaceWith(new AstVarRef{fl, varp, VAccess::WRITE}); prep->replaceWith(new AstVarRef{fl, varp, VAccess::WRITE});
if (m_timingControlp) m_timingControlp->unlinkFrBack(); if (m_timingControlp) m_timingControlp->unlinkFrBack();
@ -128,7 +129,7 @@ class UnknownVisitor final : public VNVisitor {
newp->branchPred(VBranchPred::BP_LIKELY); newp->branchPred(VBranchPred::BP_LIKELY);
newp->isBoundsCheck(true); newp->isBoundsCheck(true);
UINFOTREE(9, newp, "", "_new"); UINFOTREE(9, newp, "", "_new");
abovep->addNextStmt(newp, abovep); stmtp->addNextHere(newp);
prep->user2p(newp); // Save so we may LogAnd it next time prep->user2p(newp); // Save so we may LogAnd it next time
} }
} }