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