[llvm] [SandboxIR] Adds BasicBlock and adds functionality to Function and Context (PR #97637)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 11:23:30 PDT 2024


================
@@ -278,12 +381,55 @@ class Context {
   DenseMap<llvm::Value *, std::unique_ptr<sandboxir::Value>>
       LLVMValueToValueMap;
 
+  /// Take ownership of VPtr and store it in `LLVMValueToValueMap`.
+  Value *registerValue(std::unique_ptr<Value> &&VPtr);
+
+  /// Helper for avoiding recursion loop when creating SBConstants.
+  SmallDenseSet<llvm::Constant *, 8> VisitedConstants;
+
+  Value *getOrCreateValueInternal(llvm::Value *V, int Depth,
+                                  llvm::User *U = nullptr);
+
+  template <typename SBT, typename LLVMT>
+  SBT *getOrCreateGeneric(LLVMT *LLVMV) {
----------------
vporpo wrote:

I can drop it from the argument, but I would still need to create an object of LLVMT type, so I don't think I can drop it from the template entirely. It will look like this:
```
 template <typename SBT, typename LLVMT>  
 SBT *getOrCreateGeneric(llvm::Value *LLVMV) {
  ...
      It->second = std::make_unique<SBT>(cast<LLVMT>(LLVMV), *this);
```
Wdyt?

https://github.com/llvm/llvm-project/pull/97637


More information about the llvm-commits mailing list