diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 9ada2ccc3..6dac06e36 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -37,7 +37,7 @@ #include #include -#define CDC_WEIGHT_ASYNC 0x1000 // Weight for edges that feed async logic +constexpr int CDC_WEIGHT_ASYNC = 0x1000; // Weight for edges that feed async logic //###################################################################### diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index 567367730..6b05cabec 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -45,7 +45,9 @@ //###################################################################### -#define COMBINE_MIN_STATEMENTS 50 // Min # of statements to be worth making a function +#ifdef VL_COMBINE_STATEMENTS +constexpr int COMBINE_MIN_STATEMENTS = 50; // Min # of statements to be worth making a function +#endif //###################################################################### diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index e73709d7a..4dd03b268 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -30,9 +30,10 @@ #include #include -#define VL_VALUE_STRING_MAX_WIDTH 8192 // We use a static char array in VL_VALUE_STRING +constexpr int VL_VALUE_STRING_MAX_WIDTH = 8192; // We use a static char array in VL_VALUE_STRING -#define EMITC_NUM_CONSTW 8 // Number of VL_CONST_W_*X's in verilated.h (IE VL_CONST_W_8X is last) +constexpr int EMITC_NUM_CONSTW + = 8; // Number of VL_CONST_W_*X's in verilated.h (IE VL_CONST_W_8X is last) //###################################################################### // Emit statements and math operators diff --git a/src/V3Error.h b/src/V3Error.h index 4a0fd4809..23d411055 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -239,7 +239,7 @@ private: static MessagesSet s_messages; // What errors we've outputted static ErrorExitCb s_errorExitCb; // Callback when error occurs for dumping - enum MaxErrors { MAX_ERRORS = 50 }; // Fatal after this may errors + static constexpr unsigned MAX_ERRORS = 50; // Fatal after this may errors V3Error() { std::cerr << ("Static class"); diff --git a/src/V3File.cpp b/src/V3File.cpp index 646c9ba75..4281ce676 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -56,8 +56,8 @@ // If change this code, run a test with the below size set very small //#define INFILTER_IPC_BUFSIZ 16 -#define INFILTER_IPC_BUFSIZ (64 * 1024) // For debug, try this as a small number -#define INFILTER_CACHE_MAX (64 * 1024) // Maximum bytes to cache if same file read twice +constexpr int INFILTER_IPC_BUFSIZ = (64 * 1024); // For debug, try this as a small number +constexpr int INFILTER_CACHE_MAX = (64 * 1024); // Maximum bytes to cache if same file read twice //###################################################################### // V3File Internal state diff --git a/src/V3File.h b/src/V3File.h index b558e19b9..98145475e 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -101,7 +101,7 @@ public: class V3OutFormatter { // TYPES - enum MiscConsts { MAXSPACE = 80 }; // After this indent, stop indenting more + static constexpr int MAXSPACE = 80; // After this indent, stop indenting more public: enum AlignClass : uint8_t { AL_AUTO = 0, AL_STATIC = 1 }; enum Language : uint8_t { diff --git a/src/V3FileLine.h b/src/V3FileLine.h index e91515d95..85aa5500a 100644 --- a/src/V3FileLine.h +++ b/src/V3FileLine.h @@ -89,7 +89,7 @@ std::ostream& operator<<(std::ostream& os, VFileContent* contentp); //! language is held in tables in the FileLineSingleton class. class FileLine { // CONSTANTS - enum { SHOW_SOURCE_MAX_LENGTH = 400 }; // Don't show source lines > this long + static constexpr unsigned SHOW_SOURCE_MAX_LENGTH = 400; // Don't show source lines > this long // MEMBERS // Columns here means number of chars from beginning (i.e. tabs count as one) diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 1e67d08af..e227864d7 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -39,7 +39,7 @@ typedef std::list GateVarRefList; -#define GATE_DEDUP_MAX_DEPTH 20 +constexpr int GATE_DEDUP_MAX_DEPTH = 20; //###################################################################### diff --git a/src/V3Number.cpp b/src/V3Number.cpp index cdeb13f22..bc4ca4cbc 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -25,7 +25,8 @@ #include #include -#define MAX_SPRINTF_DOUBLE_SIZE 1100 // Maximum characters with a sprintf %e/%f/%g (really 1079) +constexpr int MAX_SPRINTF_DOUBLE_SIZE + = 1100; // Maximum characters with a sprintf %e/%f/%g (really 1079) // Number operations build output in-place so can't call e.g. foo.opX(foo) #define NUM_ASSERT_OP_ARGS1(arg1) \ diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 6890dc13e..58d1caa7a 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -72,9 +72,9 @@ class MergeCandidate; // If you don't care about partitioner runtime and you want the most // aggressive partition, set the limit very high. If you have huge // vertices, leave this as is. -#define PART_SIBLING_EDGE_LIMIT 25 +constexpr unsigned PART_SIBLING_EDGE_LIMIT = 25; -// PART_STEPPED_COST (boolean) +// PART_STEPPED_COST (defined/undef) // // When computing critical path costs, use a step function on the actual // underlying vertex cost. @@ -106,28 +106,6 @@ class MergeCandidate; // behavior. #define PART_STEPPED_COST true -// PART_STEPPED_RESCORE_LIMIT (boolean) -// -// If false, we always try to merge the absolute lowest (best) scoring -// mtask pair among all candidates. -// -// If true, we're willing to merge mtask pairs with scores up to 5% higher -// (worse) than the best, in exchange for doing a Rescore() operation -// somewhat less often. -// -// A true setting can result in a much faster compile in the presence of -// huge vertices, eg. 45 minutes versus 4.5 minutes for one particular -// model. HOWEVER, a true setting usually results in modestly worse -// partitions, often around 10% more MTasks and 10% longer cycle times. -// -// (TODO: Why does this setting save time with huge vertices? -// Is there a way to get best of both worlds without the trade off?) -// -// If you have huge vertices, you may wish to set this true. If you don't -// have huge vertices (which should be everyone, we think, now that V3Split -// is fixed) leave it set false for the most aggressive partition. -#define PART_STEPPED_RESCORE_LIMIT false - // Don't produce more than a certain maximum number of MTasks. This helps // the TSP variable sort not to blow up (a concern for some of the tests) // and we probably don't want a huge number of mtasks in practice anyway @@ -136,7 +114,7 @@ class MergeCandidate; // If the user doesn't give one with '--threads-max-mtasks', we'll set the // maximum # of MTasks to // (# of threads * PART_DEFAULT_MAX_MTASKS_PER_THREAD) -#define PART_DEFAULT_MAX_MTASKS_PER_THREAD 50 +constexpr unsigned PART_DEFAULT_MAX_MTASKS_PER_THREAD = 50; // end tunables. diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index eeb47b0c6..7122b906c 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -39,7 +39,7 @@ #include -#define RELOOP_MIN_ITERS 40 // Need at least this many loops to do this optimization +constexpr unsigned RELOOP_MIN_ITERS = 40; // Need at least this many loops to do this optimization //###################################################################### diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 96f04b1e6..69773c2b5 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -156,7 +156,7 @@ class SplitEdge : public V3GraphEdge { uint32_t m_ignoreInStep = 0; // Step number that if set to, causes this edge to be ignored static uint32_t s_stepNum; // Global step number protected: - enum { WEIGHT_NORMAL = 10 }; + static constexpr int WEIGHT_NORMAL = 10; SplitEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, bool cutable = CUTABLE) : V3GraphEdge{graphp, fromp, top, weight, cutable} {} diff --git a/src/V3String.h b/src/V3String.h index 95004e57d..b02ee587f 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -185,8 +185,8 @@ public: class VSpellCheck { // CONSTANTS - enum { NUM_CANDIDATE_LIMIT = 10000 }; // Avoid searching huge netlists - enum { LENGTH_LIMIT = 100 }; // Maximum string length to search + static constexpr unsigned NUM_CANDIDATE_LIMIT = 10000; // Avoid searching huge netlists + static constexpr unsigned LENGTH_LIMIT = 100; // Maximum string length to search // TYPES typedef unsigned int EditDistance; typedef std::vector Candidates;