VPlanHCFGBuilder.h 2.4 KB

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