1336809Sdim//===-- VPlanHCFGBuilder.h --------------------------------------*- C++ -*-===// 2336809Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6336809Sdim// 7336809Sdim//===----------------------------------------------------------------------===// 8336809Sdim/// 9336809Sdim/// \file 10336809Sdim/// This file defines the VPlanHCFGBuilder class which contains the public 11336809Sdim/// interface (buildHierarchicalCFG) to build a VPlan-based Hierarchical CFG 12336809Sdim/// (H-CFG) for an incoming IR. 13336809Sdim/// 14336809Sdim/// A H-CFG in VPlan is a control-flow graph whose nodes are VPBasicBlocks 15336809Sdim/// and/or VPRegionBlocks (i.e., other H-CFGs). The outermost H-CFG of a VPlan 16336809Sdim/// consists of a VPRegionBlock, denoted Top Region, which encloses any other 17336809Sdim/// VPBlockBase in the H-CFG. This guarantees that any VPBlockBase in the H-CFG 18336809Sdim/// other than the Top Region will have a parent VPRegionBlock and allows us 19336809Sdim/// to easily add more nodes before/after the main vector loop (such as the 20336809Sdim/// reduction epilogue). 21336809Sdim/// 22336809Sdim//===----------------------------------------------------------------------===// 23336809Sdim 24336809Sdim#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 25336809Sdim#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 26336809Sdim 27336809Sdim#include "VPlan.h" 28337149Sdim#include "VPlanDominatorTree.h" 29336809Sdim#include "VPlanVerifier.h" 30336809Sdim 31336809Sdimnamespace llvm { 32336809Sdim 33336809Sdimclass Loop; 34337149Sdimclass VPlanTestBase; 35336809Sdim 36336809Sdim/// Main class to build the VPlan H-CFG for an incoming IR. 37336809Sdimclass VPlanHCFGBuilder { 38337149Sdim friend VPlanTestBase; 39337149Sdim 40336809Sdimprivate: 41336809Sdim // The outermost loop of the input loop nest considered for vectorization. 42336809Sdim Loop *TheLoop; 43336809Sdim 44336809Sdim // Loop Info analysis. 45336809Sdim LoopInfo *LI; 46336809Sdim 47337149Sdim // The VPlan that will contain the H-CFG we are building. 48337149Sdim VPlan &Plan; 49337149Sdim 50336809Sdim // VPlan verifier utility. 51336809Sdim VPlanVerifier Verifier; 52336809Sdim 53337149Sdim // Dominator analysis for VPlan plain CFG to be used in the 54337149Sdim // construction of the H-CFG. This analysis is no longer valid once regions 55337149Sdim // are introduced. 56337149Sdim VPDominatorTree VPDomTree; 57337149Sdim 58337149Sdim /// Build plain CFG for TheLoop. Return a new VPRegionBlock (TopRegion) 59337149Sdim /// enclosing the plain CFG. 60337149Sdim VPRegionBlock *buildPlainCFG(); 61337149Sdim 62336809Sdimpublic: 63337149Sdim VPlanHCFGBuilder(Loop *Lp, LoopInfo *LI, VPlan &P) 64337149Sdim : TheLoop(Lp), LI(LI), Plan(P) {} 65336809Sdim 66337149Sdim /// Build H-CFG for TheLoop and update Plan accordingly. 67337149Sdim void buildHierarchicalCFG(); 68336809Sdim}; 69336809Sdim} // namespace llvm 70336809Sdim 71336809Sdim#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H 72