LLVM  8.0.1
SSAUpdaterBulk.h
Go to the documentation of this file.
1 //===- SSAUpdaterBulk.h - Unstructured SSA Update Tool ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the SSAUpdaterBulk class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
15 #define LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/ADT/StringRef.h"
21 
22 namespace llvm {
23 
24 class BasicBlock;
25 class PHINode;
26 template <typename T> class SmallVectorImpl;
27 class Type;
28 class Use;
29 class Value;
30 class DominatorTree;
31 
32 /// Helper class for SSA formation on a set of values defined in multiple
33 /// blocks.
34 ///
35 /// This is used when code duplication or another unstructured transformation
36 /// wants to rewrite a set of uses of one value with uses of a set of values.
37 /// The update is done only when RewriteAllUses is called, all other methods are
38 /// used for book-keeping. That helps to share some common computations between
39 /// updates of different uses (which is not the case when traditional SSAUpdater
40 /// is used).
42  struct RewriteInfo {
46  Type *Ty;
47  RewriteInfo(){};
48  RewriteInfo(StringRef &N, Type *T) : Name(N), Ty(T){};
49  };
51 
52  PredIteratorCache PredCache;
53 
54  Value *computeValueAt(BasicBlock *BB, RewriteInfo &R, DominatorTree *DT);
55 
56 public:
57  explicit SSAUpdaterBulk(){};
58  SSAUpdaterBulk(const SSAUpdaterBulk &) = delete;
59  SSAUpdaterBulk &operator=(const SSAUpdaterBulk &) = delete;
61 
62  /// Add a new variable to the SSA rewriter. This needs to be called before
63  /// AddAvailableValue or AddUse calls. The return value is the variable ID,
64  /// which needs to be passed to AddAvailableValue and AddUse.
65  unsigned AddVariable(StringRef Name, Type *Ty);
66 
67  /// Indicate that a rewritten value is available in the specified block with
68  /// the specified value.
69  void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V);
70 
71  /// Record a use of the symbolic value. This use will be updated with a
72  /// rewritten value when RewriteAllUses is called.
73  void AddUse(unsigned Var, Use *U);
74 
75  /// Return true if the SSAUpdater already has a value for the specified
76  /// variable in the specified block.
77  bool HasValueForBlock(unsigned Var, BasicBlock *BB);
78 
79  /// Perform all the necessary updates, including new PHI-nodes insertion and
80  /// the requested uses update.
81  ///
82  /// The function requires dominator tree DT, which is used for computing
83  /// locations for new phi-nodes insertions. If a nonnull pointer to a vector
84  /// InsertedPHIs is passed, all the new phi-nodes will be added to this
85  /// vector.
87  SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr);
88 };
89 
90 } // end namespace llvm
91 
92 #endif // LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Various leaf nodes.
Definition: ISDOpcodes.h:60
unsigned AddVariable(StringRef Name, Type *Ty)
Add a new variable to the SSA rewriter.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value...
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries...
Helper class for SSA formation on a set of values defined in multiple blocks.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:145
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void AddUse(unsigned Var, Use *U)
Record a use of the symbolic value.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
void RewriteAllUses(DominatorTree *DT, SmallVectorImpl< PHINode *> *InsertedPHIs=nullptr)
Perform all the necessary updates, including new PHI-nodes insertion and the requested uses update...
#define N
LLVM Value Representation.
Definition: Value.h:73
SSAUpdaterBulk & operator=(const SSAUpdaterBulk &)=delete
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool HasValueForBlock(unsigned Var, BasicBlock *BB)
Return true if the SSAUpdater already has a value for the specified variable in the specified block...