Internals: Constructor style cleanup. No functional change.
This commit is contained in:
parent
9f37cef1bb
commit
3d71716a8a
|
|
@ -15,7 +15,7 @@
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
//
|
//
|
||||||
// void example_usage() {
|
// void example_usage() {
|
||||||
// SimulateVisitor simvis (false, false);
|
// SimulateVisitor simvis{false, false};
|
||||||
// simvis.clear();
|
// simvis.clear();
|
||||||
// // Set all inputs to the constant
|
// // Set all inputs to the constant
|
||||||
// for (deque<AstVarScope*>::iterator it = m_inVarps.begin(); it!=m_inVarps.end(); ++it) {
|
// for (deque<AstVarScope*>::iterator it = m_inVarps.begin(); it!=m_inVarps.end(); ++it) {
|
||||||
|
|
@ -130,7 +130,7 @@ private:
|
||||||
const int width = itemp->width();
|
const int width = itemp->width();
|
||||||
const int lsb = itemp->lsb();
|
const int lsb = itemp->lsb();
|
||||||
const int msb = lsb + width - 1;
|
const int msb = lsb + width - 1;
|
||||||
V3Number fieldNum(nump, width);
|
V3Number fieldNum{nump, width};
|
||||||
fieldNum.opSel(*nump, msb, lsb);
|
fieldNum.opSel(*nump, msb, lsb);
|
||||||
out << itemp->name() << ": ";
|
out << itemp->name() << ": ";
|
||||||
if (AstNodeDType* const childTypep = itemp->subDTypep()) {
|
if (AstNodeDType* const childTypep = itemp->subDTypep()) {
|
||||||
|
|
@ -152,7 +152,7 @@ private:
|
||||||
const int width = childTypep->width();
|
const int width = childTypep->width();
|
||||||
const int lsb = width * element;
|
const int lsb = width * element;
|
||||||
const int msb = lsb + width - 1;
|
const int msb = lsb + width - 1;
|
||||||
V3Number fieldNum(nump, width);
|
V3Number fieldNum{nump, width};
|
||||||
fieldNum.opSel(*nump, msb, lsb);
|
fieldNum.opSel(*nump, msb, lsb);
|
||||||
const int arrayElem = arrayp->lo() + element;
|
const int arrayElem = arrayp->lo() + element;
|
||||||
out << arrayElem << " = " << prettyNumber(&fieldNum, childTypep);
|
out << arrayElem << " = " << prettyNumber(&fieldNum, childTypep);
|
||||||
|
|
@ -236,7 +236,7 @@ private:
|
||||||
}
|
}
|
||||||
if (allocNewConst) {
|
if (allocNewConst) {
|
||||||
// Need to allocate new constant
|
// Need to allocate new constant
|
||||||
constp = new AstConst(nodep->fileline(), AstConst::DtypedValue(), nodep->dtypep(), 0);
|
constp = new AstConst{nodep->fileline(), AstConst::DtypedValue{}, nodep->dtypep(), 0};
|
||||||
// Mark as in use, add to free list for later reuse
|
// Mark as in use, add to free list for later reuse
|
||||||
constp->user2(1);
|
constp->user2(1);
|
||||||
freeList.push_back(constp);
|
freeList.push_back(constp);
|
||||||
|
|
@ -683,15 +683,15 @@ private:
|
||||||
initp = vscpnump;
|
initp = vscpnump;
|
||||||
} else { // Assignment to unassigned variable, all bits are X
|
} else { // Assignment to unassigned variable, all bits are X
|
||||||
// TODO generic initialization which builds X/arrays by recursion
|
// TODO generic initialization which builds X/arrays by recursion
|
||||||
AstConst* const outconstp = new AstConst(
|
AstConst* const outconstp = new AstConst{
|
||||||
nodep->fileline(), AstConst::WidthedValue(), basicp->widthMin(), 0);
|
nodep->fileline(), AstConst::WidthedValue{}, basicp->widthMin(), 0};
|
||||||
if (basicp->isZeroInit()) {
|
if (basicp->isZeroInit()) {
|
||||||
outconstp->num().setAllBits0();
|
outconstp->num().setAllBits0();
|
||||||
} else {
|
} else {
|
||||||
outconstp->num().setAllBitsX();
|
outconstp->num().setAllBitsX();
|
||||||
}
|
}
|
||||||
|
|
||||||
initp = new AstInitArray(nodep->fileline(), arrayp, outconstp);
|
initp = new AstInitArray{nodep->fileline(), arrayp, outconstp};
|
||||||
m_reclaimValuesp.push_back(initp);
|
m_reclaimValuesp.push_back(initp);
|
||||||
}
|
}
|
||||||
const uint32_t index = fetchConst(selp->bitp())->toUInt();
|
const uint32_t index = fetchConst(selp->bitp())->toUInt();
|
||||||
|
|
@ -706,7 +706,7 @@ private:
|
||||||
}
|
}
|
||||||
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
||||||
AstVarRef* varrefp = nullptr;
|
AstVarRef* varrefp = nullptr;
|
||||||
V3Number lsb(nodep);
|
V3Number lsb{nodep};
|
||||||
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
||||||
handleAssignSelRecurse(nodep, selp, varrefp /*ref*/, lsb /*ref*/, 0);
|
handleAssignSelRecurse(nodep, selp, varrefp /*ref*/, lsb /*ref*/, 0);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
|
@ -719,8 +719,8 @@ private:
|
||||||
} else if (AstConst* const vscpnump = fetchConstNull(vscp)) {
|
} else if (AstConst* const vscpnump = fetchConstNull(vscp)) {
|
||||||
outconstp = vscpnump;
|
outconstp = vscpnump;
|
||||||
} else { // Assignment to unassigned variable, all bits are X or 0
|
} else { // Assignment to unassigned variable, all bits are X or 0
|
||||||
outconstp = new AstConst(nodep->fileline(), AstConst::WidthedValue(),
|
outconstp = new AstConst{nodep->fileline(), AstConst::WidthedValue{},
|
||||||
varrefp->varp()->widthMin(), 0);
|
varrefp->varp()->widthMin(), 0};
|
||||||
if (varrefp->varp()->basicp() && varrefp->varp()->basicp()->isZeroInit()) {
|
if (varrefp->varp()->basicp() && varrefp->varp()->basicp()->isZeroInit()) {
|
||||||
outconstp->num().setAllBits0();
|
outconstp->num().setAllBits0();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -742,7 +742,7 @@ private:
|
||||||
lsbRef = fetchConst(selp->lsbp())->num();
|
lsbRef = fetchConst(selp->lsbp())->num();
|
||||||
return; // And presumably still optimizable()
|
return; // And presumably still optimizable()
|
||||||
} else if (AstSel* const subselp = VN_CAST(selp->lhsp(), Sel)) {
|
} else if (AstSel* const subselp = VN_CAST(selp->lhsp(), Sel)) {
|
||||||
V3Number sublsb(nodep);
|
V3Number sublsb{nodep};
|
||||||
handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb /*ref*/, depth + 1);
|
handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb /*ref*/, depth + 1);
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
lsbRef = sublsb;
|
lsbRef = sublsb;
|
||||||
|
|
@ -829,7 +829,7 @@ private:
|
||||||
if (hit) break;
|
if (hit) break;
|
||||||
iterateAndNextNull(ep);
|
iterateAndNextNull(ep);
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
V3Number match(nodep, 1);
|
V3Number match{nodep, 1};
|
||||||
match.opEq(fetchConst(nodep->exprp())->num(), fetchConst(ep)->num());
|
match.opEq(fetchConst(nodep->exprp())->num(), fetchConst(ep)->num());
|
||||||
if (match.isNeqZero()) {
|
if (match.isNeqZero()) {
|
||||||
iterateAndNextNull(itemp->bodysp());
|
iterateAndNextNull(itemp->bodysp());
|
||||||
|
|
@ -1097,7 +1097,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
AstConst* const resultConstp
|
AstConst* const resultConstp
|
||||||
= new AstConst(nodep->fileline(), AstConst::String(), result);
|
= new AstConst{nodep->fileline(), AstConst::String{}, result};
|
||||||
setValue(nodep, resultConstp);
|
setValue(nodep, resultConstp);
|
||||||
m_reclaimValuesp.push_back(resultConstp);
|
m_reclaimValuesp.push_back(resultConstp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ public:
|
||||||
= elemDType->isString()
|
= elemDType->isString()
|
||||||
? elemDType
|
? elemDType
|
||||||
: v3Global.rootp()->findBitDType(width, width, VSigning::UNSIGNED);
|
: v3Global.rootp()->findBitDType(width, width, VSigning::UNSIGNED);
|
||||||
AstUnpackArrayDType* const tableDTypep
|
AstUnpackArrayDType* const tableDTypep = new AstUnpackArrayDType{
|
||||||
= new AstUnpackArrayDType(m_fl, subDTypep, new AstRange(m_fl, size, 0));
|
m_fl, subDTypep, new AstRange{m_fl, static_cast<int>(size), 0}};
|
||||||
v3Global.rootp()->typeTablep()->addTypesp(tableDTypep);
|
v3Global.rootp()->typeTablep()->addTypesp(tableDTypep);
|
||||||
// Create table initializer (with default value 0)
|
// Create table initializer (with default value 0)
|
||||||
AstConst* const defaultp = elemDType->isString()
|
AstConst* const defaultp = elemDType->isString()
|
||||||
|
|
@ -106,7 +106,7 @@ public:
|
||||||
UASSERT_OBJ(!m_varScopep, m_fl, "Table variable already created");
|
UASSERT_OBJ(!m_varScopep, m_fl, "Table variable already created");
|
||||||
// Default value is zero/empty string so don't add it
|
// Default value is zero/empty string so don't add it
|
||||||
if (value.isString() ? value.toString().empty() : value.isEqZero()) return;
|
if (value.isString() ? value.toString().empty() : value.isEqZero()) return;
|
||||||
m_initp->addIndexValuep(index, new AstConst(m_fl, value));
|
m_initp->addIndexValuep(index, new AstConst{m_fl, value});
|
||||||
}
|
}
|
||||||
|
|
||||||
AstVarScope* varScopep() {
|
AstVarScope* varScopep() {
|
||||||
|
|
@ -247,14 +247,14 @@ private:
|
||||||
|
|
||||||
// We will need a table index variable, create it here.
|
// We will need a table index variable, create it here.
|
||||||
AstVar* const indexVarp
|
AstVar* const indexVarp
|
||||||
= new AstVar(fl, VVarType::BLOCKTEMP, "__Vtableidx" + cvtToStr(m_modTables),
|
= new AstVar{fl, VVarType::BLOCKTEMP, "__Vtableidx" + cvtToStr(m_modTables),
|
||||||
VFlagBitPacked(), m_inWidthBits);
|
VFlagBitPacked{}, static_cast<int>(m_inWidthBits)};
|
||||||
m_modp->addStmtp(indexVarp);
|
m_modp->addStmtp(indexVarp);
|
||||||
AstVarScope* const indexVscp = new AstVarScope(indexVarp->fileline(), m_scopep, indexVarp);
|
AstVarScope* const indexVscp = new AstVarScope{indexVarp->fileline(), m_scopep, indexVarp};
|
||||||
m_scopep->addVarp(indexVscp);
|
m_scopep->addVarp(indexVscp);
|
||||||
|
|
||||||
// The 'output assigned' table builder
|
// The 'output assigned' table builder
|
||||||
TableBuilder outputAssignedTableBuilder(fl);
|
TableBuilder outputAssignedTableBuilder{fl};
|
||||||
outputAssignedTableBuilder.setTableSize(
|
outputAssignedTableBuilder.setTableSize(
|
||||||
nodep->findBitDType(m_outVarps.size(), m_outVarps.size(), VSigning::UNSIGNED),
|
nodep->findBitDType(m_outVarps.size(), m_outVarps.size(), VSigning::UNSIGNED),
|
||||||
VL_MASK_I(m_inWidthBits));
|
VL_MASK_I(m_inWidthBits));
|
||||||
|
|
@ -311,7 +311,7 @@ private:
|
||||||
<< simvis.whyNotMessage());
|
<< simvis.whyNotMessage());
|
||||||
|
|
||||||
// Build output value tables and the assigned flags table
|
// Build output value tables and the assigned flags table
|
||||||
V3Number outputAssignedMask(nodep, m_outVarps.size(), 0);
|
V3Number outputAssignedMask{nodep, static_cast<int>(m_outVarps.size()), 0};
|
||||||
for (TableOutputVar& tov : m_outVarps) {
|
for (TableOutputVar& tov : m_outVarps) {
|
||||||
if (V3Number* const outnump = simvis.fetchOutNumberNull(tov.varScopep())) {
|
if (V3Number* const outnump = simvis.fetchOutNumberNull(tov.varScopep())) {
|
||||||
UINFO(8, " Output " << tov.name() << " = " << *outnump << endl);
|
UINFO(8, " Output " << tov.name() << " = " << *outnump << endl);
|
||||||
|
|
@ -333,21 +333,21 @@ private:
|
||||||
// First var in inVars becomes the LSB of the concat
|
// First var in inVars becomes the LSB of the concat
|
||||||
AstNode* concatp = nullptr;
|
AstNode* concatp = nullptr;
|
||||||
for (AstVarScope* invscp : m_inVarps) {
|
for (AstVarScope* invscp : m_inVarps) {
|
||||||
AstVarRef* const refp = new AstVarRef(fl, invscp, VAccess::READ);
|
AstVarRef* const refp = new AstVarRef{fl, invscp, VAccess::READ};
|
||||||
if (concatp) {
|
if (concatp) {
|
||||||
concatp = new AstConcat(fl, refp, concatp);
|
concatp = new AstConcat{fl, refp, concatp};
|
||||||
} else {
|
} else {
|
||||||
concatp = refp;
|
concatp = refp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AstAssign(fl, new AstVarRef(fl, indexVscp, VAccess::WRITE), concatp);
|
return new AstAssign{fl, new AstVarRef{fl, indexVscp, VAccess::WRITE}, concatp};
|
||||||
}
|
}
|
||||||
|
|
||||||
AstArraySel* select(FileLine* fl, AstVarScope* fromp, AstVarScope* indexp) {
|
AstArraySel* select(FileLine* fl, AstVarScope* fromp, AstVarScope* indexp) {
|
||||||
AstVarRef* const fromRefp = new AstVarRef(fl, fromp, VAccess::READ);
|
AstVarRef* const fromRefp = new AstVarRef{fl, fromp, VAccess::READ};
|
||||||
AstVarRef* const indexRefp = new AstVarRef(fl, indexp, VAccess::READ);
|
AstVarRef* const indexRefp = new AstVarRef{fl, indexp, VAccess::READ};
|
||||||
return new AstArraySel(fl, fromRefp, indexRefp);
|
return new AstArraySel{fl, fromRefp, indexRefp};
|
||||||
}
|
}
|
||||||
|
|
||||||
void createOutputAssigns(AstNode* nodep, AstNode* stmtsp, AstVarScope* indexVscp,
|
void createOutputAssigns(AstNode* nodep, AstNode* stmtsp, AstVarScope* indexVscp,
|
||||||
|
|
@ -362,12 +362,12 @@ private:
|
||||||
|
|
||||||
// If this output is unassigned on some code paths, wrap the assignment in an If
|
// If this output is unassigned on some code paths, wrap the assignment in an If
|
||||||
if (tov.mayBeUnassigned()) {
|
if (tov.mayBeUnassigned()) {
|
||||||
V3Number outputChgMask(nodep, m_outVarps.size(), 0);
|
V3Number outputChgMask{nodep, static_cast<int>(m_outVarps.size()), 0};
|
||||||
outputChgMask.setBit(tov.ord(), 1);
|
outputChgMask.setBit(tov.ord(), 1);
|
||||||
AstNode* const condp
|
AstNode* const condp
|
||||||
= new AstAnd(fl, select(fl, outputAssignedTableVscp, indexVscp),
|
= new AstAnd{fl, select(fl, outputAssignedTableVscp, indexVscp),
|
||||||
new AstConst(fl, outputChgMask));
|
new AstConst{fl, outputChgMask}};
|
||||||
outsetp = new AstIf(fl, condp, outsetp);
|
outsetp = new AstIf{fl, condp, outsetp};
|
||||||
}
|
}
|
||||||
|
|
||||||
stmtsp->addNext(outsetp);
|
stmtsp->addNext(outsetp);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue