From cc0b7804121155141e29a9f63f4a74a4bcd11e12 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 18 Oct 2017 18:22:58 -0400 Subject: [PATCH] Internals: More use of unordered_map/set. No functional change intended. --- include/verilatedos.h | 12 ++++++------ src/V3Ast.cpp | 2 +- src/V3AstNodes.cpp | 3 ++- src/V3Broken.cpp | 2 +- src/V3Cdc.cpp | 2 +- src/V3EmitC.cpp | 2 +- src/V3File.cpp | 6 +++--- src/V3FileLine.cpp | 7 +++++-- src/V3Gate.cpp | 3 ++- src/V3Graph.cpp | 2 +- src/V3Hashed.cpp | 2 +- src/V3LinkCells.cpp | 5 +++-- src/V3LinkDot.cpp | 2 +- src/V3Options.cpp | 2 +- src/V3Order.cpp | 4 ++-- src/V3StatsReport.cpp | 3 ++- src/V3SymTable.h | 2 +- src/VlcPoint.h | 4 ++-- 18 files changed, 36 insertions(+), 29 deletions(-) diff --git a/include/verilatedos.h b/include/verilatedos.h index 9579efe4a..a1e479ae5 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -112,15 +112,15 @@ # define VL_HAS_UNIQUE_PTR # define VL_HAS_UNORDERED_MAP # define VL_HAS_UNORDERED_SET -# define VL_UNIQUE_PTR std::unique_ptr -# define VL_UNORDERED_MAP std::unordered_map -# define VL_UNORDERED_SET std::unordered_set +# define vl_unique_ptr std::unique_ptr +# define vl_unordered_map std::unordered_map +# define vl_unordered_set std::unordered_set # define VL_INCLUDE_UNORDERED_MAP # define VL_INCLUDE_UNORDERED_SET #else -# define VL_UNIQUE_PTR std::auto_ptr -# define VL_UNORDERED_MAP std::map -# define VL_UNORDERED_SET std::set +# define vl_unique_ptr std::auto_ptr +# define vl_unordered_map std::map +# define vl_unordered_set std::set # define VL_INCLUDE_UNORDERED_MAP # define VL_INCLUDE_UNORDERED_SET #endif diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 34d5aa03b..7780959a4 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1037,7 +1037,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump) { if (doDump) { { // Write log & close UINFO(2,"Dumping "< logsp (V3File::new_ofstream(filename, append)); + const vl_unique_ptr logsp (V3File::new_ofstream(filename, append)); if (logsp->fail()) v3fatalSrc("Can't write "<"; *logsp<<" to "< #include #include +#include VL_INCLUDE_UNORDERED_SET #include "V3Ast.h" #include "V3File.h" @@ -69,7 +70,7 @@ void AstNodeClassDType::repairMemberCache() { } const char* AstNodeClassDType::broken() const { - set exists; + vl_unordered_set exists; for (AstMemberDType* itemp = membersp(); itemp; itemp=itemp->nextp()->castMemberDType()) { exists.insert(itemp); } diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 724d841a6..290f9b77b 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -47,7 +47,7 @@ class BrokenTable : public AstNVisitor { private: // MEMBERS // For each node, we keep if it exists or not. - typedef VL_UNORDERED_MAP NodeMap; // Performance matters (when --debug) + typedef vl_unordered_map NodeMap; // Performance matters (when --debug) static NodeMap s_nodes; // Set of all nodes that exist // BITMASK enum { FLAG_ALLOCATED = 0x01 }; // new() and not delete()ed diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 76f776a9b..05c4f6f53 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -496,7 +496,7 @@ private: } string filename = v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__cdc_edges.txt"; - const VL_UNIQUE_PTR ofp (V3File::new_ofstream(filename)); + const vl_unique_ptr ofp (V3File::new_ofstream(filename)); if (ofp->fail()) v3fatalSrc("Can't write "< didClassName; + vl_unordered_set didClassName; for (AstNode* nodep=modp->stmtsp(); nodep; nodep = nodep->nextp()) { if (AstCell* cellp=nodep->castCell()) { string className = modClassName(cellp->modp()); diff --git a/src/V3File.cpp b/src/V3File.cpp index 0c9240e03..21e8b1fac 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -134,7 +134,7 @@ V3FileDependImp dependImp; // Depend implementation class // V3FileDependImp inline void V3FileDependImp::writeDepend(const string& filename) { - const VL_UNIQUE_PTR ofp (V3File::new_ofstream(filename)); + const vl_unique_ptr ofp (V3File::new_ofstream(filename)); if (ofp->fail()) v3fatalSrc("Can't write "<::iterator iter=m_filenameList.begin(); @@ -170,7 +170,7 @@ inline void V3FileDependImp::writeDepend(const string& filename) { } inline void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { - const VL_UNIQUE_PTR ofp (V3File::new_ofstream(filename)); + const vl_unique_ptr ofp (V3File::new_ofstream(filename)); if (ofp->fail()) v3fatalSrc("Can't write "< ifp (V3File::new_ifstream_nodepend(filename)); + const vl_unique_ptr ifp (V3File::new_ifstream_nodepend(filename)); if (ifp->fail()) { UINFO(2," --check-times failed: no input "< #include #include -#include +#include VL_INCLUDE_UNORDERED_SET + #include "V3Error.h" #include "V3FileLine.h" #ifndef _V3ERROR_NO_GLOBAL_ @@ -254,7 +257,7 @@ string FileLine::warnMore() const { } #ifdef VL_LEAK_CHECKS -typedef set FileLineCheckSet; +typedef vl_unordered_set FileLineCheckSet; FileLineCheckSet fileLineLeakChecks; void* FileLine::operator new(size_t size) { diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index b6b95dc74..22714235b 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -35,6 +35,7 @@ #include #include #include +#include VL_INCLUDE_UNORDERED_SET #include "V3Global.h" #include "V3Gate.h" @@ -668,7 +669,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { bool GateVisitor::elimLogicOkOutputs(GateLogicVertex* consumeVertexp, const GateOkVisitor& okVisitor) { // Return true if can optimize // Return false if the consuming logic has an output signal that the replacement logic has as an input - typedef set VarScopeSet; + typedef vl_unordered_set VarScopeSet; // Use map to find duplicates between two lists VarScopeSet varscopes; // Replacement logic usually has shorter input list, so faster to build list based on it diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 92bf1ff8c..dda271082 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -288,7 +288,7 @@ void V3Graph::dumpDotFilePrefixedAlways(const string& nameComment, bool colorAsS void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) { // This generates a file used by graphviz, http://www.graphviz.org // "hardcoded" parameters: - const VL_UNIQUE_PTR logp (V3File::new_ofstream(filename)); + const vl_unique_ptr logp (V3File::new_ofstream(filename)); if (logp->fail()) v3fatalSrc("Can't write "< logp (V3File::new_ofstream(filename)); + const vl_unique_ptr logp (V3File::new_ofstream(filename)); if (logp->fail()) v3fatalSrc("Can't write "< dist; diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index f49789032..92973ae02 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -35,6 +35,7 @@ #include #include #include +#include VL_INCLUDE_UNORDERED_SET #include "V3Global.h" #include "V3LinkCells.h" @@ -105,7 +106,7 @@ private: LinkCellsGraph m_graph; // Linked graph of all cell interconnects LibraryVertex* m_libVertexp; // Vertex at root of all libraries V3GraphVertex* m_topVertexp; // Vertex of top module - set m_declfnWarned; // Files we issued DECLFILENAME on + vl_unordered_set m_declfnWarned; // Files we issued DECLFILENAME on static int debug() { static int level = -1; @@ -311,7 +312,7 @@ private: } if (nodep->modp()) { // Note what pins exist - set ports; // Symbol table of all connected port names + vl_unordered_set ports; // Symbol table of all connected port names for (AstPin* pinp = nodep->pinsp(); pinp; pinp=pinp->nextp()->castPin()) { if (pinp->name()=="") pinp->v3error("Connect by position is illegal in .* connected cells"); if (!pinp->exprp()) { diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 7ba72b86e..f18cf9b91 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -134,7 +134,7 @@ public: void dump(const string& nameComment="linkdot", bool force=false) { if (debug()>=6 || force) { string filename = v3Global.debugFilename(nameComment)+".txt"; - const VL_UNIQUE_PTR logp (V3File::new_ofstream(filename)); + const vl_unique_ptr logp (V3File::new_ofstream(filename)); if (logp->fail()) v3fatalSrc("Can't write "< ifp (V3File::new_ifstream(filename)); + const vl_unique_ptr ifp (V3File::new_ifstream(filename)); if (ifp->fail()) { fl->v3error("Cannot open -f command file: "+filename); return; diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 5217aa790..a3aa7d98d 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1286,7 +1286,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 VL_UNIQUE_PTR logp (V3File::new_ofstream(filename)); + const vl_unique_ptr logp (V3File::new_ofstream(filename)); if (logp->fail()) v3fatalSrc("Can't write "< logp (V3File::new_ofstream(dfilename)); + const vl_unique_ptr logp (V3File::new_ofstream(dfilename)); if (logp->fail()) v3fatalSrc("Can't write "< #include #include +#include VL_INCLUDE_UNORDERED_MAP #include "V3Global.h" #include "V3Stats.h" @@ -122,7 +123,7 @@ class StatsReport { size_t maxWidth = 0; typedef vector Stages; Stages stages; - map stageInt; + vl_unordered_map stageInt; typedef multimap ByName; ByName byName; // * is always first diff --git a/src/V3SymTable.h b/src/V3SymTable.h index c04000e3e..85a3e57ea 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -275,7 +275,7 @@ public: if (v3Global.opt.dumpTree()) { string filename = v3Global.debugFilename(nameComment)+".txt"; UINFO(2,"Dumping "< logp (V3File::new_ofstream(filename)); + const vl_unique_ptr logp (V3File::new_ofstream(filename)); if (logp->fail()) v3fatalSrc("Can't write "< #include #include +#include VL_INCLUDE_UNORDERED_MAP //******************************************************************** // VlcPoint - A coverage point (across all tests) @@ -98,7 +98,7 @@ public: class VlcPoints { private: // MEMBERS - typedef std::map NameMap; + typedef vl_unordered_map NameMap; NameMap m_nameMap; //< Name to point-number vector m_points; //< List of all points vluint64_t m_numPoints; //< Total unique points