[ControlHeightReduction] Add assert to avoid underflow (#116339)
[llvm-project.git] / llvm / lib / Transforms / Vectorize / VPlanDominatorTree.h
blob787cd940c4e26631dead3316bee648caa8ffbef1
1 //===-- VPlanDominatorTree.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 implements dominator tree analysis for a single level of a VPlan's
11 /// H-CFG.
12 ///
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H
16 #define LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H
18 #include "VPlan.h"
19 #include "VPlanCFG.h"
20 #include "llvm/ADT/GraphTraits.h"
21 #include "llvm/IR/Dominators.h"
22 #include "llvm/Support/GenericDomTree.h"
24 namespace llvm {
26 template <> struct DomTreeNodeTraits<VPBlockBase> {
27 using NodeType = VPBlockBase;
28 using NodePtr = VPBlockBase *;
29 using ParentPtr = VPlan *;
31 static NodePtr getEntryNode(ParentPtr Parent) { return Parent->getEntry(); }
32 static ParentPtr getParent(NodePtr B) { return B->getPlan(); }
35 /// Template specialization of the standard LLVM dominator tree utility for
36 /// VPBlockBases.
37 class VPDominatorTree : public DominatorTreeBase<VPBlockBase, false> {
38 using Base = DominatorTreeBase<VPBlockBase, false>;
40 public:
41 VPDominatorTree() = default;
43 /// Returns true if \p A properly dominates \p B.
44 bool properlyDominates(const VPRecipeBase *A, const VPRecipeBase *B);
47 using VPDomTreeNode = DomTreeNodeBase<VPBlockBase>;
49 /// Template specializations of GraphTraits for VPDomTreeNode.
50 template <>
51 struct GraphTraits<VPDomTreeNode *>
52 : public DomTreeGraphTraitsBase<VPDomTreeNode,
53 VPDomTreeNode::const_iterator> {};
55 template <>
56 struct GraphTraits<const VPDomTreeNode *>
57 : public DomTreeGraphTraitsBase<const VPDomTreeNode,
58 VPDomTreeNode::const_iterator> {};
59 } // namespace llvm
60 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H