Internals: Style modernization. No functional change intended.
This commit is contained in:
parent
f7533010c6
commit
4f93ac6477
|
|
@ -218,10 +218,10 @@ public:
|
||||||
void lifeToAbove() {
|
void lifeToAbove() {
|
||||||
// Any varrefs under a if/else branch affect statements outside and after the if/else
|
// Any varrefs under a if/else branch affect statements outside and after the if/else
|
||||||
if (!m_aboveLifep) v3fatalSrc("Pushing life when already at the top level");
|
if (!m_aboveLifep) v3fatalSrc("Pushing life when already at the top level");
|
||||||
for (LifeMap::iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
for (auto& itr : m_map) {
|
||||||
AstVarScope* const nodep = it->first;
|
AstVarScope* const nodep = itr.first;
|
||||||
m_aboveLifep->complexAssignFind(nodep);
|
m_aboveLifep->complexAssignFind(nodep);
|
||||||
if (it->second.everSet()) {
|
if (itr.second.everSet()) {
|
||||||
// Record there may be an assignment, so we don't constant propagate across the if.
|
// Record there may be an assignment, so we don't constant propagate across the if.
|
||||||
complexAssignFind(nodep);
|
complexAssignFind(nodep);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -235,14 +235,14 @@ public:
|
||||||
// life1p->lifeDump();
|
// life1p->lifeDump();
|
||||||
// life2p->lifeDump();
|
// life2p->lifeDump();
|
||||||
AstNode::user1ClearTree(); // user1p() used on entire tree
|
AstNode::user1ClearTree(); // user1p() used on entire tree
|
||||||
for (LifeMap::iterator it = life1p->m_map.begin(); it != life1p->m_map.end(); ++it) {
|
for (auto& itr : life1p->m_map) {
|
||||||
// When the if branch sets a var before it's used, mark that variable
|
// When the if branch sets a var before it's used, mark that variable
|
||||||
if (it->second.setBeforeUse()) it->first->user1(1);
|
if (itr.second.setBeforeUse()) itr.first->user1(1);
|
||||||
}
|
}
|
||||||
for (LifeMap::iterator it = life2p->m_map.begin(); it != life2p->m_map.end(); ++it) {
|
for (auto& itr : life2p->m_map) {
|
||||||
// When the else branch sets a var before it's used
|
// When the else branch sets a var before it's used
|
||||||
AstVarScope* const nodep = it->first;
|
AstVarScope* const nodep = itr.first;
|
||||||
if (it->second.setBeforeUse() && nodep->user1()) {
|
if (itr.second.setBeforeUse() && nodep->user1()) {
|
||||||
// Both branches set the var, we can remove the assignment before the IF.
|
// Both branches set the var, we can remove the assignment before the IF.
|
||||||
UINFO(4, "DUALBRANCH " << nodep << endl);
|
UINFO(4, "DUALBRANCH " << nodep << endl);
|
||||||
const auto itab = m_map.find(nodep);
|
const auto itab = m_map.find(nodep);
|
||||||
|
|
@ -255,11 +255,11 @@ public:
|
||||||
// DEBUG
|
// DEBUG
|
||||||
void lifeDump() {
|
void lifeDump() {
|
||||||
UINFO(5, " LifeMap:" << endl);
|
UINFO(5, " LifeMap:" << endl);
|
||||||
for (LifeMap::iterator it = m_map.begin(); it != m_map.end(); ++it) {
|
for (const auto& itr : m_map) {
|
||||||
UINFO(5, " Ent: " << (it->second.setBeforeUse() ? "[F] " : " ") << it->first
|
UINFO(5, " Ent: " << (itr.second.setBeforeUse() ? "[F] " : " ") << itr.first
|
||||||
<< endl);
|
<< endl);
|
||||||
if (it->second.assignp()) { //
|
if (itr.second.assignp()) { //
|
||||||
UINFO(5, " Ass: " << it->second.assignp() << endl);
|
UINFO(5, " Ass: " << itr.second.assignp() << endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -391,13 +391,12 @@ private:
|
||||||
// Just don't optimize blocks with labels; they're rare - so far.
|
// Just don't optimize blocks with labels; they're rare - so far.
|
||||||
LifeBlock* const prevLifep = m_lifep;
|
LifeBlock* const prevLifep = m_lifep;
|
||||||
LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep);
|
LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep);
|
||||||
const bool prev_noopt = m_noopt;
|
|
||||||
{
|
{
|
||||||
|
VL_RESTORER(m_noopt);
|
||||||
m_lifep = bodyLifep;
|
m_lifep = bodyLifep;
|
||||||
setNoopt();
|
setNoopt();
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextNull(nodep->stmtsp());
|
||||||
m_lifep = prevLifep;
|
m_lifep = prevLifep;
|
||||||
m_noopt = prev_noopt;
|
|
||||||
}
|
}
|
||||||
UINFO(4, " joinjump" << endl);
|
UINFO(4, " joinjump" << endl);
|
||||||
// For the next assignments, clear any variables that were read or written in the block
|
// For the next assignments, clear any variables that were read or written in the block
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue