mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Localize variables from other modules when possible
V3Localize can now localize variable references that reference variables located in scopes different from the referencing function. This also means V3Descope has now moved after V3Localize.
This commit is contained in:
@@ -48,25 +48,24 @@ private:
|
||||
AstCFunc* createDeepFunc(AstNode* nodep) {
|
||||
AstNRelinker relinkHandle;
|
||||
nodep->unlinkFrBack(&relinkHandle);
|
||||
// Create function
|
||||
string name = m_cfuncp->name() + "__deep" + cvtToStr(++m_deepNum);
|
||||
AstCFunc* funcp = new AstCFunc(nodep->fileline(), name, nullptr);
|
||||
// Create sub function
|
||||
AstScope* const scopep = m_cfuncp->scopep();
|
||||
const string name = m_cfuncp->name() + "__deep" + cvtToStr(++m_deepNum);
|
||||
AstCFunc* const funcp = new AstCFunc(nodep->fileline(), name, scopep);
|
||||
funcp->slow(m_cfuncp->slow());
|
||||
funcp->isStatic(m_cfuncp->isStatic());
|
||||
funcp->isLoose(m_cfuncp->isLoose());
|
||||
funcp->addStmtsp(nodep);
|
||||
m_modp->addStmtp(funcp);
|
||||
// Call it at the point where the body was removed from
|
||||
AstCCall* callp = new AstCCall(nodep->fileline(), funcp);
|
||||
scopep->addActivep(funcp);
|
||||
// Call sub function at the point where the body was removed from
|
||||
AstCCall* const callp = new AstCCall(nodep->fileline(), funcp);
|
||||
if (VN_IS(m_modp, Class)) {
|
||||
funcp->argTypes(EmitCBaseVisitor::symClassVar());
|
||||
callp->argTypes("vlSymsp");
|
||||
} else if (!funcp->isStatic()) {
|
||||
callp->selfPointer("this");
|
||||
}
|
||||
UINFO(6, " New " << callp << endl);
|
||||
//
|
||||
relinkHandle.relink(callp);
|
||||
// Done
|
||||
return funcp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user