[llvm] [llvm-remarkutil] Add an instruction-mix tool (PR #140598)
Tobias Stadler via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 09:36:21 PDT 2025
================
@@ -0,0 +1,150 @@
+//===- RemarkInstructionMix.cpp -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Generic tool to extract instruction mix from asm-printer remarks.
+//
+//===----------------------------------------------------------------------===//
+
+#include "RemarkUtilHelpers.h"
+#include "RemarkUtilRegistry.h"
+
+#include "llvm/Support/Format.h"
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/Regex.h"
+
+#include <cmath>
+#include <numeric>
+
+using namespace llvm;
+using namespace remarks;
+using namespace llvm::remarkutil;
+
+namespace instructionmix {
+
+static cl::SubCommand
+ InstructionMix("instruction-mix",
+ "Instruction Mix (requires asm-printer remarks)");
+
+static cl::opt<std::string>
+ FunctionFilter("filter", cl::sub(InstructionMix), cl::ValueOptional,
+ cl::desc("Optional function name to filter collection by"));
+
+static cl::opt<std::string>
+ FunctionFilterRE("rfilter", cl::sub(InstructionMix), cl::ValueOptional,
+ cl::desc("Optional function name to filter collection by "
+ "(accepts regular expressions)"));
+
+enum ReportStyleOptions { human_output, csv_output };
+static cl::opt<ReportStyleOptions> ReportStyle(
+ "report_style", cl::sub(InstructionMix),
+ cl::init(ReportStyleOptions::human_output),
+ cl::desc("Choose the report output format:"),
+ cl::values(clEnumValN(human_output, "human", "Human-readable format"),
+ clEnumValN(csv_output, "csv", "CSV format")));
+
+INPUT_FORMAT_COMMAND_LINE_OPTIONS(InstructionMix)
+INPUT_OUTPUT_COMMAND_LINE_OPTIONS(InstructionMix)
+
+static Expected<FilterMatcher> getRemarkFilter() {
----------------
tobias-stadler wrote:
createExactOrRE
https://github.com/llvm/llvm-project/pull/140598
More information about the llvm-commits
mailing list