From 28bd7e5b198b1380dcf193d14c1c170db7371c6b Mon Sep 17 00:00:00 2001 From: Mariusz Glebocki Date: Mon, 25 Sep 2023 04:12:23 +0200 Subject: [PATCH] Rework multithreading handling to separate by code units that use/never use it. (#4228) --- src/Makefile_obj.in | 2 +- src/V3Active.cpp | 2 + src/V3Active.h | 4 +- src/V3ActiveTop.cpp | 2 + src/V3ActiveTop.h | 4 +- src/V3Assert.cpp | 2 + src/V3Assert.h | 3 +- src/V3AssertPre.cpp | 2 + src/V3AssertPre.h | 4 +- src/V3AstNodeOther.h | 2 +- src/V3AstNodes.cpp | 8 +- src/V3Begin.cpp | 2 + src/V3Begin.h | 4 +- src/V3Branch.cpp | 2 + src/V3Branch.h | 4 +- src/V3CCtors.cpp | 2 + src/V3CCtors.h | 6 +- src/V3CUse.cpp | 2 + src/V3CUse.h | 4 +- src/V3Case.cpp | 2 + src/V3Case.h | 6 +- src/V3Cast.cpp | 2 + src/V3Cast.h | 4 +- src/V3Class.cpp | 2 + src/V3Class.h | 4 +- src/V3Clean.cpp | 2 + src/V3Clean.h | 4 +- src/V3Clock.cpp | 2 + src/V3Clock.h | 4 +- src/V3Combine.cpp | 2 + src/V3Combine.h | 4 +- src/V3Common.cpp | 2 + src/V3Common.h | 4 +- src/V3Const.cpp | 2 + src/V3Const.h | 29 +- src/V3Coverage.cpp | 2 + src/V3Coverage.h | 4 +- src/V3CoverageJoin.cpp | 2 + src/V3CoverageJoin.h | 4 +- src/V3Dead.cpp | 2 + src/V3Dead.h | 12 +- src/V3Delayed.cpp | 2 + src/V3Delayed.h | 4 +- src/V3Depth.cpp | 2 + src/V3Depth.h | 4 +- src/V3DepthBlock.cpp | 2 + src/V3DepthBlock.h | 4 +- src/V3Descope.cpp | 2 + src/V3Descope.h | 4 +- src/V3Dfg.cpp | 2 + src/V3Dfg.h | 75 +-- src/V3DfgAstToDfg.cpp | 2 + src/V3DfgDecomposition.cpp | 2 + src/V3DfgDfgToAst.cpp | 2 + src/V3DfgOptimizer.cpp | 2 + src/V3DfgOptimizer.h | 5 +- src/V3DfgPasses.cpp | 2 + src/V3DfgPasses.h | 25 +- src/V3DfgPeephole.cpp | 2 + src/V3DfgPeephole.h | 6 +- src/V3DfgVertices.h | 12 +- src/V3DupFinder.cpp | 2 + src/V3DupFinder.h | 9 +- src/V3EmitC.h | 14 +- src/V3EmitCBase.h | 2 +- src/V3EmitCFunc.h | 1 + src/V3EmitCMain.cpp | 2 + src/V3EmitCMain.h | 4 +- src/V3EmitCMake.cpp | 2 + src/V3EmitCMake.h | 4 +- src/V3EmitCModel.cpp | 2 + src/V3EmitCSyms.cpp | 2 + src/V3EmitMk.cpp | 2 + src/V3EmitMk.h | 6 +- src/V3EmitV.h | 2 + src/V3EmitXml.cpp | 2 + src/V3EmitXml.h | 4 +- src/V3Error.cpp | 23 +- src/V3Error.h | 35 +- src/V3Expand.cpp | 2 + src/V3Expand.h | 4 +- src/V3Force.cpp | 2 + src/V3Force.h | 4 +- src/V3Fork.cpp | 2 + src/V3Fork.h | 6 +- src/V3Gate.cpp | 2 + src/V3Gate.h | 4 +- src/V3Global.h | 7 +- src/V3Graph.cpp | 2 + src/V3Graph.h | 109 +++-- src/V3GraphAcyc.cpp | 2 + src/V3GraphAlg.cpp | 2 + src/V3GraphPathChecker.cpp | 2 + src/V3GraphPathChecker.h | 14 +- src/V3GraphTest.cpp | 2 + src/V3HierBlock.cpp | 2 + src/V3HierBlock.h | 41 +- src/V3Inline.cpp | 2 + src/V3Inline.h | 4 +- src/V3Inst.cpp | 2 + src/V3Inst.h | 10 +- src/V3InstrCount.cpp | 2 + src/V3InstrCount.h | 5 +- src/V3Life.cpp | 2 + src/V3Life.h | 4 +- src/V3LifePost.cpp | 2 + src/V3LifePost.h | 4 +- src/V3LinkCells.cpp | 2 + src/V3LinkCells.h | 4 +- src/V3LinkDot.cpp | 2 + src/V3LinkDot.h | 11 +- src/V3LinkInc.cpp | 2 + src/V3LinkInc.h | 4 +- src/V3LinkJump.cpp | 2 + src/V3LinkJump.h | 4 +- src/V3LinkLValue.cpp | 2 + src/V3LinkLValue.h | 6 +- src/V3LinkLevel.cpp | 2 + src/V3LinkLevel.h | 11 +- src/V3LinkParse.cpp | 2 + src/V3LinkParse.h | 4 +- src/V3LinkResolve.cpp | 2 + src/V3LinkResolve.h | 4 +- src/V3Localize.cpp | 2 + src/V3Localize.h | 4 +- src/V3MergeCond.cpp | 2 + src/V3MergeCond.h | 4 +- src/V3Name.cpp | 2 + src/V3Name.h | 4 +- src/V3Number_test.cpp | 1 + src/V3OptionParser.cpp | 2 + src/V3OptionParser.h | 56 ++- src/V3Options.cpp | 25 +- src/V3Options.h | 11 +- src/V3Order.cpp | 2 + src/V3Order.h | 4 +- src/V3OrderGraph.h | 59 ++- src/V3OrderMoveGraph.h | 24 +- src/V3Param.cpp | 2 + src/V3Param.h | 4 +- src/V3Parse.h | 9 +- src/V3ParseGrammar.cpp | 2 + src/V3ParseImp.cpp | 2 + src/V3ParseImp.h | 68 +-- src/V3ParseLex.cpp | 2 + src/V3Partition.cpp | 2 + src/V3Partition.h | 15 +- src/V3PartitionGraph.h | 14 +- src/V3PreProc.cpp | 2 + src/V3PreProc.h | 5 +- src/V3PreShell.cpp | 2 + src/V3PreShell.h | 17 +- src/V3Premit.cpp | 2 + src/V3Premit.h | 4 +- src/V3ProtectLib.cpp | 2 + src/V3ProtectLib.h | 4 +- src/V3Randomize.cpp | 2 + src/V3Randomize.h | 8 +- src/V3Reloop.cpp | 2 + src/V3Reloop.h | 4 +- src/V3Sched.cpp | 2 + src/V3Sched.h | 22 +- src/V3SchedAcyclic.cpp | 2 + src/V3SchedPartition.cpp | 2 + src/V3SchedReplicate.cpp | 2 + src/V3SchedTiming.cpp | 2 + src/V3Scope.cpp | 2 + src/V3Scope.h | 4 +- src/V3Scoreboard.cpp | 2 + src/V3Scoreboard.h | 3 +- src/V3Slice.cpp | 2 + src/V3Slice.h | 4 +- src/V3Split.cpp | 2 + src/V3Split.h | 6 +- src/V3SplitAs.cpp | 2 + src/V3SplitAs.h | 4 +- src/V3SplitVar.cpp | 2 + src/V3SplitVar.h | 6 +- src/V3Subst.cpp | 2 + src/V3Subst.h | 4 +- src/V3TSP.cpp | 2 + src/V3TSP.h | 5 +- src/V3Table.cpp | 2 + src/V3Table.h | 4 +- src/V3Task.cpp | 2 + src/V3Task.h | 14 +- src/V3Timing.cpp | 2 + src/V3Timing.h | 3 +- src/V3Trace.cpp | 2 + src/V3Trace.h | 4 +- src/V3TraceDecl.cpp | 2 + src/V3TraceDecl.h | 4 +- src/V3Tristate.cpp | 2 + src/V3Tristate.h | 4 +- src/V3Undriven.cpp | 2 + src/V3Undriven.h | 4 +- src/V3Unknown.cpp | 2 + src/V3Unknown.h | 4 +- src/V3Unroll.cpp | 2 + src/V3Unroll.h | 11 +- src/V3VariableOrder.cpp | 2 + src/V3VariableOrder.h | 4 +- src/V3Width.cpp | 5 +- src/V3Width.h | 14 +- src/V3WidthSel.cpp | 2 + src/Verilator.cpp | 943 +++++++++++++++++++------------------ src/VlcMain.cpp | 2 + src/VlcOptions.h | 10 +- src/VlcTop.cpp | 2 + src/verilog.y | 13 +- 210 files changed, 1365 insertions(+), 913 deletions(-) diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 471af2c79..162da5d85 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -389,7 +389,7 @@ HEADER_CC_H := $(filter-out $(NON_STANDALONE_HEADERS), $(notdir $(wildcard $(src header_cc: $(addsuffix __header_cc.o, $(basename $(HEADER_CC_H))) %__header_cc.cpp: %.h - $(PYTHON3) $(srcdir)/../bin/verilator_includer $^ > $@ + $(PYTHON3) $(srcdir)/../bin/verilator_includer -DVL_MT_DISABLED_CODE_UNIT=1 $^ > $@ .SUFFIXES: diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 54b110d00..857c34045 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -26,6 +26,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Active.h b/src/V3Active.h index 81684c6f1..090d7b019 100644 --- a/src/V3Active.h +++ b/src/V3Active.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Active final { public: - static void activeAll(AstNetlist* nodep); + static void activeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 16cfe6e95..4dc193116 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3ActiveTop.h b/src/V3ActiveTop.h index ac9361c7d..ae3821112 100644 --- a/src/V3ActiveTop.h +++ b/src/V3ActiveTop.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3ActiveTop final { public: - static void activeTopAll(AstNetlist* nodep); + static void activeTopAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index e010215d9..b13fae8c0 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Assert.h b/src/V3Assert.h index dcf26756a..f345c2e27 100644 --- a/src/V3Assert.h +++ b/src/V3Assert.h @@ -21,12 +21,13 @@ #include "verilatedos.h" #include "V3Ast.h" +#include "V3ThreadSafety.h" //============================================================================ class V3Assert final { public: - static void assertAll(AstNetlist* nodep); + static void assertAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 766d454d1..bf416c276 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -19,6 +19,8 @@ // Transform clocking blocks into imperative logic //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3AssertPre.h b/src/V3AssertPre.h index 9cc61528d..dc58f6054 100644 --- a/src/V3AssertPre.h +++ b/src/V3AssertPre.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3AssertPre final { public: - static void assertPreAll(AstNetlist* nodep); + static void assertPreAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 12b7ce9f2..a6b8aa63f 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -1034,7 +1034,7 @@ class AstExecGraph final : public AstNode { const string m_name; // Name of this AstExecGraph (for uniqueness at code generation) public: - explicit AstExecGraph(FileLine* fl, const string& name); + explicit AstExecGraph(FileLine* fl, const string& name) VL_MT_DISABLED; ASTGEN_MEMBERS_AstExecGraph; ~AstExecGraph() override; const char* broken() const override { diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 81dfdbaf4..3ba281286 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -357,10 +357,10 @@ AstNodeBiop* AstEqWild::newTyped(FileLine* fl, AstNodeExpr* lhsp, AstNodeExpr* r } } -AstExecGraph::AstExecGraph(FileLine* fileline, const string& name) - : ASTGEN_SUPER_ExecGraph(fileline) - , m_depGraphp{new V3Graph} - , m_name{name} {} +AstExecGraph::AstExecGraph(FileLine* fileline, const string& name) VL_MT_DISABLED + : ASTGEN_SUPER_ExecGraph(fileline), + m_depGraphp{new V3Graph}, + m_name{name} {} AstExecGraph::~AstExecGraph() { VL_DO_DANGLING(delete m_depGraphp, m_depGraphp); } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index abe27a1dc..1ff68713b 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -26,6 +26,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Begin.h b/src/V3Begin.h index b62f6ce34..b2cd44a01 100644 --- a/src/V3Begin.h +++ b/src/V3Begin.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Begin final { public: - static void debeginAll(AstNetlist* nodep); + static void debeginAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index e84e041b5..f24307808 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Branch.h b/src/V3Branch.h index a86d9fae1..79f793307 100644 --- a/src/V3Branch.h +++ b/src/V3Branch.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ @@ -27,7 +29,7 @@ class AstNetlist; class V3Branch final { public: // CONSTRUCTORS - static void branchAll(AstNetlist* nodep); + static void branchAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 0cec01ab1..1727126ed 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -24,6 +24,8 @@ // This transformation honors outputSplitCFuncs. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3CCtors.h b/src/V3CCtors.h index 4a244dca2..c719d65d1 100644 --- a/src/V3CCtors.h +++ b/src/V3CCtors.h @@ -20,14 +20,16 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3CCtors final { public: - static void cctorsAll(); + static void cctorsAll() VL_MT_DISABLED; private: - static void evalAsserts(); + static void evalAsserts() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 1fae654db..05215f5bc 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -22,6 +22,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3CUse.h b/src/V3CUse.h index 1ab67c8f0..4e475f3b8 100644 --- a/src/V3CUse.h +++ b/src/V3CUse.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3CUse final { public: - static void cUseAll(); + static void cUseAll() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 9110d9b93..53cc524ce 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -34,6 +34,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Case.h b/src/V3Case.h index 0fa9fb11f..d78984d16 100644 --- a/src/V3Case.h +++ b/src/V3Case.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; class AstNodeCase; @@ -27,8 +29,8 @@ class AstNodeCase; class V3Case final { public: - static void caseAll(AstNetlist* nodep); - static void caseLint(AstNodeCase* nodep); + static void caseAll(AstNetlist* nodep) VL_MT_DISABLED; + static void caseLint(AstNodeCase* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index eaecd7320..7362f9c71 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -37,6 +37,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Cast.h b/src/V3Cast.h index 1f359dc9c..23177ced6 100644 --- a/src/V3Cast.h +++ b/src/V3Cast.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Cast final { public: - static void castAll(AstNetlist* nodep); + static void castAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Class.cpp b/src/V3Class.cpp index ab62db18c..e71de0dab 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -20,6 +20,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Class.h b/src/V3Class.h index bde611ead..8401a9504 100644 --- a/src/V3Class.h +++ b/src/V3Class.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Class final { public: - static void classAll(AstNetlist* nodep); + static void classAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 026ebe039..9023fadd7 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Clean.h b/src/V3Clean.h index 451004d00..be37e2420 100644 --- a/src/V3Clean.h +++ b/src/V3Clean.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Clean final { public: - static void cleanAll(AstNetlist* nodep); + static void cleanAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index c72730ffb..6a66f45e5 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -27,6 +27,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Clock.h b/src/V3Clock.h index c809b9113..da009685b 100644 --- a/src/V3Clock.h +++ b/src/V3Clock.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Clock final { public: - static void clockAll(AstNetlist* nodep); + static void clockAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index a4d425229..f6fcd3260 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -19,6 +19,8 @@ // Also drop empty CFuncs //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Combine.h b/src/V3Combine.h index 2ea3ef581..466cb850c 100644 --- a/src/V3Combine.h +++ b/src/V3Combine.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Combine final { public: - static void combineAll(AstNetlist* nodep); + static void combineAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Common.cpp b/src/V3Common.cpp index e4cddae9d..d6e08d083 100644 --- a/src/V3Common.cpp +++ b/src/V3Common.cpp @@ -20,6 +20,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Common.h b/src/V3Common.h index f71e7ba2e..854077e07 100644 --- a/src/V3Common.h +++ b/src/V3Common.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3Common final { public: - static void commonAll(); + static void commonAll() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Const.cpp b/src/V3Const.cpp index b96b2fee8..ea0e4bea6 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -20,6 +20,8 @@ // If operands are constant, replace this node with constant. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Const.h b/src/V3Const.h index a0c0cf797..e992faca8 100644 --- a/src/V3Const.h +++ b/src/V3Const.h @@ -21,43 +21,44 @@ #include "verilatedos.h" #include "V3Ast.h" +#include "V3ThreadSafety.h" //============================================================================ class V3Const final { public: - static AstNode* constifyParamsEdit(AstNode* nodep); - static AstNodeExpr* constifyParamsEdit(AstNodeExpr* exprp) { + static AstNode* constifyParamsEdit(AstNode* nodep) VL_MT_DISABLED; + static AstNodeExpr* constifyParamsEdit(AstNodeExpr* exprp) VL_MT_DISABLED { return VN_AS(constifyParamsEdit(static_cast(exprp)), NodeExpr); } - static AstNode* constifyParamsNoWarnEdit(AstNode* nodep); - static AstNodeExpr* constifyParamsNoWarnEdit(AstNodeExpr* exprp) { + static AstNode* constifyParamsNoWarnEdit(AstNode* nodep) VL_MT_DISABLED; + static AstNodeExpr* constifyParamsNoWarnEdit(AstNodeExpr* exprp) VL_MT_DISABLED { return VN_AS(constifyParamsNoWarnEdit(static_cast(exprp)), NodeExpr); } - static AstNode* constifyGenerateParamsEdit(AstNode* nodep); + static AstNode* constifyGenerateParamsEdit(AstNode* nodep) VL_MT_DISABLED; // Only do constant pushing, without removing dead logic - static void constifyAllLive(AstNetlist* nodep); + static void constifyAllLive(AstNetlist* nodep) VL_MT_DISABLED; // Everything that's possible - static void constifyAll(AstNetlist* nodep); + static void constifyAll(AstNetlist* nodep) VL_MT_DISABLED; // Also, warn - static void constifyAllLint(AstNetlist* nodep); + static void constifyAllLint(AstNetlist* nodep) VL_MT_DISABLED; // C++ datatypes - static void constifyCpp(AstNetlist* nodep); + static void constifyCpp(AstNetlist* nodep) VL_MT_DISABLED; // Only the current node and lower // Return new node that may have replaced nodep - static AstNode* constifyEditCpp(AstNode* nodep); - static AstNodeExpr* constifyEditCpp(AstNodeExpr* exprp) { + static AstNode* constifyEditCpp(AstNode* nodep) VL_MT_DISABLED; + static AstNodeExpr* constifyEditCpp(AstNodeExpr* exprp) VL_MT_DISABLED { return VN_AS(constifyEditCpp(static_cast(exprp)), NodeExpr); } // Only the current node and lower // Return new node that may have replaced nodep - static AstNode* constifyEdit(AstNode* nodep); - static AstNodeExpr* constifyEdit(AstNodeExpr* exprp) { + static AstNode* constifyEdit(AstNode* nodep) VL_MT_DISABLED; + static AstNodeExpr* constifyEdit(AstNodeExpr* exprp) VL_MT_DISABLED { return VN_AS(constifyEdit(static_cast(exprp)), NodeExpr); } // Only the current node and lower, with special SenTree optimization // Return new node that may have replaced nodep - static AstNode* constifyExpensiveEdit(AstNode* nodep); + static AstNode* constifyExpensiveEdit(AstNode* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 280e652cc..85c9af732 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Coverage.h b/src/V3Coverage.h index 3a29fd7cb..b3a48739b 100644 --- a/src/V3Coverage.h +++ b/src/V3Coverage.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ @@ -27,7 +29,7 @@ class AstNetlist; class V3Coverage final { public: // CONSTRUCTORS - static void coverage(AstNetlist* rootp); + static void coverage(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index dbfc26862..58176cd69 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -17,6 +17,8 @@ // If two COVERTOGGLEs have same VARSCOPE, combine them //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3CoverageJoin.h b/src/V3CoverageJoin.h index 3f1a88345..9441b3742 100644 --- a/src/V3CoverageJoin.h +++ b/src/V3CoverageJoin.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ @@ -27,7 +29,7 @@ class AstNetlist; class V3CoverageJoin final { public: // CONSTRUCTORS - static void coverageJoin(AstNetlist* rootp); + static void coverageJoin(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index dd91a542d..6a0f8ae7a 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -33,6 +33,8 @@ // here after scoping to allow more dead node removal. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Dead.h b/src/V3Dead.h index c94508137..614bc7270 100644 --- a/src/V3Dead.h +++ b/src/V3Dead.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ @@ -27,13 +29,13 @@ class AstNetlist; class V3Dead final { public: // Modules, no vars/dtypes - static void deadifyModules(AstNetlist* nodep); + static void deadifyModules(AstNetlist* nodep) VL_MT_DISABLED; // Modules, Data types - static void deadifyDTypes(AstNetlist* nodep); - static void deadifyDTypesScoped(AstNetlist* nodep); + static void deadifyDTypes(AstNetlist* nodep) VL_MT_DISABLED; + static void deadifyDTypesScoped(AstNetlist* nodep) VL_MT_DISABLED; // Everything that's possible - static void deadifyAll(AstNetlist* nodep); - static void deadifyAllScoped(AstNetlist* nodep); + static void deadifyAll(AstNetlist* nodep) VL_MT_DISABLED; + static void deadifyAllScoped(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index d8d9185ff..eba736d48 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -48,6 +48,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Delayed.h b/src/V3Delayed.h index dd36bda69..c8147cb0d 100644 --- a/src/V3Delayed.h +++ b/src/V3Delayed.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Delayed final { public: - static void delayedAll(AstNetlist* nodep); + static void delayedAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 32797e069..7f1012f50 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Depth.h b/src/V3Depth.h index a35aaf56a..b844330cf 100644 --- a/src/V3Depth.h +++ b/src/V3Depth.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Depth final { public: - static void depthAll(AstNetlist* nodep); + static void depthAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 4adebda13..b0e65d136 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -20,6 +20,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DepthBlock.h b/src/V3DepthBlock.h index 0282d0487..9f29b0ce9 100644 --- a/src/V3DepthBlock.h +++ b/src/V3DepthBlock.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3DepthBlock final { public: - static void depthBlockAll(AstNetlist* nodep); + static void depthBlockAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index fe5fe15f9..8b68ca011 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -22,6 +22,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Descope.h b/src/V3Descope.h index b8f77b8db..ff1e0a9ff 100644 --- a/src/V3Descope.h +++ b/src/V3Descope.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Descope final { public: - static void descopeAll(AstNetlist* nodep); + static void descopeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Dfg.cpp b/src/V3Dfg.cpp index c3caf86c8..4e70c94ac 100644 --- a/src/V3Dfg.cpp +++ b/src/V3Dfg.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Dfg.h b/src/V3Dfg.h index e0d72335b..3be33cf06 100644 --- a/src/V3Dfg.h +++ b/src/V3Dfg.h @@ -35,8 +35,10 @@ #include "V3Ast.h" #include "V3Error.h" +#include "V3Global.h" #include "V3Hash.h" #include "V3List.h" +#include "V3ThreadSafety.h" #include "V3Dfg__gen_forward_class_decls.h" // From ./astgen @@ -140,8 +142,8 @@ class DfgGraph final { public: // CONSTRUCTOR - explicit DfgGraph(AstModule& module, const string& name = ""); - ~DfgGraph(); + explicit DfgGraph(AstModule& module, const string& name = "") VL_MT_DISABLED; + ~DfgGraph() VL_MT_DISABLED; VL_UNCOPYABLE(DfgGraph); // METHODS @@ -183,12 +185,12 @@ public: inline void forEachVertex(std::function f) const; // Add contents of other graph to this graph. Leaves other graph empty. - void addGraph(DfgGraph& other); + void addGraph(DfgGraph& other) VL_MT_DISABLED; // Split this graph into individual components (unique sub-graphs with no edges between them). // Also removes any vertices that are not weakly connected to any variable. // Leaves 'this' graph empty. - std::vector> splitIntoComponents(std::string label); + std::vector> splitIntoComponents(std::string label) VL_MT_DISABLED; // Extract cyclic sub-graphs from 'this' graph. Cyclic sub-graphs are those that contain at // least one strongly connected component (SCC) plus any other vertices that feed or sink from @@ -198,26 +200,27 @@ public: // of a cycle) are left in 'this' graph. This means that at the end 'this' graph is guaranteed // to be a DAG (acyclic). 'this' will not necessarily be a connected graph at the end, even if // it was originally connected. - std::vector> extractCyclicComponents(std::string label); + std::vector> + extractCyclicComponents(std::string label) VL_MT_DISABLED; // Dump graph in Graphviz format into the given stream 'os'. 'label' is added to the name of // the graph which is included in the output. - void dumpDot(std::ostream& os, const string& label = "") const; + void dumpDot(std::ostream& os, const string& label = "") const VL_MT_DISABLED; // Dump graph in Graphviz format into a new file with the given 'fileName'. 'label' is added to // the name of the graph which is included in the output. - void dumpDotFile(const string& fileName, const string& label = "") const; + void dumpDotFile(const string& fileName, const string& label = "") const VL_MT_DISABLED; // Dump graph in Graphviz format into a new automatically numbered debug file. 'label' is // added to the name of the graph, which is included in the file name and the output. - void dumpDotFilePrefixed(const string& label = "") const; + void dumpDotFilePrefixed(const string& label = "") const VL_MT_DISABLED; // Dump upstream (source) logic cone starting from given vertex into a file with the given // 'fileName'. 'name' is the name of the graph, which is included in the output. void dumpDotUpstreamCone(const string& fileName, const DfgVertex& vtx, - const string& name = "") const; + const string& name = "") const VL_MT_DISABLED; // Dump all individual logic cones driving external variables in Graphviz format into separate // new automatically numbered debug files. 'label' is added to the name of the graph, which is // included in the file names and the output. This is useful for very large graphs that are // otherwise difficult to browse visually due to their size. - void dumpDotAllVarConesPrefixed(const string& label = "") const; + void dumpDotAllVarConesPrefixed(const string& label = "") const VL_MT_DISABLED; }; //------------------------------------------------------------------------------ @@ -243,9 +246,9 @@ public: // The sink (consumer) of this edge DfgVertex* sinkp() const { return m_sinkp; } // Remove driver of this edge - void unlinkSource(); + void unlinkSource() VL_MT_DISABLED; // Relink this edge to be driven from the given new source vertex - void relinkSource(DfgVertex* newSourcep); + void relinkSource(DfgVertex* newSourcep) VL_MT_DISABLED; }; //------------------------------------------------------------------------------ @@ -272,10 +275,10 @@ protected: UserDataStorage m_userDataStorage; // User data storage // CONSTRUCTOR - DfgVertex(DfgGraph& dfg, VDfgType type, FileLine* flp, AstNodeDType* dtypep); + DfgVertex(DfgGraph& dfg, VDfgType type, FileLine* flp, AstNodeDType* dtypep) VL_MT_DISABLED; public: - virtual ~DfgVertex(); + virtual ~DfgVertex() VL_MT_DISABLED; // METHODS private: @@ -283,10 +286,10 @@ private: virtual void accept(DfgVisitor& v) = 0; // Part of Vertex equality only dependent on this vertex - virtual bool selfEquals(const DfgVertex& that) const; + virtual bool selfEquals(const DfgVertex& that) const VL_MT_DISABLED; // Part of Vertex hash only dependent on this vertex - virtual V3Hash selfHash() const; + virtual V3Hash selfHash() const VL_MT_DISABLED; public: // Supported packed types @@ -409,7 +412,7 @@ public: // semantics of the logic. The 'cache' argument is used to store results to avoid repeat // evaluations, but it requires that the upstream sources of the compared vertices do not // change between invocations. - bool equals(const DfgVertex& that, EqualsCache& cache) const; + bool equals(const DfgVertex& that, EqualsCache& cache) const VL_MT_DISABLED; // Uncached version of 'equals' bool equals(const DfgVertex& that) const { @@ -419,7 +422,7 @@ public: // Hash of vertex (depends on this vertex and all upstream vertices feeding into this vertex). // Uses user data for caching hashes - V3Hash hash(); + V3Hash hash() VL_MT_DISABLED; // Source edges of this vertex virtual std::pair sourceEdges() = 0; @@ -437,13 +440,13 @@ public: bool hasMultipleSinks() const { return m_sinksp && m_sinksp->m_nextp; } // Fanout (number of sinks) of this vertex (expensive to compute) - uint32_t fanout() const; + uint32_t fanout() const VL_MT_DISABLED; // Unlink from container (graph or builder), then delete this vertex - void unlinkDelete(DfgGraph& dfg); + void unlinkDelete(DfgGraph& dfg) VL_MT_DISABLED; // Relink all sinks to be driven from the given new source - void replaceWith(DfgVertex* newSourcep); + void replaceWith(DfgVertex* newSourcep) VL_MT_DISABLED; // Access to vertex list for faster iteration in important contexts DfgVertex* verticesNext() const { return m_verticesEnt.nextp(); } @@ -451,56 +454,58 @@ public: // Calls given function 'f' for each source vertex of this vertex // Unconnected source edges are not iterated. - inline void forEachSource(std::function f); + inline void forEachSource(std::function f) VL_MT_DISABLED; // Calls given function 'f' for each source vertex of this vertex // Unconnected source edges are not iterated. - inline void forEachSource(std::function f) const; + inline void forEachSource(std::function f) const VL_MT_DISABLED; // Calls given function 'f' for each source edge of this vertex. Also passes source index. - inline void forEachSourceEdge(std::function f); + inline void forEachSourceEdge(std::function f) VL_MT_DISABLED; // Calls given function 'f' for each source edge of this vertex. Also passes source index. - inline void forEachSourceEdge(std::function f) const; + inline void + forEachSourceEdge(std::function f) const VL_MT_DISABLED; // Calls given function 'f' for each sink vertex of this vertex // Unlinking/deleting the given sink during iteration is safe, but not other sinks of this // vertex. - inline void forEachSink(std::function f); + inline void forEachSink(std::function f) VL_MT_DISABLED; // Calls given function 'f' for each sink vertex of this vertex - inline void forEachSink(std::function f) const; + inline void forEachSink(std::function f) const VL_MT_DISABLED; // Calls given function 'f' for each sink edge of this vertex. // Unlinking/deleting the given sink during iteration is safe, but not other sinks of this // vertex. - inline void forEachSinkEdge(std::function f); + inline void forEachSinkEdge(std::function f) VL_MT_DISABLED; // Calls given function 'f' for each sink edge of this vertex. - inline void forEachSinkEdge(std::function f) const; + inline void forEachSinkEdge(std::function f) const VL_MT_DISABLED; // Returns first source edge which satisfies the given predicate 'p', or nullptr if no such // sink vertex exists - inline const DfgEdge* findSourceEdge(std::function p) const; + inline const DfgEdge* + findSourceEdge(std::function p) const VL_MT_DISABLED; // Returns first sink vertex of type 'Vertex' which satisfies the given predicate 'p', // or nullptr if no such sink vertex exists template - inline Vertex* findSink(std::function p) const; + inline Vertex* findSink(std::function p) const VL_MT_DISABLED; // Returns first sink vertex of type 'Vertex', or nullptr if no such sink vertex exists. // This is a special case of 'findSink' above with the predicate always true. template - inline Vertex* findSink() const; + inline Vertex* findSink() const VL_MT_DISABLED; // Is this a DfgConst that is all zeroes - inline bool isZero() const; + inline bool isZero() const VL_MT_DISABLED; // Is this a DfgConst that is all ones - inline bool isOnes() const; + inline bool isOnes() const VL_MT_DISABLED; // Should this vertex be inlined when rendering to Ast, or be stored to a temporary - inline bool inlined() const; + inline bool inlined() const VL_MT_DISABLED; // Methods that allow DfgVertex to participate in error reporting/messaging void v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) { diff --git a/src/V3DfgAstToDfg.cpp b/src/V3DfgAstToDfg.cpp index da265a1ff..c4aa2d1be 100644 --- a/src/V3DfgAstToDfg.cpp +++ b/src/V3DfgAstToDfg.cpp @@ -26,6 +26,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DfgDecomposition.cpp b/src/V3DfgDecomposition.cpp index 9dc61a07d..31bb001ce 100644 --- a/src/V3DfgDecomposition.cpp +++ b/src/V3DfgDecomposition.cpp @@ -18,6 +18,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DfgDfgToAst.cpp b/src/V3DfgDfgToAst.cpp index 089e551b4..43728cef9 100644 --- a/src/V3DfgDfgToAst.cpp +++ b/src/V3DfgDfgToAst.cpp @@ -26,6 +26,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DfgOptimizer.cpp b/src/V3DfgOptimizer.cpp index a299cae0e..0a514723b 100644 --- a/src/V3DfgOptimizer.cpp +++ b/src/V3DfgOptimizer.cpp @@ -18,6 +18,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DfgOptimizer.h b/src/V3DfgOptimizer.h index 16b4b34cb..8ec1ede6c 100644 --- a/src/V3DfgOptimizer.h +++ b/src/V3DfgOptimizer.h @@ -21,15 +21,16 @@ #include "verilatedos.h" #include "V3Ast.h" +#include "V3ThreadSafety.h" //============================================================================ namespace V3DfgOptimizer { // Extract further logic blocks from the design for additional optimization opportunities -void extract(AstNetlist*); +void extract(AstNetlist*) VL_MT_DISABLED; // Optimize the design -void optimize(AstNetlist*, const string& label); +void optimize(AstNetlist*, const string& label) VL_MT_DISABLED; } // namespace V3DfgOptimizer #endif // Guard diff --git a/src/V3DfgPasses.cpp b/src/V3DfgPasses.cpp index 3edfe5a88..44026320e 100644 --- a/src/V3DfgPasses.cpp +++ b/src/V3DfgPasses.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "V3DfgPasses.h" diff --git a/src/V3DfgPasses.h b/src/V3DfgPasses.h index fabe4f92d..6b6689503 100644 --- a/src/V3DfgPasses.h +++ b/src/V3DfgPasses.h @@ -20,6 +20,7 @@ #include "config_build.h" #include "V3DfgPeephole.h" +#include "V3ThreadSafety.h" class AstModule; class DfgGraph; @@ -35,7 +36,7 @@ public: VDouble0 m_eliminated; // Number of common sub-expressions eliminated explicit V3DfgCseContext(const std::string& label) : m_label{label} {} - ~V3DfgCseContext(); + ~V3DfgCseContext() VL_MT_DISABLED; }; class DfgRemoveVarsContext final { @@ -45,7 +46,7 @@ public: VDouble0 m_removed; // Number of redundant variables removed explicit DfgRemoveVarsContext(const std::string& label) : m_label{label} {} - ~DfgRemoveVarsContext(); + ~DfgRemoveVarsContext() VL_MT_DISABLED; }; class V3DfgOptimizationContext final { @@ -73,8 +74,8 @@ public: V3DfgCseContext m_cseContext1{m_label + " 2nd"}; V3DfgPeepholeContext m_peepholeContext{m_label}; DfgRemoveVarsContext m_removeVarsContext{m_label}; - explicit V3DfgOptimizationContext(const std::string& label); - ~V3DfgOptimizationContext(); + explicit V3DfgOptimizationContext(const std::string& label) VL_MT_DISABLED; + ~V3DfgOptimizationContext() VL_MT_DISABLED; const std::string& prefix() const { return m_prefix; } }; @@ -87,29 +88,29 @@ namespace V3DfgPasses { // Construct a DfGGraph representing the combinational logic in the given AstModule. The logic // that is represented by the graph is removed from the given AstModule. Returns the // constructed DfgGraph. -DfgGraph* astToDfg(AstModule&, V3DfgOptimizationContext&); +DfgGraph* astToDfg(AstModule&, V3DfgOptimizationContext&) VL_MT_DISABLED; // Optimize the given DfgGraph -void optimize(DfgGraph&, V3DfgOptimizationContext&); +void optimize(DfgGraph&, V3DfgOptimizationContext&) VL_MT_DISABLED; // Convert DfgGraph back into Ast, and insert converted graph back into its parent module. // Returns the parent module. -AstModule* dfgToAst(DfgGraph&, V3DfgOptimizationContext&); +AstModule* dfgToAst(DfgGraph&, V3DfgOptimizationContext&) VL_MT_DISABLED; //=========================================================================== // Intermediate/internal operations //=========================================================================== // Common subexpression elimination -void cse(DfgGraph&, V3DfgCseContext&); +void cse(DfgGraph&, V3DfgCseContext&) VL_MT_DISABLED; // Inline fully driven variables -void inlineVars(const DfgGraph&); +void inlineVars(const DfgGraph&) VL_MT_DISABLED; // Peephole optimizations -void peephole(DfgGraph&, V3DfgPeepholeContext&); +void peephole(DfgGraph&, V3DfgPeepholeContext&) VL_MT_DISABLED; // Remove redundant variables -void removeVars(DfgGraph&, DfgRemoveVarsContext&); +void removeVars(DfgGraph&, DfgRemoveVarsContext&) VL_MT_DISABLED; // Remove unused nodes -void removeUnused(DfgGraph&); +void removeUnused(DfgGraph&) VL_MT_DISABLED; } // namespace V3DfgPasses #endif diff --git a/src/V3DfgPeephole.cpp b/src/V3DfgPeephole.cpp index 72d1f19b0..c3d969a8e 100644 --- a/src/V3DfgPeephole.cpp +++ b/src/V3DfgPeephole.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "V3DfgPeephole.h" diff --git a/src/V3DfgPeephole.h b/src/V3DfgPeephole.h index 70cf8e044..c2d83042e 100644 --- a/src/V3DfgPeephole.h +++ b/src/V3DfgPeephole.h @@ -19,6 +19,8 @@ #include "config_build.h" +#include "V3ThreadSafety.h" + #include #define _FOR_EACH_DFG_PEEPHOLE_OPTIMIZATION_APPLY(macro, arg) macro(arg, #arg) @@ -127,8 +129,8 @@ struct V3DfgPeepholeContext final { // Count of applications for each optimization (for statistics) std::array m_count; - explicit V3DfgPeepholeContext(const std::string& label); - ~V3DfgPeepholeContext(); + explicit V3DfgPeepholeContext(const std::string& label) VL_MT_DISABLED; + ~V3DfgPeepholeContext() VL_MT_DISABLED; }; #endif diff --git a/src/V3DfgVertices.h b/src/V3DfgVertices.h index a576d5767..bbcd9bdca 100644 --- a/src/V3DfgVertices.h +++ b/src/V3DfgVertices.h @@ -43,8 +43,8 @@ class DfgVertexVar VL_NOT_FINAL : public DfgVertexVariadic { bool m_hasModRefs = false; // This AstVar is referenced outside the DFG, but in the module bool m_hasExtRefs = false; // This AstVar is referenced from outside the module - bool selfEquals(const DfgVertex& that) const final; - V3Hash selfHash() const final; + bool selfEquals(const DfgVertex& that) const final VL_MT_DISABLED; + V3Hash selfHash() const final VL_MT_DISABLED; public: DfgVertexVar(DfgGraph& dfg, VDfgType type, AstVar* varp, uint32_t initialCapacity) @@ -92,8 +92,8 @@ class DfgConst final : public DfgVertex { V3Number m_num; // Constant value - bool selfEquals(const DfgVertex& that) const override; - V3Hash selfHash() const override; + bool selfEquals(const DfgVertex& that) const override VL_MT_DISABLED; + V3Hash selfHash() const override VL_MT_DISABLED; public: DfgConst(DfgGraph& dfg, FileLine* flp, const V3Number& num) @@ -158,8 +158,8 @@ class DfgSel final : public DfgVertexUnary { // the constant 'lsbp', and as 'DfgMux` for the non-constant 'lsbp'. uint32_t m_lsb = 0; // The LSB index - bool selfEquals(const DfgVertex& that) const override; - V3Hash selfHash() const override; + bool selfEquals(const DfgVertex& that) const override VL_MT_DISABLED; + V3Hash selfHash() const override VL_MT_DISABLED; public: DfgSel(DfgGraph& dfg, FileLine* flp, AstNodeDType* dtypep) diff --git a/src/V3DupFinder.cpp b/src/V3DupFinder.cpp index f41d9b1df..f1e3ab956 100644 --- a/src/V3DupFinder.cpp +++ b/src/V3DupFinder.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3DupFinder.h b/src/V3DupFinder.h index 37118aebc..102ef6a43 100644 --- a/src/V3DupFinder.h +++ b/src/V3DupFinder.h @@ -26,6 +26,7 @@ #include "V3Ast.h" #include "V3Error.h" #include "V3Hasher.h" +#include "V3ThreadSafety.h" #include #include @@ -76,14 +77,14 @@ public: iterator insert(AstNode* nodep) { return emplace(m_hasher(nodep), nodep); } // Erase node from data structure - size_type erase(AstNode* nodep); + size_type erase(AstNode* nodep) VL_MT_DISABLED; // Return duplicate, if one was inserted, with optional user check for sameness - iterator findDuplicate(AstNode* nodep, V3DupFinderUserSame* checkp = nullptr); + iterator findDuplicate(AstNode* nodep, V3DupFinderUserSame* checkp = nullptr) VL_MT_DISABLED; // Dump for debug - void dumpFile(const string& filename, bool tree); - void dumpFilePrefixed(const string& nameComment, bool tree = false); + void dumpFile(const string& filename, bool tree) VL_MT_DISABLED; + void dumpFilePrefixed(const string& nameComment, bool tree = false) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3EmitC.h b/src/V3EmitC.h index 696eb3df6..4ee9460cf 100644 --- a/src/V3EmitC.h +++ b/src/V3EmitC.h @@ -20,17 +20,19 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3EmitC final { public: - static void emitcConstPool(); - static void emitcHeaders(); + static void emitcConstPool() VL_MT_DISABLED; + static void emitcHeaders() VL_MT_DISABLED; static void emitcImp(); - static void emitcInlines(); - static void emitcModel(); - static void emitcSyms(bool dpiHdrOnly = false); - static void emitcFiles(); + static void emitcInlines() VL_MT_DISABLED; + static void emitcModel() VL_MT_DISABLED; + static void emitcSyms(bool dpiHdrOnly = false) VL_MT_DISABLED; + static void emitcFiles() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index d3d797e3a..5abf33271 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -22,7 +22,7 @@ #include "V3Ast.h" #include "V3File.h" -#include "V3Global.h" +#include "V3ThreadSafety.h" #include #include diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 6481ea2c4..8dbe3ca70 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -23,6 +23,7 @@ #include "V3EmitCConstInit.h" #include "V3Global.h" #include "V3MemberMap.h" +#include "V3ThreadSafety.h" #include #include diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index 3ea952903..873519d5d 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitCMain.h b/src/V3EmitCMain.h index cf4d04f9f..65877429b 100644 --- a/src/V3EmitCMain.h +++ b/src/V3EmitCMain.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3EmitCMain final { public: - static void emit(); + static void emit() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index 071808934..6598da9a8 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitCMake.h b/src/V3EmitCMake.h index 1f2a11246..ac611386c 100644 --- a/src/V3EmitCMake.h +++ b/src/V3EmitCMake.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3EmitCMake final { public: - static void emit(); + static void emit() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 3f988ed32..8eff11e6f 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 0ae5d82fd..4a041d784 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 02696c342..3f38e5119 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitMk.h b/src/V3EmitMk.h index 0ddfdba66..2c043890b 100644 --- a/src/V3EmitMk.h +++ b/src/V3EmitMk.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class V3HierBlockPlan; //============================================================================ @@ -29,8 +31,8 @@ public: // Number of source files after which to use parallel compiles static const size_t PARALLEL_FILE_CNT_THRESHOLD = 128; - static void emitmk(); - static void emitHierVerilation(const V3HierBlockPlan* planp); + static void emitmk() VL_MT_DISABLED; + static void emitHierVerilation(const V3HierBlockPlan* planp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3EmitV.h b/src/V3EmitV.h index 8af3061df..80be5453a 100644 --- a/src/V3EmitV.h +++ b/src/V3EmitV.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNode; class AstSenTree; diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 5466bf2f4..9065a24b7 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3EmitXml.h b/src/V3EmitXml.h index 399f3f743..420795b0d 100644 --- a/src/V3EmitXml.h +++ b/src/V3EmitXml.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3EmitXml final { public: - static void emitxml(); + static void emitxml() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 48966be77..5d915f9c5 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -291,22 +291,27 @@ void V3Error::vlAbort() { VL_GCOV_DUMP(); std::abort(); } -void V3Error::v3errorAcquireLock() VL_ACQUIRE(s().m_mutex) { -#ifndef V3ERROR_NO_GLOBAL_ - V3Error::s().m_mutex.lockCheckStopRequest( - []() -> void { V3ThreadPool::s().waitIfStopRequested(); }); +void V3Error::v3errorAcquireLock(bool mtDisabledCodeUnit) VL_ACQUIRE(s().m_mutex) { +#if !defined(V3ERROR_NO_GLOBAL_) + if (!mtDisabledCodeUnit) { + V3Error::s().m_mutex.lockCheckStopRequest( + []() -> void { V3ThreadPool::s().waitIfStopRequested(); }); + } else { + V3Error::s().m_mutex.lock(); + } #else V3Error::s().m_mutex.lock(); #endif } -std::ostringstream& V3Error::v3errorPrep(V3ErrorCode code) VL_ACQUIRE(s().m_mutex) { - v3errorAcquireLock(); +std::ostringstream& V3Error::v3errorPrep(V3ErrorCode code, bool mtDisabledCodeUnit) + VL_ACQUIRE(s().m_mutex) { + v3errorAcquireLock(mtDisabledCodeUnit); s().v3errorPrep(code); return v3errorStr(); } -std::ostringstream& V3Error::v3errorPrepFileLine(V3ErrorCode code, const char* file, int line) - VL_ACQUIRE(s().m_mutex) { - v3errorPrep(code) << file << ":" << std::dec << line << ": "; +std::ostringstream& V3Error::v3errorPrepFileLine(V3ErrorCode code, const char* file, int line, + bool mtDisabledCodeUnit) VL_ACQUIRE(s().m_mutex) { + v3errorPrep(code, mtDisabledCodeUnit) << file << ":" << std::dec << line << ": "; return v3errorStr(); } std::ostringstream& V3Error::v3errorStr() VL_REQUIRES(s().m_mutex) { return s().v3errorStr(); } diff --git a/src/V3Error.h b/src/V3Error.h index b6c92e8af..87c6c0bad 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -24,7 +24,7 @@ // Limited V3 headers here - this is a base class for Vlc etc #include "V3String.h" -#ifndef V3ERROR_NO_GLOBAL_ +#ifndef VL_MT_DISABLED_CODE_UNIT #include "V3ThreadPool.h" #endif @@ -518,9 +518,11 @@ public: // Internals for v3error()/v3fatal() macros only // Error end takes the string stream to output, be careful to seek() as needed - static void v3errorAcquireLock() VL_ACQUIRE(s().m_mutex); - static std::ostringstream& v3errorPrep(V3ErrorCode code) VL_ACQUIRE(s().m_mutex); - static std::ostringstream& v3errorPrepFileLine(V3ErrorCode code, const char* file, int line) + static void v3errorAcquireLock(bool checkStopRequest) VL_ACQUIRE(s().m_mutex); + static std::ostringstream& v3errorPrep(V3ErrorCode code, bool mtDisabledCodeUnit) + VL_ACQUIRE(s().m_mutex); + static std::ostringstream& v3errorPrepFileLine(V3ErrorCode code, const char* file, int line, + bool mtDisabledCodeUnit) VL_ACQUIRE(s().m_mutex); static std::ostringstream& v3errorStr() VL_REQUIRES(s().m_mutex); // static, but often overridden in classes. @@ -530,8 +532,15 @@ public: }; // Global versions, so that if the class doesn't define an operator, we get the functions anyway. -void v3errorEnd(std::ostringstream& sstr) VL_RELEASE(V3Error::s().m_mutex); -void v3errorEndFatal(std::ostringstream& sstr) VL_RELEASE(V3Error::s().m_mutex) VL_ATTR_NORETURN; +void v3errorEnd(std::ostringstream& sstr) VL_RELEASE(V3Error::s().m_mutex) VL_MT_SAFE; +void v3errorEndFatal(std::ostringstream& sstr) + VL_RELEASE(V3Error::s().m_mutex) VL_MT_SAFE VL_ATTR_NORETURN; + +#ifdef VL_MT_DISABLED_CODE_UNIT +#define VL_MT_DISABLED_CODE_UNIT_DEFINED 1 +#else +#define VL_MT_DISABLED_CODE_UNIT_DEFINED 0 +#endif // Theses allow errors using << operators: v3error("foo"<<"bar"); // Careful, you can't put () around msg, as you would in most macro definitions. @@ -541,9 +550,12 @@ void v3errorEndFatal(std::ostringstream& sstr) VL_RELEASE(V3Error::s().m_mutex) // the comma operator (,) to guarantee the execution order here. #define v3errorBuildMessage(prep, msg) \ (prep, static_cast(V3Error::v3errorStr() << msg)) -#define v3warnCode(code, msg) v3errorEnd(v3errorBuildMessage(V3Error::v3errorPrep(code), msg)) +#define v3warnCode(code, msg) \ + v3errorEnd( \ + v3errorBuildMessage(V3Error::v3errorPrep(code, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg)) #define v3warnCodeFatal(code, msg) \ - v3errorEndFatal(v3errorBuildMessage(V3Error::v3errorPrep(code), msg)) + v3errorEndFatal( \ + v3errorBuildMessage(V3Error::v3errorPrep(code, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg)) #define v3warn(code, msg) v3warnCode(V3ErrorCode::code, msg) #define v3info(msg) v3warnCode(V3ErrorCode::EC_INFO, msg) #define v3error(msg) v3warnCode(V3ErrorCode::EC_ERROR, msg) @@ -553,10 +565,13 @@ void v3errorEndFatal(std::ostringstream& sstr) VL_RELEASE(V3Error::s().m_mutex) // Use this instead of fatal() to mention the source code line. #define v3fatalSrc(msg) \ v3errorEndFatal(v3errorBuildMessage( \ - V3Error::v3errorPrepFileLine(V3ErrorCode::EC_FATALSRC, __FILE__, __LINE__), msg)) + V3Error::v3errorPrepFileLine(V3ErrorCode::EC_FATALSRC, __FILE__, __LINE__, \ + VL_MT_DISABLED_CODE_UNIT_DEFINED), \ + msg)) // Use this when normal v3fatal is called in static method that overrides fileline. #define v3fatalStatic(msg) \ - ::v3errorEndFatal(v3errorBuildMessage(V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), msg)) + ::v3errorEndFatal(v3errorBuildMessage( \ + V3Error::v3errorPrep(V3ErrorCode::EC_FATAL, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg)) #define UINFO(level, stmsg) \ do { \ diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 7af734fe8..2bfe49c5a 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -25,6 +25,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Expand.h b/src/V3Expand.h index 01938f7a9..e3f8fc630 100644 --- a/src/V3Expand.h +++ b/src/V3Expand.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Expand final { public: - static void expandAll(AstNetlist* nodep); + static void expandAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Force.cpp b/src/V3Force.cpp index 464ea6237..51437482b 100644 --- a/src/V3Force.cpp +++ b/src/V3Force.cpp @@ -37,6 +37,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Force.h b/src/V3Force.h index 0318f80e3..647d6c813 100644 --- a/src/V3Force.h +++ b/src/V3Force.h @@ -21,13 +21,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Force final { public: - static void forceAll(AstNetlist* nodep); + static void forceAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Fork.cpp b/src/V3Fork.cpp index db64eda77..bce03b9fa 100644 --- a/src/V3Fork.cpp +++ b/src/V3Fork.cpp @@ -38,6 +38,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Fork.h b/src/V3Fork.h index e36b530cb..53bd6c19d 100644 --- a/src/V3Fork.h +++ b/src/V3Fork.h @@ -21,6 +21,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ @@ -29,10 +31,10 @@ class V3Fork final { public: // Move/copy variables to "anonymous" objects if their lifetime might exceed the scope of a // procedure that declared them. Update the references apropriately. - static void makeDynamicScopes(AstNetlist* nodep); + static void makeDynamicScopes(AstNetlist* nodep) VL_MT_DISABLED; // Create tasks out of blocks/statments that can outlive processes in which they were forked. // Return value: number of tasks created - static void makeTasks(AstNetlist* nodep); + static void makeTasks(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index b3811bce8..a1594e185 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Gate.h b/src/V3Gate.h index f4a03d3f0..f30c6f9a4 100644 --- a/src/V3Gate.h +++ b/src/V3Gate.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Gate final { public: - static void gateAll(AstNetlist* nodep); + static void gateAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Global.h b/src/V3Global.h index 90f8bc59b..a25a3f274 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -28,7 +28,9 @@ #include "V3Error.h" #include "V3FileLine.h" +#include "V3Mutex.h" #include "V3Options.h" +#include "V3ThreadSafety.h" #include #include @@ -127,6 +129,7 @@ public: V3Global() {} void boot(); void shutdown(); // Release allocated resources + // ACCESSORS (general) AstNetlist* rootp() const VL_MT_SAFE { return m_rootp; } VWidthMinUsage widthMinUsage() const { return m_widthMinUsage; } @@ -134,8 +137,8 @@ public: bool assertScoped() const { return m_assertScoped; } // METHODS - void readFiles(); - void removeStd(); + void readFiles() VL_MT_DISABLED; + void removeStd() VL_MT_DISABLED; void checkTree() const; static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0, bool doDump = true); diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 9eca82238..e8ab00441 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Graph.h b/src/V3Graph.h index 84dd4f85f..c8a01acfa 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -23,6 +23,7 @@ #include "V3Error.h" #include "V3List.h" #include "V3Rtti.h" +#include "V3ThreadSafety.h" #include @@ -88,19 +89,20 @@ protected: friend class V3GraphEdge; friend class GraphAcyc; // METHODS - double orderDFSIterate(V3GraphVertex* vertexp); - void dumpEdge(std::ostream& os, const V3GraphVertex* vertexp, const V3GraphEdge* edgep); + double orderDFSIterate(V3GraphVertex* vertexp) VL_MT_DISABLED; + void dumpEdge(std::ostream& os, const V3GraphVertex* vertexp, + const V3GraphEdge* edgep) VL_MT_DISABLED; void verticesUnlink() { m_vertices.reset(); } // ACCESSORS public: - V3Graph(); - virtual ~V3Graph(); + V3Graph() VL_MT_DISABLED; + virtual ~V3Graph() VL_MT_DISABLED; virtual string dotRankDir() const { return "TB"; } // rankdir for dot plotting // METHODS - void clear(); // Empty it of all vertices/edges, as if making a new object - void clearColors(); + void clear() VL_MT_DISABLED; // Empty it of all vertices/edges, as if making a new object + void clearColors() VL_MT_DISABLED; bool empty() const { return m_vertices.empty(); } V3GraphVertex* verticesBeginp() const { return m_vertices.begin(); } @@ -109,66 +111,69 @@ public: /// Assign same color to all vertices in the same weakly connected component /// Thus different color if there's no edges between the two subgraphs - void weaklyConnected(V3EdgeFuncP edgeFuncp); + void weaklyConnected(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; /// Assign same color to all vertices that are strongly connected /// Thus different color if there's no directional circuit within the subgraphs. /// (I.E. all loops will occur within each color, not between them.) - void stronglyConnected(V3EdgeFuncP edgeFuncp); + void stronglyConnected(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; /// Assign an ordering number to all vertexes in a tree. /// All nodes with no inputs will get rank 1 - void rank(V3EdgeFuncP edgeFuncp); - void rank(); + void rank(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; + void rank() VL_MT_DISABLED; /// Sort all vertices and edges using the V3GraphVertex::sortCmp() function - void sortVertices(); + void sortVertices() VL_MT_DISABLED; /// Sort all edges and edges using the V3GraphEdge::sortCmp() function - void sortEdges(); + void sortEdges() VL_MT_DISABLED; /// Order all vertices by rank and fanout, lowest first /// Sort all vertices by rank and fanout, lowest first /// Sort all edges by weight, lowest first /// Side-effect: assigns ranks to every node. - void order(); + void order() VL_MT_DISABLED; // Similar to order() but does not assign ranks. Caller must // ensure that the graph has been ranked ahead of the call. - void orderPreRanked(); + void orderPreRanked() VL_MT_DISABLED; /// Make acyclical (into a tree) by breaking a minimal subset of cutable edges. - void acyclic(V3EdgeFuncP edgeFuncp); + void acyclic(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; /// Remove any redundant edges, weights become MAX of any other weight - void removeRedundantEdges(V3EdgeFuncP edgeFuncp); + void removeRedundantEdges(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; /// Remove any redundant edges, weights become SUM of any other weight - void removeRedundantEdgesSum(V3EdgeFuncP edgeFuncp); + void removeRedundantEdgesSum(V3EdgeFuncP edgeFuncp) VL_MT_DISABLED; /// Remove any transitive edges. E.g. if have edges A->B, B->C, and A->C /// then A->C is a "transitive" edge; it's implied by the first two /// (assuming the DAG is a dependency graph.) /// This algorithm can be expensive. - void removeTransitiveEdges(); + void removeTransitiveEdges() VL_MT_DISABLED; /// Call loopsVertexCb on any one loop starting where specified - void reportLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp); + void reportLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp) VL_MT_DISABLED; /// Build a subgraph of all loops starting where specified - void subtreeLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp, V3Graph* loopGraphp); + void subtreeLoops(V3EdgeFuncP edgeFuncp, V3GraphVertex* vertexp, + V3Graph* loopGraphp) VL_MT_DISABLED; /// Debugging - void dump(std::ostream& os = std::cout); - void dumpDotFile(const string& filename, bool colorAsSubgraph) const; - void dumpDotFilePrefixed(const string& nameComment, bool colorAsSubgraph = false) const; - void dumpDotFilePrefixedAlways(const string& nameComment, bool colorAsSubgraph = false) const; - void userClearVertices(); - void userClearEdges(); - static void selfTest(); + void dump(std::ostream& os = std::cout) VL_MT_DISABLED; + void dumpDotFile(const string& filename, bool colorAsSubgraph) const VL_MT_DISABLED; + void dumpDotFilePrefixed(const string& nameComment, + bool colorAsSubgraph = false) const VL_MT_DISABLED; + void dumpDotFilePrefixedAlways(const string& nameComment, + bool colorAsSubgraph = false) const VL_MT_DISABLED; + void userClearVertices() VL_MT_DISABLED; + void userClearEdges() VL_MT_DISABLED; + static void selfTest() VL_MT_DISABLED; // CALLBACKS - virtual void loopsMessageCb(V3GraphVertex* vertexp); - virtual void loopsVertexCb(V3GraphVertex* vertexp); + virtual void loopsMessageCb(V3GraphVertex* vertexp) VL_MT_DISABLED; + virtual void loopsVertexCb(V3GraphVertex* vertexp) VL_MT_DISABLED; }; //============================================================================ @@ -192,24 +197,24 @@ protected: uint32_t m_user; // Marker for some algorithms }; // METHODS - void verticesPushBack(V3Graph* graphp); + void verticesPushBack(V3Graph* graphp) VL_MT_DISABLED; // ACCESSORS void fanout(double fanout) { m_fanout = fanout; } void inUnlink() { m_ins.reset(); } // Low level; normally unlinkDelete is what you want void outUnlink() { m_outs.reset(); } // Low level; normally unlinkDelete is what you want protected: // CONSTRUCTORS - V3GraphVertex(V3Graph* graphp, const V3GraphVertex& old); + V3GraphVertex(V3Graph* graphp, const V3GraphVertex& old) VL_MT_DISABLED; public: - explicit V3GraphVertex(V3Graph* graphp); + explicit V3GraphVertex(V3Graph* graphp) VL_MT_DISABLED; //! Clone copy constructor. Doesn't copy edges or user/userp. - virtual V3GraphVertex* clone(V3Graph* graphp) const { + virtual V3GraphVertex* clone(V3Graph* graphp) const VL_MT_DISABLED { return new V3GraphVertex{graphp, *this}; } virtual ~V3GraphVertex() = default; - void unlinkEdges(V3Graph* graphp); - void unlinkDelete(V3Graph* graphp); + void unlinkEdges(V3Graph* graphp) VL_MT_DISABLED; + void unlinkDelete(V3Graph* graphp) VL_MT_DISABLED; // METHODS // Return true iff of type T @@ -275,23 +280,24 @@ public: V3GraphVertex* verticesNextp() const { return m_vertices.nextp(); } V3GraphEdge* inBeginp() const { return m_ins.begin(); } bool inEmpty() const { return inBeginp() == nullptr; } - bool inSize1() const; + bool inSize1() const VL_MT_DISABLED; V3GraphEdge* outBeginp() const { return m_outs.begin(); } bool outEmpty() const { return outBeginp() == nullptr; } - bool outSize1() const; + bool outSize1() const VL_MT_DISABLED; V3GraphEdge* beginp(GraphWay way) const { return way.forward() ? outBeginp() : inBeginp(); } // METHODS /// Error reporting - void v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex); - void v3errorEndFatal(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex); + void v3errorEnd(std::ostringstream& str) const VL_RELEASE(V3Error::s().m_mutex) VL_MT_DISABLED; + void v3errorEndFatal(std::ostringstream& str) const + VL_RELEASE(V3Error::s().m_mutex) VL_MT_DISABLED; /// Edges are routed around this vertex to point from "from" directly to "to" - void rerouteEdges(V3Graph* graphp); + void rerouteEdges(V3Graph* graphp) VL_MT_DISABLED; /// Find the edge connecting ap and bp, where bp is wayward from ap. /// If edge is not found returns nullptr. O(edges) performance. - V3GraphEdge* findConnectingEdgep(GraphWay way, const V3GraphVertex* waywardp); + V3GraphEdge* findConnectingEdgep(GraphWay way, const V3GraphVertex* waywardp) VL_MT_DISABLED; }; -std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp); +std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp) VL_MT_DISABLED; //============================================================================ @@ -320,25 +326,26 @@ protected: }; // METHODS void init(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, - bool cutable = false); + bool cutable = false) VL_MT_DISABLED; void cut() { m_weight = 0; } // 0 weight is same as disconnected - void outPushBack(); - void inPushBack(); + void outPushBack() VL_MT_DISABLED; + void inPushBack() VL_MT_DISABLED; // CONSTRUCTORS protected: V3GraphEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, - const V3GraphEdge& old) { + const V3GraphEdge& old) VL_MT_DISABLED { init(graphp, fromp, top, old.m_weight, old.m_cutable); } public: //! Add DAG from one node to the specified node V3GraphEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, - bool cutable = false) { + bool cutable = false) VL_MT_DISABLED { init(graphp, fromp, top, weight, cutable); } //! Clone copy constructor. Doesn't copy existing vertices or user/userp. - virtual V3GraphEdge* clone(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) const { + virtual V3GraphEdge* clone(V3Graph* graphp, V3GraphVertex* fromp, + V3GraphVertex* top) const VL_MT_DISABLED { return new V3GraphEdge{graphp, fromp, top, *this}; } virtual ~V3GraphEdge() = default; @@ -384,9 +391,9 @@ public: if (!m_weight || !rhsp->m_weight) return 0; return top()->sortCmp(rhsp->top()); } - void unlinkDelete(); - V3GraphEdge* relinkFromp(V3GraphVertex* newFromp); - V3GraphEdge* relinkTop(V3GraphVertex* newTop); + void unlinkDelete() VL_MT_DISABLED; + V3GraphEdge* relinkFromp(V3GraphVertex* newFromp) VL_MT_DISABLED; + V3GraphEdge* relinkTop(V3GraphVertex* newTop) VL_MT_DISABLED; // ACCESSORS int weight() const { return m_weight; } void weight(int weight) { m_weight = weight; } diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 4b15ca3dd..968efd38b 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index 67a2f12b0..99b65dbc5 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3GraphPathChecker.cpp b/src/V3GraphPathChecker.cpp index f609652b0..21cd1493c 100644 --- a/src/V3GraphPathChecker.cpp +++ b/src/V3GraphPathChecker.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3GraphPathChecker.h b/src/V3GraphPathChecker.h index 620736ff1..c4326d129 100644 --- a/src/V3GraphPathChecker.h +++ b/src/V3GraphPathChecker.h @@ -20,6 +20,7 @@ #include "V3Error.h" #include "V3Graph.h" #include "V3GraphAlg.h" +#include "V3ThreadSafety.h" //###################################################################### @@ -39,21 +40,22 @@ class GraphPathChecker final : GraphAlg { public: // CONSTRUCTORS explicit GraphPathChecker(const V3Graph* graphp, - V3EdgeFuncP edgeFuncp = V3GraphEdge::followAlwaysTrue); - ~GraphPathChecker(); + V3EdgeFuncP edgeFuncp + = V3GraphEdge::followAlwaysTrue) VL_MT_DISABLED; + ~GraphPathChecker() VL_MT_DISABLED; // METHODS - bool pathExistsFrom(const V3GraphVertex* fromp, const V3GraphVertex* top); + bool pathExistsFrom(const V3GraphVertex* fromp, const V3GraphVertex* top) VL_MT_DISABLED; // If have edges A->B, B->C, and A->C then A->C is considered a // "transitive" edge (implied by A->B and B->C) and it could be safely // removed. Detect such an edge. - bool isTransitiveEdge(const V3GraphEdge* edgep); + bool isTransitiveEdge(const V3GraphEdge* edgep) VL_MT_DISABLED; private: bool pathExistsInternal(const V3GraphVertex* ap, const V3GraphVertex* bp, - unsigned* costp = nullptr); - void initHalfCriticalPaths(GraphWay way, bool checkOnly); + unsigned* costp = nullptr) VL_MT_DISABLED; + void initHalfCriticalPaths(GraphWay way, bool checkOnly) VL_MT_DISABLED; void incGeneration() { ++m_generation; } VL_UNCOPYABLE(GraphPathChecker); diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index 0550e73c1..1635bfc6a 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 8c234cac2..331c8cbc9 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -72,6 +72,8 @@ // Used for b) and c). // This options is repeated for all instantiating hierarchical blocks. +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "V3HierBlock.h" #include "V3Ast.h" diff --git a/src/V3HierBlock.h b/src/V3HierBlock.h index 02842a62d..33310209f 100644 --- a/src/V3HierBlock.h +++ b/src/V3HierBlock.h @@ -19,7 +19,8 @@ #include "verilatedos.h" -#include "V3Global.h" +#include "V3Options.h" +#include "V3ThreadSafety.h" #include #include @@ -56,13 +57,13 @@ private: // METHODS VL_UNCOPYABLE(V3HierBlock); - static StrGParams stringifyParams(const GParams& gparams, bool forGOption); + static StrGParams stringifyParams(const GParams& gparams, bool forGOption) VL_MT_DISABLED; public: V3HierBlock(const AstNodeModule* modp, const GParams& gparams) : m_modp{modp} , m_gparams{gparams} {} - ~V3HierBlock(); + ~V3HierBlock() VL_MT_DISABLED; void addParent(V3HierBlock* parentp) { m_parents.insert(parentp); } void addChild(V3HierBlock* childp) { m_children.insert(childp); } @@ -73,19 +74,19 @@ public: const AstNodeModule* modp() const { return m_modp; } // For emitting Makefile and CMakeLists.txt - V3StringList commandArgs(bool forCMake) const; - V3StringList hierBlockArgs() const; - string hierPrefix() const; - string hierSomeFile(bool withDir, const char* prefix, const char* suffix) const; - string hierWrapper(bool withDir) const; - string hierMk(bool withDir) const; - string hierLib(bool withDir) const; - string hierGenerated(bool withDir) const; + V3StringList commandArgs(bool forCMake) const VL_MT_DISABLED; + V3StringList hierBlockArgs() const VL_MT_DISABLED; + string hierPrefix() const VL_MT_DISABLED; + string hierSomeFile(bool withDir, const char* prefix, const char* suffix) const VL_MT_DISABLED; + string hierWrapper(bool withDir) const VL_MT_DISABLED; + string hierMk(bool withDir) const VL_MT_DISABLED; + string hierLib(bool withDir) const VL_MT_DISABLED; + string hierGenerated(bool withDir) const VL_MT_DISABLED; // Returns the original HDL file if it is not included in v3Global.opt.vFiles(). - string vFileIfNecessary() const; + string vFileIfNecessary() const VL_MT_DISABLED; // Write command line arguments to .f file for this hierarchical block - void writeCommandArgsFile(bool forCMake) const; - string commandArgsFileName(bool forCMake) const; + void writeCommandArgsFile(bool forCMake) const VL_MT_DISABLED; + string commandArgsFileName(bool forCMake) const VL_MT_DISABLED; }; //###################################################################### @@ -103,8 +104,8 @@ public: using const_iterator = HierMap::const_iterator; using HierVector = std::vector; - void add(const AstNodeModule* modp, const std::vector& gparams); - void registerUsage(const AstNodeModule* parentp, const AstNodeModule* childp); + void add(const AstNodeModule* modp, const std::vector& gparams) VL_MT_DISABLED; + void registerUsage(const AstNodeModule* parentp, const AstNodeModule* childp) VL_MT_DISABLED; const_iterator begin() const { return m_blocks.begin(); } const_iterator end() const { return m_blocks.end(); } @@ -112,13 +113,13 @@ public: // Returns all hierarchical blocks that sorted in leaf-first order. // Latter block refers only already appeared hierarchical blocks. - HierVector hierBlocksSorted() const; + HierVector hierBlocksSorted() const VL_MT_DISABLED; // Write command line arguments to .f files for child Verilation run - void writeCommandArgsFiles(bool forCMake) const; - static string topCommandArgsFileName(bool forCMake); + void writeCommandArgsFiles(bool forCMake) const VL_MT_DISABLED; + static string topCommandArgsFileName(bool forCMake) VL_MT_DISABLED; - static void createPlan(AstNetlist* nodep); + static void createPlan(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // guard diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 09e486a12..996e9d9bf 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Inline.h b/src/V3Inline.h index dc5264ad1..1f347b139 100644 --- a/src/V3Inline.h +++ b/src/V3Inline.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Inline final { public: - static void inlineAll(AstNetlist* nodep); + static void inlineAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 0b96463e5..5f0455714 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Inst.h b/src/V3Inst.h index 6cfce8f77..8baccb465 100644 --- a/src/V3Inst.h +++ b/src/V3Inst.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstAssignW; class AstCell; class AstNetlist; @@ -29,11 +31,11 @@ class AstPin; class V3Inst final { public: - static void instAll(AstNetlist* nodep); - static void dearrayAll(AstNetlist* nodep); + static void instAll(AstNetlist* nodep) VL_MT_DISABLED; + static void dearrayAll(AstNetlist* nodep) VL_MT_DISABLED; static AstAssignW* pinReconnectSimple(AstPin* pinp, AstCell* cellp, bool forTristate, - bool alwaysCvt = false); - static void checkOutputShort(AstPin* nodep); + bool alwaysCvt = false) VL_MT_DISABLED; + static void checkOutputShort(AstPin* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index c236da288..7e363ba17 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -15,6 +15,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3InstrCount.h b/src/V3InstrCount.h index 279885616..fc4978439 100644 --- a/src/V3InstrCount.h +++ b/src/V3InstrCount.h @@ -21,6 +21,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNode; class V3InstrCount final { @@ -38,7 +40,8 @@ public: // if we see the same node twice (across more than one call to count, // potentially) raises an error. // Optional osp is stream to dump critical path to. - static uint32_t count(AstNode* nodep, bool assertNoDups, std::ostream* osp = nullptr); + static uint32_t count(AstNode* nodep, bool assertNoDups, + std::ostream* osp = nullptr) VL_MT_DISABLED; }; #endif // guard diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 0b5f83122..a20c17252 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Life.h b/src/V3Life.h index fa4291519..024f4e7c8 100644 --- a/src/V3Life.h +++ b/src/V3Life.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Life final { public: - static void lifeAll(AstNetlist* nodep); + static void lifeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index f62882369..35728e5de 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LifePost.h b/src/V3LifePost.h index ddf92c555..01042ce38 100644 --- a/src/V3LifePost.h +++ b/src/V3LifePost.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3LifePost final { public: - static void lifepostAll(AstNetlist* nodep); + static void lifepostAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 6087999b3..d98a9158b 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -23,6 +23,8 @@ // Link to module that instantiates it //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkCells.h b/src/V3LinkCells.h index eab1a73fe..dbaecd2be 100644 --- a/src/V3LinkCells.h +++ b/src/V3LinkCells.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; class VInFilter; class V3ParseSym; @@ -28,7 +30,7 @@ class V3ParseSym; class V3LinkCells final { public: - static void link(AstNetlist* nodep, VInFilter* filterp, V3ParseSym* parseSymp); + static void link(AstNetlist* nodep, VInFilter* filterp, V3ParseSym* parseSymp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index d9751b87a..7ea95b46f 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -61,6 +61,8 @@ // b (VSymEnt->AstCell) //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkDot.h b/src/V3LinkDot.h index 14af04e82..5e3667210 100644 --- a/src/V3LinkDot.h +++ b/src/V3LinkDot.h @@ -22,19 +22,20 @@ #include "V3Ast.h" #include "V3Error.h" +#include "V3ThreadSafety.h" //============================================================================ enum VLinkDotStep : uint8_t { LDS_PRIMARY, LDS_PARAMED, LDS_ARRAYED, LDS_SCOPED }; class V3LinkDot final { - static void linkDotGuts(AstNetlist* rootp, VLinkDotStep step); + static void linkDotGuts(AstNetlist* rootp, VLinkDotStep step) VL_MT_DISABLED; public: - static void linkDotPrimary(AstNetlist* nodep); - static void linkDotParamed(AstNetlist* nodep); - static void linkDotArrayed(AstNetlist* nodep); - static void linkDotScope(AstNetlist* nodep); + static void linkDotPrimary(AstNetlist* nodep) VL_MT_DISABLED; + static void linkDotParamed(AstNetlist* nodep) VL_MT_DISABLED; + static void linkDotArrayed(AstNetlist* nodep) VL_MT_DISABLED; + static void linkDotScope(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index 164f005c2..49b775ab9 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -36,6 +36,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkInc.h b/src/V3LinkInc.h index 1b5a6ff55..b41807437 100644 --- a/src/V3LinkInc.h +++ b/src/V3LinkInc.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3LinkInc final { public: - static void linkIncrements(AstNetlist* nodep); + static void linkIncrements(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index b7785e975..68807a097 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -29,6 +29,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkJump.h b/src/V3LinkJump.h index 598cd98bc..48b919f8a 100644 --- a/src/V3LinkJump.h +++ b/src/V3LinkJump.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3LinkJump final { public: - static void linkJump(AstNetlist* nodep); + static void linkJump(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index 6ba79865f..9431731a3 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -18,6 +18,8 @@ // Set lvalue() attributes on appropriate VARREFs. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkLValue.h b/src/V3LinkLValue.h index 16656936d..26cbaa4e3 100644 --- a/src/V3LinkLValue.h +++ b/src/V3LinkLValue.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; class AstNode; @@ -27,8 +29,8 @@ class AstNode; class V3LinkLValue final { public: - static void linkLValue(AstNetlist* nodep); - static void linkLValueSet(AstNode* nodep); + static void linkLValue(AstNetlist* nodep) VL_MT_DISABLED; + static void linkLValueSet(AstNode* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 03ba5bf96..dbb0631da 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -19,6 +19,8 @@ // Create new MODULE TOP with connections to below signals //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkLevel.h b/src/V3LinkLevel.h index c1b1c6354..aa86a2b82 100644 --- a/src/V3LinkLevel.h +++ b/src/V3LinkLevel.h @@ -22,6 +22,7 @@ #include "V3Ast.h" #include "V3Error.h" +#include "V3ThreadSafety.h" #include @@ -31,13 +32,13 @@ class V3LinkLevel final { private: using ModVec = std::vector; - static void timescaling(const ModVec& mods); - static void wrapTopCell(AstNetlist* rootp); - static void wrapTopPackages(AstNetlist* rootp); + static void timescaling(const ModVec& mods) VL_MT_DISABLED; + static void wrapTopCell(AstNetlist* rootp) VL_MT_DISABLED; + static void wrapTopPackages(AstNetlist* rootp) VL_MT_DISABLED; public: - static void modSortByLevel(); - static void wrapTop(AstNetlist* rootp); + static void modSortByLevel() VL_MT_DISABLED; + static void wrapTop(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 00b9ea3aa..48a5cf0e4 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -18,6 +18,8 @@ // Move some attributes around //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkParse.h b/src/V3LinkParse.h index df57d97d2..5694c4396 100644 --- a/src/V3LinkParse.h +++ b/src/V3LinkParse.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3LinkParse final { public: - static void linkParse(AstNetlist* rootp); + static void linkParse(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 187d84028..e3767407c 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -24,6 +24,8 @@ // SenItems: Convert pos/negedge of non-simple signals to temporaries //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3LinkResolve.h b/src/V3LinkResolve.h index 929c36452..0588f8e7a 100644 --- a/src/V3LinkResolve.h +++ b/src/V3LinkResolve.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3LinkResolve final { public: - static void linkResolve(AstNetlist* rootp); + static void linkResolve(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 586e8940e..16500e84d 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -22,6 +22,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Localize.h b/src/V3Localize.h index 65d369214..ee4e62e6d 100644 --- a/src/V3Localize.h +++ b/src/V3Localize.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Localize final { public: - static void localizeAll(AstNetlist* nodep); + static void localizeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 52c6a4dfa..5598a5cdf 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -72,6 +72,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3MergeCond.h b/src/V3MergeCond.h index 07d41e538..4510e4572 100644 --- a/src/V3MergeCond.h +++ b/src/V3MergeCond.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3MergeCond final { public: - static void mergeAll(AstNetlist* nodep); + static void mergeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Name.cpp b/src/V3Name.cpp index fc532f498..56896ef58 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -19,6 +19,8 @@ // Prepend __PVT__ to variable names //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Name.h b/src/V3Name.h index f51fdac0b..cb2781378 100644 --- a/src/V3Name.h +++ b/src/V3Name.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Name final { public: - static void nameAll(AstNetlist* nodep); + static void nameAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Number_test.cpp b/src/V3Number_test.cpp index fd0887d8b..1d7898013 100644 --- a/src/V3Number_test.cpp +++ b/src/V3Number_test.cpp @@ -17,6 +17,7 @@ // CHEAT! #define V3NUMBER_ASCII_BINARY #define V3ERROR_NO_GLOBAL_ +#define VL_MT_DISABLED_CODE_UNIT 1 #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp index 8d9f41b2c..ea245400e 100644 --- a/src/V3OptionParser.cpp +++ b/src/V3OptionParser.cpp @@ -15,6 +15,8 @@ //************************************************************************* #ifndef V3OPTION_PARSER_NO_VOPTION_BOOL +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "V3Global.h" #include "V3Options.h" #endif diff --git a/src/V3OptionParser.h b/src/V3OptionParser.h index cc22b8f0a..6975bd844 100644 --- a/src/V3OptionParser.h +++ b/src/V3OptionParser.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + #include #include #include @@ -64,25 +66,27 @@ private: const std::unique_ptr m_pimpl; // METHODS - ActionIfs* find(const char* optp); + ActionIfs* find(const char* optp) VL_MT_DISABLED; template - ActionIfs& add(const string& opt, ARG arg); - static bool hasPrefixFNo(const char* strp); // Returns true if strp starts with "-fno" - static bool hasPrefixNo(const char* strp); // Returns true if strp starts with "-no" + ActionIfs& add(const string& opt, ARG arg) VL_MT_DISABLED; + // Returns true if strp starts with "-fno" + static bool hasPrefixFNo(const char* strp) VL_MT_DISABLED; + // Returns true if strp starts with "-no" + static bool hasPrefixNo(const char* strp) VL_MT_DISABLED; public: // METHODS // Returns how many args are consumed. 0 means not match - int parse(int idx, int argc, char* argv[]); + int parse(int idx, int argc, char* argv[]) VL_MT_DISABLED; // Find the most similar option - string getSuggestion(const char* str) const; - void addSuggestionCandidate(const string& s); + string getSuggestion(const char* str) const VL_MT_DISABLED; + void addSuggestionCandidate(const string& s) VL_MT_DISABLED; // Call this function after all options are registered. - void finalize(); + void finalize() VL_MT_DISABLED; // CONSTRUCTORS - V3OptionParser(); - ~V3OptionParser(); + V3OptionParser() VL_MT_DISABLED; + ~V3OptionParser() VL_MT_DISABLED; }; class V3OptionParser::ActionIfs VL_NOT_FINAL { @@ -121,29 +125,33 @@ private: public: // METHODS - ActionIfs& operator()(const char* optp, Set, bool*) const; + ActionIfs& operator()(const char* optp, Set, bool*) const VL_MT_DISABLED; #ifndef V3OPTION_PARSER_NO_VOPTION_BOOL - ActionIfs& operator()(const char* optp, Set, VOptionBool*) const; + ActionIfs& operator()(const char* optp, Set, VOptionBool*) const VL_MT_DISABLED; #endif - ActionIfs& operator()(const char* optp, Set, int*) const; - ActionIfs& operator()(const char* optp, Set, string*) const; + ActionIfs& operator()(const char* optp, Set, int*) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, Set, string*) const VL_MT_DISABLED; - ActionIfs& operator()(const char* optp, FOnOff, bool*) const; - ActionIfs& operator()(const char* optp, OnOff, bool*) const; + ActionIfs& operator()(const char* optp, FOnOff, bool*) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, OnOff, bool*) const VL_MT_DISABLED; #ifndef V3OPTION_PARSER_NO_VOPTION_BOOL - ActionIfs& operator()(const char* optp, OnOff, VOptionBool*) const; + ActionIfs& operator()(const char* optp, OnOff, VOptionBool*) const VL_MT_DISABLED; #endif - ActionIfs& operator()(const char* optp, CbCall, std::function) const; - ActionIfs& operator()(const char* optp, CbFOnOff, std::function) const; - ActionIfs& operator()(const char* optp, CbOnOff, std::function) const; - ActionIfs& operator()(const char* optp, CbVal, std::function) const; - ActionIfs& operator()(const char* optp, CbVal, std::function) const; + ActionIfs& operator()(const char* optp, CbCall, + std::function) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, CbFOnOff, + std::function) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, CbOnOff, + std::function) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, CbVal, std::function) const VL_MT_DISABLED; + ActionIfs& operator()(const char* optp, CbVal, + std::function) const VL_MT_DISABLED; ActionIfs& operator()(const char* optp, CbPartialMatch, - std::function) const; + std::function) const VL_MT_DISABLED; ActionIfs& operator()(const char* optp, CbPartialMatchVal, - std::function) const; + std::function) const VL_MT_DISABLED; // CONSTRUCTORS explicit AppendHelper(V3OptionParser& parser) diff --git a/src/V3Options.cpp b/src/V3Options.cpp index bc08b0256..42e33a040 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -292,7 +292,7 @@ void V3Options::addLangExt(const string& langext, const V3LangCode& lc) { m_impp->addLangExt(langext, lc); } void V3Options::addLibExtV(const string& libext) { m_impp->addLibExtV(libext); } -void V3Options::addDefine(const string& defline, bool allowPlus) { +void V3Options::addDefine(const string& defline, bool allowPlus) VL_MT_DISABLED { // Split +define+foo=value into the appropriate parts and parse // Optional + says to allow multiple defines on the line // + is not quotable, as other simulators do not allow that @@ -792,7 +792,7 @@ bool V3Options::coroutineSupport() { //###################################################################### // V3 Options notification methods -void V3Options::notify() { +void V3Options::notify() VL_MT_DISABLED { // Notify that all arguments have been passed and final modification can be made. FileLine* const cmdfl = new FileLine{FileLine::commandLineFilename()}; @@ -978,7 +978,7 @@ string V3Options::argString(int argc, char** argv) { //###################################################################### // V3 Options Parsing -void V3Options::parseOpts(FileLine* fl, int argc, char** argv) { +void V3Options::parseOpts(FileLine* fl, int argc, char** argv) VL_MT_DISABLED { // Parse all options // Initial entry point from Verilator.cpp parseOptsList(fl, ".", argc, argv); @@ -1009,7 +1009,8 @@ bool V3Options::suffixed(const string& sw, const char* arg) { return (0 == std::strcmp(sw.c_str() + sw.length() - std::strlen(arg), arg)); } -void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv) { +void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, + char** argv) VL_MT_DISABLED { // Parse parameters // Note argc and argv DO NOT INCLUDE the filename in [0]!!! // May be called recursively when there are -f files. @@ -1057,7 +1058,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char // (If DECL_OPTION is a macro, then lambda would be collapsed into a single line). // Plus options - DECL_OPTION("+define+", CbPartialMatch, [this](const char* optp) { addDefine(optp, true); }); + DECL_OPTION("+define+", CbPartialMatch, + [this](const char* optp) VL_MT_DISABLED { addDefine(optp, true); }); DECL_OPTION("+incdir+", CbPartialMatch, [this, &optdir](const char* optp) { addIncDirUser(parseFileArg(optdir, optp)); }); DECL_OPTION("+libext+", CbPartialMatch, [this](const char* optp) { @@ -1159,7 +1161,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-coverage-underscore", OnOff, &m_coverageUnderscore); DECL_OPTION("-coverage-user", OnOff, &m_coverageUser); - DECL_OPTION("-D", CbPartialMatch, [this](const char* valp) { addDefine(valp, false); }); + DECL_OPTION("-D", CbPartialMatch, + [this](const char* valp) VL_MT_DISABLED { addDefine(valp, false); }); DECL_OPTION("-debug", CbCall, [this]() { setDebugMode(3); }); DECL_OPTION("-debugi", CbVal, [this](int v) { setDebugMode(v); }); DECL_OPTION("-debugi-", CbPartialMatchVal, [this](const char* optp, const char* valp) { @@ -1199,12 +1202,12 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-expand-limit", CbVal, [this](const char* valp) { m_expandLimit = std::atoi(valp); }); - DECL_OPTION("-F", CbVal, [this, fl, &optdir](const char* valp) { + DECL_OPTION("-F", CbVal, [this, fl, &optdir](const char* valp) VL_MT_DISABLED { parseOptsFile(fl, parseFileArg(optdir, valp), true); }); DECL_OPTION("-FI", CbVal, [this, &optdir](const char* valp) { addForceInc(parseFileArg(optdir, valp)); }); - DECL_OPTION("-f", CbVal, [this, fl, &optdir](const char* valp) { + DECL_OPTION("-f", CbVal, [this, fl, &optdir](const char* valp) VL_MT_DISABLED { parseOptsFile(fl, parseFileArg(optdir, valp), false); }); DECL_OPTION("-flatten", OnOff, &m_flatten); @@ -1604,7 +1607,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char // Note it may not be a future option, but one that is currently implemented. addFuture(optp); }); - DECL_OPTION("-Wno-", CbPartialMatch, [fl, &parser](const char* optp) { + DECL_OPTION("-Wno-", CbPartialMatch, [fl, &parser](const char* optp) VL_MT_DISABLED { if (!FileLine::globalWarnOff(optp, true)) { const string fullopt = std::string{"-Wno-"} + optp; fl->v3fatal("Unknown warning specified: " << fullopt @@ -1624,7 +1627,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-Wno-style", CbCall, []() { FileLine::globalWarnStyleOff(true); }); DECL_OPTION("-Wno-UNUSED", CbCall, []() { FileLine::globalWarnUnusedOff(true); }); DECL_OPTION("-Wno-WIDTH", CbCall, []() { FileLine::globalWarnOff(V3ErrorCode::WIDTH, true); }); - DECL_OPTION("-Wwarn-", CbPartialMatch, [this, fl, &parser](const char* optp) { + DECL_OPTION("-Wwarn-", CbPartialMatch, [this, fl, &parser](const char* optp) VL_MT_DISABLED { const V3ErrorCode code{optp}; if (code == V3ErrorCode::EC_ERROR) { if (!isFuture(optp)) { @@ -1741,7 +1744,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char //====================================================================== -void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { +void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) VL_MT_DISABLED { // Read the specified -f filename and process as arguments UINFO(1, "Reading Options File " << filename << endl); diff --git a/src/V3Options.h b/src/V3Options.h index f9ee897bb..6378c8545 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -22,6 +22,7 @@ #include "V3Error.h" #include "V3LangCode.h" +#include "V3ThreadSafety.h" #include #include @@ -385,7 +386,7 @@ private: private: // METHODS void addArg(const string& arg); - void addDefine(const string& defline, bool allowPlus); + void addDefine(const string& defline, bool allowPlus) VL_MT_DISABLED; void addFuture(const string& flag); void addFuture0(const string& flag); void addFuture1(const string& flag); @@ -426,7 +427,7 @@ public: void addForceInc(const string& filename); bool available() const VL_MT_SAFE { return m_available; } void ccSet(); - void notify(); + void notify() VL_MT_DISABLED; // ACCESSORS (options) bool preprocOnly() const { return m_preprocOnly; } @@ -666,9 +667,9 @@ public: // Return options for child hierarchical blocks when forTop==false, otherwise returns args for // the top module. string allArgsStringForHierBlock(bool forTop) const; - void parseOpts(FileLine* fl, int argc, char** argv); - void parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv); - void parseOptsFile(FileLine* fl, const string& filename, bool rel); + void parseOpts(FileLine* fl, int argc, char** argv) VL_MT_DISABLED; + void parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv) VL_MT_DISABLED; + void parseOptsFile(FileLine* fl, const string& filename, bool rel) VL_MT_DISABLED; // METHODS (environment) // Most of these may be built into the executable with --enable-defenv, diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 066d5d5b4..f0047b81e 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -71,6 +71,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Order.h b/src/V3Order.h index be2612371..3262e0ed8 100644 --- a/src/V3Order.h +++ b/src/V3Order.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + #include #include #include @@ -48,7 +50,7 @@ AstCFunc* order( bool parallel, // bool slow, // const ExternalDomainsProvider& externalDomains - = [](const AstVarScope*, std::vector&) {}); + = [](const AstVarScope*, std::vector&) {}) VL_MT_DISABLED; }; // namespace V3Order diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index af6788d6e..fef667f5b 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -92,10 +92,14 @@ public: // Methods to add edges representing constraints, utilizing the type system to help us ensure // the graph remains bipartite. - inline void addHardEdge(OrderLogicVertex* fromp, OrderVarVertex* top, int weight); - inline void addHardEdge(OrderVarVertex* fromp, OrderLogicVertex* top, int weight); - inline void addSoftEdge(OrderLogicVertex* fromp, OrderVarVertex* top, int weight); - inline void addSoftEdge(OrderVarVertex* fromp, OrderLogicVertex* top, int weight); + inline void addHardEdge(OrderLogicVertex* fromp, OrderVarVertex* top, + int weight) VL_MT_DISABLED; + inline void addHardEdge(OrderVarVertex* fromp, OrderLogicVertex* top, + int weight) VL_MT_DISABLED; + inline void addSoftEdge(OrderLogicVertex* fromp, OrderVarVertex* top, + int weight) VL_MT_DISABLED; + inline void addSoftEdge(OrderVarVertex* fromp, OrderLogicVertex* top, + int weight) VL_MT_DISABLED; }; //====================================================================== @@ -114,9 +118,9 @@ class OrderEitherVertex VL_NOT_FINAL : public V3GraphVertex { protected: // CONSTRUCTOR - OrderEitherVertex(OrderGraph* graphp, AstSenTree* domainp) - : V3GraphVertex{graphp} - , m_domainp{domainp} {} + OrderEitherVertex(OrderGraph* graphp, AstSenTree* domainp) VL_MT_DISABLED + : V3GraphVertex{graphp}, + m_domainp{domainp} {} ~OrderEitherVertex() override = default; public: @@ -125,7 +129,7 @@ public: // ACCESSORS AstSenTree* domainp() const VL_MT_STABLE { return m_domainp; } - void domainp(AstSenTree* domainp) { + void domainp(AstSenTree* domainp) VL_MT_DISABLED { #if VL_DEBUG UASSERT(!m_domainp, "Domain should only be set once"); #endif @@ -142,11 +146,11 @@ class OrderLogicVertex final : public OrderEitherVertex { public: // CONSTRUCTOR OrderLogicVertex(OrderGraph* graphp, AstScope* scopep, AstSenTree* domainp, - AstSenTree* hybridp, AstNode* nodep) - : OrderEitherVertex{graphp, domainp} - , m_nodep{nodep} - , m_scopep{scopep} - , m_hybridp{hybridp} { + AstSenTree* hybridp, AstNode* nodep) VL_MT_DISABLED + : OrderEitherVertex{graphp, domainp}, + m_nodep{nodep}, + m_scopep{scopep}, + m_hybridp{hybridp} { UASSERT_OBJ(scopep, nodep, "Must not be null"); UASSERT_OBJ(!(domainp && hybridp), nodep, "Cannot have bot domainp and hybridp set"); } @@ -174,9 +178,9 @@ class OrderVarVertex VL_NOT_FINAL : public OrderEitherVertex { public: // CONSTRUCTOR - OrderVarVertex(OrderGraph* graphp, AstVarScope* vscp) - : OrderEitherVertex{graphp, nullptr} - , m_vscp{vscp} {} + OrderVarVertex(OrderGraph* graphp, AstVarScope* vscp) VL_MT_DISABLED + : OrderEitherVertex{graphp, nullptr}, + m_vscp{vscp} {} ~OrderVarVertex() override = default; // ACCESSORS @@ -195,7 +199,7 @@ class OrderVarStdVertex final : public OrderVarVertex { VL_RTTI_IMPL(OrderVarStdVertex, OrderVarVertex) public: // CONSTRUCTOR - OrderVarStdVertex(OrderGraph* graphp, AstVarScope* vscp) + OrderVarStdVertex(OrderGraph* graphp, AstVarScope* vscp) VL_MT_DISABLED : OrderVarVertex{graphp, vscp} {} ~OrderVarStdVertex() override = default; @@ -212,7 +216,7 @@ class OrderVarPreVertex final : public OrderVarVertex { VL_RTTI_IMPL(OrderVarPreVertex, OrderVarVertex) public: // CONSTRUCTOR - OrderVarPreVertex(OrderGraph* graphp, AstVarScope* vscp) + OrderVarPreVertex(OrderGraph* graphp, AstVarScope* vscp) VL_MT_DISABLED : OrderVarVertex{graphp, vscp} {} ~OrderVarPreVertex() override = default; @@ -229,7 +233,7 @@ class OrderVarPostVertex final : public OrderVarVertex { VL_RTTI_IMPL(OrderVarPostVertex, OrderVarVertex) public: // CONSTRUCTOR - OrderVarPostVertex(OrderGraph* graphp, AstVarScope* vscp) + OrderVarPostVertex(OrderGraph* graphp, AstVarScope* vscp) VL_MT_DISABLED : OrderVarVertex{graphp, vscp} {} ~OrderVarPostVertex() override = default; @@ -246,7 +250,7 @@ class OrderVarPordVertex final : public OrderVarVertex { VL_RTTI_IMPL(OrderVarPordVertex, OrderVarVertex) public: // CONSTRUCTOR - OrderVarPordVertex(OrderGraph* graphp, AstVarScope* vscp) + OrderVarPordVertex(OrderGraph* graphp, AstVarScope* vscp) VL_MT_DISABLED : OrderVarVertex{graphp, vscp} {} ~OrderVarPordVertex() override = default; @@ -267,8 +271,7 @@ class OrderEdge final : public V3GraphEdge { friend class OrderGraph; // Only the OrderGraph can create these // CONSTRUCTOR OrderEdge(OrderGraph* graphp, OrderEitherVertex* fromp, OrderEitherVertex* top, int weight, - bool cutable) - : V3GraphEdge{graphp, fromp, top, weight, cutable} {} + bool cutable) VL_MT_DISABLED : V3GraphEdge{graphp, fromp, top, weight, cutable} {} ~OrderEdge() override = default; // LCOV_EXCL_START // Debug code @@ -279,16 +282,20 @@ class OrderEdge final : public V3GraphEdge { //====================================================================== // Inline methods -void OrderGraph::addHardEdge(OrderLogicVertex* fromp, OrderVarVertex* top, int weight) { +void OrderGraph::addHardEdge(OrderLogicVertex* fromp, OrderVarVertex* top, + int weight) VL_MT_DISABLED { new OrderEdge{this, fromp, top, weight, /* cutable: */ false}; } -void OrderGraph::addHardEdge(OrderVarVertex* fromp, OrderLogicVertex* top, int weight) { +void OrderGraph::addHardEdge(OrderVarVertex* fromp, OrderLogicVertex* top, + int weight) VL_MT_DISABLED { new OrderEdge{this, fromp, top, weight, /* cutable: */ false}; } -void OrderGraph::addSoftEdge(OrderLogicVertex* fromp, OrderVarVertex* top, int weight) { +void OrderGraph::addSoftEdge(OrderLogicVertex* fromp, OrderVarVertex* top, + int weight) VL_MT_DISABLED { new OrderEdge{this, fromp, top, weight, /* cutable: */ true}; } -void OrderGraph::addSoftEdge(OrderVarVertex* fromp, OrderLogicVertex* top, int weight) { +void OrderGraph::addSoftEdge(OrderVarVertex* fromp, OrderLogicVertex* top, + int weight) VL_MT_DISABLED { new OrderEdge{this, fromp, top, weight, /* cutable: */ true}; } diff --git a/src/V3OrderMoveGraph.h b/src/V3OrderMoveGraph.h index af5da4df0..2404e9730 100644 --- a/src/V3OrderMoveGraph.h +++ b/src/V3OrderMoveGraph.h @@ -27,6 +27,7 @@ #include "V3Ast.h" #include "V3Graph.h" #include "V3OrderGraph.h" +#include "V3ThreadSafety.h" #include @@ -49,11 +50,11 @@ protected: V3ListEnt m_readyVerticesE; // List of ready under domain/scope public: // CONSTRUCTORS - OrderMoveVertex(V3Graph* graphp, OrderLogicVertex* logicp) - : V3GraphVertex{graphp} - , m_logicp{logicp} - , m_state{POM_WAIT} - , m_domScopep{nullptr} {} + OrderMoveVertex(V3Graph* graphp, OrderLogicVertex* logicp) VL_MT_DISABLED + : V3GraphVertex{graphp}, + m_logicp{logicp}, + m_state{POM_WAIT}, + m_domScopep{nullptr} {} ~OrderMoveVertex() override = default; // METHODS @@ -78,11 +79,11 @@ public: } OrderLogicVertex* logicp() const VL_MT_STABLE { return m_logicp; } bool isWait() const { return m_state == POM_WAIT; } - void setReady() { + void setReady() VL_MT_DISABLED { UASSERT(m_state == POM_WAIT, "Wait->Ready on node not in proper state"); m_state = POM_READY; } - void setMoved() { + void setMoved() VL_MT_DISABLED { UASSERT(m_state == POM_READY, "Ready->Moved on node not in proper state"); m_state = POM_MOVED; } @@ -103,11 +104,10 @@ class MTaskMoveVertex final : public V3GraphVertex { public: MTaskMoveVertex(V3Graph* graphp, OrderLogicVertex* logicp, const OrderEitherVertex* varp, - const AstSenTree* domainp) - : V3GraphVertex{graphp} - , m_logicp{logicp} - , m_varp{varp} - , m_domainp{domainp} { + const AstSenTree* domainp) VL_MT_DISABLED : V3GraphVertex{graphp}, + m_logicp{logicp}, + m_varp{varp}, + m_domainp{domainp} { UASSERT(!(logicp && varp), "MTaskMoveVertex: logicp and varp may not both be set!\n"); } ~MTaskMoveVertex() override = default; diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 1539ce3c4..ce5ded6a8 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -44,6 +44,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Param.h b/src/V3Param.h index bf4fbe16d..d09a4314c 100644 --- a/src/V3Param.h +++ b/src/V3Param.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Param final { public: - static void param(AstNetlist* rootp); + static void param(AstNetlist* rootp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Parse.h b/src/V3Parse.h index ed034d36b..70e7b4896 100644 --- a/src/V3Parse.h +++ b/src/V3Parse.h @@ -22,6 +22,7 @@ #include "V3Error.h" #include "V3Global.h" +#include "V3ThreadSafety.h" class AstNetlist; class VInFilter; @@ -39,16 +40,16 @@ private: public: // We must allow reading multiple files into one parser - V3Parse(AstNetlist* rootp, VInFilter* filterp, V3ParseSym* symp); - ~V3Parse(); + V3Parse(AstNetlist* rootp, VInFilter* filterp, V3ParseSym* symp) VL_MT_DISABLED; + ~V3Parse() VL_MT_DISABLED; // METHODS // Preprocess and read the Verilog file specified into the netlist database void parseFile(FileLine* fileline, const string& modname, bool inLibrary, - const string& errmsg); + const string& errmsg) VL_MT_DISABLED; // Push preprocessed text to the lexer - static void ppPushText(V3ParseImp* impp, const string& text); + static void ppPushText(V3ParseImp* impp, const string& text) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3ParseGrammar.cpp b/src/V3ParseGrammar.cpp index 74b729abc..10be43782 100644 --- a/src/V3ParseGrammar.cpp +++ b/src/V3ParseGrammar.cpp @@ -16,6 +16,8 @@ #define YYDEBUG 1 // Nicer errors +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "V3Ast.h" // This must be before V3ParseBison.cpp, as we don't want #defines to conflict VL_DEFINE_DEBUG_FUNCTIONS; diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index c7e2e62b4..1da582004 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -22,6 +22,8 @@ // V3Lexer.yy.cpp Flex output //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 9017c0ae6..743b4ec14 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -25,6 +25,7 @@ #include "V3Global.h" #include "V3Parse.h" #include "V3ParseSym.h" +#include "V3ThreadSafety.h" #include #include @@ -123,7 +124,7 @@ struct V3ParseBisonYYSType { #include "V3Ast__gen_yystype.h" }; }; -std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs); +std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs) VL_MT_DISABLED; #define YYSTYPE V3ParseBisonYYSType @@ -170,21 +171,21 @@ public: void tagNodep(AstNode* nodep) { m_tagNodep = nodep; } AstNode* tagNodep() const { return m_tagNodep; } - void lexTimescaleParse(FileLine* fl, const char* textp); + void lexTimescaleParse(FileLine* fl, const char* textp) VL_MT_DISABLED; void timescaleMod(FileLine* fl, AstNodeModule* modp, bool unitSet, double unitVal, - bool precSet, double precVal); + bool precSet, double precVal) VL_MT_DISABLED; VTimescale timeLastUnit() const { return m_timeLastUnit; } FileLine* lexFileline() const { return m_lexFileline; } FileLine* lexCopyOrSameFileLine() { return lexFileline()->copyOrSameFileLine(); } - static void lexErrorPreprocDirective(FileLine* fl, const char* textp); - static string lexParseTag(const char* textp); - static double lexParseTimenum(const char* text); - void lexPpline(const char* textp); - void lexVerilatorCmtLint(FileLine* fl, const char* textp, bool warnOff); - void lexVerilatorCmtLintSave(const FileLine* fl); - void lexVerilatorCmtLintRestore(FileLine* fl); - static void lexVerilatorCmtBad(FileLine* fl, const char* textp); + static void lexErrorPreprocDirective(FileLine* fl, const char* textp) VL_MT_DISABLED; + static string lexParseTag(const char* textp) VL_MT_DISABLED; + static double lexParseTimenum(const char* text) VL_MT_DISABLED; + void lexPpline(const char* textp) VL_MT_DISABLED; + void lexVerilatorCmtLint(FileLine* fl, const char* textp, bool warnOff) VL_MT_DISABLED; + void lexVerilatorCmtLintSave(const FileLine* fl) VL_MT_DISABLED; + void lexVerilatorCmtLintRestore(FileLine* fl) VL_MT_DISABLED; + static void lexVerilatorCmtBad(FileLine* fl, const char* textp) VL_MT_DISABLED; void lexPushKeywords(int state) { ++m_lexKwdDepth; @@ -199,14 +200,14 @@ public: } } int lexKwdLastState() const { return m_lexKwdLast; } - static const char* tokenName(int tok); - static bool isStrengthToken(int tok); + static const char* tokenName(int tok) VL_MT_DISABLED; + static bool isStrengthToken(int tok) VL_MT_DISABLED; void ppPushText(const string& text) { m_ppBuffers.push_back(text); if (lexFileline()->contentp()) lexFileline()->contentp()->pushText(text); } - size_t ppInputToLex(char* buf, size_t max_size); + size_t ppInputToLex(char* buf, size_t max_size) VL_MT_DISABLED; static V3ParseImp* parsep() { return s_parsep; } @@ -248,12 +249,12 @@ public: void unconnectedDrive(const VOptionBool flag) { m_unconnectedDrive = flag; } // Interactions with parser - int bisonParse(); + int bisonParse() VL_MT_DISABLED; // Interactions with lexer - void lexNew(); - void lexDestroy(); - static int stateVerilogRecent(); // Parser -> lexer communication + void lexNew() VL_MT_DISABLED; + void lexDestroy() VL_MT_DISABLED; + static int stateVerilogRecent() VL_MT_DISABLED; // Parser -> lexer communication int lexPrevToken() const { return m_lexPrevToken; } // Parser -> lexer communication size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf, max_size); } @@ -282,28 +283,29 @@ public: m_lexKwdLast = stateVerilogRecent(); m_timeLastUnit = v3Global.opt.timeDefaultUnit(); } - ~V3ParseImp(); - void parserClear(); - void lexUnputString(const char* textp, size_t length); + ~V3ParseImp() VL_MT_DISABLED; + void parserClear() VL_MT_DISABLED; + void lexUnputString(const char* textp, size_t length) VL_MT_DISABLED; // METHODS // Preprocess and read the Verilog file specified into the netlist database - int tokenToBison(); // Pass token to bison + int tokenToBison() VL_MT_DISABLED; // Pass token to bison void parseFile(FileLine* fileline, const string& modfilename, bool inLibrary, - const string& errmsg); - void dumpInputsFile(); + const string& errmsg) VL_MT_DISABLED; + void dumpInputsFile() VL_MT_DISABLED; private: - void lexFile(const string& modname); - void yylexReadTok(); - void tokenPull(); - void tokenPipeline(); // Internal; called from tokenToBison - void tokenPipelineSym(); - size_t tokenPipeScanParam(size_t depth); - size_t tokenPipeScanType(size_t depth); - const V3ParseBisonYYSType* tokenPeekp(size_t depth); - void preprocDumps(std::ostream& os, bool forInputs); + void preprocDumps(std::ostream& os); + void lexFile(const string& modname) VL_MT_DISABLED; + void yylexReadTok() VL_MT_DISABLED; + void tokenPull() VL_MT_DISABLED; + void tokenPipeline() VL_MT_DISABLED; // Internal; called from tokenToBison + void tokenPipelineSym() VL_MT_DISABLED; + size_t tokenPipeScanParam(size_t depth) VL_MT_DISABLED; + size_t tokenPipeScanType(size_t depth) VL_MT_DISABLED; + const V3ParseBisonYYSType* tokenPeekp(size_t depth) VL_MT_DISABLED; + void preprocDumps(std::ostream& os, bool forInputs) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3ParseLex.cpp b/src/V3ParseLex.cpp index 43ae1fb53..bb39e3a59 100644 --- a/src/V3ParseLex.cpp +++ b/src/V3ParseLex.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index a67f92d7b..d2e27a85b 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Partition.h b/src/V3Partition.h index cfa68c515..caac97371 100644 --- a/src/V3Partition.h +++ b/src/V3Partition.h @@ -23,6 +23,7 @@ #include "V3Graph.h" #include "V3OrderGraph.h" #include "V3OrderMoveGraph.h" +#include "V3ThreadSafety.h" #include #include @@ -51,24 +52,24 @@ public: // Fill in the provided empty graph with AbstractLogicMTask's and their // interdependencies. - void go(V3Graph* mtasksp); + void go(V3Graph* mtasksp) VL_MT_DISABLED; - static void selfTest(); - static void selfTestNormalizeCosts(); + static void selfTest() VL_MT_DISABLED; + static void selfTestNormalizeCosts() VL_MT_DISABLED; // Print out a hash of the shape of graphp. Only needed to debug the // origin of some nondeterminism; otherwise this is pretty useless. - static void hashGraphDebug(const V3Graph* graphp, const char* debugName); + static void hashGraphDebug(const V3Graph* graphp, const char* debugName) VL_MT_DISABLED; // Print debug stats about graphp whose nodes must be AbstractMTask's. - static void debugMTaskGraphStats(const V3Graph* graphp, const string& stage); + static void debugMTaskGraphStats(const V3Graph* graphp, const string& stage) VL_MT_DISABLED; // Operate on the final ExecMTask graph, immediately prior to code // generation time. - static void finalize(AstNetlist* netlistp); + static void finalize(AstNetlist* netlistp) VL_MT_DISABLED; private: - uint32_t setupMTaskDeps(V3Graph* mtasksp); + uint32_t setupMTaskDeps(V3Graph* mtasksp) VL_MT_DISABLED; VL_UNCOPYABLE(V3Partition); }; diff --git a/src/V3PartitionGraph.h b/src/V3PartitionGraph.h index eb1455e2a..cdfab1be1 100644 --- a/src/V3PartitionGraph.h +++ b/src/V3PartitionGraph.h @@ -31,8 +31,7 @@ class AbstractMTask VL_NOT_FINAL : public V3GraphVertex { VL_RTTI_IMPL(AbstractMTask, V3GraphVertex) public: - explicit AbstractMTask(V3Graph* graphp) - : V3GraphVertex{graphp} {} + explicit AbstractMTask(V3Graph* graphp) VL_MT_DISABLED : V3GraphVertex{graphp} {} ~AbstractMTask() override = default; virtual uint32_t id() const = 0; virtual uint32_t cost() const = 0; @@ -44,8 +43,7 @@ public: // TYPES using VxList = std::list; // CONSTRUCTORS - explicit AbstractLogicMTask(V3Graph* graphp) - : AbstractMTask{graphp} {} + explicit AbstractLogicMTask(V3Graph* graphp) VL_MT_DISABLED : AbstractMTask{graphp} {} ~AbstractLogicMTask() override = default; // METHODS // Set of logic vertices in this mtask. Order is not significant. @@ -70,10 +68,10 @@ private: VL_UNCOPYABLE(ExecMTask); public: - ExecMTask(V3Graph* graphp, AstMTaskBody* bodyp, uint32_t id) - : AbstractMTask{graphp} - , m_bodyp{bodyp} - , m_id{id} {} + ExecMTask(V3Graph* graphp, AstMTaskBody* bodyp, uint32_t id) VL_MT_DISABLED + : AbstractMTask{graphp}, + m_bodyp{bodyp}, + m_id{id} {} AstMTaskBody* bodyp() const { return m_bodyp; } uint32_t id() const override VL_MT_SAFE { return m_id; } uint32_t priority() const { return m_priority; } diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index cea6db1f2..075d677d2 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3PreProc.h b/src/V3PreProc.h index f13ef98ed..13d4aefad 100644 --- a/src/V3PreProc.h +++ b/src/V3PreProc.h @@ -23,6 +23,7 @@ #include "V3Error.h" #include "V3FileLine.h" #include "V3Global.h" +#include "V3ThreadSafety.h" #include #include @@ -57,7 +58,7 @@ public: virtual bool isEof() const = 0; // Return true on EOF. virtual void insertUnreadback(const string& text) = 0; - FileLine* fileline(); ///< File/Line number for last getline call + FileLine* fileline() VL_MT_DISABLED; ///< File/Line number for last getline call // CONTROL METHODS // These options control how the parsing proceeds @@ -96,7 +97,7 @@ protected: void configure(FileLine* fl); public: - static V3PreProc* createPreProc(FileLine* fl); + static V3PreProc* createPreProc(FileLine* fl) VL_MT_DISABLED; virtual ~V3PreProc() = default; // LCOV_EXCL_LINE // Persistent }; diff --git a/src/V3PreShell.cpp b/src/V3PreShell.cpp index 087b25a75..fc48e1f62 100644 --- a/src/V3PreShell.cpp +++ b/src/V3PreShell.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3PreShell.h b/src/V3PreShell.h index eb6a426cd..6972d5a67 100644 --- a/src/V3PreShell.h +++ b/src/V3PreShell.h @@ -22,6 +22,7 @@ #include "V3Error.h" #include "V3FileLine.h" +#include "V3ThreadSafety.h" class V3ParseImp; class VInFilter; @@ -32,15 +33,15 @@ class VSpellCheck; class V3PreShell final { // Static class for calling preprocessor public: - static void boot(); - static void shutdown(); + static void boot() VL_MT_DISABLED; + static void shutdown() VL_MT_DISABLED; static bool preproc(FileLine* fl, const string& modname, VInFilter* filterp, - V3ParseImp* parsep, const string& errmsg); - static void preprocInclude(FileLine* fl, const string& modname); - static void defineCmdLine(const string& name, const string& value); - static void undef(const string& name); - static void dumpDefines(std::ostream& os); - static void candidateDefines(VSpellCheck* spellerp); + V3ParseImp* parsep, const string& errmsg) VL_MT_DISABLED; + static void preprocInclude(FileLine* fl, const string& modname) VL_MT_DISABLED; + static void defineCmdLine(const string& name, const string& value) VL_MT_DISABLED; + static void undef(const string& name) VL_MT_DISABLED; + static void dumpDefines(std::ostream& os) VL_MT_DISABLED; + static void candidateDefines(VSpellCheck* spellerp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 39dbdb9ad..78a748543 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Premit.h b/src/V3Premit.h index 59f09a188..e625392f0 100644 --- a/src/V3Premit.h +++ b/src/V3Premit.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Premit final { public: - static void premitAll(AstNetlist* nodep); + static void premitAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index 3a993714a..08a415395 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3ProtectLib.h b/src/V3ProtectLib.h index a3db9ea8c..7c1361573 100644 --- a/src/V3ProtectLib.h +++ b/src/V3ProtectLib.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3ProtectLib final { public: - static void protect(); + static void protect() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 983ecf98a..b544690d1 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Randomize.h b/src/V3Randomize.h index 223575203..5de300667 100644 --- a/src/V3Randomize.h +++ b/src/V3Randomize.h @@ -20,16 +20,18 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstClass; class AstFunc; class AstNetlist; class V3Randomize final { public: - static void randomizeNetlist(AstNetlist* nodep); + static void randomizeNetlist(AstNetlist* nodep) VL_MT_DISABLED; - static AstFunc* newRandomizeFunc(AstClass* nodep); - static AstFunc* newSRandomFunc(AstClass* nodep); + static AstFunc* newRandomizeFunc(AstClass* nodep) VL_MT_DISABLED; + static AstFunc* newSRandomFunc(AstClass* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 284c0df36..b50f21b67 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -29,6 +29,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Reloop.h b/src/V3Reloop.h index da9228510..4408bcb8d 100644 --- a/src/V3Reloop.h +++ b/src/V3Reloop.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Reloop final { public: - static void reloopAll(AstNetlist* nodep); + static void reloopAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Sched.cpp b/src/V3Sched.cpp index 897cb6343..32386e38b 100644 --- a/src/V3Sched.cpp +++ b/src/V3Sched.cpp @@ -35,6 +35,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Sched.h b/src/V3Sched.h index 526525a37..fca742de4 100644 --- a/src/V3Sched.h +++ b/src/V3Sched.h @@ -21,6 +21,7 @@ #include "verilatedos.h" #include "V3Ast.h" +#include "V3ThreadSafety.h" #include #include @@ -130,12 +131,12 @@ public: AstNodeStmt* m_postUpdates = nullptr; // Post updates for the trigger eval function // Remaps external domains using the specified trigger map - std::map> - remapDomains(const std::unordered_map& trigMap) const; + std::map> remapDomains( + const std::unordered_map& trigMap) const VL_MT_DISABLED; // Creates a timing resume call (if needed, else returns null) - AstCCall* createResume(AstNetlist* const netlistp); + AstCCall* createResume(AstNetlist* const netlistp) VL_MT_DISABLED; // Creates a timing commit call (if needed, else returns null) - AstCCall* createCommit(AstNetlist* const netlistp); + AstCCall* createCommit(AstNetlist* const netlistp) VL_MT_DISABLED; TimingKit() = default; TimingKit(LogicByScope&& lbs, AstNodeStmt* postUpdates, @@ -149,19 +150,20 @@ public: }; // Creates the timing kit and marks variables written by suspendables -TimingKit prepareTiming(AstNetlist* const netlistp); +TimingKit prepareTiming(AstNetlist* const netlistp) VL_MT_DISABLED; // Transforms fork sub-statements into separate functions -void transformForks(AstNetlist* const netlistp); +void transformForks(AstNetlist* const netlistp) VL_MT_DISABLED; // Top level entry point to scheduling -void schedule(AstNetlist*); +void schedule(AstNetlist*) VL_MT_DISABLED; // Sub-steps -LogicByScope breakCycles(AstNetlist* netlistp, const LogicByScope& combinationalLogic); +LogicByScope breakCycles(AstNetlist* netlistp, + const LogicByScope& combinationalLogic) VL_MT_DISABLED; LogicRegions partition(LogicByScope& clockedLogic, LogicByScope& combinationalLogic, - LogicByScope& hybridLogic); -LogicReplicas replicateLogic(LogicRegions&); + LogicByScope& hybridLogic) VL_MT_DISABLED; +LogicReplicas replicateLogic(LogicRegions&) VL_MT_DISABLED; } // namespace V3Sched diff --git a/src/V3SchedAcyclic.cpp b/src/V3SchedAcyclic.cpp index 1416bc2e4..d6d9d73ce 100644 --- a/src/V3SchedAcyclic.cpp +++ b/src/V3SchedAcyclic.cpp @@ -33,6 +33,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3SchedPartition.cpp b/src/V3SchedPartition.cpp index 6299813b2..c7c3fb29b 100644 --- a/src/V3SchedPartition.cpp +++ b/src/V3SchedPartition.cpp @@ -34,6 +34,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3SchedReplicate.cpp b/src/V3SchedReplicate.cpp index e47e2fad8..037fd3593 100644 --- a/src/V3SchedReplicate.cpp +++ b/src/V3SchedReplicate.cpp @@ -34,6 +34,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3SchedTiming.cpp b/src/V3SchedTiming.cpp index ca7e45626..c3ffa9ef6 100644 --- a/src/V3SchedTiming.cpp +++ b/src/V3SchedTiming.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 8156ec1e3..c68b14fe8 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Scope.h b/src/V3Scope.h index 3a6e6b2c6..5e5760554 100644 --- a/src/V3Scope.h +++ b/src/V3Scope.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Scope final { public: - static void scopeAll(AstNetlist* nodep); + static void scopeAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Scoreboard.cpp b/src/V3Scoreboard.cpp index 761ba9f94..5d25cdf76 100644 --- a/src/V3Scoreboard.cpp +++ b/src/V3Scoreboard.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Scoreboard.h b/src/V3Scoreboard.h index 796183ef6..27573b8d2 100644 --- a/src/V3Scoreboard.h +++ b/src/V3Scoreboard.h @@ -22,6 +22,7 @@ #include "V3Error.h" #include "V3PairingHeap.h" +#include "V3ThreadSafety.h" //=============================================================================================== // V3Scoreboard is essentially a heap that can be hinted that some elements have changed keys, at @@ -139,7 +140,7 @@ public: // ###################################################################### namespace V3ScoreboardBase { -void selfTest(); +void selfTest() VL_MT_DISABLED; } // namespace V3ScoreboardBase #endif // Guard diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 968a16571..3282e9ef2 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -35,6 +35,8 @@ // simplified to look primarily for SLICESELs. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Slice.h b/src/V3Slice.h index 002c31443..5eefd784c 100644 --- a/src/V3Slice.h +++ b/src/V3Slice.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Slice final { public: - static void sliceAll(AstNetlist* nodep); + static void sliceAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 1e6b82801..aa0ac31f0 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -77,6 +77,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Split.h b/src/V3Split.h index e0978405d..e3eff188f 100644 --- a/src/V3Split.h +++ b/src/V3Split.h @@ -20,14 +20,16 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Split final { public: - static void splitReorderAll(AstNetlist* nodep); - static void splitAlwaysAll(AstNetlist* nodep); + static void splitReorderAll(AstNetlist* nodep) VL_MT_DISABLED; + static void splitAlwaysAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index f67263dd7..80be47d77 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3SplitAs.h b/src/V3SplitAs.h index 7d692813d..528695564 100644 --- a/src/V3SplitAs.h +++ b/src/V3SplitAs.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3SplitAs final { public: - static void splitAsAll(AstNetlist* nodep); + static void splitAsAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index dc62dc823..34779a573 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -110,6 +110,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3SplitVar.h b/src/V3SplitVar.h index 2d2c525a5..d3f47afb6 100644 --- a/src/V3SplitVar.h +++ b/src/V3SplitVar.h @@ -19,17 +19,19 @@ //============================================================================ +#include "V3ThreadSafety.h" + class AstNetlist; class AstVar; class V3SplitVar final { public: // Split variables marked with split_var metacomment. - static void splitVariable(AstNetlist* nodep); + static void splitVariable(AstNetlist* nodep) VL_MT_DISABLED; // Return true if the variable can be split. // This check is not perfect. - static bool canSplitVar(const AstVar* varp); + static bool canSplitVar(const AstVar* varp) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 79aa116a6..b214a860f 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -22,6 +22,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Subst.h b/src/V3Subst.h index de7e09381..5320e4c3c 100644 --- a/src/V3Subst.h +++ b/src/V3Subst.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Subst final { public: - static void substituteAll(AstNetlist* nodep); + static void substituteAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 09774b8fc..cdc296c45 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -19,6 +19,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3TSP.h b/src/V3TSP.h index ea698c62a..91a31d7ed 100644 --- a/src/V3TSP.h +++ b/src/V3TSP.h @@ -22,6 +22,7 @@ #include "verilatedos.h" #include "V3Error.h" +#include "V3ThreadSafety.h" #include @@ -49,9 +50,9 @@ using StateVec = std::vector; // Given an unsorted set of TspState's, sort them to minimize // the transition cost for walking the sorted list. -void tspSort(const StateVec& states, StateVec* resultp); +void tspSort(const StateVec& states, StateVec* resultp) VL_MT_DISABLED; -void selfTest(); +void selfTest() VL_MT_DISABLED; } // namespace V3TSP #endif // Guard diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 6e1c4d6db..ec9bb4167 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -21,6 +21,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Table.h b/src/V3Table.h index 08eaf62b7..40c43657b 100644 --- a/src/V3Table.h +++ b/src/V3Table.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Table final { public: - static void tableAll(AstNetlist* nodep); + static void tableAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 7586795a0..576342885 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Task.h b/src/V3Task.h index 8dea5bee7..feea7e17e 100644 --- a/src/V3Task.h +++ b/src/V3Task.h @@ -22,6 +22,7 @@ #include "V3Ast.h" #include "V3Error.h" +#include "V3ThreadSafety.h" #include #include @@ -51,19 +52,20 @@ class V3Task final { static const char* const s_dpiTemporaryVarSuffix; public: - static void taskAll(AstNetlist* nodep); + static void taskAll(AstNetlist* nodep) VL_MT_DISABLED; /// Return vector of [port, pin-connects-to] (SLOW) static V3TaskConnects taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp, - V3TaskConnectState* statep = nullptr); + V3TaskConnectState* statep = nullptr) VL_MT_DISABLED; static void taskConnectWrap(AstNodeFTaskRef* nodep, const V3TaskConnects& tconnects, V3TaskConnectState* statep, - const std::set& argWrap); + const std::set& argWrap) VL_MT_DISABLED; static AstNodeFTask* taskConnectWrapNew(AstNodeFTask* taskp, const string& newname, const V3TaskConnects& tconnects, - const std::set& argWrap); + const std::set& argWrap) VL_MT_DISABLED; static string assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSuffix, - const string& toSuffix, const string& frPrefix = ""); - static string assignDpiToInternal(const string& lhsName, AstVar* rhsp); + const string& toSuffix, + const string& frPrefix = "") VL_MT_DISABLED; + static string assignDpiToInternal(const string& lhsName, AstVar* rhsp) VL_MT_DISABLED; static const char* dpiTemporaryVarSuffix() VL_MT_SAFE { return s_dpiTemporaryVarSuffix; } }; diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index ba5fb36e1..6a10731b6 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -44,6 +44,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Timing.h b/src/V3Timing.h index 784b5cddf..271583793 100644 --- a/src/V3Timing.h +++ b/src/V3Timing.h @@ -21,12 +21,13 @@ #include "verilatedos.h" #include "V3Ast.h" +#include "V3ThreadSafety.h" //============================================================================ class V3Timing final { public: - static void timingAll(AstNetlist* nodep); + static void timingAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index abd9b5ffd..c698e1f99 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -35,6 +35,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Trace.h b/src/V3Trace.h index 4e89805e3..214f71a33 100644 --- a/src/V3Trace.h +++ b/src/V3Trace.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Trace final { public: - static void traceAll(AstNetlist* nodep); + static void traceAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index e06a7f02b..d7c69efc7 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -20,6 +20,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3TraceDecl.h b/src/V3TraceDecl.h index 0922e842f..91ca6cad7 100644 --- a/src/V3TraceDecl.h +++ b/src/V3TraceDecl.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3TraceDecl final { public: - static void traceDeclAll(AstNetlist* nodep); + static void traceDeclAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index ded800d65..f13c1dfa0 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -115,6 +115,8 @@ // unsupported. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Tristate.h b/src/V3Tristate.h index 2b8a22c64..0fff67827 100644 --- a/src/V3Tristate.h +++ b/src/V3Tristate.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Tristate final { public: - static void tristateAll(AstNetlist* nodep); + static void tristateAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 84e7aba35..ece583f21 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -23,6 +23,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Undriven.h b/src/V3Undriven.h index a93e7fc1a..30c107598 100644 --- a/src/V3Undriven.h +++ b/src/V3Undriven.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Undriven final { public: - static void undrivenAll(AstNetlist* nodep); + static void undrivenAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 5a5c6d969..4ad6c78b9 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -28,6 +28,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Unknown.h b/src/V3Unknown.h index 24af14faa..912152836 100644 --- a/src/V3Unknown.h +++ b/src/V3Unknown.h @@ -20,13 +20,15 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; //============================================================================ class V3Unknown final { public: - static void unknownAll(AstNetlist* nodep); + static void unknownAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 6655001d1..59a6efa7b 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -24,6 +24,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3Unroll.h b/src/V3Unroll.h index 4abf47241..c13e99a58 100644 --- a/src/V3Unroll.h +++ b/src/V3Unroll.h @@ -22,6 +22,7 @@ #include "V3Ast.h" #include "V3Error.h" +#include "V3ThreadSafety.h" //============================================================================ /// Unroller with saved state, so caller can determine when pushDelete's are executed. @@ -35,18 +36,18 @@ class UnrollStateful final { public: // CONSTRUCTORS - UnrollStateful(); - ~UnrollStateful(); + UnrollStateful() VL_MT_DISABLED; + ~UnrollStateful() VL_MT_DISABLED; // METHODS - void unrollGen(AstNodeFor* nodep, const string& beginName); - void unrollAll(AstNetlist* nodep); + void unrollGen(AstNodeFor* nodep, const string& beginName) VL_MT_DISABLED; + void unrollAll(AstNetlist* nodep) VL_MT_DISABLED; }; //============================================================================ class V3Unroll final { public: - static void unrollAll(AstNetlist* nodep); + static void unrollAll(AstNetlist* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index e108e1605..707a8d391 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -20,6 +20,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/V3VariableOrder.h b/src/V3VariableOrder.h index 5dc7b274e..33cc55cec 100644 --- a/src/V3VariableOrder.h +++ b/src/V3VariableOrder.h @@ -20,11 +20,13 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + //============================================================================ class V3VariableOrder final { public: - static void orderAll(); + static void orderAll() VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 1e2be1013..3cc703257 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -63,6 +63,8 @@ // iterateSubtreeReturnEdits. //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" @@ -124,7 +126,8 @@ std::ostream& operator<<(std::ostream& str, const Castable& rhs) { v3errorEnd( \ v3errorBuildMessage(V3Error::v3errorPrep((lhs) < (rhs) ? V3ErrorCode::WIDTHTRUNC \ : (lhs) > (rhs) ? V3ErrorCode::WIDTHEXPAND \ - : V3ErrorCode::WIDTH), \ + : V3ErrorCode::WIDTH, \ + VL_MT_DISABLED_CODE_UNIT), \ msg)) //###################################################################### diff --git a/src/V3Width.h b/src/V3Width.h index 497c0bd23..29021146f 100644 --- a/src/V3Width.h +++ b/src/V3Width.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + class AstNetlist; class AstNode; class AstNodeDType; @@ -28,18 +30,18 @@ class AstNodeDType; class V3Width final { public: - static void width(AstNetlist* nodep); - static AstNode* widthParamsEdit(AstNode* nodep); - static AstNode* widthGenerateParamsEdit(AstNode* nodep); + static void width(AstNetlist* nodep) VL_MT_DISABLED; + static AstNode* widthParamsEdit(AstNode* nodep) VL_MT_DISABLED; + static AstNode* widthGenerateParamsEdit(AstNode* nodep) VL_MT_DISABLED; // Final step... Mark all widths as equal - static void widthCommit(AstNetlist* nodep); + static void widthCommit(AstNetlist* nodep) VL_MT_DISABLED; - static AstNodeDType* getCommonClassTypep(AstNode* nodep1, AstNode* nodep2); + static AstNodeDType* getCommonClassTypep(AstNode* nodep1, AstNode* nodep2) VL_MT_DISABLED; // For use only in WidthVisitor // Replace AstSelBit, etc with AstSel/AstArraySel // Returns replacement node if nodep was deleted, or null if none. - static AstNode* widthSelNoIterEdit(AstNode* nodep); + static AstNode* widthSelNoIterEdit(AstNode* nodep) VL_MT_DISABLED; }; #endif // Guard diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 96c88a2d5..c15d64add 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -26,6 +26,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #include "verilatedos.h" diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 1e98874b8..10b0fb06d 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_CONTROL_CODE_UNIT 1 + #include "V3Active.h" #include "V3ActiveTop.h" #include "V3Assert.h" @@ -116,479 +118,490 @@ static void reportStatsIfEnabled() { } static void process() { - // Sort modules by level so later algorithms don't need to care - V3LinkLevel::modSortByLevel(); - V3Error::abortIfErrors(); - if (v3Global.opt.debugExitParse()) { - cout << "--debug-exit-parse: Exiting after parse\n"; - std::exit(0); - } - - // Convert parseref's to varrefs, and other directly post parsing fixups - V3LinkParse::linkParse(v3Global.rootp()); - // Cross-link signal names - // Cross-link dotted hierarchical references - V3LinkDot::linkDotPrimary(v3Global.rootp()); - v3Global.checkTree(); // Force a check, as link is most likely place for problems - // Check if all parameters have been found - v3Global.opt.checkParameters(); - // Correct state we couldn't know at parse time, repair SEL's - V3LinkResolve::linkResolve(v3Global.rootp()); - // Set Lvalue's in variable refs - V3LinkLValue::linkLValue(v3Global.rootp()); - // Convert return/continue/disable to jumps - V3LinkJump::linkJump(v3Global.rootp()); - // Convert --/++ to normal operations. Must be after LinkJump. - V3LinkInc::linkIncrements(v3Global.rootp()); - V3Error::abortIfErrors(); - - if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "Link"); - if (v3Global.opt.debugExitUvm23()) { + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + // Sort modules by level so later algorithms don't need to care + V3LinkLevel::modSortByLevel(); V3Error::abortIfErrors(); - if (v3Global.opt.xmlOnly()) V3EmitXml::emitxml(); - cout << "--debug-exit-uvm23: Exiting after UVM-supported pass\n"; - std::exit(0); - } - - // Remove parameters by cloning modules to de-parameterized versions - // This requires some width calculations and constant propagation - V3Param::param(v3Global.rootp()); - V3LinkDot::linkDotParamed(v3Global.rootp()); // Cleanup as made new modules - V3LinkLValue::linkLValue(v3Global.rootp()); // Resolve new VarRefs - V3Error::abortIfErrors(); - - // Remove any modules that were parameterized and are no longer referenced. - V3Dead::deadifyModules(v3Global.rootp()); - v3Global.checkTree(); - - // Create a hierarchical Verilation plan - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.hierarchical()) { - V3HierBlockPlan::createPlan(v3Global.rootp()); - // If a plan is created, further analysis is not necessary. - // The actual Verilation will be done based on this plan. - if (v3Global.hierPlanp()) { - reportStatsIfEnabled(); - return; + if (v3Global.opt.debugExitParse()) { + cout << "--debug-exit-parse: Exiting after parse\n"; + std::exit(0); } - } - if (v3Global.opt.debugExitUvm()) { + + // Convert parseref's to varrefs, and other directly post parsing fixups + V3LinkParse::linkParse(v3Global.rootp()); + // Cross-link signal names + // Cross-link dotted hierarchical references + V3LinkDot::linkDotPrimary(v3Global.rootp()); + v3Global.checkTree(); // Force a check, as link is most likely place for problems + // Check if all parameters have been found + v3Global.opt.checkParameters(); + // Correct state we couldn't know at parse time, repair SEL's + V3LinkResolve::linkResolve(v3Global.rootp()); + // Set Lvalue's in variable refs + V3LinkLValue::linkLValue(v3Global.rootp()); + // Convert return/continue/disable to jumps + V3LinkJump::linkJump(v3Global.rootp()); + // Convert --/++ to normal operations. Must be after LinkJump. + V3LinkInc::linkIncrements(v3Global.rootp()); V3Error::abortIfErrors(); - if (v3Global.opt.xmlOnly()) V3EmitXml::emitxml(); - cout << "--debug-exit-uvm: Exiting after UVM-supported pass\n"; - std::exit(0); - } - // Calculate and check widths, edit tree to TRUNC/EXTRACT any width mismatches - V3Width::width(v3Global.rootp()); - - V3Error::abortIfErrors(); - - // Commit to the widths we've chosen; Make widthMin==width - V3Width::widthCommit(v3Global.rootp()); - v3Global.assertDTypesResolved(true); - v3Global.widthMinUsage(VWidthMinUsage::MATCHES_WIDTH); - - // Coverage insertion - // Before we do dead code elimination and inlining, or we'll lose it. - if (v3Global.opt.coverage()) V3Coverage::coverage(v3Global.rootp()); - - // Add randomize() class methods if they are used by the design - if (v3Global.useRandomizeMethods()) V3Randomize::randomizeNetlist(v3Global.rootp()); - - // Push constants, but only true constants preserving liveness - // so V3Undriven sees variables to be eliminated, ie "if (0 && foo) ..." - if (v3Global.opt.fConstBeforeDfg()) V3Const::constifyAllLive(v3Global.rootp()); - - // Signal based lint checks, no change to structures - // Must be before first constification pass drops dead code - V3Undriven::undrivenAll(v3Global.rootp()); - - // Assertion insertion - // After we've added block coverage, but before other nasty transforms - V3AssertPre::assertPreAll(v3Global.rootp()); - // - V3Assert::assertAll(v3Global.rootp()); - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // Add top level wrapper with instance pointing to old top - // Move packages to under new top - // Must do this after we know parameters and dtypes (as don't clone dtype decls) - V3LinkLevel::wrapTop(v3Global.rootp()); - } - - // Propagate constants into expressions - if (v3Global.opt.fConstBeforeDfg()) V3Const::constifyAllLint(v3Global.rootp()); - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // Split packed variables into multiple pieces to resolve UNOPTFLAT. - // should be after constifyAllLint() which flattens to 1D bit vector - V3SplitVar::splitVariable(v3Global.rootp()); - - // Remove cell arrays (must be between V3Width and scoping) - V3Inst::dearrayAll(v3Global.rootp()); - V3LinkDot::linkDotArrayed(v3Global.rootp()); - - // Generate classes and tasks required to maintain proper lifetimes for references in forks - V3Fork::makeDynamicScopes(v3Global.rootp()); - V3Fork::makeTasks(v3Global.rootp()); - - // Task inlining & pushing BEGINs names to variables/cells - // Begin processing must be after Param, before module inlining - V3Begin::debeginAll(v3Global.rootp()); // Flatten cell names, before inliner - - // Expand inouts, stage 2 - // Also simplify pin connections to always be AssignWs in prep for V3Unknown - V3Tristate::tristateAll(v3Global.rootp()); - } - - if (!v3Global.opt.xmlOnly()) { - // Move assignments from X into MODULE temps. - // (Before flattening, so each new X variable is shared between all scopes of that module.) - V3Unknown::unknownAll(v3Global.rootp()); - v3Global.constRemoveXs(true); - } - - if (v3Global.opt.fDfgPreInline() || v3Global.opt.fDfgPostInline()) { - // If doing DFG optimization, extract some additional candidates - V3DfgOptimizer::extract(v3Global.rootp()); - } - - if (v3Global.opt.fDfgPreInline()) { - // Pre inline DFG optimization - V3DfgOptimizer::optimize(v3Global.rootp(), " pre inline"); - } - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // Module inlining - // Cannot remove dead variables after this, as alias information for final - // V3Scope's V3LinkDot is in the AstVar. - if (v3Global.opt.fInline()) { - V3Inline::inlineAll(v3Global.rootp()); - V3LinkDot::linkDotArrayed(v3Global.rootp()); // Cleanup as made new modules - } - } - - if (v3Global.opt.fDfgPostInline()) { - // Post inline DFG optimization - V3DfgOptimizer::optimize(v3Global.rootp(), "post inline"); - } - - // --PRE-FLAT OPTIMIZATIONS------------------ - - // Initial const/dead to reduce work for ordering code - V3Const::constifyAll(v3Global.rootp()); - v3Global.checkTree(); - - V3Dead::deadifyDTypes(v3Global.rootp()); - v3Global.checkTree(); - - V3Error::abortIfErrors(); - - // --FLATTENING--------------- - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // We're going to flatten the hierarchy, so as many optimizations that - // can be done as possible should be before this.... - - // Convert instantiations to wassigns and always blocks - V3Inst::instAll(v3Global.rootp()); - - // Inst may have made lots of concats; fix them - V3Const::constifyAll(v3Global.rootp()); - - // Flatten hierarchy, creating a SCOPE for each module's usage as a cell - V3Scope::scopeAll(v3Global.rootp()); - V3LinkDot::linkDotScope(v3Global.rootp()); - - // Relocate classes (after linkDot) - V3Class::classAll(v3Global.rootp()); - } - - // --SCOPE BASED OPTIMIZATIONS-------------- - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // Cleanup - V3Const::constifyAll(v3Global.rootp()); - V3Dead::deadifyDTypesScoped(v3Global.rootp()); - v3Global.checkTree(); - } - - if (!v3Global.opt.xmlOnly()) { - // Convert case statements to if() blocks. Must be after V3Unknown - // Must be before V3Task so don't need to deal with task in case value compares - V3Case::caseAll(v3Global.rootp()); - } - - if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { - // Inline all tasks - V3Task::taskAll(v3Global.rootp()); - } - - if (!v3Global.opt.xmlOnly()) { - // Add __PVT's - // After V3Task so task internal variables will get renamed - V3Name::nameAll(v3Global.rootp()); - - // Loop unrolling & convert FORs to WHILEs - V3Unroll::unrollAll(v3Global.rootp()); - - // Expand slices of arrays - V3Slice::sliceAll(v3Global.rootp()); - - // Push constants across variables and remove redundant assignments - V3Const::constifyAll(v3Global.rootp()); - - if (v3Global.opt.fLife()) V3Life::lifeAll(v3Global.rootp()); - - // Make large low-fanin logic blocks into lookup tables - // This should probably be done much later, once we have common logic elimination. - if (!v3Global.opt.lintOnly() && v3Global.opt.fTable()) { - V3Table::tableAll(v3Global.rootp()); + if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "Link"); + if (v3Global.opt.debugExitUvm23()) { + V3Error::abortIfErrors(); + if (v3Global.opt.xmlOnly()) V3EmitXml::emitxml(); + cout << "--debug-exit-uvm23: Exiting after UVM-supported pass\n"; + std::exit(0); } - // Cleanup - V3Const::constifyAll(v3Global.rootp()); - V3Dead::deadifyDTypesScoped(v3Global.rootp()); + // Remove parameters by cloning modules to de-parameterized versions + // This requires some width calculations and constant propagation + V3Param::param(v3Global.rootp()); + V3LinkDot::linkDotParamed(v3Global.rootp()); // Cleanup as made new modules + V3LinkLValue::linkLValue(v3Global.rootp()); // Resolve new VarRefs + V3Error::abortIfErrors(); + + // Remove any modules that were parameterized and are no longer referenced. + V3Dead::deadifyModules(v3Global.rootp()); v3Global.checkTree(); - // Move assignments/sensitives into a SBLOCK for each unique sensitivity list - // (May convert some ALWAYS to combo blocks, so should be before V3Gate step.) - V3Active::activeAll(v3Global.rootp()); - - // Split single ALWAYS blocks into multiple blocks for better ordering chances - if (v3Global.opt.fSplit()) V3Split::splitAlwaysAll(v3Global.rootp()); - V3SplitAs::splitAsAll(v3Global.rootp()); - - // Create tracing sample points, before we start eliminating signals - if (v3Global.opt.trace()) V3TraceDecl::traceDeclAll(v3Global.rootp()); - - // Convert forceable signals, process force/release statements. - // After V3TraceDecl so we don't trace additional signals inserted to implement forcing. - V3Force::forceAll(v3Global.rootp()); - - // Gate-based logic elimination; eliminate signals and push constant across cell boundaries - // Instant propagation makes lots-o-constant reduction possibilities. - if (v3Global.opt.fGate()) { - V3Gate::gateAll(v3Global.rootp()); - // V3Gate calls constant propagation itself. - } else { - v3info("Command Line disabled gate optimization with -fno-gate. " - "This may cause ordering problems."); + // Create a hierarchical Verilation plan + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.hierarchical()) { + V3HierBlockPlan::createPlan(v3Global.rootp()); + // If a plan is created, further analysis is not necessary. + // The actual Verilation will be done based on this plan. + if (v3Global.hierPlanp()) { + reportStatsIfEnabled(); + return; + } + } + if (v3Global.opt.debugExitUvm()) { + V3Error::abortIfErrors(); + if (v3Global.opt.xmlOnly()) V3EmitXml::emitxml(); + cout << "--debug-exit-uvm: Exiting after UVM-supported pass\n"; + std::exit(0); } - // Combine COVERINCs with duplicate terms - if (v3Global.opt.coverage()) V3CoverageJoin::coverageJoin(v3Global.rootp()); + // Calculate and check widths, edit tree to TRUNC/EXTRACT any width mismatches + V3Width::width(v3Global.rootp()); - // Remove unused vars + V3Error::abortIfErrors(); + + // Commit to the widths we've chosen; Make widthMin==width + V3Width::widthCommit(v3Global.rootp()); + v3Global.assertDTypesResolved(true); + v3Global.widthMinUsage(VWidthMinUsage::MATCHES_WIDTH); + + // Coverage insertion + // Before we do dead code elimination and inlining, or we'll lose it. + if (v3Global.opt.coverage()) V3Coverage::coverage(v3Global.rootp()); + + // Add randomize() class methods if they are used by the design + if (v3Global.useRandomizeMethods()) V3Randomize::randomizeNetlist(v3Global.rootp()); + + // Push constants, but only true constants preserving liveness + // so V3Undriven sees variables to be eliminated, ie "if (0 && foo) ..." + if (v3Global.opt.fConstBeforeDfg()) V3Const::constifyAllLive(v3Global.rootp()); + + // Signal based lint checks, no change to structures + // Must be before first constification pass drops dead code + V3Undriven::undrivenAll(v3Global.rootp()); + + // Assertion insertion + // After we've added block coverage, but before other nasty transforms + V3AssertPre::assertPreAll(v3Global.rootp()); + // + V3Assert::assertAll(v3Global.rootp()); + + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // Add top level wrapper with instance pointing to old top + // Move packages to under new top + // Must do this after we know parameters and dtypes (as don't clone dtype decls) + V3LinkLevel::wrapTop(v3Global.rootp()); + } + + // Propagate constants into expressions + if (v3Global.opt.fConstBeforeDfg()) V3Const::constifyAllLint(v3Global.rootp()); + + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // Split packed variables into multiple pieces to resolve UNOPTFLAT. + // should be after constifyAllLint() which flattens to 1D bit vector + V3SplitVar::splitVariable(v3Global.rootp()); + + // Remove cell arrays (must be between V3Width and scoping) + V3Inst::dearrayAll(v3Global.rootp()); + V3LinkDot::linkDotArrayed(v3Global.rootp()); + + // Generate classes and tasks required to maintain proper lifetimes for references in + // forks + V3Fork::makeDynamicScopes(v3Global.rootp()); + V3Fork::makeTasks(v3Global.rootp()); + + // Task inlining & pushing BEGINs names to variables/cells + // Begin processing must be after Param, before module inlining + V3Begin::debeginAll(v3Global.rootp()); // Flatten cell names, before inliner + + // Expand inouts, stage 2 + // Also simplify pin connections to always be AssignWs in prep for V3Unknown + V3Tristate::tristateAll(v3Global.rootp()); + } + + if (!v3Global.opt.xmlOnly()) { + // Move assignments from X into MODULE temps. + // (Before flattening, so each new X variable is shared between all scopes of that + // module.) + V3Unknown::unknownAll(v3Global.rootp()); + v3Global.constRemoveXs(true); + } + + if (v3Global.opt.fDfgPreInline() || v3Global.opt.fDfgPostInline()) { + // If doing DFG optimization, extract some additional candidates + V3DfgOptimizer::extract(v3Global.rootp()); + } + + if (v3Global.opt.fDfgPreInline()) { + // Pre inline DFG optimization + V3DfgOptimizer::optimize(v3Global.rootp(), " pre inline"); + } + + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // Module inlining + // Cannot remove dead variables after this, as alias information for final + // V3Scope's V3LinkDot is in the AstVar. + if (v3Global.opt.fInline()) { + V3Inline::inlineAll(v3Global.rootp()); + V3LinkDot::linkDotArrayed(v3Global.rootp()); // Cleanup as made new modules + } + } + + if (v3Global.opt.fDfgPostInline()) { + // Post inline DFG optimization + V3DfgOptimizer::optimize(v3Global.rootp(), "post inline"); + } + + // --PRE-FLAT OPTIMIZATIONS------------------ + + // Initial const/dead to reduce work for ordering code V3Const::constifyAll(v3Global.rootp()); - V3Dead::deadifyAllScoped(v3Global.rootp()); + v3Global.checkTree(); - // Reorder assignments in pipelined blocks - if (v3Global.opt.fReorder()) V3Split::splitReorderAll(v3Global.rootp()); + V3Dead::deadifyDTypes(v3Global.rootp()); + v3Global.checkTree(); - if (v3Global.opt.timing().isSetTrue()) { - // Convert AST for timing if requested - // Needs to be after V3Gate, as that step modifies sentrees - // Needs to be before V3Delayed, as delayed assignments are handled differently in - // suspendable processes - V3Timing::timingAll(v3Global.rootp()); - } + V3Error::abortIfErrors(); - // Create delayed assignments - // This creates lots of duplicate ACTIVES so ActiveTop needs to be after this step - V3Delayed::delayedAll(v3Global.rootp()); + // --FLATTENING--------------- - // Make Active's on the top level. - // Differs from V3Active, because identical clocks may be pushed - // down to a module and now be identical - V3ActiveTop::activeTopAll(v3Global.rootp()); + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // We're going to flatten the hierarchy, so as many optimizations that + // can be done as possible should be before this.... - if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "PreOrder"); + // Convert instantiations to wassigns and always blocks + V3Inst::instAll(v3Global.rootp()); - // Schedule the logic - V3Sched::schedule(v3Global.rootp()); - - // Convert sense lists into IF statements. - V3Clock::clockAll(v3Global.rootp()); - - // Cleanup any dly vars or other temps that are simple assignments - // Life must be done before Subst, as it assumes each CFunc under - // _eval is called only once. - if (v3Global.opt.fLife()) { + // Inst may have made lots of concats; fix them V3Const::constifyAll(v3Global.rootp()); - V3Life::lifeAll(v3Global.rootp()); + + // Flatten hierarchy, creating a SCOPE for each module's usage as a cell + V3Scope::scopeAll(v3Global.rootp()); + V3LinkDot::linkDotScope(v3Global.rootp()); + + // Relocate classes (after linkDot) + V3Class::classAll(v3Global.rootp()); } - if (v3Global.opt.fLifePost()) V3LifePost::lifepostAll(v3Global.rootp()); + // --SCOPE BASED OPTIMIZATIONS-------------- - // Remove unused vars - V3Const::constifyAll(v3Global.rootp()); - V3Dead::deadifyAllScoped(v3Global.rootp()); - - // Create tracing logic, since we ripped out some signals the user might want to trace - // Note past this point, we presume traced variables won't move between CFuncs - // (It's OK if untraced temporaries move around, or vars - // "effectively" activate the same way.) - if (v3Global.opt.trace()) V3Trace::traceAll(v3Global.rootp()); - - if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "Scoped"); - } - - // --MODULE OPTIMIZATIONS-------------- - - if (!v3Global.opt.xmlOnly()) { - // Split deep blocks to appease MSVC++. Must be before Localize. - if (!v3Global.opt.lintOnly() && v3Global.opt.compLimitBlocks()) { - V3DepthBlock::depthBlockAll(v3Global.rootp()); + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // Cleanup + V3Const::constifyAll(v3Global.rootp()); + V3Dead::deadifyDTypesScoped(v3Global.rootp()); + v3Global.checkTree(); } - // Up until this point, all references must be scoped - v3Global.assertScoped(false); - - // Move variables from modules to function local variables where possible - if (v3Global.opt.fLocalize()) V3Localize::localizeAll(v3Global.rootp()); - - // Remove remaining scopes; make varrefs/funccalls relative to current module - V3Descope::descopeAll(v3Global.rootp()); - - // Icache packing; combine common code in each module's functions into subroutines - if (v3Global.opt.fCombine()) V3Combine::combineAll(v3Global.rootp()); - } - - V3Error::abortIfErrors(); - - // --GENERATION------------------ - - if (!v3Global.opt.xmlOnly()) { - // Remove unused vars - V3Const::constifyAll(v3Global.rootp()); - V3Dead::deadifyAll(v3Global.rootp()); - - // Here down, widthMin() is the Verilog width, and width() is the C++ width - // Bits between widthMin() and width() are irrelevant, but may be non zero. - v3Global.widthMinUsage(VWidthMinUsage::VERILOG_WIDTH); - - // Make all expressions either 8, 16, 32 or 64 bits - V3Clean::cleanAll(v3Global.rootp()); - - // Move wide constants to BLOCK temps / ConstPool. - V3Premit::premitAll(v3Global.rootp()); - } - - // Expand macros and wide operators into C++ primitives - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.fExpand()) { - V3Expand::expandAll(v3Global.rootp()); - } - - // Propagate constants across WORDSEL arrayed temporaries - if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubst()) { - // Constant folding of expanded stuff - V3Const::constifyCpp(v3Global.rootp()); - V3Subst::substituteAll(v3Global.rootp()); - } - - if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubstConst()) { - // Constant folding of substitutions - V3Const::constifyCpp(v3Global.rootp()); - V3Dead::deadifyAll(v3Global.rootp()); - } - - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) { - if (v3Global.opt.fMergeCond()) { - // Merge conditionals - V3MergeCond::mergeAll(v3Global.rootp()); + if (!v3Global.opt.xmlOnly()) { + // Convert case statements to if() blocks. Must be after V3Unknown + // Must be before V3Task so don't need to deal with task in case value compares + V3Case::caseAll(v3Global.rootp()); } - if (v3Global.opt.fReloop()) { - // Reform loops to reduce code size - // Must be after all Sel/array index based optimizations - V3Reloop::reloopAll(v3Global.rootp()); + if (!(v3Global.opt.xmlOnly() && !v3Global.opt.flatten())) { + // Inline all tasks + V3Task::taskAll(v3Global.rootp()); } - // Fix very deep expressions - // Mark evaluation functions as member functions, if needed. - V3Depth::depthAll(v3Global.rootp()); + if (!v3Global.opt.xmlOnly()) { + // Add __PVT's + // After V3Task so task internal variables will get renamed + V3Name::nameAll(v3Global.rootp()); - // Branch prediction - V3Branch::branchAll(v3Global.rootp()); + // Loop unrolling & convert FORs to WHILEs + V3Unroll::unrollAll(v3Global.rootp()); - // Add C casts when longs need to become long-long and vice-versa - // Note depth may insert something needing a cast, so this must be last. - V3Cast::castAll(v3Global.rootp()); - } + // Expand slices of arrays + V3Slice::sliceAll(v3Global.rootp()); - V3Error::abortIfErrors(); - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) { // - V3CCtors::cctorsAll(); - } + // Push constants across variables and remove redundant assignments + V3Const::constifyAll(v3Global.rootp()); - if (!v3Global.opt.xmlOnly() && v3Global.opt.mtasks()) { - // Finalize our MTask cost estimates and pack the mtasks into - // threads. Must happen pre-EmitC which relies on the packing - // order. Must happen post-V3LifePost which changes the relative - // costs of mtasks. - V3Partition::finalize(v3Global.rootp()); - } + if (v3Global.opt.fLife()) V3Life::lifeAll(v3Global.rootp()); - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { - // Add common methods/etc to modules - V3Common::commonAll(); + // Make large low-fanin logic blocks into lookup tables + // This should probably be done much later, once we have common logic elimination. + if (!v3Global.opt.lintOnly() && v3Global.opt.fTable()) { + V3Table::tableAll(v3Global.rootp()); + } - // Order variables - V3VariableOrder::orderAll(); + // Cleanup + V3Const::constifyAll(v3Global.rootp()); + V3Dead::deadifyDTypesScoped(v3Global.rootp()); + v3Global.checkTree(); - // Create AstCUse to determine what class forward declarations/#includes needed in C - V3CUse::cUseAll(); - } + // Move assignments/sensitives into a SBLOCK for each unique sensitivity list + // (May convert some ALWAYS to combo blocks, so should be before V3Gate step.) + V3Active::activeAll(v3Global.rootp()); - // Output the text - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { - // emitcInlines is first, as it may set needHInlines which other emitters read - V3EmitC::emitcInlines(); - V3EmitC::emitcSyms(); - V3EmitC::emitcConstPool(); - V3EmitC::emitcModel(); - V3EmitC::emitcHeaders(); - } else if (v3Global.opt.dpiHdrOnly()) { - V3EmitC::emitcSyms(true); + // Split single ALWAYS blocks into multiple blocks for better ordering chances + if (v3Global.opt.fSplit()) V3Split::splitAlwaysAll(v3Global.rootp()); + V3SplitAs::splitAsAll(v3Global.rootp()); + + // Create tracing sample points, before we start eliminating signals + if (v3Global.opt.trace()) V3TraceDecl::traceDeclAll(v3Global.rootp()); + + // Convert forceable signals, process force/release statements. + // After V3TraceDecl so we don't trace additional signals inserted to implement + // forcing. + V3Force::forceAll(v3Global.rootp()); + + // Gate-based logic elimination; eliminate signals and push constant across cell + // boundaries Instant propagation makes lots-o-constant reduction possibilities. + if (v3Global.opt.fGate()) { + V3Gate::gateAll(v3Global.rootp()); + // V3Gate calls constant propagation itself. + } else { + v3info("Command Line disabled gate optimization with -fno-gate. " + "This may cause ordering problems."); + } + + // Combine COVERINCs with duplicate terms + if (v3Global.opt.coverage()) V3CoverageJoin::coverageJoin(v3Global.rootp()); + + // Remove unused vars + V3Const::constifyAll(v3Global.rootp()); + V3Dead::deadifyAllScoped(v3Global.rootp()); + + // Reorder assignments in pipelined blocks + if (v3Global.opt.fReorder()) V3Split::splitReorderAll(v3Global.rootp()); + + if (v3Global.opt.timing().isSetTrue()) { + // Convert AST for timing if requested + // Needs to be after V3Gate, as that step modifies sentrees + // Needs to be before V3Delayed, as delayed assignments are handled differently in + // suspendable processes + V3Timing::timingAll(v3Global.rootp()); + } + + // Create delayed assignments + // This creates lots of duplicate ACTIVES so ActiveTop needs to be after this step + V3Delayed::delayedAll(v3Global.rootp()); + + // Make Active's on the top level. + // Differs from V3Active, because identical clocks may be pushed + // down to a module and now be identical + V3ActiveTop::activeTopAll(v3Global.rootp()); + + if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "PreOrder"); + + // Schedule the logic + V3Sched::schedule(v3Global.rootp()); + + // Convert sense lists into IF statements. + V3Clock::clockAll(v3Global.rootp()); + + // Cleanup any dly vars or other temps that are simple assignments + // Life must be done before Subst, as it assumes each CFunc under + // _eval is called only once. + if (v3Global.opt.fLife()) { + V3Const::constifyAll(v3Global.rootp()); + V3Life::lifeAll(v3Global.rootp()); + } + + if (v3Global.opt.fLifePost()) V3LifePost::lifepostAll(v3Global.rootp()); + + // Remove unused vars + V3Const::constifyAll(v3Global.rootp()); + V3Dead::deadifyAllScoped(v3Global.rootp()); + + // Create tracing logic, since we ripped out some signals the user might want to trace + // Note past this point, we presume traced variables won't move between CFuncs + // (It's OK if untraced temporaries move around, or vars + // "effectively" activate the same way.) + if (v3Global.opt.trace()) V3Trace::traceAll(v3Global.rootp()); + + if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "Scoped"); + } + + // --MODULE OPTIMIZATIONS-------------- + + if (!v3Global.opt.xmlOnly()) { + // Split deep blocks to appease MSVC++. Must be before Localize. + if (!v3Global.opt.lintOnly() && v3Global.opt.compLimitBlocks()) { + V3DepthBlock::depthBlockAll(v3Global.rootp()); + } + + // Up until this point, all references must be scoped + v3Global.assertScoped(false); + + // Move variables from modules to function local variables where possible + if (v3Global.opt.fLocalize()) V3Localize::localizeAll(v3Global.rootp()); + + // Remove remaining scopes; make varrefs/funccalls relative to current module + V3Descope::descopeAll(v3Global.rootp()); + + // Icache packing; combine common code in each module's functions into subroutines + if (v3Global.opt.fCombine()) V3Combine::combineAll(v3Global.rootp()); + } + + V3Error::abortIfErrors(); + + // --GENERATION------------------ + + if (!v3Global.opt.xmlOnly()) { + // Remove unused vars + V3Const::constifyAll(v3Global.rootp()); + V3Dead::deadifyAll(v3Global.rootp()); + + // Here down, widthMin() is the Verilog width, and width() is the C++ width + // Bits between widthMin() and width() are irrelevant, but may be non zero. + v3Global.widthMinUsage(VWidthMinUsage::VERILOG_WIDTH); + + // Make all expressions either 8, 16, 32 or 64 bits + V3Clean::cleanAll(v3Global.rootp()); + + // Move wide constants to BLOCK temps / ConstPool. + V3Premit::premitAll(v3Global.rootp()); + } + + // Expand macros and wide operators into C++ primitives + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && v3Global.opt.fExpand()) { + V3Expand::expandAll(v3Global.rootp()); + } + + // Propagate constants across WORDSEL arrayed temporaries + if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubst()) { + // Constant folding of expanded stuff + V3Const::constifyCpp(v3Global.rootp()); + V3Subst::substituteAll(v3Global.rootp()); + } + + if (!v3Global.opt.xmlOnly() && v3Global.opt.fSubstConst()) { + // Constant folding of substitutions + V3Const::constifyCpp(v3Global.rootp()); + V3Dead::deadifyAll(v3Global.rootp()); + } + + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) { + if (v3Global.opt.fMergeCond()) { + // Merge conditionals + V3MergeCond::mergeAll(v3Global.rootp()); + } + + if (v3Global.opt.fReloop()) { + // Reform loops to reduce code size + // Must be after all Sel/array index based optimizations + V3Reloop::reloopAll(v3Global.rootp()); + } + + // Fix very deep expressions + // Mark evaluation functions as member functions, if needed. + V3Depth::depthAll(v3Global.rootp()); + + // Branch prediction + V3Branch::branchAll(v3Global.rootp()); + + // Add C casts when longs need to become long-long and vice-versa + // Note depth may insert something needing a cast, so this must be last. + V3Cast::castAll(v3Global.rootp()); + } + + V3Error::abortIfErrors(); + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly()) { // + V3CCtors::cctorsAll(); + } + + if (!v3Global.opt.xmlOnly() && v3Global.opt.mtasks()) { + // Finalize our MTask cost estimates and pack the mtasks into + // threads. Must happen pre-EmitC which relies on the packing + // order. Must happen post-V3LifePost which changes the relative + // costs of mtasks. + V3Partition::finalize(v3Global.rootp()); + } + + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { + // Add common methods/etc to modules + V3Common::commonAll(); + + // Order variables + V3VariableOrder::orderAll(); + + // Create AstCUse to determine what class forward declarations/#includes needed in C + V3CUse::cUseAll(); + } + + // Output the text + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { + // emitcInlines is first, as it may set needHInlines which other emitters read + V3EmitC::emitcInlines(); + V3EmitC::emitcSyms(); + V3EmitC::emitcConstPool(); + V3EmitC::emitcModel(); + V3EmitC::emitcHeaders(); + } else if (v3Global.opt.dpiHdrOnly()) { + V3EmitC::emitcSyms(true); + } } if (!v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { // Unfortunately we have some lint checks in emitcImp. V3EmitC::emitcImp(); } - if (v3Global.opt.xmlOnly() - // Check XML when debugging to make sure no missing node types - || (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly() && !v3Global.opt.dpiHdrOnly())) { - V3EmitXml::emitxml(); - } - - // Output DPI protected library files - if (!v3Global.opt.libCreate().empty()) { - if (v3Global.rootp()->delaySchedulerp()) { - v3warn(E_UNSUPPORTED, "Unsupported: --lib-create with --timing and delays"); + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + if (v3Global.opt.xmlOnly() + // Check XML when debugging to make sure no missing node types + || (v3Global.opt.debugCheck() && !v3Global.opt.lintOnly() + && !v3Global.opt.dpiHdrOnly())) { + V3EmitXml::emitxml(); } - V3ProtectLib::protect(); - V3EmitV::emitvFiles(); - V3EmitC::emitcFiles(); - } - if (v3Global.opt.stats()) V3Stats::statsStage("emit"); - - // Statistics - reportStatsIfEnabled(); - - if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { - size_t src_f_cnt = 0; - for (AstNode* nodep = v3Global.rootp()->filesp(); nodep; nodep = nodep->nextp()) { - if (const AstCFile* cfilep = VN_CAST(nodep, CFile)) - src_f_cnt += cfilep->source() ? 1 : 0; + // Output DPI protected library files + if (!v3Global.opt.libCreate().empty()) { + if (v3Global.rootp()->delaySchedulerp()) { + v3warn(E_UNSUPPORTED, "Unsupported: --lib-create with --timing and delays"); + } + V3ProtectLib::protect(); + V3EmitV::emitvFiles(); + V3EmitC::emitcFiles(); } - if (src_f_cnt >= V3EmitMk::PARALLEL_FILE_CNT_THRESHOLD) v3Global.useParallelBuild(true); - // Makefile must be after all other emitters - if (v3Global.opt.main()) V3EmitCMain::emit(); - if (v3Global.opt.cmake()) V3EmitCMake::emit(); - if (v3Global.opt.gmake()) V3EmitMk::emitmk(); + if (v3Global.opt.stats()) V3Stats::statsStage("emit"); + + // Statistics + reportStatsIfEnabled(); + + if (!v3Global.opt.lintOnly() && !v3Global.opt.xmlOnly() && !v3Global.opt.dpiHdrOnly()) { + size_t src_f_cnt = 0; + for (AstNode* nodep = v3Global.rootp()->filesp(); nodep; nodep = nodep->nextp()) { + if (const AstCFile* cfilep = VN_CAST(nodep, CFile)) + src_f_cnt += cfilep->source() ? 1 : 0; + } + if (src_f_cnt >= V3EmitMk::PARALLEL_FILE_CNT_THRESHOLD) + v3Global.useParallelBuild(true); + + // Makefile must be after all other emitters + if (v3Global.opt.main()) V3EmitCMain::emit(); + if (v3Global.opt.cmake()) V3EmitCMake::emit(); + if (v3Global.opt.gmake()) V3EmitMk::emitmk(); + } } } @@ -626,21 +639,29 @@ static void verilate(const string& argString) { // and after removing files as may make debug output) VBasicDTypeKwd::selfTest(); if (v3Global.opt.debugSelfTest()) { - VHashSha256::selfTest(); - VSpellCheck::selfTest(); - V3Graph::selfTest(); - V3TSP::selfTest(); - V3ScoreboardBase::selfTest(); - V3Partition::selfTest(); - V3Partition::selfTestNormalizeCosts(); - V3Broken::selfTest(); + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + + VHashSha256::selfTest(); + VSpellCheck::selfTest(); + V3Graph::selfTest(); + V3TSP::selfTest(); + V3ScoreboardBase::selfTest(); + V3Partition::selfTest(); + V3Partition::selfTestNormalizeCosts(); + V3Broken::selfTest(); + } V3ThreadPool::selfTest(); UINFO(2, "selfTest done\n"); } - // Read first filename - v3Global.readFiles(); - v3Global.removeStd(); + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + + // Read first filename + v3Global.readFiles(); + v3Global.removeStd(); + } // Link, etc, if needed if (!v3Global.opt.preprocOnly()) { // @@ -660,6 +681,8 @@ static void verilate(const string& argString) { V3Error::abortIfWarnings(); if (v3Global.hierPlanp()) { // This run is for just write a makefile + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + UASSERT(v3Global.opt.hierarchical(), "hierarchical must be set"); UASSERT(!v3Global.opt.hierChild(), "This must not be a hierarhcical-child run"); UASSERT(v3Global.opt.hierBlocks().empty(), "hierarchical-block must not be set"); @@ -747,21 +770,25 @@ int main(int argc, char** argv) { time(&randseed); srand(static_cast(randseed)); - // Post-constructor initialization of netlists - v3Global.boot(); - - // Preprocessor - // Before command parsing so we can handle -Ds on command line. - V3PreShell::boot(); - - // Command option parsing - v3Global.opt.buildDepBin(VString::escapeStringForPath(argv[0])); const string argString = V3Options::argString(argc - 1, argv + 1); - v3Global.opt.parseOpts(new FileLine{FileLine::commandLineFilename()}, argc - 1, argv + 1); + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; - // Validate settings (aka Boost.Program_options) - v3Global.opt.notify(); - v3Global.rootp()->timeInit(); + // Post-constructor initialization of netlists + v3Global.boot(); + + // Preprocessor + // Before command parsing so we can handle -Ds on command line. + V3PreShell::boot(); + + // Command option parsing + v3Global.opt.buildDepBin(VString::escapeStringForPath(argv[0])); + v3Global.opt.parseOpts(new FileLine{FileLine::commandLineFilename()}, argc - 1, argv + 1); + + // Validate settings (aka Boost.Program_options) + v3Global.opt.notify(); + v3Global.rootp()->timeInit(); + } V3Error::abortIfErrors(); @@ -777,10 +804,14 @@ int main(int argc, char** argv) { execBuildJob(); } - // Explicitly release resources - V3PreShell::shutdown(); - v3Global.shutdown(); - FileLine::deleteAllRemaining(); + { + const V3MtDisabledLockGuard mtDisabler{v3MtDisabledLock()}; + + // Explicitly release resources + V3PreShell::shutdown(); + v3Global.shutdown(); + FileLine::deleteAllRemaining(); + } UINFO(1, "Done, Exiting...\n"); } diff --git a/src/VlcMain.cpp b/src/VlcMain.cpp index c0c75cdc7..34e314d6d 100644 --- a/src/VlcMain.cpp +++ b/src/VlcMain.cpp @@ -15,6 +15,8 @@ //************************************************************************* // clang-format off +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "config_build.h" #ifndef HAVE_CONFIG_PACKAGE # error "Something failed during ./configure as config_package.h is incomplete. Perhaps you used autoreconf, don't." diff --git a/src/VlcOptions.h b/src/VlcOptions.h index 5bfd183f5..a81737b4f 100644 --- a/src/VlcOptions.h +++ b/src/VlcOptions.h @@ -20,6 +20,8 @@ #include "config_build.h" #include "verilatedos.h" +#include "V3ThreadSafety.h" + #include "config_rev.h" #include @@ -47,7 +49,7 @@ class VlcOptions final { private: // METHODS - static void showVersion(bool verbose); + static void showVersion(bool verbose) VL_MT_DISABLED; public: // CONSTRUCTORS @@ -55,8 +57,8 @@ public: ~VlcOptions() = default; // METHODS - void parseOptsList(int argc, char** argv); - void addReadFile(const string& filename); + void parseOptsList(int argc, char** argv) VL_MT_DISABLED; + void addReadFile(const string& filename) VL_MT_DISABLED; // ACCESSORS (options) const VlStringSet& readFiles() const { return m_readFiles; } @@ -70,7 +72,7 @@ public: string writeInfoFile() const { return m_writeInfoFile; } // METHODS (from main) - static string version(); + static string version() VL_MT_DISABLED; }; //###################################################################### diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index bf5038450..5ca8d968e 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -14,6 +14,8 @@ // //************************************************************************* +#define VL_MT_DISABLED_CODE_UNIT 1 + #include "VlcTop.h" #include "V3Error.h" diff --git a/src/verilog.y b/src/verilog.y index c850947d2..cdc6682e9 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -120,15 +120,16 @@ public: } // METHODS - AstArg* argWrapList(AstNodeExpr* nodep); + AstArg* argWrapList(AstNodeExpr* nodep) VL_MT_DISABLED; bool allTracingOn(FileLine* fl) { return v3Global.opt.trace() && m_tracingParse && fl->tracingOn(); } - AstRange* scrubRange(AstNodeRange* rangep); - AstNodeDType* createArray(AstNodeDType* basep, AstNodeRange* rangep, bool isPacked); + AstRange* scrubRange(AstNodeRange* rangep) VL_MT_DISABLED; + AstNodeDType* createArray(AstNodeDType* basep, AstNodeRange* rangep, + bool isPacked) VL_MT_DISABLED; AstVar* createVariable(FileLine* fileline, const string& name, AstNodeRange* arrayp, - AstNode* attrsp); - AstNode* createSupplyExpr(FileLine* fileline, const string& name, int value); + AstNode* attrsp) VL_MT_DISABLED; + AstNode* createSupplyExpr(FileLine* fileline, const string& name, int value) VL_MT_DISABLED; AstText* createTextQuoted(FileLine* fileline, const string& text) { string newtext = deQuote(fileline, text); return new AstText{fileline, newtext}; @@ -254,7 +255,7 @@ public: return createArray(dtypep, rangearraysp, isPacked); } } - string deQuote(FileLine* fileline, string text); + string deQuote(FileLine* fileline, string text) VL_MT_DISABLED; void checkDpiVer(FileLine* fileline, const string& str) { if (str != "DPI-C" && !v3Global.opt.bboxSys()) { fileline->v3error("Unsupported DPI type '" << str << "': Use 'DPI-C'");