[llvm] 56d2c62 - [SandboxVec][Interval] Add print() and dump()

Vasileios Porpodas via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 15:27:27 PDT 2024


Author: Vasileios Porpodas
Date: 2024-10-08T15:27:07-07:00
New Revision: 56d2c626f75e86923facefb9f0c27c94152afc50

URL: https://github.com/llvm/llvm-project/commit/56d2c626f75e86923facefb9f0c27c94152afc50
DIFF: https://github.com/llvm/llvm-project/commit/56d2c626f75e86923facefb9f0c27c94152afc50.diff

LOG: [SandboxVec][Interval] Add print() and dump()

Added: 
    llvm/lib/Transforms/Vectorize/SandboxVectorizer/Interval.cpp

Modified: 
    llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
    llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h
    llvm/lib/Transforms/Vectorize/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
index 6333f0b81f9c33..7bc920537faf41 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
@@ -110,7 +110,7 @@ class DGNode {
 
 #ifndef NDEBUG
   virtual void print(raw_ostream &OS, bool PrintDeps = true) const;
-  friend raw_ostream &operator<<(DGNode &N, raw_ostream &OS) {
+  friend raw_ostream &operator<<(raw_ostream &OS, DGNode &N) {
     N.print(OS);
     return OS;
   }

diff  --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h
index 58ae3c06620fad..b05294d70a3e0c 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h
@@ -13,7 +13,7 @@
 //
 // This is currently used for Instruction intervals.
 // It provides an API for some basic operations on the interval, including some
-// simple set operations, like union, interseciton and others.
+// simple set operations, like union, intersection and others.
 //
 //===----------------------------------------------------------------------===//
 
@@ -21,6 +21,7 @@
 #define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_INSTRINTERVAL_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include <iterator>
 
 namespace llvm::sandboxir {
@@ -197,6 +198,27 @@ template <typename T> class Interval {
     auto *NewTo = To->comesBefore(Other.To) ? Other.To : To;
     return {NewFrom, NewTo};
   }
+
+#ifndef NDEBUG
+  void print(raw_ostream &OS) const {
+    auto *Top = top();
+    auto *Bot = bottom();
+    OS << "Top: ";
+    if (Top != nullptr)
+      OS << *Top;
+    else
+      OS << "nullptr";
+    OS << "\n";
+
+    OS << "Bot: ";
+    if (Bot != nullptr)
+      OS << *Bot;
+    else
+      OS << "nullptr";
+    OS << "\n";
+  }
+  LLVM_DUMP_METHOD void dump() const;
+#endif
 };
 
 } // namespace llvm::sandboxir

diff  --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index 887c2089c5a520..9c2e7c1e0c5bc7 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMVectorize
   LoopVectorizationLegality.cpp
   LoopVectorize.cpp
   SandboxVectorizer/DependencyGraph.cpp
+  SandboxVectorizer/Interval.cpp
   SandboxVectorizer/Passes/BottomUpVec.cpp
   SandboxVectorizer/SandboxVectorizer.cpp
   SandboxVectorizer/SeedCollector.cpp

diff  --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Interval.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Interval.cpp
new file mode 100644
index 00000000000000..79b37444195359
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Interval.cpp
@@ -0,0 +1,22 @@
+//===- Interval.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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h"
+#include "llvm/SandboxIR/Instruction.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h"
+
+namespace llvm::sandboxir {
+
+template class Interval<Instruction>;
+template class Interval<MemDGNode>;
+
+#ifndef NDEBUG
+template <typename T> void Interval<T>::dump() const { print(dbgs()); }
+#endif
+} // namespace llvm::sandboxir


        


More information about the llvm-commits mailing list