mirror of
https://github.com/verilator/verilator.git
synced 2025-04-30 20:46:54 +00:00
Internals: Minor cleanups before class fix (#2654). No functional change intended.
This commit is contained in:
parent
cf09a9b6d2
commit
fd21a41acd
@ -1526,11 +1526,13 @@ void AstVarScope::dump(std::ostream& str) const {
|
||||
str << " ->UNLINKED";
|
||||
}
|
||||
}
|
||||
void AstNodeVarRef::dump(std::ostream& str) const { this->AstNodeMath::dump(str); }
|
||||
void AstVarXRef::dump(std::ostream& str) const {
|
||||
this->AstNodeVarRef::dump(str);
|
||||
void AstNodeVarRef::dump(std::ostream& str) const {
|
||||
this->AstNodeMath::dump(str);
|
||||
if (packagep()) str << " pkg=" << nodeAddr(packagep());
|
||||
str << " " << access().arrow() << " ";
|
||||
}
|
||||
void AstVarXRef::dump(std::ostream& str) const {
|
||||
this->AstNodeVarRef::dump(str);
|
||||
str << ".=" << dotted() << " ";
|
||||
if (inlinedDots() != "") str << " inline.=" << inlinedDots() << " - ";
|
||||
if (varScopep()) {
|
||||
@ -1543,8 +1545,6 @@ void AstVarXRef::dump(std::ostream& str) const {
|
||||
}
|
||||
void AstVarRef::dump(std::ostream& str) const {
|
||||
this->AstNodeVarRef::dump(str);
|
||||
if (packagep()) str << " pkg=" << nodeAddr(packagep());
|
||||
str << " " << access().arrow() << " ";
|
||||
if (varScopep()) {
|
||||
varScopep()->dump(str);
|
||||
} else if (varp()) {
|
||||
|
@ -1256,7 +1256,7 @@ public:
|
||||
AstNodeModule* packagep() const { return m_packagep; }
|
||||
void packagep(AstNodeModule* nodep) { m_packagep = nodep; }
|
||||
AstNode* typeofp() const { return op2p(); }
|
||||
AstNode* classOrPackagep() const { return op3p(); }
|
||||
AstNode* classOrPackageOpp() const { return op3p(); }
|
||||
AstPin* paramsp() const { return VN_CAST(op4p(), Pin); }
|
||||
};
|
||||
|
||||
|
@ -42,8 +42,8 @@ private:
|
||||
AstNodeModule* m_modp; // Current module
|
||||
AstCFunc* m_tlFuncp; // Top level function being built
|
||||
AstCFunc* m_funcp; // Current function
|
||||
int m_numStmts; // Number of statements output
|
||||
int m_funcNum; // Function number being built
|
||||
int m_numStmts = 0; // Number of statements output
|
||||
int m_funcNum = 0; // Function number being built
|
||||
|
||||
public:
|
||||
void add(AstNode* nodep) {
|
||||
@ -76,8 +76,6 @@ public:
|
||||
m_argsp = argsp;
|
||||
m_callargsp = callargsp;
|
||||
m_modp = nodep;
|
||||
m_numStmts = 0;
|
||||
m_funcNum = 0;
|
||||
m_tlFuncp = new AstCFunc(nodep->fileline(), basename, nullptr, "void");
|
||||
m_tlFuncp->declPrivate(true);
|
||||
m_tlFuncp->isStatic(false);
|
||||
|
@ -30,9 +30,8 @@
|
||||
// Note on packagep: After the V3Scope/V3LinkDotScoped stage, package links
|
||||
// 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
|
||||
// here after scoping to allow more dead node
|
||||
// removal.
|
||||
// *************************************************************************
|
||||
// here after scoping to allow more dead node removal.
|
||||
//*************************************************************************
|
||||
|
||||
#include "config_build.h"
|
||||
#include "verilatedos.h"
|
||||
@ -83,7 +82,7 @@ private:
|
||||
typedef std::multimap<AstVarScope*, AstNodeAssign*> AssignMap;
|
||||
|
||||
// STATE
|
||||
AstNodeModule* m_modp; // Current module
|
||||
AstNodeModule* m_modp = nullptr; // Current module
|
||||
// List of all encountered to avoid another loop through tree
|
||||
std::vector<AstVar*> m_varsp;
|
||||
std::vector<AstNode*> m_dtypesp;
|
||||
@ -93,10 +92,10 @@ private:
|
||||
std::vector<AstClass*> m_classesp;
|
||||
|
||||
AssignMap m_assignMap; // List of all simple assignments for each variable
|
||||
bool m_elimUserVars; // Allow removal of user's vars
|
||||
bool m_elimDTypes; // Allow removal of DTypes
|
||||
bool m_elimCells; // Allow removal of Cells
|
||||
bool m_sideEffect; // Side effects discovered in assign RHS
|
||||
const bool m_elimUserVars; // Allow removal of user's vars
|
||||
const bool m_elimDTypes; // Allow removal of DTypes
|
||||
const bool m_elimCells; // Allow removal of Cells
|
||||
bool m_sideEffect = false; // Side effects discovered in assign RHS
|
||||
|
||||
// METHODS
|
||||
VL_DEBUG_FUNC; // Declare debug()
|
||||
@ -438,12 +437,10 @@ private:
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
DeadVisitor(AstNetlist* nodep, bool elimUserVars, bool elimDTypes, bool elimScopes,
|
||||
bool elimCells) {
|
||||
m_modp = nullptr;
|
||||
m_elimCells = elimCells;
|
||||
m_elimUserVars = elimUserVars;
|
||||
m_elimDTypes = elimDTypes;
|
||||
m_sideEffect = false;
|
||||
bool elimCells)
|
||||
: m_elimUserVars{elimUserVars}
|
||||
, m_elimDTypes{elimDTypes}
|
||||
, m_elimCells{elimCells} {
|
||||
// Prepare to remove some datatypes
|
||||
nodep->typeTablep()->clearCache();
|
||||
// Operate on whole netlist
|
||||
|
@ -777,6 +777,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
||||
bool standalonePkg = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package));
|
||||
bool doit = (m_modSymp || standalonePkg);
|
||||
VL_RESTORER(m_scope);
|
||||
VL_RESTORER(m_packagep);
|
||||
VL_RESTORER(m_modSymp);
|
||||
VL_RESTORER(m_curSymp);
|
||||
VL_RESTORER(m_paramNum);
|
||||
@ -833,8 +834,6 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
||||
// Can't remove now, as our backwards iterator will throw up
|
||||
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 {
|
||||
UASSERT_OBJ(m_curSymp, nodep, "Class not under module/package/$unit");
|
||||
@ -2824,7 +2823,7 @@ private:
|
||||
virtual void visit(AstRefDType* nodep) override {
|
||||
// Resolve its reference
|
||||
if (nodep->user3SetOnce()) return;
|
||||
if (AstNode* cpackagep = nodep->classOrPackagep()) {
|
||||
if (AstNode* cpackagep = nodep->classOrPackageOpp()) {
|
||||
if (AstClassOrPackageRef* cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) {
|
||||
if (cpackagerefp->packagep()) {
|
||||
nodep->packagep(cpackagerefp->packagep());
|
||||
|
@ -959,7 +959,7 @@ public:
|
||||
class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
||||
typedef std::map<AstVar*, PackedVarRef, AstNodeComparator> PackedVarRefMap;
|
||||
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
|
||||
// key:variable to be split. value:location where the variable is referenced.
|
||||
PackedVarRefMap m_refs;
|
||||
@ -1207,9 +1207,7 @@ class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
||||
public:
|
||||
// When reusing the information from SplitUnpackedVarVisitor
|
||||
SplitPackedVarVisitor(AstNetlist* nodep, SplitVarRefsMap& refs)
|
||||
: m_netp{nodep}
|
||||
, m_modp{nullptr}
|
||||
, m_numSplit{0} {
|
||||
: m_netp{nodep} {
|
||||
// If you want ignore refs and walk the tne entire AST,
|
||||
// just call iterateChildren(m_modp) and split() for each module
|
||||
for (auto& i : refs) {
|
||||
|
Loading…
Reference in New Issue
Block a user