From 53c6b7df63baa76fa1df2e89f690b645ba9a8252 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 16 Dec 2019 22:46:09 -0500 Subject: [PATCH] Internals: Rename NodeClassDType. No functional change. --- src/V3Ast.h | 7 ++++--- src/V3AstNodes.cpp | 12 ++++++------ src/V3AstNodes.h | 10 +++++----- src/V3Changed.cpp | 2 +- src/V3Dead.cpp | 4 ++-- src/V3EmitV.cpp | 2 +- src/V3LinkParse.cpp | 2 +- src/V3ParseImp.h | 2 +- src/V3TraceDecl.cpp | 2 +- src/V3Width.cpp | 17 +++++++++-------- src/V3WidthCommit.h | 2 +- src/V3WidthSel.cpp | 10 +++++----- src/verilog.y | 10 +++++----- 13 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 72cd16bab..5206ef0bb 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1949,7 +1949,8 @@ public: const char* charIQWN() const { return (isString() ? "N" : isWide() ? "W" : isQuad() ? "Q" : "I"); } }; -class AstNodeClassDType : public AstNodeDType { +class AstNodeUOrStructDType : public AstNodeDType { + // A struct or union; common handling private: // TYPES typedef std::map MemberNameMap; @@ -1959,14 +1960,14 @@ private: bool m_isFourstate; MemberNameMap m_members; public: - AstNodeClassDType(FileLine* fl, AstNumeric numericUnpack) + AstNodeUOrStructDType(FileLine* fl, AstNumeric numericUnpack) : AstNodeDType(fl) { // AstNumeric::NOSIGN overloaded to indicate not packed m_packed = (numericUnpack != AstNumeric::NOSIGN); m_isFourstate = false; // V3Width computes numeric(AstNumeric::fromBool(numericUnpack.isSigned())); } - ASTNODE_BASE_FUNCS(NodeClassDType) + ASTNODE_BASE_FUNCS(NodeUOrStructDType) virtual const char* broken() const; virtual void dump(std::ostream& str) const; // For basicp() we reuse the size to indicate a "fake" basic type of same size diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 545480008..e95e2e53e 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -65,7 +65,7 @@ int AstNodeSel::bitConst() const { return (constp ? constp->toSInt() : 0); } -void AstNodeClassDType::repairMemberCache() { +void AstNodeUOrStructDType::repairMemberCache() { clearCache(); for (AstMemberDType* itemp = membersp(); itemp; itemp=VN_CAST(itemp->nextp(), MemberDType)) { if (m_members.find(itemp->name())!=m_members.end()) { @@ -74,7 +74,7 @@ void AstNodeClassDType::repairMemberCache() { } } -const char* AstNodeClassDType::broken() const { +const char* AstNodeUOrStructDType::broken() const { vl_unordered_set exists; for (AstMemberDType* itemp = membersp(); itemp; itemp=VN_CAST(itemp->nextp(), MemberDType)) { exists.insert(itemp); @@ -107,14 +107,14 @@ int AstBasicDType::widthTotalBytes() const { else return widthWords() * (VL_EDATASIZE / 8); } -int AstNodeClassDType::widthTotalBytes() const { +int AstNodeUOrStructDType::widthTotalBytes() const { if (width()<=8) return 1; else if (width()<=16) return 2; else if (isQuad()) return 8; else return widthWords() * (VL_EDATASIZE / 8); } -int AstNodeClassDType::widthAlignBytes() const { +int AstNodeUOrStructDType::widthAlignBytes() const { // Could do max across members but that would be slow, // instead intuit based on total structure size if (width()<=8) return 1; @@ -580,7 +580,7 @@ AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) { } return NULL; } - else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) { + else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { if (adtypep->packed()) { if ((dim++) == dimension) { return adtypep; @@ -1030,7 +1030,7 @@ void AstRefDType::dump(std::ostream& str) const { } else { str<<" -> UNLINKED"; } } -void AstNodeClassDType::dump(std::ostream& str) const { +void AstNodeUOrStructDType::dump(std::ostream& str) const { this->AstNode::dump(str); if (packed()) str<<" [PACKED]"; if (isFourstate()) str<<" [4STATE]"; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 57142ca97..69fcab625 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -842,26 +842,26 @@ public: void packagep(AstPackage* nodep) { m_packagep = nodep; } }; -class AstStructDType : public AstNodeClassDType { +class AstStructDType : public AstNodeUOrStructDType { public: AstStructDType(FileLine* fl, AstNumeric numericUnpack) - : AstNodeClassDType(fl, numericUnpack) {} + : AstNodeUOrStructDType(fl, numericUnpack) {} ASTNODE_NODE_FUNCS(StructDType) virtual string verilogKwd() const { return "struct"; } }; -class AstUnionDType : public AstNodeClassDType { +class AstUnionDType : public AstNodeUOrStructDType { public: //UNSUP: bool isTagged; AstUnionDType(FileLine* fl, AstNumeric numericUnpack) - : AstNodeClassDType(fl, numericUnpack) {} + : AstNodeUOrStructDType(fl, numericUnpack) {} ASTNODE_NODE_FUNCS(UnionDType) virtual string verilogKwd() const { return "union"; } }; class AstMemberDType : public AstNodeDType { // A member of a struct/union - // PARENT: AstNodeClassDType + // PARENT: AstNodeUOrStructDType private: AstNodeDType* m_refDTypep; // Elements of this type (after widthing) string m_name; // Name of variable diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index f426847de..665677cf7 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -175,7 +175,7 @@ private: m_newRvEqnp = origNREp; } } - virtual void visit(AstNodeClassDType* nodep) { + virtual void visit(AstNodeUOrStructDType* nodep) { if (nodep->packedUnsup()) { newChangeDet(); } else { diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index d34b80221..1cd44de2c 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -373,11 +373,11 @@ private: } for (std::vector::iterator it = m_dtypesp.begin(); it != m_dtypesp.end();++it) { if ((*it)->user1() == 0) { - AstNodeClassDType *classp; + AstNodeUOrStructDType *classp; // It's possible that there if a reference to each individual member, but // not to the dtype itself. Check and don't remove the parent dtype if // members are still alive. - if ((classp = VN_CAST((*it), NodeClassDType))) { + if ((classp = VN_CAST((*it), NodeUOrStructDType))) { bool cont = true; for (AstMemberDType *memberp = classp->membersp(); memberp; memberp = VN_CAST(memberp->nextp(), MemberDType)) { diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index e2d6dd909..21ca8594d 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -542,7 +542,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor { iterate(nodep->subDTypep()); iterateAndNextNull(nodep->rangep()); } - virtual void visit(AstNodeClassDType* nodep) { + virtual void visit(AstNodeUOrStructDType* nodep) { puts(nodep->verilogKwd()+" "); if (nodep->packed()) puts("packed "); puts("\n"); diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 72f83f0f0..2ca7674cc 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -132,7 +132,7 @@ private: } visitIterateNodeDType(nodep); } - virtual void visit(AstNodeClassDType* nodep) { + virtual void visit(AstNodeUOrStructDType* nodep) { if (nodep->name() == "") { nodep->name(nameFromTypedef(nodep)); // Might still remain "" } diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index b5c73003e..73c691bf2 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -73,7 +73,7 @@ struct V3ParseBisonYYSType { AstConst* constp; AstMemberDType* memberp; AstNodeModule* modulep; - AstNodeClassDType* classp; + AstNodeUOrStructDType* uorstructp; AstNodeDType* dtypep; AstNodeFTask* ftaskp; AstNodeFTaskRef* ftaskrefp; diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 3db115a91..b9a780c7d 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -306,7 +306,7 @@ private: } } } - virtual void visit(AstNodeClassDType* nodep) { + virtual void visit(AstNodeUOrStructDType* nodep) { if (m_traVscp) { if (nodep->packed() && !v3Global.opt.traceStructs()) { // Everything downstream is packed, so deal with as one trace unit diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 35d5b6856..c8981902d 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1374,7 +1374,7 @@ private: } else if (nodep->isIO() && !(VN_IS(nodep->dtypeSkipRefp(), BasicDType) || VN_IS(nodep->dtypeSkipRefp(), NodeArrayDType) - || VN_IS(nodep->dtypeSkipRefp(), NodeClassDType))) { + || VN_IS(nodep->dtypeSkipRefp(), NodeUOrStructDType))) { nodep->v3error("Unsupported: Inputs and outputs must be simple data types"); } if (VN_IS(nodep->dtypep()->skipRefToConstp(), ConstDType)) { @@ -1647,7 +1647,7 @@ private: nodep->widthForce(1, 1); // Not really relevant UINFO(4,"dtWidthed "<didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed UINFO(5," NODECLASS "<=9) nodep->dumpTree("-class-in--"); @@ -1697,7 +1697,7 @@ private: AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); UINFO(9," from dt "<findMember(nodep->name()); if (!memberp) { @@ -2255,8 +2255,8 @@ private: while (const AstConstDType* vdtypep = VN_CAST(dtypep, ConstDType)) { dtypep = vdtypep->subDTypep()->skipRefp(); } - if (AstNodeClassDType* vdtypep = VN_CAST(dtypep, NodeClassDType)) { - patternClass(nodep, vdtypep, defaultp); VL_DANGLING(nodep); + if (AstNodeUOrStructDType* vdtypep = VN_CAST(dtypep, NodeUOrStructDType)) { + patternUOrStruct(nodep, vdtypep, defaultp); VL_DANGLING(nodep); } else if (AstNodeArrayDType* vdtypep = VN_CAST(dtypep, NodeArrayDType)) { patternArray(nodep, vdtypep, defaultp); VL_DANGLING(nodep); @@ -2270,7 +2270,8 @@ private: } } } - void patternClass(AstPattern* nodep, AstNodeClassDType* vdtypep, AstPatMember* defaultp) { + void patternUOrStruct(AstPattern* nodep, AstNodeUOrStructDType* vdtypep, + AstPatMember* defaultp) { // Due to "default" and tagged patterns, we need to determine // which member each AstPatMember corresponds to before we can // determine the dtypep for that PatMember's value, and then @@ -4336,7 +4337,7 @@ private: declRange = adtypep->declRange(); if (isubDTypep()->skipRefp(); continue; - } else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) { + } else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { declRange = adtypep->declRange(); if (adtypep) {} // UNUSED break; // Sub elements don't look like arrays and can't iterate into @@ -4357,7 +4358,7 @@ private: bits *= adtypep->declRange().elements(); dtypep = adtypep->subDTypep()->skipRefp(); continue; - } else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) { + } else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { bits *= adtypep->width(); break; } else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) { diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index c92170cca..147e4737e 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -129,7 +129,7 @@ private: virtual void visit(AstNodeDType* nodep) { visitIterateNodeDType(nodep); } - virtual void visit(AstNodeClassDType* nodep) { + virtual void visit(AstNodeUOrStructDType* nodep) { if (nodep->user1SetOnce()) return; // Process once visitIterateNodeDType(nodep); nodep->clearCache(); diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 233c6b27f..8f8f7dd9d 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -95,7 +95,7 @@ private: } else if (const AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) { } - else if (const AstNodeClassDType* adtypep = VN_CAST(ddtypep, NodeClassDType)) { + else if (const AstNodeUOrStructDType* adtypep = VN_CAST(ddtypep, NodeUOrStructDType)) { fromRange = adtypep->declRange(); } else if (AstBasicDType* adtypep = VN_CAST(ddtypep, BasicDType)) { @@ -280,7 +280,7 @@ private: if (debug()>=9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } - else if (VN_IS(ddtypep, NodeClassDType)) { // It's packed, so a bit from the packed struct + else if (VN_IS(ddtypep, NodeUOrStructDType)) { // A bit from the packed struct // SELBIT(range, index) -> SEL(array, index, 1) AstSel* newp = new AstSel(nodep->fileline(), fromp, @@ -389,7 +389,7 @@ private: //if (debug()>=9) newp->dumpTree(cout, "--SELEXnew: "); nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep); } - else if (VN_IS(ddtypep, NodeClassDType)) { + else if (VN_IS(ddtypep, NodeUOrStructDType)) { // Classes aren't little endian if (lsb > msb) { nodep->v3error("["<packedUnsup())) { + || (VN_IS(ddtypep, NodeUOrStructDType) + && VN_CAST(ddtypep, NodeUOrStructDType)->packedUnsup())) { int elwidth = 1; AstNode* newwidthp = widthp; if (const AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) { diff --git a/src/verilog.y b/src/verilog.y index 9ac2862f2..c1e828a22 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1521,14 +1521,14 @@ var_data_type: // ==IEEE: var_data_type | yVAR implicit_typeE { $$ = $2; } ; -struct_unionDecl: // IEEE: part of data_type +struct_unionDecl: // IEEE: part of data_type // // packedSigningE is NOP for unpacked - ySTRUCT packedSigningE '{' { $$ = new AstStructDType($1, $2); SYMP->pushNew($$); } + ySTRUCT packedSigningE '{' { $$ = new AstStructDType($1, $2); SYMP->pushNew($$); } /*cont*/ struct_union_memberList '}' - { $$=$4; $$->addMembersp($5); SYMP->popScope($$); } - | yUNION taggedE packedSigningE '{' { $$ = new AstUnionDType($1, $3); SYMP->pushNew($$); } + { $$=$4; $$->addMembersp($5); SYMP->popScope($$); } + | yUNION taggedE packedSigningE '{' { $$ = new AstUnionDType($1, $3); SYMP->pushNew($$); } /*cont*/ struct_union_memberList '}' - { $$=$5; $$->addMembersp($6); SYMP->popScope($$); } + { $$=$5; $$->addMembersp($6); SYMP->popScope($$); } ; struct_union_memberList: // IEEE: { struct_union_member }