Internals: Emit newlines for AstCStmt automatically. No functional change intended.

This commit is contained in:
Wilson Snyder 2025-09-26 08:25:47 -04:00
parent 62880c125e
commit 4ad1dde723
16 changed files with 841 additions and 820 deletions

View File

@ -68,10 +68,10 @@ class V3CCtorsBuilder final {
string preventUnusedStmt;
if (m_type.isClass()) {
funcp->argTypes(EmitCUtil::symClassVar());
preventUnusedStmt = "(void)vlSymsp; // Prevent unused variable warning\n";
preventUnusedStmt = "(void)vlSymsp; // Prevent unused variable warning";
} else if (m_type.isCoverage()) {
funcp->argTypes("bool first");
preventUnusedStmt = "(void)first; // Prevent unused variable warning\n";
preventUnusedStmt = "(void)first; // Prevent unused variable warning";
}
if (!preventUnusedStmt.empty()) {
funcp->addStmtsp(new AstCStmt{m_modp->fileline(), preventUnusedStmt});

View File

@ -86,7 +86,7 @@ static void makeVlToString(AstNodeUOrStructDType* nodep) {
funcp->isConst(false);
funcp->isStatic(false);
funcp->protect(false);
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;\n"});
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;"});
for (const AstMemberDType* itemp = nodep->membersp(); itemp;
itemp = VN_AS(itemp->nextp(), MemberDType)) {
std::string stmt = "out += \"";
@ -97,11 +97,15 @@ static void makeVlToString(AstNodeUOrStructDType* nodep) {
}
stmt += VIdProtect::protect(itemp->prettyName()) + ":\" + ";
stmt += V3Common::makeToStringCall(itemp->dtypep(), "obj."s + itemp->nameProtect());
stmt += ";\n";
stmt += ";";
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "out += \"}\";\n"});
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "return out;\n"});
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "out += \"}\";"});
AstCExpr* const exprp = new AstCExpr{nodep->fileline(), "out", 0};
exprp->dtypeSetString();
funcp->addStmtsp(new AstCReturn{nodep->fileline(), exprp});
modp->addStmtsp(funcp);
}
static void makeToString(AstClass* nodep) {
@ -121,7 +125,7 @@ static void makeToStringMiddle(AstClass* nodep) {
funcp->isConst(true);
funcp->isStatic(false);
funcp->protect(false);
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;\n"});
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;"});
std::string comma;
for (AstNode* itemp = nodep->membersp(); itemp; itemp = itemp->nextp()) {
if (const auto* const varp = VN_CAST(itemp, Var)) {
@ -135,7 +139,7 @@ static void makeToStringMiddle(AstClass* nodep) {
stmt += itemp->origNameProtect();
stmt += ":\" + ";
stmt += V3Common::makeToStringCall(itemp->dtypep(), itemp->nameProtect());
stmt += ";\n";
stmt += ";";
nodep->user1(true); // So what we extend dumps this
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
@ -146,11 +150,15 @@ static void makeToStringMiddle(AstClass* nodep) {
if (!comma.empty()) stmt += "\", \"+ ";
// comma = ", "; // Nothing further so not needed
stmt += EmitCUtil::prefixNameProtect(nodep->extendsp()->dtypep());
stmt += "::to_string_middle();\n";
stmt += "::to_string_middle();";
nodep->user1(true); // So what we extend dumps this
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "return out;\n"});
AstCExpr* const exprp = new AstCExpr{nodep->fileline(), "out", 0};
exprp->dtypeSetString();
funcp->addStmtsp(new AstCReturn{nodep->fileline(), exprp});
nodep->addStmtsp(funcp);
}

View File

@ -1161,7 +1161,7 @@ class DelayedVisitor final : public VNVisitor {
AstTextBlock* const blockp = new AstTextBlock{flp};
blockp->addText(flp, "vlSymsp->fireEvent(", true);
blockp->addNodesp(eventp);
blockp->addText(flp, ");\n", true);
blockp->addText(flp, ");", true);
AstNode* newp = new AstCStmt{flp, blockp};
if (nodep->isDelayed()) {

View File

@ -378,7 +378,7 @@ public:
});
if (m_instantiatesOwnProcess) {
AstNode* const vlprocp = new AstCStmt{
nodep->fileline(), "VlProcessRef vlProcess = std::make_shared<VlProcess>();\n"};
nodep->fileline(), "VlProcessRef vlProcess = std::make_shared<VlProcess>();"};
nodep->stmtsp()->addHereThisAsNext(vlprocp);
}
@ -1246,6 +1246,7 @@ public:
void visit(AstCStmt* nodep) override {
putnbs(nodep, "");
iterateAndNextConstNull(nodep->exprsp());
puts("\n");
}
void visit(AstCExpr* nodep) override {
putnbs(nodep, "");

View File

@ -927,18 +927,17 @@ void addMTaskToFunction(const ThreadSchedule& schedule, const uint32_t threadId,
modp->addStmtsp(varp);
// For now, reference is still via text bashing
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitBegin();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitBegin();");
}
addStrStmt("vlSelf->" + name + +".waitUntilUpstreamDone(even_cycle);\n");
addStrStmt("vlSelf->" + name + +".waitUntilUpstreamDone(even_cycle);");
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitEnd();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitEnd();");
}
}
if (v3Global.opt.profPgo()) {
// No lock around startCounter, as counter numbers are unique per thread
addStrStmt("vlSymsp->_vm_pgoProfiler.startCounter(" + std::to_string(mtaskp->id())
+ ");\n");
addStrStmt("vlSymsp->_vm_pgoProfiler.startCounter(" + std::to_string(mtaskp->id()) + ");");
}
// Move the actual body into this function
@ -946,8 +945,7 @@ void addMTaskToFunction(const ThreadSchedule& schedule, const uint32_t threadId,
if (v3Global.opt.profPgo()) {
// No lock around stopCounter, as counter numbers are unique per thread
addStrStmt("vlSymsp->_vm_pgoProfiler.stopCounter(" + std::to_string(mtaskp->id())
+ ");\n");
addStrStmt("vlSymsp->_vm_pgoProfiler.stopCounter(" + std::to_string(mtaskp->id()) + ");");
}
// For any dependent mtask that's on another thread, signal one dependency completion.
@ -955,7 +953,7 @@ void addMTaskToFunction(const ThreadSchedule& schedule, const uint32_t threadId,
const ExecMTask* const nextp = edge.top()->as<ExecMTask>();
if (schedule.threadId(nextp) != threadId && schedule.contains(nextp)) {
addStrStmt("vlSelf->__Vm_mtaskstate_" + cvtToStr(nextp->id())
+ ".signalUpstreamDone(even_cycle);\n");
+ ".signalUpstreamDone(even_cycle);");
}
}
}
@ -993,7 +991,7 @@ const std::vector<AstCFunc*> createThreadFunctions(const ThreadSchedule& schedul
// Unblock the fake "final" mtask when this thread is finished
funcp->addStmtsp(new AstCStmt{fl, "vlSelf->__Vm_mtaskstate_final__"
+ cvtToStr(schedule.id()) + tag
+ ".signalUpstreamDone(even_cycle);\n"});
+ ".signalUpstreamDone(even_cycle);"});
}
// Create the fake "final" mtask state variable
@ -1020,13 +1018,12 @@ void addThreadStartWrapper(AstExecGraph* const execGraphp) {
};
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).execGraphBegin();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).execGraphBegin();");
}
addStrStmt("vlSymsp->__Vm_even_cycle__" + tag + " = !vlSymsp->__Vm_even_cycle__" + tag
+ ";\n");
addStrStmt("vlSymsp->__Vm_even_cycle__" + tag + " = !vlSymsp->__Vm_even_cycle__" + tag + ";");
if (!v3Global.opt.hierBlocks().empty()) addStrStmt("std::vector<size_t> indexes;\n");
if (!v3Global.opt.hierBlocks().empty()) addStrStmt("std::vector<size_t> indexes;");
}
void addThreadEndWrapper(AstExecGraph* const execGraphp) {
@ -1036,9 +1033,9 @@ void addThreadEndWrapper(AstExecGraph* const execGraphp) {
execGraphp->addStmtsp(new AstCStmt{flp, stmt});
};
addStrStmt("Verilated::mtaskId(0);\n");
addStrStmt("Verilated::mtaskId(0);");
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).execGraphEnd();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).execGraphEnd();");
}
}
void addThreadStartToExecGraph(AstExecGraph* const execGraphp,
@ -1057,9 +1054,8 @@ void addThreadStartToExecGraph(AstExecGraph* const execGraphp,
const uint32_t last = funcps.size() - 1;
if (!v3Global.opt.hierBlocks().empty() && last > 0) {
addStrStmt(
"for (size_t i = 0; i < " + cvtToStr(last)
+ "; ++i) indexes.push_back(vlSymsp->__Vm_threadPoolp->assignWorkerIndex());\n");
addStrStmt("for (size_t i = 0; i < " + cvtToStr(last)
+ "; ++i) indexes.push_back(vlSymsp->__Vm_threadPoolp->assignWorkerIndex());");
}
uint32_t i = 0;
for (AstCFunc* const funcp : funcps) {
@ -1085,16 +1081,16 @@ void addThreadStartToExecGraph(AstExecGraph* const execGraphp,
V3Stats::addStatSum("Optimizations, Thread schedule total tasks", i);
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitBegin();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitBegin();");
}
addStrStmt("vlSelf->__Vm_mtaskstate_final__" + std::to_string(scheduleId) + tag
+ ".waitUntilUpstreamDone(vlSymsp->__Vm_even_cycle__" + tag + ");\n");
+ ".waitUntilUpstreamDone(vlSymsp->__Vm_even_cycle__" + tag + ");");
if (v3Global.opt.profExec()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitEnd();\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).threadScheduleWaitEnd();");
}
// Free all assigned worker indices in this section
if (!v3Global.opt.hierBlocks().empty() && last > 0) {
addStrStmt("vlSymsp->__Vm_threadPoolp->freeWorkerIndexes(indexes);\n");
addStrStmt("vlSymsp->__Vm_threadPoolp->freeWorkerIndexes(indexes);");
}
}
@ -1116,31 +1112,31 @@ void wrapMTaskBodies(AstExecGraph* const execGraphp) {
funcp->addStmtsp(new AstCStmt{flp, stmt});
};
addStrStmt("static constexpr unsigned taskId = " + cvtToStr(mtaskp->id()) + ";\n");
addStrStmt("static constexpr unsigned taskId = " + cvtToStr(mtaskp->id()) + ";");
if (v3Global.opt.profExec()) {
const string& predictStart = std::to_string(mtaskp->predictStart());
if (v3Global.opt.hierChild()) {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).mtaskBegin(taskId, " + predictStart
+ ", \"" + v3Global.opt.topModule() + "\");\n");
+ ", \"" + v3Global.opt.topModule() + "\");");
} else {
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).mtaskBegin(taskId, " + predictStart
+ ");\n");
+ ");");
}
}
// Set mtask ID in the run-time system
addStrStmt("Verilated::mtaskId(taskId);\n");
addStrStmt("Verilated::mtaskId(taskId);");
// Run body
funcp->addStmtsp(mtaskBodyp->stmtsp()->unlinkFrBackWithNext());
// Flush message queue
addStrStmt("Verilated::endOfThreadMTask(vlSymsp->__Vm_evalMsgQp);\n");
addStrStmt("Verilated::endOfThreadMTask(vlSymsp->__Vm_evalMsgQp);");
if (v3Global.opt.profExec()) {
const string& predictCost = std::to_string(mtaskp->cost());
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).mtaskEnd(" + predictCost + ");\n");
addStrStmt("VL_EXEC_TRACE_ADD_RECORD(vlSymsp).mtaskEnd(" + predictCost + ");");
}
// AstMTask will simply contain a call

View File

@ -125,8 +125,8 @@ AstCFunc* V3Order::order(AstNetlist* netlistp, //
if (v3Global.opt.profExec()) {
const string name
= (v3Global.opt.hierChild() ? (v3Global.opt.topModule() + " ") : "") + "func " + tag;
funcp->addStmtsp(new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\""
+ name + "\");\n"});
funcp->addStmtsp(
new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"" + name + "\");"});
}
// Build the OrderGraph
@ -155,7 +155,7 @@ AstCFunc* V3Order::order(AstNetlist* netlistp, //
for (auto* const lbsp : logic) lbsp->deleteActives();
if (v3Global.opt.profExec()) {
funcp->addStmtsp(new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();\n"});
funcp->addStmtsp(new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();"});
}
// Done

View File

@ -502,12 +502,12 @@ class ProtectVisitor final : public VNVisitor {
m_comboAssignsp->addText(fl,
varp->prettyName() + " = " + varp->prettyName() + "_combo__V;\n");
m_cComboParamsp->addText(fl, varp->dpiArgType(true, false) + "\n");
m_cComboOutsp->addText(fl,
V3Task::assignInternalToDpi(varp, true, "", "", "handlep__V->"));
m_cComboOutsp->addText(fl, V3Task::assignInternalToDpi(varp, true, "", "", "handlep__V->")
+ "\n");
if (m_hasClk) {
m_cSeqParamsp->addText(fl, varp->dpiArgType(true, false) + "\n");
m_cSeqOutsp->addText(fl,
V3Task::assignInternalToDpi(varp, true, "", "", "handlep__V->"));
m_cSeqOutsp->addText(
fl, V3Task::assignInternalToDpi(varp, true, "", "", "handlep__V->") + "\n");
}
}

View File

@ -2599,7 +2599,7 @@ AstFunc* V3Randomize::newSRandomFunc(VMemberMap& memberMap, AstClass* nodep) {
funcp->isVirtual(false);
basep->addMembersp(funcp);
memberMap.insert(nodep, funcp);
funcp->addStmtsp(new AstCStmt{basep->fileline(), "__Vm_rng.srandom(seed);\n"});
funcp->addStmtsp(new AstCStmt{basep->fileline(), "__Vm_rng.srandom(seed);"});
basep->needRNG(true);
}
return funcp;

View File

@ -176,11 +176,11 @@ AstNodeStmt* checkIterationLimit(AstNetlist* netlistp, const string& name, AstVa
AstNodeStmt* profExecSectionPush(FileLine* flp, const string& section) {
const string name
= (v3Global.opt.hierChild() ? (v3Global.opt.topModule() + " ") : "") + section;
return new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"" + name + "\");\n"};
return new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"" + name + "\");"};
}
AstNodeStmt* profExecSectionPop(FileLine* flp) {
return new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();\n"};
return new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();"};
}
struct EvalLoop final {
@ -668,8 +668,7 @@ const TriggerKit createTriggers(AstNetlist* netlistp, AstCFunc* const initFuncp,
callp->dtypeSetBit();
AstIf* const ifp = new AstIf{flp, callp};
dumpp->addStmtsp(ifp);
ifp->addElsesp(
new AstText{flp, "VL_DBG_MSGF(\" No triggers active\\n\");\n", true});
ifp->addElsesp(new AstCStmt{flp, "VL_DBG_MSGF(\" No triggers active\\n\");"});
}
// Set the given trigger to the given value

View File

@ -346,7 +346,7 @@ void transformForks(AstNetlist* const netlistp) {
if (nodep->isCoroutine() && m_awaitMoved
&& !nodep->stmtsp()->exists([](AstCAwait*) { return true; })) {
// co_return at the end (either that or a co_await is required in a coroutine
nodep->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;\n"});
nodep->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;"});
}
}
void visit(AstVar* nodep) override {
@ -389,7 +389,7 @@ void transformForks(AstNetlist* const netlistp) {
nodep->replaceWith(callp->makeStmt());
// If we're in a class, add a vlSymsp arg
if (m_inClass) {
newfuncp->addInitsp(new AstCStmt{nodep->fileline(), "VL_KEEP_THIS;\n"});
newfuncp->addInitsp(new AstCStmt{nodep->fileline(), "VL_KEEP_THIS;"});
newfuncp->argTypes(EmitCUtil::symClassVar());
callp->argTypes("vlSymsp");
}
@ -397,12 +397,12 @@ void transformForks(AstNetlist* const netlistp) {
newfuncp->addStmtsp(nodep->stmtsp()->unlinkFrBackWithNext());
if (nodep->needProcess()) {
newfuncp->setNeedProcess();
newfuncp->addStmtsp(new AstCStmt{nodep->fileline(),
"vlProcess->state(VlProcess::FINISHED);\n"});
newfuncp->addStmtsp(
new AstCStmt{nodep->fileline(), "vlProcess->state(VlProcess::FINISHED);"});
}
if (!m_beginHasAwaits) {
// co_return at the end (either that or a co_await is required in a coroutine
newfuncp->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;\n"});
newfuncp->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;"});
} else {
m_awaitMoved = true;
}

View File

@ -753,7 +753,7 @@ class TaskVisitor final : public VNVisitor {
}
static AstNode* createDpiTemp(AstVar* portp, const string& suffix) {
const string stmt = portp->dpiTmpVarType(portp->name() + suffix) + ";\n";
const string stmt = portp->dpiTmpVarType(portp->name() + suffix) + ";";
return new AstCStmt{portp->fileline(), stmt};
}
@ -826,7 +826,7 @@ class TaskVisitor final : public VNVisitor {
linesp->addNext(srcp);
linesp->addNext(
new AstText{portvscp->fileline(),
", " + frName + " + " + cvtToStr(i * widthWords) + ");\n"});
", " + frName + " + " + cvtToStr(i * widthWords) + ");"});
stmtp = new AstCStmt{portvscp->fileline(), linesp};
} else {
string from = frstmt;
@ -877,22 +877,26 @@ class TaskVisitor final : public VNVisitor {
// We could use 64-bits of a MD5/SHA hash rather than a string here,
// but the compare is only done on first call then memoized, so
// it's not worth optimizing.
string stmt;
// Static doesn't need save-restore as if below will re-fill proper value
stmt += "static int __Vfuncnum = -1;\n";
funcp->addStmtsp(new AstCStmt{nodep->fileline(), "static int __Vfuncnum = -1;"});
// First time init (faster than what the compiler does if we did a singleton
stmt += "if (VL_UNLIKELY(__Vfuncnum == -1)) __Vfuncnum = Verilated::exportFuncNum(\""
+ nodep->cname() + "\");\n";
funcp->addStmtsp(new AstCStmt{
nodep->fileline(),
"if (VL_UNLIKELY(__Vfuncnum == -1)) __Vfuncnum = Verilated::exportFuncNum(\""
+ nodep->cname() + "\");"});
// If the find fails, it will throw an error
stmt += "const VerilatedScope* const __Vscopep = Verilated::dpiScope();\n";
funcp->addStmtsp(
new AstCStmt{nodep->fileline(),
"const VerilatedScope* const __Vscopep = Verilated::dpiScope();"});
// If dpiScope is fails and is null; the exportFind function throws and error
// If __Vcb is null the exportFind function throws and error
const string cbtype
= VIdProtect::protect(v3Global.opt.prefix() + "__Vcb_" + nodep->cname() + "_t");
stmt += cbtype + " __Vcb = (" + cbtype
+ ")(VerilatedScope::exportFind(__Vscopep, __Vfuncnum));\n"; // Can't use
// static_cast
// If __Vcb is null the exportFind function throws and error
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
funcp->addStmtsp(
new AstCStmt{nodep->fileline(),
cbtype + " __Vcb = (" + cbtype + ")(" // Can't use static_cast
+ "VerilatedScope::exportFind(__Vscopep, __Vfuncnum));"});
}
// Convert input/inout DPI arguments to Internal types
@ -973,7 +977,7 @@ class TaskVisitor final : public VNVisitor {
funcp->addStmtsp(createDpiTemp(rtnvarp, ""));
funcp->addStmtsp(createAssignInternalToDpi(rtnvarp, false, tmpSuffixp, ""));
string stmt = "return " + rtnvarp->name(); // TODO use AstCReturn?
stmt += rtnvarp->basicp()->isDpiPrimitive() ? ";\n" : "[0];\n";
stmt += rtnvarp->basicp()->isDpiPrimitive() ? ";"s : "[0];"s;
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
if (!makePortList(nodep, funcp)) return nullptr;
@ -1081,7 +1085,7 @@ class TaskVisitor final : public VNVisitor {
if (v3Global.opt.profExec())
cfuncp->addStmtsp(
new AstCStmt{nodep->fileline(),
"VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"dpiimports\");\n"});
"VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"dpiimports\");"});
// Convert input/inout arguments to DPI types
string args;
@ -1137,7 +1141,7 @@ class TaskVisitor final : public VNVisitor {
// Store context, if needed
if (nodep->dpiContext()) {
const string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);\n";
const string stmt = "Verilated::dpiContext(__Vscopep, __Vfilenamep, __Vlineno);";
cfuncp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
@ -1171,7 +1175,7 @@ class TaskVisitor final : public VNVisitor {
if (v3Global.opt.profExec())
cfuncp->addStmtsp(new AstCStmt{nodep->fileline(),
"VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();\n"});
"VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();"});
}
AstVarScope* getDpiExporTrigger() {
@ -1302,7 +1306,7 @@ class TaskVisitor final : public VNVisitor {
if (!nodep->dpiImport() && !nodep->taskPublic()) {
// Need symbol table
if (cfuncp->name() == "new") {
const string stmt = VIdProtect::protect("_ctor_var_reset") + "(vlSymsp);\n";
const string stmt = VIdProtect::protect("_ctor_var_reset") + "(vlSymsp);";
cfuncp->addInitsp(new AstCStmt{nodep->fileline(), stmt});
}
}
@ -2020,7 +2024,7 @@ string V3Task::assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSu
}
if (isString) stmt += ".c_str()";
}
stmt += ket + ";\n";
stmt += ket + ";";
return stmt;
}

View File

@ -787,7 +787,7 @@ class TimingControlVisitor final : public VNVisitor {
visit(static_cast<AstNodeProcedure*>(nodep));
if (nodep->needProcess() && !nodep->user1SetOnce()) {
nodep->addStmtsp(
new AstCStmt{nodep->fileline(), "vlProcess->state(VlProcess::FINISHED);\n"});
new AstCStmt{nodep->fileline(), "vlProcess->state(VlProcess::FINISHED);"});
}
}
void visit(AstJumpBlock* nodep) override {
@ -833,7 +833,7 @@ class TimingControlVisitor final : public VNVisitor {
nodep->rtnType("VlCoroutine");
// If in a class, create a shared pointer to 'this'
if (m_classp) nodep->addInitsp(new AstCStmt{nodep->fileline(), "VL_KEEP_THIS;\n"});
if (m_classp) nodep->addInitsp(new AstCStmt{nodep->fileline(), "VL_KEEP_THIS;"});
AstNode* firstCoStmtp = nullptr; // First co_* statement in the function
nodep->exists([&](AstCAwait* const awaitp) -> bool { return (firstCoStmtp = awaitp); });
if (!firstCoStmtp) {
@ -841,7 +841,7 @@ class TimingControlVisitor final : public VNVisitor {
// overridden by a suspendable, but doesn't have any awaits itself). Add a
// co_return at the end (either that or a co_await is required in a
// coroutine)
firstCoStmtp = new AstCStmt{nodep->fileline(), "co_return;\n"};
firstCoStmtp = new AstCStmt{nodep->fileline(), "co_return;"};
nodep->addStmtsp(firstCoStmtp);
}
if (nodep->dpiExportImpl()) {

View File

@ -736,13 +736,16 @@ class TraceVisitor final : public VNVisitor {
cleanupFuncp->addInitsp(new AstCStmt{fl, EmitCUtil::symClassAssign()});
// Register it
m_regFuncp->addStmtsp(new AstText{fl, "tracep->addCleanupCb(", true});
m_regFuncp->addStmtsp(new AstAddrOfCFunc{fl, cleanupFuncp});
m_regFuncp->addStmtsp(new AstText{fl, ", vlSelf);\n", true});
{
AstNode* const argsp = new AstText{fl, "tracep->addCleanupCb(", true};
argsp->addNext(new AstAddrOfCFunc{fl, cleanupFuncp});
argsp->addNext(new AstText{fl, ", vlSelf);"});
m_regFuncp->addStmtsp(new AstCStmt{fl, argsp});
}
// Clear global activity flag
cleanupFuncp->addStmtsp(
new AstCStmt{m_topScopep->fileline(), "vlSymsp->__Vm_activity = false;\n"s});
new AstCStmt{m_topScopep->fileline(), "vlSymsp->__Vm_activity = false;"s});
// Clear fine grained activity flags
for (uint32_t i = 0; i < m_activityNumber; ++i) {

View File

@ -222,7 +222,7 @@ class TraceDeclVisitor final : public VNVisitor {
const string n = cvtToStr(m_subFuncps.size());
const string name{"trace_init_sub__" + m_currScopep->nameDotless() + "__" + n};
AstCFunc* const funcp = newCFunc(flp, name);
funcp->addInitsp(new AstCStmt{flp, "const int c = vlSymsp->__Vm_baseCode;\n"});
funcp->addInitsp(new AstCStmt{flp, "const int c = vlSymsp->__Vm_baseCode;"});
m_subFuncps.push_back(funcp);
}
m_subFuncps.back()->addStmtsp(stmtp);

File diff suppressed because it is too large Load Diff

View File

@ -639,7 +639,9 @@
</not>
</and>
<begin>
<text loc="d,11,8,11,9"/>
<cstmt loc="d,11,8,11,9">
<text loc="d,11,8,11,9"/>
</cstmt>
</begin>
</if>
<if loc="d,11,8,11,9">
@ -666,7 +668,9 @@
</not>
</and>
<begin>
<text loc="d,11,8,11,9"/>
<cstmt loc="d,11,8,11,9">
<text loc="d,11,8,11,9"/>
</cstmt>
</begin>
</if>
<if loc="d,11,8,11,9">