Reland and fix "Fix wide enum names" (#8344) (#8362) (#8365) (#8366)

This commit is contained in:
Marco Bartoli
2026-09-16 17:47:51 -04:00
committed by GitHub
parent 9f66980355
commit 08cadc034d
23 changed files with 910 additions and 158 deletions
+13 -1
View File
@@ -304,7 +304,11 @@ void EmitCFunc::displayNode(AstNode* nodep, AstSFormatF* fmtp, // fmtp is nullp
int argc = 0;
if (needsScope) ++argc;
if (needsTimescale) ++argc;
for (AstNode* argp = exprsp; argp; argp = argp->nextp()) ++argc;
for (AstNode* argp = exprsp; argp; argp = argp->nextp()) {
++argc;
const AstSFormatArg* const fargp = VN_CAST(argp, SFormatArg);
if (fargp && fargp->formatAttr().isEnum()) ++argc; // Additional name argument
}
ofp()->puts("," + std::to_string(argc));
if (needsScope) {
@@ -345,7 +349,9 @@ void EmitCFunc::displayNode(AstNode* nodep, AstSFormatF* fmtp, // fmtp is nullp
if (formatAttr.isSigned() || formatAttr.isUnsigned() || formatAttr.isEnum())
puts("," + cvtToStr(subargp->widthMin()));
const bool addrof = isScan || formatAttr.isString() || formatAttr.isComplex();
const bool wideEnum = formatAttr.isEnum() && subargp->isWide();
puts(",");
if (wideEnum) puts("static_cast<const EData*>(");
if (addrof) puts("&(");
if (VN_IS(subargp, StreamR))
emitStreamR(
@@ -354,6 +360,12 @@ void EmitCFunc::displayNode(AstNode* nodep, AstSFormatF* fmtp, // fmtp is nullp
else { iterateConst(subargp); }
if (addrof) puts(")");
if (!addrof) emitDatap(argp);
if (wideEnum) puts(")");
if (formatAttr.isEnum()) {
puts(", '"s + VFormatAttr{VFormatAttr::STRING}.ascii() + "', &(");
iterateConst(fargp->namep());
puts(")");
}
ofp()->indentDec();
}