From de4016dcfff28ec49713923ee2d378c39aeff529 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 17 Jan 2013 20:41:45 -0500 Subject: [PATCH] Internals: Ast classes create declRange(). --- src/V3Ast.h | 3 +++ src/V3AstNodes.cpp | 4 ++-- src/V3AstNodes.h | 1 + src/V3WidthSel.cpp | 12 +++--------- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 097eef043..80ffb678f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1559,6 +1559,7 @@ public: } int lsb() const { return 0; } int msb() const { return dtypep()->width()-1; } // Packed classes look like arrays + VNumRange declRange() const { return VNumRange(msb(), lsb(), false); } }; struct AstNodeArrayDType : public AstNodeDType { @@ -1601,6 +1602,7 @@ public: int msb() const; int lsb() const; int elementsConst() const; + VNumRange declRange() const; }; struct AstNodeSel : public AstNodeBiop { @@ -1802,5 +1804,6 @@ inline void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); } inline int AstNodeArrayDType::msb() const { return rangep()->msbConst(); } inline int AstNodeArrayDType::lsb() const { return rangep()->lsbConst(); } inline int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); } +inline VNumRange AstNodeArrayDType::declRange() const { return VNumRange(msb(), lsb(), rangep()->littleEndian()); } #endif // Guard diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index b110e5749..f3008e082 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -746,11 +746,11 @@ void AstNodeDType::dumpSmall(ostream& str) { void AstNodeArrayDType::dumpSmall(ostream& str) { this->AstNodeDType::dumpSmall(str); if (castPackArrayDType()) str<<"p"; else str<<"u"; - str<<"["<AstNodeDType::dump(str); - str<<" ["<AstNode::dump(str); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index b839ce3b5..8155a7bbb 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -374,6 +374,7 @@ public: int right() const { return littleEndian()?msb():lsb(); } bool littleEndian() const { return (rangep() ? rangep()->littleEndian() : m.m_nrange.littleEndian()); } bool implicit() const { return keyword() == AstBasicDTypeKwd::LOGIC_IMPLICIT; } + VNumRange declRange() const { return isRanged() ? VNumRange(msb(), lsb(), littleEndian()) : VNumRange(); } void cvtRangeConst() { // Convert to smaller represenation if (rangep() && rangep()->msbp()->castConst() && rangep()->lsbp()->castConst()) { m.m_nrange.init(rangep()->msbConst(), rangep()->lsbConst(), diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index cc42af826..56dc57067 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -94,14 +94,10 @@ private: AstNode* errp = ddtypep; UINFO(9," fromData.ddtypep = "<castNodeArrayDType()) { - fromRange.init(adtypep->msb(), - adtypep->lsb(), - adtypep->rangep()->littleEndian()); + fromRange = adtypep->declRange(); } else if (AstNodeClassDType* adtypep = ddtypep->castNodeClassDType()) { - fromRange.init(adtypep->msb(), - adtypep->lsb(), - false); // big endian + fromRange = adtypep->declRange(); } else if (AstBasicDType* adtypep = ddtypep->castBasicDType()) { if (adtypep->isRanged()) { @@ -109,9 +105,7 @@ private: && (!adtypep->rangep()->msbp()->castConst() || !adtypep->rangep()->lsbp()->castConst())) nodep->v3fatalSrc("Non-constant variable range; errored earlier"); // in constifyParam(bfdtypep) - fromRange.init(adtypep->msb(), - adtypep->lsb(), - adtypep->littleEndian()); + fromRange = adtypep->declRange(); } else { nodep->v3error("Illegal bit or array select; type does not have a bit range, or bad dimension: type is " <prettyName());