Ensure DFG stats are consistent
This commit is contained in:
parent
47bce4157d
commit
9da012568c
|
|
@ -85,6 +85,7 @@ class AstToDfgVisitor final : public VNVisitor {
|
||||||
V3DfgOptimizationContext& m_ctx; // The optimization context for stats
|
V3DfgOptimizationContext& m_ctx; // The optimization context for stats
|
||||||
bool m_foundUnhandled = false; // Found node not implemented as DFG or not implemented 'visit'
|
bool m_foundUnhandled = false; // Found node not implemented as DFG or not implemented 'visit'
|
||||||
std::vector<DfgVertex*> m_uncommittedVertices; // Vertices that we might decide to revert
|
std::vector<DfgVertex*> m_uncommittedVertices; // Vertices that we might decide to revert
|
||||||
|
bool m_converting = false; // We are trying to convert some logic at the moment
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void markReferenced(AstNode* nodep) {
|
void markReferenced(AstNode* nodep) {
|
||||||
|
|
@ -141,8 +142,8 @@ class AstToDfgVisitor final : public VNVisitor {
|
||||||
// VISITORS
|
// VISITORS
|
||||||
void visit(AstNode* nodep) override {
|
void visit(AstNode* nodep) override {
|
||||||
// Conservatively treat this node as unhandled
|
// Conservatively treat this node as unhandled
|
||||||
|
if (!m_foundUnhandled && m_converting) ++m_ctx.m_nonRepUnknown;
|
||||||
m_foundUnhandled = true;
|
m_foundUnhandled = true;
|
||||||
++m_ctx.m_nonRepUnknown;
|
|
||||||
markReferenced(nodep);
|
markReferenced(nodep);
|
||||||
}
|
}
|
||||||
void visit(AstCell* nodep) override { markReferenced(nodep); }
|
void visit(AstCell* nodep) override { markReferenced(nodep); }
|
||||||
|
|
@ -158,6 +159,10 @@ class AstToDfgVisitor final : public VNVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstAssignW* nodep) override {
|
void visit(AstAssignW* nodep) override {
|
||||||
|
VL_RESTORER(m_converting);
|
||||||
|
m_converting = true;
|
||||||
|
++m_ctx.m_inputEquations;
|
||||||
|
|
||||||
// Cannot handle assignment with timing control yet
|
// Cannot handle assignment with timing control yet
|
||||||
if (nodep->timingControlp()) {
|
if (nodep->timingControlp()) {
|
||||||
markReferenced(nodep);
|
markReferenced(nodep);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ V3DfgOptimizationContext::V3DfgOptimizationContext(const std::string& label)
|
||||||
V3DfgOptimizationContext::~V3DfgOptimizationContext() {
|
V3DfgOptimizationContext::~V3DfgOptimizationContext() {
|
||||||
const string prefix = "Optimizations, DFG " + m_label + " ";
|
const string prefix = "Optimizations, DFG " + m_label + " ";
|
||||||
V3Stats::addStat(prefix + "General, modules", m_modules);
|
V3Stats::addStat(prefix + "General, modules", m_modules);
|
||||||
|
V3Stats::addStat(prefix + "Ast2Dfg, input equations", m_inputEquations);
|
||||||
V3Stats::addStat(prefix + "Ast2Dfg, representable", m_representable);
|
V3Stats::addStat(prefix + "Ast2Dfg, representable", m_representable);
|
||||||
V3Stats::addStat(prefix + "Ast2Dfg, non-representable (dtype)", m_nonRepDType);
|
V3Stats::addStat(prefix + "Ast2Dfg, non-representable (dtype)", m_nonRepDType);
|
||||||
V3Stats::addStat(prefix + "Ast2Dfg, non-representable (impure)", m_nonRepImpure);
|
V3Stats::addStat(prefix + "Ast2Dfg, non-representable (impure)", m_nonRepImpure);
|
||||||
|
|
@ -65,6 +66,12 @@ V3DfgOptimizationContext::~V3DfgOptimizationContext() {
|
||||||
V3Stats::addStat(prefix + "Dfg2Ast, intermediate variables", m_intermediateVars);
|
V3Stats::addStat(prefix + "Dfg2Ast, intermediate variables", m_intermediateVars);
|
||||||
V3Stats::addStat(prefix + "Dfg2Ast, replaced variables", m_replacedVars);
|
V3Stats::addStat(prefix + "Dfg2Ast, replaced variables", m_replacedVars);
|
||||||
V3Stats::addStat(prefix + "Dfg2Ast, result equations", m_resultEquations);
|
V3Stats::addStat(prefix + "Dfg2Ast, result equations", m_resultEquations);
|
||||||
|
|
||||||
|
// Check the stats are consistent
|
||||||
|
UASSERT(m_inputEquations
|
||||||
|
== m_representable + m_nonRepDType + m_nonRepImpure + m_nonRepTiming + m_nonRepLhs
|
||||||
|
+ m_nonRepNode + m_nonRepUnknown + m_nonRepVarRef + m_nonRepWidth,
|
||||||
|
"Inconsistent statistics");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'Inline' DfgVar nodes with known drivers
|
// 'Inline' DfgVar nodes with known drivers
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ class V3DfgOptimizationContext final {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VDouble0 m_modules; // Number of modules optimized
|
VDouble0 m_modules; // Number of modules optimized
|
||||||
|
VDouble0 m_inputEquations; // Number of input combinational equations
|
||||||
VDouble0 m_representable; // Number of combinational equations representable
|
VDouble0 m_representable; // Number of combinational equations representable
|
||||||
VDouble0 m_nonRepDType; // Equations non-representable due to data type
|
VDouble0 m_nonRepDType; // Equations non-representable due to data type
|
||||||
VDouble0 m_nonRepImpure; // Equations non-representable due to impure node
|
VDouble0 m_nonRepImpure; // Equations non-representable due to impure node
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue