blob: 3f11dcb5164d0c08d001482b37d31e0faa05e1d1 [file] [log] [blame]
Diego Caballero168d04d2018-05-21 18:14:23 +00001//===-- 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"
Diego Caballero2a34ac82018-07-30 21:33:31 +000029#include "VPlanDominatorTree.h"
Diego Caballero168d04d2018-05-21 18:14:23 +000030#include "VPlanVerifier.h"
31
32namespace llvm {
33
34class Loop;
Diego Caballero2a34ac82018-07-30 21:33:31 +000035class VPlanTestBase;
Diego Caballero168d04d2018-05-21 18:14:23 +000036
37/// Main class to build the VPlan H-CFG for an incoming IR.
38class VPlanHCFGBuilder {
Diego Caballero2a34ac82018-07-30 21:33:31 +000039 friend VPlanTestBase;
40
Diego Caballero168d04d2018-05-21 18:14:23 +000041private:
42 // The outermost loop of the input loop nest considered for vectorization.
43 Loop *TheLoop;
44
45 // Loop Info analysis.
46 LoopInfo *LI;
47
Diego Caballero2a34ac82018-07-30 21:33:31 +000048 // The VPlan that will contain the H-CFG we are building.
49 VPlan &Plan;
50
Diego Caballero168d04d2018-05-21 18:14:23 +000051 // VPlan verifier utility.
52 VPlanVerifier Verifier;
53
Diego Caballero2a34ac82018-07-30 21:33:31 +000054 // 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;
Diego Caballero168d04d2018-05-21 18:14:23 +000058
Diego Caballero2a34ac82018-07-30 21:33:31 +000059 /// Build plain CFG for TheLoop. Return a new VPRegionBlock (TopRegion)
60 /// enclosing the plain CFG.
61 VPRegionBlock *buildPlainCFG();
62
63public:
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();
Diego Caballero168d04d2018-05-21 18:14:23 +000069};
70} // namespace llvm
71
72#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H