Internals: Make consistent left/right/lo/hi accessors to ranges.

Change order of Range to store always left:right.
XML output changes to now show left:right (previously info was lost), no other change intended.
This commit is contained in:
Wilson Snyder
2020-12-06 21:13:56 -05:00
parent b32d530000
commit cd248f6bd7
16 changed files with 177 additions and 206 deletions
+9 -9
View File
@@ -96,8 +96,8 @@ private:
} else if (adtypep->isRanged()) {
UASSERT_OBJ(
!(adtypep->rangep()
&& (!VN_IS(adtypep->rangep()->msbp(), Const)
|| !VN_IS(adtypep->rangep()->lsbp(), Const))),
&& (!VN_IS(adtypep->rangep()->leftp(), Const)
|| !VN_IS(adtypep->rangep()->rightp(), Const))),
nodep,
"Non-constant variable range; errored earlier"); // in constifyParam(bfdtypep)
fromRange = adtypep->declRange();
@@ -324,12 +324,12 @@ private:
UINFO(6, "SELEXTRACT " << nodep << endl);
// if (debug() >= 9) nodep->dumpTree(cout, "--SELEX0: ");
// Below 2 lines may change nodep->widthp()
V3Const::constifyParamsEdit(nodep->lsbp()); // May relink pointed to node
V3Const::constifyParamsEdit(nodep->msbp()); // May relink pointed to node
V3Const::constifyParamsEdit(nodep->leftp()); // May relink pointed to node
V3Const::constifyParamsEdit(nodep->rightp()); // May relink pointed to node
// if (debug() >= 9) nodep->dumpTree(cout, "--SELEX3: ");
checkConstantOrReplace(nodep->lsbp(),
checkConstantOrReplace(nodep->leftp(),
"First value of [a:b] isn't a constant, maybe you want +: or -:");
checkConstantOrReplace(nodep->msbp(),
checkConstantOrReplace(nodep->rightp(),
"Second value of [a:b] isn't a constant, maybe you want +: or -:");
AstNode* fromp = nodep->lhsp()->unlinkFrBack();
AstNode* msbp = nodep->rhsp()->unlinkFrBack();
@@ -351,9 +351,9 @@ private:
nodep->replaceWith(newp);
VL_DO_DANGLING(pushDeletep(nodep), nodep);
} else { // Slice
AstSliceSel* newp = new AstSliceSel(
nodep->fileline(), fromp,
VNumRange(VNumRange::LeftRight(), msb - fromRange.lo(), lsb - fromRange.lo()));
AstSliceSel* newp
= new AstSliceSel{nodep->fileline(), fromp,
VNumRange{msb - fromRange.lo(), lsb - fromRange.lo()}};
nodep->replaceWith(newp);
VL_DO_DANGLING(pushDeletep(nodep), nodep);
}