Internals: Standardize on template<typename. No functional change.

This commit is contained in:
Wilson Snyder 2024-11-29 18:01:50 -05:00
parent f631587a20
commit 990ccd6763
17 changed files with 44 additions and 45 deletions

View File

@ -100,7 +100,7 @@ class VerilatedFstC;
class VerilatedFstSc; class VerilatedFstSc;
class VerilatedScope; class VerilatedScope;
class VerilatedScopeNameMap; class VerilatedScopeNameMap;
template <class, class> template <typename, typename>
class VerilatedTrace; class VerilatedTrace;
class VerilatedTraceBaseC; class VerilatedTraceBaseC;
class VerilatedTraceConfig; class VerilatedTraceConfig;
@ -300,7 +300,7 @@ public:
private: private:
// The following are for use by Verilator internals only // The following are for use by Verilator internals only
template <class, class> template <typename, typename>
friend class VerilatedTrace; friend class VerilatedTrace;
// Run-time trace configuration requested by this model // Run-time trace configuration requested by this model
virtual std::unique_ptr<VerilatedTraceConfig> traceConfig() const; virtual std::unique_ptr<VerilatedTraceConfig> traceConfig() const;

View File

@ -71,7 +71,7 @@ public: // But only local to this file
// This isn't in the header file for auto-magic conversion because it // This isn't in the header file for auto-magic conversion because it
// inlines to too much code and makes compilation too slow. // inlines to too much code and makes compilation too slow.
template <class T> template <typename T>
class VerilatedCoverItemSpec final : public VerilatedCovImpItem { class VerilatedCoverItemSpec final : public VerilatedCovImpItem {
private: private:
// MEMBERS // MEMBERS

View File

@ -300,7 +300,7 @@ inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, std::string& r
VerilatedSerialize& operator<<(VerilatedSerialize& os, VerilatedContext* rhsp); VerilatedSerialize& operator<<(VerilatedSerialize& os, VerilatedContext* rhsp);
VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VerilatedContext* rhsp); VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VerilatedContext* rhsp);
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray<T_Key, T_Value>& rhs) { VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray<T_Key, T_Value>& rhs) {
os << rhs.atDefault(); os << rhs.atDefault();
const uint32_t len = rhs.size(); const uint32_t len = rhs.size();
@ -312,7 +312,7 @@ VerilatedSerialize& operator<<(VerilatedSerialize& os, VlAssocArray<T_Key, T_Val
} }
return os; return os;
} }
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VlAssocArray<T_Key, T_Value>& rhs) { VerilatedDeserialize& operator>>(VerilatedDeserialize& os, VlAssocArray<T_Key, T_Value>& rhs) {
os >> rhs.atDefault(); os >> rhs.atDefault();
uint32_t len = 0; uint32_t len = 0;

View File

@ -41,9 +41,9 @@
// clang-format on // clang-format on
class VlThreadPool; class VlThreadPool;
template <class T_Buffer> template <typename T_Buffer>
class VerilatedTraceBuffer; class VerilatedTraceBuffer;
template <class T_Buffer> template <typename T_Buffer>
class VerilatedTraceOffloadBuffer; class VerilatedTraceOffloadBuffer;
//============================================================================= //=============================================================================
@ -100,7 +100,7 @@ enum class VerilatedTraceSigType : uint8_t {
// Offloaded tracing // Offloaded tracing
// A simple synchronized first in first out queue // A simple synchronized first in first out queue
template <class T> template <typename T>
class VerilatedThreadQueue final { // LCOV_EXCL_LINE // lcov bug class VerilatedThreadQueue final { // LCOV_EXCL_LINE // lcov bug
private: private:
mutable VerilatedMutex m_mutex; // Protects m_queue mutable VerilatedMutex m_mutex; // Protects m_queue
@ -202,7 +202,7 @@ public:
// T_Trace is the format-specific subclass of VerilatedTrace. // T_Trace is the format-specific subclass of VerilatedTrace.
// T_Buffer is the format-specific base class of VerilatedTraceBuffer. // T_Buffer is the format-specific base class of VerilatedTraceBuffer.
template <class T_Trace, class T_Buffer> template <typename T_Trace, typename T_Buffer>
class VerilatedTrace VL_NOT_FINAL { class VerilatedTrace VL_NOT_FINAL {
public: public:
using Buffer = VerilatedTraceBuffer<T_Buffer>; using Buffer = VerilatedTraceBuffer<T_Buffer>;
@ -442,7 +442,7 @@ public:
// T_Buffer is the format-specific base class of VerilatedTraceBuffer. // T_Buffer is the format-specific base class of VerilatedTraceBuffer.
// The format-specific hot-path methods use duck-typing via T_Buffer for performance. // The format-specific hot-path methods use duck-typing via T_Buffer for performance.
template <class T_Buffer> template <typename T_Buffer>
class VerilatedTraceBuffer VL_NOT_FINAL : public T_Buffer { class VerilatedTraceBuffer VL_NOT_FINAL : public T_Buffer {
protected: protected:
// Type of the owner trace file // Type of the owner trace file
@ -543,7 +543,7 @@ public:
// T_Buffer is the format-specific base class of VerilatedTraceBuffer. // T_Buffer is the format-specific base class of VerilatedTraceBuffer.
// The format-specific hot-path methods use duck-typing via T_Buffer for performance. // The format-specific hot-path methods use duck-typing via T_Buffer for performance.
template <class T_Buffer> template <typename T_Buffer>
class VerilatedTraceOffloadBuffer final : public VerilatedTraceBuffer<T_Buffer> { class VerilatedTraceOffloadBuffer final : public VerilatedTraceBuffer<T_Buffer> {
using typename VerilatedTraceBuffer<T_Buffer>::Trace; using typename VerilatedTraceBuffer<T_Buffer>::Trace;

View File

@ -309,7 +309,7 @@ public:
size_t operator()() { return VL_MASK_I(31) & vl_rand64(); } size_t operator()() { return VL_MASK_I(31) & vl_rand64(); }
}; };
template <class T_Value, uint64_t T_numValues> template <typename T_Value, uint64_t T_numValues>
class VlRandC final { class VlRandC final {
T_Value m_remaining = 0; // Number of values to pull before re-randomize T_Value m_remaining = 0; // Number of values to pull before re-randomize
T_Value m_lfsr = 1; // LFSR state T_Value m_lfsr = 1; // LFSR state
@ -477,7 +477,7 @@ std::string VL_TO_STRING(const VlWide<T_Words>& obj) {
// //
// Bound here is the maximum size() allowed, e.g. 1 + SystemVerilog bound // Bound here is the maximum size() allowed, e.g. 1 + SystemVerilog bound
// For dynamic arrays it is always zero // For dynamic arrays it is always zero
template <class T_Value, size_t T_MaxSize = 0> template <typename T_Value, size_t T_MaxSize = 0>
class VlQueue final { class VlQueue final {
private: private:
// TYPES // TYPES
@ -485,7 +485,7 @@ private:
public: public:
using const_iterator = typename Deque::const_iterator; using const_iterator = typename Deque::const_iterator;
template <class Func> template <typename Func>
using WithFuncReturnType = decltype(std::declval<Func>()(0, std::declval<T_Value>())); using WithFuncReturnType = decltype(std::declval<Func>()(0, std::declval<T_Value>()));
private: private:
@ -909,7 +909,7 @@ public:
} }
}; };
template <class T_Value, size_t T_MaxSize> template <typename T_Value, size_t T_MaxSize>
std::string VL_TO_STRING(const VlQueue<T_Value, T_MaxSize>& obj) { std::string VL_TO_STRING(const VlQueue<T_Value, T_MaxSize>& obj) {
return obj.to_string(); return obj.to_string();
} }
@ -919,7 +919,7 @@ std::string VL_TO_STRING(const VlQueue<T_Value, T_MaxSize>& obj) {
// There are no multithreaded locks on this; the base variable must // There are no multithreaded locks on this; the base variable must
// be protected by other means // be protected by other means
// //
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
class VlAssocArray final { class VlAssocArray final {
private: private:
// TYPES // TYPES
@ -927,7 +927,7 @@ private:
public: public:
using const_iterator = typename Map::const_iterator; using const_iterator = typename Map::const_iterator;
template <class Func> template <typename Func>
using WithFuncReturnType using WithFuncReturnType
= decltype(std::declval<Func>()(std::declval<T_Key>(), std::declval<T_Value>())); = decltype(std::declval<Func>()(std::declval<T_Key>(), std::declval<T_Value>()));
@ -1244,12 +1244,12 @@ public:
} }
}; };
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
std::string VL_TO_STRING(const VlAssocArray<T_Key, T_Value>& obj) { std::string VL_TO_STRING(const VlAssocArray<T_Key, T_Value>& obj) {
return obj.to_string(); return obj.to_string();
} }
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
void VL_READMEM_N(bool hex, int bits, const std::string& filename, void VL_READMEM_N(bool hex, int bits, const std::string& filename,
VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE { VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
VlReadMem rmem{hex, bits, filename, start, end}; VlReadMem rmem{hex, bits, filename, start, end};
@ -1265,7 +1265,7 @@ void VL_READMEM_N(bool hex, int bits, const std::string& filename,
} }
} }
template <class T_Key, class T_Value> template <typename T_Key, typename T_Value>
void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename, void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename,
const VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE { const VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
VlWriteMem wmem{hex, bits, filename, start, end}; VlWriteMem wmem{hex, bits, filename, start, end};
@ -1287,9 +1287,8 @@ void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename,
/// This class may get exposed to a Verilated Model's top I/O, if the top /// This class may get exposed to a Verilated Model's top I/O, if the top
/// IO has an unpacked array. /// IO has an unpacked array.
template <class T_Value, std::size_t T_Depth> template <typename T_Value, std::size_t T_Depth>
struct VlUnpacked final { class VlUnpacked final {
private:
// TYPES // TYPES
using T_Key = IData; // Index type, for uniformity with other containers using T_Key = IData; // Index type, for uniformity with other containers
using Unpacked = T_Value[T_Depth]; using Unpacked = T_Value[T_Depth];
@ -1569,7 +1568,7 @@ private:
} }
}; };
template <class T_Value, std::size_t T_Depth> template <typename T_Value, std::size_t T_Depth>
std::string VL_TO_STRING(const VlUnpacked<T_Value, T_Depth>& obj) { std::string VL_TO_STRING(const VlUnpacked<T_Value, T_Depth>& obj) {
return obj.to_string(); return obj.to_string();
} }
@ -2027,7 +2026,7 @@ public:
#define VL_KEEP_THIS \ #define VL_KEEP_THIS \
VlClassRef<std::remove_pointer<decltype(this)>::type> __Vthisref { this } VlClassRef<std::remove_pointer<decltype(this)>::type> __Vthisref { this }
template <class T> // T typically of type VlClassRef<x> template <typename T> // T typically of type VlClassRef<x>
inline T VL_NULL_CHECK(T t, const char* filename, int linenum) { inline T VL_NULL_CHECK(T t, const char* filename, int linenum) {
if (VL_UNLIKELY(!t)) Verilated::nullPointerError(filename, linenum); if (VL_UNLIKELY(!t)) Verilated::nullPointerError(filename, linenum);
return t; return t;

View File

@ -701,7 +701,7 @@ reverse_wrapper<T> reverse_view(const T& v) {
// Object that is returned by this function is not considered // Object that is returned by this function is not considered
// as MT_SAFE and any function call on this object still // as MT_SAFE and any function call on this object still
// needs to be `VL_MT_SAFE`. // needs to be `VL_MT_SAFE`.
template <class T> template <typename T>
T const& as_const(T& v) VL_MT_SAFE { T const& as_const(T& v) VL_MT_SAFE {
return v; return v;
} }

View File

@ -1745,7 +1745,7 @@ public:
explicit VNUser(void* p) { m_u.up = p; } explicit VNUser(void* p) { m_u.up = p; }
~VNUser() = default; ~VNUser() = default;
// Casters // Casters
template <class T> template <typename T>
typename std::enable_if<std::is_pointer<T>::value, T>::type to() const VL_MT_SAFE { typename std::enable_if<std::is_pointer<T>::value, T>::type to() const VL_MT_SAFE {
return reinterpret_cast<T>(m_u.up); return reinterpret_cast<T>(m_u.up);
} }

View File

@ -27,7 +27,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
template <class T_Node, class T_Data, int T_UserN> template <typename T_Node, typename T_Data, int T_UserN>
class AstUserAllocatorBase VL_NOT_FINAL { class AstUserAllocatorBase VL_NOT_FINAL {
static_assert(1 <= T_UserN && T_UserN <= 4, "Wrong user pointer number"); static_assert(1 <= T_UserN && T_UserN <= 4, "Wrong user pointer number");
static_assert(std::is_base_of<AstNode, T_Node>::value, "T_Node must be an AstNode type"); static_assert(std::is_base_of<AstNode, T_Node>::value, "T_Node must be an AstNode type");
@ -107,13 +107,13 @@ public:
// User pointer allocator classes. T_Node is the type of node the allocator should be applied to // User pointer allocator classes. T_Node is the type of node the allocator should be applied to
// and is there for a bit of extra type safety. T_Data is the type of the data structure // and is there for a bit of extra type safety. T_Data is the type of the data structure
// managed by the allocator. // managed by the allocator.
template <class T_Node, class T_Data> template <typename T_Node, typename T_Data>
class AstUser1Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 1> {}; class AstUser1Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 1> {};
template <class T_Node, class T_Data> template <typename T_Node, typename T_Data>
class AstUser2Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 2> {}; class AstUser2Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 2> {};
template <class T_Node, class T_Data> template <typename T_Node, typename T_Data>
class AstUser3Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 3> {}; class AstUser3Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 3> {};
template <class T_Node, class T_Data> template <typename T_Node, typename T_Data>
class AstUser4Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 4> {}; class AstUser4Allocator final : public AstUserAllocatorBase<T_Node, T_Data, 4> {};
#endif // Guard #endif // Guard

View File

@ -57,7 +57,7 @@ static bool isConst(const AstNode* nodep, uint64_t v) {
return constp && constp->toUQuad() == v; return constp && constp->toUQuad() == v;
} }
template <class T> template <typename T>
static typename std::enable_if<std::is_integral<T>::value, bool>::type isPow2(T val) { static typename std::enable_if<std::is_integral<T>::value, bool>::type isPow2(T val) {
return (val & (val - 1)) == 0; return (val & (val - 1)) == 0;
} }

View File

@ -27,7 +27,7 @@
// Algorithms - common class // Algorithms - common class
// For internal use, most graph algorithms use this as a base class // For internal use, most graph algorithms use this as a base class
template <class T_Graph = V3Graph> // Or sometimes const V3Graph template <typename T_Graph = V3Graph> // Or sometimes const V3Graph
class GraphAlg VL_NOT_FINAL { class GraphAlg VL_NOT_FINAL {
protected: protected:
T_Graph* const m_graphp; // Graph we're operating upon T_Graph* const m_graphp; // Graph we're operating upon

View File

@ -40,7 +40,7 @@
// not generally safe. If you want a raw pointer compare, see // not generally safe. If you want a raw pointer compare, see
// GraphStreamUnordered below. // GraphStreamUnordered below.
template <class T_Compare> template <typename T_Compare>
class GraphStream final { class GraphStream final {
// TYPES // TYPES
class VxHolder final { class VxHolder final {

View File

@ -57,13 +57,13 @@ public:
bool operator<(const V3Hash& rh) const { return m_value < rh.m_value; } bool operator<(const V3Hash& rh) const { return m_value < rh.m_value; }
// '+' combines hashes // '+' combines hashes
template <class T> template <typename T>
V3Hash operator+(T that) const { V3Hash operator+(T that) const {
return V3Hash{combine(m_value, V3Hash{that}.m_value)}; return V3Hash{combine(m_value, V3Hash{that}.m_value)};
} }
// '+=' combines in place // '+=' combines in place
template <class T> template <typename T>
V3Hash& operator+=(T that) { V3Hash& operator+=(T that) {
return *this = *this + that; return *this = *this + that;
} }

View File

@ -59,7 +59,7 @@ struct V3OptionParser::Impl final {
class ActionCbCall; // Callback without argument for "-opt" class ActionCbCall; // Callback without argument for "-opt"
class ActionCbFOnOff; // Callback for "-fopt" and "-fno-opt" class ActionCbFOnOff; // Callback for "-fopt" and "-fno-opt"
class ActionCbOnOff; // Callback for "-opt" and "-no-opt" class ActionCbOnOff; // Callback for "-opt" and "-no-opt"
template <class T> template <typename T>
class ActionCbVal; // Callback for "-opt val" class ActionCbVal; // Callback for "-opt val"
class ActionCbPartialMatch; // Callback "-O3" for "-O" class ActionCbPartialMatch; // Callback "-O3" for "-O"
class ActionCbPartialMatchVal; // Callback "-debugi-V3Options 3" for "-debugi-" class ActionCbPartialMatchVal; // Callback "-debugi-V3Options 3" for "-debugi-"
@ -171,7 +171,7 @@ V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) {
return nullptr; return nullptr;
} }
template <class ACT, class ARG> template <typename ACT, typename ARG>
V3OptionParser::ActionIfs& V3OptionParser::add(const std::string& opt, ARG arg) { V3OptionParser::ActionIfs& V3OptionParser::add(const std::string& opt, ARG arg) {
UASSERT(!m_pimpl->m_isFinalized, "Cannot add after finalize() is called"); UASSERT(!m_pimpl->m_isFinalized, "Cannot add after finalize() is called");
std::unique_ptr<ACT> act{new ACT{std::move(arg)}}; std::unique_ptr<ACT> act{new ACT{std::move(arg)}};

View File

@ -65,7 +65,7 @@ private:
// METHODS // METHODS
ActionIfs* find(const char* optp) VL_MT_DISABLED; ActionIfs* find(const char* optp) VL_MT_DISABLED;
template <class ACT, class ARG> template <typename ACT, typename ARG>
ActionIfs& add(const string& opt, ARG arg) VL_MT_DISABLED; ActionIfs& add(const string& opt, ARG arg) VL_MT_DISABLED;
// Returns true if strp starts with "-fno" // Returns true if strp starts with "-fno"
static bool hasPrefixFNo(const char* strp) VL_MT_DISABLED; static bool hasPrefixFNo(const char* strp) VL_MT_DISABLED;

View File

@ -186,7 +186,7 @@ struct SplitVarImpl VL_NOT_FINAL {
static const char* cannotSplitPackedVarReason(const AstVar* varp); static const char* cannotSplitPackedVarReason(const AstVar* varp);
template <class T_ALWAYSLIKE> template <typename T_ALWAYSLIKE>
void insertBeginCore(T_ALWAYSLIKE* ap, AstNodeStmt* stmtp, AstNodeModule* modp) { void insertBeginCore(T_ALWAYSLIKE* ap, AstNodeStmt* stmtp, AstNodeModule* modp) {
if (ap->isJustOneBodyStmt() && ap->stmtsp() == stmtp) { if (ap->isJustOneBodyStmt() && ap->stmtsp() == stmtp) {
stmtp->unlinkFrBack(); stmtp->unlinkFrBack();

View File

@ -22,7 +22,7 @@
namespace vlstd { namespace vlstd {
// constexpr std::max with arguments passed by value (required by constexpr before C++14) // constexpr std::max with arguments passed by value (required by constexpr before C++14)
template <class T> template <typename T>
constexpr T max(T a, T b) { constexpr T max(T a, T b) {
return a > b ? a : b; return a > b ? a : b;
} }

View File

@ -33,20 +33,20 @@
//###################################################################### //######################################################################
// Global string-related functions // Global string-related functions
template <class T> template <typename T>
std::string cvtToStr(const T& t) VL_PURE { std::string cvtToStr(const T& t) VL_PURE {
std::ostringstream os; std::ostringstream os;
os << t; os << t;
return os.str(); return os.str();
} }
template <class T> template <typename T>
typename std::enable_if<std::is_pointer<T>::value, std::string>::type typename std::enable_if<std::is_pointer<T>::value, std::string>::type
cvtToHex(const T tp) VL_PURE { cvtToHex(const T tp) VL_PURE {
std::ostringstream os; std::ostringstream os;
os << static_cast<const void*>(tp); os << static_cast<const void*>(tp);
return os.str(); return os.str();
} }
template <class T> template <typename T>
typename std::enable_if<std::is_integral<T>::value, std::string>::type cvtToHex(const T t) { typename std::enable_if<std::is_integral<T>::value, std::string>::type cvtToHex(const T t) {
std::ostringstream os; std::ostringstream os;
os << std::hex << std::setw(sizeof(T) * 8 / 4) << std::setfill('0') << t; os << std::hex << std::setw(sizeof(T) * 8 / 4) << std::setfill('0') << t;