Skip to content

Commit 56d2c62

Browse files
author
Vasileios Porpodas
committed
[SandboxVec][Interval] Add print() and dump()
1 parent c6d6da4 commit 56d2c62

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class DGNode {
110110

111111
#ifndef NDEBUG
112112
virtual void print(raw_ostream &OS, bool PrintDeps = true) const;
113-
friend raw_ostream &operator<<(DGNode &N, raw_ostream &OS) {
113+
friend raw_ostream &operator<<(raw_ostream &OS, DGNode &N) {
114114
N.print(OS);
115115
return OS;
116116
}

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
//
1414
// This is currently used for Instruction intervals.
1515
// It provides an API for some basic operations on the interval, including some
16-
// simple set operations, like union, interseciton and others.
16+
// simple set operations, like union, intersection and others.
1717
//
1818
//===----------------------------------------------------------------------===//
1919

2020
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_INSTRINTERVAL_H
2121
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_INSTRINTERVAL_H
2222

2323
#include "llvm/ADT/ArrayRef.h"
24+
#include "llvm/Support/raw_ostream.h"
2425
#include <iterator>
2526

2627
namespace llvm::sandboxir {
@@ -197,6 +198,27 @@ template <typename T> class Interval {
197198
auto *NewTo = To->comesBefore(Other.To) ? Other.To : To;
198199
return {NewFrom, NewTo};
199200
}
201+
202+
#ifndef NDEBUG
203+
void print(raw_ostream &OS) const {
204+
auto *Top = top();
205+
auto *Bot = bottom();
206+
OS << "Top: ";
207+
if (Top != nullptr)
208+
OS << *Top;
209+
else
210+
OS << "nullptr";
211+
OS << "\n";
212+
213+
OS << "Bot: ";
214+
if (Bot != nullptr)
215+
OS << *Bot;
216+
else
217+
OS << "nullptr";
218+
OS << "\n";
219+
}
220+
LLVM_DUMP_METHOD void dump() const;
221+
#endif
200222
};
201223

202224
} // namespace llvm::sandboxir

llvm/lib/Transforms/Vectorize/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMVectorize
44
LoopVectorizationLegality.cpp
55
LoopVectorize.cpp
66
SandboxVectorizer/DependencyGraph.cpp
7+
SandboxVectorizer/Interval.cpp
78
SandboxVectorizer/Passes/BottomUpVec.cpp
89
SandboxVectorizer/SandboxVectorizer.cpp
910
SandboxVectorizer/SeedCollector.cpp
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===- Interval.cpp -------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h"
10+
#include "llvm/SandboxIR/Instruction.h"
11+
#include "llvm/Support/Debug.h"
12+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h"
13+
14+
namespace llvm::sandboxir {
15+
16+
template class Interval<Instruction>;
17+
template class Interval<MemDGNode>;
18+
19+
#ifndef NDEBUG
20+
template <typename T> void Interval<T>::dump() const { print(dbgs()); }
21+
#endif
22+
} // namespace llvm::sandboxir

0 commit comments

Comments
 (0)