LLVM  10.0.0svn
IteratedDominanceFrontier.h
Go to the documentation of this file.
1 //===- IteratedDominanceFrontier.h - Calculate IDF --------------*- 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 #ifndef LLVM_ANALYSIS_IDF_H
10 #define LLVM_ANALYSIS_IDF_H
11 
12 #include "llvm/IR/CFGDiff.h"
14 
15 namespace llvm {
16 
17 class BasicBlock;
18 
19 namespace IDFCalculatorDetail {
20 
21 /// Specialization for BasicBlock for the optional use of GraphDiff.
22 template <bool IsPostDom> struct ChildrenGetterTy<BasicBlock, IsPostDom> {
23  using NodeRef = BasicBlock *;
25 
26  ChildrenGetterTy() = default;
28  assert(GD);
29  }
30 
31  ChildrenTy get(const NodeRef &N);
32 
34 };
35 
36 } // end of namespace IDFCalculatorDetail
37 
38 template <bool IsPostDom>
39 class IDFCalculator final : public IDFCalculatorBase<BasicBlock, IsPostDom> {
40 public:
41  using IDFCalculatorBase =
44 
46  : IDFCalculatorBase(DT) {}
47 
51  assert(GD);
52  }
53 };
54 
57 
58 //===----------------------------------------------------------------------===//
59 // Implementation.
60 //===----------------------------------------------------------------------===//
61 
62 namespace IDFCalculatorDetail {
63 
64 template <bool IsPostDom>
67 
68  using OrderedNodeTy =
70 
71  if (!GD) {
72  auto Children = children<OrderedNodeTy>(N);
73  return {Children.begin(), Children.end()};
74  }
75 
76  using SnapShotBBPairTy =
77  std::pair<const GraphDiff<BasicBlock *, IsPostDom> *, OrderedNodeTy>;
78 
80  for (const auto &SnapShotBBPair : children<SnapShotBBPairTy>({GD, N}))
81  Ret.emplace_back(SnapShotBBPair.second);
82  return Ret;
83 }
84 
85 } // end of namespace IDFCalculatorDetail
86 
87 } // end of namespace llvm
88 
89 #endif
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:641
IDFCalculator(DominatorTreeBase< BasicBlock, IsPostDom > &DT, const GraphDiff< BasicBlock *, IsPostDom > *GD)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Various leaf nodes.
Definition: ISDOpcodes.h:59
typename llvm::IDFCalculatorBase< BasicBlock, IsPostDom > IDFCalculatorBase
IDFCalculatorDetail::ChildrenGetterTy< NodeTy, IsPostDom > ChildrenGetterTy
Generic utility class used for getting the children of a basic block.
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
typename IDFCalculatorBase::ChildrenGetterTy ChildrenGetterTy
Compute iterated dominance frontiers using a linear time algorithm.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
#define N
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
IDFCalculator(DominatorTreeBase< BasicBlock, IsPostDom > &DT)