From ef3b2b03803a9df681dd5a4fb490259ab420c3b6 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Mon, 26 Jan 2026 22:59:20 +0100 Subject: [PATCH 1/4] linux_perf: mark internal, fix help formatting --- passes/cmds/linux_perf.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/passes/cmds/linux_perf.cc b/passes/cmds/linux_perf.cc index f57a887fb..5c2c23b6a 100644 --- a/passes/cmds/linux_perf.cc +++ b/passes/cmds/linux_perf.cc @@ -29,9 +29,14 @@ PRIVATE_NAMESPACE_BEGIN #ifdef __linux__ struct LinuxPerf : public Pass { - LinuxPerf() : Pass("linux_perf", "turn linux perf recording off or on") { } + LinuxPerf() : Pass("linux_perf", "turn linux perf recording off or on") { + internal(); + } void help() override { + log("\n"); + log(" linux_perf [mode]\n"); + log("\n"); log("This pass turns Linux 'perf' profiling on or off, when it has been configured to use control FIFOs.\n"); log("\n"); log("Example shell command line:\n"); From aaebce7adc453c71c38cd3e3cab305518ff79174 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Wed, 14 Jan 2026 07:39:45 +1300 Subject: [PATCH 2/4] log_help: Don't reformat codeblocks --- kernel/log_help.cc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/kernel/log_help.cc b/kernel/log_help.cc index 93b91b08b..01c9a93f6 100644 --- a/kernel/log_help.cc +++ b/kernel/log_help.cc @@ -78,7 +78,7 @@ ContentListing* ContentListing::open_option(const string &text, } #define MAX_LINE_LEN 80 -void log_pass_str(const std::string &pass_str, std::string indent_str, bool leading_newline=false) { +void log_body_str(const std::string &pass_str, std::string indent_str, bool leading_newline=false, bool is_formatted=false) { if (pass_str.empty()) return; std::istringstream iss(pass_str); @@ -86,26 +86,30 @@ void log_pass_str(const std::string &pass_str, std::string indent_str, bool lead log("\n"); for (std::string line; std::getline(iss, line);) { log("%s", indent_str); - auto curr_len = indent_str.length(); - std::istringstream lss(line); - for (std::string word; std::getline(lss, word, ' ');) { - while (word[0] == '`' && word.back() == '`') - word = word.substr(1, word.length()-2); - if (curr_len + word.length() >= MAX_LINE_LEN-1) { - curr_len = 0; - log("\n%s", indent_str); - } - if (word.length()) { - log("%s ", word); - curr_len += word.length() + 1; + if (is_formatted) { + log("%s", line); + } else { + auto curr_len = indent_str.length(); + std::istringstream lss(line); + for (std::string word; std::getline(lss, word, ' ');) { + while (word[0] == '`' && word.back() == '`') + word = word.substr(1, word.length()-2); + if (curr_len + word.length() >= MAX_LINE_LEN-1) { + curr_len = 0; + log("\n%s", indent_str); + } + if (word.length()) { + log("%s ", word); + curr_len += word.length() + 1; + } } } log("\n"); } } -void log_pass_str(const std::string &pass_str, int indent=0, bool leading_newline=false) { +void log_body(const ContentListing &content, int indent=0, bool leading_newline=false) { std::string indent_str(indent*4, ' '); - log_pass_str(pass_str, indent_str, leading_newline); + log_body_str(content.body, indent_str, leading_newline, content.type.compare("code") == 0); } PrettyHelp *current_help = nullptr; @@ -134,16 +138,16 @@ void PrettyHelp::log_help() const { for (auto &content : _root_listing) { if (content.type.compare("usage") == 0) { - log_pass_str(content.body, 1, true); + log_body(content, 1, true); log("\n"); } else if (content.type.compare("option") == 0) { - log_pass_str(content.body, 1); + log_body(content, 1); for (auto text : content) { - log_pass_str(text.body, 2); + log_body(text, 2); log("\n"); } } else { - log_pass_str(content.body, 0); + log_body(content, 0); log("\n"); } } From 4031310ebb7b9d5278aa6373692184266dd9b3b6 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Wed, 28 Jan 2026 08:10:31 +1300 Subject: [PATCH 3/4] linux_perf.cc: Use formatted_help Gets the codeblock formatting better. Also fold the on|off into a single usage. --- passes/cmds/linux_perf.cc | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/passes/cmds/linux_perf.cc b/passes/cmds/linux_perf.cc index 5c2c23b6a..fcd529d78 100644 --- a/passes/cmds/linux_perf.cc +++ b/passes/cmds/linux_perf.cc @@ -32,28 +32,28 @@ struct LinuxPerf : public Pass { LinuxPerf() : Pass("linux_perf", "turn linux perf recording off or on") { internal(); } - void help() override + bool formatted_help() override { - log("\n"); - log(" linux_perf [mode]\n"); - log("\n"); - log("This pass turns Linux 'perf' profiling on or off, when it has been configured to use control FIFOs.\n"); - log("\n"); - log("Example shell command line:\n"); - log("mkfifo /tmp/perf.fifo /tmp/perf-ack.fifo\n"); - log("YOSYS_PERF_CTL=/tmp/perf.fifo YOSYS_PERF_ACK=/tmp/perf-ack.fifo \\\n"); - log(" perf record --latency --delay=-1 \\\n"); - log(" --control=fifo:/tmp/perf.fifo,/tmp/perf-ack.fifo --call-graph=dwarf ./yosys -dt -p \\\n"); - log(" \"read_rtlil design.rtlil; linux_perf on; opt_clean; linux_perf off\"\n"); - log("\n"); - log(" linux_perf on\n"); - log("\n"); - log("Start perf recording. YOSYS_PERF_CTL and YOSYS_PERF_ACK must point to Linux perf control FIFOs.\n"); - log("\n"); - log(" linux_perf off\n"); - log("\n"); - log("Stop perf recording.\n"); - log("\n"); + auto *help = PrettyHelp::get_current(); + + auto content_root = help->get_root(); + + content_root->usage("linux_perf [on|off]"); + + content_root->paragraph( + "This pass turns Linux 'perf' profiling on or off, when it has been configured to use control FIFOs." + "YOSYS_PERF_CTL and YOSYS_PERF_ACK must point to Linux perf control FIFOs." + ); + content_root->paragraph("Example shell command line:"); + content_root->codeblock( + "mkfifo /tmp/perf.fifo /tmp/perf-ack.fifo\n" + "YOSYS_PERF_CTL=/tmp/perf.fifo YOSYS_PERF_ACK=/tmp/perf-ack.fifo \\\n" + " perf record --latency --delay=-1 \\\n" + " --control=fifo:/tmp/perf.fifo,/tmp/perf-ack.fifo --call-graph=dwarf ./yosys -dt -p \\\n" + " \"read_rtlil design.rtlil; linux_perf on; opt_clean; linux_perf off\"\n" + ); + + return true; } void execute(std::vector args, RTLIL::Design *) override { From 8ed7ac04d887a68f3787ac37f75fd2cd08392313 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Wed, 28 Jan 2026 08:17:50 +1300 Subject: [PATCH 4/4] linux_perf.cc: Fix overlength codeblock --- passes/cmds/linux_perf.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/passes/cmds/linux_perf.cc b/passes/cmds/linux_perf.cc index fcd529d78..967ccd2f8 100644 --- a/passes/cmds/linux_perf.cc +++ b/passes/cmds/linux_perf.cc @@ -49,8 +49,8 @@ struct LinuxPerf : public Pass { "mkfifo /tmp/perf.fifo /tmp/perf-ack.fifo\n" "YOSYS_PERF_CTL=/tmp/perf.fifo YOSYS_PERF_ACK=/tmp/perf-ack.fifo \\\n" " perf record --latency --delay=-1 \\\n" - " --control=fifo:/tmp/perf.fifo,/tmp/perf-ack.fifo --call-graph=dwarf ./yosys -dt -p \\\n" - " \"read_rtlil design.rtlil; linux_perf on; opt_clean; linux_perf off\"\n" + " --control=fifo:/tmp/perf.fifo,/tmp/perf-ack.fifo --call-graph=dwarf ./yosys \\\n" + " -dt -p \"read_rtlil design.rtlil; linux_perf on; opt_clean; linux_perf off\"\n" ); return true;