mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
C++11 cleanup
This commit is contained in:
parent
d8420413b7
commit
30318a6654
@ -453,7 +453,7 @@ void VerilatedTrace<VL_SUB_T, VL_BUF_T>::dumpvars(int level, const std::string&
|
||||
for (auto& i : hierSpaced) {
|
||||
if (i == '.') i = ' ';
|
||||
}
|
||||
m_dumpvars.push_back(std::make_pair(level, hierSpaced));
|
||||
m_dumpvars.emplace_back(level, hierSpaced);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,8 +542,7 @@ public:
|
||||
VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_register_cb reason=%d id=%" PRId64 " time=%" PRIu64
|
||||
" obj=%p\n",
|
||||
cb_data_p->reason, id, time, cb_data_p->obj););
|
||||
s().m_futureCbs.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(std::make_pair(time, id)),
|
||||
s().m_futureCbs.emplace(std::piecewise_construct, std::forward_as_tuple(time, id),
|
||||
std::forward_as_tuple(id, cb_data_p, nullptr));
|
||||
}
|
||||
static void cbNextAdd(uint64_t id, const s_cb_data* cb_data_p, QData time) {
|
||||
@ -551,8 +550,7 @@ public:
|
||||
VL_DEBUG_IF_PLI(VL_DBG_MSGF("- vpi: vpi_register_cb reason=%d(NEXT) id=%" PRId64
|
||||
" time=%" PRIu64 " obj=%p\n",
|
||||
cb_data_p->reason, id, time, cb_data_p->obj););
|
||||
s().m_nextCbs.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(std::make_pair(time, id)),
|
||||
s().m_nextCbs.emplace(std::piecewise_construct, std::forward_as_tuple(time, id),
|
||||
std::forward_as_tuple(id, cb_data_p, nullptr));
|
||||
}
|
||||
static void cbReasonRemove(uint64_t id, uint32_t reason, QData time) {
|
||||
|
@ -122,13 +122,13 @@ private:
|
||||
// Move later, or we wouldn't keep iterating the class
|
||||
// We're really moving the VarScope but we might not
|
||||
// have a pointer to it yet
|
||||
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
|
||||
m_toScopeMoves.emplace_back(nodep, m_packageScopep);
|
||||
}
|
||||
if (!m_ftaskp && nodep->lifetime().isStatic()) {
|
||||
m_toPackageMoves.emplace_back(std::make_pair(nodep, m_classPackagep));
|
||||
m_toPackageMoves.emplace_back(nodep, m_classPackagep);
|
||||
// We're really moving the VarScope but we might not
|
||||
// have a pointer to it yet
|
||||
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
|
||||
m_toScopeMoves.emplace_back(nodep, m_packageScopep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ private:
|
||||
m_ftaskp = nodep;
|
||||
iterateChildren(nodep);
|
||||
if (m_packageScopep && nodep->lifetime().isStatic()) {
|
||||
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
|
||||
m_toScopeMoves.emplace_back(nodep, m_packageScopep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ private:
|
||||
// Don't move now, or wouldn't keep iterating the class
|
||||
// TODO move function statics only
|
||||
// if (m_classScopep) {
|
||||
// m_toScopeMoves.push_back(std::make_pair(nodep, m_classScopep));
|
||||
// m_toScopeMoves.emplace_back(nodep, m_classScopep);
|
||||
//}
|
||||
}
|
||||
void visit(AstCoverDecl* nodep) override {
|
||||
@ -164,16 +164,12 @@ private:
|
||||
void visit(AstInitial* nodep) override {
|
||||
// But not AstInitialAutomatic, which remains under the class
|
||||
iterateChildren(nodep);
|
||||
if (m_packageScopep) {
|
||||
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
|
||||
}
|
||||
if (m_packageScopep) { m_toScopeMoves.emplace_back(nodep, m_packageScopep); }
|
||||
}
|
||||
void visit(AstInitialStatic* nodep) override {
|
||||
// But not AstInitialAutomatic, which remains under the class
|
||||
iterateChildren(nodep);
|
||||
if (m_packageScopep) {
|
||||
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
|
||||
}
|
||||
if (m_packageScopep) { m_toScopeMoves.emplace_back(nodep, m_packageScopep); }
|
||||
}
|
||||
|
||||
void setStructModulep(AstNodeUOrStructDType* const dtypep) {
|
||||
|
@ -300,7 +300,7 @@ public:
|
||||
m_lastIgnore.it = m_ignLines.begin();
|
||||
}
|
||||
void addIgnoreMatch(V3ErrorCode code, const string& match) {
|
||||
m_waivers.push_back(std::make_pair(code, match));
|
||||
m_waivers.emplace_back(code, match);
|
||||
}
|
||||
|
||||
void applyBlock(AstNodeBlock* nodep) {
|
||||
|
@ -240,12 +240,11 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
||||
// << scpSym << endl);
|
||||
if (v3Global.opt.vpi()) varHierarchyScopes(scpName);
|
||||
if (m_scopeNames.find(scpSym) == m_scopeNames.end()) {
|
||||
m_scopeNames.insert(std::make_pair(
|
||||
scpSym, ScopeData{scpSym, scpPretty, 0, "SCOPE_OTHER"}));
|
||||
m_scopeNames.emplace(scpSym,
|
||||
ScopeData{scpSym, scpPretty, 0, "SCOPE_OTHER"});
|
||||
}
|
||||
m_scopeVars.insert(
|
||||
std::make_pair(scpSym + " " + varp->name(),
|
||||
ScopeVarData{scpSym, varBasePretty, varp, modp, scopep}));
|
||||
m_scopeVars.emplace(scpSym + " " + varp->name(),
|
||||
ScopeVarData{scpSym, varBasePretty, varp, modp, scopep});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,24 +311,24 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
||||
const string name = nodep->scopep()->shortName() + "__DOT__" + nodep->name();
|
||||
const string name_pretty = AstNode::vpiName(name);
|
||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||
m_vpiScopeCandidates.insert(
|
||||
std::make_pair(scopeSymString(name),
|
||||
ScopeData{scopeSymString(name), name_pretty, timeunit, type}));
|
||||
m_vpiScopeCandidates.emplace(
|
||||
scopeSymString(name),
|
||||
ScopeData{scopeSymString(name), name_pretty, timeunit, type});
|
||||
}
|
||||
}
|
||||
void visit(AstScope* nodep) override {
|
||||
if (VN_IS(m_modp, Class)) return; // The ClassPackage is what is visible
|
||||
nameCheck(nodep);
|
||||
|
||||
m_scopes.emplace_back(std::make_pair(nodep, m_modp));
|
||||
m_scopes.emplace_back(nodep, m_modp);
|
||||
|
||||
if (v3Global.opt.vpi() && !nodep->isTop()) {
|
||||
const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE";
|
||||
const string name_pretty = AstNode::vpiName(nodep->shortName());
|
||||
const int timeunit = m_modp->timeunit().powerOfTen();
|
||||
m_vpiScopeCandidates.insert(std::make_pair(
|
||||
m_vpiScopeCandidates.emplace(
|
||||
scopeSymString(nodep->name()),
|
||||
ScopeData{scopeSymString(nodep->name()), name_pretty, timeunit, type}));
|
||||
ScopeData{scopeSymString(nodep->name()), name_pretty, timeunit, type});
|
||||
}
|
||||
}
|
||||
void visit(AstScopeName* nodep) override {
|
||||
@ -341,22 +340,20 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
||||
name, ScopeData{name, nodep->scopePrettySymName(), timeunit, "SCOPE_OTHER"});
|
||||
if (nodep->dpiExport()) {
|
||||
UASSERT_OBJ(m_cfuncp, nodep, "ScopeName not under DPI function");
|
||||
m_scopeFuncs.insert(std::make_pair(name + " " + m_cfuncp->name(),
|
||||
ScopeFuncData(nodep, m_cfuncp, m_modp)));
|
||||
m_scopeFuncs.emplace(name + " " + m_cfuncp->name(),
|
||||
ScopeFuncData(nodep, m_cfuncp, m_modp));
|
||||
} else {
|
||||
if (m_scopeNames.find(nodep->scopeDpiName()) == m_scopeNames.end()) {
|
||||
m_scopeNames.insert(
|
||||
std::make_pair(nodep->scopeDpiName(),
|
||||
ScopeData{nodep->scopeDpiName(), nodep->scopePrettyDpiName(),
|
||||
timeunit, "SCOPE_OTHER"}));
|
||||
m_scopeNames.emplace(nodep->scopeDpiName(),
|
||||
ScopeData{nodep->scopeDpiName(), nodep->scopePrettyDpiName(),
|
||||
timeunit, "SCOPE_OTHER"});
|
||||
}
|
||||
}
|
||||
}
|
||||
void visit(AstVar* nodep) override {
|
||||
nameCheck(nodep);
|
||||
iterateChildrenConst(nodep);
|
||||
if (nodep->isSigUserRdPublic() && !m_cfuncp)
|
||||
m_modVars.emplace_back(std::make_pair(m_modp, nodep));
|
||||
if (nodep->isSigUserRdPublic() && !m_cfuncp) m_modVars.emplace_back(m_modp, nodep);
|
||||
}
|
||||
void visit(AstCoverDecl* nodep) override {
|
||||
// Assign numbers to all bins, so we know how big of an array to use
|
||||
|
@ -290,7 +290,7 @@ private:
|
||||
ForkDynScopeFrame* pushDynScopeFrame(AstNode* procp) {
|
||||
ForkDynScopeFrame* const framep
|
||||
= new ForkDynScopeFrame{m_modp, procp, m_class_id++, m_id++};
|
||||
auto r = m_frames.emplace(std::make_pair(procp, framep));
|
||||
auto r = m_frames.emplace(procp, framep);
|
||||
UASSERT_OBJ(r.second, m_modp, "Procedure already contains a frame");
|
||||
return framep;
|
||||
}
|
||||
@ -321,7 +321,7 @@ private:
|
||||
}
|
||||
|
||||
void bindNodeToDynScope(AstNode* nodep, ForkDynScopeFrame* frame) {
|
||||
m_frames.emplace(std::make_pair(nodep, frame));
|
||||
m_frames.emplace(nodep, frame);
|
||||
}
|
||||
|
||||
bool needsDynScope(const AstVarRef* refp) const {
|
||||
|
@ -125,7 +125,7 @@ const std::string& V3Global::ptrToId(const void* p) {
|
||||
} else {
|
||||
os << "0";
|
||||
}
|
||||
it = m_ptrToId.insert(std::make_pair(p, os.str())).first;
|
||||
it = m_ptrToId.emplace(p, os.str()).first;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ V3HierBlock::StrGParams V3HierBlock::stringifyParams(const GParams& gparams, boo
|
||||
s = constp->num().ascii(true, true);
|
||||
s = VString::quoteAny(s, '\'', '\\');
|
||||
}
|
||||
strParams.push_back(std::make_pair(gparam->name(), s));
|
||||
strParams.emplace_back(gparam->name(), s);
|
||||
}
|
||||
}
|
||||
return strParams;
|
||||
|
@ -442,7 +442,7 @@ public:
|
||||
|
||||
// Track and later recurse interface modules
|
||||
void insertIfaceModSym(AstIface* nodep, VSymEnt* symp) {
|
||||
m_ifaceModSyms.push_back(std::make_pair(nodep, symp));
|
||||
m_ifaceModSyms.emplace_back(nodep, symp);
|
||||
}
|
||||
void computeIfaceModSyms();
|
||||
|
||||
|
@ -534,8 +534,7 @@ private:
|
||||
} else {
|
||||
defp = new AstTypedef{nodep->fileline(), nodep->name(), nullptr, VFlagChildDType{},
|
||||
dtypep};
|
||||
m_implTypedef.insert(
|
||||
std::make_pair(std::make_pair(nodep->containerp(), defp->name()), defp));
|
||||
m_implTypedef.emplace(std::make_pair(nodep->containerp(), defp->name()), defp);
|
||||
backp->addNextHere(defp);
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ V3HierarchicalBlockOption::V3HierarchicalBlockOption(const string& opts) {
|
||||
cmdfl.v3error(hierBlock + " requires at least two comma-separated values");
|
||||
}
|
||||
for (size_t i = 2; i + 1 < vals.size(); i += 2) {
|
||||
const bool inserted = m_parameters.insert(std::make_pair(vals[i], vals[i + 1])).second;
|
||||
const bool inserted = m_parameters.emplace(vals[i], vals[i + 1]).second;
|
||||
if (!inserted) {
|
||||
cmdfl.v3error("Module name '" + vals[i] + "' is duplicated in " + hierBlock);
|
||||
}
|
||||
|
@ -856,7 +856,7 @@ class OrderProcess final {
|
||||
string name = "_" + m_tag;
|
||||
name += domainp->isMulti() ? "_comb" : "_sequent";
|
||||
name = name + "__" + scopep->nameDotless();
|
||||
const unsigned funcnum = m_funcNums.emplace(std::make_pair(modp, name), 0).first->second++;
|
||||
const unsigned funcnum = m_funcNums[{modp, name}]++;
|
||||
name = name + "__" + cvtToStr(funcnum);
|
||||
if (v3Global.opt.profCFuncs()) {
|
||||
name += "__PROF__" + forWhatp->fileline()->profileFuncname();
|
||||
|
@ -90,8 +90,7 @@ class ParameterizedHierBlocks final {
|
||||
public:
|
||||
ParameterizedHierBlocks(const V3HierBlockOptSet& hierOpts, AstNetlist* nodep) {
|
||||
for (const auto& hierOpt : hierOpts) {
|
||||
m_hierBlockOptsByOrigName.insert(
|
||||
std::make_pair(hierOpt.second.origName(), &hierOpt.second));
|
||||
m_hierBlockOptsByOrigName.emplace(hierOpt.second.origName(), &hierOpt.second);
|
||||
const V3HierarchicalBlockOption::ParamStrMap& params = hierOpt.second.params();
|
||||
ParamConstMap& consts = m_hierParams[&hierOpt.second];
|
||||
for (V3HierarchicalBlockOption::ParamStrMap::const_iterator pIt = params.begin();
|
||||
@ -807,7 +806,7 @@ class ParamProcessor final {
|
||||
longnamer += ("_" + paramSmallName(srcModp, pinp->modVarp())
|
||||
+ paramValueNumber(pinIrefp));
|
||||
any_overridesr = true;
|
||||
ifaceRefRefs.push_back(std::make_pair(portIrefp, pinIrefp));
|
||||
ifaceRefRefs.emplace_back(portIrefp, pinIrefp);
|
||||
if (portIrefp->ifacep() != pinIrefp->ifacep()
|
||||
// Might be different only due to param cloning, so check names too
|
||||
&& portIrefp->ifaceName() != pinIrefp->ifaceName()) {
|
||||
|
@ -182,7 +182,7 @@ private:
|
||||
if (it != m_randcDtypes.end()) return it->second;
|
||||
AstCDType* newp = new AstCDType{fl, name};
|
||||
v3Global.rootp()->typeTablep()->addTypesp(newp);
|
||||
m_randcDtypes.emplace(std::make_pair(name, newp));
|
||||
m_randcDtypes.emplace(name, newp);
|
||||
return newp;
|
||||
}
|
||||
|
||||
|
@ -278,13 +278,11 @@ EvalLoop createEvalLoop(AstNetlist* netlistp, //
|
||||
//============================================================================
|
||||
// Split large function according to --output-split-cfuncs
|
||||
|
||||
std::map<AstCFunc*, int> s_funcNums; // What split number to attach to a function
|
||||
|
||||
AstCFunc* splitCheckCreateNewSubFunc(AstCFunc* ofuncp) {
|
||||
auto funcNumItMatch = s_funcNums.emplace(std::make_pair(ofuncp, 0));
|
||||
AstCFunc* const subFuncp = new AstCFunc{
|
||||
ofuncp->fileline(), ofuncp->name() + "__" + cvtToStr(funcNumItMatch.first->second++),
|
||||
ofuncp->scopep()};
|
||||
static std::map<AstCFunc*, uint32_t> funcNums; // What split number to attach to a function
|
||||
const uint32_t funcNum = funcNums[ofuncp]++;
|
||||
const std::string name = ofuncp->name() + "__" + cvtToStr(funcNum);
|
||||
AstCFunc* const subFuncp = new AstCFunc{ofuncp->fileline(), name, ofuncp->scopep()};
|
||||
subFuncp->dontCombine(true);
|
||||
subFuncp->isStatic(false);
|
||||
subFuncp->isLoose(true);
|
||||
|
@ -317,8 +317,7 @@ private:
|
||||
public:
|
||||
// Register a variable to split
|
||||
void registerVar(AstVar* varp) {
|
||||
const bool inserted
|
||||
= m_map.insert(std::make_pair(varp, MapType::value_type::second_type())).second;
|
||||
const bool inserted = m_map.emplace(varp, MapType::value_type::second_type()).second;
|
||||
UASSERT_OBJ(inserted, varp, "already registered");
|
||||
}
|
||||
// Register the location where a variable is used.
|
||||
@ -907,8 +906,8 @@ public:
|
||||
std::vector<std::pair<int, bool>> points; // <bit location, is end>
|
||||
points.reserve(m_lhs.size() * 2 + 2); // 2 points will be added per one PackedVarRefEntry
|
||||
for (const PackedVarRefEntry& ref : m_lhs) {
|
||||
points.emplace_back(std::make_pair(ref.lsb(), false)); // Start of a region
|
||||
points.emplace_back(std::make_pair(ref.msb() + 1, true)); // End of a region
|
||||
points.emplace_back(ref.lsb(), false); // Start of a region
|
||||
points.emplace_back(ref.msb() + 1, true); // End of a region
|
||||
}
|
||||
if (skipUnused && !m_rhs.empty()) { // Range to be read must be kept, so add points here
|
||||
int lsb = m_basicp->hi() + 1;
|
||||
@ -918,12 +917,12 @@ public:
|
||||
msb = std::max(msb, ref.msb());
|
||||
}
|
||||
UASSERT_OBJ(lsb <= msb, m_basicp, "lsb:" << lsb << " msb:" << msb << " are wrong");
|
||||
points.emplace_back(std::make_pair(lsb, false));
|
||||
points.emplace_back(std::make_pair(msb + 1, true));
|
||||
points.emplace_back(lsb, false);
|
||||
points.emplace_back(msb + 1, true);
|
||||
}
|
||||
if (!skipUnused) { // All bits are necessary
|
||||
points.emplace_back(std::make_pair(m_basicp->lo(), false));
|
||||
points.emplace_back(std::make_pair(m_basicp->hi() + 1, true));
|
||||
points.emplace_back(m_basicp->lo(), false);
|
||||
points.emplace_back(m_basicp->hi() + 1, true);
|
||||
}
|
||||
std::sort(points.begin(), points.end(), SortByFirst());
|
||||
|
||||
@ -960,7 +959,7 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl {
|
||||
warnNoSplit(nodep, nodep, reason);
|
||||
nodep->attrSplitVar(false);
|
||||
} else { // Finally find a good candidate
|
||||
const bool inserted = m_refs.insert(std::make_pair(nodep, PackedVarRef{nodep})).second;
|
||||
const bool inserted = m_refs.emplace(nodep, PackedVarRef{nodep}).second;
|
||||
if (inserted) UINFO(3, nodep->prettyNameQ() << " is added to candidate list.\n");
|
||||
}
|
||||
}
|
||||
|
@ -174,8 +174,7 @@ private:
|
||||
if (AstVarScope* const vscp = VN_CAST(stmtp, VarScope)) {
|
||||
if (vscp->varp()->isFuncLocal() || vscp->varp()->isUsedLoopIdx()) {
|
||||
UINFO(9, " funcvsc " << vscp << endl);
|
||||
m_varToScopeMap.insert(
|
||||
std::make_pair(std::make_pair(nodep, vscp->varp()), vscp));
|
||||
m_varToScopeMap.emplace(std::make_pair(nodep, vscp->varp()), vscp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1623,9 +1622,8 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp,
|
||||
for (AstNode* stmtp = taskStmtsp; stmtp; stmtp = stmtp->nextp()) {
|
||||
if (AstVar* const portp = VN_CAST(stmtp, Var)) {
|
||||
if (portp->isIO()) {
|
||||
tconnects.push_back(std::make_pair(portp, static_cast<AstArg*>(nullptr)));
|
||||
nameToIndex.insert(
|
||||
std::make_pair(portp->name(), tpinnum)); // For name based connections
|
||||
tconnects.emplace_back(portp, static_cast<AstArg*>(nullptr));
|
||||
nameToIndex.emplace(portp->name(), tpinnum); // For name based connections
|
||||
tpinnum++;
|
||||
if (portp->attrSFormat()) {
|
||||
sformatp = portp;
|
||||
@ -1665,7 +1663,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp,
|
||||
} else { // By pin number
|
||||
if (ppinnum >= tpinnum) {
|
||||
if (sformatp) {
|
||||
tconnects.push_back(std::make_pair(sformatp, static_cast<AstArg*>(nullptr)));
|
||||
tconnects.emplace_back(sformatp, static_cast<AstArg*>(nullptr));
|
||||
tconnects[ppinnum].second = argp;
|
||||
tpinnum++;
|
||||
} else {
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
// Return argument, prepended with the prefix if any, then appended with a unique suffix each
|
||||
// time we are called with the same argument.
|
||||
std::string get(const std::string& name) {
|
||||
const unsigned num = m_multiplicity.emplace(name, 0).first->second++;
|
||||
const unsigned num = m_multiplicity[name]++;
|
||||
std::string result;
|
||||
if (!m_prefix.empty()) {
|
||||
result += m_prefix;
|
||||
|
@ -95,8 +95,7 @@ public:
|
||||
// METHODS
|
||||
void lineIncCount(int lineno, uint64_t count, bool ok, const VlcPoint* pointp) {
|
||||
auto lit = m_lines.find(lineno);
|
||||
if (lit == m_lines.end())
|
||||
lit = m_lines.emplace(std::make_pair(lineno, VlcSourceCount{lineno})).first;
|
||||
if (lit == m_lines.end()) lit = m_lines.emplace(lineno, VlcSourceCount{lineno}).first;
|
||||
VlcSourceCount& sc = lit->second;
|
||||
sc.incCount(count, ok);
|
||||
sc.insertPoint(pointp);
|
||||
@ -131,7 +130,7 @@ public:
|
||||
if (iter != m_sources.end()) {
|
||||
return iter->second;
|
||||
} else {
|
||||
iter = m_sources.insert(std::make_pair(name, VlcSource{name})).first;
|
||||
iter = m_sources.emplace(name, VlcSource{name}).first;
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user