xref: /llvm-project/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Interval.cpp (revision acf6072fae00123e78e362f74f0dc2d830837d10)
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 <typename T> bool Interval<T>::disjoint(const Interval &Other) const {
17   if (Other.empty())
18     return true;
19   if (empty())
20     return true;
21   return Other.Bottom->comesBefore(Top) || Bottom->comesBefore(Other.Top);
22 }
23 
24 #ifndef NDEBUG
25 template <typename T> void Interval<T>::print(raw_ostream &OS) const {
26   auto *Top = top();
27   auto *Bot = bottom();
28   OS << "Top: ";
29   if (Top != nullptr)
30     OS << *Top;
31   else
32     OS << "nullptr";
33   OS << "\n";
34 
35   OS << "Bot: ";
36   if (Bot != nullptr)
37     OS << *Bot;
38   else
39     OS << "nullptr";
40   OS << "\n";
41 }
42 template <typename T> void Interval<T>::dump() const { print(dbgs()); }
43 #endif
44 
45 template class Interval<Instruction>;
46 template class Interval<MemDGNode>;
47 
48 } // namespace llvm::sandboxir
49