Internals: Add cloneTreePure to prepare for side effect check.

Use cloneTreePure when what is being cloned must be side-effect free.
Use cloneTree when safe to contain side effects (e.g. cloning module).
This commit is contained in:
Wilson Snyder
2023-09-16 22:50:54 -04:00
parent cd1fe64e6c
commit 761adf1cf0
25 changed files with 193 additions and 180 deletions
+6 -6
View File
@@ -257,7 +257,7 @@ private:
// Create equivalent of VL_SIGNONES_(node_width)
constzerop = new AstNegate{
nodep->fileline(),
new AstShiftR{nodep->fileline(), nodep->lhsp()->cloneTree(false),
new AstShiftR{nodep->fileline(), nodep->lhsp()->cloneTreePure(false),
new AstConst(nodep->fileline(), m1value), nodep->width()}};
} else {
constzerop = new AstConst{nodep->fileline(), AstConst::WidthedValue{},
@@ -269,10 +269,10 @@ private:
= new AstConst(nodep->fileline(), AstConst::WidthedValue{},
nodep->rhsp()->widthMin(), m1value);
constwidthp->dtypeFrom(nodep->rhsp()); // unsigned
AstCond* const newp = new AstCond{
nodep->fileline(),
new AstGte{nodep->fileline(), constwidthp, nodep->rhsp()->cloneTree(false)},
nodep, constzerop};
AstCond* const newp = new AstCond{nodep->fileline(),
new AstGte{nodep->fileline(), constwidthp,
nodep->rhsp()->cloneTreePure(false)},
nodep, constzerop};
replaceHandle.relink(newp);
}
}
@@ -370,7 +370,7 @@ private:
UINFO(4, "Autoflush " << nodep << endl);
nodep->addNextHere(
new AstFFlush{nodep->fileline(),
nodep->filep() ? nodep->filep()->cloneTree(true) : nullptr});
nodep->filep() ? nodep->filep()->cloneTreePure(true) : nullptr});
}
}
}