LLVM 22.0.0git
SSAUpdaterBulk.h
Go to the documentation of this file.
1//===- SSAUpdaterBulk.h - Unstructured SSA Update Tool ----------*- 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 declares the SSAUpdaterBulk class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
14#define LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
15
16#include "llvm/ADT/StringRef.h"
19
20namespace llvm {
21
22class BasicBlock;
23class PHINode;
24template <typename T> class SmallVectorImpl;
25class Type;
26class Use;
27class Value;
28class DominatorTree;
29
30/// Helper class for SSA formation on a set of values defined in multiple
31/// blocks.
32///
33/// This is used when code duplication or another unstructured transformation
34/// wants to rewrite a set of uses of one value with uses of a set of values.
35/// The update is done only when RewriteAllUses is called, all other methods are
36/// used for book-keeping. That helps to share some common computations between
37/// updates of different uses (which is not the case when traditional SSAUpdater
38/// is used).
40 struct RewriteInfo {
43 StringRef Name;
44 Type *Ty;
45 RewriteInfo() = default;
46 RewriteInfo(StringRef &N, Type *T) : Name(N), Ty(T){};
47 };
49
50 PredIteratorCache PredCache;
51
52public:
53 explicit SSAUpdaterBulk() = default;
54 SSAUpdaterBulk(const SSAUpdaterBulk &) = delete;
56 ~SSAUpdaterBulk() = default;
57
58 /// Add a new variable to the SSA rewriter. This needs to be called before
59 /// AddAvailableValue or AddUse calls. The return value is the variable ID,
60 /// which needs to be passed to AddAvailableValue and AddUse.
61 LLVM_ABI unsigned AddVariable(StringRef Name, Type *Ty);
62
63 /// Indicate that a rewritten value is available in the specified block with
64 /// the specified value.
65 LLVM_ABI void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V);
66
67 /// Record a use of the symbolic value. This use will be updated with a
68 /// rewritten value when RewriteAllUses is called.
69 LLVM_ABI void AddUse(unsigned Var, Use *U);
70
71 /// Perform all the necessary updates, including new PHI-nodes insertion and
72 /// the requested uses update.
73 ///
74 /// The function requires dominator tree DT, which is used for computing
75 /// locations for new phi-nodes insertions. If a nonnull pointer to a vector
76 /// InsertedPHIs is passed, all the new phi-nodes will be added to this
77 /// vector.
78 LLVM_ABI void
80 SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr);
81
82 /// Rewrite all uses and simplify the inserted PHI nodes.
83 /// Use this method to preserve behavior when replacing SSAUpdater.
85};
86
87} // end namespace llvm
88
89#endif // LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
#define LLVM_ABI
Definition Compiler.h:213
#define T
Remove Loads Into Fake Uses
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:165
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
SSAUpdaterBulk()=default
SSAUpdaterBulk & operator=(const SSAUpdaterBulk &)=delete
~SSAUpdaterBulk()=default
LLVM_ABI unsigned AddVariable(StringRef Name, Type *Ty)
Add a new variable to the SSA rewriter.
LLVM_ABI void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value.
LLVM_ABI void RewriteAllUses(DominatorTree *DT, SmallVectorImpl< PHINode * > *InsertedPHIs=nullptr)
Perform all the necessary updates, including new PHI-nodes insertion and the requested uses update.
SSAUpdaterBulk(const SSAUpdaterBulk &)=delete
LLVM_ABI void AddUse(unsigned Var, Use *U)
Record a use of the symbolic value.
void RewriteAndOptimizeAllUses(DominatorTree &DT)
Rewrite all uses and simplify the inserted PHI nodes.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
This is an optimization pass for GlobalISel generic memory operations.
#define N