Internals: Add more const. No functional change intended.

This commit is contained in:
Wilson Snyder
2021-11-13 13:50:44 -05:00
parent 4cb5c1e1db
commit 37e3c6da70
85 changed files with 1172 additions and 1115 deletions
+11 -10
View File
@@ -61,7 +61,8 @@ class SliceVisitor final : public AstNVisitor {
AstNode* cloneAndSel(AstNode* nodep, int elements, int offset) {
// Insert an ArraySel, except for a few special cases
AstUnpackArrayDType* arrayp = VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType);
const AstUnpackArrayDType* const arrayp
= VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType);
if (!arrayp) { // V3Width should have complained, but...
if (!m_assignError) {
nodep->v3error(
@@ -84,7 +85,7 @@ class SliceVisitor final : public AstNVisitor {
offset = 0;
}
AstNode* newp;
if (AstInitArray* initp = VN_CAST(nodep, InitArray)) {
if (const AstInitArray* const initp = VN_CAST(nodep, InitArray)) {
UINFO(9, " cloneInitArray(" << elements << "," << offset << ") " << nodep << endl);
const int leOffset = !arrayp->rangep()->littleEndian()
? arrayp->rangep()->elementsConst() - 1 - offset
@@ -132,17 +133,17 @@ class SliceVisitor final : public AstNVisitor {
nodep->user1(true);
m_assignError = false;
if (debug() >= 9) nodep->dumpTree(cout, " Deslice-In: ");
AstNodeDType* dtp = nodep->lhsp()->dtypep()->skipRefp();
if (AstUnpackArrayDType* arrayp = VN_CAST(dtp, UnpackArrayDType)) {
AstNodeDType* const dtp = nodep->lhsp()->dtypep()->skipRefp();
if (const AstUnpackArrayDType* const arrayp = VN_CAST(dtp, UnpackArrayDType)) {
// Left and right could have different msb/lsbs/endianness, but #elements is common
// and all variables are realigned to start at zero
// Assign of a little endian'ed slice to a big endian one must reverse the elements
AstNode* newlistp = nullptr;
const int elements = arrayp->rangep()->elementsConst();
for (int offset = 0; offset < elements; ++offset) {
AstNode* newp = nodep->cloneType // AstNodeAssign
(cloneAndSel(nodep->lhsp(), elements, offset),
cloneAndSel(nodep->rhsp(), elements, offset));
AstNode* const newp = nodep->cloneType // AstNodeAssign
(cloneAndSel(nodep->lhsp(), elements, offset),
cloneAndSel(nodep->rhsp(), elements, offset));
if (debug() >= 9) newp->dumpTree(cout, "-new ");
newlistp = AstNode::addNextNull(newlistp, newp);
}
@@ -167,9 +168,9 @@ class SliceVisitor final : public AstNVisitor {
if (!nodep->user1()) {
nodep->user1(true);
// If it's an unpacked array, blow it up into comparing each element
AstNodeDType* fromDtp = nodep->lhsp()->dtypep()->skipRefp();
AstNodeDType* const fromDtp = nodep->lhsp()->dtypep()->skipRefp();
UINFO(9, " Bi-Eq/Neq expansion " << nodep << endl);
if (AstUnpackArrayDType* adtypep = VN_CAST(fromDtp, UnpackArrayDType)) {
if (const AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType)) {
AstNodeBiop* logp = nullptr;
if (!VN_IS(nodep->lhsp()->dtypep()->skipRefp(), NodeArrayDType)) {
nodep->lhsp()->v3error(
@@ -184,7 +185,7 @@ class SliceVisitor final : public AstNVisitor {
} else {
for (int index = 0; index < adtypep->rangep()->elementsConst(); ++index) {
// EQ(a,b) -> LOGAND(EQ(ARRAYSEL(a,0), ARRAYSEL(b,0)), ...[1])
AstNodeBiop* clonep
AstNodeBiop* const clonep
= VN_AS(nodep->cloneType(
new AstArraySel(nodep->fileline(),
nodep->lhsp()->cloneTree(false), index),