Internals: Cleanup style of coverage visitors. No functional change. Ignore whitespace if diff.

This commit is contained in:
Wilson Snyder 2024-10-09 18:12:55 -04:00
parent 6d936654ba
commit f98637e122
2 changed files with 57 additions and 64 deletions

View File

@ -65,22 +65,24 @@ class CoverageVisitor final : public VNVisitor {
&& v3Global.opt.coverageLine();
}
};
int m_nextHandle = 0;
// NODE STATE
// Entire netlist:
// AstIf::user1() -> bool. True indicates ifelse processed
const VNUser1InUse m_inuser1;
// STATE
// STATE - across all visitors
int m_nextHandle = 0;
// STATE - for current visit position (use VL_RESTORER)
CheckState m_state; // State save-restored on each new coverage scope/block
AstNodeModule* m_modp = nullptr; // Current module to add statement to
bool m_inToggleOff = false; // In function/task etc
// Uniquification of inserted variable names
std::unordered_map<std::string, uint32_t> m_varnames;
string m_beginHier; // AstBegin hier name for user coverage points
std::unordered_map<int, LinenoSet>
m_handleLines; // All line numbers for a given m_stateHandle
// STATE - cleared each module
std::unordered_map<std::string, uint32_t> m_varnames; // Uniquify inserted variable names
std::unordered_map<int, LinenoSet> m_handleLines; // Line numbers for given m_stateHandle
// METHODS
@ -207,7 +209,6 @@ class CoverageVisitor final : public VNVisitor {
const AstNodeModule* const origModp = m_modp;
VL_RESTORER(m_modp);
VL_RESTORER(m_state);
{
createHandle(nodep);
m_modp = nodep;
m_state.m_inModOff
@ -219,7 +220,6 @@ class CoverageVisitor final : public VNVisitor {
}
iterateChildren(nodep);
}
}
void visit(AstNodeProcedure* nodep) override { iterateProcedure(nodep); }
void visit(AstWhile* nodep) override { iterateProcedure(nodep); }
@ -229,15 +229,14 @@ class CoverageVisitor final : public VNVisitor {
void iterateProcedure(AstNode* nodep) {
VL_RESTORER(m_state);
VL_RESTORER(m_inToggleOff);
{
m_inToggleOff = true;
createHandle(nodep);
iterateChildren(nodep);
if (m_state.lineCoverageOn(nodep)) {
lineTrack(nodep);
AstNode* const newp
= newCoverInc(nodep->fileline(), "", "v_line", "block",
linesCov(m_state, nodep), 0, traceNameForLine(nodep, "block"));
= newCoverInc(nodep->fileline(), "", "v_line", "block", linesCov(m_state, nodep),
0, traceNameForLine(nodep, "block"));
if (AstNodeProcedure* const itemp = VN_CAST(nodep, NodeProcedure)) {
itemp->addStmtsp(newp);
} else if (AstNodeFTask* const itemp = VN_CAST(nodep, NodeFTask)) {
@ -249,7 +248,6 @@ class CoverageVisitor final : public VNVisitor {
}
}
}
}
// VISITORS - TOGGLE COVERAGE
void visit(AstVar* nodep) override {
@ -488,7 +486,6 @@ class CoverageVisitor final : public VNVisitor {
UINFO(4, " CASEI: " << nodep << endl);
if (m_state.lineCoverageOn(nodep)) {
VL_RESTORER(m_state);
{
createHandle(nodep);
iterateAndNextNull(nodep->stmtsp());
if (m_state.lineCoverageOn(nodep)) { // if the case body didn't disable it
@ -500,11 +497,9 @@ class CoverageVisitor final : public VNVisitor {
}
}
}
}
void visit(AstCover* nodep) override {
UINFO(4, " COVER: " << nodep << endl);
VL_RESTORER(m_state);
{
m_state.m_on = true; // Always do cover blocks, even if there's a $stop
createHandle(nodep);
iterateChildren(nodep);
@ -516,7 +511,6 @@ class CoverageVisitor final : public VNVisitor {
m_beginHier + "_vlCoverageUserTrace"));
}
}
}
void visit(AstStop* nodep) override {
UINFO(4, " STOP: " << nodep << endl);
m_state.m_on = false;
@ -540,7 +534,6 @@ class CoverageVisitor final : public VNVisitor {
// covers the code in that line.)
VL_RESTORER(m_beginHier);
VL_RESTORER(m_inToggleOff);
{
m_inToggleOff = true;
if (nodep->name() != "") {
m_beginHier = m_beginHier + (m_beginHier != "" ? "." : "") + nodep->name();
@ -548,7 +541,6 @@ class CoverageVisitor final : public VNVisitor {
iterateChildren(nodep);
lineTrack(nodep);
}
}
// VISITORS - BOTH
void visit(AstNode* nodep) override {

View File

@ -35,9 +35,10 @@ class CoverageJoinVisitor final : public VNVisitor {
// NODE STATE
// VNUser4InUse In V3Hasher via V3DupFinder
// STATE
// STATE - per active
std::vector<AstCoverToggle*> m_toggleps; // List of of all AstCoverToggle's
// STATE - Statistic tracking
VDouble0 m_statToggleJoins; // Statistic tracking
// METHODS