From 41bb54bc2c47d2abc0ee41015b6e584ac50917d0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 25 Jan 2025 13:35:56 -0500 Subject: [PATCH] Add Makefile targets count to stats --- src/V3EmitMk.cpp | 17 +++++++++++++---- test_regress/t/t_flag_csplit_groups.py | 6 ++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index f87463f34..4ffd6a29f 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -479,6 +479,9 @@ class EmitMk final { using FileOrConcatenatedFilesList = EmitGroup::FileOrConcatenatedFilesList; using FilenameWithScore = EmitGroup::FilenameWithScore; + // MEMBERS + double m_putClassCount = 0; // Number of classEntries printed + public: // METHODS @@ -494,6 +497,7 @@ public: void putMakeClassEntry(V3OutMkFile& of, const string& name) { of.puts("\t" + V3Os::filenameNonDirExt(name) + " \\\n"); + ++m_putClassCount; } void emitClassMake() { @@ -577,9 +581,12 @@ public: } else { of.puts(", fast-path, compile with highest optimization\n"); } - of.puts(support == 2 ? "VM_GLOBAL" : support == 1 ? "VM_SUPPORT" : "VM_CLASSES"); - of.puts(slow ? "_SLOW" : "_FAST"); - of.puts(" += \\\n"); + const string targetVar = (support == 2 ? "VM_GLOBAL"s + : support == 1 ? "VM_SUPPORT"s + : "VM_CLASSES"s) + + (slow ? "_SLOW" : "_FAST"); + m_putClassCount = 0; + of.puts(targetVar + " += \\\n"); if (support == 2 && v3Global.opt.hierChild()) { // Do nothing because VM_GLOBAL is necessary per executable. Top module will // have them. @@ -605,7 +612,7 @@ public: const std::vector& list = slow ? vmClassesSlowList : vmClassesFastList; for (const FileOrConcatenatedFilesList& entry : list) { - if (entry.isConcatenatingFile()) { emitConcatenatingFile(entry); } + if (entry.isConcatenatingFile()) emitConcatenatingFile(entry); putMakeClassEntry(of, entry.m_filename); } } else { @@ -619,6 +626,7 @@ public: } } of.puts("\n"); + V3Stats::addStat("Makefile targets, " + targetVar, m_putClassCount); } } @@ -808,6 +816,7 @@ public: }; //###################################################################### + class EmitMkHierVerilation final { const V3HierBlockPlan* const m_planp; const string m_makefile; // path of this makefile diff --git a/test_regress/t/t_flag_csplit_groups.py b/test_regress/t/t_flag_csplit_groups.py index 8fe9707ba..467fe6ad4 100755 --- a/test_regress/t/t_flag_csplit_groups.py +++ b/test_regress/t/t_flag_csplit_groups.py @@ -87,6 +87,7 @@ test.compile(v_flags2=["--trace", "--output-groups 2", "--output-split-cfuncs 1", "--exe", + "--stats", "../" + test.main_filename], verilator_make_gmake=False) # yapf:disable @@ -122,4 +123,9 @@ test.file_grep(test.obj_dir + "/" + test.vm_prefix + "_classes.mk", "vm_classes_ test.file_grep_not(test.obj_dir + "/" + test.vm_prefix + "_classes.mk", "vm_classes_Slow_2") test.file_grep_not(test.obj_dir + "/" + test.vm_prefix + "_classes.mk", "vm_classes_2") +# Check combine count +test.file_grep(test.stats, r'Node count, CFILE + (\d+)', (174 if test.vltmt else 156)) +test.file_grep(test.stats, r'Makefile targets, VM_CLASSES_FAST + (\d+)', (2 if test.vltmt else 3)) +test.file_grep(test.stats, r'Makefile targets, VM_CLASSES_SLOW + (\d+)', 2) + test.passes()