10b57cec5SDimitry Andric //===-- VPlanDominatorTree.h ------------------------------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric ///
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric /// This file implements dominator tree analysis for a single level of a VPlan's
110b57cec5SDimitry Andric /// H-CFG.
120b57cec5SDimitry Andric ///
130b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H
160b57cec5SDimitry Andric #define LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric #include "VPlan.h"
19bdd1243dSDimitry Andric #include "VPlanCFG.h"
200b57cec5SDimitry Andric #include "llvm/ADT/GraphTraits.h"
210b57cec5SDimitry Andric #include "llvm/IR/Dominators.h"
22bdd1243dSDimitry Andric #include "llvm/Support/GenericDomTree.h"
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric namespace llvm {
250b57cec5SDimitry Andric 
26bdd1243dSDimitry Andric template <> struct DomTreeNodeTraits<VPBlockBase> {
27bdd1243dSDimitry Andric   using NodeType = VPBlockBase;
28bdd1243dSDimitry Andric   using NodePtr = VPBlockBase *;
29bdd1243dSDimitry Andric   using ParentPtr = VPlan *;
30bdd1243dSDimitry Andric 
31bdd1243dSDimitry Andric   static NodePtr getEntryNode(ParentPtr Parent) { return Parent->getEntry(); }
32bdd1243dSDimitry Andric   static ParentPtr getParent(NodePtr B) { return B->getPlan(); }
33bdd1243dSDimitry Andric };
34bdd1243dSDimitry Andric 
35bdd1243dSDimitry Andric ///
360b57cec5SDimitry Andric /// Template specialization of the standard LLVM dominator tree utility for
370b57cec5SDimitry Andric /// VPBlockBases.
380b57cec5SDimitry Andric using VPDominatorTree = DomTreeBase<VPBlockBase>;
390b57cec5SDimitry Andric 
400b57cec5SDimitry Andric using VPDomTreeNode = DomTreeNodeBase<VPBlockBase>;
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric /// Template specializations of GraphTraits for VPDomTreeNode.
430b57cec5SDimitry Andric template <>
440b57cec5SDimitry Andric struct GraphTraits<VPDomTreeNode *>
455ffd83dbSDimitry Andric     : public DomTreeGraphTraitsBase<VPDomTreeNode,
465ffd83dbSDimitry Andric                                     VPDomTreeNode::const_iterator> {};
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric template <>
490b57cec5SDimitry Andric struct GraphTraits<const VPDomTreeNode *>
500b57cec5SDimitry Andric     : public DomTreeGraphTraitsBase<const VPDomTreeNode,
510b57cec5SDimitry Andric                                     VPDomTreeNode::const_iterator> {};
520b57cec5SDimitry Andric } // namespace llvm
530b57cec5SDimitry Andric #endif // LLVM_TRANSFORMS_VECTORIZE_VPLANDOMINATORTREE_H
54