diff --git a/bin/verilator b/bin/verilator index 36332490c..7f17581c3 100755 --- a/bin/verilator +++ b/bin/verilator @@ -284,6 +284,7 @@ detailed descriptions of these arguments. --bbox-unsup Blackbox unsupported language features --bin Override Verilator binary --build Build model executable/library after Verilation + --build-jobs Parallelism for --build --cc Create C++ output --cdc Clock domain crossing analysis -CFLAGS C++ compiler arguments for makefile @@ -334,7 +335,7 @@ detailed descriptions of these arguments. +incdir+ Directory to search for includes --inline-mult Tune module inlining --instr-count-dpi Assumed dynamic instruction count of DPI imports - -j Parallelism for --build + -j Parallelism for --build (alias to --build-jobs) --l2-name Verilog scope name of the top module --language Default language standard to parse -LDFLAGS Linker pre-object arguments for makefile diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 123d56059..92b795f38 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -129,6 +129,15 @@ Summary: is also used). Verilator manages the build itself, and for this --build requires GNU Make to be available on the platform. +.. option:: --build-jobs [] + + Specify the level of parallelism for :vlopt:`--build`. If zero, uses the + number of threads in the current hardware. Otherwise, the must + be a positive integer specifying the maximum number of parallel build + jobs. + + See also :vlopt:`-j`. + .. option:: --cc Specifies C++ without SystemC output mode; see also :vlopt:`--sc` @@ -612,11 +621,10 @@ Summary: .. option:: -j [] - Specify the level of parallelism for :vlopt:`--build`. The must - be a positive integer specifying the maximum number of parallel build - jobs, or can be omitted. When is omitted, the build will not try - to limit the number of parallel build jobs but attempt to execute all - independent build steps in parallel. + Specify the level of parallelism for :vlopt:`--build` if + :vlopt:`--build-jobs` isn't provided. If zero, uses the number of threads + in the current hardware. Otherwise, the must be a positive + integer specifying the maximum number of parallel build jobs. .. option:: --l2-name diff --git a/include/verilated.cpp b/include/verilated.cpp index ee5090507..1b5dab84b 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1003,22 +1003,22 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } } -static inline bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE { +static bool _vl_vsss_eof(FILE* fp, int floc) VL_MT_SAFE { if (VL_LIKELY(fp)) { return std::feof(fp) ? true : false; // true : false to prevent MSVC++ warning } else { return floc < 0; } } -static inline void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { +static void _vl_vsss_advance(FILE* fp, int& floc) VL_MT_SAFE { if (VL_LIKELY(fp)) { std::fgetc(fp); } else { floc -= 8; } } -static inline int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr) VL_MT_SAFE { +static int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, + const std::string& fstr) VL_MT_SAFE { // Get a character without advancing if (VL_LIKELY(fp)) { const int data = std::fgetc(fp); @@ -1035,17 +1035,16 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, const WDataInP fromp, } } } -static inline void _vl_vsss_skipspace(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr) VL_MT_SAFE { +static void _vl_vsss_skipspace(FILE* fp, int& floc, const WDataInP fromp, + const std::string& fstr) VL_MT_SAFE { while (true) { const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c == EOF || !std::isspace(c)) return; _vl_vsss_advance(fp, floc); } } -static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, - const std::string& fstr, char* tmpp, - const char* acceptp) VL_MT_SAFE { +static void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, const std::string& fstr, + char* tmpp, const char* acceptp) VL_MT_SAFE { // Read into tmp, consisting of characters from acceptp list char* cp = tmpp; while (true) { @@ -1059,9 +1058,8 @@ static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, *cp++ = '\0'; // VL_DBG_MSGF(" _read got='"<>= 1) { VL_ASSIGNBIT_WI(lsb, owp, ld & 1); } } -static inline void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const char* strp, - size_t posstart, size_t posend) VL_MT_SAFE { +static void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const char* strp, + size_t posstart, size_t posend) VL_MT_SAFE { // Read in base "2^^baseLog2" digits from strp[posstart..posend-1] into owp of size obits. int lsb = 0; for (int i = 0, pos = static_cast(posend) - 1; diff --git a/include/verilated.h b/include/verilated.h index 5700e67be..ed7f7955a 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -274,7 +274,7 @@ protected: public: /// Returns the VerilatedContext this model is instantiated under /// Used to get to e.g. simulation time via contextp()->time() - inline VerilatedContext* contextp() const { return &m_context; } + VerilatedContext* contextp() const { return &m_context; } /// Returns the hierarchical name of this module instance. virtual const char* hierName() const = 0; /// Returns the name of this model (the name of the generated model class). @@ -457,9 +457,9 @@ public: VerilatedCovContext* coveragep() VL_MT_SAFE; /// Set debug level /// Debug is currently global, but for forward compatibility have a per-context method - static void debug(int val) VL_MT_SAFE; + static inline void debug(int val) VL_MT_SAFE; /// Return debug level - static int debug() VL_MT_SAFE; + static inline int debug() VL_MT_SAFE; /// Set current number of errors/assertions void errorCount(int val) VL_MT_SAFE; /// Increment current number of errors/assertions @@ -521,7 +521,7 @@ public: /// /// * Else, time comes from the legacy 'double sc_time_stamp()' which /// must be a function defined by the user's wrapper. - uint64_t time() const VL_MT_SAFE; + inline uint64_t time() const VL_MT_SAFE; /// Set current simulation time. See time() for side effect details void time(uint64_t value) VL_MT_SAFE { m_s.m_time = value; } /// Advance current simulation time. See time() for side effect details @@ -652,13 +652,13 @@ public: // But internals only - called from VerilatedModule's const char* name() const { return m_namep; } const char* identifier() const { return m_identifierp; } int8_t timeunit() const { return m_timeunit; } - inline VerilatedSyms* symsp() const { return m_symsp; } + VerilatedSyms* symsp() const { return m_symsp; } VerilatedVar* varFind(const char* namep) const VL_MT_SAFE_POSTINIT; VerilatedVarNameMap* varsp() const VL_MT_SAFE_POSTINIT { return m_varsp; } void scopeDump() const; void* exportFindError(int funcnum) const; static void* exportFindNullError(int funcnum) VL_MT_SAFE; - static inline void* exportFind(const VerilatedScope* scopep, int funcnum) VL_MT_SAFE { + static void* exportFind(const VerilatedScope* scopep, int funcnum) VL_MT_SAFE { if (VL_UNLIKELY(!scopep)) return exportFindNullError(funcnum); if (VL_LIKELY(funcnum < scopep->m_funcnumMax)) { // m_callbacksp must be declared, as Max'es are > 0 @@ -727,7 +727,7 @@ public: /// Return debug level /// When multithreaded this may not immediately react to another thread /// changing the level (no mutex) - static inline int debug() VL_MT_SAFE { return s_debug; } + static int debug() VL_MT_SAFE { return s_debug; } #else /// Return constant 0 debug level, so C++'s optimizer rips up static constexpr int debug() VL_PURE { return 0; } @@ -933,8 +933,8 @@ private: #endif }; -inline void VerilatedContext::debug(int val) VL_MT_SAFE { Verilated::debug(val); } -inline int VerilatedContext::debug() VL_MT_SAFE { return Verilated::debug(); } +void VerilatedContext::debug(int val) VL_MT_SAFE { Verilated::debug(val); } +int VerilatedContext::debug() VL_MT_SAFE { return Verilated::debug(); } //========================================================================= // Data Types diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index caa72af85..7f68e1bad 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -181,7 +181,7 @@ void svPutPartselLogic(svLogicVecVal* dp, const svLogicVecVal s, int lbit, int w //====================================================================== // Open array internals -static inline const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHandle h) { +static const VerilatedDpiOpenVar* _vl_openhandle_varp(const svOpenArrayHandle h) { if (VL_UNLIKELY(!h)) { VL_FATAL_MT(__FILE__, __LINE__, "", "%%Error: DPI svOpenArrayHandle function called with nullptr handle"); diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index 73c821a60..8b33b4855 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -161,13 +161,13 @@ class VerilatedFstBuffer VL_NOT_FINAL { // Implementations of duck-typed methods for VerilatedTraceBuffer. These are // called from only one place (the full* methods), so always inline them. - VL_ATTR_ALWINLINE inline void emitBit(uint32_t code, CData newval); - VL_ATTR_ALWINLINE inline void emitCData(uint32_t code, CData newval, int bits); - VL_ATTR_ALWINLINE inline void emitSData(uint32_t code, SData newval, int bits); - VL_ATTR_ALWINLINE inline void emitIData(uint32_t code, IData newval, int bits); - VL_ATTR_ALWINLINE inline void emitQData(uint32_t code, QData newval, int bits); - VL_ATTR_ALWINLINE inline void emitWData(uint32_t code, const WData* newvalp, int bits); - VL_ATTR_ALWINLINE inline void emitDouble(uint32_t code, double newval); + VL_ATTR_ALWINLINE void emitBit(uint32_t code, CData newval); + VL_ATTR_ALWINLINE void emitCData(uint32_t code, CData newval, int bits); + VL_ATTR_ALWINLINE void emitSData(uint32_t code, SData newval, int bits); + VL_ATTR_ALWINLINE void emitIData(uint32_t code, IData newval, int bits); + VL_ATTR_ALWINLINE void emitQData(uint32_t code, QData newval, int bits); + VL_ATTR_ALWINLINE void emitWData(uint32_t code, const WData* newvalp, int bits); + VL_ATTR_ALWINLINE void emitDouble(uint32_t code, double newval); }; //============================================================================= @@ -232,7 +232,7 @@ public: } // Internal class access - inline VerilatedFst* spTrace() { return &m_sptrace; } + VerilatedFst* spTrace() { return &m_sptrace; } }; #endif // guard diff --git a/include/verilated_fst_sc.h b/include/verilated_fst_sc.h index ae0943d8b..f5aaa305c 100644 --- a/include/verilated_fst_sc.h +++ b/include/verilated_fst_sc.h @@ -52,35 +52,35 @@ public: } spTrace()->set_time_resolution(sc_get_time_resolution().to_string()); } - virtual ~VerilatedFstSc() /*override*/ { close(); } + ~VerilatedFstSc() override { close(); } // METHODS /// Called by SystemC simulate() - virtual void cycle(bool delta_cycle) { + void cycle(bool delta_cycle) override { if (!delta_cycle) { this->dump(sc_time_stamp().to_double()); } } // Override VerilatedFstC. Must be called after starting simulation. - // cppcheck-suppress missingOverride // GCC won't accept override - virtual void open(const char* filename) /*override*/ VL_MT_SAFE; + // Note: this is not a virtual function in the base class, so no 'override' + virtual void open(const char* filename) VL_MT_SAFE; private: /// Fake outs for linker #ifdef NC_SYSTEMC // Cadence Incisive has these as abstract functions so we must create them - virtual void set_time_unit(int exponent10_seconds) {} // deprecated + void set_time_unit(int exponent10_seconds) override {} // deprecated #endif - virtual void set_time_unit(double v, sc_time_unit tu) {} // LCOV_EXCL_LINE + void set_time_unit(double v, sc_time_unit tu) override {} // LCOV_EXCL_LINE //-------------------------------------------------- // SystemC 2.1.v1 -#define DECL_TRACE_METHOD_A(tp) virtual void trace(const tp& object, const std::string& name); +#define DECL_TRACE_METHOD_A(tp) void trace(const tp& object, const std::string& name) override; #define DECL_TRACE_METHOD_B(tp) \ - virtual void trace(const tp& object, const std::string& name, int width); + void trace(const tp& object, const std::string& name, int width) override; - virtual void write_comment(const std::string&); - virtual void trace(const unsigned int&, const std::string&, const char**); + void write_comment(const std::string&) override; + void trace(const unsigned int&, const std::string&, const char**) override; // clang-format off // Formatting matches that of sc_trace.h diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 8bcef8019..8f5027f96 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -282,7 +282,7 @@ inline uint64_t vl_time_stamp64() { # endif #endif -inline uint64_t VerilatedContext::time() const VL_MT_SAFE { +uint64_t VerilatedContext::time() const VL_MT_SAFE { // When using non-default context, fastest path is return time if (VL_LIKELY(m_s.m_time)) return m_s.m_time; #if defined(SYSTEMC_VERSION) || (!defined(VL_TIME_CONTEXT) && !defined(VL_NO_LEGACY)) diff --git a/include/verilated_imp.h b/include/verilated_imp.h index d55c7b228..cc1971d04 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -356,7 +356,7 @@ public: // But only for verilated*.cpp } } } - inline FILE* fdToFp(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) { + FILE* fdToFp(IData fdi) VL_MT_SAFE_EXCLUDES(m_fdMutex) { const VerilatedLockGuard lock{m_fdMutex}; const VerilatedFpList fdlist = fdToFpList(fdi); if (VL_UNLIKELY(fdlist.size() != 1)) return nullptr; @@ -466,7 +466,7 @@ public: // There's often many more scopes than userdata's and thus having a ~48byte // per map overhead * N scopes would take much more space and cache thrashing. // As scopep's are pointers, this implicitly handles multiple Context's - static inline void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE { + static void userInsert(const void* scopep, void* userKey, void* userData) VL_MT_SAFE { const VerilatedLockGuard lock{s().m_userMapMutex}; const auto it = s().m_userMap.find(std::make_pair(scopep, userKey)); if (it != s().m_userMap.end()) { @@ -475,7 +475,7 @@ public: s().m_userMap.emplace(std::make_pair(scopep, userKey), userData); } } - static inline void* userFind(const void* scopep, void* userKey) VL_MT_SAFE { + static void* userFind(const void* scopep, void* userKey) VL_MT_SAFE { const VerilatedLockGuard lock{s().m_userMapMutex}; const auto& it = vlstd::as_const(s().m_userMap).find(std::make_pair(scopep, userKey)); if (VL_UNLIKELY(it == s().m_userMap.end())) return nullptr; diff --git a/include/verilated_profiler.h b/include/verilated_profiler.h index a237ee5cf..5ddf3b0d9 100644 --- a/include/verilated_profiler.h +++ b/include/verilated_profiler.h @@ -45,8 +45,7 @@ class VlThreadPool; //============================================================================= // Return high-precision counter for profiling, or 0x0 if not available -VL_ATTR_ALWINLINE -inline QData VL_CPU_TICK() { +VL_ATTR_ALWINLINE QData VL_CPU_TICK() { uint64_t val; VL_GET_CPU_TICK(val); return val; @@ -171,9 +170,9 @@ public: // METHODS // Is profiling enabled - inline bool enabled() const { return m_enabled; } + bool enabled() const { return m_enabled; } // Append a trace record to the trace buffer of the current thread - static inline VlExecutionRecord& addRecord() { + static VlExecutionRecord& addRecord() { t_trace.emplace_back(); return t_trace.back(); } diff --git a/include/verilated_threads.h b/include/verilated_threads.h index 59658bf20..b595c1bca 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -103,7 +103,7 @@ public: // Upstream mtasks must call this when they complete. // Returns true when the current MTaskVertex becomes ready to execute, // false while it's still waiting on more dependencies. - inline bool signalUpstreamDone(bool evenCycle) { + bool signalUpstreamDone(bool evenCycle) { if (evenCycle) { const uint32_t upstreamDepsDone = 1 + m_upstreamDepsDone.fetch_add(1, std::memory_order_release); @@ -116,11 +116,11 @@ public: return (upstreamDepsDone_prev == 1); } } - inline bool areUpstreamDepsDone(bool evenCycle) const { + bool areUpstreamDepsDone(bool evenCycle) const { const uint32_t target = evenCycle ? m_upstreamDepCount : 0; return m_upstreamDepsDone.load(std::memory_order_acquire) == target; } - inline void waitUntilUpstreamDone(bool evenCycle) const { + void waitUntilUpstreamDone(bool evenCycle) const { unsigned ct = 0; while (VL_UNLIKELY(!areUpstreamDepsDone(evenCycle))) { VL_CPU_RELAX(); @@ -171,7 +171,7 @@ public: // METHODS template - inline void dequeWork(ExecRec* workp) VL_MT_SAFE_EXCLUDES(m_mutex) { + void dequeWork(ExecRec* workp) VL_MT_SAFE_EXCLUDES(m_mutex) { // Spin for a while, waiting for new data if VL_CONSTEXPR_CXX17 (SpinWait) { for (unsigned i = 0; i < VL_LOCK_SPINS; ++i) { @@ -191,7 +191,7 @@ public: m_ready.erase(m_ready.begin()); m_ready_size.fetch_sub(1, std::memory_order_relaxed); } - inline void addTask(VlExecFnp fnp, VlSelfP selfp, bool evenCycle = false) + void addTask(VlExecFnp fnp, VlSelfP selfp, bool evenCycle = false) VL_MT_SAFE_EXCLUDES(m_mutex) { bool notify; { @@ -223,8 +223,8 @@ public: ~VlThreadPool() override; // METHODS - inline int numThreads() const { return m_workers.size(); } - inline VlWorkerThread* workerp(int index) { + int numThreads() const { return m_workers.size(); } + VlWorkerThread* workerp(int index) { assert(index >= 0); assert(index < m_workers.size()); return m_workers[index]; diff --git a/include/verilated_trace.h b/include/verilated_trace.h index 03ca2ba2c..151d2c9f2 100644 --- a/include/verilated_trace.h +++ b/include/verilated_trace.h @@ -318,8 +318,8 @@ protected: void flushBase(); #ifdef VL_THREADED - inline bool offload() const { return m_offload; } - inline bool parallel() const { return m_parallel; } + bool offload() const { return m_offload; } + bool parallel() const { return m_parallel; } #else static constexpr bool offload() { return false; } static constexpr bool parallel() { return false; } @@ -425,7 +425,7 @@ public: // duck-typed void emitWData(uint32_t code, const WData* newvalp, int bits) = 0; // duck-typed void emitDouble(uint32_t code, double newval) = 0; - VL_ATTR_ALWINLINE inline uint32_t* oldp(uint32_t code) { return m_sigs_oldvalp + code; } + VL_ATTR_ALWINLINE uint32_t* oldp(uint32_t code) { return m_sigs_oldvalp + code; } // Write to previous value buffer value and emit trace entry. void fullBit(uint32_t* oldp, CData newval); @@ -441,27 +441,27 @@ public: // thread and are called chg*Impl // Check previous dumped value of signal. If changed, then emit trace entry - VL_ATTR_ALWINLINE inline void chgBit(uint32_t* oldp, CData newval) { + VL_ATTR_ALWINLINE void chgBit(uint32_t* oldp, CData newval) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullBit(oldp, newval); } - VL_ATTR_ALWINLINE inline void chgCData(uint32_t* oldp, CData newval, int bits) { + VL_ATTR_ALWINLINE void chgCData(uint32_t* oldp, CData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullCData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgSData(uint32_t* oldp, SData newval, int bits) { + VL_ATTR_ALWINLINE void chgSData(uint32_t* oldp, SData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullSData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgIData(uint32_t* oldp, IData newval, int bits) { + VL_ATTR_ALWINLINE void chgIData(uint32_t* oldp, IData newval, int bits) { const uint32_t diff = *oldp ^ newval; if (VL_UNLIKELY(diff)) fullIData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgQData(uint32_t* oldp, QData newval, int bits) { + VL_ATTR_ALWINLINE void chgQData(uint32_t* oldp, QData newval, int bits) { const uint64_t diff = *reinterpret_cast(oldp) ^ newval; if (VL_UNLIKELY(diff)) fullQData(oldp, newval, bits); } - VL_ATTR_ALWINLINE inline void chgWData(uint32_t* oldp, const WData* newvalp, int bits) { + VL_ATTR_ALWINLINE void chgWData(uint32_t* oldp, const WData* newvalp, int bits) { for (int i = 0; i < (bits + 31) / 32; ++i) { if (VL_UNLIKELY(oldp[i] ^ newvalp[i])) { fullWData(oldp, newvalp, bits); @@ -469,7 +469,7 @@ public: } } } - VL_ATTR_ALWINLINE inline void chgDouble(uint32_t* oldp, double newval) { + VL_ATTR_ALWINLINE void chgDouble(uint32_t* oldp, double newval) { // cppcheck-suppress invalidPointerCast if (VL_UNLIKELY(*reinterpret_cast(oldp) != newval)) fullDouble(oldp, newval); } @@ -498,48 +498,48 @@ public: // Hot path internal interface to Verilator generated code // Offloaded tracing. Just dump everything in the offload buffer - inline void chgBit(uint32_t code, CData newval) { + void chgBit(uint32_t code, CData newval) { m_offloadBufferWritep[0] = VerilatedTraceOffloadCommand::CHG_BIT_0 | newval; m_offloadBufferWritep[1] = code; m_offloadBufferWritep += 2; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgCData(uint32_t code, CData newval, int bits) { + void chgCData(uint32_t code, CData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_CDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgSData(uint32_t code, SData newval, int bits) { + void chgSData(uint32_t code, SData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_SDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgIData(uint32_t code, IData newval, int bits) { + void chgIData(uint32_t code, IData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_IDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep[2] = newval; m_offloadBufferWritep += 3; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgQData(uint32_t code, QData newval, int bits) { + void chgQData(uint32_t code, QData newval, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_QDATA; m_offloadBufferWritep[1] = code; *reinterpret_cast(m_offloadBufferWritep + 2) = newval; m_offloadBufferWritep += 4; VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgWData(uint32_t code, const WData* newvalp, int bits) { + void chgWData(uint32_t code, const WData* newvalp, int bits) { m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_WDATA; m_offloadBufferWritep[1] = code; m_offloadBufferWritep += 2; for (int i = 0; i < (bits + 31) / 32; ++i) { *m_offloadBufferWritep++ = newvalp[i]; } VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); } - inline void chgDouble(uint32_t code, double newval) { + void chgDouble(uint32_t code, double newval) { m_offloadBufferWritep[0] = VerilatedTraceOffloadCommand::CHG_DOUBLE; m_offloadBufferWritep[1] = code; // cppcheck-suppress invalidPointerCast diff --git a/include/verilated_types.h b/include/verilated_types.h index 6a9b7d074..bdcc0cdad 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -966,7 +966,7 @@ struct VlUnpacked final { // *this != that, which might be used for change detection/trigger computation, but avoid // operator overloading in VlUnpacked for safety in other contexts. - inline bool neq(const VlUnpacked& that) const { return neq(*this, that); } + bool neq(const VlUnpacked& that) const { return neq(*this, that); } // Similar to 'neq' above, *this = that used for change detection void assign(const VlUnpacked& that) { *this = that; } @@ -992,7 +992,7 @@ private: } template // - inline static bool neq(const T_Other& a, const T_Other& b) { + static bool neq(const T_Other& a, const T_Other& b) { // Base case (T_Other is not VlUnpacked<_, _>), fall back on != return a != b; } diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index ed36e6583..2d0cc57f0 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -632,10 +632,10 @@ void VerilatedVcd::commitTraceBuffer(VerilatedVcd::Buffer* bufp) { //============================================================================= // Trace rendering primitives -static inline void -VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) VL_ATTR_NO_SANITIZE_ALIGN; +static void VerilatedVcdCCopyAndAppendNewLine(char* writep, + const char* suffixp) VL_ATTR_NO_SANITIZE_ALIGN; -static inline void VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) { +static void VerilatedVcdCCopyAndAppendNewLine(char* writep, const char* suffixp) { // Copy the whole suffix (this avoid having hard to predict branches which // helps a lot). Note: The maximum length of the suffix is // VL_TRACE_MAX_VCD_CODE_SIZE + 2 == 7, but we unroll this here for speed. diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 9079ef926..2967225b1 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -73,7 +73,7 @@ private: void bufferResize(size_t minsize); void bufferFlush() VL_MT_UNSAFE_ONE; - inline void bufferCheck() { + void bufferCheck() { // Flush the write buffer if there's not enough space left for new information // We only call this once per vector, so we need enough slop for a very wide "b###" line if (VL_UNLIKELY(m_writep > m_wrFlushp)) bufferFlush(); @@ -210,13 +210,13 @@ class VerilatedVcdBuffer VL_NOT_FINAL { // Implementation of VerilatedTraceBuffer interface // Implementations of duck-typed methods for VerilatedTraceBuffer. These are // called from only one place (the full* methods), so always inline them. - VL_ATTR_ALWINLINE inline void emitBit(uint32_t code, CData newval); - VL_ATTR_ALWINLINE inline void emitCData(uint32_t code, CData newval, int bits); - VL_ATTR_ALWINLINE inline void emitSData(uint32_t code, SData newval, int bits); - VL_ATTR_ALWINLINE inline void emitIData(uint32_t code, IData newval, int bits); - VL_ATTR_ALWINLINE inline void emitQData(uint32_t code, QData newval, int bits); - VL_ATTR_ALWINLINE inline void emitWData(uint32_t code, const WData* newvalp, int bits); - VL_ATTR_ALWINLINE inline void emitDouble(uint32_t code, double newval); + VL_ATTR_ALWINLINE void emitBit(uint32_t code, CData newval); + VL_ATTR_ALWINLINE void emitCData(uint32_t code, CData newval, int bits); + VL_ATTR_ALWINLINE void emitSData(uint32_t code, SData newval, int bits); + VL_ATTR_ALWINLINE void emitIData(uint32_t code, IData newval, int bits); + VL_ATTR_ALWINLINE void emitQData(uint32_t code, QData newval, int bits); + VL_ATTR_ALWINLINE void emitWData(uint32_t code, const WData* newvalp, int bits); + VL_ATTR_ALWINLINE void emitDouble(uint32_t code, double newval); }; //============================================================================= @@ -313,7 +313,7 @@ public: } // Internal class access - inline VerilatedVcd* spTrace() { return &m_sptrace; } + VerilatedVcd* spTrace() { return &m_sptrace; } }; #endif // guard diff --git a/include/verilated_vcd_sc.h b/include/verilated_vcd_sc.h index a32134b23..c0ba6e528 100644 --- a/include/verilated_vcd_sc.h +++ b/include/verilated_vcd_sc.h @@ -55,35 +55,34 @@ public: spTrace()->set_time_resolution(sc_get_time_resolution().to_string()); } /// Destruct, flush, and close the dump - virtual ~VerilatedVcdSc() /*override*/ { close(); } + ~VerilatedVcdSc() override { close(); } // METHODS - for SC kernel // Called by SystemC simulate() - virtual void cycle(bool delta_cycle) { + void cycle(bool delta_cycle) override { if (!delta_cycle) this->dump(sc_time_stamp().to_double()); } // Override VerilatedVcdC. Must be called after starting simulation. - // cppcheck-suppress missingOverride // GCC won't accept override - virtual void open(const char* filename) /*override*/ VL_MT_SAFE; + void open(const char* filename) override VL_MT_SAFE; private: // METHODS - Fake outs for linker #ifdef NC_SYSTEMC // Cadence Incisive has these as abstract functions so we must create them - virtual void set_time_unit(int exponent10_seconds) {} // deprecated + void set_time_unit(int exponent10_seconds) override {} // deprecated #endif - virtual void set_time_unit(double v, sc_time_unit tu) {} // LCOV_EXCL_LINE + void set_time_unit(double v, sc_time_unit tu) override {} // LCOV_EXCL_LINE //-------------------------------------------------- // SystemC 2.1.v1 -#define DECL_TRACE_METHOD_A(tp) virtual void trace(const tp& object, const std::string& name); +#define DECL_TRACE_METHOD_A(tp) void trace(const tp& object, const std::string& name) override; #define DECL_TRACE_METHOD_B(tp) \ - virtual void trace(const tp& object, const std::string& name, int width); + void trace(const tp& object, const std::string& name, int width) override; - virtual void write_comment(const std::string&); - virtual void trace(const unsigned int&, const std::string&, const char**); + void write_comment(const std::string&) override; + void trace(const unsigned int&, const std::string&, const char**) override; // clang-format off // Formatting matches that of sc_trace.h diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index ff2d25c27..be58390ed 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -114,7 +114,7 @@ public: static VerilatedVpio* castp(vpiHandle h) { return dynamic_cast(reinterpret_cast(h)); } - inline vpiHandle castVpiHandle() { return reinterpret_cast(this); } + vpiHandle castVpiHandle() { return reinterpret_cast(this); } // ACCESSORS virtual const char* name() const { return ""; } virtual const char* fullname() const { return ""; } diff --git a/include/verilatedos.h b/include/verilatedos.h index 12763f815..c84e13ef0 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -39,7 +39,7 @@ #ifdef __GNUC__ # define VL_ATTR_ALIGNED(alignment) __attribute__((aligned(alignment))) -# define VL_ATTR_ALWINLINE __attribute__((always_inline)) +# define VL_ATTR_ALWINLINE __attribute__((always_inline)) inline # define VL_ATTR_NOINLINE __attribute__((noinline)) # define VL_ATTR_COLD __attribute__((cold)) # define VL_ATTR_HOT __attribute__((hot)) @@ -548,8 +548,8 @@ struct reverse_wrapper { explicit reverse_wrapper(const T& a_v) : m_v(a_v) {} - inline auto begin() -> decltype(m_v.rbegin()) { return m_v.rbegin(); } - inline auto end() -> decltype(m_v.rend()) { return m_v.rend(); } + auto begin() -> decltype(m_v.rbegin()) { return m_v.rbegin(); } + auto end() -> decltype(m_v.rend()) { return m_v.rend(); } }; // C++20's std::ranges::reverse_view diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 4cedf73e2..1e8d0cb90 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -66,8 +66,8 @@ public: : V3GraphVertex{graphp} , m_name{name} , m_type{type} {} - virtual string name() const override { return m_name + " " + typestr(); } - virtual string dotColor() const override { return user() ? "green" : "black"; } + string name() const override { return m_name + " " + typestr(); } + string dotColor() const override { return user() ? "green" : "black"; } virtual int type() const { return m_type; } }; @@ -120,7 +120,7 @@ protected: public: LatchDetectGraph() { clear(); } - virtual ~LatchDetectGraph() override { clear(); } + ~LatchDetectGraph() override { clear(); } // ACCESSORS LatchDetectGraphVertex* currentp() { return m_curVertexp; } void currentp(LatchDetectGraphVertex* vertex) { m_curVertexp = vertex; } @@ -222,7 +222,7 @@ private: } // VISITORS - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { m_scopep = nodep; m_sActivep = nullptr; m_iActivep = nullptr; @@ -232,13 +232,13 @@ private: iterateChildren(nodep); // Don't clear scopep, the namer persists beyond this visit } - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { // Simplify sensitivity list VL_DO_DANGLING(V3Const::constifyExpensiveEdit(nodep), nodep); } //-------------------- - virtual void visit(AstNodeStmt*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeStmt*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } // Specialized below for the special sensitivity classes template @@ -280,7 +280,7 @@ public: // CONSTRUCTORS ActiveNamer() = default; - virtual ~ActiveNamer() override = default; + ~ActiveNamer() override = default; void main(AstScope* nodep) { iterate(nodep); } }; @@ -313,13 +313,13 @@ private: // STATE LatchDetectGraph m_graph; // Graph used to detect latches in combo always // VISITORS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { const AstVar* const varp = nodep->varp(); if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()) { m_graph.addAssignment(nodep); } } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { if (!nodep->isBoundsCheck()) { LatchDetectGraphVertex* const parentp = m_graph.currentp(); LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true); @@ -331,7 +331,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -355,7 +355,7 @@ private: const CheckType m_check; // Process type we are checking // VISITORS - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { // Non-blocking assignments are OK in sequential processes if (m_check == CT_SEQ) return; @@ -381,7 +381,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstAssign* nodep) override { + void visit(AstAssign* nodep) override { // Blocking assignments are always OK in combinational (and initial/final) processes if (m_check != CT_SEQ) return; @@ -404,7 +404,7 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -505,36 +505,30 @@ private: } // VISITORS - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { m_namer.main(nodep); // Clear last scope's names, and collect this scope's existing names iterateChildren(nodep); } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { // Actives are being formed, so we can ignore any already made } - virtual void visit(AstInitialStatic* nodep) override { - moveUnderSpecial(nodep); - } - virtual void visit(AstInitial* nodep) override { + void visit(AstInitialStatic* nodep) override { moveUnderSpecial(nodep); } + void visit(AstInitial* nodep) override { const ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; visitSenItems(nodep); moveUnderSpecial(nodep); } - virtual void visit(AstFinal* nodep) override { + void visit(AstFinal* nodep) override { const ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; moveUnderSpecial(nodep); } - virtual void visit(AstAssignAlias* nodep) override { - moveUnderSpecial(nodep); - } - virtual void visit(AstCoverToggle* nodep) override { - moveUnderSpecial(nodep); - } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignAlias* nodep) override { moveUnderSpecial(nodep); } + void visit(AstCoverToggle* nodep) override { moveUnderSpecial(nodep); } + void visit(AstAssignW* nodep) override { visitAlways(nodep, nullptr, VAlwaysKwd::ALWAYS_COMB); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { if (!nodep->bodysp()) { // Empty always. Remove it now. VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; @@ -542,18 +536,17 @@ private: visitSenItems(nodep); visitAlways(nodep, nodep->sensesp(), nodep->keyword()); } - virtual void visit(AstAlwaysPostponed* nodep) override { + void visit(AstAlwaysPostponed* nodep) override { // Might be empty with later optimizations, so this assertion can be removed, // but for now it is guaranteed to be not empty. UASSERT_OBJ(nodep->bodysp(), nodep, "Should not be empty"); visitAlways(nodep, nullptr, VAlwaysKwd::ALWAYS); } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { visitAlways(nodep, nodep->sensesp(), VAlwaysKwd::ALWAYS); } - virtual void visit(AstCFunc* nodep) override { visitSenItems(nodep); } - - virtual void visit(AstSenItem* nodep) override { + void visit(AstCFunc* nodep) override { visitSenItems(nodep); } + void visit(AstSenItem* nodep) override { UASSERT_OBJ(!m_walkingBody, nodep, "Should not reach here when walking body without --timing"); if (!nodep->sensp()) return; // Ignore sequential items (e.g.: initial, comb, etc.) @@ -563,6 +556,7 @@ private: if (const auto* const dtypep = nodep->sensp()->dtypep()) { if (const auto* const basicp = dtypep->basicp()) { + if (basicp->isEvent()) nodep->edgeType(VEdgeType::ET_EVENT); } } @@ -573,7 +567,7 @@ private: }); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { AstVarScope* const vscp = nodep->varScopep(); if (nodep->access().isWriteOnly()) { vscp->user2(true); @@ -584,24 +578,24 @@ private: if (!vscp->user2() && !vscp->user1()) m_canBeComb = false; } } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { m_canBeComb = false; if (nodep->isTimingControl()) m_clockedProcess = true; iterateChildrenConst(nodep); } - virtual void visit(AstFireEvent* nodep) override { + void visit(AstFireEvent* nodep) override { m_canBeComb = false; iterateChildrenConst(nodep); } - virtual void visit(AstAssignForce* nodep) override { + void visit(AstAssignForce* nodep) override { m_canBeComb = false; iterateChildrenConst(nodep); } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { m_canBeComb = false; iterateChildrenConst(nodep); } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (nodep->isTimingControl()) { m_canBeComb = false; m_clockedProcess = true; @@ -610,9 +604,9 @@ private: } //-------------------- - virtual void visit(AstVar*) override {} // Accelerate - virtual void visit(AstVarScope*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { + void visit(AstVar*) override {} // Accelerate + void visit(AstVarScope*) override {} // Accelerate + void visit(AstNode* nodep) override { if (!v3Global.opt.timing().isSetTrue() && m_walkingBody && !m_canBeComb) { return; // Accelerate } diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 8e5ba7ff8..39b9b54df 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -60,13 +60,13 @@ class ActiveTopVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Create required actives and add to module // We can start ordering at a module, or a scope UINFO(4, " MOD " << nodep << endl); iterateChildren(nodep); } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { UINFO(4, " ACTIVE " << nodep << endl); // Remove duplicate clocks and such; sensesp() may change! V3Const::constifyExpensiveEdit(nodep); @@ -115,27 +115,27 @@ class ActiveTopVisitor final : public VNVisitor { if (initialp) nodep->addHereThisAsNext(initialp); } } - virtual void visit(AstNodeProcedure* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodeProcedure* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("Node should have been under ACTIVE"); } - virtual void visit(AstAssignAlias* nodep) override { // LCOV_EXCL_LINE + void visit(AstAssignAlias* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("Node should have been under ACTIVE"); } - virtual void visit(AstAssignW* nodep) override { // LCOV_EXCL_LINE + void visit(AstAssignW* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("Node should have been under ACTIVE"); } - virtual void visit(AstAlwaysPublic* nodep) override { // LCOV_EXCL_LINE + void visit(AstAlwaysPublic* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("Node should have been under ACTIVE"); } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstVarScope*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstVarScope*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ActiveTopVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ActiveTopVisitor() override = default; + ~ActiveTopVisitor() override = default; }; //###################################################################### diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 5a46f1ad9..f8d73be67 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -202,7 +202,7 @@ private: } // VISITORS - virtual void visit(AstIf* nodep) override { + void visit(AstIf* nodep) override { if (nodep->user1SetOnce()) return; if (nodep->uniquePragma() || nodep->unique0Pragma()) { const AstNodeIf* ifp = nodep; @@ -260,7 +260,7 @@ private: } //========== Case assertions - virtual void visit(AstCase* nodep) override { + void visit(AstCase* nodep) override { iterateChildren(nodep); if (!nodep->user1SetOnce()) { bool has_default = false; @@ -329,7 +329,7 @@ private: } //========== Past - virtual void visit(AstPast* nodep) override { + void visit(AstPast* nodep) override { iterateChildren(nodep); uint32_t ticks = 1; if (nodep->ticksp()) { @@ -362,7 +362,7 @@ private: } //========== Move $sampled down to read-only variables - virtual void visit(AstSampled* nodep) override { + void visit(AstSampled* nodep) override { if (nodep->user1()) return; VL_RESTORER(m_inSampled); { @@ -372,7 +372,7 @@ private: nodep->replaceWith(nodep->exprp()->unlinkFrBack()); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { iterateChildren(nodep); if (m_inSampled) { if (!nodep->access().isReadOnly()) { @@ -388,7 +388,7 @@ private: } } // Don't sample sensitivities - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { VL_RESTORER(m_inSampled); { m_inSampled = false; @@ -397,7 +397,7 @@ private: } //========== Statements - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { iterateChildren(nodep); // Replace the special types with standard text if (nodep->displayType() == VDisplayType::DT_INFO) { @@ -448,32 +448,32 @@ private: m_modp->addStmtp(newp); } } - virtual void visit(AstMonitorOff* nodep) override { + void visit(AstMonitorOff* nodep) override { const auto newp = new AstAssign(nodep->fileline(), newMonitorOffVarRefp(nodep, VAccess::WRITE), new AstConst(nodep->fileline(), AstConst::BitTrue{}, nodep->off())); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstAssert* nodep) override { + void visit(AstAssert* nodep) override { iterateChildren(nodep); newPslAssertion(nodep, nodep->failsp()); } - virtual void visit(AstAssertIntrinsic* nodep) override { + void visit(AstAssertIntrinsic* nodep) override { iterateChildren(nodep); newPslAssertion(nodep, nodep->failsp()); } - virtual void visit(AstCover* nodep) override { + void visit(AstCover* nodep) override { iterateChildren(nodep); newPslAssertion(nodep, nullptr); } - virtual void visit(AstRestrict* nodep) override { + void visit(AstRestrict* nodep) override { iterateChildren(nodep); // IEEE says simulator ignores these VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); VL_RESTORER(m_modPastNum); VL_RESTORER(m_modStrobeNum); @@ -484,7 +484,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { // This code is needed rather than a visitor in V3Begin, // because V3Assert is called before V3Begin VL_RESTORER(m_beginp); @@ -494,12 +494,12 @@ private: } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit AssertVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~AssertVisitor() override { + ~AssertVisitor() override { V3Stats::addStat("Assertions, assert non-immediate statements", m_statAsNotImm); V3Stats::addStat("Assertions, assert immediate statements", m_statAsImm); V3Stats::addStat("Assertions, cover statements", m_statCover); diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 705dfcbb2..e993bd432 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -69,7 +69,7 @@ private: // VISITORS //========== Statements - virtual void visit(AstClocking* nodep) override { + void visit(AstClocking* nodep) override { UINFO(8, " CLOCKING" << nodep << endl); // Store the new default clock, reset on new module m_seniDefaultp = nodep->sensesp(); @@ -81,14 +81,14 @@ private: } VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { iterateAndNextNull(nodep->sensesp()); if (nodep->sensesp()) m_seniAlwaysp = nodep->sensesp()->sensesp(); iterateAndNextNull(nodep->bodysp()); m_seniAlwaysp = nullptr; } - virtual void visit(AstNodeCoverOrAssert* nodep) override { + void visit(AstNodeCoverOrAssert* nodep) override { if (nodep->sentreep()) return; // Already processed clearAssertInfo(); // Find Clocking's buried under nodep->exprsp @@ -96,7 +96,7 @@ private: if (!nodep->immediate()) nodep->sentreep(newSenTree(nodep)); clearAssertInfo(); } - virtual void visit(AstFell* nodep) override { + void visit(AstFell* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); FileLine* const fl = nodep->fileline(); @@ -110,12 +110,12 @@ private: nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstPast* nodep) override { + void visit(AstPast* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); nodep->sentreep(newSenTree(nodep)); } - virtual void visit(AstRose* nodep) override { + void visit(AstRose* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); FileLine* const fl = nodep->fileline(); @@ -129,7 +129,7 @@ private: nodep->sentreep(newSenTree(nodep)); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstStable* nodep) override { + void visit(AstStable* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); FileLine* const fl = nodep->fileline(); @@ -143,7 +143,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstImplication* nodep) override { + void visit(AstImplication* nodep) override { if (nodep->sentreep()) return; // Already processed FileLine* const fl = nodep->fileline(); @@ -161,7 +161,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstPropClocked* nodep) override { + void visit(AstPropClocked* nodep) override { // No need to iterate the body, once replace will get iterated iterateAndNextNull(nodep->sensesp()); if (m_senip) @@ -183,12 +183,12 @@ private: nodep->replaceWith(blockp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { iterateChildren(nodep); // Reset defaults m_seniDefaultp = nullptr; } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -197,7 +197,7 @@ public: // Process iterate(nodep); } - virtual ~AssertPreVisitor() override = default; + ~AssertPreVisitor() override = default; }; //###################################################################### diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 7694e1e69..4a516e6be 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -212,8 +212,7 @@ string AstNode::prettyTypeName() const { //###################################################################### // Insertion -inline void AstNode::debugTreeChange(const AstNode* nodep, const char* prefix, int lineno, - bool next) { +void AstNode::debugTreeChange(const AstNode* nodep, const char* prefix, int lineno, bool next) { #ifdef VL_DEBUG // Called on all major tree changers. // Only for use for those really nasty bugs relating to internals @@ -927,7 +926,7 @@ AstNode* AstNode::iterateSubtreeReturnEdits(VNVisitor& v) { } else if (!nodep->backp()) { // Calling on standalone tree; insert a shim node so we can keep // track, then delete it on completion - AstBegin* const tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); + AstBegin* const tempp = new AstBegin{nodep->fileline(), "[EditWrapper]", nodep}; { VL_DO_DANGLING(tempp->stmtsp()->accept(v), nodep); // nodep to null as may be replaced diff --git a/src/V3Ast.h b/src/V3Ast.h index 51a87de54..459ffc6cf 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -93,11 +93,11 @@ public: // const char* ascii() const {...}; enum en m_e; // cppcheck-suppress uninitVar // responsibility of each subclass - inline VNType() = default; + VNType() = default; // cppcheck-suppress noExplicitConstructor - inline VNType(en _e) + VNType(en _e) : m_e{_e} {} - explicit inline VNType(int _e) + explicit VNType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -116,12 +116,12 @@ public: static const char* const names[] = {"NONE", "VAUTOM", "VSTATIC"}; return names[m_e]; } - inline VLifetime() + VLifetime() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VLifetime(en _e) + VLifetime(en _e) : m_e{_e} {} - explicit inline VLifetime(int _e) + explicit VLifetime(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool isNone() const { return m_e == NONE; } @@ -157,16 +157,16 @@ public: static const char* const names[] = {"[RV] <-", "[LV] =>", "[LV] <=>", "--"}; return names[m_e]; } - inline VAccess() + VAccess() : m_e{READ} {} // cppcheck-suppress noExplicitConstructor - inline VAccess(en _e) + VAccess(en _e) : m_e{_e} {} - explicit inline VAccess(int _e) + explicit VAccess(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } VAccess invert() const { - return (m_e == READWRITE) ? VAccess(m_e) : (m_e == WRITE ? VAccess(READ) : VAccess(WRITE)); + return (m_e == READWRITE) ? VAccess{m_e} : (m_e == WRITE ? VAccess{READ} : VAccess{WRITE}); } bool isReadOnly() const { return m_e == READ; } // False with READWRITE bool isWriteOnly() const { return m_e == WRITE; } // False with READWRITE @@ -194,19 +194,19 @@ public: static const char* const names[] = {"UNSIGNED", "SIGNED", "NOSIGN"}; return names[m_e]; } - inline VSigning() + VSigning() : m_e{UNSIGNED} {} // cppcheck-suppress noExplicitConstructor - inline VSigning(en _e) + VSigning(en _e) : m_e{_e} {} - static inline VSigning fromBool(bool isSigned) { // Factory method - return isSigned ? VSigning(SIGNED) : VSigning(UNSIGNED); + static VSigning fromBool(bool isSigned) { // Factory method + return isSigned ? VSigning{SIGNED} : VSigning{UNSIGNED}; } - explicit inline VSigning(int _e) + explicit VSigning(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } - inline bool isSigned() const { return m_e == SIGNED; } - inline bool isNosign() const { return m_e == NOSIGN; } + bool isSigned() const { return m_e == SIGNED; } + bool isNosign() const { return m_e == NOSIGN; } // No isUnsigned() as it's ambiguous if NOSIGN should be included or not. }; inline bool operator==(const VSigning& lhs, const VSigning& rhs) { return lhs.m_e == rhs.m_e; } @@ -234,12 +234,12 @@ public: ENUM_SIZE }; enum en m_e; - inline VPragmaType() + VPragmaType() : m_e{ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VPragmaType(en _e) + VPragmaType(en _e) : m_e{_e} {} - explicit inline VPragmaType(int _e) + explicit VPragmaType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -330,12 +330,12 @@ public: } return false; } - inline VEdgeType() + VEdgeType() : m_e{ET_ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VEdgeType(en _e) + VEdgeType(en _e) : m_e{_e} {} - explicit inline VEdgeType(int _e) + explicit VEdgeType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -411,12 +411,12 @@ public: // clang-format on return names[m_e]; } - inline VAttrType() + VAttrType() : m_e{ILLEGAL} {} // cppcheck-suppress noExplicitConstructor - inline VAttrType(en _e) + VAttrType(en _e) : m_e{_e} {} - explicit inline VAttrType(int _e) + explicit VAttrType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -515,17 +515,17 @@ public: return names[m_e]; } static void selfTest() { - UASSERT(0 == std::strcmp(VBasicDTypeKwd(_ENUM_MAX).ascii(), " MAX"), + UASSERT(0 == std::strcmp(VBasicDTypeKwd{_ENUM_MAX}.ascii(), " MAX"), "SelfTest: Enum mismatch"); - UASSERT(0 == std::strcmp(VBasicDTypeKwd(_ENUM_MAX).dpiType(), " MAX"), + UASSERT(0 == std::strcmp(VBasicDTypeKwd{_ENUM_MAX}.dpiType(), " MAX"), "SelfTest: Enum mismatch"); } - inline VBasicDTypeKwd() + VBasicDTypeKwd() : m_e{UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBasicDTypeKwd(en _e) + VBasicDTypeKwd(en _e) : m_e{_e} {} - explicit inline VBasicDTypeKwd(int _e) + explicit VBasicDTypeKwd(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } int width() const { @@ -628,12 +628,12 @@ class VDirection final { public: enum en : uint8_t { NONE, INPUT, OUTPUT, INOUT, REF, CONSTREF }; enum en m_e; - inline VDirection() + VDirection() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VDirection(en _e) + VDirection(en _e) : m_e{_e} {} - explicit inline VDirection(int _e) + explicit VDirection(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -674,12 +674,12 @@ public: enum en : uint8_t { BU_FALSE = 0, BU_TRUE = 1, BU_UNKNOWN = 2, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VBoolOrUnknown() + VBoolOrUnknown() : m_e{BU_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBoolOrUnknown(en _e) + VBoolOrUnknown(en _e) : m_e{_e} {} - explicit inline VBoolOrUnknown(int _e) + explicit VBoolOrUnknown(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning const char* ascii() const { static const char* const names[] = {"FALSE", "TRUE", "UNK"}; @@ -713,12 +713,12 @@ public: enum en : uint8_t { JOIN = 0, JOIN_ANY = 1, JOIN_NONE = 2 }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VJoinType() + VJoinType() : m_e{JOIN} {} // cppcheck-suppress noExplicitConstructor - inline VJoinType(en _e) + VJoinType(en _e) : m_e{_e} {} - explicit inline VJoinType(int _e) + explicit VJoinType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning const char* ascii() const { static const char* const names[] = {"JOIN", "JOIN_ANY", "JOIN_NONE"}; @@ -766,12 +766,12 @@ public: MEMBER }; enum en m_e; - inline VVarType() + VVarType() : m_e{UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VVarType(en _e) + VVarType(en _e) : m_e{_e} {} - explicit inline VVarType(int _e) + explicit VVarType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -818,12 +818,12 @@ public: enum en : uint8_t { BP_UNKNOWN = 0, BP_LIKELY, BP_UNLIKELY, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VBranchPred() + VBranchPred() : m_e{BP_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VBranchPred(en _e) + VBranchPred(en _e) : m_e{_e} {} - explicit inline VBranchPred(int _e) + explicit VBranchPred(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool unknown() const { return m_e == BP_UNKNOWN; } @@ -859,12 +859,12 @@ public: enum en : uint8_t { CLOCKER_UNKNOWN = 0, CLOCKER_YES, CLOCKER_NO, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline VVarAttrClocker() + VVarAttrClocker() : m_e{CLOCKER_UNKNOWN} {} // cppcheck-suppress noExplicitConstructor - inline VVarAttrClocker(en _e) + VVarAttrClocker(en _e) : m_e{_e} {} - explicit inline VVarAttrClocker(int _e) + explicit VVarAttrClocker(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool unknown() const { return m_e == CLOCKER_UNKNOWN; } @@ -901,12 +901,12 @@ class VAlwaysKwd final { public: enum en : uint8_t { ALWAYS, ALWAYS_FF, ALWAYS_LATCH, ALWAYS_COMB }; enum en m_e; - inline VAlwaysKwd() + VAlwaysKwd() : m_e{ALWAYS} {} // cppcheck-suppress noExplicitConstructor - inline VAlwaysKwd(en _e) + VAlwaysKwd(en _e) : m_e{_e} {} - explicit inline VAlwaysKwd(int _e) + explicit VAlwaysKwd(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -924,12 +924,12 @@ class VCaseType final { public: enum en : uint8_t { CT_CASE, CT_CASEX, CT_CASEZ, CT_CASEINSIDE }; enum en m_e; - inline VCaseType() + VCaseType() : m_e{CT_CASE} {} // cppcheck-suppress noExplicitConstructor - inline VCaseType(en _e) + VCaseType(en _e) : m_e{_e} {} - explicit inline VCaseType(int _e) + explicit VCaseType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; @@ -957,7 +957,7 @@ public: // cppcheck-suppress noExplicitConstructor VDisplayType(en _e) : m_e{_e} {} - explicit inline VDisplayType(int _e) + explicit VDisplayType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool addNewline() const { return m_e != DT_WRITE; } @@ -980,12 +980,12 @@ class VDumpCtlType final { public: enum en : uint8_t { FILE, VARS, ALL, FLUSH, LIMIT, OFF, ON }; enum en m_e; - inline VDumpCtlType() + VDumpCtlType() : m_e{ON} {} // cppcheck-suppress noExplicitConstructor - inline VDumpCtlType(en _e) + VDumpCtlType(en _e) : m_e{_e} {} - explicit inline VDumpCtlType(int _e) + explicit VDumpCtlType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -1010,12 +1010,12 @@ public: PX_TEXT // Unknown ID component }; enum en m_e; - inline VParseRefExp() + VParseRefExp() : m_e{PX_NONE} {} // cppcheck-suppress noExplicitConstructor - inline VParseRefExp(en _e) + VParseRefExp(en _e) : m_e{_e} {} - explicit inline VParseRefExp(int _e) + explicit VParseRefExp(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { @@ -1039,9 +1039,10 @@ public: enum en : uint8_t { HIGHZ, SMALL, MEDIUM, WEAK, LARGE, PULL, STRONG, SUPPLY }; enum en m_e; - inline VStrength(en strengthLevel) + // cppcheck-suppress noExplicitConstructor + VStrength(en strengthLevel) : m_e(strengthLevel) {} - explicit inline VStrength(int _e) + explicit VStrength(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } @@ -1133,12 +1134,12 @@ public: INT_FWD_CLASS, // Interface (.h) needs a forward class declaration }; enum en m_e; - inline VUseType() + VUseType() : m_e{IMP_FWD_CLASS} {} // cppcheck-suppress noExplicitConstructor - inline VUseType(en _e) + VUseType(en _e) : m_e{_e} {} - explicit inline VUseType(int _e) + explicit VUseType(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning bool isInclude() const { return m_e == IMP_INCLUDE || m_e == INT_INCLUDE; } bool isFwdClass() const { return m_e == IMP_FWD_CLASS || m_e == INT_FWD_CLASS; } @@ -1225,7 +1226,7 @@ public: AstNode* toNodep() const { return to(); } V3GraphVertex* toGraphVertex() const { return to(); } int toInt() const { return m_u.ui; } - static VNUser fromInt(int i) { return VNUser(i); } + static VNUser fromInt(int i) { return VNUser{i}; } }; //###################################################################### @@ -1362,23 +1363,23 @@ class VNVisitor VL_NOT_FINAL : public VNDeleter { public: /// Call visit()s on nodep - void iterate(AstNode* nodep); + inline void iterate(AstNode* nodep); /// Call visit()s on nodep - void iterateNull(AstNode* nodep); + inline void iterateNull(AstNode* nodep); /// Call visit()s on nodep's children - void iterateChildren(AstNode* nodep); + inline void iterateChildren(AstNode* nodep); /// Call visit()s on nodep's children in backp() order - void iterateChildrenBackwards(AstNode* nodep); + inline void iterateChildrenBackwards(AstNode* nodep); /// Call visit()s on const nodep's children - void iterateChildrenConst(AstNode* nodep); + inline void iterateChildrenConst(AstNode* nodep); /// Call visit()s on nodep (maybe nullptr) and nodep's nextp() list - void iterateAndNextNull(AstNode* nodep); + inline void iterateAndNextNull(AstNode* nodep); /// Call visit()s on const nodep (maybe nullptr) and nodep's nextp() list - void iterateAndNextConstNull(AstNode* nodep); + inline void iterateAndNextConstNull(AstNode* nodep); /// Call visit()s on const nodep (maybe nullptr) and nodep's nextp() list, in reverse order - void iterateAndNextConstNullBackwards(AstNode* nodep); + inline void iterateAndNextConstNullBackwards(AstNode* nodep); /// Return edited nodep; see comments in V3Ast.cpp - AstNode* iterateSubtreeReturnEdits(AstNode* nodep); + inline AstNode* iterateSubtreeReturnEdits(AstNode* nodep); virtual void visit(AstNode* nodep) = 0; #include "V3Ast__gen_visitor_decls.h" // From ./astgen @@ -1406,7 +1407,7 @@ protected: public: VNRelinker() = default; - void relink(AstNode* newp); + inline void relink(AstNode* newp); AstNode* oldp() const { return m_oldp; } void dump(std::ostream& str = std::cout) const; }; @@ -1491,15 +1492,15 @@ class AstNode VL_NOT_FINAL { static int s_cloneCntGbl; // Count of which userp is set // This member ordering both allows 64 bit alignment and puts associated data together - VNUser m_user1u = VNUser{0}; // Contains any information the user iteration routine wants + VNUser m_user1u{0}; // Contains any information the user iteration routine wants uint32_t m_user1Cnt = 0; // Mark of when userp was set uint32_t m_user2Cnt = 0; // Mark of when userp was set - VNUser m_user2u = VNUser{0}; // Contains any information the user iteration routine wants - VNUser m_user3u = VNUser{0}; // Contains any information the user iteration routine wants + VNUser m_user2u{0}; // Contains any information the user iteration routine wants + VNUser m_user3u{0}; // Contains any information the user iteration routine wants uint32_t m_user3Cnt = 0; // Mark of when userp was set uint32_t m_user4Cnt = 0; // Mark of when userp was set - VNUser m_user4u = VNUser{0}; // Contains any information the user iteration routine wants - VNUser m_user5u = VNUser{0}; // Contains any information the user iteration routine wants + VNUser m_user4u{0}; // Contains any information the user iteration routine wants + VNUser m_user5u{0}; // Contains any information the user iteration routine wants uint32_t m_user5Cnt = 0; // Mark of when userp was set // METHODS @@ -1578,7 +1579,7 @@ protected: public: // ACCESSORS - inline VNType type() const { return m_type; } + VNType type() const { return m_type; } const char* typeName() const { return type().ascii(); } // See also prettyTypeName AstNode* nextp() const { return m_nextp; } AstNode* backp() const { return m_backp; } @@ -1660,8 +1661,8 @@ public: virtual string prettyOperatorName() const { return "operator " + prettyTypeName(); } FileLine* fileline() const { return m_fileline; } void fileline(FileLine* fl) { m_fileline = fl; } - bool width1() const; - int widthInstrs() const; + inline bool width1() const; + inline int widthInstrs() const; void didWidth(bool flag) { m_flags.didWidth = flag; } bool didWidth() const { return m_flags.didWidth; } bool didWidthAndSet() { @@ -1675,29 +1676,29 @@ public: void protect(bool flag) { m_flags.protect = flag; } // TODO stomp these width functions out, and call via dtypep() instead - int width() const; - int widthMin() const; + inline int width() const; + inline int widthMin() const; int widthMinV() const { return v3Global.widthMinUsage() == VWidthMinUsage::VERILOG_WIDTH ? widthMin() : width(); } int widthWords() const { return VL_WORDS_I(width()); } bool isQuad() const { return (width() > VL_IDATASIZE && width() <= VL_QUADSIZE); } bool isWide() const { return (width() > VL_QUADSIZE); } - bool isDouble() const; - bool isSigned() const; - bool isString() const; + inline bool isDouble() const; + inline bool isSigned() const; + inline bool isString() const; // clang-format off VNUser user1u() const { // Slows things down measurably, so disabled by default //UASSERT_STATIC(VNUser1InUse::s_userBusy, "userp set w/o busy"); - return ((m_user1Cnt==VNUser1InUse::s_userCntGbl) ? m_user1u : VNUser(0)); + return ((m_user1Cnt==VNUser1InUse::s_userCntGbl) ? m_user1u : VNUser{0}); } AstNode* user1p() const { return user1u().toNodep(); } void user1u(const VNUser& user) { m_user1u=user; m_user1Cnt=VNUser1InUse::s_userCntGbl; } - void user1p(void* userp) { user1u(VNUser(userp)); } + void user1p(void* userp) { user1u(VNUser{userp}); } int user1() const { return user1u().toInt(); } - void user1(int val) { user1u(VNUser(val)); } + void user1(int val) { user1u(VNUser{val}); } int user1Inc(int val=1) { int v=user1(); user1(v+val); return v; } int user1SetOnce() { int v=user1(); if (!v) user1(1); return v; } // Better for cache than user1Inc() static void user1ClearTree() { VNUser1InUse::clear(); } // Clear userp()'s across the entire tree @@ -1705,13 +1706,13 @@ public: VNUser user2u() const { // Slows things down measurably, so disabled by default //UASSERT_STATIC(VNUser2InUse::s_userBusy, "userp set w/o busy"); - return ((m_user2Cnt==VNUser2InUse::s_userCntGbl) ? m_user2u : VNUser(0)); + return ((m_user2Cnt==VNUser2InUse::s_userCntGbl) ? m_user2u : VNUser{0}); } AstNode* user2p() const { return user2u().toNodep(); } void user2u(const VNUser& user) { m_user2u=user; m_user2Cnt=VNUser2InUse::s_userCntGbl; } - void user2p(void* userp) { user2u(VNUser(userp)); } + void user2p(void* userp) { user2u(VNUser{userp}); } int user2() const { return user2u().toInt(); } - void user2(int val) { user2u(VNUser(val)); } + void user2(int val) { user2u(VNUser{val}); } int user2Inc(int val=1) { int v=user2(); user2(v+val); return v; } int user2SetOnce() { int v=user2(); if (!v) user2(1); return v; } // Better for cache than user2Inc() static void user2ClearTree() { VNUser2InUse::clear(); } // Clear userp()'s across the entire tree @@ -1719,13 +1720,13 @@ public: VNUser user3u() const { // Slows things down measurably, so disabled by default //UASSERT_STATIC(VNUser3InUse::s_userBusy, "userp set w/o busy"); - return ((m_user3Cnt==VNUser3InUse::s_userCntGbl) ? m_user3u : VNUser(0)); + return ((m_user3Cnt==VNUser3InUse::s_userCntGbl) ? m_user3u : VNUser{0}); } AstNode* user3p() const { return user3u().toNodep(); } void user3u(const VNUser& user) { m_user3u=user; m_user3Cnt=VNUser3InUse::s_userCntGbl; } - void user3p(void* userp) { user3u(VNUser(userp)); } + void user3p(void* userp) { user3u(VNUser{userp}); } int user3() const { return user3u().toInt(); } - void user3(int val) { user3u(VNUser(val)); } + void user3(int val) { user3u(VNUser{val}); } int user3Inc(int val=1) { int v=user3(); user3(v+val); return v; } int user3SetOnce() { int v=user3(); if (!v) user3(1); return v; } // Better for cache than user3Inc() static void user3ClearTree() { VNUser3InUse::clear(); } // Clear userp()'s across the entire tree @@ -1733,13 +1734,13 @@ public: VNUser user4u() const { // Slows things down measurably, so disabled by default //UASSERT_STATIC(VNUser4InUse::s_userBusy, "userp set w/o busy"); - return ((m_user4Cnt==VNUser4InUse::s_userCntGbl) ? m_user4u : VNUser(0)); + return ((m_user4Cnt==VNUser4InUse::s_userCntGbl) ? m_user4u : VNUser{0}); } AstNode* user4p() const { return user4u().toNodep(); } void user4u(const VNUser& user) { m_user4u=user; m_user4Cnt=VNUser4InUse::s_userCntGbl; } - void user4p(void* userp) { user4u(VNUser(userp)); } + void user4p(void* userp) { user4u(VNUser{userp}); } int user4() const { return user4u().toInt(); } - void user4(int val) { user4u(VNUser(val)); } + void user4(int val) { user4u(VNUser{val}); } int user4Inc(int val=1) { int v=user4(); user4(v+val); return v; } int user4SetOnce() { int v=user4(); if (!v) user4(1); return v; } // Better for cache than user4Inc() static void user4ClearTree() { VNUser4InUse::clear(); } // Clear userp()'s across the entire tree @@ -1747,13 +1748,13 @@ public: VNUser user5u() const { // Slows things down measurably, so disabled by default //UASSERT_STATIC(VNUser5InUse::s_userBusy, "userp set w/o busy"); - return ((m_user5Cnt==VNUser5InUse::s_userCntGbl) ? m_user5u : VNUser(0)); + return ((m_user5Cnt==VNUser5InUse::s_userCntGbl) ? m_user5u : VNUser{0}); } AstNode* user5p() const { return user5u().toNodep(); } void user5u(const VNUser& user) { m_user5u=user; m_user5Cnt=VNUser5InUse::s_userCntGbl; } - void user5p(void* userp) { user5u(VNUser(userp)); } + void user5p(void* userp) { user5u(VNUser{userp}); } int user5() const { return user5u().toInt(); } - void user5(int val) { user5u(VNUser(val)); } + void user5(int val) { user5u(VNUser{val}); } int user5Inc(int val=1) { int v=user5(); user5(v+val); return v; } int user5SetOnce() { int v=user5(); if (!v) user5(1); return v; } // Better for cache than user5Inc() static void user5ClearTree() { VNUser5InUse::clear(); } // Clear userp()'s across the entire tree @@ -1769,11 +1770,11 @@ public: // ACCESSORS for specific types // Alas these can't be virtual or they break when passed a nullptr - bool isZero() const; - bool isOne() const; - bool isNeqZero() const; - bool isAllOnes() const; - bool isAllOnesV() const; // Verilog width rules apply + inline bool isZero() const; + inline bool isOne() const; + inline bool isNeqZero() const; + inline bool isAllOnes() const; + inline bool isAllOnesV() const; // Verilog width rules apply // METHODS - data type changes especially for initial creation void dtypep(AstNodeDType* nodep) { @@ -1885,9 +1886,9 @@ public: } AstNode* cloneTree(bool cloneNextLink); // Not const, as sets clonep() on original nodep bool gateTree() { return gateTreeIter(); } // Is tree isGateOptimizable? - bool sameTree(const AstNode* node2p) const; // Does tree of this == node2p? + inline bool sameTree(const AstNode* node2p) const; // Does tree of this == node2p? // Does tree of this == node2p?, not allowing non-isGateOptimizable - bool sameGateTree(const AstNode* node2p) const; + inline bool sameGateTree(const AstNode* node2p) const; void deleteTree(); // Always deletes the next link void checkTree(); // User Interface version void checkIter() const; @@ -1987,7 +1988,7 @@ private: public: // For use via the VN_IS macro only template - inline static bool privateIs(const AstNode* nodep) { + static bool privateIs(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_IS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_IS, node cannot be this type."); return nodep && privateTypeTest(nodep); @@ -1995,14 +1996,14 @@ public: // For use via the VN_CAST macro only template - inline static T* privateCast(AstNode* nodep) { + static T* privateCast(AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_CAST, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } template - inline static const T* privateCast(const AstNode* nodep) { + static const T* privateCast(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_CAST, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); @@ -2011,7 +2012,7 @@ public: // For use via the VN_AS macro only template - inline static T* privateAs(AstNode* nodep) { + static T* privateAs(AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, @@ -2020,7 +2021,7 @@ public: return reinterpret_cast(nodep); } template - inline static const T* privateAs(const AstNode* nodep) { + static const T* privateAs(const AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, @@ -2239,7 +2240,7 @@ void AstNode::foreachImpl(ConstCorrectAstNode* nodep, const std::function constexpr int prefetchDistance = 2; // Grow stack to given size - const auto grow = [&](size_t size) VL_ATTR_ALWINLINE { + const auto grow = [&](size_t size) { const ptrdiff_t occupancy = topp - basep; stack.resize(size); basep = stack.data() + prefetchDistance; @@ -2255,7 +2256,7 @@ void AstNode::foreachImpl(ConstCorrectAstNode* nodep, const std::function for (int i = -prefetchDistance; i; ++i) basep[i] = nodep; // Visit given node, enqueue children for traversal - const auto visit = [&](Node* currp) VL_ATTR_ALWINLINE { + const auto visit = [&](Node* currp) { // Type test this node if (AstNode::privateTypeTest(currp)) { // Call the client function @@ -2320,7 +2321,7 @@ bool AstNode::predicateImpl(ConstCorrectAstNode* nodep, constexpr int prefetchDistance = 2; // Grow stack to given size - const auto grow = [&](size_t size) VL_ATTR_ALWINLINE { + const auto grow = [&](size_t size) { const ptrdiff_t occupancy = topp - basep; stack.resize(size); basep = stack.data() + prefetchDistance; @@ -2336,7 +2337,7 @@ bool AstNode::predicateImpl(ConstCorrectAstNode* nodep, for (int i = -prefetchDistance; i; ++i) basep[i] = nodep; // Visit given node, enqueue children for traversal, return true if result determined. - const auto visit = [&](Node* currp) VL_ATTR_ALWINLINE { + const auto visit = [&](Node* currp) { // Type test this node if (AstNode::privateTypeTest(currp)) { // Call the client function @@ -2389,7 +2390,7 @@ inline std::ostream& operator<<(std::ostream& os, const AstNode* rhs) { } return os; } -inline void VNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); } +void VNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); } //###################################################################### @@ -2436,58 +2437,36 @@ struct std::equal_to> final { //###################################################################### // Inline VNVisitor METHODS -inline void VNVisitor::iterate(AstNode* nodep) { nodep->accept(*this); } -inline void VNVisitor::iterateNull(AstNode* nodep) { +void VNVisitor::iterate(AstNode* nodep) { nodep->accept(*this); } +void VNVisitor::iterateNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->accept(*this); } -inline void VNVisitor::iterateChildren(AstNode* nodep) { nodep->iterateChildren(*this); } -inline void VNVisitor::iterateChildrenBackwards(AstNode* nodep) { +void VNVisitor::iterateChildren(AstNode* nodep) { nodep->iterateChildren(*this); } +void VNVisitor::iterateChildrenBackwards(AstNode* nodep) { nodep->iterateChildrenBackwards(*this); } -inline void VNVisitor::iterateChildrenConst(AstNode* nodep) { nodep->iterateChildrenConst(*this); } -inline void VNVisitor::iterateAndNextNull(AstNode* nodep) { +void VNVisitor::iterateChildrenConst(AstNode* nodep) { nodep->iterateChildrenConst(*this); } +void VNVisitor::iterateAndNextNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateAndNext(*this); } -inline void VNVisitor::iterateAndNextConstNullBackwards(AstNode* nodep) { +void VNVisitor::iterateAndNextConstNullBackwards(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateListBackwards(*this); } -inline void VNVisitor::iterateAndNextConstNull(AstNode* nodep) { +void VNVisitor::iterateAndNextConstNull(AstNode* nodep) { if (VL_LIKELY(nodep)) nodep->iterateAndNextConst(*this); } -inline AstNode* VNVisitor::iterateSubtreeReturnEdits(AstNode* nodep) { +AstNode* VNVisitor::iterateSubtreeReturnEdits(AstNode* nodep) { return nodep->iterateSubtreeReturnEdits(*this); } -// ###################################################################### -// Standard defines for all AstNode subclasses - -#define ASTNODE_BASE_FUNCS(name) \ - virtual ~Ast##name() override = default; \ - static Ast##name* cloneTreeNull(Ast##name* nodep, bool cloneNextLink) { \ - return nodep ? nodep->cloneTree(cloneNextLink) : nullptr; \ - } \ - Ast##name* cloneTree(bool cloneNext) { \ - return static_cast(AstNode::cloneTree(cloneNext)); \ - } \ - Ast##name* clonep() const { return static_cast(AstNode::clonep()); } - -#define ASTNODE_NODE_FUNCS_NO_DTOR(name) \ - virtual void accept(VNVisitor& v) override { v.visit(this); } \ - virtual AstNode* clone() override { return new Ast##name(*this); } \ - static Ast##name* cloneTreeNull(Ast##name* nodep, bool cloneNextLink) { \ - return nodep ? nodep->cloneTree(cloneNextLink) : nullptr; \ - } \ - Ast##name* cloneTree(bool cloneNext) { \ - return static_cast(AstNode::cloneTree(cloneNext)); \ - } \ - Ast##name* clonep() const { return static_cast(AstNode::clonep()); } - -#define ASTNODE_NODE_FUNCS(name) \ - virtual ~Ast##name() override = default; \ - ASTNODE_NODE_FUNCS_NO_DTOR(name) - -// Macros generated by 'astgen' -#include "V3AstNodes__gen_macros.h" +// Include macros generated by 'astgen'. These include ASTGEN_MEMBERS_ +// for each AstNode sub-type, and ASTGEN_SUPER_ for concrete final +// AstNode sub-types. The generated members include boilerplate methods related +// to cloning, visitor dispatch, and other functionality. ASTGEN_SUPER_ +// is the necessary constructor invocation for concrete AstNode sub-types +// that passes the generated type-id numbers all the way back to AstNode. +// For precise details please read the generated macros. +#include "V3Ast__gen_macros.h" // AstNode subclasses #include "V3AstNodeDType.h" diff --git a/src/V3AstInlines.h b/src/V3AstInlines.h index 79a90d2f0..4f6217af8 100644 --- a/src/V3AstInlines.h +++ b/src/V3AstInlines.h @@ -25,71 +25,56 @@ //###################################################################### // Inline METHODS -inline AstNode* AstNode::addNext(AstNode* newp) { return addNext(this, newp); } -inline AstNode* AstNode::addNextNull(AstNode* newp) { return addNextNull(this, newp); } -inline void AstNode::addPrev(AstNode* newp) { +AstNode* AstNode::addNext(AstNode* newp) { return addNext(this, newp); } +AstNode* AstNode::addNextNull(AstNode* newp) { return addNextNull(this, newp); } +void AstNode::addPrev(AstNode* newp) { replaceWith(newp); newp->addNext(this); } -inline int AstNode::width() const { return dtypep() ? dtypep()->width() : 0; } -inline int AstNode::widthMin() const { return dtypep() ? dtypep()->widthMin() : 0; } -inline bool AstNode::width1() const { // V3Const uses to know it can optimize +int AstNode::width() const { return dtypep() ? dtypep()->width() : 0; } +int AstNode::widthMin() const { return dtypep() ? dtypep()->widthMin() : 0; } +bool AstNode::width1() const { // V3Const uses to know it can optimize return dtypep() && dtypep()->width() == 1; } -inline int AstNode::widthInstrs() const { +int AstNode::widthInstrs() const { return (!dtypep() ? 1 : (dtypep()->isWide() ? dtypep()->widthWords() : 1)); } -inline bool AstNode::isDouble() const { +bool AstNode::isDouble() const { return dtypep() && VN_IS(dtypep(), BasicDType) && VN_AS(dtypep(), BasicDType)->isDouble(); } -inline bool AstNode::isString() const { +bool AstNode::isString() const { return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isString(); } -inline bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } +bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } -inline bool AstNode::isZero() const { +bool AstNode::isZero() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqZero()); } -inline bool AstNode::isNeqZero() const { +bool AstNode::isNeqZero() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isNeqZero()); } -inline bool AstNode::isOne() const { - return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqOne()); -} -inline bool AstNode::isAllOnes() const { +bool AstNode::isOne() const { return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqOne()); } +bool AstNode::isAllOnes() const { return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnes()); } -inline bool AstNode::isAllOnesV() const { +bool AstNode::isAllOnesV() const { return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnesV()); } -inline bool AstNode::sameTree(const AstNode* node2p) const { +bool AstNode::sameTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, false); } -inline bool AstNode::sameGateTree(const AstNode* node2p) const { +bool AstNode::sameGateTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, true); } -inline void AstNodeVarRef::varp(AstVar* varp) { - m_varp = varp; - dtypeFrom(varp); -} - -inline bool AstNodeDType::isFourstate() const { return basicp()->isFourstate(); } - -inline void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); } -inline int AstNodeArrayDType::left() const { return rangep()->leftConst(); } -inline int AstNodeArrayDType::right() const { return rangep()->rightConst(); } -inline int AstNodeArrayDType::hi() const { return rangep()->hiConst(); } -inline int AstNodeArrayDType::lo() const { return rangep()->loConst(); } -inline int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); } -inline VNumRange AstNodeArrayDType::declRange() const { return VNumRange{left(), right()}; } - -inline void AstIfaceRefDType::cloneRelink() { - if (m_cellp && m_cellp->clonep()) m_cellp = m_cellp->clonep(); - if (m_ifacep && m_ifacep->clonep()) m_ifacep = m_ifacep->clonep(); - if (m_modportp && m_modportp->clonep()) m_modportp = m_modportp->clonep(); -} +void AstNodeArrayDType::rangep(AstRange* nodep) { setOp2p(nodep); } +int AstNodeArrayDType::left() const { return rangep()->leftConst(); } +int AstNodeArrayDType::right() const { return rangep()->rightConst(); } +int AstNodeArrayDType::hi() const { return rangep()->hiConst(); } +int AstNodeArrayDType::lo() const { return rangep()->loConst(); } +int AstNodeArrayDType::elementsConst() const { return rangep()->elementsConst(); } +VNumRange AstNodeArrayDType::declRange() const { return VNumRange{left(), right()}; } AstRange::AstRange(FileLine* fl, int left, int right) : ASTGEN_SUPER_Range(fl) { diff --git a/src/V3AstNodeDType.h b/src/V3AstNodeDType.h index 6931d41b1..c1db3ae5b 100644 --- a/src/V3AstNodeDType.h +++ b/src/V3AstNodeDType.h @@ -35,29 +35,26 @@ class AstNodeDType VL_NOT_FINAL : public AstNode { // but it's currently so prevalent in the code we leave it here. // Note the below members are included in AstTypeTable::Key lookups private: - int m_width; // (also in AstTypeTable::Key) Bit width of operation - int m_widthMin; // (also in AstTypeTable::Key) If unsized, bitwidth of minimum implementation + int m_width = 0; // (also in AstTypeTable::Key) Bit width of operation + int m_widthMin + = 0; // (also in AstTypeTable::Key) If unsized, bitwidth of minimum implementation VSigning m_numeric; // (also in AstTypeTable::Key) Node is signed // Other members - bool m_generic; // Simple globally referenced type, don't garbage collect + bool m_generic = false; // Simple globally referenced type, don't garbage collect // Unique number assigned to each dtype during creation for IEEE matching static int s_uniqueNum; protected: // CONSTRUCTORS AstNodeDType(VNType t, FileLine* fl) - : AstNode{t, fl} { - m_width = 0; - m_widthMin = 0; - m_generic = false; - } + : AstNode{t, fl} {} public: - ASTNODE_BASE_FUNCS(NodeDType) + ASTGEN_MEMBERS_NodeDType; // ACCESSORS - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; virtual void dumpSmall(std::ostream& str) const; - virtual bool hasDType() const override { return true; } + bool hasDType() const override { return true; } /// Require VlUnpacked, instead of [] for POD elements. /// A non-POD object is always compound, but some POD elements /// are compound when methods calls operate on object, or when @@ -75,7 +72,7 @@ public: virtual int widthAlignBytes() const = 0; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,... virtual int widthTotalBytes() const = 0; - virtual bool maybePointedTo() const override { return true; } + bool maybePointedTo() const override { return true; } // Iff has a non-null refDTypep(), as generic node function virtual AstNodeDType* virtRefDTypep() const { return nullptr; } // Iff has refDTypep(), set as generic node function @@ -145,56 +142,54 @@ protected: : AstNodeDType{t, fl} {} public: - ASTNODE_BASE_FUNCS(NodeArrayDType) - virtual void dump(std::ostream& str) const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual const char* broken() const override { + ASTGEN_MEMBERS_NodeArrayDType; + void dump(std::ostream& str) const override; + void dumpSmall(std::ostream& str) const override; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstNodeArrayDType* const asamep = static_cast(samep); return (hi() == asamep->hi() && subDTypep() == asamep->subDTypep() && rangenp()->sameTree(asamep->rangenp())); } // HashedDT doesn't recurse, so need to check children - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { const AstNodeArrayDType* const asamep = static_cast(samep); return (asamep && type() == samep->type() && hi() == asamep->hi() && rangenp()->sameTree(asamep->rangenp()) && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp())); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Array(s) of variable - void rangep(AstRange* nodep); + inline void rangep(AstRange* nodep); // METHODS - virtual AstBasicDType* basicp() const override { + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } // (Slow) recurse down to find basic data type - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return elementsConst() * subDTypep()->widthTotalBytes(); } - int left() const; - int right() const; - int hi() const; - int lo() const; - int elementsConst() const; - VNumRange declRange() const; + inline int left() const; + inline int right() const; + inline int hi() const; + inline int lo() const; + inline int elementsConst() const; + inline VNumRange declRange() const; }; class AstNodeUOrStructDType VL_NOT_FINAL : public AstNodeDType { // A struct or union; common handling @@ -204,7 +199,7 @@ private: // MEMBERS string m_name; // Name from upper typedef, if any bool m_packed; - bool m_isFourstate; + bool m_isFourstate = false; // V3Width computes MemberNameMap m_members; const int m_uniqueNum; @@ -214,37 +209,36 @@ protected: , m_uniqueNum{uniqueNumInc()} { // VSigning::NOSIGN overloaded to indicate not packed m_packed = (numericUnpack != VSigning::NOSIGN); - m_isFourstate = false; // V3Width computes numeric(VSigning::fromBool(numericUnpack.isSigned())); } public: - ASTNODE_BASE_FUNCS(NodeUOrStructDType) + ASTGEN_MEMBERS_NodeUOrStructDType; int uniqueNum() const { return m_uniqueNum; } - virtual const char* broken() const override; - virtual void dump(std::ostream& str) const override; - virtual bool isCompound() const override { return false; } // Because don't support unpacked + const char* broken() const override; + void dump(std::ostream& str) const override; + bool isCompound() const override { return false; } // Because don't support unpacked // For basicp() we reuse the size to indicate a "fake" basic type of same size - virtual AstBasicDType* basicp() const override { + AstBasicDType* basicp() const override { return (isFourstate() ? VN_AS(findLogicRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), BasicDType) : VN_AS(findBitRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), BasicDType)); } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this) - virtual int widthAlignBytes() const override; + int widthAlignBytes() const override; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,... - virtual int widthTotalBytes() const override; + int widthTotalBytes() const override; // op1 = members - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return this == samep; // We don't compare members, require exact equivalence } - virtual string name() const override { return m_name; } - virtual void name(const string& flag) override { m_name = flag; } + string name() const override { return m_name; } + void name(const string& flag) override { m_name = flag; } AstMemberDType* membersp() const { return VN_AS(op1p(), MemberDType); } // op1 = AstMember list @@ -253,7 +247,7 @@ public: // packed() but as don't support unpacked, presently all structs static bool packedUnsup() { return true; } void isFourstate(bool flag) { m_isFourstate = flag; } - virtual bool isFourstate() const override { return m_isFourstate; } + bool isFourstate() const override { return m_isFourstate; } void clearCache() { m_members.clear(); } void repairMemberCache(); AstMemberDType* findMember(const string& name) const { @@ -280,11 +274,11 @@ public: addNOp1p(rangep); addNOp2p(initp); } - ASTNODE_NODE_FUNCS(EnumItem) - virtual string name() const override { return m_name; } - virtual bool maybePointedTo() const override { return true; } - virtual bool hasDType() const override { return true; } - virtual void name(const string& flag) override { m_name = flag; } + ASTGEN_MEMBERS_EnumItem; + string name() const override { return m_name; } + bool maybePointedTo() const override { return true; } + bool hasDType() const override { return true; } + void name(const string& flag) override { m_name = flag; } AstRange* rangep() const { return VN_AS(op1p(), Range); } // op1 = Range for name appending void rangep(AstRange* nodep) { addOp1p((AstNode*)nodep); } AstNode* valuep() const { return op2p(); } // op2 = Value @@ -314,44 +308,42 @@ public: keyDTypep(keyDtp); dtypep(dtp); } - ASTNODE_NODE_FUNCS(AssocArrayDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_AssocArrayDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); BROKEN_RTN(!((m_keyDTypep && !childDTypep() && m_keyDTypep->brokeExists()) || (!m_keyDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); if (m_keyDTypep && m_keyDTypep->clonep()) m_keyDTypep = m_keyDTypep->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstAssocArrayDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; if (!asamep->keyDTypep()) return false; return (subDTypep() == asamep->subDTypep() && keyDTypep() == asamep->keyDTypep()); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { const AstAssocArrayDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } - virtual string prettyDTypeName() const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } - virtual AstNodeDType* getChild2DTypep() const override { return keyChildDTypep(); } + string prettyDTypeName() const override; + void dumpSmall(std::ostream& str) const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChild2DTypep() const override { return keyChildDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } - virtual AstNodeDType* virtRefDType2p() const override { return m_keyDTypep; } - virtual void virtRefDType2p(AstNodeDType* nodep) override { keyDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDType2p() const override { return m_keyDTypep; } + void virtRefDType2p(AstNodeDType* nodep) override { keyDTypep(nodep); } // AstNodeDType* keyDTypep() const { return m_keyDTypep ? m_keyDTypep : keyChildDTypep(); } void keyDTypep(AstNodeDType* nodep) { m_keyDTypep = nodep; } @@ -359,13 +351,13 @@ public: AstNodeDType* keyChildDTypep() const { return VN_AS(op2p(), NodeDType); } void keyChildDTypep(AstNodeDType* nodep) { setOp2p(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } - virtual bool isCompound() const override { return true; } + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + bool isCompound() const override { return true; } }; class AstBasicDType final : public AstNodeDType { // Builtin atomic/vectored data type @@ -407,19 +399,19 @@ private: AstRange* rangep); public: - ASTNODE_NODE_FUNCS(BasicDType) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_BasicDType; + void dump(std::ostream& str) const override; // width/widthMin/numeric compared elsewhere - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstBasicDType* const sp = static_cast(samep); return m == sp->m; } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return type() == samep->type() && same(samep); } - virtual string name() const override { return m.m_keyword.ascii(); } - virtual string prettyDTypeName() const override; - virtual const char* broken() const override { + string name() const override { return m.m_keyword.ascii(); } + string prettyDTypeName() const override; + const char* broken() const override { BROKEN_RTN(dtypep() != this); return nullptr; } @@ -434,15 +426,15 @@ public: } } // METHODS - virtual AstBasicDType* basicp() const override { return (AstBasicDType*)this; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + AstBasicDType* basicp() const override { return (AstBasicDType*)this; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this) - virtual int widthAlignBytes() const override; + int widthAlignBytes() const override; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,... - virtual int widthTotalBytes() const override; - virtual bool isFourstate() const override { return keyword().isFourstate(); } + int widthTotalBytes() const override; + bool isFourstate() const override { return keyword().isFourstate(); } VBasicDTypeKwd keyword() const { // Avoid using - use isSomething accessors instead return m.m_keyword; } @@ -477,7 +469,7 @@ public: bool implicit() const { return keyword() == VBasicDTypeKwd::LOGIC_IMPLICIT; } VNumRange declRange() const { return isRanged() ? VNumRange{left(), right()} : VNumRange{}; } void cvtRangeConst(); // Convert to smaller representation - virtual bool isCompound() const override { return isString(); } + bool isCompound() const override { return isString(); } }; class AstBracketArrayDType final : public AstNodeDType { // Associative/Queue/Normal array data type, ie "[dtype_or_expr]" @@ -490,24 +482,24 @@ public: setOp1p(dtp); // Only for parser setOp2p(elementsp); // Only for parser } - ASTNODE_NODE_FUNCS(BracketArrayDType) - virtual bool similarDType(AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); } + ASTGEN_MEMBERS_BracketArrayDType; + bool similarDType(AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } - virtual AstNodeDType* subDTypep() const override { return childDTypep(); } + AstNodeDType* subDTypep() const override { return childDTypep(); } // op2 = Range of variable AstNode* elementsp() const { return op2p(); } // METHODS // Will be removed in V3Width, which relies on this // being a child not a dtype pointed node - virtual bool maybePointedTo() const override { return false; } - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { V3ERROR_NA_RETURN(0); } - virtual int widthTotalBytes() const override { V3ERROR_NA_RETURN(0); } - virtual bool isCompound() const override { return true; } + bool maybePointedTo() const override { return false; } + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { V3ERROR_NA_RETURN(0); } + int widthTotalBytes() const override { V3ERROR_NA_RETURN(0); } + bool isCompound() const override { return true; } }; class AstClassRefDType final : public AstNodeDType { // Reference to a class @@ -522,35 +514,35 @@ public: dtypep(this); addNOp4p(paramsp); } - ASTNODE_NODE_FUNCS(ClassRefDType) + ASTGEN_MEMBERS_ClassRefDType; // METHODS const char* broken() const override; void cloneRelink() override; - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstClassRefDType* const asamep = static_cast(samep); return (m_classp == asamep->m_classp && m_classOrPackagep == asamep->m_classOrPackagep); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return this == samep || (type() == samep->type() && same(samep)); } - virtual void dump(std::ostream& str = std::cout) const override; - virtual void dumpSmall(std::ostream& str) const override; + void dump(std::ostream& str = std::cout) const override; + void dumpSmall(std::ostream& str) const override; string name() const override; - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return 0; } - virtual int widthTotalBytes() const override { return 0; } - virtual AstNodeDType* virtRefDTypep() const override { return nullptr; } - virtual void virtRefDTypep(AstNodeDType* nodep) override {} - virtual AstNodeDType* subDTypep() const override { return nullptr; } + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return 0; } + int widthTotalBytes() const override { return 0; } + AstNodeDType* virtRefDTypep() const override { return nullptr; } + void virtRefDTypep(AstNodeDType* nodep) override {} + AstNodeDType* subDTypep() const override { return nullptr; } AstNodeModule* classOrPackagep() const { return m_classOrPackagep; } void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } AstClass* classp() const { return m_classp; } void classp(AstClass* nodep) { m_classp = nodep; } AstPin* paramsp() const { return VN_AS(op4p(), Pin); } - virtual bool isCompound() const override { return true; } + bool isCompound() const override { return true; } }; class AstConstDType final : public AstNodeDType { // const data type, ie "const some_dtype var_name [2:0]" @@ -566,40 +558,38 @@ public: dtypep(nullptr); // V3Width will resolve widthFromSub(subDTypep()); } - ASTNODE_NODE_FUNCS(ConstDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_ConstDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstConstDType* const sp = static_cast(samep); return (m_refDTypep == sp->m_refDTypep); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return skipRefp()->similarDType(samep->skipRefp()); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } - virtual bool isCompound() const override { + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; } @@ -624,35 +614,33 @@ public: childDTypep(dtp); // Only for parser dtypep(nullptr); // V3Width will resolve } - ASTNODE_NODE_FUNCS(DefImplicitDType) + ASTGEN_MEMBERS_DefImplicitDType; int uniqueNum() const { return m_uniqueNum; } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstDefImplicitDType* const sp = static_cast(samep); return uniqueNum() == sp->uniqueNum(); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return type() == samep->type() && same(samep); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return dtypep() ? dtypep() : childDTypep(); - } + AstNodeDType* subDTypep() const override { return dtypep() ? dtypep() : childDTypep(); } void* containerp() const { return m_containerp; } // METHODS // op1 = Range of variable AstNodeDType* dtypeSkipRefp() const { return dtypep()->skipRefp(); } - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return dtypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return dtypep()->widthTotalBytes(); } - virtual string name() const override { return m_name; } - virtual void name(const string& flag) override { m_name = flag; } - virtual bool isCompound() const override { return false; } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return dtypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return dtypep()->widthTotalBytes(); } + string name() const override { return m_name; } + void name(const string& flag) override { m_name = flag; } + bool isCompound() const override { return false; } }; class AstDynArrayDType final : public AstNodeDType { // Dynamic array data type, ie "[]" @@ -671,45 +659,43 @@ public: refDTypep(dtp); dtypep(nullptr); // V3Width will resolve } - ASTNODE_NODE_FUNCS(DynArrayDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_DynArrayDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstAssocArrayDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; return subDTypep() == asamep->subDTypep(); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { const AstAssocArrayDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } - virtual string prettyDTypeName() const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + string prettyDTypeName() const override; + void dumpSmall(std::ostream& str) const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } - virtual bool isCompound() const override { return true; } + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + bool isCompound() const override { return true; } }; class AstEmptyQueueDType final : public AstNodeDType { // For EmptyQueue @@ -718,25 +704,25 @@ public: : ASTGEN_SUPER_EmptyQueueDType(fl) { dtypep(this); } - ASTNODE_NODE_FUNCS(EmptyQueueDType) - virtual void dumpSmall(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } - virtual bool maybePointedTo() const override { return true; } - virtual bool undead() const override { return true; } - virtual AstNodeDType* subDTypep() const override { return nullptr; } - virtual AstNodeDType* virtRefDTypep() const override { return nullptr; } - virtual void virtRefDTypep(AstNodeDType* nodep) override {} - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } - virtual AstBasicDType* basicp() const override { return nullptr; } + ASTGEN_MEMBERS_EmptyQueueDType; + void dumpSmall(std::ostream& str) const override; + bool hasDType() const override { return true; } + bool maybePointedTo() const override { return true; } + bool undead() const override { return true; } + AstNodeDType* subDTypep() const override { return nullptr; } + AstNodeDType* virtRefDTypep() const override { return nullptr; } + void virtRefDTypep(AstNodeDType* nodep) override {} + bool similarDType(AstNodeDType* samep) const override { return this == samep; } + AstBasicDType* basicp() const override { return nullptr; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return 1; } - virtual int widthTotalBytes() const override { return 1; } - virtual bool isCompound() const override { return false; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return 1; } + int widthTotalBytes() const override { return 1; } + bool isCompound() const override { return false; } }; class AstEnumDType final : public AstNodeDType { // Parents: TYPEDEF/MODULE @@ -756,50 +742,46 @@ public: dtypep(nullptr); // V3Width will resolve widthFromSub(subDTypep()); } - ASTNODE_NODE_FUNCS(EnumDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_EnumDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } int uniqueNum() const { return m_uniqueNum; } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstEnumDType* const sp = static_cast(samep); return uniqueNum() == sp->uniqueNum(); } - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + bool similarDType(AstNodeDType* samep) const override { return this == samep; } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } // op1 = Data type void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } // op1 = Range of variable - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } - virtual string name() const override { return m_name; } - virtual void name(const string& flag) override { m_name = flag; } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + string name() const override { return m_name; } + void name(const string& flag) override { m_name = flag; } AstEnumItem* itemsp() const { return VN_AS(op2p(), EnumItem); } // op2 = AstEnumItem's // METHODS - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } - virtual AstNodeDType* skipRefToConstp() const override { - return subDTypep()->skipRefToConstp(); - } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } + AstNodeDType* skipRefToConstp() const override { return subDTypep()->skipRefToConstp(); } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } int itemCount() const { size_t count = 0; for (AstNode* itemp = itemsp(); itemp; itemp = itemp->nextp()) count++; return count; } - virtual bool isCompound() const override { return false; } + bool isCompound() const override { return false; } }; class AstIfaceRefDType final : public AstNodeDType { // Reference to an interface, either for a port, or inside parent cell @@ -825,19 +807,19 @@ public: , m_cellName{cellName} , m_ifaceName{ifaceName} , m_modportName{modport} {} - ASTNODE_NODE_FUNCS(IfaceRefDType) + ASTGEN_MEMBERS_IfaceRefDType; // METHODS - virtual const char* broken() const override; - virtual void dump(std::ostream& str = std::cout) const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual void cloneRelink() override; - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } - virtual int widthAlignBytes() const override { return 1; } - virtual int widthTotalBytes() const override { return 1; } + const char* broken() const override; + void dump(std::ostream& str = std::cout) const override; + void dumpSmall(std::ostream& str) const override; + void cloneRelink() override; + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + bool similarDType(AstNodeDType* samep) const override { return this == samep; } + int widthAlignBytes() const override { return 1; } + int widthTotalBytes() const override { return 1; } FileLine* modportFileline() const { return m_modportFileline; } string cellName() const { return m_cellName; } void cellName(const string& name) { m_cellName = name; } @@ -852,7 +834,7 @@ public: AstModport* modportp() const { return m_modportp; } void modportp(AstModport* modportp) { m_modportp = modportp; } bool isModport() { return !m_modportName.empty(); } - virtual bool isCompound() const override { return true; } // But not relevant + bool isCompound() const override { return true; } // But not relevant }; class AstMemberDType final : public AstNodeDType { // A member of a struct/union @@ -879,50 +861,46 @@ public: dtypep(this); widthFromSub(subDTypep()); } - ASTNODE_NODE_FUNCS(MemberDType) - virtual string name() const override { return m_name; } // * = Var name - virtual bool hasDType() const override { return true; } - virtual bool maybePointedTo() const override { return true; } - virtual const char* broken() const override { + ASTGEN_MEMBERS_MemberDType; + string name() const override { return m_name; } // * = Var name + bool hasDType() const override { return true; } + bool maybePointedTo() const override { return true; } + const char* broken() const override { BROKEN_RTN(m_refDTypep && !m_refDTypep->brokeExists()); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + bool similarDType(AstNodeDType* samep) const override { return this == samep; } // // (Slow) recurse down to find basic data type (Note don't need virtual - // AstVar isn't a NodeDType) - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } // op1 = Range of variable (Note don't need virtual - AstVar isn't a NodeDType) AstNodeDType* dtypeSkipRefp() const { return subDTypep()->skipRefp(); } - virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } - virtual AstNodeDType* skipRefToConstp() const override { - return subDTypep()->skipRefToConstp(); - } - virtual AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } + AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } + AstNodeDType* skipRefToConstp() const override { return subDTypep()->skipRefToConstp(); } + AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this) - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,... - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } // METHODS - virtual void name(const string& name) override { m_name = name; } - virtual void tag(const string& text) override { m_tag = text; } - virtual string tag() const override { return m_tag; } + void name(const string& name) override { m_name = name; } + void tag(const string& text) override { m_tag = text; } + string tag() const override { return m_tag; } int lsb() const { return m_lsb; } void lsb(int lsb) { m_lsb = lsb; } - virtual bool isCompound() const override { + bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; } @@ -942,36 +920,32 @@ public: childDTypep(dtp); // Only for parser dtypep(nullptr); // V3Width will resolve } - ASTNODE_NODE_FUNCS(ParamTypeDType) - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + ASTGEN_MEMBERS_ParamTypeDType; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Type assigning to AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return dtypep() ? dtypep() : childDTypep(); - } - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } - virtual AstNodeDType* skipRefToConstp() const override { - return subDTypep()->skipRefToConstp(); - } - virtual AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } - virtual bool similarDType(AstNodeDType* samep) const override { + AstNodeDType* subDTypep() const override { return dtypep() ? dtypep() : childDTypep(); } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } + AstNodeDType* skipRefToConstp() const override { return subDTypep()->skipRefToConstp(); } + AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } + bool similarDType(AstNodeDType* samep) const override { const AstParamTypeDType* const sp = static_cast(samep); return type() == samep->type() && sp && this->subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp()); } - virtual int widthAlignBytes() const override { return dtypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return dtypep()->widthTotalBytes(); } + int widthAlignBytes() const override { return dtypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return dtypep()->widthTotalBytes(); } // METHODS - virtual string name() const override { return m_name; } - virtual bool maybePointedTo() const override { return true; } - virtual bool hasDType() const override { return true; } - virtual void name(const string& flag) override { m_name = flag; } + string name() const override { return m_name; } + bool maybePointedTo() const override { return true; } + bool hasDType() const override { return true; } + void name(const string& flag) override { m_name = flag; } VVarType varType() const { return m_varType; } // * = Type of variable bool isParam() const { return true; } bool isGParam() const { return (varType() == VVarType::GPARAM); } - virtual bool isCompound() const override { + bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; } @@ -983,19 +957,19 @@ class AstParseTypeDType final : public AstNodeDType { public: explicit AstParseTypeDType(FileLine* fl) : ASTGEN_SUPER_ParseTypeDType(fl) {} - ASTNODE_NODE_FUNCS(ParseTypeDType) + ASTGEN_MEMBERS_ParseTypeDType; AstNodeDType* dtypep() const { return nullptr; } // METHODS - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } - virtual AstBasicDType* basicp() const override { return nullptr; } - virtual AstNodeDType* skipRefp() const override { return nullptr; } + bool similarDType(AstNodeDType* samep) const override { return this == samep; } + AstBasicDType* basicp() const override { return nullptr; } + AstNodeDType* skipRefp() const override { return nullptr; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return 0; } - virtual int widthTotalBytes() const override { return 0; } - virtual bool isCompound() const override { + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return 0; } + int widthTotalBytes() const override { return 0; } + bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; } @@ -1019,51 +993,49 @@ public: refDTypep(dtp); dtypep(dtp); } - ASTNODE_NODE_FUNCS(QueueDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_QueueDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstQueueDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; return (subDTypep() == asamep->subDTypep()); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { const AstQueueDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } - virtual void dumpSmall(std::ostream& str) const override; - virtual string prettyDTypeName() const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + void dumpSmall(std::ostream& str) const override; + string prettyDTypeName() const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } AstNode* boundp() const { return op2p(); } // op2 = Bound, nullptr = none void boundp(AstNode* nodep) { setNOp2p(nodep); } inline int boundConst() const; - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return nullptr; } + AstBasicDType* basicp() const override { return nullptr; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } - virtual bool isCompound() const override { return true; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + bool isCompound() const override { return true; } }; class AstRefDType final : public AstNodeDType { private: @@ -1089,28 +1061,28 @@ public: : ASTGEN_SUPER_RefDType(fl) { setOp2p(typeofp); } - ASTNODE_NODE_FUNCS(RefDType) + ASTGEN_MEMBERS_RefDType; // METHODS const char* broken() const override; void cloneRelink() override; - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstRefDType* const asamep = static_cast(samep); return (m_typedefp == asamep->m_typedefp && m_refDTypep == asamep->m_refDTypep && m_name == asamep->m_name && m_classOrPackagep == asamep->m_classOrPackagep); } - virtual bool similarDType(AstNodeDType* samep) const override { + bool similarDType(AstNodeDType* samep) const override { return skipRefp()->similarDType(samep->skipRefp()); } - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } - virtual string prettyDTypeName() const override { + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } + string prettyDTypeName() const override { return subDTypep() ? subDTypep()->name() : prettyName(); } - virtual AstBasicDType* basicp() const override { + AstBasicDType* basicp() const override { return subDTypep() ? subDTypep()->basicp() : nullptr; } AstNodeDType* subDTypep() const override; - virtual AstNodeDType* skipRefp() const override { + AstNodeDType* skipRefp() const override { // Skip past both the Ref and the Typedef if (subDTypep()) { return subDTypep()->skipRefp(); @@ -1119,7 +1091,7 @@ public: return nullptr; } } - virtual AstNodeDType* skipRefToConstp() const override { + AstNodeDType* skipRefToConstp() const override { if (subDTypep()) { return subDTypep()->skipRefToConstp(); } else { @@ -1127,7 +1099,7 @@ public: return nullptr; } } - virtual AstNodeDType* skipRefToEnump() const override { + AstNodeDType* skipRefToEnump() const override { if (subDTypep()) { return subDTypep()->skipRefToEnump(); } else { @@ -1135,23 +1107,23 @@ public: return nullptr; } } - virtual int widthAlignBytes() const override { return dtypeSkipRefp()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return dtypeSkipRefp()->widthTotalBytes(); } - virtual void name(const string& flag) override { m_name = flag; } + int widthAlignBytes() const override { return dtypeSkipRefp()->widthAlignBytes(); } + int widthTotalBytes() const override { return dtypeSkipRefp()->widthTotalBytes(); } + void name(const string& flag) override { m_name = flag; } // op1 = Range of variable AstNodeDType* dtypeSkipRefp() const { return subDTypep()->skipRefp(); } AstTypedef* typedefp() const { return m_typedefp; } void typedefp(AstTypedef* nodep) { m_typedefp = nodep; } AstNodeDType* refDTypep() const { return m_refDTypep; } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return refDTypep(); } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return refDTypep(); } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } AstNodeModule* classOrPackagep() const { return m_classOrPackagep; } void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } AstNode* typeofp() const { return op2p(); } AstNode* classOrPackageOpp() const { return op3p(); } AstPin* paramsp() const { return VN_AS(op4p(), Pin); } - virtual bool isCompound() const override { + bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; } @@ -1168,36 +1140,34 @@ public: refDTypep(nullptr); dtypep(nullptr); // V3Width will resolve } - ASTNODE_NODE_FUNCS(UnsizedArrayDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_UnsizedArrayDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } bool same(const AstNode* samep) const override; bool similarDType(AstNodeDType* samep) const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + void dumpSmall(std::ostream& str) const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } - virtual int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } - virtual bool isCompound() const override { return true; } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return subDTypep()->widthAlignBytes(); } + int widthTotalBytes() const override { return subDTypep()->widthTotalBytes(); } + bool isCompound() const override { return true; } }; class AstVoidDType final : public AstNodeDType { // For e.g. a function returning void @@ -1206,25 +1176,25 @@ public: : ASTGEN_SUPER_VoidDType(fl) { dtypep(this); } - ASTNODE_NODE_FUNCS(VoidDType) - virtual void dumpSmall(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } - virtual bool maybePointedTo() const override { return true; } - virtual bool undead() const override { return true; } - virtual AstNodeDType* subDTypep() const override { return nullptr; } - virtual AstNodeDType* virtRefDTypep() const override { return nullptr; } - virtual void virtRefDTypep(AstNodeDType* nodep) override {} - virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } - virtual AstBasicDType* basicp() const override { return nullptr; } + ASTGEN_MEMBERS_VoidDType; + void dumpSmall(std::ostream& str) const override; + bool hasDType() const override { return true; } + bool maybePointedTo() const override { return true; } + bool undead() const override { return true; } + AstNodeDType* subDTypep() const override { return nullptr; } + AstNodeDType* virtRefDTypep() const override { return nullptr; } + void virtRefDTypep(AstNodeDType* nodep) override {} + bool similarDType(AstNodeDType* samep) const override { return this == samep; } + AstBasicDType* basicp() const override { return nullptr; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } // cppcheck-suppress csyleCast - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { return 1; } - virtual int widthTotalBytes() const override { return 1; } - virtual bool isCompound() const override { return false; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return 1; } + int widthTotalBytes() const override { return 1; } + bool isCompound() const override { return false; } }; class AstWildcardArrayDType final : public AstNodeDType { // Wildcard index type associative array data type, ie "some_dtype var_name [*]" @@ -1238,40 +1208,34 @@ public: refDTypep(nullptr); dtypep(nullptr); // V3Width will resolve } - ASTNODE_NODE_FUNCS(WildcardArrayDType) - virtual const char* broken() const override { + ASTGEN_MEMBERS_WildcardArrayDType; + const char* broken() const override { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists()) || (!m_refDTypep && childDTypep()))); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } bool same(const AstNode* samep) const override; bool similarDType(AstNodeDType* samep) const override; - virtual void dumpSmall(std::ostream& str) const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + void dumpSmall(std::ostream& str) const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } - virtual AstNodeDType* subDTypep() const override { - return m_refDTypep ? m_refDTypep : childDTypep(); - } + AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); } void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } - virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } - virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } + AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } + void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } // METHODS - virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } - virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } - virtual AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } - virtual int widthAlignBytes() const override { - return sizeof(std::map); - } - virtual int widthTotalBytes() const override { - return sizeof(std::map); - } - virtual bool isCompound() const override { return true; } + AstBasicDType* basicp() const override { return subDTypep()->basicp(); } + AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } + AstNodeDType* skipRefToEnump() const override { return (AstNodeDType*)this; } + int widthAlignBytes() const override { return sizeof(std::map); } + int widthTotalBytes() const override { return sizeof(std::map); } + bool isCompound() const override { return true; } }; // === AstNodeArrayDType === @@ -1282,9 +1246,9 @@ class AstPackArrayDType final : public AstNodeArrayDType { public: inline AstPackArrayDType(FileLine* fl, VFlagChildDType, AstNodeDType* dtp, AstRange* rangep); inline AstPackArrayDType(FileLine* fl, AstNodeDType* dtp, AstRange* rangep); - ASTNODE_NODE_FUNCS(PackArrayDType) - virtual string prettyDTypeName() const override; - virtual bool isCompound() const override { return false; } + ASTGEN_MEMBERS_PackArrayDType; + string prettyDTypeName() const override; + bool isCompound() const override { return false; } }; class AstUnpackArrayDType final : public AstNodeArrayDType { // Array data type, ie "some_dtype var_name [2:0]" @@ -1311,16 +1275,16 @@ public: // width and signing from the subDType/base type widthFromSub(subDTypep()); } - ASTNODE_NODE_FUNCS(UnpackArrayDType) - virtual string prettyDTypeName() const override; - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_UnpackArrayDType; + string prettyDTypeName() const override; + bool same(const AstNode* samep) const override { const AstUnpackArrayDType* const sp = static_cast(samep); return m_isCompound == sp->m_isCompound; } // Outer dimension comes first. The first element is this node. std::vector unpackDimensions(); void isCompound(bool flag) { m_isCompound = flag; } - virtual bool isCompound() const override { return m_isCompound; } + bool isCompound() const override { return m_isCompound; } }; // === AstNodeUOrStructDType === @@ -1329,8 +1293,8 @@ public: // VSigning below is mispurposed to indicate if packed or not AstStructDType(FileLine* fl, VSigning numericUnpack) : ASTGEN_SUPER_StructDType(fl, numericUnpack) {} - ASTNODE_NODE_FUNCS(StructDType) - virtual string verilogKwd() const override { return "struct"; } + ASTGEN_MEMBERS_StructDType; + string verilogKwd() const override { return "struct"; } }; class AstUnionDType final : public AstNodeUOrStructDType { public: @@ -1338,8 +1302,8 @@ public: // VSigning below is mispurposed to indicate if packed or not AstUnionDType(FileLine* fl, VSigning numericUnpack) : ASTGEN_SUPER_UnionDType(fl, numericUnpack) {} - ASTNODE_NODE_FUNCS(UnionDType) - virtual string verilogKwd() const override { return "union"; } + ASTGEN_MEMBERS_UnionDType; + string verilogKwd() const override { return "union"; } }; #endif // Guard diff --git a/src/V3AstNodeMath.h b/src/V3AstNodeMath.h index 1ae0c4b20..e9defaef8 100644 --- a/src/V3AstNodeMath.h +++ b/src/V3AstNodeMath.h @@ -44,10 +44,10 @@ protected: : AstNode{t, fl} {} public: - ASTNODE_BASE_FUNCS(NodeMath) + ASTGEN_MEMBERS_NodeMath; // METHODS - virtual void dump(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } + void dump(std::ostream& str) const override; + bool hasDType() const override { return true; } virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV // For documentation on emitC format see EmitCFunc::emitOpName virtual string emitC() = 0; @@ -68,7 +68,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeBiop) + ASTGEN_MEMBERS_NodeBiop; // Clone single node, just get same type back. virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) = 0; // ACCESSORS @@ -87,8 +87,8 @@ public: // Signed flavor of nodes with both flavors? virtual bool signedFlavor() const { return false; } virtual bool stringFlavor() const { return false; } // N flavor of nodes with both flavors? - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode*) const override { return true; } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode*) const override { return true; } }; class AstNodeBiCom VL_NOT_FINAL : public AstNodeBiop { // Binary math with commutative properties @@ -97,7 +97,7 @@ protected: : AstNodeBiop{t, fl, lhs, rhs} {} public: - ASTNODE_BASE_FUNCS(NodeBiCom) + ASTGEN_MEMBERS_NodeBiCom; }; class AstNodeBiComAsv VL_NOT_FINAL : public AstNodeBiCom { // Binary math with commutative & associative properties @@ -106,7 +106,7 @@ protected: : AstNodeBiCom{t, fl, lhs, rhs} {} public: - ASTNODE_BASE_FUNCS(NodeBiComAsv) + ASTGEN_MEMBERS_NodeBiComAsv; }; class AstNodeSel VL_NOT_FINAL : public AstNodeBiop { // Single bit range extraction, perhaps with non-constant selection or array selection @@ -115,7 +115,7 @@ protected: : AstNodeBiop{t, fl, fromp, bitp} {} public: - ASTNODE_BASE_FUNCS(NodeSel) + ASTGEN_MEMBERS_NodeSel; AstNode* fromp() const { return op1p(); } // op1 = Extracting what (nullptr=TBD during parsing) @@ -123,7 +123,7 @@ public: AstNode* bitp() const { return op2p(); } // op2 = Msb selection expression void bitp(AstNode* nodep) { setOp2p(nodep); } int bitConst() const; - virtual bool hasDType() const override { return true; } + bool hasDType() const override { return true; } }; class AstNodeStream VL_NOT_FINAL : public AstNodeBiop { // Verilog {rhs{lhs}} - Note rhsp() is the slice size, not the lhsp() @@ -134,7 +134,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeStream) + ASTGEN_MEMBERS_NodeStream; }; class AstNodeSystemBiop VL_NOT_FINAL : public AstNodeBiop { public: @@ -142,13 +142,14 @@ public: : AstNodeBiop(t, fl, lhsp, rhsp) { dtypeSetDouble(); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL_TRIG; } - virtual bool doubleFlavor() const override { return true; } + ASTGEN_MEMBERS_NodeSystemBiop; + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL_TRIG; } + bool doubleFlavor() const override { return true; } }; class AstNodeQuadop VL_NOT_FINAL : public AstNodeMath { // Quaternary math @@ -162,7 +163,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeQuadop) + ASTGEN_MEMBERS_NodeQuadop; AstNode* lhsp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } AstNode* thsp() const { return op3p(); } @@ -184,8 +185,8 @@ public: virtual bool sizeMattersRhs() const = 0; // True if output result depends on rhs size virtual bool sizeMattersThs() const = 0; // True if output result depends on ths size virtual bool sizeMattersFhs() const = 0; // True if output result depends on ths size - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode*) const override { return true; } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode*) const override { return true; } }; class AstNodeTermop VL_NOT_FINAL : public AstNodeMath { // Terminal operator -- a operator with no "inputs" @@ -194,12 +195,12 @@ protected: : AstNodeMath{t, fl} {} public: - ASTNODE_BASE_FUNCS(NodeTermop) + ASTGEN_MEMBERS_NodeTermop; // Know no children, and hot function, so skip iterator for speed // See checkTreeIter also that asserts no children // cppcheck-suppress functionConst void iterateChildren(VNVisitor& v) {} - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; }; class AstNodeTriop VL_NOT_FINAL : public AstNodeMath { // Trinary math @@ -212,7 +213,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeTriop) + ASTGEN_MEMBERS_NodeTriop; AstNode* lhsp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } AstNode* thsp() const { return op3p(); } @@ -220,7 +221,7 @@ public: void rhsp(AstNode* nodep) { return setOp2p(nodep); } void thsp(AstNode* nodep) { return setOp3p(nodep); } // METHODS - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; // Set out to evaluation of a AstConst'ed virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, const V3Number& ths) @@ -231,8 +232,8 @@ public: virtual bool sizeMattersLhs() const = 0; // True if output result depends on lhs size virtual bool sizeMattersRhs() const = 0; // True if output result depends on rhs size virtual bool sizeMattersThs() const = 0; // True if output result depends on ths size - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode*) const override { return true; } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode*) const override { return true; } }; class AstNodeCond VL_NOT_FINAL : public AstNodeTriop { protected: @@ -246,22 +247,22 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeCond) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override; + ASTGEN_MEMBERS_NodeCond; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override; AstNode* condp() const { return op1p(); } // op1 = Condition AstNode* expr1p() const { return op2p(); } // op2 = If true... AstNode* expr2p() const { return op3p(); } // op3 = If false... - virtual string emitVerilog() override { return "%k(%l %f? %r %k: %t)"; } - virtual string emitC() override { return "VL_COND_%nq%lq%rq%tq(%nw, %P, %li, %ri, %ti)"; } - virtual bool cleanOut() const override { return false; } // clean if e1 & e2 clean - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return false; } - virtual bool cleanThs() const override { return false; } // Propagates up - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } + string emitVerilog() override { return "%k(%l %f? %r %k: %t)"; } + string emitC() override { return "VL_COND_%nq%lq%rq%tq(%nw, %P, %li, %ri, %ti)"; } + bool cleanOut() const override { return false; } // clean if e1 & e2 clean + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return false; } + bool cleanThs() const override { return false; } // Propagates up + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } virtual AstNode* cloneType(AstNode* condp, AstNode* expr1p, AstNode* expr2p) = 0; }; class AstNodeUniop VL_NOT_FINAL : public AstNodeMath { @@ -274,11 +275,11 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeUniop) + ASTGEN_MEMBERS_NodeUniop; AstNode* lhsp() const { return op1p(); } void lhsp(AstNode* nodep) { return setOp1p(nodep); } // METHODS - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; // Set out to evaluation of a AstConst'ed lhs virtual void numberOperate(V3Number& out, const V3Number& lhs) = 0; virtual bool cleanLhs() const = 0; @@ -287,8 +288,8 @@ public: // Signed flavor of nodes with both flavors? virtual bool signedFlavor() const { return false; } virtual bool stringFlavor() const { return false; } // N flavor of nodes with both flavors? - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode*) const override { return true; } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode*) const override { return true; } }; class AstNodeSystemUniop VL_NOT_FINAL : public AstNodeUniop { public: @@ -296,12 +297,12 @@ public: : AstNodeUniop(t, fl, lhsp) { dtypeSetDouble(); } - ASTNODE_BASE_FUNCS(NodeSystemUniop) - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL_TRIG; } - virtual bool doubleFlavor() const override { return true; } + ASTGEN_MEMBERS_NodeSystemUniop; + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL_TRIG; } + bool doubleFlavor() const override { return true; } }; class AstNodeVarRef VL_NOT_FINAL : public AstNodeMath { // An AstVarRef or AstVarXRef @@ -329,18 +330,21 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeVarRef) - virtual void dump(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } - virtual const char* broken() const override; - virtual int instrCount() const override { return widthInstrs(); } - virtual void cloneRelink() override; - virtual string name() const override { return m_name; } // * = Var name - virtual void name(const string& name) override { m_name = name; } + ASTGEN_MEMBERS_NodeVarRef; + void dump(std::ostream& str) const override; + bool hasDType() const override { return true; } + const char* broken() const override; + int instrCount() const override { return widthInstrs(); } + void cloneRelink() override; + string name() const override { return m_name; } // * = Var name + void name(const string& name) override { m_name = name; } VAccess access() const { return m_access; } void access(const VAccess& flag) { m_access = flag; } // Avoid using this; Set in constructor AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable - void varp(AstVar* varp); + void varp(AstVar* varp) { + m_varp = varp; + dtypeFrom((AstNode*)varp); + } AstVarScope* varScopep() const { return m_varScopep; } void varScopep(AstVarScope* varscp) { m_varScopep = varscp; } string selfPointer() const { return m_selfPointer; } @@ -370,12 +374,12 @@ public: } public: - ASTNODE_NODE_FUNCS(AddrOfCFunc) - virtual void cloneRelink() override; - virtual const char* broken() const override; - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + ASTGEN_MEMBERS_AddrOfCFunc; + void cloneRelink() override; + const char* broken() const override; + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } AstCFunc* funcp() const { return m_funcp; } }; class AstCMath final : public AstNodeMath { @@ -392,13 +396,13 @@ public: dtypeFrom(exprsp); } inline AstCMath(FileLine* fl, const string& textStmt, int setwidth, bool cleanOut = true); - ASTNODE_NODE_FUNCS(CMath) - virtual bool isGateOptimizable() const override { return m_pure; } - virtual bool isPredictOptimizable() const override { return m_pure; } - virtual bool cleanOut() const override { return m_cleanOut; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_CMath; + bool isGateOptimizable() const override { return m_pure; } + bool isPredictOptimizable() const override { return m_pure; } + bool cleanOut() const override { return m_cleanOut; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool same(const AstNode* /*samep*/) const override { return true; } void addBodysp(AstNode* nodep) { addNOp1p(nodep); } AstNode* bodysp() const { return op1p(); } // op1 = expressions to print bool pure() const { return m_pure; } @@ -413,14 +417,14 @@ public: : ASTGEN_SUPER_ConsAssoc(fl) { setNOp1p(defaultp); } - ASTNODE_NODE_FUNCS(ConsAssoc) - virtual string emitVerilog() override { return "'{}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_ConsAssoc; + string emitVerilog() override { return "'{}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* defaultp() const { return op1p(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstConsDynArray final : public AstNodeMath { // Construct a queue and return object, '{}. '{lhs}, '{lhs. rhs} @@ -432,15 +436,15 @@ public: setNOp1p(lhsp); setNOp2p(rhsp); } - ASTNODE_NODE_FUNCS(ConsDynArray) - virtual string emitVerilog() override { return "'{%l, %r}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_ConsDynArray; + string emitVerilog() override { return "'{%l, %r}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* lhsp() const { return op1p(); } // op1 = expression AstNode* rhsp() const { return op2p(); } // op2 = expression - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstConsQueue final : public AstNodeMath { // Construct a queue and return object, '{}. '{lhs}, '{lhs. rhs} @@ -452,15 +456,15 @@ public: setNOp1p(lhsp); setNOp2p(rhsp); } - ASTNODE_NODE_FUNCS(ConsQueue) - virtual string emitVerilog() override { return "'{%l, %r}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_ConsQueue; + string emitVerilog() override { return "'{%l, %r}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* lhsp() const { return op1p(); } // op1 = expression AstNode* rhsp() const { return op2p(); } // op2 = expression - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstConsWildcard final : public AstNodeMath { // Construct a wildcard assoc array and return object, '{} @@ -471,14 +475,14 @@ public: : ASTGEN_SUPER_ConsWildcard(fl) { setNOp1p(defaultp); } - ASTNODE_NODE_FUNCS(ConsWildcard) - virtual string emitVerilog() override { return "'{}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_ConsWildcard; + string emitVerilog() override { return "'{}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* defaultp() const { return op1p(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstConst final : public AstNodeMath { // A constant @@ -593,21 +597,21 @@ public: dtypeSetBit(); // Events 1 bit, objects 64 bits, so autoExtend=1 and use bit here initWithNumber(); } - ASTNODE_NODE_FUNCS(Const) - virtual string name() const override { return num().ascii(); } // * = Value + ASTGEN_MEMBERS_Const; + string name() const override { return num().ascii(); } // * = Value const V3Number& num() const { return m_num; } // * = Value V3Number& num() { return m_num; } // * = Value uint32_t toUInt() const { return num().toUInt(); } int32_t toSInt() const { return num().toSInt(); } uint64_t toUQuad() const { return num().toUQuad(); } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* samep) const override { + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool same(const AstNode* samep) const override { const AstConst* const sp = static_cast(samep); return num().isCaseEq(sp->num()); } - virtual int instrCount() const override { return widthInstrs(); } + int instrCount() const override { return widthInstrs(); } bool isEqAllOnes() const { return num().isEqAllOnes(width()); } bool isEqAllOnesV() const { return num().isEqAllOnes(widthMinV()); } // Parse string and create appropriate type of AstConst. @@ -618,11 +622,11 @@ class AstEmptyQueue final : public AstNodeMath { public: explicit AstEmptyQueue(FileLine* fl) : ASTGEN_SUPER_EmptyQueue(fl) {} - ASTNODE_NODE_FUNCS(EmptyQueue) - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitVerilog() override { return "{}"; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual bool cleanOut() const override { return true; } + ASTGEN_MEMBERS_EmptyQueue; + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitVerilog() override { return "{}"; } + bool same(const AstNode* /*samep*/) const override { return true; } + bool cleanOut() const override { return true; } }; class AstEnumItemRef final : public AstNodeMath { private: @@ -635,22 +639,22 @@ public: , m_classOrPackagep{classOrPackagep} { dtypeFrom(m_itemp); } - ASTNODE_NODE_FUNCS(EnumItemRef) - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return itemp()->name(); } - virtual int instrCount() const override { return 0; } + ASTGEN_MEMBERS_EnumItemRef; + void dump(std::ostream& str) const override; + string name() const override { return itemp()->name(); } + int instrCount() const override { return 0; } const char* broken() const override; - virtual void cloneRelink() override { + void cloneRelink() override { if (m_itemp->clonep()) m_itemp = m_itemp->clonep(); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstEnumItemRef* const sp = static_cast(samep); return itemp() == sp->itemp(); } AstEnumItem* itemp() const { return m_itemp; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } AstNodeModule* classOrPackagep() const { return m_classOrPackagep; } void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } }; @@ -665,16 +669,16 @@ public: setOp2p(resultp); // Possibly in future nullptr could mean return rhsp() dtypeFrom(resultp); } - ASTNODE_NODE_FUNCS(ExprStmt) + ASTGEN_MEMBERS_ExprStmt; // ACCESSORS AstNode* stmtsp() const { return op1p(); } void addStmtsp(AstNode* nodep) { addOp1p(nodep); } AstNode* resultp() const { return op2p(); } // METHODS - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode*) const override { return true; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool same(const AstNode*) const override { return true; } }; class AstFError final : public AstNodeMath { public: @@ -683,21 +687,19 @@ public: setOp1p(filep); setOp2p(strp); } - ASTNODE_NODE_FUNCS(FError) - virtual string emitVerilog() override { return "%f$ferror(%l, %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + ASTGEN_MEMBERS_FError; + string emitVerilog() override { return "%f$ferror(%l, %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } virtual bool cleanLhs() const { return true; } virtual bool sizeMattersLhs() const { return false; } - virtual int instrCount() const override { return widthInstrs() * 64; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering + int instrCount() const override { return widthInstrs() * 64; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering void filep(AstNode* nodep) { setOp1p(nodep); } AstNode* filep() const { return op1p(); } void strp(AstNode* nodep) { setOp2p(nodep); } AstNode* strp() const { return op2p(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstFRead final : public AstNodeMath { // Parents: expr @@ -713,16 +715,16 @@ public: setNOp3p(startp); setNOp4p(countp); } - ASTNODE_NODE_FUNCS(FRead) - virtual string verilogKwd() const override { return "$fread"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: makes output - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FRead; + string verilogKwd() const override { return "$fread"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: makes output + bool cleanOut() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* memp() const { return op1p(); } void memp(AstNode* nodep) { setOp1p(nodep); } AstNode* filep() const { return op2p(); } @@ -740,17 +742,17 @@ public: : ASTGEN_SUPER_FRewind(fl) { setNOp2p(filep); } - ASTNODE_NODE_FUNCS(FRewind) - virtual string verilogKwd() const override { return "$frewind"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FRewind; + string verilogKwd() const override { return "$frewind"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool cleanOut() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op2p(); } void filep(AstNodeVarRef* nodep) { setNOp2p((AstNode*)nodep); } }; @@ -768,17 +770,17 @@ public: addNOp1p(exprsp); setNOp2p(filep); } - ASTNODE_NODE_FUNCS(FScanF) - virtual string name() const override { return m_text; } - virtual string verilogKwd() const override { return "$fscanf"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: makes output - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_FScanF; + string name() const override { return m_text; } + string verilogKwd() const override { return "$fscanf"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: makes output + bool cleanOut() const override { return false; } + bool same(const AstNode* samep) const override { return text() == static_cast(samep)->text(); } AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output @@ -800,16 +802,16 @@ public: setNOp3p(offset); setNOp4p(operation); } - ASTNODE_NODE_FUNCS(FSeek) - virtual string verilogKwd() const override { return "$fseek"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: makes output - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FSeek; + string verilogKwd() const override { return "$fseek"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: makes output + bool cleanOut() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op2p(); } void filep(AstNode* nodep) { setOp2p(nodep); } AstNode* offset() const { return op3p(); } @@ -825,17 +827,17 @@ public: : ASTGEN_SUPER_FTell(fl) { setNOp2p(filep); } - ASTNODE_NODE_FUNCS(FTell) - virtual string verilogKwd() const override { return "$ftell"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FTell; + string verilogKwd() const override { return "$ftell"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool cleanOut() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op2p(); } void filep(AstNodeVarRef* nodep) { setNOp2p((AstNode*)nodep); } }; @@ -848,16 +850,16 @@ public: : ASTGEN_SUPER_Fell(fl) { addOp1p(exprp); } - ASTNODE_NODE_FUNCS(Fell) - virtual string emitVerilog() override { return "$fell(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_Fell; + string emitVerilog() override { return "$fell(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p((AstNode*)sentreep); } // op2 = clock domain - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstGatePin final : public AstNodeMath { // Possibly expand a gate primitive input pin value to match the range of the gate primitive @@ -867,10 +869,10 @@ public: setOp1p(lhsp); setOp2p((AstNode*)rangep); } - ASTNODE_NODE_FUNCS(GatePin) - virtual string emitVerilog() override { return "%l"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + ASTGEN_MEMBERS_GatePin; + string emitVerilog() override { return "%l"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } AstNode* exprp() const { return op1p(); } // op1 = Pin expression AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Range of pin }; @@ -884,19 +886,19 @@ public: setOp1p(lhs); setOp2p(rhs); } - ASTNODE_NODE_FUNCS(Implication) - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_Implication; + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } AstNode* lhsp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } void lhsp(AstNode* nodep) { return setOp1p(nodep); } void rhsp(AstNode* nodep) { return setOp2p(nodep); } AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p((AstNode*)sentreep); } // op4 = clock domain - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstInside final : public AstNodeMath { public: @@ -906,13 +908,13 @@ public: addOp2p(itemsp); dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Inside) + ASTGEN_MEMBERS_Inside; AstNode* exprp() const { return op1p(); } // op1 = LHS expression to compare with // op2 = RHS, possibly a list of expr or AstInsideRange AstNode* itemsp() const { return op2p(); } - virtual string emitVerilog() override { return "%l inside { %r }"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } // NA + string emitVerilog() override { return "%l inside { %r }"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } // NA }; class AstInsideRange final : public AstNodeMath { public: @@ -921,12 +923,12 @@ public: addOp1p(lhsp); addOp2p(rhsp); } - ASTNODE_NODE_FUNCS(InsideRange) + ASTGEN_MEMBERS_InsideRange; AstNode* lhsp() const { return op1p(); } // op1 = LHS AstNode* rhsp() const { return op2p(); } // op2 = RHS - virtual string emitVerilog() override { return "[%l:%r]"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } // NA + string emitVerilog() override { return "[%l:%r]"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } // NA // Create AstAnd(AstGte(...), AstLte(...)) AstNode* newAndFromInside(AstNode* exprp, AstNode* lhsp, AstNode* rhsp); }; @@ -943,15 +945,15 @@ public: : ASTGEN_SUPER_LambdaArgRef(fl) , m_name{name} , m_index(index) {} - ASTNODE_NODE_FUNCS(LambdaArgRef) - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual string emitVerilog() override { return name(); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool hasDType() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } - virtual string name() const override { return m_name; } // * = Var name - virtual void name(const string& name) override { m_name = name; } + ASTGEN_MEMBERS_LambdaArgRef; + bool same(const AstNode* /*samep*/) const override { return true; } + string emitVerilog() override { return name(); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool hasDType() const override { return true; } + int instrCount() const override { return widthInstrs(); } + string name() const override { return m_name; } // * = Var name + void name(const string& name) override { m_name = name; } bool index() const { return m_index; } }; class AstMemberSel final : public AstNodeMath { @@ -974,18 +976,16 @@ public: setOp1p(fromp); dtypep(dtp); } - ASTNODE_NODE_FUNCS(MemberSel) + ASTGEN_MEMBERS_MemberSel; void cloneRelink() override; const char* broken() const override; - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* samep) const override { - return true; - } // dtype comparison does it - virtual int instrCount() const override { return widthInstrs(); } + void dump(std::ostream& str) const override; + string name() const override { return m_name; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool same(const AstNode* samep) const override { return true; } // dtype comparison does it + int instrCount() const override { return widthInstrs(); } AstNode* fromp() const { return op1p(); } // op1 = Extracting what (nullptr=TBD during parsing) @@ -1003,12 +1003,12 @@ public: dtypeFrom(rhsp); // otherwise V3Width will resolve setNOp1p(rhsp); } - ASTNODE_NODE_FUNCS(NewCopy) - virtual string emitVerilog() override { return "new"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_NewCopy; + string emitVerilog() override { return "new"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* rhsp() const { return op1p(); } }; class AstNewDynamic final : public AstNodeMath { @@ -1022,12 +1022,12 @@ public: setNOp1p(sizep); setNOp2p(rhsp); } - ASTNODE_NODE_FUNCS(NewDynamic) - virtual string emitVerilog() override { return "new"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_NewDynamic; + string emitVerilog() override { return "new"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* sizep() const { return op1p(); } AstNode* rhsp() const { return op2p(); } }; @@ -1041,17 +1041,17 @@ public: addOp1p(exprp); addNOp2p(ticksp); } - ASTNODE_NODE_FUNCS(Past) - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_Past; + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression AstNode* ticksp() const { return op2p(); } // op2 = ticks or nullptr means 1 AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p((AstNode*)sentreep); } // op4 = clock domain - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstPatMember final : public AstNodeMath { // Verilog '{a} or '{a{b}} @@ -1065,13 +1065,13 @@ public: : ASTGEN_SUPER_PatMember(fl) { addOp1p(lhsp), setNOp2p(keyp), setNOp3p(repp); } - ASTNODE_NODE_FUNCS(PatMember) - virtual string emitVerilog() override { return lhssp() ? "%f{%r{%k%l}}" : "%l"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs() * 2; } - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_PatMember; + string emitVerilog() override { return lhssp() ? "%f{%r{%k%l}}" : "%l"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs() * 2; } + void dump(std::ostream& str = std::cout) const override; // op1 = expression to assign or another AstPattern (list if replicated) AstNode* lhssp() const { return op1p(); } AstNode* keyp() const { return op2p(); } // op2 = assignment key (Const, id Text) @@ -1088,13 +1088,13 @@ public: : ASTGEN_SUPER_Pattern(fl) { addNOp2p(itemsp); } - ASTNODE_NODE_FUNCS(Pattern) - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + ASTGEN_MEMBERS_Pattern; + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); } // op1 = Type assigning to AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } @@ -1117,26 +1117,26 @@ public: } AstRand(FileLine* fl, AstNode* seedp, bool urandom) : ASTGEN_SUPER_Rand(fl) - , m_urandom(urandom) { + , m_urandom{urandom} { setNOp1p(seedp); } - ASTNODE_NODE_FUNCS(Rand) - virtual string emitVerilog() override { + ASTGEN_MEMBERS_Rand; + string emitVerilog() override { return seedp() ? (m_urandom ? "%f$urandom(%l)" : "%f$random(%l)") : (m_urandom ? "%f$urandom()" : "%f$random()"); } - virtual string emitC() override { + string emitC() override { return m_reset ? "VL_RAND_RESET_%nq(%nw, %P)" : seedp() ? (urandom() ? "VL_URANDOM_SEEDED_%nq%lq(%li)" : "VL_RANDOM_SEEDED_%nq%lq(%li)") : isWide() ? "VL_RANDOM_%nq(%nw, %P)" // : "VL_RANDOM_%nq()"; } - virtual bool cleanOut() const override { return false; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool cleanOut() const override { return false; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_PLI; } + bool same(const AstNode* /*samep*/) const override { return true; } bool combinable(const AstRand* samep) const { return !seedp() && !samep->seedp() && reset() == samep->reset() && urandom() == samep->urandom(); @@ -1154,16 +1154,16 @@ public: : ASTGEN_SUPER_Rose(fl) { addOp1p(exprp); } - ASTNODE_NODE_FUNCS(Rose) - virtual string emitVerilog() override { return "$rose(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_Rose; + string emitVerilog() override { return "$rose(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p((AstNode*)sentreep); } // op2 = clock domain - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstSScanF final : public AstNodeMath { // Parents: expr @@ -1179,17 +1179,17 @@ public: addNOp1p(exprsp); setOp2p(fromp); } - ASTNODE_NODE_FUNCS(SScanF) - virtual string name() const override { return m_text; } - virtual string verilogKwd() const override { return "$sscanf"; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: makes output - virtual bool cleanOut() const override { return false; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_SScanF; + string name() const override { return m_text; } + string verilogKwd() const override { return "$sscanf"; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: makes output + bool cleanOut() const override { return false; } + bool same(const AstNode* samep) const override { return text() == static_cast(samep)->text(); } AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output @@ -1208,14 +1208,14 @@ public: : ASTGEN_SUPER_Sampled(fl) { addOp1p(exprp); } - ASTNODE_NODE_FUNCS(Sampled) - virtual string emitVerilog() override { return "$sampled(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return 0; } + ASTGEN_MEMBERS_Sampled; + string emitVerilog() override { return "$sampled(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return 0; } AstNode* exprp() const { return op1p(); } // op1 = expression - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstScopeName final : public AstNodeMath { // For display %m and DPI context imports @@ -1234,15 +1234,15 @@ public: , m_forFormat{forFormat} { dtypeSetUInt64(); } - ASTNODE_NODE_FUNCS(ScopeName) - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_ScopeName; + bool same(const AstNode* samep) const override { return (m_dpiExport == static_cast(samep)->m_dpiExport && m_forFormat == static_cast(samep)->m_forFormat); } - virtual string emitVerilog() override { return ""; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual void dump(std::ostream& str = std::cout) const override; + string emitVerilog() override { return ""; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + void dump(std::ostream& str = std::cout) const override; AstText* scopeAttrp() const { return VN_AS(op1p(), Text); } void scopeAttrp(AstNode* nodep) { addOp1p(nodep); } AstText* scopeEntrp() const { return VN_AS(op2p(), Text); } @@ -1274,16 +1274,16 @@ public: setNOp2p(keyp); setOp3p(valuep); } - ASTNODE_NODE_FUNCS(SetAssoc) - virtual string emitVerilog() override { return "'{}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_SetAssoc; + string emitVerilog() override { return "'{}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* lhsp() const { return op1p(); } AstNode* keyp() const { return op2p(); } AstNode* valuep() const { return op3p(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstSetWildcard final : public AstNodeMath { // Set a wildcard assoc array element and return object, '{} @@ -1296,16 +1296,16 @@ public: setNOp2p(keyp); setOp3p(valuep); } - ASTNODE_NODE_FUNCS(SetWildcard) - virtual string emitVerilog() override { return "'{}"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_SetWildcard; + string emitVerilog() override { return "'{}"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } AstNode* lhsp() const { return op1p(); } AstNode* keyp() const { return op2p(); } AstNode* valuep() const { return op3p(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstStable final : public AstNodeMath { // Verilog $stable @@ -1316,16 +1316,16 @@ public: : ASTGEN_SUPER_Stable(fl) { addOp1p(exprp); } - ASTNODE_NODE_FUNCS(Stable) - virtual string emitVerilog() override { return "$stable(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } - virtual int instrCount() const override { return widthInstrs(); } + ASTGEN_MEMBERS_Stable; + string emitVerilog() override { return "$stable(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } + int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p((AstNode*)sentreep); } // op2 = clock domain - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstSystemF final : public AstNodeMath { // $system used as function @@ -1334,17 +1334,17 @@ public: : ASTGEN_SUPER_SystemF(fl) { setOp1p(lhsp); } - ASTNODE_NODE_FUNCS(SystemF) - virtual string verilogKwd() const override { return "$system"; } - virtual string emitVerilog() override { return verilogKwd(); } - virtual string emitC() override { return "VL_SYSTEM_%nq(%lw, %P)"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_SystemF; + string verilogKwd() const override { return "$system"; } + string emitVerilog() override { return verilogKwd(); } + string emitC() override { return "VL_SYSTEM_%nq(%lw, %P)"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool cleanOut() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* lhsp() const { return op1p(); } }; class AstTestPlusArgs final : public AstNodeMath { @@ -1355,14 +1355,14 @@ public: : ASTGEN_SUPER_TestPlusArgs(fl) { setOp1p(searchp); } - ASTNODE_NODE_FUNCS(TestPlusArgs) - virtual string verilogKwd() const override { return "$test$plusargs"; } - virtual string emitVerilog() override { return verilogKwd(); } - virtual string emitC() override { return "VL_VALUEPLUSARGS_%nq(%lw, %P, nullptr)"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_TestPlusArgs; + string verilogKwd() const override { return "$test$plusargs"; } + string emitVerilog() override { return verilogKwd(); } + string emitC() override { return "VL_VALUEPLUSARGS_%nq(%lw, %P, nullptr)"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool cleanOut() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* searchp() const { return op1p(); } // op1 = Search expression void searchp(AstNode* nodep) { setOp1p(nodep); } }; @@ -1374,18 +1374,18 @@ public: : ASTGEN_SUPER_UCFunc(fl) { addNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(UCFunc) - virtual bool cleanOut() const override { return false; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } + ASTGEN_MEMBERS_UCFunc; + bool cleanOut() const override { return false; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } AstNode* bodysp() const { return op1p(); } // op1 = expressions to print - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isSubstOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isSubstOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_PLI; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstUnbounded final : public AstNodeMath { // A $ in the parser, used for unbounded and queues @@ -1395,10 +1395,10 @@ public: : ASTGEN_SUPER_Unbounded(fl) { dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(Unbounded) - virtual string emitVerilog() override { return "$"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + ASTGEN_MEMBERS_Unbounded; + string emitVerilog() override { return "$"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } }; class AstValuePlusArgs final : public AstNodeMath { // Parents: expr @@ -1409,15 +1409,15 @@ public: setOp1p(searchp); setOp2p(outp); } - ASTNODE_NODE_FUNCS(ValuePlusArgs) - virtual string verilogKwd() const override { return "$value$plusargs"; } - virtual string emitVerilog() override { return "%f$value$plusargs(%l, %k%r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return !outp(); } - virtual bool cleanOut() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_ValuePlusArgs; + string verilogKwd() const override { return "$value$plusargs"; } + string emitVerilog() override { return "%f$value$plusargs(%l, %k%r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return !outp(); } + bool cleanOut() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* searchp() const { return op1p(); } // op1 = Search expression void searchp(AstNode* nodep) { setOp1p(nodep); } AstNode* outp() const { return op2p(); } // op2 = Expressions to output @@ -1434,21 +1434,21 @@ public: : ASTGEN_SUPER_BufIf1(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(BufIf1) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_BufIf1; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstBufIf1(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opBufIf1(lhs, rhs); } - virtual string emitVerilog() override { return "bufif(%r,%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "bufif(%r,%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean + bool cleanOut() const override { V3ERROR_NA_RETURN(""); } // Lclean || Rclean + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstCastDynamic final : public AstNodeBiop { // Verilog $cast used as a function @@ -1461,22 +1461,22 @@ class AstCastDynamic final : public AstNodeBiop { public: AstCastDynamic(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_CastDynamic(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(CastDynamic) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + ASTGEN_MEMBERS_CastDynamic; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstCastDynamic(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f$cast(%r, %l)"; } - virtual string emitC() override { return "VL_DYNAMIC_CAST(%r, %l)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 20; } - virtual bool isPure() const override { return true; } + string emitVerilog() override { return "%f$cast(%r, %l)"; } + string emitC() override { return "VL_DYNAMIC_CAST(%r, %l)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 20; } + bool isPure() const override { return true; } AstNode* fromp() const { return lhsp(); } AstNode* top() const { return rhsp(); } }; @@ -1490,26 +1490,26 @@ public: , m_ignoreCase{ignoreCase} { dtypeSetUInt32(); } - ASTNODE_NODE_FUNCS(CompareNN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_CompareNN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstCompareNN(this->fileline(), lhsp, rhsp, m_ignoreCase); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opCompareNN(lhs, rhs, m_ignoreCase); } - virtual string name() const override { return m_ignoreCase ? "icompare" : "compare"; } - virtual string emitVerilog() override { + string name() const override { return m_ignoreCase ? "icompare" : "compare"; } + string emitVerilog() override { return m_ignoreCase ? "%k(%l.icompare(%r))" : "%k(%l.compare(%r))"; } - virtual string emitC() override { + string emitC() override { return m_ignoreCase ? "VL_CMP_NN(%li,%ri,true)" : "VL_CMP_NN(%li,%ri,false)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstConcat final : public AstNodeBiop { // If you're looking for {#{}}, see AstReplicate @@ -1521,21 +1521,21 @@ public: VSigning::UNSIGNED); } } - ASTNODE_NODE_FUNCS(Concat) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Concat; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstConcat(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f{%l, %k%r}"; } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + string emitVerilog() override { return "%f{%l, %k%r}"; } + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opConcat(lhs, rhs); } - virtual string emitC() override { return "VL_CONCAT_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 2; } + string emitC() override { return "VL_CONCAT_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 2; } }; class AstConcatN final : public AstNodeBiop { // String concatenate @@ -1544,22 +1544,22 @@ public: : ASTGEN_SUPER_ConcatN(fl, lhsp, rhsp) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(ConcatN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ConcatN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstConcatN(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f{%l, %k%r}"; } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + string emitVerilog() override { return "%f{%l, %k%r}"; } + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opConcatN(lhs, rhs); } - virtual string emitC() override { return "VL_CONCATN_NNN(%li, %ri)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitC() override { return "VL_CONCATN_NNN(%li, %ri)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstDiv final : public AstNodeBiop { public: @@ -1567,21 +1567,21 @@ public: : ASTGEN_SUPER_Div(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Div) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Div; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstDiv(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opDiv(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f/ %r)"; } - virtual string emitC() override { return "VL_DIV_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } + string emitVerilog() override { return "%k(%l %f/ %r)"; } + string emitC() override { return "VL_DIV_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } }; class AstDivD final : public AstNodeBiop { public: @@ -1589,23 +1589,23 @@ public: : ASTGEN_SUPER_DivD(fl, lhsp, rhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(DivD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_DivD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstDivD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opDivD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f/ %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "/"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL_DIV; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f/ %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "/"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL_DIV; } + bool doubleFlavor() const override { return true; } }; class AstDivS final : public AstNodeBiop { public: @@ -1613,22 +1613,22 @@ public: : ASTGEN_SUPER_DivS(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(DivS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_DivS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstDivS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opDivS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f/ %r)"; } - virtual string emitC() override { return "VL_DIVS_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f/ %r)"; } + string emitC() override { return "VL_DIVS_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } + bool signedFlavor() const override { return true; } }; class AstEqWild final : public AstNodeBiop { // Note wildcard operator rhs differs from lhs @@ -1637,46 +1637,46 @@ public: : ASTGEN_SUPER_EqWild(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(EqWild) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_EqWild; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstEqWild(this->fileline(), lhsp, rhsp); } static AstNodeBiop* newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp); // Return AstEqWild/AstEqD - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opWildEq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f==? %r)"; } - virtual string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "=="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f==? %r)"; } + string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "=="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstFGetS final : public AstNodeBiop { public: AstFGetS(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_FGetS(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(FGetS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_FGetS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstFGetS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%f$fgets(%l,%r)"; } - virtual string emitC() override { + string emitVerilog() override { return "%f$fgets(%l,%r)"; } + string emitC() override { return strgp()->dtypep()->basicp()->isString() ? "VL_FGETS_NI(%li, %ri)" : "VL_FGETS_%nqX%rq(%lw, %P, &(%li), %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 64; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 64; } AstNode* strgp() const { return lhsp(); } AstNode* filep() const { return rhsp(); } }; @@ -1684,27 +1684,25 @@ class AstFUngetC final : public AstNodeBiop { public: AstFUngetC(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_FUngetC(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(FUngetC) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + ASTGEN_MEMBERS_FUngetC; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstFUngetC(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f$ungetc(%r, %l)"; } + string emitVerilog() override { return "%f$ungetc(%r, %l)"; } // Non-existent filehandle returns EOF - virtual string emitC() override { + string emitC() override { return "(%li ? (ungetc(%ri, VL_CVT_I_FP(%li)) >= 0 ? 0 : -1) : -1)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 64; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 64; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering AstNode* filep() const { return lhsp(); } AstNode* charp() const { return rhsp(); } }; @@ -1715,22 +1713,22 @@ public: : ASTGEN_SUPER_GetcN(fl, lhsp, rhsp) { dtypeSetBitSized(8, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(GetcN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GetcN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGetcN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGetcN(lhs, rhs); } - virtual string name() const override { return "getc"; } - virtual string emitVerilog() override { return "%k(%l.getc(%r))"; } - virtual string emitC() override { return "VL_GETC_N(%li,%ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string name() const override { return "getc"; } + string emitVerilog() override { return "%k(%l.getc(%r))"; } + string emitC() override { return "VL_GETC_N(%li,%ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstGetcRefN final : public AstNodeBiop { // Verilog string[#] on the left-hand-side of assignment @@ -1740,21 +1738,21 @@ public: : ASTGEN_SUPER_GetcRefN(fl, lhsp, rhsp) { dtypeSetBitSized(8, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(GetcRefN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GetcRefN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGetcRefN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%k%l[%r]"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k%l[%r]"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstGt final : public AstNodeBiop { public: @@ -1762,21 +1760,21 @@ public: : ASTGEN_SUPER_Gt(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Gt) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Gt; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGt(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGt(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f> %r)"; } - virtual string emitC() override { return "VL_GT_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ">"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f> %r)"; } + string emitC() override { return "VL_GT_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ">"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstGtD final : public AstNodeBiop { public: @@ -1784,23 +1782,23 @@ public: : ASTGEN_SUPER_GtD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GtD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GtD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGtD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGtD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f> %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return ">"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f> %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return ">"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstGtN final : public AstNodeBiop { public: @@ -1808,23 +1806,23 @@ public: : ASTGEN_SUPER_GtN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GtN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GtN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGtN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGtN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f> %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return ">"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f> %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return ">"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstGtS final : public AstNodeBiop { public: @@ -1832,22 +1830,22 @@ public: : ASTGEN_SUPER_GtS(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GtS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GtS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGtS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGtS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f> %r)"; } - virtual string emitC() override { return "VL_GTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f> %r)"; } + string emitC() override { return "VL_GTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool signedFlavor() const override { return true; } }; class AstGte final : public AstNodeBiop { public: @@ -1855,21 +1853,21 @@ public: : ASTGEN_SUPER_Gte(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Gte) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Gte; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGte(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGte(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f>= %r)"; } - virtual string emitC() override { return "VL_GTE_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ">="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f>= %r)"; } + string emitC() override { return "VL_GTE_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ">="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstGteD final : public AstNodeBiop { public: @@ -1877,23 +1875,23 @@ public: : ASTGEN_SUPER_GteD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GteD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GteD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGteD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGteD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f>= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return ">="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f>= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return ">="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstGteN final : public AstNodeBiop { public: @@ -1901,23 +1899,23 @@ public: : ASTGEN_SUPER_GteN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GteN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GteN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGteN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGteN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f>= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return ">="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f>= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return ">="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstGteS final : public AstNodeBiop { public: @@ -1925,22 +1923,22 @@ public: : ASTGEN_SUPER_GteS(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(GteS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_GteS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGteS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGteS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f>= %r)"; } - virtual string emitC() override { return "VL_GTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f>= %r)"; } + string emitC() override { return "VL_GTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool signedFlavor() const override { return true; } }; class AstLogAnd final : public AstNodeBiop { public: @@ -1948,22 +1946,22 @@ public: : ASTGEN_SUPER_LogAnd(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LogAnd) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LogAnd; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLogAnd(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLogAnd(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f&& %r)"; } - virtual string emitC() override { return "VL_LOGAND_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "&&"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } + string emitVerilog() override { return "%k(%l %f&& %r)"; } + string emitC() override { return "VL_LOGAND_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "&&"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } }; class AstLogIf final : public AstNodeBiop { public: @@ -1971,22 +1969,22 @@ public: : ASTGEN_SUPER_LogIf(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LogIf) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LogIf; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLogIf(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLogIf(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f-> %r)"; } - virtual string emitC() override { return "VL_LOGIF_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "->"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } + string emitVerilog() override { return "%k(%l %f-> %r)"; } + string emitC() override { return "VL_LOGIF_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "->"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } }; class AstLogOr final : public AstNodeBiop { // LOGOR with optional side effects @@ -1999,28 +1997,28 @@ public: : ASTGEN_SUPER_LogOr(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LogOr) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LogOr; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLogOr(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLogOr(lhs, rhs); } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstLogOr* const sp = static_cast(samep); return m_sideEffect == sp->m_sideEffect; } - virtual void dump(std::ostream& str = std::cout) const override; - virtual string emitVerilog() override { return "%k(%l %f|| %r)"; } - virtual string emitC() override { return "VL_LOGOR_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "||"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } - virtual bool isPure() const override { return !m_sideEffect; } + void dump(std::ostream& str = std::cout) const override; + string emitVerilog() override { return "%k(%l %f|| %r)"; } + string emitC() override { return "VL_LOGOR_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "||"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } + bool isPure() const override { return !m_sideEffect; } void sideEffect(bool flag) { m_sideEffect = flag; } bool sideEffect() const { return m_sideEffect; } }; @@ -2030,21 +2028,21 @@ public: : ASTGEN_SUPER_Lt(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Lt) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Lt; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLt(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLt(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f< %r)"; } - virtual string emitC() override { return "VL_LT_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "<"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f< %r)"; } + string emitC() override { return "VL_LT_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "<"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstLtD final : public AstNodeBiop { public: @@ -2052,23 +2050,23 @@ public: : ASTGEN_SUPER_LtD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LtD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LtD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLtD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLtD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f< %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "<"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f< %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "<"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstLtN final : public AstNodeBiop { public: @@ -2076,23 +2074,23 @@ public: : ASTGEN_SUPER_LtN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LtN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LtN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLtN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLtN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f< %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "<"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f< %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "<"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstLtS final : public AstNodeBiop { public: @@ -2100,22 +2098,22 @@ public: : ASTGEN_SUPER_LtS(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LtS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LtS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLtS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLtS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f< %r)"; } - virtual string emitC() override { return "VL_LTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f< %r)"; } + string emitC() override { return "VL_LTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool signedFlavor() const override { return true; } }; class AstLte final : public AstNodeBiop { public: @@ -2123,21 +2121,21 @@ public: : ASTGEN_SUPER_Lte(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Lte) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Lte; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLte(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLte(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<= %r)"; } - virtual string emitC() override { return "VL_LTE_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "<="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f<= %r)"; } + string emitC() override { return "VL_LTE_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "<="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstLteD final : public AstNodeBiop { public: @@ -2145,23 +2143,23 @@ public: : ASTGEN_SUPER_LteD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LteD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LteD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLteD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLteD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "<="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f<= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "<="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstLteN final : public AstNodeBiop { public: @@ -2169,23 +2167,23 @@ public: : ASTGEN_SUPER_LteN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LteN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LteN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLteN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLteN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "<="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f<= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "<="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstLteS final : public AstNodeBiop { public: @@ -2193,22 +2191,22 @@ public: : ASTGEN_SUPER_LteS(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LteS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LteS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLteS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLteS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<= %r)"; } - virtual string emitC() override { return "VL_LTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f<= %r)"; } + string emitC() override { return "VL_LTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool signedFlavor() const override { return true; } }; class AstModDiv final : public AstNodeBiop { public: @@ -2216,21 +2214,21 @@ public: : ASTGEN_SUPER_ModDiv(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(ModDiv) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ModDiv; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstModDiv(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opModDiv(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f%% %r)"; } - virtual string emitC() override { return "VL_MODDIV_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } + string emitVerilog() override { return "%k(%l %f%% %r)"; } + string emitC() override { return "VL_MODDIV_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } }; class AstModDivS final : public AstNodeBiop { public: @@ -2238,22 +2236,22 @@ public: : ASTGEN_SUPER_ModDivS(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(ModDivS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ModDivS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstModDivS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opModDivS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f%% %r)"; } - virtual string emitC() override { return "VL_MODDIVS_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f%% %r)"; } + string emitC() override { return "VL_MODDIVS_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_DIV; } + bool signedFlavor() const override { return true; } }; class AstNeqWild final : public AstNodeBiop { public: @@ -2261,21 +2259,21 @@ public: : ASTGEN_SUPER_NeqWild(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(NeqWild) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_NeqWild; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstNeqWild(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opWildNeq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f!=? %r)"; } - virtual string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "!="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f!=? %r)"; } + string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "!="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstPow final : public AstNodeBiop { public: @@ -2283,22 +2281,22 @@ public: : ASTGEN_SUPER_Pow(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Pow) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Pow; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstPow(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opPow(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f** %r)"; } - virtual string emitC() override { return "VL_POW_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } + string emitVerilog() override { return "%k(%l %f** %r)"; } + string emitC() override { return "VL_POW_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } }; class AstPowD final : public AstNodeBiop { public: @@ -2306,22 +2304,22 @@ public: : ASTGEN_SUPER_PowD(fl, lhsp, rhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(PowD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_PowD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstPowD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opPowD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f** %r)"; } - virtual string emitC() override { return "pow(%li,%ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL_DIV * 5; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f** %r)"; } + string emitC() override { return "pow(%li,%ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL_DIV * 5; } + bool doubleFlavor() const override { return true; } }; class AstPowSS final : public AstNodeBiop { public: @@ -2329,25 +2327,23 @@ public: : ASTGEN_SUPER_PowSS(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(PowSS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_PowSS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstPowSS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opPowSS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f** %r)"; } - virtual string emitC() override { - return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 1,1)"; - } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f** %r)"; } + string emitC() override { return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 1,1)"; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } + bool signedFlavor() const override { return true; } }; class AstPowSU final : public AstNodeBiop { public: @@ -2355,25 +2351,23 @@ public: : ASTGEN_SUPER_PowSU(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(PowSU) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_PowSU; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstPowSU(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opPowSU(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f** %r)"; } - virtual string emitC() override { - return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 1,0)"; - } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f** %r)"; } + string emitC() override { return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 1,0)"; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } + bool signedFlavor() const override { return true; } }; class AstPowUS final : public AstNodeBiop { public: @@ -2381,25 +2375,23 @@ public: : ASTGEN_SUPER_PowUS(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(PowUS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_PowUS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstPowUS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opPowUS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f** %r)"; } - virtual string emitC() override { - return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 0,1)"; - } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f** %r)"; } + string emitC() override { return "VL_POWSS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri, 0,1)"; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL * 10; } + bool signedFlavor() const override { return true; } }; class AstReplicate final : public AstNodeBiop { // Also used as a "Uniop" flavor of Concat, e.g. "{a}" @@ -2415,21 +2407,21 @@ public: } AstReplicate(FileLine* fl, AstNode* lhsp, uint32_t repCount) : AstReplicate(fl, lhsp, new AstConst(fl, repCount)) {} - ASTNODE_NODE_FUNCS(Replicate) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Replicate; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstReplicate(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opRepl(lhs, rhs); } - virtual string emitVerilog() override { return "%f{%r{%k%l}}"; } - virtual string emitC() override { return "VL_REPLICATE_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 2; } + string emitVerilog() override { return "%f{%r{%k%l}}"; } + string emitC() override { return "VL_REPLICATE_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 2; } }; class AstReplicateN final : public AstNodeBiop { // String replicate @@ -2440,22 +2432,22 @@ public: } AstReplicateN(FileLine* fl, AstNode* lhsp, uint32_t repCount) : AstReplicateN(fl, lhsp, new AstConst(fl, repCount)) {} - ASTNODE_NODE_FUNCS(ReplicateN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ReplicateN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstReplicateN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opReplN(lhs, rhs); } - virtual string emitVerilog() override { return "%f{%r{%k%l}}"; } - virtual string emitC() override { return "VL_REPLICATEN_NN%rq(%li, %ri)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 2; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%f{%r{%k%l}}"; } + string emitC() override { return "VL_REPLICATEN_NN%rq(%li, %ri)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 2; } + bool stringFlavor() const override { return true; } }; class AstShiftL final : public AstNodeBiop { public: @@ -2463,23 +2455,23 @@ public: : ASTGEN_SUPER_ShiftL(fl, lhsp, rhsp) { if (setwidth) dtypeSetLogicSized(setwidth, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(ShiftL) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ShiftL; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstShiftL(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opShiftL(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<< %r)"; } - virtual string emitC() override { return "VL_SHIFTL_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { + string emitVerilog() override { return "%k(%l %f<< %r)"; } + string emitC() override { return "VL_SHIFTL_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return (rhsp()->isWide() || rhsp()->isQuad()) ? "" : "<<"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } }; class AstShiftR final : public AstNodeBiop { public: @@ -2487,24 +2479,24 @@ public: : ASTGEN_SUPER_ShiftR(fl, lhsp, rhsp) { if (setwidth) dtypeSetLogicSized(setwidth, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(ShiftR) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ShiftR; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstShiftR(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opShiftR(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f>> %r)"; } - virtual string emitC() override { return "VL_SHIFTR_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { + string emitVerilog() override { return "%k(%l %f>> %r)"; } + string emitC() override { return "VL_SHIFTR_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return (rhsp()->isWide() || rhsp()->isQuad()) ? "" : ">>"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } // LHS size might be > output size, so don't want to force size - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstShiftRS final : public AstNodeBiop { // Shift right with sign extension, >>> operator @@ -2515,22 +2507,22 @@ public: // Important that widthMin be correct, as opExtend requires it after V3Expand if (setwidth) dtypeSetLogicSized(setwidth, VSigning::SIGNED); } - ASTNODE_NODE_FUNCS(ShiftRS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ShiftRS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstShiftRS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opShiftRS(lhs, rhs, lhsp()->widthMinV()); } - virtual string emitVerilog() override { return "%k(%l %f>>> %r)"; } - virtual string emitC() override { return "VL_SHIFTRS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f>>> %r)"; } + string emitC() override { return "VL_SHIFTRS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool signedFlavor() const override { return true; } }; class AstSub final : public AstNodeBiop { public: @@ -2538,21 +2530,21 @@ public: : ASTGEN_SUPER_Sub(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Sub) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Sub; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstSub(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opSub(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f- %r)"; } - virtual string emitC() override { return "VL_SUB_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "-"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } + string emitVerilog() override { return "%k(%l %f- %r)"; } + string emitC() override { return "VL_SUB_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "-"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } }; class AstSubD final : public AstNodeBiop { public: @@ -2560,23 +2552,23 @@ public: : ASTGEN_SUPER_SubD(fl, lhsp, rhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(SubD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_SubD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstSubD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opSubD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f- %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "-"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f- %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "-"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstURandomRange final : public AstNodeBiop { // $urandom_range @@ -2585,23 +2577,23 @@ public: : ASTGEN_SUPER_URandomRange(fl, lhsp, rhsp) { dtypeSetUInt32(); // Says IEEE } - ASTNODE_NODE_FUNCS(URandomRange) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_URandomRange; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstURandomRange(fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%f$urandom_range(%l, %r)"; } - virtual string emitC() override { return "VL_URANDOM_RANGE_%nq(%li, %ri)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + string emitVerilog() override { return "%f$urandom_range(%l, %r)"; } + string emitC() override { return "VL_URANDOM_RANGE_%nq(%li, %ri)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_PLI; } }; // === AstNodeBiCom === @@ -2611,23 +2603,23 @@ public: : ASTGEN_SUPER_Eq(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Eq) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Eq; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstEq(this->fileline(), lhsp, rhsp); } static AstNodeBiop* newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp); // Return AstEq/AstEqD - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opEq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f== %r)"; } - virtual string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "=="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f== %r)"; } + string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "=="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstEqCase final : public AstNodeBiCom { public: @@ -2635,21 +2627,21 @@ public: : ASTGEN_SUPER_EqCase(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(EqCase) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_EqCase; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstEqCase(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opCaseEq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f=== %r)"; } - virtual string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "=="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f=== %r)"; } + string emitC() override { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "=="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstEqD final : public AstNodeBiCom { public: @@ -2657,23 +2649,23 @@ public: : ASTGEN_SUPER_EqD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(EqD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_EqD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstEqD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opEqD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f== %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "=="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f== %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "=="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstEqN final : public AstNodeBiCom { public: @@ -2681,23 +2673,23 @@ public: : ASTGEN_SUPER_EqN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(EqN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_EqN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstEqN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opEqN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f== %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "=="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f== %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "=="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; class AstLogEq final : public AstNodeBiCom { public: @@ -2705,22 +2697,22 @@ public: : ASTGEN_SUPER_LogEq(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LogEq) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_LogEq; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLogEq(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLogEq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f<-> %r)"; } - virtual string emitC() override { return "VL_LOGEQ_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "<->"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } + string emitVerilog() override { return "%k(%l %f<-> %r)"; } + string emitC() override { return "VL_LOGEQ_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "<->"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } }; class AstNeq final : public AstNodeBiCom { public: @@ -2728,21 +2720,21 @@ public: : ASTGEN_SUPER_Neq(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(Neq) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Neq; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstNeq(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opNeq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f!= %r)"; } - virtual string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "!="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f!= %r)"; } + string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "!="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstNeqCase final : public AstNodeBiCom { public: @@ -2750,21 +2742,21 @@ public: : ASTGEN_SUPER_NeqCase(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(NeqCase) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_NeqCase; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstNeqCase(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opCaseNeq(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f!== %r)"; } - virtual string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "!="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f!== %r)"; } + string emitC() override { return "VL_NEQ_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "!="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstNeqD final : public AstNodeBiCom { public: @@ -2772,23 +2764,23 @@ public: : ASTGEN_SUPER_NeqD(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(NeqD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_NeqD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstNeqD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opNeqD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f!= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "!="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f!= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "!="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstNeqN final : public AstNodeBiCom { public: @@ -2796,23 +2788,23 @@ public: : ASTGEN_SUPER_NeqN(fl, lhsp, rhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(NeqN) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_NeqN; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstNeqN(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opNeqN(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f!= %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "!="; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_STR; } - virtual bool stringFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f!= %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "!="; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_STR; } + bool stringFlavor() const override { return true; } }; // === AstNodeBiComAsv === @@ -2822,21 +2814,21 @@ public: : ASTGEN_SUPER_Add(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Add) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Add; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAdd(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opAdd(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f+ %r)"; } - virtual string emitC() override { return "VL_ADD_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "+"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } + string emitVerilog() override { return "%k(%l %f+ %r)"; } + string emitC() override { return "VL_ADD_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "+"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } }; class AstAddD final : public AstNodeBiComAsv { public: @@ -2844,23 +2836,23 @@ public: : ASTGEN_SUPER_AddD(fl, lhsp, rhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(AddD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AddD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAddD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opAddD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f+ %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "+"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f+ %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "+"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstAnd final : public AstNodeBiComAsv { public: @@ -2868,21 +2860,21 @@ public: : ASTGEN_SUPER_And(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(And) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_And; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAnd(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opAnd(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f& %r)"; } - virtual string emitC() override { return "VL_AND_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "&"; } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(false); } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f& %r)"; } + string emitC() override { return "VL_AND_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "&"; } + bool cleanOut() const override { V3ERROR_NA_RETURN(false); } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstMul final : public AstNodeBiComAsv { public: @@ -2890,22 +2882,22 @@ public: : ASTGEN_SUPER_Mul(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Mul) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Mul; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstMul(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opMul(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f* %r)"; } - virtual string emitC() override { return "VL_MUL_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "*"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL; } + string emitVerilog() override { return "%k(%l %f* %r)"; } + string emitC() override { return "VL_MUL_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "*"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL; } }; class AstMulD final : public AstNodeBiComAsv { public: @@ -2913,23 +2905,23 @@ public: : ASTGEN_SUPER_MulD(fl, lhsp, rhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(MulD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_MulD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstMulD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opMulD(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f* %r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "*"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f* %r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "*"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstMulS final : public AstNodeBiComAsv { public: @@ -2937,24 +2929,24 @@ public: : ASTGEN_SUPER_MulS(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(MulS) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_MulS; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstMulS(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opMulS(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f* %r)"; } - virtual string emitC() override { return "VL_MULS_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL; } - virtual bool signedFlavor() const override { return true; } + string emitVerilog() override { return "%k(%l %f* %r)"; } + string emitC() override { return "VL_MULS_%nq%lq%rq(%lw, %P, %li, %ri)"; } + string emitSimpleOperator() override { return ""; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + int instrCount() const override { return widthInstrs() * INSTR_COUNT_INT_MUL; } + bool signedFlavor() const override { return true; } }; class AstOr final : public AstNodeBiComAsv { public: @@ -2962,21 +2954,21 @@ public: : ASTGEN_SUPER_Or(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Or) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Or; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstOr(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opOr(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f| %r)"; } - virtual string emitC() override { return "VL_OR_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "|"; } - virtual bool cleanOut() const override { V3ERROR_NA_RETURN(false); } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f| %r)"; } + string emitC() override { return "VL_OR_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "|"; } + bool cleanOut() const override { V3ERROR_NA_RETURN(false); } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; class AstXor final : public AstNodeBiComAsv { public: @@ -2984,21 +2976,21 @@ public: : ASTGEN_SUPER_Xor(fl, lhsp, rhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Xor) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Xor; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstXor(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opXor(lhs, rhs); } - virtual string emitVerilog() override { return "%k(%l %f^ %r)"; } - virtual string emitC() override { return "VL_XOR_%lq(%lW, %P, %li, %ri)"; } - virtual string emitSimpleOperator() override { return "^"; } - virtual bool cleanOut() const override { return false; } // Lclean && Rclean - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } + string emitVerilog() override { return "%k(%l %f^ %r)"; } + string emitC() override { return "VL_XOR_%lq(%lW, %P, %li, %ri)"; } + string emitSimpleOperator() override { return "^"; } + bool cleanOut() const override { return false; } // Lclean && Rclean + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } }; // === AstNodeSel === @@ -3022,26 +3014,24 @@ public: : ASTGEN_SUPER_ArraySel(fl, fromp, new AstConst(fl, bit)) { init(fromp); } - ASTNODE_NODE_FUNCS(ArraySel) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_ArraySel; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstArraySel(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; /* How can from be a const? */ } - virtual string emitVerilog() override { return "%k(%l%f[%r])"; } - virtual string emitC() override { return "%li%k[%ri]"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool isGateOptimizable() const override { - return true; - } // esp for V3Const::ifSameAssign - virtual bool isPredictOptimizable() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + string emitVerilog() override { return "%k(%l%f[%r])"; } + string emitC() override { return "%li%k[%ri]"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool isGateOptimizable() const override { return true; } // esp for V3Const::ifSameAssign + bool isPredictOptimizable() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return widthInstrs(); } // Special operators // Return base var (or const) nodep dereferences static AstNode* baseFromp(AstNode* nodep, bool overMembers); @@ -3062,26 +3052,24 @@ public: : ASTGEN_SUPER_AssocSel(fl, fromp, bitp) { init(fromp); } - ASTNODE_NODE_FUNCS(AssocSel) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssocSel; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAssocSel(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%k(%l%f[%r])"; } - virtual string emitC() override { return "%li%k[%ri]"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool isGateOptimizable() const override { - return true; - } // esp for V3Const::ifSameAssign - virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + string emitVerilog() override { return "%k(%l%f[%r])"; } + string emitC() override { return "%li%k[%ri]"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool isGateOptimizable() const override { return true; } // esp for V3Const::ifSameAssign + bool isPredictOptimizable() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return widthInstrs(); } }; class AstWildcardSel final : public AstNodeSel { // Parents: math|stmt @@ -3099,26 +3087,24 @@ public: : ASTGEN_SUPER_WildcardSel(fl, fromp, bitp) { init(fromp); } - ASTNODE_NODE_FUNCS(WildcardSel) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_WildcardSel; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstWildcardSel{this->fileline(), lhsp, rhsp}; } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%k(%l%f[%r])"; } - virtual string emitC() override { return "%li%k[%ri]"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool isGateOptimizable() const override { - return true; - } // esp for V3Const::ifSameAssign - virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + string emitVerilog() override { return "%k(%l%f[%r])"; } + string emitC() override { return "%li%k[%ri]"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool isGateOptimizable() const override { return true; } // esp for V3Const::ifSameAssign + bool isPredictOptimizable() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return widthInstrs(); } }; class AstWordSel final : public AstNodeSel { // Select a single word from a multi-word wide value @@ -3127,23 +3113,23 @@ public: : ASTGEN_SUPER_WordSel(fl, fromp, bitp) { dtypeSetUInt32(); // Always used on WData arrays so returns edata size } - ASTNODE_NODE_FUNCS(WordSel) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_WordSel; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstWordSel(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& from, const V3Number& bit) override { + void numberOperate(V3Number& out, const V3Number& from, const V3Number& bit) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%k(%l%f[%r])"; } - virtual string emitC() override { + string emitVerilog() override { return "%k(%l%f[%r])"; } + string emitC() override { return "%li[%ri]"; } // Not %k, as usually it's a small constant rhsp - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } }; // === AstNodeStream === @@ -3152,42 +3138,42 @@ class AstStreamL final : public AstNodeStream { public: AstStreamL(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_StreamL(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(StreamL) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_StreamL; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstStreamL(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f{ << %r %k{%l} }"; } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + string emitVerilog() override { return "%f{ << %r %k{%l} }"; } + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opStreamL(lhs, rhs); } - virtual string emitC() override { return "VL_STREAML_%nq%lq%rq(%lw, %P, %li, %ri)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 2; } + string emitC() override { return "VL_STREAML_%nq%lq%rq(%lw, %P, %li, %ri)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 2; } }; class AstStreamR final : public AstNodeStream { // Verilog {rhs{lhs}} - Note rhsp() is the slice size, not the lhsp() public: AstStreamR(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_StreamR(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(StreamR) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_StreamR; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstStreamR(this->fileline(), lhsp, rhsp); } - virtual string emitVerilog() override { return "%f{ >> %r %k{%l} }"; } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + string emitVerilog() override { return "%f{ >> %r %k{%l} }"; } + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opAssign(lhs); } - virtual string emitC() override { return isWide() ? "VL_ASSIGN_W(%nw, %P, %li)" : "%li"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 2; } + string emitC() override { return isWide() ? "VL_ASSIGN_W(%nw, %P, %li)" : "%li"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 2; } }; // === AstNodeSystemBiop === @@ -3195,29 +3181,29 @@ class AstAtan2D final : public AstNodeSystemBiop { public: AstAtan2D(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_Atan2D(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(Atan2D) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Atan2D; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAtan2D(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.setDouble(std::atan2(lhs.toDouble(), rhs.toDouble())); } - virtual string emitVerilog() override { return "%f$atan2(%l,%r)"; } - virtual string emitC() override { return "atan2(%li,%ri)"; } + string emitVerilog() override { return "%f$atan2(%l,%r)"; } + string emitC() override { return "atan2(%li,%ri)"; } }; class AstHypotD final : public AstNodeSystemBiop { public: AstHypotD(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_HypotD(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(HypotD) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_HypotD; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstHypotD(this->fileline(), lhsp, rhsp); } - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.setDouble(std::hypot(lhs.toDouble(), rhs.toDouble())); } - virtual string emitVerilog() override { return "%f$hypot(%l,%r)"; } - virtual string emitC() override { return "hypot(%li,%ri)"; } + string emitVerilog() override { return "%f$hypot(%l,%r)"; } + string emitC() override { return "hypot(%li,%ri)"; } }; // === AstNodeQuadop === @@ -3231,23 +3217,23 @@ public: : ASTGEN_SUPER_CountBits(fl, exprp, ctrl1p, ctrl2p, ctrl2p->cloneTree(false)) {} AstCountBits(FileLine* fl, AstNode* exprp, AstNode* ctrl1p, AstNode* ctrl2p, AstNode* ctrl3p) : ASTGEN_SUPER_CountBits(fl, exprp, ctrl1p, ctrl2p, ctrl3p) {} - ASTNODE_NODE_FUNCS(CountBits) - virtual void numberOperate(V3Number& out, const V3Number& expr, const V3Number& ctrl1, - const V3Number& ctrl2, const V3Number& ctrl3) override { + ASTGEN_MEMBERS_CountBits; + void numberOperate(V3Number& out, const V3Number& expr, const V3Number& ctrl1, + const V3Number& ctrl2, const V3Number& ctrl3) override { out.opCountBits(expr, ctrl1, ctrl2, ctrl3); } - virtual string emitVerilog() override { return "%f$countbits(%l, %r, %f, %o)"; } - virtual string emitC() override { return ""; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool cleanThs() const override { return true; } - virtual bool cleanFhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } - virtual bool sizeMattersFhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 16; } + string emitVerilog() override { return "%f$countbits(%l, %r, %f, %o)"; } + string emitC() override { return ""; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool cleanThs() const override { return true; } + bool cleanFhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } + bool sizeMattersFhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 16; } }; // === AstNodeTermop === @@ -3259,15 +3245,15 @@ public: , m_timeunit{timeunit} { dtypeSetUInt64(); } - ASTNODE_NODE_FUNCS(Time) - virtual string emitVerilog() override { return "%f$time"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_TIME; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_Time; + string emitVerilog() override { return "%f$time"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_TIME; } + bool same(const AstNode* /*samep*/) const override { return true; } + void dump(std::ostream& str = std::cout) const override; void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } }; @@ -3279,15 +3265,15 @@ public: , m_timeunit{timeunit} { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(TimeD) - virtual string emitVerilog() override { return "%f$realtime"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_TIME; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_TimeD; + string emitVerilog() override { return "%f$realtime"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_TIME; } + bool same(const AstNode* /*samep*/) const override { return true; } + void dump(std::ostream& str = std::cout) const override; void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } }; @@ -3302,21 +3288,21 @@ class AstPostAdd final : public AstNodeTriop { public: AstPostAdd(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp) : ASTGEN_SUPER_PostAdd(fl, lhsp, rhsp, thsp) {} - ASTNODE_NODE_FUNCS(PostAdd) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_PostAdd; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { V3ERROR_NA; // Need to modify lhs } - virtual string emitVerilog() override { return "%k(%r++)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool cleanThs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual bool sizeMattersThs() const override { return true; } + string emitVerilog() override { return "%k(%r++)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool cleanThs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + bool sizeMattersThs() const override { return true; } }; class AstPostSub final : public AstNodeTriop { // Post-decrement/subtract @@ -3327,21 +3313,21 @@ class AstPostSub final : public AstNodeTriop { public: AstPostSub(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp) : ASTGEN_SUPER_PostSub(fl, lhsp, rhsp, thsp) {} - ASTNODE_NODE_FUNCS(PostSub) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_PostSub; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { V3ERROR_NA; // Need to modify lhs } - virtual string emitVerilog() override { return "%k(%r--)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool cleanThs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual bool sizeMattersThs() const override { return true; } + string emitVerilog() override { return "%k(%r--)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool cleanThs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + bool sizeMattersThs() const override { return true; } }; class AstPreAdd final : public AstNodeTriop { // Pre-increment/add @@ -3352,21 +3338,21 @@ class AstPreAdd final : public AstNodeTriop { public: AstPreAdd(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp) : ASTGEN_SUPER_PreAdd(fl, lhsp, rhsp, thsp) {} - ASTNODE_NODE_FUNCS(PreAdd) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_PreAdd; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { V3ERROR_NA; // Need to modify lhs } - virtual string emitVerilog() override { return "%k(++%r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool cleanThs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual bool sizeMattersThs() const override { return true; } + string emitVerilog() override { return "%k(++%r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool cleanThs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + bool sizeMattersThs() const override { return true; } }; class AstPreSub final : public AstNodeTriop { // Pre-decrement/subtract @@ -3377,21 +3363,21 @@ class AstPreSub final : public AstNodeTriop { public: AstPreSub(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* thsp) : ASTGEN_SUPER_PreSub(fl, lhsp, rhsp, thsp) {} - ASTNODE_NODE_FUNCS(PreSub) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_PreSub; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { V3ERROR_NA; // Need to modify lhs } - virtual string emitVerilog() override { return "%k(--%r)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return false; } - virtual bool cleanThs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } - virtual bool sizeMattersRhs() const override { return true; } - virtual bool sizeMattersThs() const override { return true; } + string emitVerilog() override { return "%k(--%r)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return false; } + bool cleanThs() const override { return false; } + bool sizeMattersLhs() const override { return true; } + bool sizeMattersRhs() const override { return true; } + bool sizeMattersThs() const override { return true; } }; class AstPutcN final : public AstNodeTriop { // Verilog string.putc() @@ -3400,22 +3386,22 @@ public: : ASTGEN_SUPER_PutcN(fl, lhsp, rhsp, ths) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(PutcN) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_PutcN; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { out.opPutcN(lhs, rhs, ths); } - virtual string name() const override { return "putc"; } - virtual string emitVerilog() override { return "%k(%l.putc(%r,%t))"; } - virtual string emitC() override { return "VL_PUTC_N(%li,%ri,%ti)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool cleanThs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } + string name() const override { return "putc"; } + string emitVerilog() override { return "%k(%l.putc(%r,%t))"; } + string emitC() override { return "VL_PUTC_N(%li,%ri,%ti)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool cleanThs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } }; class AstSel final : public AstNodeTriop { // Multiple bit range extraction @@ -3439,29 +3425,27 @@ public: , m_declElWidth{1} { dtypeSetLogicSized(bitwidth, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(Sel) - virtual void dump(std::ostream& str) const override; - virtual void numberOperate(V3Number& out, const V3Number& from, const V3Number& bit, - const V3Number& width) override { + ASTGEN_MEMBERS_Sel; + void dump(std::ostream& str) const override; + void numberOperate(V3Number& out, const V3Number& from, const V3Number& bit, + const V3Number& width) override { out.opSel(from, bit.toUInt() + width.toUInt() - 1, bit.toUInt()); } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { return widthp()->isOne() ? "VL_BITSEL_%nq%lq%rq%tq(%lw, %P, %li, %ri)" : isWide() ? "VL_SEL_%nq%lq%rq%tq(%nw,%lw, %P, %li, %ri, %ti)" : "VL_SEL_%nq%lq%rq%tq(%lw, %P, %li, %ri, %ti)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool cleanThs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } - virtual bool same(const AstNode*) const override { return true; } - virtual int instrCount() const override { - return widthInstrs() * (VN_CAST(lsbp(), Const) ? 3 : 10); - } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool cleanThs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } + bool same(const AstNode*) const override { return true; } + int instrCount() const override { return widthInstrs() * (VN_CAST(lsbp(), Const) ? 3 : 10); } AstNode* fromp() const { return op1p(); } // op1 = Extracting what (nullptr=TBD during parsing) @@ -3488,23 +3472,23 @@ public: : ASTGEN_SUPER_SliceSel(fl, fromp, new AstConst(fl, declRange.lo()), new AstConst(fl, declRange.elements())) , m_declRange{declRange} {} - ASTNODE_NODE_FUNCS(SliceSel) - virtual void dump(std::ostream& str) const override; - virtual void numberOperate(V3Number& out, const V3Number& from, const V3Number& lo, - const V3Number& width) override { + ASTGEN_MEMBERS_SliceSel; + void dump(std::ostream& str) const override; + void numberOperate(V3Number& out, const V3Number& from, const V3Number& lo, + const V3Number& width) override { V3ERROR_NA; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } // Removed before EmitC - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool cleanRhs() const override { return true; } - virtual bool cleanThs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } - virtual bool same(const AstNode*) const override { return true; } - virtual int instrCount() const override { return 10; } // Removed before matters + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } // Removed before EmitC + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool cleanRhs() const override { return true; } + bool cleanThs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } + bool same(const AstNode*) const override { return true; } + int instrCount() const override { return 10; } // Removed before matters AstNode* fromp() const { return op1p(); } // op1 = Extracting what (nullptr=TBD during parsing) @@ -3520,22 +3504,22 @@ public: : ASTGEN_SUPER_SubstrN(fl, lhsp, rhsp, ths) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(SubstrN) - virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, - const V3Number& ths) override { + ASTGEN_MEMBERS_SubstrN; + void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, + const V3Number& ths) override { out.opSubstrN(lhs, rhs, ths); } - virtual string name() const override { return "substr"; } - virtual string emitVerilog() override { return "%k(%l.substr(%r,%t))"; } - virtual string emitC() override { return "VL_SUBSTR_N(%li,%ri,%ti)"; } - virtual string emitSimpleOperator() override { return ""; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool cleanRhs() const override { return true; } - virtual bool cleanThs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool sizeMattersRhs() const override { return false; } - virtual bool sizeMattersThs() const override { return false; } + string name() const override { return "substr"; } + string emitVerilog() override { return "%k(%l.substr(%r,%t))"; } + string emitC() override { return "VL_SUBSTR_N(%li,%ri,%ti)"; } + string emitSimpleOperator() override { return ""; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool cleanRhs() const override { return true; } + bool cleanThs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool sizeMattersRhs() const override { return false; } + bool sizeMattersThs() const override { return false; } }; // === AstNodeCond === @@ -3546,8 +3530,8 @@ class AstCond final : public AstNodeCond { public: AstCond(FileLine* fl, AstNode* condp, AstNode* expr1p, AstNode* expr2p) : ASTGEN_SUPER_Cond(fl, condp, expr1p, expr2p) {} - ASTNODE_NODE_FUNCS(Cond) - virtual AstNode* cloneType(AstNode* condp, AstNode* expr1p, AstNode* expr2p) override { + ASTGEN_MEMBERS_Cond; + AstNode* cloneType(AstNode* condp, AstNode* expr1p, AstNode* expr2p) override { return new AstCond(this->fileline(), condp, expr1p, expr2p); } }; @@ -3558,8 +3542,8 @@ class AstCondBound final : public AstNodeCond { public: AstCondBound(FileLine* fl, AstNode* condp, AstNode* expr1p, AstNode* expr2p) : ASTGEN_SUPER_CondBound(fl, condp, expr1p, expr2p) {} - ASTNODE_NODE_FUNCS(CondBound) - virtual AstNode* cloneType(AstNode* condp, AstNode* expr1p, AstNode* expr2p) override { + ASTGEN_MEMBERS_CondBound; + AstNode* cloneType(AstNode* condp, AstNode* expr1p, AstNode* expr2p) override { return new AstCondBound(this->fileline(), condp, expr1p, expr2p); } }; @@ -3578,11 +3562,9 @@ public: , m_fmt{fmt} { fmt == ATOREAL ? dtypeSetDouble() : dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(AtoN) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opAtoN(lhs, m_fmt); - } - virtual string name() const override { + ASTGEN_MEMBERS_AtoN; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAtoN(lhs, m_fmt); } + string name() const override { switch (m_fmt) { case ATOI: return "atoi"; case ATOHEX: return "atohex"; @@ -3592,8 +3574,8 @@ public: default: V3ERROR_NA; } } - virtual string emitVerilog() override { return "%l." + name() + "()"; } - virtual string emitC() override { + string emitVerilog() override { return "%l." + name() + "()"; } + string emitC() override { switch (m_fmt) { case ATOI: return "VL_ATOI_N(%li, 10)"; case ATOHEX: return "VL_ATOI_N(%li, 16)"; @@ -3603,9 +3585,9 @@ public: default: V3ERROR_NA; } } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } FmtType format() const { return m_fmt; } }; class AstBitsToRealD final : public AstNodeUniop { @@ -3614,16 +3596,14 @@ public: : ASTGEN_SUPER_BitsToRealD(fl, lhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(BitsToRealD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opBitsToRealD(lhs); - } - virtual string emitVerilog() override { return "%f$bitstoreal(%l)"; } - virtual string emitC() override { return "VL_CVT_D_Q(%li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } // Eliminated before matters - virtual bool sizeMattersLhs() const override { return false; } // Eliminated before matters - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + ASTGEN_MEMBERS_BitsToRealD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opBitsToRealD(lhs); } + string emitVerilog() override { return "%f$bitstoreal(%l)"; } + string emitC() override { return "VL_CVT_D_Q(%li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } // Eliminated before matters + bool sizeMattersLhs() const override { return false; } // Eliminated before matters + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstCCast final : public AstNodeUniop { // Cast to C-based data type @@ -3644,17 +3624,17 @@ public: dtypeFrom(typeFromp); m_size = width(); } - ASTNODE_NODE_FUNCS(CCast) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); } - virtual string emitVerilog() override { return "%f$_CAST(%l)"; } - virtual string emitC() override { return "VL_CAST_%nq%lq(%nw,%lw, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } // Special cased in V3Cast - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_CCast; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); } + string emitVerilog() override { return "%f$_CAST(%l)"; } + string emitC() override { return "VL_CAST_%nq%lq(%nw,%lw, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } // Special cased in V3Cast + bool same(const AstNode* samep) const override { return size() == static_cast(samep)->size(); } - virtual void dump(std::ostream& str = std::cout) const override; + void dump(std::ostream& str = std::cout) const override; // int size() const { return m_size; } }; @@ -3664,30 +3644,28 @@ public: : ASTGEN_SUPER_CLog2(fl, lhsp) { dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(CLog2) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opCLog2(lhs); } - virtual string emitVerilog() override { return "%f$clog2(%l)"; } - virtual string emitC() override { return "VL_CLOG2_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 16; } + ASTGEN_MEMBERS_CLog2; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opCLog2(lhs); } + string emitVerilog() override { return "%f$clog2(%l)"; } + string emitC() override { return "VL_CLOG2_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 16; } }; class AstCountOnes final : public AstNodeUniop { // Number of bits set in vector public: AstCountOnes(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_CountOnes(fl, lhsp) {} - ASTNODE_NODE_FUNCS(CountOnes) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opCountOnes(lhs); - } - virtual string emitVerilog() override { return "%f$countones(%l)"; } - virtual string emitC() override { return "VL_COUNTONES_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 16; } + ASTGEN_MEMBERS_CountOnes; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opCountOnes(lhs); } + string emitVerilog() override { return "%f$countones(%l)"; } + string emitC() override { return "VL_COUNTONES_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 16; } }; class AstCvtPackString final : public AstNodeUniop { // Convert to Verilator Packed String (aka verilog "string") @@ -3696,14 +3674,14 @@ public: : ASTGEN_SUPER_CvtPackString(fl, lhsp) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(CvtPackString) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%f$_CAST(%l)"; } - virtual string emitC() override { return "VL_CVT_PACK_STR_N%lq(%lW, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_CvtPackString; + void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } + string emitVerilog() override { return "%f$_CAST(%l)"; } + string emitC() override { return "VL_CVT_PACK_STR_N%lq(%lW, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstExtend final : public AstNodeUniop { // Expand a value into a wider entity by 0 extension. Width is implied from nodep->width() @@ -3714,16 +3692,16 @@ public: : ASTGEN_SUPER_Extend(fl, lhsp) { dtypeSetLogicSized(width, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(Extend) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); } - virtual string emitVerilog() override { return "%l"; } - virtual string emitC() override { return "VL_EXTEND_%nq%lq(%nw,%lw, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { + ASTGEN_MEMBERS_Extend; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); } + string emitVerilog() override { return "%l"; } + string emitC() override { return "VL_EXTEND_%nq%lq(%nw,%lw, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; // Because the EXTEND operator self-casts } - virtual int instrCount() const override { return 0; } + int instrCount() const override { return 0; } }; class AstExtendS final : public AstNodeUniop { // Expand a value into a wider entity by sign extension. Width is implied from nodep->width() @@ -3735,53 +3713,49 @@ public: : ASTGEN_SUPER_ExtendS(fl, lhsp) { dtypeSetLogicSized(width, VSigning::UNSIGNED); } - ASTNODE_NODE_FUNCS(ExtendS) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_ExtendS; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opExtendS(lhs, lhsp()->widthMinV()); } - virtual string emitVerilog() override { return "%l"; } - virtual string emitC() override { return "VL_EXTENDS_%nq%lq(%nw,%lw, %P, %li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { + string emitVerilog() override { return "%l"; } + string emitC() override { return "VL_EXTENDS_%nq%lq(%nw,%lw, %P, %li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; // Because the EXTEND operator self-casts } - virtual int instrCount() const override { return 0; } - virtual bool signedFlavor() const override { return true; } + int instrCount() const override { return 0; } + bool signedFlavor() const override { return true; } }; class AstFEof final : public AstNodeUniop { public: AstFEof(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_FEof(fl, lhsp) {} - ASTNODE_NODE_FUNCS(FEof) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%f$feof(%l)"; } - virtual string emitC() override { return "(%li ? feof(VL_CVT_I_FP(%li)) : true)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 16; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering + ASTGEN_MEMBERS_FEof; + void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } + string emitVerilog() override { return "%f$feof(%l)"; } + string emitC() override { return "(%li ? feof(VL_CVT_I_FP(%li)) : true)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 16; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering AstNode* filep() const { return lhsp(); } }; class AstFGetC final : public AstNodeUniop { public: AstFGetC(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_FGetC(fl, lhsp) {} - ASTNODE_NODE_FUNCS(FGetC) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%f$fgetc(%l)"; } + ASTGEN_MEMBERS_FGetC; + void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } + string emitVerilog() override { return "%f$fgetc(%l)"; } // Non-existent filehandle returns EOF - virtual string emitC() override { return "(%li ? fgetc(VL_CVT_I_FP(%li)) : -1)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 64; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering + string emitC() override { return "(%li ? fgetc(VL_CVT_I_FP(%li)) : -1)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 64; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering AstNode* filep() const { return lhsp(); } }; class AstISToRD final : public AstNodeUniop { @@ -3791,15 +3765,15 @@ public: : ASTGEN_SUPER_ISToRD(fl, lhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(ISToRD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opISToRD(lhs); } - virtual string emitVerilog() override { return "%f$itor($signed(%l))"; } - virtual string emitC() override { return "VL_ISTOR_D_%lq(%lw, %li)"; } - virtual bool emitCheckMaxWords() override { return true; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + ASTGEN_MEMBERS_ISToRD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opISToRD(lhs); } + string emitVerilog() override { return "%f$itor($signed(%l))"; } + string emitC() override { return "VL_ISTOR_D_%lq(%lw, %li)"; } + bool emitCheckMaxWords() override { return true; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstIToRD final : public AstNodeUniop { // $itor where lhs is unsigned @@ -3808,14 +3782,14 @@ public: : ASTGEN_SUPER_IToRD(fl, lhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(IToRD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opIToRD(lhs); } - virtual string emitVerilog() override { return "%f$itor(%l)"; } - virtual string emitC() override { return "VL_ITOR_D_%lq(%lw, %li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + ASTGEN_MEMBERS_IToRD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opIToRD(lhs); } + string emitVerilog() override { return "%f$itor(%l)"; } + string emitC() override { return "VL_ITOR_D_%lq(%lw, %li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstIsUnbounded final : public AstNodeUniop { // True if is unmbounded ($) @@ -3824,16 +3798,16 @@ public: : ASTGEN_SUPER_IsUnbounded(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(IsUnbounded) - virtual void numberOperate(V3Number& out, const V3Number&) override { + ASTGEN_MEMBERS_IsUnbounded; + void numberOperate(V3Number& out, const V3Number&) override { // Any constant isn't unbounded out.setZero(); } - virtual string emitVerilog() override { return "%f$isunbounded(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } + string emitVerilog() override { return "%f$isunbounded(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } }; class AstIsUnknown final : public AstNodeUniop { // True if any unknown bits @@ -3842,15 +3816,13 @@ public: : ASTGEN_SUPER_IsUnknown(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(IsUnknown) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opIsUnknown(lhs); - } - virtual string emitVerilog() override { return "%f$isunknown(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_IsUnknown; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opIsUnknown(lhs); } + string emitVerilog() override { return "%f$isunknown(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } }; class AstLenN final : public AstNodeUniop { // Length of a string @@ -3859,13 +3831,13 @@ public: : ASTGEN_SUPER_LenN(fl, lhsp) { dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(LenN) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opLenN(lhs); } - virtual string emitVerilog() override { return "%f(%l)"; } - virtual string emitC() override { return "VL_LEN_IN(%li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_LenN; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opLenN(lhs); } + string emitVerilog() override { return "%f(%l)"; } + string emitC() override { return "VL_LEN_IN(%li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstLogNot final : public AstNodeUniop { public: @@ -3873,14 +3845,14 @@ public: : ASTGEN_SUPER_LogNot(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(LogNot) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opLogNot(lhs); } - virtual string emitVerilog() override { return "%f(! %l)"; } - virtual string emitC() override { return "VL_LOGNOT_%nq%lq(%nw,%lw, %P, %li)"; } - virtual string emitSimpleOperator() override { return "!"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_LogNot; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opLogNot(lhs); } + string emitVerilog() override { return "%f(! %l)"; } + string emitC() override { return "VL_LOGNOT_%nq%lq(%nw,%lw, %P, %li)"; } + string emitSimpleOperator() override { return "!"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstNegate final : public AstNodeUniop { public: @@ -3888,14 +3860,14 @@ public: : ASTGEN_SUPER_Negate(fl, lhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Negate) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNegate(lhs); } - virtual string emitVerilog() override { return "%f(- %l)"; } - virtual string emitC() override { return "VL_NEGATE_%lq(%lW, %P, %li)"; } - virtual string emitSimpleOperator() override { return "-"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } + ASTGEN_MEMBERS_Negate; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNegate(lhs); } + string emitVerilog() override { return "%f(- %l)"; } + string emitC() override { return "VL_NEGATE_%lq(%lW, %P, %li)"; } + string emitSimpleOperator() override { return "-"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } }; class AstNegateD final : public AstNodeUniop { public: @@ -3903,16 +3875,16 @@ public: : ASTGEN_SUPER_NegateD(fl, lhsp) { dtypeSetDouble(); } - ASTNODE_NODE_FUNCS(NegateD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNegateD(lhs); } - virtual string emitVerilog() override { return "%f(- %l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { return "-"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } - virtual bool doubleFlavor() const override { return true; } + ASTGEN_MEMBERS_NegateD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNegateD(lhs); } + string emitVerilog() override { return "%f(- %l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { return "-"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } + bool doubleFlavor() const override { return true; } }; class AstNot final : public AstNodeUniop { public: @@ -3920,14 +3892,14 @@ public: : ASTGEN_SUPER_Not(fl, lhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Not) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNot(lhs); } - virtual string emitVerilog() override { return "%f(~ %l)"; } - virtual string emitC() override { return "VL_NOT_%lq(%lW, %P, %li)"; } - virtual string emitSimpleOperator() override { return "~"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return true; } + ASTGEN_MEMBERS_Not; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opNot(lhs); } + string emitVerilog() override { return "%f(~ %l)"; } + string emitC() override { return "VL_NOT_%lq(%lW, %P, %li)"; } + string emitSimpleOperator() override { return "~"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return true; } }; class AstNullCheck final : public AstNodeUniop { // Return LHS after checking that LHS is non-null @@ -3937,18 +3909,16 @@ public: : ASTGEN_SUPER_NullCheck(fl, lhsp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(NullCheck) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } - virtual int instrCount() const override { return 1; } // Rarely executes - virtual string emitVerilog() override { return "%l"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual bool same(const AstNode* samep) const override { - return fileline() == samep->fileline(); - } + ASTGEN_MEMBERS_NullCheck; + void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } + int instrCount() const override { return 1; } // Rarely executes + string emitVerilog() override { return "%l"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + string emitSimpleOperator() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + bool same(const AstNode* samep) const override { return fileline() == samep->fileline(); } }; class AstOneHot final : public AstNodeUniop { // True if only single bit set in vector @@ -3957,14 +3927,14 @@ public: : ASTGEN_SUPER_OneHot(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(OneHot) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot(lhs); } - virtual string emitVerilog() override { return "%f$onehot(%l)"; } - virtual string emitC() override { return "VL_ONEHOT_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 4; } + ASTGEN_MEMBERS_OneHot; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot(lhs); } + string emitVerilog() override { return "%f$onehot(%l)"; } + string emitC() override { return "VL_ONEHOT_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 4; } }; class AstOneHot0 final : public AstNodeUniop { // True if only single bit, or no bits set in vector @@ -3973,14 +3943,14 @@ public: : ASTGEN_SUPER_OneHot0(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(OneHot0) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot0(lhs); } - virtual string emitVerilog() override { return "%f$onehot0(%l)"; } - virtual string emitC() override { return "VL_ONEHOT0_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return widthInstrs() * 3; } + ASTGEN_MEMBERS_OneHot0; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opOneHot0(lhs); } + string emitVerilog() override { return "%f$onehot0(%l)"; } + string emitC() override { return "VL_ONEHOT0_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return widthInstrs() * 3; } }; class AstRToIRoundS final : public AstNodeUniop { // Convert real to integer, with arbitrary sized output (not just "integer" format) @@ -3989,18 +3959,16 @@ public: : ASTGEN_SUPER_RToIRoundS(fl, lhsp) { dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(RToIRoundS) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opRToIRoundS(lhs); - } - virtual string emitVerilog() override { return "%f$rtoi_rounded(%l)"; } - virtual string emitC() override { + ASTGEN_MEMBERS_RToIRoundS; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRToIRoundS(lhs); } + string emitVerilog() override { return "%f$rtoi_rounded(%l)"; } + string emitC() override { return isWide() ? "VL_RTOIROUND_%nq_D(%nw, %P, %li)" : "VL_RTOIROUND_%nq_D(%li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstRToIS final : public AstNodeUniop { // $rtoi(lhs) @@ -4009,14 +3977,14 @@ public: : ASTGEN_SUPER_RToIS(fl, lhsp) { dtypeSetSigned32(); } - ASTNODE_NODE_FUNCS(RToIS) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRToIS(lhs); } - virtual string emitVerilog() override { return "%f$rtoi(%l)"; } - virtual string emitC() override { return "VL_RTOI_I_D(%li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } // Eliminated before matters - virtual bool sizeMattersLhs() const override { return false; } // Eliminated before matters - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + ASTGEN_MEMBERS_RToIS; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRToIS(lhs); } + string emitVerilog() override { return "%f$rtoi(%l)"; } + string emitC() override { return "VL_RTOI_I_D(%li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } // Eliminated before matters + bool sizeMattersLhs() const override { return false; } // Eliminated before matters + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstRealToBits final : public AstNodeUniop { public: @@ -4024,16 +3992,14 @@ public: : ASTGEN_SUPER_RealToBits(fl, lhsp) { dtypeSetUInt64(); } - ASTNODE_NODE_FUNCS(RealToBits) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opRealToBits(lhs); - } - virtual string emitVerilog() override { return "%f$realtobits(%l)"; } - virtual string emitC() override { return "VL_CVT_Q_D(%li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } // Eliminated before matters - virtual bool sizeMattersLhs() const override { return false; } // Eliminated before matters - virtual int instrCount() const override { return INSTR_COUNT_DBL; } + ASTGEN_MEMBERS_RealToBits; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRealToBits(lhs); } + string emitVerilog() override { return "%f$realtobits(%l)"; } + string emitC() override { return "VL_CVT_Q_D(%li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } // Eliminated before matters + bool sizeMattersLhs() const override { return false; } // Eliminated before matters + int instrCount() const override { return INSTR_COUNT_DBL; } }; class AstRedAnd final : public AstNodeUniop { public: @@ -4041,13 +4007,13 @@ public: : ASTGEN_SUPER_RedAnd(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(RedAnd) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedAnd(lhs); } - virtual string emitVerilog() override { return "%f(& %l)"; } - virtual string emitC() override { return "VL_REDAND_%nq%lq(%lw, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_RedAnd; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedAnd(lhs); } + string emitVerilog() override { return "%f(& %l)"; } + string emitC() override { return "VL_REDAND_%nq%lq(%lw, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstRedOr final : public AstNodeUniop { public: @@ -4055,13 +4021,13 @@ public: : ASTGEN_SUPER_RedOr(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(RedOr) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedOr(lhs); } - virtual string emitVerilog() override { return "%f(| %l)"; } - virtual string emitC() override { return "VL_REDOR_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_RedOr; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedOr(lhs); } + string emitVerilog() override { return "%f(| %l)"; } + string emitC() override { return "VL_REDOR_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstRedXor final : public AstNodeUniop { public: @@ -4069,17 +4035,17 @@ public: : ASTGEN_SUPER_RedXor(fl, lhsp) { dtypeSetBit(); } - ASTNODE_NODE_FUNCS(RedXor) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedXor(lhs); } - virtual string emitVerilog() override { return "%f(^ %l)"; } - virtual string emitC() override { return "VL_REDXOR_%lq(%lW, %P, %li)"; } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { + ASTGEN_MEMBERS_RedXor; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedXor(lhs); } + string emitVerilog() override { return "%f(^ %l)"; } + string emitC() override { return "VL_REDXOR_%lq(%lW, %P, %li)"; } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { const int w = lhsp()->width(); return (w != 1 && w != 2 && w != 4 && w != 8 && w != 16); } - virtual bool sizeMattersLhs() const override { return false; } - virtual int instrCount() const override { return 1 + V3Number::log2b(width()); } + bool sizeMattersLhs() const override { return false; } + int instrCount() const override { return 1 + V3Number::log2b(width()); } }; class AstSigned final : public AstNodeUniop { // $signed(lhs) @@ -4089,17 +4055,17 @@ public: UASSERT_OBJ(!v3Global.assertDTypesResolved(), this, "not coded to create after dtypes resolved"); } - ASTNODE_NODE_FUNCS(Signed) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_Signed; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); out.isSigned(false); } - virtual string emitVerilog() override { return "%f$signed(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } // Eliminated before matters - virtual bool sizeMattersLhs() const override { return true; } // Eliminated before matters - virtual int instrCount() const override { return 0; } + string emitVerilog() override { return "%f$signed(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } // Eliminated before matters + bool sizeMattersLhs() const override { return true; } // Eliminated before matters + int instrCount() const override { return 0; } }; class AstTimeImport final : public AstNodeUniop { // Take a constant that represents a time and needs conversion based on time units @@ -4107,14 +4073,14 @@ class AstTimeImport final : public AstNodeUniop { public: AstTimeImport(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_TimeImport(fl, lhsp) {} - ASTNODE_NODE_FUNCS(TimeImport) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } - virtual string emitVerilog() override { return "%l"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } - virtual bool sizeMattersLhs() const override { return false; } - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_TimeImport; + void numberOperate(V3Number& out, const V3Number& lhs) override { V3ERROR_NA; } + string emitVerilog() override { return "%l"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } + bool sizeMattersLhs() const override { return false; } + void dump(std::ostream& str = std::cout) const override; void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } }; @@ -4125,15 +4091,13 @@ public: : ASTGEN_SUPER_ToLowerN(fl, lhsp) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(ToLowerN) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opToLowerN(lhs); - } - virtual string emitVerilog() override { return "%l.tolower()"; } - virtual string emitC() override { return "VL_TOLOWER_NN(%li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_ToLowerN; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opToLowerN(lhs); } + string emitVerilog() override { return "%l.tolower()"; } + string emitC() override { return "VL_TOLOWER_NN(%li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstToUpperN final : public AstNodeUniop { // string.toupper() @@ -4142,15 +4106,13 @@ public: : ASTGEN_SUPER_ToUpperN(fl, lhsp) { dtypeSetString(); } - ASTNODE_NODE_FUNCS(ToUpperN) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { - out.opToUpperN(lhs); - } - virtual string emitVerilog() override { return "%l.toupper()"; } - virtual string emitC() override { return "VL_TOUPPER_NN(%li)"; } - virtual bool cleanOut() const override { return true; } - virtual bool cleanLhs() const override { return true; } - virtual bool sizeMattersLhs() const override { return false; } + ASTGEN_MEMBERS_ToUpperN; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opToUpperN(lhs); } + string emitVerilog() override { return "%l.toupper()"; } + string emitC() override { return "VL_TOUPPER_NN(%li)"; } + bool cleanOut() const override { return true; } + bool cleanLhs() const override { return true; } + bool sizeMattersLhs() const override { return false; } }; class AstUnsigned final : public AstNodeUniop { // $unsigned(lhs) @@ -4160,17 +4122,17 @@ public: UASSERT_OBJ(!v3Global.assertDTypesResolved(), this, "not coded to create after dtypes resolved"); } - ASTNODE_NODE_FUNCS(Unsigned) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_Unsigned; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.opAssign(lhs); out.isSigned(false); } - virtual string emitVerilog() override { return "%f$unsigned(%l)"; } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return false; } - virtual bool cleanLhs() const override { return false; } // Eliminated before matters - virtual bool sizeMattersLhs() const override { return true; } // Eliminated before matters - virtual int instrCount() const override { return 0; } + string emitVerilog() override { return "%f$unsigned(%l)"; } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return false; } + bool cleanLhs() const override { return false; } // Eliminated before matters + bool sizeMattersLhs() const override { return true; } // Eliminated before matters + int instrCount() const override { return 0; } }; // === AstNodeSystemUniop === @@ -4178,199 +4140,199 @@ class AstAcosD final : public AstNodeSystemUniop { public: AstAcosD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AcosD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AcosD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AcosD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::acos(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$acos(%l)"; } - virtual string emitC() override { return "acos(%li)"; } + string emitVerilog() override { return "%f$acos(%l)"; } + string emitC() override { return "acos(%li)"; } }; class AstAcoshD final : public AstNodeSystemUniop { public: AstAcoshD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AcoshD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AcoshD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AcoshD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::acosh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$acosh(%l)"; } - virtual string emitC() override { return "acosh(%li)"; } + string emitVerilog() override { return "%f$acosh(%l)"; } + string emitC() override { return "acosh(%li)"; } }; class AstAsinD final : public AstNodeSystemUniop { public: AstAsinD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AsinD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AsinD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AsinD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::asin(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$asin(%l)"; } - virtual string emitC() override { return "asin(%li)"; } + string emitVerilog() override { return "%f$asin(%l)"; } + string emitC() override { return "asin(%li)"; } }; class AstAsinhD final : public AstNodeSystemUniop { public: AstAsinhD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AsinhD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AsinhD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AsinhD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::asinh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$asinh(%l)"; } - virtual string emitC() override { return "asinh(%li)"; } + string emitVerilog() override { return "%f$asinh(%l)"; } + string emitC() override { return "asinh(%li)"; } }; class AstAtanD final : public AstNodeSystemUniop { public: AstAtanD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AtanD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AtanD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AtanD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::atan(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$atan(%l)"; } - virtual string emitC() override { return "atan(%li)"; } + string emitVerilog() override { return "%f$atan(%l)"; } + string emitC() override { return "atan(%li)"; } }; class AstAtanhD final : public AstNodeSystemUniop { public: AstAtanhD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_AtanhD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(AtanhD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_AtanhD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::atanh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$atanh(%l)"; } - virtual string emitC() override { return "atanh(%li)"; } + string emitVerilog() override { return "%f$atanh(%l)"; } + string emitC() override { return "atanh(%li)"; } }; class AstCeilD final : public AstNodeSystemUniop { public: AstCeilD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_CeilD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(CeilD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_CeilD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::ceil(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$ceil(%l)"; } - virtual string emitC() override { return "ceil(%li)"; } + string emitVerilog() override { return "%f$ceil(%l)"; } + string emitC() override { return "ceil(%li)"; } }; class AstCosD final : public AstNodeSystemUniop { public: AstCosD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_CosD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(CosD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_CosD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::cos(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$cos(%l)"; } - virtual string emitC() override { return "cos(%li)"; } + string emitVerilog() override { return "%f$cos(%l)"; } + string emitC() override { return "cos(%li)"; } }; class AstCoshD final : public AstNodeSystemUniop { public: AstCoshD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_CoshD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(CoshD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_CoshD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::cosh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$cosh(%l)"; } - virtual string emitC() override { return "cosh(%li)"; } + string emitVerilog() override { return "%f$cosh(%l)"; } + string emitC() override { return "cosh(%li)"; } }; class AstExpD final : public AstNodeSystemUniop { public: AstExpD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_ExpD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(ExpD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_ExpD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::exp(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$exp(%l)"; } - virtual string emitC() override { return "exp(%li)"; } + string emitVerilog() override { return "%f$exp(%l)"; } + string emitC() override { return "exp(%li)"; } }; class AstFloorD final : public AstNodeSystemUniop { public: AstFloorD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_FloorD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(FloorD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_FloorD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::floor(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$floor(%l)"; } - virtual string emitC() override { return "floor(%li)"; } + string emitVerilog() override { return "%f$floor(%l)"; } + string emitC() override { return "floor(%li)"; } }; class AstLog10D final : public AstNodeSystemUniop { public: AstLog10D(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_Log10D(fl, lhsp) {} - ASTNODE_NODE_FUNCS(Log10D) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_Log10D; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::log10(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$log10(%l)"; } - virtual string emitC() override { return "log10(%li)"; } + string emitVerilog() override { return "%f$log10(%l)"; } + string emitC() override { return "log10(%li)"; } }; class AstLogD final : public AstNodeSystemUniop { public: AstLogD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_LogD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(LogD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_LogD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::log(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$ln(%l)"; } - virtual string emitC() override { return "log(%li)"; } + string emitVerilog() override { return "%f$ln(%l)"; } + string emitC() override { return "log(%li)"; } }; class AstSinD final : public AstNodeSystemUniop { public: AstSinD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_SinD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(SinD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_SinD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::sin(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$sin(%l)"; } - virtual string emitC() override { return "sin(%li)"; } + string emitVerilog() override { return "%f$sin(%l)"; } + string emitC() override { return "sin(%li)"; } }; class AstSinhD final : public AstNodeSystemUniop { public: AstSinhD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_SinhD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(SinhD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_SinhD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::sinh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$sinh(%l)"; } - virtual string emitC() override { return "sinh(%li)"; } + string emitVerilog() override { return "%f$sinh(%l)"; } + string emitC() override { return "sinh(%li)"; } }; class AstSqrtD final : public AstNodeSystemUniop { public: AstSqrtD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_SqrtD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(SqrtD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_SqrtD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::sqrt(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$sqrt(%l)"; } - virtual string emitC() override { return "sqrt(%li)"; } + string emitVerilog() override { return "%f$sqrt(%l)"; } + string emitC() override { return "sqrt(%li)"; } }; class AstTanD final : public AstNodeSystemUniop { public: AstTanD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_TanD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(TanD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_TanD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::tan(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$tan(%l)"; } - virtual string emitC() override { return "tan(%li)"; } + string emitVerilog() override { return "%f$tan(%l)"; } + string emitC() override { return "tan(%li)"; } }; class AstTanhD final : public AstNodeSystemUniop { public: AstTanhD(FileLine* fl, AstNode* lhsp) : ASTGEN_SUPER_TanhD(fl, lhsp) {} - ASTNODE_NODE_FUNCS(TanhD) - virtual void numberOperate(V3Number& out, const V3Number& lhs) override { + ASTGEN_MEMBERS_TanhD; + void numberOperate(V3Number& out, const V3Number& lhs) override { out.setDouble(std::tanh(lhs.toDouble())); } - virtual string emitVerilog() override { return "%f$tanh(%l)"; } - virtual string emitC() override { return "tanh(%li)"; } + string emitVerilog() override { return "%f$tanh(%l)"; } + string emitC() override { return "tanh(%li)"; } }; // === AstNodeVarRef === @@ -4384,17 +4346,17 @@ public: inline AstVarRef(FileLine* fl, AstVar* varp, const VAccess& access); // This form only allowed post-link (see above) inline AstVarRef(FileLine* fl, AstVarScope* varscp, const VAccess& access); - ASTNODE_NODE_FUNCS(VarRef) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_VarRef; + void dump(std::ostream& str) const override; bool same(const AstNode* samep) const override; inline bool same(const AstVarRef* samep) const; inline bool sameNoLvalue(AstVarRef* samep) const; - virtual int instrCount() const override { + int instrCount() const override { return widthInstrs() * (access().isReadOrRW() ? INSTR_COUNT_LD : 1); } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } }; class AstVarXRef final : public AstNodeVarRef { // A VarRef to something in another module before AstScope. @@ -4407,17 +4369,17 @@ public: : ASTGEN_SUPER_VarXRef(fl, name, nullptr, access) , m_dotted{dotted} {} inline AstVarXRef(FileLine* fl, AstVar* varp, const string& dotted, const VAccess& access); - ASTNODE_NODE_FUNCS(VarXRef) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_VarXRef; + void dump(std::ostream& str) const override; string dotted() const { return m_dotted; } void dotted(const string& dotted) { m_dotted = dotted; } string inlinedDots() const { return m_inlinedDots; } void inlinedDots(const string& flag) { m_inlinedDots = flag; } - virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } - virtual string emitC() override { V3ERROR_NA_RETURN(""); } - virtual bool cleanOut() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode* samep) const override { + string emitVerilog() override { V3ERROR_NA_RETURN(""); } + string emitC() override { V3ERROR_NA_RETURN(""); } + bool cleanOut() const override { return true; } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode* samep) const override { const AstVarXRef* asamep = static_cast(samep); return (selfPointer() == asamep->selfPointer() && varp() == asamep->varp() && name() == asamep->name() && dotted() == asamep->dotted()); diff --git a/src/V3AstNodeOther.h b/src/V3AstNodeOther.h index 3ac5655a6..123ab7a4b 100644 --- a/src/V3AstNodeOther.h +++ b/src/V3AstNodeOther.h @@ -46,10 +46,10 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeBlock) - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } // * = Block name - virtual void name(const string& name) override { m_name = name; } + ASTGEN_MEMBERS_NodeBlock; + void dump(std::ostream& str) const override; + string name() const override { return m_name; } // * = Block name + void name(const string& name) override { m_name = name; } // op1 = Statements AstNode* stmtsp() const { return op1p(); } // op1 = List of statements void addStmtsp(AstNode* nodep) { addNOp1p(nodep); } @@ -111,15 +111,13 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeFTask) - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } // * = Var name - virtual bool maybePointedTo() const override { return true; } - virtual bool isGateOptimizable() const override { - return !((m_dpiExport || m_dpiImport) && !m_pure); - } + ASTGEN_MEMBERS_NodeFTask; + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } // * = Var name + bool maybePointedTo() const override { return true; } + bool isGateOptimizable() const override { return !((m_dpiExport || m_dpiImport) && !m_pure); } // {AstFunc only} op1 = Range output variable - virtual void name(const string& name) override { m_name = name; } + void name(const string& name) override { m_name = name; } string cname() const { return m_cname; } void cname(const string& cname) { m_cname = cname; } // op1 = Output variable (functions only, nullptr for tasks) @@ -191,13 +189,12 @@ private: string m_name; ///< Filename public: AstNodeFile(VNType t, FileLine* fl, const string& name) - : AstNode(t, fl) { - m_name = name; - } - ASTNODE_BASE_FUNCS(NodeFile) - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + : AstNode{t, fl} + , m_name{name} {} + ASTGEN_MEMBERS_NodeFile; + void dump(std::ostream& str) const override; + string name() const override { return m_name; } + bool same(const AstNode* /*samep*/) const override { return true; } void tblockp(AstTextBlock* tblockp) { setOp1p((AstNode*)tblockp); } AstTextBlock* tblockp() { return VN_AS(op1p(), TextBlock); } }; @@ -237,10 +234,10 @@ protected: , m_recursiveClone{false} {} public: - ASTNODE_BASE_FUNCS(NodeModule) - virtual void dump(std::ostream& str) const override; - virtual bool maybePointedTo() const override { return true; } - virtual string name() const override { return m_name; } + ASTGEN_MEMBERS_NodeModule; + void dump(std::ostream& str) const override; + bool maybePointedTo() const override { return true; } + string name() const override { return m_name; } virtual bool timescaleMatters() const = 0; AstNode* stmtsp() const { return op2p(); } // op2 = List of statements AstActive* activesp() const { return VN_AS(op3p(), Active); } // op3 = List of i/sblocks @@ -249,8 +246,8 @@ public: void addStmtp(AstNode* nodep) { addNOp2p(nodep); } void addActivep(AstNode* nodep) { addOp3p(nodep); } // ACCESSORS - virtual void name(const string& name) override { m_name = name; } - virtual string origName() const override { return m_origName; } + void name(const string& name) override { m_name = name; } + string origName() const override { return m_origName; } string someInstanceName() const { return m_someInstanceName; } void someInstanceName(const string& name) { m_someInstanceName = name; } bool inLibrary() const { return m_inLibrary; } @@ -290,7 +287,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodePreSel) + ASTGEN_MEMBERS_NodePreSel; AstNode* fromp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } AstNode* thsp() const { return op3p(); } @@ -300,7 +297,7 @@ public: void thsp(AstNode* nodep) { return setOp3p(nodep); } void attrp(AstAttrOf* nodep) { return setOp4p(reinterpret_cast(nodep)); } // METHODS - virtual bool same(const AstNode*) const override { return true; } + bool same(const AstNode*) const override { return true; } }; class AstNodeProcedure VL_NOT_FINAL : public AstNode { // IEEE procedure: initial, final, always @@ -313,9 +310,9 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeProcedure) + ASTGEN_MEMBERS_NodeProcedure; // METHODS - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; AstNode* bodysp() const { return op2p(); } // op2 = Statements to evaluate void addStmtp(AstNode* nodep) { addOp2p(nodep); } bool isJustOneBodyStmt() const { return bodysp() && !bodysp()->nextp(); } @@ -329,8 +326,8 @@ protected: : AstNode{t, fl} {} public: - ASTNODE_BASE_FUNCS(NodeRange) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_NodeRange; + void dump(std::ostream& str) const override; }; class AstNodeStmt VL_NOT_FINAL : public AstNode { // Statement -- anything that's directly under a function @@ -341,15 +338,15 @@ protected: , m_statement{statement} {} public: - ASTNODE_BASE_FUNCS(NodeStmt) + ASTGEN_MEMBERS_NodeStmt; // METHODS bool isStatement() const { return m_statement; } // Really a statement void statement(bool flag) { m_statement = flag; } - virtual void addNextStmt(AstNode* newp, - AstNode* belowp) override; // Stop statement searchback here - virtual void addBeforeStmt(AstNode* newp, - AstNode* belowp) override; // Stop statement searchback here - virtual void dump(std::ostream& str = std::cout) const override; + void addNextStmt(AstNode* newp, + AstNode* belowp) override; // Stop statement searchback here + void addBeforeStmt(AstNode* newp, + AstNode* belowp) override; // Stop statement searchback here + void dump(std::ostream& str = std::cout) const override; }; class AstNodeAssign VL_NOT_FINAL : public AstNodeStmt { protected: @@ -363,7 +360,7 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeAssign) + ASTGEN_MEMBERS_NodeAssign; // Clone single node, just get same type back. virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) = 0; // So iteration hits the RHS which is "earlier" in execution order, it's op1, not op2 @@ -374,12 +371,12 @@ public: void timingControlp(AstNode* const np) { setNOp3p(np); } void rhsp(AstNode* np) { setOp1p(np); } void lhsp(AstNode* np) { setOp2p(np); } - virtual bool hasDType() const override { return true; } + bool hasDType() const override { return true; } virtual bool cleanRhs() const { return true; } - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode*) const override { return true; } - virtual string verilogKwd() const override { return "="; } - virtual bool isTimingControl() const override { return timingControlp(); } + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode*) const override { return true; } + string verilogKwd() const override { return "="; } + bool isTimingControl() const override { return timingControlp(); } virtual bool brokeLhsMustBeLvalue() const = 0; }; class AstNodeCCall VL_NOT_FINAL : public AstNodeStmt { @@ -396,20 +393,20 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeCCall) - virtual void dump(std::ostream& str = std::cout) const override; - virtual void cloneRelink() override; - virtual const char* broken() const override; - virtual int instrCount() const override { return INSTR_COUNT_CALL; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_NodeCCall; + void dump(std::ostream& str = std::cout) const override; + void cloneRelink() override; + const char* broken() const override; + int instrCount() const override { return INSTR_COUNT_CALL; } + bool same(const AstNode* samep) const override { const AstNodeCCall* const asamep = static_cast(samep); return (funcp() == asamep->funcp() && argTypes() == asamep->argTypes()); } AstNode* exprsp() const { return op2p(); } // op2 = expressions to print - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override; - virtual bool isOutputter() const override { return !isPure(); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override; + bool isOutputter() const override { return !isPure(); } AstCFunc* funcp() const { return m_funcp; } void funcp(AstCFunc* funcp) { m_funcp = funcp; } void argTypes(const string& str) { m_argTypes = str; } @@ -427,8 +424,8 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeCase) - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } + ASTGEN_MEMBERS_NodeCase; + int instrCount() const override { return INSTR_COUNT_BRANCH; } AstNode* exprp() const { return op1p(); } // op1 = case condition AstCaseItem* itemsp() const { return VN_AS(op2p(), CaseItem); @@ -453,11 +450,11 @@ public: addOp1p(propp); addNOp4p(passsp); } - ASTNODE_BASE_FUNCS(NodeCoverOrAssert) - virtual string name() const override { return m_name; } // * = Var name - virtual bool same(const AstNode* samep) const override { return samep->name() == name(); } - virtual void name(const string& name) override { m_name = name; } - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_NodeCoverOrAssert; + string name() const override { return m_name; } // * = Var name + bool same(const AstNode* samep) const override { return samep->name() == name(); } + void name(const string& name) override { m_name = name; } + void dump(std::ostream& str = std::cout) const override; AstNode* propp() const { return op1p(); } // op1 = property AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p((AstNode*)sentreep); } // op2 = clock domain @@ -487,20 +484,18 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeFTaskRef) - virtual const char* broken() const override; - virtual void cloneRelink() override; - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } // * = Var name - virtual bool isGateOptimizable() const override { - return m_taskp && m_taskp->isGateOptimizable(); - } + ASTGEN_MEMBERS_NodeFTaskRef; + const char* broken() const override; + void cloneRelink() override; + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } // * = Var name + bool isGateOptimizable() const override { return m_taskp && m_taskp->isGateOptimizable(); } string dotted() const { return m_dotted; } // * = Scope name or "" string inlinedDots() const { return m_inlinedDots; } void inlinedDots(const string& flag) { m_inlinedDots = flag; } AstNodeFTask* taskp() const { return m_taskp; } // [After Link] Pointer to variable void taskp(AstNodeFTask* taskp) { m_taskp = taskp; } - virtual void name(const string& name) override { m_name = name; } + void name(const string& name) override { m_name = name; } void dotted(const string& name) { m_dotted = name; } AstNodeModule* classOrPackagep() const { return m_classOrPackagep; } void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } @@ -528,14 +523,14 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeFor) + ASTGEN_MEMBERS_NodeFor; AstNode* initsp() const { return op1p(); } // op1 = initial statements AstNode* condp() const { return op2p(); } // op2 = condition to continue AstNode* incsp() const { return op3p(); } // op3 = increment statements AstNode* bodysp() const { return op4p(); } // op4 = body of loop - virtual bool isGateOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstNodeIf VL_NOT_FINAL : public AstNodeStmt { private: @@ -551,17 +546,17 @@ protected: } public: - ASTNODE_BASE_FUNCS(NodeIf) + ASTGEN_MEMBERS_NodeIf; AstNode* condp() const { return op1p(); } // op1 = condition AstNode* ifsp() const { return op2p(); } // op2 = list of true statements AstNode* elsesp() const { return op3p(); } // op3 = list of false statements void condp(AstNode* newp) { setOp1p(newp); } void addIfsp(AstNode* newp) { addOp2p(newp); } void addElsesp(AstNode* newp) { addOp3p(newp); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isGateDedupable() const override { return true; } - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isGateDedupable() const override { return true; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* /*samep*/) const override { return true; } void branchPred(VBranchPred flag) { m_branchPred = flag; } VBranchPred branchPred() const { return m_branchPred; } void isBoundsCheck(bool flag) { m_isBoundsCheck = flag; } @@ -583,12 +578,13 @@ public: setNOp3p(lsbp); setNOp4p(msbp); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_NodeReadWriteMem; + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* samep) const override { return isHex() == static_cast(samep)->isHex(); } bool isHex() const { return m_isHex; } @@ -604,15 +600,14 @@ private: protected: // Node that puts text into the output stream - AstNodeText(VNType t, FileLine* fl, const string& textp) - : AstNode{t, fl} { - m_text = textp; // Copy it - } + AstNodeText(VNType t, FileLine* fl, const string& text) + : AstNode{t, fl} + , m_text{text} {} public: - ASTNODE_BASE_FUNCS(NodeText) - virtual void dump(std::ostream& str = std::cout) const override; - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_NodeText; + void dump(std::ostream& str = std::cout) const override; + bool same(const AstNode* samep) const override { const AstNodeText* asamep = static_cast(samep); return text() == asamep->text(); } @@ -626,7 +621,7 @@ public: AstNodeSimpleText(VNType t, FileLine* fl, const string& textp, bool tracking = false) : AstNodeText(t, fl, textp) , m_tracking(tracking) {} - ASTNODE_BASE_FUNCS(NodeSimpleText) + ASTGEN_MEMBERS_NodeSimpleText; void tracking(bool flag) { m_tracking = flag; } bool tracking() const { return m_tracking; } }; @@ -644,14 +639,14 @@ private: public: AstActive(FileLine* fl, const string& name, AstSenTree* sensesp) - : ASTGEN_SUPER_Active(fl) { - m_name = name; // Copy it + : ASTGEN_SUPER_Active(fl) + , m_name{name} + , m_sensesp{sensesp} { UASSERT(sensesp, "Sensesp required arg"); - m_sensesp = sensesp; } - ASTNODE_NODE_FUNCS(Active) - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } + ASTGEN_MEMBERS_Active; + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } const char* broken() const override; void cloneRelink() override; // Statements are broken into pieces, as some must come before others. @@ -677,9 +672,9 @@ public: , m_name{name} { setNOp1p(exprp); } - ASTNODE_NODE_FUNCS(Arg) - virtual string name() const override { return m_name; } // * = Pin name, ""=go by number - virtual void name(const string& name) override { m_name = name; } + ASTGEN_MEMBERS_Arg; + string name() const override { return m_name; } // * = Pin name, ""=go by number + void name(const string& name) override { m_name = name; } void exprp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expression connected to pin, nullptr if unconnected AstNode* exprp() const { return op1p(); } @@ -696,11 +691,11 @@ public: setNOp2p(dimp); m_attrType = attrtype; } - ASTNODE_NODE_FUNCS(AttrOf) + ASTGEN_MEMBERS_AttrOf; AstNode* fromp() const { return op1p(); } AstNode* dimp() const { return op2p(); } VAttrType attrType() const { return m_attrType; } - virtual void dump(std::ostream& str = std::cout) const override; + void dump(std::ostream& str = std::cout) const override; }; class AstBind final : public AstNode { // Parents: MODULE @@ -714,10 +709,10 @@ public: UASSERT_OBJ(VN_IS(cellsp, Cell), cellsp, "Only instances allowed to be bound"); addNOp1p(cellsp); } - ASTNODE_NODE_FUNCS(Bind) + ASTGEN_MEMBERS_Bind; // ACCESSORS - virtual string name() const override { return m_name; } // * = Bind Target name - virtual void name(const string& name) override { m_name = name; } + string name() const override { return m_name; } // * = Bind Target name + void name(const string& name) override { m_name = name; } AstNode* cellsp() const { return op1p(); } // op1 = cells }; class AstCFunc final : public AstNode { @@ -782,13 +777,13 @@ public: m_dpiImportWrapper = false; m_dpiTraceInit = false; } - ASTNODE_NODE_FUNCS(CFunc) - virtual string name() const override { return m_name; } + ASTGEN_MEMBERS_CFunc; + string name() const override { return m_name; } const char* broken() const override; void cloneRelink() override; - virtual bool maybePointedTo() const override { return true; } - virtual void dump(std::ostream& str = std::cout) const override; - virtual bool same(const AstNode* samep) const override { + bool maybePointedTo() const override { return true; } + void dump(std::ostream& str = std::cout) const override; + bool same(const AstNode* samep) const override { const AstCFunc* const asamep = static_cast(samep); return ((isTrace() == asamep->isTrace()) && (rtnTypeVoid() == asamep->rtnTypeVoid()) && (argTypes() == asamep->argTypes()) && (ctorInits() == asamep->ctorInits()) @@ -796,8 +791,8 @@ public: && (!(dpiImportPrototype() || dpiExportImpl()) || name() == asamep->name())); } // - virtual void name(const string& name) override { m_name = name; } - virtual int instrCount() const override { + void name(const string& name) override { m_name = name; } + int instrCount() const override { return dpiImportPrototype() ? v3Global.opt.instrCountDpi() : 0; } VBoolOrUnknown isConst() const { return m_isConst; } @@ -886,9 +881,9 @@ public: : ASTGEN_SUPER_CUse(fl) , m_useType{useType} , m_name{name} {} - ASTNODE_NODE_FUNCS(CUse) - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } + ASTGEN_MEMBERS_CUse; + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } VUseType useType() const { return m_useType; } }; class AstCaseItem final : public AstNode { @@ -902,8 +897,8 @@ public: addNOp1p(condsp); addNOp2p(bodysp); } - ASTNODE_NODE_FUNCS(CaseItem) - virtual int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } + ASTGEN_MEMBERS_CaseItem; + int instrCount() const override { return widthInstrs() + INSTR_COUNT_BRANCH; } AstNode* condsp() const { return op1p(); } // op1 = list of possible matching expressions AstNode* bodysp() const { return op2p(); } // op2 = what to do void condsp(AstNode* nodep) { setOp1p(nodep); } @@ -925,8 +920,8 @@ public: setOp1p(lhsp); dtypeFrom(dtp); } - ASTNODE_NODE_FUNCS(Cast) - virtual bool hasDType() const override { return true; } + ASTGEN_MEMBERS_Cast; + bool hasDType() const override { return true; } virtual string emitVerilog() { return "((%d)'(%l))"; } virtual bool cleanOut() const { V3ERROR_NA_RETURN(true); } virtual bool cleanLhs() const { return true; } @@ -934,7 +929,7 @@ public: AstNode* lhsp() const { return op1p(); } AstNode* fromp() const { return lhsp(); } void lhsp(AstNode* nodep) { setOp1p(nodep); } - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } AstNodeDType* childDTypep() const { return VN_AS(op2p(), NodeDType); } virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); } }; @@ -946,7 +941,7 @@ public: setOp1p(lhsp); setOp2p(dtp); } - ASTNODE_NODE_FUNCS(CastParse) + ASTGEN_MEMBERS_CastParse; virtual string emitVerilog() { return "((%d)'(%l))"; } virtual string emitC() { V3ERROR_NA_RETURN(""); } virtual bool cleanOut() const { V3ERROR_NA_RETURN(true); } @@ -963,7 +958,7 @@ public: setOp1p(lhsp); setOp2p((AstNode*)rhsp); } - ASTNODE_NODE_FUNCS(CastSize) + ASTGEN_MEMBERS_CastSize; // No hasDType because widthing removes this node before the hasDType check virtual string emitVerilog() { return "((%r)'(%l))"; } virtual bool cleanOut() const { V3ERROR_NA_RETURN(true); } @@ -998,15 +993,15 @@ public: addNOp2p((AstNode*)paramsp); setNOp3p((AstNode*)rangep); } - ASTNODE_NODE_FUNCS(Cell) + ASTGEN_MEMBERS_Cell; // No cloneRelink, we presume cloneee's want the same module linkages - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; const char* broken() const override; - virtual bool maybePointedTo() const override { return true; } + bool maybePointedTo() const override { return true; } // ACCESSORS - virtual string name() const override { return m_name; } // * = Cell name - virtual void name(const string& name) override { m_name = name; } - virtual string origName() const override { return m_origName; } // * = Original name + string name() const override { return m_name; } // * = Cell name + void name(const string& name) override { m_name = name; } + string origName() const override { return m_origName; } // * = Original name void origName(const string& name) { m_origName = name; } string modName() const { return m_modName; } // * = Instance name void modName(const string& name) { m_modName = name; } @@ -1040,9 +1035,9 @@ public: , m_name{name} { addNOp1p(selectExprp); } - ASTNODE_NODE_FUNCS(CellArrayRef) + ASTGEN_MEMBERS_CellArrayRef; // ACCESSORS - virtual string name() const override { return m_name; } // * = Array name + string name() const override { return m_name; } // * = Array name AstNode* selp() const { return op1p(); } // op1 = Select expression }; class AstCellInline final : public AstNode { @@ -1064,13 +1059,13 @@ public: , m_name{name} , m_origModName{origModName} , m_timeunit{timeunit} {} - ASTNODE_NODE_FUNCS(CellInline) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_CellInline; + void dump(std::ostream& str) const override; const char* broken() const override; // ACCESSORS - virtual string name() const override { return m_name; } // * = Cell name + string name() const override { return m_name; } // * = Cell name string origModName() const { return m_origModName; } // * = modp()->origName() before inlining - virtual void name(const string& name) override { m_name = name; } + void name(const string& name) override { m_name = name; } void scopep(AstScope* scp) { m_scopep = scp; } AstScope* scopep() const { return m_scopep; } void timeunit(const VTimescale& flag) { m_timeunit = flag; } @@ -1087,9 +1082,9 @@ public: addNOp1p(cellp); addNOp2p(exprp); } - ASTNODE_NODE_FUNCS(CellRef) + ASTGEN_MEMBERS_CellRef; // ACCESSORS - virtual string name() const override { return m_name; } // * = Array name + string name() const override { return m_name; } // * = Array name AstNode* cellp() const { return op1p(); } // op1 = Cell AstNode* exprp() const { return op2p(); } // op2 = Expression }; @@ -1101,9 +1096,9 @@ public: : ASTGEN_SUPER_ClassExtends(fl) { setNOp2p(classOrPkgsp); // Only for parser } - ASTNODE_NODE_FUNCS(ClassExtends) - virtual bool hasDType() const override { return true; } - virtual string verilogKwd() const override { return "extends"; } + ASTGEN_MEMBERS_ClassExtends; + bool hasDType() const override { return true; } + string verilogKwd() const override { return "extends"; } AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } AstNode* classOrPkgsp() const { return op2p(); } @@ -1122,23 +1117,23 @@ public: , m_classOrPackageNodep{classOrPackageNodep} { addNOp4p(paramsp); } - ASTNODE_NODE_FUNCS(ClassOrPackageRef) + ASTGEN_MEMBERS_ClassOrPackageRef; // METHODS - virtual const char* broken() const override { + const char* broken() const override { BROKEN_RTN(m_classOrPackageNodep && !m_classOrPackageNodep->brokeExists()); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_classOrPackageNodep && m_classOrPackageNodep->clonep()) { m_classOrPackageNodep = m_classOrPackageNodep->clonep(); } } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { return (m_classOrPackageNodep == static_cast(samep)->m_classOrPackageNodep); } - virtual void dump(std::ostream& str = std::cout) const override; - virtual string name() const override { return m_name; } // * = Var name + void dump(std::ostream& str = std::cout) const override; + string name() const override { return m_name; } // * = Var name AstNode* classOrPackageNodep() const { return m_classOrPackageNodep; } void classOrPackageNodep(AstNode* nodep) { m_classOrPackageNodep = nodep; } AstNodeModule* classOrPackagep() const; @@ -1156,7 +1151,7 @@ public: addOp1p((AstNode*)sensesp); addNOp2p(bodysp); } - ASTNODE_NODE_FUNCS(Clocking) + ASTGEN_MEMBERS_Clocking; // op1 = Sensitivity list AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } AstNode* bodysp() const { return op2p(); } // op2 = Body @@ -1172,10 +1167,10 @@ class AstConstPool final : public AstNode { public: explicit AstConstPool(FileLine* fl); - ASTNODE_NODE_FUNCS(ConstPool) - virtual bool maybePointedTo() const override { return true; } + ASTGEN_MEMBERS_ConstPool; + bool maybePointedTo() const override { return true; } const char* broken() const override; - virtual void cloneRelink() override { V3ERROR_NA; } + void cloneRelink() override { V3ERROR_NA; } AstModule* modp() const { return m_modp; } // Find a table (unpacked array) within the constant pool which is initialized with the @@ -1200,14 +1195,14 @@ private: string m_path; // Dotted cellname to set parameter of public: AstDefParam(FileLine* fl, const string& path, const string& name, AstNode* rhsp) - : ASTGEN_SUPER_DefParam(fl) { + : ASTGEN_SUPER_DefParam(fl) + , m_name{name} + , m_path{path} { setOp1p(rhsp); - m_name = name; - m_path = path; } - virtual string name() const override { return m_name; } // * = Scope name - ASTNODE_NODE_FUNCS(DefParam) - virtual bool same(const AstNode*) const override { return true; } + string name() const override { return m_name; } // * = Scope name + ASTGEN_MEMBERS_DefParam; + bool same(const AstNode*) const override { return true; } AstNode* rhsp() const { return op1p(); } // op1 = Assign from string path() const { return m_path; } }; @@ -1222,13 +1217,13 @@ public: setOp1p(lhsp); setOp2p(rhsp); } - ASTNODE_NODE_FUNCS(Dot) + ASTGEN_MEMBERS_Dot; // For parser, make only if non-null package static AstNode* newIfPkg(FileLine* fl, AstNode* packageOrClassp, AstNode* rhsp) { if (!packageOrClassp) return rhsp; return new AstDot(fl, true, packageOrClassp, rhsp); } - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; AstNode* lhsp() const { return op1p(); } void rhsp(AstNode* nodep) { setOp2p(nodep); } AstNode* rhsp() const { return op2p(); } @@ -1246,9 +1241,9 @@ public: : ASTGEN_SUPER_DpiExport(fl) , m_name{vname} , m_cname{cname} {} - ASTNODE_NODE_FUNCS(DpiExport) - virtual string name() const override { return m_name; } - virtual void name(const string& name) override { m_name = name; } + ASTGEN_MEMBERS_DpiExport; + string name() const override { return m_name; } + void name(const string& name) override { m_name = name; } string cname() const { return m_cname; } void cname(const string& cname) { m_cname = cname; } }; @@ -1260,25 +1255,21 @@ private: public: inline AstElabDisplay(FileLine* fl, VDisplayType dispType, AstNode* exprsp); - ASTNODE_NODE_FUNCS(ElabDisplay) - virtual const char* broken() const override { + ASTGEN_MEMBERS_ElabDisplay; + const char* broken() const override { BROKEN_RTN(!fmtp()); return nullptr; } - virtual string verilogKwd() const override { - return (string("$") + string(displayType().ascii())); - } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: $display makes output - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* samep) const override { + string verilogKwd() const override { return (string("$") + string(displayType().ascii())); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: $display makes output + bool isUnlikely() const override { return true; } + bool same(const AstNode* samep) const override { return displayType() == static_cast(samep)->displayType(); } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + int instrCount() const override { return INSTR_COUNT_PLI; } VDisplayType displayType() const { return m_displayType; } void displayType(VDisplayType type) { m_displayType = type; } void fmtp(AstSFormatF* nodep) { addOp1p((AstNode*)nodep); } // op1 = To-String formatter @@ -1289,8 +1280,8 @@ class AstEmpty final : public AstNode { public: explicit AstEmpty(FileLine* fl) : ASTGEN_SUPER_Empty(fl) {} - ASTNODE_NODE_FUNCS(Empty) - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_Empty; + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstExecGraph final : public AstNode { // For parallel execution, this node contains a dependency graph. Each @@ -1305,13 +1296,13 @@ private: public: explicit AstExecGraph(FileLine* fl, const string& name); - ASTNODE_NODE_FUNCS_NO_DTOR(ExecGraph) - virtual ~AstExecGraph() override; - virtual const char* broken() const override { + ASTGEN_MEMBERS_ExecGraph; + ~AstExecGraph() override; + const char* broken() const override { BROKEN_RTN(!m_depGraphp); return nullptr; } - virtual string name() const override { return m_name; } + string name() const override { return m_name; } V3Graph* depGraphp() { return m_depGraphp; } const V3Graph* depGraphp() const { return m_depGraphp; } // op1: The mtask bodies @@ -1328,7 +1319,7 @@ public: : ASTGEN_SUPER_Implicit(fl) { addNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(Implicit) + ASTGEN_MEMBERS_Implicit; AstNode* exprsp() const { return op1p(); } // op1 = Assign from }; class AstInitArray final : public AstNode { @@ -1349,12 +1340,12 @@ public: dtypep(newDTypep); addNOp1p(defaultp); } - ASTNODE_NODE_FUNCS(InitArray) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_InitArray; + void dump(std::ostream& str) const override; const char* broken() const override; void cloneRelink() override; - virtual bool hasDType() const override { return true; } - virtual bool same(const AstNode* samep) const override { + bool hasDType() const override { return true; } + bool same(const AstNode* samep) const override { // Only works if exact same children, instead should override comparison // of children list, and instead use map-vs-map key/value compare return m_map == static_cast(samep)->m_map; @@ -1378,9 +1369,9 @@ public: : ASTGEN_SUPER_InitItem(fl) { addOp1p(valuep); } - ASTNODE_NODE_FUNCS(InitItem) - virtual bool maybePointedTo() const override { return true; } - virtual bool hasDType() const override { return false; } // See valuep()'s dtype instead + ASTGEN_MEMBERS_InitItem; + bool maybePointedTo() const override { return true; } + bool hasDType() const override { return false; } // See valuep()'s dtype instead AstNode* valuep() const { return op1p(); } // op1 = Value void valuep(AstNode* nodep) { addOp1p(nodep); } }; @@ -1392,8 +1383,8 @@ public: AstIntfRef(FileLine* fl, const string& name) : ASTGEN_SUPER_IntfRef(fl) , m_name{name} {} - virtual string name() const override { return m_name; } - ASTNODE_NODE_FUNCS(IntfRef) + string name() const override { return m_name; } + ASTGEN_MEMBERS_IntfRef; }; class AstMTaskBody final : public AstNode { // Hold statements for each MTask @@ -1403,8 +1394,8 @@ private: public: explicit AstMTaskBody(FileLine* fl) : ASTGEN_SUPER_MTaskBody(fl) {} - ASTNODE_NODE_FUNCS(MTaskBody); - virtual const char* broken() const override { + ASTGEN_MEMBERS_MTaskBody; + const char* broken() const override { BROKEN_RTN(!m_execMTaskp); return nullptr; } @@ -1419,7 +1410,7 @@ public: } ExecMTask* execMTaskp() const { return m_execMTaskp; } void execMTaskp(ExecMTask* execMTaskp) { m_execMTaskp = execMTaskp; } - virtual void dump(std::ostream& str = std::cout) const override; + void dump(std::ostream& str = std::cout) const override; }; class AstModport final : public AstNode { // A modport in an interface @@ -1431,9 +1422,9 @@ public: , m_name{name} { addNOp1p(varsp); } - virtual string name() const override { return m_name; } - virtual bool maybePointedTo() const override { return true; } - ASTNODE_NODE_FUNCS(Modport) + string name() const override { return m_name; } + bool maybePointedTo() const override { return true; } + ASTGEN_MEMBERS_Modport; AstNode* varsp() const { return op1p(); } // op1 = List of Vars }; class AstModportFTaskRef final : public AstNode { @@ -1450,11 +1441,11 @@ public: : ASTGEN_SUPER_ModportFTaskRef(fl) , m_name{name} , m_export{isExport} {} - ASTNODE_NODE_FUNCS(ModportFTaskRef) + ASTGEN_MEMBERS_ModportFTaskRef; const char* broken() const override; void cloneRelink() override; - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } + void dump(std::ostream& str) const override; + string name() const override { return m_name; } bool isImport() const { return !m_export; } bool isExport() const { return m_export; } AstNodeFTask* ftaskp() const { return m_ftaskp; } // [After Link] Pointer to variable @@ -1473,11 +1464,11 @@ public: : ASTGEN_SUPER_ModportVarRef(fl) , m_name{name} , m_direction{direction} {} - ASTNODE_NODE_FUNCS(ModportVarRef) + ASTGEN_MEMBERS_ModportVarRef; const char* broken() const override; void cloneRelink() override; - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } + void dump(std::ostream& str) const override; + string name() const override { return m_name; } void direction(const VDirection& flag) { m_direction = flag; } VDirection direction() const { return m_direction; } AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable @@ -1504,11 +1495,11 @@ private: uint32_t m_nextFreeMTaskProfilingID = 0; // Next unique ID to use for PGO public: AstNetlist(); - ASTNODE_NODE_FUNCS(Netlist) + ASTGEN_MEMBERS_Netlist; const char* broken() const override; - virtual void cloneRelink() override { V3ERROR_NA; } - virtual string name() const override { return "$root"; } - virtual void dump(std::ostream& str) const override; + void cloneRelink() override { V3ERROR_NA; } + string name() const override { return "$root"; } + void dump(std::ostream& str) const override; AstNodeModule* modulesp() const { // op1 = List of modules return VN_AS(op1p(), NodeModule); } @@ -1557,11 +1548,11 @@ public: : ASTGEN_SUPER_PackageExport(fl) , m_name{name} , m_packagep{packagep} {} - ASTNODE_NODE_FUNCS(PackageExport) + ASTGEN_MEMBERS_PackageExport; const char* broken() const override; void cloneRelink() override; - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } + void dump(std::ostream& str) const override; + string name() const override { return m_name; } AstPackage* packagep() const { return m_packagep; } void packagep(AstPackage* nodep) { m_packagep = nodep; } }; @@ -1571,7 +1562,7 @@ public: // cppcheck-suppress noExplicitConstructor AstPackageExportStarStar(FileLine* fl) : ASTGEN_SUPER_PackageExportStarStar(fl) {} - ASTNODE_NODE_FUNCS(PackageExportStarStar) + ASTGEN_MEMBERS_PackageExportStarStar; }; class AstPackageImport final : public AstNode { private: @@ -1583,11 +1574,11 @@ public: : ASTGEN_SUPER_PackageImport(fl) , m_name{name} , m_packagep{packagep} {} - ASTNODE_NODE_FUNCS(PackageImport) + ASTGEN_MEMBERS_PackageImport; const char* broken() const override; void cloneRelink() override; - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } + void dump(std::ostream& str) const override; + string name() const override { return m_name; } AstPackage* packagep() const { return m_packagep; } void packagep(AstPackage* nodep) { m_packagep = nodep; } }; @@ -1610,14 +1601,14 @@ public: setNOp1p(lhsp); setNOp2p((AstNode*)ftaskrefp); } - ASTNODE_NODE_FUNCS(ParseRef) - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } // * = Var name - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_ParseRef; + void dump(std::ostream& str) const override; + string name() const override { return m_name; } // * = Var name + bool same(const AstNode* samep) const override { const AstParseRef* const asamep = static_cast(samep); return (expect() == asamep->expect() && m_name == asamep->m_name); } - virtual void name(const string& name) override { m_name = name; } + void name(const string& name) override { m_name = name; } VParseRefExp expect() const { return m_expect; } void expect(VParseRefExp exp) { m_expect = exp; } // op1 = Components @@ -1643,11 +1634,11 @@ public: setNOp1p(exprp); } inline AstPin(FileLine* fl, int pinNum, AstVarRef* varname, AstNode* exprp); - ASTNODE_NODE_FUNCS(Pin) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_Pin; + void dump(std::ostream& str) const override; const char* broken() const override; - virtual string name() const override { return m_name; } // * = Pin name, ""=go by number - virtual void name(const string& name) override { m_name = name; } + string name() const override { return m_name; } // * = Pin name, ""=go by number + void name(const string& name) override { m_name = name; } string prettyOperatorName() const override; bool dotStar() const { return name() == ".*"; } // Fake name for .* connections until linked int pinNum() const { return m_pinNum; } @@ -1674,8 +1665,8 @@ public: : ASTGEN_SUPER_Port(fl) , m_pinNum{pinnum} , m_name{name} {} - ASTNODE_NODE_FUNCS(Port) - virtual string name() const override { return m_name; } // * = Port name + ASTGEN_MEMBERS_Port; + string name() const override { return m_name; } // * = Port name int pinNum() const { return m_pinNum; } // * = Pin number, for order based instantiation AstNode* exprp() const { return op1p(); } // op1 = Expression connected to port }; @@ -1688,10 +1679,10 @@ public: AstPragma(FileLine* fl, VPragmaType pragType) : ASTGEN_SUPER_Pragma(fl) , m_pragType{pragType} {} - ASTNODE_NODE_FUNCS(Pragma) + ASTGEN_MEMBERS_Pragma; VPragmaType pragType() const { return m_pragType; } // *=type of the pragma - virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* samep) const override { + bool isPredictOptimizable() const override { return false; } + bool same(const AstNode* samep) const override { return pragType() == static_cast(samep)->pragType(); } }; @@ -1706,8 +1697,8 @@ public: addNOp2p(disablep); addOp3p(propp); } - ASTNODE_NODE_FUNCS(PropClocked) - virtual bool hasDType() const override { + ASTGEN_MEMBERS_PropClocked; + bool hasDType() const override { return true; } // Used under Cover, which expects a bool child AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } // op1 = Sensitivity list @@ -1720,12 +1711,12 @@ private: public: AstPull(FileLine* fl, AstNode* lhsp, bool direction) - : ASTGEN_SUPER_Pull(fl) { + : ASTGEN_SUPER_Pull(fl) + , m_direction{direction} { setOp1p(lhsp); - m_direction = direction; } - ASTNODE_NODE_FUNCS(Pull) - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_Pull; + bool same(const AstNode* samep) const override { return direction() == static_cast(samep)->direction(); } void lhsp(AstNode* np) { setOp1p(np); } @@ -1764,14 +1755,14 @@ public: addNOp1p(exprsp); addNOp2p(nullptr); } - ASTNODE_NODE_FUNCS(SFormatF) - virtual string name() const override { return m_text; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool hasDType() const override { return true; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_SFormatF; + string name() const override { return m_text; } + int instrCount() const override { return INSTR_COUNT_PLI; } + bool hasDType() const override { return true; } + bool same(const AstNode* samep) const override { return text() == static_cast(samep)->text(); } - virtual string verilogKwd() const override { return "$sformatf"; } + string verilogKwd() const override { return "$sformatf"; } void addExprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output string text() const { return m_text; } // * = Text to display @@ -1806,13 +1797,13 @@ public: , m_aboveScopep{aboveScopep} , m_aboveCellp{aboveCellp} , m_modp{modp} {} - ASTNODE_NODE_FUNCS(Scope) - virtual void cloneRelink() override; - virtual const char* broken() const override; - virtual bool maybePointedTo() const override { return true; } - virtual string name() const override { return m_name; } // * = Scope name - virtual void name(const string& name) override { m_name = name; } - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_Scope; + void cloneRelink() override; + const char* broken() const override; + bool maybePointedTo() const override { return true; } + string name() const override { return m_name; } // * = Scope name + void name(const string& name) override { m_name = name; } + void dump(std::ostream& str) const override; string nameDotless() const; string nameVlSym() const { return ((string("vlSymsp->")) + nameDotless()); } AstNodeModule* modp() const { return m_modp; } @@ -1840,9 +1831,9 @@ public: setOp1p(fromp); addNOp2p(elementsp); } - ASTNODE_NODE_FUNCS(SelLoopVars) - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual bool maybePointedTo() const override { return false; } + ASTGEN_MEMBERS_SelLoopVars; + bool same(const AstNode* /*samep*/) const override { return true; } + bool maybePointedTo() const override { return false; } AstNode* fromp() const { return op1p(); } void fromp(AstNode* nodep) { setOp1p(nodep); } AstNode* elementsp() const { return op2p(); } @@ -1882,9 +1873,9 @@ public: AstSenItem(FileLine* fl, Never) : ASTGEN_SUPER_SenItem(fl) , m_edgeType{VEdgeType::ET_NEVER} {} - ASTNODE_NODE_FUNCS(SenItem) - virtual void dump(std::ostream& str) const override; - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_SenItem; + void dump(std::ostream& str) const override; + bool same(const AstNode* samep) const override { return edgeType() == static_cast(samep)->edgeType(); } VEdgeType edgeType() const { return m_edgeType; } @@ -1917,9 +1908,9 @@ public: : ASTGEN_SUPER_SenTree(fl) { addNOp1p(sensesp); } - ASTNODE_NODE_FUNCS(SenTree) - virtual void dump(std::ostream& str) const override; - virtual bool maybePointedTo() const override { return true; } + ASTGEN_MEMBERS_SenTree; + void dump(std::ostream& str) const override; + bool maybePointedTo() const override { return true; } bool isMulti() const { return m_multi; } // op1 = Sensitivity list AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } @@ -1938,7 +1929,7 @@ public: // Dummy node used within V3Split; never exists outside of V3Split. explicit AstSplitPlaceholder(FileLine* fl) : ASTGEN_SUPER_SplitPlaceholder(fl) {} - ASTNODE_NODE_FUNCS(SplitPlaceholder) + ASTGEN_MEMBERS_SplitPlaceholder; }; class AstStrengthSpec final : public AstNode { private: @@ -1951,10 +1942,10 @@ public: , m_s0{s0} , m_s1{s1} {} - ASTNODE_NODE_FUNCS(StrengthSpec) + ASTGEN_MEMBERS_StrengthSpec; VStrength strength0() { return m_s0; } VStrength strength1() { return m_s1; } - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; }; class AstTopScope final : public AstNode { // A singleton, held under the top level AstModule. Holds the top level AstScope, @@ -1968,8 +1959,8 @@ class AstTopScope final : public AstNode { } public: - ASTNODE_NODE_FUNCS(TopScope) - virtual bool maybePointedTo() const override { return true; } + ASTGEN_MEMBERS_TopScope; + bool maybePointedTo() const override { return true; } AstSenTree* senTreesp() const { return VN_AS(op1p(), SenTree); } void addSenTreep(AstSenTree* nodep) { addOp1p((AstNode*)nodep); } AstScope* scopep() const { return VN_AS(op2p(), Scope); } @@ -1987,15 +1978,15 @@ class AstTypeTable final : public AstNode { public: explicit AstTypeTable(FileLine* fl); - ASTNODE_NODE_FUNCS(TypeTable) - virtual bool maybePointedTo() const override { return true; } - virtual const char* broken() const override { + ASTGEN_MEMBERS_TypeTable; + bool maybePointedTo() const override { return true; } + const char* broken() const override { BROKEN_RTN(m_emptyQueuep && !m_emptyQueuep->brokeExists()); BROKEN_RTN(m_queueIndexp && !m_queueIndexp->brokeExists()); BROKEN_RTN(m_voidp && !m_voidp->brokeExists()); return nullptr; } - virtual void cloneRelink() override { V3ERROR_NA; } + void cloneRelink() override { V3ERROR_NA; } AstNodeDType* typesp() const { return VN_AS(op1p(), NodeDType); } // op1 = List of dtypes void addTypesp(AstNodeDType* nodep) { addOp1p(nodep); } AstBasicDType* findBasicDType(FileLine* fl, VBasicDTypeKwd kwd); @@ -2009,12 +2000,12 @@ public: AstVoidDType* findVoidDType(FileLine* fl); void clearCache(); void repairCache(); - virtual void dump(std::ostream& str = std::cout) const override; + void dump(std::ostream& str = std::cout) const override; }; class AstTypedef final : public AstNode { private: string m_name; - bool m_attrPublic; + bool m_attrPublic = false; string m_tag; // Holds the string of the verilator tag -- used in XML output. public: AstTypedef(FileLine* fl, const string& name, AstNode* attrsp, VFlagChildDType, @@ -2024,11 +2015,10 @@ public: childDTypep(dtp); // Only for parser addAttrsp(attrsp); dtypep(nullptr); // V3Width will resolve - m_attrPublic = false; } - ASTNODE_NODE_FUNCS(Typedef) - virtual void dump(std::ostream& str) const override; - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + ASTGEN_MEMBERS_Typedef; + void dump(std::ostream& str) const override; + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Type assigning to AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } @@ -2036,14 +2026,14 @@ public: void addAttrsp(AstNode* nodep) { addNOp4p(nodep); } AstNode* attrsp() const { return op4p(); } // op4 = Attributes during early parse // METHODS - virtual string name() const override { return m_name; } - virtual bool maybePointedTo() const override { return true; } - virtual bool hasDType() const override { return true; } - virtual void name(const string& flag) override { m_name = flag; } + string name() const override { return m_name; } + bool maybePointedTo() const override { return true; } + bool hasDType() const override { return true; } + void name(const string& flag) override { m_name = flag; } bool attrPublic() const { return m_attrPublic; } void attrPublic(bool flag) { m_attrPublic = flag; } - virtual void tag(const string& text) override { m_tag = text; } - virtual string tag() const override { return m_tag; } + void tag(const string& text) override { m_tag = text; } + string tag() const override { return m_tag; } }; class AstTypedefFwd final : public AstNode { // Forward declaration of a type; stripped after netlist parsing is complete @@ -2054,10 +2044,10 @@ public: AstTypedefFwd(FileLine* fl, const string& name) : ASTGEN_SUPER_TypedefFwd(fl) , m_name{name} {} - ASTNODE_NODE_FUNCS(TypedefFwd) + ASTGEN_MEMBERS_TypedefFwd; // METHODS - virtual string name() const override { return m_name; } - virtual bool maybePointedTo() const override { return true; } + string name() const override { return m_name; } + bool maybePointedTo() const override { return true; } }; class AstUdpTable final : public AstNode { public: @@ -2065,7 +2055,7 @@ public: : ASTGEN_SUPER_UdpTable(fl) { addNOp1p(bodysp); } - ASTNODE_NODE_FUNCS(UdpTable) + ASTGEN_MEMBERS_UdpTable; // op1 = List of UdpTableLines AstUdpTableLine* bodysp() const { return VN_AS(op1p(), UdpTableLine); } }; @@ -2076,8 +2066,8 @@ public: AstUdpTableLine(FileLine* fl, const string& text) : ASTGEN_SUPER_UdpTableLine(fl) , m_text{text} {} - ASTNODE_NODE_FUNCS(UdpTableLine) - virtual string name() const override { return m_text; } + ASTGEN_MEMBERS_UdpTableLine; + string name() const override { return m_text; } string text() const { return m_text; } }; class AstUnlinkedRef final : public AstNode { @@ -2091,9 +2081,9 @@ public: addNOp1p(refp); addNOp2p(crp); } - ASTNODE_NODE_FUNCS(UnlinkedRef) + ASTGEN_MEMBERS_UnlinkedRef; // ACCESSORS - virtual string name() const override { return m_name; } // * = Var name + string name() const override { return m_name; } // * = Var name AstNode* refp() const { return op1p(); } // op1 = VarXRef or AstNodeFTaskRef AstNode* cellrefp() const { return op2p(); } // op2 = CellArrayRef or CellRef }; @@ -2253,12 +2243,12 @@ public: dtypeFrom(examplep); m_declKwd = examplep->declKwd(); } - ASTNODE_NODE_FUNCS(Var) - virtual void dump(std::ostream& str) const override; - virtual string name() const override { return m_name; } // * = Var name - virtual bool hasDType() const override { return true; } - virtual bool maybePointedTo() const override { return true; } - virtual string origName() const override { return m_origName; } // * = Original name + ASTGEN_MEMBERS_Var; + void dump(std::ostream& str) const override; + string name() const override { return m_name; } // * = Var name + bool hasDType() const override { return true; } + bool maybePointedTo() const override { return true; } + string origName() const override { return m_origName; } // * = Original name void origName(const string& name) { m_origName = name; } VVarType varType() const { return m_varType; } // * = Type of variable void direction(const VDirection& flag) { @@ -2291,7 +2281,7 @@ public: string vlEnumDir() const; // Return VerilatorVarDir: VLVD_INOUT, etc string vlPropDecl(const string& propName) const; // Return VerilatorVarProps declaration void combineType(VVarType type); - virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } + AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } // op2 = Net delay @@ -2366,9 +2356,9 @@ public: void setWrittenBySuspendable() { m_isWrittenBySuspendable = true; } // METHODS - virtual void name(const string& name) override { m_name = name; } - virtual void tag(const string& text) override { m_tag = text; } - virtual string tag() const override { return m_tag; } + void name(const string& name) override { m_name = name; } + void tag(const string& text) override { m_tag = text; } + string tag() const override { return m_tag; } bool isAnsi() const { return m_ansi; } bool isContinuously() const { return m_isContinuously; } bool isDeclTyped() const { return m_declTyped; } @@ -2431,7 +2421,7 @@ public: bool attrSplitVar() const { return m_attrSplitVar; } bool attrIsolateAssign() const { return m_attrIsolateAssign; } VVarAttrClocker attrClocker() const { return m_attrClocker; } - virtual string verilogKwd() const override; + string verilogKwd() const override; void lifetime(const VLifetime& flag) { m_lifetime = flag; } VLifetime lifetime() const { return m_lifetime; } void propagateAttrFrom(AstVar* fromp) { @@ -2490,23 +2480,23 @@ public: m_trace = true; dtypeFrom(varp); } - ASTNODE_NODE_FUNCS(VarScope) - virtual void cloneRelink() override { + ASTGEN_MEMBERS_VarScope; + void cloneRelink() override { if (m_varp && m_varp->clonep()) { m_varp = m_varp->clonep(); UASSERT(m_scopep->clonep(), "No clone cross link: " << this); m_scopep = m_scopep->clonep(); } } - virtual const char* broken() const override { + const char* broken() const override { BROKEN_RTN(m_varp && !m_varp->brokeExists()); BROKEN_RTN(m_scopep && !m_scopep->brokeExists()); return nullptr; } - virtual bool maybePointedTo() const override { return true; } - virtual string name() const override { return scopep()->name() + "->" + varp()->name(); } - virtual void dump(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } + bool maybePointedTo() const override { return true; } + string name() const override { return scopep()->name() + "->" + varp()->name(); } + void dump(std::ostream& str) const override; + bool hasDType() const override { return true; } AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable AstScope* scopep() const { return m_scopep; } // Pointer to scope it's under void scopep(AstScope* nodep) { m_scopep = nodep; } @@ -2529,8 +2519,8 @@ public: : ASTGEN_SUPER_Begin(fl, name, stmtsp) , m_generate{generate} , m_implied{implied} {} - ASTNODE_NODE_FUNCS(Begin) - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_Begin; + void dump(std::ostream& str) const override; // op1p is statements in NodeBlock AstNode* genforp() const { return op2p(); } // op2 = GENFOR, if applicable, // might NOT be a GenFor, as loop unrolling replaces with Begin @@ -2549,9 +2539,9 @@ public: // Node that puts name into the output stream AstFork(FileLine* fl, const string& name, AstNode* stmtsp) : ASTGEN_SUPER_Fork(fl, name, stmtsp) {} - ASTNODE_NODE_FUNCS(Fork) - virtual bool isTimingControl() const override { return !joinType().joinNone(); } - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_Fork; + bool isTimingControl() const override { return !joinType().joinNone(); } + void dump(std::ostream& str) const override; VJoinType joinType() const { return m_joinType; } void joinType(const VJoinType& flag) { m_joinType = flag; } }; @@ -2564,15 +2554,15 @@ public: : ASTGEN_SUPER_Func(fl, name, stmtp) { addNOp1p(fvarsp); } - ASTNODE_NODE_FUNCS(Func) - virtual bool hasDType() const override { return true; } + ASTGEN_MEMBERS_Func; + bool hasDType() const override { return true; } }; class AstTask final : public AstNodeFTask { // A task inside a module public: AstTask(FileLine* fl, const string& name, AstNode* stmtp) : ASTGEN_SUPER_Task(fl, name, stmtp) {} - ASTNODE_NODE_FUNCS(Task) + ASTGEN_MEMBERS_Task; }; // === AstNodeFile === @@ -2589,8 +2579,8 @@ public: , m_slow{false} , m_source{false} , m_support{false} {} - ASTNODE_NODE_FUNCS(CFile) - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_CFile; + void dump(std::ostream& str = std::cout) const override; bool slow() const { return m_slow; } void slow(bool flag) { m_slow = flag; } bool source() const { return m_source; } @@ -2604,8 +2594,8 @@ class AstVFile final : public AstNodeFile { public: AstVFile(FileLine* fl, const string& name) : ASTGEN_SUPER_VFile(fl, name) {} - ASTNODE_NODE_FUNCS(VFile) - virtual void dump(std::ostream& str = std::cout) const override; + ASTGEN_MEMBERS_VFile; + void dump(std::ostream& str = std::cout) const override; }; // === AstNodeModule === @@ -2622,13 +2612,13 @@ class AstClass final : public AstNodeModule { public: AstClass(FileLine* fl, const string& name) : ASTGEN_SUPER_Class(fl, name) {} - ASTNODE_NODE_FUNCS(Class) - virtual string verilogKwd() const override { return "class"; } - virtual bool maybePointedTo() const override { return true; } - virtual void dump(std::ostream& str) const override; + ASTGEN_MEMBERS_Class; + string verilogKwd() const override { return "class"; } + bool maybePointedTo() const override { return true; } + void dump(std::ostream& str) const override; const char* broken() const override; void cloneRelink() override; - virtual bool timescaleMatters() const override { return false; } + bool timescaleMatters() const override { return false; } // op1/op2/op3 in AstNodeModule AstClassPackage* classOrPackagep() const { return m_classOrPackagep; } void classOrPackagep(AstClassPackage* classpackagep) { m_classOrPackagep = classpackagep; } @@ -2660,11 +2650,11 @@ class AstClassPackage final : public AstNodeModule { public: AstClassPackage(FileLine* fl, const string& name) : ASTGEN_SUPER_ClassPackage(fl, name) {} - ASTNODE_NODE_FUNCS(ClassPackage) - virtual string verilogKwd() const override { return "classpackage"; } - virtual const char* broken() const override; - virtual void cloneRelink() override; - virtual bool timescaleMatters() const override { return false; } + ASTGEN_MEMBERS_ClassPackage; + string verilogKwd() const override { return "classpackage"; } + const char* broken() const override; + void cloneRelink() override; + bool timescaleMatters() const override { return false; } AstClass* classp() const { return m_classp; } void classp(AstClass* classp) { m_classp = classp; } }; @@ -2673,11 +2663,11 @@ class AstIface final : public AstNodeModule { public: AstIface(FileLine* fl, const string& name) : ASTGEN_SUPER_Iface(fl, name) {} - ASTNODE_NODE_FUNCS(Iface) + ASTGEN_MEMBERS_Iface; // Interfaces have `timescale applicability but lots of code seems to // get false warnings if we enable this - virtual string verilogKwd() const override { return "interface"; } - virtual bool timescaleMatters() const override { return false; } + string verilogKwd() const override { return "interface"; } + bool timescaleMatters() const override { return false; } }; class AstModule final : public AstNodeModule { // A module declaration @@ -2687,27 +2677,27 @@ public: AstModule(FileLine* fl, const string& name, bool program = false) : ASTGEN_SUPER_Module(fl, name) , m_isProgram{program} {} - ASTNODE_NODE_FUNCS(Module) - virtual string verilogKwd() const override { return m_isProgram ? "program" : "module"; } - virtual bool timescaleMatters() const override { return true; } + ASTGEN_MEMBERS_Module; + string verilogKwd() const override { return m_isProgram ? "program" : "module"; } + bool timescaleMatters() const override { return true; } }; class AstNotFoundModule final : public AstNodeModule { // A missing module declaration public: AstNotFoundModule(FileLine* fl, const string& name) : ASTGEN_SUPER_NotFoundModule(fl, name) {} - ASTNODE_NODE_FUNCS(NotFoundModule) - virtual string verilogKwd() const override { return "/*not-found-*/ module"; } - virtual bool timescaleMatters() const override { return false; } + ASTGEN_MEMBERS_NotFoundModule; + string verilogKwd() const override { return "/*not-found-*/ module"; } + bool timescaleMatters() const override { return false; } }; class AstPackage final : public AstNodeModule { // A package declaration public: AstPackage(FileLine* fl, const string& name) : ASTGEN_SUPER_Package(fl, name) {} - ASTNODE_NODE_FUNCS(Package) - virtual string verilogKwd() const override { return "package"; } - virtual bool timescaleMatters() const override { return !isDollarUnit(); } + ASTGEN_MEMBERS_Package; + string verilogKwd() const override { return "package"; } + bool timescaleMatters() const override { return !isDollarUnit(); } static string dollarUnitName() { return AstNode::encodeName("$unit"); } bool isDollarUnit() const { return name() == dollarUnitName(); } }; @@ -2716,9 +2706,9 @@ class AstPrimitive final : public AstNodeModule { public: AstPrimitive(FileLine* fl, const string& name) : ASTGEN_SUPER_Primitive(fl, name) {} - ASTNODE_NODE_FUNCS(Primitive) - virtual string verilogKwd() const override { return "primitive"; } - virtual bool timescaleMatters() const override { return false; } + ASTGEN_MEMBERS_Primitive; + string verilogKwd() const override { return "primitive"; } + bool timescaleMatters() const override { return false; } }; // === AstNodePreSel === @@ -2731,7 +2721,7 @@ public: UASSERT_OBJ(!v3Global.assertDTypesResolved(), this, "not coded to create after dtypes resolved"); } - ASTNODE_NODE_FUNCS(SelBit) + ASTGEN_MEMBERS_SelBit; AstNode* bitp() const { return rhsp(); } }; class AstSelExtract final : public AstNodePreSel { @@ -2739,7 +2729,7 @@ class AstSelExtract final : public AstNodePreSel { public: AstSelExtract(FileLine* fl, AstNode* fromp, AstNode* msbp, AstNode* lsbp) : ASTGEN_SUPER_SelExtract(fl, fromp, msbp, lsbp) {} - ASTNODE_NODE_FUNCS(SelExtract) + ASTGEN_MEMBERS_SelExtract; AstNode* leftp() const { return rhsp(); } AstNode* rightp() const { return thsp(); } }; @@ -2749,7 +2739,7 @@ class AstSelMinus final : public AstNodePreSel { public: AstSelMinus(FileLine* fl, AstNode* fromp, AstNode* bitp, AstNode* widthp) : ASTGEN_SUPER_SelMinus(fl, fromp, bitp, widthp) {} - ASTNODE_NODE_FUNCS(SelMinus) + ASTGEN_MEMBERS_SelMinus; AstNode* bitp() const { return rhsp(); } AstNode* widthp() const { return thsp(); } }; @@ -2759,7 +2749,7 @@ class AstSelPlus final : public AstNodePreSel { public: AstSelPlus(FileLine* fl, AstNode* fromp, AstNode* bitp, AstNode* widthp) : ASTGEN_SUPER_SelPlus(fl, fromp, bitp, widthp) {} - ASTNODE_NODE_FUNCS(SelPlus) + ASTGEN_MEMBERS_SelPlus; AstNode* bitp() const { return rhsp(); } AstNode* widthp() const { return thsp(); } }; @@ -2774,9 +2764,9 @@ public: , m_keyword{keyword} { addNOp1p(sensesp); } - ASTNODE_NODE_FUNCS(Always) + ASTGEN_MEMBERS_Always; // - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list void sensesp(AstSenTree* nodep) { setOp1p(nodep); } VAlwaysKwd keyword() const { return m_keyword; } @@ -2788,7 +2778,7 @@ public: : ASTGEN_SUPER_AlwaysPost(fl, bodysp) { addNOp1p(sensesp); } - ASTNODE_NODE_FUNCS(AlwaysPost) + ASTGEN_MEMBERS_AlwaysPost; }; class AstAlwaysPostponed final : public AstNodeProcedure { // Like always but postponement scheduling region @@ -2796,19 +2786,19 @@ class AstAlwaysPostponed final : public AstNodeProcedure { public: AstAlwaysPostponed(FileLine* fl, AstNode* bodysp) : ASTGEN_SUPER_AlwaysPostponed(fl, bodysp) {} - ASTNODE_NODE_FUNCS(AlwaysPostponed) + ASTGEN_MEMBERS_AlwaysPostponed; }; class AstFinal final : public AstNodeProcedure { public: AstFinal(FileLine* fl, AstNode* bodysp) : ASTGEN_SUPER_Final(fl, bodysp) {} - ASTNODE_NODE_FUNCS(Final) + ASTGEN_MEMBERS_Final; }; class AstInitial final : public AstNodeProcedure { public: AstInitial(FileLine* fl, AstNode* bodysp) : ASTGEN_SUPER_Initial(fl, bodysp) {} - ASTNODE_NODE_FUNCS(Initial) + ASTGEN_MEMBERS_Initial; }; class AstInitialAutomatic final : public AstNodeProcedure { // Automatic variable initialization @@ -2816,7 +2806,7 @@ class AstInitialAutomatic final : public AstNodeProcedure { public: AstInitialAutomatic(FileLine* fl, AstNode* bodysp) : ASTGEN_SUPER_InitialAutomatic(fl, bodysp) {} - ASTNODE_NODE_FUNCS(InitialAutomatic) + ASTGEN_MEMBERS_InitialAutomatic; }; class AstInitialStatic final : public AstNodeProcedure { // Static variable initialization @@ -2824,7 +2814,7 @@ class AstInitialStatic final : public AstNodeProcedure { public: AstInitialStatic(FileLine* fl, AstNode* bodysp) : ASTGEN_SUPER_InitialStatic(fl, bodysp) {} - ASTNODE_NODE_FUNCS(InitialStatic) + ASTGEN_MEMBERS_InitialStatic; }; // === AstNodeRange === @@ -2836,13 +2826,13 @@ public: : ASTGEN_SUPER_BracketRange(fl) { setOp1p(elementsp); } - ASTNODE_NODE_FUNCS(BracketRange) + ASTGEN_MEMBERS_BracketRange; virtual string emitC() { V3ERROR_NA_RETURN(""); } virtual string emitVerilog() { V3ERROR_NA_RETURN(""); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } // Will be removed in V3Width, which relies on this // being a child not a dtype pointed node - virtual bool maybePointedTo() const override { return false; } + bool maybePointedTo() const override { return false; } AstNode* elementsp() const { return op1p(); } }; class AstRange final : public AstNodeRange { @@ -2855,7 +2845,7 @@ public: } inline AstRange(FileLine* fl, int left, int right); inline AstRange(FileLine* fl, const VNumRange& range); - ASTNODE_NODE_FUNCS(Range) + ASTGEN_MEMBERS_Range; AstNode* leftp() const { return op2p(); } AstNode* rightp() const { return op3p(); } inline int leftConst() const; @@ -2872,29 +2862,29 @@ public: } int elementsConst() const { return hiConst() - loConst() + 1; } bool littleEndian() const { return leftConst() < rightConst(); } - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; virtual string emitC() { V3ERROR_NA_RETURN(""); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstUnsizedRange final : public AstNodeRange { // Unsized range specification, for open arrays public: explicit AstUnsizedRange(FileLine* fl) : ASTGEN_SUPER_UnsizedRange(fl) {} - ASTNODE_NODE_FUNCS(UnsizedRange) + ASTGEN_MEMBERS_UnsizedRange; virtual string emitC() { V3ERROR_NA_RETURN(""); } virtual string emitVerilog() { return "[]"; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstWildcardRange final : public AstNodeRange { // Wildcard range specification, for wildcard index type associative arrays public: explicit AstWildcardRange(FileLine* fl) : ASTGEN_SUPER_WildcardRange(fl) {} - ASTNODE_NODE_FUNCS(WildcardRange) + ASTGEN_MEMBERS_WildcardRange; virtual string emitC() { V3ERROR_NA_RETURN(""); } virtual string emitVerilog() { return "[*]"; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; // === AstNodeStmt === @@ -2907,8 +2897,8 @@ public: addNOp1p(sensesp); addNOp2p(bodysp); } - ASTNODE_NODE_FUNCS(AlwaysPublic) - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_AlwaysPublic; + bool same(const AstNode* /*samep*/) const override { return true; } // AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list AstNode* bodysp() const { return op2p(); } // op2 = Statements to evaluate @@ -2921,9 +2911,9 @@ class AstBreak final : public AstNodeStmt { public: explicit AstBreak(FileLine* fl) : ASTGEN_SUPER_Break(fl) {} - ASTNODE_NODE_FUNCS(Break) - virtual string verilogKwd() const override { return "break"; } - virtual bool isBrancher() const override { + ASTGEN_MEMBERS_Break; + string verilogKwd() const override { return "break"; } + bool isBrancher() const override { return true; // SPECIAL: We don't process code after breaks } }; @@ -2937,16 +2927,16 @@ public: , m_sensesp{sensesp} { setNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(CAwait) - virtual bool isTimingControl() const override { return true; } - virtual const char* broken() const override { + ASTGEN_MEMBERS_CAwait; + bool isTimingControl() const override { return true; } + const char* broken() const override { BROKEN_RTN(m_sensesp && !m_sensesp->brokeExists()); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_sensesp && m_sensesp->clonep()) m_sensesp = m_sensesp->clonep(); } - virtual void dump(std::ostream& str) const override; + void dump(std::ostream& str) const override; AstNode* exprp() const { return op1p(); } // op1 = awaited expression void exprp(AstNode* const nodep) { setNOp1p(nodep); } AstSenTree* sensesp() const { return m_sensesp; } @@ -2974,15 +2964,15 @@ public: setOp1p(fromp); addNOp2p(pinsp); } - ASTNODE_NODE_FUNCS(CMethodHard) - virtual string name() const override { return m_name; } // * = Var name - virtual bool hasDType() const override { return true; } - virtual void name(const string& name) override { m_name = name; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_CMethodHard; + string name() const override { return m_name; } // * = Var name + bool hasDType() const override { return true; } + void name(const string& name) override { m_name = name; } + bool same(const AstNode* samep) const override { const AstCMethodHard* asamep = static_cast(samep); return (m_name == asamep->m_name); } - virtual bool isPure() const override { return m_pure; } + bool isPure() const override { return m_pure; } void pure(bool flag) { m_pure = flag; } void makeStatement() { statement(true); @@ -3002,10 +2992,10 @@ public: : ASTGEN_SUPER_CReset(fl) { addNOp1p((AstNode*)exprsp); } - ASTNODE_NODE_FUNCS(CReset) - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_CReset; + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } AstVarRef* varrefp() const { return VN_AS(op1p(), VarRef); } // op1 = varref to reset }; class AstCReturn final : public AstNodeStmt { @@ -3017,9 +3007,9 @@ public: : ASTGEN_SUPER_CReturn(fl) { setOp1p(lhsp); } - ASTNODE_NODE_FUNCS(CReturn) - virtual int instrCount() const override { return widthInstrs(); } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_CReturn; + int instrCount() const override { return widthInstrs(); } + bool same(const AstNode* /*samep*/) const override { return true; } // AstNode* lhsp() const { return op1p(); } }; @@ -3031,10 +3021,10 @@ public: addNOp1p(exprsp); } inline AstCStmt(FileLine* fl, const string& textStmt); - ASTNODE_NODE_FUNCS(CStmt) - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_CStmt; + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool same(const AstNode* /*samep*/) const override { return true; } void addBodysp(AstNode* nodep) { addNOp1p(nodep); } AstNode* bodysp() const { return op1p(); } // op1 = expressions to print }; @@ -3050,20 +3040,18 @@ public: : ASTGEN_SUPER_Comment(fl) , m_showAt{showAt} , m_name{name} {} - ASTNODE_NODE_FUNCS(Comment) - virtual string name() const override { return m_name; } // * = Text - virtual bool same(const AstNode* samep) const override { - return true; - } // Ignore name in comments + ASTGEN_MEMBERS_Comment; + string name() const override { return m_name; } // * = Text + bool same(const AstNode* samep) const override { return true; } // Ignore name in comments virtual bool showAt() const { return m_showAt; } }; class AstContinue final : public AstNodeStmt { public: explicit AstContinue(FileLine* fl) : ASTGEN_SUPER_Continue(fl) {} - ASTNODE_NODE_FUNCS(Continue) - virtual string verilogKwd() const override { return "continue"; } - virtual bool isBrancher() const override { + ASTGEN_MEMBERS_Continue; + string verilogKwd() const override { return "continue"; } + bool isBrancher() const override { return true; // SPECIAL: We don't process code after breaks } }; @@ -3072,39 +3060,36 @@ class AstCoverDecl final : public AstNodeStmt { // Parents: {statement list} // Children: none private: - AstCoverDecl* m_dataDeclp; // [After V3CoverageJoin] Pointer to duplicate declaration to get - // data from instead + AstCoverDecl* m_dataDeclp = nullptr; // [After V3CoverageJoin] Pointer to duplicate + // declaration to get data from instead string m_page; string m_text; string m_hier; string m_linescov; int m_offset; // Offset column numbers to uniq-ify IFs - int m_binNum; // Set by V3EmitCSyms to tell final V3Emit what to increment + int m_binNum = 0; // Set by V3EmitCSyms to tell final V3Emit what to increment public: AstCoverDecl(FileLine* fl, const string& page, const string& comment, const string& linescov, int offset) - : ASTGEN_SUPER_CoverDecl(fl) { - m_page = page; - m_text = comment; - m_linescov = linescov; - m_offset = offset; - m_binNum = 0; - m_dataDeclp = nullptr; - } - ASTNODE_NODE_FUNCS(CoverDecl) - virtual const char* broken() const override { + : ASTGEN_SUPER_CoverDecl(fl) + , m_page{page} + , m_text{comment} + , m_linescov{linescov} + , m_offset{offset} {} + ASTGEN_MEMBERS_CoverDecl; + const char* broken() const override { BROKEN_RTN(m_dataDeclp && !m_dataDeclp->brokeExists()); if (m_dataDeclp && m_dataDeclp->m_dataDeclp) { // Avoid O(n^2) accessing v3fatalSrc("dataDeclp should point to real data, not be a list"); } return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_dataDeclp && m_dataDeclp->clonep()) m_dataDeclp = m_dataDeclp->clonep(); } - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return 1 + 2 * INSTR_COUNT_LD; } - virtual bool maybePointedTo() const override { return true; } + void dump(std::ostream& str) const override; + int instrCount() const override { return 1 + 2 * INSTR_COUNT_LD; } + bool maybePointedTo() const override { return true; } void binNum(int flag) { m_binNum = flag; } int binNum() const { return m_binNum; } int offset() const { return m_offset; } @@ -3114,12 +3099,12 @@ public: const string& hier() const { return m_hier; } void hier(const string& flag) { m_hier = flag; } void comment(const string& flag) { m_text = flag; } - virtual bool same(const AstNode* samep) const override { + bool same(const AstNode* samep) const override { const AstCoverDecl* const asamep = static_cast(samep); return (fileline() == asamep->fileline() && linescov() == asamep->linescov() && hier() == asamep->hier() && comment() == asamep->comment()); } - virtual bool isPredictOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } void dataDeclp(AstCoverDecl* nodep) { m_dataDeclp = nodep; } // dataDecl nullptr means "use this one", but often you want "this" to // indicate to get data from here @@ -3136,22 +3121,22 @@ public: AstCoverInc(FileLine* fl, AstCoverDecl* declp) : ASTGEN_SUPER_CoverInc(fl) , m_declp{declp} {} - ASTNODE_NODE_FUNCS(CoverInc) - virtual const char* broken() const override { + ASTGEN_MEMBERS_CoverInc; + const char* broken() const override { BROKEN_RTN(!declp()->brokeExists()); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_declp->clonep()) m_declp = m_declp->clonep(); } - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return 1 + 2 * INSTR_COUNT_LD; } - virtual bool same(const AstNode* samep) const override { + void dump(std::ostream& str) const override; + int instrCount() const override { return 1 + 2 * INSTR_COUNT_LD; } + bool same(const AstNode* samep) const override { return declp() == static_cast(samep)->declp(); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isOutputter() const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isOutputter() const override { return true; } // but isPure() true AstCoverDecl* declp() const { return m_declp; } // Where defined }; @@ -3166,12 +3151,12 @@ public: setOp2p(origp); setOp3p(changep); } - ASTNODE_NODE_FUNCS(CoverToggle) - virtual int instrCount() const override { return 3 + INSTR_COUNT_BRANCH + INSTR_COUNT_LD; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return true; } - virtual bool isOutputter() const override { + ASTGEN_MEMBERS_CoverToggle; + int instrCount() const override { return 3 + INSTR_COUNT_BRANCH + INSTR_COUNT_LD; } + bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return true; } + bool isOutputter() const override { return false; // Though the AstCoverInc under this is an outputter } // but isPure() true @@ -3188,9 +3173,9 @@ public: setOp1p(lhsp); setNOp2p(stmtsp); } - ASTNODE_NODE_FUNCS(Delay) - virtual bool isTimingControl() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_Delay; + bool isTimingControl() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } // AstNode* lhsp() const { return op1p(); } // op1 = delay value void lhsp(AstNode* nodep) { setOp1p(nodep); } @@ -3204,10 +3189,10 @@ public: AstDisable(FileLine* fl, const string& name) : ASTGEN_SUPER_Disable(fl) , m_name{name} {} - ASTNODE_NODE_FUNCS(Disable) - virtual string name() const override { return m_name; } // * = Block name - virtual void name(const string& flag) override { m_name = flag; } - virtual bool isBrancher() const override { + ASTGEN_MEMBERS_Disable; + string name() const override { return m_name; } // * = Block name + void name(const string& flag) override { m_name = flag; } + bool isBrancher() const override { return true; // SPECIAL: We don't process code after breaks } }; @@ -3216,7 +3201,7 @@ class AstDisableFork final : public AstNodeStmt { public: explicit AstDisableFork(FileLine* fl) : ASTGEN_SUPER_DisableFork(fl) {} - ASTNODE_NODE_FUNCS(DisableFork) + ASTGEN_MEMBERS_DisableFork; }; class AstDisplay final : public AstNodeStmt { // Parents: stmtlist @@ -3228,39 +3213,37 @@ private: public: AstDisplay(FileLine* fl, VDisplayType dispType, const string& text, AstNode* filep, AstNode* exprsp, char missingArgChar = 'd') - : ASTGEN_SUPER_Display(fl) { - setOp1p(new AstSFormatF(fl, text, true, exprsp, missingArgChar)); + : ASTGEN_SUPER_Display(fl) + , m_displayType{dispType} { + setOp1p(new AstSFormatF{fl, text, true, exprsp, missingArgChar}); setNOp3p(filep); - m_displayType = dispType; } AstDisplay(FileLine* fl, VDisplayType dispType, AstNode* filep, AstNode* exprsp, char missingArgChar = 'd') - : ASTGEN_SUPER_Display(fl) { - setOp1p(new AstSFormatF(fl, AstSFormatF::NoFormat(), exprsp, missingArgChar)); + : ASTGEN_SUPER_Display(fl) + , m_displayType{dispType} { + setOp1p(new AstSFormatF{fl, AstSFormatF::NoFormat(), exprsp, missingArgChar}); setNOp3p(filep); - m_displayType = dispType; } - ASTNODE_NODE_FUNCS(Display) - virtual void dump(std::ostream& str) const override; - virtual const char* broken() const override { + ASTGEN_MEMBERS_Display; + void dump(std::ostream& str) const override; + const char* broken() const override { BROKEN_RTN(!fmtp()); return nullptr; } - virtual string verilogKwd() const override { + string verilogKwd() const override { return (filep() ? string("$f") + string(displayType().ascii()) : string("$") + string(displayType().ascii())); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: $display makes output - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* samep) const override { + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: $display makes output + bool isUnlikely() const override { return true; } + bool same(const AstNode* samep) const override { return displayType() == static_cast(samep)->displayType(); } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + int instrCount() const override { return INSTR_COUNT_PLI; } VDisplayType displayType() const { return m_displayType; } void displayType(VDisplayType type) { m_displayType = type; } // * = Add a newline for $display @@ -3281,13 +3264,13 @@ public: , m_ctlType{ctlType} { setNOp1p(exprp); } - ASTNODE_NODE_FUNCS(DumpCtl) - virtual string verilogKwd() const override { return ctlType().ascii(); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_DumpCtl; + string verilogKwd() const override { return ctlType().ascii(); } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isOutputter() const override { return true; } virtual bool cleanOut() const { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } VDumpCtlType ctlType() const { return m_ctlType; } AstNode* exprp() const { return op1p(); } // op2 = Expressions to output void exprp(AstNode* nodep) { setOp1p(nodep); } @@ -3301,10 +3284,10 @@ public: setNOp1p(sensesp); addNOp2p(stmtsp); } - ASTNODE_NODE_FUNCS(EventControl) - virtual string verilogKwd() const override { return "@(%l) %r"; } - virtual bool isTimingControl() const override { return true; } - virtual int instrCount() const override { return 0; } + ASTGEN_MEMBERS_EventControl; + string verilogKwd() const override { return "@(%l) %r"; } + bool isTimingControl() const override { return true; } + int instrCount() const override { return 0; } AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } AstNode* stmtsp() const { return op2p(); } void stmtsp(AstNode* stmtsp) { setNOp2p(stmtsp); } @@ -3317,14 +3300,14 @@ public: : ASTGEN_SUPER_FClose(fl) { setNOp2p(filep); } - ASTNODE_NODE_FUNCS(FClose) - virtual string verilogKwd() const override { return "$fclose"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FClose; + string verilogKwd() const override { return "$fclose"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op2p(); } void filep(AstNodeVarRef* nodep) { setNOp2p((AstNode*)nodep); } }; @@ -3336,14 +3319,14 @@ public: : ASTGEN_SUPER_FFlush(fl) { setNOp2p(filep); } - ASTNODE_NODE_FUNCS(FFlush) - virtual string verilogKwd() const override { return "$fflush"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FFlush; + string verilogKwd() const override { return "$fflush"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op2p(); } void filep(AstNodeVarRef* nodep) { setNOp2p((AstNode*)nodep); } }; @@ -3356,14 +3339,14 @@ public: setOp2p(filenamep); setOp3p(modep); } - ASTNODE_NODE_FUNCS(FOpen) - virtual string verilogKwd() const override { return "$fopen"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FOpen; + string verilogKwd() const override { return "$fopen"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op1p(); } AstNode* filenamep() const { return op2p(); } AstNode* modep() const { return op3p(); } @@ -3376,14 +3359,14 @@ public: setOp1p(filep); setOp2p(filenamep); } - ASTNODE_NODE_FUNCS(FOpenMcd) - virtual string verilogKwd() const override { return "$fopen"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_FOpenMcd; + string verilogKwd() const override { return "$fopen"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* filep() const { return op1p(); } AstNode* filenamep() const { return op2p(); } }; @@ -3391,18 +3374,14 @@ class AstFinish final : public AstNodeStmt { public: explicit AstFinish(FileLine* fl) : ASTGEN_SUPER_Finish(fl) {} - ASTNODE_NODE_FUNCS(Finish) - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: $display makes output - virtual bool isUnlikely() const override { return true; } - virtual int instrCount() const override { return 0; } // Rarely executes - virtual bool same(const AstNode* samep) const override { - return fileline() == samep->fileline(); - } + ASTGEN_MEMBERS_Finish; + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: $display makes output + bool isUnlikely() const override { return true; } + int instrCount() const override { return 0; } // Rarely executes + bool same(const AstNode* samep) const override { return fileline() == samep->fileline(); } }; class AstFireEvent final : public AstNodeStmt { // '-> _' and '->> _' event trigger statements @@ -3413,7 +3392,7 @@ public: , m_delayed{delayed} { setOp1p(operandp); } - ASTNODE_NODE_FUNCS(FireEvent); + ASTGEN_MEMBERS_FireEvent; AstNode* operandp() const { return op1p(); } bool isDelayed() const { return m_delayed; } }; @@ -3424,12 +3403,12 @@ public: setOp1p(arrayp); addNOp4p(bodysp); } - ASTNODE_NODE_FUNCS(Foreach) + ASTGEN_MEMBERS_Foreach; AstNode* arrayp() const { return op1p(); } // op1 = array and index vars AstNode* bodysp() const { return op4p(); } // op4 = body of loop - virtual bool isGateOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* /*samep*/) const override { return true; } bool isFirstInMyListOfStatements(AstNode* n) const override { return n == bodysp(); } }; class AstJumpBlock final : public AstNodeStmt { @@ -3445,12 +3424,12 @@ public: : ASTGEN_SUPER_JumpBlock(fl) { addNOp1p(stmtsp); } - virtual const char* broken() const override; - virtual void cloneRelink() override; - ASTNODE_NODE_FUNCS(JumpBlock) - virtual int instrCount() const override { return 0; } - virtual bool maybePointedTo() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + const char* broken() const override; + void cloneRelink() override; + ASTGEN_MEMBERS_JumpBlock; + int instrCount() const override { return 0; } + bool maybePointedTo() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } // op1 = Statements AstNode* stmtsp() const { return op1p(); } // op1 = List of statements void addStmtsp(AstNode* nodep) { addNOp1p(nodep); } @@ -3472,16 +3451,16 @@ public: AstJumpGo(FileLine* fl, AstJumpLabel* labelp) : ASTGEN_SUPER_JumpGo(fl) , m_labelp{labelp} {} - ASTNODE_NODE_FUNCS(JumpGo); + ASTGEN_MEMBERS_JumpGo; const char* broken() const override; void cloneRelink() override; - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* samep) const override { + void dump(std::ostream& str) const override; + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* samep) const override { return labelp() == static_cast(samep)->labelp(); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isBrancher() const override { + bool isGateOptimizable() const override { return false; } + bool isBrancher() const override { return true; // SPECIAL: We don't process code after breaks } AstJumpLabel* labelp() const { return m_labelp; } @@ -3496,19 +3475,19 @@ public: AstJumpLabel(FileLine* fl, AstJumpBlock* blockp) : ASTGEN_SUPER_JumpLabel(fl) , m_blockp{blockp} {} - ASTNODE_NODE_FUNCS(JumpLabel) - virtual bool maybePointedTo() const override { return true; } - virtual const char* broken() const override { + ASTGEN_MEMBERS_JumpLabel; + bool maybePointedTo() const override { return true; } + const char* broken() const override { BROKEN_RTN(!blockp()->brokeExistsAbove()); BROKEN_RTN(blockp()->labelp() != this); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_blockp->clonep()) m_blockp = m_blockp->clonep(); } - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return 0; } - virtual bool same(const AstNode* samep) const override { + void dump(std::ostream& str) const override; + int instrCount() const override { return 0; } + bool same(const AstNode* samep) const override { return blockp() == static_cast(samep)->blockp(); } AstJumpBlock* blockp() const { return m_blockp; } @@ -3520,16 +3499,14 @@ public: AstMonitorOff(FileLine* fl, bool off) : ASTGEN_SUPER_MonitorOff(fl) , m_off{off} {} - ASTNODE_NODE_FUNCS(MonitorOff) - virtual string verilogKwd() const override { return m_off ? "$monitoroff" : "$monitoron"; } - virtual bool isGateOptimizable() const override { return false; } // Though deleted before opt - virtual bool isPredictOptimizable() const override { - return false; - } // Though deleted before opt - virtual bool isPure() const override { return false; } // Though deleted before opt - virtual bool isOutputter() const override { return true; } // Though deleted before opt - virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_MonitorOff; + string verilogKwd() const override { return m_off ? "$monitoroff" : "$monitoron"; } + bool isGateOptimizable() const override { return false; } // Though deleted before opt + bool isPredictOptimizable() const override { return false; } // Though deleted before opt + bool isPure() const override { return false; } // Though deleted before opt + bool isOutputter() const override { return true; } // Though deleted before opt + int instrCount() const override { return INSTR_COUNT_PLI; } + bool same(const AstNode* samep) const override { return m_off == static_cast(samep)->m_off; } bool off() const { return m_off; } @@ -3541,16 +3518,16 @@ class AstPrintTimeScale final : public AstNodeStmt { public: explicit AstPrintTimeScale(FileLine* fl) : ASTGEN_SUPER_PrintTimeScale(fl) {} - ASTNODE_NODE_FUNCS(PrintTimeScale) - virtual void name(const string& name) override { m_name = name; } - virtual string name() const override { return m_name; } // * = Var name - virtual void dump(std::ostream& str) const override; - virtual string verilogKwd() const override { return "$printtimescale"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + ASTGEN_MEMBERS_PrintTimeScale; + void name(const string& name) override { m_name = name; } + string name() const override { return m_name; } // * = Var name + void dump(std::ostream& str) const override; + string verilogKwd() const override { return "$printtimescale"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + int instrCount() const override { return INSTR_COUNT_PLI; } void timeunit(const VTimescale& flag) { m_timeunit = flag; } VTimescale timeunit() const { return m_timeunit; } }; @@ -3561,7 +3538,7 @@ public: : ASTGEN_SUPER_Release(fl) { setOp1p(lhsp); } - ASTNODE_NODE_FUNCS(Release); + ASTGEN_MEMBERS_Release; AstNode* lhsp() const { return op1p(); } }; class AstRepeat final : public AstNodeStmt { @@ -3571,14 +3548,12 @@ public: setOp2p(countp); addNOp3p(bodysp); } - ASTNODE_NODE_FUNCS(Repeat) + ASTGEN_MEMBERS_Repeat; AstNode* countp() const { return op2p(); } // op2 = condition to continue AstNode* bodysp() const { return op3p(); } // op3 = body of loop - virtual bool isGateOptimizable() const override { - return false; - } // Not relevant - converted to FOR - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } // Not relevant - converted to FOR + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* /*samep*/) const override { return true; } bool isFirstInMyListOfStatements(AstNode* n) const override { return n == bodysp(); } }; class AstReturn final : public AstNodeStmt { @@ -3587,10 +3562,10 @@ public: : ASTGEN_SUPER_Return(fl) { setNOp1p(lhsp); } - ASTNODE_NODE_FUNCS(Return) - virtual string verilogKwd() const override { return "return"; } + ASTGEN_MEMBERS_Return; + string verilogKwd() const override { return "return"; } AstNode* lhsp() const { return op1p(); } - virtual bool isBrancher() const override { + bool isBrancher() const override { return true; // SPECIAL: We don't process code after breaks } }; @@ -3610,19 +3585,19 @@ public: setOp1p(new AstSFormatF(fl, AstSFormatF::NoFormat(), exprsp, missingArgChar)); setOp3p(lhsp); } - ASTNODE_NODE_FUNCS(SFormat) - virtual const char* broken() const override { + ASTGEN_MEMBERS_SFormat; + const char* broken() const override { BROKEN_RTN(!fmtp()); return nullptr; } - virtual string verilogKwd() const override { return "$sformat"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return true; } - virtual bool isPure() const override { return true; } - virtual bool isOutputter() const override { return false; } + string verilogKwd() const override { return "$sformat"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return true; } + bool isPure() const override { return true; } + bool isOutputter() const override { return false; } virtual bool cleanOut() const { return false; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + int instrCount() const override { return INSTR_COUNT_PLI; } + bool same(const AstNode* /*samep*/) const override { return true; } void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); } AstNode* lhsp() const { return op3p(); } @@ -3632,18 +3607,14 @@ class AstStop final : public AstNodeStmt { public: AstStop(FileLine* fl, bool maybe) : ASTGEN_SUPER_Stop(fl) {} - ASTNODE_NODE_FUNCS(Stop) - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { - return false; - } // SPECIAL: $display has 'visual' ordering - virtual bool isOutputter() const override { return true; } // SPECIAL: $display makes output - virtual bool isUnlikely() const override { return true; } - virtual int instrCount() const override { return 0; } // Rarely executes - virtual bool same(const AstNode* samep) const override { - return fileline() == samep->fileline(); - } + ASTGEN_MEMBERS_Stop; + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } // SPECIAL: $display has 'visual' ordering + bool isOutputter() const override { return true; } // SPECIAL: $display makes output + bool isUnlikely() const override { return true; } + int instrCount() const override { return 0; } // Rarely executes + bool same(const AstNode* samep) const override { return fileline() == samep->fileline(); } }; class AstSysFuncAsTask final : public AstNodeStmt { // Call what is normally a system function (with a return) in a non-return context @@ -3654,14 +3625,14 @@ public: : ASTGEN_SUPER_SysFuncAsTask(fl) { addNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(SysFuncAsTask) - virtual string verilogKwd() const override { return ""; } - virtual bool isGateOptimizable() const override { return true; } - virtual bool isPredictOptimizable() const override { return true; } - virtual bool isPure() const override { return true; } - virtual bool isOutputter() const override { return false; } - virtual int instrCount() const override { return 0; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_SysFuncAsTask; + string verilogKwd() const override { return ""; } + bool isGateOptimizable() const override { return true; } + bool isPredictOptimizable() const override { return true; } + bool isPure() const override { return true; } + bool isOutputter() const override { return false; } + int instrCount() const override { return 0; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* lhsp() const { return op1p(); } // op1 = Expressions to eval void lhsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to eval }; @@ -3673,15 +3644,13 @@ public: : ASTGEN_SUPER_SysIgnore(fl) { addNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(SysIgnore) - virtual string verilogKwd() const override { return "$ignored"; } - virtual bool isGateOptimizable() const override { return false; } // Though deleted before opt - virtual bool isPredictOptimizable() const override { - return false; - } // Though deleted before opt - virtual bool isPure() const override { return false; } // Though deleted before opt - virtual bool isOutputter() const override { return true; } // Though deleted before opt - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + ASTGEN_MEMBERS_SysIgnore; + string verilogKwd() const override { return "$ignored"; } + bool isGateOptimizable() const override { return false; } // Though deleted before opt + bool isPredictOptimizable() const override { return false; } // Though deleted before opt + bool isPure() const override { return false; } // Though deleted before opt + bool isOutputter() const override { return true; } // Though deleted before opt + int instrCount() const override { return INSTR_COUNT_PLI; } AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output void exprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output }; @@ -3692,14 +3661,14 @@ public: : ASTGEN_SUPER_SystemT(fl) { setOp1p(lhsp); } - ASTNODE_NODE_FUNCS(SystemT) - virtual string verilogKwd() const override { return "$system"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool isUnlikely() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_SystemT; + string verilogKwd() const override { return "$system"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool isUnlikely() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } AstNode* lhsp() const { return op1p(); } }; class AstTimeFormat final : public AstNodeStmt { @@ -3713,13 +3682,13 @@ public: setOp3p(suffixp); setOp4p(widthp); } - ASTNODE_NODE_FUNCS(TimeFormat) - virtual string verilogKwd() const override { return "$timeformat"; } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual int instrCount() const override { return INSTR_COUNT_PLI; } + ASTGEN_MEMBERS_TimeFormat; + string verilogKwd() const override { return "$timeformat"; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + int instrCount() const override { return INSTR_COUNT_PLI; } AstNode* unitsp() const { return op1p(); } AstNode* precisionp() const { return op2p(); } AstNode* suffixp() const { return op3p(); } @@ -3756,13 +3725,13 @@ public: dtypeFrom(valuep); addNOp1p(valuep); } - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return 100; } // Large... - ASTNODE_NODE_FUNCS(TraceDecl) - virtual string name() const override { return m_showname; } - virtual bool maybePointedTo() const override { return true; } - virtual bool hasDType() const override { return true; } - virtual bool same(const AstNode* samep) const override { return false; } + void dump(std::ostream& str) const override; + int instrCount() const override { return 100; } // Large... + ASTGEN_MEMBERS_TraceDecl; + string name() const override { return m_showname; } + bool maybePointedTo() const override { return true; } + bool hasDType() const override { return true; } + bool same(const AstNode* samep) const override { return false; } string showname() const { return m_showname; } // * = Var name // Details on what we're tracing uint32_t code() const { return m_code; } @@ -3795,23 +3764,23 @@ public: dtypeFrom(declp); addOp2p(declp->valuep()->cloneTree(true)); } - ASTNODE_NODE_FUNCS(TraceInc) - virtual const char* broken() const override { + ASTGEN_MEMBERS_TraceInc; + const char* broken() const override { BROKEN_RTN(!declp()->brokeExists()); return nullptr; } - virtual void cloneRelink() override { + void cloneRelink() override { if (m_declp->clonep()) m_declp = m_declp->clonep(); } - virtual void dump(std::ostream& str) const override; - virtual int instrCount() const override { return 10 + 2 * INSTR_COUNT_LD; } - virtual bool hasDType() const override { return true; } - virtual bool same(const AstNode* samep) const override { + void dump(std::ostream& str) const override; + int instrCount() const override { return 10 + 2 * INSTR_COUNT_LD; } + bool hasDType() const override { return true; } + bool same(const AstNode* samep) const override { return declp() == static_cast(samep)->declp(); } - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isOutputter() const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isOutputter() const override { return true; } // but isPure() true // op1 = Statements before the value AstNode* precondsp() const { return op1p(); } @@ -3827,8 +3796,8 @@ public: AstTracePopNamePrefix(FileLine* fl, unsigned count) : ASTGEN_SUPER_TracePopNamePrefix(fl) , m_count{count} {} - ASTNODE_NODE_FUNCS(TracePopNamePrefix) - virtual bool same(const AstNode* samep) const override { return false; } + ASTGEN_MEMBERS_TracePopNamePrefix; + bool same(const AstNode* samep) const override { return false; } unsigned count() const { return m_count; } }; class AstTracePushNamePrefix final : public AstNodeStmt { @@ -3837,8 +3806,8 @@ public: AstTracePushNamePrefix(FileLine* fl, const string& prefix) : ASTGEN_SUPER_TracePushNamePrefix(fl) , m_prefix{prefix} {} - ASTNODE_NODE_FUNCS(TracePushNamePrefix) - virtual bool same(const AstNode* samep) const override { return false; } + ASTGEN_MEMBERS_TracePushNamePrefix; + bool same(const AstNode* samep) const override { return false; } string prefix() const { return m_prefix; } }; class AstUCStmt final : public AstNodeStmt { @@ -3848,13 +3817,13 @@ public: : ASTGEN_SUPER_UCStmt(fl) { addNOp1p(exprsp); } - ASTNODE_NODE_FUNCS(UCStmt) + ASTGEN_MEMBERS_UCStmt; AstNode* bodysp() const { return op1p(); } // op1 = expressions to print - virtual bool isGateOptimizable() const override { return false; } - virtual bool isPredictOptimizable() const override { return false; } - virtual bool isPure() const override { return false; } - virtual bool isOutputter() const override { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + bool isPredictOptimizable() const override { return false; } + bool isPure() const override { return false; } + bool isOutputter() const override { return true; } + bool same(const AstNode* /*samep*/) const override { return true; } }; class AstWait final : public AstNodeStmt { public: @@ -3863,18 +3832,18 @@ public: setOp2p(condp); addNOp3p(bodysp); } - ASTNODE_NODE_FUNCS(Wait) + ASTGEN_MEMBERS_Wait; AstNode* condp() const { return op2p(); } // op2 = condition AstNode* bodysp() const { return op3p(); } // op3 = statements after wait bool isFirstInMyListOfStatements(AstNode* n) const override { return n == bodysp(); } - virtual bool isTimingControl() const override { return true; } + bool isTimingControl() const override { return true; } }; class AstWaitFork final : public AstNodeStmt { // A "wait fork" statement public: explicit AstWaitFork(FileLine* fl) : ASTGEN_SUPER_WaitFork(fl) {} - ASTNODE_NODE_FUNCS(WaitFork) + ASTGEN_MEMBERS_WaitFork; }; class AstWhile final : public AstNodeStmt { public: @@ -3884,7 +3853,7 @@ public: addNOp3p(bodysp); addNOp4p(incsp); } - ASTNODE_NODE_FUNCS(While) + ASTGEN_MEMBERS_While; // op1 = prepare statements for condition (exec every loop) AstNode* precondsp() const { return op1p(); } AstNode* condp() const { return op2p(); } // op2 = condition to continue @@ -3893,13 +3862,13 @@ public: void addPrecondsp(AstNode* newp) { addOp1p(newp); } void addBodysp(AstNode* newp) { addOp3p(newp); } void addIncsp(AstNode* newp) { addOp4p(newp); } - virtual bool isGateOptimizable() const override { return false; } - virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } + bool isGateOptimizable() const override { return false; } + int instrCount() const override { return INSTR_COUNT_BRANCH; } + bool same(const AstNode* /*samep*/) const override { return true; } // Stop statement searchback here - virtual void addBeforeStmt(AstNode* newp, AstNode* belowp) override; + void addBeforeStmt(AstNode* newp, AstNode* belowp) override; // Stop statement searchback here - virtual void addNextStmt(AstNode* newp, AstNode* belowp) override; + void addNextStmt(AstNode* newp, AstNode* belowp) override; bool isFirstInMyListOfStatements(AstNode* n) const override { return n == bodysp(); } }; class AstWith final : public AstNodeStmt { @@ -3917,10 +3886,10 @@ public: addOp2p((AstNode*)valueArgRefp); addNOp3p(exprp); } - ASTNODE_NODE_FUNCS(With) - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual bool hasDType() const override { return true; } - virtual const char* broken() const override { + ASTGEN_MEMBERS_With; + bool same(const AstNode* /*samep*/) const override { return true; } + bool hasDType() const override { return true; } + const char* broken() const override { BROKEN_RTN(!indexArgRefp()); // varp needed to know lambda's arg dtype BROKEN_RTN(!valueArgRefp()); // varp needed to know lambda's arg dtype return nullptr; @@ -3942,8 +3911,8 @@ public: setOp1p(funcrefp); addNOp2p(exprp); } - ASTNODE_NODE_FUNCS(WithParse) - virtual bool same(const AstNode* /*samep*/) const override { return true; } + ASTGEN_MEMBERS_WithParse; + bool same(const AstNode* /*samep*/) const override { return true; } // AstNode* funcrefp() const { return op1p(); } AstNode* exprp() const { return op2p(); } @@ -3956,12 +3925,12 @@ public: : ASTGEN_SUPER_Assign(fl, lhsp, rhsp, timingControlp) { dtypeFrom(lhsp); } - ASTNODE_NODE_FUNCS(Assign) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_Assign; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { AstNode* const controlp = timingControlp() ? timingControlp()->cloneTree(false) : nullptr; return new AstAssign(this->fileline(), lhsp, rhsp, controlp); } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool brokeLhsMustBeLvalue() const override { return true; } }; class AstAssignAlias final : public AstNodeAssign { // Like AstAssignW, but a true bidirect interconnection alias @@ -3969,57 +3938,55 @@ class AstAssignAlias final : public AstNodeAssign { public: AstAssignAlias(FileLine* fl, AstVarRef* lhsp, AstVarRef* rhsp) : ASTGEN_SUPER_AssignAlias(fl, (AstNode*)lhsp, (AstNode*)rhsp) {} - ASTNODE_NODE_FUNCS(AssignAlias) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { - V3ERROR_NA_RETURN(nullptr); - } - virtual bool brokeLhsMustBeLvalue() const override { return false; } + ASTGEN_MEMBERS_AssignAlias; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { V3ERROR_NA_RETURN(nullptr); } + bool brokeLhsMustBeLvalue() const override { return false; } }; class AstAssignDly final : public AstNodeAssign { public: AstAssignDly(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* timingControlp = nullptr) : ASTGEN_SUPER_AssignDly(fl, lhsp, rhsp, timingControlp) {} - ASTNODE_NODE_FUNCS(AssignDly) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssignDly; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { AstNode* const controlp = timingControlp() ? timingControlp()->cloneTree(false) : nullptr; return new AstAssignDly(this->fileline(), lhsp, rhsp, controlp); } - virtual bool isGateOptimizable() const override { return false; } - virtual string verilogKwd() const override { return "<="; } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool isGateOptimizable() const override { return false; } + string verilogKwd() const override { return "<="; } + bool brokeLhsMustBeLvalue() const override { return true; } }; class AstAssignForce final : public AstNodeAssign { // Procedural 'force' statement public: AstAssignForce(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_AssignForce(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(AssignForce) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssignForce; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAssignForce{this->fileline(), lhsp, rhsp}; } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool brokeLhsMustBeLvalue() const override { return true; } }; class AstAssignPost final : public AstNodeAssign { // Like Assign, but predelayed assignment requiring special order handling public: AstAssignPost(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_AssignPost(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(AssignPost) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssignPost; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAssignPost(this->fileline(), lhsp, rhsp); } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool brokeLhsMustBeLvalue() const override { return true; } }; class AstAssignPre final : public AstNodeAssign { // Like Assign, but predelayed assignment requiring special order handling public: AstAssignPre(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_AssignPre(fl, lhsp, rhsp) {} - ASTNODE_NODE_FUNCS(AssignPre) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssignPre; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAssignPre(this->fileline(), lhsp, rhsp); } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool brokeLhsMustBeLvalue() const override { return true; } }; class AstAssignVarScope final : public AstNodeAssign { // Assign two VarScopes to each other @@ -4028,25 +3995,25 @@ public: : ASTGEN_SUPER_AssignVarScope(fl, lhsp, rhsp) { dtypeFrom(rhsp); } - ASTNODE_NODE_FUNCS(AssignVarScope) - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + ASTGEN_MEMBERS_AssignVarScope; + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstAssignVarScope(this->fileline(), lhsp, rhsp); } - virtual bool brokeLhsMustBeLvalue() const override { return false; } + bool brokeLhsMustBeLvalue() const override { return false; } }; class AstAssignW final : public AstNodeAssign { // Like assign, but wire/assign's in verilog, the only setting of the specified variable public: AstAssignW(FileLine* fl, AstNode* lhsp, AstNode* rhsp, AstNode* timingControlp = nullptr) : ASTGEN_SUPER_AssignW(fl, lhsp, rhsp, timingControlp) {} - ASTNODE_NODE_FUNCS(AssignW) + ASTGEN_MEMBERS_AssignW; AstStrengthSpec* strengthSpecp() const { return VN_AS(op4p(), StrengthSpec); } void strengthSpecp(AstStrengthSpec* const strengthSpecp) { setOp4p((AstNode*)strengthSpecp); } - virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { + AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { AstNode* const controlp = timingControlp() ? timingControlp()->cloneTree(false) : nullptr; return new AstAssignW(this->fileline(), lhsp, rhsp, controlp); } - virtual bool brokeLhsMustBeLvalue() const override { return true; } + bool brokeLhsMustBeLvalue() const override { return true; } AstAlways* convertToAlways(); }; @@ -4061,7 +4028,7 @@ class AstCCall final : public AstNodeCCall { public: AstCCall(FileLine* fl, AstCFunc* funcp, AstNode* argsp = nullptr) : ASTGEN_SUPER_CCall(fl, funcp, argsp) {} - ASTNODE_NODE_FUNCS(CCall) + ASTGEN_MEMBERS_CCall; string selfPointer() const { return m_selfPointer; } void selfPointer(const string& value) { m_selfPointer = value; } @@ -4076,8 +4043,8 @@ public: : ASTGEN_SUPER_CMethodCall(fl, funcp, argsp) { setOp1p(fromp); } - ASTNODE_NODE_FUNCS(CMethodCall) - virtual const char* broken() const override { + ASTGEN_MEMBERS_CMethodCall; + const char* broken() const override { BROKEN_BASE_RTN(AstNodeCCall::broken()); BROKEN_RTN(!fromp()); return nullptr; @@ -4096,8 +4063,8 @@ public: : ASTGEN_SUPER_CNew(fl, funcp, argsp) { statement(false); } - virtual bool hasDType() const override { return true; } - ASTNODE_NODE_FUNCS(CNew) + bool hasDType() const override { return true; } + ASTGEN_MEMBERS_CNew; }; // === AstNodeCase === @@ -4117,11 +4084,9 @@ public: AstCase(FileLine* fl, VCaseType casex, AstNode* exprp, AstNode* casesp) : ASTGEN_SUPER_Case(fl, exprp, casesp) , m_casex{casex} {} - ASTNODE_NODE_FUNCS(Case) - virtual string verilogKwd() const override { - return casez() ? "casez" : casex() ? "casex" : "case"; - } - virtual bool same(const AstNode* samep) const override { + ASTGEN_MEMBERS_Case; + string verilogKwd() const override { return casez() ? "casez" : casex() ? "casex" : "case"; } + bool same(const AstNode* samep) const override { return m_casex == static_cast(samep)->m_casex; } bool casex() const { return m_casex == VCaseType::CT_CASEX; } @@ -4148,13 +4113,13 @@ class AstGenCase final : public AstNodeCase { public: AstGenCase(FileLine* fl, AstNode* exprp, AstNode* casesp) : ASTGEN_SUPER_GenCase(fl, exprp, casesp) {} - ASTNODE_NODE_FUNCS(GenCase) + ASTGEN_MEMBERS_GenCase; }; // === AstNodeCoverOrAssert === class AstAssert final : public AstNodeCoverOrAssert { public: - ASTNODE_NODE_FUNCS(Assert) + ASTGEN_MEMBERS_Assert; AstAssert(FileLine* fl, AstNode* propp, AstNode* passsp, AstNode* failsp, bool immediate, const string& name = "") : ASTGEN_SUPER_Assert(fl, propp, passsp, immediate, name) { @@ -4165,7 +4130,7 @@ public: class AstAssertIntrinsic final : public AstNodeCoverOrAssert { // A $cast or other compiler inserted assert, that must run even without --assert option public: - ASTNODE_NODE_FUNCS(AssertIntrinsic) + ASTGEN_MEMBERS_AssertIntrinsic; AstAssertIntrinsic(FileLine* fl, AstNode* propp, AstNode* passsp, AstNode* failsp, bool immediate, const string& name = "") : ASTGEN_SUPER_AssertIntrinsic(fl, propp, passsp, immediate, name) { @@ -4175,7 +4140,7 @@ public: }; class AstCover final : public AstNodeCoverOrAssert { public: - ASTNODE_NODE_FUNCS(Cover) + ASTGEN_MEMBERS_Cover; AstCover(FileLine* fl, AstNode* propp, AstNode* stmtsp, bool immediate, const string& name = "") : ASTGEN_SUPER_Cover(fl, propp, stmtsp, immediate, name) {} @@ -4185,7 +4150,7 @@ public: }; class AstRestrict final : public AstNodeCoverOrAssert { public: - ASTNODE_NODE_FUNCS(Restrict) + ASTGEN_MEMBERS_Restrict; AstRestrict(FileLine* fl, AstNode* propp) : ASTGEN_SUPER_Restrict(fl, propp, nullptr, false, "") {} }; @@ -4198,8 +4163,8 @@ public: : ASTGEN_SUPER_FuncRef(fl, false, namep, pinsp) {} AstFuncRef(FileLine* fl, const string& name, AstNode* pinsp) : ASTGEN_SUPER_FuncRef(fl, false, name, pinsp) {} - ASTNODE_NODE_FUNCS(FuncRef) - virtual bool hasDType() const override { return true; } + ASTGEN_MEMBERS_FuncRef; + bool hasDType() const override { return true; } }; class AstMethodCall final : public AstNodeFTaskRef { // A reference to a member task (or function) @@ -4217,14 +4182,14 @@ public: : ASTGEN_SUPER_MethodCall(fl, false, name, pinsp) { setOp2p(fromp); } - ASTNODE_NODE_FUNCS(MethodCall) - virtual const char* broken() const override { + ASTGEN_MEMBERS_MethodCall; + const char* broken() const override { BROKEN_BASE_RTN(AstNodeFTaskRef::broken()); BROKEN_RTN(!fromp()); return nullptr; } - virtual void dump(std::ostream& str) const override; - virtual bool hasDType() const override { return true; } + void dump(std::ostream& str) const override; + bool hasDType() const override { return true; } void makeStatement() { statement(true); dtypeSetVoid(); @@ -4242,11 +4207,11 @@ class AstNew final : public AstNodeFTaskRef { public: AstNew(FileLine* fl, AstNode* pinsp) : ASTGEN_SUPER_New(fl, false, "new", pinsp) {} - ASTNODE_NODE_FUNCS(New) + ASTGEN_MEMBERS_New; virtual bool cleanOut() const { return true; } - virtual bool same(const AstNode* /*samep*/) const override { return true; } - virtual bool hasDType() const override { return true; } - virtual int instrCount() const override { return widthInstrs(); } + bool same(const AstNode* /*samep*/) const override { return true; } + bool hasDType() const override { return true; } + int instrCount() const override { return widthInstrs(); } }; class AstTaskRef final : public AstNodeFTaskRef { // A reference to a task @@ -4257,7 +4222,7 @@ public: } AstTaskRef(FileLine* fl, const string& name, AstNode* pinsp) : ASTGEN_SUPER_TaskRef(fl, true, name, pinsp) {} - ASTNODE_NODE_FUNCS(TaskRef) + ASTGEN_MEMBERS_TaskRef; }; // === AstNodeFor === @@ -4265,7 +4230,7 @@ class AstGenFor final : public AstNodeFor { public: AstGenFor(FileLine* fl, AstNode* initsp, AstNode* condp, AstNode* incsp, AstNode* bodysp) : ASTGEN_SUPER_GenFor(fl, initsp, condp, incsp, bodysp) {} - ASTNODE_NODE_FUNCS(GenFor) + ASTGEN_MEMBERS_GenFor; }; // === AstNodeIf === @@ -4273,21 +4238,17 @@ class AstGenIf final : public AstNodeIf { public: AstGenIf(FileLine* fl, AstNode* condp, AstNode* ifsp, AstNode* elsesp) : ASTGEN_SUPER_GenIf(fl, condp, ifsp, elsesp) {} - ASTNODE_NODE_FUNCS(GenIf) + ASTGEN_MEMBERS_GenIf; }; class AstIf final : public AstNodeIf { private: - bool m_uniquePragma; // unique case - bool m_unique0Pragma; // unique0 case - bool m_priorityPragma; // priority case + bool m_uniquePragma = false; // unique case + bool m_unique0Pragma = false; // unique0 case + bool m_priorityPragma = false; // priority case public: AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp = nullptr, AstNode* elsesp = nullptr) - : ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) { - m_uniquePragma = false; - m_unique0Pragma = false; - m_priorityPragma = false; - } - ASTNODE_NODE_FUNCS(If) + : ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) {} + ASTGEN_MEMBERS_If; bool uniquePragma() const { return m_uniquePragma; } void uniquePragma(bool flag) { m_uniquePragma = flag; } bool unique0Pragma() const { return m_unique0Pragma; } @@ -4302,18 +4263,18 @@ public: AstReadMem(FileLine* fl, bool hex, AstNode* filenamep, AstNode* memp, AstNode* lsbp, AstNode* msbp) : ASTGEN_SUPER_ReadMem(fl, hex, filenamep, memp, lsbp, msbp) {} - ASTNODE_NODE_FUNCS(ReadMem); - virtual string verilogKwd() const override { return (isHex() ? "$readmemh" : "$readmemb"); } - virtual const char* cFuncPrefixp() const override { return "VL_READMEM_"; } + ASTGEN_MEMBERS_ReadMem; + string verilogKwd() const override { return (isHex() ? "$readmemh" : "$readmemb"); } + const char* cFuncPrefixp() const override { return "VL_READMEM_"; } }; class AstWriteMem final : public AstNodeReadWriteMem { public: AstWriteMem(FileLine* fl, bool hex, AstNode* filenamep, AstNode* memp, AstNode* lsbp, AstNode* msbp) : ASTGEN_SUPER_WriteMem(fl, hex, filenamep, memp, lsbp, msbp) {} - ASTNODE_NODE_FUNCS(WriteMem) - virtual string verilogKwd() const override { return (isHex() ? "$writememh" : "$writememb"); } - virtual const char* cFuncPrefixp() const override { return "VL_WRITEMEM_"; } + ASTGEN_MEMBERS_WriteMem; + string verilogKwd() const override { return (isHex() ? "$writememh" : "$writememb"); } + const char* cFuncPrefixp() const override { return "VL_WRITEMEM_"; } }; // === AstNodeText === @@ -4321,49 +4282,49 @@ class AstScCtor final : public AstNodeText { public: AstScCtor(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScCtor(fl, textp) {} - ASTNODE_NODE_FUNCS(ScCtor) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScCtor; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; class AstScDtor final : public AstNodeText { public: AstScDtor(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScDtor(fl, textp) {} - ASTNODE_NODE_FUNCS(ScDtor) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScDtor; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; class AstScHdr final : public AstNodeText { public: AstScHdr(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScHdr(fl, textp) {} - ASTNODE_NODE_FUNCS(ScHdr) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScHdr; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; class AstScImp final : public AstNodeText { public: AstScImp(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScImp(fl, textp) {} - ASTNODE_NODE_FUNCS(ScImp) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScImp; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; class AstScImpHdr final : public AstNodeText { public: AstScImpHdr(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScImpHdr(fl, textp) {} - ASTNODE_NODE_FUNCS(ScImpHdr) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScImpHdr; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; class AstScInt final : public AstNodeText { public: AstScInt(FileLine* fl, const string& textp) : ASTGEN_SUPER_ScInt(fl, textp) {} - ASTNODE_NODE_FUNCS(ScInt) - virtual bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs - virtual bool isOutputter() const override { return true; } + ASTGEN_MEMBERS_ScInt; + bool isPure() const override { return false; } // SPECIAL: User may order w/other sigs + bool isOutputter() const override { return true; } }; // === AstNodeSimpleText === @@ -4371,7 +4332,7 @@ class AstText final : public AstNodeSimpleText { public: AstText(FileLine* fl, const string& textp, bool tracking = false) : ASTGEN_SUPER_Text(fl, textp, tracking) {} - ASTNODE_NODE_FUNCS(Text) + ASTGEN_MEMBERS_Text; }; class AstTextBlock final : public AstNodeSimpleText { private: @@ -4381,7 +4342,7 @@ public: bool commas = false) : ASTGEN_SUPER_TextBlock(fl, textp, tracking) , m_commas(commas) {} - ASTNODE_NODE_FUNCS(TextBlock) + ASTGEN_MEMBERS_TextBlock; void commas(bool flag) { m_commas = flag; } bool commas() const { return m_commas; } AstNode* nodesp() const { return op1p(); } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index c4d6cb654..cb3ccca4e 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -26,7 +26,7 @@ #include "V3PartitionGraph.h" // Just for mtask dumping #include "V3String.h" -#include "V3AstNodes__gen_macros.h" // Generated by 'astgen' +#include "V3Ast__gen_macros.h" // Generated by 'astgen' #include #include @@ -564,11 +564,11 @@ string AstVar::dpiArgType(bool named, bool forReturn) const { return dpiTypesToStringConverter{}.convert(this); } else { class converter final : public dpiTypesToStringConverter { - virtual string bitLogicVector(const AstVar* varp, bool isBit) const override { + string bitLogicVector(const AstVar* varp, bool isBit) const override { return string(varp->isReadOnly() ? "const " : "") + dpiTypesToStringConverter::bitLogicVector(varp, isBit) + '*'; } - virtual string primitive(const AstVar* varp) const override { + string primitive(const AstVar* varp) const override { string type = dpiTypesToStringConverter::primitive(varp); if (varp->isWritable() || VN_IS(varp->dtypep()->skipRefp(), UnpackArrayDType)) { if (!varp->isWritable() && varp->basicp()->keyword() != VBasicDTypeKwd::STRING) @@ -600,16 +600,16 @@ string AstVar::dpiTmpVarType(const string& varName) const { return ""; } } - virtual string openArray(const AstVar* varp) const override { + string openArray(const AstVar* varp) const override { return dpiTypesToStringConverter::openArray(varp) + ' ' + m_name + arraySuffix(varp, 0); } - virtual string bitLogicVector(const AstVar* varp, bool isBit) const override { + string bitLogicVector(const AstVar* varp, bool isBit) const override { string type = dpiTypesToStringConverter::bitLogicVector(varp, isBit); type += ' ' + m_name + arraySuffix(varp, varp->widthWords()); return type; } - virtual string primitive(const AstVar* varp) const override { + string primitive(const AstVar* varp) const override { string type = dpiTypesToStringConverter::primitive(varp); if (varp->isWritable() || VN_IS(varp->dtypep()->skipRefp(), UnpackArrayDType)) { if (!varp->isWritable() && varp->basicp()->keyword() == VBasicDTypeKwd::CHANDLE) @@ -683,6 +683,8 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) { return nullptr; } +bool AstNodeDType::isFourstate() const { return basicp()->isFourstate(); } + class AstNodeDType::CTypeRecursed final { public: string m_type; // The base type, e.g.: "Foo_t"s @@ -1540,6 +1542,11 @@ void AstIfaceRefDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); str << "iface"; } +void AstIfaceRefDType::cloneRelink() { + if (m_cellp && m_cellp->clonep()) m_cellp = m_cellp->clonep(); + if (m_ifacep && m_ifacep->clonep()) m_ifacep = m_ifacep->clonep(); + if (m_modportp && m_modportp->clonep()) m_modportp = m_modportp->clonep(); +} void AstInitArray::dump(std::ostream& str) const { this->AstNode::dump(str); int n = 0; @@ -1923,7 +1930,7 @@ void AstTypeTable::dump(std::ostream& str) const { for (int i = 0; i < static_cast(VBasicDTypeKwd::_ENUM_MAX); ++i) { if (AstBasicDType* const subnodep = m_basicps[i]) { str << '\n'; // Newline from caller, so newline first - str << "\t\t" << std::setw(8) << VBasicDTypeKwd(i).ascii(); + str << "\t\t" << std::setw(8) << VBasicDTypeKwd{i}.ascii(); str << " -> "; subnodep->dump(str); } diff --git a/src/V3AstUserAllocator.h b/src/V3AstUserAllocator.h index 76ec4fc5d..1a7f55a46 100644 --- a/src/V3AstUserAllocator.h +++ b/src/V3AstUserAllocator.h @@ -35,7 +35,7 @@ class AstUserAllocatorBase VL_NOT_FINAL { private: std::vector m_allocated; - inline T_Data* getUserp(const T_Node* nodep) const { + T_Data* getUserp(const T_Node* nodep) const { if VL_CONSTEXPR_CXX17 (T_UserN == 1) { const VNUser user = nodep->user1u(); return user.to(); @@ -54,17 +54,17 @@ private: } } - inline void setUserp(T_Node* nodep, T_Data* userp) const { + void setUserp(T_Node* nodep, T_Data* userp) const { if VL_CONSTEXPR_CXX17 (T_UserN == 1) { - nodep->user1u(VNUser(userp)); + nodep->user1u(VNUser{userp}); } else if VL_CONSTEXPR_CXX17 (T_UserN == 2) { - nodep->user2u(VNUser(userp)); + nodep->user2u(VNUser{userp}); } else if VL_CONSTEXPR_CXX17 (T_UserN == 3) { - nodep->user3u(VNUser(userp)); + nodep->user3u(VNUser{userp}); } else if VL_CONSTEXPR_CXX17 (T_UserN == 4) { - nodep->user4u(VNUser(userp)); + nodep->user4u(VNUser{userp}); } else { - nodep->user5u(VNUser(userp)); + nodep->user5u(VNUser{userp}); } } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 4bdc05cb4..6370c2435 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -121,20 +121,20 @@ private: } // VISITORS - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { VL_RESTORER(m_underFork); m_underFork = true; dotNames(nodep, "__FORK__"); nodep->name(""); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; iterateChildren(nodep); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { UINFO(8, " " << nodep << endl); // Rename it if (m_unnamedScope != "") { @@ -169,7 +169,7 @@ private: m_ftaskp = nullptr; } } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { // Begin blocks were only useful in variable creation, change names and delete UINFO(8, " " << nodep << endl); VL_RESTORER(m_displayScope); @@ -206,7 +206,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (m_unnamedScope != "") { // Rename it nodep->name(dot(m_unnamedScope, nodep->name())); @@ -215,7 +215,7 @@ private: liftNode(nodep); } } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { if (m_unnamedScope != "") { // Rename it nodep->name(dot(m_unnamedScope, nodep->name())); @@ -224,7 +224,7 @@ private: liftNode(nodep); } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { UINFO(8, " CELL " << nodep << endl); if (m_namedScope != "") { m_statep->userMarkChanged(nodep); @@ -237,14 +237,14 @@ private: } iterateChildren(nodep); } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { UINFO(9, " VARXREF " << nodep << endl); if (m_namedScope != "" && nodep->inlinedDots() == "" && !m_ftaskp) { nodep->inlinedDots(m_namedScope); UINFO(9, " rescope to " << nodep << endl); } } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { // If there's a %m in the display text, we add a special node that will contain the name() // Similar code in V3Inline if (nodep->user1SetOnce()) return; // Don't double-add text's @@ -259,13 +259,13 @@ private: } iterateChildren(nodep); } - virtual void visit(AstCoverDecl* nodep) override { + void visit(AstCoverDecl* nodep) override { // Don't need to fix path in coverage statements, they're not under // any BEGINs, but V3Coverage adds them all under the module itself. iterateChildren(nodep); } // VISITORS - LINT CHECK - virtual void visit(AstIf* nodep) override { // not AstNodeIf; other types not covered + void visit(AstIf* nodep) override { // not AstNodeIf; other types not covered VL_RESTORER(m_underFork); m_underFork = false; // Check IFDEPTH warning - could be in other transform files if desire @@ -281,7 +281,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { VL_RESTORER(m_underFork); m_underFork = false; iterateChildren(nodep); @@ -293,7 +293,7 @@ public: : m_statep{statep} { iterate(nodep); } - virtual ~BeginVisitor() override = default; + ~BeginVisitor() override = default; }; //###################################################################### @@ -306,21 +306,21 @@ private: // AstNodeFTask::user1p // Node replaced, rename it // VISITORS - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { if (nodep->taskp()->user1()) { // It was converted UINFO(9, " relinkFTask " << nodep << endl); nodep->name(nodep->taskp()->name()); } iterateChildren(nodep); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->varp()->user1()) { // It was converted UINFO(9, " relinVarRef " << nodep << endl); nodep->name(nodep->varp()->name()); } iterateChildren(nodep); } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { // May have changed cell names // TypeTable is always after all modules, so names are stable UINFO(8, " IFACEREFDTYPE " << nodep << endl); @@ -329,12 +329,12 @@ private: iterateChildren(nodep); } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS BeginRelinkVisitor(AstNetlist* nodep, BeginState*) { iterate(nodep); } - virtual ~BeginRelinkVisitor() override = default; + ~BeginRelinkVisitor() override = default; }; //###################################################################### diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index 51c749eb4..eed4e49fc 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -63,7 +63,7 @@ private: } // VISITORS - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { UINFO(4, " IF: " << nodep << endl); VL_RESTORER(m_likely); VL_RESTORER(m_unlikely); @@ -87,17 +87,17 @@ private: } // else leave unknown } } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { checkUnlikely(nodep); nodep->funcp()->user1Inc(); iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { checkUnlikely(nodep); m_cfuncsp.push_back(nodep); iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { checkUnlikely(nodep); iterateChildren(nodep); } @@ -116,7 +116,7 @@ public: iterateChildren(nodep); calc_tasks(); } - virtual ~BranchVisitor() override = default; + ~BranchVisitor() override = default; }; //###################################################################### diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 6f1f906e8..dd4978eca 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -132,8 +132,8 @@ private: public: // METHODS void clear() { m_linkable.clear(); } - inline void addLinkable(const AstNode* nodep) { m_linkable.emplace(nodep); } - inline bool isLinkable(const AstNode* nodep) const { return m_linkable.count(nodep) != 0; } + void addLinkable(const AstNode* nodep) { m_linkable.emplace(nodep); } + bool isLinkable(const AstNode* nodep) const { return m_linkable.count(nodep) != 0; } } s_linkableTable; bool V3Broken::isLinkable(const AstNode* nodep) { return s_linkableTable.isLinkable(nodep); } @@ -214,27 +214,27 @@ private: } return false; } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { processAndIterate(nodep); UASSERT_OBJ(!(v3Global.assertDTypesResolved() && nodep->brokeLhsMustBeLvalue() && VN_IS(nodep->lhsp(), NodeVarRef) && !VN_AS(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()), nodep, "Assignment LHS is not an lvalue"); } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { processAndIterate(nodep); UASSERT_OBJ(!(v3Global.assertDTypesResolved() && VN_IS(nodep->lhsp(), NodeVarRef) && !VN_AS(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()), nodep, "Release LHS is not an lvalue"); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { VL_RESTORER(m_inScope); { m_inScope = true; processAndIterate(nodep); } } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { processAndIterate(nodep); // m_inScope because some Vars have initial variable references without scopes // This might false fire with some debug flags, as not certain we don't have temporary @@ -252,7 +252,7 @@ private: } } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { UASSERT_OBJ(!m_cfuncp, nodep, "Nested AstCFunc"); m_cfuncp = nodep; m_localVars.clear(); @@ -270,7 +270,7 @@ private: m_cfuncp = nullptr; } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { // Each branch is a separate local variable scope pushLocalScope(); processEnter(nodep); @@ -288,21 +288,21 @@ private: processExit(nodep); popLocalScope(); } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { // For local variable checking act as if any statement introduces a new scope. // This is aggressive but conservatively correct. pushLocalScope(); processAndIterate(nodep); popLocalScope(); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { processAndIterate(nodep); if (m_cfuncp) { m_localVars.insert(nodep); m_localsStack.back().insert(nodep); } } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // Process not just iterate processAndIterate(nodep); } @@ -310,7 +310,7 @@ private: public: // CONSTRUCTORS explicit BrokenCheckVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~BrokenCheckVisitor() override = default; + ~BrokenCheckVisitor() override = default; }; //###################################################################### diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 381144661..27c884947 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -44,7 +44,7 @@ private: public: // cppcheck-suppress noExplicitConstructor - inline VCtorType(en _e) + VCtorType(en _e) : m_e{_e} {} bool isClass() const { return m_e == CLASS; } bool isCoverage() const { return m_e == COVERAGE; } diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 2d301567e..5bf6bfe69 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -57,7 +57,7 @@ class CUseVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstClassRefDType* nodep) override { + void visit(AstClassRefDType* nodep) override { if (nodep->user1SetOnce()) return; // Process once if (!m_impOnly) addNewUse(nodep, VUseType::INT_FWD_CLASS, nodep->classp()->name()); // Need to include extends() when we implement, but no need for pointers to know @@ -67,17 +67,17 @@ class CUseVisitor final : public VNVisitor { iterateChildren(nodep->classp()); // This also gets all extend classes } } - virtual void visit(AstNodeDType* nodep) override { + void visit(AstNodeDType* nodep) override { if (nodep->user1SetOnce()) return; // Process once if (nodep->virtRefDTypep()) iterate(nodep->virtRefDTypep()); if (nodep->virtRefDType2p()) iterate(nodep->virtRefDType2p()); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (nodep->user1SetOnce()) return; // Process once if (nodep->dtypep() && !nodep->dtypep()->user1()) iterate(nodep->dtypep()); iterateChildren(nodep); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { if (nodep->user1SetOnce()) return; // Process once // Currently no IMP_INCLUDE because we include __Syms which has them all addNewUse(nodep, VUseType::INT_FWD_CLASS, nodep->modp()->name()); @@ -90,7 +90,7 @@ public: : m_modp(modp) { iterate(modp); } - virtual ~CUseVisitor() override = default; + ~CUseVisitor() override = default; VL_UNCOPYABLE(CUseVisitor); }; diff --git a/src/V3Case.cpp b/src/V3Case.cpp index c8a2e639f..58a160301 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -59,7 +59,7 @@ private: // METHODS VL_DEBUG_FUNC; // Declare debug() - virtual void visit(AstNodeCase* nodep) override { + void visit(AstNodeCase* nodep) override { if (VN_IS(nodep, Case) && VN_AS(nodep, Case)->casex()) { nodep->v3warn(CASEX, "Suggest casez (with ?'s) in place of casex (with X's)"); } @@ -86,7 +86,7 @@ private: m_caseExprp = nullptr; } } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { // See also neverItem if (m_caseExprp && nodep->num().isFourState()) { if (VN_IS(m_caseExprp, GenCase)) { @@ -107,12 +107,12 @@ private: } } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit CaseLintVisitor(AstNodeCase* nodep) { iterate(nodep); } - virtual ~CaseLintVisitor() override = default; + ~CaseLintVisitor() override = default; }; //###################################################################### @@ -493,7 +493,7 @@ private: } // VISITORS - virtual void visit(AstCase* nodep) override { + void visit(AstCase* nodep) override { V3Case::caseLint(nodep); iterateChildren(nodep); if (debug() >= 9) nodep->dumpTree(cout, " case_old: "); @@ -510,7 +510,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (VN_IS(nodep, Always)) m_alwaysp = nodep; iterateChildren(nodep); } @@ -521,7 +521,7 @@ public: for (auto& itr : m_valueItem) itr = nullptr; iterate(nodep); } - virtual ~CaseVisitor() override { + ~CaseVisitor() override { V3Stats::addStat("Optimizations, Cases parallelized", m_statCaseFast); V3Stats::addStat("Optimizations, Cases complex", m_statCaseSlow); } diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index ad8c66572..c0add7658 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -111,25 +111,25 @@ private: } // VISITORS - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeUniop* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1()); if (nodep->sizeMattersLhs()) ensureCast(nodep->lhsp()); } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1() | nodep->rhsp()->user1()); if (nodep->sizeMattersLhs()) ensureCast(nodep->lhsp()); if (nodep->sizeMattersRhs()) ensureCast(nodep->rhsp()); } - virtual void visit(AstNodeTriop* nodep) override { + void visit(AstNodeTriop* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1() | nodep->rhsp()->user1() | nodep->thsp()->user1()); if (nodep->sizeMattersLhs()) ensureCast(nodep->lhsp()); if (nodep->sizeMattersRhs()) ensureCast(nodep->rhsp()); if (nodep->sizeMattersThs()) ensureCast(nodep->thsp()); } - virtual void visit(AstNodeQuadop* nodep) override { + void visit(AstNodeQuadop* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1() | nodep->rhsp()->user1() | nodep->thsp()->user1() | nodep->fhsp()->user1()); @@ -138,12 +138,12 @@ private: if (nodep->sizeMattersThs()) ensureCast(nodep->thsp()); if (nodep->sizeMattersFhs()) ensureCast(nodep->fhsp()); } - virtual void visit(AstCCast* nodep) override { + void visit(AstCCast* nodep) override { iterateChildren(nodep); ensureLower32Cast(nodep); nodep->user1(1); } - virtual void visit(AstNegate* nodep) override { + void visit(AstNegate* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1()); if (nodep->lhsp()->widthMin() == 1) { @@ -155,7 +155,7 @@ private: ensureCast(nodep->lhsp()); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { const AstNode* const backp = nodep->backp(); if (nodep->access().isReadOnly() && !VN_IS(backp, CCast) && VN_IS(backp, NodeMath) && !VN_IS(backp, ArraySel) && !VN_IS(backp, RedXor) @@ -168,7 +168,7 @@ private: } nodep->user1(1); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { // Constants are of unknown size if smaller than 33 bits, because // we're too lazy to wrap every constant in the universe in // ((IData)#). @@ -176,29 +176,29 @@ private: } // Null dereference protection - virtual void visit(AstNullCheck* nodep) override { + void visit(AstNullCheck* nodep) override { iterateChildren(nodep); nodep->user1(nodep->lhsp()->user1()); } - virtual void visit(AstCMethodCall* nodep) override { + void visit(AstCMethodCall* nodep) override { iterateChildren(nodep); ensureNullChecked(nodep->fromp()); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { iterateChildren(nodep); ensureNullChecked(nodep->fromp()); } // NOPs - virtual void visit(AstVar*) override {} + void visit(AstVar*) override {} //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit CastVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~CastVisitor() override = default; + ~CastVisitor() override = default; }; //###################################################################### diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 4263bae77..0fe808ab3 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -67,9 +67,9 @@ public: , m_srcDomainSet{false} , m_dstDomainSet{false} , m_asyncPath{false} {} - virtual ~CdcEitherVertex() override = default; + ~CdcEitherVertex() override = default; // ACCESSORS - virtual FileLine* fileline() const override { return nodep()->fileline(); } + FileLine* fileline() const override { return nodep()->fileline(); } AstScope* scopep() const { return m_scopep; } AstNode* nodep() const { return m_nodep; } AstSenTree* srcDomainp() const { return m_srcDomainp; } @@ -93,11 +93,11 @@ public: CdcVarVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varScp) : CdcEitherVertex{graphp, scopep, varScp} , m_varScp{varScp} {} - virtual ~CdcVarVertex() override = default; + ~CdcVarVertex() override = default; // ACCESSORS AstVarScope* varScp() const { return m_varScp; } - virtual string name() const override { return (cvtToHex(m_varScp) + " " + varScp()->name()); } - virtual string dotColor() const override { + string name() const override { return (cvtToHex(m_varScp) + " " + varScp()->name()); } + string dotColor() const override { return fromFlop() ? "green" : cntAsyncRst() ? "red" : "blue"; } int cntAsyncRst() const { return m_cntAsyncRst; } @@ -118,12 +118,10 @@ public: srcDomainp(sensenodep); dstDomainp(sensenodep); } - virtual ~CdcLogicVertex() override = default; + ~CdcLogicVertex() override = default; // ACCESSORS - virtual string name() const override { - return (cvtToHex(nodep()) + "@" + scopep()->prettyName()); - } - virtual string dotColor() const override { return hazard() ? "black" : "yellow"; } + string name() const override { return (cvtToHex(nodep()) + "@" + scopep()->prettyName()); } + string dotColor() const override { return hazard() ? "black" : "yellow"; } bool hazard() const { return m_hazard; } void setHazard(AstNode* nodep) { m_hazard = true; @@ -144,7 +142,7 @@ private: std::ofstream* const m_ofp = nullptr; // Output file string m_prefix; - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { *m_ofp << m_prefix; if (nodep->user3()) { *m_ofp << " %%"; @@ -171,7 +169,7 @@ public: , m_prefix{prefix} { iterate(nodep); } - virtual ~CdcDumpVisitor() override = default; + ~CdcDumpVisitor() override = default; }; //###################################################################### @@ -181,7 +179,7 @@ private: int m_maxLineno = 0; size_t m_maxFilenameLen = 0; - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); // Keeping line+filename lengths separate is much faster than calling ascii().length() if (nodep->fileline()->lineno() >= m_maxLineno) { @@ -195,7 +193,7 @@ private: public: // CONSTRUCTORS explicit CdcWidthVisitor(AstNode* nodep) { iterate(nodep); } - virtual ~CdcWidthVisitor() override = default; + ~CdcWidthVisitor() override = default; // ACCESSORS int maxWidth() const { size_t width = 1; @@ -628,21 +626,21 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UINFO(4, " SCOPE " << nodep << endl); m_scopep = nodep; m_logicVertexp = nullptr; iterateChildren(nodep); m_scopep = nullptr; } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { // Create required blocks and add to module UINFO(4, " BLOCK " << nodep << endl); AstNode::user2ClearTree(); @@ -654,7 +652,7 @@ private: m_domainp = nullptr; AstNode::user2ClearTree(); } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { if (m_scopep) { UASSERT_OBJ(m_logicVertexp, nodep, "Var ref not under a logic block"); AstVarScope* const varscp = nodep->varScopep(); @@ -682,53 +680,53 @@ private: } } } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { m_inDly = true; iterateChildren(nodep); m_inDly = false; } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { m_inSenItem = true; iterateChildren(nodep); m_inSenItem = false; } - virtual void visit(AstAlways* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlways* nodep) override { iterateNewStmt(nodep); } + void visit(AstAlwaysPublic* nodep) override { // CDC doesn't care about public variables } - virtual void visit(AstCFunc* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAssignAlias* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAssignW* nodep) override { iterateNewStmt(nodep); } + void visit(AstCFunc* nodep) override { iterateNewStmt(nodep); } + void visit(AstAssignAlias* nodep) override { iterateNewStmt(nodep); } + void visit(AstAssignW* nodep) override { iterateNewStmt(nodep); } // Math that shouldn't cause us to clear hazard - virtual void visit(AstConst*) override {} - virtual void visit(AstReplicate* nodep) override { iterateChildren(nodep); } - virtual void visit(AstConcat* nodep) override { iterateChildren(nodep); } - virtual void visit(AstNot* nodep) override { iterateChildren(nodep); } - virtual void visit(AstSel* nodep) override { + void visit(AstConst*) override {} + void visit(AstReplicate* nodep) override { iterateChildren(nodep); } + void visit(AstConcat* nodep) override { iterateChildren(nodep); } + void visit(AstNot* nodep) override { iterateChildren(nodep); } + void visit(AstSel* nodep) override { if (!VN_IS(nodep->lsbp(), Const)) setNodeHazard(nodep); iterateChildren(nodep); } - virtual void visit(AstNodeSel* nodep) override { + void visit(AstNodeSel* nodep) override { if (!VN_IS(nodep->bitp(), Const)) setNodeHazard(nodep); iterateChildren(nodep); } // Ignores - virtual void visit(AstInitial*) override {} - virtual void visit(AstInitialAutomatic*) override {} - virtual void visit(AstInitialStatic*) override {} - virtual void visit(AstTraceDecl*) override {} - virtual void visit(AstCoverToggle*) override {} - virtual void visit(AstNodeDType*) override {} + void visit(AstInitial*) override {} + void visit(AstInitialAutomatic*) override {} + void visit(AstInitialStatic*) override {} + void visit(AstTraceDecl*) override {} + void visit(AstCoverToggle*) override {} + void visit(AstNodeDType*) override {} //-------------------- // Default - virtual void visit(AstNodeMath* nodep) override { + void visit(AstNodeMath* nodep) override { setNodeHazard(nodep); iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -754,7 +752,7 @@ public: *m_ofp << '\n'; } } - virtual ~CdcVisitor() override { + ~CdcVisitor() override { if (m_ofp) VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); } }; diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp new file mode 100644 index 000000000..f99b40284 --- /dev/null +++ b/src/V3Changed.cpp @@ -0,0 +1,256 @@ +// -*- mode: C++; c-file-style: "cc-mode" -*- +//************************************************************************* +// DESCRIPTION: Verilator: Add temporaries, such as for changed nodes +// +// Code available from: https://verilator.org +// +//************************************************************************* +// +// Copyright 2003-2022 by Wilson Snyder. This program is free software; you +// can redistribute it and/or modify it under the terms of either the GNU +// Lesser General Public License Version 3 or the Perl Artistic License +// Version 2.0. +// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 +// +//************************************************************************* +// V3Changed's Transformations: +// +// Each module: +// Each combo block +// For each variable that comes from combo block and is generated AFTER a usage +// Add __Vlast_{var} to local section, init to current value (just use array?) +// Change = if any var != last. +// If a signal is used as a clock in this module or any +// module *below*, and it isn't a input to this module, +// we need to indicate a new clock has been created. +// +//************************************************************************* + +#include "config_build.h" +#include "verilatedos.h" + +#include "V3Changed.h" + +#include "V3Ast.h" +#include "V3Global.h" + +#include + +//###################################################################### + +class ChangedState final { +public: + // STATE + AstNodeModule* m_topModp = nullptr; // Top module + AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE + AstCFunc* m_chgFuncp = nullptr; // Change function we're building + AstCFunc* m_tlChgFuncp = nullptr; // Top level change function we're building + int m_numStmts = 0; // Number of statements added to m_chgFuncp + int m_funcNum = 0; // Number of change functions emitted + bool m_madeTopChg = false; + + ChangedState() = default; + ~ChangedState() = default; + + void maybeCreateChgFuncp() { + maybeCreateTopChg(); + maybeCreateMidChg(); + } + void maybeCreateTopChg() { + if (m_madeTopChg) return; + m_madeTopChg = true; + v3Global.rootp()->changeRequest(true); + + // Create a wrapper change detection function that calls each change detection function + m_tlChgFuncp + = new AstCFunc{m_scopetopp->fileline(), "_change_request", m_scopetopp, "QData"}; + m_tlChgFuncp->isStatic(false); + m_tlChgFuncp->isLoose(true); + m_tlChgFuncp->declPrivate(true); + m_scopetopp->addActivep(m_tlChgFuncp); + // Each change detection function needs at least one AstChangeDet + // to ensure that V3EmitC outputs the necessary code. + maybeCreateMidChg(); + m_chgFuncp->addStmtsp(new AstChangeDet{m_scopetopp->fileline(), nullptr, nullptr}); + } + void maybeCreateMidChg() { + // Don't create an extra function call if splitting is disabled + if (!v3Global.opt.outputSplitCFuncs()) { + m_chgFuncp = m_tlChgFuncp; + return; + } + if (!m_chgFuncp || v3Global.opt.outputSplitCFuncs() < m_numStmts) { + m_chgFuncp + = new AstCFunc{m_scopetopp->fileline(), "_change_request_" + cvtToStr(++m_funcNum), + m_scopetopp, "QData"}; + m_chgFuncp->isStatic(false); + m_chgFuncp->isLoose(true); + m_chgFuncp->declPrivate(true); + m_scopetopp->addActivep(m_chgFuncp); + + // Add a top call to it + AstCCall* const callp = new AstCCall{m_scopetopp->fileline(), m_chgFuncp}; + + if (!m_tlChgFuncp->stmtsp()) { + m_tlChgFuncp->addStmtsp(new AstCReturn{m_scopetopp->fileline(), callp}); + } else { + AstCReturn* const returnp = VN_AS(m_tlChgFuncp->stmtsp(), CReturn); + UASSERT_OBJ(returnp, m_scopetopp, "Lost CReturn in top change function"); + // This is currently using AstLogOr which will shortcut the + // evaluation if any function returns true. This is likely what + // we want and is similar to the logic already in use inside + // V3EmitC, however, it also means that verbose logging may + // miss to print change detect variables. + AstNode* const newp = new AstCReturn{ + m_scopetopp->fileline(), + new AstLogOr{m_scopetopp->fileline(), callp, returnp->lhsp()->unlinkFrBack()}}; + returnp->replaceWith(newp); + VL_DO_DANGLING(returnp->deleteTree(), returnp); + } + m_numStmts = 0; + } + } +}; + +//###################################################################### +// Utility visitor to find elements to be compared + +class ChangedInsertVisitor final : public VNVisitor { +private: + // STATE + ChangedState& m_state; // Shared state across visitors + AstVarScope* const m_vscp; // Original (non-change) variable we're change-detecting + AstVarScope* m_newvscp = nullptr; // New (change detect) variable we're change-detecting + AstNode* m_varEqnp = nullptr; // Original var's equation to get var value + AstNode* m_newLvEqnp = nullptr; // New var's equation to read value + AstNode* m_newRvEqnp = nullptr; // New var's equation to set value + uint32_t m_detects = 0; // # detects created + + // CONSTANTS + // How many indexes before error. Ok to increase this, but may result in much slower model + static constexpr uint32_t DETECTARRAY_MAX_INDEXES = 256; + + void newChangeDet() { + if (++m_detects > DETECTARRAY_MAX_INDEXES) { + m_vscp->v3warn(E_DETECTARRAY, + "Unsupported: Can't detect more than " + << DETECTARRAY_MAX_INDEXES + << " array indexes (probably with UNOPTFLAT warning suppressed): " + << m_vscp->prettyName() << '\n' + << m_vscp->warnMore() + << "... Could recompile with DETECTARRAY_MAX_INDEXES increased"); + return; + } + m_state.maybeCreateChgFuncp(); + + AstChangeDet* const changep = new AstChangeDet{ + m_vscp->fileline(), m_varEqnp->cloneTree(true), m_newRvEqnp->cloneTree(true)}; + m_state.m_chgFuncp->addStmtsp(changep); + AstAssign* const initp = new AstAssign{m_vscp->fileline(), m_newLvEqnp->cloneTree(true), + m_varEqnp->cloneTree(true)}; + m_state.m_chgFuncp->addFinalsp(initp); + + // Later code will expand words which adds to GCC compile time, + // so add penalty based on word width also + m_state.m_numStmts += initp->nodeCount() + m_varEqnp->widthWords(); + } + + void visit(AstBasicDType*) override { // + newChangeDet(); + } + void visit(AstPackArrayDType*) override { // + newChangeDet(); + } + void visit(AstUnpackArrayDType* nodep) override { + for (int index = 0; index < nodep->elementsConst(); ++index) { + VL_RESTORER(m_varEqnp); + VL_RESTORER(m_newLvEqnp); + VL_RESTORER(m_newRvEqnp); + { + m_varEqnp = new AstArraySel{nodep->fileline(), m_varEqnp->cloneTree(true), index}; + m_newLvEqnp + = new AstArraySel{nodep->fileline(), m_newLvEqnp->cloneTree(true), index}; + m_newRvEqnp + = new AstArraySel{nodep->fileline(), m_newRvEqnp->cloneTree(true), index}; + + iterate(nodep->subDTypep()->skipRefp()); + + m_varEqnp->deleteTree(); + m_newLvEqnp->deleteTree(); + m_newRvEqnp->deleteTree(); + } + } + } + void visit(AstNodeUOrStructDType* nodep) override { + if (nodep->packedUnsup()) { + newChangeDet(); + } else { + if (debug()) nodep->dumpTree(cout, "-DETECTARRAY-class-"); + m_vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable" + " (probably with UNOPTFLAT warning suppressed): " + << m_vscp->varp()->prettyNameQ()); + } + } + void visit(AstNode* nodep) override { + iterateChildren(nodep); + if (debug()) nodep->dumpTree(cout, "-DETECTARRAY-general-"); + m_vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable" + " (probably with UNOPTFLAT warning suppressed): " + << m_vscp->varp()->prettyNameQ()); + } + +public: + // CONSTRUCTORS + ChangedInsertVisitor(AstVarScope* vscp, ChangedState& state) + : m_state{state} + , m_vscp{vscp} { + // DPI export trigger should never need change detect. See similar assertions in V3Order + // (OrderVisitor::nodeMarkCircular), and V3GenClk (GenClkRenameVisitor::genInpClk). + UASSERT_OBJ(vscp != v3Global.rootp()->dpiExportTriggerp(), vscp, + "DPI export trigger should not need change detect"); + { + AstVar* const varp = m_vscp->varp(); + const string newvarname{"__Vchglast__" + m_vscp->scopep()->nameDotless() + "__" + + varp->shortName()}; + // Create: VARREF(_last) + // ASSIGN(VARREF(_last), VARREF(var)) + // ... + // CHANGEDET(VARREF(_last), VARREF(var)) + AstVar* const newvarp + = new AstVar{varp->fileline(), VVarType::MODULETEMP, newvarname, varp}; + m_state.m_topModp->addStmtp(newvarp); + m_newvscp = new AstVarScope{m_vscp->fileline(), m_state.m_scopetopp, newvarp}; + m_state.m_scopetopp->addVarp(m_newvscp); + + m_varEqnp = new AstVarRef{m_vscp->fileline(), m_vscp, VAccess::READ}; + m_newLvEqnp = new AstVarRef{m_vscp->fileline(), m_newvscp, VAccess::WRITE}; + m_newRvEqnp = new AstVarRef{m_vscp->fileline(), m_newvscp, VAccess::READ}; + } + iterate(vscp->dtypep()->skipRefp()); + m_varEqnp->deleteTree(); + m_newLvEqnp->deleteTree(); + m_newRvEqnp->deleteTree(); + } + ~ChangedInsertVisitor() override = default; + VL_UNCOPYABLE(ChangedInsertVisitor); +}; + +//###################################################################### +// Changed class functions + +void V3Changed::changedAll(AstNetlist* nodep) { + UINFO(2, __FUNCTION__ << ": " << endl); + + ChangedState state; + state.m_scopetopp = nodep->topScopep()->scopep(); + state.m_topModp = nodep->topModulep(); + nodep->foreach([&state](AstVarScope* vscp) { + if (vscp->isCircular()) { + vscp->v3warn(IMPERFECTSCH, + "Imperfect scheduling of variable: " << vscp->prettyNameQ()); + ChangedInsertVisitor{vscp, state}; + } + }); + + V3Global::dumpCheckGlobalTree("changed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); +} diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 94f513802..52a7c0f1f 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -49,7 +49,7 @@ private: // METHODS VL_DEBUG_FUNC; // Declare debug() - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { if (nodep->user1SetOnce()) return; // Move this class nodep->name(m_prefix + nodep->name()); @@ -100,7 +100,7 @@ private: } nodep->repairCache(); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Visit for NodeModules that are not AstClass (AstClass is-a AstNodeModule) VL_RESTORER(m_prefix); { @@ -109,7 +109,7 @@ private: } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); if (m_packageScopep) { if (m_ftaskp && m_ftaskp->lifetime().isStatic()) { @@ -127,12 +127,12 @@ private: } } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { iterateChildren(nodep); nodep->varp()->user1p(nodep); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { VL_RESTORER(m_ftaskp); { m_ftaskp = nodep; @@ -142,7 +142,7 @@ private: } } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { iterateChildren(nodep); // Don't move now, or wouldn't keep interating the class // TODO move function statics only @@ -150,14 +150,14 @@ private: // m_toScopeMoves.push_back(std::make_pair(nodep, m_classScopep)); //} } - virtual void visit(AstInitial* nodep) override { + void visit(AstInitial* nodep) override { // But not AstInitialAutomatic, which remains under the class iterateChildren(nodep); if (m_packageScopep) { m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep)); } } - virtual void visit(AstInitialStatic* nodep) override { + void visit(AstInitialStatic* nodep) override { // But not AstInitialAutomatic, which remains under the class iterateChildren(nodep); if (m_packageScopep) { @@ -165,14 +165,14 @@ private: } } - virtual void visit(AstNodeMath* nodep) override {} // Short circuit - virtual void visit(AstNodeStmt* nodep) override {} // Short circuit - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath* nodep) override {} // Short circuit + void visit(AstNodeStmt* nodep) override {} // Short circuit + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ClassVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ClassVisitor() override { + ~ClassVisitor() override { for (auto moved : m_toScopeMoves) { AstNode* const nodep = moved.first; AstScope* const scopep = moved.second; diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 3cca98d7f..64fa0dcba 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -173,64 +173,64 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; iterateChildren(nodep); } } - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeUniop* nodep) override { iterateChildren(nodep); computeCppWidth(nodep); if (nodep->cleanLhs()) ensureClean(nodep->lhsp()); setClean(nodep, nodep->cleanOut()); } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { operandBiop(nodep); setClean(nodep, nodep->cleanOut()); } - virtual void visit(AstAnd* nodep) override { + void visit(AstAnd* nodep) override { operandBiop(nodep); setClean(nodep, isClean(nodep->lhsp()) || isClean(nodep->rhsp())); } - virtual void visit(AstXor* nodep) override { + void visit(AstXor* nodep) override { operandBiop(nodep); setClean(nodep, isClean(nodep->lhsp()) && isClean(nodep->rhsp())); } - virtual void visit(AstOr* nodep) override { + void visit(AstOr* nodep) override { operandBiop(nodep); setClean(nodep, isClean(nodep->lhsp()) && isClean(nodep->rhsp())); } - virtual void visit(AstNodeQuadop* nodep) override { + void visit(AstNodeQuadop* nodep) override { operandQuadop(nodep); setClean(nodep, nodep->cleanOut()); } - virtual void visit(AstNodeMath* nodep) override { + void visit(AstNodeMath* nodep) override { iterateChildren(nodep); computeCppWidth(nodep); setClean(nodep, nodep->cleanOut()); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { iterateChildren(nodep); computeCppWidth(nodep); if (nodep->cleanRhs()) ensureClean(nodep->rhsp()); } - virtual void visit(AstText* nodep) override { // + void visit(AstText* nodep) override { // setClean(nodep, true); } - virtual void visit(AstScopeName* nodep) override { // + void visit(AstScopeName* nodep) override { // setClean(nodep, true); } - virtual void visit(AstCNew* nodep) override { + void visit(AstCNew* nodep) override { iterateChildren(nodep); setClean(nodep, true); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { operandTriop(nodep); setClean(nodep, nodep->cleanOut()); } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { iterateChildren(nodep); computeCppWidth(nodep); setClean(nodep, false); @@ -238,69 +238,69 @@ private: if (!VN_IS(nodep->backp(), And)) insertClean(nodep); ensureCleanAndNext(nodep->bodysp()); } - virtual void visit(AstTraceDecl* nodep) override { + void visit(AstTraceDecl* nodep) override { // No cleaning, or would loose pointer to enum iterateChildren(nodep); } - virtual void visit(AstTraceInc* nodep) override { + void visit(AstTraceInc* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->valuep()); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { // No cleaning, or would loose pointer to enum iterateChildren(nodep); } - virtual void visit(AstParamTypeDType* nodep) override { + void visit(AstParamTypeDType* nodep) override { // No cleaning, or would loose pointer to enum iterateChildren(nodep); } // Control flow operators - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { iterateChildren(nodep); ensureClean(nodep->condp()); setClean(nodep, isClean(nodep->expr1p()) && isClean(nodep->expr2p())); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { iterateChildren(nodep); ensureClean(nodep->condp()); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { iterateChildren(nodep); ensureClean(nodep->condp()); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->exprsp()); setClean(nodep, true); // generates a string, so not relevant } - virtual void visit(AstUCStmt* nodep) override { + void visit(AstUCStmt* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->bodysp()); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->argsp()); setClean(nodep, true); } - virtual void visit(AstCMethodHard* nodep) override { + void visit(AstCMethodHard* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->pinsp()); setClean(nodep, true); } - virtual void visit(AstWith* nodep) override { + void visit(AstWith* nodep) override { iterateChildren(nodep); ensureCleanAndNext(nodep->exprp()); setClean(nodep, true); } - virtual void visit(AstIntfRef* nodep) override { + void visit(AstIntfRef* nodep) override { iterateChildren(nodep); setClean(nodep, true); // generates a string, so not relevant } //-------------------- // Default: Just iterate - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); computeCppWidth(nodep); } @@ -308,7 +308,7 @@ private: public: // CONSTRUCTORS explicit CleanVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~CleanVisitor() override = default; + ~CleanVisitor() override = default; }; //###################################################################### diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index be1dec524..2159fd0e6 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -120,7 +120,7 @@ private: m_lastIfp = nullptr; } // VISITORS - virtual void visit(AstCoverToggle* nodep) override { + void visit(AstCoverToggle* nodep) override { // nodep->dumpTree(cout, "ct:"); // COVERTOGGLE(INC, ORIG, CHANGE) -> // IF(ORIG ^ CHANGE) { INC; CHANGE = ORIG; } @@ -137,11 +137,11 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { nodep->unlinkFrBack(); pushDeletep(nodep); // Delete it later, AstActives still pointing to it } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { UASSERT_OBJ(nodep->hasClocked(), nodep, "Should have been converted by V3Sched"); UASSERT_OBJ(nodep->stmtsp(), nodep, "Should not have been created if empty"); @@ -164,7 +164,7 @@ private: // Dispose of the AstActive VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstExecGraph* nodep) override { + void visit(AstExecGraph* nodep) override { for (AstMTaskBody* mtaskBodyp = nodep->mTaskBodiesp(); mtaskBodyp; mtaskBodyp = VN_AS(mtaskBodyp->nextp(), MTaskBody)) { clearLastSen(); @@ -174,14 +174,14 @@ private: } //========== Create sampled values - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { VL_RESTORER(m_scopep); { m_scopep = nodep; iterateChildren(nodep); } } - virtual void visit(AstSampled* nodep) override { + void visit(AstSampled* nodep) override { VL_RESTORER(m_inSampled); { m_inSampled = true; @@ -190,7 +190,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { iterateChildren(nodep); if (m_inSampled && !nodep->user1SetOnce()) { UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Should have failed in V3Access"); @@ -204,7 +204,7 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -212,7 +212,7 @@ public: m_evalp = netlistp->evalp(); iterate(netlistp); } - virtual ~ClockVisitor() override = default; + ~ClockVisitor() override = default; }; //###################################################################### diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index 8fa0edbeb..e372629d0 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -180,32 +180,32 @@ class CombineVisitor final : VNVisitor { } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Gather functions and references iterateChildrenConst(nodep); // Combine functions process(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UASSERT_OBJ(!m_modp, nodep, "Should not nest"); m_modp = nodep; iterateChildrenConst(nodep); m_modp = nullptr; } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { iterateChildrenConst(nodep); if (nodep->dontCombine()) return; auto& coll = nodep->slow() ? m_cfuncs(m_modp).m_slow : m_cfuncs(m_modp).m_fast; coll.emplace_back(nodep); } - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { iterateChildrenConst(nodep); AstCFunc* const funcp = nodep->funcp(); if (funcp->dontCombine()) return; m_callSites(funcp).emplace_back(nodep); } - virtual void visit(AstAddrOfCFunc* nodep) override { + void visit(AstAddrOfCFunc* nodep) override { iterateChildrenConst(nodep); if (nodep->funcp()->dontCombine()) return; // LCOV_EXCL_START @@ -217,7 +217,7 @@ class CombineVisitor final : VNVisitor { } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } + void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } // CONSTRUCTORS explicit CombineVisitor(AstNetlist* nodep) { iterate(nodep); } diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 5961bf7d0..f716bba2b 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -309,7 +309,7 @@ public: if (lineMatch(lineno, VPragmaType::FULL_CASE)) nodep->fullPragma(true); if (lineMatch(lineno, VPragmaType::PARALLEL_CASE)) nodep->parallelPragma(true); } - inline void applyIgnores(FileLine* filelinep) { + void applyIgnores(FileLine* filelinep) { // HOT routine, called each parsed token line of this filename if (m_lastIgnore.lineno != filelinep->lineno()) { // UINFO(9, " ApplyIgnores for " << filelinep->ascii() << endl); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 9b6cfe84c..bed6ca32a 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -417,14 +417,12 @@ class ConstBitOpTreeVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstNode* nodep) override { - CONST_BITOP_SET_FAILED("Hit unexpected op", nodep); - } - virtual void visit(AstCCast* nodep) override { + void visit(AstNode* nodep) override { CONST_BITOP_SET_FAILED("Hit unexpected op", nodep); } + void visit(AstCCast* nodep) override { iterateChildren(nodep); if (m_leafp) m_leafp->updateBitRange(nodep); } - virtual void visit(AstShiftR* nodep) override { + void visit(AstShiftR* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); AstConst* const constp = VN_CAST(nodep->rhsp(), Const); CONST_BITOP_RETURN_IF(!constp, nodep->rhsp()); @@ -434,7 +432,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor { m_leafp->updateBitRange(nodep); m_lsb -= constp->toUInt(); } - virtual void visit(AstNot* nodep) override { + void visit(AstNot* nodep) override { CONST_BITOP_RETURN_IF(nodep->widthMin() != 1, nodep); AstNode* lhsp = nodep->lhsp(); AstCCast* const castp = VN_CAST(lhsp, CCast); @@ -449,7 +447,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor { if (!isXorTree()) m_polarity = !m_polarity; if (m_leafp && castp) m_leafp->updateBitRange(castp); } - virtual void visit(AstWordSel* nodep) override { + void visit(AstWordSel* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); AstConst* const constp = VN_CAST(nodep->bitp(), Const); CONST_BITOP_RETURN_IF(!constp, nodep->rhsp()); @@ -457,17 +455,17 @@ class ConstBitOpTreeVisitor final : public VNVisitor { m_leafp->wordIdx(constp->toSInt()); iterate(nodep->fromp()); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); m_leafp->setLeaf(nodep); m_leafp->polarity(m_polarity); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); m_leafp->setLeaf(nodep); } - virtual void visit(AstRedXor* nodep) override { + void visit(AstRedXor* nodep) override { Restorer restorer{*this}; CONST_BITOP_RETURN_IF(!VN_IS(m_rootp, Xor), nodep); AstNode* lhsp = nodep->lhsp(); @@ -514,7 +512,7 @@ class ConstBitOpTreeVisitor final : public VNVisitor { } } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { if (VN_IS(nodep, And) && isConst(nodep->lhsp(), 1)) { // 1 & _ // Always reach past a plain making AND Restorer restorer{*this}; @@ -2252,11 +2250,11 @@ private: //---------------------------------------- // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Iterate modules backwards, in bottom-up order. That's faster iterateChildrenBackwards(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; @@ -2264,7 +2262,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // No ASSIGNW removals under funcs, we've long eliminated INITIALs // (We should perhaps rename the assignw's to just assigns) VL_RESTORER(m_wremove); @@ -2273,7 +2271,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { // No ASSIGNW removals under scope, we've long eliminated INITIALs VL_RESTORER(m_wremove); VL_RESTORER(m_scopep); @@ -2370,17 +2368,17 @@ private: } // Special cases - virtual void visit(AstConst*) override {} // Already constant + void visit(AstConst*) override {} // Already constant - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { if (m_params) { iterateAndNextNull(nodep->paramsp()); } else { iterateChildren(nodep); } } - virtual void visit(AstClassOrPackageRef* nodep) override { iterateChildren(nodep); } - virtual void visit(AstPin* nodep) override { iterateChildren(nodep); } + void visit(AstClassOrPackageRef* nodep) override { iterateChildren(nodep); } + void visit(AstPin* nodep) override { iterateChildren(nodep); } void replaceLogEq(AstLogEq* nodep) { // LOGEQ(a,b) => AstLogAnd{AstLogOr{AstLogNot{a},b},AstLogOr{AstLogNot{b},a}} @@ -2562,7 +2560,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstAttrOf* nodep) override { + void visit(AstAttrOf* nodep) override { VL_RESTORER(m_attrp); { m_attrp = nodep; @@ -2570,7 +2568,7 @@ private: } } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { iterateAndNextNull(nodep->bitp()); if (VN_IS(nodep->bitp(), Const) && VN_IS(nodep->fromp(), VarRef) @@ -2596,7 +2594,7 @@ private: } m_selp = nullptr; } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { iterateChildren(nodep); UASSERT_OBJ(nodep->varp(), nodep, "Not linked"); bool did = false; @@ -2650,7 +2648,7 @@ private: << nodep->varp()->prettyNameQ()); } } - virtual void visit(AstEnumItemRef* nodep) override { + void visit(AstEnumItemRef* nodep) override { iterateChildren(nodep); UASSERT_OBJ(nodep->itemp(), nodep, "Not linked"); bool did = false; @@ -2675,7 +2673,7 @@ private: } } - // virtual void visit(AstCvtPackString* nodep) override { + // void visit(AstCvtPackString* nodep) override { // Not constant propagated (for today) because AstNodeMath::isOpaque is set // Someday if lower is constant, convert to quoted "string". @@ -2683,7 +2681,7 @@ private: // Only one if it's not in a list return (!nodep->nextp() && nodep->backp()->nextp() != nodep); } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { iterateChildren(nodep); if (m_doNConst && (VN_IS(nodep->sensp(), Const) || VN_IS(nodep->sensp(), EnumItemRef) @@ -2772,7 +2770,7 @@ private: } }; - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { iterateChildren(nodep); if (m_doExpensive) { // cout<dumpTree(cout, "ssin: "); @@ -2852,18 +2850,18 @@ private: //----- // Zero elimination - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { iterateChildren(nodep); if (nodep->timingControlp()) m_hasJumpDelay = true; if (m_doNConst && replaceNodeAssign(nodep)) return; } - virtual void visit(AstAssignAlias* nodep) override { + void visit(AstAssignAlias* nodep) override { // Don't perform any optimizations, keep the alias around } - virtual void visit(AstAssignVarScope* nodep) override { + void visit(AstAssignVarScope* nodep) override { // Don't perform any optimizations, the node won't be linked yet } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { iterateChildren(nodep); if (m_doNConst && replaceNodeAssign(nodep)) return; AstNodeVarRef* const varrefp = VN_CAST( @@ -2890,7 +2888,7 @@ private: varrefp->varp()->valuep(initvaluep); } } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { if (AstConcat* const concatp = VN_CAST(nodep->lhsp(), Concat)) { FileLine* const flp = nodep->fileline(); AstRelease* const newLp = new AstRelease{flp, concatp->lhsp()->unlinkFrBack()}; @@ -2903,7 +2901,7 @@ private: } } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { iterateChildren(nodep); if (m_doNConst) { if (const AstConst* const constp = VN_CAST(nodep->condp(), Const)) { @@ -2987,7 +2985,7 @@ private: } } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { // DISPLAY(SFORMAT(text1)),DISPLAY(SFORMAT(text2)) -> DISPLAY(SFORMAT(text1+text2)) iterateChildren(nodep); if (stmtDisplayDisplay(nodep)) return; @@ -3041,7 +3039,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return true; } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { // Substitute constants into displays. The main point of this is to // simplify assertion methodologies which call functions with display's. // This eliminates a pile of wide temps, and makes the C a whole lot more readable. @@ -3108,17 +3106,17 @@ private: } } - virtual void visit(AstFuncRef* nodep) override { + void visit(AstFuncRef* nodep) override { iterateChildren(nodep); if (m_params) { // Only parameters force us to do constant function call propagation replaceWithSimulation(nodep); } } - virtual void visit(AstArg* nodep) override { + void visit(AstArg* nodep) override { // replaceWithSimulation on the Arg's parent FuncRef replaces these iterateChildren(nodep); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { const bool oldHasJumpDelay = m_hasJumpDelay; m_hasJumpDelay = false; { iterateChildren(nodep); } @@ -3144,22 +3142,22 @@ private: } } } - virtual void visit(AstInitArray* nodep) override { iterateChildren(nodep); } - virtual void visit(AstInitItem* nodep) override { iterateChildren(nodep); } - virtual void visit(AstUnbounded* nodep) override { iterateChildren(nodep); } + void visit(AstInitArray* nodep) override { iterateChildren(nodep); } + void visit(AstInitItem* nodep) override { iterateChildren(nodep); } + void visit(AstUnbounded* nodep) override { iterateChildren(nodep); } // These are converted by V3Param. Don't constify as we don't want the // from() VARREF to disappear, if any. // If output of a presel didn't get consted, chances are V3Param didn't visit properly - virtual void visit(AstNodePreSel*) override {} + void visit(AstNodePreSel*) override {} // Ignored, can eliminate early - virtual void visit(AstSysIgnore* nodep) override { + void visit(AstSysIgnore* nodep) override { iterateChildren(nodep); if (m_doNConst) VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } // Simplify - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { iterateChildren(nodep); nodep->cvtRangeConst(); } @@ -3167,7 +3165,7 @@ private: //----- // Jump elimination - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { iterateChildren(nodep); // Jump to label where label immediately follows label is not useful if (nodep->labelp() == VN_CAST(nodep->nextp(), JumpLabel)) { @@ -3198,7 +3196,7 @@ private: m_hasJumpDelay = true; } - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { // Because JumpLabels disable many optimizations, // remove JumpLabels that are not pointed to by any AstJumpGos // Note this assumes all AstJumpGos are underneath the given label; V3Broken asserts this @@ -3552,7 +3550,7 @@ private: // Note we can't convert EqCase/NeqCase to Eq/Neq here because that would break 3'b1x1==3'b101 //----- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // Default: Just iterate if (m_required) { if (VN_IS(nodep, NodeDType) || VN_IS(nodep, Range) || VN_IS(nodep, SliceSel)) { @@ -3600,7 +3598,7 @@ public: } // clang-format on } - virtual ~ConstVisitor() override { + ~ConstVisitor() override { if (m_doCpp) { if (m_globalPass) { V3Stats::addStat("Optimizations, Const bit op reduction", m_statBitOpReduction); diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index e03be42d4..a5e8b1dc3 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -209,7 +209,7 @@ private: } // VISITORS - BOTH - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { const AstNodeModule* const origModp = m_modp; VL_RESTORER(m_modp); VL_RESTORER(m_state); @@ -227,9 +227,9 @@ private: } } - virtual void visit(AstNodeProcedure* nodep) override { iterateProcedure(nodep); } - virtual void visit(AstWhile* nodep) override { iterateProcedure(nodep); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeProcedure* nodep) override { iterateProcedure(nodep); } + void visit(AstWhile* nodep) override { iterateProcedure(nodep); } + void visit(AstNodeFTask* nodep) override { if (!nodep->dpiImport()) iterateProcedure(nodep); } void iterateProcedure(AstNode* nodep) { @@ -258,7 +258,7 @@ private: } // VISITORS - TOGGLE COVERAGE - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); if (m_modp && !m_inToggleOff && !m_state.m_inModOff && nodep->fileline()->coverageOn() && v3Global.opt.coverageToggle()) { @@ -383,7 +383,7 @@ private: // VISITORS - LINE COVERAGE // Note not AstNodeIf; other types don't get covered - virtual void visit(AstIf* nodep) override { + void visit(AstIf* nodep) override { UINFO(4, " IF: " << nodep << endl); if (m_state.m_on) { // An else-if. When we iterate the if, use "elsif" marking @@ -460,7 +460,7 @@ private: } UINFO(9, " done HANDLE " << m_state.m_handle << " for " << nodep << endl); } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { // We don't add an explicit "default" coverage if not provided, // as we already have a warning when there is no default. UINFO(4, " CASEI: " << nodep << endl); @@ -479,7 +479,7 @@ private: } } } - virtual void visit(AstCover* nodep) override { + void visit(AstCover* nodep) override { UINFO(4, " COVER: " << nodep << endl); VL_RESTORER(m_state); { @@ -495,11 +495,11 @@ private: } } } - virtual void visit(AstStop* nodep) override { + void visit(AstStop* nodep) override { UINFO(4, " STOP: " << nodep << endl); m_state.m_on = false; } - virtual void visit(AstPragma* nodep) override { + void visit(AstPragma* nodep) override { if (nodep->pragType() == VPragmaType::COVERAGE_BLOCK_OFF) { // Skip all NEXT nodes under this block, and skip this if/case branch UINFO(4, " OFF: h" << m_state.m_handle << " " << nodep << endl); @@ -510,7 +510,7 @@ private: lineTrack(nodep); } } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { // Record the hierarchy of any named begins, so we can apply to user // coverage points. This is because there may be cov points inside // generate blocks; each point should get separate consideration. @@ -529,7 +529,7 @@ private: } // VISITORS - BOTH - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); lineTrack(nodep); } @@ -537,7 +537,7 @@ private: public: // CONSTRUCTORS explicit CoverageVisitor(AstNetlist* rootp) { iterateChildren(rootp); } - virtual ~CoverageVisitor() override = default; + ~CoverageVisitor() override = default; }; //###################################################################### diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 1b16971d6..b0d081a1d 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -88,24 +88,24 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Find all Coverage's iterateChildren(nodep); // Simplify detectDuplicates(); } - virtual void visit(AstCoverToggle* nodep) override { + void visit(AstCoverToggle* nodep) override { m_toggleps.push_back(nodep); iterateChildren(nodep); } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit CoverageJoinVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~CoverageJoinVisitor() override { + ~CoverageJoinVisitor() override { V3Stats::addStat("Coverage, Toggle points joined", m_statToggleJoins); } }; diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index e72d4ab21..ca79c18f5 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -102,7 +102,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (m_modp) m_modp->user1Inc(); // e.g. Class under Package VL_RESTORER(m_modp); { @@ -120,12 +120,12 @@ private: } } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->scopep()) nodep->scopep()->user1Inc(); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->aboveScopep()) nodep->aboveScopep()->user1Inc(); @@ -136,14 +136,14 @@ private: m_scopesp.push_back(nodep); } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { iterateChildren(nodep); checkAll(nodep); m_cellsp.push_back(nodep); nodep->modp()->user1Inc(); } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { // Note NodeAssign skips calling this in some cases iterateChildren(nodep); checkAll(nodep); @@ -155,7 +155,7 @@ private: if (nodep->varp()) nodep->varp()->user1Inc(); if (nodep->classOrPackagep()) nodep->classOrPackagep()->user1Inc(); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->classOrPackagep()) { @@ -166,11 +166,11 @@ private: } } } - virtual void visit(AstMethodCall* nodep) override { + void visit(AstMethodCall* nodep) override { iterateChildren(nodep); checkAll(nodep); } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { iterateChildren(nodep); checkDType(nodep); checkAll(nodep); @@ -184,7 +184,7 @@ private: } } } - virtual void visit(AstClassRefDType* nodep) override { + void visit(AstClassRefDType* nodep) override { iterateChildren(nodep); checkDType(nodep); checkAll(nodep); @@ -197,12 +197,12 @@ private: } if (nodep->classp()) nodep->classp()->user1Inc(); } - virtual void visit(AstNodeDType* nodep) override { + void visit(AstNodeDType* nodep) override { iterateChildren(nodep); checkDType(nodep); checkAll(nodep); } - virtual void visit(AstEnumItemRef* nodep) override { + void visit(AstEnumItemRef* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->classOrPackagep()) { @@ -214,13 +214,13 @@ private: } checkAll(nodep); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { iterateChildren(nodep); if (nodep->varp()) nodep->varp()->user1Inc(); if (nodep->fromp()->dtypep()) nodep->fromp()->dtypep()->user1Inc(); // classref checkAll(nodep); } - virtual void visit(AstModport* nodep) override { + void visit(AstModport* nodep) override { iterateChildren(nodep); if (m_elimCells) { if (!nodep->varsp()) { @@ -230,14 +230,14 @@ private: } checkAll(nodep); } - virtual void visit(AstSelLoopVars* nodep) override { + void visit(AstSelLoopVars* nodep) override { // Var under a SelLoopVars means we haven't called V3Width to remove them yet VL_RESTORER(m_selloopvarsp); m_selloopvarsp = nodep; iterateChildren(nodep); checkAll(nodep); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { iterateChildren(nodep); if (m_elimCells && !nodep->attrPublic()) { VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); @@ -248,20 +248,20 @@ private: // Normal modules may disappear, e.g. if they are parameterized then removed if (nodep->attrPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc(); } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->scopep()) nodep->scopep()->user1Inc(); if (mightElimVar(nodep->varp())) m_vscsp.push_back(nodep); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); checkAll(nodep); if (nodep->isSigPublic() && m_modp && VN_IS(m_modp, Package)) m_modp->user1Inc(); if (m_selloopvarsp) nodep->user1Inc(); if (mightElimVar(nodep)) m_varsp.push_back(nodep); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // See if simple assignments to variables may be eliminated because // that variable is never used. // Similar code in V3Life @@ -285,7 +285,7 @@ private: } //----- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (nodep->isOutputter()) m_sideEffect = true; iterateChildren(nodep); checkAll(nodep); @@ -452,7 +452,7 @@ public: // We may have removed some datatypes, cleanup nodep->typeTablep()->repairCache(); } - virtual ~DeadVisitor() override = default; + ~DeadVisitor() override = default; }; //###################################################################### diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 6a85328c9..878de72f6 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -401,24 +401,24 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // VV***** We reset all userp() on the netlist m_modVarMap.clear(); iterateChildren(nodep); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UINFO(4, " MOD " << nodep << endl); AstNode::user3ClearTree(); iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); { m_cfuncp = nodep; iterateChildren(nodep); } } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { m_activep = nodep; VL_RESTORER(m_inInitial); { @@ -429,7 +429,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { m_procp = nodep; m_timingDomains.clear(); iterateChildren(nodep); @@ -456,8 +456,8 @@ private: actp->sensesStorep(clockedDomain); } } - virtual void visit(AstCAwait* nodep) override { m_timingDomains.insert(nodep->sensesp()); } - virtual void visit(AstFireEvent* nodep) override { + void visit(AstCAwait* nodep) override { m_timingDomains.insert(nodep->sensesp()); } + void visit(AstFireEvent* nodep) override { UASSERT_OBJ(v3Global.hasEvents(), nodep, "Inconsistent"); FileLine* const flp = nodep->fileline(); if (nodep->isDelayed()) { @@ -498,7 +498,7 @@ private: } nodep->deleteTree(); } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { m_inDly = true; m_nextDlyp = VN_CAST(nodep->nextp(), AssignDly); // Next assignment in same block, maybe nullptr. @@ -535,7 +535,7 @@ private: m_nextDlyp = nullptr; } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (!nodep->user2Inc()) { // Not done yet if (m_inDly && nodep->access().isWriteOrRW()) { UINFO(4, "AssignDlyVar: " << nodep << endl); @@ -587,18 +587,18 @@ private: } } - virtual void visit(AstNodeReadWriteMem* nodep) override { + void visit(AstNodeReadWriteMem* nodep) override { VL_RESTORER(m_ignoreBlkAndNBlk); m_ignoreBlkAndNBlk = true; // $readmem/$writemem often used in mem models // so we will suppress BLKANDNBLK warnings iterateChildren(nodep); } - virtual void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc( "For statements should have been converted to while statements in V3Begin"); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { VL_RESTORER(m_inLoop); { m_inLoop = true; @@ -607,12 +607,12 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit DelayedVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~DelayedVisitor() override { + ~DelayedVisitor() override { V3Stats::addStat("Optimizations, Delayed shared-sets", m_statSharedSet); } }; diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 7b81e22ca..f370c6d09 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -73,7 +73,7 @@ private: } // VISITORS - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); VL_RESTORER(m_mtaskbodyp); { @@ -85,7 +85,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstMTaskBody* nodep) override { + void visit(AstMTaskBody* nodep) override { VL_RESTORER(m_cfuncp); VL_RESTORER(m_mtaskbodyp); { @@ -106,7 +106,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); } else { @@ -114,8 +114,8 @@ private: } } // Operators - virtual void visit(AstNodeTermop* nodep) override {} - virtual void visit(AstNodeMath* nodep) override { + void visit(AstNodeTermop* nodep) override {} + void visit(AstNodeMath* nodep) override { // We have some operator defines that use 2 parens, so += 2. { VL_RESTORER(m_depth); @@ -142,19 +142,19 @@ private: m_cfuncp->isStatic(false); } } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { needNonStaticFunc(nodep); iterateChildren(nodep); } - virtual void visit(AstUCStmt* nodep) override { + void visit(AstUCStmt* nodep) override { needNonStaticFunc(nodep); visitStmt(nodep); } //-------------------- // Default: Just iterate - virtual void visit(AstVar*) override {} // Don't hit varrefs under vars - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't hit varrefs under vars + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -162,7 +162,7 @@ public: : m_tempNames{"__Vdeeptemp"} { iterate(nodep); } - virtual ~DepthVisitor() override = default; + ~DepthVisitor() override = default; }; //###################################################################### diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 22da37e91..c4cde8287 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -71,7 +71,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UINFO(4, " MOD " << nodep << endl); VL_RESTORER(m_modp); { @@ -80,7 +80,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // We recurse into this. VL_RESTORER(m_depth); VL_RESTORER(m_cfuncp); @@ -106,7 +106,7 @@ private: } m_depth--; } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); } else { @@ -114,15 +114,15 @@ private: } } - virtual void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNodeMath*) override {} // Accelerate //-------------------- - virtual void visit(AstVar*) override {} // Don't hit varrefs under vars - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't hit varrefs under vars + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit DepthBlockVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~DepthBlockVisitor() override = default; + ~DepthBlockVisitor() override = default; }; //###################################################################### diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 4ff47ddf2..80b848f1b 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -185,7 +185,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; @@ -195,17 +195,17 @@ private: makePublicFuncWrappers(); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { m_scopep = nodep; iterateChildren(nodep); m_scopep = nullptr; } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { // Delete the varscope when we're finished nodep->unlinkFrBack(); pushDeletep(nodep); } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { iterateChildren(nodep); if (!nodep->varScopep()) { UASSERT_OBJ(nodep->varp()->isFuncLocal(), nodep, @@ -229,7 +229,7 @@ private: nodep->varScopep(nullptr); UINFO(9, " refout " << nodep << " selfPtr=" << nodep->selfPointer() << endl); } - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { // UINFO(9, " " << nodep << endl); iterateChildren(nodep); // Convert the hierch name @@ -239,9 +239,9 @@ private: // Can't do this, as we may have more calls later // nodep->funcp()->scopep(nullptr); } - virtual void visit(AstCMethodCall* nodep) override { iterateChildren(nodep); } - virtual void visit(AstCNew* nodep) override { iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCMethodCall* nodep) override { iterateChildren(nodep); } + void visit(AstCNew* nodep) override { iterateChildren(nodep); } + void visit(AstCFunc* nodep) override { VL_RESTORER(m_funcp); if (!nodep->user1()) { // Static functions should have been moved under the corresponding AstClassPackage @@ -264,13 +264,13 @@ private: } } } - virtual void visit(AstVar*) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit DescopeVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~DescopeVisitor() override = default; + ~DescopeVisitor() override = default; }; //###################################################################### diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 2451cfdfc..ca293eef1 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -110,7 +110,7 @@ public: // CONSTRUCTORS EmitCBaseVisitor() = default; - virtual ~EmitCBaseVisitor() override = default; + ~EmitCBaseVisitor() override = default; }; #endif // guard diff --git a/src/V3EmitCConstInit.h b/src/V3EmitCConstInit.h index 6c02bf099..9c0960180 100644 --- a/src/V3EmitCConstInit.h +++ b/src/V3EmitCConstInit.h @@ -45,7 +45,7 @@ class EmitCConstInit VL_NOT_FINAL : public EmitCBaseVisitor { protected: // VISITORS - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { VL_RESTORER(m_inUnpacked); VL_RESTORER(m_unpackedWord); m_inUnpacked = true; @@ -94,11 +94,11 @@ protected: } } - virtual void visit(AstInitItem* nodep) override { // LCOV_EXCL_START + void visit(AstInitItem* nodep) override { // LCOV_EXCL_START nodep->v3fatal("Handled by AstInitArray"); } // LCOV_EXCL_STOP - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { const V3Number& num = nodep->num(); UASSERT_OBJ(!num.isFourState(), nodep, "4-state value in constant pool"); const AstNodeDType* const dtypep = nodep->dtypep(); @@ -145,7 +145,7 @@ protected: } // Default - virtual void visit(AstNode* nodep) override { // LCOV_EXCL_START + void visit(AstNode* nodep) override { // LCOV_EXCL_START nodep->v3fatalSrc("Unknown node type reached EmitCConstInit: " << nodep->prettyTypeName()); } // LCOV_EXCL_STOP }; diff --git a/src/V3EmitCConstPool.cpp b/src/V3EmitCConstPool.cpp index 2fd22ccc4..d813fc955 100644 --- a/src/V3EmitCConstPool.cpp +++ b/src/V3EmitCConstPool.cpp @@ -100,7 +100,7 @@ class EmitCConstPool final : public EmitCConstInit { } // VISITORS - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { m_outFileSize += nodep->num().isString() ? 10 : nodep->isWide() ? nodep->widthWords() : 1; EmitCConstInit::visit(nodep); } diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 1426679a7..0bd404cb3 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -70,17 +70,17 @@ class EmitCLazyDecls final : public VNVisitor { } // VISITORS - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { lazyDeclare(nodep->funcp()); iterateChildren(nodep); } - virtual void visit(AstAddrOfCFunc* nodep) override { + void visit(AstAddrOfCFunc* nodep) override { lazyDeclare(nodep->funcp()); iterateChildren(nodep); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { AstVar* const varp = nodep->varp(); // Only constant pool symbols are lazy declared for now ... if (EmitCBaseVisitor::isConstPoolMod(EmitCParentModule::get(varp))) { @@ -88,7 +88,7 @@ class EmitCLazyDecls final : public VNVisitor { } } - virtual void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } + void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } VL_DEBUG_FUNC; @@ -211,7 +211,7 @@ public: // VISITORS using EmitCConstInit::visit; - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_useSelfForThis); VL_RESTORER(m_cfuncp); m_cfuncp = nodep; @@ -273,12 +273,12 @@ public: if (nodep->ifdef() != "") puts("#endif // " + nodep->ifdef() + "\n"); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { UASSERT_OBJ(m_cfuncp, nodep, "Cannot emit non-local variable"); emitVarDecl(nodep); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { bool paren = true; bool decind = false; bool rhs = true; @@ -360,8 +360,8 @@ public: if (decind) ofp()->blockDec(); puts(";\n"); } - virtual void visit(AstAlwaysPublic*) override {} - virtual void visit(AstAssocSel* nodep) override { + void visit(AstAlwaysPublic*) override {} + void visit(AstAssocSel* nodep) override { iterateAndNextNull(nodep->fromp()); putbs(".at("); AstAssocArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType); @@ -373,7 +373,7 @@ public: } puts(")"); } - virtual void visit(AstWildcardSel* nodep) override { + void visit(AstWildcardSel* nodep) override { iterateAndNextNull(nodep->fromp()); putbs(".at("); AstWildcardArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), WildcardArrayDType); @@ -381,7 +381,7 @@ public: iterateAndNextNull(nodep->bitp()); puts(")"); } - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { const AstCFunc* const funcp = nodep->funcp(); const AstNodeModule* const funcModp = EmitCParentModule::get(funcp); if (funcp->dpiImportPrototype()) { @@ -407,7 +407,7 @@ public: } emitCCallArgs(nodep, nodep->selfPointerProtect(m_useSelfForThis)); } - virtual void visit(AstCMethodCall* nodep) override { + void visit(AstCMethodCall* nodep) override { const AstCFunc* const funcp = nodep->funcp(); UASSERT_OBJ(!funcp->isLoose(), nodep, "Loose method called via AstCMethodCall"); iterate(nodep->fromp()); @@ -415,12 +415,12 @@ public: puts(funcp->nameProtect()); emitCCallArgs(nodep, ""); } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { puts("co_await "); iterate(nodep->exprp()); if (nodep->isStatement()) puts(";\n"); } - virtual void visit(AstCNew* nodep) override { + void visit(AstCNew* nodep) override { bool comma = false; puts("std::make_shared<" + prefixNameProtect(nodep->dtypep()) + ">("); puts("vlSymsp"); // TODO make this part of argsp, and eliminate when unnecessary @@ -432,7 +432,7 @@ public: } puts(")"); } - virtual void visit(AstCMethodHard* nodep) override { + void visit(AstCMethodHard* nodep) override { iterate(nodep->fromp()); puts("."); puts(nodep->name()); @@ -454,8 +454,8 @@ public: UASSERT_OBJ(!nodep->isStatement() || VN_IS(nodep->dtypep(), VoidDType), nodep, "Statement of non-void data type"); } - virtual void visit(AstLambdaArgRef* nodep) override { putbs(nodep->nameProtect()); } - virtual void visit(AstWith* nodep) override { + void visit(AstLambdaArgRef* nodep) override { putbs(nodep->nameProtect()); } + void visit(AstWith* nodep) override { // With uses a C++11 lambda putbs("[=]("); if (auto* const argrefp = nodep->indexArgRefp()) { @@ -470,11 +470,11 @@ public: iterateAndNextNull(nodep->exprp()); puts("; }\n"); } - virtual void visit(AstNodeCase* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodeCase* nodep) override { // LCOV_EXCL_LINE // In V3Case... nodep->v3fatalSrc("Case statements should have been reduced out"); } - virtual void visit(AstComment* nodep) override { + void visit(AstComment* nodep) override { string at; if (nodep->showAt()) { at = " at " + nodep->fileline()->ascii(); @@ -486,7 +486,7 @@ public: } iterateChildren(nodep); } - virtual void visit(AstCoverDecl* nodep) override { + void visit(AstCoverDecl* nodep) override { puts("vlSelf->__vlCoverInsert("); // As Declared in emitCoverageDecl puts("&(vlSymsp->__Vcoverage["); puts(cvtToStr(nodep->dataDeclThisp()->binNum())); @@ -514,7 +514,7 @@ public: putsQuoted(nodep->linescov()); puts(");\n"); } - virtual void visit(AstCoverInc* nodep) override { + void visit(AstCoverInc* nodep) override { if (v3Global.opt.threads()) { puts("vlSymsp->__Vcoverage["); puts(cvtToStr(nodep->declp()->dataDeclThisp()->binNum())); @@ -525,17 +525,17 @@ public: puts("]);\n"); } } - virtual void visit(AstCReturn* nodep) override { + void visit(AstCReturn* nodep) override { puts("return ("); iterateAndNextNull(nodep->lhsp()); puts(");\n"); } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { string text = nodep->fmtp()->text(); if (nodep->addNewline()) text += "\n"; displayNode(nodep, nodep->fmtp()->scopeNamep(), text, nodep->fmtp()->exprsp(), false); } - virtual void visit(AstDumpCtl* nodep) override { + void visit(AstDumpCtl* nodep) override { switch (nodep->ctlType()) { case VDumpCtlType::FILE: puts("vlSymsp->_vm_contextp__->dumpfile("); @@ -574,7 +574,7 @@ public: default: nodep->v3fatalSrc("Bad case, unexpected " << nodep->ctlType().ascii()); } } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { // For use under AstCCalls for dpiImports. ScopeNames under // displays are handled in AstDisplay if (!nodep->dpiExport()) { @@ -583,20 +583,20 @@ public: putbs("(&(vlSymsp->" + protect("__Vscope_" + scope) + "))"); } } - virtual void visit(AstSFormat* nodep) override { + void visit(AstSFormat* nodep) override { displayNode(nodep, nodep->fmtp()->scopeNamep(), nodep->fmtp()->text(), nodep->fmtp()->exprsp(), false); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { displayNode(nodep, nodep->scopeNamep(), nodep->text(), nodep->exprsp(), false); } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { displayNode(nodep, nullptr, nodep->text(), nodep->exprsp(), true); } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { displayNode(nodep, nullptr, nodep->text(), nodep->exprsp(), true); } - virtual void visit(AstValuePlusArgs* nodep) override { + void visit(AstValuePlusArgs* nodep) override { puts("VL_VALUEPLUSARGS_IN"); emitIQW(nodep->outp()); puts("("); @@ -608,19 +608,19 @@ public: iterateAndNextNull(nodep->outp()); puts(")"); } - virtual void visit(AstTestPlusArgs* nodep) override { + void visit(AstTestPlusArgs* nodep) override { puts("VL_TESTPLUSARGS_I("); emitCvtPackStr(nodep->searchp()); puts(")"); } - virtual void visit(AstFError* nodep) override { + void visit(AstFError* nodep) override { puts("VL_FERROR_IN("); iterateAndNextNull(nodep->filep()); putbs(", "); iterateAndNextNull(nodep->strp()); puts(")"); } - virtual void visit(AstFGetS* nodep) override { + void visit(AstFGetS* nodep) override { checkMaxWords(nodep); emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr); } @@ -633,7 +633,7 @@ public: << " bits exceeds hardcoded limit VL_VALUE_STRING_MAX_WORDS in verilatedos.h"); } } - virtual void visit(AstFOpen* nodep) override { + void visit(AstFOpen* nodep) override { iterateAndNextNull(nodep->filep()); puts(" = VL_FOPEN_NN("); emitCvtPackStr(nodep->filenamep()); @@ -643,13 +643,13 @@ public: emitCvtPackStr(nodep->modep()); puts(");\n"); } - virtual void visit(AstFOpenMcd* nodep) override { + void visit(AstFOpenMcd* nodep) override { iterateAndNextNull(nodep->filep()); puts(" = VL_FOPEN_MCD_N("); emitCvtPackStr(nodep->filenamep()); puts(");\n"); } - virtual void visit(AstNodeReadWriteMem* nodep) override { + void visit(AstNodeReadWriteMem* nodep) override { puts(nodep->cFuncPrefixp()); puts("N("); puts(nodep->isHex() ? "true" : "false"); @@ -698,14 +698,14 @@ public: } puts(");\n"); } - virtual void visit(AstFClose* nodep) override { + void visit(AstFClose* nodep) override { puts("VL_FCLOSE_I("); iterateAndNextNull(nodep->filep()); puts("); "); iterateAndNextNull(nodep->filep()); // For safety, so user doesn't later WRITE with it. puts(" = 0;\n"); } - virtual void visit(AstFFlush* nodep) override { + void visit(AstFFlush* nodep) override { if (!nodep->filep()) { puts("Verilated::runFlushCallbacks();\n"); } else { @@ -716,7 +716,7 @@ public: puts("); }\n"); } } - virtual void visit(AstFSeek* nodep) override { + void visit(AstFSeek* nodep) override { puts("(VL_FSEEK_I("); iterateAndNextNull(nodep->filep()); puts(","); @@ -725,17 +725,17 @@ public: iterateAndNextNull(nodep->operation()); puts(") == -1 ? -1 : 0)"); } - virtual void visit(AstFTell* nodep) override { + void visit(AstFTell* nodep) override { puts("VL_FTELL_I("); iterateAndNextNull(nodep->filep()); puts(")"); } - virtual void visit(AstFRewind* nodep) override { + void visit(AstFRewind* nodep) override { puts("(VL_FSEEK_I("); iterateAndNextNull(nodep->filep()); puts(", 0, 0) == -1 ? -1 : 0)"); } - virtual void visit(AstFRead* nodep) override { + void visit(AstFRead* nodep) override { puts("VL_FREAD_I("); puts(cvtToStr(nodep->memp()->widthMin())); // Need real storage width putbs(","); @@ -778,12 +778,12 @@ public: } puts(")"); } - virtual void visit(AstSysFuncAsTask* nodep) override { + void visit(AstSysFuncAsTask* nodep) override { if (!nodep->lhsp()->isWide()) puts("(void)"); iterateAndNextNull(nodep->lhsp()); if (!nodep->lhsp()->isWide()) puts(";"); } - virtual void visit(AstSystemT* nodep) override { + void visit(AstSystemT* nodep) override { puts("(void)VL_SYSTEM_I"); emitIQW(nodep->lhsp()); puts("("); @@ -795,7 +795,7 @@ public: iterateAndNextNull(nodep->lhsp()); puts(");\n"); } - virtual void visit(AstSystemF* nodep) override { + void visit(AstSystemF* nodep) override { puts("VL_SYSTEM_I"); emitIQW(nodep->lhsp()); puts("("); @@ -807,20 +807,20 @@ public: iterateAndNextNull(nodep->lhsp()); puts(")"); } - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { nodep->labelNum(++m_labelNum); puts("{\n"); // Make it visually obvious label jumps outside these iterateAndNextNull(nodep->stmtsp()); iterateAndNextNull(nodep->endStmtsp()); puts("}\n"); } - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { puts("goto __Vlabel" + cvtToStr(nodep->labelp()->blockp()->labelNum()) + ";\n"); } - virtual void visit(AstJumpLabel* nodep) override { + void visit(AstJumpLabel* nodep) override { puts("__Vlabel" + cvtToStr(nodep->blockp()->labelNum()) + ": ;\n"); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { iterateAndNextNull(nodep->precondsp()); puts("while ("); iterateAndNextNull(nodep->condp()); @@ -830,7 +830,7 @@ public: iterateAndNextNull(nodep->precondsp()); // Need to recompute before next loop puts("}\n"); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { puts("if ("); if (!nodep->branchPred().unknown()) { puts(nodep->branchPred().ascii()); @@ -854,7 +854,7 @@ public: } } } - virtual void visit(AstExprStmt* nodep) override { + void visit(AstExprStmt* nodep) override { // GCC allows compound statements in expressions, but this is not standard. // So we use an immediate-evaluation lambda and comma operator putbs("([&]() {\n"); @@ -863,7 +863,7 @@ public: iterateAndNextNull(nodep->resultp()); puts(")"); } - virtual void visit(AstStop* nodep) override { + void visit(AstStop* nodep) override { puts("VL_STOP_MT("); putsQuoted(protect(nodep->fileline()->filename())); puts(", "); @@ -871,38 +871,38 @@ public: puts(", \"\""); puts(");\n"); } - virtual void visit(AstFinish* nodep) override { + void visit(AstFinish* nodep) override { puts("VL_FINISH_MT("); putsQuoted(protect(nodep->fileline()->filename())); puts(", "); puts(cvtToStr(nodep->fileline()->lineno())); puts(", \"\");\n"); } - virtual void visit(AstPrintTimeScale* nodep) override { + void visit(AstPrintTimeScale* nodep) override { puts("VL_PRINTTIMESCALE("); putsQuoted(protect(nodep->name())); puts(", "); putsQuoted(nodep->timeunit().ascii()); puts(", vlSymsp->_vm_contextp__);\n"); } - virtual void visit(AstRand* nodep) override { + void visit(AstRand* nodep) override { emitOpName(nodep, nodep->emitC(), nodep->seedp(), nullptr, nullptr); } - virtual void visit(AstTime* nodep) override { + void visit(AstTime* nodep) override { puts("VL_TIME_UNITED_Q("); if (nodep->timeunit().isNone()) nodep->v3fatalSrc("$time has no units"); puts(cvtToStr(nodep->timeunit().multiplier() / v3Global.rootp()->timeprecision().multiplier())); puts(")"); } - virtual void visit(AstTimeD* nodep) override { + void visit(AstTimeD* nodep) override { puts("VL_TIME_UNITED_D("); if (nodep->timeunit().isNone()) nodep->v3fatalSrc("$realtime has no units"); puts(cvtToStr(nodep->timeunit().multiplier() / v3Global.rootp()->timeprecision().multiplier())); puts(")"); } - virtual void visit(AstTimeFormat* nodep) override { + void visit(AstTimeFormat* nodep) override { puts("VL_TIMEFORMAT_IINI("); iterateAndNextNull(nodep->unitsp()); puts(", "); @@ -913,7 +913,7 @@ public: iterateAndNextNull(nodep->widthp()); puts(", vlSymsp->_vm_contextp__);\n"); } - virtual void visit(AstNodeSimpleText* nodep) override { + void visit(AstNodeSimpleText* nodep) override { const string text = m_inUC && m_useSelfForThis ? VString::replaceWord(nodep->text(), "this", "vlSelf") : nodep->text(); @@ -923,29 +923,29 @@ public: ofp()->putsNoTracking(text); } } - virtual void visit(AstTextBlock* nodep) override { + void visit(AstTextBlock* nodep) override { visit(static_cast(nodep)); for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { iterate(childp); if (nodep->commas() && childp->nextp()) puts(", "); } } - virtual void visit(AstCStmt* nodep) override { + void visit(AstCStmt* nodep) override { putbs(""); iterateAndNextNull(nodep->bodysp()); } - virtual void visit(AstCMath* nodep) override { + void visit(AstCMath* nodep) override { putbs(""); iterateAndNextNull(nodep->bodysp()); } - virtual void visit(AstUCStmt* nodep) override { + void visit(AstUCStmt* nodep) override { VL_RESTORER(m_inUC); m_inUC = true; putsDecoration(ifNoProtect("// $c statement at " + nodep->fileline()->ascii() + "\n")); iterateAndNextNull(nodep->bodysp()); puts("\n"); } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { VL_RESTORER(m_inUC); m_inUC = true; puts("\n"); @@ -955,10 +955,10 @@ public: } // Operators - virtual void visit(AstNodeTermop* nodep) override { + void visit(AstNodeTermop* nodep) override { emitOpName(nodep, nodep->emitC(), nullptr, nullptr, nullptr); } - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeUniop* nodep) override { if (nodep->emitCheckMaxWords() && (nodep->widthWords() > VL_MULS_MAX_WORDS || nodep->lhsp()->widthWords() > VL_MULS_MAX_WORDS)) { @@ -978,7 +978,7 @@ public: emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nullptr, nullptr); } } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { if (nodep->emitCheckMaxWords() && nodep->widthWords() > VL_MULS_MAX_WORDS) { nodep->v3warn( E_UNSUPPORTED, @@ -998,11 +998,11 @@ public: emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr); } } - virtual void visit(AstNodeTriop* nodep) override { + void visit(AstNodeTriop* nodep) override { UASSERT_OBJ(!emitSimpleOk(nodep), nodep, "Triop cannot be described in a simple way"); emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nodep->thsp()); } - virtual void visit(AstRedXor* nodep) override { + void visit(AstRedXor* nodep) override { if (nodep->lhsp()->isWide()) { visit(static_cast(nodep)); } else { @@ -1018,7 +1018,7 @@ public: puts(")"); } } - virtual void visit(AstCCast* nodep) override { + void visit(AstCCast* nodep) override { // Extending a value of the same word width is just a NOP. if (nodep->size() <= VL_IDATASIZE) { puts("(IData)("); @@ -1028,7 +1028,7 @@ public: iterateAndNextNull(nodep->lhsp()); puts(")"); } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { // Widths match up already, so we'll just use C++'s operator w/o any temps. if (nodep->expr1p()->isWide()) { emitOpName(nodep, nodep->emitC(), nodep->condp(), nodep->expr1p(), nodep->expr2p()); @@ -1042,12 +1042,12 @@ public: puts(")"); } } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { iterateAndNextNull(nodep->fromp()); putbs("->"); puts(nodep->varp()->nameProtect()); } - virtual void visit(AstNullCheck* nodep) override { + void visit(AstNullCheck* nodep) override { puts("VL_NULL_CHECK("); iterateAndNextNull(nodep->lhsp()); puts(", "); @@ -1056,17 +1056,17 @@ public: puts(cvtToStr(nodep->fileline()->lineno())); puts(")"); } - virtual void visit(AstNewCopy* nodep) override { + void visit(AstNewCopy* nodep) override { puts("std::make_shared<" + prefixNameProtect(nodep->dtypep()) + ">("); puts("*"); // i.e. make into a reference iterateAndNextNull(nodep->rhsp()); puts(")"); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { // Note ASSIGN checks for this on a LHS emitOpName(nodep, nodep->emitC(), nodep->fromp(), nodep->lsbp(), nodep->thsp()); } - virtual void visit(AstReplicate* nodep) override { + void visit(AstReplicate* nodep) override { if (nodep->lhsp()->widthMin() == 1 && !nodep->isWide()) { UASSERT_OBJ((static_cast(VN_AS(nodep->rhsp(), Const)->toUInt()) * nodep->lhsp()->widthMin()) @@ -1085,7 +1085,7 @@ public: emitOpName(nodep, nodep->emitC(), nodep->lhsp(), nodep->rhsp(), nullptr); } } - virtual void visit(AstStreamL* nodep) override { + void visit(AstStreamL* nodep) override { // Attempt to use a "fast" stream function for slice size = power of 2 if (!nodep->isWide()) { const uint32_t isPow2 = VN_AS(nodep->rhsp(), Const)->num().countOnes() == 1; @@ -1107,14 +1107,14 @@ public: emitOpName(nodep, "VL_STREAML_%nq%lq%rq(%lw, %P, %li, %ri)", nodep->lhsp(), nodep->rhsp(), nullptr); } - virtual void visit(AstCastDynamic* nodep) override { + void visit(AstCastDynamic* nodep) override { putbs("VL_CAST_DYNAMIC("); iterateAndNextNull(nodep->lhsp()); puts(", "); iterateAndNextNull(nodep->rhsp()); puts(")"); } - virtual void visit(AstCountBits* nodep) override { + void visit(AstCountBits* nodep) override { putbs("VL_COUNTBITS_"); emitIQW(nodep->lhsp()); puts("("); @@ -1134,9 +1134,9 @@ public: iterateAndNextNull(nodep->fhsp()); puts(")"); } - virtual void visit(AstInitItem* nodep) override { iterateChildren(nodep); } + void visit(AstInitItem* nodep) override { iterateChildren(nodep); } // Terminals - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { const AstVar* const varp = nodep->varp(); const AstNodeModule* const varModp = EmitCParentModule::get(varp); if (isConstPoolMod(varModp)) { @@ -1153,14 +1153,14 @@ public: } puts(nodep->varp()->nameProtect()); } - virtual void visit(AstAddrOfCFunc* nodep) override { + void visit(AstAddrOfCFunc* nodep) override { // Note: Can be thought to handle more, but this is all that is needed right now const AstCFunc* const funcp = nodep->funcp(); UASSERT_OBJ(funcp->isLoose(), nodep, "Cannot take address of non-loose method"); puts("&"); puts(funcNameProtect(funcp)); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { if (m_emitConstInit) { EmitCConstInit::visit(nodep); } else if (nodep->isWide()) { @@ -1173,12 +1173,12 @@ public: } // - virtual void visit(AstMTaskBody* nodep) override { + void visit(AstMTaskBody* nodep) override { VL_RESTORER(m_useSelfForThis); m_useSelfForThis = true; iterateChildrenConst(nodep); } - virtual void visit(AstConsAssoc* nodep) override { + void visit(AstConsAssoc* nodep) override { putbs(nodep->dtypep()->cType("", false, false)); puts("()"); if (nodep->defaultp()) { @@ -1187,7 +1187,7 @@ public: puts(")"); } } - virtual void visit(AstSetAssoc* nodep) override { + void visit(AstSetAssoc* nodep) override { iterateAndNextNull(nodep->lhsp()); putbs(".set("); iterateAndNextNull(nodep->keyp()); @@ -1196,7 +1196,7 @@ public: iterateAndNextNull(nodep->valuep()); puts(")"); } - virtual void visit(AstConsWildcard* nodep) override { + void visit(AstConsWildcard* nodep) override { putbs(nodep->dtypep()->cType("", false, false)); puts("()"); if (nodep->defaultp()) { @@ -1205,7 +1205,7 @@ public: puts(")"); } } - virtual void visit(AstSetWildcard* nodep) override { + void visit(AstSetWildcard* nodep) override { iterateAndNextNull(nodep->lhsp()); putbs(".set("); iterateAndNextNull(nodep->keyp()); @@ -1214,7 +1214,7 @@ public: iterateAndNextNull(nodep->valuep()); puts(")"); } - virtual void visit(AstConsDynArray* nodep) override { + void visit(AstConsDynArray* nodep) override { putbs(nodep->dtypep()->cType("", false, false)); if (!nodep->lhsp()) { puts("()"); @@ -1229,7 +1229,7 @@ public: puts(")"); } } - virtual void visit(AstConsQueue* nodep) override { + void visit(AstConsQueue* nodep) override { putbs(nodep->dtypep()->cType("", false, false)); if (!nodep->lhsp()) { puts("()"); @@ -1244,11 +1244,11 @@ public: puts(")"); } } - virtual void visit(AstCReset* nodep) override { + void visit(AstCReset* nodep) override { AstVar* const varp = nodep->varrefp()->varp(); emitVarReset(varp); } - virtual void visit(AstExecGraph* nodep) override { + void visit(AstExecGraph* nodep) override { // The location of the AstExecGraph within the containing AstCFunc is where we want to // invoke the graph and wait for it to complete. Emitting the children does just that. UASSERT_OBJ(!nodep->mTaskBodiesp(), nodep, "These should have been lowered"); @@ -1256,7 +1256,7 @@ public: } // Default - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { puts(string("\n???? // ") + nodep->prettyTypeName() + "\n"); iterateChildren(nodep); // LCOV_EXCL_START @@ -1274,7 +1274,7 @@ public: m_trackText = trackText; iterate(nodep); } - virtual ~EmitCFunc() override = default; + ~EmitCFunc() override = default; }; #endif // guard diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index 474964b26..c4032b1f1 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -327,7 +327,7 @@ class EmitCHeader final : public EmitCConstInit { // Close output file VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); } - virtual ~EmitCHeader() override = default; + ~EmitCHeader() override = default; public: static void main(const AstNodeModule* modp) { EmitCHeader emitCHeader(modp); } diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index f4c90a5ed..43671b3c9 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -68,59 +68,59 @@ class EmitCGatherDependencies final : VNVisitor { } // VISITORS - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { addSelfDependency(nodep->selfPointer(), nodep->funcp()); iterateChildrenConst(nodep); } - virtual void visit(AstCNew* nodep) override { + void visit(AstCNew* nodep) override { addDTypeDependency(nodep->dtypep()); iterateChildrenConst(nodep); } - virtual void visit(AstCMethodCall* nodep) override { + void visit(AstCMethodCall* nodep) override { addDTypeDependency(nodep->fromp()->dtypep()); iterateChildrenConst(nodep); } - virtual void visit(AstNewCopy* nodep) override { + void visit(AstNewCopy* nodep) override { addDTypeDependency(nodep->dtypep()); iterateChildrenConst(nodep); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { addDTypeDependency(nodep->fromp()->dtypep()); iterateChildrenConst(nodep); } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { addSelfDependency(nodep->selfPointer(), nodep->varp()); iterateChildrenConst(nodep); } - virtual void visit(AstCoverDecl* nodep) override { + void visit(AstCoverDecl* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstCoverInc* nodep) override { + void visit(AstCoverInc* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstDumpCtl* nodep) override { + void visit(AstDumpCtl* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstPrintTimeScale* nodep) override { + void visit(AstPrintTimeScale* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstTimeFormat* nodep) override { + void visit(AstTimeFormat* nodep) override { addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstNodeSimpleText* nodep) override { + void visit(AstNodeSimpleText* nodep) override { if (nodep->text().find("vlSymsp") != string::npos) addSymsDependency(); iterateChildrenConst(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } + void visit(AstNode* nodep) override { iterateChildrenConst(nodep); } // CONSTRUCTOR explicit EmitCGatherDependencies(AstCFunc* cfuncp) { @@ -517,7 +517,7 @@ class EmitCImp final : EmitCFunc { } // VISITORS - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (splitNeeded()) { // Splitting file, so using parallel build. v3Global.useParallelBuild(true); @@ -549,7 +549,7 @@ class EmitCImp final : EmitCFunc { // Emit implementations of all AstCFunc emitCFuncImp(modp); } - virtual ~EmitCImp() override = default; + ~EmitCImp() override = default; public: static void main(const AstNodeModule* modp, bool slow, std::deque& cfilesr) { @@ -828,7 +828,7 @@ class EmitCTrace final : EmitCFunc { // VISITORS using EmitCFunc::visit; // Suppress hidden overloaded virtual function warning - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (!nodep->isTrace()) return; if (nodep->slow() != m_slow) return; @@ -843,17 +843,17 @@ class EmitCTrace final : EmitCFunc { EmitCFunc::visit(nodep); } - virtual void visit(AstTracePushNamePrefix* nodep) override { + void visit(AstTracePushNamePrefix* nodep) override { puts("tracep->pushNamePrefix("); putsQuoted(VIdProtect::protectWordsIf(nodep->prefix(), nodep->protect())); puts(");\n"); } - virtual void visit(AstTracePopNamePrefix* nodep) override { // + void visit(AstTracePopNamePrefix* nodep) override { // puts("tracep->popNamePrefix("); puts(cvtToStr(nodep->count())); puts(");\n"); } - virtual void visit(AstTraceDecl* nodep) override { + void visit(AstTraceDecl* nodep) override { const int enumNum = emitTraceDeclDType(nodep->dtypep()); if (nodep->arrayRange().ranged()) { puts("for (int i = 0; i < " + cvtToStr(nodep->arrayRange().elements()) + "; ++i) {\n"); @@ -864,7 +864,7 @@ class EmitCTrace final : EmitCFunc { puts("\n"); } } - virtual void visit(AstTraceInc* nodep) override { + void visit(AstTraceInc* nodep) override { if (nodep->declp()->arrayRange().ranged()) { // It traces faster if we unroll the loop for (int i = 0; i < nodep->declp()->arrayRange().elements(); i++) { @@ -888,7 +888,7 @@ class EmitCTrace final : EmitCFunc { // Close output file VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); } - virtual ~EmitCTrace() override = default; + ~EmitCTrace() override = default; public: static void main(AstNodeModule* modp, bool slow, std::deque& cfilesr) { diff --git a/src/V3EmitCInlines.cpp b/src/V3EmitCInlines.cpp index f9a667e25..36b92ffec 100644 --- a/src/V3EmitCInlines.cpp +++ b/src/V3EmitCInlines.cpp @@ -32,18 +32,18 @@ class EmitCInlines final : EmitCBaseVisitor { // METHODS // VISITORS - virtual void visit(AstCNew* nodep) override { + void visit(AstCNew* nodep) override { if (v3Global.opt.savable()) v3warn(E_UNSUPPORTED, "Unsupported: --savable with dynamic new"); iterateChildren(nodep); } - virtual void visit(AstDumpCtl* nodep) override { + void visit(AstDumpCtl* nodep) override { if (v3Global.opt.trace()) v3Global.needTraceDumper(true); iterateChildren(nodep); } //--------------------------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: explicit EmitCInlines(AstNetlist* nodep) { iterate(nodep); } diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index 833766dc6..ce744b4a6 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -32,7 +32,7 @@ class EmitCMain final : EmitCBaseVisitor { // VISITORS // This visitor doesn't really iterate, but exist to appease base class - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } // LCOV_EXCL_LINE + void visit(AstNode* nodep) override { iterateChildren(nodep); } // LCOV_EXCL_LINE public: // CONSTRUCTORS diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 74104e500..115a449ea 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -201,7 +201,7 @@ class EmitCModel final : public EmitCFunc { + "C* tfp, int levels, int options = 0);\n"); if (optSystemC()) { puts("/// SC tracing; avoid overloaded virtual function lint warning\n"); - puts("virtual void trace(sc_trace_file* tfp) const override { " + puts("void trace(sc_trace_file* tfp) const override { " "::sc_core::sc_module::trace(tfp); }\n"); } } diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index d2c3fbf93..97edeafbe 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -258,7 +258,7 @@ class EmitCSyms final : EmitCBaseVisitor { } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Collect list of scopes iterateChildren(nodep); varsExpand(); @@ -280,8 +280,8 @@ class EmitCSyms final : EmitCBaseVisitor { if (!m_dpiHdrOnly) emitDpiImp(); } } - virtual void visit(AstConstPool* nodep) override {} // Ignore - virtual void visit(AstNodeModule* nodep) override { + void visit(AstConstPool* nodep) override {} // Ignore + void visit(AstNodeModule* nodep) override { nameCheck(nodep); VL_RESTORER(m_modp); { @@ -289,7 +289,7 @@ class EmitCSyms final : EmitCBaseVisitor { iterateChildren(nodep); } } - virtual void visit(AstCellInline* nodep) override { + void visit(AstCellInline* nodep) override { if (v3Global.opt.vpi()) { const string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE"; @@ -300,7 +300,7 @@ class EmitCSyms final : EmitCBaseVisitor { std::make_pair(name, ScopeData(scopeSymString(name), name_dedot, timeunit, type))); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { if (VN_IS(m_modp, Class)) return; // The ClassPackage is what is visible nameCheck(nodep); @@ -315,7 +315,7 @@ class EmitCSyms final : EmitCBaseVisitor { timeunit, type))); } } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { const string name = nodep->scopeSymName(); // UINFO(9,"scnameins sp "<name()<<" sp "<scopePrettySymName() // <<" ss"<isSigUserRdPublic() && !m_cfuncp) m_modVars.emplace_back(std::make_pair(m_modp, nodep)); } - virtual void visit(AstCoverDecl* nodep) override { + void visit(AstCoverDecl* nodep) override { // Assign numbers to all bins, so we know how big of an array to use if (!nodep->dataDeclNullp()) { // else duplicate we don't need code for nodep->binNum(m_coverBins++); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { nameCheck(nodep); if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) m_dpis.push_back(nodep); VL_RESTORER(m_cfuncp); @@ -360,8 +360,8 @@ class EmitCSyms final : EmitCBaseVisitor { } //--------------------------------------- - virtual void visit(AstConst*) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstConst*) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: explicit EmitCSyms(AstNetlist* nodep, bool dpiHdrOnly) diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index a5246eae6..0260135b7 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -53,14 +53,14 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } // VISITORS - virtual void visit(AstNetlist* nodep) override { iterateAndNextConstNull(nodep->modulesp()); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNetlist* nodep) override { iterateAndNextConstNull(nodep->modulesp()); } + void visit(AstNodeModule* nodep) override { putfs(nodep, nodep->verilogKwd() + " " + prefixNameProtect(nodep) + ";\n"); iterateChildrenConst(nodep); putqs(nodep, "end" + nodep->verilogKwd() + "\n"); } - virtual void visit(AstPort* nodep) override {} - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstPort* nodep) override {} + void visit(AstNodeFTask* nodep) override { putfs(nodep, nodep->isFunction() ? "function" : "task"); puts(" "); puts(nodep->prettyName()); @@ -70,7 +70,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { putfs(nodep, nodep->isFunction() ? "endfunction\n" : "endtask\n"); } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { if (nodep->name() == "") { putbs("begin\n"); } else { @@ -79,7 +79,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateChildrenConst(nodep); puts("end\n"); } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (nodep->name() == "") { putbs("fork\n"); } else { @@ -89,19 +89,19 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { puts(nodep->joinType().verilogKwd()); puts("\n"); } - virtual void visit(AstFinal* nodep) override { + void visit(AstFinal* nodep) override { putfs(nodep, "final begin\n"); iterateChildrenConst(nodep); putqs(nodep, "end\n"); } - virtual void visit(AstInitial* nodep) override { + void visit(AstInitial* nodep) override { putfs(nodep, "initial begin\n"); iterateChildrenConst(nodep); putqs(nodep, "end\n"); } - virtual void visit(AstInitialAutomatic* nodep) override { iterateChildrenConst(nodep); } - virtual void visit(AstInitialStatic* nodep) override { iterateChildrenConst(nodep); } - virtual void visit(AstAlways* nodep) override { + void visit(AstInitialAutomatic* nodep) override { iterateChildrenConst(nodep); } + void visit(AstInitialStatic* nodep) override { iterateChildrenConst(nodep); } + void visit(AstAlways* nodep) override { putfs(nodep, "always "); if (m_sensesp) { iterateAndNextConstNull(m_sensesp); @@ -113,7 +113,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->bodysp()); putqs(nodep, "end\n"); } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { putfs(nodep, "/*verilator public_flat_rw "); if (m_sensesp) { iterateAndNextConstNull(m_sensesp); @@ -125,43 +125,43 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->bodysp()); putqs(nodep, "*/\n"); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (VN_IS(nodep, AssignForce)) puts("force "); iterateAndNextConstNull(nodep->lhsp()); putfs(nodep, " " + nodep->verilogKwd() + " "); iterateAndNextConstNull(nodep->rhsp()); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { iterateAndNextConstNull(nodep->lhsp()); putfs(nodep, " <= "); iterateAndNextConstNull(nodep->rhsp()); puts(";\n"); } - virtual void visit(AstAssignAlias* nodep) override { + void visit(AstAssignAlias* nodep) override { putbs("alias "); iterateAndNextConstNull(nodep->lhsp()); putfs(nodep, " = "); iterateAndNextConstNull(nodep->rhsp()); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { putfs(nodep, "assign "); iterateAndNextConstNull(nodep->lhsp()); putbs(" = "); iterateAndNextConstNull(nodep->rhsp()); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { puts("release "); iterateAndNextConstNull(nodep->lhsp()); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstBreak*) override { + void visit(AstBreak*) override { putbs("break"); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { // AstSenItem is called for dumping in isolation by V3Order putfs(nodep, "@("); for (AstNode* expp = nodep->sensesp(); expp; expp = expp->nextp()) { @@ -170,13 +170,13 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(")"); } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { putfs(nodep, ""); puts(nodep->edgeType().verilogKwd()); if (nodep->sensp()) puts(" "); iterateChildrenConst(nodep); } - virtual void visit(AstNodeCase* nodep) override { + void visit(AstNodeCase* nodep) override { putfs(nodep, ""); if (const AstCase* const casep = VN_CAST(nodep, Case)) { if (casep->priorityPragma()) puts("priority "); @@ -197,7 +197,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->itemsp()); putqs(nodep, "endcase\n"); } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { if (nodep->condsp()) { iterateAndNextConstNull(nodep->condsp()); } else { @@ -207,17 +207,17 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->bodysp()); putqs(nodep, "end\n"); } - virtual void visit(AstComment* nodep) override { + void visit(AstComment* nodep) override { puts(std::string{"// "} + nodep->name() + "\n"); iterateChildrenConst(nodep); } - virtual void visit(AstContinue*) override { + void visit(AstContinue*) override { putbs("continue"); if (!m_suppressSemi) puts(";\n"); } - virtual void visit(AstCoverDecl*) override {} // N/A - virtual void visit(AstCoverInc*) override {} // N/A - virtual void visit(AstCoverToggle*) override {} // N/A + void visit(AstCoverDecl*) override {} // N/A + void visit(AstCoverInc*) override {} // N/A + void visit(AstCoverToggle*) override {} // N/A void visitNodeDisplay(AstNode* nodep, AstNode* fileOrStrgp, const string& text, AstNode* exprsp) { @@ -234,26 +234,26 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(");\n"); } - virtual void visit(AstDisable* nodep) override { putbs("disable " + nodep->name() + ";\n"); } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisable* nodep) override { putbs("disable " + nodep->name() + ";\n"); } + void visit(AstDisplay* nodep) override { visitNodeDisplay(nodep, nodep->filep(), nodep->fmtp()->text(), nodep->fmtp()->exprsp()); } - virtual void visit(AstElabDisplay* nodep) override { + void visit(AstElabDisplay* nodep) override { visitNodeDisplay(nodep, nullptr, nodep->fmtp()->text(), nodep->fmtp()->exprsp()); } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { visitNodeDisplay(nodep, nodep->filep(), nodep->text(), nodep->exprsp()); } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { visitNodeDisplay(nodep, nodep->fromp(), nodep->text(), nodep->exprsp()); } - virtual void visit(AstSFormat* nodep) override { + void visit(AstSFormat* nodep) override { visitNodeDisplay(nodep, nodep->lhsp(), nodep->fmtp()->text(), nodep->fmtp()->exprsp()); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { visitNodeDisplay(nodep, nullptr, nodep->text(), nodep->exprsp()); } - virtual void visit(AstFOpen* nodep) override { + void visit(AstFOpen* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); iterateAndNextConstNull(nodep->filenamep()); @@ -261,36 +261,34 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->modep()); puts(");\n"); } - virtual void visit(AstFOpenMcd* nodep) override { + void visit(AstFOpenMcd* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); iterateAndNextConstNull(nodep->filenamep()); puts(");\n"); } - virtual void visit(AstFClose* nodep) override { + void visit(AstFClose* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); if (nodep->filep()) iterateAndNextConstNull(nodep->filep()); puts(");\n"); } - virtual void visit(AstFFlush* nodep) override { + void visit(AstFFlush* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); if (nodep->filep()) iterateAndNextConstNull(nodep->filep()); puts(");\n"); } - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { putbs("begin : label" + cvtToStr(nodep->labelNum()) + "\n"); if (nodep->stmtsp()) iterateAndNextConstNull(nodep->stmtsp()); puts("end\n"); } - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { putbs("disable label" + cvtToStr(nodep->labelp()->blockp()->labelNum()) + ";\n"); } - virtual void visit(AstJumpLabel* nodep) override { - putbs("// " + cvtToStr(nodep->blockp()) + ":\n"); - } - virtual void visit(AstNodeReadWriteMem* nodep) override { + void visit(AstJumpLabel* nodep) override { putbs("// " + cvtToStr(nodep->blockp()) + ":\n"); } + void visit(AstNodeReadWriteMem* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); if (nodep->filenamep()) iterateAndNextConstNull(nodep->filenamep()); @@ -306,17 +304,17 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(");\n"); } - virtual void visit(AstSysFuncAsTask* nodep) override { + void visit(AstSysFuncAsTask* nodep) override { iterateAndNextConstNull(nodep->lhsp()); puts(";\n"); } - virtual void visit(AstSysIgnore* nodep) override { + void visit(AstSysIgnore* nodep) override { putfs(nodep, nodep->verilogKwd()); putbs("("); iterateAndNextConstNull(nodep->exprsp()); puts(");\n"); } - virtual void visit(AstNodeFor* nodep) override { + void visit(AstNodeFor* nodep) override { putfs(nodep, "for ("); { VL_RESTORER(m_suppressSemi); @@ -331,14 +329,14 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->bodysp()); putqs(nodep, "end\n"); } - virtual void visit(AstRepeat* nodep) override { + void visit(AstRepeat* nodep) override { putfs(nodep, "repeat ("); iterateAndNextConstNull(nodep->countp()); puts(") begin\n"); iterateAndNextConstNull(nodep->bodysp()); putfs(nodep, "end\n"); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { iterateAndNextConstNull(nodep->precondsp()); putfs(nodep, "while ("); iterateAndNextConstNull(nodep->condp()); @@ -348,7 +346,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->precondsp()); // Need to recompute before next loop putfs(nodep, "end\n"); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { putfs(nodep, ""); if (const AstIf* const ifp = VN_CAST(nodep, If)) { if (ifp->priorityPragma()) puts("priority "); @@ -366,7 +364,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } putqs(nodep, "end\n"); } - virtual void visit(AstPast* nodep) override { + void visit(AstPast* nodep) override { putfs(nodep, "$past("); iterateAndNextConstNull(nodep->exprp()); if (nodep->ticksp()) { @@ -375,21 +373,21 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(")"); } - virtual void visit(AstReturn* nodep) override { + void visit(AstReturn* nodep) override { putfs(nodep, "return "); iterateAndNextConstNull(nodep->lhsp()); puts(";\n"); } - virtual void visit(AstStop* nodep) override { putfs(nodep, "$stop;\n"); } - virtual void visit(AstFinish* nodep) override { putfs(nodep, "$finish;\n"); } - virtual void visit(AstNodeSimpleText* nodep) override { + void visit(AstStop* nodep) override { putfs(nodep, "$stop;\n"); } + void visit(AstFinish* nodep) override { putfs(nodep, "$finish;\n"); } + void visit(AstNodeSimpleText* nodep) override { if (nodep->tracking() || m_trackText) { puts(nodep->text()); } else { putsNoTracking(nodep->text()); } } - virtual void visit(AstTextBlock* nodep) override { + void visit(AstTextBlock* nodep) override { visit(static_cast(nodep)); { VL_RESTORER(m_suppressSemi); @@ -400,29 +398,29 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } } } - virtual void visit(AstScopeName* nodep) override {} - virtual void visit(AstCStmt* nodep) override { + void visit(AstScopeName* nodep) override {} + void visit(AstCStmt* nodep) override { putfs(nodep, "$_CSTMT("); iterateAndNextConstNull(nodep->bodysp()); puts(");\n"); } - virtual void visit(AstCMath* nodep) override { + void visit(AstCMath* nodep) override { putfs(nodep, "$_CMATH("); iterateAndNextConstNull(nodep->bodysp()); puts(");\n"); } - virtual void visit(AstUCStmt* nodep) override { + void visit(AstUCStmt* nodep) override { putfs(nodep, "$c("); iterateAndNextConstNull(nodep->bodysp()); puts(");\n"); } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { putfs(nodep, "$c("); iterateAndNextConstNull(nodep->bodysp()); puts(")"); } - virtual void visit(AstCMethodHard* nodep) override { + void visit(AstCMethodHard* nodep) override { iterate(nodep->fromp()); puts("." + nodep->name() + "("); for (AstNode* pinp = nodep->pinsp(); pinp; pinp = pinp->nextp()) { @@ -491,25 +489,23 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } } - virtual void visit(AstNodeTermop* nodep) override { - emitVerilogFormat(nodep, nodep->emitVerilog()); - } - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeTermop* nodep) override { emitVerilogFormat(nodep, nodep->emitVerilog()); } + void visit(AstNodeUniop* nodep) override { emitVerilogFormat(nodep, nodep->emitVerilog(), nodep->lhsp()); } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { emitVerilogFormat(nodep, nodep->emitVerilog(), nodep->lhsp(), nodep->rhsp()); } - virtual void visit(AstNodeTriop* nodep) override { + void visit(AstNodeTriop* nodep) override { emitVerilogFormat(nodep, nodep->emitVerilog(), nodep->lhsp(), nodep->rhsp(), nodep->thsp()); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { iterate(nodep->fromp()); puts("."); puts(nodep->prettyName()); } - virtual void visit(AstAttrOf* nodep) override { + void visit(AstAttrOf* nodep) override { putfs(nodep, "$_ATTROF("); iterateAndNextConstNull(nodep->fromp()); if (nodep->dimp()) { @@ -518,7 +514,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(")"); } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { putfs(nodep, "'{"); int comma = 0; const auto& mapr = nodep->map(); @@ -531,7 +527,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts("}"); } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { putbs("("); iterateAndNextConstNull(nodep->condp()); putfs(nodep, " ? "); @@ -540,7 +536,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->expr2p()); puts(")"); } - virtual void visit(AstRange* nodep) override { + void visit(AstRange* nodep) override { puts("["); if (VN_IS(nodep->leftp(), Const) && VN_IS(nodep->rightp(), Const)) { // Looks nicer if we print [1:0] rather than [32'sh1:32sh0] @@ -555,7 +551,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { puts("]"); } } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { iterateAndNextConstNull(nodep->fromp()); puts("["); if (VN_IS(nodep->lsbp(), Const)) { @@ -579,18 +575,18 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts("]"); } - virtual void visit(AstSliceSel* nodep) override { + void visit(AstSliceSel* nodep) override { iterateAndNextConstNull(nodep->fromp()); puts(cvtToStr(nodep->declRange())); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { putfs(nodep, "typedef "); iterateAndNextConstNull(nodep->dtypep()); puts(" "); puts(nodep->prettyName()); puts(";\n"); } - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { if (nodep->isSigned()) putfs(nodep, "signed "); putfs(nodep, nodep->prettyName()); if (nodep->rangep()) { @@ -603,15 +599,15 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { puts(":0] "); } } - virtual void visit(AstConstDType* nodep) override { + void visit(AstConstDType* nodep) override { putfs(nodep, "const "); iterate(nodep->subDTypep()); } - virtual void visit(AstNodeArrayDType* nodep) override { + void visit(AstNodeArrayDType* nodep) override { iterate(nodep->subDTypep()); iterateAndNextConstNull(nodep->rangep()); } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { puts(nodep->verilogKwd() + " "); if (nodep->packed()) puts("packed "); puts("\n"); @@ -619,12 +615,12 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->membersp()); puts("}"); } - virtual void visit(AstMemberDType* nodep) override { + void visit(AstMemberDType* nodep) override { iterate(nodep->subDTypep()); puts(" "); puts(nodep->name()); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { if (nodep->dotted() != "") { putfs(nodep, nodep->dotted()); puts("."); @@ -636,14 +632,14 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { iterateAndNextConstNull(nodep->pinsp()); puts(")"); } - virtual void visit(AstArg* nodep) override { iterateAndNextConstNull(nodep->exprp()); } - virtual void visit(AstPrintTimeScale* nodep) override { + void visit(AstArg* nodep) override { iterateAndNextConstNull(nodep->exprp()); } + void visit(AstPrintTimeScale* nodep) override { puts(nodep->verilogKwd()); puts(";\n"); } // Terminals - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->varScopep()) { putfs(nodep, nodep->varScopep()->prettyName()); } else { @@ -659,7 +655,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } } } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { putfs(nodep, nodep->dotted()); puts("."); if (nodep->varp()) { @@ -668,12 +664,12 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { puts(nodep->prettyName()); } } - virtual void visit(AstConst* nodep) override { putfs(nodep, nodep->num().ascii(true, true)); } + void visit(AstConst* nodep) override { putfs(nodep, nodep->num().ascii(true, true)); } // Just iterate - virtual void visit(AstTopScope* nodep) override { iterateChildrenConst(nodep); } - virtual void visit(AstScope* nodep) override { iterateChildrenConst(nodep); } - virtual void visit(AstVar* nodep) override { + void visit(AstTopScope* nodep) override { iterateChildrenConst(nodep); } + void visit(AstScope* nodep) override { iterateChildrenConst(nodep); } + void visit(AstVar* nodep) override { if (nodep->isIO()) { putfs(nodep, nodep->verilogKwd()); puts(" "); @@ -701,21 +697,21 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } puts(m_suppressVarSemi ? "\n" : ";\n"); } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { m_sensesp = nodep->sensesp(); iterateAndNextConstNull(nodep->stmtsp()); m_sensesp = nullptr; } - virtual void visit(AstParseRef* nodep) override { puts(nodep->prettyName()); } - virtual void visit(AstVarScope*) override {} - virtual void visit(AstNodeText*) override {} - virtual void visit(AstTraceDecl*) override {} - virtual void visit(AstTraceInc*) override {} + void visit(AstParseRef* nodep) override { puts(nodep->prettyName()); } + void visit(AstVarScope*) override {} + void visit(AstNodeText*) override {} + void visit(AstTraceDecl*) override {} + void visit(AstTraceInc*) override {} // NOPs - virtual void visit(AstPragma*) override {} - virtual void visit(AstCell*) override {} // Handled outside the Visit class + void visit(AstPragma*) override {} + void visit(AstCell*) override {} // Handled outside the Visit class // Default - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { puts(std::string{"\n???? // "} + nodep->prettyTypeName() + "\n"); iterateChildrenConst(nodep); // Not v3fatalSrc so we keep processing @@ -730,7 +726,7 @@ public: explicit EmitVBaseVisitor(bool suppressUnknown, AstSenTree* domainp) : m_suppressUnknown{suppressUnknown} , m_sensesp{domainp} {} - virtual ~EmitVBaseVisitor() override = default; + ~EmitVBaseVisitor() override = default; }; //###################################################################### @@ -741,11 +737,11 @@ class EmitVFileVisitor final : public EmitVBaseVisitor { V3OutFile* m_ofp; // METHODS V3OutFile* ofp() const { return m_ofp; } - virtual void puts(const string& str) override { ofp()->puts(str); } - virtual void putbs(const string& str) override { ofp()->putbs(str); } - virtual void putfs(AstNode*, const string& str) override { putbs(str); } - virtual void putqs(AstNode*, const string& str) override { putbs(str); } - virtual void putsNoTracking(const string& str) override { ofp()->putsNoTracking(str); } + void puts(const string& str) override { ofp()->puts(str); } + void putbs(const string& str) override { ofp()->putbs(str); } + void putfs(AstNode*, const string& str) override { putbs(str); } + void putqs(AstNode*, const string& str) override { putbs(str); } + void putsNoTracking(const string& str) override { ofp()->putsNoTracking(str); } public: EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp, bool trackText, bool suppressUnknown) @@ -754,7 +750,7 @@ public: m_trackText = trackText; iterate(nodep); } - virtual ~EmitVFileVisitor() override = default; + ~EmitVFileVisitor() override = default; }; //###################################################################### @@ -764,11 +760,11 @@ class EmitVStreamVisitor final : public EmitVBaseVisitor { // MEMBERS std::ostream& m_os; // METHODS - virtual void putsNoTracking(const string& str) override { m_os << str; } - virtual void puts(const string& str) override { putsNoTracking(str); } - virtual void putbs(const string& str) override { puts(str); } - virtual void putfs(AstNode*, const string& str) override { putbs(str); } - virtual void putqs(AstNode*, const string& str) override { putbs(str); } + void putsNoTracking(const string& str) override { m_os << str; } + void puts(const string& str) override { putsNoTracking(str); } + void putbs(const string& str) override { puts(str); } + void putfs(AstNode*, const string& str) override { putbs(str); } + void putqs(AstNode*, const string& str) override { putbs(str); } public: EmitVStreamVisitor(const AstNode* nodep, std::ostream& os) @@ -776,7 +772,7 @@ public: , m_os(os) { // Need () or GCC 4.8 false warning iterate(const_cast(nodep)); } - virtual ~EmitVStreamVisitor() override = default; + ~EmitVStreamVisitor() override = default; }; //###################################################################### @@ -789,7 +785,7 @@ class EmitVPrefixedFormatter final : public V3OutFormatter { int m_column = 0; // Rough location; need just zero or non-zero FileLine* m_prefixFl; // METHODS - virtual void putcOutput(char chr) override { + void putcOutput(char chr) override { if (chr == '\n') { m_column = 0; m_os << chr; @@ -806,7 +802,7 @@ class EmitVPrefixedFormatter final : public V3OutFormatter { } } - virtual void putsOutput(const char* strg) override { + void putsOutput(const char* strg) override { for (const char* cp = strg; *cp; cp++) putcOutput(*cp); } @@ -822,7 +818,7 @@ public: m_prefixFl = v3Global.rootp()->fileline(); // NETLIST's fileline instead of nullptr to // avoid nullptr checks } - virtual ~EmitVPrefixedFormatter() override { + ~EmitVPrefixedFormatter() override { if (m_column) puts("\n"); } }; @@ -832,13 +828,13 @@ class EmitVPrefixedVisitor final : public EmitVBaseVisitor { EmitVPrefixedFormatter m_formatter; // Special verilog formatter (Way down the // inheritance is another unused V3OutFormatter) // METHODS - virtual void putsNoTracking(const string& str) override { m_formatter.putsNoTracking(str); } - virtual void puts(const string& str) override { m_formatter.puts(str); } + void putsNoTracking(const string& str) override { m_formatter.putsNoTracking(str); } + void puts(const string& str) override { m_formatter.puts(str); } // We don't use m_formatter's putbs because the tokens will change filelines // and insert returns at the proper locations - virtual void putbs(const string& str) override { m_formatter.puts(str); } - virtual void putfs(AstNode* nodep, const string& str) override { putfsqs(nodep, str, false); } - virtual void putqs(AstNode* nodep, const string& str) override { putfsqs(nodep, str, true); } + void putbs(const string& str) override { m_formatter.puts(str); } + void putfs(AstNode* nodep, const string& str) override { putfsqs(nodep, str, false); } + void putqs(AstNode* nodep, const string& str) override { putfsqs(nodep, str, true); } void putfsqs(AstNode* nodep, const string& str, bool quiet) { if (m_formatter.prefixFl() != nodep->fileline()) { m_formatter.prefixFl(nodep->fileline()); @@ -856,7 +852,7 @@ public: if (user3mark) VNUser3InUse::check(); iterate(const_cast(nodep)); } - virtual ~EmitVPrefixedVisitor() override = default; + ~EmitVPrefixedVisitor() override = default; }; //###################################################################### diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index fc0865a95..a791bfde9 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -101,11 +101,11 @@ class EmitXmlFileVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { outputTag(nodep, "contassign"); // IEEE: vpiContAssign outputChildrenEnd(nodep, "contassign"); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { outputTag(nodep, "instance"); // IEEE: vpiInstance puts(" defName="); putsQuoted(nodep->modName()); // IEEE vpiDefName @@ -113,7 +113,7 @@ class EmitXmlFileVisitor final : public VNVisitor { putsQuoted(nodep->origName()); outputChildrenEnd(nodep, "instance"); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { outputTag(nodep, "if"); puts(">\n"); iterateAndNextNull(nodep->op1p()); @@ -127,7 +127,7 @@ class EmitXmlFileVisitor final : public VNVisitor { } puts("\n"); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { outputTag(nodep, "while"); puts(">\n"); puts("\n"); @@ -150,19 +150,19 @@ class EmitXmlFileVisitor final : public VNVisitor { } puts("\n"); } - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { puts("\n"); iterateChildren(nodep); puts("\n"); } - virtual void visit(AstConstPool* nodep) override { + void visit(AstConstPool* nodep) override { if (!v3Global.opt.xmlOnly()) { puts("\n"); iterateChildren(nodep); puts("\n"); } } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { puts("\n"); const auto& mapr = nodep->map(); for (const auto& itr : mapr) { @@ -174,7 +174,7 @@ class EmitXmlFileVisitor final : public VNVisitor { } puts("\n"); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { outputTag(nodep, ""); puts(" origName="); putsQuoted(nodep->origName()); @@ -184,7 +184,7 @@ class EmitXmlFileVisitor final : public VNVisitor { if (nodep->modPublic()) puts(" public=\"true\""); outputChildrenEnd(nodep, ""); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { const VVarType typ = nodep->varType(); const string kw = nodep->verilogKwd(); const string vt = nodep->dtypep()->name(); @@ -221,7 +221,7 @@ class EmitXmlFileVisitor final : public VNVisitor { if (nodep->attrSFormat()) puts(" sformat=\"true\""); outputChildrenEnd(nodep, ""); } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // What we call a pin in verilator is a port in the IEEE spec. outputTag(nodep, "port"); // IEEE: vpiPort if (nodep->modVarp()->isIO()) { @@ -231,12 +231,12 @@ class EmitXmlFileVisitor final : public VNVisitor { // Children includes vpiHighConn and vpiLowConn; we don't support port bits (yet?) outputChildrenEnd(nodep, "port"); } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { outputTag(nodep, ""); puts(" edgeType=\"" + cvtToStr(nodep->edgeType().ascii()) + "\""); // IEEE vpiTopModule outputChildrenEnd(nodep, ""); } - virtual void visit(AstModportVarRef* nodep) override { + void visit(AstModportVarRef* nodep) override { // Dump direction for Modport references const string kw = nodep->direction().xmlKwd(); outputTag(nodep, ""); @@ -244,13 +244,13 @@ class EmitXmlFileVisitor final : public VNVisitor { putsQuoted(kw); outputChildrenEnd(nodep, ""); } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { outputTag(nodep, ""); puts(" dotted="); putsQuoted(nodep->dotted()); outputChildrenEnd(nodep, ""); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { outputTag(nodep, ""); puts(" func="); putsQuoted(nodep->funcp()->name()); @@ -258,7 +258,7 @@ class EmitXmlFileVisitor final : public VNVisitor { } // Data types - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { outputTag(nodep, "basicdtype"); if (nodep->isRanged()) { puts(" left=\"" + cvtToStr(nodep->left()) + "\""); @@ -267,7 +267,7 @@ class EmitXmlFileVisitor final : public VNVisitor { if (nodep->isSigned()) { puts(" signed=\"true\""); } puts("/>\n"); } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { string mpn; outputTag(nodep, ""); if (nodep->isModport()) mpn = nodep->modportName(); @@ -275,19 +275,19 @@ class EmitXmlFileVisitor final : public VNVisitor { putsQuoted(mpn); outputChildrenEnd(nodep, ""); } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { outputTag(nodep, ""); puts(" displaytype="); putsQuoted(nodep->verilogKwd()); outputChildrenEnd(nodep, ""); } - virtual void visit(AstElabDisplay* nodep) override { + void visit(AstElabDisplay* nodep) override { outputTag(nodep, ""); puts(" displaytype="); putsQuoted(nodep->verilogKwd()); outputChildrenEnd(nodep, ""); } - virtual void visit(AstExtend* nodep) override { + void visit(AstExtend* nodep) override { outputTag(nodep, ""); puts(" width="); putsQuoted(cvtToStr(nodep->width())); @@ -295,7 +295,7 @@ class EmitXmlFileVisitor final : public VNVisitor { putsQuoted(cvtToStr(nodep->lhsp()->widthMinV())); outputChildrenEnd(nodep, ""); } - virtual void visit(AstExtendS* nodep) override { + void visit(AstExtendS* nodep) override { outputTag(nodep, ""); puts(" width="); putsQuoted(cvtToStr(nodep->width())); @@ -305,7 +305,7 @@ class EmitXmlFileVisitor final : public VNVisitor { } // Default - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { outputTag(nodep, ""); outputChildrenEnd(nodep, ""); } @@ -315,7 +315,7 @@ public: : m_ofp{ofp} { iterate(nodep); } - virtual ~EmitXmlFileVisitor() override = default; + ~EmitXmlFileVisitor() override = default; }; //###################################################################### @@ -332,11 +332,11 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Children are iterated backwards to ensure correct compilation order iterateChildrenBackwards(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Only list modules and interfaces // Assumes modules and interfaces list is already sorted level wise if (!nodep->dead() && (VN_IS(nodep, Module) || VN_IS(nodep, Iface)) @@ -345,7 +345,7 @@ private: } } //----- - virtual void visit(AstNode*) override { + void visit(AstNode*) override { // All modules are present at root so no need to iterate on children } @@ -363,7 +363,7 @@ public: } m_os << "\n"; } - virtual ~ModuleFilesXmlVisitor() override = default; + ~ModuleFilesXmlVisitor() override = default; }; //###################################################################### @@ -380,9 +380,9 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstConstPool*) override {} + void visit(AstConstPool*) override {} - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (nodep->level() >= 0 && nodep->level() <= 2) { // ==2 because we don't add wrapper when in XML mode m_os << "\n"; @@ -401,7 +401,7 @@ private: m_os << "\n"; } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { if (nodep->modp()->dead()) return; if (!m_hasChildren) m_os << ">\n"; m_os << "fileline()->xmlDetailedLocation() << " name=\"" << nodep->name() @@ -421,7 +421,7 @@ private: m_hasChildren = true; } //----- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -430,7 +430,7 @@ public: // Operate on whole netlist nodep->accept(*this); } - virtual ~HierCellsXmlVisitor() override = default; + ~HierCellsXmlVisitor() override = default; }; //###################################################################### diff --git a/src/V3Error.cpp b/src/V3Error.cpp index be30eae9b..4912e67b4 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -54,7 +54,7 @@ v3errorIniter v3errorInit; V3ErrorCode::V3ErrorCode(const char* msgp) { // Return error encoding for given string, or ERROR, which is a bad code for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - const V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code{codei}; if (0 == VL_STRCASECMP(msgp, code.ascii())) { m_e = code; return; @@ -69,9 +69,9 @@ V3ErrorCode::V3ErrorCode(const char* msgp) { void V3Error::init() { for (int i = 0; i < V3ErrorCode::_ENUM_MAX; i++) { s_describedEachWarn[i] = false; - s_pretendError[i] = V3ErrorCode(i).pretendError(); + s_pretendError[i] = V3ErrorCode{i}.pretendError(); } - if (VL_UNCOVERABLE(string(V3ErrorCode(V3ErrorCode::_ENUM_MAX).ascii()) != " MAX")) { + if (VL_UNCOVERABLE(string(V3ErrorCode{V3ErrorCode::_ENUM_MAX}.ascii()) != " MAX")) { v3fatalSrc("Enum table in V3ErrorCode::EC_ascii() is munged"); } } diff --git a/src/V3Error.h b/src/V3Error.h index 1283ed785..22d156ac0 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -149,13 +149,13 @@ public: }; // clang-format on enum en m_e; - inline V3ErrorCode() + V3ErrorCode() : m_e{EC_MIN} {} // cppcheck-suppress noExplicitConstructor - inline V3ErrorCode(en _e) + V3ErrorCode(en _e) : m_e{_e} {} explicit V3ErrorCode(const char* msgp); // Matching code or ERROR - explicit inline V3ErrorCode(int _e) + explicit V3ErrorCode(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 6e8e2c1ec..85635e31a 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -313,7 +313,7 @@ private: } // VISITORS - virtual void visit(AstExtend* nodep) override { + void visit(AstExtend* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); if (nodep->isWide()) { @@ -339,7 +339,7 @@ private: } } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); // Remember, Sel's may have non-integer rhs, so need to optimize for that! @@ -628,7 +628,7 @@ private: } } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); if (nodep->isWide()) { @@ -665,7 +665,7 @@ private: return true; } - virtual void visit(AstReplicate* nodep) override { + void visit(AstReplicate* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); if (nodep->isWide()) { @@ -750,10 +750,10 @@ private: VL_DO_DANGLING(replaceWithDelete(nodep, newp), nodep); } } - virtual void visit(AstEq* nodep) override { visitEqNeq(nodep); } - virtual void visit(AstNeq* nodep) override { visitEqNeq(nodep); } + void visit(AstEq* nodep) override { visitEqNeq(nodep); } + void visit(AstNeq* nodep) override { visitEqNeq(nodep); } - virtual void visit(AstRedOr* nodep) override { + void visit(AstRedOr* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); FileLine* const fl = nodep->fileline(); @@ -775,7 +775,7 @@ private: VL_DO_DANGLING(replaceWithDelete(nodep, newp), nodep); } } - virtual void visit(AstRedAnd* nodep) override { + void visit(AstRedAnd* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); FileLine* const fl = nodep->fileline(); @@ -805,7 +805,7 @@ private: VL_DO_DANGLING(replaceWithDelete(nodep, newp), nodep); } } - virtual void visit(AstRedXor* nodep) override { + void visit(AstRedXor* nodep) override { if (nodep->user1SetOnce()) return; // Process once iterateChildren(nodep); if (nodep->lhsp()->isWide()) { @@ -825,7 +825,7 @@ private: // which the inlined function does nicely. } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (nodep->user1SetOnce()) return; // Process once if (!nodep->isStatement()) { iterateChildren(nodep); @@ -835,7 +835,7 @@ private: iterateChildren(nodep); m_stmtp = nullptr; } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (nodep->user1SetOnce()) return; // Process once m_stmtp = nodep; iterateChildren(nodep); @@ -876,13 +876,13 @@ private: } //-------------------- - virtual void visit(AstVar*) override {} // Don't hit varrefs under vars - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't hit varrefs under vars + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ExpandVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ExpandVisitor() override { + ~ExpandVisitor() override { V3Stats::addStat("Optimizations, expand wides", m_statWides); V3Stats::addStat("Optimizations, expand wide words", m_statWideWords); V3Stats::addStat("Optimizations, expand limited", m_statWideLimited); diff --git a/src/V3File.cpp b/src/V3File.cpp index c4adf58bc..b8c8e6ad6 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -146,7 +146,7 @@ V3FileDependImp dependImp; // Depend implementation class //###################################################################### // V3FileDependImp -inline void V3FileDependImp::writeDepend(const string& filename) { +void V3FileDependImp::writeDepend(const string& filename) { const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); @@ -171,7 +171,7 @@ inline void V3FileDependImp::writeDepend(const string& filename) { } } -inline std::vector V3FileDependImp::getAllDeps() const { +std::vector V3FileDependImp::getAllDeps() const { std::vector r; for (const auto& itr : m_filenameList) { if (!itr.target() && itr.exists()) r.push_back(itr.filename()); @@ -179,7 +179,7 @@ inline std::vector V3FileDependImp::getAllDeps() const { return r; } -inline void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { +void V3FileDependImp::writeTimes(const string& filename, const string& cmdlineIn) { const std::unique_ptr ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); @@ -214,7 +214,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm } } -inline bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) { +bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) { const std::unique_ptr ifp{V3File::new_ifstream_nodepend(filename)}; if (ifp->fail()) { UINFO(2, " --check-times failed: no input " << filename << endl); diff --git a/src/V3File.h b/src/V3File.h index 95b29eb8d..38f4dc6ff 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -206,7 +206,7 @@ public: V3OutFile(V3OutFile&&) = delete; V3OutFile& operator=(V3OutFile&&) = delete; - virtual ~V3OutFile() override; + ~V3OutFile() override; void putsForceIncs(); private: @@ -216,11 +216,11 @@ private: } // CALLBACKS - virtual void putcOutput(char chr) override { + void putcOutput(char chr) override { m_bufferp->at(m_usedBytes++) = chr; if (VL_UNLIKELY(m_usedBytes >= WRITE_BUFFER_SIZE_BYTES)) writeBlock(); } - virtual void putsOutput(const char* str) override { + void putsOutput(const char* str) override { std::size_t len = strlen(str); std::size_t availableBytes = WRITE_BUFFER_SIZE_BYTES - m_usedBytes; while (VL_UNLIKELY(len >= availableBytes)) { @@ -246,7 +246,7 @@ public: : V3OutFile{filename, V3OutFormatter::LA_C} { resetPrivate(); } - virtual ~V3OutCFile() override = default; + ~V3OutCFile() override = default; virtual void putsHeader() { puts("// Verilated -*- C++ -*-\n"); } virtual void putsIntTopInclude() { putsForceIncs(); } virtual void putsGuard(); @@ -270,9 +270,9 @@ class V3OutScFile final : public V3OutCFile { public: explicit V3OutScFile(const string& filename) : V3OutCFile{filename} {} - virtual ~V3OutScFile() override = default; - virtual void putsHeader() override { puts("// Verilated -*- SystemC -*-\n"); } - virtual void putsIntTopInclude() override { + ~V3OutScFile() override = default; + void putsHeader() override { puts("// Verilated -*- SystemC -*-\n"); } + void putsIntTopInclude() override { putsForceIncs(); puts("#include \"systemc.h\"\n"); puts("#include \"verilated_sc.h\"\n"); @@ -283,7 +283,7 @@ class V3OutVFile final : public V3OutFile { public: explicit V3OutVFile(const string& filename) : V3OutFile{filename, V3OutFormatter::LA_VERILOG} {} - virtual ~V3OutVFile() override = default; + ~V3OutVFile() override = default; virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); } }; @@ -293,7 +293,7 @@ public: : V3OutFile{filename, V3OutFormatter::LA_XML} { blockIndent(2); } - virtual ~V3OutXmlFile() override = default; + ~V3OutXmlFile() override = default; virtual void putsHeader() { puts("\n"); } }; @@ -301,7 +301,7 @@ class V3OutMkFile final : public V3OutFile { public: explicit V3OutMkFile(const string& filename) : V3OutFile{filename, V3OutFormatter::LA_MK} {} - virtual ~V3OutMkFile() override = default; + ~V3OutMkFile() override = default; virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); } // No automatic indentation yet. void puts(const char* strg) { putsNoTracking(strg); } diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index fd7669275..4201e77d5 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -149,7 +149,7 @@ FileLine::FileLine(FileLine::EmptySecret) { m_warnOn = 0; for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - const V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code{codei}; warnOff(code, code.defaultsOff()); } } @@ -309,14 +309,14 @@ bool FileLine::warnOff(const string& msg, bool flag) { void FileLine::warnLintOff(bool flag) { for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - const V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code{codei}; if (code.lintError()) warnOff(code, flag); } } void FileLine::warnStyleOff(bool flag) { for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - const V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code{codei}; if (code.styleError()) warnOff(code, flag); } } @@ -333,7 +333,7 @@ bool FileLine::warnIsOff(V3ErrorCode code) const { void FileLine::modifyStateInherit(const FileLine* fromp) { // Any warnings that are off in "from", become off in "this". for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - const V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code{codei}; if (fromp->warnIsOff(code)) warnOff(code, true); } } diff --git a/src/V3FileLine.h b/src/V3FileLine.h index 078b5cafc..106827dc6 100644 --- a/src/V3FileLine.h +++ b/src/V3FileLine.h @@ -249,7 +249,11 @@ public: // OPERATORS void v3errorEnd(std::ostringstream& str, const string& extra = ""); - void v3errorEndFatal(std::ostringstream& str) VL_ATTR_NORETURN; + void v3errorEndFatal(std::ostringstream& str) VL_ATTR_NORETURN { + v3errorEnd(str); + assert(0); // LCOV_EXCL_LINE + VL_UNREACHABLE + } /// When building an error, prefix for printing continuation lines /// e.g. information referring to the same FileLine as before string warnMore() const; @@ -288,10 +292,4 @@ private: }; std::ostream& operator<<(std::ostream& os, FileLine* fileline); -inline void FileLine::v3errorEndFatal(std::ostringstream& str) { - v3errorEnd(str); - assert(0); // LCOV_EXCL_LINE - VL_UNREACHABLE -} - #endif // Guard diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 2b8b6c85f..c49eb56a1 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -62,8 +62,8 @@ public: explicit GateGraphBaseVisitor(V3Graph* graphp) : m_graphp{graphp} {} virtual ~GateGraphBaseVisitor() = default; - virtual VNUser visit(GateLogicVertex* vertexp, VNUser vu = VNUser(0)) = 0; - virtual VNUser visit(GateVarVertex* vertexp, VNUser vu = VNUser(0)) = 0; + virtual VNUser visit(GateLogicVertex* vertexp, VNUser vu = VNUser{0}) = 0; + virtual VNUser visit(GateVarVertex* vertexp, VNUser vu = VNUser{0}) = 0; VL_DEBUG_FUNC; // Declare debug() }; @@ -79,9 +79,9 @@ public: GateEitherVertex(V3Graph* graphp, AstScope* scopep) : V3GraphVertex{graphp} , m_scopep{scopep} {} - virtual ~GateEitherVertex() override = default; + ~GateEitherVertex() override = default; // ACCESSORS - virtual string dotStyle() const override { return m_consumed ? "" : "dotted"; } + string dotStyle() const override { return m_consumed ? "" : "dotted"; } AstScope* scopep() const { return m_scopep; } bool reducible() const { return m_reducible; } bool dedupable() const { return m_dedupable; } @@ -102,10 +102,10 @@ public: clearReducible(nonReducibleReason); clearDedupable(nonReducibleReason); } - virtual VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser(0)) = 0; + virtual VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser{0}) = 0; // Returns only the result from the LAST vertex iterated over - VNUser iterateInEdges(GateGraphBaseVisitor& v, VNUser vu = VNUser(0)) { - VNUser ret = VNUser(0); + VNUser iterateInEdges(GateGraphBaseVisitor& v, VNUser vu = VNUser{0}) { + VNUser ret{0}; for (V3GraphEdge* edgep = inBeginp(); edgep; edgep = edgep->inNextp()) { ret = static_cast(edgep->fromp())->accept(v, vu); } @@ -115,8 +115,8 @@ public: // Note: This behaves differently than iterateInEdges() in that it will traverse // all edges that exist when it is initially called, whereas // iterateInEdges() will stop traversing edges if one is deleted - VNUser iterateCurrentOutEdges(GateGraphBaseVisitor& v, VNUser vu = VNUser(0)) { - VNUser ret = VNUser(0); + VNUser iterateCurrentOutEdges(GateGraphBaseVisitor& v, VNUser vu = VNUser{0}) { + VNUser ret{0}; V3GraphEdge* next_edgep = nullptr; for (V3GraphEdge* edgep = outBeginp(); edgep; edgep = next_edgep) { // Need to find the next edge before visiting in case the edge is deleted @@ -137,11 +137,11 @@ public: GateVarVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varScp) : GateEitherVertex{graphp, scopep} , m_varScp{varScp} {} - virtual ~GateVarVertex() override = default; + ~GateVarVertex() override = default; // ACCESSORS AstVarScope* varScp() const { return m_varScp; } - virtual string name() const override { return (cvtToHex(m_varScp) + " " + varScp()->name()); } - virtual string dotColor() const override { return "blue"; } + string name() const override { return (cvtToHex(m_varScp) + " " + varScp()->name()); } + string dotColor() const override { return "blue"; } bool isTop() const { return m_isTop; } void setIsTop() { m_isTop = true; } bool isClock() const { return m_isClock; } @@ -162,7 +162,7 @@ public: setIsClock(); } } - virtual VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser(0)) override { + VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser{0}) override { return v.visit(this, vu); } }; @@ -178,17 +178,15 @@ public: , m_nodep{nodep} , m_activep{activep} , m_slow{slow} {} - virtual ~GateLogicVertex() override = default; + ~GateLogicVertex() override = default; // ACCESSORS - virtual string name() const override { - return (cvtToHex(m_nodep) + "@" + scopep()->prettyName()); - } - virtual string dotColor() const override { return "purple"; } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + string name() const override { return (cvtToHex(m_nodep) + "@" + scopep()->prettyName()); } + string dotColor() const override { return "purple"; } + FileLine* fileline() const override { return nodep()->fileline(); } AstNode* nodep() const { return m_nodep; } AstActive* activep() const { return m_activep; } bool slow() const { return m_slow; } - virtual VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser(0)) override { + VNUser accept(GateGraphBaseVisitor& v, VNUser vu = VNUser{0}) override { return v.visit(this, vu); } }; @@ -217,7 +215,7 @@ private: } } // VISITORS - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { ++m_ops; iterateChildren(nodep); // We only allow a LHS ref for the var being set, and a RHS ref for @@ -243,7 +241,7 @@ private: m_rhsVarRefs.push_back(nodep); } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { m_substTreep = nodep->rhsp(); if (!VN_IS(nodep->lhsp(), NodeVarRef)) { clearSimple("ASSIGN(non-VARREF)"); @@ -266,7 +264,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // *** Special iterator if (!m_isSimple) return; // Fastpath if (++m_ops > v3Global.opt.gateStmts()) clearSimple("--gate-stmts exceeded"); @@ -296,7 +294,7 @@ public: } if (debug() >= 9 && !m_isSimple) nodep->dumpTree(cout, " gate!Ok: "); } - virtual ~GateOkVisitor() override = default; + ~GateOkVisitor() override = default; // PUBLIC METHODS bool isSimple() const { return m_isSimple; } AstNode* substTree() const { return m_substTreep; } @@ -423,7 +421,7 @@ private: void decomposeClkVectors(); // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { iterateChildren(nodep); // if (debug() > 6) m_graph.dump(); if (debug() > 6) m_graph.dumpDotFilePrefixed("gate_pre"); @@ -455,7 +453,7 @@ private: // Rewrite assignments consumedMove(); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; @@ -463,14 +461,14 @@ private: iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UINFO(4, " SCOPE " << nodep << endl); m_scopep = nodep; m_logicVertexp = nullptr; iterateChildren(nodep); m_scopep = nullptr; } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { // Create required blocks and add to module UINFO(4, " BLOCK " << nodep << endl); m_activeReducible = !(nodep->hasClocked()); // Seq logic outputs aren't reducible @@ -481,7 +479,7 @@ private: m_activep = nullptr; m_activeReducible = true; } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { if (m_scopep) { UASSERT_OBJ(m_logicVertexp, nodep, "Var ref not under a logic block"); AstVarScope* const varscp = nodep->varScopep(); @@ -509,17 +507,17 @@ private: } } } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { VL_RESTORER(m_inSlow); { m_inSlow = true; iterateNewStmt(nodep, "AlwaysPublic", nullptr); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { iterateNewStmt(nodep, "User C Function", "User C Function"); } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { m_inSenItem = true; if (m_logicVertexp) { // Already under logic; presumably a SenGate iterateChildren(nodep); @@ -528,7 +526,7 @@ private: } m_inSenItem = false; } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { VL_RESTORER(m_inSlow); { m_inSlow = VN_IS(nodep, Initial) || VN_IS(nodep, Final); @@ -536,23 +534,23 @@ private: nullptr); } } - virtual void visit(AstAssignAlias* nodep) override { // + void visit(AstAssignAlias* nodep) override { // iterateNewStmt(nodep, nullptr, nullptr); } - virtual void visit(AstAssignW* nodep) override { // + void visit(AstAssignW* nodep) override { // iterateNewStmt(nodep, nullptr, nullptr); } - virtual void visit(AstCoverToggle* nodep) override { + void visit(AstCoverToggle* nodep) override { iterateNewStmt(nodep, "CoverToggle", "CoverToggle"); } - virtual void visit(AstTraceDecl* nodep) override { + void visit(AstTraceDecl* nodep) override { VL_RESTORER(m_inSlow); { m_inSlow = true; iterateNewStmt(nodep, "Tracing", "Tracing"); } } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { UASSERT_OBJ(!(VN_IS(nodep->backp(), NodeAssign) && VN_AS(nodep->backp(), NodeAssign)->lhsp() == nodep), nodep, "Concat on LHS of assignment; V3Const should have deleted it"); @@ -560,7 +558,7 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); if (nodep->isOutputter() && m_logicVertexp) m_logicVertexp->setConsumed("outputter"); checkTimingControl(nodep); @@ -569,7 +567,7 @@ private: public: // CONSTRUCTORS explicit GateVisitor(AstNode* nodep) { iterate(nodep); } - virtual ~GateVisitor() override { + ~GateVisitor() override { V3Stats::addStat("Optimizations, Gate sigs deleted", m_statSigs); V3Stats::addStat("Optimizations, Gate inputs replaced", m_statRefs); V3Stats::addStat("Optimizations, Gate sigs deduped", m_statDedupLogic); @@ -821,7 +819,7 @@ private: public: GateDedupeHash() = default; - virtual ~GateDedupeHash() override { + ~GateDedupeHash() override { if (v3Global.opt.debugCheck()) check(); } @@ -847,7 +845,7 @@ public: } // Callback from V3DupFinder::findDuplicate - virtual bool isSame(AstNode* node1p, AstNode* node2p) override { + bool isSame(AstNode* node1p, AstNode* node2p) override { // Assignment may have been hashReplaced, if so consider non-match (effectively removed) if (isReplaced(node1p) || isReplaced(node2p)) { // UINFO(9, "isSame hit on replaced "<<(void*)node1p<<" "<<(void*)node2p<elsesp()) { // we're under an always, this is the first IF, and there's no else @@ -956,16 +954,16 @@ private: } } - virtual void visit(AstComment*) override {} // NOP + void visit(AstComment*) override {} // NOP //-------------------- - virtual void visit(AstNode*) override { // + void visit(AstNode*) override { // m_dedupable = false; } public: // CONSTRUCTORS GateDedupeVarVisitor() = default; - virtual ~GateDedupeVarVisitor() override = default; + ~GateDedupeVarVisitor() override = default; // PUBLIC METHODS AstNodeVarRef* findDupe(AstNode* nodep, AstVarScope* consumerVarScopep, AstActive* activep) { m_assignp = nullptr; @@ -1054,17 +1052,17 @@ private: GateDedupeVarVisitor m_varVisitor; // Looks for a dupe of the logic int m_depth = 0; // Iteration depth - virtual VNUser visit(GateVarVertex* vvertexp, VNUser) override { + VNUser visit(GateVarVertex* vvertexp, VNUser) override { // Check that we haven't been here before if (m_depth > GATE_DEDUP_MAX_DEPTH) - return VNUser(0); // Break loops; before user2 set so hit this vertex later - if (vvertexp->varScp()->user2()) return VNUser(0); + return VNUser{0}; // Break loops; before user2 set so hit this vertex later + if (vvertexp->varScp()->user2()) return VNUser{0}; vvertexp->varScp()->user2(true); m_depth++; if (vvertexp->inSize1()) { AstNodeVarRef* const dupVarRefp = static_cast( - vvertexp->iterateInEdges(*this, VNUser(vvertexp)).toNodep()); + vvertexp->iterateInEdges(*this, VNUser{vvertexp}).toNodep()); if (dupVarRefp) { // visit(GateLogicVertex*...) returned match const V3GraphEdge* edgep = vvertexp->inBeginp(); GateLogicVertex* const lvertexp = static_cast(edgep->fromp()); @@ -1111,12 +1109,12 @@ private: } } m_depth--; - return VNUser(0); + return VNUser{0}; } // Given iterated logic, starting at vu which was consumer's GateVarVertex // Returns a varref that has the same logic input; or nullptr if none - virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { + VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { lvertexp->iterateInEdges(*this); const GateVarVertex* const consumerVvertexpp @@ -1129,9 +1127,9 @@ private: // different generated clocks will never compare as equal, even if the // generated clocks are deduped into one clock. AstActive* const activep = lvertexp->activep(); - return VNUser(m_varVisitor.findDupe(nodep, consumerVarScopep, activep)); + return VNUser{m_varVisitor.findDupe(nodep, consumerVarScopep, activep)}; } - return VNUser(0); + return VNUser{0}; } public: @@ -1196,7 +1194,7 @@ private: } } - virtual VNUser visit(GateVarVertex* vvertexp, VNUser) override { + VNUser visit(GateVarVertex* vvertexp, VNUser) override { for (V3GraphEdge* edgep = vvertexp->inBeginp(); edgep;) { V3GraphEdge* oldedgep = edgep; edgep = edgep->inNextp(); // for recursive since the edge could be deleted @@ -1268,10 +1266,10 @@ private: } } } - return VNUser(0); + return VNUser{0}; } - virtual VNUser visit(GateLogicVertex*, VNUser) override { // - return VNUser(0); + VNUser visit(GateLogicVertex*, VNUser) override { // + return VNUser{0}; } public: @@ -1308,7 +1306,7 @@ private: bool m_found = false; // Offset found // VISITORS - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { UINFO(9, "CLK DECOMP Concat search var (off = " << m_offset << ") - " << nodep << endl); if (nodep->varScopep() == m_vscp && !nodep->user2() && !m_found) { // A concatenation may use the same var multiple times @@ -1320,18 +1318,18 @@ private: } m_offset += nodep->dtypep()->width(); } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { UINFO(9, "CLK DECOMP Concat search (off = " << m_offset << ") - " << nodep << endl); iterate(nodep->rhsp()); iterate(nodep->lhsp()); } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS GateConcatVisitor() = default; - virtual ~GateConcatVisitor() override = default; + ~GateConcatVisitor() override = default; // PUBLIC METHODS bool concatOffset(AstConcat* concatp, AstVarScope* vscp, int& offsetr) { m_vscp = vscp; @@ -1371,10 +1369,10 @@ private: int m_total_seen_clk_vectors = 0; int m_total_decomposed_clk_vectors = 0; - virtual VNUser visit(GateVarVertex* vvertexp, VNUser vu) override { + VNUser visit(GateVarVertex* vvertexp, VNUser vu) override { // Check that we haven't been here before AstVarScope* const vsp = vvertexp->varScp(); - if (vsp->user2SetOnce()) return VNUser(0); + if (vsp->user2SetOnce()) return VNUser{0}; UINFO(9, "CLK DECOMP Var - " << vvertexp << " : " << vsp << endl); if (vsp->varp()->width() > 1) { m_seen_clk_vectors++; @@ -1382,13 +1380,13 @@ private: } const GateClkDecompState* const currState = reinterpret_cast(vu.c()); GateClkDecompState nextState(currState->m_offset, vsp); - vvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState)); + vvertexp->iterateCurrentOutEdges(*this, VNUser{&nextState}); if (vsp->varp()->width() > 1) --m_seen_clk_vectors; vsp->user2(false); - return VNUser(0); // Unused + return VNUser{0}; // Unused } - virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { + VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { const GateClkDecompState* const currState = reinterpret_cast(vu.c()); int clk_offset = currState->m_offset; if (const AstAssignW* const assignp = VN_CAST(lvertexp->nodep(), AssignW)) { @@ -1401,37 +1399,37 @@ private: UINFO(9, "CLK DECOMP Sel [ " << rselp->msbConst() << " : " << rselp->lsbConst() << " ] dropped clock (" << clk_offset << ")" << endl); - return VNUser(0); + return VNUser{0}; } clk_offset -= rselp->lsbConst(); } else { - return VNUser(0); + return VNUser{0}; } } else if (AstConcat* const catp = VN_CAST(assignp->rhsp(), Concat)) { UINFO(9, "CLK DECOMP Concat searching - " << assignp->lhsp() << endl); int concat_offset; if (!m_concat_visitor.concatOffset(catp, currState->m_last_vsp, concat_offset /*ref*/)) { - return VNUser(0); + return VNUser{0}; } clk_offset += concat_offset; } else if (VN_IS(assignp->rhsp(), VarRef)) { UINFO(9, "CLK DECOMP VarRef searching - " << assignp->lhsp() << endl); } else { - return VNUser(0); + return VNUser{0}; } // LHS if (const AstSel* const lselp = VN_CAST(assignp->lhsp(), Sel)) { if (VN_IS(lselp->lsbp(), Const) && VN_IS(lselp->widthp(), Const)) { clk_offset += lselp->lsbConst(); } else { - return VNUser(0); + return VNUser{0}; } } else if (const AstVarRef* const vrp = VN_CAST(assignp->lhsp(), VarRef)) { if (vrp->dtypep()->width() == 1 && m_seen_clk_vectors) { if (clk_offset != 0) { UINFO(9, "Should only make it here with clk_offset = 0" << endl); - return VNUser(0); + return VNUser{0}; } UINFO(9, "CLK DECOMP Connecting - " << assignp->lhsp() << endl); UINFO(9, " to - " << m_clk_vsp << endl); @@ -1444,18 +1442,18 @@ private: m_total_decomposed_clk_vectors++; } } else { - return VNUser(0); + return VNUser{0}; } GateClkDecompState nextState(clk_offset, currState->m_last_vsp); - return lvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState)); + return lvertexp->iterateCurrentOutEdges(*this, VNUser{&nextState}); } - return VNUser(0); + return VNUser{0}; } public: explicit GateClkDecompGraphVisitor(V3Graph* graphp) : GateGraphBaseVisitor{graphp} {} - virtual ~GateClkDecompGraphVisitor() override { + ~GateClkDecompGraphVisitor() override { V3Stats::addStat("Optimizations, Clocker seen vectors", m_total_seen_clk_vectors); V3Stats::addStat("Optimizations, Clocker decomposed vectors", m_total_decomposed_clk_vectors); @@ -1466,7 +1464,7 @@ public: m_clk_vsp = vvertexp->varScp(); m_clk_vvertexp = vvertexp; GateClkDecompState nextState(0, m_clk_vsp); - vvertexp->accept(*this, VNUser(&nextState)); + vvertexp->accept(*this, VNUser{&nextState}); } }; diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp new file mode 100644 index 000000000..40327384b --- /dev/null +++ b/src/V3GenClk.cpp @@ -0,0 +1,225 @@ +// -*- mode: C++; c-file-style: "cc-mode" -*- +//************************************************************************* +// DESCRIPTION: Verilator: Generated Clock repairs +// +// Code available from: https://verilator.org +// +//************************************************************************* +// +// Copyright 2003-2022 by Wilson Snyder. This program is free software; you +// can redistribute it and/or modify it under the terms of either the GNU +// Lesser General Public License Version 3 or the Perl Artistic License +// Version 2.0. +// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 +// +//************************************************************************* +// GENCLK TRANSFORMATIONS: +// Follow control-flow graph with assignments and var usages +// ASSIGNDLY to variable later used as clock requires change detect +// +//************************************************************************* + +#include "config_build.h" +#include "verilatedos.h" + +#include "V3GenClk.h" + +#include "V3Ast.h" +#include "V3Global.h" + +//###################################################################### +// GenClk state, as a visitor of each AstNode + +class GenClkBaseVisitor VL_NOT_FINAL : public VNVisitor { +protected: + VL_DEBUG_FUNC; // Declare debug() +}; + +//###################################################################### +// GenClk Read + +class GenClkRenameVisitor final : public GenClkBaseVisitor { +private: + // NODE STATE + // Cleared on top scope + // AstVarScope::user2() -> AstVarScope*. Signal replacing activation with + // AstVarRef::user3() -> bool. Signal is replaced activation (already done) + const VNUser2InUse m_inuser2; + const VNUser3InUse m_inuser3; + + // STATE + const AstActive* m_activep = nullptr; // Inside activate statement + AstNodeModule* const m_topModp; // Top module + AstScope* const m_scopetopp = v3Global.rootp()->topScopep()->scopep(); // The top AstScope + + // METHODS + AstVarScope* genInpClk(AstVarScope* vscp) { + if (!vscp->user2p()) { + // In order to create a __VinpClk* for a signal, it needs to be marked circular. + // The DPI export trigger is never marked circular by V3Order (see comments in + // OrderVisitor::nodeMarkCircular). The only other place where one might mark + // a node circular is in this pass (V3GenClk), if the signal is assigned but was + // previously used as a clock. The DPI export trigger is only ever assigned in + // a DPI export called from outside eval, or from a DPI import, which are not + // discovered by GenClkReadVisitor (note that impure tasks - i.e.: those setting + // non-local variables - cannot be no-inline, see V3Task), hence the DPI export + // trigger should never be marked circular. Note that ordering should still be + // correct as there will be a change detect on any signals set from a DPI export + // that might have dependents scheduled earlier. + UASSERT_OBJ(vscp != v3Global.rootp()->dpiExportTriggerp(), vscp, + "DPI export trigger should not need __VinpClk"); + AstVar* const varp = vscp->varp(); + const string newvarname + = "__VinpClk__" + vscp->scopep()->nameDotless() + "__" + varp->name(); + // Create: VARREF(inpclk) + // ... + // ASSIGN(VARREF(inpclk), VARREF(var)) + AstVar* const newvarp + = new AstVar(varp->fileline(), VVarType::MODULETEMP, newvarname, varp); + m_topModp->addStmtp(newvarp); + AstVarScope* const newvscp = new AstVarScope(vscp->fileline(), m_scopetopp, newvarp); + m_scopetopp->addVarp(newvscp); + AstAssign* const asninitp = new AstAssign( + vscp->fileline(), new AstVarRef(vscp->fileline(), newvscp, VAccess::WRITE), + new AstVarRef(vscp->fileline(), vscp, VAccess::READ)); + m_scopetopp->addFinalClkp(asninitp); + // + vscp->user2p(newvscp); + } + return VN_AS(vscp->user2p(), VarScope); + } + + // VISITORS + void visit(AstVarRef* nodep) override { + // Consumption/generation of a variable, + if (m_activep && !nodep->user3SetOnce()) { + AstVarScope* const vscp = nodep->varScopep(); + if (vscp->isCircular()) { + UINFO(8, " VarActReplace " << nodep << endl); + // Replace with the new variable + AstVarScope* const newvscp = genInpClk(vscp); + AstVarRef* const newrefp + = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); + nodep->replaceWith(newrefp); + VL_DO_DANGLING(pushDeletep(nodep), nodep); + } + } + } + void visit(AstActive* nodep) override { + m_activep = nodep; + iterate(nodep->sensesp()); + m_activep = nullptr; + } + + //----- + void visit(AstNode* nodep) override { iterateChildren(nodep); } + +public: + // CONSTRUCTORS + GenClkRenameVisitor(AstTopScope* nodep, AstNodeModule* topModp) + : m_topModp{topModp} { + iterate(nodep); + } + ~GenClkRenameVisitor() override = default; +}; + +//###################################################################### +// GenClk Read + +class GenClkReadVisitor final : public GenClkBaseVisitor { +private: + // NODE STATE + // Cleared on top scope + // AstVarScope::user() -> bool. Set when the var has been used as clock + + // STATE + bool m_tracingCall = false; // Iterating into a call to a cfunc + const AstActive* m_activep = nullptr; // Inside activate statement + const AstNodeAssign* m_assignp = nullptr; // Inside assigndly statement + AstNodeModule* m_topModp = nullptr; // Top module + + // VISITORS + void visit(AstTopScope* nodep) override { + { + const VNUser1InUse user1InUse; + iterateChildren(nodep); + } + // Make the new clock signals and replace any activate references + // See rename, it does some AstNode::userClearTree()'s + GenClkRenameVisitor{nodep, m_topModp}; + } + void visit(AstNodeModule* nodep) override { + // Only track the top scopes, not lower level functions + if (nodep->isTop()) { + m_topModp = nodep; + iterateChildren(nodep); + } + } + void visit(AstNodeCCall* nodep) override { + iterateChildren(nodep); + if (!nodep->funcp()->entryPoint()) { + // Enter the function and trace it + m_tracingCall = true; + iterate(nodep->funcp()); + } + } + void visit(AstCFunc* nodep) override { + if (!m_tracingCall && !nodep->entryPoint()) { + // Only consider logic within a CFunc when looking + // at the call to it, and not when scanning whatever + // scope it happens to live beneath. + return; + } + m_tracingCall = false; + iterateChildren(nodep); + } + //---- + + void visit(AstVarRef* nodep) override { + // Consumption/generation of a variable, + AstVarScope* const vscp = nodep->varScopep(); + UASSERT_OBJ(vscp, nodep, "Scope not assigned"); + if (m_activep) { + UINFO(8, " VarAct " << nodep << endl); + vscp->user1(true); + } + if (m_assignp && nodep->access().isWriteOrRW() && vscp->user1()) { + // Variable was previously used as a clock, and is now being set + // Thus a unordered generated clock... + UINFO(8, " VarSetAct " << nodep << endl); + vscp->circular(true); + } + } + void visit(AstNodeAssign* nodep) override { + // UINFO(8, "ASS " << nodep << endl); + m_assignp = nodep; + iterateChildren(nodep); + m_assignp = nullptr; + } + void visit(AstActive* nodep) override { + UINFO(8, "ACTIVE " << nodep << endl); + m_activep = nodep; + UASSERT_OBJ(nodep->sensesp(), nodep, "Unlinked"); + iterate(nodep->sensesp()); + m_activep = nullptr; + iterateChildren(nodep); + } + + //----- + void visit(AstVar*) override {} // Don't want varrefs under it + void visit(AstNode* nodep) override { iterateChildren(nodep); } + +public: + // CONSTRUCTORS + explicit GenClkReadVisitor(AstNetlist* nodep) { iterate(nodep); } + ~GenClkReadVisitor() override = default; +}; + +//###################################################################### +// GenClk class functions + +void V3GenClk::genClkAll(AstNetlist* nodep) { + UINFO(2, __FUNCTION__ << ": " << endl); + { GenClkReadVisitor{nodep}; } // Destruct before checking + V3Global::dumpCheckGlobalTree("genclk", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); +} diff --git a/src/V3Graph.h b/src/V3Graph.h index a18fb5dfc..9d6b9ea06 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -54,12 +54,12 @@ public: // // an array dimension or loop bound. }; enum en m_e; - inline GraphWay() + GraphWay() : m_e{FORWARD} {} // cppcheck-suppress noExplicitConstructor - inline constexpr GraphWay(en _e) + constexpr GraphWay(en _e) : m_e{_e} {} - explicit inline constexpr GraphWay(int _e) + explicit constexpr GraphWay(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } const char* ascii() const { diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 0df758ed1..8860a5479 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -42,13 +42,13 @@ public: GraphAcycVertex(V3Graph* graphp, V3GraphVertex* origVertexp) : V3GraphVertex{graphp} , m_origVertexp{origVertexp} {} - virtual ~GraphAcycVertex() override = default; + ~GraphAcycVertex() override = default; V3GraphVertex* origVertexp() const { return m_origVertexp; } void setDelete() { m_deleted = true; } bool isDelete() const { return m_deleted; } - virtual string name() const override { return m_origVertexp->name(); } - virtual string dotColor() const override { return m_origVertexp->dotColor(); } - virtual FileLine* fileline() const override { return m_origVertexp->fileline(); } + string name() const override { return m_origVertexp->name(); } + string dotColor() const override { return m_origVertexp->dotColor(); } + FileLine* fileline() const override { return m_origVertexp->fileline(); } }; //-------------------------------------------------------------------- @@ -67,11 +67,9 @@ public: GraphAcycEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, bool cutable = false) : V3GraphEdge{graphp, fromp, top, weight, cutable} {} - virtual ~GraphAcycEdge() override = default; + ~GraphAcycEdge() override = default; // yellow=we might still cut it, else oldEdge: yellowGreen=made uncutable, red=uncutable - virtual string dotColor() const override { - return (cutable() ? "yellow" : origEdgep()->dotColor()); - } + string dotColor() const override { return (cutable() ? "yellow" : origEdgep()->dotColor()); } }; //-------------------------------------------------------------------- @@ -123,7 +121,7 @@ private: void placeTryEdge(V3GraphEdge* edgep); bool placeIterate(GraphAcycVertex* vertexp, uint32_t currentRank); - inline bool origFollowEdge(V3GraphEdge* edgep) { + bool origFollowEdge(V3GraphEdge* edgep) { return (edgep->weight() && (m_origEdgeFuncp)(edgep)); } V3GraphEdge* edgeFromEdge(V3GraphEdge* oldedgep, V3GraphVertex* fromp, V3GraphVertex* top) { diff --git a/src/V3GraphAlg.h b/src/V3GraphAlg.h index 2cc4ce9b5..6441b2cca 100644 --- a/src/V3GraphAlg.h +++ b/src/V3GraphAlg.h @@ -38,9 +38,7 @@ protected: , m_edgeFuncp{edgeFuncp} {} ~GraphAlg() = default; // METHODS - inline bool followEdge(V3GraphEdge* edgep) { - return (edgep->weight() && (m_edgeFuncp)(edgep)); - } + bool followEdge(V3GraphEdge* edgep) { return (edgep->weight() && (m_edgeFuncp)(edgep)); } }; //============================================================================ diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index 757c7ff70..40f847e0e 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -56,18 +56,18 @@ public: V3GraphTestVertex(V3Graph* graphp, const string& name) : V3GraphVertex{graphp} , m_name{name} {} - virtual ~V3GraphTestVertex() override = default; + ~V3GraphTestVertex() override = default; // ACCESSORS - virtual string name() const override { return m_name; } + string name() const override { return m_name; } }; class V3GraphTestVarVertex final : public V3GraphTestVertex { public: V3GraphTestVarVertex(V3Graph* graphp, const string& name) : V3GraphTestVertex{graphp, name} {} - virtual ~V3GraphTestVarVertex() override = default; + ~V3GraphTestVarVertex() override = default; // ACCESSORS - virtual string dotColor() const override { return "blue"; } + string dotColor() const override { return "blue"; } }; //###################################################################### @@ -76,8 +76,8 @@ public: class V3GraphTestStrong final : public V3GraphTest { public: - virtual string name() override { return "strong"; } - virtual void runTest() override { + string name() override { return "strong"; } + void runTest() override { V3Graph* gp = &m_graph; // Verify we break edges at a good point // A simple alg would make 3 breaks, below only requires b->i to break @@ -114,8 +114,8 @@ public: class V3GraphTestAcyc final : public V3GraphTest { public: - virtual string name() override { return "acyc"; } - virtual void runTest() override { + string name() override { return "acyc"; } + void runTest() override { V3Graph* gp = &m_graph; // Verify we break edges at a good point // A simple alg would make 3 breaks, below only requires b->i to break @@ -142,8 +142,8 @@ public: class V3GraphTestVars final : public V3GraphTest { public: - virtual string name() override { return "vars"; } - virtual void runTest() override { + string name() override { return "vars"; } + void runTest() override { V3Graph* gp = &m_graph; V3GraphTestVertex* clk = new V3GraphTestVarVertex(gp, "$clk"); @@ -268,8 +268,8 @@ class V3GraphTestImport final : public V3GraphTest { #endif public: - virtual string name() override { return "import"; } - virtual void runTest() override { + string name() override { return "import"; } + void runTest() override { V3Graph* const gp = &m_graph; dotImport(); dump(); diff --git a/src/V3Hash.h b/src/V3Hash.h index 13f86dd6d..c5dd1b631 100644 --- a/src/V3Hash.h +++ b/src/V3Hash.h @@ -26,7 +26,7 @@ class V3Hash final { uint32_t m_value; // The 32-bit hash value. - inline static uint32_t combine(uint32_t a, uint32_t b) { + static uint32_t combine(uint32_t a, uint32_t b) { return a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2)); } diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index bd6417414..d27bd64b8 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -80,7 +80,7 @@ private: //------------------------------------------------------------ // AstNode - Warns to help find missing cases - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { #if VL_DEBUG UINFO(0, "%Warning: Hashing node as AstNode: " << nodep << endl); #endif @@ -89,93 +89,93 @@ private: //------------------------------------------------------------ // AstNodeDType - virtual void visit(AstNodeArrayDType* nodep) override { + void visit(AstNodeArrayDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { iterateNull(nodep->virtRefDTypep()); m_hash += nodep->left(); m_hash += nodep->right(); }); } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, false, [=]() { // m_hash += nodep->uniqueNum(); }); } - virtual void visit(AstParamTypeDType* nodep) override { + void visit(AstParamTypeDType* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); m_hash += nodep->varType(); }); } - virtual void visit(AstMemberDType* nodep) override { + void visit(AstMemberDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstDefImplicitDType* nodep) override { + void visit(AstDefImplicitDType* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->uniqueNum(); }); } - virtual void visit(AstAssocArrayDType* nodep) override { + void visit(AstAssocArrayDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { iterateNull(nodep->virtRefDTypep()); iterateNull(nodep->virtRefDType2p()); }); } - virtual void visit(AstDynArrayDType* nodep) override { + void visit(AstDynArrayDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->virtRefDTypep()); }); } - virtual void visit(AstUnsizedArrayDType* nodep) override { + void visit(AstUnsizedArrayDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->virtRefDTypep()); }); } - virtual void visit(AstWildcardArrayDType* nodep) override { + void visit(AstWildcardArrayDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->virtRefDTypep()); }); } - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { m_hash += nodep->keyword(); m_hash += nodep->nrange().left(); m_hash += nodep->nrange().right(); }); } - virtual void visit(AstConstDType* nodep) override { + void visit(AstConstDType* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // iterateNull(nodep->virtRefDTypep()); }); } - virtual void visit(AstClassRefDType* nodep) override { + void visit(AstClassRefDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->classp()); }); } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->cellp()); }); } - virtual void visit(AstQueueDType* nodep) override { + void visit(AstQueueDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->virtRefDTypep()); }); } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { m_hash += nodep->name(); iterateNull(nodep->typedefp()); iterateNull(nodep->refDTypep()); }); } - virtual void visit(AstVoidDType* nodep) override { + void visit(AstVoidDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstEnumDType* nodep) override { + void visit(AstEnumDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, false, [=]() { // m_hash += nodep->uniqueNum(); }); @@ -183,23 +183,23 @@ private: //------------------------------------------------------------ // AstNodeMath - virtual void visit(AstNodeMath* nodep) override { + void visit(AstNodeMath* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->num().toHash(); }); } - virtual void visit(AstNullCheck* nodep) override { + void visit(AstNullCheck* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstCCast* nodep) override { + void visit(AstCCast* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->size(); }); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { if (nodep->varScopep()) { iterateNull(nodep->varScopep()); @@ -209,28 +209,28 @@ private: } }); } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { iterateNull(nodep->varp()); m_hash += nodep->dotted(); }); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->text(); }); } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->text(); }); } - virtual void visit(AstAddrOfCFunc* nodep) override { + void visit(AstAddrOfCFunc* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // iterateNull(nodep->funcp()); }); @@ -238,61 +238,61 @@ private: //------------------------------------------------------------ // AstNodeStmt - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstNodeText* nodep) override { + void visit(AstNodeText* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->text(); }); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->funcp()); }); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { iterateNull(nodep->taskp()); iterateNull(nodep->classOrPackagep()); }); } - virtual void visit(AstCMethodHard* nodep) override { + void visit(AstCMethodHard* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // iterateNull(nodep->sensesp()); }); } - virtual void visit(AstCoverInc* nodep) override { + void visit(AstCoverInc* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->declp()); }); } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->displayType(); }); } - virtual void visit(AstMonitorOff* nodep) override { + void visit(AstMonitorOff* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->off(); }); } - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->labelp()); }); } - virtual void visit(AstTraceInc* nodep) override { + void visit(AstTraceInc* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // iterateNull(nodep->declp()); }); } - virtual void visit(AstNodeCoverOrAssert* nodep) override { + void visit(AstNodeCoverOrAssert* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); @@ -300,62 +300,62 @@ private: //------------------------------------------------------------ // AstNode direct descendents - virtual void visit(AstNodeRange* nodep) override { + void visit(AstNodeRange* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() { // m_hash += nodep->origName(); }); } - virtual void visit(AstNodePreSel* nodep) override { + void visit(AstNodePreSel* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstClassExtends* nodep) override { + void visit(AstClassExtends* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstSelLoopVars* nodep) override { + void visit(AstSelLoopVars* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstDefParam* nodep) override { + void visit(AstDefParam* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstArg* nodep) override { + void visit(AstArg* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstParseRef* nodep) override { + void visit(AstParseRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->expect(); m_hash += nodep->name(); }); } - virtual void visit(AstClassOrPackageRef* nodep) override { + void visit(AstClassOrPackageRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // iterateNull(nodep->classOrPackageNodep()); }); } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->edgeType(); }); } - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->text(); }); } - virtual void visit(AstElabDisplay* nodep) override { + void visit(AstElabDisplay* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->displayType(); }); } - virtual void visit(AstInitItem* nodep) override { + void visit(AstInitItem* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { if (const AstAssocArrayDType* const dtypep = VN_CAST(nodep->dtypep(), AssocArrayDType)) { if (nodep->defaultp()) { m_hash @@ -381,22 +381,22 @@ private: }); } } - virtual void visit(AstPragma* nodep) override { + void visit(AstPragma* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->pragType(); }); } - virtual void visit(AstAttrOf* nodep) override { + void visit(AstAttrOf* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->attrType(); }); } - virtual void visit(AstNodeFile* nodep) override { + void visit(AstNodeFile* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // // We might be in a recursive function, if so on *second* call // here we need to break what would be an infinite loop. @@ -407,90 +407,90 @@ private: m_hash += nodep->isLoose(); }); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); m_hash += nodep->varType(); }); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() { m_hash += nodep->name(); iterateNull(nodep->aboveScopep()); }); } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { iterateNull(nodep->varp()); iterateNull(nodep->scopep()); }); } - virtual void visit(AstEnumItem* nodep) override { + void visit(AstEnumItem* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstTypedefFwd* nodep) override { + void visit(AstTypedefFwd* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // iterateNull(nodep->sensesp()); }); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); iterateNull(nodep->modp()); }); } - virtual void visit(AstCellInline* nodep) override { + void visit(AstCellInline* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); iterateNull(nodep->scopep()); }); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstModport* nodep) override { + void visit(AstModport* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstModportVarRef* nodep) override { + void visit(AstModportVarRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); iterateNull(nodep->varp()); }); } - virtual void visit(AstModportFTaskRef* nodep) override { + void visit(AstModportFTaskRef* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); iterateNull(nodep->ftaskp()); }); } - virtual void visit(AstMTaskBody* nodep) override { + void visit(AstMTaskBody* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() {}); } - virtual void visit(AstNodeBlock* nodep) override { + void visit(AstNodeBlock* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { // m_hash += nodep->name(); }); } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, HASH_CHILDREN, [=]() { m_hash += nodep->name(); m_hash += nodep->pinNum(); @@ -509,7 +509,7 @@ public: iterate(const_cast(nodep)); } V3Hash finalHash() const { return m_hash; } - virtual ~HasherVisitor() override = default; + ~HasherVisitor() override = default; }; //###################################################################### diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index e7ac8dd9b..7a1b07057 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -250,7 +250,7 @@ class HierBlockUsageCollectVisitor final : public VNVisitor { ModuleSet m_referred; // Modules that have hier_block pragma V3HierBlock::GParams m_gparams; // list of variables that is VVarType::GPARAM - virtual void visit(AstModule* nodep) override { + void visit(AstModule* nodep) override { // Don't visit twice if (nodep->user1SetOnce()) return; UINFO(5, "Checking " << nodep->prettyNameQ() << " from " @@ -277,7 +277,7 @@ class HierBlockUsageCollectVisitor final : public VNVisitor { } m_gparams = prevGParams; } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { // Visit used module here to know that the module is hier_block or not. // This visitor behaves almost depth first search if (AstModule* const modp = VN_CAST(nodep->modp(), Module)) { @@ -287,15 +287,15 @@ class HierBlockUsageCollectVisitor final : public VNVisitor { // Nothing to do for interface because hierarchical block does not exist // beyond interface. } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (m_modp && m_modp->hierBlock() && nodep->isIfaceRef() && !nodep->isIfaceParent()) { nodep->v3error("Modport cannot be used at the hierarchical block boundary"); } if (nodep->isGParam() && nodep->overriddenParam()) m_gparams.push_back(nodep); } - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: HierBlockUsageCollectVisitor(V3HierBlockPlan* planp, AstNetlist* netlist) diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 40f54dcce..277531647 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -112,7 +112,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UASSERT_OBJ(!m_modp, nodep, "Unsupported: Nested modules"); m_modp = nodep; m_allMods.push_back(nodep); @@ -130,19 +130,19 @@ private: iterateChildren(nodep); m_modp = nullptr; } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { // TODO allow inlining of modules that have classes // (Probably wait for new inliner scheme) cantInline("class", true); iterateChildren(nodep); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { m_moduleState(nodep->modp()).m_cellRefs++; m_moduleState(m_modp).m_childCells.push_back(nodep); m_instances[m_modp][nodep->modp()]++; iterateChildren(nodep); } - virtual void visit(AstPragma* nodep) override { + void visit(AstPragma* nodep) override { if (nodep->pragType() == VPragmaType::INLINE_MODULE) { if (!m_modp) { nodep->v3error("Inline pragma not under a module"); // LCOV_EXCL_LINE @@ -162,28 +162,28 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { // Remove link. V3LinkDot will reestablish it after inlining. nodep->varp(nullptr); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { // Remove link. V3LinkDot will reestablish it after inlining. // MethodCalls not currently supported by inliner, so keep linked if (!nodep->classOrPackagep() && !VN_IS(nodep, MethodCall)) nodep->taskp(nullptr); iterateChildren(nodep); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { m_modp->user4Inc(); // statement count iterateChildren(nodep); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // Don't count assignments, as they'll likely flatten out // Still need to iterate though to nullify VarXRefs const int oldcnt = m_modp->user4(); iterateChildren(nodep); m_modp->user4(oldcnt); } - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Build ModuleState, user2, and user4 for all modules. // Also build m_allMods and m_instances. iterateChildren(nodep); @@ -226,7 +226,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (m_modp) m_modp->user4Inc(); // Inc statement count iterateChildren(nodep); } @@ -237,7 +237,7 @@ public: : m_moduleState{moduleState} { iterate(nodep); } - virtual ~InlineMarkVisitor() override { + ~InlineMarkVisitor() override { V3Stats::addStat("Optimizations, Inline unsupported", m_statUnsup); } }; @@ -260,7 +260,7 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstCellInline* nodep) override { + void visit(AstCellInline* nodep) override { // Inlined cell under the inline cell, need to move to avoid conflicts nodep->unlinkFrBack(); m_modp->addInlinesp(nodep); @@ -270,20 +270,20 @@ private: // Do CellInlines under this, but don't move them iterateChildren(nodep); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { // Cell under the inline cell, need to rename to avoid conflicts nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); iterateChildren(nodep); } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); iterateChildren(nodep); } - virtual void visit(AstModule* nodep) override { + void visit(AstModule* nodep) override { m_renamedInterfaces.clear(); iterateChildren(nodep); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (nodep->user2p()) { // Make an assignment, so we'll trace it properly // user2p is either a const or a var. @@ -360,17 +360,17 @@ private: if (debug() >= 9) nodep->dumpTree(cout, "varchanged:"); if (debug() >= 9 && nodep->valuep()) nodep->valuep()->dumpTree(cout, "varchangei:"); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // Function under the inline cell, need to rename to avoid conflicts nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); iterateChildren(nodep); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { // Typedef under the inline cell, need to rename to avoid conflicts nodep->name(m_cellp->name() + "__DOT__" + nodep->name()); iterateChildren(nodep); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->varp()->user2p() // It's being converted to an alias. && !nodep->varp()->user3() // Don't constant propagate aliases (we just made) @@ -388,7 +388,7 @@ private: } nodep->name(nodep->varp()->name()); } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { // Track what scope it was originally under so V3LinkDot can resolve it nodep->inlinedDots(VString::dot(m_cellp->name(), ".", nodep->inlinedDots())); for (string tryname = nodep->dotted(); true;) { @@ -406,7 +406,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { // Track what scope it was originally under so V3LinkDot can resolve it nodep->inlinedDots(VString::dot(m_cellp->name(), ".", nodep->inlinedDots())); if (m_renamedInterfaces.count(nodep->dotted())) { @@ -417,9 +417,9 @@ private: } // Not needed, as V3LinkDot doesn't care about typedefs - // virtual void visit(AstRefDType* nodep) override {} + // void visit(AstRefDType* nodep) override {} - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { // If there's a %m in the display text, we add a special node that will contain the name() // Similar code in V3Begin // To keep correct visual order, must add before other Text's @@ -435,12 +435,12 @@ private: if (afterp) nodep->scopeEntrp(afterp); iterateChildren(nodep); } - virtual void visit(AstCoverDecl* nodep) override { + void visit(AstCoverDecl* nodep) override { // Fix path in coverage statements nodep->hier(VString::dot(m_cellp->prettyName(), ".", nodep->hier())); iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -449,7 +449,7 @@ public: , m_cellp{cellp} { iterate(cloneModp); } - virtual ~InlineRelinkVisitor() override = default; + ~InlineRelinkVisitor() override = default; }; //###################################################################### @@ -576,13 +576,13 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Iterate modules backwards, in bottom-up order. Required! iterateAndNextConstNullBackwards(nodep->modulesp()); // Clean up AstIfaceRefDType references iterateChildren(nodep->typeTablep()); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UASSERT_OBJ(!m_modp, nodep, "Unsupported: Nested modules"); m_modp = nodep; // Iterate the stored cells directly to reduce traversal @@ -592,7 +592,7 @@ private: m_moduleState(nodep).m_childCells.clear(); m_modp = nullptr; } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { if (nodep->user5()) { // The cell has been removed so let's make sure we don't leave a reference to it // This dtype may still be in use by the AstAssignVarScope created earlier @@ -602,15 +602,15 @@ private: } //-------------------- - virtual void visit(AstCell* nodep) override { // LCOV_EXCL_START + void visit(AstCell* nodep) override { // LCOV_EXCL_START nodep->v3fatal("Traversal should have been short circuited"); } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { nodep->v3fatal("Traversal should have been short circuited"); } // LCOV_EXCL_STOP - virtual void visit(AstNodeFile*) override {} // Accelerate - virtual void visit(AstNodeDType*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeFile*) override {} // Accelerate + void visit(AstNodeDType*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -618,7 +618,7 @@ public: : m_moduleState{moduleState} { iterate(nodep); } - virtual ~InlineVisitor() override { + ~InlineVisitor() override { V3Stats::addStat("Optimizations, Inlined instances", m_statCells); } }; @@ -639,8 +639,8 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstNetlist* nodep) override { iterateChildren(nodep->topModulep()); } - virtual void visit(AstCell* nodep) override { + void visit(AstNetlist* nodep) override { iterateChildren(nodep->topModulep()); } + void visit(AstCell* nodep) override { VL_RESTORER(m_scope); if (m_scope.empty()) { m_scope = nodep->name(); @@ -673,7 +673,7 @@ private: iterateChildren(modp); } } - virtual void visit(AstAssignVarScope* nodep) override { + void visit(AstAssignVarScope* nodep) override { // Reference const AstVarRef* const reflp = VN_CAST(nodep->lhsp(), VarRef); // What the reference refers to @@ -698,14 +698,14 @@ private: cellp->addIntfRefp(new AstIntfRef(varlp->fileline(), alias)); } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNodeStmt*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNodeStmt*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit InlineIntfRefVisitor(AstNode* nodep) { iterate(nodep); } - virtual ~InlineIntfRefVisitor() override = default; + ~InlineIntfRefVisitor() override = default; }; //###################################################################### diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index e66936eec..adca8b9da 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -49,7 +49,7 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { UINFO(4, " CELL " << nodep << endl); m_cellp = nodep; // VV***** We reset user1p() on each cell!!! @@ -57,7 +57,7 @@ private: iterateChildren(nodep); m_cellp = nullptr; } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // PIN(p,expr) -> ASSIGNW(VARXREF(p),expr) (if sub's input) // or ASSIGNW(expr,VARXREF(p)) (if sub's output) UINFO(4, " PIN " << nodep << endl); @@ -116,7 +116,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstUdpTable* nodep) override { + void visit(AstUdpTable* nodep) override { if (!v3Global.opt.bboxUnsup()) { // If we support primitives, update V3Undriven to remove special case nodep->v3warn(E_UNSUPPORTED, "Unsupported: Verilog 1995 UDP Tables. " @@ -125,17 +125,17 @@ private: } // Save some time - virtual void visit(AstNodeMath*) override {} - virtual void visit(AstNodeAssign*) override {} - virtual void visit(AstAlways*) override {} + void visit(AstNodeMath*) override {} + void visit(AstNodeAssign*) override {} + void visit(AstAlways*) override {} //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit InstVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~InstVisitor() override = default; + ~InstVisitor() override = default; }; //###################################################################### @@ -149,15 +149,15 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (VN_IS(nodep->dtypep(), IfaceRefDType)) { UINFO(8, " dm-1-VAR " << nodep << endl); insert(nodep); } iterateChildren(nodep); } - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // METHODS @@ -181,7 +181,7 @@ public: // CONSTRUCTORS InstDeModVarVisitor() = default; - virtual ~InstDeModVarVisitor() override = default; + ~InstDeModVarVisitor() override = default; void main(AstNodeModule* nodep) { UINFO(8, " dmMODULE " << nodep << endl); m_modVarNameMap.clear(); @@ -203,7 +203,7 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (VN_IS(nodep->dtypep(), UnpackArrayDType) && VN_IS(VN_AS(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) { UINFO(8, " dv-vec-VAR " << nodep << endl); @@ -239,7 +239,7 @@ private: iterateChildren(nodep); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { UINFO(4, " CELL " << nodep << endl); // Find submodule vars UASSERT_OBJ(nodep->modp(), nodep, "Unlinked"); @@ -316,7 +316,7 @@ private: } } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // Any non-direct pins need reconnection with a part-select if (!nodep->exprp()) return; // No-connect if (m_cellRangep) { @@ -478,13 +478,13 @@ private: } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit InstDeVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~InstDeVisitor() override = default; + ~InstDeVisitor() override = default; }; //###################################################################### diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index e07db1461..5514a6e1c 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -76,7 +76,7 @@ public: , m_osp{osp} { if (nodep) iterate(nodep); } - virtual ~InstrCountVisitor() override = default; + ~InstrCountVisitor() override = default; // METHODS uint32_t instrCount() const { return m_instrCount; } @@ -123,7 +123,7 @@ private: } // VISITORS - virtual void visit(AstNodeSel* nodep) override { + void visit(AstNodeSel* nodep) override { if (m_ignoreRemaining) return; // This covers both AstArraySel and AstWordSel // @@ -135,7 +135,7 @@ private: const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->bitp()); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { if (m_ignoreRemaining) return; // Similar to AstNodeSel above, a small select into a large vector // is not expensive. Count the cost of the AstSel itself (scales with @@ -145,13 +145,13 @@ private: iterateAndNextNull(nodep->lsbp()); iterateAndNextNull(nodep->widthp()); } - virtual void visit(AstSliceSel* nodep) override { // LCOV_EXCL_LINE + void visit(AstSliceSel* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("AstSliceSel unhandled"); } - virtual void visit(AstMemberSel* nodep) override { // LCOV_EXCL_LINE + void visit(AstMemberSel* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("AstMemberSel unhandled"); } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { if (m_ignoreRemaining) return; // Nop. // @@ -172,7 +172,7 @@ private: // the widths of the operands (ignored here). markCost(nodep); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { if (m_ignoreRemaining) return; const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->condp()); @@ -199,7 +199,7 @@ private: if (nodep->ifsp()) nodep->ifsp()->user4(0); // Don't dump it } } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { if (m_ignoreRemaining) return; // Just like if/else above, the ternary operator only evaluates // one of the two expressions, so only count the max. @@ -226,13 +226,13 @@ private: if (nodep->expr2p()) nodep->expr2p()->user4(0); // Don't dump it } } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { if (m_ignoreRemaining) return; iterateChildren(nodep); // Anything past a co_await is irrelevant m_ignoreRemaining = true; } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (m_ignoreRemaining) return; const VisitBase vb{this, nodep}; uint32_t totalCount = m_instrCount; @@ -245,7 +245,7 @@ private: m_instrCount = totalCount; m_ignoreRemaining = false; } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { // You'd think that the OrderLogicVertex's would be disjoint trees // of stuff in the AST, but it isn't so: V3Order makes an // OrderLogicVertex for each ACTIVE, and then also makes an @@ -261,7 +261,7 @@ private: markCost(nodep); UASSERT_OBJ(nodep == m_startNodep, nodep, "Multiple actives, or not start node"); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { if (m_ignoreRemaining) return; const VisitBase vb{this, nodep}; iterateChildren(nodep); @@ -269,7 +269,7 @@ private: iterate(nodep->funcp()); UASSERT_OBJ(!m_tracingCall, nodep, "visit(AstCFunc) should have cleared m_tracingCall."); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // Don't count a CFunc other than by tracing a call or counting it // from the root UASSERT_OBJ(m_tracingCall || nodep == m_startNodep, nodep, @@ -284,7 +284,7 @@ private: } m_ignoreRemaining = false; } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (m_ignoreRemaining) return; const VisitBase vb{this, nodep}; iterateChildren(nodep); @@ -312,12 +312,12 @@ public: UASSERT_OBJ(osp, nodep, "Don't call if not dumping"); if (nodep) iterate(nodep); } - virtual ~InstrCountDumpVisitor() override = default; + ~InstrCountDumpVisitor() override = default; private: // METHODS string indent() const { return string(m_depth, ':') + " "; } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { ++m_depth; if (unsigned costPlus1 = nodep->user4()) { *m_osp << " " << indent() << "cost " << std::setw(6) << std::left << (costPlus1 - 1) diff --git a/src/V3LangCode.h b/src/V3LangCode.h index 3877dcf3d..1d2d70326 100644 --- a/src/V3LangCode.h +++ b/src/V3LangCode.h @@ -48,20 +48,20 @@ public: "1800-2005", "1800-2009", "1800-2012", "1800-2017"}; return names[m_e]; } - static V3LangCode mostRecent() { return V3LangCode(L1800_2017); } + static V3LangCode mostRecent() { return V3LangCode{L1800_2017}; } bool systemVerilog() const { return m_e == L1800_2005 || m_e == L1800_2009 || m_e == L1800_2012 || m_e == L1800_2017; } bool legal() const { return m_e != L_ERROR; } // enum en m_e; - inline V3LangCode() + V3LangCode() : m_e{L_ERROR} {} // cppcheck-suppress noExplicitConstructor - inline V3LangCode(en _e) + V3LangCode(en _e) : m_e{_e} {} explicit V3LangCode(const char* textp); - explicit inline V3LangCode(int _e) + explicit V3LangCode(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } }; diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 6a704b5ae..a0b436f64 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -94,18 +94,18 @@ public: consumed(); } ~LifeVarEntry() = default; - inline void simpleAssign(AstNodeAssign* assp) { // New simple A=.... assignment + void simpleAssign(AstNodeAssign* assp) { // New simple A=.... assignment m_assignp = assp; m_constp = nullptr; m_everSet = true; if (VN_IS(assp->rhsp(), Const)) m_constp = VN_AS(assp->rhsp(), Const); } - inline void complexAssign() { // A[x]=... or some complicated assignment + void complexAssign() { // A[x]=... or some complicated assignment m_assignp = nullptr; m_constp = nullptr; m_everSet = true; } - inline void consumed() { // Rvalue read of A + void consumed() { // Rvalue read of A m_assignp = nullptr; } AstNodeAssign* assignp() const { return m_assignp; } @@ -165,7 +165,7 @@ public: checkRemoveAssign(it); it->second.simpleAssign(assp); } else { - m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::SIMPLEASSIGN(), assp)); + m_map.emplace(nodep, LifeVarEntry{LifeVarEntry::SIMPLEASSIGN{}, assp}); } // lifeDump(); } @@ -175,7 +175,7 @@ public: if (it != m_map.end()) { it->second.complexAssign(); } else { - m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN())); + m_map.emplace(nodep, LifeVarEntry{LifeVarEntry::COMPLEXASSIGN{}}); } } void varUsageReplace(AstVarScope* nodep, AstVarRef* varrefp) { @@ -196,7 +196,7 @@ public: UINFO(4, " usage: " << nodep << endl); it->second.consumed(); } else { - m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::CONSUMED())); + m_map.emplace(nodep, LifeVarEntry{LifeVarEntry::CONSUMED{}}); } } void complexAssignFind(AstVarScope* nodep) { @@ -205,7 +205,7 @@ public: UINFO(4, " casfind: " << it->first << endl); it->second.complexAssign(); } else { - m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::COMPLEXASSIGN())); + m_map.emplace(nodep, LifeVarEntry{LifeVarEntry::COMPLEXASSIGN{}}); } } void consumedFind(AstVarScope* nodep) { @@ -213,7 +213,7 @@ public: if (it != m_map.end()) { it->second.consumed(); } else { - m_map.emplace(nodep, LifeVarEntry(LifeVarEntry::CONSUMED())); + m_map.emplace(nodep, LifeVarEntry{LifeVarEntry::CONSUMED{}}); } } void lifeToAbove() { @@ -291,7 +291,7 @@ private: } // VISITORS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, // it's used so can't elim assignment before this use. UASSERT_OBJ(nodep->varScopep(), nodep, "nullptr"); @@ -305,7 +305,7 @@ private: VL_DO_DANGLING(m_lifep->varUsageReplace(vscp, nodep), nodep); } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (nodep->isTimingControl()) { // V3Life doesn't understand time sense - don't optimize setNoopt(); @@ -331,7 +331,7 @@ private: iterateAndNextNull(nodep->lhsp()); } } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { // V3Life doesn't understand time sense if (nodep->isTimingControl()) { // Don't optimize @@ -342,7 +342,7 @@ private: } //---- Track control flow changes - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { UINFO(4, " IF " << nodep << endl); // Condition is part of PREVIOUS block iterateAndNextNull(nodep->condp()); @@ -368,7 +368,7 @@ private: VL_DO_DANGLING(delete elseLifep, elseLifep); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { // While's are a problem, as we don't allow loops in the graph. We // may go around the cond/body multiple times. Thus a // lifelication just in the body is ok, but we can't delete an @@ -397,7 +397,7 @@ private: VL_DO_DANGLING(delete condLifep, condLifep); VL_DO_DANGLING(delete bodyLifep, bodyLifep); } - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { // As with While's we can't predict if a JumpGo will kill us or not // It's worse though as an IF(..., JUMPGO) may change the control flow. // Just don't optimize blocks with labels; they're rare - so far. @@ -415,7 +415,7 @@ private: bodyLifep->lifeToAbove(); VL_DO_DANGLING(delete bodyLifep, bodyLifep); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { // UINFO(4, " CCALL " << nodep << endl); iterateChildren(nodep); // Enter the function and trace it @@ -425,7 +425,7 @@ private: iterate(nodep->funcp()); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // UINFO(4, " CFUNC " << nodep << endl); if (!m_tracingCall && !nodep->entryPoint()) return; m_tracingCall = false; @@ -434,17 +434,17 @@ private: } iterateChildren(nodep); } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment iterateChildren(nodep); } - virtual void visit(AstCMath* nodep) override { + void visit(AstCMath* nodep) override { m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment iterateChildren(nodep); } - virtual void visit(AstVar*) override {} // Don't want varrefs under it - virtual void visit(AstNode* nodep) override { + void visit(AstVar*) override {} // Don't want varrefs under it + void visit(AstNode* nodep) override { if (nodep->isTimingControl()) { // V3Life doesn't understand time sense - don't optimize setNoopt(); @@ -463,7 +463,7 @@ public: if (m_lifep) VL_DO_CLEAR(delete m_lifep, m_lifep = nullptr); } } - virtual ~LifeVisitor() override { + ~LifeVisitor() override { if (m_lifep) VL_DO_CLEAR(delete m_lifep, m_lifep = nullptr); } VL_UNCOPYABLE(LifeVisitor); @@ -479,20 +479,20 @@ private: LifeState* const m_statep; // Current state // VISITORS - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (nodep->entryPoint()) { // Usage model 1: Simulate all C code, doing lifetime analysis LifeVisitor{nodep, m_statep}; } } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { // Usage model 2: Cleanup basic blocks LifeVisitor{nodep, m_statep}; } - virtual void visit(AstVar*) override {} // Accelerate - virtual void visit(AstNodeStmt*) override {} // Accelerate - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Accelerate + void visit(AstNodeStmt*) override {} // Accelerate + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -500,7 +500,7 @@ public: : m_statep{statep} { iterate(nodep); } - virtual ~LifeTopVisitor() override = default; + ~LifeTopVisitor() override = default; }; //###################################################################### diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 78e417192..faa13a32f 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -54,21 +54,21 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { const AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); if (AstVarScope* const newvscp = reinterpret_cast(vscp->user4p())) { UINFO(9, " Replace " << nodep << " to " << newvscp << endl); - AstVarRef* const newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); + AstVarRef* const newrefp = new AstVarRef{nodep->fileline(), newvscp, nodep->access()}; nodep->replaceWith(newrefp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Only track the top scopes, not lower level functions if (nodep->isTop()) iterateChildren(nodep); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { iterateChildren(nodep); if (!nodep->funcp()->entryPoint()) { // Enter the function and trace it @@ -76,23 +76,23 @@ private: iterate(nodep->funcp()); } } - virtual void visit(AstExecGraph* nodep) override { + void visit(AstExecGraph* nodep) override { // Can just iterate across the MTask bodies in any order. Order // isn't important for LifePostElimVisitor's simple substitution. iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (!m_tracingCall && !nodep->entryPoint()) return; m_tracingCall = false; iterateChildren(nodep); } - virtual void visit(AstVar*) override {} // Don't want varrefs under it - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't want varrefs under it + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit LifePostElimVisitor(AstTopScope* nodep) { iterate(nodep); } - virtual ~LifePostElimVisitor() override = default; + ~LifePostElimVisitor() override = default; }; //###################################################################### @@ -256,7 +256,7 @@ private: } // VISITORS - virtual void visit(AstTopScope* nodep) override { + void visit(AstTopScope* nodep) override { AstNode::user4ClearTree(); // user4p() used on entire tree // First, build maps of every location (mtask and sequence @@ -280,7 +280,7 @@ private: // Replace any node4p varscopes with the new scope LifePostElimVisitor{nodep}; } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // Mark variables referenced outside _eval__nba if (!m_inEvalNba) { nodep->varScopep()->user1(true); @@ -295,7 +295,7 @@ private: if (nodep->access().isWriteOrRW()) m_writes[vscp].insert(loc); if (nodep->access().isReadOrRW()) m_reads[vscp].insert(loc); } - virtual void visit(AstAssignPre* nodep) override { + void visit(AstAssignPre* nodep) override { // Do not record varrefs within assign pre. // // The pre-assignment into the dly var should not count as its @@ -303,7 +303,7 @@ private: // would still happen if the dly var were eliminated. if (!m_inEvalNba) iterateChildren(nodep); } - virtual void visit(AstAssignPost* nodep) override { + void visit(AstAssignPost* nodep) override { // Don't record ASSIGNPOST in the read/write maps, record them in a // separate map if (const AstVarRef* const rhsp = VN_CAST(nodep->rhsp(), VarRef)) { @@ -315,11 +315,11 @@ private: m_assignposts[dlyVarp] = LifePostLocation(loc, nodep); } } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Only track the top scopes, not lower level functions if (nodep->isTop()) iterateChildren(nodep); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { iterateChildren(nodep); if (!nodep->funcp()->entryPoint()) { // Enter the function and trace it @@ -327,7 +327,7 @@ private: iterate(nodep->funcp()); } } - virtual void visit(AstExecGraph* nodep) override { + void visit(AstExecGraph* nodep) override { // Treat the ExecGraph like a call to each mtask body if (m_inEvalNba) { UASSERT_OBJ(!m_mtasksGraphp, nodep, "Cannot handle more than one AstExecGraph"); @@ -342,7 +342,7 @@ private: } m_execMTaskp = nullptr; } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (!m_tracingCall && !nodep->entryPoint()) return; VL_RESTORER(m_inEvalNba); if (nodep == m_evalNbap) m_inEvalNba = true; @@ -350,8 +350,8 @@ private: iterateChildren(nodep); } //----- - virtual void visit(AstVar*) override {} // Don't want varrefs under it - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't want varrefs under it + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -359,7 +359,7 @@ public: : m_evalNbap{netlistp->evalNbap()} { iterate(netlistp); } - virtual ~LifePostDlyVisitor() override { + ~LifePostDlyVisitor() override { V3Stats::addStat("Optimizations, Lifetime postassign deletions", m_statAssnDel); } }; diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 03703c2c8..393013026 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -45,8 +45,8 @@ class LinkCellsGraph final : public V3Graph { public: LinkCellsGraph() = default; - virtual ~LinkCellsGraph() override = default; - virtual void loopsMessageCb(V3GraphVertex* vertexp) override; + ~LinkCellsGraph() override = default; + void loopsMessageCb(V3GraphVertex* vertexp) override; }; class LinkCellsVertex final : public V3GraphVertex { @@ -56,12 +56,12 @@ public: LinkCellsVertex(V3Graph* graphp, AstNodeModule* modp) : V3GraphVertex{graphp} , m_modp{modp} {} - virtual ~LinkCellsVertex() override = default; + ~LinkCellsVertex() override = default; AstNodeModule* modp() const { return m_modp; } - virtual string name() const override { return modp()->name(); } - virtual FileLine* fileline() const override { return modp()->fileline(); } + string name() const override { return modp()->name(); } + FileLine* fileline() const override { return modp()->fileline(); } // Recursive modules get space for maximum recursion - virtual uint32_t rankAdder() const override { + uint32_t rankAdder() const override { return m_modp->recursiveClone() ? (1 + v3Global.opt.moduleRecursionDepth()) : 1; } }; @@ -70,8 +70,8 @@ class LibraryVertex final : public V3GraphVertex { public: explicit LibraryVertex(V3Graph* graphp) : V3GraphVertex{graphp} {} - virtual ~LibraryVertex() override = default; - virtual string name() const override { return "*LIBRARY*"; } + ~LibraryVertex() override = default; + string name() const override { return "*LIBRARY*"; } }; void LinkCellsGraph::loopsMessageCb(V3GraphVertex* vertexp) { @@ -161,7 +161,7 @@ private: } // VISITs - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { AstNode::user1ClearTree(); readModNames(); iterateChildren(nodep); @@ -181,8 +181,8 @@ private: << "' was not found in design."); } } - virtual void visit(AstConstPool* nodep) override {} - virtual void visit(AstNodeModule* nodep) override { + void visit(AstConstPool* nodep) override {} + void visit(AstNodeModule* nodep) override { // Module: Pick up modnames, so we can resolve cells later VL_RESTORER(m_modp); { @@ -227,7 +227,7 @@ private: } } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { // Cell: Resolve its filename. If necessary, parse it. UINFO(4, "Link IfaceRef: " << nodep << endl); // Use findIdUpward instead of findIdFlat; it doesn't matter for now @@ -246,14 +246,14 @@ private: // Note cannot do modport resolution here; modports are allowed underneath generates } - virtual void visit(AstPackageImport* nodep) override { + void visit(AstPackageImport* nodep) override { // Package Import: We need to do the package before the use of a package iterateChildren(nodep); UASSERT_OBJ(nodep->packagep(), nodep, "Unlinked package"); // Parser should set packagep new V3GraphEdge(&m_graph, vertex(m_modp), vertex(nodep->packagep()), 1, false); } - virtual void visit(AstBind* nodep) override { + void visit(AstBind* nodep) override { // Bind: Has cells underneath that need to be put into the new // module, and cells which need resolution // TODO this doesn't allow bind to dotted hier names, that would require @@ -275,7 +275,7 @@ private: pushDeletep(nodep->unlinkFrBack()); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { // Cell: Resolve its filename. If necessary, parse it. // Execute only once. Complication is that cloning may result in // user1 being set (for pre-clone) so check if user1() matches the @@ -452,14 +452,14 @@ private: UINFO(4, " Link Cell done: " << nodep << endl); } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { iterateChildren(nodep); for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { pinp->param(true); if (pinp->name() == "") pinp->name("__paramNumber" + cvtToStr(pinp->pinNum())); } } - virtual void visit(AstClassOrPackageRef* nodep) override { + void visit(AstClassOrPackageRef* nodep) override { iterateChildren(nodep); // Inside a class, an extends or reference to another class // Note we don't add a V3GraphEdge{vertex(m_modp), vertex(nodep->classOrPackagep()} @@ -471,7 +471,7 @@ private: } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } // METHODS void readModNames() { @@ -528,7 +528,7 @@ public: } iterate(nodep); } - virtual ~LinkCellsVisitor() override = default; + ~LinkCellsVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 493beaf4d..2825daaf7 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -81,25 +81,25 @@ class LinkNodeMatcherClass final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Class); } + bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Class); } }; class LinkNodeMatcherFTask final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, NodeFTask); } + bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, NodeFTask); } }; class LinkNodeMatcherModport final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Modport); } + bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Modport); } }; class LinkNodeMatcherVar final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { + bool nodeMatch(const AstNode* nodep) const override { return VN_IS(nodep, Var) || VN_IS(nodep, LambdaArgRef); } }; class LinkNodeMatcherVarIO final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { + bool nodeMatch(const AstNode* nodep) const override { const AstVar* const varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isIO(); @@ -107,7 +107,7 @@ public: }; class LinkNodeMatcherVarParam final : public VNodeMatcher { public: - virtual bool nodeMatch(const AstNode* nodep) const override { + bool nodeMatch(const AstNode* nodep) const override { const AstVar* const varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isParam(); @@ -742,7 +742,7 @@ class LinkDotFindVisitor final : public VNVisitor { } // VISITs - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Process $unit or other packages // Not needed - dotted references not allowed from inside packages // for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); @@ -770,9 +770,9 @@ class LinkDotFindVisitor final : public VNVisitor { m_curSymp = m_modSymp = nullptr; } } - virtual void visit(AstTypeTable*) override {} - virtual void visit(AstConstPool*) override {} - virtual void visit(AstNodeModule* nodep) override { + void visit(AstTypeTable*) override {} + void visit(AstConstPool*) override {} + void visit(AstNodeModule* nodep) override { // Called on top module from Netlist, other modules from the cell creating them, // and packages UINFO(8, " " << nodep << endl); @@ -839,7 +839,7 @@ class LinkDotFindVisitor final : public VNVisitor { UINFO(5, "Module not under any CELL or top - dead module: " << nodep << endl); } } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { UASSERT_OBJ(m_curSymp, nodep, "Class not under module/package/$unit"); UINFO(8, " " << nodep << endl); VL_RESTORER(m_scope); @@ -871,12 +871,12 @@ class LinkDotFindVisitor final : public VNVisitor { if (!m_explicitNew && m_statep->forPrimary()) makeImplicitNew(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UASSERT_OBJ(m_statep->forScopeCreation(), nodep, "Scopes should only exist right after V3Scope"); // Ignored. Processed in next step } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { UINFO(5, " CELL under " << m_scope << " is " << nodep << endl); // Process XREFs/etc inside pins if (nodep->recursive() && m_inRecursion) return; @@ -911,7 +911,7 @@ class LinkDotFindVisitor final : public VNVisitor { if (nodep->modp()) iterate(nodep->modp()); } } - virtual void visit(AstCellInline* nodep) override { + void visit(AstCellInline* nodep) override { UINFO(5, " CELLINLINE under " << m_scope << " is " << nodep << endl); VSymEnt* aboveSymp = m_curSymp; // If baz__DOT__foo__DOT__bar, we need to find baz__DOT__foo and add bar to it. @@ -931,11 +931,11 @@ class LinkDotFindVisitor final : public VNVisitor { m_statep->insertInline(aboveSymp, m_modSymp, nodep, nodep->name()); } } - virtual void visit(AstDefParam* nodep) override { + void visit(AstDefParam* nodep) override { nodep->user1p(m_curSymp); iterateChildren(nodep); } - virtual void visit(AstNodeBlock* nodep) override { + void visit(AstNodeBlock* nodep) override { UINFO(5, " " << nodep << endl); if (nodep->name() == "" && nodep->unnamed()) { // Unnamed blocks are only important when they contain var @@ -967,7 +967,7 @@ class LinkDotFindVisitor final : public VNVisitor { } } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // NodeTask: Remember its name for later resolution UINFO(5, " " << nodep << endl); UASSERT_OBJ(m_curSymp && m_modSymp, nodep, "Function/Task not under module?"); @@ -1024,7 +1024,7 @@ class LinkDotFindVisitor final : public VNVisitor { } AstVar* const newvarp = new AstVar(nodep->fileline(), VVarType::VAR, nodep->name(), - VFlagChildDType(), dtypep); // Not dtype resolved yet + VFlagChildDType{}, dtypep); // Not dtype resolved yet newvarp->direction(VDirection::OUTPUT); newvarp->lifetime(VLifetime::AUTOMATIC); newvarp->funcReturn(true); @@ -1040,7 +1040,7 @@ class LinkDotFindVisitor final : public VNVisitor { m_ftaskp = nullptr; } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { // Var: Remember its name for later resolution UASSERT_OBJ(m_curSymp && m_modSymp, nodep, "Var not under module?"); iterateChildren(nodep); @@ -1139,8 +1139,8 @@ class LinkDotFindVisitor final : public VNVisitor { // We first search if the parameter is overwritten and then replace it with a // new value. It will keep the same FileLine information. if (v3Global.opt.hasParameter(nodep->name())) { - AstVar* const newp = new AstVar( - nodep->fileline(), VVarType(VVarType::GPARAM), nodep->name(), nodep); + AstVar* const newp = new AstVar{ + nodep->fileline(), VVarType{VVarType::GPARAM}, nodep->name(), nodep}; newp->combineType(nodep); const string svalue = v3Global.opt.parameter(nodep->name()); if (AstNode* const valuep @@ -1173,18 +1173,18 @@ class LinkDotFindVisitor final : public VNVisitor { } } } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { UASSERT_OBJ(m_curSymp, nodep, "Typedef not under module/package/$unit"); iterateChildren(nodep); m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_classOrPackagep); } - virtual void visit(AstTypedefFwd* nodep) override { + void visit(AstTypedefFwd* nodep) override { UASSERT_OBJ(m_curSymp, nodep, "Typedef not under module/package/$unit"); iterateChildren(nodep); // No need to insert, only the real typedef matters, but need to track for errors nodep->user1p(m_curSymp); } - virtual void visit(AstParamTypeDType* nodep) override { + void visit(AstParamTypeDType* nodep) override { UASSERT_OBJ(m_curSymp, nodep, "Parameter type not under module/package/$unit"); iterateChildren(nodep); m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_classOrPackagep); @@ -1195,11 +1195,11 @@ class LinkDotFindVisitor final : public VNVisitor { symp->exported(false); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // For dotted resolution, ignore all AstVars under functions, otherwise shouldn't exist UASSERT_OBJ(!m_statep->forScopeCreation(), nodep, "No CFuncs expected in tree yet"); } - virtual void visit(AstEnumItem* nodep) override { + void visit(AstEnumItem* nodep) override { // EnumItem: Remember its name for later resolution iterateChildren(nodep); // Find under either a task or the module's vars @@ -1238,7 +1238,7 @@ class LinkDotFindVisitor final : public VNVisitor { } if (ins) m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_classOrPackagep); } - virtual void visit(AstPackageImport* nodep) override { + void visit(AstPackageImport* nodep) override { UINFO(4, " Link: " << nodep << endl); VSymEnt* const srcp = m_statep->getNodeSym(nodep->packagep()); if (nodep->name() == "*") { @@ -1256,7 +1256,7 @@ class LinkDotFindVisitor final : public VNVisitor { UINFO(9, " Link Done: " << nodep << endl); // No longer needed, but can't delete until any multi-instantiated modules are expanded } - virtual void visit(AstPackageExport* nodep) override { + void visit(AstPackageExport* nodep) override { UINFO(9, " Link: " << nodep << endl); VSymEnt* const srcp = m_statep->getNodeSym(nodep->packagep()); if (nodep->name() != "*") { @@ -1270,13 +1270,13 @@ class LinkDotFindVisitor final : public VNVisitor { UINFO(9, " Link Done: " << nodep << endl); // No longer needed, but can't delete until any multi-instantiated modules are expanded } - virtual void visit(AstPackageExportStarStar* nodep) override { + void visit(AstPackageExportStarStar* nodep) override { UINFO(4, " Link: " << nodep << endl); m_curSymp->exportStarStar(m_statep->symsp()); // No longer needed, but can't delete until any multi-instantiated modules are expanded } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { // Symbol table needs nodep->name() as the index variable's name VL_RESTORER(m_curSymp); VSymEnt* const oldCurSymp = m_curSymp; @@ -1327,7 +1327,7 @@ class LinkDotFindVisitor final : public VNVisitor { } } - virtual void visit(AstWithParse* nodep) override { + void visit(AstWithParse* nodep) override { // Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation)) const auto funcrefp = VN_AS(nodep->funcrefp(), NodeFTaskRef); UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task"); @@ -1355,7 +1355,7 @@ class LinkDotFindVisitor final : public VNVisitor { nodep->replaceWith(funcrefp->unlinkFrBack()); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstWith* nodep) override { + void visit(AstWith* nodep) override { // Symbol table needs nodep->name() as the index variable's name // Iteration will pickup the AstVar we made under AstWith VL_RESTORER(m_curSymp); @@ -1373,7 +1373,7 @@ class LinkDotFindVisitor final : public VNVisitor { } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1383,7 +1383,7 @@ public: iterate(rootp); } - virtual ~LinkDotFindVisitor() override = default; + ~LinkDotFindVisitor() override = default; }; //====================================================================== @@ -1425,9 +1425,9 @@ private: } // VISITs - virtual void visit(AstTypeTable*) override {} - virtual void visit(AstConstPool*) override {} - virtual void visit(AstNodeModule* nodep) override { + void visit(AstTypeTable*) override {} + void visit(AstConstPool*) override {} + void visit(AstNodeModule* nodep) override { UINFO(5, " " << nodep << endl); if (nodep->dead() || !nodep->user4()) { UINFO(4, "Mark dead module " << nodep << endl); @@ -1444,7 +1444,7 @@ private: m_modp = nullptr; } } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // Pin: Link to submodule's port // Deal with implicit definitions - do before Resolve visitor as may // be referenced above declaration @@ -1453,7 +1453,7 @@ private: pinImplicitExprRecurse(nodep->exprp()); } } - virtual void visit(AstDefParam* nodep) override { + void visit(AstDefParam* nodep) override { iterateChildren(nodep); nodep->v3warn(DEFPARAM, "defparam is deprecated (IEEE 1800-2017 C.4.1)\n" << nodep->warnMore() @@ -1475,7 +1475,7 @@ private: } VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstPort* nodep) override { + void visit(AstPort* nodep) override { // Port: Stash the pin number // Need to set pin numbers after varnames are created // But before we do the final resolution based on names @@ -1508,14 +1508,14 @@ private: // Ports not needed any more VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { // Deal with implicit definitions // We used to nodep->allowImplicit() here, but it turns out // normal "assigns" can also make implicit wires. Yuk. pinImplicitExprRecurse(nodep->lhsp()); iterateChildren(nodep); } - virtual void visit(AstAssignAlias* nodep) override { + void visit(AstAssignAlias* nodep) override { // tran gates need implicit creation // As VarRefs don't exist in forPrimary, sanity check UASSERT_OBJ(!m_statep->forPrimary(), nodep, "Assign aliases unexpected pre-dot"); @@ -1527,13 +1527,13 @@ private: } iterateChildren(nodep); } - virtual void visit(AstImplicit* nodep) override { + void visit(AstImplicit* nodep) override { // Unsupported gates need implicit creation pinImplicitExprRecurse(nodep); // We're done with implicit gates VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstClassOrPackageRef* nodep) override { + void visit(AstClassOrPackageRef* nodep) override { if (auto* const fwdp = VN_CAST(nodep->classOrPackageNodep(), TypedefFwd)) { // Relink forward definitions to the "real" definition VSymEnt* const foundp = m_statep->getNodeSym(fwdp)->findIdFallback(fwdp->name()); @@ -1555,7 +1555,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstTypedefFwd* nodep) override { + void visit(AstTypedefFwd* nodep) override { VSymEnt* const foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->name()); if (!foundp && v3Global.opt.pedantic()) { // We only check it was ever really defined in pedantic mode, as it @@ -1570,7 +1570,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1579,7 +1579,7 @@ public: UINFO(4, __FUNCTION__ << ": " << endl); iterate(rootp); } - virtual ~LinkDotParamVisitor() override = default; + ~LinkDotParamVisitor() override = default; }; //====================================================================== @@ -1594,12 +1594,12 @@ class LinkDotScopeVisitor final : public VNVisitor { static int debug() { return LinkDotState::debug(); } // VISITs - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Recurse..., backward as must do packages before using packages iterateChildrenBackwards(nodep); } - virtual void visit(AstConstPool*) override {} - virtual void visit(AstScope* nodep) override { + void visit(AstConstPool*) override {} + void visit(AstScope* nodep) override { UINFO(8, " SCOPE " << nodep << endl); UASSERT_OBJ(m_statep->forScopeCreation(), nodep, "Scopes should only exist right after V3Scope"); @@ -1611,7 +1611,7 @@ class LinkDotScopeVisitor final : public VNVisitor { m_modSymp = nullptr; m_scopep = nullptr; } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { if (!nodep->varp()->isFuncLocal() && !nodep->varp()->isClassMember()) { VSymEnt* const varSymp = m_statep->insertSym(m_modSymp, nodep->varp()->name(), nodep, nullptr); @@ -1649,22 +1649,22 @@ class LinkDotScopeVisitor final : public VNVisitor { } } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { VSymEnt* const symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); symp->fallbackp(m_modSymp); // No recursion, we don't want to pick up variables } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { VSymEnt* const symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); symp->fallbackp(m_modSymp); // No recursion, we don't want to pick up variables } - virtual void visit(AstWith* nodep) override { + void visit(AstWith* nodep) override { VSymEnt* const symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); symp->fallbackp(m_modSymp); // No recursion, we don't want to pick up variables } - virtual void visit(AstAssignAlias* nodep) override { + void visit(AstAssignAlias* nodep) override { // Track aliases created by V3Inline; if we get a VARXREF(aliased_from) // we'll need to replace it with a VARXREF(aliased_to) if (debug() >= 9) nodep->dumpTree(cout, "- alias: "); @@ -1674,7 +1674,7 @@ class LinkDotScopeVisitor final : public VNVisitor { fromVscp->user2p(toVscp); iterateChildren(nodep); } - virtual void visit(AstAssignVarScope* nodep) override { + void visit(AstAssignVarScope* nodep) override { UINFO(5, "ASSIGNVARSCOPE " << nodep << endl); if (debug() >= 9) nodep->dumpTree(cout, "- avs: "); VSymEnt* rhsSymp; @@ -1734,9 +1734,9 @@ class LinkDotScopeVisitor final : public VNVisitor { } // For speed, don't recurse things that can't have scope // Note we allow AstNodeStmt's as generates may be under them - virtual void visit(AstCell*) override {} - virtual void visit(AstVar*) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstCell*) override {} + void visit(AstVar*) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1745,7 +1745,7 @@ public: UINFO(4, __FUNCTION__ << ": " << endl); iterate(rootp); } - virtual ~LinkDotScopeVisitor() override = default; + ~LinkDotScopeVisitor() override = default; }; //====================================================================== @@ -1760,7 +1760,7 @@ class LinkDotIfaceVisitor final : public VNVisitor { static int debug() { return LinkDotState::debug(); } // VISITs - virtual void visit(AstModport* nodep) override { + void visit(AstModport* nodep) override { // Modport: Remember its name for later resolution UINFO(5, " fiv: " << nodep << endl); VL_RESTORER(m_curSymp); @@ -1772,7 +1772,7 @@ class LinkDotIfaceVisitor final : public VNVisitor { iterateChildren(nodep); } } - virtual void visit(AstModportFTaskRef* nodep) override { + void visit(AstModportFTaskRef* nodep) override { UINFO(5, " fif: " << nodep << endl); iterateChildren(nodep); if (nodep->isExport()) nodep->v3warn(E_UNSUPPORTED, "Unsupported: modport export"); @@ -1795,7 +1795,7 @@ class LinkDotIfaceVisitor final : public VNVisitor { VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstModportVarRef* nodep) override { + void visit(AstModportVarRef* nodep) override { UINFO(5, " fiv: " << nodep << endl); iterateChildren(nodep); VSymEnt* const symp = m_curSymp->findIdFallback(nodep->name()); @@ -1820,7 +1820,7 @@ class LinkDotIfaceVisitor final : public VNVisitor { VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1830,7 +1830,7 @@ public: UINFO(4, __FUNCTION__ << ": " << endl); iterate(nodep); } - virtual ~LinkDotIfaceVisitor() override = default; + ~LinkDotIfaceVisitor() override = default; }; void LinkDotState::computeIfaceModSyms() { @@ -1935,7 +1935,7 @@ private: } } AstVar* const newp = new AstVar(nodep->fileline(), VVarType::WIRE, nodep->name(), - VFlagLogicPacked(), 1); + VFlagLogicPacked{}, 1); newp->trace(modp->modTrace()); nodep->varp(newp); modp->addStmtp(newp); @@ -1966,7 +1966,7 @@ private: nodep->v3error("Illegal call of a task as a function: " << nodep->prettyNameQ()); } } - inline void checkNoDot(AstNode* nodep) { + void checkNoDot(AstNode* nodep) { if (VL_UNLIKELY(m_ds.m_dotPos != DP_NONE)) { // UINFO(9, "ds=" << m_ds.ascii() << endl); nodep->v3error("Syntax Error: Not expecting " << nodep->type() << " under a " @@ -2005,13 +2005,13 @@ private: } // VISITs - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Recurse..., backward as must do packages before using packages iterateChildrenBackwards(nodep); } - virtual void visit(AstTypeTable*) override {} - virtual void visit(AstConstPool*) override {} - virtual void visit(AstNodeModule* nodep) override { + void visit(AstTypeTable*) override {} + void visit(AstConstPool*) override {} + void visit(AstNodeModule* nodep) override { if (nodep->dead()) return; checkNoDot(nodep); UINFO(8, " " << nodep << endl); @@ -2025,7 +2025,7 @@ private: m_modp = nullptr; m_ds.m_dotSymp = m_curSymp = m_modSymp = nullptr; } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UINFO(8, " " << nodep << endl); VL_RESTORER(m_modSymp); VL_RESTORER(m_curSymp); @@ -2036,14 +2036,14 @@ private: m_ds.m_dotSymp = m_curSymp = m_modSymp = nullptr; } } - virtual void visit(AstCellInline* nodep) override { + void visit(AstCellInline* nodep) override { checkNoDot(nodep); if (m_statep->forScopeCreation() && !v3Global.opt.vpi()) { nodep->unlinkFrBack(); VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { // Cell: Recurse inside or cleanup not founds checkNoDot(nodep); AstNode::user5ClearTree(); @@ -2072,7 +2072,7 @@ private: // Parent module inherits child's publicity // This is done bottom up in the LinkBotupVisitor stage } - virtual void visit(AstClassRefDType* nodep) override { + void visit(AstClassRefDType* nodep) override { // Cell: Recurse inside or cleanup not founds checkNoDot(nodep); AstNode::user5ClearTree(); @@ -2089,7 +2089,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // Pin: Link to submodule's port checkNoDot(nodep); iterateChildren(nodep); @@ -2130,7 +2130,7 @@ private: } // Early return() above when deleted } - virtual void visit(AstDot* nodep) override { + void visit(AstDot* nodep) override { // Legal under a DOT: AstDot, AstParseRef, AstPackageRef, AstNodeSel // also a DOT can be part of an expression, but only above plus // AstFTaskRef are legal children @@ -2239,7 +2239,7 @@ private: m_ds.m_dotp = lastStates.m_dotp; } } - virtual void visit(AstParseRef* nodep) override { + void visit(AstParseRef* nodep) override { if (nodep->user3SetOnce()) return; UINFO(9, " linkPARSEREF " << m_ds.ascii() << " n=" << nodep << endl); // m_curSymp is symbol table of outer expression @@ -2509,7 +2509,7 @@ private: UINFO(7, " ErrParseRef curSymp=se" << cvtToHex(m_curSymp) << " ds=" << m_ds.ascii() << endl); const string suggest = m_statep->suggestSymFallback( - m_ds.m_dotSymp, nodep->name(), VNodeMatcher()); + m_ds.m_dotSymp, nodep->name(), VNodeMatcher{}); nodep->v3error("Can't find definition of " << expectWhat << ": " << nodep->prettyNameQ() << '\n' << (suggest.empty() ? "" : nodep->warnMore() + suggest)); @@ -2538,7 +2538,7 @@ private: } if (start) m_ds = lastStates; } - virtual void visit(AstClassOrPackageRef* nodep) override { + void visit(AstClassOrPackageRef* nodep) override { // Class: Recurse inside or cleanup not founds // checkNoDot not appropriate, can be under a dot AstNode::user5ClearTree(); @@ -2559,7 +2559,7 @@ private: } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // VarRef: Resolve its reference // ParseRefs are used the first pass (forPrimary) so we shouldn't get can't find // errors here now that we have a VarRef. @@ -2581,7 +2581,7 @@ private: } } } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { // VarRef: Resolve its reference // We always link even if varp() is set, because the module we choose may change // due to creating new modules, flattening, etc. @@ -2661,18 +2661,18 @@ private: } } } - virtual void visit(AstEnumDType* nodep) override { + void visit(AstEnumDType* nodep) override { iterateChildren(nodep); AstRefDType* const refdtypep = VN_CAST(nodep->subDTypep(), RefDType); if (refdtypep && (nodep == refdtypep->subDTypep())) { refdtypep->v3error("Self-referential enumerated type definition"); } } - virtual void visit(AstEnumItemRef* nodep) override { + void visit(AstEnumItemRef* nodep) override { // EnumItemRef may be under a dot. Should already be resolved. iterateChildren(nodep); } - virtual void visit(AstMethodCall* nodep) override { + void visit(AstMethodCall* nodep) override { // Created here so should already be resolved. VL_RESTORER(m_ds); { @@ -2680,7 +2680,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { checkNoDot(nodep); iterateChildren(nodep); if (m_statep->forPrimary() && nodep->isIO() && !m_ftaskp && !nodep->user4()) { @@ -2688,7 +2688,7 @@ private: "Input/output/inout does not appear in port list: " << nodep->prettyNameQ()); } } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { if (nodep->user3SetOnce()) return; UINFO(8, " " << nodep << endl); UINFO(8, " " << m_ds.ascii() << endl); @@ -2854,7 +2854,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstSelBit* nodep) override { + void visit(AstSelBit* nodep) override { if (nodep->user3SetOnce()) return; iterateAndNextNull(nodep->fromp()); if (m_ds.m_dotPos @@ -2882,7 +2882,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstNodePreSel* nodep) override { + void visit(AstNodePreSel* nodep) override { // Excludes simple AstSelBit, see above if (nodep->user3SetOnce()) return; if (m_ds.m_dotPos @@ -2901,11 +2901,11 @@ private: iterateAndNextNull(nodep->attrp()); } } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { // checkNoDot not appropriate, can be under a dot iterateChildren(nodep); } - virtual void visit(AstNodeBlock* nodep) override { + void visit(AstNodeBlock* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); VSymEnt* const oldCurSymp = m_curSymp; @@ -2919,7 +2919,7 @@ private: m_ds.m_dotSymp = m_curSymp = oldCurSymp; UINFO(5, " cur=se" << cvtToHex(m_curSymp) << endl); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); if (nodep->isExternDef()) { @@ -2941,7 +2941,7 @@ private: m_ds.m_dotSymp = m_curSymp = oldCurSymp; m_ftaskp = nullptr; } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); VSymEnt* const oldCurSymp = m_curSymp; @@ -2951,7 +2951,7 @@ private: } m_ds.m_dotSymp = m_curSymp = oldCurSymp; } - virtual void visit(AstWith* nodep) override { + void visit(AstWith* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); VSymEnt* const oldCurSymp = m_curSymp; @@ -2961,12 +2961,12 @@ private: } m_ds.m_dotSymp = m_curSymp = oldCurSymp; } - virtual void visit(AstLambdaArgRef* nodep) override { + void visit(AstLambdaArgRef* nodep) override { UINFO(5, " " << nodep << endl); // No checknodot(nodep), visit(AstScope) will check for LambdaArgRef iterateChildren(nodep); } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); VL_RESTORER(m_curSymp); @@ -3041,7 +3041,7 @@ private: } } } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { // Resolve its reference if (nodep->user3SetOnce()) return; if (AstNode* const cpackagep = nodep->classOrPackageOpp()) { @@ -3112,7 +3112,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstDpiExport* nodep) override { + void visit(AstDpiExport* nodep) override { // AstDpiExport: Make sure the function referenced exists, then dump it iterateChildren(nodep); checkNoDot(nodep); @@ -3130,35 +3130,35 @@ private: } VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstPackageImport* nodep) override { + void visit(AstPackageImport* nodep) override { // No longer needed checkNoDot(nodep); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstPackageExport* nodep) override { + void visit(AstPackageExport* nodep) override { // No longer needed checkNoDot(nodep); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstPackageExportStarStar* nodep) override { + void visit(AstPackageExportStarStar* nodep) override { // No longer needed checkNoDot(nodep); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstCellRef* nodep) override { + void visit(AstCellRef* nodep) override { UINFO(5, " AstCellRef: " << nodep << " " << m_ds.ascii() << endl); iterateChildren(nodep); } - virtual void visit(AstCellArrayRef* nodep) override { + void visit(AstCellArrayRef* nodep) override { UINFO(5, " AstCellArrayRef: " << nodep << " " << m_ds.ascii() << endl); // Expression already iterated } - virtual void visit(AstUnlinkedRef* nodep) override { + void visit(AstUnlinkedRef* nodep) override { UINFO(5, " AstCellArrayRef: " << nodep << " " << m_ds.ascii() << endl); // No need to iterate, if we have a UnlinkedVarXRef, we're already done } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { checkNoDot(nodep); iterateChildren(nodep); } @@ -3170,7 +3170,7 @@ public: UINFO(4, __FUNCTION__ << ": " << endl); iterate(rootp); } - virtual ~LinkDotResolveVisitor() override = default; + ~LinkDotResolveVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index a74bda289..8af3f4152 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -89,12 +89,12 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modIncrementsNum); m_modIncrementsNum = 0; iterateChildren(nodep); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { // Special, as statements need to be put in different places // Preconditions insert first just before themselves (the normal // rule for other statement types) @@ -111,7 +111,7 @@ private: // Done the loop m_insStmtp = nullptr; // Next thing should be new statement } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { // Special, as statements need to be put in different places // Body insert just before themselves m_insStmtp = nullptr; // First thing should be new statement @@ -119,7 +119,7 @@ private: // Done the loop m_insStmtp = nullptr; // Next thing should be new statement } - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { // Special, as statements need to be put in different places // Body insert just before themselves m_insStmtp = nullptr; // First thing should be new statement @@ -127,7 +127,7 @@ private: // Done the loop m_insStmtp = nullptr; // Next thing should be new statement } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { m_insStmtp = nodep; iterateAndNextNull(nodep->condp()); m_insStmtp = nullptr; @@ -135,7 +135,7 @@ private: iterateAndNextNull(nodep->elsesp()); m_insStmtp = nullptr; } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { m_insMode = IM_BEFORE; { VL_RESTORER(m_unsupportedHere); @@ -145,30 +145,30 @@ private: m_insStmtp = nullptr; // Next thing should be new statement iterateAndNextNull(nodep->bodysp()); } - virtual void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc( "For statements should have been converted to while statements in V3Begin.cpp"); } - virtual void visit(AstDelay* nodep) override { + void visit(AstDelay* nodep) override { m_insStmtp = nodep; iterateAndNextNull(nodep->lhsp()); m_insStmtp = nullptr; iterateAndNextNull(nodep->stmtsp()); m_insStmtp = nullptr; } - virtual void visit(AstEventControl* nodep) override { + void visit(AstEventControl* nodep) override { m_insStmtp = nullptr; iterateAndNextNull(nodep->stmtsp()); m_insStmtp = nullptr; } - virtual void visit(AstWait* nodep) override { + void visit(AstWait* nodep) override { m_insStmtp = nodep; iterateAndNextNull(nodep->condp()); m_insStmtp = nullptr; iterateAndNextNull(nodep->bodysp()); m_insStmtp = nullptr; } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); return; @@ -184,11 +184,11 @@ private: UINFO(9, "Marking unsupported " << nodep << endl); iterateChildren(nodep); } - virtual void visit(AstLogAnd* nodep) override { unsupported_visit(nodep); } - virtual void visit(AstLogOr* nodep) override { unsupported_visit(nodep); } - virtual void visit(AstLogEq* nodep) override { unsupported_visit(nodep); } - virtual void visit(AstLogIf* nodep) override { unsupported_visit(nodep); } - virtual void visit(AstNodeCond* nodep) override { unsupported_visit(nodep); } + void visit(AstLogAnd* nodep) override { unsupported_visit(nodep); } + void visit(AstLogOr* nodep) override { unsupported_visit(nodep); } + void visit(AstLogEq* nodep) override { unsupported_visit(nodep); } + void visit(AstLogIf* nodep) override { unsupported_visit(nodep); } + void visit(AstNodeCond* nodep) override { unsupported_visit(nodep); } void prepost_visit(AstNodeTriop* nodep) { // Check if we are underneath a statement if (!m_insStmtp) { @@ -276,17 +276,17 @@ private: nodep->replaceWith(new AstVarRef(varrefp->fileline(), varp, VAccess::WRITE)); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPreSub* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPostSub* nodep) override { prepost_visit(nodep); } - virtual void visit(AstGenFor* nodep) override { iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } + void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } + void visit(AstPreSub* nodep) override { prepost_visit(nodep); } + void visit(AstPostSub* nodep) override { prepost_visit(nodep); } + void visit(AstGenFor* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit LinkIncVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~LinkIncVisitor() override = default; + ~LinkIncVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index db3429fdb..405bcbaec 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -122,7 +122,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (nodep->dead()) return; VL_RESTORER(m_modp); VL_RESTORER(m_modRepeatNum); @@ -132,12 +132,12 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { m_ftaskp = nodep; iterateChildren(nodep); m_ftaskp = nullptr; } - virtual void visit(AstNodeBlock* nodep) override { + void visit(AstNodeBlock* nodep) override { UINFO(8, " " << nodep << endl); VL_RESTORER(m_inFork); m_blockStack.push_back(nodep); @@ -147,7 +147,7 @@ private: } m_blockStack.pop_back(); } - virtual void visit(AstRepeat* nodep) override { + void visit(AstRepeat* nodep) override { // So later optimizations don't need to deal with them, // REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- } // Note var can be signed or unsigned based on original number. @@ -175,7 +175,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { // Don't need to track AstRepeat/AstFor as they have already been converted VL_RESTORER(m_loopp); VL_RESTORER(m_loopInc); @@ -189,14 +189,14 @@ private: iterateAndNextNull(nodep->incsp()); } } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { VL_RESTORER(m_loopp); { m_loopp = nodep; iterateAndNextNull(nodep->bodysp()); } } - virtual void visit(AstReturn* nodep) override { + void visit(AstReturn* nodep) override { iterateChildren(nodep); const AstFunc* const funcp = VN_CAST(m_ftaskp, Func); if (m_inFork) { @@ -224,7 +224,7 @@ private: nodep->unlinkFrBack(); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstBreak* nodep) override { + void visit(AstBreak* nodep) override { iterateChildren(nodep); if (!m_loopp) { nodep->v3error("break isn't underneath a loop"); @@ -236,7 +236,7 @@ private: nodep->unlinkFrBack(); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstContinue* nodep) override { + void visit(AstContinue* nodep) override { iterateChildren(nodep); if (!m_loopp) { nodep->v3error("continue isn't underneath a loop"); @@ -249,7 +249,7 @@ private: nodep->unlinkFrBack(); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstDisable* nodep) override { + void visit(AstDisable* nodep) override { UINFO(8, " DISABLE " << nodep << endl); iterateChildren(nodep); AstNodeBlock* blockp = nullptr; @@ -274,16 +274,16 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); // if (debug() >= 9) { UINFO(0, "\n"); beginp->dumpTree(cout, " labelo: "); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (m_loopInc && nodep->varp()) nodep->varp()->usedLoopIdx(true); } - virtual void visit(AstConst*) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstConst*) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit LinkJumpVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~LinkJumpVisitor() override = default; + ~LinkJumpVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index 09c91ff1b..0baf289c8 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -46,7 +46,7 @@ private: // VISITs // Result handing - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { // VarRef: LValue its reference if (m_setRefLvalue != VAccess::NOCHANGE) nodep->access(m_setRefLvalue); if (nodep->varp()) { @@ -65,7 +65,7 @@ private: } // Nodes that start propagating down lvalues - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { if (nodep->modVarp() && nodep->modVarp()->isWritable()) { // When the varref's were created, we didn't know the I/O state // Now that we do, and it's from a output, we know it's a lvalue @@ -76,7 +76,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setContinuously); { @@ -92,7 +92,7 @@ private: iterateAndNextNull(nodep->rhsp()); } } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { VL_RESTORER(m_setRefLvalue); VL_RESTORER(m_setContinuously); { @@ -101,14 +101,14 @@ private: iterateAndNextNull(nodep->lhsp()); } } - virtual void visit(AstFireEvent* nodep) override { + void visit(AstFireEvent* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->operandp()); } } - virtual void visit(AstCastDynamic* nodep) override { + void visit(AstCastDynamic* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::NOCHANGE; @@ -117,7 +117,7 @@ private: iterateAndNextNull(nodep->top()); } } - virtual void visit(AstFOpen* nodep) override { + void visit(AstFOpen* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -127,7 +127,7 @@ private: iterateAndNextNull(nodep->modep()); } } - virtual void visit(AstFOpenMcd* nodep) override { + void visit(AstFOpenMcd* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -136,14 +136,14 @@ private: iterateAndNextNull(nodep->filenamep()); } } - virtual void visit(AstFClose* nodep) override { + void visit(AstFClose* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->filep()); } } - virtual void visit(AstFError* nodep) override { + void visit(AstFError* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -151,21 +151,21 @@ private: iterateAndNextNull(nodep->strp()); } } - virtual void visit(AstFFlush* nodep) override { + void visit(AstFFlush* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->filep()); } } - virtual void visit(AstFGetC* nodep) override { + void visit(AstFGetC* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->filep()); } } - virtual void visit(AstFGetS* nodep) override { + void visit(AstFGetS* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -173,7 +173,7 @@ private: iterateAndNextNull(nodep->strgp()); } } - virtual void visit(AstFRead* nodep) override { + void visit(AstFRead* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -181,7 +181,7 @@ private: iterateAndNextNull(nodep->filep()); } } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -189,33 +189,33 @@ private: iterateAndNextNull(nodep->exprsp()); } } - virtual void visit(AstFUngetC* nodep) override { + void visit(AstFUngetC* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->filep()); } } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->exprsp()); } } - virtual void visit(AstSysIgnore* nodep) override { + void visit(AstSysIgnore* nodep) override { // Can't know if lvalue or not; presume so as stricter VL_RESTORER(m_setRefLvalue); iterateChildren(nodep); } - virtual void visit(AstRand* nodep) override { + void visit(AstRand* nodep) override { VL_RESTORER(m_setRefLvalue); { if (!nodep->urandom()) m_setRefLvalue = VAccess::WRITE; iterateAndNextNull(nodep->seedp()); } } - virtual void visit(AstReadMem* nodep) override { + void visit(AstReadMem* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -226,14 +226,14 @@ private: iterateAndNextNull(nodep->msbp()); } } - virtual void visit(AstTestPlusArgs* nodep) override { + void visit(AstTestPlusArgs* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->searchp()); } } - virtual void visit(AstValuePlusArgs* nodep) override { + void visit(AstValuePlusArgs* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::NOCHANGE; @@ -242,7 +242,7 @@ private: iterateAndNextNull(nodep->outp()); } } - virtual void visit(AstSFormat* nodep) override { + void visit(AstSFormat* nodep) override { VL_RESTORER(m_setRefLvalue); { m_setRefLvalue = VAccess::WRITE; @@ -261,13 +261,13 @@ private: iterateAndNextNull(nodep->thsp()); } } - virtual void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPreSub* nodep) override { prepost_visit(nodep); } - virtual void visit(AstPostSub* nodep) override { prepost_visit(nodep); } + void visit(AstPreAdd* nodep) override { prepost_visit(nodep); } + void visit(AstPostAdd* nodep) override { prepost_visit(nodep); } + void visit(AstPreSub* nodep) override { prepost_visit(nodep); } + void visit(AstPostSub* nodep) override { prepost_visit(nodep); } // Nodes that change LValue state - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { VL_RESTORER(m_setRefLvalue); { iterateAndNextNull(nodep->lhsp()); @@ -277,7 +277,7 @@ private: iterateAndNextNull(nodep->thsp()); } } - virtual void visit(AstNodeSel* nodep) override { + void visit(AstNodeSel* nodep) override { VL_RESTORER(m_setRefLvalue); { // Only set lvalues on the from iterateAndNextNull(nodep->lhsp()); @@ -285,14 +285,14 @@ private: iterateAndNextNull(nodep->rhsp()); } } - virtual void visit(AstCellArrayRef* nodep) override { + void visit(AstCellArrayRef* nodep) override { VL_RESTORER(m_setRefLvalue); { // selp is not an lvalue m_setRefLvalue = VAccess::NOCHANGE; iterateAndNextNull(nodep->selp()); } } - virtual void visit(AstNodePreSel* nodep) override { + void visit(AstNodePreSel* nodep) override { VL_RESTORER(m_setRefLvalue); { // Only set lvalues on the from iterateAndNextNull(nodep->fromp()); @@ -301,12 +301,12 @@ private: iterateAndNextNull(nodep->thsp()); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { m_ftaskp = nodep; iterateChildren(nodep); m_ftaskp = nullptr; } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { AstNode* pinp = nodep->pinsp(); const AstNodeFTask* const taskp = nodep->taskp(); // We'll deal with mismatching pins later @@ -328,7 +328,7 @@ private: } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -336,7 +336,7 @@ public: : m_setRefLvalue{start} { iterate(nodep); } - virtual ~LinkLValueVisitor() override = default; + ~LinkLValueVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index b9ecca249..3e9130ed3 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -94,7 +94,7 @@ void V3LinkLevel::timescaling(const ModVec& mods) { } } unit = v3Global.opt.timeComputeUnit(unit); // Apply override - if (unit.isNone()) unit = VTimescale(VTimescale::TS_DEFAULT); + if (unit.isNone()) unit = VTimescale{VTimescale::TS_DEFAULT}; v3Global.rootp()->timeunit(unit); bool dunitTimed = false; // $unit had a timeunit @@ -127,7 +127,7 @@ void V3LinkLevel::timescaling(const ModVec& mods) { if (v3Global.rootp()->timeprecision().isNone()) { v3Global.rootp()->timeprecisionMerge(v3Global.rootp()->fileline(), - VTimescale(VTimescale::TS_DEFAULT)); + VTimescale{VTimescale::TS_DEFAULT}); } // Classes under package have timescale propaged in V3LinkParse diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 4558190df..5ae3738ce 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -73,7 +73,7 @@ private: // We could have verilog.l create a new one on every token, // but that's a lot more structures than only doing AST nodes. if (m_filelines.find(nodep->fileline()) != m_filelines.end()) { - nodep->fileline(new FileLine(nodep->fileline())); + nodep->fileline(new FileLine{nodep->fileline()}); } m_filelines.insert(nodep->fileline()); } @@ -122,7 +122,7 @@ private: } // VISITs - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { if (!nodep->user1SetOnce()) { // Process only once. V3Config::applyFTask(m_modp, nodep); cleanFileline(nodep); @@ -139,7 +139,7 @@ private: } } } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { if (!nodep->user1SetOnce()) { // Process only once. cleanFileline(nodep); UINFO(5, " " << nodep << endl); @@ -150,20 +150,20 @@ private: } } } - virtual void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); } - virtual void visit(AstEnumDType* nodep) override { + void visit(AstNodeDType* nodep) override { visitIterateNodeDType(nodep); } + void visit(AstEnumDType* nodep) override { if (nodep->name() == "") { nodep->name(nameFromTypedef(nodep)); // Might still remain "" } visitIterateNodeDType(nodep); } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { if (nodep->name() == "") { nodep->name(nameFromTypedef(nodep)); // Might still remain "" } visitIterateNodeDType(nodep); } - virtual void visit(AstEnumItem* nodep) override { + void visit(AstEnumItem* nodep) override { // Expand ranges cleanFileline(nodep); iterateChildren(nodep); @@ -198,7 +198,7 @@ private: } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { cleanFileline(nodep); if (nodep->lifetime().isNone()) { if (m_ftaskp) { @@ -296,7 +296,7 @@ private: } } - virtual void visit(AstAttrOf* nodep) override { + void visit(AstAttrOf* nodep) override { cleanFileline(nodep); iterateChildren(nodep); if (nodep->attrType() == VAttrType::DT_PUBLIC) { @@ -365,7 +365,7 @@ private: } } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { // AlwaysPublic was attached under a var, but it's a statement that should be // at the same level as the var cleanFileline(nodep); @@ -381,7 +381,7 @@ private: } } - virtual void visit(AstDefImplicitDType* nodep) override { + void visit(AstDefImplicitDType* nodep) override { cleanFileline(nodep); UINFO(8, " DEFIMPLICIT " << nodep << endl); // Must remember what names we've already created, and combine duplicates @@ -422,7 +422,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { // FOREACH(array, loopvars, body) UINFO(9, "FOREACH " << nodep << endl); // Separate iteration vars from base from variable @@ -457,7 +457,7 @@ private: iterateChildren(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { V3Config::applyModule(nodep); VL_RESTORER(m_modp); @@ -490,16 +490,16 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); } - virtual void visit(AstAlways* nodep) override { + void visit(AstNodeProcedure* nodep) override { visitIterateNoValueMod(nodep); } + void visit(AstAlways* nodep) override { VL_RESTORER(m_inAlways); m_inAlways = true; visitIterateNoValueMod(nodep); } - virtual void visit(AstCover* nodep) override { visitIterateNoValueMod(nodep); } - virtual void visit(AstRestrict* nodep) override { visitIterateNoValueMod(nodep); } + void visit(AstCover* nodep) override { visitIterateNoValueMod(nodep); } + void visit(AstRestrict* nodep) override { visitIterateNoValueMod(nodep); } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { V3Config::applyCoverageBlock(m_modp, nodep); cleanFileline(nodep); const AstNode* const backp = nodep->backp(); @@ -525,7 +525,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstGenCase* nodep) override { + void visit(AstGenCase* nodep) override { ++m_genblkNum; cleanFileline(nodep); { @@ -536,7 +536,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstGenIf* nodep) override { + void visit(AstGenIf* nodep) override { cleanFileline(nodep); const bool nestedIf = (VN_IS(nodep->backp(), Begin) && nestedIfBegin(VN_CAST(nodep->backp(), Begin))); @@ -551,39 +551,39 @@ private: iterateChildren(nodep); } } - virtual void visit(AstCase* nodep) override { + void visit(AstCase* nodep) override { V3Config::applyCase(nodep); cleanFileline(nodep); iterateChildren(nodep); } - virtual void visit(AstPrintTimeScale* nodep) override { + void visit(AstPrintTimeScale* nodep) override { // Inlining may change hierarchy, so just save timescale where needed cleanFileline(nodep); iterateChildren(nodep); nodep->name(m_modp->name()); nodep->timeunit(m_modp->timeunit()); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { cleanFileline(nodep); iterateChildren(nodep); nodep->timeunit(m_modp->timeunit()); } - virtual void visit(AstTime* nodep) override { + void visit(AstTime* nodep) override { cleanFileline(nodep); iterateChildren(nodep); nodep->timeunit(m_modp->timeunit()); } - virtual void visit(AstTimeD* nodep) override { + void visit(AstTimeD* nodep) override { cleanFileline(nodep); iterateChildren(nodep); nodep->timeunit(m_modp->timeunit()); } - virtual void visit(AstTimeImport* nodep) override { + void visit(AstTimeImport* nodep) override { cleanFileline(nodep); iterateChildren(nodep); nodep->timeunit(m_modp->timeunit()); } - virtual void visit(AstEventControl* nodep) override { + void visit(AstEventControl* nodep) override { cleanFileline(nodep); iterateChildren(nodep); AstAlways* const alwaysp = VN_CAST(nodep->backp(), Always); @@ -603,7 +603,7 @@ private: } } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // Default: Just iterate cleanFileline(nodep); iterateChildren(nodep); @@ -612,7 +612,7 @@ private: public: // CONSTRUCTORS explicit LinkParseVisitor(AstNetlist* rootp) { iterate(rootp); } - virtual ~LinkParseVisitor() override = default; + ~LinkParseVisitor() override = default; }; //###################################################################### diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 073ffda44..ed418f025 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -62,7 +62,7 @@ private: // TODO: Most of these visitors are here for historical reasons. // TODO: ExpectDecriptor can move to data type resolution, and the rest // TODO: could move to V3LinkParse to get them out of the way of elaboration - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Module: Create sim table for entire module and iterate UINFO(8, "MODULE " << nodep << endl); if (nodep->dead()) return; @@ -74,14 +74,14 @@ private: iterateChildren(nodep); } } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { VL_RESTORER(m_classp); { m_classp = nodep; iterateChildren(nodep); } } - virtual void visit(AstInitialAutomatic* nodep) override { + void visit(AstInitialAutomatic* nodep) override { iterateChildren(nodep); // Initial assignments under function/tasks can just be simple // assignments without the initial @@ -89,13 +89,13 @@ private: VL_DO_DANGLING(nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()), nodep); } } - virtual void visit(AstNodeCoverOrAssert* nodep) override { + void visit(AstNodeCoverOrAssert* nodep) override { if (m_assertp) nodep->v3error("Assert not allowed under another assert"); m_assertp = nodep; iterateChildren(nodep); m_assertp = nullptr; } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); if (m_classp && !nodep->isParam()) nodep->varType(VVarType::MEMBER); if (m_ftaskp) nodep->funcLocal(true); @@ -105,13 +105,13 @@ private: } } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { // VarRef: Resolve its reference if (nodep->varp()) nodep->varp()->usedParam(true); iterateChildren(nodep); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // NodeTask: Remember its name for later resolution if (m_underGenerate) nodep->underGenerate(true); // Remember the existing symbol table scope @@ -139,13 +139,13 @@ private: m_ftaskp = nullptr; if (nodep->dpiExport()) nodep->scopeNamep(new AstScopeName{nodep->fileline(), false}); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { iterateChildren(nodep); if (nodep->taskp() && (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) { nodep->scopeNamep(new AstScopeName{nodep->fileline(), false}); } } - virtual void visit(AstNodePreSel* nodep) override { + void visit(AstNodePreSel* nodep) override { if (!nodep->attrp()) { iterateChildren(nodep); // Constification may change the fromp() to a constant, which will lose the @@ -180,7 +180,7 @@ private: } } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { // Move default caseItems to the bottom of the list // That saves us from having to search each case list twice, for non-defaults and defaults iterateChildren(nodep); @@ -192,7 +192,7 @@ private: } } - virtual void visit(AstPragma* nodep) override { + void visit(AstPragma* nodep) override { if (nodep->pragType() == VPragmaType::HIER_BLOCK) { UASSERT_OBJ(m_modp, nodep, "HIER_BLOCK not under a module"); // If this is hierarchical mode which is to lib-create, @@ -342,39 +342,39 @@ private: if (filep && filep->varp()) filep->varp()->attrFileDescr(true); } - virtual void visit(AstFOpen* nodep) override { + void visit(AstFOpen* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFOpenMcd* nodep) override { + void visit(AstFOpenMcd* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFClose* nodep) override { + void visit(AstFClose* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFError* nodep) override { + void visit(AstFError* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFEof* nodep) override { + void visit(AstFEof* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFRead* nodep) override { + void visit(AstFRead* nodep) override { iterateChildren(nodep); expectDescriptor(nodep, VN_CAST(nodep->filep(), NodeVarRef)); } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { iterateChildren(nodep); expectFormat(nodep, nodep->text(), nodep->exprsp(), true); } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { iterateChildren(nodep); expectFormat(nodep, nodep->text(), nodep->exprsp(), true); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { iterateChildren(nodep); // Cleanup old-school displays without format arguments if (!nodep->hasFormat()) { @@ -397,7 +397,7 @@ private: } } - virtual void visit(AstUdpTable* nodep) override { + void visit(AstUdpTable* nodep) override { UINFO(5, "UDPTABLE " << nodep << endl); if (!v3Global.opt.bboxUnsup()) { // We don't warn until V3Inst, so that UDPs that are in libraries and @@ -428,49 +428,49 @@ private: } } - virtual void visit(AstScCtor* nodep) override { + void visit(AstScCtor* nodep) override { // Constructor info means the module must remain public m_modp->modPublic(true); iterateChildren(nodep); } - virtual void visit(AstScDtor* nodep) override { + void visit(AstScDtor* nodep) override { // Destructor info means the module must remain public m_modp->modPublic(true); iterateChildren(nodep); } - virtual void visit(AstScInt* nodep) override { + void visit(AstScInt* nodep) override { // Special class info means the module must remain public m_modp->modPublic(true); iterateChildren(nodep); } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { // LinkDot checked modports, now remove references to them // Keeping them later caused problems with InstDeArray, // as it needed to make new modport arrays and such nodep->modportp(nullptr); iterateChildren(nodep); } - // virtual void visit(AstModport* nodep) override { ... } + // void visit(AstModport* nodep) override { ... } // We keep Modport's themselves around for XML dump purposes - virtual void visit(AstGenFor* nodep) override { + void visit(AstGenFor* nodep) override { VL_RESTORER(m_underGenerate); m_underGenerate = true; iterateChildren(nodep); } - virtual void visit(AstGenIf* nodep) override { + void visit(AstGenIf* nodep) override { VL_RESTORER(m_underGenerate); m_underGenerate = true; iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit LinkResolveVisitor(AstNetlist* rootp) { iterate(rootp); } - virtual ~LinkResolveVisitor() override = default; + ~LinkResolveVisitor() override = default; }; //###################################################################### @@ -487,29 +487,29 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITs - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Iterate modules backwards, in bottom-up order. iterateChildrenBackwards(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; iterateChildren(nodep); } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { // Parent module inherits child's publicity if (nodep->modp()->modPublic()) m_modp->modPublic(true); //** No iteration for speed } - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit LinkBotupVisitor(AstNetlist* rootp) { iterate(rootp); } - virtual ~LinkBotupVisitor() override = default; + ~LinkBotupVisitor() override = default; }; //###################################################################### diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index 27d652110..9a9bf51db 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -123,12 +123,12 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { iterateChildrenConst(nodep); moveVarScopes(); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { UINFO(4, " CFUNC " << nodep << endl); VL_RESTORER(m_cfuncp); VL_RESTORER(m_nodeDepth); @@ -140,12 +140,12 @@ private: } } - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { m_cfuncp->user1(true); // Mark caller as not a leaf function iterateChildrenConst(nodep); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // Analyze RHS first so "a = a + 1" is detected as a read before write iterate(nodep->rhsp()); // For now we only consider an assignment that is directly under the function, (in @@ -163,7 +163,7 @@ private: iterate(nodep->lhsp()); } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { if (!nodep->varp()->isPrimaryIO() // Not an IO the user wants to interact with && !nodep->varp()->isSigPublic() // Not something the user wants to interact with && !nodep->varp()->isFuncLocal() // Not already a function local (e.g.: argument) @@ -177,7 +177,7 @@ private: // No iterate; Don't want varrefs under it (e.g.: in child dtype?) } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { UASSERT_OBJ(m_cfuncp, nodep, "AstVarRef not under function"); AstVarScope* const varScopep = nodep->varScopep(); @@ -201,7 +201,7 @@ private: // No iterate; Don't want varrefs under it (e.g.: in child dtype?) } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { ++m_nodeDepth; iterateChildrenConst(nodep); --m_nodeDepth; @@ -210,7 +210,7 @@ private: public: // CONSTRUCTORS explicit LocalizeVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~LocalizeVisitor() override { + ~LocalizeVisitor() override { V3Stats::addStat("Optimizations, Vars localized", m_statLocVars); } }; diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index bb3389861..3dd8fe02e 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -823,7 +823,7 @@ private: } // VISITORS - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (AstNode* const condp = (*m_stmtPropertiesp)(nodep).m_condp) { // Check if mergeable if (!checkOrMakeMergeable(nodep)) return; @@ -836,7 +836,7 @@ private: } } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { // Check if mergeable if (!checkOrMakeMergeable(nodep)) { // If not mergeable, try to merge the branches @@ -850,25 +850,25 @@ private: addToList(nodep, nodep->condp()); } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (m_mgFirstp && addIfHelpfulElseEndMerge(nodep)) return; iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // Merge function body if (nodep->stmtsp()) process(nodep->stmtsp()); } // For speed, only iterate what is necessary. - virtual void visit(AstNetlist* nodep) override { iterateAndNextNull(nodep->modulesp()); } - virtual void visit(AstNodeModule* nodep) override { iterateAndNextNull(nodep->stmtsp()); } - virtual void visit(AstNode* nodep) override {} + void visit(AstNetlist* nodep) override { iterateAndNextNull(nodep->modulesp()); } + void visit(AstNodeModule* nodep) override { iterateAndNextNull(nodep->stmtsp()); } + void visit(AstNode* nodep) override {} public: // CONSTRUCTORS explicit MergeCondVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~MergeCondVisitor() override { + ~MergeCondVisitor() override { V3Stats::addStat("Optimizations, MergeCond merges", m_statMerges); V3Stats::addStat("Optimizations, MergeCond merged items", m_statMergedItems); V3Stats::addStat("Optimizations, MergeCond longest merge", m_statLongestList); diff --git a/src/V3Name.cpp b/src/V3Name.cpp index 9c3b422c8..ca8fde8f1 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -68,7 +68,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; @@ -76,44 +76,44 @@ private: } } // Add __PVT__ to names of local signals - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { // Don't iterate... Don't need temps for RANGES under the Var. rename(nodep, ((!m_modp || !m_modp->isTop()) && !nodep->isSigPublic() && !nodep->isFuncLocal() // Isn't exposed, and would mess up dpi import wrappers && !nodep->isTemp())); // Don't bother to rename internal signals } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (!nodep->user1()) { iterateChildren(nodep); rename(nodep, false); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->varp()) { iterate(nodep->varp()); nodep->name(nodep->varp()->name()); } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { if (!nodep->user1()) { rename(nodep, (!nodep->modp()->modPublic() && !VN_IS(nodep->modp(), ClassPackage))); iterateChildren(nodep); } } - virtual void visit(AstMemberDType* nodep) override { + void visit(AstMemberDType* nodep) override { if (!nodep->user1()) { rename(nodep, false); iterateChildren(nodep); } } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { if (!nodep->user1()) { rename(nodep, false); iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { if (!nodep->user1SetOnce()) { if (nodep->aboveScopep()) iterate(nodep->aboveScopep()); if (nodep->aboveCellp()) iterate(nodep->aboveCellp()); @@ -130,12 +130,12 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit NameVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~NameVisitor() override = default; + ~NameVisitor() override = default; }; //###################################################################### diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp index 8035916e7..1a1f7d84a 100644 --- a/src/V3OptionParser.cpp +++ b/src/V3OptionParser.cpp @@ -39,12 +39,12 @@ struct V3OptionParser::Impl { class ActionBase VL_NOT_FINAL : public ActionIfs { bool m_undocumented = false; // This option is not documented public: - virtual bool isValueNeeded() const override final { return MODE == en::VALUE; } - virtual bool isFOnOffAllowed() const override final { return MODE == en::FONOFF; } - virtual bool isOnOffAllowed() const override final { return MODE == en::ONOFF; } - virtual bool isPartialMatchAllowed() const override final { return ALLOW_PARTIAL_MATCH; } - virtual bool isUndocumented() const override { return m_undocumented; } - virtual void undocumented() override { m_undocumented = true; } + bool isValueNeeded() const override final { return MODE == en::VALUE; } + bool isFOnOffAllowed() const override final { return MODE == en::FONOFF; } + bool isOnOffAllowed() const override final { return MODE == en::ONOFF; } + bool isPartialMatchAllowed() const override final { return ALLOW_PARTIAL_MATCH; } + bool isUndocumented() const override { return m_undocumented; } + void undocumented() override { m_undocumented = true; } }; // Actual action classes @@ -78,7 +78,7 @@ struct V3OptionParser::Impl { public: \ explicit className(type* valp) \ : m_valp(valp) {} \ - virtual void exec(const char* optp, const char* argp) override { body; } \ + void exec(const char* optp, const char* argp) override { body; } \ } V3OPTION_PARSER_DEF_ACT_CLASS(ActionSet, bool, *m_valp = true, en::NONE); @@ -104,7 +104,7 @@ V3OPTION_PARSER_DEF_ACT_CLASS(ActionOnOff, VOptionBool, m_valp->setTrueOrFalse(! using CbType = std::function; \ explicit className(CbType cb) \ : m_cb(std::move(cb)) {} \ - virtual void exec(const char* optp, const char* argp) override { body; } \ + void exec(const char* optp, const char* argp) override { body; } \ } V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbCall, void(void), m_cb(), en::NONE); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 5e0a4a57f..c21656510 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "config_rev.h" @@ -112,7 +113,7 @@ public: V3LangCode::V3LangCode(const char* textp) { // Return code for given string, or ERROR, which is a bad code for (int codei = V3LangCode::L_ERROR; codei < V3LangCode::_ENUM_END; ++codei) { - const V3LangCode code = V3LangCode(codei); + const V3LangCode code{codei}; if (0 == VL_STRCASECMP(textp, code.ascii())) { m_e = code; return; @@ -264,7 +265,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr if (!precStr.empty()) { VTimescale prec(VTimescale::NONE); bool precbad; - prec = VTimescale(precStr, precbad /*ref*/); + prec = VTimescale{precStr, precbad /*ref*/}; if (precbad) { fl->v3error("`timescale timeprecision syntax error: '" << precStr << "'"); return; @@ -1014,6 +1015,17 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char }); DECL_OPTION("-bin", Set, &m_bin); DECL_OPTION("-build", Set, &m_build); + DECL_OPTION("-build-jobs", CbVal, [this, fl](const char* valp) { + int val = std::atoi(valp); + if (val < 0) { + fl->v3fatal("--build-jobs requires a non-negative integer, but '" << valp + << "' was passed"); + val = 1; + } else if (val == 0) { + val = std::thread::hardware_concurrency(); + } + m_buildJobs = val; + }); DECL_OPTION("-CFLAGS", CbVal, callStrSetter(&V3Options::addCFlags)); DECL_OPTION("-cc", CbCall, [this]() { ccSet(); }); @@ -1160,7 +1172,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-LDFLAGS", CbVal, callStrSetter(&V3Options::addLdLibs)); const auto setLang = [this, fl](const char* valp) { - const V3LangCode optval = V3LangCode(valp); + const V3LangCode optval{valp}; if (optval.legal()) { m_defaultLanguage = optval; } else { @@ -1525,14 +1537,19 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char if (!std::strcmp(argv[i], "-j") || !std::strcmp(argv[i], "--j")) { // Allow gnu -- switches ++i; - m_buildJobs = 0; // Unlimited parallelism + int val = 0; if (i < argc && isdigit(argv[i][0])) { - m_buildJobs = std::atoi(argv[i]); - if (m_buildJobs <= 0) { - fl->v3error("-j accepts positive integer, but '" << argv[i] << "' is passed"); + val = atoi(argv[i]); + if (val < 0) { + fl->v3error("-j requires a non-negative integer argument, but '" + << argv[i] << "' was passed"); + val = 1; // Fall-back value, though we will exit on error. + } else if (val == 0) { + val = std::thread::hardware_concurrency(); } ++i; } + if (m_buildJobs == -1) m_buildJobs = val; } else if (argv[i][0] == '-' || argv[i][0] == '+') { const char* argvNoDashp = (argv[i][1] == '-') ? (argv[i] + 2) : (argv[i] + 1); if (const int consumed = parser.parse(i, argc, argv)) { @@ -1564,6 +1581,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char ++i; } } + if (m_buildJobs == -1) m_buildJobs = 1; } //====================================================================== diff --git a/src/V3Options.h b/src/V3Options.h index ad966e5b5..ada58dfc8 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -39,12 +39,12 @@ class VOptionBool final { public: enum en : uint8_t { OPT_DEFAULT_FALSE = 0, OPT_DEFAULT_TRUE, OPT_TRUE, OPT_FALSE }; enum en m_e; - inline VOptionBool() + VOptionBool() : m_e{OPT_DEFAULT_FALSE} {} // cppcheck-suppress noExplicitConstructor - inline VOptionBool(en _e) + VOptionBool(en _e) : m_e{_e} {} - explicit inline VOptionBool(int _e) + explicit VOptionBool(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; } @@ -78,12 +78,12 @@ public: enum : uint8_t { TS_DEFAULT = TS_1PS }; enum en m_e; // CONSTRUCTOR - inline VTimescale() + VTimescale() : m_e{NONE} {} // cppcheck-suppress noExplicitConstructor - inline VTimescale(en _e) + VTimescale(en _e) : m_e{_e} {} - explicit inline VTimescale(int _e) + explicit VTimescale(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning // Construct from string VTimescale(const string& value, bool& badr); @@ -131,9 +131,9 @@ class TraceFormat final { public: enum en : uint8_t { VCD = 0, FST } m_e; // cppcheck-suppress noExplicitConstructor - inline TraceFormat(en _e = VCD) + TraceFormat(en _e = VCD) : m_e{_e} {} - explicit inline TraceFormat(int _e) + explicit TraceFormat(int _e) : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } bool fst() const { return m_e == FST; } @@ -283,7 +283,7 @@ private: bool m_xInitialEdge = false; // main switch: --x-initial-edge bool m_xmlOnly = false; // main switch: --xml-only - int m_buildJobs = 1; // main switch: -j + int m_buildJobs = -1; // main switch: --build-jobs, -j int m_convergeLimit = 100; // main switch: --converge-limit int m_coverageMaxWidth = 256; // main switch: --coverage-max-width int m_dumpTree = 0; // main switch: --dump-tree diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 209b38205..f8aeb96d6 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -202,7 +202,7 @@ class OrderBuildVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { UASSERT_OBJ(!nodep->sensesStorep(), nodep, "AstSenTrees should have been made global in V3ActiveTop"); UASSERT_OBJ(m_scopep, nodep, "AstActive not under AstScope"); @@ -247,7 +247,7 @@ class OrderBuildVisitor final : public VNVisitor { m_domainp = nullptr; m_hybridp = nullptr; } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { // As we explicitly not visit (see ignored nodes below) any subtree that is not relevant // for ordering, we should be able to assert this: UASSERT_OBJ(m_scopep, nodep, "AstVarRef not under scope"); @@ -376,49 +376,49 @@ class OrderBuildVisitor final : public VNVisitor { } } } - virtual void visit(AstCCall* nodep) override { iterateChildren(nodep); } + void visit(AstCCall* nodep) override { iterateChildren(nodep); } //--- Logic akin to SystemVerilog Processes (AstNodeProcedure) - virtual void visit(AstInitial* nodep) override { // LCOV_EXCL_START + void visit(AstInitial* nodep) override { // LCOV_EXCL_START nodep->v3fatalSrc("AstInitial should not need ordering"); } // LCOV_EXCL_STOP - virtual void visit(AstInitialStatic* nodep) override { // LCOV_EXCL_START + void visit(AstInitialStatic* nodep) override { // LCOV_EXCL_START nodep->v3fatalSrc("AstInitialStatic should not need ordering"); } // LCOV_EXCL_STOP - virtual void visit(AstInitialAutomatic* nodep) override { // + void visit(AstInitialAutomatic* nodep) override { // iterateLogic(nodep); } - virtual void visit(AstAlways* nodep) override { // + void visit(AstAlways* nodep) override { // iterateLogic(nodep); } - virtual void visit(AstAlwaysPost* nodep) override { + void visit(AstAlwaysPost* nodep) override { UASSERT_OBJ(!m_inPost, nodep, "Should not nest"); m_inPost = true; iterateLogic(nodep); m_inPost = false; } - virtual void visit(AstAlwaysPostponed* nodep) override { + void visit(AstAlwaysPostponed* nodep) override { UASSERT_OBJ(!m_inPostponed, nodep, "Should not nest"); m_inPostponed = true; iterateLogic(nodep); m_inPostponed = false; } - virtual void visit(AstFinal* nodep) override { // LCOV_EXCL_START + void visit(AstFinal* nodep) override { // LCOV_EXCL_START nodep->v3fatalSrc("AstFinal should not need ordering"); } // LCOV_EXCL_STOP //--- Logic akin go SystemVerilog continuous assignments - virtual void visit(AstAssignAlias* nodep) override { // + void visit(AstAssignAlias* nodep) override { // iterateLogic(nodep); } - virtual void visit(AstAssignW* nodep) override { iterateLogic(nodep); } - virtual void visit(AstAssignPre* nodep) override { + void visit(AstAssignW* nodep) override { iterateLogic(nodep); } + void visit(AstAssignPre* nodep) override { UASSERT_OBJ(!m_inPre, nodep, "Should not nest"); m_inPre = true; iterateLogic(nodep); m_inPre = false; } - virtual void visit(AstAssignPost* nodep) override { + void visit(AstAssignPost* nodep) override { UASSERT_OBJ(!m_inPost, nodep, "Should not nest"); m_inPost = true; iterateLogic(nodep); @@ -426,21 +426,21 @@ class OrderBuildVisitor final : public VNVisitor { } //--- Verilator concoctions - virtual void visit(AstAlwaysPublic* nodep) override { // + void visit(AstAlwaysPublic* nodep) override { // iterateLogic(nodep); } - virtual void visit(AstCoverToggle* nodep) override { // + void visit(AstCoverToggle* nodep) override { // iterateLogic(nodep); } //--- Ignored nodes - virtual void visit(AstVar*) override {} - virtual void visit(AstVarScope* nodep) override {} - virtual void visit(AstCell*) override {} // Only interested in the respective AstScope - virtual void visit(AstTypeTable*) override {} - virtual void visit(AstConstPool*) override {} - virtual void visit(AstClass*) override {} - virtual void visit(AstCFunc*) override { + void visit(AstVar*) override {} + void visit(AstVarScope* nodep) override {} + void visit(AstCell*) override {} // Only interested in the respective AstScope + void visit(AstTypeTable*) override {} + void visit(AstConstPool*) override {} + void visit(AstClass*) override {} + void visit(AstCFunc*) override { // Calls to DPI exports handled with AstCCall. /* verilator public */ functions are // ignored for now (and hence potentially mis-ordered), but could use the same or // similar mechanism as DPI exports. Every other impure function (including those @@ -448,7 +448,7 @@ class OrderBuildVisitor final : public VNVisitor { } //--- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } // CONSTRUCTOR OrderBuildVisitor(AstNetlist* /*nodep*/, const std::vector& coll, @@ -532,7 +532,7 @@ public: OrderMoveDomScope::DomScopeMap OrderMoveDomScope::s_dsMap; -inline std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { +std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { lhs << rhs.name(); return lhs; } @@ -756,8 +756,8 @@ public: : m_pomGraphp{pomGraphp} , m_pomWaitingp{pomWaitingp} {} // METHODS - virtual OrderMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, const OrderEitherVertex*, - const AstSenTree* domainp) override { + OrderMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, const OrderEitherVertex*, + const AstSenTree* domainp) override { OrderMoveVertex* const resultp = new OrderMoveVertex(m_pomGraphp, lvertexp); AstScope* const scopep = lvertexp ? lvertexp->scopep() : nullptr; resultp->domScopep(OrderMoveDomScope::findCreate(domainp, scopep)); @@ -776,9 +776,8 @@ class OrderMTaskMoveVertexMaker final public: explicit OrderMTaskMoveVertexMaker(V3Graph* pomGraphp) : m_pomGraphp{pomGraphp} {} - virtual MTaskMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, - const OrderEitherVertex* varVertexp, - const AstSenTree* domainp) override { + MTaskMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, const OrderEitherVertex* varVertexp, + const AstSenTree* domainp) override { return new MTaskMoveVertex(m_pomGraphp, lvertexp, varVertexp, domainp); } @@ -938,7 +937,7 @@ public: // OrderMoveDomScope methods // Check the domScope is on ready list, add if not -inline void OrderMoveDomScope::ready(OrderProcess* opp) { +void OrderMoveDomScope::ready(OrderProcess* opp) { if (!m_onReadyList) { m_onReadyList = true; m_readyDomScopeE.pushBack(opp->m_pomReadyDomScope, this); @@ -946,7 +945,7 @@ inline void OrderMoveDomScope::ready(OrderProcess* opp) { } // Mark one vertex as finished, remove from ready list if done -inline void OrderMoveDomScope::movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp) { +void OrderMoveDomScope::movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp) { UASSERT_OBJ(m_onReadyList, vertexp, "Moving vertex from ready when nothing was on que as ready."); if (m_readyVertices.empty()) { // Else more work to get to later diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 625cbbe3a..a8093944d 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -116,7 +116,7 @@ protected: OrderEitherVertex(OrderGraph* graphp, AstSenTree* domainp) : V3GraphVertex{graphp} , m_domainp{domainp} {} - virtual ~OrderEitherVertex() override = default; + ~OrderEitherVertex() override = default; public: // METHODS @@ -148,10 +148,10 @@ public: UASSERT_OBJ(scopep, nodep, "Must not be null"); UASSERT_OBJ(!(domainp && hybridp), nodep, "Cannot have bot domainp and hybridp set"); } - virtual ~OrderLogicVertex() override = default; + ~OrderLogicVertex() override = default; // METHODS - virtual bool domainMatters() override { return true; } + bool domainMatters() override { return true; } // ACCESSORS AstNode* nodep() const { return m_nodep; } @@ -159,12 +159,10 @@ public: AstSenTree* hybridp() const { return m_hybridp; } // LCOV_EXCL_START // Debug code - virtual string name() const override { + string name() const override { return (cvtToHex(m_nodep) + "\\n " + cvtToStr(nodep()->typeName())); } - virtual string dotShape() const override { - return VN_IS(m_nodep, Active) ? "doubleoctagon" : "rect"; - } + string dotShape() const override { return VN_IS(m_nodep, Active) ? "doubleoctagon" : "rect"; } // LCOV_EXCL_STOP }; @@ -176,7 +174,7 @@ public: OrderVarVertex(OrderGraph* graphp, AstVarScope* vscp) : OrderEitherVertex{graphp, nullptr} , m_vscp{vscp} {} - virtual ~OrderVarVertex() override = default; + ~OrderVarVertex() override = default; // ACCESSORS AstVarScope* vscp() const { return m_vscp; } @@ -195,14 +193,14 @@ public: // CONSTRUCTOR OrderVarStdVertex(OrderGraph* graphp, AstVarScope* vscp) : OrderVarVertex{graphp, vscp} {} - virtual ~OrderVarStdVertex() override = default; + ~OrderVarStdVertex() override = default; // METHODS - virtual bool domainMatters() override { return true; } + bool domainMatters() override { return true; } // LCOV_EXCL_START // Debug code - virtual string nameSuffix() const override { return ""; } - virtual string dotColor() const override { return "grey"; } + string nameSuffix() const override { return ""; } + string dotColor() const override { return "grey"; } // LCOV_EXCL_STOP }; @@ -211,14 +209,14 @@ public: // CONSTRUCTOR OrderVarPreVertex(OrderGraph* graphp, AstVarScope* vscp) : OrderVarVertex{graphp, vscp} {} - virtual ~OrderVarPreVertex() override = default; + ~OrderVarPreVertex() override = default; // METHODS - virtual bool domainMatters() override { return false; } + bool domainMatters() override { return false; } // LCOV_EXCL_START // Debug code - virtual string nameSuffix() const override { return "PRE"; } - virtual string dotColor() const override { return "green"; } + string nameSuffix() const override { return "PRE"; } + string dotColor() const override { return "green"; } // LCOV_EXCL_STOP }; @@ -227,14 +225,14 @@ public: // CONSTRUCTOR OrderVarPostVertex(OrderGraph* graphp, AstVarScope* vscp) : OrderVarVertex{graphp, vscp} {} - virtual ~OrderVarPostVertex() override = default; + ~OrderVarPostVertex() override = default; // METHODS - virtual bool domainMatters() override { return false; } + bool domainMatters() override { return false; } // LCOV_EXCL_START // Debug code - virtual string nameSuffix() const override { return "POST"; } - virtual string dotColor() const override { return "red"; } + string nameSuffix() const override { return "POST"; } + string dotColor() const override { return "red"; } // LCOV_EXCL_STOP }; @@ -243,14 +241,14 @@ public: // CONSTRUCTOR OrderVarPordVertex(OrderGraph* graphp, AstVarScope* vscp) : OrderVarVertex{graphp, vscp} {} - virtual ~OrderVarPordVertex() override = default; + ~OrderVarPordVertex() override = default; // METHODS - virtual bool domainMatters() override { return false; } + bool domainMatters() override { return false; } // LCOV_EXCL_START // Debug code - virtual string nameSuffix() const override { return "PORD"; } - virtual string dotColor() const override { return "blue"; } + string nameSuffix() const override { return "PORD"; } + string dotColor() const override { return "blue"; } // LCOV_EXCL_STOP }; @@ -263,10 +261,10 @@ class OrderEdge final : public V3GraphEdge { OrderEdge(OrderGraph* graphp, OrderEitherVertex* fromp, OrderEitherVertex* top, int weight, bool cutable) : V3GraphEdge{graphp, fromp, top, weight, cutable} {} - virtual ~OrderEdge() override = default; + ~OrderEdge() override = default; // LCOV_EXCL_START // Debug code - virtual string dotColor() const override { return cutable() ? "green" : "red"; } + string dotColor() const override { return cutable() ? "green" : "red"; } // LCOV_EXCL_STOP }; diff --git a/src/V3OrderMoveGraph.h b/src/V3OrderMoveGraph.h index fea02866c..bfcdb239a 100644 --- a/src/V3OrderMoveGraph.h +++ b/src/V3OrderMoveGraph.h @@ -53,10 +53,10 @@ public: , m_logicp{logicp} , m_state{POM_WAIT} , m_domScopep{nullptr} {} - virtual ~OrderMoveVertex() override = default; + ~OrderMoveVertex() override = default; // METHODS - virtual string dotColor() const override { + string dotColor() const override { if (logicp()) { return logicp()->dotColor(); } else { @@ -64,7 +64,7 @@ public: } } - virtual string name() const override { + string name() const override { string nm; if (VL_UNCOVERABLE(!logicp())) { // Avoid crash when debugging nm = "nul"; // LCOV_EXCL_LINE @@ -108,7 +108,7 @@ public: , m_domainp{domainp} { UASSERT(!(logicp && varp), "MTaskMoveVertex: logicp and varp may not both be set!\n"); } - virtual ~MTaskMoveVertex() override = default; + ~MTaskMoveVertex() override = default; // ACCESSORS OrderLogicVertex* logicp() const { return m_logicp; } @@ -116,14 +116,14 @@ public: const AstScope* scopep() const { return m_logicp ? m_logicp->scopep() : nullptr; } const AstSenTree* domainp() const { return m_domainp; } - virtual string dotColor() const override { + string dotColor() const override { if (logicp()) { return logicp()->dotColor(); } else { return "yellow"; } } - virtual string name() const override { + string name() const override { string nm; if (logicp()) { nm = logicp()->name(); diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 01807114f..3a21266fc 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -977,7 +977,7 @@ class ParamVisitor final : public VNVisitor { } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (nodep->recursiveClone()) nodep->dead(true); // Fake, made for recursive elimination if (nodep->dead()) return; // Marked by LinkDot (and above) @@ -995,14 +995,14 @@ class ParamVisitor final : public VNVisitor { } } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { visitCellOrClassRef(nodep, VN_IS(nodep->modp(), Iface)); } - virtual void visit(AstClassRefDType* nodep) override { visitCellOrClassRef(nodep, false); } - virtual void visit(AstClassOrPackageRef* nodep) override { visitCellOrClassRef(nodep, false); } + void visit(AstClassRefDType* nodep) override { visitCellOrClassRef(nodep, false); } + void visit(AstClassOrPackageRef* nodep) override { visitCellOrClassRef(nodep, false); } // Make sure all parameters are constantified - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (nodep->user5SetOnce()) return; // Process once iterateChildren(nodep); if (nodep->isParam()) { @@ -1015,7 +1015,7 @@ class ParamVisitor final : public VNVisitor { } } // Make sure varrefs cause vars to constify before things above - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // Might jump across functions, so beware if ever add a m_funcp if (nodep->varp()) iterate(nodep->varp()); } @@ -1036,7 +1036,7 @@ class ParamVisitor final : public VNVisitor { } return false; } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { // Check to see if the scope is just an interface because interfaces are special const string dotted = nodep->dotted(); if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) { @@ -1082,7 +1082,7 @@ class ParamVisitor final : public VNVisitor { nodep->varp(nullptr); // Needs relink, as may remove pointed-to var } - virtual void visit(AstUnlinkedRef* nodep) override { + void visit(AstUnlinkedRef* nodep) override { AstVarXRef* const varxrefp = VN_CAST(nodep->op1p(), VarXRef); AstNodeFTaskRef* const taskrefp = VN_CAST(nodep->op1p(), NodeFTaskRef); if (varxrefp) { @@ -1103,7 +1103,7 @@ class ParamVisitor final : public VNVisitor { nodep->replaceWith(nodep->op1p()->unlinkFrBack()); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstCellArrayRef* nodep) override { + void visit(AstCellArrayRef* nodep) override { V3Const::constifyParamsEdit(nodep->selp()); if (const AstConst* const constp = VN_CAST(nodep->selp(), Const)) { const string index = AstNode::encodeNumber(constp->toSInt()); @@ -1122,7 +1122,7 @@ class ParamVisitor final : public VNVisitor { } // Generate Statements - virtual void visit(AstGenIf* nodep) override { + void visit(AstGenIf* nodep) override { UINFO(9, " GENIF " << nodep << endl); iterateAndNextNull(nodep->condp()); // We suppress errors when widthing params since short-circuiting in @@ -1149,7 +1149,7 @@ class ParamVisitor final : public VNVisitor { //! @todo Unlike generated IF, we don't have to worry about short-circuiting the conditional //! expression, since this is currently restricted to simple comparisons. If we ever do //! move to more generic constant expressions, such code will be needed here. - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { if (nodep->genforp()) { AstGenFor* const forp = VN_AS(nodep->genforp(), GenFor); UASSERT_OBJ(forp, nodep, "Non-GENFOR under generate-for BEGIN"); @@ -1181,10 +1181,10 @@ class ParamVisitor final : public VNVisitor { iterateChildren(nodep); } } - virtual void visit(AstGenFor* nodep) override { // LCOV_EXCL_LINE + void visit(AstGenFor* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("GENFOR should have been wrapped in BEGIN"); } - virtual void visit(AstGenCase* nodep) override { + void visit(AstGenCase* nodep) override { UINFO(9, " GENCASE " << nodep << endl); AstNode* keepp = nullptr; iterateAndNextNull(nodep->exprp()); @@ -1235,7 +1235,7 @@ class ParamVisitor final : public VNVisitor { VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1272,7 +1272,7 @@ public: for (AstNodeModule* const modp : modps) netlistp->addModulep(modp); } } - virtual ~ParamVisitor() override = default; + ~ParamVisitor() override = default; VL_UNCOPYABLE(ParamVisitor); }; diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 1d2832ce5..37da5a1fc 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -89,19 +89,19 @@ void V3ParseImp::lexTimescaleParse(FileLine* fl, const char* textp) { } void V3ParseImp::timescaleMod(FileLine* fl, AstNodeModule* modp, bool unitSet, double unitVal, bool precSet, double precVal) { - VTimescale unit(VTimescale::NONE); + VTimescale unit{VTimescale::NONE}; if (unitSet) { bool bad; - unit = VTimescale(unitVal, bad /*ref*/); + unit = VTimescale{unitVal, bad /*ref*/}; if (bad) { UINFO(1, "Value = " << unitVal << endl); fl->v3error("timeunit illegal value"); } } - VTimescale prec(VTimescale::NONE); + VTimescale prec{VTimescale::NONE}; if (precSet) { bool bad; - prec = VTimescale(precVal, bad /*ref*/); + prec = VTimescale{precVal, bad /*ref*/}; if (bad) { UINFO(1, "Value = " << precVal << endl); fl->v3error("timeprecision illegal value"); diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index ac96491f3..e18af2528 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -253,7 +253,7 @@ public: m_vertices.splice(m_vertices.end(), otherp->m_vertices); m_cost += otherp->m_cost; } - virtual const VxList* vertexListp() const override { return &m_vertices; } + const VxList* vertexListp() const override { return &m_vertices; } static uint64_t incGeneration() { static uint64_t s_generation = 0; ++s_generation; @@ -263,10 +263,10 @@ public: // Use this instead of pointer-compares to compare LogicMTasks. Avoids // nondeterministic output. Also name mtasks based on this number in // the final C++ output. - virtual uint32_t id() const override { return m_serialId; } + uint32_t id() const override { return m_serialId; } void id(uint32_t id) { m_serialId = id; } // Abstract cost of every logic mtask - virtual uint32_t cost() const override { return m_cost; } + uint32_t cost() const override { return m_cost; } void setCost(uint32_t cost) { m_cost = cost; } // For tests only uint32_t stepCost() const { return stepCost(m_cost); } static uint32_t stepCost(uint32_t cost) { @@ -319,7 +319,7 @@ public: void checkRelativesCp(GraphWay way) const; - virtual string name() const override { + string name() const override { // Display forward and reverse critical path costs. This gives a quick // read on whether graph partitioning looks reasonable or bad. std::ostringstream out; @@ -1839,7 +1839,7 @@ private: // METHODS VL_DEBUG_FUNC; - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (!m_tracingCall) return; m_tracingCall = false; if (nodep->dpiImportWrapper()) { @@ -1850,19 +1850,19 @@ private: } iterateChildren(nodep); } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { iterateChildren(nodep); // Enter the function and trace it m_tracingCall = true; iterate(nodep->funcp()); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit DpiImportCallVisitor(AstNode* nodep) { iterate(nodep); } bool hasDpiHazard() const { return m_hasDpiHazard; } - virtual ~DpiImportCallVisitor() override = default; + ~DpiImportCallVisitor() override = default; private: VL_UNCOPYABLE(DpiImportCallVisitor); diff --git a/src/V3PartitionGraph.h b/src/V3PartitionGraph.h index 896ee6826..6f8e8c72d 100644 --- a/src/V3PartitionGraph.h +++ b/src/V3PartitionGraph.h @@ -32,7 +32,7 @@ class AbstractMTask VL_NOT_FINAL : public V3GraphVertex { public: explicit AbstractMTask(V3Graph* graphp) : V3GraphVertex{graphp} {} - virtual ~AbstractMTask() override = default; + ~AbstractMTask() override = default; virtual uint32_t id() const = 0; virtual uint32_t cost() const = 0; }; @@ -44,12 +44,12 @@ public: // CONSTRUCTORS explicit AbstractLogicMTask(V3Graph* graphp) : AbstractMTask{graphp} {} - virtual ~AbstractLogicMTask() override = default; + ~AbstractLogicMTask() override = default; // METHODS // Set of logic vertices in this mtask. Order is not significant. virtual const VxList* vertexListp() const = 0; - virtual uint32_t id() const override = 0; // Unique id of this mtask. - virtual uint32_t cost() const override = 0; + uint32_t id() const override = 0; // Unique id of this mtask. + uint32_t cost() const override = 0; }; class ExecMTask final : public AbstractMTask { @@ -72,10 +72,10 @@ public: , m_bodyp{bodyp} , m_id{id} {} AstMTaskBody* bodyp() const { return m_bodyp; } - virtual uint32_t id() const override { return m_id; } + uint32_t id() const override { return m_id; } uint32_t priority() const { return m_priority; } void priority(uint32_t pri) { m_priority = pri; } - virtual uint32_t cost() const override { return m_cost; } + uint32_t cost() const override { return m_cost; } void cost(uint32_t cost) { m_cost = cost; } void predictStart(uint64_t time) { m_predictStart = time; } uint64_t predictStart() const { return m_predictStart; } @@ -85,7 +85,7 @@ public: // If this MTask maps to a C function, this should be the name return std::string{"__Vmtask"} + "__" + cvtToStr(m_id); } - virtual string name() const override { return std::string{"mt"} + cvtToStr(id()); } + string name() const override { return std::string{"mt"} + cvtToStr(id()); } string hashName() const { return m_hashName; } void hashName(const string& name) { m_hashName = name; } void dump(std::ostream& str) const { diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 804b29e86..8ce783957 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -143,7 +143,7 @@ public: ~VPreStream() { lexStreamDepthAdd(-1); } private: - void lexStreamDepthAdd(int delta); + inline void lexStreamDepthAdd(int delta); }; //====================================================================== @@ -237,6 +237,6 @@ private: void scanSwitchStream(VPreStream* streamp); }; -inline void VPreStream::lexStreamDepthAdd(int delta) { m_lexp->streamDepthAdd(delta); } +void VPreStream::lexStreamDepthAdd(int delta) { m_lexp->streamDepthAdd(delta); } #endif // Guard diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 0cf66dc24..684733a6e 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -250,13 +250,13 @@ public: void candidateDefines(VSpellCheck* spellerp) override; // METHODS, callbacks - virtual void comment(const string& text) override; // Comment detected (if keepComments==2) - virtual void include(const string& filename) override; // Request a include file be processed - virtual void undef(const string& name) override; + void comment(const string& text) override; // Comment detected (if keepComments==2) + void include(const string& filename) override; // Request a include file be processed + void undef(const string& name) override; virtual void undefineall(); - virtual void define(FileLine* fl, const string& name, const string& value, - const string& params, bool cmdline) override; - virtual string removeDefines(const string& text) override; // Remove defines in a text string + void define(FileLine* fl, const string& name, const string& value, const string& params, + bool cmdline) override; + string removeDefines(const string& text) override; // Remove defines in a text string // CONSTRUCTORS V3PreProcImp() { diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index e10f13458..842b8d720 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -151,11 +151,11 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UINFO(4, " MOD " << nodep << endl); iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); { m_cfuncp = nodep; @@ -167,7 +167,7 @@ private: m_assignLhs = false; if (m_cfuncp) m_stmtp = nodep; } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { UINFO(4, " WHILE " << nodep << endl); startStatement(nodep); iterateAndNextNull(nodep->precondsp()); @@ -180,7 +180,7 @@ private: iterateAndNextNull(nodep->incsp()); m_stmtp = nullptr; } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { startStatement(nodep); { bool noopt = false; @@ -207,7 +207,7 @@ private: m_assignLhs = false; m_stmtp = nullptr; } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); return; @@ -217,7 +217,7 @@ private: iterateChildren(nodep); m_stmtp = nullptr; } - virtual void visit(AstTraceInc* nodep) override { + void visit(AstTraceInc* nodep) override { startStatement(nodep); m_inTracep = nodep; iterateChildren(nodep); @@ -271,31 +271,31 @@ private: iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstShiftL* nodep) override { visitShift(nodep); } - virtual void visit(AstShiftR* nodep) override { visitShift(nodep); } - virtual void visit(AstShiftRS* nodep) override { visitShift(nodep); } + void visit(AstShiftL* nodep) override { visitShift(nodep); } + void visit(AstShiftR* nodep) override { visitShift(nodep); } + void visit(AstShiftRS* nodep) override { visitShift(nodep); } // Operators - virtual void visit(AstNodeTermop* nodep) override { + void visit(AstNodeTermop* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeUniop* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstRand* nodep) override { + void visit(AstRand* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { iterateAndNextNull(nodep->fromp()); { // Only the 'from' is part of the assignment LHS VL_RESTORER(m_assignLhs); @@ -305,7 +305,7 @@ private: } checkNode(nodep); } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { iterateAndNextNull(nodep->fromp()); { // Only the 'from' is part of the assignment LHS VL_RESTORER(m_assignLhs); @@ -314,7 +314,7 @@ private: } checkNode(nodep); } - virtual void visit(AstAssocSel* nodep) override { + void visit(AstAssocSel* nodep) override { iterateAndNextNull(nodep->fromp()); { // Only the 'from' is part of the assignment LHS VL_RESTORER(m_assignLhs); @@ -323,11 +323,11 @@ private: } checkNode(nodep); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { iterateChildren(nodep); checkNode(nodep); } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { iterateChildren(nodep); if (nodep->expr1p()->isWide() && !VN_IS(nodep->condp(), Const) && !VN_IS(nodep->condp(), VarRef)) { @@ -339,7 +339,7 @@ private: } // Autoflush - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { startStatement(nodep); iterateChildren(nodep); m_stmtp = nullptr; @@ -356,7 +356,7 @@ private: } } } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { iterateChildren(nodep); // Any strings sent to a display must be var of string data type, // to avoid passing a pointer to a temporary. @@ -370,8 +370,8 @@ private: //-------------------- // Default: Just iterate - virtual void visit(AstVar*) override {} // Don't hit varrefs under vars - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Don't hit varrefs under vars + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index c9a7acf9b..21abed5a7 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -64,7 +64,7 @@ private: bool m_hasClk = false; // True if the top module has sequential logic // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { m_vfilep = new AstVFile{nodep->fileline(), v3Global.opt.makeDir() + "/" + m_libName + ".sv"}; nodep->addFilesp(m_vfilep); @@ -74,7 +74,7 @@ private: iterateChildren(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (!nodep->isTop()) { return; } else { @@ -422,7 +422,7 @@ private: m_cfilep->tblockp(txtp); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (!nodep->isIO()) return; if (nodep->direction() == VDirection::INPUT) { if (nodep->isUsedClock() || nodep->attrClocker() == VVarAttrClocker::CLOCKER_YES) { @@ -439,7 +439,7 @@ private: } } - virtual void visit(AstNode*) override {} + void visit(AstNode*) override {} string cInputConnection(AstVar* varp) { return V3Task::assignDpiToInternal("handlep__V->" + varp->name(), varp); diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 0ac20c3b7..448623a08 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -82,7 +82,7 @@ private: } // VISITORS - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { iterateChildren(nodep); if (nodep->extendsp()) { // Save pointer to derived class @@ -90,7 +90,7 @@ private: m_baseToDerivedMap[basep].insert(nodep); } } - virtual void visit(AstMethodCall* nodep) override { + void visit(AstMethodCall* nodep) override { iterateChildren(nodep); if (nodep->name() != "randomize") return; if (const AstClassRefDType* const classRefp @@ -100,7 +100,7 @@ private: markMembers(classp); } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -108,7 +108,7 @@ public: iterate(nodep); markAllDerived(); } - virtual ~RandomizeMarkVisitor() override = default; + ~RandomizeMarkVisitor() override = default; }; //###################################################################### @@ -199,7 +199,7 @@ private: } // VISITORS - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { iterateChildren(nodep); if (!nodep->user1()) return; // Doesn't need randomize, or already processed UINFO(9, "Define randomize() for " << nodep << endl); @@ -241,12 +241,12 @@ private: } nodep->user1(false); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit RandomizeVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~RandomizeVisitor() override = default; + ~RandomizeVisitor() override = default; }; //###################################################################### diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 19a4363ca..e163bdf8c 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -151,7 +151,7 @@ private: } // VISITORS - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_cfuncp); { m_cfuncp = nodep; @@ -159,7 +159,7 @@ private: mergeEnd(); // Finish last pending merge, if any } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (!m_cfuncp) return; // Left select WordSel or ArraySel @@ -250,14 +250,14 @@ private: UINFO(9, "Start merge i=" << lindex << " o=" << m_mgOffset << nodep << endl); } //-------------------- - virtual void visit(AstVar*) override {} // Accelerate - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar*) override {} // Accelerate + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ReloopVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ReloopVisitor() override { + ~ReloopVisitor() override { V3Stats::addStat("Optimizations, Reloops", m_statReloops); V3Stats::addStat("Optimizations, Reloop iterations", m_statReItems); } diff --git a/src/V3SchedPartition.cpp b/src/V3SchedPartition.cpp index 5a87cbcae..fe0a08a6a 100644 --- a/src/V3SchedPartition.cpp +++ b/src/V3SchedPartition.cpp @@ -217,7 +217,7 @@ class SchedGraphBuilder final : public VNVisitor { } // VISIT methods - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { AstSenTree* const senTreep = nodep->sensesp(); UASSERT_OBJ(senTreep->hasClocked() || senTreep->hasCombo() || senTreep->hasHybrid(), nodep, "Unhandled"); @@ -236,30 +236,28 @@ class SchedGraphBuilder final : public VNVisitor { m_senTreep = nullptr; } - virtual void visit(AstNodeProcedure* nodep) override { visitLogic(nodep); } - virtual void visit(AstNodeAssign* nodep) override { visitLogic(nodep); } - virtual void visit(AstCoverToggle* nodep) override { visitLogic(nodep); } - virtual void visit(AstAlwaysPublic* nodep) override { visitLogic(nodep); } + void visit(AstNodeProcedure* nodep) override { visitLogic(nodep); } + void visit(AstNodeAssign* nodep) override { visitLogic(nodep); } + void visit(AstCoverToggle* nodep) override { visitLogic(nodep); } + void visit(AstAlwaysPublic* nodep) override { visitLogic(nodep); } // Pre and Post logic are handled separately - virtual void visit(AstAssignPre* nodep) override {} - virtual void visit(AstAssignPost* nodep) override {} - virtual void visit(AstAlwaysPost* nodep) override {} + void visit(AstAssignPre* nodep) override {} + void visit(AstAssignPost* nodep) override {} + void visit(AstAlwaysPost* nodep) override {} // LCOV_EXCL_START // Ignore - virtual void visit(AstInitialStatic* nodep) override { + void visit(AstInitialStatic* nodep) override { nodep->v3fatalSrc("Should not need ordering"); } + void visit(AstInitial* nodep) override { // nodep->v3fatalSrc("Should not need ordering"); } - virtual void visit(AstInitial* nodep) override { // - nodep->v3fatalSrc("Should not need ordering"); - } - virtual void visit(AstFinal* nodep) override { // + void visit(AstFinal* nodep) override { // nodep->v3fatalSrc("Should not need ordering"); } // Default - Any other AstActive content not handled above will hit this - virtual void visit(AstNode* nodep) override { // + void visit(AstNode* nodep) override { // nodep->v3fatalSrc("Should behandled above"); } // LCOV_EXCL_STOP diff --git a/src/V3SchedTiming.cpp b/src/V3SchedTiming.cpp index 24612ccd4..d091718e3 100644 --- a/src/V3SchedTiming.cpp +++ b/src/V3SchedTiming.cpp @@ -168,7 +168,7 @@ TimingKit prepareTiming(AstNetlist* const netlistp) { } // VISITORS - virtual void visit(AstNodeProcedure* const nodep) override { + void visit(AstNodeProcedure* const nodep) override { UASSERT_OBJ(!m_inProcess && !m_gatherVars && m_processDomains.empty() && m_writtenBySuspendable.empty(), nodep, "Process in process?"); @@ -186,20 +186,20 @@ TimingKit prepareTiming(AstNetlist* const netlistp) { m_inProcess = false; m_gatherVars = false; } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { VL_RESTORER(m_gatherVars); if (m_inProcess) m_gatherVars = true; // If not in a process, we don't need to gather variables or domains iterateChildren(nodep); } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { if (AstSenTree* const sensesp = nodep->sensesp()) { if (!sensesp->user1SetOnce()) createResumeActive(nodep); nodep->clearSensesp(); // Clear as these sentrees will get deleted later if (m_inProcess) m_processDomains.insert(sensesp); } } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { if (m_gatherVars && nodep->access().isWriteOrRW() && !nodep->varScopep()->user2SetOnce()) { m_writtenBySuspendable.push_back(nodep->varScopep()); @@ -207,8 +207,8 @@ TimingKit prepareTiming(AstNetlist* const netlistp) { } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -219,7 +219,7 @@ TimingKit prepareTiming(AstNetlist* const netlistp) { , m_externalDomains{externalDomains} { iterate(nodep); } - virtual ~AwaitVisitor() override = default; + ~AwaitVisitor() override = default; }; LogicByScope lbs; std::map> externalDomains; @@ -300,20 +300,20 @@ void transformForks(AstNetlist* const netlistp) { } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_inClass); m_inClass = VN_IS(nodep, Class); iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { m_funcp = nodep; iterateChildren(nodep); m_funcp = nullptr; } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (!m_forkp) nodep->user1(true); } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (m_forkp) return; // Handle forks in forks after moving them to new functions VL_RESTORER(m_forkp); m_forkp = nodep; @@ -323,7 +323,7 @@ void transformForks(AstNetlist* const netlistp) { nodep->replaceWith(nodep->stmtsp()->unlinkFrBackWithNext()); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { UASSERT_OBJ(m_forkp, nodep, "Begin outside of a fork"); // Start with children, so later we only find awaits that are actually in this begin m_beginHasAwaits = false; @@ -356,19 +356,19 @@ void transformForks(AstNetlist* const netlistp) { } VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { m_beginHasAwaits = true; iterateChildrenConst(nodep); } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ForkVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ForkVisitor() override = default; + ~ForkVisitor() override = default; }; ForkVisitor{netlistp}; V3Global::dumpCheckGlobalTree("sched_forks", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index e39c1aa93..0c4bad466 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -81,7 +81,7 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { AstNodeModule* const modp = nodep->topModulep(); if (!modp) { nodep->v3error("No top level module found"); @@ -93,7 +93,7 @@ private: iterate(modp); cleanupVarRefs(); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { // Create required blocks and add to module string scopename; if (!m_aboveScopep) { @@ -144,7 +144,7 @@ private: // ***Note m_scopep is passed back to the caller of the routine (above) } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { // Create required blocks and add to module VL_RESTORER(m_scopep); VL_RESTORER(m_aboveCellp); @@ -177,13 +177,13 @@ private: iterateChildren(nodep); } } - virtual void visit(AstCellInline* nodep) override { // + void visit(AstCellInline* nodep) override { // nodep->scopep(m_scopep); } - virtual void visit(AstActive* nodep) override { // LCOV_EXCL_LINE + void visit(AstActive* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc("Actives now made after scoping"); } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -191,7 +191,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstAssignAlias* nodep) override { + void visit(AstAssignAlias* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -199,7 +199,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstAssignVarScope* nodep) override { + void visit(AstAssignVarScope* nodep) override { // Copy under the scope but don't recurse UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -207,7 +207,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -215,7 +215,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -223,7 +223,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstCoverToggle* nodep) override { + void visit(AstCoverToggle* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); AstNode* const clonep = nodep->cloneTree(false); @@ -231,7 +231,7 @@ private: m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { // Add to list of blocks under this scope UINFO(4, " CFUNC " << nodep << endl); AstCFunc* const clonep = nodep->cloneTree(false); @@ -241,7 +241,7 @@ private: // We iterate under the *clone* iterateChildren(clonep); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // Add to list of blocks under this scope UINFO(4, " FTASK " << nodep << endl); AstNodeFTask* clonep; @@ -257,7 +257,7 @@ private: // We iterate under the *clone* iterateChildren(clonep); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { // Make new scope variable if (!nodep->user1p()) { AstVarScope* const varscp = new AstVarScope(nodep->fileline(), m_scopep, nodep); @@ -275,7 +275,7 @@ private: m_scopep->addVarp(varscp); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // VarRef needs to point to VarScope // Make sure variable has made user1p. UASSERT_OBJ(nodep->varp(), nodep, "Unlinked"); @@ -289,7 +289,7 @@ private: m_varRefScopes.emplace(nodep, m_scopep); } } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { // If there's a %m in the display text, we add a special node that will contain the name() const string prefix = std::string{"__DOT__"} + m_scopep->name(); // TOP and above will be the user's name(). @@ -305,17 +305,17 @@ private: if (afterp) nodep->scopeEntrp(afterp); iterateChildren(nodep); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { // Scope that was made by this module for different cell; // Want to ignore blocks under it, so just do nothing } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ScopeVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ScopeVisitor() override = default; + ~ScopeVisitor() override = default; }; //###################################################################### @@ -330,7 +330,7 @@ private: VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { // Want to ignore blocks under it VL_RESTORER(m_scopep); { @@ -351,20 +351,20 @@ private: } } - virtual void visit(AstNodeProcedure* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstAssignAlias* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstAssignVarScope* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstAssignW* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstAlwaysPublic* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstCoverToggle* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstNodeFTask* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstCFunc* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstNodeProcedure* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstAssignAlias* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstAssignVarScope* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstAssignW* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstAlwaysPublic* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstCoverToggle* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstNodeFTask* nodep) override { movedDeleteOrIterate(nodep); } + void visit(AstCFunc* nodep) override { movedDeleteOrIterate(nodep); } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { // The crossrefs are dealt with in V3LinkDot nodep->varp(nullptr); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { // The crossrefs are dealt with in V3LinkDot UINFO(9, " Old pkg-taskref " << nodep << endl); if (nodep->classOrPackagep()) { @@ -380,7 +380,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstModportFTaskRef* nodep) override { + void visit(AstModportFTaskRef* nodep) override { // The modport persists only for xml dump // The crossrefs are dealt with in V3LinkDot nodep->ftaskp(nullptr); @@ -388,12 +388,12 @@ private: } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit ScopeCleanupVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ScopeCleanupVisitor() override = default; + ~ScopeCleanupVisitor() override = default; }; //###################################################################### diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 0c9c6f43f..98d44a3c8 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -397,15 +397,15 @@ private: } // VISITORS - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { if (jumpingOver(nodep)) return; checkNodeInfo(nodep); iterateChildren(nodep); } - virtual void visit(AstSenTree* nodep) override { + void visit(AstSenTree* nodep) override { // Sensitivities aren't inputs per se; we'll keep our tree under the same sens. } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (jumpingOver(nodep)) return; if (!optimizable()) return; // Accelerate UASSERT_OBJ(nodep->varp(), nodep, "Unlinked"); @@ -473,7 +473,7 @@ private: } } } - virtual void visit(AstVarXRef* nodep) override { + void visit(AstVarXRef* nodep) override { if (jumpingOver(nodep)) return; if (m_scoped) { badNodeType(nodep); @@ -483,7 +483,7 @@ private: "allowed in constant functions"); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { if (jumpingOver(nodep)) return; if (!m_params) { badNodeType(nodep); @@ -503,7 +503,7 @@ private: checkNodeInfo(nodep); iterateChildren(nodep); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { if (jumpingOver(nodep)) return; UINFO(5, " IF " << nodep << endl); checkNodeInfo(nodep); @@ -520,15 +520,15 @@ private: } } } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { checkNodeInfo(nodep); if (!m_checkOnly && optimizable()) newValue(nodep, nodep); } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { checkNodeInfo(nodep); if (!m_checkOnly && optimizable()) newValue(nodep, nodep); } - virtual void visit(AstEnumItemRef* nodep) override { + void visit(AstEnumItemRef* nodep) override { checkNodeInfo(nodep); UASSERT_OBJ(nodep->itemp(), nodep, "Not linked"); if (!m_checkOnly && optimizable()) { @@ -541,7 +541,7 @@ private: } } } - virtual void visit(AstNodeUniop* nodep) override { + void visit(AstNodeUniop* nodep) override { if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); iterateChildren(nodep); @@ -549,7 +549,7 @@ private: nodep->numberOperate(newConst(nodep)->num(), fetchConst(nodep->lhsp())->num()); } } - virtual void visit(AstNodeBiop* nodep) override { + void visit(AstNodeBiop* nodep) override { if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); iterateChildren(nodep); @@ -558,7 +558,7 @@ private: fetchConst(nodep->rhsp())->num()); } } - virtual void visit(AstNodeTriop* nodep) override { + void visit(AstNodeTriop* nodep) override { if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); iterateChildren(nodep); @@ -568,7 +568,7 @@ private: fetchConst(nodep->thsp())->num()); } } - virtual void visit(AstNodeQuadop* nodep) override { + void visit(AstNodeQuadop* nodep) override { if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); iterateChildren(nodep); @@ -579,7 +579,7 @@ private: fetchConst(nodep->fhsp())->num()); } } - virtual void visit(AstLogAnd* nodep) override { + void visit(AstLogAnd* nodep) override { // Need to short circuit if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); @@ -597,7 +597,7 @@ private: } } } - virtual void visit(AstLogOr* nodep) override { + void visit(AstLogOr* nodep) override { // Need to short circuit if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); @@ -615,7 +615,7 @@ private: } } } - virtual void visit(AstLogIf* nodep) override { + void visit(AstLogIf* nodep) override { // Need to short circuit, same as (!A || B) if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); @@ -625,8 +625,8 @@ private: iterate(nodep->lhsp()); if (optimizable()) { if (fetchConst(nodep->lhsp())->num().isEqZero()) { - const AstConst cnst(nodep->fileline(), AstConst::WidthedValue(), 1, - 1); // a one + const AstConst cnst{nodep->fileline(), AstConst::WidthedValue{}, 1, + 1}; // a one newValue(nodep, &cnst); // a one } else { iterate(nodep->rhsp()); @@ -635,7 +635,7 @@ private: } } } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { // We could use above visit(AstNodeTriop), but need to do short circuiting. // It's also slower even O(n^2) to evaluate both sides when we // really only need to evaluate one side. @@ -755,7 +755,7 @@ private: } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { if (jumpingOver(nodep)) return; if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); @@ -795,7 +795,7 @@ private: } m_inDlyAssign = false; } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { checkNodeInfo(nodep); iterateChildren(nodep); if (AstInitArray* const initp = VN_CAST(fetchValueNull(nodep->fromp()), InitArray)) { @@ -812,11 +812,11 @@ private: clearOptimizable(nodep, "Array select of non-array"); } } - virtual void visit(AstBegin* nodep) override { + void visit(AstBegin* nodep) override { checkNodeInfo(nodep); iterateChildren(nodep); } - virtual void visit(AstNodeCase* nodep) override { + void visit(AstNodeCase* nodep) override { if (jumpingOver(nodep)) return; UINFO(5, " CASE " << nodep << endl); checkNodeInfo(nodep); @@ -854,20 +854,20 @@ private: } } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { // Real handling is in AstNodeCase if (jumpingOver(nodep)) return; checkNodeInfo(nodep); iterateChildren(nodep); } - virtual void visit(AstComment*) override {} + void visit(AstComment*) override {} - virtual void visit(AstJumpBlock* nodep) override { + void visit(AstJumpBlock* nodep) override { if (jumpingOver(nodep)) return; iterateChildren(nodep); } - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { if (jumpingOver(nodep)) return; checkNodeInfo(nodep); if (!m_checkOnly) { @@ -875,7 +875,7 @@ private: m_jumpp = nodep; } } - virtual void visit(AstJumpLabel* nodep) override { + void visit(AstJumpLabel* nodep) override { // This only supports forward jumps. That's all we make at present, // AstJumpGo::broken uses brokeExistsBelow() to check this. if (jumpingOver(nodep)) return; @@ -886,7 +886,7 @@ private: m_jumpp = nullptr; } } - virtual void visit(AstStop* nodep) override { + void visit(AstStop* nodep) override { if (jumpingOver(nodep)) return; if (m_params) { // This message seems better than an obscure $stop // The spec says $stop is just ignored, it seems evil to ignore assertions @@ -897,7 +897,7 @@ private: checkNodeInfo(nodep); } - virtual void visit(AstNodeFor* nodep) override { + void visit(AstNodeFor* nodep) override { // Doing lots of Whiles is slow, so only for parameters UINFO(5, " FOR " << nodep << endl); if (!m_params) { @@ -929,7 +929,7 @@ private: } } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { // Doing lots of Whiles is slow, so only for parameters if (jumpingOver(nodep)) return; UINFO(5, " WHILE " << nodep << endl); @@ -969,7 +969,7 @@ private: } } - virtual void visit(AstFuncRef* nodep) override { + void visit(AstFuncRef* nodep) override { if (jumpingOver(nodep)) return; if (!optimizable()) return; // Accelerate UINFO(5, " FUNCREF " << nodep << endl); @@ -1022,8 +1022,8 @@ private: m_callStack.push_back(&stackNode); // Clear output variable if (const auto* const basicp = VN_CAST(funcp->fvarp(), Var)->basicp()) { - AstConst cnst(funcp->fvarp()->fileline(), AstConst::WidthedValue(), basicp->widthMin(), - 0); + AstConst cnst{funcp->fvarp()->fileline(), AstConst::WidthedValue{}, basicp->widthMin(), + 0}; if (basicp->isZeroInit()) { cnst.num().setAllBits0(); } else { @@ -1041,7 +1041,7 @@ private: } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (jumpingOver(nodep)) return; if (!m_params) { badNodeType(nodep); @@ -1049,12 +1049,12 @@ private: } } - virtual void visit(AstScopeName* nodep) override { + void visit(AstScopeName* nodep) override { if (jumpingOver(nodep)) return; // Ignore } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { if (jumpingOver(nodep)) return; if (!optimizable()) return; // Accelerate checkNodeInfo(nodep); @@ -1108,7 +1108,7 @@ private: } } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { if (jumpingOver(nodep)) return; if (!optimizable()) return; // Accelerate // We ignore isPredictOptimizable as $display is often in constant @@ -1133,7 +1133,7 @@ private: // These types are definitely not reducible // AstCoverInc, AstFinish, // AstRand, AstTime, AstUCFunc, AstCCall, AstCStmt, AstUCStmt - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (jumpingOver(nodep)) return; badNodeType(nodep); } @@ -1188,7 +1188,7 @@ public: setMode(false /*scoped*/, false /*checking*/, true /*params*/); mainGuts(nodep); } - virtual ~SimulateVisitor() override { + ~SimulateVisitor() override { for (const auto& pair : m_constps) { for (AstConst* const constp : pair.second) { delete constp; } } diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index b143373f2..c5a993e75 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -128,7 +128,7 @@ class SliceVisitor final : public VNVisitor { return newp; } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // Called recursively on newly created assignments if (!nodep->user1() && !VN_IS(nodep, AssignAlias)) { nodep->user1(true); @@ -162,7 +162,7 @@ class SliceVisitor final : public VNVisitor { } } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { UASSERT_OBJ(!m_assignp, nodep, "Array initialization should have been removed earlier"); } @@ -221,17 +221,17 @@ class SliceVisitor final : public VNVisitor { iterateChildren(nodep); } } - virtual void visit(AstEq* nodep) override { expandBiOp(nodep); } - virtual void visit(AstNeq* nodep) override { expandBiOp(nodep); } - virtual void visit(AstEqCase* nodep) override { expandBiOp(nodep); } - virtual void visit(AstNeqCase* nodep) override { expandBiOp(nodep); } + void visit(AstEq* nodep) override { expandBiOp(nodep); } + void visit(AstNeq* nodep) override { expandBiOp(nodep); } + void visit(AstEqCase* nodep) override { expandBiOp(nodep); } + void visit(AstNeqCase* nodep) override { expandBiOp(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit SliceVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~SliceVisitor() override = default; + ~SliceVisitor() override = default; }; //###################################################################### diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 979371c8b..8b9c2f64a 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -103,14 +103,12 @@ protected: SplitNodeVertex(V3Graph* graphp, AstNode* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~SplitNodeVertex() override = default; + ~SplitNodeVertex() override = default; // ACCESSORS // Do not make accessor for nodep(), It may change due to // reordering a lower block, but we don't repair it - virtual string name() const override { - return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName(); - } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + string name() const override { return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName(); } + FileLine* fileline() const override { return nodep()->fileline(); } public: virtual AstNode* nodep() const { return m_nodep; } @@ -120,34 +118,34 @@ class SplitPliVertex final : public SplitNodeVertex { public: explicit SplitPliVertex(V3Graph* graphp, AstNode* nodep) : SplitNodeVertex{graphp, nodep} {} - virtual ~SplitPliVertex() override = default; - virtual string name() const override { return "*PLI*"; } - virtual string dotColor() const override { return "green"; } + ~SplitPliVertex() override = default; + string name() const override { return "*PLI*"; } + string dotColor() const override { return "green"; } }; class SplitLogicVertex final : public SplitNodeVertex { public: SplitLogicVertex(V3Graph* graphp, AstNode* nodep) : SplitNodeVertex{graphp, nodep} {} - virtual ~SplitLogicVertex() override = default; - virtual string dotColor() const override { return "yellow"; } + ~SplitLogicVertex() override = default; + string dotColor() const override { return "yellow"; } }; class SplitVarStdVertex final : public SplitNodeVertex { public: SplitVarStdVertex(V3Graph* graphp, AstNode* nodep) : SplitNodeVertex{graphp, nodep} {} - virtual ~SplitVarStdVertex() override = default; - virtual string dotColor() const override { return "skyblue"; } + ~SplitVarStdVertex() override = default; + string dotColor() const override { return "skyblue"; } }; class SplitVarPostVertex final : public SplitNodeVertex { public: SplitVarPostVertex(V3Graph* graphp, AstNode* nodep) : SplitNodeVertex{graphp, nodep} {} - virtual ~SplitVarPostVertex() override = default; - virtual string name() const override { return string("POST ") + SplitNodeVertex::name(); } - virtual string dotColor() const override { return "CadetBlue"; } + ~SplitVarPostVertex() override = default; + string name() const override { return string("POST ") + SplitNodeVertex::name(); } + string dotColor() const override { return "CadetBlue"; } }; //###################################################################### @@ -161,7 +159,7 @@ protected: SplitEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, bool cutable = CUTABLE) : V3GraphEdge{graphp, fromp, top, weight, cutable} {} - virtual ~SplitEdge() override = default; + ~SplitEdge() override = default; public: // Iterator for graph functions @@ -180,7 +178,7 @@ public: if (!oedgep) v3fatalSrc("Following edge of non-SplitEdge type"); return (!oedgep->ignoreThisStep()); } - virtual string dotStyle() const override { + string dotStyle() const override { return ignoreThisStep() ? "dotted" : V3GraphEdge::dotStyle(); } }; @@ -190,36 +188,36 @@ class SplitPostEdge final : public SplitEdge { public: SplitPostEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) : SplitEdge{graphp, fromp, top, WEIGHT_NORMAL} {} - virtual ~SplitPostEdge() override = default; - virtual bool followScoreboard() const override { return false; } - virtual string dotColor() const override { return "khaki"; } + ~SplitPostEdge() override = default; + bool followScoreboard() const override { return false; } + string dotColor() const override { return "khaki"; } }; class SplitLVEdge final : public SplitEdge { public: SplitLVEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) : SplitEdge{graphp, fromp, top, WEIGHT_NORMAL} {} - virtual ~SplitLVEdge() override = default; - virtual bool followScoreboard() const override { return true; } - virtual string dotColor() const override { return "yellowGreen"; } + ~SplitLVEdge() override = default; + bool followScoreboard() const override { return true; } + string dotColor() const override { return "yellowGreen"; } }; class SplitRVEdge final : public SplitEdge { public: SplitRVEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) : SplitEdge{graphp, fromp, top, WEIGHT_NORMAL} {} - virtual ~SplitRVEdge() override = default; - virtual bool followScoreboard() const override { return true; } - virtual string dotColor() const override { return "green"; } + ~SplitRVEdge() override = default; + bool followScoreboard() const override { return true; } + string dotColor() const override { return "green"; } }; struct SplitScorebdEdge : public SplitEdge { public: SplitScorebdEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) : SplitEdge{graphp, fromp, top, WEIGHT_NORMAL} {} - virtual ~SplitScorebdEdge() override = default; - virtual bool followScoreboard() const override { return true; } - virtual string dotColor() const override { return "blue"; } + ~SplitScorebdEdge() override = default; + bool followScoreboard() const override { return true; } + string dotColor() const override { return "blue"; } }; struct SplitStrictEdge : public SplitEdge { @@ -228,9 +226,9 @@ struct SplitStrictEdge : public SplitEdge { public: SplitStrictEdge(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top) : SplitEdge{graphp, fromp, top, WEIGHT_NORMAL, NOT_CUTABLE} {} - virtual ~SplitStrictEdge() override = default; - virtual bool followScoreboard() const override { return true; } - virtual string dotColor() const override { return "blue"; } + ~SplitStrictEdge() override = default; + bool followScoreboard() const override { return true; } + string dotColor() const override { return "blue"; } }; //###################################################################### @@ -259,7 +257,7 @@ protected: // CONSTRUCTORS public: SplitReorderBaseVisitor() { scoreboardClear(); } - virtual ~SplitReorderBaseVisitor() override = default; + ~SplitReorderBaseVisitor() override = default; // METHODS protected: @@ -335,19 +333,19 @@ protected: virtual void makeRvalueEdges(SplitVarStdVertex* vstdp) = 0; // VISITORS - virtual void visit(AstAlways* nodep) override = 0; - virtual void visit(AstNodeIf* nodep) override = 0; + void visit(AstAlways* nodep) override = 0; + void visit(AstNodeIf* nodep) override = 0; // We don't do AstNodeFor/AstWhile loops, due to the standard question // of what is before vs. after - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { m_inDly = true; UINFO(4, " ASSIGNDLY " << nodep << endl); iterateChildren(nodep); m_inDly = false; } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (!m_stmtStackps.empty()) { AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Not linked"); @@ -410,7 +408,7 @@ protected: } } - virtual void visit(AstJumpGo* nodep) override { + void visit(AstJumpGo* nodep) override { // Jumps will disable reordering at all levels // This is overly pessimistic; we could treat jumps as barriers, and // reorder everything between jumps/labels, however jumps are rare @@ -422,7 +420,7 @@ protected: //-------------------- // Default - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // **** SPECIAL default type that sets PLI_ORDERING if (!m_stmtStackps.empty() && !nodep->isPure()) { UINFO(9, " NotSplittable " << nodep << endl); @@ -443,11 +441,11 @@ class ReorderVisitor final : public SplitReorderBaseVisitor { // CONSTRUCTORS public: explicit ReorderVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~ReorderVisitor() override = default; + ~ReorderVisitor() override = default; // METHODS protected: - virtual void makeRvalueEdges(SplitVarStdVertex* vstdp) override { + void makeRvalueEdges(SplitVarStdVertex* vstdp) override { for (SplitLogicVertex* vxp : m_stmtStackps) new SplitRVEdge(&m_graph, vxp, vstdp); } @@ -603,7 +601,7 @@ protected: firstp->user3p(oldBlockUser3); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { UINFO(4, " ALW " << nodep << endl); if (debug() >= 9) nodep->dumpTree(cout, " alwIn:: "); scoreboardClear(); @@ -611,7 +609,7 @@ protected: if (debug() >= 9) nodep->dumpTree(cout, " alwOut: "); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { UINFO(4, " IF " << nodep << endl); iterateAndNextNull(nodep->condp()); processBlock(nodep->ifsp()); @@ -640,7 +638,7 @@ public: // Visit through *nodep and map each AstNodeIf within to the set of // colors it will participate in. Also find the whole set of colors. explicit IfColorVisitor(AstAlways* nodep) { iterate(nodep); } - virtual ~IfColorVisitor() override = default; + ~IfColorVisitor() override = default; // METHODS const ColorSet& colors() const { return m_colors; } @@ -667,13 +665,13 @@ private: } protected: - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { m_ifStack.push_back(nodep); trackNode(nodep); iterateChildren(nodep); m_ifStack.pop_back(); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { trackNode(nodep); iterateChildren(nodep); } @@ -705,7 +703,7 @@ public: UINFO(6, " splitting always " << nodep << endl); } - virtual ~EmitSplitVisitor() override = default; + ~EmitSplitVisitor() override = default; // METHODS void go() { @@ -736,7 +734,7 @@ protected: return new AstSplitPlaceholder(m_origAlwaysp->fileline()); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // Anything that's not an if/else we assume is a leaf // (that is, something we won't split.) Don't visit further // into the leaf. @@ -758,7 +756,7 @@ protected: m_addAfter[color] = clonedp; } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { const ColorSet& colors = m_ifColorp->colors(nodep); using CloneMap = std::unordered_map; CloneMap clones; @@ -802,17 +800,17 @@ class RemovePlaceholdersVisitor final : public VNVisitor { // CONSTRUCTORS RemovePlaceholdersVisitor() = default; - virtual ~RemovePlaceholdersVisitor() override = default; + ~RemovePlaceholdersVisitor() override = default; // VISITORS - virtual void visit(AstSplitPlaceholder* nodep) override { pushDeletep(nodep->unlinkFrBack()); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstSplitPlaceholder* nodep) override { pushDeletep(nodep->unlinkFrBack()); } + void visit(AstNodeIf* nodep) override { VL_RESTORER(m_isPure); m_isPure = true; iterateChildren(nodep); if (!nodep->ifsp() && !nodep->elsesp() && m_isPure) pushDeletep(nodep->unlinkFrBack()); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { VL_RESTORER(m_isPure); m_isPure = true; iterateChildren(nodep); @@ -832,7 +830,7 @@ class RemovePlaceholdersVisitor final : public VNVisitor { } } } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { m_isPure &= nodep->isPure(); iterateChildren(nodep); // must visit regardless of m_isPure to remove placeholders } @@ -879,13 +877,11 @@ public: } } - virtual ~SplitVisitor() override { - V3Stats::addStat("Optimizations, Split always", m_statSplits); - } + ~SplitVisitor() override { V3Stats::addStat("Optimizations, Split always", m_statSplits); } // METHODS protected: - virtual void makeRvalueEdges(SplitVarStdVertex* vstdp) override { + void makeRvalueEdges(SplitVarStdVertex* vstdp) override { // Each 'if' depends on rvalues in its own conditional ONLY, // not rvalues in the if/else bodies. for (auto it = m_stmtStackps.cbegin(); it != m_stmtStackps.cend(); ++it) { @@ -960,7 +956,7 @@ protected: if (debug() >= 9) m_graph.dumpDotFilePrefixed("splitg_colored", false); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { // build the scoreboard scoreboardClear(); scanBlock(nodep->bodysp()); @@ -992,7 +988,7 @@ protected: emitSplit.go(); } } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { UINFO(4, " IF " << nodep << endl); m_curIfConditional = nodep; iterateAndNextNull(nodep->condp()); diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index ebdac1d7a..d22429f93 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -49,17 +49,17 @@ private: AstVarScope* m_splitVscp = nullptr; // Variable we want to split // METHODS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->access().isWriteOrRW() && !m_splitVscp && nodep->varp()->attrIsolateAssign()) { m_splitVscp = nodep->varScopep(); } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit SplitAsFindVisitor(AstAlways* nodep) { iterate(nodep); } - virtual ~SplitAsFindVisitor() override = default; + ~SplitAsFindVisitor() override = default; // METHODS AstVarScope* splitVscp() const { return m_splitVscp; } }; @@ -76,7 +76,7 @@ private: bool m_matches = false; // Statement below has matching lvalue reference // METHODS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (nodep->access().isWriteOrRW()) { if (nodep->varScopep() == m_splitVscp) { UINFO(6, " CL VAR " << nodep << endl); @@ -84,7 +84,7 @@ private: } } } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); return; @@ -110,7 +110,7 @@ private: m_keepStmt = oldKeep || m_keepStmt; UINFO(9, " upKeep=" << m_keepStmt << " STMT " << nodep << endl); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -119,7 +119,7 @@ public: , m_modeMatch{modeMatch} { iterate(nodep); } - virtual ~SplitAsCleanVisitor() override = default; + ~SplitAsCleanVisitor() override = default; }; //###################################################################### @@ -154,7 +154,7 @@ private: } } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { // Are there any lvalue references below this? // There could be more than one. So, we process the first one found first. const AstVarScope* lastSplitVscp = nullptr; @@ -179,13 +179,13 @@ private: } // Speedup; no always under math - virtual void visit(AstNodeMath*) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit SplitAsVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~SplitAsVisitor() override { + ~SplitAsVisitor() override { V3Stats::addStat("Optimizations, isolate_assignments blocks", m_statSplits); } }; diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 7ca9464d0..47dc0e006 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -362,10 +362,10 @@ public: void remove(AstNode* nodep) { struct Visitor : public VNVisitor { RefsInModule& m_parent; - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } - virtual void visit(AstVar* nodep) override { m_parent.m_vars.erase(nodep); } - virtual void visit(AstVarRef* nodep) override { m_parent.m_refs.erase(nodep); } - virtual void visit(AstSel* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstVar* nodep) override { m_parent.m_vars.erase(nodep); } + void visit(AstVarRef* nodep) override { m_parent.m_refs.erase(nodep); } + void visit(AstSel* nodep) override { m_parent.m_sels.erase(nodep); iterateChildren(nodep); } @@ -456,8 +456,8 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { return refp; } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeModule* nodep) override { UINFO(4, "Start checking " << nodep->prettyNameQ() << "\n"); if (!VN_IS(nodep, Module)) { UINFO(4, "Skip " << nodep->prettyNameQ() << "\n"); @@ -471,9 +471,9 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { split(); m_modp = nullptr; } - virtual void visit(AstNodeStmt* nodep) override { setContextAndIterateChildren(nodep); } - virtual void visit(AstCell* nodep) override { setContextAndIterateChildren(nodep); } - virtual void visit(AstAlways* nodep) override { + void visit(AstNodeStmt* nodep) override { setContextAndIterateChildren(nodep); } + void visit(AstCell* nodep) override { setContextAndIterateChildren(nodep); } + void visit(AstAlways* nodep) override { if (nodep->sensesp()) { // When visiting sensitivity list, always is the context setContextAndIterate(nodep, nodep->sensesp()); } @@ -481,7 +481,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { iterate(bodysp); } }; - virtual void visit(AstAlwaysPublic* nodep) override { + void visit(AstAlwaysPublic* nodep) override { if (nodep->sensesp()) { // When visiting sensitivity list, always is the context setContextAndIterate(nodep, nodep->sensesp()); } @@ -489,7 +489,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { iterate(bodysp); } } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { VL_RESTORER(m_contextp); { m_contextp = nodep; @@ -524,7 +524,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { } } } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { UINFO(5, nodep->modVarp()->prettyNameQ() << " pin \n"); AstNode* const exprp = nodep->exprp(); if (!exprp) return; // Not connected pin @@ -538,7 +538,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { m_foundTargetVar.clear(); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { UASSERT_OBJ(!m_inFTask, nodep, "Nested func/task"); if (!cannotSplitTaskReason(nodep)) { m_inFTask = nodep; @@ -546,7 +546,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { m_inFTask = nullptr; } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (!nodep->attrSplitVar()) return; // Nothing to do if (!cannotSplitReason(nodep)) { m_refs.registerVar(nodep); @@ -554,18 +554,18 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { } m_refsForPackedSplit[m_modp].add(nodep); } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (!nodep->varp()->attrSplitVar()) return; // Nothing to do if (m_refs.tryAdd(m_contextp, nodep, m_inFTask)) { m_foundTargetVar.insert(nodep->varp()); } m_refsForPackedSplit[m_modp].add(nodep); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { if (VN_IS(nodep->fromp(), VarRef)) m_refsForPackedSplit[m_modp].add(nodep); iterateChildren(nodep); } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { if (AstVarRef* const refp = isTargetVref(nodep->fromp())) { const AstConst* const indexp = VN_CAST(nodep->bitp(), Const); if (indexp) { // OK @@ -585,7 +585,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl { iterateChildren(nodep); } } - virtual void visit(AstSliceSel* nodep) override { + void visit(AstSliceSel* nodep) override { if (AstVarRef* const refp = isTargetVref(nodep->fromp())) { const AstUnpackArrayDType* const dtypep = VN_AS(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType); @@ -966,10 +966,10 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl { int m_numSplit = 0; // Total number of split variables // key:variable to be split. value:location where the variable is referenced. std::map m_refs; - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { if (!cannotSplitTaskReason(nodep)) iterateChildren(nodep); } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { if (!nodep->attrSplitVar()) return; // Nothing to do if (const char* const reason = cannotSplitReason(nodep, true)) { warnNoSplit(nodep, nodep, reason); @@ -979,7 +979,7 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl { if (inserted) UINFO(3, nodep->prettyNameQ() << " is added to candidate list.\n"); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { AstVar* const varp = nodep->varp(); visit(varp); const auto refit = m_refs.find(varp); @@ -993,7 +993,7 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl { UINFO(5, varp->prettyName() << " Entire bit of [" << basicp->lo() << "+:" << varp->width() << "] \n"); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { const AstVarRef* const vrefp = VN_CAST(nodep->fromp(), VarRef); if (!vrefp) { iterateChildren(nodep); @@ -1032,7 +1032,7 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl { iterateChildren(nodep); } } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } // Extract necessary bit range from a newly created variable to meet ref static AstNode* extractBits(const PackedVarRefEntry& ref, const SplitNewVar& var, diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index 97d2514b8..01d3ec2f2 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -76,7 +76,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { allNodes(nodep); if (!m_fast) { // Count all CFuncs below this module @@ -85,7 +85,7 @@ private: // Else we recursively trace fast CFuncs from the top _eval // func, see visit(AstNetlist*) } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { allNodes(nodep); iterateChildrenConst(nodep); if (m_counting && nodep->dtypep()) { @@ -111,7 +111,7 @@ private: } } } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { allNodes(nodep); iterateChildrenConst(nodep); if (m_counting) { @@ -120,7 +120,7 @@ private: } } } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { UINFO(4, " IF i=" << m_instrs << " " << nodep << endl); allNodes(nodep); // Condition is part of cost allocated to PREVIOUS block @@ -166,9 +166,9 @@ private: } } // While's we assume evaluate once. - // virtual void visit(AstWhile* nodep) override { + // void visit(AstWhile* nodep) override { - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { allNodes(nodep); iterateChildrenConst(nodep); if (m_fast && !nodep->funcp()->entryPoint()) { @@ -177,7 +177,7 @@ private: iterate(nodep->funcp()); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { if (m_fast) { if (!m_tracingCall && !nodep->entryPoint()) return; m_tracingCall = false; @@ -189,11 +189,11 @@ private: iterateChildrenConst(nodep); } } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { allNodes(nodep); iterateChildrenConst(nodep); } - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { if (m_fast && nodep->evalp()) { m_instrs = 0; m_counting = true; @@ -219,7 +219,7 @@ public: // Process iterate(nodep); } - virtual ~StatsVisitor() override { + ~StatsVisitor() override { // Done. Publish statistics V3Stats::addStat(m_stage, "Instruction count, TOTAL", m_statInstr); V3Stats::addStat(m_stage, "Instruction count, fast critical", m_statInstrFast); @@ -231,7 +231,7 @@ public: V3Stats::addStat(m_stage, "Var space, scoped, bytes", m_statVarScpBytes); } for (unsigned i = 0; i < m_statVarWidths.size(); i++) { - const double count = double(m_statVarWidths.at(i)); + const double count{m_statVarWidths.at(i)}; if (count != 0.0) { if (v3Global.opt.statsVars()) { const NameMap& nameMapr = m_statVarWidthNames.at(i); @@ -249,7 +249,7 @@ public: } // Node types for (int type = 0; type < VNType::_ENUM_END; type++) { - const double count = double(m_statTypeCount.at(type)); + const double count{m_statTypeCount.at(type)}; if (count != 0.0) { V3Stats::addStat(m_stage, std::string{"Node count, "} + VNType{type}.ascii(), count); @@ -257,18 +257,18 @@ public: } for (int type = 0; type < VNType::_ENUM_END; type++) { for (int type2 = 0; type2 < VNType::_ENUM_END; type2++) { - const double count = double(m_statAbove[type][type2]); + const double count{m_statAbove[type][type2]}; if (count != 0.0) { V3Stats::addStat(m_stage, (std::string{"Node pairs, "} + VNType{type}.ascii() + "_" - + VNType(type2).ascii()), + + VNType{type2}.ascii()), count); } } } // Branch pred for (int type = 0; type < VBranchPred::_ENUM_END; type++) { - const double count = double(m_statPred[type]); + const double count{m_statPred[type]}; if (count != 0.0) { V3Stats::addStat(m_stage, (std::string{"Branch prediction, "} + VBranchPred{type}.ascii()), diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index ad12bd812..85860e43e 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -44,6 +44,7 @@ class StatsReport final { os << "Information:\n"; os << " " << V3Options::version() << '\n'; os << " Arguments: " << v3Global.opt.allArgsString() << '\n'; + os << " Build jobs: " << v3Global.opt.buildJobs() << '\n'; os << '\n'; } diff --git a/src/V3String.cpp b/src/V3String.cpp index 1a42ee2e7..54fcfac07 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -31,7 +31,7 @@ std::map VName::s_dehashMap; // Wildcard // Double procedures, inlined, unrolls loop much better -inline bool VString::wildmatchi(const char* s, const char* p) { +bool VString::wildmatchi(const char* s, const char* p) { for (; *p; s++, p++) { if (*p != '*') { if (((*s) != (*p)) && *p != '?') return false; @@ -193,13 +193,11 @@ static const uint32_t sha256K[] 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; -static inline uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) VL_ATTR_ALWINLINE; -static inline uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) { - return lhs >> rhs | lhs << (32 - rhs); -} +VL_ATTR_ALWINLINE +static uint32_t shaRotr32(uint32_t lhs, uint32_t rhs) { return lhs >> rhs | lhs << (32 - rhs); } -static inline void sha256Block(uint32_t* h, const uint32_t* chunk) VL_ATTR_ALWINLINE; -static inline void sha256Block(uint32_t* h, const uint32_t* chunk) { +VL_ATTR_ALWINLINE +static void sha256Block(uint32_t* h, const uint32_t* chunk) { uint32_t ah[8]; const uint32_t* p = chunk; diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index ce43a7fd0..d671e23f3 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -189,7 +189,7 @@ private: return reinterpret_cast(nodep->varp()->user1p()); // Might be nullptr } // VISITORS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { const SubstVarEntry* const entryp = findEntryp(nodep); if (entryp) { // Don't sweat it. We assign a new temp variable for every new assignment, @@ -204,8 +204,8 @@ private: } } } - virtual void visit(AstConst*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstConst*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -214,7 +214,7 @@ public: UINFO(9, " SubstUseVisitor " << origStep << " " << nodep << endl); iterate(nodep); } - virtual ~SubstUseVisitor() override = default; + ~SubstUseVisitor() override = default; // METHODS bool ok() const { return m_ok; } }; @@ -255,10 +255,10 @@ private: return entryp; } } - inline bool isSubstVar(AstVar* nodep) { return nodep->isStatementTemp() && !nodep->noSubst(); } + bool isSubstVar(AstVar* nodep) { return nodep->isStatementTemp() && !nodep->noSubst(); } // VISITORS - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { m_ops = 0; m_assignStep++; iterateAndNextNull(nodep->rhsp()); @@ -304,7 +304,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); ++m_statSubsts; } - virtual void visit(AstWordSel* nodep) override { + void visit(AstWordSel* nodep) override { iterate(nodep->rhsp()); AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef); const AstConst* const constp = VN_CAST(nodep->rhsp(), Const); @@ -329,7 +329,7 @@ private: iterate(nodep->lhsp()); } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { // Any variable if (nodep->access().isWriteOrRW()) { m_assignStep++; @@ -357,16 +357,16 @@ private: } } } - virtual void visit(AstVar*) override {} - virtual void visit(AstConst*) override {} - virtual void visit(AstModule* nodep) override { + void visit(AstVar*) override {} + void visit(AstConst*) override {} + void visit(AstModule* nodep) override { ++m_ops; if (!nodep->isSubstOptimizable()) m_ops = SUBST_MAX_OPS_NA; iterateChildren(nodep); // Reduce peak memory usage by reclaiming the edited AstNodes doDeletes(); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { m_ops++; if (!nodep->isSubstOptimizable()) m_ops = SUBST_MAX_OPS_NA; iterateChildren(nodep); @@ -375,7 +375,7 @@ private: public: // CONSTRUCTORS explicit SubstVisitor(AstNode* nodep) { iterate(nodep); } - virtual ~SubstVisitor() override { + ~SubstVisitor() override { V3Stats::addStat("Optimizations, Substituted temps", m_statSubsts); for (SubstVarEntry* ip : m_entryps) { ip->deleteUnusedAssign(); diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 27d877369..26055725d 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -61,7 +61,7 @@ public: TspVertexTmpl(V3Graph* graphp, const T_Key& k) : V3GraphVertex{graphp} , m_key{k} {} - virtual ~TspVertexTmpl() override = default; + ~TspVertexTmpl() override = default; const T_Key& key() const { return m_key; } private: @@ -84,7 +84,7 @@ public: // CONSTRUCTORS TspGraphTmpl() : V3Graph{} {} - virtual ~TspGraphTmpl() override = default; + ~TspGraphTmpl() override = default; // METHODS void addVertex(const T_Key& key) { @@ -122,7 +122,7 @@ public: (new V3GraphEdge(this, tp, fp, cost))->user(userValue); } - inline static uint32_t getEdgeId(const V3GraphEdge* edgep) { + static uint32_t getEdgeId(const V3GraphEdge* edgep) { return static_cast(edgep->user()); } @@ -138,7 +138,7 @@ private: // We will keep sorted lists of edges as vectors using EdgeList = std::vector; - inline static bool edgeCmp(const V3GraphEdge* ap, const V3GraphEdge* bp) { + static bool edgeCmp(const V3GraphEdge* ap, const V3GraphEdge* bp) { // We pre-computed these when adding the edge to sort first by cost, then by identity return ap->user() > bp->user(); } @@ -150,7 +150,7 @@ private: } }; - inline static Vertex* castVertexp(V3GraphVertex* vxp) { return static_cast(vxp); } + static Vertex* castVertexp(V3GraphVertex* vxp) { return static_cast(vxp); } public: // From *this, populate *mstp with the minimum spanning tree. @@ -542,8 +542,8 @@ public: : m_xpos{xpos} , m_ypos{ypos} , m_serial{++s_serialNext} {} - virtual ~TspTestState() override = default; - virtual int cost(const TspStateBase* otherp) const override { + ~TspTestState() override = default; + int cost(const TspStateBase* otherp) const override { return cost(dynamic_cast(otherp)); } static unsigned diff(unsigned a, unsigned b) { diff --git a/src/V3Table.cpp b/src/V3Table.cpp index e1f6cc2f0..76fcb3711 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -59,12 +59,12 @@ class TableSimulateVisitor final : public SimulateVisitor { public: ///< Call other-this function on all new var references - virtual void varRefCb(AstVarRef* nodep) override; + void varRefCb(AstVarRef* nodep) override; // CONSTRUCTORS explicit TableSimulateVisitor(TableVisitor* cbthis) : m_cbthis{cbthis} {} - virtual ~TableSimulateVisitor() override = default; + ~TableSimulateVisitor() override = default; }; //###################################################################### @@ -298,8 +298,8 @@ private: uint32_t shift = 0; for (AstVarScope* invscp : m_inVarps) { // LSB is first variable, so extract it that way - const AstConst cnst(invscp->fileline(), AstConst::WidthedValue(), invscp->width(), - VL_MASK_I(invscp->width()) & (inValue >> shift)); + const AstConst cnst{invscp->fileline(), AstConst::WidthedValue{}, invscp->width(), + VL_MASK_I(invscp->width()) & (inValue >> shift)}; simvis.newValue(invscp, &cnst); shift += invscp->width(); // We are using 32 bit arithmetic, because there's no way the input table can be @@ -379,8 +379,8 @@ private: } // VISITORS - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); VL_RESTORER(m_modTables); { @@ -389,20 +389,20 @@ private: iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UINFO(4, " SCOPE " << nodep << endl); m_scopep = nodep; iterateChildren(nodep); m_scopep = nullptr; } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { UINFO(4, " ALWAYS " << nodep << endl); if (treeTest(nodep)) { // Well, then, I'll be a memory hog. replaceWithTable(nodep); } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // It's nearly impossible to have a large enough assign to make this worthwhile // For now we won't bother. // Accelerated: no iterate @@ -411,7 +411,7 @@ private: public: // CONSTRUCTORS explicit TableVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~TableVisitor() override { // + ~TableVisitor() override { // V3Stats::addStat("Optimizations, Tables created", m_statTablesCre); } }; diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 42c995865..3d6207c05 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -47,7 +47,7 @@ class TaskBaseVertex VL_NOT_FINAL : public V3GraphVertex { public: explicit TaskBaseVertex(V3Graph* graphp) : V3GraphVertex{graphp} {} - virtual ~TaskBaseVertex() override = default; + ~TaskBaseVertex() override = default; bool pure() const { return m_impurep == nullptr; } AstNode* impureNode() const { return m_impurep; } void impure(AstNode* nodep) { m_impurep = nodep; } @@ -64,10 +64,10 @@ public: TaskFTaskVertex(V3Graph* graphp, AstNodeFTask* nodep) : TaskBaseVertex{graphp} , m_nodep{nodep} {} - virtual ~TaskFTaskVertex() override = default; + ~TaskFTaskVertex() override = default; AstNodeFTask* nodep() const { return m_nodep; } - virtual string name() const override { return nodep()->name(); } - virtual string dotColor() const override { return pure() ? "black" : "red"; } + string name() const override { return nodep()->name(); } + string dotColor() const override { return pure() ? "black" : "red"; } AstCFunc* cFuncp() const { return m_cFuncp; } void cFuncp(AstCFunc* nodep) { m_cFuncp = nodep; } }; @@ -77,17 +77,17 @@ class TaskCodeVertex final : public TaskBaseVertex { public: explicit TaskCodeVertex(V3Graph* graphp) : TaskBaseVertex{graphp} {} - virtual ~TaskCodeVertex() override = default; - virtual string name() const override { return "*CODE*"; } - virtual string dotColor() const override { return "green"; } + ~TaskCodeVertex() override = default; + string name() const override { return "*CODE*"; } + string dotColor() const override { return "green"; } }; class TaskEdge final : public V3GraphEdge { public: TaskEdge(V3Graph* graphp, TaskBaseVertex* fromp, TaskBaseVertex* top) : V3GraphEdge{graphp, fromp, top, 1, false} {} - virtual ~TaskEdge() override = default; - virtual string dotLabel() const override { return "w" + cvtToStr(weight()); } + ~TaskEdge() override = default; + string dotLabel() const override { return "w" + cvtToStr(weight()); } }; //###################################################################### @@ -166,7 +166,7 @@ private: } // VISITORS - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { // Each FTask is unique per-scope, so AstNodeFTaskRefs do not need // pointers to what scope the FTask is to be invoked under. // However, to create variables, we need to track the scopes involved. @@ -186,12 +186,12 @@ private: } iterateChildren(nodep); } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { m_assignwp = nodep; VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. m_assignwp = nullptr; } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { // Includes handling AstMethodCall, AstNew if (m_assignwp) { // Wire assigns must become always statements to deal with insertion @@ -204,7 +204,7 @@ private: UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked task"); new TaskEdge(&m_callGraph, m_curVxp, getFTaskVertex(nodep->taskp())); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { UINFO(9, " TASK " << nodep << endl); { VL_RESTORER(m_curVxp); @@ -221,7 +221,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstPragma* nodep) override { + void visit(AstPragma* nodep) override { if (nodep->pragType() == VPragmaType::NO_INLINE_TASK) { // Just mark for the next steps, and we're done with it. m_curVxp->noInline(true); @@ -230,17 +230,17 @@ private: iterateChildren(nodep); } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); nodep->user4p(m_curVxp); // Remember what task it's under } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { iterateChildren(nodep); if (nodep->varp()->user4u().toGraphVertex() != m_curVxp) { if (m_curVxp->pure() && !nodep->varp()->isXTemp()) m_curVxp->impure(nodep); } } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { // Move initial statements into the constructor m_initialps.clear(); m_ctorp = nullptr; @@ -264,12 +264,12 @@ private: m_ctorp = nullptr; m_classp = nullptr; } - virtual void visit(AstInitialAutomatic* nodep) override { + void visit(AstInitialAutomatic* nodep) override { m_initialps.push_back(nodep); iterateChildren(nodep); } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -283,7 +283,7 @@ public: m_callGraph.removeRedundantEdgesSum(&TaskEdge::followAlwaysTrue); m_callGraph.dumpDotFilePrefixed("task_call"); } - virtual ~TaskStateVisitor() override = default; + ~TaskStateVisitor() override = default; VL_UNCOPYABLE(TaskStateVisitor); }; @@ -1353,7 +1353,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); VL_RESTORER(m_modNCalls); { @@ -1363,13 +1363,13 @@ private: iterateChildren(nodep); } } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { m_scopep = nodep; m_insStmtp = nullptr; iterateChildren(nodep); m_scopep = nullptr; } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { if (m_inSensesp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: function calls in sensitivity lists"); nodep->taskp(nullptr); // So V3Broken doesn't complain @@ -1428,7 +1428,7 @@ private: // Visit nodes that normal iteration won't find if (visitp) iterateAndNextNull(visitp); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { UINFO(4, " visitFTask " << nodep << endl); VL_RESTORER(m_insMode); VL_RESTORER(m_insStmtp); @@ -1496,7 +1496,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { // Special, as statements need to be put in different places // Preconditions insert first just before themselves (the normal // rule for other statement types) @@ -1513,11 +1513,11 @@ private: // Done the loop m_insStmtp = nullptr; // Next thing should be new statement } - virtual void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodeFor* nodep) override { // LCOV_EXCL_LINE nodep->v3fatalSrc( "For statements should have been converted to while statements in V3Begin.cpp"); } - virtual void visit(AstNodeStmt* nodep) override { + void visit(AstNodeStmt* nodep) override { if (!nodep->isStatement()) { iterateChildren(nodep); return; @@ -1527,14 +1527,14 @@ private: iterateChildren(nodep); m_insStmtp = nullptr; // Next thing should be new statement } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { UASSERT_OBJ(!m_inSensesp, nodep, "Senitem under senitem?"); VL_RESTORER(m_inSensesp); m_inSensesp = true; iterateChildren(nodep); } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -1542,7 +1542,7 @@ public: : m_statep{statep} { iterate(nodep); } - virtual ~TaskVisitor() override = default; + ~TaskVisitor() override = default; }; //###################################################################### diff --git a/src/V3Timing.cpp b/src/V3Timing.cpp index 7d456cc2b..73086abec 100644 --- a/src/V3Timing.cpp +++ b/src/V3Timing.cpp @@ -64,18 +64,18 @@ private: class DependencyVertex final : public V3GraphVertex { AstNode* const m_nodep; // AST node represented by this graph vertex // ACCESSORS - virtual string name() const override { + string name() const override { return cvtToHex(nodep()) + ' ' + nodep()->prettyTypeName(); } - virtual FileLine* fileline() const override { return nodep()->fileline(); } - virtual string dotColor() const override { return nodep()->user2() ? "red" : "black"; } + FileLine* fileline() const override { return nodep()->fileline(); } + string dotColor() const override { return nodep()->user2() ? "red" : "black"; } public: // CONSTRUCTORS DependencyVertex(V3Graph* graphp, AstNode* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~DependencyVertex() override = default; + ~DependencyVertex() override = default; // ACCESSORS virtual AstNode* nodep() const { return m_nodep; } @@ -317,7 +317,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UASSERT(!m_classp, "Module or class under class"); VL_RESTORER(m_classp); m_classp = VN_CAST(nodep, Class); @@ -325,23 +325,23 @@ private: m_timescaleFactor = calculateTimescaleFactor(nodep->timeunit()); iterateChildren(nodep); } - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { VL_RESTORER(m_scopep); m_scopep = nodep; iterateChildren(nodep); } - virtual void visit(AstActive* nodep) override { + void visit(AstActive* nodep) override { m_activep = nodep; iterateChildren(nodep); m_activep = nullptr; } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { VL_RESTORER(m_procp); m_procp = nodep; iterateChildren(nodep); if (nodep->user2()) nodep->setSuspendable(); } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { visit(static_cast(nodep)); if (nodep->isSuspendable() && !nodep->user1SetOnce()) { FileLine* const flp = nodep->fileline(); @@ -360,7 +360,7 @@ private: m_activep->addNextHere(activep); } } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { VL_RESTORER(m_procp); m_procp = nodep; iterateChildren(nodep); @@ -410,7 +410,7 @@ private: } } } - virtual void visit(AstNodeCCall* nodep) override { + void visit(AstNodeCCall* nodep) override { if (nodep->funcp()->user2()) { // If suspendable auto* const awaitp = new AstCAwait{nodep->fileline(), nullptr}; nodep->replaceWith(awaitp); @@ -423,11 +423,11 @@ private: } iterateChildren(nodep); } - virtual void visit(AstCAwait* nodep) override { + void visit(AstCAwait* nodep) override { v3Global.setUsesTiming(); m_procp->user2(true); } - virtual void visit(AstDelay* nodep) override { + void visit(AstDelay* nodep) override { FileLine* const flp = nodep->fileline(); AstNode* valuep = V3Const::constifyEdit(nodep->lhsp()->unlinkFrBack()); auto* const constp = VN_CAST(valuep, Const); @@ -462,7 +462,7 @@ private: nodep->replaceWith(awaitp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstEventControl* nodep) override { + void visit(AstEventControl* nodep) override { if (m_classp) nodep->v3warn(E_UNSUPPORTED, "Unsupported: event controls in methods"); auto* const sensesp = m_finder.getSenTree(nodep->sensesp()); nodep->sensesp()->unlinkFrBack()->deleteTree(); @@ -485,7 +485,7 @@ private: nodep->replaceWith(awaitp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { iterateChildren(nodep); // Only process once to avoid infinite loops (due to the net delay) if (nodep->user1SetOnce()) return; @@ -528,7 +528,7 @@ private: // Replace the RHS with an intermediate value var replaceWithIntermediate(nodep->rhsp(), m_intraValueNames.get(nodep)); } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { iterateChildren(nodep); auto* const netDelayp = getLhsNetDelay(nodep); if (!netDelayp && !nodep->timingControlp()) return; @@ -563,7 +563,7 @@ private: // var alwaysp->addNextHere(nodep); } - virtual void visit(AstWait* nodep) override { + void visit(AstWait* nodep) override { // Wait on changed events related to the vars in the wait statement AstSenItem* const senItemsp = varRefpsToSenItemsp(nodep->condp()); AstNode* const condp = nodep->condp()->unlinkFrBack(); @@ -595,7 +595,7 @@ private: } VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (nodep->user1SetOnce()) return; // Create a unique name for this fork nodep->name(m_forkNames.get(nodep)); @@ -623,8 +623,8 @@ private: } //-------------------- - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNodeMath*) override {} // Accelerate + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -633,7 +633,7 @@ public: iterate(nodep); if (debug() >= 6) m_depGraph.dumpDotFilePrefixed("timing_deps"); } - virtual ~TimingVisitor() override = default; + ~TimingVisitor() override = default; }; //###################################################################### diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 57ecce96f..4153178f3 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -73,20 +73,20 @@ public: m_activityCode = code; m_slow = false; } - virtual ~TraceActivityVertex() override = default; + ~TraceActivityVertex() override = default; // ACCESSORS AstNode* insertp() const { if (!m_insertp) v3fatalSrc("Null insertp; probably called on a special always/slow."); return m_insertp; } - virtual string name() const override { + string name() const override { if (activityAlways()) { return "*ALWAYS*"; } else { return std::string{slow() ? "*SLOW* " : ""} + insertp()->name(); } } - virtual string dotColor() const override { return slow() ? "yellowGreen" : "green"; } + string dotColor() const override { return slow() ? "yellowGreen" : "green"; } int32_t activityCode() const { return m_activityCode; } bool activityAlways() const { return activityCode() == ACTIVITY_ALWAYS; } bool activitySlow() const { return activityCode() == ACTIVITY_SLOW; } @@ -104,12 +104,12 @@ public: TraceCFuncVertex(V3Graph* graphp, AstCFunc* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~TraceCFuncVertex() override = default; + ~TraceCFuncVertex() override = default; // ACCESSORS AstCFunc* nodep() const { return m_nodep; } - virtual string name() const override { return nodep()->name(); } - virtual string dotColor() const override { return "yellow"; } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + string name() const override { return nodep()->name(); } + string dotColor() const override { return "yellow"; } + FileLine* fileline() const override { return nodep()->fileline(); } }; class TraceTraceVertex final : public V3GraphVertex { @@ -121,12 +121,12 @@ public: TraceTraceVertex(V3Graph* graphp, AstTraceDecl* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~TraceTraceVertex() override = default; + ~TraceTraceVertex() override = default; // ACCESSORS AstTraceDecl* nodep() const { return m_nodep; } - virtual string name() const override { return nodep()->name(); } - virtual string dotColor() const override { return "red"; } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + string name() const override { return nodep()->name(); } + string dotColor() const override { return "red"; } + FileLine* fileline() const override { return nodep()->fileline(); } TraceTraceVertex* duplicatep() const { return m_duplicatep; } void duplicatep(TraceTraceVertex* dupp) { UASSERT_OBJ(!duplicatep(), nodep(), "Assigning duplicatep() to already duplicated node"); @@ -141,12 +141,12 @@ public: TraceVarVertex(V3Graph* graphp, AstVarScope* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~TraceVarVertex() override = default; + ~TraceVarVertex() override = default; // ACCESSORS AstVarScope* nodep() const { return m_nodep; } - virtual string name() const override { return nodep()->name(); } - virtual string dotColor() const override { return "skyblue"; } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + string name() const override { return nodep()->name(); } + string dotColor() const override { return "skyblue"; } + FileLine* fileline() const override { return nodep()->fileline(); } }; //###################################################################### @@ -796,7 +796,7 @@ private: } // VISITORS - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { m_code = 1; // Multiple TopScopes will require fixing how code#s // are assigned as duplicate varscopes must result in the same tracing code#. @@ -811,11 +811,11 @@ private: // Create the trace functions and insert them into the tree createTraceFunctions(); } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { if (nodep->isTop()) m_topModp = nodep; iterateChildren(nodep); } - virtual void visit(AstCCall* nodep) override { + void visit(AstCCall* nodep) override { UINFO(8, " CCALL " << nodep << endl); if (!m_finding && !nodep->user2()) { // See if there are other calls in same statement list; @@ -834,7 +834,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstCFunc* nodep) override { + void visit(AstCFunc* nodep) override { UINFO(8, " CFUNC " << nodep << endl); V3GraphVertex* const funcVtxp = getCFuncVertexp(nodep); if (!m_finding) { // If public, we need a unique activity code to allow for sets @@ -853,7 +853,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstTraceDecl* nodep) override { + void visit(AstTraceDecl* nodep) override { UINFO(8, " TRACE " << nodep << endl); if (!m_finding) { V3GraphVertex* const vertexp = new TraceTraceVertex(&m_graph, nodep); @@ -865,7 +865,7 @@ private: m_tracep = nullptr; } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (m_tracep) { UASSERT_OBJ(nodep->varScopep(), nodep, "No var scope?"); UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Lvalue in trace? Should be const."); @@ -890,7 +890,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -898,7 +898,7 @@ public: : m_alwaysVtxp{new TraceActivityVertex{&m_graph, TraceActivityVertex::ACTIVITY_ALWAYS}} { iterate(nodep); } - virtual ~TraceVisitor() override { + ~TraceVisitor() override { V3Stats::addStat("Tracing, Unique traced signals", m_statUniqSigs); V3Stats::addStat("Tracing, Unique trace codes", m_statUniqCodes); } diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 4a596e434..4c8cae3a8 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -241,7 +241,7 @@ private: } // VISITORS - virtual void visit(AstScope* nodep) override { + void visit(AstScope* nodep) override { UASSERT_OBJ(!m_currScopep, nodep, "Should not nest"); UASSERT_OBJ(m_subFuncps.empty(), nodep, "Should not nest"); UASSERT_OBJ(m_signals.empty(), nodep, "Should not nest"); @@ -330,7 +330,7 @@ private: m_scopeSubFuncps.emplace(scopeName, std::move(m_subFuncps)); } } - virtual void visit(AstVarScope* nodep) override { + void visit(AstVarScope* nodep) override { UASSERT_OBJ(m_currScopep, nodep, "AstVarScope not under AstScope"); // Prefilter - things that get added to m_vscps will either get traced or get a comment as @@ -345,13 +345,13 @@ private: } // VISITORS - Data types when tracing - virtual void visit(AstConstDType* nodep) override { + void visit(AstConstDType* nodep) override { if (m_traVscp) iterate(nodep->subDTypep()->skipRefToEnump()); } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { if (m_traVscp) iterate(nodep->subDTypep()->skipRefToEnump()); } - virtual void visit(AstUnpackArrayDType* nodep) override { + void visit(AstUnpackArrayDType* nodep) override { // Note more specific dtypes above if (m_traVscp) { if (static_cast(nodep->arrayUnpackedElements()) > v3Global.opt.traceMaxArray()) { @@ -386,13 +386,13 @@ private: } } } - virtual void visit(AstPackArrayDType* nodep) override { + void visit(AstPackArrayDType* nodep) override { if (m_traVscp) { if (!v3Global.opt.traceStructs()) { // Everything downstream is packed, so deal with as one trace unit. // This may not be the nicest for user presentation, but is // a much faster way to trace - addTraceDecl(VNumRange(), nodep->width()); + addTraceDecl(VNumRange{}, nodep->width()); } else { FileLine* const flp = nodep->fileline(); AstNodeDType* const subtypep = nodep->subDTypep()->skipRefToEnump(); @@ -412,13 +412,13 @@ private: } } } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { if (m_traVscp) { if (nodep->packed() && !v3Global.opt.traceStructs()) { // Everything downstream is packed, so deal with as one trace unit // This may not be the nicest for user presentation, but is // a much faster way to trace - addTraceDecl(VNumRange(), nodep->width()); + addTraceDecl(VNumRange{}, nodep->width()); } else if (!nodep->packed()) { addIgnore("Unsupported: Unpacked struct/union"); } else { @@ -449,24 +449,24 @@ private: } } } - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { if (m_traVscp) { if (nodep->isString()) { addIgnore("Unsupported: strings"); } else { - addTraceDecl(VNumRange(), 0); + addTraceDecl(VNumRange{}, 0); } } } - virtual void visit(AstEnumDType* nodep) override { iterate(nodep->skipRefp()); } - virtual void visit(AstNodeDType*) override { + void visit(AstEnumDType* nodep) override { iterate(nodep->skipRefp()); } + void visit(AstNodeDType*) override { // Note more specific dtypes above if (!m_traVscp) return; addIgnore("Unsupported: data type"); } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -513,7 +513,7 @@ public: AstCFunc* const topFuncp = m_topFuncps.front(); topFuncp->name("trace_init_top"); } - virtual ~TraceDeclVisitor() override { + ~TraceDeclVisitor() override { V3Stats::addStat("Tracing, Traced signals", m_statSigs); V3Stats::addStat("Tracing, Ignored signals", m_statIgnSigs); } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 733d4ad74..5a04e135e 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -118,17 +118,17 @@ public: TristateVertex(V3Graph* graphp, AstNode* nodep) : V3GraphVertex{graphp} , m_nodep{nodep} {} - virtual ~TristateVertex() override = default; + ~TristateVertex() override = default; // ACCESSORS AstNode* nodep() const { return m_nodep; } const AstVar* varp() const { return VN_CAST(nodep(), Var); } - virtual string name() const override { + string name() const override { return ((isTristate() ? "tri\\n" : feedsTri() ? "feed\\n" : "-\\n") + (nodep()->prettyTypeName() + " " + cvtToHex(nodep()))); } - virtual string dotColor() const override { + string dotColor() const override { return (varp() ? (isTristate() ? "darkblue" : feedsTri() ? "blue" : "lightblue") @@ -136,7 +136,7 @@ public: : feedsTri() ? "green" : "lightgreen")); } - virtual FileLine* fileline() const override { return nodep()->fileline(); } + FileLine* fileline() const override { return nodep()->fileline(); } void isTristate(bool flag) { m_isTristate = flag; } bool isTristate() const { return m_isTristate; } void feedsTri(bool flag) { m_feedsTri = flag; } @@ -312,7 +312,7 @@ class TristatePinVisitor final : public TristateBaseVisitor { TristateGraph& m_tgraph; const bool m_lvalue; // Flip to be an LVALUE // VISITORS - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { UASSERT_OBJ(!nodep->access().isRW(), nodep, "Tristate unexpected on R/W access flip"); if (m_lvalue && !nodep->access().isWriteOrRW()) { UINFO(9, " Flip-to-LValue " << nodep << endl); @@ -325,17 +325,17 @@ class TristatePinVisitor final : public TristateBaseVisitor { m_tgraph.setTristate(nodep->varp()); } } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { // Doesn't work because we'd set lvalue on the array index's var UASSERT_OBJ(!m_lvalue, nodep, "ArraySel conversion to output, under tristate node"); iterateChildren(nodep); } - virtual void visit(AstSliceSel* nodep) override { + void visit(AstSliceSel* nodep) override { // Doesn't work because we'd set lvalue on the array index's var UASSERT_OBJ(!m_lvalue, nodep, "SliceSel conversion to output, under tristate node"); iterateChildren(nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -344,7 +344,7 @@ public: , m_lvalue{lvalue} { iterate(nodep); } - virtual ~TristatePinVisitor() override = default; + ~TristatePinVisitor() override = default; }; //###################################################################### @@ -778,7 +778,7 @@ class TristateVisitor final : public TristateBaseVisitor { } // VISITORS - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { UINFO(9, dbgState() << nodep << endl); if (m_graphing) { if (!m_alhs && nodep->num().hasZ()) m_tgraph.setTristate(nodep); @@ -811,7 +811,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstCond* nodep) override { + void visit(AstCond* nodep) override { if (m_graphing) { iterateChildren(nodep); if (m_alhs) { @@ -856,7 +856,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { if (m_graphing) { iterateChildren(nodep); if (m_alhs) { @@ -895,7 +895,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { if (m_graphing) { iterateChildren(nodep); if (m_alhs) { @@ -941,7 +941,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstBufIf1* nodep) override { + void visit(AstBufIf1* nodep) override { // For BufIf1, the enable is the LHS expression iterateChildren(nodep); UINFO(9, dbgState() << nodep << endl); @@ -1025,8 +1025,8 @@ class TristateVisitor final : public TristateBaseVisitor { expr2p->user1p(nullptr); } } - virtual void visit(AstAnd* nodep) override { visitAndOr(nodep, true); } - virtual void visit(AstOr* nodep) override { visitAndOr(nodep, false); } + void visit(AstAnd* nodep) override { visitAndOr(nodep, true); } + void visit(AstOr* nodep) override { visitAndOr(nodep, false); } void visitAssign(AstNodeAssign* nodep) { if (m_graphing) { @@ -1065,8 +1065,8 @@ class TristateVisitor final : public TristateBaseVisitor { m_alhs = false; } } - virtual void visit(AstAssignW* nodep) override { visitAssign(nodep); } - virtual void visit(AstAssign* nodep) override { visitAssign(nodep); } + void visit(AstAssignW* nodep) override { visitAssign(nodep); } + void visit(AstAssign* nodep) override { visitAssign(nodep); } void visitCaseEq(AstNodeBiop* nodep, bool neq) { if (m_graphing) { @@ -1136,12 +1136,12 @@ class TristateVisitor final : public TristateBaseVisitor { return; } } - virtual void visit(AstEqCase* nodep) override { visitCaseEq(nodep, false); } - virtual void visit(AstNeqCase* nodep) override { visitCaseEq(nodep, true); } - virtual void visit(AstEqWild* nodep) override { visitEqNeqWild(nodep); } - virtual void visit(AstNeqWild* nodep) override { visitEqNeqWild(nodep); } + void visit(AstEqCase* nodep) override { visitCaseEq(nodep, false); } + void visit(AstNeqCase* nodep) override { visitCaseEq(nodep, true); } + void visit(AstEqWild* nodep) override { visitEqNeqWild(nodep); } + void visit(AstNeqWild* nodep) override { visitEqNeqWild(nodep); } - virtual void visit(AstCountBits* nodep) override { + void visit(AstCountBits* nodep) override { std::array dropop; dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyZ(); dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyZ(); @@ -1201,7 +1201,7 @@ class TristateVisitor final : public TristateBaseVisitor { iterateChildren(nodep); } } - virtual void visit(AstPull* nodep) override { + void visit(AstPull* nodep) override { UINFO(9, dbgState() << nodep << endl); AstVarRef* varrefp = nullptr; if (VN_IS(nodep->lhsp(), VarRef)) { @@ -1276,7 +1276,7 @@ class TristateVisitor final : public TristateBaseVisitor { // __out(to-resolver-only) // const inout Spec says illegal // const output Unsupported; Illegal? - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { if (m_graphing) { if (nodep->user2() & U2_GRAPHING) return; // This pin is already expanded nodep->user2(U2_GRAPHING); @@ -1445,7 +1445,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { UINFO(9, dbgState() << nodep << endl); if (m_graphing) { if (nodep->access().isWriteOrRW()) associateLogic(nodep, nodep->varp()); @@ -1477,7 +1477,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { iterateChildren(nodep); UINFO(9, dbgState() << nodep << endl); if (m_graphing) { @@ -1510,7 +1510,7 @@ class TristateVisitor final : public TristateBaseVisitor { } } - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UINFO(8, nodep << endl); VL_RESTORER(m_modp); VL_RESTORER(m_graphing); @@ -1546,29 +1546,29 @@ class TristateVisitor final : public TristateBaseVisitor { m_tgraph.clear(); // Recursion not supported } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { // don't deal with classes } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // don't deal with functions } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { // don't deal with casez compare '???? values iterateAndNextNull(nodep->bodysp()); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { VL_RESTORER(m_cellp); m_cellp = nodep; m_alhs = false; iterateChildren(nodep); } - virtual void visit(AstNetlist* nodep) override { iterateChildrenBackwards(nodep); } + void visit(AstNetlist* nodep) override { iterateChildrenBackwards(nodep); } // Default: Just iterate - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); checkUnhandled(nodep); } @@ -1579,7 +1579,7 @@ public: m_tgraph.clear(); iterate(nodep); } - virtual ~TristateVisitor() override { + ~TristateVisitor() override { V3Stats::addStat("Tristate, Tristate resolved nets", m_statTriSigs); } }; diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 4f6374cde..1cf0f125d 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -294,7 +294,7 @@ private: } // VISITORS - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) { // For assigns and non-combo always, do just usr==1, to look // for module-wide undriven etc. @@ -315,15 +315,15 @@ private: // Discover variables used in bit definitions, etc iterateChildren(nodep); } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { // Arrays are rarely constant assigned, so for now we punt and do all entries iterateChildren(nodep); } - virtual void visit(AstSliceSel* nodep) override { + void visit(AstSliceSel* nodep) override { // Arrays are rarely constant assigned, so for now we punt and do all entries iterateChildren(nodep); } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { AstNodeVarRef* const varrefp = VN_CAST(nodep->fromp(), NodeVarRef); AstConst* const constp = VN_CAST(nodep->lsbp(), Const); if (varrefp && constp && !constp->num().isFourState()) { @@ -347,7 +347,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { // Any variable if (nodep->access().isWriteOrRW() && !VN_IS(nodep, VarXRef)) { // Ignore interface variables and similar ugly items @@ -388,7 +388,7 @@ private: } // Don't know what black boxed calls do, assume in+out - virtual void visit(AstSysIgnore* nodep) override { + void visit(AstSysIgnore* nodep) override { VL_RESTORER(m_inBBox); { m_inBBox = true; @@ -396,28 +396,28 @@ private: } } - virtual void visit(AstAssign* nodep) override { + void visit(AstAssign* nodep) override { VL_RESTORER(m_inProcAssign); { m_inProcAssign = true; iterateChildren(nodep); } } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { VL_RESTORER(m_inProcAssign); { m_inProcAssign = true; iterateChildren(nodep); } } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { VL_RESTORER(m_inContAssign); { m_inContAssign = true; iterateChildren(nodep); } } - virtual void visit(AstAlways* nodep) override { + void visit(AstAlways* nodep) override { VL_RESTORER(m_alwaysCombp); { AstNode::user2ClearTree(); @@ -432,37 +432,37 @@ private: } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { VL_RESTORER(m_taskp); { m_taskp = nodep; iterateChildren(nodep); } } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { VL_RESTORER(m_inInoutPin); m_inInoutPin = nodep->modVarp()->isInoutish(); iterateChildren(nodep); } // Until we support tables, primitives will have undriven and unused I/Os - virtual void visit(AstPrimitive*) override {} + void visit(AstPrimitive*) override {} // Coverage artifacts etc shouldn't count as a sink - virtual void visit(AstCoverDecl*) override {} - virtual void visit(AstCoverInc*) override {} - virtual void visit(AstCoverToggle*) override {} - virtual void visit(AstTraceDecl*) override {} - virtual void visit(AstTraceInc*) override {} + void visit(AstCoverDecl*) override {} + void visit(AstCoverInc*) override {} + void visit(AstCoverToggle*) override {} + void visit(AstTraceDecl*) override {} + void visit(AstTraceInc*) override {} // iterate - virtual void visit(AstConst* nodep) override {} - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstConst* nodep) override {} + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS explicit UndrivenVisitor(AstNetlist* nodep) { iterate(nodep); } - virtual ~UndrivenVisitor() override { + ~UndrivenVisitor() override { for (UndrivenVarEntry* ip : m_entryps[1]) ip->reportViolations(); for (int usr = 1; usr < 3; ++usr) { for (UndrivenVarEntry* ip : m_entryps[usr]) delete ip; diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index fec087411..61d336ba3 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -141,7 +141,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { UINFO(4, " MOD " << nodep << endl); VL_RESTORER(m_modp); VL_RESTORER(m_constXCvt); @@ -156,7 +156,7 @@ private: iterateChildren(nodep); } } - virtual void visit(AstAssignDly* nodep) override { + void visit(AstAssignDly* nodep) override { VL_RESTORER(m_assigndlyp); VL_RESTORER(m_timingControlp); { @@ -165,7 +165,7 @@ private: VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. } } - virtual void visit(AstAssignW* nodep) override { + void visit(AstAssignW* nodep) override { VL_RESTORER(m_assignwp); VL_RESTORER(m_timingControlp); { @@ -174,14 +174,14 @@ private: VL_DO_DANGLING(iterateChildren(nodep), nodep); // May delete nodep. } } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { VL_RESTORER(m_timingControlp); { m_timingControlp = nodep->timingControlp(); iterateChildren(nodep); } } - virtual void visit(AstCaseItem* nodep) override { + void visit(AstCaseItem* nodep) override { VL_RESTORER(m_constXCvt); { m_constXCvt = false; // Avoid losing the X's in casex @@ -190,7 +190,7 @@ private: iterateAndNextNull(nodep->bodysp()); } } - virtual void visit(AstNodeDType* nodep) override { + void visit(AstNodeDType* nodep) override { VL_RESTORER(m_constXCvt); { m_constXCvt = false; // Avoid losing the X's in casex @@ -269,11 +269,11 @@ private: } } - virtual void visit(AstEqCase* nodep) override { visitEqNeqCase(nodep); } - virtual void visit(AstNeqCase* nodep) override { visitEqNeqCase(nodep); } - virtual void visit(AstEqWild* nodep) override { visitEqNeqWild(nodep); } - virtual void visit(AstNeqWild* nodep) override { visitEqNeqWild(nodep); } - virtual void visit(AstIsUnknown* nodep) override { + void visit(AstEqCase* nodep) override { visitEqNeqCase(nodep); } + void visit(AstNeqCase* nodep) override { visitEqNeqCase(nodep); } + void visit(AstEqWild* nodep) override { visitEqNeqWild(nodep); } + void visit(AstNeqWild* nodep) override { visitEqNeqWild(nodep); } + void visit(AstIsUnknown* nodep) override { iterateChildren(nodep); // Ahh, we're two state, so this is easy UINFO(4, " ISUNKNOWN->0 " << nodep << endl); @@ -281,7 +281,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstCountBits* nodep) override { + void visit(AstCountBits* nodep) override { // Ahh, we're two state, so this is easy std::array dropop; dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyX(); @@ -317,7 +317,7 @@ private: } iterateChildren(nodep); } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { if (m_constXCvt && nodep->num().isFourState()) { UINFO(4, " CONST4 " << nodep << endl); if (debug() >= 9) nodep->dumpTree(cout, " Const_old: "); @@ -345,8 +345,8 @@ private: // We use the special XTEMP type so it doesn't break pure functions UASSERT_OBJ(m_modp, nodep, "X number not under module"); AstVar* const newvarp - = new AstVar(nodep->fileline(), VVarType::XTEMP, m_xrandNames.get(nodep), - VFlagLogicPacked(), nodep->width()); + = new AstVar{nodep->fileline(), VVarType::XTEMP, m_xrandNames.get(nodep), + VFlagLogicPacked{}, nodep->width()}; newvarp->lifetime(VLifetime::STATIC); ++m_statUnkVars; VNRelinker replaceHandle; @@ -378,7 +378,7 @@ private: } } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { iterateChildren(nodep); if (!nodep->user1SetOnce()) { // Guard against reading/writing past end of bit vector array @@ -425,7 +425,7 @@ private: // visit(AstSliceSel) not needed as its bounds are constant and checked // in V3Width. - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { iterateChildren(nodep); if (!nodep->user1SetOnce()) { if (debug() == 9) nodep->dumpTree(cout, "-in: "); @@ -468,7 +468,7 @@ private: nodep->unlinkFrBack(&replaceHandle); V3Number xnum(nodep, nodep->width()); if (nodep->isString()) { - xnum = V3Number(V3Number::String(), nodep, ""); + xnum = V3Number{V3Number::String{}, nodep, ""}; } else { xnum.setAllBitsX(); } @@ -496,7 +496,7 @@ private: } } //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS @@ -505,7 +505,7 @@ public: , m_xrandNames{"__Vxrand"} { iterate(nodep); } - virtual ~UnknownVisitor() override { // + ~UnknownVisitor() override { // V3Stats::addStat("Unknowns, variables created", m_statUnkVars); } }; diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 0b47ce518..8c9bf96dd 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -371,7 +371,7 @@ private: return true; } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { iterateChildren(nodep); if (m_varModeCheck || m_varModeReplace) { } else { @@ -406,7 +406,7 @@ private: } } } - virtual void visit(AstGenFor* nodep) override { + void visit(AstGenFor* nodep) override { if (!m_generate || m_varModeReplace) { iterateChildren(nodep); } // else V3Param will recursively call each for loop to be unrolled for us @@ -433,7 +433,7 @@ private: } } } - virtual void visit(AstNodeFor* nodep) override { + void visit(AstNodeFor* nodep) override { if (m_generate) { // Ignore for's when expanding genfor's iterateChildren(nodep); } else { @@ -441,7 +441,7 @@ private: } } - virtual void visit(AstVarRef* nodep) override { + void visit(AstVarRef* nodep) override { if (m_varModeCheck && nodep->varp() == m_forVarp && nodep->varScopep() == m_forVscp && nodep->access().isWriteOrRW()) { UINFO(8, " Itervar assigned to: " << nodep << endl); @@ -458,7 +458,7 @@ private: //-------------------- // Default: Just iterate - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { if (m_varModeCheck && nodep == m_ignoreIncp) { // Ignore subtree that is the increment } else { @@ -469,7 +469,7 @@ private: public: // CONSTRUCTORS UnrollVisitor() { init(false, ""); } - virtual ~UnrollVisitor() override { + ~UnrollVisitor() override { V3Stats::addStatSum("Optimizations, Unrolled Loops", m_statLoops); V3Stats::addStatSum("Optimizations, Unrolled Iterations", m_statIters); } diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index d3ea7aa3d..5bd51933d 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -51,12 +51,12 @@ public: } ~VarTspSorter() override = default; // METHODS - virtual bool operator<(const TspStateBase& other) const override { + bool operator<(const TspStateBase& other) const override { return operator<(static_cast(other)); } bool operator<(const VarTspSorter& other) const { return m_serial < other.m_serial; } const MTaskIdSet& mtaskIds() const { return m_mtaskIds; } - virtual int cost(const TspStateBase* otherp) const override { + int cost(const TspStateBase* otherp) const override { return cost(static_cast(otherp)); } int cost(const VarTspSorter* otherp) const { diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 1e625d4f7..48673f857 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -250,123 +250,119 @@ private: // _Ox=anything // Widths: 1 bit out, lhs 1 bit; Real: converts via compare with 0 - virtual void visit(AstLogNot* nodep) override { visit_log_not(nodep); } + void visit(AstLogNot* nodep) override { visit_log_not(nodep); } // Widths: 1 bit out, lhs 1 bit, rhs 1 bit; Real: converts via compare with 0 - virtual void visit(AstLogAnd* nodep) override { visit_log_and_or(nodep); } - virtual void visit(AstLogOr* nodep) override { visit_log_and_or(nodep); } - virtual void visit(AstLogEq* nodep) override { + void visit(AstLogAnd* nodep) override { visit_log_and_or(nodep); } + void visit(AstLogOr* nodep) override { visit_log_and_or(nodep); } + void visit(AstLogEq* nodep) override { // Conversion from real not in IEEE, but a fallout visit_log_and_or(nodep); } - virtual void visit(AstLogIf* nodep) override { + void visit(AstLogIf* nodep) override { // Conversion from real not in IEEE, but a fallout visit_log_and_or(nodep); } // Widths: 1 bit out, Any width lhs - virtual void visit(AstRedAnd* nodep) override { visit_red_and_or(nodep); } - virtual void visit(AstRedOr* nodep) override { visit_red_and_or(nodep); } - virtual void visit(AstRedXor* nodep) override { visit_red_and_or(nodep); } - virtual void visit(AstOneHot* nodep) override { visit_red_and_or(nodep); } - virtual void visit(AstOneHot0* nodep) override { visit_red_and_or(nodep); } - virtual void visit(AstIsUnknown* nodep) override { + void visit(AstRedAnd* nodep) override { visit_red_and_or(nodep); } + void visit(AstRedOr* nodep) override { visit_red_and_or(nodep); } + void visit(AstRedXor* nodep) override { visit_red_and_or(nodep); } + void visit(AstOneHot* nodep) override { visit_red_and_or(nodep); } + void visit(AstOneHot0* nodep) override { visit_red_and_or(nodep); } + void visit(AstIsUnknown* nodep) override { visit_red_unknown(nodep); // Allow real } // These have different node types, as they operate differently // Must add to case statement below, // Widths: 1 bit out, lhs width == rhs width. real if lhs|rhs real - virtual void visit(AstEq* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstNeq* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstGt* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstGte* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstLt* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstLte* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstGtS* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstGteS* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstLtS* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstLteS* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstEqCase* nodep) override { visit_cmp_eq_gt(nodep, true); } - virtual void visit(AstNeqCase* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstEq* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstNeq* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstGt* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstGte* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstLt* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstLte* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstGtS* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstGteS* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstLtS* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstLteS* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstEqCase* nodep) override { visit_cmp_eq_gt(nodep, true); } + void visit(AstNeqCase* nodep) override { visit_cmp_eq_gt(nodep, true); } // ... These comparisons don't allow reals - virtual void visit(AstEqWild* nodep) override { visit_cmp_eq_gt(nodep, false); } - virtual void visit(AstNeqWild* nodep) override { visit_cmp_eq_gt(nodep, false); } + void visit(AstEqWild* nodep) override { visit_cmp_eq_gt(nodep, false); } + void visit(AstNeqWild* nodep) override { visit_cmp_eq_gt(nodep, false); } // ... Real compares - virtual void visit(AstEqD* nodep) override { visit_cmp_real(nodep); } - virtual void visit(AstNeqD* nodep) override { visit_cmp_real(nodep); } - virtual void visit(AstLtD* nodep) override { visit_cmp_real(nodep); } - virtual void visit(AstLteD* nodep) override { visit_cmp_real(nodep); } - virtual void visit(AstGtD* nodep) override { visit_cmp_real(nodep); } - virtual void visit(AstGteD* nodep) override { visit_cmp_real(nodep); } + void visit(AstEqD* nodep) override { visit_cmp_real(nodep); } + void visit(AstNeqD* nodep) override { visit_cmp_real(nodep); } + void visit(AstLtD* nodep) override { visit_cmp_real(nodep); } + void visit(AstLteD* nodep) override { visit_cmp_real(nodep); } + void visit(AstGtD* nodep) override { visit_cmp_real(nodep); } + void visit(AstGteD* nodep) override { visit_cmp_real(nodep); } // ... String compares - virtual void visit(AstEqN* nodep) override { visit_cmp_string(nodep); } - virtual void visit(AstNeqN* nodep) override { visit_cmp_string(nodep); } - virtual void visit(AstLtN* nodep) override { visit_cmp_string(nodep); } - virtual void visit(AstLteN* nodep) override { visit_cmp_string(nodep); } - virtual void visit(AstGtN* nodep) override { visit_cmp_string(nodep); } - virtual void visit(AstGteN* nodep) override { visit_cmp_string(nodep); } + void visit(AstEqN* nodep) override { visit_cmp_string(nodep); } + void visit(AstNeqN* nodep) override { visit_cmp_string(nodep); } + void visit(AstLtN* nodep) override { visit_cmp_string(nodep); } + void visit(AstLteN* nodep) override { visit_cmp_string(nodep); } + void visit(AstGtN* nodep) override { visit_cmp_string(nodep); } + void visit(AstGteN* nodep) override { visit_cmp_string(nodep); } // Widths: out width = lhs width = rhs width // Signed: Output signed iff LHS & RHS signed. // Real: Not allowed - virtual void visit(AstAnd* nodep) override { visit_boolmath_and_or(nodep); } - virtual void visit(AstOr* nodep) override { visit_boolmath_and_or(nodep); } - virtual void visit(AstXor* nodep) override { visit_boolmath_and_or(nodep); } - virtual void visit(AstBufIf1* nodep) override { + void visit(AstAnd* nodep) override { visit_boolmath_and_or(nodep); } + void visit(AstOr* nodep) override { visit_boolmath_and_or(nodep); } + void visit(AstXor* nodep) override { visit_boolmath_and_or(nodep); } + void visit(AstBufIf1* nodep) override { visit_boolmath_and_or(nodep); } // Signed behavior changing in 3.814 // Width: Max(Lhs,Rhs) sort of. // Real: If either side real // Signed: If both sides real - virtual void visit(AstAdd* nodep) override { visit_add_sub_replace(nodep, true); } - virtual void visit(AstSub* nodep) override { visit_add_sub_replace(nodep, true); } - virtual void visit(AstDiv* nodep) override { visit_add_sub_replace(nodep, true); } - virtual void visit(AstMul* nodep) override { visit_add_sub_replace(nodep, true); } + void visit(AstAdd* nodep) override { visit_add_sub_replace(nodep, true); } + void visit(AstSub* nodep) override { visit_add_sub_replace(nodep, true); } + void visit(AstDiv* nodep) override { visit_add_sub_replace(nodep, true); } + void visit(AstMul* nodep) override { visit_add_sub_replace(nodep, true); } // These can't promote to real - virtual void visit(AstModDiv* nodep) override { visit_add_sub_replace(nodep, false); } - virtual void visit(AstModDivS* nodep) override { visit_add_sub_replace(nodep, false); } - virtual void visit(AstMulS* nodep) override { visit_add_sub_replace(nodep, false); } - virtual void visit(AstDivS* nodep) override { visit_add_sub_replace(nodep, false); } + void visit(AstModDiv* nodep) override { visit_add_sub_replace(nodep, false); } + void visit(AstModDivS* nodep) override { visit_add_sub_replace(nodep, false); } + void visit(AstMulS* nodep) override { visit_add_sub_replace(nodep, false); } + void visit(AstDivS* nodep) override { visit_add_sub_replace(nodep, false); } // Widths: out width = lhs width, but upper matters // Signed: Output signed iff LHS signed; unary operator // Unary promote to real - virtual void visit(AstNegate* nodep) override { visit_negate_not(nodep, true); } + void visit(AstNegate* nodep) override { visit_negate_not(nodep, true); } // Unary never real - virtual void visit(AstNot* nodep) override { visit_negate_not(nodep, false); } + void visit(AstNot* nodep) override { visit_negate_not(nodep, false); } // Real: inputs and output real - virtual void visit(AstAddD* nodep) override { visit_real_add_sub(nodep); } - virtual void visit(AstSubD* nodep) override { visit_real_add_sub(nodep); } - virtual void visit(AstDivD* nodep) override { visit_real_add_sub(nodep); } - virtual void visit(AstMulD* nodep) override { visit_real_add_sub(nodep); } - virtual void visit(AstPowD* nodep) override { visit_real_add_sub(nodep); } - virtual void visit(AstNodeSystemBiop* nodep) override { visit_real_add_sub(nodep); } + void visit(AstAddD* nodep) override { visit_real_add_sub(nodep); } + void visit(AstSubD* nodep) override { visit_real_add_sub(nodep); } + void visit(AstDivD* nodep) override { visit_real_add_sub(nodep); } + void visit(AstMulD* nodep) override { visit_real_add_sub(nodep); } + void visit(AstPowD* nodep) override { visit_real_add_sub(nodep); } + void visit(AstNodeSystemBiop* nodep) override { visit_real_add_sub(nodep); } // Real: Output real - virtual void visit(AstNegateD* nodep) override { visit_real_neg_ceil(nodep); } - virtual void visit(AstNodeSystemUniop* nodep) override { visit_real_neg_ceil(nodep); } + void visit(AstNegateD* nodep) override { visit_real_neg_ceil(nodep); } + void visit(AstNodeSystemUniop* nodep) override { visit_real_neg_ceil(nodep); } // Widths: out signed/unsigned width = lhs width, input un|signed - virtual void visit(AstSigned* nodep) override { - visit_signed_unsigned(nodep, VSigning::SIGNED); - } - virtual void visit(AstUnsigned* nodep) override { - visit_signed_unsigned(nodep, VSigning::UNSIGNED); - } + void visit(AstSigned* nodep) override { visit_signed_unsigned(nodep, VSigning::SIGNED); } + void visit(AstUnsigned* nodep) override { visit_signed_unsigned(nodep, VSigning::UNSIGNED); } // Widths: Output width from lhs, rhs<33 bits // Signed: If lhs signed - virtual void visit(AstShiftL* nodep) override { visit_shift(nodep); } - virtual void visit(AstShiftR* nodep) override { visit_shift(nodep); } + void visit(AstShiftL* nodep) override { visit_shift(nodep); } + void visit(AstShiftR* nodep) override { visit_shift(nodep); } // ShiftRS converts to ShiftR, but not vice-versa - virtual void visit(AstShiftRS* nodep) override { visit_shift(nodep); } + void visit(AstShiftRS* nodep) override { visit_shift(nodep); } //======== // Widths: Output real, input integer signed - virtual void visit(AstBitsToRealD* nodep) override { visit_Or_Lu64(nodep); } + void visit(AstBitsToRealD* nodep) override { visit_Or_Lu64(nodep); } // Widths: Output integer signed, input real - virtual void visit(AstRToIS* nodep) override { visit_Os32_Lr(nodep); } - virtual void visit(AstRToIRoundS* nodep) override { + void visit(AstRToIS* nodep) override { visit_Os32_Lr(nodep); } + void visit(AstRToIRoundS* nodep) override { // Only created here, size comes from upper expression if (m_vup->prelim()) { // First stage evaluation iterateCheckReal(nodep, "LHS", nodep->lhsp(), BOTH); @@ -375,11 +371,11 @@ private: } // Widths: Output integer unsigned, input real - virtual void visit(AstRealToBits* nodep) override { visit_Ou64_Lr(nodep); } + void visit(AstRealToBits* nodep) override { visit_Ou64_Lr(nodep); } // Output integer, input string - virtual void visit(AstLenN* nodep) override { visit_Os32_string(nodep); } - virtual void visit(AstPutcN* nodep) override { + void visit(AstLenN* nodep) override { visit_Os32_string(nodep); } + void visit(AstPutcN* nodep) override { // CALLER: str.putc() UASSERT_OBJ(nodep->rhsp() && nodep->thsp(), nodep, "For ternary ops only!"); if (m_vup && m_vup->prelim()) { @@ -391,7 +387,7 @@ private: // AstAssign } } - virtual void visit(AstGetcN* nodep) override { + void visit(AstGetcN* nodep) override { // CALLER: str.getc() UASSERT_OBJ(nodep->rhsp(), nodep, "For binary ops only!"); if (m_vup && m_vup->prelim()) { @@ -401,7 +397,7 @@ private: nodep->dtypeSetBitSized(8, VSigning::UNSIGNED); } } - virtual void visit(AstGetcRefN* nodep) override { + void visit(AstGetcRefN* nodep) override { // CALLER: str.getc() UASSERT_OBJ(nodep->rhsp(), nodep, "For binary ops only!"); if (m_vup && m_vup->prelim()) { @@ -411,7 +407,7 @@ private: nodep->dtypeSetBitSized(8, VSigning::UNSIGNED); } } - virtual void visit(AstSubstrN* nodep) override { + void visit(AstSubstrN* nodep) override { // CALLER: str.substr() UASSERT_OBJ(nodep->rhsp() && nodep->thsp(), nodep, "For ternary ops only!"); if (m_vup && m_vup->prelim()) { @@ -422,7 +418,7 @@ private: nodep->dtypeSetString(); } } - virtual void visit(AstCompareNN* nodep) override { + void visit(AstCompareNN* nodep) override { // CALLER: str.compare(), str.icompare() // Widths: 32 bit out UASSERT_OBJ(nodep->rhsp(), nodep, "For binary ops only!"); @@ -433,7 +429,7 @@ private: nodep->dtypeSetSigned32(); } } - virtual void visit(AstAtoN* nodep) override { + void visit(AstAtoN* nodep) override { // CALLER: str.atobin(), atoi(), atohex(), atooct(), atoreal() // Width: 64bit floating point for atoreal(), 32bit out for the others if (m_vup->prelim()) { @@ -448,13 +444,13 @@ private: } // Widths: Constant, terminal - virtual void visit(AstTime* nodep) override { nodep->dtypeSetUInt64(); } - virtual void visit(AstTimeD* nodep) override { nodep->dtypeSetDouble(); } - virtual void visit(AstScopeName* nodep) override { + void visit(AstTime* nodep) override { nodep->dtypeSetUInt64(); } + void visit(AstTimeD* nodep) override { nodep->dtypeSetDouble(); } + void visit(AstScopeName* nodep) override { nodep->dtypeSetUInt64(); // A pointer, but not that it matters } - virtual void visit(AstNodeCond* nodep) override { + void visit(AstNodeCond* nodep) override { // op = cond ? expr1 : expr2 // See IEEE-2012 11.4.11 and Table 11-21. // LHS is self-determined @@ -496,7 +492,7 @@ private: EXTEND_EXP); } } - virtual void visit(AstConcat* nodep) override { + void visit(AstConcat* nodep) override { // Real: Not allowed (assumed) // Signed: unsigned output, input either (assumed) // IEEE-2012 Table 11-21, and 11.8.1: @@ -579,7 +575,7 @@ private: } } } - virtual void visit(AstConcatN* nodep) override { + void visit(AstConcatN* nodep) override { // String concatenate. // Already did AstConcat simplifications if (m_vup->prelim()) { @@ -595,7 +591,7 @@ private: } } } - virtual void visit(AstDelay* nodep) override { + void visit(AstDelay* nodep) override { if (VN_IS(m_procedurep, Final)) { nodep->v3error("Delays are not legal in final blocks (IEEE 1800-2017 9.2.3)"); VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); @@ -623,7 +619,7 @@ private: if (nodep->stmtsp()) nodep->addNextHere(nodep->stmtsp()->unlinkFrBack()); VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); } - virtual void visit(AstFork* nodep) override { + void visit(AstFork* nodep) override { if (VN_IS(m_ftaskp, Func) && !nodep->joinType().joinNone()) { nodep->v3error("Only fork .. join_none is legal in functions. " "(IEEE 1800-2017 13.4.4)"); @@ -653,27 +649,27 @@ private: "Use --timing or --no-timing to specify how forks should be handled"); } } - virtual void visit(AstDisableFork* nodep) override { + void visit(AstDisableFork* nodep) override { nodep->v3warn(E_UNSUPPORTED, "Unsupported: disable fork statements"); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstWaitFork* nodep) override { + void visit(AstWaitFork* nodep) override { nodep->v3warn(E_UNSUPPORTED, "Unsupported: wait fork statements"); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstToLowerN* nodep) override { + void visit(AstToLowerN* nodep) override { if (m_vup->prelim()) { iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); nodep->dtypeSetString(); } } - virtual void visit(AstToUpperN* nodep) override { + void visit(AstToUpperN* nodep) override { if (m_vup->prelim()) { iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); nodep->dtypeSetString(); } } - virtual void visit(AstReplicate* nodep) override { + void visit(AstReplicate* nodep) override { // IEEE-2012 Table 11-21: // LHS, RHS is self-determined // width: value(LHS) * width(RHS) @@ -734,7 +730,7 @@ private: } } } - virtual void visit(AstReplicateN* nodep) override { + void visit(AstReplicateN* nodep) override { // Replicate with string if (m_vup->prelim()) { iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); @@ -761,7 +757,7 @@ private: } } } - virtual void visit(AstNodeStream* nodep) override { + void visit(AstNodeStream* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); @@ -794,7 +790,7 @@ private: } } } - virtual void visit(AstRange* nodep) override { + void visit(AstRange* nodep) override { // Real: Not allowed // Signed: unsigned output, input either // Convert all range values to constants @@ -820,7 +816,7 @@ private: } } - virtual void visit(AstSel* nodep) override { + void visit(AstSel* nodep) override { // Signed: always unsigned; Real: Not allowed // LSB is self-determined (IEEE 2012 11.5.1) // We also use SELs to shorten a signed constant etc, in this case they are signed. @@ -927,7 +923,7 @@ private: } } - virtual void visit(AstArraySel* nodep) override { + void visit(AstArraySel* nodep) override { // Signed/Real: Output signed iff LHS signed/real; binary operator // Note by contrast, bit extract selects are unsigned // LSB is self-determined (IEEE 2012 11.5.1) @@ -989,7 +985,7 @@ private: } } - virtual void visit(AstAssocSel* nodep) override { + void visit(AstAssocSel* nodep) override { // Signed/Real: Output type based on array-declared type; binary operator if (m_vup->prelim()) { const AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); @@ -1004,7 +1000,7 @@ private: } } - virtual void visit(AstWildcardSel* nodep) override { + void visit(AstWildcardSel* nodep) override { // Signed/Real: Output type based on array-declared type; binary operator if (m_vup->prelim()) { const AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); @@ -1025,7 +1021,7 @@ private: } } - virtual void visit(AstSliceSel* nodep) override { + void visit(AstSliceSel* nodep) override { // Always creates as output an unpacked array if (m_vup->prelim()) { userIterateAndNext(nodep->fromp(), WidthVP(SELF, BOTH).p()); @@ -1069,7 +1065,7 @@ private: } } - virtual void visit(AstSelBit* nodep) override { + void visit(AstSelBit* nodep) override { // Just a quick check as after V3Param these nodes instead are AstSel's userIterateAndNext(nodep->fromp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel @@ -1083,7 +1079,7 @@ private: } nodep->v3fatalSrc("AstSelBit should disappear after widthSel"); } - virtual void visit(AstSelExtract* nodep) override { + void visit(AstSelExtract* nodep) override { // Just a quick check as after V3Param these nodes instead are AstSel's userIterateAndNext(nodep->fromp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel @@ -1097,7 +1093,7 @@ private: } nodep->v3fatalSrc("AstSelExtract should disappear after widthSel"); } - virtual void visit(AstSelPlus* nodep) override { + void visit(AstSelPlus* nodep) override { userIterateAndNext(nodep->fromp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel @@ -1110,7 +1106,7 @@ private: } nodep->v3fatalSrc("AstSelPlus should disappear after widthSel"); } - virtual void visit(AstSelMinus* nodep) override { + void visit(AstSelMinus* nodep) override { userIterateAndNext(nodep->fromp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel @@ -1124,13 +1120,13 @@ private: nodep->v3fatalSrc("AstSelMinus should disappear after widthSel"); } - virtual void visit(AstExtend* nodep) override { + void visit(AstExtend* nodep) override { // Only created by this process, so we know width from here down is correct. } - virtual void visit(AstExtendS* nodep) override { + void visit(AstExtendS* nodep) override { // Only created by this process, so we know width from here down is correct. } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { // The node got setup with the signed/real state of the node. // However a later operation may have changed the node->signed w/o changing // the number's sign. So we don't: nodep->dtypeChgSigned(nodep->num().isSigned()); @@ -1146,20 +1142,20 @@ private: // We don't size the constant until we commit the widths, as need parameters // to remain unsized, and numbers to remain unsized to avoid backp() warnings } - virtual void visit(AstEmptyQueue* nodep) override { + void visit(AstEmptyQueue* nodep) override { nodep->dtypeSetEmptyQueue(); if (!VN_IS(nodep->backp(), Assign)) { nodep->v3warn(E_UNSUPPORTED, "Unsupported/Illegal: empty queue ('{}') in this context"); } } - virtual void visit(AstFell* nodep) override { + void visit(AstFell* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); nodep->dtypeSetBit(); } } - virtual void visit(AstPast* nodep) override { + void visit(AstPast* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); nodep->dtypeFrom(nodep->exprp()); @@ -1183,28 +1179,28 @@ private: } } } - virtual void visit(AstRose* nodep) override { + void visit(AstRose* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); nodep->dtypeSetBit(); } } - virtual void visit(AstSampled* nodep) override { + void visit(AstSampled* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); nodep->dtypeFrom(nodep->exprp()); } } - virtual void visit(AstStable* nodep) override { + void visit(AstStable* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); nodep->dtypeSetBit(); } } - virtual void visit(AstImplication* nodep) override { + void visit(AstImplication* nodep) override { if (m_vup->prelim()) { iterateCheckBool(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckBool(nodep, "RHS", nodep->rhsp(), BOTH); @@ -1212,7 +1208,7 @@ private: } } - virtual void visit(AstRand* nodep) override { + void visit(AstRand* nodep) override { if (m_vup->prelim()) { if (nodep->urandom()) { nodep->dtypeSetUInt32(); // Says the spec @@ -1222,7 +1218,7 @@ private: if (nodep->seedp()) iterateCheckSigned32(nodep, "seed", nodep->seedp(), BOTH); } } - virtual void visit(AstURandomRange* nodep) override { + void visit(AstURandomRange* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetUInt32(); // Says the spec AstNodeDType* const expDTypep = nodep->findUInt32DType(); @@ -1232,7 +1228,7 @@ private: iterateCheck(nodep, "RHS", nodep->rhsp(), SELF, FINAL, expDTypep, EXTEND_EXP); } } - virtual void visit(AstUnbounded* nodep) override { + void visit(AstUnbounded* nodep) override { nodep->dtypeSetSigned32(); // Used in int context if (VN_IS(nodep->backp(), IsUnbounded)) return; // Ok, leave if (VN_IS(nodep->backp(), BracketArrayDType)) return; // Ok, leave @@ -1250,13 +1246,13 @@ private: } nodep->v3warn(E_UNSUPPORTED, "Unsupported/illegal unbounded ('$') in this context."); } - virtual void visit(AstIsUnbounded* nodep) override { + void visit(AstIsUnbounded* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); nodep->dtypeSetBit(); } } - virtual void visit(AstUCFunc* nodep) override { + void visit(AstUCFunc* nodep) override { // Give it the size the user wants. if (m_vup && m_vup->prelim()) { nodep->dtypeSetLogicUnsized(32, 1, VSigning::UNSIGNED); // We don't care @@ -1271,10 +1267,10 @@ private: } } } - virtual void visit(AstCLog2* nodep) override { + void visit(AstCLog2* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); } } - virtual void visit(AstPow* nodep) override { + void visit(AstPow* nodep) override { // Pow is special, output sign only depends on LHS sign, but // function result depends on both signs // RHS is self-determined (IEEE) @@ -1318,25 +1314,25 @@ private: } } } - virtual void visit(AstPowSU* nodep) override { + void visit(AstPowSU* nodep) override { // POWSU/SS/US only created here, dtype already determined, so // nothing to do in this function userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->rhsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstPowSS* nodep) override { + void visit(AstPowSS* nodep) override { // POWSU/SS/US only created here, dtype already determined, so // nothing to do in this function userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->rhsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstPowUS* nodep) override { + void visit(AstPowUS* nodep) override { // POWSU/SS/US only created here, dtype already determined, so // nothing to do in this function userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->rhsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstCountBits* nodep) override { + void visit(AstCountBits* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); @@ -1348,7 +1344,7 @@ private: VSigning::UNSIGNED); // Spec doesn't indicate if an integer } } - virtual void visit(AstCountOnes* nodep) override { + void visit(AstCountOnes* nodep) override { if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); // If it's a 32 bit number, we need a 6 bit number as we need to return '32'. @@ -1357,12 +1353,12 @@ private: VSigning::UNSIGNED); // Spec doesn't indicate if an integer } } - virtual void visit(AstCvtPackString* nodep) override { + void visit(AstCvtPackString* nodep) override { // Opaque returns, so arbitrary userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); // Type set in constructor } - virtual void visit(AstTimeImport* nodep) override { + void visit(AstTimeImport* nodep) override { // LHS is a real number in seconds // Need to round to time units and precision userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); @@ -1377,7 +1373,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstEventControl* nodep) override { + void visit(AstEventControl* nodep) override { if (VN_IS(m_ftaskp, Func)) { nodep->v3error("Event controls are not legal in functions. Suggest use a task " "(IEEE 1800-2017 13.4.4)"); @@ -1402,7 +1398,7 @@ private: if (nodep->stmtsp()) nodep->addNextHere(nodep->stmtsp()->unlinkFrBack()); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } - virtual void visit(AstAttrOf* nodep) override { + void visit(AstAttrOf* nodep) override { VL_RESTORER(m_attrp); m_attrp = nodep; userIterateAndNext(nodep->fromp(), WidthVP(SELF, BOTH).p()); @@ -1535,16 +1531,16 @@ private: } } } - virtual void visit(AstPull* nodep) override { + void visit(AstPull* nodep) override { // May have select underneath, let seek natural size userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } - virtual void visit(AstText* nodep) override { + void visit(AstText* nodep) override { // Only used in CStmts which don't care.... } // DTYPES - virtual void visit(AstNodeArrayDType* nodep) override { + void visit(AstNodeArrayDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed if (nodep->subDTypep() == nodep->basicp()) { // Innermost dimension @@ -1575,7 +1571,7 @@ private: } UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstAssocArrayDType* nodep) override { + void visit(AstAssocArrayDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -1583,7 +1579,7 @@ private: nodep->dtypep(nodep); // The array itself, not subDtype UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstBracketArrayDType* nodep) override { + void visit(AstBracketArrayDType* nodep) override { // Type inserted only because parser didn't know elementsp() type // Resolve elementsp's type userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); @@ -1612,14 +1608,14 @@ private: // visit VL_DO_DANGLING(userIterate(newp, nullptr), newp); } - virtual void visit(AstDynArrayDType* nodep) override { + void visit(AstDynArrayDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); nodep->dtypep(nodep); // The array itself, not subDtype UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstQueueDType* nodep) override { + void visit(AstQueueDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -1629,12 +1625,12 @@ private: } UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstVoidDType* nodep) override { + void visit(AstVoidDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed nodep->dtypep(nodep); UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstUnsizedArrayDType* nodep) override { + void visit(AstUnsizedArrayDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -1642,7 +1638,7 @@ private: nodep->dtypep(nodep); // The array itself, not subDtype UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstWildcardArrayDType* nodep) override { + void visit(AstWildcardArrayDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -1650,7 +1646,7 @@ private: nodep->dtypep(nodep); // The array itself, not subDtype UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstBasicDType* nodep) override { + void visit(AstBasicDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed if (nodep->generic()) return; // Already perfect if (nodep->rangep()) { @@ -1673,7 +1669,7 @@ private: // dtype Instead for now doing this in V3WidthCommit UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstConstDType* nodep) override { + void visit(AstConstDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -1682,7 +1678,7 @@ private: nodep->widthFromSub(nodep->subDTypep()); UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstRefDType* nodep) override { + void visit(AstRefDType* nodep) override { if (nodep->doingWidth()) { // Early exit if have circular parameter definition nodep->v3error("Typedef's type is circular: " << nodep->prettyName()); nodep->dtypeSetBit(); @@ -1720,7 +1716,7 @@ private: UINFO(4, "dtWidthed " << nodep << endl); nodep->doingWidth(false); } - virtual void visit(AstTypedef* nodep) override { + void visit(AstTypedef* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed if (auto* const refp = checkRefToTypedefRecurse(nodep, nodep)) { nodep->v3error("Typedef has self-reference: " << nodep->prettyNameQ() << '\n' @@ -1736,13 +1732,13 @@ private: nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); userIterateChildren(nodep, nullptr); } - virtual void visit(AstParamTypeDType* nodep) override { + void visit(AstParamTypeDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); userIterateChildren(nodep, nullptr); nodep->widthFromSub(nodep->subDTypep()); } - virtual void visit(AstCastDynamic* nodep) override { + void visit(AstCastDynamic* nodep) override { nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); AstNodeDType* const toDtp = nodep->top()->dtypep()->skipRefToEnump(); @@ -1817,7 +1813,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); userIterate(newp, m_vup); } - virtual void visit(AstCastParse* nodep) override { + void visit(AstCastParse* nodep) override { // nodep->dtp could be data type, or a primary_constant // Don't iterate lhsp, will deal with that once convert the type V3Const::constifyParamsEdit(nodep->dtp()); // itemp may change @@ -1834,7 +1830,7 @@ private: nodep->replaceWith(nodep->lhsp()->unlinkFrBack()); } } - virtual void visit(AstCast* nodep) override { + void visit(AstCast* nodep) override { nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); if (m_vup->prelim()) { // if (debug()) nodep->dumpTree(cout, " CastPre: "); @@ -1921,7 +1917,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstCastSize* nodep) override { + void visit(AstCastSize* nodep) override { // IEEE: Signedness of result is same as self-determined signedness // However, the result is same as BITSEL, so we do not sign extend the LHS UASSERT_OBJ(VN_IS(nodep->rhsp(), Const), nodep, "Unsupported: Non-const cast of size"); @@ -1981,7 +1977,7 @@ private: VL_DANGLING(underp); } } - virtual void visit(AstVar* nodep) override { + void visit(AstVar* nodep) override { // if (debug()) nodep->dumpTree(cout, " InitPre: "); // Must have deterministic constant width // We can't skip this step when width()!=0, as creating a AstVar @@ -2093,7 +2089,7 @@ private: nodep->didWidth(true); nodep->doingWidth(false); } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { if (nodep->didWidth()) return; if (!nodep->varp()) { if (m_paramsOnly && VN_IS(nodep, VarXRef)) { @@ -2130,7 +2126,7 @@ private: nodep->didWidth(true); } - virtual void visit(AstEnumDType* nodep) override { + void visit(AstEnumDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed UINFO(5, " ENUMDTYPE " << nodep << endl); nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); @@ -2194,7 +2190,7 @@ private: num.opAdd(one, constp->num()); } } - virtual void visit(AstEnumItem* nodep) override { + void visit(AstEnumItem* nodep) override { UINFO(5, " ENUMITEM " << nodep << endl); AstNodeDType* const vdtypep = m_vup->dtypep(); UASSERT_OBJ(vdtypep, nodep, "ENUMITEM not under ENUM"); @@ -2208,7 +2204,7 @@ private: EXTEND_EXP); } } - virtual void visit(AstEnumItemRef* nodep) override { + void visit(AstEnumItemRef* nodep) override { if (!nodep->itemp()->didWidth()) { // We need to do the whole enum en-mass AstNode* enump = nodep->itemp(); @@ -2221,7 +2217,7 @@ private: } nodep->dtypeFrom(nodep->itemp()); } - virtual void visit(AstConsAssoc* nodep) override { + void visit(AstConsAssoc* nodep) override { // Type computed when constructed here auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsAssoc requires assoc upper parent data type"); @@ -2233,7 +2229,7 @@ private: } } } - virtual void visit(AstSetAssoc* nodep) override { + void visit(AstSetAssoc* nodep) override { // Type computed when constructed here auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "SetsAssoc requires assoc upper parent data type"); @@ -2246,7 +2242,7 @@ private: EXTEND_EXP); } } - virtual void visit(AstConsWildcard* nodep) override { + void visit(AstConsWildcard* nodep) override { // Type computed when constructed here auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), WildcardArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsWildcard requires wildcard upper parent data type"); @@ -2258,7 +2254,7 @@ private: } } } - virtual void visit(AstSetWildcard* nodep) override { + void visit(AstSetWildcard* nodep) override { // Type computed when constructed here auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), WildcardArrayDType); UASSERT_OBJ(vdtypep, nodep, "SetWildcard requires wildcard upper parent data type"); @@ -2271,7 +2267,7 @@ private: EXTEND_EXP); } } - virtual void visit(AstConsDynArray* nodep) override { + void visit(AstConsDynArray* nodep) override { // Type computed when constructed here AstDynArrayDType* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), DynArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsDynArray requires queue upper parent data type"); @@ -2303,7 +2299,7 @@ private: nodep->dtypeFrom(vdtypep); } } - virtual void visit(AstConsQueue* nodep) override { + void visit(AstConsQueue* nodep) override { // Type computed when constructed here AstQueueDType* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), QueueDType); UASSERT_OBJ(vdtypep, nodep, "ConsQueue requires queue upper parent data type"); @@ -2335,10 +2331,10 @@ private: nodep->dtypeFrom(vdtypep); } } - virtual void visit(AstInitItem* nodep) override { // + void visit(AstInitItem* nodep) override { // userIterateChildren(nodep, m_vup); } - virtual void visit(AstInitArray* nodep) override { + void visit(AstInitArray* nodep) override { // InitArray has type of the array; children are array values if (m_vup->prelim()) { // First stage evaluation AstNodeDType* const vdtypep = m_vup->dtypeNullp(); @@ -2353,7 +2349,7 @@ private: } } } - virtual void visit(AstInside* nodep) override { + void visit(AstInside* nodep) override { userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p()); for (AstNode *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) { nextip = itemp->nextp(); // Prelim may cause the node to get replaced @@ -2412,14 +2408,14 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - virtual void visit(AstInsideRange* nodep) override { + void visit(AstInsideRange* nodep) override { // Just do each side; AstInside will rip these nodes out later userIterateAndNext(nodep->lhsp(), m_vup); userIterateAndNext(nodep->rhsp(), m_vup); nodep->dtypeFrom(nodep->lhsp()); } - virtual void visit(AstIfaceRefDType* nodep) override { + void visit(AstIfaceRefDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed UINFO(5, " IFACEREF " << nodep << endl); userIterateChildren(nodep, m_vup); @@ -2427,7 +2423,7 @@ private: nodep->widthForce(1, 1); // Not really relevant UINFO(4, "dtWidthed " << nodep << endl); } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed UINFO(5, " NODECLASS " << nodep << endl); // if (debug() >= 9) nodep->dumpTree("-class-in--"); @@ -2462,7 +2458,7 @@ private: nodep->widthForce(width, width); // Signing stays as-is, as parsed from declaration // if (debug() >= 9) nodep->dumpTree("-class-out-"); } - virtual void visit(AstClass* nodep) override { + void visit(AstClass* nodep) override { if (nodep->didWidthAndSet()) return; // Must do extends first, as we may in functions under this class // start following a tree of extends that takes us to other classes @@ -2470,37 +2466,37 @@ private: userIterateChildren(nodep, nullptr); // First size all members nodep->repairCache(); } - virtual void visit(AstClassRefDType* nodep) override { + void visit(AstClassRefDType* nodep) override { if (nodep->didWidthAndSet()) return; // TODO this maybe eventually required to properly resolve members, // though causes problems with t_class_forward.v, so for now avoided // userIterateChildren(nodep->classp(), nullptr); } - virtual void visit(AstClassOrPackageRef* nodep) override { + void visit(AstClassOrPackageRef* nodep) override { if (nodep->didWidthAndSet()) return; userIterateChildren(nodep, nullptr); } - virtual void visit(AstDot* nodep) override { + void visit(AstDot* nodep) override { // We can only reach this from constify called during V3Param (so before linkDotParam) // ... #(Cls#(...)::...) ... // ^^~~~ this is our DOT nodep->v3warn(E_UNSUPPORTED, "dotted expressions in parameters\n" << nodep->warnMore() << "... Suggest use a typedef"); } - virtual void visit(AstClassExtends* nodep) override { + void visit(AstClassExtends* nodep) override { if (nodep->didWidthAndSet()) return; if (VN_IS(nodep->childDTypep(), ClassRefDType)) { nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->childDTypep())); } } - virtual void visit(AstMemberDType* nodep) override { + void visit(AstMemberDType* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed // Iterate into subDTypep() to resolve that type and update pointer. nodep->refDTypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); nodep->dtypep(nodep); // The member itself, not subDtype nodep->widthFromSub(nodep->subDTypep()); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { UINFO(5, " MEMBERSEL " << nodep << endl); if (debug() >= 9) nodep->dumpTree("-mbs-in: "); userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); @@ -2603,12 +2599,12 @@ private: return false; } - virtual void visit(AstCMethodHard* nodep) override { + void visit(AstCMethodHard* nodep) override { // Never created before V3Width, so no need to redo it UASSERT_OBJ(nodep->dtypep(), nodep, "CMETHODCALLs should have already been sized"); } - virtual void visit(AstMethodCall* nodep) override { + void visit(AstMethodCall* nodep) override { UINFO(5, " METHODCALL " << nodep << endl); if (nodep->didWidth()) return; if (debug() >= 9) nodep->dumpTree("-mts-in: "); @@ -3458,7 +3454,7 @@ private: } } - virtual void visit(AstNew* nodep) override { + void visit(AstNew* nodep) override { if (nodep->didWidth()) return; AstClassRefDType* const refp = m_vup ? VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType) : nullptr; @@ -3484,7 +3480,7 @@ private: userIterate(nodep->taskp(), nullptr); processFTaskRefArgs(nodep); } - virtual void visit(AstNewCopy* nodep) override { + void visit(AstNewCopy* nodep) override { if (nodep->didWidthAndSet()) return; AstClassRefDType* const refp = VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType); if (!refp) { // e.g. int a = new; @@ -3499,7 +3495,7 @@ private: << nodep->rhsp()->dtypep()->prettyTypeName() << "'"); } } - virtual void visit(AstNewDynamic* nodep) override { + void visit(AstNewDynamic* nodep) override { if (nodep->didWidthAndSet()) return; AstDynArrayDType* const adtypep = VN_CAST(m_vup->dtypeNullSkipRefp(), DynArrayDType); if (!adtypep) { // e.g. int a = new; @@ -3523,7 +3519,7 @@ private: } } - virtual void visit(AstPattern* nodep) override { + void visit(AstPattern* nodep) override { if (nodep->didWidthAndSet()) return; UINFO(9, "PATTERN " << nodep << endl); if (nodep->childDTypep()) { // data_type '{ pattern } @@ -3959,7 +3955,7 @@ private: return valuep; } - virtual void visit(AstPatMember* nodep) override { + void visit(AstPatMember* nodep) override { AstNodeDType* const vdtypep = m_vup->dtypeNullp(); UASSERT_OBJ(vdtypep, nodep, "Pattern member type not assigned by AstPattern visitor"); nodep->dtypep(vdtypep); @@ -3993,7 +3989,7 @@ private: return times; } - virtual void visit(AstPropClocked* nodep) override { + void visit(AstPropClocked* nodep) override { if (m_vup->prelim()) { // First stage evaluation iterateCheckBool(nodep, "Property", nodep->propp(), BOTH); userIterateAndNext(nodep->sensesp(), nullptr); @@ -4008,7 +4004,7 @@ private: //-------------------- // Top levels - virtual void visit(AstNodeCase* nodep) override { + void visit(AstNodeCase* nodep) override { // IEEE-2012 12.5: // Width: MAX(expr, all items) // Signed: Only if expr, and all items signed @@ -4054,7 +4050,7 @@ private: } } } - virtual void visit(AstNodeFor* nodep) override { + void visit(AstNodeFor* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->initsp(), nullptr); iterateCheckBool(nodep, "For Test Condition", nodep->condp(), @@ -4062,12 +4058,12 @@ private: if (!VN_IS(nodep, GenFor)) userIterateAndNext(nodep->bodysp(), nullptr); userIterateAndNext(nodep->incsp(), nullptr); } - virtual void visit(AstRepeat* nodep) override { + void visit(AstRepeat* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->countp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->bodysp(), nullptr); } - virtual void visit(AstWhile* nodep) override { + void visit(AstWhile* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->precondsp(), nullptr); iterateCheckBool(nodep, "For Test Condition", nodep->condp(), @@ -4075,7 +4071,7 @@ private: userIterateAndNext(nodep->bodysp(), nullptr); userIterateAndNext(nodep->incsp(), nullptr); } - virtual void visit(AstNodeIf* nodep) override { + void visit(AstNodeIf* nodep) override { assertAtStatement(nodep); // if (debug()) nodep->dumpTree(cout, " IfPre: "); if (!VN_IS(nodep, GenIf)) { // for m_paramsOnly @@ -4085,13 +4081,13 @@ private: iterateCheckBool(nodep, "If", nodep->condp(), BOTH); // it's like an if() condition. // if (debug()) nodep->dumpTree(cout, " IfOut: "); } - virtual void visit(AstExprStmt* nodep) override { + void visit(AstExprStmt* nodep) override { userIterateAndNext(nodep->stmtsp(), nullptr); // expected result is same as parent's expected result userIterateAndNext(nodep->resultp(), m_vup); nodep->dtypeFrom(nodep->resultp()); } - virtual void visit(AstForeach* nodep) override { + void visit(AstForeach* nodep) override { const AstSelLoopVars* const loopsp = VN_CAST(nodep->arrayp(), SelLoopVars); UASSERT_OBJ(loopsp, nodep, "No loop variables under foreach"); // if (debug()) nodep->dumpTree(cout, "-foreach-old: "); @@ -4254,7 +4250,7 @@ private: return newp; } - virtual void visit(AstNodeAssign* nodep) override { + void visit(AstNodeAssign* nodep) override { // IEEE-2012 10.7, 11.8.2, 11.8.3, 11.5: (Careful of 11.8.1 which is // only one step; final dtype depends on assign LHS.) // Determine RHS type width and signing @@ -4344,13 +4340,13 @@ private: } } - virtual void visit(AstRelease* nodep) override { + void visit(AstRelease* nodep) override { userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); UASSERT_OBJ(nodep->lhsp()->dtypep(), nodep, "How can LValue be untyped?"); UASSERT_OBJ(nodep->lhsp()->dtypep()->widthSized(), nodep, "How can LValue be unsized?"); } - virtual void visit(AstSFormatF* nodep) override { + void visit(AstSFormatF* nodep) override { // Excludes NodeDisplay, see below if (m_vup && !m_vup->prelim()) return; // Can be called as statement or function // Just let all arguments seek their natural sizes @@ -4483,13 +4479,13 @@ private: nodep->text(newFormat); UINFO(9, " Display out " << nodep->text() << endl); } - virtual void visit(AstDisplay* nodep) override { + void visit(AstDisplay* nodep) override { assertAtStatement(nodep); if (nodep->filep()) iterateCheckFileDesc(nodep, nodep->filep(), BOTH); // Just let all arguments seek their natural sizes userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } - virtual void visit(AstElabDisplay* nodep) override { + void visit(AstElabDisplay* nodep) override { assertAtStatement(nodep); // Just let all arguments seek their natural sizes userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); @@ -4507,28 +4503,28 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } } - virtual void visit(AstDumpCtl* nodep) override { + void visit(AstDumpCtl* nodep) override { assertAtStatement(nodep); // Just let all arguments seek their natural sizes userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } - virtual void visit(AstFOpen* nodep) override { + void visit(AstFOpen* nodep) override { // Although a system function in IEEE, here a statement which sets the file pointer (MCD) assertAtStatement(nodep); iterateCheckFileDesc(nodep, nodep->filep(), BOTH); userIterateAndNext(nodep->filenamep(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->modep(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstFOpenMcd* nodep) override { + void visit(AstFOpenMcd* nodep) override { assertAtStatement(nodep); iterateCheckFileDesc(nodep, nodep->filep(), BOTH); userIterateAndNext(nodep->filenamep(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstFClose* nodep) override { + void visit(AstFClose* nodep) override { assertAtStatement(nodep); iterateCheckFileDesc(nodep, nodep->filep(), BOTH); } - virtual void visit(AstFError* nodep) override { + void visit(AstFError* nodep) override { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); // We only support string types, not packed array @@ -4536,51 +4532,51 @@ private: nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstFEof* nodep) override { + void visit(AstFEof* nodep) override { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstFFlush* nodep) override { + void visit(AstFFlush* nodep) override { assertAtStatement(nodep); if (nodep->filep()) iterateCheckFileDesc(nodep, nodep->filep(), BOTH); } - virtual void visit(AstFRewind* nodep) override { + void visit(AstFRewind* nodep) override { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } - virtual void visit(AstFTell* nodep) override { + void visit(AstFTell* nodep) override { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } - virtual void visit(AstFSeek* nodep) override { + void visit(AstFSeek* nodep) override { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); iterateCheckSigned32(nodep, "$fseek offset", nodep->offset(), BOTH); iterateCheckSigned32(nodep, "$fseek operation", nodep->operation(), BOTH); nodep->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED); // Spec says integer return } - virtual void visit(AstFGetC* nodep) override { + void visit(AstFGetC* nodep) override { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); nodep->dtypeSetLogicUnsized(32, 8, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstFGetS* nodep) override { + void visit(AstFGetS* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetSigned32(); // Spec says integer return iterateCheckFileDesc(nodep, nodep->filep(), BOTH); userIterateAndNext(nodep->strgp(), WidthVP(SELF, BOTH).p()); } } - virtual void visit(AstFUngetC* nodep) override { + void visit(AstFUngetC* nodep) override { if (m_vup->prelim()) { iterateCheckFileDesc(nodep, nodep->filep(), BOTH); iterateCheckSigned32(nodep, "$fungetc character", nodep->charp(), BOTH); nodep->dtypeSetLogicUnsized(32, 8, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstFRead* nodep) override { + void visit(AstFRead* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetSigned32(); // Spec says integer return userIterateAndNext(nodep->memp(), WidthVP(SELF, BOTH).p()); @@ -4593,38 +4589,38 @@ private: } } } - virtual void visit(AstFScanF* nodep) override { + void visit(AstFScanF* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetSigned32(); // Spec says integer return iterateCheckFileDesc(nodep, nodep->filep(), BOTH); userIterateAndNext(nodep->exprsp(), WidthVP(SELF, BOTH).p()); } } - virtual void visit(AstSScanF* nodep) override { + void visit(AstSScanF* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetSigned32(); // Spec says integer return userIterateAndNext(nodep->fromp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->exprsp(), WidthVP(SELF, BOTH).p()); } } - virtual void visit(AstSysIgnore* nodep) override { + void visit(AstSysIgnore* nodep) override { userIterateAndNext(nodep->exprsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstSystemF* nodep) override { + void visit(AstSystemF* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); nodep->dtypeSetSigned32(); // Spec says integer return } } - virtual void visit(AstSysFuncAsTask* nodep) override { + void visit(AstSysFuncAsTask* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstSystemT* nodep) override { + void visit(AstSystemT* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstNodeReadWriteMem* nodep) override { + void visit(AstNodeReadWriteMem* nodep) override { assertAtStatement(nodep); userIterateAndNext(nodep->filenamep(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->memp(), WidthVP(SELF, BOTH).p()); @@ -4656,53 +4652,53 @@ private: userIterateAndNext(nodep->lsbp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->msbp(), WidthVP(SELF, BOTH).p()); } - virtual void visit(AstTestPlusArgs* nodep) override { + void visit(AstTestPlusArgs* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->searchp(), WidthVP{SELF, BOTH}.p()); nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstValuePlusArgs* nodep) override { + void visit(AstValuePlusArgs* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->searchp(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->outp(), WidthVP(SELF, BOTH).p()); nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return } } - virtual void visit(AstTimeFormat* nodep) override { + void visit(AstTimeFormat* nodep) override { assertAtStatement(nodep); iterateCheckSigned32(nodep, "units", nodep->unitsp(), BOTH); iterateCheckSigned32(nodep, "precision", nodep->precisionp(), BOTH); iterateCheckString(nodep, "suffix", nodep->suffixp(), BOTH); iterateCheckSigned32(nodep, "width", nodep->widthp(), BOTH); } - virtual void visit(AstUCStmt* nodep) override { + void visit(AstUCStmt* nodep) override { // Just let all arguments seek their natural sizes assertAtStatement(nodep); userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } - virtual void visit(AstAssert* nodep) override { + void visit(AstAssert* nodep) override { assertAtStatement(nodep); iterateCheckBool(nodep, "Property", nodep->propp(), BOTH); // it's like an if() condition. userIterateAndNext(nodep->passsp(), nullptr); userIterateAndNext(nodep->failsp(), nullptr); } - virtual void visit(AstAssertIntrinsic* nodep) override { + void visit(AstAssertIntrinsic* nodep) override { assertAtStatement(nodep); iterateCheckBool(nodep, "Property", nodep->propp(), BOTH); // it's like an if() condition. userIterateAndNext(nodep->passsp(), nullptr); userIterateAndNext(nodep->failsp(), nullptr); } - virtual void visit(AstCover* nodep) override { + void visit(AstCover* nodep) override { assertAtStatement(nodep); iterateCheckBool(nodep, "Property", nodep->propp(), BOTH); // it's like an if() condition. userIterateAndNext(nodep->passsp(), nullptr); } - virtual void visit(AstRestrict* nodep) override { + void visit(AstRestrict* nodep) override { assertAtStatement(nodep); iterateCheckBool(nodep, "Property", nodep->propp(), BOTH); // it's like an if() condition. } - virtual void visit(AstPin* nodep) override { + void visit(AstPin* nodep) override { // if (debug()) nodep->dumpTree(cout, "- PinPre: "); // TOP LEVEL NODE if (nodep->modVarp() && nodep->modVarp()->isGParam()) { @@ -4827,7 +4823,7 @@ private: } // if (debug()) nodep->dumpTree(cout, "- PinOut: "); } - virtual void visit(AstCell* nodep) override { + void visit(AstCell* nodep) override { VL_RESTORER(m_cellp); m_cellp = nodep; if (!m_paramsOnly) { @@ -4844,7 +4840,7 @@ private: } userIterateAndNext(nodep->paramsp(), nullptr); } - virtual void visit(AstGatePin* nodep) override { + void visit(AstGatePin* nodep) override { if (m_vup->prelim()) { userIterateAndNext(nodep->rangep(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p()); @@ -4868,7 +4864,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { // Grab width from the output variable (if it's a function) if (nodep->didWidth()) return; if (nodep->doingWidth()) { @@ -4910,7 +4906,7 @@ private: // func } } - virtual void visit(AstReturn* nodep) override { + void visit(AstReturn* nodep) override { // IEEE: Assignment-like context assertAtStatement(nodep); if (!m_funcp) { @@ -4928,7 +4924,7 @@ private: } } - virtual void visit(AstFuncRef* nodep) override { + void visit(AstFuncRef* nodep) override { visit(static_cast(nodep)); nodep->dtypeFrom(nodep->taskp()); // if (debug()) nodep->dumpTree(cout, " FuncOut: "); @@ -5098,7 +5094,7 @@ private: } } } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { // For arguments, is assignment-like context; see IEEE rules in AstNodeAssign // Function hasn't been widthed, so make it so. UINFO(5, " FTASKREF " << nodep << endl); @@ -5109,13 +5105,13 @@ private: processFTaskRefArgs(nodep); nodep->didWidth(true); } - virtual void visit(AstNodeProcedure* nodep) override { + void visit(AstNodeProcedure* nodep) override { assertAtStatement(nodep); m_procedurep = nodep; userIterateChildren(nodep, nullptr); m_procedurep = nullptr; } - virtual void visit(AstSenItem* nodep) override { + void visit(AstSenItem* nodep) override { UASSERT_OBJ(nodep->isClocked(), nodep, "Invalid edge"); // Optimize concat/replicate senitems; this has to be done here at the latest, otherwise we // emit WIDTHCONCAT if there are unsized constants @@ -5133,7 +5129,7 @@ private: userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } } - virtual void visit(AstWait* nodep) override { + void visit(AstWait* nodep) override { if (VN_IS(m_ftaskp, Func)) { nodep->v3error("Wait statements are not legal in functions. Suggest use a task " "(IEEE 1800-2017 13.4.4)"); @@ -5162,7 +5158,7 @@ private: } VL_DO_DANGLING(nodep->deleteTree(), nodep); } - virtual void visit(AstWith* nodep) override { + void visit(AstWith* nodep) override { // Should otherwise be underneath a method call AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); { @@ -5180,7 +5176,7 @@ private: nodep->dtypep()); } } - virtual void visit(AstLambdaArgRef* nodep) override { + void visit(AstLambdaArgRef* nodep) override { UASSERT_OBJ(m_withp, nodep, "LambdaArgRef not underneath 'with' lambda"); if (nodep->index()) { nodep->dtypeFrom(m_withp->indexArgRefp()); @@ -5188,21 +5184,21 @@ private: nodep->dtypeFrom(m_withp->valueArgRefp()); } } - virtual void visit(AstNetlist* nodep) override { + void visit(AstNetlist* nodep) override { // Iterate modules backwards, in bottom-up order. That's faster userIterateChildrenBackwards(nodep, nullptr); } //-------------------- // Default - virtual void visit(AstNodeMath* nodep) override { + void visit(AstNodeMath* nodep) override { if (!nodep->didWidth()) { nodep->v3fatalSrc( "Visit function missing? Widthed function missing for math node: " << nodep); } userIterateChildren(nodep, nullptr); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { // Default: Just iterate UASSERT_OBJ(!m_vup, nodep, "Visit function missing? Widthed expectation for this node: " << nodep); @@ -5224,7 +5220,7 @@ private: iterateCheck(nodep, "LHS", nodep->lhsp(), SELF, FINAL, subDTypep, EXTEND_EXP); } } - virtual void visit(AstIToRD* nodep) override { + void visit(AstIToRD* nodep) override { // Real: Output real // LHS presumed self-determined, then coerced to real if (m_vup->prelim()) { // First stage evaluation @@ -5238,7 +5234,7 @@ private: } } } - virtual void visit(AstISToRD* nodep) override { + void visit(AstISToRD* nodep) override { // Real: Output real // LHS presumed self-determined, then coerced to real if (m_vup->prelim()) { // First stage evaluation @@ -6385,7 +6381,7 @@ private: VNumRange declRange; // ranged() set false for (int i = 1; i <= dim; ++i) { // UINFO(9, " dim at "<declRange(); if (i < dim) dtypep = adtypep->subDTypep()->skipRefp(); @@ -6829,7 +6825,7 @@ public: AstNode* mainAcceptEdit(AstNode* nodep) { return userIterateSubtreeReturnEdits(nodep, WidthVP(SELF, BOTH).p()); } - virtual ~WidthVisitor() override = default; + ~WidthVisitor() override = default; }; //###################################################################### diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index 5b784387d..fb883a256 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -45,18 +45,18 @@ private: } // VISITORS - virtual void visit(AstSigned* nodep) override { + void visit(AstSigned* nodep) override { VL_DO_DANGLING(replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()), nodep); } - virtual void visit(AstUnsigned* nodep) override { + void visit(AstUnsigned* nodep) override { VL_DO_DANGLING(replaceWithSignedVersion(nodep, nodep->lhsp()->unlinkFrBack()), nodep); } - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + void visit(AstNode* nodep) override { iterateChildren(nodep); } public: // CONSTRUCTORS WidthRemoveVisitor() = default; - virtual ~WidthRemoveVisitor() override = default; + ~WidthRemoveVisitor() override = default; AstNode* mainAcceptEdit(AstNode* nodep) { return iterateSubtreeReturnEdits(nodep); } }; @@ -151,7 +151,7 @@ private: } // VISITORS - virtual void visit(AstNodeModule* nodep) override { + void visit(AstNodeModule* nodep) override { VL_RESTORER(m_modp); { m_modp = nodep; @@ -159,7 +159,7 @@ private: editDType(nodep); } } - virtual void visit(AstConst* nodep) override { + void visit(AstConst* nodep) override { UASSERT_OBJ(nodep->dtypep(), nodep, "No dtype"); iterate(nodep->dtypep()); // Do datatype first if (AstConst* const newp = newIfConstCommitSize(nodep)) { @@ -172,15 +172,15 @@ private: } editDType(nodep); } - virtual void visit(AstNodeDType* nodep) override { // + void visit(AstNodeDType* nodep) override { // visitIterateNodeDType(nodep); } - virtual void visit(AstNodeUOrStructDType* nodep) override { + void visit(AstNodeUOrStructDType* nodep) override { if (nodep->user1SetOnce()) return; // Process once visitIterateNodeDType(nodep); nodep->clearCache(); } - virtual void visit(AstParamTypeDType* nodep) override { + void visit(AstParamTypeDType* nodep) override { if (nodep->user1SetOnce()) return; // Process once visitIterateNodeDType(nodep); // Move to type table as all dtype pointers must resolve there @@ -199,7 +199,7 @@ private: nodep->virtRefDTypep(editOneDType(nodep->virtRefDTypep())); nodep->virtRefDType2p(editOneDType(nodep->virtRefDType2p())); } - virtual void visit(AstNodeFTask* nodep) override { + void visit(AstNodeFTask* nodep) override { iterateChildren(nodep); editDType(nodep); if (nodep->classMethod() && nodep->pureVirtual() && VN_IS(m_modp, Class) @@ -208,28 +208,28 @@ private: "Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2017 8.21)"); } } - virtual void visit(AstNodeVarRef* nodep) override { + void visit(AstNodeVarRef* nodep) override { iterateChildren(nodep); editDType(nodep); classEncapCheck(nodep, nodep->varp(), VN_CAST(nodep->classOrPackagep(), Class)); } - virtual void visit(AstNodeFTaskRef* nodep) override { + void visit(AstNodeFTaskRef* nodep) override { iterateChildren(nodep); editDType(nodep); classEncapCheck(nodep, nodep->taskp(), VN_CAST(nodep->classOrPackagep(), Class)); } - virtual void visit(AstMemberSel* nodep) override { + void visit(AstMemberSel* nodep) override { iterateChildren(nodep); editDType(nodep); if (auto* const classrefp = VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) { classEncapCheck(nodep, nodep->varp(), classrefp->classp()); } // else might be struct, etc } - virtual void visit(AstNodePreSel* nodep) override { // LCOV_EXCL_LINE + void visit(AstNodePreSel* nodep) override { // LCOV_EXCL_LINE // This check could go anywhere after V3Param nodep->v3fatalSrc("Presels should have been removed before this point"); } - virtual void visit(AstNode* nodep) override { + void visit(AstNode* nodep) override { iterateChildren(nodep); editDType(nodep); } @@ -243,7 +243,7 @@ public: // Don't want to repairCache, as all needed nodes have been added back in // a repair would prevent dead nodes from being detected } - virtual ~WidthCommitVisitor() override = default; + ~WidthCommitVisitor() override = default; }; //###################################################################### diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index d958f6d52..222f69c5b 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -202,7 +202,7 @@ private: // VISITORS // If adding new visitors, ensure V3Width's visit(TYPE) calls into here - virtual void visit(AstSelBit* nodep) override { + void visit(AstSelBit* nodep) override { // Select of a non-width specified part of an array, i.e. "array[2]" // This select style has a lsb and msb (no user specified width) UINFO(6, "SELBIT " << nodep << endl); @@ -330,7 +330,7 @@ private: } if (!rhsp->backp()) VL_DO_DANGLING(pushDeletep(rhsp), rhsp); } - virtual void visit(AstSelExtract* nodep) override { + void visit(AstSelExtract* nodep) override { // Select of a range specified part of an array, i.e. "array[2:3]" // SELEXTRACT(from,msb,lsb) -> SEL(from, lsb, 1+msb-lsb) // This select style has a (msb or lsb) and width @@ -524,8 +524,8 @@ private: // up array: lsb/hi -: width const int32_t msb = VN_IS(nodep, SelPlus) ? rhs + width - 1 : rhs; const int32_t lsb = VN_IS(nodep, SelPlus) ? rhs : rhs - width + 1; - AstSliceSel* const newp = new AstSliceSel( - nodep->fileline(), fromp, VNumRange(msb, lsb, fromRange.littleEndian())); + AstSliceSel* const newp = new AstSliceSel{ + nodep->fileline(), fromp, VNumRange{msb, lsb, fromRange.littleEndian()}}; nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else { @@ -584,13 +584,13 @@ private: if (!rhsp->backp()) VL_DO_DANGLING(pushDeletep(rhsp), rhsp); if (!widthp->backp()) VL_DO_DANGLING(pushDeletep(widthp), widthp); } - virtual void visit(AstSelPlus* nodep) override { replaceSelPlusMinus(nodep); } - virtual void visit(AstSelMinus* nodep) override { replaceSelPlusMinus(nodep); } + void visit(AstSelPlus* nodep) override { replaceSelPlusMinus(nodep); } + void visit(AstSelMinus* nodep) override { replaceSelPlusMinus(nodep); } // If adding new visitors, ensure V3Width's visit(TYPE) calls into here //-------------------- // Default - virtual void visit(AstNode* nodep) override { // LCOV_EXCL_LINE + void visit(AstNode* nodep) override { // LCOV_EXCL_LINE // See notes above; we never iterate nodep->v3fatalSrc("Shouldn't iterate in V3WidthSel"); } @@ -598,7 +598,7 @@ private: public: // CONSTRUCTORS WidthSelVisitor() = default; - virtual ~WidthSelVisitor() override = default; + ~WidthSelVisitor() override = default; AstNode* mainAcceptEdit(AstNode* nodep) { return iterateSubtreeReturnEdits(nodep); } }; diff --git a/src/Verilator.cpp b/src/Verilator.cpp index a68c7628f..5f74cf1c5 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -665,11 +665,7 @@ static string buildMakeCmd(const string& makefile, const string& target) { cmd << v3Global.opt.getenvMAKE(); cmd << " -C " << v3Global.opt.makeDir(); cmd << " -f " << makefile; - if (jobs == 0) { - cmd << " -j"; - } else if (jobs > 1) { - cmd << " -j " << jobs; - } + if (jobs > 0) cmd << " -j " << jobs; for (const string& flag : makeFlags) cmd << ' ' << flag; if (!target.empty()) cmd << ' ' << target; @@ -722,7 +718,7 @@ int main(int argc, char** argv, char** /*env*/) { // Command option parsing v3Global.opt.bin(argv[0]); const string argString = V3Options::argString(argc - 1, argv + 1); - v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1); + v3Global.opt.parseOpts(new FileLine{FileLine::commandLineFilename()}, argc - 1, argv + 1); // Validate settings (aka Boost.Program_options) v3Global.opt.notify(); diff --git a/src/astgen b/src/astgen index d1fa39f31..98d0750fe 100755 --- a/src/astgen +++ b/src/astgen @@ -7,6 +7,7 @@ import glob import os import re import sys +import textwrap # from pprint import pprint, pformat @@ -467,7 +468,7 @@ class Cpt: if len(out_for_type_sc) > 0: # Short-circuited types self.print( " // Generated by astgen with short-circuiting\n" + - " virtual void visit(Ast" + node.name + + " void visit(Ast" + node.name + "* nodep) override {\n" + " iterateAndNextNull(nodep->lhsp());\n" + "".join(out_for_type_sc)) @@ -480,10 +481,12 @@ class Cpt: elif len(out_for_type) > 0: # Other types with something to print skip = node.name in self.tree_skip_visit gen = "Gen" if skip else "" + virtual = "virtual " if skip else "" override = "" if skip else " override" self.print( - " // Generated by astgen\n" + " virtual void visit" + - gen + "(Ast" + node.name + "* nodep)" + override + " {\n" + + " // Generated by astgen\n" + " " + virtual + + "void visit" + gen + "(Ast" + node.name + "* nodep)" + + override + " {\n" + ("" if skip else " iterateChildren(nodep);\n") + ''.join(out_for_type) + " }\n") @@ -493,28 +496,59 @@ class Cpt: def read_types(filename): + hasErrors = False + + def error(lineno, message): + nonlocal hasErrors + print(filename + ":" + str(lineno) + ": %Error: " + message, + file=sys.stderr) + hasErrors = True + + node = None + hasAstgenMembers = False + + def checkFinishedNode(node): + nonlocal hasAstgenMembers + if not node: + return + if not hasAstgenMembers: + error( + node.lineno, "'Ast" + node.name + + "' does not contain 'ASTGEN_MEMBERS_" + node.name + ";'") + hasAstgenMembers = False + with open(filename) as fh: for (lineno, line) in enumerate(fh, start=1): - line = re.sub(r'//.*$', '', line) - if re.match(r'^\s*$', line): + line = line.strip() + if not line: continue + match = re.search(r'^\s*(class|struct)\s*(\S+)', line) if match: classn = match.group(2) match = re.search(r':\s*public\s+(\S+)', line) supern = match.group(1) if match else "" - assert classn != "AstNode" or supern == "", "AstNode can't have a superclass" - if re.search(r'Ast', supern) or classn == "AstNode": + if re.search(r'Ast', supern): classn = re.sub(r'^Ast', '', classn) supern = re.sub(r'^Ast', '', supern) if not supern: sys.exit("%Error: 'Ast{}' has no super-class".format( classn)) + checkFinishedNode(node) superClass = Nodes[supern] node = Node(classn, superClass, filename, lineno) superClass.addSubClass(node) Nodes[classn] = node + if not node: + continue + + if re.match(r'^\s*ASTGEN_MEMBERS_' + node.name + ';', line): + hasAstgenMembers = True + checkFinishedNode(node) + if hasErrors: + sys.exit("%Error: Stopping due to errors reported above") + def read_stages(filename): with open(filename) as fh: @@ -698,13 +732,41 @@ def write_yystype(filename): def write_macros(filename): with open_file(filename) as fh: - for node in SortedNodes: - # Only care about leaf classes - if not node.isLeaf: - continue + + def emitBlock(pattern, **fmt): fh.write( - "#define ASTGEN_SUPER_{t}(...) Ast{b}(VNType::at{t}, __VA_ARGS__)\n" - .format(t=node.name, b=node.superClass.name)) + textwrap.indent(textwrap.dedent(pattern), + " ").format(**fmt).replace("\n", " \\\n")) + + for node in SortedNodes: + fh.write("#define ASTGEN_MEMBERS_{t} \\\n".format(t=node.name)) + emitBlock('''\ + static Ast{t}* cloneTreeNull(Ast{t}* nodep, bool cloneNextLink) {{ + return nodep ? nodep->cloneTree(cloneNextLink) : nullptr; + }} + Ast{t}* cloneTree(bool cloneNext) {{ + return static_cast(AstNode::cloneTree(cloneNext)); + }} + Ast{t}* clonep() const {{ return static_cast(AstNode::clonep()); }} + ''', + t=node.name) + + if node.isLeaf: + emitBlock('''\ + void accept(VNVisitor& v) override {{ v.visit(this); }} + AstNode* clone() override {{ return new Ast{t}(*this); }} + ''', + t=node.name) + + fh.write( + " static_assert(true, \"\")\n") # Swallowing the semicolon + + # Only care about leaf classes for the rest + if node.isLeaf: + fh.write( + "#define ASTGEN_SUPER_{t}(...) Ast{b}(VNType::at{t}, __VA_ARGS__)\n" + .format(t=node.name, b=node.superClass.name)) + fh.write("\n") ###################################################################### @@ -807,7 +869,7 @@ if Args.classes: write_impl("V3Ast__gen_impl.h") write_types("V3Ast__gen_types.h") write_yystype("V3Ast__gen_yystype.h") - write_macros("V3AstNodes__gen_macros.h") + write_macros("V3Ast__gen_macros.h") for cpt in Args.infiles: if not re.search(r'.cpp$', cpt): diff --git a/src/verilog.y b/src/verilog.y index 60f90255d..7cbd72e4c 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3924,7 +3924,7 @@ system_f_call_or_t: // IEEE: part of system_tf_call (can be task or | yD_POW '(' expr ',' expr ')' { $$ = new AstPowD($1,$3,$5); } | yD_RANDOM '(' expr ')' { $$ = new AstRand($1, $3, false); } | yD_RANDOM parenE { $$ = new AstRand($1, nullptr, false); } - | yD_REALTIME parenE { $$ = new AstTimeD($1, VTimescale(VTimescale::NONE)); } + | yD_REALTIME parenE { $$ = new AstTimeD{$1, VTimescale{VTimescale::NONE}}; } | yD_REALTOBITS '(' expr ')' { $$ = new AstRealToBits($1,$3); } | yD_REWIND '(' idClassSel ')' { $$ = new AstFSeek($1, $3, new AstConst($1, 0), new AstConst($1, 0)); } | yD_RIGHT '(' exprOrDataType ')' { $$ = new AstAttrOf($1,VAttrType::DIM_RIGHT,$3,nullptr); } @@ -3942,13 +3942,14 @@ system_f_call_or_t: // IEEE: part of system_tf_call (can be task or | yD_SIZE '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,VAttrType::DIM_SIZE,$3,$5); } | yD_SQRT '(' expr ')' { $$ = new AstSqrtD($1,$3); } | yD_SSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstSScanF($1,*$5,$3,$6); } - | yD_STIME parenE { $$ = new AstSel($1, new AstTime($1, VTimescale(VTimescale::NONE)), 0, 32); } + | yD_STIME parenE + { $$ = new AstSel{$1, new AstTime{$1, VTimescale{VTimescale::NONE}}, 0, 32}; } | yD_STABLE '(' expr ')' { $$ = new AstStable($1,$3); } | yD_STABLE '(' expr ',' expr ')' { $$ = $3; BBUNSUP($1, "Unsupported: $stable and clock arguments"); } | yD_TAN '(' expr ')' { $$ = new AstTanD($1,$3); } | yD_TANH '(' expr ')' { $$ = new AstTanhD($1,$3); } | yD_TESTPLUSARGS '(' expr ')' { $$ = new AstTestPlusArgs($1, $3); } - | yD_TIME parenE { $$ = new AstTime($1, VTimescale(VTimescale::NONE)); } + | yD_TIME parenE { $$ = new AstTime{$1, VTimescale{VTimescale::NONE}}; } | yD_TYPENAME '(' exprOrDataType ')' { $$ = new AstAttrOf($1, VAttrType::TYPENAME, $3); } | yD_UNGETC '(' expr ',' expr ')' { $$ = new AstFUngetC($1, $5, $3); } // Arg swap to file first | yD_UNPACKED_DIMENSIONS '(' exprOrDataType ')' { $$ = new AstAttrOf($1,VAttrType::DIM_UNPK_DIMENSIONS,$3); } @@ -6620,7 +6621,7 @@ vltOffFront: | yVLT_TRACING_OFF { $$ = V3ErrorCode::I_TRACING; } | yVLT_LINT_OFF { $$ = V3ErrorCode::I_LINT; } | yVLT_LINT_OFF yVLT_D_RULE idAny - { $$ = V3ErrorCode((*$3).c_str()); + { $$ = V3ErrorCode{(*$3).c_str()}; if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); } } ; @@ -6630,7 +6631,7 @@ vltOnFront: | yVLT_TRACING_ON { $$ = V3ErrorCode::I_TRACING; } | yVLT_LINT_ON { $$ = V3ErrorCode::I_LINT; } | yVLT_LINT_ON yVLT_D_RULE idAny - { $$ = V3ErrorCode((*$3).c_str()); + { $$ = V3ErrorCode{(*$3).c_str()}; if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown Error Code: " << *$3); } } ; diff --git a/test_regress/t/TestVpi.h b/test_regress/t/TestVpi.h index 389707823..40734b7c6 100644 --- a/test_regress/t/TestVpi.h +++ b/test_regress/t/TestVpi.h @@ -29,7 +29,7 @@ public: , m_freeit(true) {} ~TestVpiHandle() { release(); } operator vpiHandle() const { return m_handle; } - inline TestVpiHandle& operator=(vpiHandle h) { + TestVpiHandle& operator=(vpiHandle h) { release(); m_handle = h; return *this; diff --git a/test_regress/t/t_dist_cppstyle.pl b/test_regress/t/t_dist_cppstyle.pl new file mode 100755 index 000000000..7a8f23e5d --- /dev/null +++ b/test_regress/t/t_dist_cppstyle.pl @@ -0,0 +1,80 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Primitive C++ style checker +# +# Copyright 2022 by Geza Lore. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(dist => 1); + +my $root = ".."; + +### Must trim output before and after our file list +my %files = %{get_source_files($root)}; + +foreach my $file (sort keys %files) { + my $filename = "$root/$file"; + next if !-f $filename; # git file might be deleted but not yet staged + next unless $file =~ /\.(h|c|cpp)(\.in)?$/; + next if $file =~ /gtkwave/; + + my $contents = file_contents($filename); + + checkPattern($filename, $contents, + qr/[^\/]*virtual[^{};]+override/, + "'virtual' keyword is redundant on 'override' method"); + + checkPattern($filename, $contents, + qr/ \s*(\w+ )*\s*(inline) [^;]+?\([^;]*?\)[^;]+?(?:{|:|=\s*default)/, + "'inline' keyword is redundant on method definitions inside classes"); + + checkPattern($filename, $contents, + qr/(?\n)inline \S+ [^;:(]+::[^;:(]+\([^;]*\)[^;]+{/, + "Use 'inline' only on declaration inside classes (except for template specializatoins)"); + + if ($file =~ /\.(c|cpp)/) { + checkPattern($filename, $contents, + qr/(\w+\s+)*(inline)/, + "'inline' keyword is on functions defined in .cpp files"); + } +} + +ok(1); +1; + +sub get_source_files { + my $root = shift; + my $git_files = `cd $root && git ls-files`; + print "MF $git_files\n" if $Self->{verbose}; + my %files; + foreach my $file (split /\s+/, $git_files) { + next if $file eq ''; + $files{$file} |= 1; + } + return \%files; +} + +sub checkPattern { + my $filename = shift; + my $contents = shift; + my $pattern = shift; + my $message = shift; + + my $offset = 0; + my $buffer = $contents; + while ($buffer =~ s/.*?^($pattern)//sm) { + my $lineno = offset_to_lineno($contents, $offset + $-[-1]); + $offset += $+[1]; + error("$filename:$lineno: $message"); + } +} + +sub offset_to_lineno { + my $contents = shift; + my $offset = shift; + my $count = (substr $contents, 0, $offset) =~ tr/\n//; + return $count + 1; +} diff --git a/test_regress/t/t_extend_class_c.h b/test_regress/t/t_extend_class_c.h index c5e98001b..a1cdd58dc 100644 --- a/test_regress/t/t_extend_class_c.h +++ b/test_regress/t/t_extend_class_c.h @@ -13,5 +13,5 @@ public: ~t_extend_class_c() = default; // METHODS // This function will be called from a instance created in Verilog - inline uint32_t my_math(uint32_t in) { return in + 1; } + uint32_t my_math(uint32_t in) { return in + 1; } }; diff --git a/test_regress/t/t_flag_build-jobs_bad.out b/test_regress/t/t_flag_build-jobs_bad.out new file mode 100644 index 000000000..341b1b979 --- /dev/null +++ b/test_regress/t/t_flag_build-jobs_bad.out @@ -0,0 +1 @@ +%Error: --build-jobs requires a non-negative integer, but '-1' was passed diff --git a/test_regress/t/t_flag_j_bad.pl b/test_regress/t/t_flag_build-jobs_bad.pl similarity index 91% rename from test_regress/t/t_flag_j_bad.pl rename to test_regress/t/t_flag_build-jobs_bad.pl index ee3d0fdc8..8432e74c6 100755 --- a/test_regress/t/t_flag_j_bad.pl +++ b/test_regress/t/t_flag_build-jobs_bad.pl @@ -14,7 +14,7 @@ top_filename("t/t_flag_werror.v"); lint( fails => 1, - verilator_flags => [qw(-j 0 --build)], + verilator_flags => [qw(--build-jobs -1 --build)], expect_filename => $Self->{golden_filename}, ); diff --git a/test_regress/t/t_flag_build_jobs_and_j.pl b/test_regress/t/t_flag_build_jobs_and_j.pl new file mode 100755 index 000000000..356011fbf --- /dev/null +++ b/test_regress/t/t_flag_build_jobs_and_j.pl @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2022 by Antmicro Ltd.. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); +top_filename("t/t_flag_make_cmake.v"); + +compile( + verilator_make_cmake => 0, + verilator_make_gmake => 0, + verilator_flags2 => ['--exe --cc --build -j 10 --build-jobs 2 --stats', + '../' . $Self->{main_filename}], + ); + +execute( + check_finished => 1, + ); + +file_grep($Self->{stats}, qr/Build jobs: 2/); + +ok(1); +1; diff --git a/test_regress/t/t_flag_j_bad.out b/test_regress/t/t_flag_j_bad.out deleted file mode 100644 index 2fe652c5d..000000000 --- a/test_regress/t/t_flag_j_bad.out +++ /dev/null @@ -1,2 +0,0 @@ -%Error: -j accepts positive integer, but '0' is passed -%Error: Exiting due to