LLVM  10.0.0svn
MachineRegionInfo.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/MachineRegionInfo.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 #ifndef LLVM_CODEGEN_MACHINEREGIONINFO_H
10 #define LLVM_CODEGEN_MACHINEREGIONINFO_H
11 
21 #include <cassert>
22 
23 namespace llvm {
24 
25 struct MachinePostDominatorTree;
26 class MachineRegion;
27 class MachineRegionNode;
28 class MachineRegionInfo;
29 
30 template <> struct RegionTraits<MachineFunction> {
41  using LoopT = MachineLoop;
43 
44  static unsigned getNumSuccessors(MachineBasicBlock *BB) {
45  return BB->succ_size();
46  }
47 };
48 
49 class MachineRegionNode : public RegionNodeBase<RegionTraits<MachineFunction>> {
50 public:
52  bool isSubRegion = false)
54  isSubRegion) {}
55 
56  bool operator==(const MachineRegion &RN) const {
57  return this == reinterpret_cast<const MachineRegionNode *>(&RN);
58  }
59 };
60 
61 class MachineRegion : public RegionBase<RegionTraits<MachineFunction>> {
62 public:
65  MachineRegion *Parent = nullptr);
66  ~MachineRegion();
67 
68  bool operator==(const MachineRegionNode &RN) const {
69  return &RN == reinterpret_cast<const MachineRegionNode *>(this);
70  }
71 };
72 
73 class MachineRegionInfo : public RegionInfoBase<RegionTraits<MachineFunction>> {
74 public:
75  explicit MachineRegionInfo();
76  ~MachineRegionInfo() override;
77 
78  // updateStatistics - Update statistic about created regions.
79  void updateStatistics(MachineRegion *R) final;
80 
81  void recalculate(MachineFunction &F, MachineDominatorTree *DT,
83 };
84 
87 
88 public:
89  static char ID;
90 
91  explicit MachineRegionInfoPass();
92  ~MachineRegionInfoPass() override;
93 
94  MachineRegionInfo &getRegionInfo() { return RI; }
95 
96  const MachineRegionInfo &getRegionInfo() const { return RI; }
97 
98  /// @name MachineFunctionPass interface
99  //@{
100  bool runOnMachineFunction(MachineFunction &F) override;
101  void releaseMemory() override;
102  void verifyAnalysis() const override;
103  void getAnalysisUsage(AnalysisUsage &AU) const override;
104  void print(raw_ostream &OS, const Module *) const override;
105  void dump() const;
106  //@}
107 };
108 
109 template <>
110 template <>
111 inline MachineBasicBlock *
112 RegionNodeBase<RegionTraits<MachineFunction>>::getNodeAs<MachineBasicBlock>()
113  const {
114  assert(!isSubRegion() && "This is not a MachineBasicBlock RegionNode!");
115  return getEntry();
116 }
117 
118 template <>
119 template <>
120 inline MachineRegion *
122  const {
123  assert(isSubRegion() && "This is not a subregion RegionNode!");
124  auto Unconst =
126  return reinterpret_cast<MachineRegion *>(Unconst);
127 }
128 
131  MachineRegion);
132 
135 
136 template <>
141 
143  return GraphTraits<FlatIt<MachineRegion *>>::getEntryNode(
144  RI->getTopLevelRegion());
145  }
146 
148  return nodes_iterator::begin(getEntryNode(RI));
149  }
150 
152  return nodes_iterator::end(getEntryNode(RI));
153  }
154 };
155 
156 template <>
161 
164  }
165 
168  }
169 
172  }
173 };
174 
175 extern template class RegionBase<RegionTraits<MachineFunction>>;
176 extern template class RegionNodeBase<RegionTraits<MachineFunction>>;
177 extern template class RegionInfoBase<RegionTraits<MachineFunction>>;
178 
179 } // end namespace llvm
180 
181 #endif // LLVM_CODEGEN_MACHINEREGIONINFO_H
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
bool operator==(const MachineRegion &RN) const
const MachineRegionInfo & getRegionInfo() const
F(f)
Analysis that detects all canonical Regions.
Definition: RegionInfo.h:69
static NodeRef getEntryNode(MachineRegionInfoPass *RI)
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
Definition: RegionInfo.h:118
static nodes_iterator nodes_end(MachineRegionInfoPass *RI)
RegionT * getTopLevelRegion() const
Definition: RegionInfo.h:868
static nodes_iterator nodes_begin(MachineRegionInfoPass *RI)
Base class for the actual dominator tree node.
RegionNodeGraphTraits(RegionNode, BasicBlock, Region)
typename FlatIt< MachineRegionNode * > ::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:78
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Represent the analysis usage information of a pass.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
static nodes_iterator nodes_begin(MachineRegionInfo *RI)
MachineRegionInfo & getRegionInfo()
RegionGraphTraits(Region, RegionNode)
A single entry single exit Region.
Definition: RegionInfo.h:67
static unsigned getNumSuccessors(MachineBasicBlock *BB)
static NodeRef getEntryNode(MachineRegionInfo *RI)
unsigned succ_size() const
Representation of each machine instruction.
Definition: MachineInstr.h:64
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(const MachineRegionNode &RN) const
static nodes_iterator nodes_end(MachineRegionInfo *RI)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineRegionNode(MachineRegion *Parent, MachineBasicBlock *Entry, bool isSubRegion=false)