LLVM  12.0.0git
CodeMoverUtils.h
Go to the documentation of this file.
1 //===- Transform/Utils/CodeMoverUtils.h - CodeMover Utils -------*- C++ -*-===//
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 // This family of functions determine movements are safe on basic blocks, and
10 // instructions contained within a function.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
15 #define LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
16 
17 namespace llvm {
18 
19 class BasicBlock;
20 class DependenceInfo;
21 class DominatorTree;
22 class Instruction;
23 class PostDominatorTree;
24 
25 /// Return true if \p I0 and \p I1 are control flow equivalent.
26 /// Two instructions are control flow equivalent if their basic blocks are
27 /// control flow equivalent.
28 bool isControlFlowEquivalent(const Instruction &I0, const Instruction &I1,
29  const DominatorTree &DT,
30  const PostDominatorTree &PDT);
31 
32 /// Return true if \p BB0 and \p BB1 are control flow equivalent.
33 /// Two basic blocks are control flow equivalent if when one executes, the other
34 /// is guaranteed to execute.
35 bool isControlFlowEquivalent(const BasicBlock &BB0, const BasicBlock &BB1,
36  const DominatorTree &DT,
37  const PostDominatorTree &PDT);
38 
39 /// Return true if \p I can be safely moved before \p InsertPoint.
40 bool isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint,
41  DominatorTree &DT,
42  const PostDominatorTree *PDT = nullptr,
43  DependenceInfo *DI = nullptr);
44 
45 /// Return true if all instructions (except the terminator) in \p BB can be
46 /// safely moved before \p InsertPoint.
47 bool isSafeToMoveBefore(BasicBlock &BB, Instruction &InsertPoint,
48  DominatorTree &DT,
49  const PostDominatorTree *PDT = nullptr,
50  DependenceInfo *DI = nullptr);
51 
52 /// Move instructions, in an order-preserving manner, from \p FromBB to the
53 /// beginning of \p ToBB when proven safe.
55  DominatorTree &DT,
56  const PostDominatorTree &PDT,
57  DependenceInfo &DI);
58 
59 /// Move instructions, in an order-preserving manner, from \p FromBB to the end
60 /// of \p ToBB when proven safe.
62  DominatorTree &DT, const PostDominatorTree &PDT,
63  DependenceInfo &DI);
64 
65 } // end namespace llvm
66 
67 #endif // LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Various leaf nodes.
Definition: ISDOpcodes.h:64
bool isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint, DominatorTree &DT, const PostDominatorTree *PDT=nullptr, DependenceInfo *DI=nullptr)
Return true if I can be safely moved before InsertPoint.
bool isControlFlowEquivalent(const Instruction &I0, const Instruction &I1, const DominatorTree &DT, const PostDominatorTree &PDT)
Return true if I0 and I1 are control flow equivalent.
void moveInstructionsToTheEnd(BasicBlock &FromBB, BasicBlock &ToBB, DominatorTree &DT, const PostDominatorTree &PDT, DependenceInfo &DI)
Move instructions, in an order-preserving manner, from FromBB to the end of ToBB when proven safe...
#define I(x, y, z)
Definition: MD5.cpp:59
void moveInstructionsToTheBeginning(BasicBlock &FromBB, BasicBlock &ToBB, DominatorTree &DT, const PostDominatorTree &PDT, DependenceInfo &DI)
Move instructions, in an order-preserving manner, from FromBB to the beginning of ToBB when proven sa...