Thanks to visit codestin.com
Credit goes to llvm.org

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/DenseMap.h"
17#include "llvm/ADT/StringRef.h"
20
21namespace llvm {
22
23class BasicBlock;
24class PHINode;
25template <typename T> class SmallVectorImpl;
26class Type;
27class Use;
28class Value;
29class DominatorTree;
30
31/// Helper class for SSA formation on a set of values defined in multiple
32/// blocks.
33///
34/// This is used when code duplication or another unstructured transformation
35/// wants to rewrite a set of uses of one value with uses of a set of values.
36/// The update is done only when RewriteAllUses is called, all other methods are
37/// used for book-keeping. That helps to share some common computations between
38/// updates of different uses (which is not the case when traditional SSAUpdater
39/// is used).
41 struct RewriteInfo {
44 StringRef Name;
45 Type *Ty;
46 RewriteInfo() = default;
47 RewriteInfo(StringRef &N, Type *T) : Name(N), Ty(T){};
48 };
50
51 PredIteratorCache PredCache;
52
53public:
54 explicit SSAUpdaterBulk() = default;
55 SSAUpdaterBulk(const SSAUpdaterBulk &) = delete;
57 ~SSAUpdaterBulk() = default;
58
59 /// Add a new variable to the SSA rewriter. This needs to be called before
60 /// AddAvailableValue or AddUse calls. The return value is the variable ID,
61 /// which needs to be passed to AddAvailableValue and AddUse.
62 LLVM_ABI unsigned AddVariable(StringRef Name, Type *Ty);
63
64 /// Indicate that a rewritten value is available in the specified block with
65 /// the specified value.
66 LLVM_ABI void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V);
67
68 /// Record a use of the symbolic value. This use will be updated with a
69 /// rewritten value when RewriteAllUses is called.
70 LLVM_ABI void AddUse(unsigned Var, Use *U);
71
72 /// Perform all the necessary updates, including new PHI-nodes insertion and
73 /// the requested uses update.
74 ///
75 /// The function requires dominator tree DT, which is used for computing
76 /// locations for new phi-nodes insertions. If a nonnull pointer to a vector
77 /// InsertedPHIs is passed, all the new phi-nodes will be added to this
78 /// vector.
79 LLVM_ABI void
81 SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr);
82};
83
84} // end namespace llvm
85
86#endif // LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
#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.
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