[llvm] [VPlan] Add VPIRBasicBlock, use to model pre-preheader. (PR #93398)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 22:06:19 PDT 2024


================
@@ -2948,12 +2953,48 @@ class VPBasicBlock : public VPBlockBase {
     return NewBlock;
   }
 
+protected:
+  void executeRecipes(VPTransformState *State, BasicBlock *BB);
+
 private:
   /// Create an IR BasicBlock to hold the output instructions generated by this
   /// VPBasicBlock, and return it. Update the CFGState accordingly.
   BasicBlock *createEmptyBasicBlock(VPTransformState::CFGState &CFG);
 };
 
+/// A special type of VPBasicBlock that wraps an existing IR basic block.
+/// Recipes of the block get added before the first non-phi instruction in the
+/// wrapped block.
+class VPIRBasicBlock : public VPBasicBlock {
+  BasicBlock *WrappedBlock;
+
+public:
+  VPIRBasicBlock(BasicBlock *WrappedBlock)
+      : VPBasicBlock(
+            VPIRBasicBlockSC,
+            (Twine("ir-bb<") + WrappedBlock->getName() + Twine(">")).str()),
+        WrappedBlock(WrappedBlock) {}
+
+  ~VPIRBasicBlock() override {}
+
+  static inline bool classof(const VPBlockBase *V) {
+    return V->getVPBlockID() == VPBlockBase::VPIRBasicBlockSC;
+  }
+
+  /// The method which generates the output IR instructions that correspond to
+  /// this VPBasicBlock, thereby "executing" the VPlan.
+  void execute(VPTransformState *State) override;
+
+  VPIRBasicBlock *clone() override {
+    auto *NewBlock = new VPIRBasicBlock(WrappedBlock);
+    for (VPRecipeBase &R : *this)
+      NewBlock->appendRecipe(R.clone());
+    return NewBlock;
+  }
+
+  BasicBlock *getWrappedBlock() const { return WrappedBlock; }
----------------
fhahn wrote:

updated, thanks!

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


More information about the llvm-commits mailing list