From 76b3776fa3557bfa9fe63902b022940d88c9f5a5 Mon Sep 17 00:00:00 2001 From: Geza Lore <gezalore@gmail.com> Date: Tue, 22 Jun 2021 13:16:23 +0100 Subject: [PATCH] Change generated tracing routines to use snake_case For consistency with the rest of the generated code, generated methods related to tracing now use snake_case instead of camelCase. No functional change intended. --- src/V3EmitCModel.cpp | 12 ++++++------ src/V3Trace.cpp | 20 ++++++++++---------- src/V3TraceDecl.cpp | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 6b67f6fad..dd0e6a64c 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -484,12 +484,12 @@ class EmitCModel final : public EmitCFunc { putSectionDelimiter("Trace configuration"); // Forward declaration - puts("\nvoid " + topModNameProtected + "__" + protect("traceInitTop") + "(" + puts("\nvoid " + topModNameProtected + "__" + protect("trace_init_top") + "(" + topModNameProtected + "* vlSelf, " + v3Global.opt.traceClassBase() + "* tracep);\n"); // Static helper function - puts("\nstatic void " + protect("traceInit") + "(void* voidSelf, " + puts("\nstatic void " + protect("trace_init") + "(void* voidSelf, " + v3Global.opt.traceClassBase() + "* tracep, uint32_t code) {\n"); putsDecoration("// Callback from tracep->open()\n"); puts(voidSelfAssign(modp)); @@ -502,20 +502,20 @@ class EmitCModel final : public EmitCFunc { puts("vlSymsp->__Vm_baseCode = code;\n"); puts("tracep->module(vlSymsp->name());\n"); puts("tracep->scopeEscape(' ');\n"); - puts(topModNameProtected + "__" + protect("traceInitTop") + "(vlSelf, tracep);\n"); + puts(topModNameProtected + "__" + protect("trace_init_top") + "(vlSelf, tracep);\n"); puts("tracep->scopeEscape('.');\n"); // Restore so later traced files won't break puts("}\n"); // Forward declaration - puts("\nvoid " + topModNameProtected + "__" + protect("traceRegister") + "(" + puts("\nvoid " + topModNameProtected + "__" + protect("trace_register") + "(" + topModNameProtected + "* vlSelf, " + v3Global.opt.traceClassBase() + "* tracep);\n"); // ::trace puts("\nvoid " + topClassName() + "::trace("); puts(v3Global.opt.traceClassBase() + "C* tfp, int, int) {\n"); - puts("tfp->spTrace()->addInitCb(&" + protect("traceInit") + ", &(vlSymsp->TOP));\n"); - puts(topModNameProtected + "__" + protect("traceRegister") + puts("tfp->spTrace()->addInitCb(&" + protect("trace_init") + ", &(vlSymsp->TOP));\n"); + puts(topModNameProtected + "__" + protect("trace_register") + "(&(vlSymsp->TOP), tfp->spTrace());\n"); puts("}\n"); } diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 92ecc8b5b..062cd2ea1 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -476,10 +476,10 @@ private: // Create new function string name; switch (type) { - case AstCFuncType::TRACE_FULL: name = "traceFullTop"; break; - case AstCFuncType::TRACE_FULL_SUB: name = "traceFullSub"; break; - case AstCFuncType::TRACE_CHANGE: name = "traceChgTop"; break; - case AstCFuncType::TRACE_CHANGE_SUB: name = "traceChgSub"; break; + case AstCFuncType::TRACE_FULL: name = "trace_full_top_"; break; + case AstCFuncType::TRACE_FULL_SUB: name = "trace_full_sub_"; break; + case AstCFuncType::TRACE_CHANGE: name = "trace_chg_top_"; break; + case AstCFuncType::TRACE_CHANGE_SUB: name = "trace_chg_sub_"; break; default: m_topScopep->v3fatalSrc("Bad trace function type"); } name += cvtToStr(funcNump++); @@ -593,8 +593,8 @@ private: } } if (topFuncp) { // might be nullptr if all trailing entries were duplicates - UINFO(5, "traceFullTop" << topFuncNum - 1 << " codes: " << nCodes << "/" - << maxCodes << endl); + UINFO(5, "trace_full_top" << topFuncNum - 1 << " codes: " << nCodes << "/" + << maxCodes << endl); } } } @@ -667,15 +667,15 @@ private: nCodes += declp->codeInc(); } if (topFuncp) { // might be nullptr if all trailing entries were duplicates/constants - UINFO(5, "traceChgTop" << topFuncNum - 1 << " codes: " << nCodes << "/" << maxCodes - << endl); + UINFO(5, "trace_chg_top" << topFuncNum - 1 << " codes: " << nCodes << "/" + << maxCodes << endl); } } } void createCleanupFunction(AstCFunc* regFuncp) { FileLine* const fl = m_topScopep->fileline(); - AstCFunc* const cleanupFuncp = new AstCFunc(fl, "traceCleanup", m_topScopep); + AstCFunc* const cleanupFuncp = new AstCFunc(fl, "trace_cleanup", m_topScopep); cleanupFuncp->argTypes("void* voidSelf, " + v3Global.opt.traceClassBase() + "* /*unused*/"); cleanupFuncp->funcType(AstCFuncType::TRACE_CLEANUP); @@ -736,7 +736,7 @@ private: // Create the trace registration function AstCFunc* const regFuncp - = new AstCFunc(m_topScopep->fileline(), "traceRegister", m_topScopep); + = new AstCFunc(m_topScopep->fileline(), "trace_register", m_topScopep); regFuncp->argTypes(v3Global.opt.traceClassBase() + "* tracep"); regFuncp->funcType(AstCFuncType::TRACE_REGISTER); regFuncp->slow(true); diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 873d66b80..b7f61a01f 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -94,7 +94,7 @@ private: basep->addStmtsp(callp); } AstCFunc* newCFuncSub(AstCFunc* basep) { - const string name = "traceInitSub" + cvtToStr(m_funcNum++); + const string name = "trace_init_sub_" + cvtToStr(m_funcNum++); AstCFunc* const funcp = newCFunc(AstCFuncType::TRACE_INIT_SUB, name); if (!m_interface) callCFuncSub(basep, funcp, nullptr); return funcp; @@ -135,7 +135,7 @@ private: virtual void visit(AstTopScope* nodep) override { m_topScopep = nodep->scopep(); // Create the trace init function - m_initFuncp = newCFunc(AstCFuncType::TRACE_INIT, "traceInitTop"); + m_initFuncp = newCFunc(AstCFuncType::TRACE_INIT, "trace_init_top"); // Create initial sub function m_initSubFuncp = newCFuncSub(m_initFuncp); // And find variables