Internals: Add const. No functional change.
This commit is contained in:
parent
ec4eb18846
commit
512fe0a2d1
|
|
@ -163,7 +163,7 @@ private:
|
|||
} else {
|
||||
++m_statAsNotImm;
|
||||
}
|
||||
bool force = VN_IS(nodep, AssertIntrinsic);
|
||||
const bool force = VN_IS(nodep, AssertIntrinsic);
|
||||
if (passsp) passsp = newIfAssertOn(passsp, force);
|
||||
if (failsp) failsp = newIfAssertOn(failsp, force);
|
||||
if (!failsp) failsp = newFireAssertUnchecked(nodep, "'assert' failed.");
|
||||
|
|
@ -231,7 +231,7 @@ private:
|
|||
} while (ifp);
|
||||
|
||||
AstNode* newifp = nodep->cloneTree(false);
|
||||
bool allow_none = nodep->unique0Pragma();
|
||||
const bool allow_none = nodep->unique0Pragma();
|
||||
|
||||
// Empty case means no property
|
||||
if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse());
|
||||
|
|
@ -305,7 +305,7 @@ private:
|
|||
// Empty case means no property
|
||||
if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse());
|
||||
|
||||
bool allow_none = has_default || nodep->unique0Pragma();
|
||||
const bool allow_none = has_default || nodep->unique0Pragma();
|
||||
AstNode* ohot
|
||||
= (allow_none
|
||||
? static_cast<AstNode*>(new AstOneHot0(nodep->fileline(), propp))
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ string AstNode::encodeName(const string& namein) {
|
|||
// a user identifier nor a temp we create in Verilator.
|
||||
// We also do *NOT* use __DOT__ etc, as we search for those
|
||||
// in some replacements, and don't want to mangle the user's names.
|
||||
unsigned val = pos[0] & 0xff; // Mask to avoid sign extension
|
||||
const unsigned val = pos[0] & 0xff; // Mask to avoid sign extension
|
||||
std::stringstream hex;
|
||||
hex << std::setfill('0') << std::setw(2) << std::hex << val;
|
||||
out += "__0" + hex.str();
|
||||
|
|
@ -1045,7 +1045,7 @@ void AstNode::dumpTreeFileGdb(const AstNode* nodep, // LCOV_EXCL_START
|
|||
cout << "<nullptr>" << endl;
|
||||
return;
|
||||
}
|
||||
string filename = filenamep ? filenamep : v3Global.debugFilename("debug.tree", 98);
|
||||
const string filename = filenamep ? filenamep : v3Global.debugFilename("debug.tree", 98);
|
||||
v3Global.rootp()->dumpTreeFile(filename);
|
||||
} // LCOV_EXCL_STOP
|
||||
|
||||
|
|
@ -1178,7 +1178,7 @@ string AstNode::locationStr() const {
|
|||
str += modp->hierName();
|
||||
return str;
|
||||
} else if ((nvrp = VN_CAST_CONST(backp, NodeVarRef))) {
|
||||
string prettyName = nvrp->prettyName();
|
||||
const string prettyName = nvrp->prettyName();
|
||||
// VarRefs have not been flattened yet and do not contain location information
|
||||
if (prettyName != nvrp->name()) {
|
||||
str += prettyName;
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ AstNetlist::AstNetlist()
|
|||
}
|
||||
|
||||
void AstNetlist::timeprecisionMerge(FileLine*, const VTimescale& value) {
|
||||
VTimescale prec = v3Global.opt.timeComputePrec(value);
|
||||
const VTimescale prec = v3Global.opt.timeComputePrec(value);
|
||||
if (prec.isNone() || prec == m_timeprecision) {
|
||||
} else if (m_timeprecision.isNone()) {
|
||||
m_timeprecision = prec;
|
||||
|
|
@ -343,7 +343,8 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string&
|
|||
string ostatic;
|
||||
if (isStatic() && namespc.empty()) ostatic = "static ";
|
||||
|
||||
bool isRef = isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef()));
|
||||
const bool isRef
|
||||
= isDpiOpenArray() || (forFunc && (isWritable() || direction().isRefOrConstRef()));
|
||||
|
||||
if (forFunc && isReadOnly() && isRef) ostatic = ostatic + "const ";
|
||||
|
||||
|
|
@ -358,7 +359,7 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string&
|
|||
string AstVar::vlEnumType() const {
|
||||
string arg;
|
||||
AstBasicDType* bdtypep = basicp();
|
||||
bool strtype = bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::STRING;
|
||||
const bool strtype = bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::STRING;
|
||||
if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::CHARPTR) {
|
||||
return "VLVT_PTR";
|
||||
} else if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::SCOPEPTR) {
|
||||
|
|
@ -648,7 +649,7 @@ public:
|
|||
};
|
||||
|
||||
string AstNodeDType::cType(const string& name, bool forFunc, bool isRef) const {
|
||||
CTypeRecursed info = cTypeRecurse(false);
|
||||
const CTypeRecursed info = cTypeRecurse(false);
|
||||
return info.render(name, isRef);
|
||||
}
|
||||
|
||||
|
|
@ -1251,8 +1252,9 @@ const char* AstClassPackage::broken() const {
|
|||
return nullptr;
|
||||
}
|
||||
void AstClass::insertCache(AstNode* nodep) {
|
||||
bool doit = (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef)
|
||||
|| (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto()));
|
||||
const bool doit
|
||||
= (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef)
|
||||
|| (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto()));
|
||||
if (doit) {
|
||||
if (m_members.find(nodep->name()) != m_members.end()) {
|
||||
nodep->v3error("Duplicate declaration of member name: " << nodep->prettyNameQ());
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ public:
|
|||
refDTypep(nullptr);
|
||||
setOp2p(rangep);
|
||||
dtypep(nullptr); // V3Width will resolve
|
||||
int width = subDTypep()->width() * rangep->elementsConst();
|
||||
const int width = subDTypep()->width() * rangep->elementsConst();
|
||||
widthForce(width, width);
|
||||
}
|
||||
AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep)
|
||||
|
|
@ -693,7 +693,7 @@ public:
|
|||
refDTypep(dtp);
|
||||
setOp2p(rangep);
|
||||
dtypep(this);
|
||||
int width = subDTypep()->width() * rangep->elementsConst();
|
||||
const int width = subDTypep()->width() * rangep->elementsConst();
|
||||
widthForce(width, width);
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(PackArrayDType)
|
||||
|
|
@ -848,7 +848,7 @@ private:
|
|||
numeric(numer);
|
||||
if (!rangep && (wantwidth || wantwidthmin >= 0)) { // Constant width
|
||||
if (wantwidth > 1) m.m_nrange.init(wantwidth - 1, 0, false);
|
||||
int wmin = wantwidthmin >= 0 ? wantwidthmin : wantwidth;
|
||||
const int wmin = wantwidthmin >= 0 ? wantwidthmin : wantwidth;
|
||||
widthForce(wantwidth, wmin);
|
||||
} else if (!rangep) { // Set based on keyword properties
|
||||
// V3Width will pull from this width
|
||||
|
|
|
|||
|
|
@ -36,19 +36,19 @@ private:
|
|||
inline T_Data* getUserp(T_Node* nodep) const {
|
||||
// This simplifies statically as T_UserN is constant. In C++17, use 'if constexpr'.
|
||||
if (T_UserN == 1) {
|
||||
VNUser user = nodep->user1u();
|
||||
const VNUser user = nodep->user1u();
|
||||
return user.to<T_Data*>();
|
||||
} else if (T_UserN == 2) {
|
||||
VNUser user = nodep->user2u();
|
||||
const VNUser user = nodep->user2u();
|
||||
return user.to<T_Data*>();
|
||||
} else if (T_UserN == 3) {
|
||||
VNUser user = nodep->user3u();
|
||||
const VNUser user = nodep->user3u();
|
||||
return user.to<T_Data*>();
|
||||
} else if (T_UserN == 4) {
|
||||
VNUser user = nodep->user4u();
|
||||
const VNUser user = nodep->user4u();
|
||||
return user.to<T_Data*>();
|
||||
} else {
|
||||
VNUser user = nodep->user5u();
|
||||
const VNUser user = nodep->user5u();
|
||||
return user.to<T_Data*>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ private:
|
|||
string dottedname = nodep->name() + "__DOT__"; // So always found
|
||||
string::size_type pos;
|
||||
while ((pos = dottedname.find("__DOT__")) != string::npos) {
|
||||
string ident = dottedname.substr(0, pos);
|
||||
const string ident = dottedname.substr(0, pos);
|
||||
dottedname = dottedname.substr(pos + strlen("__DOT__"));
|
||||
if (nodep->name() != "") m_namedScope = dot(m_namedScope, ident);
|
||||
m_unnamedScope = dot(m_unnamedScope, ident);
|
||||
|
|
|
|||
|
|
@ -70,15 +70,15 @@ private:
|
|||
// Do if
|
||||
reset();
|
||||
iterateAndNextNull(nodep->ifsp());
|
||||
int ifLikely = m_likely;
|
||||
int ifUnlikely = m_unlikely;
|
||||
const int ifLikely = m_likely;
|
||||
const int ifUnlikely = m_unlikely;
|
||||
// Do else
|
||||
reset();
|
||||
iterateAndNextNull(nodep->elsesp());
|
||||
int elseLikely = m_likely;
|
||||
int elseUnlikely = m_unlikely;
|
||||
const int elseLikely = m_likely;
|
||||
const int elseUnlikely = m_unlikely;
|
||||
// Compute
|
||||
int likeness = ifLikely - ifUnlikely - (elseLikely - elseUnlikely);
|
||||
const int likeness = ifLikely - ifUnlikely - (elseLikely - elseUnlikely);
|
||||
if (likeness > 0) {
|
||||
nodep->branchPred(VBranchPred::BP_LIKELY);
|
||||
} else if (likeness < 0) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public:
|
|||
UASSERT_OBJ(!(iter != s_nodes.end() && (iter->second & FLAG_ALLOCATED)), nodep,
|
||||
"Newing AstNode object that is already allocated");
|
||||
if (iter == s_nodes.end()) {
|
||||
int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2
|
||||
const int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2
|
||||
s_nodes.emplace(nodep, flags);
|
||||
}
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ public:
|
|||
UASSERT_OBJ(!(iter->second & FLAG_IN_TREE), nodep,
|
||||
"AstNode is already in tree at another location");
|
||||
}
|
||||
int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0);
|
||||
const int or_flags = FLAG_IN_TREE | (linkable ? FLAG_LINKABLE : 0);
|
||||
if (iter == s_nodes.end()) {
|
||||
s_nodes.emplace(nodep, or_flags);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ void V3CCtors::evalAsserts() {
|
|||
if (AstVar* varp = VN_CAST(np, Var)) {
|
||||
if (varp->isPrimaryInish() && !varp->isSc()) {
|
||||
if (AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) {
|
||||
int storedWidth = basicp->widthAlignBytes() * 8;
|
||||
int lastWordWidth = varp->width() % storedWidth;
|
||||
const int storedWidth = basicp->widthAlignBytes() * 8;
|
||||
const int lastWordWidth = varp->width() % storedWidth;
|
||||
if (lastWordWidth != 0) {
|
||||
// if (signal & CONST(upper_non_clean_mask)) { fail; }
|
||||
AstVarRef* const vrefp
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ private:
|
|||
*m_ofp << " ";
|
||||
}
|
||||
*m_ofp << nodep->prettyTypeName() << "\n";
|
||||
string lastPrefix = m_prefix;
|
||||
const string lastPrefix = m_prefix;
|
||||
m_prefix = lastPrefix + "1:";
|
||||
iterateAndNextNull(nodep->op1p());
|
||||
m_prefix = lastPrefix + "2:";
|
||||
|
|
@ -449,7 +449,7 @@ private:
|
|||
if (!vertexp->asyncPath() && level != 0) return false; // Not part of path
|
||||
|
||||
// Other logic in the path
|
||||
string cont = prefix + sep;
|
||||
const string cont = prefix + sep;
|
||||
string nextsep = " ";
|
||||
for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) {
|
||||
CdcEitherVertex* eFromVertexp = static_cast<CdcEitherVertex*>(edgep->fromp());
|
||||
|
|
@ -506,7 +506,8 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc_edges.txt";
|
||||
const string filename
|
||||
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc_edges.txt";
|
||||
const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
|
||||
if (ofp->fail()) v3fatal("Can't write " << filename);
|
||||
*ofp << "Edge Report for " << v3Global.opt.prefix() << '\n';
|
||||
|
|
@ -523,7 +524,7 @@ private:
|
|||
os.setf(std::ios::left);
|
||||
// Module name - doesn't work due to flattening having lost the original
|
||||
// so we assume the modulename matches the filebasename
|
||||
string fname = vvertexp->varScp()->fileline()->filebasename() + ":";
|
||||
const string fname = vvertexp->varScp()->fileline()->filebasename() + ":";
|
||||
os << " " << std::setw(20) << fname;
|
||||
os << " " << std::setw(8) << what;
|
||||
os << " " << std::setw(40) << vvertexp->varScp()->prettyName();
|
||||
|
|
@ -727,7 +728,7 @@ public:
|
|||
// CONSTRUCTORS
|
||||
explicit CdcVisitor(AstNode* nodep) {
|
||||
// Make report of all signal names and what clock edges they have
|
||||
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc.txt";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__cdc.txt";
|
||||
m_ofp = V3File::new_ofstream(filename);
|
||||
if (m_ofp->fail()) v3fatal("Can't write " << filename);
|
||||
m_ofFilename = filename;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ private:
|
|||
void setCppWidth(AstNode* nodep) {
|
||||
nodep->user2(true); // Don't resize it again
|
||||
AstNodeDType* old_dtypep = nodep->dtypep();
|
||||
int width = cppWidth(nodep); // widthMin is unchanged
|
||||
const int width = cppWidth(nodep); // widthMin is unchanged
|
||||
if (old_dtypep->width() != width) {
|
||||
// Since any given dtype's cppWidth() is the same, we can just
|
||||
// remember one conversion for each, and reuse it
|
||||
|
|
@ -103,7 +103,7 @@ private:
|
|||
void setCleanState(AstNode* nodep, CleanState clean) { nodep->user1(clean); }
|
||||
CleanState getCleanState(AstNode* nodep) { return static_cast<CleanState>(nodep->user1()); }
|
||||
bool isClean(AstNode* nodep) {
|
||||
CleanState clstate = getCleanState(nodep);
|
||||
const CleanState clstate = getCleanState(nodep);
|
||||
if (clstate == CS_CLEAN) return true;
|
||||
if (clstate == CS_DIRTY) return false;
|
||||
nodep->v3fatalSrc("Unknown clean state on node: " + nodep->prettyTypeName());
|
||||
|
|
@ -111,8 +111,9 @@ private:
|
|||
}
|
||||
void setClean(AstNode* nodep, bool isClean) {
|
||||
computeCppWidth(nodep); // Just to be sure it's in widthMin
|
||||
bool wholeUint = (nodep->widthMin() == VL_IDATASIZE || nodep->widthMin() == VL_QUADSIZE
|
||||
|| (nodep->widthMin() % VL_EDATASIZE) == 0);
|
||||
const bool wholeUint
|
||||
= (nodep->widthMin() == VL_IDATASIZE || nodep->widthMin() == VL_QUADSIZE
|
||||
|| (nodep->widthMin() % VL_EDATASIZE) == 0);
|
||||
setCleanState(nodep, ((isClean || wholeUint) ? CS_CLEAN : CS_DIRTY));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ private:
|
|||
if (ofuncp->finalsp()) tempp->addStmtsp(ofuncp->finalsp()->unlinkFrBackWithNext());
|
||||
while (tempp->stmtsp()) {
|
||||
AstNode* itemp = tempp->stmtsp()->unlinkFrBack();
|
||||
int stmts = EmitCBaseCounterVisitor(itemp).count();
|
||||
const int stmts = EmitCBaseCounterVisitor(itemp).count();
|
||||
if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) {
|
||||
// Make a new function
|
||||
funcp = new AstCFunc{ofuncp->fileline(), ofuncp->name() + cvtToStr(++funcnum),
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public:
|
|||
}
|
||||
|
||||
void applyBlock(AstNodeBlock* nodep) {
|
||||
AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
|
||||
const AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
|
||||
if (!nodep->unnamed()) {
|
||||
for (const string& i : m_coverageOffBlocks) {
|
||||
if (VString::wildmatch(nodep->name(), i)) {
|
||||
|
|
@ -297,14 +297,14 @@ public:
|
|||
|
||||
void applyBlock(AstNodeBlock* nodep) {
|
||||
// Apply to block at this line
|
||||
AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
|
||||
const AstPragmaType pragma = AstPragmaType::COVERAGE_BLOCK_OFF;
|
||||
if (lineMatch(nodep->fileline()->lineno(), pragma)) {
|
||||
nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma));
|
||||
}
|
||||
}
|
||||
void applyCase(AstCase* nodep) {
|
||||
// Apply to this case at this line
|
||||
int lineno = nodep->fileline()->lineno();
|
||||
const int lineno = nodep->fileline()->lineno();
|
||||
if (lineMatch(lineno, AstPragmaType::FULL_CASE)) nodep->fullPragma(true);
|
||||
if (lineMatch(lineno, AstPragmaType::PARALLEL_CASE)) nodep->parallelPragma(true);
|
||||
}
|
||||
|
|
@ -313,7 +313,7 @@ public:
|
|||
if (m_lastIgnore.lineno != filelinep->lineno()) {
|
||||
// UINFO(9, " ApplyIgnores for " << filelinep->ascii() << endl);
|
||||
// Process all on/offs for lines up to and including the current line
|
||||
int curlineno = filelinep->lastLineno();
|
||||
const int curlineno = filelinep->lastLineno();
|
||||
for (; m_lastIgnore.it != m_ignLines.end(); ++m_lastIgnore.it) {
|
||||
if (m_lastIgnore.it->m_lineno > curlineno) break;
|
||||
// UINFO(9, " Hit " << *m_lastIt << endl);
|
||||
|
|
|
|||
|
|
@ -376,10 +376,10 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
|
|||
AstAnd* andp = VN_CAST(nodep->lhsp(), And);
|
||||
CONST_BITOP_RETURN_IF(!andp, nodep->lhsp());
|
||||
|
||||
auto mask = findLeaf(andp->lhsp(), true);
|
||||
const auto mask = findLeaf(andp->lhsp(), true);
|
||||
CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp());
|
||||
|
||||
LeafInfo leaf = findLeaf(andp->rhsp(), false);
|
||||
const LeafInfo leaf = findLeaf(andp->rhsp(), false);
|
||||
CONST_BITOP_RETURN_IF(!leaf.m_refp, andp->rhsp());
|
||||
|
||||
restorer.disableRestore(); // Now all subtree succeeded
|
||||
|
|
@ -394,7 +394,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
|
|||
}
|
||||
|
||||
virtual void visit(AstNodeBiop* nodep) override {
|
||||
auto isConst = [](AstNode* nodep, vluint64_t v) -> bool {
|
||||
const auto isConst = [](AstNode* nodep, vluint64_t v) -> bool {
|
||||
AstConst* constp = VN_CAST(nodep, Const);
|
||||
return constp && constp->toUQuad() == v;
|
||||
};
|
||||
|
|
@ -452,16 +452,16 @@ class ConstBitOpTreeVisitor final : public AstNVisitor {
|
|||
Restorer restorer{*this};
|
||||
CONST_BITOP_RETURN_IF(!m_polarity, nodep);
|
||||
const bool maskFlip = isOrTree();
|
||||
LeafInfo comp = findLeaf(nodep->lhsp(), true);
|
||||
const LeafInfo comp = findLeaf(nodep->lhsp(), true);
|
||||
CONST_BITOP_RETURN_IF(!comp.m_constp || comp.m_lsb != 0, nodep->lhsp());
|
||||
|
||||
AstAnd* andp = VN_CAST(nodep->rhsp(), And); // comp == (mask & v)
|
||||
CONST_BITOP_RETURN_IF(!andp, nodep->rhsp());
|
||||
|
||||
LeafInfo mask = findLeaf(andp->lhsp(), true);
|
||||
const LeafInfo mask = findLeaf(andp->lhsp(), true);
|
||||
CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp());
|
||||
|
||||
LeafInfo ref = findLeaf(andp->rhsp(), false);
|
||||
const LeafInfo ref = findLeaf(andp->rhsp(), false);
|
||||
CONST_BITOP_RETURN_IF(!ref.m_refp, andp->rhsp());
|
||||
|
||||
restorer.disableRestore(); // Now all checks passed
|
||||
|
|
@ -1002,7 +1002,7 @@ private:
|
|||
|| lp->num().isFourState() || lp->num().isNegative()) {
|
||||
return false;
|
||||
}
|
||||
int newLsb = lp->toSInt() + bp->toSInt();
|
||||
const int newLsb = lp->toSInt() + bp->toSInt();
|
||||
if (newLsb + nodep->widthConst() > ap->width()) return false;
|
||||
//
|
||||
UINFO(9, "SEL(SHIFTR(a,b),l,w) -> SEL(a,l+b,w)\n");
|
||||
|
|
@ -1023,7 +1023,7 @@ private:
|
|||
AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend);
|
||||
if (!extendp) return false;
|
||||
AstNode* smallerp = extendp->lhsp();
|
||||
int subsize = smallerp->width();
|
||||
const int subsize = smallerp->width();
|
||||
AstConst* constp = VN_CAST(nodep->lhsp(), Const);
|
||||
if (!constp) return false;
|
||||
if (!constp->num().isBitsZero(constp->width() - 1, subsize)) return false;
|
||||
|
|
@ -1048,7 +1048,7 @@ private:
|
|||
const AstExtend* extendp = VN_CAST_CONST(nodep->rhsp(), Extend);
|
||||
if (!extendp) return false;
|
||||
AstNode* smallerp = extendp->lhsp();
|
||||
int subsize = smallerp->width();
|
||||
const int subsize = smallerp->width();
|
||||
const AstConst* constp = VN_CAST_CONST(nodep->lhsp(), Const);
|
||||
if (!constp) return false;
|
||||
if (constp->num().isBitsZero(constp->width() - 1, subsize)) return false;
|
||||
|
|
@ -1079,10 +1079,10 @@ private:
|
|||
}
|
||||
// Find range of dtype we are selecting from
|
||||
// Similar code in V3Unknown::AstSel
|
||||
bool doit = true;
|
||||
const bool doit = true;
|
||||
if (m_warn && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && doit) {
|
||||
int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth()
|
||||
+ (nodep->declElWidth() - 1);
|
||||
const int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth()
|
||||
+ (nodep->declElWidth() - 1);
|
||||
if (VN_CAST(nodep->lsbp(), Const)->num().isFourState()
|
||||
|| VN_CAST(nodep->widthp(), Const)->num().isFourState()) {
|
||||
nodep->v3error("Selection index is constantly unknown or tristated: "
|
||||
|
|
@ -1157,7 +1157,7 @@ private:
|
|||
const AstConst* lwidth = VN_CAST_CONST(lhsp->widthp(), Const);
|
||||
const AstConst* rwidth = VN_CAST_CONST(rhsp->widthp(), Const);
|
||||
if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated
|
||||
int rend = (rstart->toSInt() + rwidth->toSInt());
|
||||
const int rend = (rstart->toSInt() + rwidth->toSInt());
|
||||
return (rend == lstart->toSInt());
|
||||
}
|
||||
bool ifMergeAdjacent(AstNode* lhsp, AstNode* rhsp) {
|
||||
|
|
@ -1190,7 +1190,7 @@ private:
|
|||
AstConst* lwidth = VN_CAST(lselp->widthp(), Const);
|
||||
AstConst* rwidth = VN_CAST(rselp->widthp(), Const);
|
||||
if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated
|
||||
int rend = (rstart->toSInt() + rwidth->toSInt());
|
||||
const int rend = (rstart->toSInt() + rwidth->toSInt());
|
||||
// a[i:j] a[j-1:k]
|
||||
if (rend == lstart->toSInt()) return true;
|
||||
// a[i:0] a[msb:j]
|
||||
|
|
@ -1207,8 +1207,8 @@ private:
|
|||
const AstNodeBiop* rp = VN_CAST_CONST(rhsp, NodeBiop);
|
||||
if (!lp || !rp) return false;
|
||||
// {a[]&b[], a[]&b[]}
|
||||
bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp());
|
||||
bool rad = ifMergeAdjacent(lp->rhsp(), rp->rhsp());
|
||||
const bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp());
|
||||
const bool rad = ifMergeAdjacent(lp->rhsp(), rp->rhsp());
|
||||
if (lad && rad) return true;
|
||||
// {a[] & b[]&c[], a[] & b[]&c[]}
|
||||
if (lad && concatMergeable(lp->rhsp(), rp->rhsp())) return true;
|
||||
|
|
@ -1449,10 +1449,10 @@ private:
|
|||
// {a[1], a[0]} -> a[1:0]
|
||||
AstSel* lselp = VN_CAST(nodep->lhsp()->unlinkFrBack(), Sel);
|
||||
AstSel* rselp = VN_CAST(nodep->rhsp()->unlinkFrBack(), Sel);
|
||||
int lstart = lselp->lsbConst();
|
||||
int lwidth = lselp->widthConst();
|
||||
int rstart = rselp->lsbConst();
|
||||
int rwidth = rselp->widthConst();
|
||||
const int lstart = lselp->lsbConst();
|
||||
const int lwidth = lselp->widthConst();
|
||||
const int rstart = rselp->lsbConst();
|
||||
const int rwidth = rselp->widthConst();
|
||||
|
||||
UASSERT_OBJ((rstart + rwidth) == lstart, nodep,
|
||||
"tried to merge two selects which are not adjacent");
|
||||
|
|
@ -1513,7 +1513,7 @@ private:
|
|||
}
|
||||
void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl);
|
||||
int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
AstNode* opp = nodep->rhsp()->unlinkFrBack();
|
||||
AstShiftL* newp
|
||||
= new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
|
||||
|
|
@ -1523,7 +1523,7 @@ private:
|
|||
}
|
||||
void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl);
|
||||
int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
AstNode* opp = nodep->lhsp()->unlinkFrBack();
|
||||
AstShiftR* newp
|
||||
= new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
|
||||
|
|
@ -1533,7 +1533,7 @@ private:
|
|||
}
|
||||
void replaceModAnd(AstModDiv* nodep) { // Mod, but not ModS as not simple shift
|
||||
UINFO(5, "MOD(b,2^n)->AND(b,2^n-1) " << nodep << endl);
|
||||
int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
V3Number mask(nodep, nodep->width());
|
||||
mask.setMask(amount);
|
||||
AstNode* opp = nodep->lhsp()->unlinkFrBack();
|
||||
|
|
@ -1576,7 +1576,7 @@ private:
|
|||
if (nodep->type() == lhsp->type()) {
|
||||
int shift1 = VN_CAST(shift1p, Const)->toUInt();
|
||||
int shift2 = VN_CAST(shift2p, Const)->toUInt();
|
||||
int newshift = shift1 + shift2;
|
||||
const int newshift = shift1 + shift2;
|
||||
VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
|
||||
VL_DO_DANGLING(shift2p->deleteTree(), shift2p);
|
||||
nodep->lhsp(ap);
|
||||
|
|
@ -1588,7 +1588,7 @@ private:
|
|||
if (VN_IS(lhsp, ShiftR)) shift1 = -shift1;
|
||||
int shift2 = VN_CAST(shift2p, Const)->toUInt();
|
||||
if (VN_IS(nodep, ShiftR)) shift2 = -shift2;
|
||||
int newshift = shift1 + shift2;
|
||||
const int newshift = shift1 + shift2;
|
||||
VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
|
||||
VL_DO_DANGLING(shift2p->deleteTree(), shift2p);
|
||||
AstNode* newp;
|
||||
|
|
@ -1656,7 +1656,7 @@ private:
|
|||
&& (con2p->toSInt() != con1p->toSInt() + sel1p->width())) {
|
||||
return false;
|
||||
}
|
||||
bool lsbFirstAssign = (con1p->toUInt() < con2p->toUInt());
|
||||
const bool lsbFirstAssign = (con1p->toUInt() < con2p->toUInt());
|
||||
UINFO(4, "replaceAssignMultiSel " << nodep << endl);
|
||||
UINFO(4, " && " << nextp << endl);
|
||||
// nodep->dumpTree(cout, "comb1: ");
|
||||
|
|
@ -1815,8 +1815,8 @@ private:
|
|||
return true;
|
||||
} else if (m_doV && VN_IS(nodep->lhsp(), StreamL)) {
|
||||
// Push the stream operator to the rhs of the assignment statement
|
||||
int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width();
|
||||
int sWidth = nodep->rhsp()->width();
|
||||
const int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width();
|
||||
const int sWidth = nodep->rhsp()->width();
|
||||
// Unlink the stuff
|
||||
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_CAST(nodep->lhsp(), StreamL)->unlinkFrBack();
|
||||
|
|
@ -1836,8 +1836,8 @@ private:
|
|||
// The right stream operator on lhs of assignment statement does
|
||||
// not reorder bits. However, if the rhs is wider than the lhs,
|
||||
// then we select bits from the left-most, not the right-most.
|
||||
int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width();
|
||||
int sWidth = nodep->rhsp()->width();
|
||||
const int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width();
|
||||
const int sWidth = nodep->rhsp()->width();
|
||||
// Unlink the stuff
|
||||
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack();
|
||||
AstNode* sizep = VN_CAST(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack();
|
||||
|
|
@ -2666,7 +2666,7 @@ private:
|
|||
string fmt;
|
||||
bool inPct = false;
|
||||
AstNode* argp = nodep->exprsp();
|
||||
string text = nodep->text();
|
||||
const string text = nodep->text();
|
||||
for (const char ch : text) {
|
||||
if (!inPct && ch == '%') {
|
||||
inPct = true;
|
||||
|
|
@ -2688,7 +2688,8 @@ private:
|
|||
if (argp) {
|
||||
AstNode* nextp = argp->nextp();
|
||||
if (VN_IS(argp, Const)) { // Convert it
|
||||
string out = VN_CAST(argp, Const)->num().displayed(nodep, fmt);
|
||||
const string out
|
||||
= VN_CAST(argp, Const)->num().displayed(nodep, fmt);
|
||||
UINFO(9, " DispConst: " << fmt << " -> " << out << " for "
|
||||
<< argp << endl);
|
||||
// fmt = out w/ replace % with %% as it must be literal.
|
||||
|
|
@ -2726,10 +2727,10 @@ private:
|
|||
iterateChildren(nodep);
|
||||
}
|
||||
virtual void visit(AstWhile* nodep) override {
|
||||
bool oldHasJumpDelay = m_hasJumpDelay;
|
||||
const bool oldHasJumpDelay = m_hasJumpDelay;
|
||||
m_hasJumpDelay = false;
|
||||
{ iterateChildren(nodep); }
|
||||
bool thisWhileHasJumpDelay = m_hasJumpDelay;
|
||||
const bool thisWhileHasJumpDelay = m_hasJumpDelay;
|
||||
m_hasJumpDelay = thisWhileHasJumpDelay || oldHasJumpDelay;
|
||||
if (m_doNConst) {
|
||||
if (nodep->condp()->isZero()) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ private:
|
|||
// See also similar rule in V3TraceDecl::varIgnoreTrace
|
||||
if (!nodep->isToggleCoverable()) return "Not relevant signal type";
|
||||
if (!v3Global.opt.coverageUnderscore()) {
|
||||
string prettyName = nodep->prettyName();
|
||||
const string prettyName = nodep->prettyName();
|
||||
if (prettyName[0] == '_') return "Leading underscore";
|
||||
if (prettyName.find("._") != string::npos) return "Inlined leading underscore";
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ private:
|
|||
// Note the module name could have parameters appended, we'll consider this
|
||||
// a feature as it allows for each parameterized block to be counted separately.
|
||||
// Someday the user might be allowed to specify a different page suffix
|
||||
string page = page_prefix + "/" + m_modp->prettyName();
|
||||
const string page = page_prefix + "/" + m_modp->prettyName();
|
||||
|
||||
AstCoverDecl* declp = new AstCoverDecl(fl, page, comment, linescov, offset);
|
||||
declp->hier(hier);
|
||||
|
|
@ -144,7 +144,7 @@ private:
|
|||
if (it == m_varnames.end()) {
|
||||
m_varnames.emplace(name, 1);
|
||||
} else {
|
||||
int suffix = (it->second)++;
|
||||
const int suffix = (it->second)++;
|
||||
name += "_" + cvtToStr(suffix);
|
||||
}
|
||||
return name;
|
||||
|
|
@ -278,7 +278,7 @@ private:
|
|||
// We'll do this, and make the if(...) coverinc later.
|
||||
|
||||
// Add signal to hold the old value
|
||||
string newvarname = string("__Vtogcov__") + nodep->shortName();
|
||||
const string newvarname = string("__Vtogcov__") + nodep->shortName();
|
||||
AstVar* chgVarp
|
||||
= new AstVar(nodep->fileline(), AstVarType::MODULETEMP, newvarname, nodep);
|
||||
chgVarp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true);
|
||||
|
|
@ -312,7 +312,7 @@ private:
|
|||
if (bdtypep->isRanged()) {
|
||||
for (int index_docs = bdtypep->lo(); index_docs < bdtypep->hi() + 1;
|
||||
++index_docs) {
|
||||
int index_code = index_docs - bdtypep->lo();
|
||||
const int index_code = index_docs - bdtypep->lo();
|
||||
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
|
||||
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
|
||||
index_code, 1),
|
||||
|
|
@ -326,7 +326,7 @@ private:
|
|||
}
|
||||
} else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
|
||||
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
|
||||
int index_code = index_docs - adtypep->lo();
|
||||
const int index_code = index_docs - adtypep->lo();
|
||||
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
|
||||
new AstArraySel(varp->fileline(),
|
||||
above.m_varRefp->cloneTree(true), index_code),
|
||||
|
|
@ -339,7 +339,7 @@ private:
|
|||
} else if (AstPackArrayDType* adtypep = VN_CAST(dtypep, PackArrayDType)) {
|
||||
for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) {
|
||||
AstNodeDType* subtypep = adtypep->subDTypep()->skipRefp();
|
||||
int index_code = index_docs - adtypep->lo();
|
||||
const int index_code = index_docs - adtypep->lo();
|
||||
ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]",
|
||||
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
|
||||
index_code * subtypep->width(), subtypep->width()),
|
||||
|
|
@ -354,7 +354,7 @@ private:
|
|||
for (AstMemberDType* itemp = adtypep->membersp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
AstNodeDType* subtypep = itemp->subDTypep()->skipRefp();
|
||||
int index_code = itemp->lsb();
|
||||
const int index_code = itemp->lsb();
|
||||
ToggleEnt newent(above.m_comment + string(".") + itemp->name(),
|
||||
new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true),
|
||||
index_code, subtypep->width()),
|
||||
|
|
@ -385,17 +385,18 @@ private:
|
|||
UINFO(4, " IF: " << nodep << endl);
|
||||
if (m_state.m_on) {
|
||||
// An else-if. When we iterate the if, use "elsif" marking
|
||||
bool elsif = nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp();
|
||||
const bool elsif
|
||||
= nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp();
|
||||
if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true);
|
||||
bool first_elsif = !nodep->user1() && elsif;
|
||||
bool cont_elsif = nodep->user1() && elsif;
|
||||
bool final_elsif = nodep->user1() && !elsif && nodep->elsesp();
|
||||
const bool first_elsif = !nodep->user1() && elsif;
|
||||
const bool cont_elsif = nodep->user1() && elsif;
|
||||
const bool final_elsif = nodep->user1() && !elsif && nodep->elsesp();
|
||||
//
|
||||
// Considered: If conditional is on a different line from if/else then we
|
||||
// can show it as part of line coverage of the statement
|
||||
// above. Otherwise show it based on what is inside.
|
||||
// But: Seemed too complicated, and fragile.
|
||||
CheckState lastState = m_state;
|
||||
const CheckState lastState = m_state;
|
||||
CheckState ifState;
|
||||
CheckState elseState;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ private:
|
|||
if (!lastrefp) {
|
||||
vscp->user5p(nodep);
|
||||
} else {
|
||||
bool last_was_blocking = lastrefp->user5();
|
||||
const bool last_was_blocking = lastrefp->user5();
|
||||
if (last_was_blocking != blocking) {
|
||||
AstNode* nonblockingp = blocking ? nodep : lastrefp;
|
||||
AstNode* blockingp = blocking ? lastrefp : nodep;
|
||||
|
|
@ -228,7 +228,7 @@ private:
|
|||
UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp");
|
||||
varrefp->unlinkFrBack();
|
||||
AstVar* oldvarp = varrefp->varp();
|
||||
int modVecNum = m_scopeVecMap[varrefp->varScopep()]++;
|
||||
const int modVecNum = m_scopeVecMap[varrefp->varScopep()]++;
|
||||
//
|
||||
std::deque<AstNode*> dimreadps; // Read value for each dimension of assignment
|
||||
for (unsigned dimension = 0; dimension < dimvalp.size(); dimension++) {
|
||||
|
|
@ -236,8 +236,8 @@ private:
|
|||
if (VN_IS(dimp, Const)) { // bit = const, can just use it
|
||||
dimreadps.push_front(dimp);
|
||||
} else {
|
||||
string bitvarname = (string("__Vdlyvdim") + cvtToStr(dimension) + "__"
|
||||
+ oldvarp->shortName() + "__v" + cvtToStr(modVecNum));
|
||||
const string bitvarname = (string("__Vdlyvdim") + cvtToStr(dimension) + "__"
|
||||
+ oldvarp->shortName() + "__v" + cvtToStr(modVecNum));
|
||||
AstVarScope* bitvscp
|
||||
= createVarSc(varrefp->varScopep(), bitvarname, dimp->width(), nullptr);
|
||||
AstAssign* bitassignp = new AstAssign(
|
||||
|
|
@ -256,8 +256,8 @@ private:
|
|||
// vlsb = constant, can just push constant into where we use it
|
||||
bitreadp = lsbvaluep;
|
||||
} else {
|
||||
string bitvarname = (string("__Vdlyvlsb__") + oldvarp->shortName() + "__v"
|
||||
+ cvtToStr(modVecNum));
|
||||
const string bitvarname = (string("__Vdlyvlsb__") + oldvarp->shortName() + "__v"
|
||||
+ cvtToStr(modVecNum));
|
||||
AstVarScope* bitvscp
|
||||
= createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width(), nullptr);
|
||||
AstAssign* bitassignp = new AstAssign(
|
||||
|
|
@ -440,7 +440,7 @@ private:
|
|||
checkActivePost(nodep, oldactivep);
|
||||
}
|
||||
if (!dlyvscp) { // First use of this delayed variable
|
||||
string newvarname = (string("__Vdly__") + nodep->varp()->shortName());
|
||||
const string newvarname = (string("__Vdly__") + nodep->varp()->shortName());
|
||||
dlyvscp = createVarSc(oldvscp, newvarname, 0, nullptr);
|
||||
AstNodeAssign* prep;
|
||||
AstBasicDType* basicp = oldvscp->dtypep()->basicp();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ private:
|
|||
UINFO(6, " Deep " << nodep << endl);
|
||||
// if (debug() >= 9) nodep->dumpTree(cout, "deep:");
|
||||
|
||||
string newvarname = (string("__Vdeeptemp") + cvtToStr(m_modp->varNumGetInc()));
|
||||
const string newvarname = (string("__Vdeeptemp") + cvtToStr(m_modp->varNumGetInc()));
|
||||
AstVar* varp
|
||||
= new AstVar(nodep->fileline(), AstVarType::STMTTEMP, newvarname, nodep->dtypep());
|
||||
UASSERT_OBJ(m_cfuncp, nodep, "Deep expression not under a function");
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ private:
|
|||
// If for any given name only one function exists, we can use that function directly.
|
||||
// If multiple functions exist, we need to select the appropriate scope.
|
||||
for (FuncMmap::iterator it = m_modFuncs.begin(); it != m_modFuncs.end(); ++it) {
|
||||
string name = it->first;
|
||||
const string name = it->first;
|
||||
AstCFunc* topFuncp = it->second;
|
||||
auto nextIt1 = it;
|
||||
++nextIt1;
|
||||
|
|
@ -133,7 +133,8 @@ private:
|
|||
AstCFunc* funcp = eachIt->second;
|
||||
auto nextIt2 = eachIt;
|
||||
++nextIt2;
|
||||
bool moreOfSame = (nextIt2 != m_modFuncs.end() && nextIt2->first == name);
|
||||
const bool moreOfSame
|
||||
= (nextIt2 != m_modFuncs.end() && nextIt2->first == name);
|
||||
UASSERT_OBJ(funcp->scopep(), funcp, "Not scoped");
|
||||
|
||||
UINFO(6, " Wrapping " << name << " " << funcp << endl);
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ public:
|
|||
// displays are handled in AstDisplay
|
||||
if (!nodep->dpiExport()) {
|
||||
// this is where the DPI import context scope is set
|
||||
string scope = nodep->scopeDpiName();
|
||||
const string scope = nodep->scopeDpiName();
|
||||
putbs("(&(vlSymsp->" + protect("__Vscope_" + scope) + "))");
|
||||
}
|
||||
}
|
||||
|
|
@ -1520,15 +1520,15 @@ class EmitCImp final : EmitCStmts {
|
|||
if (v3Global.opt.lintOnly()) {
|
||||
// Unfortunately we have some lint checks here, so we can't just skip processing.
|
||||
// We should move them to a different stage.
|
||||
string filename = VL_DEV_NULL;
|
||||
const string filename = VL_DEV_NULL;
|
||||
newCFile(filename, slow, source);
|
||||
ofp = new V3OutCFile(filename);
|
||||
} else if (optSystemC()) {
|
||||
string filename = filenameNoExt + (source ? ".cpp" : ".h");
|
||||
const string filename = filenameNoExt + (source ? ".cpp" : ".h");
|
||||
newCFile(filename, slow, source);
|
||||
ofp = new V3OutScFile(filename);
|
||||
} else {
|
||||
string filename = filenameNoExt + (source ? ".cpp" : ".h");
|
||||
const string filename = filenameNoExt + (source ? ".cpp" : ".h");
|
||||
newCFile(filename, slow, source);
|
||||
ofp = new V3OutCFile(filename);
|
||||
}
|
||||
|
|
@ -1800,30 +1800,30 @@ class EmitCImp final : EmitCStmts {
|
|||
// Returns string to do resetting, empty to do nothing (which caller should handle)
|
||||
if (AstAssocArrayDType* adtypep = VN_CAST(dtypep, AssocArrayDType)) {
|
||||
// Access std::array as C array
|
||||
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
|
||||
suffix + ".atDefault()" + cvtarray);
|
||||
} else if (VN_IS(dtypep, ClassRefDType)) {
|
||||
return ""; // Constructor does it
|
||||
} else if (AstDynArrayDType* adtypep = VN_CAST(dtypep, DynArrayDType)) {
|
||||
// Access std::array as C array
|
||||
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
|
||||
suffix + ".atDefault()" + cvtarray);
|
||||
} else if (AstQueueDType* adtypep = VN_CAST(dtypep, QueueDType)) {
|
||||
// Access std::array as C array
|
||||
string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : "");
|
||||
return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1,
|
||||
suffix + ".atDefault()" + cvtarray);
|
||||
} else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) {
|
||||
UASSERT_OBJ(adtypep->hi() >= adtypep->lo(), varp,
|
||||
"Should have swapped msb & lsb earlier.");
|
||||
string ivar = string("__Vi") + cvtToStr(depth);
|
||||
string pre = ("for (int " + ivar + "=" + cvtToStr(0) + "; " + ivar + "<"
|
||||
+ cvtToStr(adtypep->elementsConst()) + "; ++" + ivar + ") {\n");
|
||||
string below = emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(),
|
||||
depth + 1, suffix + "[" + ivar + "]");
|
||||
string post = "}\n";
|
||||
const string ivar = string("__Vi") + cvtToStr(depth);
|
||||
const string pre = ("for (int " + ivar + "=" + cvtToStr(0) + "; " + ivar + "<"
|
||||
+ cvtToStr(adtypep->elementsConst()) + "; ++" + ivar + ") {\n");
|
||||
const string below = emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(),
|
||||
depth + 1, suffix + "[" + ivar + "]");
|
||||
const string post = "}\n";
|
||||
return below.empty() ? "" : pre + below + post;
|
||||
} else if (basicp && basicp->keyword() == AstBasicDTypeKwd::STRING) {
|
||||
// String's constructor deals with it
|
||||
|
|
@ -2224,9 +2224,9 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
|
|||
ofp()->putsQuoted(emitDispState.m_format);
|
||||
// Arguments
|
||||
for (unsigned i = 0; i < emitDispState.m_argsp.size(); i++) {
|
||||
char fmt = emitDispState.m_argsChar[i];
|
||||
const char fmt = emitDispState.m_argsChar[i];
|
||||
AstNode* argp = emitDispState.m_argsp[i];
|
||||
string func = emitDispState.m_argsFunc[i];
|
||||
const string func = emitDispState.m_argsFunc[i];
|
||||
if (func != "" || argp) {
|
||||
puts(",");
|
||||
ofp()->indentInc();
|
||||
|
|
@ -2234,7 +2234,7 @@ void EmitCStmts::displayEmit(AstNode* nodep, bool isScan) {
|
|||
if (func != "") {
|
||||
puts(func);
|
||||
} else if (argp) {
|
||||
bool addrof = isScan || (fmt == '@');
|
||||
const bool addrof = isScan || (fmt == '@');
|
||||
if (addrof) puts("&(");
|
||||
iterate(argp);
|
||||
if (!addrof) emitDatap(argp);
|
||||
|
|
@ -2287,7 +2287,7 @@ void EmitCStmts::displayArg(AstNode* dispp, AstNode** elistp, bool isScan, const
|
|||
// + 1.0 rounding bias.
|
||||
double dchars = mantissabits / 3.321928094887362 + 1.0;
|
||||
if (fmtLetter == 'd') dchars++; // space for sign
|
||||
int nchars = int(dchars);
|
||||
const int nchars = int(dchars);
|
||||
pfmt = string("%") + cvtToStr(nchars) + fmtLetter;
|
||||
} else {
|
||||
pfmt = string("%") + vfmt + fmtLetter;
|
||||
|
|
@ -2392,7 +2392,7 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep, const str
|
|||
case 'z': displayArg(nodep, &elistp, isScan, vfmt, ignore, 'z'); break;
|
||||
case 'm': {
|
||||
UASSERT_OBJ(scopenamep, nodep, "Display with %m but no AstScopeName");
|
||||
string suffix = scopenamep->scopePrettySymName();
|
||||
const string suffix = scopenamep->scopePrettySymName();
|
||||
if (suffix == "") {
|
||||
emitDispState.pushFormat("%S");
|
||||
} else {
|
||||
|
|
@ -2613,9 +2613,9 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
|
|||
if (v3Global.opt.savable()) {
|
||||
puts("\n// Savable\n");
|
||||
for (int de = 0; de < 2; ++de) {
|
||||
string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
|
||||
string funcname = de ? "__Vdeserialize" : "__Vserialize";
|
||||
string op = de ? ">>" : "<<";
|
||||
const string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
|
||||
const string funcname = de ? "__Vdeserialize" : "__Vserialize";
|
||||
const string op = de ? ">>" : "<<";
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
puts("void " + prefixNameProtect(modp) + "::" + protect(funcname) + "(" + classname
|
||||
+ "& os) {\n");
|
||||
|
|
@ -2657,10 +2657,10 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
|
|||
AstNodeDType* elementp = varp->dtypeSkipRefp();
|
||||
for (AstUnpackArrayDType* arrayp = VN_CAST(elementp, UnpackArrayDType);
|
||||
arrayp; arrayp = VN_CAST(elementp, UnpackArrayDType)) {
|
||||
int vecnum = vects++;
|
||||
const int vecnum = vects++;
|
||||
UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp,
|
||||
"Should have swapped msb & lsb earlier.");
|
||||
string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
const string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0));
|
||||
puts("; " + ivar + "<" + cvtToStr(arrayp->elementsConst()));
|
||||
puts("; ++" + ivar + ") {\n");
|
||||
|
|
@ -2673,8 +2673,8 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
|
|||
// (i.e. packed types of more than 64 bits).
|
||||
if (elementp->isWide()
|
||||
&& !(basicp && basicp->keyword() == AstBasicDTypeKwd::STRING)) {
|
||||
int vecnum = vects++;
|
||||
string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
const int vecnum = vects++;
|
||||
const string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(0));
|
||||
puts("; " + ivar + "<" + cvtToStr(elementp->widthWords()));
|
||||
puts("; ++" + ivar + ") {\n");
|
||||
|
|
@ -2731,10 +2731,10 @@ void EmitCImp::emitSensitives() {
|
|||
= VN_CAST(varp->dtypeSkipRefp(), UnpackArrayDType);
|
||||
arrayp;
|
||||
arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) {
|
||||
int vecnum = vects++;
|
||||
const int vecnum = vects++;
|
||||
UASSERT_OBJ(arrayp->hi() >= arrayp->lo(), varp,
|
||||
"Should have swapped msb & lsb earlier.");
|
||||
string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
const string ivar = string("__Vi") + cvtToStr(vecnum);
|
||||
puts("for (int __Vi" + cvtToStr(vecnum) + "=" + cvtToStr(arrayp->lo()));
|
||||
puts("; " + ivar + "<=" + cvtToStr(arrayp->hi()));
|
||||
puts("; ++" + ivar + ") {\n");
|
||||
|
|
@ -2947,7 +2947,7 @@ void EmitCStmts::emitVarList(AstNode* firstp, EisWhich which, const string& pref
|
|||
}
|
||||
if (varp->isStatic() ? !isstatic : isstatic) doit = false;
|
||||
if (doit) {
|
||||
int sigbytes = varp->dtypeSkipRefp()->widthAlignBytes();
|
||||
const int sigbytes = varp->dtypeSkipRefp()->widthAlignBytes();
|
||||
int sortbytes = 9;
|
||||
if (varp->isUsedClock() && varp->widthMin() == 1) {
|
||||
sortbytes = 0;
|
||||
|
|
@ -2966,13 +2966,14 @@ void EmitCStmts::emitVarList(AstNode* firstp, EisWhich which, const string& pref
|
|||
} else if (sigbytes == 1) {
|
||||
sortbytes = 1;
|
||||
}
|
||||
bool anonOk = (v3Global.opt.compLimitMembers() != 0 // Enabled
|
||||
&& !varp->isStatic() && !varp->isIO() // Confusing to user
|
||||
&& !varp->isSc() // Aggregates can't be anon
|
||||
&& (varp->basicp()
|
||||
&& !varp->basicp()->isOpaque()) // Aggregates can't be anon
|
||||
&& which != EVL_FUNC_ALL); // Anon not legal in funcs, and gcc
|
||||
// bug free there anyhow
|
||||
const bool anonOk
|
||||
= (v3Global.opt.compLimitMembers() != 0 // Enabled
|
||||
&& !varp->isStatic() && !varp->isIO() // Confusing to user
|
||||
&& !varp->isSc() // Aggregates can't be anon
|
||||
&& (varp->basicp()
|
||||
&& !varp->basicp()->isOpaque()) // Aggregates can't be anon
|
||||
&& which != EVL_FUNC_ALL); // Anon not legal in funcs, and gcc
|
||||
// bug free there anyhow
|
||||
if (anonOk) {
|
||||
varAnonMap[sortbytes].push_back(varp);
|
||||
} else {
|
||||
|
|
@ -3013,7 +3014,7 @@ void EmitCStmts::emitVarSort(const VarSortMap& vmap, VarVec* sortedp) {
|
|||
using MTaskVarSortMap = std::map<const MTaskIdSet, VarSortMap>;
|
||||
MTaskVarSortMap m2v;
|
||||
for (VarSortMap::const_iterator it = vmap.begin(); it != vmap.end(); ++it) {
|
||||
int size_class = it->first;
|
||||
const int size_class = it->first;
|
||||
const VarVec& vec = it->second;
|
||||
for (const AstVar* varp : vec) { m2v[varp->mtaskIds()][size_class].push_back(varp); }
|
||||
}
|
||||
|
|
@ -3048,8 +3049,8 @@ void EmitCStmts::emitSortedVarList(const VarVec& anons, const VarVec& nonanons,
|
|||
string curVarCmt;
|
||||
// Output anons
|
||||
{
|
||||
int anonMembers = anons.size();
|
||||
int lim = v3Global.opt.compLimitMembers();
|
||||
const int anonMembers = anons.size();
|
||||
const int lim = v3Global.opt.compLimitMembers();
|
||||
int anonL3s = 1;
|
||||
int anonL2s = 1;
|
||||
int anonL1s = 1;
|
||||
|
|
@ -3643,8 +3644,8 @@ class EmitCTrace final : EmitCStmts {
|
|||
}
|
||||
//
|
||||
// fstVarType
|
||||
AstVarType vartype = nodep->varType();
|
||||
AstBasicDTypeKwd kwd = nodep->declKwd();
|
||||
const AstVarType vartype = nodep->varType();
|
||||
const AstBasicDTypeKwd kwd = nodep->declKwd();
|
||||
string fstvt;
|
||||
// Doubles have special decoding properties, so must indicate if a double
|
||||
if (nodep->dtypep()->basicp()->isDouble()) {
|
||||
|
|
@ -3902,7 +3903,7 @@ class EmitCTrace final : EmitCStmts {
|
|||
}
|
||||
}
|
||||
virtual void visit(AstTraceDecl* nodep) override {
|
||||
int enumNum = emitTraceDeclDType(nodep->dtypep());
|
||||
const int enumNum = emitTraceDeclDType(nodep->dtypep());
|
||||
if (nodep->arrayRange().ranged()) {
|
||||
puts("{int i; for (i=0; i<" + cvtToStr(nodep->arrayRange().elements()) + "; i++) {\n");
|
||||
emitTraceInitOne(nodep, enumNum);
|
||||
|
|
@ -3947,7 +3948,7 @@ public:
|
|||
|
||||
static void setParentClassPointers() {
|
||||
// Set user4p in all CFunc and Var to point to the containing AstNodeModule
|
||||
auto setAll = [](AstNodeModule* modp) -> void {
|
||||
const auto setAll = [](AstNodeModule* modp) -> void {
|
||||
for (AstNode* nodep = VN_CAST(modp, NodeModule)->stmtsp(); nodep; nodep = nodep->nextp()) {
|
||||
if (VN_IS(nodep, CFunc) || VN_IS(nodep, Var)) nodep->user4p(modp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
private:
|
||||
// MAIN METHOD
|
||||
void emitInt() {
|
||||
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__main.cpp";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__main.cpp";
|
||||
newCFile(filename, false /*slow*/, true /*source*/);
|
||||
V3OutCFile cf(filename);
|
||||
m_ofp = &cf;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class CMakeEmitter final {
|
|||
|
||||
static void cmake_set(std::ofstream& of, const string& name, const string& value,
|
||||
const string& cache_type = "", const string& docstring = "") {
|
||||
string raw_value = "\"" + value + "\"";
|
||||
const string raw_value = "\"" + value + "\"";
|
||||
cmake_set_raw(of, name, raw_value, cache_type, docstring);
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ class CMakeEmitter final {
|
|||
static void emitOverallCMake() {
|
||||
const std::unique_ptr<std::ofstream> of(
|
||||
V3File::new_ofstream(v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".cmake"));
|
||||
string name = v3Global.opt.prefix();
|
||||
const string name = v3Global.opt.prefix();
|
||||
|
||||
*of << "# Verilated -*- CMake -*-\n";
|
||||
*of << "# DESCR"
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
&& !(VN_IS(nodep, CFunc)
|
||||
&& (VN_CAST(nodep, CFunc)->isConstructor()
|
||||
|| VN_CAST(nodep, CFunc)->isDestructor()))) {
|
||||
string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
const string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
if (rsvd != "") {
|
||||
// Generally V3Name should find all of these and throw SYMRSVDWORD.
|
||||
// We'll still check here because the compiler errors
|
||||
|
|
@ -170,7 +170,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
const auto scpit = m_vpiScopeCandidates.find(scp);
|
||||
if ((scpit != m_vpiScopeCandidates.end())
|
||||
&& (m_scopeNames.find(scp) == m_scopeNames.end())) {
|
||||
auto scopeNameit = m_scopeNames.find(scpit->second.m_symName);
|
||||
const auto scopeNameit = m_scopeNames.find(scpit->second.m_symName);
|
||||
if (scopeNameit == m_scopeNames.end()) {
|
||||
m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
|
||||
} else {
|
||||
|
|
@ -216,9 +216,9 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
}
|
||||
// UINFO(9,"For "<<scopep->name()<<" - "<<varp->name()<<" Scp "<<scpName<<"
|
||||
// Var "<<varBase<<endl);
|
||||
string varBasePretty = AstNode::prettyName(varBase);
|
||||
string scpPretty = AstNode::prettyName(scpName);
|
||||
string scpSym = scopeSymString(scpName);
|
||||
const string varBasePretty = AstNode::prettyName(varBase);
|
||||
const string scpPretty = AstNode::prettyName(scpName);
|
||||
const string scpSym = scopeSymString(scpName);
|
||||
// UINFO(9," scnameins sp "<<scpName<<" sp "<<scpPretty<<" ss "<<scpSym<<endl);
|
||||
if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
|
||||
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
|
||||
|
|
@ -238,7 +238,7 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
++it) {
|
||||
if (it->second.m_type != "SCOPE_MODULE") continue;
|
||||
|
||||
string symName = it->second.m_symName;
|
||||
const string symName = it->second.m_symName;
|
||||
string above = symName;
|
||||
if (above.substr(0, 4) == "TOP.") above.replace(0, 4, "");
|
||||
|
||||
|
|
@ -289,10 +289,11 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
}
|
||||
virtual void visit(AstCellInline* nodep) override {
|
||||
if (v3Global.opt.vpi()) {
|
||||
string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
string name = nodep->scopep()->name() + "__DOT__" + nodep->name();
|
||||
string name_dedot = AstNode::dedotName(name);
|
||||
int timeunit = m_modp->timeunit().powerOfTen();
|
||||
const string type
|
||||
= (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
const string name = nodep->scopep()->name() + "__DOT__" + nodep->name();
|
||||
const string name_dedot = AstNode::dedotName(name);
|
||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||
m_vpiScopeCandidates.insert(
|
||||
std::make_pair(name, ScopeData(scopeSymString(name), name_dedot, timeunit, type)));
|
||||
}
|
||||
|
|
@ -304,19 +305,19 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
m_scopes.emplace_back(std::make_pair(nodep, m_modp));
|
||||
|
||||
if (v3Global.opt.vpi() && !nodep->isTop()) {
|
||||
string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
string name_dedot = AstNode::dedotName(nodep->shortName());
|
||||
int timeunit = m_modp->timeunit().powerOfTen();
|
||||
const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
const string name_dedot = AstNode::dedotName(nodep->shortName());
|
||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||
m_vpiScopeCandidates.insert(
|
||||
std::make_pair(nodep->name(), ScopeData(scopeSymString(nodep->name()), name_dedot,
|
||||
timeunit, type)));
|
||||
}
|
||||
}
|
||||
virtual void visit(AstScopeName* nodep) override {
|
||||
string name = nodep->scopeSymName();
|
||||
const string name = nodep->scopeSymName();
|
||||
// UINFO(9,"scnameins sp "<<nodep->name()<<" sp "<<nodep->scopePrettySymName()
|
||||
// <<" ss"<<name<<endl);
|
||||
int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
|
||||
const int timeunit = m_modp ? m_modp->timeunit().powerOfTen() : 0;
|
||||
if (m_scopeNames.find(name) == m_scopeNames.end()) {
|
||||
m_scopeNames.emplace(
|
||||
name, ScopeData(name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"));
|
||||
|
|
@ -369,7 +370,7 @@ public:
|
|||
|
||||
void EmitCSyms::emitSymHdr() {
|
||||
UINFO(6, __FUNCTION__ << ": " << endl);
|
||||
string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".h";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".h";
|
||||
newCFile(filename, true /*slow*/, false /*source*/);
|
||||
|
||||
if (v3Global.opt.systemC()) {
|
||||
|
|
@ -408,7 +409,8 @@ void EmitCSyms::emitSymHdr() {
|
|||
for (const auto& itr : m_scopeFuncs) {
|
||||
AstCFunc* funcp = itr.second.m_cfuncp;
|
||||
if (funcp->dpiExportImpl()) {
|
||||
string cbtype = protect(v3Global.opt.prefix() + "__Vcb_" + funcp->cname() + "_t");
|
||||
const string cbtype
|
||||
= protect(v3Global.opt.prefix() + "__Vcb_" + funcp->cname() + "_t");
|
||||
types["using " + cbtype + " = void (*) (" + cFuncArgs(funcp) + ");\n"] = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -575,12 +577,12 @@ void EmitCSyms::emitSymImpPreamble() {
|
|||
|
||||
void EmitCSyms::emitScopeHier(bool destroy) {
|
||||
if (v3Global.opt.vpi()) {
|
||||
string verb = destroy ? "Tear down" : "Set up";
|
||||
string method = destroy ? "remove" : "add";
|
||||
const string verb = destroy ? "Tear down" : "Set up";
|
||||
const string method = destroy ? "remove" : "add";
|
||||
puts("\n// " + verb + " scope hierarchy\n");
|
||||
for (ScopeNames::const_iterator it = m_scopeNames.begin(); it != m_scopeNames.end();
|
||||
++it) {
|
||||
string name = it->second.m_prettyName;
|
||||
const string name = it->second.m_prettyName;
|
||||
if (it->first == "TOP") continue;
|
||||
if ((name.find('.') == string::npos) && (it->second.m_type == "SCOPE_MODULE")) {
|
||||
puts("__Vhier." + method + "(0, &" + protect("__Vscope_" + it->second.m_symName)
|
||||
|
|
@ -591,8 +593,8 @@ void EmitCSyms::emitScopeHier(bool destroy) {
|
|||
for (auto it = m_vpiScopeHierarchy.cbegin(); it != m_vpiScopeHierarchy.cend(); ++it) {
|
||||
for (ScopeNameList::const_iterator lit = it->second.begin(); lit != it->second.end();
|
||||
++lit) {
|
||||
string fromname = scopeSymString(it->first);
|
||||
string toname = scopeSymString(*lit);
|
||||
const string fromname = scopeSymString(it->first);
|
||||
const string toname = scopeSymString(*lit);
|
||||
const auto from = vlstd::as_const(m_scopeNames).find(fromname);
|
||||
const auto to = vlstd::as_const(m_scopeNames).find(toname);
|
||||
UASSERT(from != m_scopeNames.end(), fromname + " not in m_scopeNames");
|
||||
|
|
@ -608,7 +610,7 @@ void EmitCSyms::emitScopeHier(bool destroy) {
|
|||
|
||||
void EmitCSyms::emitSymImp() {
|
||||
UINFO(6, __FUNCTION__ << ": " << endl);
|
||||
string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".cpp";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".cpp";
|
||||
AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/);
|
||||
cfilep->support(true);
|
||||
|
||||
|
|
@ -623,9 +625,9 @@ void EmitCSyms::emitSymImp() {
|
|||
|
||||
if (v3Global.opt.savable()) {
|
||||
for (int de = 0; de < 2; ++de) {
|
||||
string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
|
||||
string funcname = de ? "__Vdeserialize" : "__Vserialize";
|
||||
string op = de ? ">>" : "<<";
|
||||
const string classname = de ? "VerilatedDeserialize" : "VerilatedSerialize";
|
||||
const string funcname = de ? "__Vdeserialize" : "__Vserialize";
|
||||
const string op = de ? ">>" : "<<";
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
puts("void " + symClassName() + "::" + protect(funcname) + "(" + classname
|
||||
+ "& os) {\n");
|
||||
|
|
@ -724,7 +726,7 @@ void EmitCSyms::emitSymImp() {
|
|||
if (!modp->isTop()) {
|
||||
checkSplit(false);
|
||||
// first is used by AstCoverDecl's call to __vlCoverInsert
|
||||
bool first = !modp->user1();
|
||||
const bool first = !modp->user1();
|
||||
modp->user1(true);
|
||||
puts(protectIf(scopep->nameDotless(), scopep->protect()) + "."
|
||||
+ protect("__Vconfigure") + "(this, " + (first ? "true" : "false") + ");\n");
|
||||
|
|
@ -878,7 +880,7 @@ void EmitCSyms::emitSymImp() {
|
|||
|
||||
void EmitCSyms::emitDpiHdr() {
|
||||
UINFO(6, __FUNCTION__ << ": " << endl);
|
||||
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h";
|
||||
AstCFile* cfilep = newCFile(filename, false /*slow*/, false /*source*/);
|
||||
cfilep->support(true);
|
||||
V3OutCFile hf(filename);
|
||||
|
|
@ -927,7 +929,7 @@ void EmitCSyms::emitDpiHdr() {
|
|||
|
||||
void EmitCSyms::emitDpiImp() {
|
||||
UINFO(6, __FUNCTION__ << ": " << endl);
|
||||
string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.cpp";
|
||||
const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.cpp";
|
||||
AstCFile* cfilep = newCFile(filename, false /*slow*/, true /*source*/);
|
||||
cfilep->support(true);
|
||||
V3OutCFile hf(filename);
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public:
|
|||
const V3StringSet& cppFiles = v3Global.opt.cppFiles();
|
||||
for (const auto& cppfile : cppFiles) {
|
||||
of.puts("\t" + V3Os::filenameNonExt(cppfile) + " \\\n");
|
||||
string dir = V3Os::filenameDir(cppfile);
|
||||
const string dir = V3Os::filenameDir(cppfile);
|
||||
dirs.insert(dir);
|
||||
}
|
||||
of.puts("\n");
|
||||
|
|
@ -228,7 +228,7 @@ public:
|
|||
of.puts("VPATH += $(VM_USER_DIR)\n");
|
||||
of.puts("\n");
|
||||
for (const string& cppfile : cppFiles) {
|
||||
string basename = V3Os::filenameNonExt(cppfile);
|
||||
const string basename = V3Os::filenameNonExt(cppfile);
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
of.puts(basename + ".o: " + cppfile + "\n");
|
||||
of.puts("\t$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<\n");
|
||||
|
|
|
|||
|
|
@ -850,7 +850,8 @@ void V3EmitV::emitvFiles() {
|
|||
|
||||
void V3EmitV::debugEmitV(const string& stage) {
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v";
|
||||
const string filename
|
||||
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v";
|
||||
V3OutVFile of(filename);
|
||||
EmitVFileVisitor visitor(v3Global.rootp(), &of, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,9 +129,9 @@ class EmitXmlFileVisitor final : public AstNVisitor {
|
|||
outputChildrenEnd(nodep, "");
|
||||
}
|
||||
virtual void visit(AstVar* nodep) override {
|
||||
AstVarType typ = nodep->varType();
|
||||
string kw = nodep->verilogKwd();
|
||||
string vt = nodep->dtypep()->name();
|
||||
const AstVarType typ = nodep->varType();
|
||||
const string kw = nodep->verilogKwd();
|
||||
const string vt = nodep->dtypep()->name();
|
||||
outputTag(nodep, "");
|
||||
if (nodep->isIO()) {
|
||||
puts(" dir=");
|
||||
|
|
@ -183,7 +183,7 @@ class EmitXmlFileVisitor final : public AstNVisitor {
|
|||
}
|
||||
virtual void visit(AstModportVarRef* nodep) override {
|
||||
// Dump direction for Modport references
|
||||
string kw = nodep->direction().xmlKwd();
|
||||
const string kw = nodep->direction().xmlKwd();
|
||||
outputTag(nodep, "");
|
||||
puts(" direction=");
|
||||
putsQuoted(kw);
|
||||
|
|
@ -376,9 +376,9 @@ public:
|
|||
void V3EmitXml::emitxml() {
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
// All-in-one file
|
||||
string filename = (v3Global.opt.xmlOutput().empty()
|
||||
? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml"
|
||||
: v3Global.opt.xmlOutput());
|
||||
const string filename = (v3Global.opt.xmlOutput().empty()
|
||||
? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml"
|
||||
: v3Global.opt.xmlOutput());
|
||||
V3OutXmlFile of(filename);
|
||||
of.putsHeader();
|
||||
of.puts("<!-- DESCR"
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void V3Error::incErrors() {
|
|||
}
|
||||
|
||||
void V3Error::abortIfWarnings() {
|
||||
bool exwarn = warnFatal() && warnCount();
|
||||
const bool exwarn = warnFatal() && warnCount();
|
||||
if (errorCount() && exwarn) {
|
||||
v3fatalExit("Exiting due to " << std::dec << errorCount() << " error(s), " //
|
||||
<< warnCount() << " warning(s)\n");
|
||||
|
|
@ -132,7 +132,7 @@ bool V3Error::isError(V3ErrorCode code, bool supp) {
|
|||
|
||||
string V3Error::msgPrefix() {
|
||||
V3ErrorCode code = s_errorCode;
|
||||
bool supp = s_errorSuppressed;
|
||||
const bool supp = s_errorSuppressed;
|
||||
if (supp) {
|
||||
return "-arning-suppressed: ";
|
||||
} else if (code == V3ErrorCode::USERINFO) {
|
||||
|
|
@ -210,8 +210,8 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) {
|
|||
if (s_messages.find(msg) != s_messages.end()) return;
|
||||
s_messages.insert(msg);
|
||||
if (!locationStr.empty()) {
|
||||
string locationMsg = warnMore() + locationStr + "\n";
|
||||
size_t pos = msg.find('\n');
|
||||
const string locationMsg = warnMore() + locationStr + "\n";
|
||||
const size_t pos = msg.find('\n');
|
||||
msg.insert(pos + 1, locationMsg);
|
||||
}
|
||||
// Output
|
||||
|
|
|
|||
|
|
@ -149,11 +149,11 @@ private:
|
|||
AstNode* newp;
|
||||
// Negative word numbers requested for lhs when it's "before" what we want.
|
||||
// We get a 0 then.
|
||||
int othword = word - shift / VL_EDATASIZE;
|
||||
const int othword = word - shift / VL_EDATASIZE;
|
||||
AstNode* llowp = newAstWordSelClone(lhsp, othword);
|
||||
if (int loffset = VL_BITBIT_E(shift)) {
|
||||
if (const int loffset = VL_BITBIT_E(shift)) {
|
||||
AstNode* lhip = newAstWordSelClone(lhsp, othword - 1);
|
||||
int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword
|
||||
const int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword
|
||||
newp = new AstOr(
|
||||
fl,
|
||||
new AstAnd(fl, new AstConst(fl, AstConst::SizedEData(), VL_MASK_E(loffset)),
|
||||
|
|
@ -448,7 +448,7 @@ private:
|
|||
UASSERT_OBJ(nodep->widthMin() == rhsp->widthConst(), nodep, "Width mismatch");
|
||||
if (!doExpand(nodep)) return false;
|
||||
if (VN_IS(rhsp->lsbp(), Const) && VL_BITBIT_E(rhsp->lsbConst()) == 0) {
|
||||
int lsb = rhsp->lsbConst();
|
||||
const int lsb = rhsp->lsbConst();
|
||||
UINFO(8, " Wordize ASSIGN(SEL,align) " << nodep << endl);
|
||||
for (int w = 0; w < nodep->widthWords(); w++) {
|
||||
addWordAssign(nodep, w, newAstWordSelClone(rhsp->fromp(), w + VL_BITWORD_E(lsb)));
|
||||
|
|
@ -491,15 +491,15 @@ private:
|
|||
// rhsp: may be allones and can remove AND NOT gate
|
||||
// lsbp: constant or variable
|
||||
// Yuk.
|
||||
bool destwide = lhsp->fromp()->isWide();
|
||||
bool ones = nodep->rhsp()->isAllOnesV();
|
||||
const bool destwide = lhsp->fromp()->isWide();
|
||||
const bool ones = nodep->rhsp()->isAllOnesV();
|
||||
if (VN_IS(lhsp->lsbp(), Const)) {
|
||||
// The code should work without this constant test, but it won't
|
||||
// constify as nicely as we'd like.
|
||||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* destp = lhsp->fromp()->unlinkFrBack();
|
||||
int lsb = lhsp->lsbConst();
|
||||
int msb = lhsp->msbConst();
|
||||
const int lsb = lhsp->lsbConst();
|
||||
const int msb = lhsp->msbConst();
|
||||
V3Number maskset(nodep, destp->widthMin());
|
||||
for (int bit = lsb; bit < (msb + 1); bit++) maskset.setBit(bit, 1);
|
||||
V3Number maskold(nodep, destp->widthMin());
|
||||
|
|
@ -659,7 +659,7 @@ private:
|
|||
UINFO(8, " CONCAT " << nodep << endl);
|
||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
int rhsshift = rhsp->widthMin();
|
||||
const int rhsshift = rhsp->widthMin();
|
||||
if (nodep->isQuad() && !lhsp->isQuad()) {
|
||||
lhsp = new AstCCast(nodep->fileline(), lhsp, nodep);
|
||||
}
|
||||
|
|
@ -680,7 +680,7 @@ private:
|
|||
if (!doExpand(rhsp)) return false;
|
||||
// Lhs or Rhs may be word, long, or quad.
|
||||
// newAstWordSelClone nicely abstracts the difference.
|
||||
int rhsshift = rhsp->rhsp()->widthMin();
|
||||
const int rhsshift = rhsp->rhsp()->widthMin();
|
||||
// Sometimes doing the words backwards is preferable.
|
||||
// When we have x={x,foo} backwards is better, when x={foo,x} forward is better
|
||||
// However V3Subst tends to rip this up, so not worth optimizing now.
|
||||
|
|
@ -701,7 +701,7 @@ private:
|
|||
} else {
|
||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||
AstNode* newp;
|
||||
int lhswidth = lhsp->widthMin();
|
||||
const int lhswidth = lhsp->widthMin();
|
||||
if (lhswidth == 1) {
|
||||
UINFO(8, " REPLICATE(w1) " << nodep << endl);
|
||||
newp = new AstNegate(nodep->fileline(), lhsp);
|
||||
|
|
@ -716,7 +716,7 @@ private:
|
|||
}
|
||||
newp = lhsp->cloneTree(true);
|
||||
for (unsigned repnum = 1; repnum < times; repnum++) {
|
||||
int rhsshift = repnum * lhswidth;
|
||||
const int rhsshift = repnum * lhswidth;
|
||||
newp = new AstOr(nodep->fileline(),
|
||||
new AstShiftL(nodep->fileline(), lhsp->cloneTree(true),
|
||||
new AstConst(nodep->fileline(), rhsshift),
|
||||
|
|
@ -734,7 +734,7 @@ private:
|
|||
UINFO(8, " Wordize ASSIGN(REPLICATE) " << nodep << endl);
|
||||
if (!doExpand(rhsp)) return false;
|
||||
AstNode* lhsp = rhsp->lhsp();
|
||||
int lhswidth = lhsp->widthMin();
|
||||
const int lhswidth = lhsp->widthMin();
|
||||
const AstConst* constp = VN_CAST(rhsp->rhsp(), Const);
|
||||
UASSERT_OBJ(constp, rhsp, "Replication value isn't a constant. Checked earlier!");
|
||||
uint32_t times = constp->toUInt();
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ class V3FileDependImp final {
|
|||
time_t mnstime() const { return VL_STAT_MTIME_NSEC(m_stat); } // Nanoseconds
|
||||
void loadStats() {
|
||||
if (!m_stat.st_mtime) {
|
||||
string fn = filename();
|
||||
int err = stat(fn.c_str(), &m_stat);
|
||||
const string fn = filename();
|
||||
const int err = stat(fn.c_str(), &m_stat);
|
||||
if (err != 0) {
|
||||
memset(&m_stat, 0, sizeof(m_stat));
|
||||
m_stat.st_mtime = 1;
|
||||
|
|
@ -181,7 +181,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
|
|||
const std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
|
||||
if (ofp->fail()) v3fatal("Can't write " << filename);
|
||||
|
||||
string cmdline = stripQuotes(cmdlineIn);
|
||||
const string cmdline = stripQuotes(cmdlineIn);
|
||||
*ofp << "# DESCR"
|
||||
<< "IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will.\n";
|
||||
*ofp << "C \"" << cmdline << "\"\n";
|
||||
|
|
@ -219,7 +219,7 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
|
|||
return false;
|
||||
}
|
||||
{
|
||||
string ignore = V3Os::getline(*ifp);
|
||||
const string ignore = V3Os::getline(*ifp);
|
||||
if (ignore.empty()) { /*used*/
|
||||
}
|
||||
}
|
||||
|
|
@ -228,8 +228,8 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
|
|||
*ifp >> chkDir;
|
||||
char quote;
|
||||
*ifp >> quote;
|
||||
string chkCmdline = V3Os::getline(*ifp, '"');
|
||||
string cmdline = stripQuotes(cmdlineIn);
|
||||
const string chkCmdline = V3Os::getline(*ifp, '"');
|
||||
const string cmdline = stripQuotes(cmdlineIn);
|
||||
if (cmdline != chkCmdline) {
|
||||
UINFO(2, " --check-times failed: different command line\n");
|
||||
return false;
|
||||
|
|
@ -254,12 +254,12 @@ inline bool V3FileDependImp::checkTimes(const string& filename, const string& cm
|
|||
*ifp >> chkMnstime;
|
||||
char quote;
|
||||
*ifp >> quote;
|
||||
string chkFilename = V3Os::getline(*ifp, '"');
|
||||
const string chkFilename = V3Os::getline(*ifp, '"');
|
||||
|
||||
V3Options::fileNfsFlush(chkFilename);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
struct stat chkStat;
|
||||
int err = stat(chkFilename.c_str(), &chkStat);
|
||||
const int err = stat(chkFilename.c_str(), &chkStat);
|
||||
if (err != 0) {
|
||||
UINFO(2, " --check-times failed: missing " << chkFilename << endl);
|
||||
return false;
|
||||
|
|
@ -354,7 +354,7 @@ private:
|
|||
}
|
||||
}
|
||||
bool readContentsFile(const string& filename, StrList& outl) {
|
||||
int fd = open(filename.c_str(), O_RDONLY);
|
||||
const int fd = open(filename.c_str(), O_RDONLY);
|
||||
if (fd < 0) return false;
|
||||
m_readEof = false;
|
||||
readBlocks(fd, -1, outl);
|
||||
|
|
@ -365,7 +365,7 @@ private:
|
|||
if (filename != "" || outl.empty()) {} // Prevent unused
|
||||
#ifdef INFILTER_PIPE
|
||||
writeFilter("read \"" + filename + "\"\n");
|
||||
string line = readFilterLine();
|
||||
const string line = readFilterLine();
|
||||
if (line.find("Content-Length") != string::npos) {
|
||||
int len = 0;
|
||||
sscanf(line.c_str(), "Content-Length: %d\n", &len);
|
||||
|
|
@ -402,7 +402,7 @@ private:
|
|||
ssize_t todo = INFILTER_IPC_BUFSIZ;
|
||||
if (size > 0 && size < todo) todo = size;
|
||||
errno = 0;
|
||||
ssize_t got = read(fd, buf, todo);
|
||||
const ssize_t got = read(fd, buf, todo);
|
||||
// UINFO(9,"RD GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl);
|
||||
// usleep(50*1000);
|
||||
if (got > 0) {
|
||||
|
|
@ -431,7 +431,7 @@ private:
|
|||
while (!m_readEof) {
|
||||
StrList outl;
|
||||
readBlocks(m_readFd, 1, outl);
|
||||
string onechar = listString(outl);
|
||||
const string onechar = listString(outl);
|
||||
line += onechar;
|
||||
if (onechar == "\n") {
|
||||
if (line == "\n") {
|
||||
|
|
@ -459,7 +459,7 @@ private:
|
|||
unsigned offset = 0;
|
||||
while (!m_readEof && out.length() > offset) {
|
||||
errno = 0;
|
||||
int got = write(m_writeFd, (out.c_str()) + offset, out.length() - offset);
|
||||
const int got = write(m_writeFd, (out.c_str()) + offset, out.length() - offset);
|
||||
// UINFO(9,"WR GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl);
|
||||
// usleep(50*1000);
|
||||
if (got > 0) {
|
||||
|
|
@ -506,7 +506,7 @@ private:
|
|||
|
||||
UINFO(1, "--pipe-filter: /bin/sh -c " << command << endl);
|
||||
|
||||
pid_t pid = fork();
|
||||
const pid_t pid = fork();
|
||||
if (pid < 0) v3fatal("--pipe-filter: fork failed: " << strerror(errno));
|
||||
if (pid == 0) { // Child
|
||||
UINFO(6, "In child\n");
|
||||
|
|
@ -827,7 +827,7 @@ void V3OutFormatter::putsQuoted(const string& strg) {
|
|||
// Quote \ and " for use inside C programs
|
||||
// Don't use to quote a filename for #include - #include doesn't \ escape.
|
||||
putcNoTracking('"');
|
||||
string quoted = quoteNameControls(strg);
|
||||
const string quoted = quoteNameControls(strg);
|
||||
for (const char c : quoted) putcNoTracking(c);
|
||||
putcNoTracking('"');
|
||||
}
|
||||
|
|
@ -894,8 +894,8 @@ string V3OutFormatter::quoteNameControls(const string& namein, V3OutFormatter::L
|
|||
out += c;
|
||||
} else {
|
||||
// This will also cover \a etc
|
||||
string octal = string("\\") + cvtToStr((c >> 6) & 3) + cvtToStr((c >> 3) & 7)
|
||||
+ cvtToStr(c & 7);
|
||||
const string octal = string("\\") + cvtToStr((c >> 6) & 3) + cvtToStr((c >> 3) & 7)
|
||||
+ cvtToStr(c & 7);
|
||||
out += octal;
|
||||
}
|
||||
}
|
||||
|
|
@ -1003,7 +1003,7 @@ public:
|
|||
out = "PS" + digest.digestSymbol();
|
||||
// See if we can shrink the digest symbol to something smaller
|
||||
for (size_t len = 6; len < out.size() - 3; len += 3) {
|
||||
string tryout = out.substr(0, len);
|
||||
const string tryout = out.substr(0, len);
|
||||
if (m_newIdSet.find(tryout) == m_newIdSet.end()) {
|
||||
out = tryout;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ string FileLineSingleton::filenameLetters(int fileno) {
|
|||
int FileLineSingleton::nameToNumber(const string& filename) {
|
||||
const auto it = vlstd::as_const(m_namemap).find(filename);
|
||||
if (VL_LIKELY(it != m_namemap.end())) return it->second;
|
||||
int num = m_names.size();
|
||||
const int num = m_names.size();
|
||||
m_names.push_back(filename);
|
||||
m_languages.push_back(V3LangCode::mostRecent());
|
||||
m_namemap.emplace(filename, num);
|
||||
|
|
@ -95,7 +95,7 @@ void VFileContent::pushText(const string& text) {
|
|||
}
|
||||
|
||||
// Any leftover text is stored on largest line (might be "")
|
||||
string leftover = m_lines.back() + text;
|
||||
const string leftover = m_lines.back() + text;
|
||||
m_lines.pop_back();
|
||||
|
||||
// Insert line-by-line
|
||||
|
|
@ -125,7 +125,7 @@ string VFileContent::getLine(int lineno) const {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
string text = m_lines[lineno];
|
||||
const string text = m_lines[lineno];
|
||||
UINFO(9, "Get Stream[ct" << m_id << "+" << lineno << "]: " << text);
|
||||
return text;
|
||||
}
|
||||
|
|
@ -399,7 +399,7 @@ string FileLine::warnContext(bool secondary) const {
|
|||
if (!v3Global.opt.context()) return "";
|
||||
string out;
|
||||
if (firstLineno() == lastLineno() && firstColumn()) {
|
||||
string sourceLine = prettySource();
|
||||
const string sourceLine = prettySource();
|
||||
// Don't show super-long lines as can fill screen and unlikely to help user
|
||||
if (!sourceLine.empty() && sourceLine.length() < SHOW_SOURCE_MAX_LENGTH
|
||||
&& sourceLine.length() >= static_cast<size_t>(lastColumn() - 1)) {
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
|
|||
if (logicVertexp->reducible()) {
|
||||
// Can we eliminate?
|
||||
GateOkVisitor okVisitor(logicp, vvertexp->isClock(), false);
|
||||
bool multiInputs = okVisitor.rhsVarRefs().size() > 1;
|
||||
const bool multiInputs = okVisitor.rhsVarRefs().size() > 1;
|
||||
// Was it ok?
|
||||
bool doit = okVisitor.isSimple();
|
||||
if (doit && multiInputs) {
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ V3GraphEdge* V3GraphVertex::findConnectingEdgep(GraphWay way, const V3GraphVerte
|
|||
// O(edges) linear search. Searches search both nodes' edge lists in
|
||||
// parallel. The lists probably aren't _both_ huge, so this is
|
||||
// unlikely to blow up even on fairly nasty graphs.
|
||||
GraphWay inv = way.invert();
|
||||
const GraphWay inv = way.invert();
|
||||
V3GraphEdge* aedgep = this->beginp(way);
|
||||
V3GraphEdge* bedgep = waywardp->beginp(inv);
|
||||
while (aedgep && bedgep) {
|
||||
|
|
@ -340,7 +340,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const {
|
|||
int n = 0;
|
||||
string subgr;
|
||||
for (auto it = subgraphs.cbegin(); it != subgraphs.cend(); ++it) {
|
||||
string vertexSubgraph = it->first;
|
||||
const string vertexSubgraph = it->first;
|
||||
V3GraphVertex* vertexp = it->second;
|
||||
numMap[vertexp] = n;
|
||||
if (subgr != vertexSubgraph) {
|
||||
|
|
@ -366,8 +366,8 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const {
|
|||
for (V3GraphVertex* vertexp = verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) {
|
||||
for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) {
|
||||
if (edgep->weight()) {
|
||||
int fromVnum = numMap[edgep->fromp()];
|
||||
int toVnum = numMap[edgep->top()];
|
||||
const int fromVnum = numMap[edgep->fromp()];
|
||||
const int toVnum = numMap[edgep->top()];
|
||||
*logp << "\tn" << edgep->fromp()->dotName() << fromVnum << " -> n"
|
||||
<< edgep->top()->dotName() << toVnum
|
||||
<< " ["
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ private:
|
|||
|
||||
// Foreach input state (NFA inputs of this DFA state)
|
||||
for (int inIt : inputs) {
|
||||
DfaInput input = inIt;
|
||||
const DfaInput input = inIt;
|
||||
UINFO(9, " ===" << ++i << "=======================\n");
|
||||
UINFO(9, " On input " << cvtToHex(input.toNodep()) << endl);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ GraphPathChecker::~GraphPathChecker() {
|
|||
|
||||
void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) {
|
||||
GraphStreamUnordered order(m_graphp, way);
|
||||
GraphWay rev = way.invert();
|
||||
const GraphWay rev = way.invert();
|
||||
while (const V3GraphVertex* vertexp = order.nextp()) {
|
||||
unsigned critPathCost = 0;
|
||||
for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) {
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ bool V3HierBlockPlan::isHierBlock(const AstNodeModule* modp) const {
|
|||
}
|
||||
|
||||
void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>& gparams) {
|
||||
iterator it = m_blocks.find(modp);
|
||||
const iterator it = m_blocks.find(modp);
|
||||
if (it == m_blocks.end()) {
|
||||
V3HierBlock* hblockp = new V3HierBlock(modp, gparams);
|
||||
UINFO(3, "Add " << modp->prettyNameQ() << " with " << gparams.size() << " parameters"
|
||||
|
|
@ -319,9 +319,9 @@ void V3HierBlockPlan::add(const AstNodeModule* modp, const std::vector<AstVar*>&
|
|||
}
|
||||
|
||||
void V3HierBlockPlan::registerUsage(const AstNodeModule* parentp, const AstNodeModule* childp) {
|
||||
iterator parent = m_blocks.find(parentp);
|
||||
const iterator parent = m_blocks.find(parentp);
|
||||
UASSERT_OBJ(parent != m_blocks.end(), parentp, "must be added");
|
||||
iterator child = m_blocks.find(childp);
|
||||
const iterator child = m_blocks.find(childp);
|
||||
if (child != m_blocks.end()) {
|
||||
UINFO(3, "Found usage relation " << parentp->prettyNameQ() << " uses "
|
||||
<< childp->prettyNameQ() << std::endl);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ private:
|
|||
virtual void visit(AstNodeAssign* nodep) override {
|
||||
// Don't count assignments, as they'll likely flatten out
|
||||
// Still need to iterate though to nullify VarXRefs
|
||||
int oldcnt = m_modp->user4();
|
||||
const int oldcnt = m_modp->user4();
|
||||
iterateChildren(nodep);
|
||||
m_modp->user4(oldcnt);
|
||||
}
|
||||
|
|
@ -191,8 +191,8 @@ private:
|
|||
}
|
||||
modp->user4(statements);
|
||||
|
||||
int allowed = modp->user2();
|
||||
int refs = modp->user3();
|
||||
const int allowed = modp->user2();
|
||||
const int refs = modp->user3();
|
||||
|
||||
// Should we automatically inline this module?
|
||||
// If --flatten is specified, then force everything to be inlined that can be.
|
||||
|
|
@ -282,7 +282,7 @@ private:
|
|||
nodep->unlinkFrBack();
|
||||
m_modp->addInlinesp(nodep);
|
||||
// Rename
|
||||
string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
const string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
nodep->name(name);
|
||||
UINFO(6, " Inline " << nodep << endl);
|
||||
// Do CellInlines under this, but don't move them
|
||||
|
|
@ -290,12 +290,12 @@ private:
|
|||
}
|
||||
virtual void visit(AstCell* nodep) override {
|
||||
// Cell under the inline cell, need to rename to avoid conflicts
|
||||
string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
const string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
nodep->name(name);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
virtual void visit(AstClass* nodep) override {
|
||||
string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
const string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
nodep->name(name);
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ private:
|
|||
}
|
||||
// Variable under the inline cell, need to rename to avoid conflicts
|
||||
// Also clear I/O bits, as it is now local.
|
||||
string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
const string name = m_cellp->name() + "__DOT__" + nodep->name();
|
||||
if (!nodep->isFuncLocal() && !nodep->isClassMember()) nodep->inlineAttrReset(name);
|
||||
if (!m_cellp->isTrace()) nodep->trace(false);
|
||||
if (debug() >= 9) nodep->dumpTree(cout, "varchanged:");
|
||||
|
|
@ -415,7 +415,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstVarXRef* nodep) override {
|
||||
// Track what scope it was originally under so V3LinkDot can resolve it
|
||||
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||
const string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||
nodep->inlinedDots(newdots);
|
||||
for (string tryname = nodep->dotted(); true;) {
|
||||
if (m_renamedInterfaces.count(tryname)) {
|
||||
|
|
@ -434,7 +434,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstNodeFTaskRef* nodep) override {
|
||||
// Track what scope it was originally under so V3LinkDot can resolve it
|
||||
string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||
const string newdots = VString::dot(m_cellp->name(), ".", nodep->inlinedDots());
|
||||
nodep->inlinedDots(newdots);
|
||||
if (m_renamedInterfaces.count(nodep->dotted())) {
|
||||
nodep->dotted(m_cellp->name() + "__DOT__" + nodep->dotted());
|
||||
|
|
@ -659,7 +659,7 @@ private:
|
|||
AstCell* cellp;
|
||||
if ((cellp = VN_CAST(fromVarp->user1p(), Cell)) || (cellp = irdtp->cellp())) {
|
||||
varp->user1p(cellp);
|
||||
string alias = m_scope + "__DOT__" + pinp->name();
|
||||
const string alias = m_scope + "__DOT__" + pinp->name();
|
||||
cellp->addIntfRefp(new AstIntfRef(pinp->fileline(), alias));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ private:
|
|||
AstUnpackArrayDType* arrdtype = VN_CAST(nodep->dtypep(), UnpackArrayDType);
|
||||
AstNode* prevp = nullptr;
|
||||
for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) {
|
||||
string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
const string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl);
|
||||
if (!m_deModVars.find(varNewName)) {
|
||||
AstIfaceRefDType* ifaceRefp
|
||||
|
|
@ -246,15 +246,16 @@ private:
|
|||
m_cellRangep = nodep->rangep();
|
||||
|
||||
AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var);
|
||||
bool isIface = ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType)
|
||||
&& VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(),
|
||||
IfaceRefDType);
|
||||
const bool isIface
|
||||
= ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType)
|
||||
&& VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(),
|
||||
IfaceRefDType);
|
||||
|
||||
// Make all of the required clones
|
||||
for (int i = 0; i < m_cellRangep->elementsConst(); i++) {
|
||||
m_instSelNum
|
||||
= m_cellRangep->littleEndian() ? (m_cellRangep->elementsConst() - 1 - i) : i;
|
||||
int instNum = m_cellRangep->loConst() + i;
|
||||
const int instNum = m_cellRangep->loConst() + i;
|
||||
|
||||
AstCell* newp = nodep->cloneTree(false);
|
||||
nodep->addNextHere(newp);
|
||||
|
|
@ -316,8 +317,8 @@ private:
|
|||
if (!nodep->exprp()) return; // No-connect
|
||||
if (m_cellRangep) {
|
||||
UINFO(4, " PIN " << nodep << endl);
|
||||
int pinwidth = nodep->modVarp()->width();
|
||||
int expwidth = nodep->exprp()->width();
|
||||
const int pinwidth = nodep->modVarp()->width();
|
||||
const int expwidth = nodep->exprp()->width();
|
||||
std::pair<uint32_t, uint32_t> pinDim = nodep->modVarp()->dtypep()->dimensions(false);
|
||||
std::pair<uint32_t, uint32_t> expDim = nodep->exprp()->dtypep()->dimensions(false);
|
||||
UINFO(4, " PINVAR " << nodep->modVarp() << endl);
|
||||
|
|
@ -328,9 +329,9 @@ private:
|
|||
if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) {
|
||||
// Connection to array, where array dimensions match the instant dimension
|
||||
AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep();
|
||||
int arraySelNum = rangep->littleEndian()
|
||||
? (rangep->elementsConst() - 1 - m_instSelNum)
|
||||
: m_instSelNum;
|
||||
const int arraySelNum = rangep->littleEndian()
|
||||
? (rangep->elementsConst() - 1 - m_instSelNum)
|
||||
: m_instSelNum;
|
||||
AstNode* exprp = nodep->exprp()->unlinkFrBack();
|
||||
exprp = new AstArraySel(exprp->fileline(), exprp, arraySelNum);
|
||||
nodep->exprp(exprp);
|
||||
|
|
@ -346,7 +347,7 @@ private:
|
|||
<< m_cellRangep->rightConst() << "]");
|
||||
}
|
||||
AstNode* exprp = nodep->exprp()->unlinkFrBack();
|
||||
bool inputPin = nodep->modVarp()->isNonOutput();
|
||||
const bool inputPin = nodep->modVarp()->isNonOutput();
|
||||
if (!inputPin
|
||||
&& !VN_IS(exprp, VarRef)
|
||||
// V3Const will collapse the SEL with the one we're about to make
|
||||
|
|
@ -373,7 +374,7 @@ private:
|
|||
"Unsupported: Non-constant index when passing interface to module");
|
||||
return;
|
||||
}
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
const string index = AstNode::encodeNumber(constp->toSInt());
|
||||
if (VN_IS(arrselp->lhsp(), SliceSel))
|
||||
arrselp->lhsp()->v3error("Unsupported: interface slices");
|
||||
AstVarRef* varrefp = VN_CAST(arrselp->lhsp(), VarRef);
|
||||
|
|
@ -397,7 +398,7 @@ private:
|
|||
// Clone pin varp:
|
||||
for (int in = 0; in < pinArrp->elementsConst(); ++in) { // 0 = leftmost
|
||||
int i = pinArrp->left() + in * pinArrp->declRange().leftToRightInc();
|
||||
string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
const string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
AstVar* varNewp = nullptr;
|
||||
|
||||
// Only clone the var once for all usages of a given child module
|
||||
|
|
@ -445,7 +446,7 @@ private:
|
|||
expr_i = exprArrp->left() + in * exprArrp->declRange().leftToRightInc();
|
||||
}
|
||||
|
||||
string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__";
|
||||
const string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__";
|
||||
AstVarXRef* newVarXRefp
|
||||
= new AstVarXRef(nodep->fileline(), newname, "", VAccess::WRITE);
|
||||
newVarXRefp->varp(newp->modVarp());
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ private:
|
|||
// Just don't optimize blocks with labels; they're rare - so far.
|
||||
LifeBlock* prevLifep = m_lifep;
|
||||
LifeBlock* bodyLifep = new LifeBlock(prevLifep, m_statep);
|
||||
bool prev_noopt = m_noopt;
|
||||
const bool prev_noopt = m_noopt;
|
||||
{
|
||||
m_lifep = bodyLifep;
|
||||
m_noopt = true;
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ public:
|
|||
: mtaskp{mtaskp_}
|
||||
, sequence{sequence_} {}
|
||||
bool operator<(const LifeLocation& b) const {
|
||||
unsigned a_id = mtaskp ? mtaskp->id() : 0;
|
||||
unsigned b_id = b.mtaskp ? b.mtaskp->id() : 0;
|
||||
const unsigned a_id = mtaskp ? mtaskp->id() : 0;
|
||||
const unsigned b_id = b.mtaskp ? b.mtaskp->id() : 0;
|
||||
if (a_id < b_id) return true;
|
||||
if (b_id < a_id) return false;
|
||||
return sequence < b.sequence;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ private:
|
|||
// Read-subfile
|
||||
// If file not found, make AstNotFoundModule, rather than error out.
|
||||
// We'll throw the error when we know the module will really be needed.
|
||||
string prettyName = AstNode::prettyName(modName);
|
||||
const string prettyName = AstNode::prettyName(modName);
|
||||
V3Parse parser(v3Global.rootp(), m_filterp, m_parseSymp);
|
||||
// true below -> other simulators treat modules in link-found files as library cells
|
||||
parser.parseFile(nodep->fileline(), prettyName, true, "");
|
||||
|
|
@ -217,7 +217,7 @@ private:
|
|||
if (VN_IS(nodep, Iface) || VN_IS(nodep, Package)) {
|
||||
nodep->inLibrary(true); // Interfaces can't be at top, unless asked
|
||||
}
|
||||
bool topMatch = (v3Global.opt.topModule() == nodep->prettyName());
|
||||
const bool topMatch = (v3Global.opt.topModule() == nodep->prettyName());
|
||||
if (topMatch) {
|
||||
m_topVertexp = vertex(nodep);
|
||||
UINFO(2, "Link --top-module: " << nodep << endl);
|
||||
|
|
@ -289,7 +289,7 @@ private:
|
|||
// Execute only once. Complication is that cloning may result in
|
||||
// user1 being set (for pre-clone) so check if user1() matches the
|
||||
// m_mod, if 0 never did it, if !=, it is an unprocessed clone
|
||||
bool cloned = (nodep->user1p() && nodep->user1p() != m_modp);
|
||||
const bool cloned = (nodep->user1p() && nodep->user1p() != m_modp);
|
||||
if (nodep->user1p() == m_modp) return; // AstBind and AstNodeModule may call a cell twice
|
||||
if (v3Global.opt.hierChild() && nodep->modName() == m_origTopModuleName) {
|
||||
if (nodep->modName() == m_modp->origName()) {
|
||||
|
|
@ -432,7 +432,8 @@ private:
|
|||
// classes are better supported may remap interfaces to be more
|
||||
// like a class.
|
||||
if (!nodep->hasIfaceVar()) {
|
||||
string varName = nodep->name() + "__Viftop"; // V3LinkDot looks for this naming
|
||||
const string varName
|
||||
= nodep->name() + "__Viftop"; // V3LinkDot looks for this naming
|
||||
AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(),
|
||||
nodep->modp()->name());
|
||||
idtypep->ifacep(nullptr); // cellp overrides
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public:
|
|||
VL_DEBUG_FUNC; // Declare debug()
|
||||
void dump(const string& nameComment = "linkdot", bool force = false) {
|
||||
if (debug() >= 6 || force) {
|
||||
string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatal("Can't write " << filename);
|
||||
std::ostream& os = *logp;
|
||||
|
|
@ -476,8 +476,8 @@ public:
|
|||
}
|
||||
}
|
||||
if (!ok) {
|
||||
string suggest = suggestSymFallback(ifaceSymp, ifacerefp->modportName(),
|
||||
LinkNodeMatcherModport());
|
||||
const string suggest = suggestSymFallback(ifaceSymp, ifacerefp->modportName(),
|
||||
LinkNodeMatcherModport());
|
||||
ifacerefp->modportFileline()->v3error(
|
||||
"Modport not found under interface "
|
||||
<< ifacerefp->prettyNameQ(ifacerefp->ifaceName()) << ": "
|
||||
|
|
@ -658,8 +658,8 @@ public:
|
|||
|
||||
static string removeLastInlineScope(const string& name) {
|
||||
string out = name;
|
||||
string dot = "__DOT__";
|
||||
size_t dotPos = out.rfind(dot, out.size() - dot.length() - 2);
|
||||
const string dot = "__DOT__";
|
||||
const size_t dotPos = out.rfind(dot, out.size() - dot.length() - 2);
|
||||
if (dotPos == string::npos) {
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -676,12 +676,12 @@ public:
|
|||
<< ((lookupSymp->symPrefix() == "") ? "" : " as ")
|
||||
<< ((lookupSymp->symPrefix() == "") ? "" : lookupSymp->symPrefix() + dotname)
|
||||
<< " at se" << lookupSymp << endl);
|
||||
string prefix = lookupSymp->symPrefix();
|
||||
const string prefix = lookupSymp->symPrefix();
|
||||
VSymEnt* foundp = nullptr;
|
||||
while (!foundp) {
|
||||
foundp = lookupSymp->findIdFallback(prefix + dotname); // Might be nullptr
|
||||
if (prefix.empty()) break;
|
||||
string nextPrefix = removeLastInlineScope(prefix);
|
||||
const string nextPrefix = removeLastInlineScope(prefix);
|
||||
if (prefix == nextPrefix) break;
|
||||
}
|
||||
if (!foundp) baddot = dotname;
|
||||
|
|
@ -778,8 +778,9 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
// m_curSymp/m_modSymp maybe nullptr for packages and non-top modules
|
||||
// Packages will be under top after the initial phases, but until then
|
||||
// need separate handling
|
||||
bool standalonePkg = !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package));
|
||||
bool doit = (m_modSymp || standalonePkg);
|
||||
const bool standalonePkg
|
||||
= !m_modSymp && (m_statep->forPrearray() && VN_IS(nodep, Package));
|
||||
const bool doit = (m_modSymp || standalonePkg);
|
||||
VL_RESTORER(m_scope);
|
||||
VL_RESTORER(m_classOrPackagep);
|
||||
VL_RESTORER(m_modSymp);
|
||||
|
|
@ -888,11 +889,11 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
VL_RESTORER(m_inRecursion);
|
||||
// Where do we add it?
|
||||
VSymEnt* aboveSymp = m_curSymp;
|
||||
string origname = AstNode::dedotName(nodep->name());
|
||||
const string origname = AstNode::dedotName(nodep->name());
|
||||
string::size_type pos;
|
||||
if ((pos = origname.rfind('.')) != string::npos) {
|
||||
// Flattened, find what CellInline it should live under
|
||||
string scope = origname.substr(0, pos);
|
||||
const string scope = origname.substr(0, pos);
|
||||
string baddot;
|
||||
VSymEnt* okSymp;
|
||||
aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, scope, baddot, okSymp);
|
||||
|
|
@ -913,11 +914,11 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
UINFO(5, " CELLINLINE under " << m_scope << " is " << nodep << endl);
|
||||
VSymEnt* aboveSymp = m_curSymp;
|
||||
// If baz__DOT__foo__DOT__bar, we need to find baz__DOT__foo and add bar to it.
|
||||
string dottedname = nodep->name();
|
||||
const string dottedname = nodep->name();
|
||||
string::size_type pos;
|
||||
if ((pos = dottedname.rfind("__DOT__")) != string::npos) {
|
||||
string dotted = dottedname.substr(0, pos);
|
||||
string ident = dottedname.substr(pos + strlen("__DOT__"));
|
||||
const string dotted = dottedname.substr(0, pos);
|
||||
const string ident = dottedname.substr(pos + strlen("__DOT__"));
|
||||
string baddot;
|
||||
VSymEnt* okSymp;
|
||||
aboveSymp = m_statep->findDotted(nodep->fileline(), aboveSymp, dotted, baddot, okSymp);
|
||||
|
|
@ -1004,7 +1005,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
m_classOrPackagep = VN_CAST(m_curSymp->nodep(), Class);
|
||||
}
|
||||
// Create symbol table for the task's vars
|
||||
string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name();
|
||||
const string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name();
|
||||
m_curSymp = m_statep->insertBlock(m_curSymp, name, nodep, m_classOrPackagep);
|
||||
m_curSymp->fallbackp(upSymp);
|
||||
// Convert the func's range to the output variable
|
||||
|
|
@ -1068,7 +1069,8 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
bool nansiBad
|
||||
= ((findvarp->isDeclTyped() && nodep->isDeclTyped())
|
||||
|| (findvarp->isIO() && nodep->isIO())); // e.g. !(output && output)
|
||||
bool ansiBad = findvarp->isAnsi() || nodep->isAnsi(); // dup illegal with ANSI
|
||||
const bool ansiBad
|
||||
= findvarp->isAnsi() || nodep->isAnsi(); // dup illegal with ANSI
|
||||
if (ansiBad || nansiBad) {
|
||||
bool ansiWarn = ansiBad && !nansiBad;
|
||||
if (ansiWarn) {
|
||||
|
|
@ -1134,7 +1136,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
= new AstVar(nodep->fileline(), AstVarType(AstVarType::GPARAM),
|
||||
nodep->name(), nodep);
|
||||
newp->combineType(nodep);
|
||||
string svalue = v3Global.opt.parameter(nodep->name());
|
||||
const string svalue = v3Global.opt.parameter(nodep->name());
|
||||
if (AstNode* valuep
|
||||
= AstConst::parseParamLiteral(nodep->fileline(), svalue)) {
|
||||
newp->valuep(valuep);
|
||||
|
|
@ -1268,12 +1270,12 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
}
|
||||
virtual void visit(AstWithParse* nodep) override {
|
||||
// Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation))
|
||||
auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef);
|
||||
const auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef);
|
||||
UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task");
|
||||
string name = "item";
|
||||
FileLine* argFl = nodep->fileline();
|
||||
if (auto argp = VN_CAST(funcrefp->pinsp(), Arg)) {
|
||||
if (auto parserefp = VN_CAST(argp->exprp(), ParseRef)) {
|
||||
if (const auto argp = VN_CAST(funcrefp->pinsp(), Arg)) {
|
||||
if (const auto parserefp = VN_CAST(argp->exprp(), ParseRef)) {
|
||||
name = parserefp->name();
|
||||
argFl = parserefp->fileline();
|
||||
} else {
|
||||
|
|
@ -1557,7 +1559,7 @@ class LinkDotScopeVisitor final : public AstNVisitor {
|
|||
= LinkDotState::ifaceRefFromArray(nodep->varp()->dtypep());
|
||||
UASSERT_OBJ(dtypep, nodep, "Non AstIfaceRefDType on isIfaceRef() var");
|
||||
UINFO(9, "Iface parent dtype " << dtypep << endl);
|
||||
string ifcellname = dtypep->cellName();
|
||||
const string ifcellname = dtypep->cellName();
|
||||
string baddot;
|
||||
VSymEnt* okSymp;
|
||||
VSymEnt* cellSymp = m_statep->findDotted(nodep->fileline(), m_modSymp, ifcellname,
|
||||
|
|
@ -1644,7 +1646,8 @@ class LinkDotScopeVisitor final : public AstNVisitor {
|
|||
|
||||
UASSERT_OBJ(refp || xrefp, nodep,
|
||||
"Unsupported: Non Var(X)Ref attached to interface pin");
|
||||
string scopename = refp ? refp->varp()->name() : xrefp->dotted() + "." + xrefp->name();
|
||||
const string scopename
|
||||
= refp ? refp->varp()->name() : xrefp->dotted() + "." + xrefp->name();
|
||||
string baddot;
|
||||
VSymEnt* okSymp;
|
||||
VSymEnt* symp = m_statep->findDotted(nodep->lhsp()->fileline(), m_modSymp, scopename,
|
||||
|
|
@ -1844,8 +1847,8 @@ private:
|
|||
if (!nodep->varp()) {
|
||||
if (!noWarn) {
|
||||
if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) {
|
||||
string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar());
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar());
|
||||
nodep->v3error("Signal definition not found, and implicit disabled with "
|
||||
"`default_nettype: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
|
|
@ -1855,8 +1858,8 @@ private:
|
|||
// Bypass looking for suggestions if IMPLICIT is turned off
|
||||
// as there could be thousands of these suppressed in large netlists
|
||||
else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) {
|
||||
string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar());
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar());
|
||||
nodep->v3warn(IMPLICIT,
|
||||
"Signal definition not found, creating implicitly: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
|
|
@ -1905,7 +1908,7 @@ private:
|
|||
}
|
||||
}
|
||||
AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) {
|
||||
string findName = name + "__Viftop";
|
||||
const string findName = name + "__Viftop";
|
||||
VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName);
|
||||
AstVar* ifaceTopVarp = ifaceSymp ? VN_CAST(ifaceSymp->nodep(), Var) : nullptr;
|
||||
UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName);
|
||||
|
|
@ -2057,8 +2060,8 @@ private:
|
|||
// DOT(DOT(DOT(PARSEREF(text), ...
|
||||
if (nodep->user3SetOnce()) return;
|
||||
UINFO(8, " " << nodep << endl);
|
||||
DotStates lastStates = m_ds;
|
||||
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
const DotStates lastStates = m_ds;
|
||||
const bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
{
|
||||
if (start) { // Starting dot sequence
|
||||
if (debug() >= 9) nodep->dumpTree("-dot-in: ");
|
||||
|
|
@ -2088,14 +2091,14 @@ private:
|
|||
nodep->v3error("'super' used outside class (IEEE 1800-2017 8.15)");
|
||||
m_ds.m_dotErr = true;
|
||||
} else {
|
||||
auto classp = VN_CAST(classSymp->nodep(), Class);
|
||||
const auto classp = VN_CAST(classSymp->nodep(), Class);
|
||||
if (!classp->extendsp()) {
|
||||
nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)");
|
||||
m_ds.m_dotErr = true;
|
||||
} else {
|
||||
auto cextp = VN_CAST(classp->extendsp(), ClassExtends);
|
||||
const auto cextp = VN_CAST(classp->extendsp(), ClassExtends);
|
||||
UASSERT_OBJ(cextp, nodep, "Bad super extends link");
|
||||
auto sclassp = cextp->classp();
|
||||
const auto sclassp = cextp->classp();
|
||||
UASSERT_OBJ(sclassp, nodep, "Bad superclass");
|
||||
m_ds.m_dotSymp = m_statep->getNodeSym(sclassp);
|
||||
UINFO(8, " super. " << m_ds.ascii() << endl);
|
||||
|
|
@ -2161,8 +2164,8 @@ private:
|
|||
UASSERT_OBJ(m_statep->forPrimary() || m_statep->forPrearray(), nodep,
|
||||
"ParseRefs should no longer exist");
|
||||
if (nodep->name() == "super") nodep->v3warn(E_UNSUPPORTED, "Unsupported: super");
|
||||
DotStates lastStates = m_ds;
|
||||
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
const DotStates lastStates = m_ds;
|
||||
const bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
if (start) {
|
||||
m_ds.init(m_curSymp);
|
||||
// Note m_ds.m_dot remains nullptr; this is a reference not under a dot
|
||||
|
|
@ -2175,8 +2178,8 @@ private:
|
|||
&& nodep->name() == "index") {
|
||||
// 'with' statement's 'item.index'
|
||||
iterateChildren(nodep);
|
||||
auto newp = new AstLambdaArgRef(nodep->fileline(),
|
||||
m_ds.m_unlinkedScopep->name() + "__DOT__index", true);
|
||||
const auto newp = new AstLambdaArgRef(
|
||||
nodep->fileline(), m_ds.m_unlinkedScopep->name() + "__DOT__index", true);
|
||||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
return;
|
||||
|
|
@ -2304,8 +2307,8 @@ private:
|
|||
}
|
||||
m_ds.m_dotText = "";
|
||||
if (m_ds.m_unresolved && m_ds.m_unlinkedScopep) {
|
||||
string dotted = refp->dotted();
|
||||
size_t pos = dotted.find("__BRA__??__KET__");
|
||||
const string dotted = refp->dotted();
|
||||
const size_t pos = dotted.find("__BRA__??__KET__");
|
||||
// Arrays of interfaces all have the same parameters
|
||||
if (pos != string::npos && varp->isParam()
|
||||
&& VN_IS(m_ds.m_unlinkedScopep, CellArrayRef)) {
|
||||
|
|
@ -2402,9 +2405,9 @@ private:
|
|||
//
|
||||
if (!ok) {
|
||||
// Cells/interfaces can't be implicit
|
||||
bool isCell = foundp ? VN_IS(foundp->nodep(), Cell) : false;
|
||||
bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText == "" && !isCell);
|
||||
bool err = !(checkImplicit && m_statep->implicitOk(m_modp, nodep->name()));
|
||||
const bool isCell = foundp ? VN_IS(foundp->nodep(), Cell) : false;
|
||||
const bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText == "" && !isCell);
|
||||
const bool err = !(checkImplicit && m_statep->implicitOk(m_modp, nodep->name()));
|
||||
if (err) {
|
||||
if (foundp) {
|
||||
nodep->v3error("Found definition of '"
|
||||
|
|
@ -2415,7 +2418,7 @@ private:
|
|||
} else if (m_ds.m_dotText == "") {
|
||||
UINFO(7, " ErrParseRef curSymp=se" << cvtToHex(m_curSymp)
|
||||
<< " ds=" << m_ds.ascii() << endl);
|
||||
string suggest = m_statep->suggestSymFallback(
|
||||
const string suggest = m_statep->suggestSymFallback(
|
||||
m_ds.m_dotSymp, nodep->name(), VNodeMatcher());
|
||||
nodep->v3error("Can't find definition of "
|
||||
<< expectWhat << ": " << nodep->prettyNameQ() << '\n'
|
||||
|
|
@ -2486,7 +2489,7 @@ private:
|
|||
// variable name lower down with same scope name we want to
|
||||
// ignore (t_math_divw)
|
||||
dotSymp = m_modSymp;
|
||||
string inl = AstNode::dedotName(nodep->inlinedDots());
|
||||
const string inl = AstNode::dedotName(nodep->inlinedDots());
|
||||
dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp);
|
||||
UASSERT_OBJ(dotSymp, nodep,
|
||||
"Couldn't resolve inlined scope " << AstNode::prettyNameQ(baddot)
|
||||
|
|
@ -2641,7 +2644,7 @@ private:
|
|||
// variable name lower down with same scope name we want
|
||||
// to ignore (t_math_divw)
|
||||
dotSymp = m_modSymp;
|
||||
string inl = AstNode::dedotName(nodep->inlinedDots());
|
||||
const string inl = AstNode::dedotName(nodep->inlinedDots());
|
||||
UINFO(8, " Inlined " << inl << endl);
|
||||
dotSymp
|
||||
= m_statep->findDotted(nodep->fileline(), dotSymp, inl, baddot, okSymp);
|
||||
|
|
@ -2708,15 +2711,15 @@ private:
|
|||
"Unsupported or unknown PLI call: " << nodep->prettyNameQ());
|
||||
}
|
||||
} else {
|
||||
string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(),
|
||||
LinkNodeMatcherFTask());
|
||||
const string suggest = m_statep->suggestSymFallback(
|
||||
dotSymp, nodep->name(), LinkNodeMatcherFTask());
|
||||
nodep->v3error("Can't find definition of task/function: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
<< (suggest.empty() ? "" : nodep->warnMore() + suggest));
|
||||
}
|
||||
} else {
|
||||
string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(),
|
||||
LinkNodeMatcherFTask());
|
||||
const string suggest = m_statep->suggestSymFallback(dotSymp, nodep->name(),
|
||||
LinkNodeMatcherFTask());
|
||||
nodep->v3error("Can't find definition of "
|
||||
<< AstNode::prettyNameQ(baddot) << " in dotted task/function: '"
|
||||
<< nodep->dotted() + "." + nodep->prettyName() << "'\n"
|
||||
|
|
@ -2880,7 +2883,7 @@ private:
|
|||
}
|
||||
}
|
||||
if (!ok) {
|
||||
string suggest = m_statep->suggestSymFallback(
|
||||
const string suggest = m_statep->suggestSymFallback(
|
||||
m_curSymp, cpackagerefp->name(), LinkNodeMatcherClass{});
|
||||
cpackagerefp->v3error(
|
||||
"Class to extend not found: "
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ private:
|
|||
|
||||
// Prepare a temporary variable
|
||||
FileLine* fl = backp->fileline();
|
||||
string name = string("__Vincrement") + cvtToStr(++m_modIncrementsNum);
|
||||
const string name = string("__Vincrement") + cvtToStr(++m_modIncrementsNum);
|
||||
AstVar* varp = new AstVar(fl, AstVarType::BLOCKTEMP, name, VFlagChildDType(),
|
||||
varrefp->varp()->subDTypep()->cloneTree(true));
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ private:
|
|||
// REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- }
|
||||
// Note var can be signed or unsigned based on original number.
|
||||
AstNode* countp = nodep->countp()->unlinkFrBackWithNext();
|
||||
string name = string("__Vrepeat") + cvtToStr(m_modRepeatNum++);
|
||||
const string name = string("__Vrepeat") + cvtToStr(m_modRepeatNum++);
|
||||
// Spec says value is integral, if negative is ignored
|
||||
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name,
|
||||
nodep->findSigned32DType());
|
||||
|
|
|
|||
|
|
@ -157,13 +157,13 @@ private:
|
|||
// We check this rule in the parser, so shouldn't fire
|
||||
nodep->v3error("Enum ranges must be integral, per spec");
|
||||
} // LCOV_EXCL_STOP
|
||||
int left = nodep->rangep()->leftConst();
|
||||
int right = nodep->rangep()->rightConst();
|
||||
int increment = (left > right) ? -1 : 1;
|
||||
const int left = nodep->rangep()->leftConst();
|
||||
const int right = nodep->rangep()->rightConst();
|
||||
const int increment = (left > right) ? -1 : 1;
|
||||
int offset_from_init = 0;
|
||||
AstNode* addp = nullptr;
|
||||
for (int i = left; i != (right + increment); i += increment, offset_from_init++) {
|
||||
string name = nodep->name() + cvtToStr(i);
|
||||
const string name = nodep->name() + cvtToStr(i);
|
||||
AstNode* valuep = nullptr;
|
||||
if (nodep->valuep()) {
|
||||
valuep = new AstAdd(
|
||||
|
|
@ -350,7 +350,7 @@ private:
|
|||
m_varp->addNext(nodep);
|
||||
// lvalue is true, because we know we have a verilator public_flat_rw
|
||||
// but someday we may be more general
|
||||
bool lvalue = m_varp->isSigUserRWPublic();
|
||||
const bool lvalue = m_varp->isSigUserRWPublic();
|
||||
nodep->addStmtp(
|
||||
new AstVarRef(nodep->fileline(), m_varp, lvalue ? VAccess::WRITE : VAccess::READ));
|
||||
}
|
||||
|
|
@ -540,10 +540,10 @@ private:
|
|||
cleanFileline(nodep);
|
||||
AstNode* backp = nodep->backp();
|
||||
// IEEE says directly nested item is not a new block
|
||||
bool nestedIf = (nodep->implied() // User didn't provide begin/end
|
||||
&& (VN_IS(nodep->stmtsp(), GenIf)
|
||||
|| VN_IS(nodep->stmtsp(), GenCase)) // Has an if/case
|
||||
&& !nodep->stmtsp()->nextp()); // Has only one item
|
||||
const bool nestedIf = (nodep->implied() // User didn't provide begin/end
|
||||
&& (VN_IS(nodep->stmtsp(), GenIf)
|
||||
|| VN_IS(nodep->stmtsp(), GenCase)) // Has an if/case
|
||||
&& !nodep->stmtsp()->nextp()); // Has only one item
|
||||
// It's not FOR(BEGIN(...)) but we earlier changed it to BEGIN(FOR(...))
|
||||
if (nodep->genforp()) {
|
||||
++m_genblkNum;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ private:
|
|||
AstNode* sensp = nodep->sensp();
|
||||
if (sensp && !VN_IS(sensp, NodeVarRef) && !VN_IS(sensp, Const)) {
|
||||
// Make a new temp wire
|
||||
string newvarname = "__Vsenitemexpr" + cvtToStr(++m_senitemCvtNum);
|
||||
const string newvarname = "__Vsenitemexpr" + cvtToStr(++m_senitemCvtNum);
|
||||
AstVar* newvarp = new AstVar(sensp->fileline(), AstVarType::MODULETEMP, newvarname,
|
||||
VFlagLogicPacked(), 1);
|
||||
// We can't just add under the module, because we may be
|
||||
|
|
@ -354,14 +354,14 @@ private:
|
|||
continue;
|
||||
}
|
||||
AstConst* constp = VN_CAST(argp, Const);
|
||||
bool isFromString = (constp) ? constp->num().isFromString() : false;
|
||||
const bool isFromString = (constp) ? constp->num().isFromString() : false;
|
||||
if (isFromString) {
|
||||
int numchars = argp->dtypep()->width() / 8;
|
||||
const int numchars = argp->dtypep()->width() / 8;
|
||||
string str(numchars, ' ');
|
||||
// now scan for % operators
|
||||
bool inpercent = false;
|
||||
for (int i = 0; i < numchars; i++) {
|
||||
int ii = numchars - i - 1;
|
||||
const int ii = numchars - i - 1;
|
||||
char c = constp->num().dataByte(ii);
|
||||
str[i] = c;
|
||||
if (!inpercent && c == '%') {
|
||||
|
|
@ -454,7 +454,7 @@ private:
|
|||
}
|
||||
nodep->hasFormat(true);
|
||||
}
|
||||
string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
const string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
nodep->text(newFormat);
|
||||
if ((VN_IS(nodep->backp(), Display)
|
||||
&& VN_CAST(nodep->backp(), Display)->displayType().needScopeTracking())
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public:
|
|||
void pushBack(V3List<T>& listr, T newp) {
|
||||
// "this" must be a element inside of *newp
|
||||
// cppcheck-suppress thisSubtraction
|
||||
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
|
||||
const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
|
||||
m_nextp = nullptr;
|
||||
if (!listr.m_headp) listr.m_headp = newp;
|
||||
m_prevp = listr.m_tailp;
|
||||
|
|
@ -88,7 +88,7 @@ public:
|
|||
void pushFront(V3List<T>& listr, T newp) {
|
||||
// "this" must be a element inside of *newp
|
||||
// cppcheck-suppress thisSubtraction
|
||||
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
|
||||
const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(newp);
|
||||
m_nextp = listr.m_headp;
|
||||
if (m_nextp) baseToListEnt(m_nextp, offset)->m_prevp = newp;
|
||||
listr.m_headp = newp;
|
||||
|
|
@ -99,7 +99,7 @@ public:
|
|||
void unlink(V3List<T>& listr, T oldp) {
|
||||
// "this" must be a element inside of *oldp
|
||||
// cppcheck-suppress thisSubtraction
|
||||
size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(oldp);
|
||||
const size_t offset = (size_t)(vluint8_t*)(this) - (size_t)(vluint8_t*)(oldp);
|
||||
if (m_nextp) {
|
||||
baseToListEnt(m_nextp, offset)->m_prevp = m_prevp;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -48,16 +48,16 @@ private:
|
|||
void rename(AstNode* nodep, bool addPvt) {
|
||||
if (!nodep->user1()) { // Not already done
|
||||
if (addPvt) {
|
||||
string newname = string("__PVT__") + nodep->name();
|
||||
const string newname = string("__PVT__") + nodep->name();
|
||||
nodep->name(newname);
|
||||
nodep->editCountInc();
|
||||
} else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) {
|
||||
} else {
|
||||
string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
const string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
if (rsvd != "") {
|
||||
nodep->v3warn(SYMRSVDWORD,
|
||||
"Symbol matches " + rsvd + ": " << nodep->prettyNameQ());
|
||||
string newname = string("__SYM__") + nodep->name();
|
||||
const string newname = string("__SYM__") + nodep->name();
|
||||
nodep->name(newname);
|
||||
nodep->editCountInc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ V3Number::V3Number(VerilogStringLiteral, AstNode* nodep, const string& str) {
|
|||
init(nodep, str.length() * 8);
|
||||
m_fromString = true;
|
||||
for (unsigned pos = 0; pos < str.length(); ++pos) {
|
||||
int topos = str.length() - 1 - pos;
|
||||
const int topos = str.length() - 1 - pos;
|
||||
for (int bit = 0; bit < 8; ++bit) {
|
||||
if (str[pos] & (1UL << bit)) {
|
||||
m_value[topos / 4] |= (1UL << (bit + (topos % 4) * 8));
|
||||
|
|
@ -515,10 +515,10 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
|
|||
if (isSigned()) out << "s";
|
||||
}
|
||||
|
||||
bool binary = (isFourState()
|
||||
const bool binary = (isFourState()
|
||||
#ifdef V3NUMBER_ASCII_BINARY
|
||||
// cppcheck-suppress konwnConditionTrueFalse
|
||||
|| true
|
||||
// cppcheck-suppress konwnConditionTrueFalse
|
||||
|| true
|
||||
#endif
|
||||
);
|
||||
// out<<"-"<<hex<<m_value[0]<<"-";
|
||||
|
|
@ -586,7 +586,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
|
|||
fmtsize += pos[0];
|
||||
}
|
||||
string str;
|
||||
char code = tolower(pos[0]);
|
||||
const char code = tolower(pos[0]);
|
||||
switch (code) {
|
||||
case 'b': {
|
||||
int bit = width() - 1;
|
||||
|
|
@ -655,14 +655,14 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
|
|||
if (fmtsize != "0") str += ' ';
|
||||
}
|
||||
}
|
||||
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
str = displayPad(fmtsizen, ' ', left, str);
|
||||
return str;
|
||||
}
|
||||
case '~': // Signed decimal
|
||||
case 't': // Time
|
||||
case 'd': { // Unsigned decimal
|
||||
bool issigned = (code == '~');
|
||||
const bool issigned = (code == '~');
|
||||
if (fmtsize == "") {
|
||||
const double mantissabits = this->width() - (issigned ? 1 : 0);
|
||||
// To get the number of digits required, we want to compute
|
||||
|
|
@ -686,9 +686,9 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
|
|||
str = cvtToStr(toUQuad());
|
||||
}
|
||||
}
|
||||
bool zeropad = fmtsize.length() > 0 && fmtsize[0] == '0';
|
||||
const bool zeropad = fmtsize.length() > 0 && fmtsize[0] == '0';
|
||||
// fmtsize might have changed since we parsed the %fmtsize
|
||||
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
str = displayPad(fmtsizen, (zeropad ? '0' : ' '), left, str);
|
||||
return str;
|
||||
}
|
||||
|
|
@ -741,7 +741,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const {
|
|||
return str;
|
||||
}
|
||||
case '@': { // Packed string
|
||||
size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
const size_t fmtsizen = static_cast<size_t>(atoi(fmtsize.c_str()));
|
||||
str = displayPad(fmtsizen, ' ', left, toString());
|
||||
return str;
|
||||
}
|
||||
|
|
@ -762,7 +762,7 @@ string V3Number::toDecimalS() const {
|
|||
}
|
||||
|
||||
string V3Number::toDecimalU() const {
|
||||
int maxdecwidth = (width() + 3) * 4 / 3;
|
||||
const int maxdecwidth = (width() + 3) * 4 / 3;
|
||||
|
||||
// Or (maxdecwidth+7)/8], but can't have more than 4 BCD bits per word
|
||||
V3Number bcd(this, maxdecwidth + 4);
|
||||
|
|
@ -1161,7 +1161,7 @@ V3Number& V3Number::opCLog2(const V3Number& lhs) {
|
|||
NUM_ASSERT_LOGIC_ARGS1(lhs);
|
||||
if (lhs.isFourState()) return setAllBitsX();
|
||||
// IE if 4, this algorithm didn't pre-subtract 1, so we need to post-correct now
|
||||
int adjust = (lhs.countOnes() == 1) ? 0 : 1;
|
||||
const int adjust = (lhs.countOnes() == 1) ? 0 : 1;
|
||||
for (int bit = lhs.width() - 1; bit >= 0; bit--) {
|
||||
if (lhs.bitIs1(bit)) {
|
||||
setLong(bit + adjust);
|
||||
|
|
@ -1331,9 +1331,9 @@ V3Number& V3Number::opStreamL(const V3Number& lhs, const V3Number& rhs) {
|
|||
v3warn(WIDTHCONCAT, "Unsized numbers/parameters not allowed in streams.");
|
||||
}
|
||||
// Slice size should never exceed the lhs width
|
||||
int ssize = std::min(rhs.toUInt(), static_cast<unsigned>(lhs.width()));
|
||||
const int ssize = std::min(rhs.toUInt(), static_cast<unsigned>(lhs.width()));
|
||||
for (int istart = 0; istart < lhs.width(); istart += ssize) {
|
||||
int ostart = std::max(0, lhs.width() - ssize - istart);
|
||||
const int ostart = std::max(0, lhs.width() - ssize - istart);
|
||||
for (int bit = 0; bit < ssize && bit < lhs.width() - istart; bit++) {
|
||||
setBit(ostart + bit, lhs.bitIs(istart + bit));
|
||||
}
|
||||
|
|
@ -1472,8 +1472,8 @@ V3Number& V3Number::opCompareNN(const V3Number& lhs, const V3Number& rhs, bool i
|
|||
// SystemVerilog Language Standard does not allow a string variable to contain '\0'.
|
||||
// So C functions such as strcmp() can correctly compare strings.
|
||||
int result;
|
||||
string lstring = lhs.toString();
|
||||
string rstring = rhs.toString();
|
||||
const string lstring = lhs.toString();
|
||||
const string rstring = rhs.toString();
|
||||
if (ignoreCase) {
|
||||
result = VL_STRCASECMP(lstring.c_str(), rstring.c_str());
|
||||
} else {
|
||||
|
|
@ -1609,7 +1609,7 @@ V3Number& V3Number::opGtS(const V3Number& lhs, const V3Number& rhs) {
|
|||
NUM_ASSERT_LOGIC_ARGS2(lhs, rhs);
|
||||
char outc = 0;
|
||||
{
|
||||
int mbit = std::max(lhs.width() - 1, rhs.width() - 1);
|
||||
const int mbit = std::max(lhs.width() - 1, rhs.width() - 1);
|
||||
if (lhs.bitIsXZ(mbit)) {
|
||||
outc = 'x';
|
||||
} else if (rhs.bitIsXZ(mbit)) {
|
||||
|
|
@ -1735,7 +1735,7 @@ V3Number& V3Number::opAdd(const V3Number& lhs, const V3Number& rhs) {
|
|||
// Addem
|
||||
int carry = 0;
|
||||
for (int bit = 0; bit < this->width(); bit++) {
|
||||
int sum = ((lhs.bitIs1(bit) ? 1 : 0) + (rhs.bitIs1(bit) ? 1 : 0) + carry);
|
||||
const int sum = ((lhs.bitIs1(bit) ? 1 : 0) + (rhs.bitIs1(bit) ? 1 : 0) + carry);
|
||||
if (sum & 1) setBit(bit, 1);
|
||||
carry = (sum >= 2);
|
||||
}
|
||||
|
|
@ -1871,7 +1871,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
|
|||
NUM_ASSERT_LOGIC_ARGS2(lhs, rhs);
|
||||
setZero();
|
||||
// Find MSB and check for zero.
|
||||
int words = lhs.words();
|
||||
const int words = lhs.words();
|
||||
int umsbp1 = lhs.mostSetBitP1(); // dividend
|
||||
int vmsbp1 = rhs.mostSetBitP1(); // divisor
|
||||
if (VL_UNLIKELY(vmsbp1 == 0) // rwp==0 so division by zero. Return 0.
|
||||
|
|
@ -1880,8 +1880,8 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
|
|||
return *this;
|
||||
}
|
||||
|
||||
int uw = (umsbp1 + 31) / 32; // aka "m" in the algorithm
|
||||
int vw = (vmsbp1 + 31) / 32; // aka "n" in the algorithm
|
||||
const int uw = (umsbp1 + 31) / 32; // aka "m" in the algorithm
|
||||
const int vw = (vmsbp1 + 31) / 32; // aka "n" in the algorithm
|
||||
|
||||
if (vw == 1) { // Single divisor word breaks rest of algorithm
|
||||
vluint64_t k = 0;
|
||||
|
|
@ -2084,7 +2084,7 @@ V3Number& V3Number::opExtendS(const V3Number& lhs, uint32_t lbits) {
|
|||
NUM_ASSERT_LOGIC_ARGS1(lhs);
|
||||
setZero();
|
||||
for (int bit = 0; bit < width(); bit++) {
|
||||
char extendWith = lhs.bitIsExtend(bit, lbits);
|
||||
const char extendWith = lhs.bitIsExtend(bit, lbits);
|
||||
setBit(bit, extendWith);
|
||||
}
|
||||
return *this;
|
||||
|
|
@ -2170,7 +2170,7 @@ V3Number& V3Number::opIToRD(const V3Number& lhs, bool isSigned) {
|
|||
V3Number noxz(lhs);
|
||||
noxz.opAssignNonXZ(lhs);
|
||||
double d = 0;
|
||||
bool negate = isSigned && noxz.isNegative();
|
||||
const bool negate = isSigned && noxz.isNegative();
|
||||
if (negate) {
|
||||
V3Number noxz_signed = noxz;
|
||||
noxz.opNegate(noxz_signed);
|
||||
|
|
@ -2201,15 +2201,15 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) {
|
|||
u.d = v;
|
||||
if (u.d == 0.0) {}
|
||||
|
||||
int exp = static_cast<int>((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023;
|
||||
int lsb = exp - 52;
|
||||
const int exp = static_cast<int>((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023;
|
||||
const int lsb = exp - 52;
|
||||
vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52);
|
||||
if (v != 0) {
|
||||
// IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa
|
||||
// This does not need to support subnormals as they are sub-integral
|
||||
for (int bit = 0; bit <= 52; ++bit) {
|
||||
if (mantissa & (1ULL << bit)) {
|
||||
int outbit = bit + lsb;
|
||||
const int outbit = bit + lsb;
|
||||
if (outbit >= 0) setBit(outbit, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void test(const string& lhss, const string& op, const string& rhss, const string
|
|||
char* r1 = strdup(rhss.c_str());
|
||||
char* e1 = strdup(exps.c_str());
|
||||
|
||||
FileLine fl = new FileLine(FileLine::builtInFinename());
|
||||
const FileLine fl = new FileLine(FileLine::builtInFinename());
|
||||
|
||||
V3Number lhnum(fl, l1);
|
||||
V3Number rhnum(fl, r1);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbPartialMatchVal, void(const char*, cons
|
|||
// Member functions of V3OptionParser
|
||||
|
||||
V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) {
|
||||
auto it = m_pimpl->m_options.find(optp);
|
||||
const auto it = m_pimpl->m_options.find(optp);
|
||||
if (it != m_pimpl->m_options.end()) return it->second.get();
|
||||
for (auto&& act : m_pimpl->m_options) {
|
||||
if (act.second->isOnOffAllowed()) { // Find starts with "-no"
|
||||
|
|
@ -218,7 +218,7 @@ V3OptionParser::ActionIfs&
|
|||
V3OptionParser::AppendHelper::operator()(const char* optp, CbPartialMatch,
|
||||
Impl::ActionCbPartialMatch::CbType cb) const {
|
||||
const size_t prefixLen = std::strlen(optp);
|
||||
auto wrap = [prefixLen, cb](const char* optp) { cb(optp + prefixLen); };
|
||||
const auto wrap = [prefixLen, cb](const char* optp) { cb(optp + prefixLen); };
|
||||
return m_parser.add<Impl::ActionCbPartialMatch>(optp, std::move(wrap));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ V3LangCode::V3LangCode(const char* textp) {
|
|||
VTimescale::VTimescale(const string& value, bool& badr)
|
||||
: m_e{VTimescale::NONE} {
|
||||
badr = true;
|
||||
string spaceless = VString::removeWhitespace(value);
|
||||
const string spaceless = VString::removeWhitespace(value);
|
||||
for (int i = TS_100S; i < _ENUM_END; ++i) {
|
||||
VTimescale ts(i);
|
||||
if (spaceless == ts.ascii()) {
|
||||
|
|
@ -339,7 +339,7 @@ bool V3Options::hasParameter(const string& name) {
|
|||
}
|
||||
|
||||
string V3Options::parameter(const string& name) {
|
||||
string value = m_parameters.find(name)->second;
|
||||
const string value = m_parameters.find(name)->second;
|
||||
m_parameters.erase(m_parameters.find(name));
|
||||
return value;
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ string V3Options::allArgsStringForHierBlock(bool forTop) const {
|
|||
bool V3Options::fileStatNormal(const string& filename) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
struct stat sstat; // Stat information
|
||||
int err = stat(filename.c_str(), &sstat);
|
||||
const int err = stat(filename.c_str(), &sstat);
|
||||
if (err != 0) return false;
|
||||
if (S_ISDIR(sstat.st_mode)) return false;
|
||||
return true;
|
||||
|
|
@ -454,8 +454,8 @@ string V3Options::fileExists(const string& filename) {
|
|||
// is quite slow; presumably because of re-reading each directory
|
||||
// many times. So we read a whole dir at once and cache it
|
||||
|
||||
string dir = V3Os::filenameDir(filename);
|
||||
string basename = V3Os::filenameNonDir(filename);
|
||||
const string dir = V3Os::filenameDir(filename);
|
||||
const string basename = V3Os::filenameNonDir(filename);
|
||||
|
||||
auto diriter = m_impp->m_dirMap.find(dir);
|
||||
if (diriter == m_impp->m_dirMap.end()) {
|
||||
|
|
@ -477,14 +477,14 @@ string V3Options::fileExists(const string& filename) {
|
|||
return ""; // Not found
|
||||
}
|
||||
// Check if it is a directory, ignore if so
|
||||
string filenameOut = V3Os::filenameFromDirBase(dir, basename);
|
||||
const string filenameOut = V3Os::filenameFromDirBase(dir, basename);
|
||||
if (!fileStatNormal(filenameOut)) return ""; // Directory
|
||||
return filenameOut;
|
||||
}
|
||||
|
||||
string V3Options::filePathCheckOneDir(const string& modname, const string& dirname) {
|
||||
for (const string& i : m_impp->m_libExtVs) {
|
||||
string fn = V3Os::filenameFromDirBase(dirname, modname + i);
|
||||
const string fn = V3Os::filenameFromDirBase(dirname, modname + i);
|
||||
string exists = fileExists(fn);
|
||||
if (exists != "") {
|
||||
// Strip ./, it just looks ugly
|
||||
|
|
@ -518,16 +518,16 @@ string V3Options::filePath(FileLine* fl, const string& modname, const string& la
|
|||
// using the incdir and libext's.
|
||||
// Return "" if not found.
|
||||
for (const string& dir : m_impp->m_incDirUsers) {
|
||||
string exists = filePathCheckOneDir(modname, dir);
|
||||
const string exists = filePathCheckOneDir(modname, dir);
|
||||
if (exists != "") return exists;
|
||||
}
|
||||
for (const string& dir : m_impp->m_incDirFallbacks) {
|
||||
string exists = filePathCheckOneDir(modname, dir);
|
||||
const string exists = filePathCheckOneDir(modname, dir);
|
||||
if (exists != "") return exists;
|
||||
}
|
||||
|
||||
if (m_relativeIncludes) {
|
||||
string exists = filePathCheckOneDir(modname, lastpath);
|
||||
const string exists = filePathCheckOneDir(modname, lastpath);
|
||||
if (exists != "") return V3Os::filenameRealPath(exists);
|
||||
}
|
||||
|
||||
|
|
@ -554,13 +554,13 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
|
|||
std::cerr << V3Error::warnMore() << "... Looked in:" << endl;
|
||||
for (const string& dir : m_impp->m_incDirUsers) {
|
||||
for (const string& ext : m_impp->m_libExtVs) {
|
||||
string fn = V3Os::filenameFromDirBase(dir, modname + ext);
|
||||
const string fn = V3Os::filenameFromDirBase(dir, modname + ext);
|
||||
std::cerr << V3Error::warnMore() << " " << fn << endl;
|
||||
}
|
||||
}
|
||||
for (const string& dir : m_impp->m_incDirFallbacks) {
|
||||
for (const string& ext : m_impp->m_libExtVs) {
|
||||
string fn = V3Os::filenameFromDirBase(dir, modname + ext);
|
||||
const string fn = V3Os::filenameFromDirBase(dir, modname + ext);
|
||||
std::cerr << V3Error::warnMore() << " " << fn << endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -633,16 +633,16 @@ string V3Options::getenvSYSTEMC_ARCH() {
|
|||
if (var == "") {
|
||||
#if defined(__MINGW32__)
|
||||
// Hardcoded with MINGW current version. Would like a better way.
|
||||
string sysname = "MINGW32_NT-5.0";
|
||||
const string sysname = "MINGW32_NT-5.0";
|
||||
var = "mingw32";
|
||||
#elif defined(_WIN32)
|
||||
string sysname = "WIN32";
|
||||
const string sysname = "WIN32";
|
||||
var = "win32";
|
||||
#else
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
struct utsname uts;
|
||||
uname(&uts);
|
||||
string sysname = VString::downcase(uts.sysname); // aka 'uname -s'
|
||||
const string sysname = VString::downcase(uts.sysname); // aka 'uname -s'
|
||||
if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*solaris*"))) {
|
||||
var = "gccsparcOS5";
|
||||
} else if (VL_UNCOVERABLE(VString::wildmatch(sysname.c_str(), "*cygwin*"))) {
|
||||
|
|
@ -663,7 +663,7 @@ string V3Options::getenvSYSTEMC_INCLUDE() {
|
|||
V3Os::setenvStr("SYSTEMC_INCLUDE", var, "Hardcoded at build time");
|
||||
}
|
||||
if (var == "") {
|
||||
string sc = getenvSYSTEMC();
|
||||
const string sc = getenvSYSTEMC();
|
||||
if (sc != "") var = sc + "/include";
|
||||
}
|
||||
return var;
|
||||
|
|
@ -676,8 +676,8 @@ string V3Options::getenvSYSTEMC_LIBDIR() {
|
|||
V3Os::setenvStr("SYSTEMC_LIBDIR", var, "Hardcoded at build time");
|
||||
}
|
||||
if (var == "") {
|
||||
string sc = getenvSYSTEMC();
|
||||
string arch = getenvSYSTEMC_ARCH();
|
||||
const string sc = getenvSYSTEMC();
|
||||
const string arch = getenvSYSTEMC_ARCH();
|
||||
if (sc != "" && arch != "") var = sc + "/lib-" + arch;
|
||||
}
|
||||
return var;
|
||||
|
|
@ -899,7 +899,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
V3OptionParser::AppendHelper DECL_OPTION{parser};
|
||||
V3OPTION_PARSER_DECL_TAGS;
|
||||
|
||||
auto callStrSetter = [this](void (V3Options::*cbStr)(const string&)) {
|
||||
const auto callStrSetter = [this](void (V3Options::*cbStr)(const string&)) {
|
||||
return [this, cbStr](const string& v) { (this->*cbStr)(v); };
|
||||
};
|
||||
// Usage
|
||||
|
|
@ -1104,7 +1104,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
DECL_OPTION("-inline-mult", Set, &m_inlineMult);
|
||||
|
||||
DECL_OPTION("-LDFLAGS", CbVal, callStrSetter(&V3Options::addLdLibs));
|
||||
auto setLang = [this, fl](const char* valp) {
|
||||
const auto setLang = [this, fl](const char* valp) {
|
||||
V3LangCode optval = V3LangCode(valp);
|
||||
if (optval.legal()) {
|
||||
m_defaultLanguage = optval;
|
||||
|
|
@ -1473,7 +1473,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
|||
}
|
||||
} else {
|
||||
// Filename
|
||||
string filename = parseFileArg(optdir, argv[i]);
|
||||
const string filename = parseFileArg(optdir, argv[i]);
|
||||
if (suffixed(filename, ".cpp") //
|
||||
|| suffixed(filename, ".cxx") //
|
||||
|| suffixed(filename, ".cc") //
|
||||
|
|
@ -1507,7 +1507,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
|||
string whole_file;
|
||||
bool inCmt = false;
|
||||
while (!ifp->eof()) {
|
||||
string line = V3Os::getline(*ifp);
|
||||
const string line = V3Os::getline(*ifp);
|
||||
// Strip simple comments
|
||||
string oline;
|
||||
// cppcheck-suppress StlMissingComparison
|
||||
|
|
@ -1625,7 +1625,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
|||
}
|
||||
|
||||
// Path
|
||||
string optdir = (rel ? V3Os::filenameDir(filename) : ".");
|
||||
const string optdir = (rel ? V3Os::filenameDir(filename) : ".");
|
||||
|
||||
// Convert to argv style arg list and parse them
|
||||
std::vector<char*> argv;
|
||||
|
|
@ -1649,7 +1649,7 @@ string V3Options::parseFileArg(const string& optdir, const string& relfilename)
|
|||
bool V3Options::parseLangExt(const char* swp, //!< argument text
|
||||
const char* langswp, //!< option to match
|
||||
const V3LangCode& lc) { //!< language code
|
||||
int len = strlen(langswp);
|
||||
const int len = strlen(langswp);
|
||||
if (!strncmp(swp, langswp, len)) {
|
||||
addLangExt(swp + len, lc);
|
||||
return true;
|
||||
|
|
@ -1747,7 +1747,7 @@ void V3Options::setDebugSrcLevel(const string& srcfile, int level) {
|
|||
int V3Options::debugSrcLevel(const string& srcfile_path, int default_level) {
|
||||
// For simplicity, calling functions can just use __FILE__ for srcfile.
|
||||
// That means though we need to cleanup the filename from ../Foo.cpp -> Foo
|
||||
string srcfile = V3Os::filenameNonDirExt(srcfile_path);
|
||||
const string srcfile = V3Os::filenameNonDirExt(srcfile_path);
|
||||
const auto iter = m_debugSrcs.find(srcfile);
|
||||
if (iter != m_debugSrcs.end()) {
|
||||
return iter->second;
|
||||
|
|
@ -1768,7 +1768,7 @@ void V3Options::setDumpTreeLevel(const string& srcfile, int level) {
|
|||
int V3Options::dumpTreeLevel(const string& srcfile_path) {
|
||||
// For simplicity, calling functions can just use __FILE__ for srcfile.
|
||||
// That means though we need to cleanup the filename from ../Foo.cpp -> Foo
|
||||
string srcfile = V3Os::filenameNonDirExt(srcfile_path);
|
||||
const string srcfile = V3Os::filenameNonDirExt(srcfile_path);
|
||||
const auto iter = m_dumpTrees.find(srcfile);
|
||||
if (iter != m_dumpTrees.end()) {
|
||||
return iter->second;
|
||||
|
|
@ -1779,7 +1779,7 @@ int V3Options::dumpTreeLevel(const string& srcfile_path) {
|
|||
|
||||
void V3Options::optimize(int level) {
|
||||
// Set all optimizations to on/off
|
||||
bool flag = level > 0;
|
||||
const bool flag = level > 0;
|
||||
m_oAcycSimp = flag;
|
||||
m_oAssemble = flag;
|
||||
m_oCase = flag;
|
||||
|
|
|
|||
|
|
@ -322,9 +322,9 @@ private:
|
|||
virtual void visit(AstConcat* nodep) override {
|
||||
if (m_inAss) {
|
||||
iterateAndNextNull(nodep->lhsp());
|
||||
int lw = m_childClkWidth;
|
||||
const int lw = m_childClkWidth;
|
||||
iterateAndNextNull(nodep->rhsp());
|
||||
int rw = m_childClkWidth;
|
||||
const int rw = m_childClkWidth;
|
||||
m_childClkWidth = lw + rw; // Pass up
|
||||
}
|
||||
}
|
||||
|
|
@ -502,7 +502,7 @@ private:
|
|||
if (edgep->weight() == 0) { // Was cut
|
||||
continue;
|
||||
}
|
||||
int weight = edgep->weight();
|
||||
const int weight = edgep->weight();
|
||||
if (const OrderLogicVertex* toLVertexp
|
||||
= dynamic_cast<const OrderLogicVertex*>(edgep->top())) {
|
||||
|
||||
|
|
@ -758,7 +758,7 @@ private:
|
|||
string cfuncName(AstNodeModule* modp, AstSenTree* domainp, AstScope* scopep,
|
||||
AstNode* forWhatp) {
|
||||
modp->user3Inc();
|
||||
int funcnum = modp->user3();
|
||||
const int funcnum = modp->user3();
|
||||
string name = (domainp->hasCombo()
|
||||
? "_combo"
|
||||
: (domainp->hasInitial()
|
||||
|
|
@ -805,7 +805,7 @@ private:
|
|||
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPT,
|
||||
true); // Complain just once
|
||||
// Give the user an example.
|
||||
bool tempWeight = (edgep && edgep->weight() == 0);
|
||||
const bool tempWeight = (edgep && edgep->weight() == 0);
|
||||
// Else the below loop detect can't see the loop
|
||||
if (tempWeight) edgep->weight(1);
|
||||
// Calls OrderGraph::loopsVertexCb
|
||||
|
|
@ -824,7 +824,7 @@ private:
|
|||
nodep->fileline()->modifyWarnOff(V3ErrorCode::UNOPTFLAT,
|
||||
true); // Complain just once
|
||||
// Give the user an example.
|
||||
bool tempWeight = (edgep && edgep->weight() == 0);
|
||||
const bool tempWeight = (edgep && edgep->weight() == 0);
|
||||
// Else the below loop detect can't see the loop
|
||||
if (tempWeight) edgep->weight(1);
|
||||
// Calls OrderGraph::loopsVertexCb
|
||||
|
|
@ -914,7 +914,7 @@ private:
|
|||
// Only reporting on standard variable vertices
|
||||
AstVar* varp = vsvertexp->varScp()->varp();
|
||||
if (!varp->user3()) {
|
||||
string name = varp->prettyName();
|
||||
const string name = varp->prettyName();
|
||||
if ((varp->width() != 1) && (name.find("__Vdly") == string::npos)
|
||||
&& (name.find("__Vcell") == string::npos)) {
|
||||
// Variable to report on and not yet done
|
||||
|
|
@ -1221,7 +1221,7 @@ public:
|
|||
virtual ~OrderVisitor() override {
|
||||
// Stats
|
||||
for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) {
|
||||
double count = double(m_statCut[type]);
|
||||
const double count = double(m_statCut[type]);
|
||||
if (count != 0.0) {
|
||||
V3Stats::addStat(string("Order, cut, ") + OrderVEdgeType(type).ascii(), count);
|
||||
}
|
||||
|
|
@ -1250,8 +1250,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) {
|
|||
//
|
||||
// ... unless you know more about A and B, which sounds hard.
|
||||
|
||||
bool toInitial = top->hasInitial() || top->hasSettle();
|
||||
bool fromInitial = fromp->hasInitial() || fromp->hasSettle();
|
||||
const bool toInitial = top->hasInitial() || top->hasSettle();
|
||||
const bool fromInitial = fromp->hasInitial() || fromp->hasSettle();
|
||||
if (toInitial != fromInitial) return true;
|
||||
|
||||
const AstSenItem* fromSenListp = VN_CAST(fromp->sensesp(), SenItem);
|
||||
|
|
@ -1492,7 +1492,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
|
|||
// Ignore that we have a constant (initial) input
|
||||
} else if (domainp != fromVertexp->domainp()) {
|
||||
// Make a domain that merges the two domains
|
||||
bool ddebug = debug() >= 9;
|
||||
const bool ddebug = debug() >= 9;
|
||||
|
||||
if (ddebug) { // LCOV_EXCL_START
|
||||
|
||||
|
|
@ -1544,7 +1544,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
|
|||
|
||||
void OrderVisitor::processEdgeReport() {
|
||||
// Make report of all signal names and what clock edges they have
|
||||
string filename = v3Global.debugFilename("order_edges.txt");
|
||||
const string filename = v3Global.debugFilename("order_edges.txt");
|
||||
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatal("Can't write " << filename);
|
||||
// Testing emitter: V3EmitV::verilogForTree(v3Global.rootp(), *logp);
|
||||
|
|
@ -1850,7 +1850,7 @@ void OrderVisitor::processMTasks() {
|
|||
const V3GraphVertex* moveVxp;
|
||||
while ((moveVxp = emit_logic.nextp())) {
|
||||
const MTaskMoveVertex* movep = dynamic_cast<const MTaskMoveVertex*>(moveVxp);
|
||||
unsigned mtaskId = movep->color();
|
||||
const unsigned mtaskId = movep->color();
|
||||
UASSERT(mtaskId > 0, "Every MTaskMoveVertex should have an mtask assignment >0");
|
||||
if (movep->logicp()) {
|
||||
// Add this logic to the per-mtask order
|
||||
|
|
@ -2003,7 +2003,8 @@ void OrderVisitor::process() {
|
|||
// Dump data
|
||||
m_graph.dumpDotFilePrefixed("orderg_done");
|
||||
if (false && debug()) {
|
||||
string dfilename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order";
|
||||
const string dfilename
|
||||
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "_INT_order";
|
||||
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(dfilename));
|
||||
if (logp->fail()) v3fatal("Can't write " << dfilename);
|
||||
m_graph.dump(*logp);
|
||||
|
|
|
|||
20
src/V3Os.cpp
20
src/V3Os.cpp
|
|
@ -103,7 +103,7 @@ void V3Os::setenvStr(const string& envvar, const string& value, const string& wh
|
|||
#else
|
||||
// setenv() replaced by putenv() in Solaris environment. Prototype is different
|
||||
// putenv() requires NAME=VALUE format
|
||||
string vareq = envvar + "=" + value;
|
||||
const string vareq = envvar + "=" + value;
|
||||
putenv(const_cast<char*>(vareq.c_str()));
|
||||
#endif
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ string V3Os::filenameSubstitute(const string& filename) {
|
|||
|| ((brackets == PAREN) && (filename[endpos + 1] != ')'))) {
|
||||
v3fatal("Unmatched brackets in variable substitution in file: " + filename);
|
||||
}
|
||||
string envvar = filename.substr(pos + 1, endpos - pos);
|
||||
const string envvar = filename.substr(pos + 1, endpos - pos);
|
||||
string envvalue;
|
||||
if (!envvar.empty()) envvalue = getenvStr(envvar, "");
|
||||
if (!envvalue.empty()) {
|
||||
|
|
@ -239,7 +239,7 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) {
|
|||
if (DIR* dirp = opendir(dir.c_str())) {
|
||||
while (struct dirent* direntp = readdir(dirp)) {
|
||||
if (VString::wildmatch(direntp->d_name, regexp.c_str())) {
|
||||
string fullname = dir + "/" + string(direntp->d_name);
|
||||
const string fullname = dir + "/" + string(direntp->d_name);
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
_unlink(fullname.c_str());
|
||||
#else
|
||||
|
|
@ -269,8 +269,8 @@ string V3Os::trueRandom(size_t size) {
|
|||
// Note: std::string.data() returns a non-const Char* from C++17 onwards.
|
||||
// For pre-C++17, this cast is OK in practice, even though it's UB.
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
NTSTATUS hr = BCryptGenRandom(nullptr, reinterpret_cast<BYTE*>(data), size,
|
||||
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
const NTSTATUS hr = BCryptGenRandom(nullptr, reinterpret_cast<BYTE*>(data), size,
|
||||
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
if (!BCRYPT_SUCCESS(hr)) v3fatal("Could not acquire random data.");
|
||||
#else
|
||||
std::ifstream is("/dev/urandom", std::ios::in | std::ios::binary);
|
||||
|
|
@ -307,7 +307,7 @@ uint64_t V3Os::timeUsecs() {
|
|||
|
||||
uint64_t V3Os::memUsageBytes() {
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
HANDLE process = GetCurrentProcess();
|
||||
const HANDLE process = GetCurrentProcess();
|
||||
PROCESS_MEMORY_COUNTERS pmc;
|
||||
if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc))) {
|
||||
// The best we can do using simple Windows APIs is to get the size of the working set.
|
||||
|
|
@ -320,10 +320,10 @@ uint64_t V3Os::memUsageBytes() {
|
|||
FILE* fp = fopen(statmFilename, "r");
|
||||
if (!fp) return 0;
|
||||
vluint64_t size, resident, share, text, lib, data, dt; // All in pages
|
||||
int items = fscanf(fp,
|
||||
"%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64
|
||||
"u %" VL_PRI64 "u %" VL_PRI64 "u",
|
||||
&size, &resident, &share, &text, &lib, &data, &dt);
|
||||
const int items = fscanf(fp,
|
||||
"%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64
|
||||
"u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u",
|
||||
&size, &resident, &share, &text, &lib, &data, &dt);
|
||||
fclose(fp);
|
||||
if (VL_UNCOVERABLE(7 != items)) return 0;
|
||||
return (text + data) * getpagesize();
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ class ParamProcessor final {
|
|||
usedLetter[static_cast<int>(ch)]++;
|
||||
}
|
||||
} else if (AstParamTypeDType* typep = VN_CAST(stmtp, ParamTypeDType)) {
|
||||
char ch = 'T';
|
||||
const char ch = 'T';
|
||||
typep->user4(usedLetter[static_cast<int>(ch)] * 256 + ch);
|
||||
usedLetter[static_cast<int>(ch)]++;
|
||||
}
|
||||
|
|
@ -291,7 +291,7 @@ class ParamProcessor final {
|
|||
string paramSmallName(AstNodeModule* modp, AstNode* varp) {
|
||||
if (varp->user4() <= 1) makeSmallNames(modp);
|
||||
int index = varp->user4() / 256;
|
||||
char ch = varp->user4() & 255;
|
||||
const char ch = varp->user4() & 255;
|
||||
string st = cvtToStr(ch);
|
||||
while (index) {
|
||||
st += cvtToStr(char((index % 25) + 'A'));
|
||||
|
|
@ -477,7 +477,7 @@ class ParamProcessor final {
|
|||
|
||||
string longname = modp->name();
|
||||
for (auto&& defaultValue : paramsIt->second) {
|
||||
auto pinIt = pins.find(defaultValue.first);
|
||||
const auto pinIt = pins.find(defaultValue.first);
|
||||
AstConst* constp = pinIt == pins.end() ? defaultValue.second : pinIt->second;
|
||||
// This longname is not valid as verilog symbol, but ok, because it will be hashed
|
||||
longname += "_" + defaultValue.first + "=";
|
||||
|
|
@ -485,7 +485,7 @@ class ParamProcessor final {
|
|||
if (constp) longname += constp->num().ascii(false);
|
||||
}
|
||||
|
||||
auto iter = m_longMap.find(longname);
|
||||
const auto iter = m_longMap.find(longname);
|
||||
if (iter != m_longMap.end()) return iter->second; // Already calculated
|
||||
|
||||
VHashSha256 hash;
|
||||
|
|
@ -538,7 +538,7 @@ class ParamProcessor final {
|
|||
insertp->addNextHere(newmodp);
|
||||
|
||||
m_modNameMap.emplace(newmodp->name(), ModInfo(newmodp));
|
||||
auto iter = m_modNameMap.find(newname);
|
||||
const auto iter = m_modNameMap.find(newname);
|
||||
CloneMap* clonemapp = &(iter->second.m_cloneMap);
|
||||
UINFO(4, " De-parameterize to new: " << newmodp << endl);
|
||||
|
||||
|
|
@ -773,7 +773,8 @@ public:
|
|||
// We need to relink the pins to the new module
|
||||
relinkPinsByName(nodep->pinsp(), paramedModp);
|
||||
} else {
|
||||
string newname = srcModp->hierBlock() ? longname : moduleCalcName(srcModp, longname);
|
||||
const string newname
|
||||
= srcModp->hierBlock() ? longname : moduleCalcName(srcModp, longname);
|
||||
const ModInfo* modInfop
|
||||
= moduleFindOrClone(srcModp, nodep, nodep->paramsp(), newname, ifaceRefRefs);
|
||||
// Have child use this module instead.
|
||||
|
|
@ -980,7 +981,7 @@ class ParamVisitor final : public AstNVisitor {
|
|||
}
|
||||
virtual void visit(AstVarXRef* nodep) override {
|
||||
// Check to see if the scope is just an interface because interfaces are special
|
||||
string dotted = nodep->dotted();
|
||||
const string dotted = nodep->dotted();
|
||||
if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) {
|
||||
AstNode* backp = nodep;
|
||||
while ((backp = backp->backp())) {
|
||||
|
|
@ -1048,9 +1049,9 @@ class ParamVisitor final : public AstNVisitor {
|
|||
virtual void visit(AstCellArrayRef* nodep) override {
|
||||
V3Const::constifyParamsEdit(nodep->selp());
|
||||
if (const AstConst* constp = VN_CAST(nodep->selp(), Const)) {
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
string replacestr = nodep->name() + "__BRA__??__KET__";
|
||||
size_t pos = m_unlinkedTxt.find(replacestr);
|
||||
const string index = AstNode::encodeNumber(constp->toSInt());
|
||||
const string replacestr = nodep->name() + "__BRA__??__KET__";
|
||||
const size_t pos = m_unlinkedTxt.find(replacestr);
|
||||
UASSERT_OBJ(pos != string::npos, nodep,
|
||||
"Could not find array index in unlinked text: '"
|
||||
<< m_unlinkedTxt << "' for node: " << nodep);
|
||||
|
|
@ -1105,7 +1106,7 @@ class ParamVisitor final : public AstNVisitor {
|
|||
// doesn't conflict in V3LinkDot resolution with other genvars
|
||||
// Now though we need to change BEGIN("zzz", GENFOR(...)) to
|
||||
// a BEGIN("zzz__BRA__{loop#}__KET__")
|
||||
string beginName = nodep->name();
|
||||
const string beginName = nodep->name();
|
||||
// Leave the original Begin, as need a container for the (possible) GENVAR
|
||||
// Note V3Unroll will replace some AstVarRef's to the loop variable with constants
|
||||
// Don't remove any deleted nodes in m_unroller until whole process finishes,
|
||||
|
|
|
|||
|
|
@ -165,11 +165,11 @@ void V3ParseImp::lexErrorPreprocDirective(FileLine* fl, const char* textp) {
|
|||
VSpellCheck speller;
|
||||
for (V3LanguageWords::const_iterator it = V3LanguageWords::begin();
|
||||
it != V3LanguageWords::end(); ++it) {
|
||||
string ppDirective = it->first;
|
||||
const string ppDirective = it->first;
|
||||
if (ppDirective[0] == '`') speller.pushCandidate(ppDirective);
|
||||
}
|
||||
V3PreShell::candidateDefines(&speller);
|
||||
string suggest = speller.bestCandidateMsg(textp);
|
||||
const string suggest = speller.bestCandidateMsg(textp);
|
||||
fl->v3error("Define or directive not defined: '"
|
||||
<< textp << "'\n"
|
||||
<< (suggest.empty() ? "" : fl->warnMore() + suggest));
|
||||
|
|
@ -183,7 +183,7 @@ string V3ParseImp::lexParseTag(const char* textp) {
|
|||
}
|
||||
|
||||
double V3ParseImp::lexParseTimenum(const char* textp) {
|
||||
size_t length = strlen(textp);
|
||||
const size_t length = strlen(textp);
|
||||
char* strgp = new char[length + 1];
|
||||
char* dp = strgp;
|
||||
const char* sp = textp;
|
||||
|
|
@ -227,7 +227,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
|
|||
m_ppBuffers.pop_front();
|
||||
size_t len = front.length();
|
||||
if (len > (max_size - got)) { // Front string too big
|
||||
string remainder = front.substr(max_size - got);
|
||||
const string remainder = front.substr(max_size - got);
|
||||
front = front.substr(0, max_size - got);
|
||||
m_ppBuffers.push_front(remainder); // Put back remainder for next time
|
||||
len = (max_size - got);
|
||||
|
|
@ -236,7 +236,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
|
|||
got += len;
|
||||
}
|
||||
if (debug() >= 9) {
|
||||
string out = string(buf, got);
|
||||
const string out = string(buf, got);
|
||||
cout << " inputToLex got=" << got << " '" << out << "'" << endl;
|
||||
}
|
||||
// Note returns 0 at EOF
|
||||
|
|
@ -247,7 +247,7 @@ void V3ParseImp::preprocDumps(std::ostream& os) {
|
|||
if (v3Global.opt.dumpDefines()) {
|
||||
V3PreShell::dumpDefines(os);
|
||||
} else {
|
||||
bool noblanks = v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine();
|
||||
const bool noblanks = v3Global.opt.preprocOnly() && v3Global.opt.preprocNoLine();
|
||||
for (auto& buf : m_ppBuffers) {
|
||||
if (noblanks) {
|
||||
bool blank = true;
|
||||
|
|
@ -266,7 +266,7 @@ void V3ParseImp::preprocDumps(std::ostream& os) {
|
|||
|
||||
void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool inLibrary,
|
||||
const string& errmsg) { // "" for no error, make fake node
|
||||
string modname = V3Os::filenameNonExt(modfilename);
|
||||
const string modname = V3Os::filenameNonExt(modfilename);
|
||||
|
||||
UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl);
|
||||
m_lexFileline = new FileLine(fileline);
|
||||
|
|
@ -275,7 +275,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
|
|||
m_inLibrary = inLibrary;
|
||||
|
||||
// Preprocess into m_ppBuffer
|
||||
bool ok = V3PreShell::preproc(fileline, modfilename, m_filterp, this, errmsg);
|
||||
const bool ok = V3PreShell::preproc(fileline, modfilename, m_filterp, this, errmsg);
|
||||
if (!ok) {
|
||||
if (errmsg != "") return; // Threw error already
|
||||
// Create fake node for later error reporting
|
||||
|
|
@ -351,7 +351,7 @@ size_t V3ParseImp::tokenPipeScanParam(size_t depth) {
|
|||
depth += 2; // Past the (
|
||||
int parens = 1; // Count first (
|
||||
while (true) {
|
||||
int tok = tokenPeekp(depth)->token;
|
||||
const int tok = tokenPeekp(depth)->token;
|
||||
if (tok == 0) {
|
||||
UINFO(9, "tokenPipeScanParam hit EOF; probably syntax error to come");
|
||||
break;
|
||||
|
|
@ -392,7 +392,7 @@ void V3ParseImp::tokenPipeline() {
|
|||
}
|
||||
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
|
||||
const V3ParseBisonYYSType* nexttokp = tokenPeekp(0);
|
||||
int nexttok = nexttokp->token;
|
||||
const int nexttok = nexttokp->token;
|
||||
yylval = curValue;
|
||||
// Now potentially munge the current token
|
||||
if (token == '('
|
||||
|
|
@ -467,7 +467,7 @@ void V3ParseImp::tokenPipeline() {
|
|||
} else if (nexttok == '#') {
|
||||
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
|
||||
{
|
||||
size_t depth = tokenPipeScanParam(0);
|
||||
const size_t depth = tokenPipeScanParam(0);
|
||||
if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC;
|
||||
}
|
||||
yylval = curValue;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void V3ParseImp::lexUnputString(const char* textp, size_t length) {
|
|||
void V3ParseImp::yylexReadTok() {
|
||||
// Call yylex() remembering last non-whitespace token
|
||||
parsep()->lexFileline()->startToken();
|
||||
int token = parsep()->m_lexerp->yylex();
|
||||
const int token = parsep()->m_lexerp->yylex();
|
||||
m_lexPrevToken = token; // Save so can find '#' to parse following number
|
||||
yylval.token = token;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -622,7 +622,7 @@ public:
|
|||
}
|
||||
|
||||
static void dumpCpFilePrefixed(const V3Graph* graphp, const string& nameComment) {
|
||||
string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
UINFO(1, "Writing " << filename << endl);
|
||||
std::unique_ptr<std::ofstream> ofp(V3File::new_ofstream(filename));
|
||||
std::ostream* osp = &(*ofp); // &* needed to deref unique_ptr
|
||||
|
|
@ -901,7 +901,7 @@ private:
|
|||
// vertex.
|
||||
static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool checkOnly) {
|
||||
GraphStreamUnordered order(mtasksp, way);
|
||||
GraphWay rev = way.invert();
|
||||
const GraphWay rev = way.invert();
|
||||
for (const V3GraphVertex* vertexp; (vertexp = order.nextp());) {
|
||||
const LogicMTask* mtaskcp = dynamic_cast<const LogicMTask*>(vertexp);
|
||||
LogicMTask* mtaskp = const_cast<LogicMTask*>(mtaskcp);
|
||||
|
|
@ -997,7 +997,7 @@ static V3GraphEdge* partBlastEdgep(GraphWay way, V3GraphEdge* edgep) {
|
|||
static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMTask* donorp,
|
||||
V3Scoreboard<MergeCandidate, uint32_t>* sbp) {
|
||||
for (unsigned wi = 0; wi < 2; ++wi) {
|
||||
GraphWay way = wi ? GraphWay::REVERSE : GraphWay::FORWARD;
|
||||
const GraphWay way = wi ? GraphWay::REVERSE : GraphWay::FORWARD;
|
||||
for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) {
|
||||
MTaskEdge* tedgep = MTaskEdge::cast(edgep);
|
||||
if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep);
|
||||
|
|
@ -1252,7 +1252,7 @@ private:
|
|||
erased = m_pairs.erase(*pairp);
|
||||
UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask");
|
||||
}
|
||||
size_t erased = m_mtask2sibs.erase(mtaskp);
|
||||
const size_t erased = m_mtask2sibs.erase(mtaskp);
|
||||
UASSERT_OBJ(erased > 0, mtaskp, "Expected existing mtask");
|
||||
}
|
||||
|
||||
|
|
@ -1297,10 +1297,10 @@ private:
|
|||
//
|
||||
// These 'NewCp' objects carry a bit indicating whether we must
|
||||
// propagate CP for each of the four cases:
|
||||
NewCp recipientNewCpFwd = newCp(GraphWay::FORWARD, recipientp, donorp, mergeEdgep);
|
||||
NewCp donorNewCpFwd = newCp(GraphWay::FORWARD, donorp, recipientp, mergeEdgep);
|
||||
NewCp recipientNewCpRev = newCp(GraphWay::REVERSE, recipientp, donorp, mergeEdgep);
|
||||
NewCp donorNewCpRev = newCp(GraphWay::REVERSE, donorp, recipientp, mergeEdgep);
|
||||
const NewCp recipientNewCpFwd = newCp(GraphWay::FORWARD, recipientp, donorp, mergeEdgep);
|
||||
const NewCp donorNewCpFwd = newCp(GraphWay::FORWARD, donorp, recipientp, mergeEdgep);
|
||||
const NewCp recipientNewCpRev = newCp(GraphWay::REVERSE, recipientp, donorp, mergeEdgep);
|
||||
const NewCp donorNewCpRev = newCp(GraphWay::REVERSE, donorp, recipientp, mergeEdgep);
|
||||
|
||||
if (mergeEdgep) {
|
||||
// Remove and free the connecting edge. Must do this before
|
||||
|
|
@ -2456,7 +2456,7 @@ void V3Partition::go(V3Graph* mtasksp) {
|
|||
// remove this later if it doesn't really help.
|
||||
mtasksp->orderPreRanked();
|
||||
|
||||
int targetParFactor = v3Global.opt.threads();
|
||||
const int targetParFactor = v3Global.opt.threads();
|
||||
if (targetParFactor < 2) v3fatalSrc("We should not reach V3Partition when --threads <= 1");
|
||||
|
||||
// Set cpLimit to roughly totalGraphCost / nThreads
|
||||
|
|
@ -2464,8 +2464,8 @@ void V3Partition::go(V3Graph* mtasksp) {
|
|||
// Actually set it a bit lower, by a hardcoded fudge factor. This
|
||||
// results in more smaller mtasks, which helps reduce fragmentation
|
||||
// when scheduling them.
|
||||
unsigned fudgeNumerator = 3;
|
||||
unsigned fudgeDenominator = 5;
|
||||
const unsigned fudgeNumerator = 3;
|
||||
const unsigned fudgeDenominator = 5;
|
||||
uint32_t cpLimit = ((totalGraphCost * fudgeNumerator) / (targetParFactor * fudgeDenominator));
|
||||
UINFO(4, "V3Partition set cpLimit = " << cpLimit << endl);
|
||||
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ void V3PreProcImp::unputString(const string& strg) {
|
|||
}
|
||||
|
||||
void V3PreProcImp::unputDefrefString(const string& strg) {
|
||||
int multiline = std::count(strg.begin(), strg.end(), '\n');
|
||||
const int multiline = std::count(strg.begin(), strg.end(), '\n');
|
||||
unputString(strg);
|
||||
// A define that inserts multiple newlines are really attributed to one source line,
|
||||
// so temporarily don't increment lineno.
|
||||
|
|
@ -591,7 +591,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
|
|||
UINFO(4, "defineArg[" << i << "] = '" << refp->args()[i] << "'" << endl);
|
||||
}
|
||||
// Grab value
|
||||
string value = defValue(refp->name());
|
||||
const string value = defValue(refp->name());
|
||||
UINFO(4, "defineValue '" << V3PreLex::cleanDbgStrg(value) << "'" << endl);
|
||||
|
||||
std::map<const string, string> argValueByName;
|
||||
|
|
@ -603,7 +603,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
|
|||
bool quote = false;
|
||||
bool haveDefault = false;
|
||||
// Note there's a leading ( and trailing ), so parens==1 is the base parsing level
|
||||
string params = refp->params(); // Must keep str in scope to get pointer
|
||||
const string params = refp->params(); // Must keep str in scope to get pointer
|
||||
const char* cp = params.c_str();
|
||||
if (*cp == '(') cp++;
|
||||
for (; *cp; cp++) {
|
||||
|
|
@ -626,7 +626,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
|
|||
// A call `def( a ) must be equivalent to `def(a ), so trimWhitespace
|
||||
// At one point we didn't trim trailing
|
||||
// whitespace, but this confuses `"
|
||||
string arg = trimWhitespace(refp->args()[numArgs], true);
|
||||
const string arg = trimWhitespace(refp->args()[numArgs], true);
|
||||
if (arg != "") valueDef = arg;
|
||||
} else if (!haveDefault) {
|
||||
error("Define missing argument '" + argName + "' for: " + refp->name()
|
||||
|
|
@ -698,7 +698,7 @@ string V3PreProcImp::defineSubst(VDefineRef* refp) {
|
|||
const auto iter = argValueByName.find(argName);
|
||||
if (iter != argValueByName.end()) {
|
||||
// Substitute
|
||||
string subst = iter->second;
|
||||
const string subst = iter->second;
|
||||
if (subst == "") {
|
||||
// Normally `` is removed later, but with no token after, we're otherwise
|
||||
// stuck, so remove proceeding ``
|
||||
|
|
@ -780,7 +780,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam
|
|||
|
||||
// Read a list<string> with the whole file.
|
||||
StrList wholefile;
|
||||
bool ok = filterp->readWholefile(filename, wholefile /*ref*/);
|
||||
const bool ok = filterp->readWholefile(filename, wholefile /*ref*/);
|
||||
if (!ok) {
|
||||
error("File not found: " + filename + "\n");
|
||||
return;
|
||||
|
|
@ -956,7 +956,7 @@ void V3PreProcImp::debugToken(int tok, const char* cmtp) {
|
|||
string::size_type pos;
|
||||
while ((pos = buf.find('\n')) != string::npos) { buf.replace(pos, 1, "\\n"); }
|
||||
while ((pos = buf.find('\r')) != string::npos) { buf.replace(pos, 1, "\\r"); }
|
||||
string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
fprintf(stderr, "%s: %s %s %s(%d) dr%d: <%d>%-10s: %s\n", flcol.c_str(), cmtp,
|
||||
(m_off ? "of" : "on"), procStateName(state()), static_cast<int>(m_states.size()),
|
||||
static_cast<int>(m_defRefs.size()), m_lexp->currentStartState(), tokenName(tok),
|
||||
|
|
@ -1069,11 +1069,11 @@ int V3PreProcImp::getStateToken() {
|
|||
error("`elsif with no matching `if\n");
|
||||
} else {
|
||||
// Handle `else portion
|
||||
VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
const VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
m_ifdefStack.pop();
|
||||
if (!lastIf.on()) parsingOn();
|
||||
// Handle `if portion
|
||||
bool enable = !lastIf.everOn() && defExists(m_lastSym);
|
||||
const bool enable = !lastIf.everOn() && defExists(m_lastSym);
|
||||
UINFO(4, "Elsif " << m_lastSym << (enable ? " ON" : " OFF") << endl);
|
||||
m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn()));
|
||||
if (!enable) parsingOff();
|
||||
|
|
@ -1142,7 +1142,7 @@ int V3PreProcImp::getStateToken() {
|
|||
<< "' formals='" << V3PreLex::cleanDbgStrg(m_formals) << "'\n";
|
||||
}
|
||||
// Add any formals
|
||||
string formals = m_formals;
|
||||
const string formals = m_formals;
|
||||
string value = m_lexp->m_defValue;
|
||||
// Remove returns
|
||||
// Not removing returns in values has two problems,
|
||||
|
|
@ -1165,7 +1165,7 @@ int V3PreProcImp::getStateToken() {
|
|||
define(fileline(), m_lastSym, value, formals, false);
|
||||
}
|
||||
} else {
|
||||
string msg = string("Bad define text, unexpected ") + tokenName(tok) + "\n";
|
||||
const string msg = string("Bad define text, unexpected ") + tokenName(tok) + "\n";
|
||||
fatalSrc(msg);
|
||||
}
|
||||
statePop();
|
||||
|
|
@ -1220,7 +1220,7 @@ int V3PreProcImp::getStateToken() {
|
|||
if (VL_UNCOVERABLE(m_joinStack.empty())) {
|
||||
fatalSrc("`` join stack empty, but in a ``");
|
||||
}
|
||||
string lhs = m_joinStack.top();
|
||||
const string lhs = m_joinStack.top();
|
||||
m_joinStack.pop();
|
||||
out.insert(0, lhs);
|
||||
UINFO(5, "``-end-defarg Out:" << out << endl);
|
||||
|
|
@ -1309,12 +1309,12 @@ int V3PreProcImp::getStateToken() {
|
|||
if (VL_UNCOVERABLE(m_joinStack.empty())) {
|
||||
fatalSrc("`` join stack empty, but in a ``");
|
||||
}
|
||||
string lhs = m_joinStack.top();
|
||||
const string lhs = m_joinStack.top();
|
||||
m_joinStack.pop();
|
||||
UINFO(5, "`` LHS:" << lhs << endl);
|
||||
string rhs(yyourtext(), yyourleng());
|
||||
UINFO(5, "`` RHS:" << rhs << endl);
|
||||
string out = lhs + rhs;
|
||||
const string out = lhs + rhs;
|
||||
UINFO(5, "`` Out:" << out << endl);
|
||||
unputString(out);
|
||||
statePop();
|
||||
|
|
@ -1323,7 +1323,7 @@ int V3PreProcImp::getStateToken() {
|
|||
// Other compilers just ignore this, so no warning
|
||||
// "Expecting symbol to terminate ``; whitespace etc cannot
|
||||
// follow ``. Found: "+tokenName(tok)+"\n"
|
||||
string lhs = m_joinStack.top();
|
||||
const string lhs = m_joinStack.top();
|
||||
m_joinStack.pop();
|
||||
unputString(lhs);
|
||||
statePop();
|
||||
|
|
@ -1384,9 +1384,9 @@ int V3PreProcImp::getStateToken() {
|
|||
if (m_ifdefStack.empty()) {
|
||||
error("`else with no matching `if\n");
|
||||
} else {
|
||||
VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
const VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
m_ifdefStack.pop();
|
||||
bool enable = !lastIf.everOn();
|
||||
const bool enable = !lastIf.everOn();
|
||||
UINFO(4, "Else " << (enable ? " ON" : " OFF") << endl);
|
||||
m_ifdefStack.push(VPreIfEntry(enable, lastIf.everOn()));
|
||||
if (!lastIf.on()) parsingOn();
|
||||
|
|
@ -1398,7 +1398,7 @@ int V3PreProcImp::getStateToken() {
|
|||
if (m_ifdefStack.empty()) {
|
||||
error("`endif with no matching `if\n");
|
||||
} else {
|
||||
VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
const VPreIfEntry lastIf = m_ifdefStack.top();
|
||||
m_ifdefStack.pop();
|
||||
if (!lastIf.on()) parsingOn();
|
||||
// parsingOn() really only enables parsing if
|
||||
|
|
@ -1432,7 +1432,7 @@ int V3PreProcImp::getStateToken() {
|
|||
goto next_tok;
|
||||
}
|
||||
} else {
|
||||
string params = defParams(name);
|
||||
const string params = defParams(name);
|
||||
if (params == "0" || params == "") { // Found, as simple substitution
|
||||
string out;
|
||||
if (!m_off) {
|
||||
|
|
@ -1447,7 +1447,7 @@ int V3PreProcImp::getStateToken() {
|
|||
if (VL_UNCOVERABLE(m_joinStack.empty())) {
|
||||
fatalSrc("`` join stack empty, but in a ``");
|
||||
}
|
||||
string lhs = m_joinStack.top();
|
||||
const string lhs = m_joinStack.top();
|
||||
m_joinStack.pop();
|
||||
out.insert(0, lhs);
|
||||
UINFO(5, "``-end-defref Out:" << out << endl);
|
||||
|
|
@ -1533,11 +1533,11 @@ int V3PreProcImp::getFinalToken(string& buf) {
|
|||
m_finToken = getStateToken();
|
||||
m_finBuf = string(yyourtext(), yyourleng());
|
||||
}
|
||||
int tok = m_finToken;
|
||||
const int tok = m_finToken;
|
||||
buf = m_finBuf;
|
||||
if (false && debug() >= 5) {
|
||||
string bufcln = V3PreLex::cleanDbgStrg(buf);
|
||||
string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
const string bufcln = V3PreLex::cleanDbgStrg(buf);
|
||||
const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
fprintf(stderr, "%s: FIN: %-10s: %s\n", flcol.c_str(), tokenName(tok),
|
||||
bufcln.c_str());
|
||||
}
|
||||
|
|
@ -1552,7 +1552,7 @@ int V3PreProcImp::getFinalToken(string& buf) {
|
|||
if (int outBehind
|
||||
= (m_lexp->m_tokFilelinep->lastLineno() - m_finFilelinep->lastLineno())) {
|
||||
if (debug() >= 5) {
|
||||
string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
fprintf(stderr, "%s: FIN: readjust, fin at %d request at %d\n", flcol.c_str(),
|
||||
m_finFilelinep->lastLineno(), m_lexp->m_tokFilelinep->lastLineno());
|
||||
}
|
||||
|
|
@ -1594,10 +1594,10 @@ string V3PreProcImp::getline() {
|
|||
bool gotEof = false;
|
||||
while (nullptr == (rtnp = strchr(m_lineChars.c_str(), '\n')) && !gotEof) {
|
||||
string buf;
|
||||
int tok = getFinalToken(buf /*ref*/);
|
||||
const int tok = getFinalToken(buf /*ref*/);
|
||||
if (debug() >= 5) {
|
||||
string bufcln = V3PreLex::cleanDbgStrg(buf);
|
||||
string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
const string bufcln = V3PreLex::cleanDbgStrg(buf);
|
||||
const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
fprintf(stderr, "%s: GETFETC: %-10s: %s\n", flcol.c_str(), tokenName(tok),
|
||||
bufcln.c_str());
|
||||
}
|
||||
|
|
@ -1613,12 +1613,12 @@ string V3PreProcImp::getline() {
|
|||
}
|
||||
|
||||
// Make new string with data up to the newline.
|
||||
int len = rtnp - m_lineChars.c_str() + 1;
|
||||
const int len = rtnp - m_lineChars.c_str() + 1;
|
||||
string theLine(m_lineChars, 0, len);
|
||||
m_lineChars = m_lineChars.erase(0, len); // Remove returned characters
|
||||
if (debug() >= 4) {
|
||||
string lncln = V3PreLex::cleanDbgStrg(theLine);
|
||||
string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
const string lncln = V3PreLex::cleanDbgStrg(theLine);
|
||||
const string flcol = m_lexp->m_tokFilelinep->asciiLineCol();
|
||||
fprintf(stderr, "%s: GETLINE: %s\n", flcol.c_str(), lncln.c_str());
|
||||
}
|
||||
return theLine;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ protected:
|
|||
|
||||
// Preprocess
|
||||
s_filterp = filterp;
|
||||
string modfilename = preprocOpen(fl, s_filterp, modname, "", errmsg);
|
||||
const string modfilename = preprocOpen(fl, s_filterp, modname, "", errmsg);
|
||||
if (modfilename.empty()) return false;
|
||||
|
||||
// Set language standard up front
|
||||
|
|
@ -112,7 +112,7 @@ protected:
|
|||
}
|
||||
|
||||
while (!s_preprocp->isEof()) {
|
||||
string line = s_preprocp->getline();
|
||||
const string line = s_preprocp->getline();
|
||||
V3Parse::ppPushText(parsep, line);
|
||||
}
|
||||
return true;
|
||||
|
|
@ -138,7 +138,7 @@ private:
|
|||
if (filename == "") {
|
||||
// Allow user to put `defined names on the command line instead of filenames,
|
||||
// then convert them properly.
|
||||
string ppmodname = s_preprocp->removeDefines(modname);
|
||||
const string ppmodname = s_preprocp->removeDefines(modname);
|
||||
|
||||
filename = v3Global.opt.filePath(fl, ppmodname, lastpath, errmsg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ private:
|
|||
virtual void visit(AstNodeAssign* nodep) override {
|
||||
startStatement(nodep);
|
||||
{
|
||||
bool noopt = PremitAssignVisitor(nodep).noOpt();
|
||||
const bool noopt = PremitAssignVisitor(nodep).noOpt();
|
||||
if (noopt && !nodep->user1()) {
|
||||
nodep->user1(true);
|
||||
// Need to do this even if not wide, as e.g. a select may be on a wide operator
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ private:
|
|||
AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) {
|
||||
AstVar* varp = VN_CAST(cfuncp->user1p(), Var);
|
||||
if (!varp) {
|
||||
string newvarname = string("__Vilp");
|
||||
const string newvarname = string("__Vilp");
|
||||
varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32);
|
||||
UASSERT_OBJ(cfuncp, fl, "Assignment not under a function");
|
||||
cfuncp->addInitsp(varp);
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstScopeName* nodep) override {
|
||||
// If there's a %m in the display text, we add a special node that will contain the name()
|
||||
string prefix = string("__DOT__") + m_scopep->name();
|
||||
const string prefix = string("__DOT__") + m_scopep->name();
|
||||
// TOP and above will be the user's name().
|
||||
// Note 'TOP.' is stripped by scopePrettyName
|
||||
// To keep correct visual order, must add before other Text's
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ private:
|
|||
// removed from the map.
|
||||
// Clear the m_vals mapping for k.
|
||||
KeySet& keysAtOldVal = m_vals[oldVal];
|
||||
size_t erased = keysAtOldVal.erase(k);
|
||||
const size_t erased = keysAtOldVal.erase(k);
|
||||
UASSERT(erased == 1, "removeKeyFromOldVal() removal key not found");
|
||||
if (keysAtOldVal.empty()) {
|
||||
// Don't keep empty sets in the value map.
|
||||
|
|
@ -451,7 +451,7 @@ public:
|
|||
// and sort all elements by their current score.
|
||||
void rescore() {
|
||||
for (const T_Elem* elp : m_unknown) {
|
||||
T_Score sortScore = m_scoreFnp(elp);
|
||||
const T_Score sortScore = m_scoreFnp(elp);
|
||||
m_sorted.set(elp, sortScore);
|
||||
}
|
||||
m_unknown.clear();
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ private:
|
|||
out << "'{";
|
||||
for (AstMemberDType* itemp = stp->membersp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
int width = itemp->width();
|
||||
int lsb = itemp->lsb();
|
||||
int msb = lsb + width - 1;
|
||||
const int width = itemp->width();
|
||||
const int lsb = itemp->lsb();
|
||||
const int msb = lsb + width - 1;
|
||||
V3Number fieldNum(nump, width);
|
||||
fieldNum.opSel(*nump, msb, lsb);
|
||||
out << itemp->name() << ": ";
|
||||
|
|
@ -145,14 +145,14 @@ private:
|
|||
if (AstNodeDType* childTypep = arrayp->subDTypep()) {
|
||||
std::ostringstream out;
|
||||
out << "[";
|
||||
int arrayElements = arrayp->elementsConst();
|
||||
const int arrayElements = arrayp->elementsConst();
|
||||
for (int element = 0; element < arrayElements; ++element) {
|
||||
int width = childTypep->width();
|
||||
int lsb = width * element;
|
||||
int msb = lsb + width - 1;
|
||||
const int width = childTypep->width();
|
||||
const int lsb = width * element;
|
||||
const int msb = lsb + width - 1;
|
||||
V3Number fieldNum(nump, width);
|
||||
fieldNum.opSel(*nump, msb, lsb);
|
||||
int arrayElem = arrayp->lo() + element;
|
||||
const int arrayElem = arrayp->lo() + element;
|
||||
out << arrayElem << " = " << prettyNumber(&fieldNum, childTypep);
|
||||
if (element < arrayElements - 1) out << ", ";
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ private:
|
|||
clearOptimizable(nodep, "Var write & read");
|
||||
}
|
||||
vscp->user1(vscp->user1() | VU_RV);
|
||||
bool isConst = nodep->varp()->isParam() && nodep->varp()->valuep();
|
||||
const bool isConst = nodep->varp()->isParam() && nodep->varp()->valuep();
|
||||
AstNode* valuep = isConst ? fetchValueNull(nodep->varp()->valuep()) : nullptr;
|
||||
if (isConst
|
||||
&& valuep) { // Propagate PARAM constants for constant function analysis
|
||||
|
|
@ -1021,7 +1021,7 @@ private:
|
|||
AstNode* nextArgp = nodep->exprsp();
|
||||
|
||||
string result;
|
||||
string format = nodep->text();
|
||||
const string format = nodep->text();
|
||||
auto pos = format.cbegin();
|
||||
bool inPct = false;
|
||||
for (; pos != format.cend(); ++pos) {
|
||||
|
|
@ -1041,7 +1041,7 @@ private:
|
|||
nodep, "Argument for $display like statement is not constant");
|
||||
break;
|
||||
}
|
||||
string pformat = string("%") + pos[0];
|
||||
const string pformat = string("%") + pos[0];
|
||||
result += constp->num().displayed(nodep, pformat);
|
||||
} else {
|
||||
switch (tolower(pos[0])) {
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ class SliceVisitor final : public AstNVisitor {
|
|||
AstNode* newp;
|
||||
if (AstInitArray* initp = VN_CAST(nodep, InitArray)) {
|
||||
UINFO(9, " cloneInitArray(" << elements << "," << offset << ") " << nodep << endl);
|
||||
int leOffset = !arrayp->rangep()->littleEndian()
|
||||
? arrayp->rangep()->elementsConst() - 1 - offset
|
||||
: offset;
|
||||
const int leOffset = !arrayp->rangep()->littleEndian()
|
||||
? arrayp->rangep()->elementsConst() - 1 - offset
|
||||
: offset;
|
||||
AstNode* itemp = initp->getIndexDefaultedValuep(leOffset);
|
||||
if (!itemp) {
|
||||
nodep->v3error("Array initialization has too few elements, need element "
|
||||
|
|
@ -103,17 +103,17 @@ class SliceVisitor final : public AstNVisitor {
|
|||
cloneAndSel(snodep->expr2p(), elements, offset));
|
||||
} else if (AstSliceSel* snodep = VN_CAST(nodep, SliceSel)) {
|
||||
UINFO(9, " cloneSliceSel(" << elements << "," << offset << ") " << nodep << endl);
|
||||
int leOffset = (snodep->declRange().lo()
|
||||
+ (!snodep->declRange().littleEndian()
|
||||
? snodep->declRange().elements() - 1 - offset
|
||||
: offset));
|
||||
const int leOffset = (snodep->declRange().lo()
|
||||
+ (!snodep->declRange().littleEndian()
|
||||
? snodep->declRange().elements() - 1 - offset
|
||||
: offset));
|
||||
newp = new AstArraySel(nodep->fileline(), snodep->fromp()->cloneTree(false), leOffset);
|
||||
} else if (VN_IS(nodep, ArraySel) || VN_IS(nodep, NodeVarRef) || VN_IS(nodep, NodeSel)
|
||||
|| VN_IS(nodep, CMethodHard) || VN_IS(nodep, MemberSel)) {
|
||||
UINFO(9, " cloneSel(" << elements << "," << offset << ") " << nodep << endl);
|
||||
int leOffset = !arrayp->rangep()->littleEndian()
|
||||
? arrayp->rangep()->elementsConst() - 1 - offset
|
||||
: offset;
|
||||
const int leOffset = !arrayp->rangep()->littleEndian()
|
||||
? arrayp->rangep()->elementsConst() - 1 - offset
|
||||
: offset;
|
||||
newp = new AstArraySel(nodep->fileline(), nodep->cloneTree(false), leOffset);
|
||||
} else {
|
||||
if (!m_assignError) {
|
||||
|
|
@ -138,7 +138,7 @@ class SliceVisitor final : public AstNVisitor {
|
|||
// and all variables are realigned to start at zero
|
||||
// Assign of a little endian'ed slice to a big endian one must reverse the elements
|
||||
AstNode* newlistp = nullptr;
|
||||
int elements = arrayp->rangep()->elementsConst();
|
||||
const int elements = arrayp->rangep()->elementsConst();
|
||||
for (int offset = 0; offset < elements; ++offset) {
|
||||
AstNode* newp = nodep->cloneType // AstNodeAssign
|
||||
(cloneAndSel(nodep->lhsp(), elements, offset),
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ private:
|
|||
return;
|
||||
}
|
||||
UINFO(6, " CL STMT " << nodep << endl);
|
||||
bool oldKeep = m_keepStmt;
|
||||
const bool oldKeep = m_keepStmt;
|
||||
{
|
||||
m_matches = false;
|
||||
m_keepStmt = false;
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ private:
|
|||
bool addCore(AstVarRef* refp, const UnpackRef& ref) {
|
||||
AstVar* varp = refp->varp();
|
||||
UASSERT_OBJ(varp->attrSplitVar(), varp, " no split_var metacomment");
|
||||
MapIt it = m_map.find(varp);
|
||||
const MapIt it = m_map.find(varp);
|
||||
if (it == m_map.end()) return false; // Not registered
|
||||
const bool ok = m_map[varp].insert(ref).second;
|
||||
return ok;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ private:
|
|||
if (v3Global.opt.statsVars()) m_statVarWidthNames.resize(nodep->width() + 5);
|
||||
}
|
||||
++m_statVarWidths.at(nodep->width());
|
||||
string pn = nodep->prettyName();
|
||||
const string pn = nodep->prettyName();
|
||||
if (v3Global.opt.statsVars()) {
|
||||
NameMap& nameMapr = m_statVarWidthNames.at(nodep->width());
|
||||
if (nameMapr.find(pn) != nameMapr.end()) {
|
||||
|
|
@ -230,7 +230,7 @@ public:
|
|||
V3Stats::addStat(m_stage, "Var space, scoped, bytes", m_statVarScpBytes);
|
||||
}
|
||||
for (unsigned i = 0; i < m_statVarWidths.size(); i++) {
|
||||
double count = double(m_statVarWidths.at(i));
|
||||
const double count = double(m_statVarWidths.at(i));
|
||||
if (count != 0.0) {
|
||||
if (v3Global.opt.statsVars()) {
|
||||
NameMap& nameMapr = m_statVarWidthNames.at(i);
|
||||
|
|
@ -248,14 +248,14 @@ public:
|
|||
}
|
||||
// Node types
|
||||
for (int type = 0; type < AstType::_ENUM_END; type++) {
|
||||
double count = double(m_statTypeCount.at(type));
|
||||
const double count = double(m_statTypeCount.at(type));
|
||||
if (count != 0.0) {
|
||||
V3Stats::addStat(m_stage, string("Node count, ") + AstType(type).ascii(), count);
|
||||
}
|
||||
}
|
||||
for (int type = 0; type < AstType::_ENUM_END; type++) {
|
||||
for (int type2 = 0; type2 < AstType::_ENUM_END; type2++) {
|
||||
double count = double(m_statAbove[type][type2]);
|
||||
const double count = double(m_statAbove[type][type2]);
|
||||
if (count != 0.0) {
|
||||
V3Stats::addStat(m_stage,
|
||||
(string("Node pairs, ") + AstType(type).ascii() + "_"
|
||||
|
|
@ -266,7 +266,7 @@ public:
|
|||
}
|
||||
// Branch pred
|
||||
for (int type = 0; type < VBranchPred::_ENUM_END; type++) {
|
||||
double count = double(m_statPred[type]);
|
||||
const double count = double(m_statPred[type]);
|
||||
if (count != 0.0) {
|
||||
V3Stats::addStat(
|
||||
m_stage, (string("Branch prediction, ") + VBranchPred(type).ascii()), count);
|
||||
|
|
|
|||
|
|
@ -206,13 +206,13 @@ void V3Stats::statsStage(const string& name) {
|
|||
|
||||
const string digitName = V3Global::digitsFilename(++fileNumber) + "_" + name;
|
||||
|
||||
double wallTime = V3Os::timeUsecs() / 1.0e6;
|
||||
const double wallTime = V3Os::timeUsecs() / 1.0e6;
|
||||
if (lastWallTime < 0) lastWallTime = wallTime;
|
||||
double wallTimeDelta = wallTime - lastWallTime;
|
||||
const double wallTimeDelta = wallTime - lastWallTime;
|
||||
lastWallTime = wallTime;
|
||||
V3Stats::addStatPerf("Stage, Elapsed time (sec), " + digitName, wallTimeDelta);
|
||||
|
||||
double memory = V3Os::memUsageBytes() / 1024.0 / 1024.0;
|
||||
const double memory = V3Os::memUsageBytes() / 1024.0 / 1024.0;
|
||||
V3Stats::addStatPerf("Stage, Memory (MB), " + digitName, memory);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,8 @@ void V3Stats::statsReport() {
|
|||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
|
||||
// Open stats file
|
||||
string filename = v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "__stats.txt";
|
||||
const string filename
|
||||
= v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "__stats.txt";
|
||||
std::ofstream* ofp(V3File::new_ofstream(filename));
|
||||
if (ofp->fail()) v3fatal("Can't write " << filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ double VString::parseDouble(const string& str, bool* successp) {
|
|||
*dp++ = '\0';
|
||||
char* endp = strgp;
|
||||
double d = strtod(strgp, &endp);
|
||||
size_t parsed_len = endp - strgp;
|
||||
const size_t parsed_len = endp - strgp;
|
||||
if (parsed_len != strlen(strgp)) {
|
||||
if (successp) *successp = false;
|
||||
}
|
||||
|
|
@ -406,7 +406,7 @@ string VName::dehash(const string& in) {
|
|||
for (string::size_type last_dot_pos = 0; last_dot_pos < in.size();) {
|
||||
const string::size_type next_dot_pos = in.find("__DOT__", last_dot_pos);
|
||||
// Two iterators defining the range between the last and next dots.
|
||||
auto search_begin = std::begin(in) + last_dot_pos;
|
||||
const auto search_begin = std::begin(in) + last_dot_pos;
|
||||
auto search_end
|
||||
= next_dot_pos == string::npos ? std::end(in) : std::begin(in) + next_dot_pos;
|
||||
|
||||
|
|
@ -451,7 +451,7 @@ string VName::hashedName() {
|
|||
return m_hashed;
|
||||
} else {
|
||||
VHashSha256 hash(m_name);
|
||||
string suffix = "__Vhsh" + hash.digestSymbol();
|
||||
const string suffix = "__Vhsh" + hash.digestSymbol();
|
||||
if (s_minLength < s_maxLength) {
|
||||
s_dehashMap[suffix] = m_name.substr(s_minLength);
|
||||
m_hashed = m_name.substr(0, s_minLength) + suffix;
|
||||
|
|
@ -468,8 +468,8 @@ string VName::hashedName() {
|
|||
|
||||
VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const string& t) {
|
||||
// Wagner-Fischer algorithm for the Damerau-Levenshtein distance
|
||||
size_t sLen = s.length();
|
||||
size_t tLen = t.length();
|
||||
const size_t sLen = s.length();
|
||||
const size_t tLen = t.length();
|
||||
if (sLen == 0) return tLen;
|
||||
if (tLen == 0) return sLen;
|
||||
if (sLen >= LENGTH_LIMIT) return sLen;
|
||||
|
|
@ -484,14 +484,14 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin
|
|||
for (size_t i = 0; i < tLen; i++) {
|
||||
s_v_next[0] = i + 1;
|
||||
for (size_t j = 0; j < sLen; j++) {
|
||||
EditDistance cost = (s[j] == t[i] ? 0 : 1);
|
||||
EditDistance deletion = s_v_next[j] + 1;
|
||||
EditDistance insertion = s_v_one_ago[j + 1] + 1;
|
||||
EditDistance substitution = s_v_one_ago[j] + cost;
|
||||
const EditDistance cost = (s[j] == t[i] ? 0 : 1);
|
||||
const EditDistance deletion = s_v_next[j] + 1;
|
||||
const EditDistance insertion = s_v_one_ago[j + 1] + 1;
|
||||
const EditDistance substitution = s_v_one_ago[j] + cost;
|
||||
EditDistance cheapest = std::min(deletion, insertion);
|
||||
cheapest = std::min(cheapest, substitution);
|
||||
if (i > 0 && j > 0 && s[j] == t[i - 1] && s[j - 1] == t[i]) {
|
||||
EditDistance transposition = s_v_two_ago[j - 1] + 1;
|
||||
const EditDistance transposition = s_v_two_ago[j - 1] + 1;
|
||||
cheapest = std::min(cheapest, transposition);
|
||||
}
|
||||
s_v_next[j + 1] = cheapest;
|
||||
|
|
@ -502,14 +502,14 @@ VSpellCheck::EditDistance VSpellCheck::editDistance(const string& s, const strin
|
|||
}
|
||||
}
|
||||
|
||||
EditDistance result = s_v_next[sLen];
|
||||
const EditDistance result = s_v_next[sLen];
|
||||
return result;
|
||||
}
|
||||
|
||||
VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t candidate_len) {
|
||||
// Return max acceptable edit distance
|
||||
size_t max_length = std::max(goal_len, candidate_len);
|
||||
size_t min_length = std::min(goal_len, candidate_len);
|
||||
const size_t max_length = std::max(goal_len, candidate_len);
|
||||
const size_t min_length = std::min(goal_len, candidate_len);
|
||||
if (max_length <= 1) return 0;
|
||||
if (max_length - min_length <= 1) return std::max(max_length / 3, static_cast<size_t>(1));
|
||||
return (max_length + 2) / 3;
|
||||
|
|
@ -517,19 +517,19 @@ VSpellCheck::EditDistance VSpellCheck::cutoffDistance(size_t goal_len, size_t ca
|
|||
|
||||
string VSpellCheck::bestCandidateInfo(const string& goal, EditDistance& distancer) const {
|
||||
string bestCandidate;
|
||||
size_t gLen = goal.length();
|
||||
const size_t gLen = goal.length();
|
||||
distancer = LENGTH_LIMIT * 10;
|
||||
for (const string& candidate : m_candidates) {
|
||||
size_t cLen = candidate.length();
|
||||
const size_t cLen = candidate.length();
|
||||
|
||||
// Min distance must be inserting/deleting to make lengths match
|
||||
EditDistance min_distance = (cLen > gLen ? (cLen - gLen) : (gLen - cLen));
|
||||
const EditDistance min_distance = (cLen > gLen ? (cLen - gLen) : (gLen - cLen));
|
||||
if (min_distance >= distancer) continue; // Short-circuit if already better
|
||||
|
||||
EditDistance cutoff = cutoffDistance(gLen, cLen);
|
||||
const EditDistance cutoff = cutoffDistance(gLen, cLen);
|
||||
if (min_distance > cutoff) continue; // Short-circuit if already too bad
|
||||
|
||||
EditDistance dist = editDistance(goal, candidate);
|
||||
const EditDistance dist = editDistance(goal, candidate);
|
||||
UINFO(9, "EditDistance dist=" << dist << " cutoff=" << cutoff << " goal=" << goal
|
||||
<< " candidate=" << candidate << endl);
|
||||
if (dist < distancer && dist <= cutoff) {
|
||||
|
|
@ -553,7 +553,7 @@ void VSpellCheck::selfTestSuggestOne(bool matches, const string& c, const string
|
|||
EditDistance gdist;
|
||||
VSpellCheck speller;
|
||||
speller.pushCandidate(c);
|
||||
string got = speller.bestCandidateInfo(goal, gdist /*ref*/);
|
||||
const string got = speller.bestCandidateInfo(goal, gdist /*ref*/);
|
||||
if (matches) {
|
||||
UASSERT_SELFTEST(const string&, got, c);
|
||||
UASSERT_SELFTEST(EditDistance, gdist, dist);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ public:
|
|||
}
|
||||
// Return friendly message
|
||||
string bestCandidateMsg(const string& goal) const {
|
||||
string candidate = bestCandidate(goal);
|
||||
const string candidate = bestCandidate(goal);
|
||||
if (candidate.empty()) {
|
||||
return "";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ private:
|
|||
} else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) {
|
||||
if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) {
|
||||
if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) {
|
||||
int word = VN_CAST(wordp->rhsp(), Const)->toUInt();
|
||||
const int word = VN_CAST(wordp->rhsp(), Const)->toUInt();
|
||||
SubstVarEntry* entryp = getEntryp(varrefp);
|
||||
hit = true;
|
||||
if (m_ops > SUBST_MAX_OPS_SUBST) {
|
||||
|
|
@ -309,7 +309,7 @@ private:
|
|||
if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) {
|
||||
// Nicely formed lvalues handled in NodeAssign
|
||||
// Other lvalues handled as unknown mess in AstVarRef
|
||||
int word = constp->toUInt();
|
||||
const int word = constp->toUInt();
|
||||
UINFO(8, " USEword" << word << " " << varrefp << endl);
|
||||
SubstVarEntry* entryp = getEntryp(varrefp);
|
||||
if (AstNode* substp = entryp->substWord(nodep, word)) {
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ public:
|
|||
}
|
||||
void dumpFilePrefixed(const string& nameComment) {
|
||||
if (v3Global.opt.dumpTree()) {
|
||||
string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
UINFO(2, "Dumping " << filename << endl);
|
||||
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatal("Can't write " << filename);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public:
|
|||
// The only time we may create duplicate edges is when
|
||||
// combining the MST with the perfect-matched pairs,
|
||||
// and in that case, we want to permit duplicate edges.
|
||||
unsigned edgeId = ++V3TSP::edgeIdNext;
|
||||
const unsigned edgeId = ++V3TSP::edgeIdNext;
|
||||
|
||||
// Record the 'id' which identifies a single bidir edge
|
||||
// in the user field of each V3GraphEdge:
|
||||
|
|
@ -127,8 +127,8 @@ public:
|
|||
EdgeCmp() = default;
|
||||
// METHODS
|
||||
bool operator()(const V3GraphEdge* ap, const V3GraphEdge* bp) {
|
||||
int aCost = ap->weight();
|
||||
int bCost = bp->weight();
|
||||
const int aCost = ap->weight();
|
||||
const int bCost = bp->weight();
|
||||
// Sort first on cost, lowest cost edges first:
|
||||
if (aCost < bCost) return true;
|
||||
if (bCost < aCost) return false;
|
||||
|
|
@ -188,7 +188,7 @@ public:
|
|||
// to the pending set.
|
||||
Vertex* neighborp = castVertexp(bestEdgep->top());
|
||||
if (visited_set.find(neighborp) == visited_set.end()) {
|
||||
int bestCost = bestEdgep->weight();
|
||||
const int bestCost = bestEdgep->weight();
|
||||
UINFO(6, "bestCost = " << bestCost << " from " << from_vertexp->key() << " to "
|
||||
<< neighborp->key() << endl);
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ public:
|
|||
}
|
||||
void dumpGraphFilePrefixed(const string& nameComment) const {
|
||||
if (v3Global.opt.dumpTree()) {
|
||||
string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const string filename = v3Global.debugFilename(nameComment) + ".txt";
|
||||
const std::unique_ptr<std::ofstream> logp(V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatal("Can't write " << filename);
|
||||
dumpGraph(*logp, nameComment);
|
||||
|
|
@ -463,7 +463,7 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) {
|
|||
const TspStateBase* ap = (*resultp)[i];
|
||||
const TspStateBase* bp
|
||||
= (i + 1 == resultp->size()) ? (*resultp)[0] : (*resultp)[i + 1];
|
||||
unsigned cost = ap->cost(bp);
|
||||
const unsigned cost = ap->cost(bp);
|
||||
if (cost > max_cost) {
|
||||
max_cost = cost;
|
||||
max_cost_idx = i;
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ private:
|
|||
}
|
||||
}
|
||||
// First argument is symbol table, then output if a function
|
||||
bool needSyms = !refp->taskp()->dpiImport();
|
||||
const bool needSyms = !refp->taskp()->dpiImport();
|
||||
if (needSyms) ccallp->argTypes("vlSymsp");
|
||||
|
||||
if (refp->taskp()->dpiContext()) {
|
||||
|
|
@ -691,7 +691,7 @@ private:
|
|||
|
||||
AstNode* createAssignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix,
|
||||
const string& toSuffix) {
|
||||
string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix);
|
||||
const string stmt = V3Task::assignInternalToDpi(portp, isPtr, frSuffix, toSuffix);
|
||||
return new AstCStmt(portp->fileline(), stmt);
|
||||
}
|
||||
|
||||
|
|
@ -992,14 +992,14 @@ private:
|
|||
// Ideally we'd make a table of variable
|
||||
// characteristics, and reuse it wherever we can
|
||||
// At least put them into the module's CTOR as static?
|
||||
string propName = portp->name() + "__Vopenprops";
|
||||
string propCode = portp->vlPropDecl(propName);
|
||||
const string propName = portp->name() + "__Vopenprops";
|
||||
const string propCode = portp->vlPropDecl(propName);
|
||||
cfuncp->addStmtsp(new AstCStmt(portp->fileline(), propCode));
|
||||
//
|
||||
// At runtime we need the svOpenArrayHandle to
|
||||
// point to this task & thread's data, in addition
|
||||
// to static info about the variable
|
||||
string name = portp->name() + "__Vopenarray";
|
||||
const string name = portp->name() + "__Vopenarray";
|
||||
string varCode
|
||||
= ("VerilatedDpiOpenVar "
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
|
|
@ -1025,7 +1025,7 @@ private:
|
|||
|
||||
// Store context, if needed
|
||||
if (nodep->dpiContext()) {
|
||||
string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n";
|
||||
const string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n";
|
||||
cfuncp->addStmtsp(new AstCStmt(nodep->fileline(), stmt));
|
||||
}
|
||||
|
||||
|
|
@ -1135,7 +1135,7 @@ private:
|
|||
// so make it unique now.
|
||||
string suffix; // So, make them unique
|
||||
if (!nodep->taskPublic() && !nodep->classMethod()) suffix = "_" + m_scopep->nameDotless();
|
||||
string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix);
|
||||
const string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix);
|
||||
AstCFunc* cfuncp = new AstCFunc(
|
||||
nodep->fileline(), name, m_scopep,
|
||||
((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : ""));
|
||||
|
|
@ -1307,8 +1307,8 @@ private:
|
|||
UINFO(4, " FTask REF " << nodep << endl);
|
||||
if (debug() >= 9) nodep->dumpTree(cout, "-inlfunc:");
|
||||
UASSERT_OBJ(m_scopep, nodep, "func ref not under scope");
|
||||
string namePrefix = ((VN_IS(nodep, FuncRef) ? "__Vfunc_" : "__Vtask_")
|
||||
+ nodep->taskp()->shortName() + "__" + cvtToStr(m_modNCalls++));
|
||||
const string namePrefix = ((VN_IS(nodep, FuncRef) ? "__Vfunc_" : "__Vtask_")
|
||||
+ nodep->taskp()->shortName() + "__" + cvtToStr(m_modNCalls++));
|
||||
// Create output variable
|
||||
AstVarScope* outvscp = nullptr;
|
||||
if (nodep->taskp()->isFunction()) {
|
||||
|
|
@ -1621,8 +1621,8 @@ string V3Task::assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSu
|
|||
string ket;
|
||||
// Someday we'll have better type support, and this can make variables and casts.
|
||||
// But for now, we'll just text-bash it.
|
||||
string frName = frPrefix + portp->name() + frSuffix;
|
||||
string toName = portp->name() + toSuffix;
|
||||
const string frName = frPrefix + portp->name() + frSuffix;
|
||||
const string toName = portp->name() + toSuffix;
|
||||
size_t unpackSize = 1; // non-unpacked array is treated as size 1
|
||||
int unpackDim = 0;
|
||||
if (AstUnpackArrayDType* unpackp = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) {
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ private:
|
|||
// If required, create the conditional node checking the activity flags
|
||||
if (!prevActSet || actSet != *prevActSet) {
|
||||
FileLine* const flp = m_topScopep->fileline();
|
||||
bool always = actSet.count(TraceActivityVertex::ACTIVITY_ALWAYS) != 0;
|
||||
const bool always = actSet.count(TraceActivityVertex::ACTIVITY_ALWAYS) != 0;
|
||||
AstNode* condp = nullptr;
|
||||
if (always) {
|
||||
condp = new AstConst(flp, 1); // Always true, will be folded later
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ private:
|
|||
|
||||
const string irpName = irp->prettyName();
|
||||
if (scopeLen > irpName.length()) continue;
|
||||
string intfScopeName = irpName.substr(0, scopeLen);
|
||||
const string intfScopeName = irpName.substr(0, scopeLen);
|
||||
if (scopeName != intfScopeName) continue;
|
||||
callCFuncSub(origSubFunc, m_initSubFuncp, irp);
|
||||
++origSubStmts;
|
||||
|
|
|
|||
|
|
@ -1138,13 +1138,13 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
if (debug() >= 9) nodep->dumpTree(cout, "-pin-pre: ");
|
||||
|
||||
// Empty/in-only; need Z to propagate
|
||||
bool inDeclProcessing = (nodep->exprp()
|
||||
&& nodep->modVarp()->direction() == VDirection::INPUT
|
||||
// Need to consider the original state
|
||||
// instead of current state as we converted
|
||||
// tristates to inputs, which do not want
|
||||
// to have this.
|
||||
&& !nodep->modVarp()->declDirection().isWritable());
|
||||
const bool inDeclProcessing = (nodep->exprp()
|
||||
&& nodep->modVarp()->direction() == VDirection::INPUT
|
||||
// Need to consider the original state
|
||||
// instead of current state as we converted
|
||||
// tristates to inputs, which do not want
|
||||
// to have this.
|
||||
&& !nodep->modVarp()->declDirection().isWritable());
|
||||
if (!nodep->exprp()) { // No-connect; covert to empty connection
|
||||
UINFO(5, "Unconnected pin terminate " << nodep << endl);
|
||||
AstVar* ucVarp = getCreateUnconnVarp(nodep, nodep->modVarp()->dtypep());
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ private:
|
|||
}
|
||||
} else if (prev) {
|
||||
AstBasicDType* bdtypep = m_varp->basicp();
|
||||
int lsb = bit + 1;
|
||||
const int lsb = bit + 1;
|
||||
if (bits != "") bits += ",";
|
||||
if (lsb == msb) {
|
||||
bits += cvtToStr(lsb + bdtypep->lo());
|
||||
|
|
@ -141,9 +141,9 @@ public:
|
|||
return isUsedNotDrivenBit(0, m_bitFlags.size() / FLAGS_PER_BIT);
|
||||
}
|
||||
bool unusedMatch(AstVar* nodep) {
|
||||
string regexp = v3Global.opt.unusedRegexp();
|
||||
const string regexp = v3Global.opt.unusedRegexp();
|
||||
if (regexp == "") return false;
|
||||
string prettyName = nodep->prettyName();
|
||||
const string prettyName = nodep->prettyName();
|
||||
return VString::wildmatch(prettyName.c_str(), regexp.c_str());
|
||||
}
|
||||
void reportViolations() {
|
||||
|
|
@ -158,8 +158,8 @@ public:
|
|||
bool anyDnotU = false;
|
||||
bool anynotDU = false;
|
||||
for (unsigned bit = 0; bit < m_bitFlags.size() / FLAGS_PER_BIT; bit++) {
|
||||
bool used = usedFlag(bit);
|
||||
bool driv = drivenFlag(bit);
|
||||
const bool used = usedFlag(bit);
|
||||
const bool driv = drivenFlag(bit);
|
||||
allU &= used;
|
||||
anyU |= used;
|
||||
allD &= driv;
|
||||
|
|
@ -326,7 +326,7 @@ private:
|
|||
if (varrefp && constp && !constp->num().isFourState()) {
|
||||
for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) {
|
||||
UndrivenVarEntry* entryp = getEntryp(varrefp->varp(), usr);
|
||||
int lsb = constp->toUInt();
|
||||
const int lsb = constp->toUInt();
|
||||
if (m_inBBox || varrefp->access().isWriteOrRW()) {
|
||||
// Don't warn if already driven earlier as "a=0; if(a) a=1;" is fine.
|
||||
if (usr == 2 && m_alwaysCombp
|
||||
|
|
@ -365,8 +365,8 @@ private:
|
|||
}
|
||||
for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) {
|
||||
UndrivenVarEntry* entryp = getEntryp(nodep->varp(), usr);
|
||||
bool fdrv = nodep->access().isWriteOrRW()
|
||||
&& nodep->varp()->attrFileDescr(); // FD's are also being read from
|
||||
const bool fdrv = nodep->access().isWriteOrRW()
|
||||
&& nodep->varp()->attrFileDescr(); // FD's are also being read from
|
||||
if (m_inBBox || nodep->access().isWriteOrRW()) {
|
||||
if (usr == 2 && m_alwaysCombp && entryp->isUsedNotDrivenAny()) {
|
||||
UINFO(9, " Full bus. Entryp=" << cvtToHex(entryp) << endl);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ private:
|
|||
m_assignwp->convertToAlways();
|
||||
VL_DO_CLEAR(pushDeletep(m_assignwp), m_assignwp = nullptr);
|
||||
}
|
||||
bool needDly = (m_assigndlyp != nullptr);
|
||||
const bool needDly = (m_assigndlyp != nullptr);
|
||||
if (m_assigndlyp) {
|
||||
// Delayed assignments become normal assignments,
|
||||
// then the temp created becomes the delayed assignment
|
||||
|
|
@ -113,7 +113,7 @@ private:
|
|||
UINFO(4, "Edit BOUNDLVALUE " << newp << endl);
|
||||
replaceHandle.relink(newp);
|
||||
} else {
|
||||
string name = (string("__Vlvbound") + cvtToStr(m_modp->varNumGetInc()));
|
||||
const string name = (string("__Vlvbound") + cvtToStr(m_modp->varNumGetInc()));
|
||||
AstVar* varp = new AstVar(fl, AstVarType::MODULETEMP, name, prep->dtypep());
|
||||
m_modp->addStmtp(varp);
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ private:
|
|||
// Make a Vxrand variable
|
||||
// We use the special XTEMP type so it doesn't break pure functions
|
||||
UASSERT_OBJ(m_modp, nodep, "X number not under module");
|
||||
string newvarname = (string("__Vxrand") + cvtToStr(m_modp->varNumGetInc()));
|
||||
const string newvarname = (string("__Vxrand") + cvtToStr(m_modp->varNumGetInc()));
|
||||
AstVar* newvarp = new AstVar(nodep->fileline(), AstVarType::XTEMP, newvarname,
|
||||
VFlagLogicPacked(), nodep->width());
|
||||
++m_statUnkVars;
|
||||
|
|
@ -365,7 +365,7 @@ private:
|
|||
}
|
||||
// Find range of dtype we are selecting from
|
||||
// Similar code in V3Const::warnSelect
|
||||
int maxmsb = nodep->fromp()->dtypep()->width() - 1;
|
||||
const int maxmsb = nodep->fromp()->dtypep()->width() - 1;
|
||||
if (debug() >= 9) nodep->dumpTree(cout, "sel_old: ");
|
||||
|
||||
// If (maxmsb >= selected), we're in bound
|
||||
|
|
|
|||
|
|
@ -324,8 +324,8 @@ private:
|
|||
VL_DO_DANGLING(tempp->deleteTree(), tempp);
|
||||
}
|
||||
if (m_generate) {
|
||||
string index = AstNode::encodeNumber(m_varValuep->toSInt());
|
||||
string nname = m_beginName + "__BRA__" + index + "__KET__";
|
||||
const string index = AstNode::encodeNumber(m_varValuep->toSInt());
|
||||
const string nname = m_beginName + "__BRA__" + index + "__KET__";
|
||||
oneloopp = new AstBegin(oneloopp->fileline(), nname, oneloopp, true);
|
||||
}
|
||||
VL_DO_CLEAR(pushDeletep(m_varValuep), m_varValuep = nullptr);
|
||||
|
|
|
|||
124
src/V3Width.cpp
124
src/V3Width.cpp
|
|
@ -467,9 +467,10 @@ private:
|
|||
} else if (nodep->expr1p()->isString() || nodep->expr2p()->isString()) {
|
||||
nodep->dtypeSetString();
|
||||
} else {
|
||||
int width = std::max(nodep->expr1p()->width(), nodep->expr2p()->width());
|
||||
int mwidth = std::max(nodep->expr1p()->widthMin(), nodep->expr2p()->widthMin());
|
||||
bool issigned = nodep->expr1p()->isSigned() && nodep->expr2p()->isSigned();
|
||||
const int width = std::max(nodep->expr1p()->width(), nodep->expr2p()->width());
|
||||
const int mwidth
|
||||
= std::max(nodep->expr1p()->widthMin(), nodep->expr2p()->widthMin());
|
||||
const bool issigned = nodep->expr1p()->isSigned() && nodep->expr2p()->isSigned();
|
||||
nodep->dtypeSetLogicUnsized(width, mwidth, VSigning::fromBool(issigned));
|
||||
}
|
||||
}
|
||||
|
|
@ -757,7 +758,7 @@ private:
|
|||
checkConstantOrReplace(nodep->rightp(), "right side of bit range isn't a constant");
|
||||
if (m_vup->prelim()) {
|
||||
// Don't need to iterate because V3Const already constified
|
||||
int width = nodep->elementsConst();
|
||||
const int width = nodep->elementsConst();
|
||||
if (width > (1 << 28)) {
|
||||
nodep->v3error("Width of bit range is huge; vector of over 1billion bits: 0x"
|
||||
<< std::hex << width);
|
||||
|
|
@ -818,7 +819,7 @@ private:
|
|||
// variable[15:15] and 5 bits for [15:-2]
|
||||
int frommsb = nodep->fromp()->width() - 1;
|
||||
int fromlsb = 0;
|
||||
int elw = nodep->declElWidth(); // Must adjust to tell user bit ranges
|
||||
const int elw = nodep->declElWidth(); // Must adjust to tell user bit ranges
|
||||
if (nodep->declRange().ranged()) {
|
||||
frommsb = nodep->declRange().hiMaxSelect() * elw
|
||||
+ (elw - 1); // Corrected for negative lsb
|
||||
|
|
@ -826,7 +827,7 @@ private:
|
|||
} else {
|
||||
// nodep->v3fatalSrc("Should have been declRanged in V3WidthSel");
|
||||
}
|
||||
int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
|
||||
const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
|
||||
AstNodeDType* selwidthDTypep
|
||||
= nodep->findLogicDType(selwidth, selwidth, nodep->lsbp()->dtypep()->numeric());
|
||||
userIterateAndNext(nodep->fromp(), WidthVP(SELF, FINAL).p());
|
||||
|
|
@ -907,7 +908,7 @@ private:
|
|||
nodep->v3fatalSrc("Array reference exceeds dimension of array");
|
||||
frommsb = fromlsb = 0;
|
||||
}
|
||||
int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
|
||||
const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit
|
||||
AstNodeDType* selwidthDTypep
|
||||
= nodep->findLogicDType(selwidth, selwidth, nodep->bitp()->dtypep()->numeric());
|
||||
if (widthBad(nodep->bitp(), selwidthDTypep) && nodep->bitp()->width() != 32) {
|
||||
|
|
@ -1270,7 +1271,7 @@ private:
|
|||
iterateCheckSizedSelf(nodep, "THS", nodep->thsp(), SELF, BOTH);
|
||||
iterateCheckSizedSelf(nodep, "FHS", nodep->fhsp(), SELF, BOTH);
|
||||
// If it's a 32 bit number, we need a 6 bit number as we need to return '32'.
|
||||
int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
|
||||
const int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
|
||||
nodep->dtypeSetLogicSized(selwidth,
|
||||
VSigning::UNSIGNED); // Spec doesn't indicate if an integer
|
||||
}
|
||||
|
|
@ -1279,7 +1280,7 @@ private:
|
|||
if (m_vup->prelim()) {
|
||||
iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH);
|
||||
// If it's a 32 bit number, we need a 6 bit number as we need to return '32'.
|
||||
int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
|
||||
const int selwidth = V3Number::log2b(nodep->lhsp()->width()) + 1;
|
||||
nodep->dtypeSetLogicSized(selwidth,
|
||||
VSigning::UNSIGNED); // Spec doesn't indicate if an integer
|
||||
}
|
||||
|
|
@ -1327,9 +1328,9 @@ private:
|
|||
case AstAttrType::DIM_UNPK_DIMENSIONS: {
|
||||
UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression");
|
||||
std::pair<uint32_t, uint32_t> dim = nodep->fromp()->dtypep()->dimensions(true);
|
||||
int val = (nodep->attrType() == AstAttrType::DIM_UNPK_DIMENSIONS
|
||||
? dim.second
|
||||
: (dim.first + dim.second));
|
||||
const int val = (nodep->attrType() == AstAttrType::DIM_UNPK_DIMENSIONS
|
||||
? dim.second
|
||||
: (dim.first + dim.second));
|
||||
nodep->replaceWith(new AstConst(nodep->fileline(), AstConst::Signed32(), val));
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
break;
|
||||
|
|
@ -1392,13 +1393,13 @@ private:
|
|||
= nodep->fromp()->dtypep()->skipRefp()->dimensions(true);
|
||||
uint32_t msbdim = dimpair.first + dimpair.second;
|
||||
if (!nodep->dimp() || msbdim < 1) {
|
||||
int dim = 1;
|
||||
const int dim = 1;
|
||||
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
|
||||
nodep->attrType(), dim);
|
||||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else if (VN_IS(nodep->dimp(), Const)) {
|
||||
int dim = VN_CAST(nodep->dimp(), Const)->toSInt();
|
||||
const int dim = VN_CAST(nodep->dimp(), Const)->toSInt();
|
||||
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
|
||||
nodep->attrType(), dim);
|
||||
nodep->replaceWith(newp);
|
||||
|
|
@ -1420,7 +1421,7 @@ private:
|
|||
}
|
||||
case AstAttrType::TYPENAME: {
|
||||
UASSERT_OBJ(nodep->fromp(), nodep, "Unprovided expression");
|
||||
string result = nodep->fromp()->dtypep()->prettyDTypeName();
|
||||
const string result = nodep->fromp()->dtypep()->prettyDTypeName();
|
||||
AstNode* newp = new AstConst(nodep->fileline(), AstConst::String(), result);
|
||||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
|
|
@ -1470,7 +1471,7 @@ private:
|
|||
nodep->widthFromSub(nodep->subDTypep());
|
||||
if (nodep->subDTypep()->skipRefp()->isCompound()) adtypep->isCompound(true);
|
||||
} else {
|
||||
int width = nodep->subDTypep()->width() * nodep->rangep()->elementsConst();
|
||||
const int width = nodep->subDTypep()->width() * nodep->rangep()->elementsConst();
|
||||
nodep->widthForce(width, width);
|
||||
}
|
||||
UINFO(4, "dtWidthed " << nodep << endl);
|
||||
|
|
@ -1653,7 +1654,7 @@ private:
|
|||
auto* enumDtp = VN_CAST(toDtp, EnumDType);
|
||||
UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type");
|
||||
uint64_t maxval = enumMaxValue(nodep, enumDtp);
|
||||
int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit
|
||||
const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit
|
||||
AstVar* varp = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1);
|
||||
AstVarRef* varrefp = new AstVarRef(fl, varp, VAccess::READ);
|
||||
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
|
||||
|
|
@ -1755,7 +1756,7 @@ private:
|
|||
if (bad) {
|
||||
} else if (AstBasicDType* basicp = toDtp->basicp()) {
|
||||
if (!basicp->isDouble() && !fromDtp->isDouble()) {
|
||||
int width = toDtp->width();
|
||||
const int width = toDtp->width();
|
||||
castSized(nodep, nodep->fromp(), width);
|
||||
// Note castSized might modify nodep->fromp()
|
||||
} else {
|
||||
|
|
@ -1840,7 +1841,7 @@ private:
|
|||
// However the output width is exactly that requested.
|
||||
// So two steps, first do the calculation's width (max of the two widths)
|
||||
{
|
||||
int calcWidth = std::max(width, underDtp->width());
|
||||
const int calcWidth = std::max(width, underDtp->width());
|
||||
AstNodeDType* calcDtp
|
||||
= (underDtp->isFourstate()
|
||||
? nodep->findLogicDType(calcWidth, calcWidth, underDtp->numeric())
|
||||
|
|
@ -1895,7 +1896,7 @@ private:
|
|||
// Parameters if implicit untyped inherit from what they are assigned to
|
||||
AstBasicDType* bdtypep = VN_CAST(nodep->dtypep(), BasicDType);
|
||||
bool didchk = false;
|
||||
bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit();
|
||||
const bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit();
|
||||
if (implicitParam) {
|
||||
if (nodep->valuep()) {
|
||||
userIterateAndNext(nodep->valuep(), WidthVP(nodep->dtypep(), PRELIM).p());
|
||||
|
|
@ -2403,7 +2404,7 @@ private:
|
|||
}
|
||||
classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr;
|
||||
}
|
||||
string suggest = speller.bestCandidateMsg(nodep->prettyName());
|
||||
const string suggest = speller.bestCandidateMsg(nodep->prettyName());
|
||||
nodep->v3error(
|
||||
"Member " << nodep->prettyNameQ() << " not found in class "
|
||||
<< first_classp->prettyNameQ() << "\n"
|
||||
|
|
@ -2509,7 +2510,7 @@ private:
|
|||
++narg;
|
||||
UASSERT_OBJ(VN_IS(argp, Arg), nodep, "Method arg without Arg type");
|
||||
}
|
||||
bool ok = (narg >= minArg) && (narg <= maxArg);
|
||||
const bool ok = (narg >= minArg) && (narg <= maxArg);
|
||||
if (!ok) {
|
||||
nodep->v3error("The " << narg << " arguments passed to ." << nodep->prettyName()
|
||||
<< " method does not match its requiring " << cvtToStr(minArg)
|
||||
|
|
@ -2601,7 +2602,7 @@ private:
|
|||
}
|
||||
// Need a runtime lookup table. Yuk.
|
||||
uint64_t msbdim = enumMaxValue(nodep, adtypep);
|
||||
int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit
|
||||
const int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit
|
||||
AstVar* varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1);
|
||||
AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ);
|
||||
varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp());
|
||||
|
|
@ -3000,7 +3001,7 @@ private:
|
|||
}
|
||||
classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr;
|
||||
}
|
||||
string suggest = speller.bestCandidateMsg(nodep->prettyName());
|
||||
const string suggest = speller.bestCandidateMsg(nodep->prettyName());
|
||||
nodep->v3error("Class method "
|
||||
<< nodep->prettyNameQ() << " not found in class "
|
||||
<< first_classp->prettyNameQ() << "\n"
|
||||
|
|
@ -3272,7 +3273,7 @@ private:
|
|||
// widths need to be individually determined
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
int times = visitPatMemberRep(patp);
|
||||
const int times = visitPatMemberRep(patp);
|
||||
for (int i = 1; i < times; i++) {
|
||||
AstNode* newp = patp->cloneTree(false);
|
||||
patp->addNextHere(newp);
|
||||
|
|
@ -3428,7 +3429,7 @@ private:
|
|||
VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present
|
||||
}
|
||||
void patternArray(AstPattern* nodep, AstNodeArrayDType* arrayDtp, AstPatMember* defaultp) {
|
||||
VNumRange range = arrayDtp->declRange();
|
||||
const VNumRange range = arrayDtp->declRange();
|
||||
PatVecMap patmap = patVectorMap(nodep, range);
|
||||
UINFO(9, "ent " << range.left() << " to " << range.right() << endl);
|
||||
AstNode* newp = nullptr;
|
||||
|
|
@ -3533,7 +3534,7 @@ private:
|
|||
}
|
||||
void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) {
|
||||
AstBasicDType* bdtypep = VN_CAST(vdtypep, BasicDType);
|
||||
VNumRange range = bdtypep->declRange();
|
||||
const VNumRange range = bdtypep->declRange();
|
||||
PatVecMap patmap = patVectorMap(nodep, range);
|
||||
UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl);
|
||||
AstNode* newp = nullptr;
|
||||
|
|
@ -3670,9 +3671,9 @@ private:
|
|||
if (condp->dtypep()->isDouble()) {
|
||||
subDTypep = nodep->findDoubleDType();
|
||||
} else {
|
||||
int width = std::max(subDTypep->width(), condp->width());
|
||||
int mwidth = std::max(subDTypep->widthMin(), condp->widthMin());
|
||||
bool issigned = subDTypep->isSigned() && condp->isSigned();
|
||||
const int width = std::max(subDTypep->width(), condp->width());
|
||||
const int mwidth = std::max(subDTypep->widthMin(), condp->widthMin());
|
||||
const bool issigned = subDTypep->isSigned() && condp->isSigned();
|
||||
subDTypep
|
||||
= nodep->findLogicDType(width, mwidth, VSigning::fromBool(issigned));
|
||||
}
|
||||
|
|
@ -3789,7 +3790,7 @@ private:
|
|||
string newFormat;
|
||||
bool inPct = false;
|
||||
AstNode* argp = nodep->exprsp();
|
||||
string txt = nodep->text();
|
||||
const string txt = nodep->text();
|
||||
string fmt;
|
||||
for (char ch : txt) {
|
||||
if (!inPct && ch == '%') {
|
||||
|
|
@ -4145,13 +4146,13 @@ private:
|
|||
modDTypep = modDTypep->skipRefp();
|
||||
conDTypep = conDTypep->skipRefp();
|
||||
AstNodeDType* subDTypep = modDTypep;
|
||||
int pinwidth = modDTypep->width();
|
||||
int conwidth = conDTypep->width();
|
||||
const int pinwidth = modDTypep->width();
|
||||
const int conwidth = conDTypep->width();
|
||||
if (conDTypep == modDTypep // If match, we're golden
|
||||
|| similarDTypeRecurse(conDTypep, modDTypep)) {
|
||||
userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p());
|
||||
} else if (m_cellp->rangep()) {
|
||||
int numInsts = m_cellp->rangep()->elementsConst();
|
||||
const int numInsts = m_cellp->rangep()->elementsConst();
|
||||
if (conwidth == pinwidth) {
|
||||
// Arrayed instants: widths match so connect to each instance
|
||||
subDTypep = conDTypep; // = same expr dtype
|
||||
|
|
@ -4216,8 +4217,8 @@ private:
|
|||
AstNodeArrayDType* modArrayp = VN_CAST(modDTypep, UnpackArrayDType);
|
||||
if (exprArrayp && modArrayp && VN_IS(exprArrayp->subDTypep(), IfaceRefDType)
|
||||
&& exprArrayp->declRange().elements() != modArrayp->declRange().elements()) {
|
||||
int exprSize = exprArrayp->declRange().elements();
|
||||
int modSize = modArrayp->declRange().elements();
|
||||
const int exprSize = exprArrayp->declRange().elements();
|
||||
const int modSize = modArrayp->declRange().elements();
|
||||
nodep->v3error("Illegal "
|
||||
<< nodep->prettyOperatorName() << ","
|
||||
<< " mismatch between port which is an interface array of size "
|
||||
|
|
@ -4265,9 +4266,9 @@ private:
|
|||
nodep->dtypeFrom(nodep->rangep());
|
||||
// Very much like like an pin
|
||||
AstNodeDType* conDTypep = nodep->exprp()->dtypep();
|
||||
int numInsts = nodep->rangep()->elementsConst();
|
||||
int pinwidth = numInsts;
|
||||
int conwidth = conDTypep->width();
|
||||
const int numInsts = nodep->rangep()->elementsConst();
|
||||
const int pinwidth = numInsts;
|
||||
const int conwidth = conDTypep->width();
|
||||
if (conwidth == 1 && pinwidth > 1) { // Multiple connections
|
||||
AstNodeDType* subDTypep = nodep->findLogicDType(1, 1, conDTypep->numeric());
|
||||
userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p());
|
||||
|
|
@ -4714,13 +4715,13 @@ private:
|
|||
iterateCheckString(nodep, "RHS", nodep->rhsp(), FINAL);
|
||||
}
|
||||
} else {
|
||||
bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned();
|
||||
const bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned();
|
||||
if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, signedFl)) {
|
||||
VL_DANGLING(nodep);
|
||||
nodep = newp; // Process new node instead
|
||||
}
|
||||
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
int ewidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
const int ewidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
AstNodeDType* subDTypep
|
||||
= nodep->findLogicDType(width, ewidth, VSigning::fromBool(signedFl));
|
||||
bool warnOn = true;
|
||||
|
|
@ -4828,7 +4829,7 @@ private:
|
|||
if (m_vup->prelim()) {
|
||||
userIterateAndNext(nodep->lhsp(), WidthVP(SELF, PRELIM).p());
|
||||
checkCvtUS(nodep->lhsp());
|
||||
int width = nodep->lhsp()->width();
|
||||
const int width = nodep->lhsp()->width();
|
||||
AstNodeDType* expDTypep = nodep->findLogicDType(width, width, rs_out);
|
||||
nodep->dtypep(expDTypep);
|
||||
AstNodeDType* subDTypep = expDTypep;
|
||||
|
|
@ -4909,9 +4910,9 @@ private:
|
|||
userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p());
|
||||
checkCvtUS(nodep->lhsp());
|
||||
checkCvtUS(nodep->rhsp());
|
||||
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
|
||||
const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
const int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
const bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
|
||||
nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned));
|
||||
}
|
||||
if (m_vup->final()) {
|
||||
|
|
@ -4957,9 +4958,9 @@ private:
|
|||
iterateCheckReal(nodep, "RHS", nodep->rhsp(), FINAL);
|
||||
return;
|
||||
} else {
|
||||
int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
|
||||
const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width());
|
||||
const int mwidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin());
|
||||
const bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned());
|
||||
nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned));
|
||||
}
|
||||
}
|
||||
|
|
@ -5016,7 +5017,7 @@ private:
|
|||
// LOWER LEVEL WIDTH METHODS (none iterate)
|
||||
|
||||
bool widthBad(AstNode* nodep, AstNodeDType* expDTypep) {
|
||||
int expWidth = expDTypep->width();
|
||||
const int expWidth = expDTypep->width();
|
||||
int expWidthMin = expDTypep->widthMin();
|
||||
UASSERT_OBJ(nodep->dtypep(), nodep,
|
||||
"Under node " << nodep->prettyTypeName()
|
||||
|
|
@ -5048,7 +5049,7 @@ private:
|
|||
UINFO(4, " widthExtend_(r=" << extendRule << ") old: " << nodep << endl);
|
||||
if (extendRule == EXTEND_OFF) return;
|
||||
AstConst* constp = VN_CAST(nodep, Const);
|
||||
int expWidth = expDTypep->width();
|
||||
const int expWidth = expDTypep->width();
|
||||
if (constp && !constp->num().isNegative()) {
|
||||
// Save later constant propagation work, just right-size it.
|
||||
V3Number num(nodep, expWidth);
|
||||
|
|
@ -5100,8 +5101,8 @@ private:
|
|||
// IF (A(CONSTwide)) becomes IF (A(CONSTreduced))
|
||||
// IF (A(somewide)) becomes IF (A(REDOR(somewide)))
|
||||
// Attempt to fix it quietly
|
||||
int expWidth = 1;
|
||||
int expSigned = false;
|
||||
const int expWidth = 1;
|
||||
const int expSigned = false;
|
||||
UINFO(4, " widthReduce_old: " << nodep << endl);
|
||||
AstConst* constp = VN_CAST(nodep, Const);
|
||||
if (constp) {
|
||||
|
|
@ -5287,7 +5288,7 @@ private:
|
|||
underp->replaceWith(new AstConst(nodep->fileline(), AstConst::BitFalse()));
|
||||
VL_DO_DANGLING(pushDeletep(underp), underp);
|
||||
} else {
|
||||
bool bad = widthBad(underp, nodep->findBitDType());
|
||||
const bool bad = widthBad(underp, nodep->findBitDType());
|
||||
if (bad) {
|
||||
{ // if (warnOn), but not needed here
|
||||
if (debug() > 4) nodep->backp()->dumpTree(cout, " back: ");
|
||||
|
|
@ -5401,10 +5402,10 @@ private:
|
|||
#endif
|
||||
return;
|
||||
} else {
|
||||
int expWidth = expDTypep->width();
|
||||
const int expWidth = expDTypep->width();
|
||||
int expWidthMin = expDTypep->widthMin();
|
||||
if (expWidthMin == 0) expWidthMin = expWidth;
|
||||
bool bad = widthBad(underp, expDTypep);
|
||||
const bool bad = widthBad(underp, expDTypep);
|
||||
if ((bad || underp->width() != expWidth) && fixAutoExtend(underp /*ref*/, expWidth)) {
|
||||
underp = nullptr; // Changes underp
|
||||
return;
|
||||
|
|
@ -6003,7 +6004,7 @@ private:
|
|||
}
|
||||
static Castable computeCastableImp(AstNodeDType* toDtp, AstNodeDType* fromDtp,
|
||||
AstNode* fromConstp) {
|
||||
Castable castable = UNSUPPORTED;
|
||||
const Castable castable = UNSUPPORTED;
|
||||
toDtp = toDtp->skipRefToEnump();
|
||||
fromDtp = fromDtp->skipRefToEnump();
|
||||
if (toDtp == fromDtp) return COMPATIBLE;
|
||||
|
|
@ -6014,8 +6015,9 @@ private:
|
|||
fromBaseDtp = refp->refDTypep();
|
||||
}
|
||||
}
|
||||
bool fromNumericable = VN_IS(fromBaseDtp, BasicDType) || VN_IS(fromBaseDtp, EnumDType)
|
||||
|| VN_IS(fromBaseDtp, NodeUOrStructDType);
|
||||
const bool fromNumericable = VN_IS(fromBaseDtp, BasicDType)
|
||||
|| VN_IS(fromBaseDtp, EnumDType)
|
||||
|| VN_IS(fromBaseDtp, NodeUOrStructDType);
|
||||
// UNSUP unpacked struct/unions (treated like BasicDType)
|
||||
if (VN_IS(toDtp, BasicDType) || VN_IS(toDtp, NodeUOrStructDType)) {
|
||||
if (fromNumericable) return COMPATIBLE;
|
||||
|
|
@ -6027,8 +6029,8 @@ private:
|
|||
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) {
|
||||
const auto toClassp = VN_CAST(toDtp, ClassRefDType)->classp();
|
||||
const auto fromClassp = VN_CAST(fromDtp, ClassRefDType)->classp();
|
||||
bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp);
|
||||
bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp);
|
||||
const bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp);
|
||||
const bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp);
|
||||
if (upcast) {
|
||||
return COMPATIBLE;
|
||||
} else if (downcast) {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ private:
|
|||
nodep->v3fatalSrc("ref to unhandled definition type " << defp->prettyTypeName());
|
||||
}
|
||||
if (local || prot) {
|
||||
auto refClassp = VN_CAST(m_modp, Class);
|
||||
const auto refClassp = VN_CAST(m_modp, Class);
|
||||
const char* how = nullptr;
|
||||
if (local && defClassp && refClassp != defClassp) {
|
||||
how = "'local'";
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ private:
|
|||
AstNode* fromp = nodep->fromp()->unlinkFrBack();
|
||||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting
|
||||
if (debug() >= 9) nodep->dumpTree(cout, "--SELBT2: ");
|
||||
FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
const FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
AstNodeDType* ddtypep = fromdata.m_dtypep;
|
||||
VNumRange fromRange = fromdata.m_fromRange;
|
||||
const VNumRange fromRange = fromdata.m_fromRange;
|
||||
UINFO(6, " ddtypep " << ddtypep << endl);
|
||||
if (AstUnpackArrayDType* adtypep = VN_CAST(ddtypep, UnpackArrayDType)) {
|
||||
// SELBIT(array, index) -> ARRAYSEL(array, index)
|
||||
|
|
@ -234,7 +234,7 @@ private:
|
|||
adtypep,
|
||||
"Array extraction with width miscomputed " << adtypep->width() << "/"
|
||||
<< fromRange.elements());
|
||||
int elwidth = adtypep->width() / fromRange.elements();
|
||||
const int elwidth = adtypep->width() / fromRange.elements();
|
||||
AstSel* newp = new AstSel(
|
||||
nodep->fileline(), fromp,
|
||||
new AstMul(nodep->fileline(),
|
||||
|
|
@ -335,9 +335,9 @@ private:
|
|||
vlsint32_t msb = VN_CAST(msbp, Const)->toSInt();
|
||||
vlsint32_t lsb = VN_CAST(lsbp, Const)->toSInt();
|
||||
vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1);
|
||||
FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
const FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
AstNodeDType* ddtypep = fromdata.m_dtypep;
|
||||
VNumRange fromRange = fromdata.m_fromRange;
|
||||
const VNumRange fromRange = fromdata.m_fromRange;
|
||||
if (VN_IS(ddtypep, UnpackArrayDType)) {
|
||||
// Slice extraction
|
||||
if (fromRange.elements() == elem
|
||||
|
|
@ -378,7 +378,7 @@ private:
|
|||
msb = lsb;
|
||||
lsb = x;
|
||||
}
|
||||
int elwidth = adtypep->width() / fromRange.elements();
|
||||
const int elwidth = adtypep->width() / fromRange.elements();
|
||||
AstSel* newp = new AstSel(
|
||||
nodep->fileline(), fromp,
|
||||
new AstMul(nodep->fileline(), newSubLsbOf(lsbp, fromRange),
|
||||
|
|
@ -479,15 +479,15 @@ private:
|
|||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* widthp = nodep->thsp()->unlinkFrBack();
|
||||
warnTri(rhsp);
|
||||
int width = VN_CAST(widthp, Const)->toSInt();
|
||||
const int width = VN_CAST(widthp, Const)->toSInt();
|
||||
if (width > (1 << 28)) {
|
||||
nodep->v3error("Width of :+ or :- is huge; vector of over 1billion bits: "
|
||||
<< widthp->prettyName());
|
||||
}
|
||||
if (width < 0) nodep->v3error("Width of :+ or :- is < 0: " << widthp->prettyName());
|
||||
FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
const FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
AstNodeDType* ddtypep = fromdata.m_dtypep;
|
||||
VNumRange fromRange = fromdata.m_fromRange;
|
||||
const VNumRange fromRange = fromdata.m_fromRange;
|
||||
if (VN_IS(ddtypep, UnpackArrayDType)) {
|
||||
// Slice +: and -: extraction
|
||||
if (fromRange.elements() == width && VN_IS(rhsp, Const)
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ int main(int argc, char** argv, char** env) {
|
|||
|
||||
// Command option parsing
|
||||
v3Global.opt.bin(argv[0]);
|
||||
string argString = V3Options::argString(argc - 1, argv + 1);
|
||||
const string argString = V3Options::argString(argc - 1, argv + 1);
|
||||
v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1);
|
||||
|
||||
// Validate settings (aka Boost.Program_options)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ void VlcOptions::parseOptsList(int argc, char** argv) {
|
|||
for (int i = 0; i < argc;) {
|
||||
UINFO(9, " Option: " << argv[i] << endl);
|
||||
if (argv[i][0] == '-') {
|
||||
if (int consumed = parser.parse(i, argc, argv)) {
|
||||
if (const int consumed = parser.parse(i, argc, argv)) {
|
||||
i += consumed;
|
||||
} else {
|
||||
v3fatal("Invalid option: " << argv[i] << parser.getSuggestion(argv[i]));
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public:
|
|||
// METHODS
|
||||
string keyExtract(const char* shortKey) const {
|
||||
// Hot function
|
||||
size_t shortLen = std::strlen(shortKey);
|
||||
const size_t shortLen = std::strlen(shortKey);
|
||||
const string namestr = name();
|
||||
for (const char* cp = namestr.c_str(); *cp; ++cp) {
|
||||
if (*cp == '\001') {
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ void VlcTop::readCoverage(const string& filename, bool nonfatal) {
|
|||
VlcTest* testp = tests().newTest(filename, 0, 0);
|
||||
|
||||
while (!is.eof()) {
|
||||
string line = V3Os::getline(is);
|
||||
const string line = V3Os::getline(is);
|
||||
// UINFO(9," got "<<line<<endl);
|
||||
if (line[0] == 'C') {
|
||||
string::size_type secspace = 3;
|
||||
for (; secspace < line.length(); secspace++) {
|
||||
if (line[secspace] == '\'' && line[secspace + 1] == ' ') break;
|
||||
}
|
||||
string point = line.substr(3, secspace - 3);
|
||||
const string point = line.substr(3, secspace - 3);
|
||||
vluint64_t hits = std::atoll(line.c_str() + secspace + 1);
|
||||
// UINFO(9," point '"<<point<<"'"<<" "<<hits<<endl);
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ void VlcTop::writeInfo(const string& filename) {
|
|||
os << "SF:" << source.name() << '\n';
|
||||
VlcSource::LinenoMap& lines = source.lines();
|
||||
for (auto& li : lines) {
|
||||
int lineno = li.first;
|
||||
const int lineno = li.first;
|
||||
VlcSource::ColumnMap& cmap = li.second;
|
||||
bool first = true;
|
||||
vluint64_t min_count = 0; // Minimum across all columns on line
|
||||
|
|
@ -198,14 +198,14 @@ void VlcTop::annotateCalc() {
|
|||
// Calculate per-line information into filedata structure
|
||||
for (const auto& i : m_points) {
|
||||
const VlcPoint& point = m_points.pointNumber(i.second);
|
||||
string filename = point.filename();
|
||||
int lineno = point.lineno();
|
||||
const string filename = point.filename();
|
||||
const int lineno = point.lineno();
|
||||
if (!filename.empty() && lineno != 0) {
|
||||
VlcSource& source = sources().findNewSource(filename);
|
||||
string threshStr = point.thresh();
|
||||
const string threshStr = point.thresh();
|
||||
unsigned thresh
|
||||
= (!threshStr.empty()) ? std::atoi(threshStr.c_str()) : opt.annotateMin();
|
||||
bool ok = (point.count() >= thresh);
|
||||
const bool ok = (point.count() >= thresh);
|
||||
UINFO(9, "AnnoCalc count " << filename << ":" << lineno << ":" << point.column() << " "
|
||||
<< point.count() << " " << point.linescov() << '\n');
|
||||
// Base coverage
|
||||
|
|
@ -214,7 +214,7 @@ void VlcTop::annotateCalc() {
|
|||
bool range = false;
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
string linescov = point.linescov();
|
||||
const string linescov = point.linescov();
|
||||
for (const char* covp = linescov.c_str(); true; ++covp) {
|
||||
if (!*covp || *covp == ',') { // Ending
|
||||
for (int lni = start; start && lni <= end; ++lni) {
|
||||
|
|
@ -262,7 +262,7 @@ void VlcTop::annotateCalcNeeded() {
|
|||
}
|
||||
}
|
||||
}
|
||||
float pct = totCases ? (100 * totOk / totCases) : 0;
|
||||
const float pct = totCases ? (100 * totOk / totCases) : 0;
|
||||
cout << "Total coverage (" << totOk << "/" << totCases << ") ";
|
||||
cout << std::fixed << std::setw(3) << std::setprecision(2) << pct << "%\n";
|
||||
if (totOk != totCases) cout << "See lines with '%00' in " << opt.annotateOut() << '\n';
|
||||
|
|
@ -274,8 +274,8 @@ void VlcTop::annotateOutputFiles(const string& dirname) {
|
|||
for (auto& si : m_sources) {
|
||||
VlcSource& source = si.second;
|
||||
if (!source.needed()) continue;
|
||||
string filename = source.name();
|
||||
string outfilename = dirname + "/" + V3Os::filenameNonDir(filename);
|
||||
const string filename = source.name();
|
||||
const string outfilename = dirname + "/" + V3Os::filenameNonDir(filename);
|
||||
|
||||
UINFO(1, "annotateOutputFile " << filename << " -> " << outfilename << endl);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue