[llvm] [MCA] New option -scheduling-info (PR #130574)
    Min-Yih Hsu via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Mar 17 10:42:23 PDT 2025
    
    
  
================
@@ -14,13 +14,45 @@
 #include "Views/InstructionInfoView.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Support/WithColor.h"
 
 namespace llvm {
 namespace mca {
 
+void InstructionInfoView::getComment(const MCInst &MCI,
+                                     std::string &CommentString) const {
+  StringRef s = MCI.getLoc().getPointer();
+  std::string InstrStr;
+  size_t pos = 0, pos_cmt = 0;
+
+  // Recognized comments are after assembly instructions on the same line.
+  // It is usefull to add in comment scheduling information from architecture
+  // specification.
+  // '#' comment mark is not supported by llvm-mca
+
+  CommentString = "";
+  if ((pos = s.find("\n")) != std::string::npos) {
+    InstrStr = s.substr(0, pos);
----------------
mshockwave wrote:
could we use `StringRef::take_front`?
https://github.com/llvm/llvm-project/pull/130574
    
    
More information about the llvm-commits
mailing list