1 //===-- VPlanHCFGBuilder.h --------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// This file defines the VPlanHCFGBuilder class which contains the public 12 /// interface (buildHierarchicalCFG) to build a VPlan-based Hierarchical CFG 13 /// (H-CFG) for an incoming IR. 14 /// 15 /// A H-CFG in VPlan is a control-flow graph whose nodes are VPBasicBlocks 16 /// and/or VPRegionBlocks (i.e., other H-CFGs). The outermost H-CFG of a VPlan 17 /// consists of a VPRegionBlock, denoted Top Region, which encloses any other 18 /// VPBlockBase in the H-CFG. This guarantees that any VPBlockBase in the H-CFG 19 /// other than the Top Region will have a parent VPRegionBlock and allows us 20 /// to easily add more nodes before/after the main vector loop (such as the 21 /// reduction epilogue). 22 /// 23 //===----------------------------------------------------------------------===// 24 25 #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 26 #define LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 27 28 #include "VPlan.h" 29 #include "VPlanDominatorTree.h" 30 #include "VPlanVerifier.h" 31 32 namespace llvm { 33 34 class Loop; 35 class VPlanTestBase; 36 37 /// Main class to build the VPlan H-CFG for an incoming IR. 38 class VPlanHCFGBuilder { 39 friend VPlanTestBase; 40 41 private: 42 // The outermost loop of the input loop nest considered for vectorization. 43 Loop *TheLoop; 44 45 // Loop Info analysis. 46 LoopInfo *LI; 47 48 // The VPlan that will contain the H-CFG we are building. 49 VPlan &Plan; 50 51 // VPlan verifier utility. 52 VPlanVerifier Verifier; 53 54 // Dominator analysis for VPlan plain CFG to be used in the 55 // construction of the H-CFG. This analysis is no longer valid once regions 56 // are introduced. 57 VPDominatorTree VPDomTree; 58 59 /// Build plain CFG for TheLoop. Return a new VPRegionBlock (TopRegion) 60 /// enclosing the plain CFG. 61 VPRegionBlock *buildPlainCFG(); 62 63 public: 64 VPlanHCFGBuilder(Loop *Lp, LoopInfo *LI, VPlan &P) 65 : TheLoop(Lp), LI(LI), Plan(P) {} 66 67 /// Build H-CFG for TheLoop and update Plan accordingly. 68 void buildHierarchicalCFG(); 69 }; 70 } // namespace llvm 71 72 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 73