Internals: Remove dimension and use only dtypes for V3Width.

This commit is contained in:
Wilson Snyder 2013-01-13 15:21:38 -05:00
parent 13bf2f19ac
commit 7a8184d206
3 changed files with 4 additions and 24 deletions

View File

@ -386,20 +386,6 @@ int AstNodeDType::widthPow2() const {
return 1;
}
// Special operators
int AstArraySel::dimension(AstNode* nodep) {
// How many dimensions is this reference from the base variable?
// nodep is typically the fromp() of a select; thus the first select
// is selecting from the entire variable type - effectively dimension 0.
// Dimension passed to AstVar::dtypeDimensionp; see comments there
int dim = 0;
while (nodep) {
if (nodep->castNodeSel()) { dim++; nodep=nodep->castNodeSel()->fromp(); continue; }
if (nodep->castNodePreSel()) { dim++; nodep=nodep->castNodePreSel()->fromp(); continue; }
break;
}
return dim;
}
AstNode* AstArraySel::baseFromp(AstNode* nodep) { ///< What is the base variable (or const) this dereferences?
// Else AstArraySel etc; search for the base
while (nodep) {

View File

@ -650,7 +650,6 @@ public:
void start(unsigned start) { m_start = start; }
unsigned start() const { return m_start; }
// Special operators
static int dimension(AstNode* nodep); ///< How many dimensions is this reference from the base variable?
static AstNode* baseFromp(AstNode* nodep); ///< What is the base variable (or const) this dereferences?
virtual void dump(ostream& str);
};

View File

@ -504,15 +504,11 @@ private:
checkCvtUS(nodep->bitp());
//
nodep->fromp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,PRELIM).p());
AstNode* basefromp = AstArraySel::baseFromp(nodep->fromp());
int dimension = AstArraySel::dimension(nodep->fromp());
AstNodeVarRef* varrp = basefromp->castNodeVarRef();
if (!varrp) nodep->v3fatalSrc("No VarRef found under ArraySel(s)");
//
int frommsb;
int fromlsb;
AstNodeDType* ddtypep = varrp->varp()->dtypep()->dtypeDimensionp(dimension);
if (AstNodeArrayDType* adtypep = ddtypep->castNodeArrayDType()) {
AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefp();
if (AstNodeArrayDType* adtypep = fromDtp->castNodeArrayDType()) {
frommsb = adtypep->msb();
fromlsb = adtypep->lsb();
if (fromlsb>frommsb) {int t=frommsb; frommsb=fromlsb; fromlsb=t; }
@ -521,9 +517,8 @@ private:
nodep->dtypeFrom(adtypep->subDTypep()); // Need to strip off array reference
}
else {
UINFO(1," Related var dtypep: "<<varrp->varp()->dtypep()<<endl);
UINFO(1," Related ddtypep: "<<ddtypep<<endl);
UINFO(1," Related dimension: "<<dimension<<endl);
// Note PackArrayDType doesn't use an ArraySel but a normal Sel.
UINFO(1," Related dtype: "<<fromDtp<<endl);
nodep->v3fatalSrc("Array reference exceeds dimension of array");
frommsb = fromlsb = 0;
}