[llvm] [MCA] Enable customization of individual instructions (PR #155420)

Roman Belenov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 22:03:22 PDT 2025


================
@@ -123,13 +126,41 @@ class Instrument {
   /// The instrumentation data
   const StringRef Data;
 
+  std::optional<unsigned> Latency;
+
 public:
-  Instrument(StringRef Desc, StringRef Data) : Desc(Desc), Data(Data) {}
+  Instrument(StringRef Desc, StringRef Data) : Desc(Desc), Data(Data) {
+    // Skip spaces and tabs.
+    unsigned Position = Data.find_first_not_of(" \t");
+    if (Position >= Data.size())
+      // We reached the end of the comment. Bail out.
+      return;
+    Data = Data.drop_front(Position);
+    auto [Name, Value] = Data.split(':');
+    if (Name.upper() == "LATENCY") {
+      Position = Value.find_first_not_of(" \t");
+      if (Position >= Value.size())
+        return;
+      auto Stripped = Value.drop_front(Position);
+      unsigned L = 0;
+      if (!Stripped.getAsInteger(10, L))
+        Latency = L;
+    }
+  }
 
   Instrument() : Instrument("", "") {}
 
   virtual ~Instrument() = default;
 
+  virtual bool canCustomize() const { return bool(Latency); }
+  virtual void customize(InstrDesc &ID) const {
----------------
r-belenov wrote:

Ping - any additional comments?

https://github.com/llvm/llvm-project/pull/155420


More information about the llvm-commits mailing list