Minor cleanup of trace internals
This commit is contained in:
parent
6012ec8eb7
commit
c5ba6e22fa
|
|
@ -3213,7 +3213,6 @@ class AstTraceDecl final : public AstNodeStmt {
|
|||
const string m_showname; // Name of variable
|
||||
const VNumRange m_bitRange; // Property of var the trace details
|
||||
const VNumRange m_arrayRange; // Property of var the trace details
|
||||
const uint32_t m_codeInc; // Code increment
|
||||
const VVarType m_varType; // Type of variable (for localparam vs. param)
|
||||
const VDirection m_declDirection; // Declared direction input/output etc
|
||||
public:
|
||||
|
|
@ -3224,9 +3223,6 @@ public:
|
|||
, m_showname{showname}
|
||||
, m_bitRange{bitRange}
|
||||
, m_arrayRange{arrayRange}
|
||||
, m_codeInc(
|
||||
((arrayRange.ranged() ? arrayRange.elements() : 1) * valuep->dtypep()->widthWords()
|
||||
* (VL_EDATASIZE / 32))) // A code is always 32-bits
|
||||
, m_varType{varp->varType()}
|
||||
, m_declDirection{varp->declDirection()} {
|
||||
dtypeFrom(valuep);
|
||||
|
|
@ -3245,7 +3241,11 @@ public:
|
|||
void code(uint32_t code) { m_code = code; }
|
||||
uint32_t fidx() const { return m_fidx; }
|
||||
void fidx(uint32_t fidx) { m_fidx = fidx; }
|
||||
uint32_t codeInc() const { return m_codeInc; }
|
||||
uint32_t codeInc() const {
|
||||
return (m_arrayRange.ranged() ? m_arrayRange.elements() : 1)
|
||||
* valuep()->dtypep()->widthWords()
|
||||
* (VL_EDATASIZE / 32); // A code is always 32-bits
|
||||
}
|
||||
const VNumRange& bitRange() const { return m_bitRange; }
|
||||
const VNumRange& arrayRange() const { return m_arrayRange; }
|
||||
VVarType varType() const { return m_varType; }
|
||||
|
|
@ -3266,8 +3266,9 @@ public:
|
|||
, m_traceType{traceType}
|
||||
, m_declp{declp} {
|
||||
dtypeFrom(declp);
|
||||
this->valuep(
|
||||
declp->valuep()->cloneTree(true)); // TODO: maybe use reference to TraceDecl instead?
|
||||
// Note: A clone is necessary (instead of using declp()->valuep()),
|
||||
// for insertion of local temporaries in V3Premit
|
||||
valuep(declp->valuep()->cloneTree(true));
|
||||
}
|
||||
ASTGEN_MEMBERS_AstTraceInc;
|
||||
void dump(std::ostream& str) const override;
|
||||
|
|
|
|||
|
|
@ -238,10 +238,7 @@ class CleanVisitor final : public VNVisitor {
|
|||
if (AstNodeExpr* const exprp = VN_CAST(argp, NodeExpr)) ensureClean(exprp);
|
||||
}
|
||||
}
|
||||
void visit(AstTraceDecl* nodep) override {
|
||||
// No cleaning, or would loose pointer to enum
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
void visit(AstTraceDecl* nodep) override {} // Nothing to do here
|
||||
void visit(AstTraceInc* nodep) override {
|
||||
iterateChildren(nodep);
|
||||
ensureCleanAndNext(nodep->valuep());
|
||||
|
|
|
|||
|
|
@ -201,31 +201,16 @@ class TraceVisitor final : public VNVisitor {
|
|||
UINFO(9, "Finding duplicates\n");
|
||||
// Note uses user4
|
||||
V3DupFinder dupFinder; // Duplicate code detection
|
||||
// Hash all of the values the traceIncs need
|
||||
for (const V3GraphVertex* itp = m_graph.verticesBeginp(); itp;
|
||||
itp = itp->verticesNextp()) {
|
||||
if (const TraceTraceVertex* const vvertexp = itp->cast<const TraceTraceVertex>()) {
|
||||
const AstTraceDecl* const nodep = vvertexp->nodep();
|
||||
if (nodep->valuep()) {
|
||||
UASSERT_OBJ(nodep->valuep()->backp() == nodep, nodep,
|
||||
"Trace duplicate back needs consistency,"
|
||||
" so we can map duplicates back to TRACEINCs");
|
||||
// Just keep one node in the map and point all duplicates to this node
|
||||
if (dupFinder.findDuplicate(nodep->valuep()) == dupFinder.end()) {
|
||||
dupFinder.insert(nodep->valuep());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Find if there are any duplicates
|
||||
// Hash all of the traced values and find if there are any duplicates
|
||||
for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) {
|
||||
if (TraceTraceVertex* const vvertexp = itp->cast<TraceTraceVertex>()) {
|
||||
const AstTraceDecl* const nodep = vvertexp->nodep();
|
||||
if (nodep->valuep() && !vvertexp->duplicatep()) {
|
||||
UASSERT_OBJ(!vvertexp->duplicatep(), nodep, "Should not be a duplicate");
|
||||
const auto dupit = dupFinder.findDuplicate(nodep->valuep());
|
||||
if (dupit != dupFinder.end()) {
|
||||
const AstTraceDecl* const dupDeclp
|
||||
= VN_AS(dupit->second->backp(), TraceDecl);
|
||||
if (dupit == dupFinder.end()) {
|
||||
dupFinder.insert(nodep->valuep());
|
||||
} else {
|
||||
const AstTraceDecl* const dupDeclp = VN_AS(dupit->second->backp(), TraceDecl);
|
||||
UASSERT_OBJ(dupDeclp, nodep, "Trace duplicate of wrong type");
|
||||
TraceTraceVertex* const dupvertexp
|
||||
= dupDeclp->user1u().toGraphVertex()->cast<TraceTraceVertex>();
|
||||
|
|
@ -238,7 +223,6 @@ class TraceVisitor final : public VNVisitor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void graphSimplify(bool initial) {
|
||||
if (initial) {
|
||||
|
|
@ -594,8 +578,9 @@ class TraceVisitor final : public VNVisitor {
|
|||
UASSERT_OBJ(declp->code() == 0, declp,
|
||||
"Canonical node should not have code assigned yet");
|
||||
declp->code(m_code);
|
||||
m_code += declp->codeInc();
|
||||
m_statUniqCodes += declp->codeInc();
|
||||
const uint32_t codeInc = declp->codeInc();
|
||||
m_code += codeInc;
|
||||
m_statUniqCodes += codeInc;
|
||||
++m_statUniqSigs;
|
||||
|
||||
// If this is a const signal, add the AstTraceInc
|
||||
|
|
|
|||
Loading…
Reference in New Issue