Add Makefile targets count to stats

This commit is contained in:
Wilson Snyder 2025-01-25 13:35:56 -05:00
parent 001c098e5a
commit 41bb54bc2c
2 changed files with 19 additions and 4 deletions

View File

@ -479,6 +479,9 @@ class EmitMk final {
using FileOrConcatenatedFilesList = EmitGroup::FileOrConcatenatedFilesList; using FileOrConcatenatedFilesList = EmitGroup::FileOrConcatenatedFilesList;
using FilenameWithScore = EmitGroup::FilenameWithScore; using FilenameWithScore = EmitGroup::FilenameWithScore;
// MEMBERS
double m_putClassCount = 0; // Number of classEntries printed
public: public:
// METHODS // METHODS
@ -494,6 +497,7 @@ public:
void putMakeClassEntry(V3OutMkFile& of, const string& name) { void putMakeClassEntry(V3OutMkFile& of, const string& name) {
of.puts("\t" + V3Os::filenameNonDirExt(name) + " \\\n"); of.puts("\t" + V3Os::filenameNonDirExt(name) + " \\\n");
++m_putClassCount;
} }
void emitClassMake() { void emitClassMake() {
@ -577,9 +581,12 @@ public:
} else { } else {
of.puts(", fast-path, compile with highest optimization\n"); of.puts(", fast-path, compile with highest optimization\n");
} }
of.puts(support == 2 ? "VM_GLOBAL" : support == 1 ? "VM_SUPPORT" : "VM_CLASSES"); const string targetVar = (support == 2 ? "VM_GLOBAL"s
of.puts(slow ? "_SLOW" : "_FAST"); : support == 1 ? "VM_SUPPORT"s
of.puts(" += \\\n"); : "VM_CLASSES"s)
+ (slow ? "_SLOW" : "_FAST");
m_putClassCount = 0;
of.puts(targetVar + " += \\\n");
if (support == 2 && v3Global.opt.hierChild()) { if (support == 2 && v3Global.opt.hierChild()) {
// Do nothing because VM_GLOBAL is necessary per executable. Top module will // Do nothing because VM_GLOBAL is necessary per executable. Top module will
// have them. // have them.
@ -605,7 +612,7 @@ public:
const std::vector<FileOrConcatenatedFilesList>& list const std::vector<FileOrConcatenatedFilesList>& list
= slow ? vmClassesSlowList : vmClassesFastList; = slow ? vmClassesSlowList : vmClassesFastList;
for (const FileOrConcatenatedFilesList& entry : list) { for (const FileOrConcatenatedFilesList& entry : list) {
if (entry.isConcatenatingFile()) { emitConcatenatingFile(entry); } if (entry.isConcatenatingFile()) emitConcatenatingFile(entry);
putMakeClassEntry(of, entry.m_filename); putMakeClassEntry(of, entry.m_filename);
} }
} else { } else {
@ -619,6 +626,7 @@ public:
} }
} }
of.puts("\n"); of.puts("\n");
V3Stats::addStat("Makefile targets, " + targetVar, m_putClassCount);
} }
} }
@ -808,6 +816,7 @@ public:
}; };
//###################################################################### //######################################################################
class EmitMkHierVerilation final { class EmitMkHierVerilation final {
const V3HierBlockPlan* const m_planp; const V3HierBlockPlan* const m_planp;
const string m_makefile; // path of this makefile const string m_makefile; // path of this makefile

View File

@ -87,6 +87,7 @@ test.compile(v_flags2=["--trace",
"--output-groups 2", "--output-groups 2",
"--output-split-cfuncs 1", "--output-split-cfuncs 1",
"--exe", "--exe",
"--stats",
"../" + test.main_filename], "../" + test.main_filename],
verilator_make_gmake=False) # yapf:disable 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_Slow_2")
test.file_grep_not(test.obj_dir + "/" + test.vm_prefix + "_classes.mk", "vm_classes_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() test.passes()