LLVM 22.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// Please note that this is work in progress, and the functionality is not
13// ready for broader production use.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
18#define LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
19
21
22namespace llvm {
23
24class BasicBlock;
25class DependenceInfo;
26class DominatorTree;
27class Instruction;
29
30/// Return true if \p I can be safely moved before \p InsertPoint.
32 DominatorTree &DT,
33 const PostDominatorTree *PDT = nullptr,
34 DependenceInfo *DI = nullptr,
35 bool CheckForEntireBlock = false);
36
37/// Return true if all instructions (except the terminator) in \p BB can be
38/// safely moved before \p InsertPoint.
40 DominatorTree &DT,
41 const PostDominatorTree *PDT = nullptr,
42 DependenceInfo *DI = nullptr);
43
44/// Move instructions, in an order-preserving manner, from \p FromBB to the
45/// beginning of \p ToBB when proven safe.
47 BasicBlock &ToBB,
48 DominatorTree &DT,
49 const PostDominatorTree &PDT,
50 DependenceInfo &DI);
51
52/// Move instructions, in an order-preserving manner, from \p FromBB to the end
53/// of \p ToBB when proven safe.
55 DominatorTree &DT,
56 const PostDominatorTree &PDT,
57 DependenceInfo &DI);
58
59/// In case that two BBs \p ThisBlock and \p OtherBlock are control flow
60/// equivalent but they do not strictly dominate and post-dominate each
61/// other, we determine if \p ThisBlock is reached after \p OtherBlock
62/// in the control flow.
63LLVM_ABI bool nonStrictlyPostDominate(const BasicBlock *ThisBlock,
64 const BasicBlock *OtherBlock,
65 const DominatorTree *DT,
66 const PostDominatorTree *PDT);
67
68// Check if I0 is reached before I1 in the control flow.
69LLVM_ABI bool isReachedBefore(const Instruction *I0, const Instruction *I1,
70 const DominatorTree *DT,
71 const PostDominatorTree *PDT);
72
73} // end namespace llvm
74
75#endif // LLVM_TRANSFORMS_UTILS_CODEMOVERUTILS_H
#define LLVM_ABI
Definition Compiler.h:213
#define I(x, y, z)
Definition MD5.cpp:57
LLVM Basic Block Representation.
Definition BasicBlock.h:62
DependenceInfo - This class is the main dependence-analysis driver.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:164
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI 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.
LLVM_ABI bool isReachedBefore(const Instruction *I0, const Instruction *I1, const DominatorTree *DT, const PostDominatorTree *PDT)
LLVM_ABI bool nonStrictlyPostDominate(const BasicBlock *ThisBlock, const BasicBlock *OtherBlock, const DominatorTree *DT, const PostDominatorTree *PDT)
In case that two BBs ThisBlock and OtherBlock are control flow equivalent but they do not strictly do...
LLVM_ABI 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...
LLVM_ABI bool isSafeToMoveBefore(Instruction &I, Instruction &InsertPoint, DominatorTree &DT, const PostDominatorTree *PDT=nullptr, DependenceInfo *DI=nullptr, bool CheckForEntireBlock=false)
Return true if I can be safely moved before InsertPoint.