C++11: constexpr replacing defines. No functional change intended.

This commit is contained in:
Wilson Snyder 2020-08-16 14:19:12 -04:00
parent ac04e85a1c
commit d75a8624c1
13 changed files with 22 additions and 40 deletions

View File

@ -37,7 +37,7 @@
#include <iomanip>
#include <memory>
#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
//######################################################################

View File

@ -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
//######################################################################

View File

@ -30,9 +30,10 @@
#include <vector>
#include <unordered_set>
#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

View File

@ -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");

View File

@ -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

View File

@ -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 {

View File

@ -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)

View File

@ -39,7 +39,7 @@
typedef std::list<AstNodeVarRef*> GateVarRefList;
#define GATE_DEDUP_MAX_DEPTH 20
constexpr int GATE_DEDUP_MAX_DEPTH = 20;
//######################################################################

View File

@ -25,7 +25,8 @@
#include <cerrno>
#include <cmath>
#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) \

View File

@ -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.

View File

@ -39,7 +39,7 @@
#include <algorithm>
#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
//######################################################################

View File

@ -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} {}

View File

@ -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<string> Candidates;