[llvm] [VPlan] Add VPIRBasicBlock, use to model pre-preheader. (PR #93398)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon May 27 22:12:50 PDT 2024
================
@@ -2951,6 +2960,50 @@ class VPBasicBlock : public VPBlockBase {
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 terminator of the wrapped IR basic
+/// block.
+class VPIRWrapperBlock : public VPBasicBlock {
+ BasicBlock *WrappedBlock;
+
+public:
+ VPIRWrapperBlock(BasicBlock *WrappedBlock)
+ : VPBasicBlock(VPIRWrapperBlockSC, WrappedBlock->getName()),
+ WrappedBlock(WrappedBlock) {}
+
+ ~VPIRWrapperBlock() override {}
+
+ static inline bool classof(const VPBlockBase *V) {
+ return V->getVPBlockID() == VPBlockBase::VPIRWrapperBlockSC;
+ }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ /// Print this VPBsicBlock to \p O, prefixing all lines with \p Indent. \p
+ /// SlotTracker is used to print unnamed VPValue's using consequtive numbers.
+ ///
+ /// Note that the numbering is applied to the whole VPlan, so printing
+ /// individual blocks is consistent with the whole VPlan printing.
+ void print(raw_ostream &O, const Twine &Indent,
+ VPSlotTracker &SlotTracker) const override;
+ using VPBlockBase::print; // Get the print(raw_stream &O) version.
+#endif
+ /// The method which generates the output IR instructions that correspond to
+ /// this VPBasicBlock, thereby "executing" the VPlan.
+ void execute(VPTransformState *State) override;
+
+ VPIRWrapperBlock *clone() override {
+ auto *NewBlock = new VPIRWrapperBlock(WrappedBlock);
+ for (VPRecipeBase &R : *this)
----------------
fhahn wrote:
Recipes is private, can move to protected?
https://github.com/llvm/llvm-project/pull/93398
More information about the llvm-commits
mailing list