Internals: Minor cleanups before class fix (#2654). No functional change intended.

This commit is contained in:
Wilson Snyder 2020-11-24 21:28:04 -05:00
parent cf09a9b6d2
commit fd21a41acd
6 changed files with 23 additions and 31 deletions

View File

@ -1526,11 +1526,13 @@ void AstVarScope::dump(std::ostream& str) const {
str << " ->UNLINKED"; str << " ->UNLINKED";
} }
} }
void AstNodeVarRef::dump(std::ostream& str) const { this->AstNodeMath::dump(str); } void AstNodeVarRef::dump(std::ostream& str) const {
void AstVarXRef::dump(std::ostream& str) const { this->AstNodeMath::dump(str);
this->AstNodeVarRef::dump(str);
if (packagep()) str << " pkg=" << nodeAddr(packagep()); if (packagep()) str << " pkg=" << nodeAddr(packagep());
str << " " << access().arrow() << " "; str << " " << access().arrow() << " ";
}
void AstVarXRef::dump(std::ostream& str) const {
this->AstNodeVarRef::dump(str);
str << ".=" << dotted() << " "; str << ".=" << dotted() << " ";
if (inlinedDots() != "") str << " inline.=" << inlinedDots() << " - "; if (inlinedDots() != "") str << " inline.=" << inlinedDots() << " - ";
if (varScopep()) { if (varScopep()) {
@ -1543,8 +1545,6 @@ void AstVarXRef::dump(std::ostream& str) const {
} }
void AstVarRef::dump(std::ostream& str) const { void AstVarRef::dump(std::ostream& str) const {
this->AstNodeVarRef::dump(str); this->AstNodeVarRef::dump(str);
if (packagep()) str << " pkg=" << nodeAddr(packagep());
str << " " << access().arrow() << " ";
if (varScopep()) { if (varScopep()) {
varScopep()->dump(str); varScopep()->dump(str);
} else if (varp()) { } else if (varp()) {

View File

@ -1256,7 +1256,7 @@ public:
AstNodeModule* packagep() const { return m_packagep; } AstNodeModule* packagep() const { return m_packagep; }
void packagep(AstNodeModule* nodep) { m_packagep = nodep; } void packagep(AstNodeModule* nodep) { m_packagep = nodep; }
AstNode* typeofp() const { return op2p(); } AstNode* typeofp() const { return op2p(); }
AstNode* classOrPackagep() const { return op3p(); } AstNode* classOrPackageOpp() const { return op3p(); }
AstPin* paramsp() const { return VN_CAST(op4p(), Pin); } AstPin* paramsp() const { return VN_CAST(op4p(), Pin); }
}; };

View File

@ -42,8 +42,8 @@ private:
AstNodeModule* m_modp; // Current module AstNodeModule* m_modp; // Current module
AstCFunc* m_tlFuncp; // Top level function being built AstCFunc* m_tlFuncp; // Top level function being built
AstCFunc* m_funcp; // Current function AstCFunc* m_funcp; // Current function
int m_numStmts; // Number of statements output int m_numStmts = 0; // Number of statements output
int m_funcNum; // Function number being built int m_funcNum = 0; // Function number being built
public: public:
void add(AstNode* nodep) { void add(AstNode* nodep) {
@ -76,8 +76,6 @@ public:
m_argsp = argsp; m_argsp = argsp;
m_callargsp = callargsp; m_callargsp = callargsp;
m_modp = nodep; m_modp = nodep;
m_numStmts = 0;
m_funcNum = 0;
m_tlFuncp = new AstCFunc(nodep->fileline(), basename, nullptr, "void"); m_tlFuncp = new AstCFunc(nodep->fileline(), basename, nullptr, "void");
m_tlFuncp->declPrivate(true); m_tlFuncp->declPrivate(true);
m_tlFuncp->isStatic(false); m_tlFuncp->isStatic(false);

View File

@ -30,9 +30,8 @@
// Note on packagep: After the V3Scope/V3LinkDotScoped stage, package links // Note on packagep: After the V3Scope/V3LinkDotScoped stage, package links
// are no longer used, but their presence prevents us from removing empty // are no longer used, but their presence prevents us from removing empty
// packages. As the links as no longer used after V3Scope, we remove them // packages. As the links as no longer used after V3Scope, we remove them
// here after scoping to allow more dead node // here after scoping to allow more dead node removal.
// removal. //*************************************************************************
// *************************************************************************
#include "config_build.h" #include "config_build.h"
#include "verilatedos.h" #include "verilatedos.h"
@ -83,7 +82,7 @@ private:
typedef std::multimap<AstVarScope*, AstNodeAssign*> AssignMap; typedef std::multimap<AstVarScope*, AstNodeAssign*> AssignMap;
// STATE // STATE
AstNodeModule* m_modp; // Current module AstNodeModule* m_modp = nullptr; // Current module
// List of all encountered to avoid another loop through tree // List of all encountered to avoid another loop through tree
std::vector<AstVar*> m_varsp; std::vector<AstVar*> m_varsp;
std::vector<AstNode*> m_dtypesp; std::vector<AstNode*> m_dtypesp;
@ -93,10 +92,10 @@ private:
std::vector<AstClass*> m_classesp; std::vector<AstClass*> m_classesp;
AssignMap m_assignMap; // List of all simple assignments for each variable AssignMap m_assignMap; // List of all simple assignments for each variable
bool m_elimUserVars; // Allow removal of user's vars const bool m_elimUserVars; // Allow removal of user's vars
bool m_elimDTypes; // Allow removal of DTypes const bool m_elimDTypes; // Allow removal of DTypes
bool m_elimCells; // Allow removal of Cells const bool m_elimCells; // Allow removal of Cells
bool m_sideEffect; // Side effects discovered in assign RHS bool m_sideEffect = false; // Side effects discovered in assign RHS
// METHODS // METHODS
VL_DEBUG_FUNC; // Declare debug() VL_DEBUG_FUNC; // Declare debug()
@ -438,12 +437,10 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes, bool elimScopes, DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes, bool elimScopes,
bool elimCells) { bool elimCells)
m_modp = nullptr; : m_elimUserVars{elimUserVars}
m_elimCells = elimCells; , m_elimDTypes{elimDTypes}
m_elimUserVars = elimUserVars; , m_elimCells{elimCells} {
m_elimDTypes = elimDTypes;
m_sideEffect = false;
// Prepare to remove some datatypes // Prepare to remove some datatypes
nodep->typeTablep()->clearCache(); nodep->typeTablep()->clearCache();
// Operate on whole netlist // Operate on whole netlist

View File

@ -777,6 +777,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
bool standalonePkg = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package)); bool standalonePkg = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package));
bool doit = (m_modSymp || standalonePkg); bool doit = (m_modSymp || standalonePkg);
VL_RESTORER(m_scope); VL_RESTORER(m_scope);
VL_RESTORER(m_packagep);
VL_RESTORER(m_modSymp); VL_RESTORER(m_modSymp);
VL_RESTORER(m_curSymp); VL_RESTORER(m_curSymp);
VL_RESTORER(m_paramNum); VL_RESTORER(m_paramNum);
@ -833,8 +834,6 @@ class LinkDotFindVisitor final : public AstNVisitor {
// Can't remove now, as our backwards iterator will throw up // Can't remove now, as our backwards iterator will throw up
UINFO(5, "Module not under any CELL or top - dead module: " << nodep << endl); UINFO(5, "Module not under any CELL or top - dead module: " << nodep << endl);
} }
// Prep for next
m_packagep = nullptr;
} }
virtual void visit(AstClass* nodep) override { virtual void visit(AstClass* nodep) override {
UASSERT_OBJ(m_curSymp, nodep, "Class not under module/package/$unit"); UASSERT_OBJ(m_curSymp, nodep, "Class not under module/package/$unit");
@ -2824,7 +2823,7 @@ private:
virtual void visit(AstRefDType* nodep) override { virtual void visit(AstRefDType* nodep) override {
// Resolve its reference // Resolve its reference
if (nodep->user3SetOnce()) return; if (nodep->user3SetOnce()) return;
if (AstNode* cpackagep = nodep->classOrPackagep()) { if (AstNode* cpackagep = nodep->classOrPackageOpp()) {
if (AstClassOrPackageRef* cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) { if (AstClassOrPackageRef* cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) {
if (cpackagerefp->packagep()) { if (cpackagerefp->packagep()) {
nodep->packagep(cpackagerefp->packagep()); nodep->packagep(cpackagerefp->packagep());

View File

@ -959,7 +959,7 @@ public:
class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl { class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
typedef std::map<AstVar*, PackedVarRef, AstNodeComparator> PackedVarRefMap; typedef std::map<AstVar*, PackedVarRef, AstNodeComparator> PackedVarRefMap;
AstNetlist* m_netp; AstNetlist* m_netp;
AstNodeModule* m_modp; // Current module (just for log) AstNodeModule* m_modp = nullptr; // Current module (just for log)
int m_numSplit; // Total number of split variables int m_numSplit; // Total number of split variables
// key:variable to be split. value:location where the variable is referenced. // key:variable to be split. value:location where the variable is referenced.
PackedVarRefMap m_refs; PackedVarRefMap m_refs;
@ -1207,9 +1207,7 @@ class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
public: public:
// When reusing the information from SplitUnpackedVarVisitor // When reusing the information from SplitUnpackedVarVisitor
SplitPackedVarVisitor(AstNetlist* nodep, SplitVarRefsMap& refs) SplitPackedVarVisitor(AstNetlist* nodep, SplitVarRefsMap& refs)
: m_netp{nodep} : m_netp{nodep} {
, m_modp{nullptr}
, m_numSplit{0} {
// If you want ignore refs and walk the tne entire AST, // If you want ignore refs and walk the tne entire AST,
// just call iterateChildren(m_modp) and split() for each module // just call iterateChildren(m_modp) and split() for each module
for (auto& i : refs) { for (auto& i : refs) {