LLVM  11.0.0git
OrderedInstructions.h
Go to the documentation of this file.
1 //===- llvm/Transforms/Utils/OrderedInstructions.h -------------*- 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 file defines an efficient way to check for dominance relation between 2
10 // instructions.
11 //
12 // FIXME: This is really just a convenience wrapper to check dominance between
13 // two arbitrary instructions in different basic blocks. We should fold it into
14 // DominatorTree, which is the more widely used interface.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_ANALYSIS_ORDEREDINSTRUCTIONS_H
19 #define LLVM_ANALYSIS_ORDEREDINSTRUCTIONS_H
20 
21 namespace llvm {
22 
23 class DominatorTree;
24 class Instruction;
25 
27  /// The dominator tree of the parent function.
28  DominatorTree *DT;
29 
30  /// Return true if the first instruction comes before the second in the
31  /// same basic block. It will create an ordered basic block, if it does
32  /// not yet exist in OBBMap.
33  bool localDominates(const Instruction *, const Instruction *) const;
34 
35 public:
36  /// Constructor.
38 
39  /// Return true if first instruction dominates the second.
40  bool dominates(const Instruction *, const Instruction *) const;
41 
42  /// Return true if the first instruction comes before the second in the
43  /// dominator tree DFS traversal if they are in different basic blocks,
44  /// or if the first instruction comes before the second in the same basic
45  /// block.
46  bool dfsBefore(const Instruction *, const Instruction *) const;
47 
48  // Return true if the first instruction comes before the second in the
49  // dominator tree BFS traversal based on the level number of nodes in
50  // dominator tree if they are in different basic blocks else if the first
51  // instruction comes before the second in the same basic block.
52  bool domTreeLevelBefore(const Instruction *, const Instruction *) const;
53 };
54 
55 } // end namespace llvm
56 
57 #endif // LLVM_ANALYSIS_ORDEREDINSTRUCTIONS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool dominates(const Instruction *, const Instruction *) const
Return true if first instruction dominates the second.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:144
bool dfsBefore(const Instruction *, const Instruction *) const
Return true if the first instruction comes before the second in the dominator tree DFS traversal if t...
OrderedInstructions(DominatorTree *DT)
Constructor.
bool domTreeLevelBefore(const Instruction *, const Instruction *) const