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