Internals: Cleanup some V3LinkParse code; ignore whitespace if diff. No functional change.

This commit is contained in:
Wilson Snyder 2025-09-21 15:30:49 -04:00
parent ad6379b762
commit 9e664a3921
1 changed files with 85 additions and 85 deletions

View File

@ -44,13 +44,14 @@ class LinkParseVisitor final : public VNVisitor {
// TYPES
using ImplTypedefMap = std::map<std::string, AstTypedef*>;
// STATE
AstVar* m_varp = nullptr; // Variable we're under
ImplTypedefMap m_implTypedef; // Created typedefs for each <container,name>
// STATE - across all visitors
std::unordered_set<FileLine*> m_filelines; // Filelines that have been seen
bool m_inAlways = false; // Inside an always
AstNodeModule* m_valueModp
= nullptr; // If set, move AstVar->valuep() initial values to this module
// STATE - for current visit position (use VL_RESTORER)
// If set, move AstVar->valuep() initial values to this module
ImplTypedefMap m_implTypedef; // Created typedefs for each <container,name>
AstVar* m_varp = nullptr; // Variable we're under
AstNodeModule* m_valueModp = nullptr;
AstNodeModule* m_modp = nullptr; // Current module
AstNodeFTask* m_ftaskp = nullptr; // Current task
AstNodeDType* m_dtypep = nullptr; // Current data type
@ -61,14 +62,17 @@ class LinkParseVisitor final : public VNVisitor {
int m_genblkNum = 0; // Begin block number, 0=none seen
int m_beginDepth = 0; // How many begin blocks above current node within current AstNodeModule
VLifetime m_lifetime = VLifetime::STATIC; // Propagating lifetime
bool m_inAlways = false; // Inside an always
bool m_insideLoop = false; // True if the node is inside a loop
bool m_lifetimeAllowed = false; // True to allow lifetime settings
VDouble0 m_statModules; // Number of modules seen
bool m_moduleWithGenericIface = false; // If current module contains generic interface
// STATE - Statistic tracking
VDouble0 m_statModules; // Number of modules seen
// METHODS
void cleanFileline(AstNode* nodep) {
if (!nodep->user2SetOnce()) { // Process once
if (nodep->user2SetOnce()) return; // Process once
// We make all filelines unique per AstNode. This allows us to
// later turn off messages on a fileline when an issue is found
// so that messages on replicated blocks occur only once,
@ -82,7 +86,6 @@ class LinkParseVisitor final : public VNVisitor {
}
m_filelines.insert(nodep->fileline());
}
}
string nameFromTypedef(AstNode* nodep) {
// Try to find a name for a typedef'ed enum/struct
@ -101,13 +104,12 @@ class LinkParseVisitor final : public VNVisitor {
}
void visitIterateNodeDType(AstNodeDType* nodep) {
if (!nodep->user1SetOnce()) { // Process only once.
if (nodep->user1SetOnce()) return; // Process only once.
cleanFileline(nodep);
VL_RESTORER(m_dtypep);
m_dtypep = nodep;
iterateChildren(nodep);
}
}
bool nestedIfBegin(AstBegin* nodep) { // Point at begin inside the GenIf
// IEEE says directly nested item is not a new block
@ -178,7 +180,7 @@ class LinkParseVisitor final : public VNVisitor {
// VISITORS
void visit(AstNodeFTask* nodep) override {
if (!nodep->user1SetOnce()) { // Process only once.
if (nodep->user1SetOnce()) return; // Process only once.
// Mark class methods
if (VN_IS(m_modp, Class)) nodep->classMethod(true);
@ -234,16 +236,14 @@ class LinkParseVisitor final : public VNVisitor {
}
iterateChildren(nodep);
}
}
void visit(AstNodeFTaskRef* nodep) override {
if (!nodep->user1SetOnce()) { // Process only once.
if (nodep->user1SetOnce()) return; // Process only once.
cleanFileline(nodep);
UINFO(5, " " << nodep);
VL_RESTORER(m_valueModp);
m_valueModp = nullptr;
iterateChildren(nodep);
}
}
void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); }
void visit(AstConstraint* nodep) override {
v3Global.useRandomizeMethods(true);
@ -673,7 +673,7 @@ class LinkParseVisitor final : public VNVisitor {
V3Control::applyCoverageBlock(m_modp, nodep);
cleanFileline(nodep);
VL_RESTORER(m_beginDepth);
m_beginDepth++;
++m_beginDepth;
const AstNode* const backp = nodep->backp();
// IEEE says directly nested item is not a new block
// The genblk name will get attached to the if true/false LOWER begin block(s)