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