VPlanHCFGBuilder.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "VPlan.h"
  26. #include "VPlanDominatorTree.h"
  27. #include "VPlanVerifier.h"
  28. namespace llvm {
  29. class Loop;
  30. class VPlanTestBase;
  31. /// Main class to build the VPlan H-CFG for an incoming IR.
  32. class VPlanHCFGBuilder {
  33. friend VPlanTestBase;
  34. private:
  35. // The outermost loop of the input loop nest considered for vectorization.
  36. Loop *TheLoop;
  37. // Loop Info analysis.
  38. LoopInfo *LI;
  39. // The VPlan that will contain the H-CFG we are building.
  40. VPlan &Plan;
  41. // VPlan verifier utility.
  42. VPlanVerifier Verifier;
  43. // Dominator analysis for VPlan plain CFG to be used in the
  44. // construction of the H-CFG. This analysis is no longer valid once regions
  45. // are introduced.
  46. VPDominatorTree VPDomTree;
  47. /// Build plain CFG for TheLoop. Return a new VPRegionBlock (TopRegion)
  48. /// enclosing the plain CFG.
  49. VPRegionBlock *buildPlainCFG();
  50. public:
  51. VPlanHCFGBuilder(Loop *Lp, LoopInfo *LI, VPlan &P)
  52. : TheLoop(Lp), LI(LI), Plan(P) {}
  53. /// Build H-CFG for TheLoop and update Plan accordingly.
  54. void buildHierarchicalCFG();
  55. };
  56. } // namespace llvm
  57. #endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_VPLANHCFGBUILDER_H