VPlanPredicator.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //===-- VPlanPredicator.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 VPlanPredicator class which contains the public
  11. /// interfaces to predicate and linearize the VPlan region.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_PREDICATOR_H
  15. #define LLVM_TRANSFORMS_VECTORIZE_VPLAN_PREDICATOR_H
  16. #include "LoopVectorizationPlanner.h"
  17. #include "VPlan.h"
  18. #include "VPlanDominatorTree.h"
  19. namespace llvm {
  20. class VPlanPredicator {
  21. private:
  22. enum class EdgeType {
  23. TRUE_EDGE,
  24. FALSE_EDGE,
  25. };
  26. // VPlan being predicated.
  27. VPlan &Plan;
  28. // VPLoopInfo for Plan's HCFG.
  29. VPLoopInfo *VPLI;
  30. // Dominator tree for Plan's HCFG.
  31. VPDominatorTree VPDomTree;
  32. // VPlan builder used to generate VPInstructions for block predicates.
  33. VPBuilder Builder;
  34. /// Get the type of edge from \p FromBlock to \p ToBlock. Returns TRUE_EDGE if
  35. /// \p ToBlock is either the unconditional successor or the conditional true
  36. /// successor of \p FromBlock and FALSE_EDGE otherwise.
  37. EdgeType getEdgeTypeBetween(VPBlockBase *FromBlock, VPBlockBase *ToBlock);
  38. /// Create and return VPValue corresponding to the predicate for the edge from
  39. /// \p PredBB to \p CurrentBlock.
  40. VPValue *getOrCreateNotPredicate(VPBasicBlock *PredBB, VPBasicBlock *CurrBB);
  41. /// Generate and return the result of ORing all the predicate VPValues in \p
  42. /// Worklist.
  43. VPValue *genPredicateTree(std::list<VPValue *> &Worklist);
  44. /// Create or propagate predicate for \p CurrBlock in region \p Region using
  45. /// predicate(s) of its predecessor(s)
  46. void createOrPropagatePredicates(VPBlockBase *CurrBlock,
  47. VPRegionBlock *Region);
  48. /// Predicate the CFG within \p Region.
  49. void predicateRegionRec(VPRegionBlock *Region);
  50. /// Linearize the CFG within \p Region.
  51. void linearizeRegionRec(VPRegionBlock *Region);
  52. public:
  53. VPlanPredicator(VPlan &Plan);
  54. /// Predicate Plan's HCFG.
  55. void predicate();
  56. };
  57. } // end namespace llvm
  58. #endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_PREDICATOR_H