Internals: More const. No functional change intended.

This commit is contained in:
Wilson Snyder
2021-11-26 17:55:36 -05:00
parent 010084201a
commit cd737065f2
110 changed files with 1917 additions and 1836 deletions
+23 -23
View File
@@ -121,7 +121,7 @@ private:
m_modp->addStmtp(varp);
AstNode* const abovep = prep->backp(); // Grab above point before we replace 'prep'
prep->replaceWith(new AstVarRef(fl, varp, VAccess::WRITE));
AstIf* newp = new AstIf(
AstIf* const newp = new AstIf(
fl, condp,
(needDly ? static_cast<AstNode*>(
new AstAssignDly(fl, prep, new AstVarRef(fl, varp, VAccess::READ)))
@@ -188,8 +188,8 @@ private:
VL_DO_DANGLING(V3Const::constifyEdit(nodep), nodep);
return;
} else {
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* const lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* const rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* newp;
// If we got ==1'bx it can never be true (but 1'bx==1'bx can be!)
if (((VN_IS(lhsp, Const) && VN_AS(lhsp, Const)->num().isFourState())
@@ -220,8 +220,8 @@ private:
VL_DO_DANGLING(V3Const::constifyEdit(nodep), nodep);
return;
} else {
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* const lhsp = nodep->lhsp()->unlinkFrBack();
AstNode* const rhsp = nodep->rhsp()->unlinkFrBack();
AstNode* newp;
if (!VN_IS(rhsp, Const)) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: RHS of ==? or !=? must be "
@@ -234,9 +234,9 @@ private:
nummask.opBitsNonX(VN_AS(rhsp, Const)->num());
V3Number numval(rhsp, rhsp->width());
numval.opBitsOne(VN_AS(rhsp, Const)->num());
AstNode* and1p = new AstAnd(nodep->fileline(), lhsp,
new AstConst(nodep->fileline(), nummask));
AstNode* and2p = new AstConst(nodep->fileline(), numval);
AstNode* const and1p = new AstAnd(nodep->fileline(), lhsp,
new AstConst(nodep->fileline(), nummask));
AstNode* const and2p = new AstConst(nodep->fileline(), numval);
if (VN_IS(nodep, EqWild)) {
newp = new AstEq(nodep->fileline(), and1p, and2p);
} else {
@@ -259,7 +259,7 @@ private:
iterateChildren(nodep);
// Ahh, we're two state, so this is easy
UINFO(4, " ISUNKNOWN->0 " << nodep << endl);
AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse());
AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse());
nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep);
}
@@ -280,7 +280,7 @@ private:
nonXp = nodep->fhsp();
else { // Was all X-s
UINFO(4, " COUNTBITS('x)->0 " << nodep << endl);
AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse());
AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse());
nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep);
return;
@@ -318,7 +318,7 @@ private:
} else {
numnew.opAssign(numb1);
}
AstConst* newp = new AstConst(nodep->fileline(), numnew);
AstConst* const newp = new AstConst(nodep->fileline(), numnew);
nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep);
UINFO(4, " -> " << newp << endl);
@@ -363,9 +363,9 @@ private:
iterateChildren(nodep);
if (!nodep->user1SetOnce()) {
// Guard against reading/writing past end of bit vector array
const AstNode* basefromp = AstArraySel::baseFromp(nodep, true);
const AstNode* const basefromp = AstArraySel::baseFromp(nodep, true);
bool lvalue = false;
if (const AstNodeVarRef* varrefp = VN_CAST(basefromp, NodeVarRef)) {
if (const AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) {
lvalue = varrefp->access().isWriteOrRW();
}
// Find range of dtype we are selecting from
@@ -390,8 +390,8 @@ private:
nodep->unlinkFrBack(&replaceHandle);
V3Number xnum(nodep, nodep->width());
xnum.setAllBitsX();
AstNode* newp = new AstCondBound(nodep->fileline(), condp, nodep,
new AstConst(nodep->fileline(), xnum));
AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep,
new AstConst(nodep->fileline(), xnum));
if (debug() >= 9) newp->dumpTree(cout, " _new: ");
// Link in conditional
replaceHandle.relink(newp);
@@ -411,9 +411,9 @@ private:
if (!nodep->user1SetOnce()) {
if (debug() == 9) nodep->dumpTree(cout, "-in: ");
// Guard against reading/writing past end of arrays
AstNode* basefromp = AstArraySel::baseFromp(nodep->fromp(), true);
AstNode* const basefromp = AstArraySel::baseFromp(nodep->fromp(), true);
bool lvalue = false;
if (const AstNodeVarRef* varrefp = VN_CAST(basefromp, NodeVarRef)) {
if (const AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) {
lvalue = varrefp->access().isWriteOrRW();
} else if (VN_IS(basefromp, Const)) {
// If it's a PARAMETER[bit], then basefromp may be a constant instead of a varrefp
@@ -422,9 +422,9 @@ private:
}
// Find range of dtype we are selecting from
int declElements = -1;
AstNodeDType* dtypep = nodep->fromp()->dtypep()->skipRefp();
AstNodeDType* const dtypep = nodep->fromp()->dtypep()->skipRefp();
UASSERT_OBJ(dtypep, nodep, "Select of non-selectable type");
if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) {
if (const AstNodeArrayDType* const adtypep = VN_CAST(dtypep, NodeArrayDType)) {
declElements = adtypep->elementsConst();
} else {
nodep->v3error("Select from non-array " << dtypep->prettyTypeName());
@@ -453,8 +453,8 @@ private:
} else {
xnum.setAllBitsX();
}
AstNode* newp = new AstCondBound(nodep->fileline(), condp, nodep,
new AstConst(nodep->fileline(), xnum));
AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep,
new AstConst(nodep->fileline(), xnum));
if (debug() >= 9) newp->dumpTree(cout, " _new: ");
// Link in conditional, can blow away temp xor
replaceHandle.relink(newp);
@@ -463,8 +463,8 @@ private:
} else if (!lvalue) { // Mid-multidimension read, just use zero
// ARRAYSEL(...) -> ARRAYSEL(COND(LT(bit<maxbit), bit, 0))
AstNRelinker replaceHandle;
AstNode* bitp = nodep->bitp()->unlinkFrBack(&replaceHandle);
AstNode* newp = new AstCondBound(
AstNode* const bitp = nodep->bitp()->unlinkFrBack(&replaceHandle);
AstNode* const newp = new AstCondBound(
bitp->fileline(), condp, bitp,
new AstConst(bitp->fileline(), AstConst::WidthedValue(), bitp->width(), 0));
// Added X's, tristate them too