From 139e93d37174f823c33309cc83778562eeaab754 Mon Sep 17 00:00:00 2001 From: Krzysztof Bieganski Date: Fri, 8 Sep 2023 13:35:52 +0200 Subject: [PATCH] Internals: Reduce the number of typechecks in graphs (#4398). No functional change intended. --- src/V3Split.cpp | 17 +++++++++-------- src/V3Tristate.cpp | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 80eb67778..5ff887b59 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -176,12 +176,12 @@ public: void setIgnoreThisStep() { m_ignoreInStep = s_stepNum; } virtual bool followScoreboard() const = 0; static bool followScoreboard(const V3GraphEdge* edgep) { - const SplitEdge* const oedgep = edgep->as(); + const SplitEdge* const oedgep = static_cast(edgep); if (oedgep->ignoreThisStep()) return false; return oedgep->followScoreboard(); } static bool followCyclic(const V3GraphEdge* edgep) { - const SplitEdge* const oedgep = edgep->as(); + const SplitEdge* const oedgep = static_cast(edgep); return (!oedgep->ignoreThisStep()); } string dotStyle() const override { @@ -332,7 +332,7 @@ protected: stdp->nodep()->dumpTree("- "); } for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* const oedgep = edgep->as(); + SplitEdge* const oedgep = static_cast(edgep); oedgep->setIgnoreThisStep(); } } @@ -487,12 +487,12 @@ protected: if (const SplitLogicVertex* const vvertexp = vertexp->cast()) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* const oedgep = edgep->as(); + SplitEdge* const oedgep = static_cast(edgep); oedgep->setIgnoreThisStep(); } for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - SplitEdge* const oedgep = edgep->as(); + SplitEdge* const oedgep = static_cast(edgep); oedgep->setIgnoreThisStep(); } } @@ -919,7 +919,7 @@ protected: bool pruneMe = true; for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { - const SplitEdge* const oedgep = edgep->as(); + const SplitEdge* const oedgep = static_cast(edgep); if (!oedgep->ignoreThisStep()) { // This if conditional depends on something we can't // prune -- a variable generated in the current block. @@ -929,7 +929,8 @@ protected: // give a hint about why... if (debug() >= 9) { V3GraphVertex* vxp = oedgep->top(); - const SplitNodeVertex* const nvxp = vxp->as(); + const SplitNodeVertex* const nvxp + = static_cast(vxp); UINFO(0, "Cannot prune if-node due to edge " << oedgep << " pointing to node " << nvxp->nodep() << endl); nvxp->nodep()->dumpTree("- "); @@ -943,7 +944,7 @@ protected: // This if can be split; prune dependencies on it. for (V3GraphEdge* edgep = logicp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* const oedgep = edgep->as(); + SplitEdge* const oedgep = static_cast(edgep); oedgep->setIgnoreThisStep(); } } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index fdf303b28..99ff0f328 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -223,7 +223,7 @@ private: UINFO(9, " Mark tri " << level << " " << vtxp << endl); if (!vtxp->varp()) { // not a var where we stop the recursion for (V3GraphEdge* edgep = vtxp->outBeginp(); edgep; edgep = edgep->outNextp()) { - TristateVertex* const vvertexp = edgep->top()->as(); + TristateVertex* const vvertexp = static_cast(edgep->top()); // Doesn't hurt to not check if already set, but by doing so when we // print out the debug messages, we'll see this node at level 0 instead. if (!vvertexp->isTristate()) { @@ -235,7 +235,7 @@ private: // A variable is tristated. Find all of the LHS VARREFs that // drive this signal now need tristate drivers for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) { - TristateVertex* const vvertexp = edgep->fromp()->as(); + TristateVertex* const vvertexp = static_cast(edgep->fromp()); if (const AstVarRef* const refp = VN_CAST(vvertexp->nodep(), VarRef)) { if (refp->access().isWriteOrRW() // Doesn't hurt to not check if already set, but by doing so when we @@ -260,7 +260,7 @@ private: UINFO(9, " Mark feedstri " << level << " " << vtxp << endl); if (!vtxp->varp()) { // not a var where we stop the recursion for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) { - TristateVertex* const vvertexp = edgep->fromp()->as(); + TristateVertex* const vvertexp = static_cast(edgep->fromp()); // Doesn't hurt to not check if already set, but by doing so when we // print out the debug messages, we'll see this node at level 0 instead. if (!vvertexp->feedsTri()) {