astgen: Enforce the use of aliased operand accessors (#4688)

This patch enforces the use of the most specific accessors for operands
which have an '@astgen alias' declaration, by making the superclass
accessors of the same operands private. This ensures client code is
cleaner as you can't use multiple different methods to reference the
same operands (which we used to in some places). Also prep for some
refactoring.
This commit is contained in:
Geza Lore
2023-11-12 18:30:48 +00:00
committed by GitHub
parent 1c0af6c7bc
commit 47588f343b
13 changed files with 106 additions and 86 deletions
+5 -5
View File
@@ -216,7 +216,7 @@ private:
if (debug() >= 9) nodep->backp()->dumpTree("- SELBT0: ");
// lhsp/rhsp do not need to be constant
AstNodeExpr* const fromp = nodep->fromp()->unlinkFrBack();
AstNodeExpr* const rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting
AstNodeExpr* const rhsp = nodep->bitp()->unlinkFrBack(); // bit we're extracting
if (debug() >= 9) nodep->dumpTree("- SELBT2: ");
const FromData fromdata = fromDataForArray(nodep, fromp);
AstNodeDType* const ddtypep = fromdata.m_dtypep;
@@ -354,8 +354,8 @@ private:
AstNodeDType* const ddtypep = fromdata.m_dtypep;
const VNumRange fromRange = fromdata.m_fromRange;
if (VN_IS(ddtypep, QueueDType)) {
AstNodeExpr* const qleftp = nodep->rhsp()->unlinkFrBack();
AstNodeExpr* const qrightp = nodep->thsp()->unlinkFrBack();
AstNodeExpr* const qleftp = nodep->leftp()->unlinkFrBack();
AstNodeExpr* const qrightp = nodep->rightp()->unlinkFrBack();
AstNodeExpr* const qleftBacknessp = selQueueBackness(qleftp);
AstNodeExpr* const qrightBacknessp = selQueueBackness(qrightp);
// Use special methods to refer to back rather than math using
@@ -381,8 +381,8 @@ private:
"First value of [a:b] isn't a constant, maybe you want +: or -:");
checkConstantOrReplace(nodep->rightp(),
"Second value of [a:b] isn't a constant, maybe you want +: or -:");
AstNodeExpr* const msbp = nodep->rhsp()->unlinkFrBack();
AstNodeExpr* const lsbp = nodep->thsp()->unlinkFrBack();
AstNodeExpr* const msbp = nodep->leftp()->unlinkFrBack();
AstNodeExpr* const lsbp = nodep->rightp()->unlinkFrBack();
int32_t msb = VN_AS(msbp, Const)->toSInt();
int32_t lsb = VN_AS(lsbp, Const)->toSInt();
const int32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1);