|
|
|||
File indexing completed on 2026-05-10 08:44:44
0001 //===- SSAUpdaterBulk.h - Unstructured SSA Update Tool ----------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file declares the SSAUpdaterBulk class. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H 0014 #define LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H 0015 0016 #include "llvm/ADT/DenseMap.h" 0017 #include "llvm/ADT/StringRef.h" 0018 #include "llvm/IR/PredIteratorCache.h" 0019 0020 namespace llvm { 0021 0022 class BasicBlock; 0023 class PHINode; 0024 template <typename T> class SmallVectorImpl; 0025 class Type; 0026 class Use; 0027 class Value; 0028 class DominatorTree; 0029 0030 /// Helper class for SSA formation on a set of values defined in multiple 0031 /// blocks. 0032 /// 0033 /// This is used when code duplication or another unstructured transformation 0034 /// wants to rewrite a set of uses of one value with uses of a set of values. 0035 /// The update is done only when RewriteAllUses is called, all other methods are 0036 /// used for book-keeping. That helps to share some common computations between 0037 /// updates of different uses (which is not the case when traditional SSAUpdater 0038 /// is used). 0039 class SSAUpdaterBulk { 0040 struct RewriteInfo { 0041 DenseMap<BasicBlock *, Value *> Defines; 0042 SmallVector<Use *, 4> Uses; 0043 StringRef Name; 0044 Type *Ty; 0045 RewriteInfo() = default; 0046 RewriteInfo(StringRef &N, Type *T) : Name(N), Ty(T){}; 0047 }; 0048 SmallVector<RewriteInfo, 4> Rewrites; 0049 0050 PredIteratorCache PredCache; 0051 0052 Value *computeValueAt(BasicBlock *BB, RewriteInfo &R, DominatorTree *DT); 0053 0054 public: 0055 explicit SSAUpdaterBulk() = default; 0056 SSAUpdaterBulk(const SSAUpdaterBulk &) = delete; 0057 SSAUpdaterBulk &operator=(const SSAUpdaterBulk &) = delete; 0058 ~SSAUpdaterBulk() = default; 0059 0060 /// Add a new variable to the SSA rewriter. This needs to be called before 0061 /// AddAvailableValue or AddUse calls. The return value is the variable ID, 0062 /// which needs to be passed to AddAvailableValue and AddUse. 0063 unsigned AddVariable(StringRef Name, Type *Ty); 0064 0065 /// Indicate that a rewritten value is available in the specified block with 0066 /// the specified value. 0067 void AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V); 0068 0069 /// Record a use of the symbolic value. This use will be updated with a 0070 /// rewritten value when RewriteAllUses is called. 0071 void AddUse(unsigned Var, Use *U); 0072 0073 /// Perform all the necessary updates, including new PHI-nodes insertion and 0074 /// the requested uses update. 0075 /// 0076 /// The function requires dominator tree DT, which is used for computing 0077 /// locations for new phi-nodes insertions. If a nonnull pointer to a vector 0078 /// InsertedPHIs is passed, all the new phi-nodes will be added to this 0079 /// vector. 0080 void RewriteAllUses(DominatorTree *DT, 0081 SmallVectorImpl<PHINode *> *InsertedPHIs = nullptr); 0082 }; 0083 0084 } // end namespace llvm 0085 0086 #endif // LLVM_TRANSFORMS_UTILS_SSAUPDATERBULK_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|