mirror of
https://github.com/verilator/verilator.git
synced 2026-09-01 10:27:04 +02:00
clang-format many files. No functional change.
Use nodist/clang_formatter to reformat files that are now clean.
This commit is contained in:
+66
-57
@@ -47,27 +47,27 @@
|
||||
class ReloopVisitor : public AstNVisitor {
|
||||
private:
|
||||
// TYPES
|
||||
typedef std::vector<AstNodeAssign*> AssVec;
|
||||
typedef std::vector<AstNodeAssign*> AssVec;
|
||||
|
||||
// NODE STATE
|
||||
// AstCFunc::user1p -> Var* for temp var, 0=not set yet
|
||||
AstUser1InUse m_inuser1;
|
||||
AstUser1InUse m_inuser1;
|
||||
|
||||
// STATE
|
||||
VDouble0 m_statReloops; // Statistic tracking
|
||||
VDouble0 m_statReItems; // Statistic tracking
|
||||
AstCFunc* m_cfuncp; // Current block
|
||||
VDouble0 m_statReloops; // Statistic tracking
|
||||
VDouble0 m_statReItems; // Statistic tracking
|
||||
AstCFunc* m_cfuncp; // Current block
|
||||
|
||||
AssVec m_mgAssignps; // List of assignments merging
|
||||
AstCFunc* m_mgCfuncp; // Parent C function
|
||||
AstNode* m_mgNextp; // Next node
|
||||
AstNodeSel* m_mgSelLp; // Parent select, NULL = idle
|
||||
AstNodeSel* m_mgSelRp; // Parent select, NULL = constant
|
||||
AstNodeVarRef* m_mgVarrefLp; // Parent varref
|
||||
AstNodeVarRef* m_mgVarrefRp; // Parent varref, NULL = constant
|
||||
AstConst* m_mgConstRp; // Parent RHS constant, NULL = sel
|
||||
uint32_t m_mgIndexLo; // Merge range
|
||||
uint32_t m_mgIndexHi; // Merge range
|
||||
AssVec m_mgAssignps; // List of assignments merging
|
||||
AstCFunc* m_mgCfuncp; // Parent C function
|
||||
AstNode* m_mgNextp; // Next node
|
||||
AstNodeSel* m_mgSelLp; // Parent select, NULL = idle
|
||||
AstNodeSel* m_mgSelRp; // Parent select, NULL = constant
|
||||
AstNodeVarRef* m_mgVarrefLp; // Parent varref
|
||||
AstNodeVarRef* m_mgVarrefRp; // Parent varref, NULL = constant
|
||||
AstConst* m_mgConstRp; // Parent RHS constant, NULL = sel
|
||||
uint32_t m_mgIndexLo; // Merge range
|
||||
uint32_t m_mgIndexHi; // Merge range
|
||||
|
||||
// METHODS
|
||||
VL_DEBUG_FUNC; // Declare debug()
|
||||
@@ -76,8 +76,7 @@ private:
|
||||
AstVar* varp = VN_CAST(cfuncp->user1p(), Var);
|
||||
if (!varp) {
|
||||
string newvarname = string("__Vilp");
|
||||
varp = new AstVar(fl, AstVarType::STMTTEMP,
|
||||
newvarname, VFlagLogicPacked(), 32);
|
||||
varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32);
|
||||
UASSERT_OBJ(cfuncp, fl, "Assignment not under a function");
|
||||
cfuncp->addInitsp(varp);
|
||||
cfuncp->user1p(varp);
|
||||
@@ -87,11 +86,11 @@ private:
|
||||
void mergeEnd() {
|
||||
if (!m_mgAssignps.empty()) {
|
||||
uint32_t items = m_mgIndexHi - m_mgIndexLo + 1;
|
||||
UINFO(9, "End merge iter="<<items<<" "<<m_mgIndexHi<<":"<<m_mgIndexLo
|
||||
<<" "<<m_mgAssignps[0]<<endl);
|
||||
UINFO(9, "End merge iter=" << items << " " << m_mgIndexHi << ":" << m_mgIndexLo << " "
|
||||
<< m_mgAssignps[0] << endl);
|
||||
if (items >= RELOOP_MIN_ITERS) {
|
||||
UINFO(6, "Reloop merging items="<<items<<" "<<m_mgIndexHi<<":"<<m_mgIndexLo
|
||||
<<" "<<m_mgAssignps[0]<<endl);
|
||||
UINFO(6, "Reloop merging items=" << items << " " << m_mgIndexHi << ":"
|
||||
<< m_mgIndexLo << " " << m_mgAssignps[0] << endl);
|
||||
++m_statReloops;
|
||||
m_statReItems += items;
|
||||
|
||||
@@ -103,11 +102,11 @@ private:
|
||||
|
||||
AstNode* initp = new AstAssign(fl, new AstVarRef(fl, itp, true),
|
||||
new AstConst(fl, m_mgIndexLo));
|
||||
AstNode* condp = new AstLte(fl, new AstVarRef(fl, itp, false),
|
||||
new AstConst(fl, m_mgIndexHi));
|
||||
AstNode* incp = new AstAssign(fl, new AstVarRef(fl, itp, true),
|
||||
new AstAdd(fl, new AstConst(fl, 1),
|
||||
new AstVarRef(fl, itp, false)));
|
||||
AstNode* condp
|
||||
= new AstLte(fl, new AstVarRef(fl, itp, false), new AstConst(fl, m_mgIndexHi));
|
||||
AstNode* incp = new AstAssign(
|
||||
fl, new AstVarRef(fl, itp, true),
|
||||
new AstAdd(fl, new AstConst(fl, 1), new AstVarRef(fl, itp, false)));
|
||||
AstWhile* whilep = new AstWhile(fl, condp, NULL, incp);
|
||||
initp->addNext(whilep);
|
||||
bodyp->replaceWith(initp);
|
||||
@@ -122,11 +121,11 @@ private:
|
||||
rbitp->replaceWith(new AstVarRef(fl, itp, false));
|
||||
VL_DO_DANGLING(rbitp->deleteTree(), lbitp);
|
||||
}
|
||||
if (debug()>=9) initp->dumpTree(cout, "-new: ");
|
||||
if (debug()>=9) whilep->dumpTree(cout, "-new: ");
|
||||
if (debug() >= 9) initp->dumpTree(cout, "-new: ");
|
||||
if (debug() >= 9) whilep->dumpTree(cout, "-new: ");
|
||||
|
||||
// Remove remaining assigns
|
||||
for (AssVec::iterator it=m_mgAssignps.begin(); it!=m_mgAssignps.end(); ++it) {
|
||||
for (AssVec::iterator it = m_mgAssignps.begin(); it != m_mgAssignps.end(); ++it) {
|
||||
AstNodeAssign* assp = *it;
|
||||
if (assp != bodyp) {
|
||||
VL_DO_DANGLING(assp->unlinkFrBack()->deleteTree(), assp);
|
||||
@@ -154,15 +153,27 @@ private:
|
||||
|
||||
// Left select WordSel or ArraySel
|
||||
AstNodeSel* lselp = VN_CAST(nodep->lhsp(), NodeSel);
|
||||
if (!lselp) { mergeEnd(); return; } // Not ever merged
|
||||
if (!lselp) { // Not ever merged
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
// Of a constant index
|
||||
AstConst* lbitp = VN_CAST(lselp->bitp(), Const);
|
||||
if (!lbitp) { mergeEnd(); return; }
|
||||
if (lbitp->width() > 32) { mergeEnd(); return; } // Assoc arrays can do this
|
||||
if (!lbitp) {
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
if (lbitp->width() > 32) { // Assoc arrays can do this
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
uint32_t index = lbitp->toUInt();
|
||||
// Of variable
|
||||
AstNodeVarRef* lvarrefp = VN_CAST(lselp->fromp(), NodeVarRef);
|
||||
if (!lvarrefp) { mergeEnd(); return; }
|
||||
if (!lvarrefp) {
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
// RHS is a constant or a select
|
||||
AstConst* rconstp = VN_CAST(nodep->rhsp(), Const);
|
||||
@@ -170,38 +181,38 @@ private:
|
||||
AstNodeVarRef* rvarrefp = NULL;
|
||||
if (rconstp) { // Ok
|
||||
} else {
|
||||
if (!rselp) { mergeEnd(); return; }
|
||||
if (!rselp) {
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
AstConst* rbitp = VN_CAST(rselp->bitp(), Const);
|
||||
rvarrefp = VN_CAST(rselp->fromp(), NodeVarRef);
|
||||
if (!rbitp || rbitp->toUInt() != index
|
||||
|| !rvarrefp
|
||||
if (!rbitp || rbitp->toUInt() != index || !rvarrefp
|
||||
|| lvarrefp->varp() == rvarrefp->varp()) {
|
||||
mergeEnd(); return;
|
||||
mergeEnd();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mgSelLp) { // Old merge
|
||||
if (m_mgCfuncp == m_cfuncp
|
||||
&& m_mgNextp == nodep
|
||||
&& m_mgSelLp->same(lselp)
|
||||
if (m_mgCfuncp == m_cfuncp && m_mgNextp == nodep && m_mgSelLp->same(lselp)
|
||||
&& m_mgVarrefLp->same(lvarrefp)
|
||||
&& (m_mgConstRp
|
||||
? (rconstp && m_mgConstRp->same(rconstp))
|
||||
: (rselp
|
||||
&& m_mgSelRp->same(rselp)
|
||||
&& m_mgVarrefRp->same(rvarrefp)))
|
||||
&& (index == m_mgIndexLo-1
|
||||
|| index == m_mgIndexHi+1)) {
|
||||
? (rconstp && m_mgConstRp->same(rconstp))
|
||||
: (rselp && m_mgSelRp->same(rselp) && m_mgVarrefRp->same(rvarrefp)))
|
||||
&& (index == m_mgIndexLo - 1 || index == m_mgIndexHi + 1)) {
|
||||
// Sequentially next to last assign; continue merge
|
||||
if (index == m_mgIndexLo-1) m_mgIndexLo = index;
|
||||
else if (index == m_mgIndexHi+1) m_mgIndexHi = index;
|
||||
UINFO(9, "Continue merge i="<<index
|
||||
<<" "<<m_mgIndexHi<<":"<<m_mgIndexLo<<" "<<nodep<<endl);
|
||||
if (index == m_mgIndexLo - 1) {
|
||||
m_mgIndexLo = index;
|
||||
} else if (index == m_mgIndexHi + 1) {
|
||||
m_mgIndexHi = index;
|
||||
}
|
||||
UINFO(9, "Continue merge i=" << index << " " << m_mgIndexHi << ":" << m_mgIndexLo
|
||||
<< " " << nodep << endl);
|
||||
m_mgAssignps.push_back(nodep);
|
||||
m_mgNextp = nodep->nextp();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// This assign doesn't merge with previous assign,
|
||||
// but should start a new merge
|
||||
mergeEnd();
|
||||
@@ -219,7 +230,7 @@ private:
|
||||
m_mgConstRp = rconstp;
|
||||
m_mgIndexLo = index;
|
||||
m_mgIndexHi = index;
|
||||
UINFO(9, "Start merge i="<<index<<" "<<nodep<<endl);
|
||||
UINFO(9, "Start merge i=" << index << " " << nodep << endl);
|
||||
}
|
||||
//--------------------
|
||||
virtual void visit(AstVar*) VL_OVERRIDE {} // Accelerate
|
||||
@@ -251,9 +262,7 @@ public:
|
||||
// Reloop class functions
|
||||
|
||||
void V3Reloop::reloopAll(AstNetlist* nodep) {
|
||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||
{
|
||||
ReloopVisitor visitor(nodep);
|
||||
} // Destruct before checking
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
{ ReloopVisitor visitor(nodep); } // Destruct before checking
|
||||
V3Global::dumpCheckGlobalTree("reloop", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user