LLVM  8.0.1
MachineRegionInfo.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/MachineRegionInfo.h -------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CODEGEN_MACHINEREGIONINFO_H
11 #define LLVM_CODEGEN_MACHINEREGIONINFO_H
12 
22 #include <cassert>
23 
24 namespace llvm {
25 
26 struct MachinePostDominatorTree;
27 class MachineRegion;
28 class MachineRegionNode;
29 class MachineRegionInfo;
30 
31 template <> struct RegionTraits<MachineFunction> {
42  using LoopT = MachineLoop;
44 
45  static unsigned getNumSuccessors(MachineBasicBlock *BB) {
46  return BB->succ_size();
47  }
48 };
49 
50 class MachineRegionNode : public RegionNodeBase<RegionTraits<MachineFunction>> {
51 public:
53  bool isSubRegion = false)
55  isSubRegion) {}
56 
57  bool operator==(const MachineRegion &RN) const {
58  return this == reinterpret_cast<const MachineRegionNode *>(&RN);
59  }
60 };
61 
62 class MachineRegion : public RegionBase<RegionTraits<MachineFunction>> {
63 public:
66  MachineRegion *Parent = nullptr);
67  ~MachineRegion();
68 
69  bool operator==(const MachineRegionNode &RN) const {
70  return &RN == reinterpret_cast<const MachineRegionNode *>(this);
71  }
72 };
73 
74 class MachineRegionInfo : public RegionInfoBase<RegionTraits<MachineFunction>> {
75 public:
76  explicit MachineRegionInfo();
77  ~MachineRegionInfo() override;
78 
79  // updateStatistics - Update statistic about created regions.
80  void updateStatistics(MachineRegion *R) final;
81 
82  void recalculate(MachineFunction &F, MachineDominatorTree *DT,
84 };
85 
88 
89 public:
90  static char ID;
91 
92  explicit MachineRegionInfoPass();
93  ~MachineRegionInfoPass() override;
94 
95  MachineRegionInfo &getRegionInfo() { return RI; }
96 
97  const MachineRegionInfo &getRegionInfo() const { return RI; }
98 
99  /// @name MachineFunctionPass interface
100  //@{
101  bool runOnMachineFunction(MachineFunction &F) override;
102  void releaseMemory() override;
103  void verifyAnalysis() const override;
104  void getAnalysisUsage(AnalysisUsage &AU) const override;
105  void print(raw_ostream &OS, const Module *) const override;
106  void dump() const;
107  //@}
108 };
109 
110 template <>
111 template <>
112 inline MachineBasicBlock *
113 RegionNodeBase<RegionTraits<MachineFunction>>::getNodeAs<MachineBasicBlock>()
114  const {
115  assert(!isSubRegion() && "This is not a MachineBasicBlock RegionNode!");
116  return getEntry();
117 }
118 
119 template <>
120 template <>
121 inline MachineRegion *
123  const {
124  assert(isSubRegion() && "This is not a subregion RegionNode!");
125  auto Unconst =
127  return reinterpret_cast<MachineRegion *>(Unconst);
128 }
129 
132  MachineRegion);
133 
136 
137 template <>
142 
144  return GraphTraits<FlatIt<MachineRegion *>>::getEntryNode(
145  RI->getTopLevelRegion());
146  }
147 
149  return nodes_iterator::begin(getEntryNode(RI));
150  }
151 
153  return nodes_iterator::end(getEntryNode(RI));
154  }
155 };
156 
157 template <>
162 
165  }
166 
169  }
170 
173  }
174 };
175 
176 extern template class RegionBase<RegionTraits<MachineFunction>>;
177 extern template class RegionNodeBase<RegionTraits<MachineFunction>>;
178 extern template class RegionInfoBase<RegionTraits<MachineFunction>>;
179 
180 } // end namespace llvm
181 
182 #endif // LLVM_CODEGEN_MACHINEREGIONINFO_H
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:259
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:250
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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:70
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:119
static nodes_iterator nodes_end(MachineRegionInfoPass *RI)
RegionT * getTopLevelRegion() const
Definition: RegionInfo.h:869
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:79
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:68
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:46
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineRegionNode(MachineRegion *Parent, MachineBasicBlock *Entry, bool isSubRegion=false)