diff options
author | Aina Niemetz <aina.niemetz@gmail.com> | 2019-10-22 14:03:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-22 14:03:09 -0700 |
commit | 2caeef9745366ad4c45f61dabedf1cd7f676a4a1 (patch) | |
tree | 4ddcc391429293e4a4e75d6ff23019ee9f71e781 /src/expr/node_builder.h | |
parent | 2bd74b751844230b82c58bfdd29666206562781d (diff) |
NodeValue: Eliminate redundant NBITS macros. (#3400)
Previously, the metakind header defined macros for the number of bits
reserved for fields in the NodeValue "header" (for the reference count,
the node kind, the number of children and the node id). These macros
were redundant, since the only one using them was the NodeValue itself,
which redefined them (while using them) as constants in the class.
Additionally, MAX_CHILDREN was defined (using these macros) not only
in the metakind header, but redefined in other places.
This commit defines the above values as constexpr members of the
NodeValue class and cleans up redundancy.
Diffstat (limited to 'src/expr/node_builder.h')
-rw-r--r-- | src/expr/node_builder.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h index d07790f92..b5e99c6fd 100644 --- a/src/expr/node_builder.h +++ b/src/expr/node_builder.h @@ -272,10 +272,12 @@ class NodeBuilder { * NodeValue is evacuated, make sure its children won't be * double-decremented later (on destruction/clear). */ - inline void realloc() { + inline void realloc() + { size_t newSize = 2 * size_t(d_nvMaxChildren); - size_t hardLimit = (1lu << CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN) - 1; - realloc(__builtin_expect( ( newSize > hardLimit ), false ) ? hardLimit : newSize); + size_t hardLimit = expr::NodeValue::MAX_CHILDREN; + realloc(__builtin_expect((newSize > hardLimit), false) ? hardLimit + : newSize); } /** @@ -774,9 +776,11 @@ template <unsigned nchild_thresh> void NodeBuilder<nchild_thresh>::realloc(size_t toSize) { AlwaysAssert(toSize > d_nvMaxChildren, "attempt to realloc() a NodeBuilder to a smaller/equal size!"); - Assert( toSize < (1lu << CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN), - "attempt to realloc() a NodeBuilder to size %u (beyond hard limit of %u)", - toSize, (1lu << CVC4__EXPR__NODE_VALUE__NBITS__NCHILDREN) - 1 ); + Assert(toSize < (static_cast<size_t>(1) << expr::NodeValue::NBITS_NCHILDREN), + "attempt to realloc() a NodeBuilder to size %lu (beyond hard limit of " + "%u)", + toSize, + expr::NodeValue::MAX_CHILDREN); if(__builtin_expect( ( nvIsAllocated() ), false )) { // Ensure d_nv is not modified on allocation failure |