LLVM  13.0.0git
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 class MachinePostDominatorTree;
26 class MachineRegion;
27 class MachineRegionNode;
28 class MachineRegionInfo;
29 
30 template <> struct RegionTraits<MachineFunction> {
41  using LoopT = MachineLoop;
43 
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);
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 
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
RegionInfo.h
llvm::MachineRegionInfoPass::ID
static char ID
Definition: MachineRegionInfo.h:89
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::RegionInfoBase::getTopLevelRegion
RegionT * getTopLevelRegion() const
Definition: RegionInfo.h:866
llvm::MachineRegionInfo::updateStatistics
void updateStatistics(MachineRegion *R) final
Definition: MachineRegionInfo.cpp:51
llvm::GraphTraits< MachineRegionInfo * >::getEntryNode
static NodeRef getEntryNode(MachineRegionInfo *RI)
Definition: MachineRegionInfo.h:142
llvm::RegionBase
A single entry single exit Region.
Definition: RegionInfo.h:66
llvm::MachineRegion::MachineRegion
MachineRegion(MachineBasicBlock *Entry, MachineBasicBlock *Exit, MachineRegionInfo *RI, MachineDominatorTree *DT, MachineRegion *Parent=nullptr)
Definition: MachineRegionInfo.cpp:37
llvm::MachineRegionInfoPass::dump
void dump() const
Definition: MachineRegionInfo.cpp:123
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
MachineBasicBlock.h
llvm::GraphTraits< MachineRegionInfo * >::nodes_end
static nodes_iterator nodes_end(MachineRegionInfo *RI)
Definition: MachineRegionInfo.h:151
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
llvm::MachineRegionInfoPass::verifyAnalysis
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
Definition: MachineRegionInfo.cpp:102
llvm::MachineRegionInfo::MachineRegionInfo
MachineRegionInfo()
llvm::RegionGraphTraits
RegionGraphTraits(Region, RegionNode)
llvm::MachineRegionNode
Definition: MachineRegionInfo.h:49
DepthFirstIterator.h
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::MachineLoopInfo
Definition: MachineLoopInfo.h:90
llvm::MachineRegionInfo::~MachineRegionInfo
~MachineRegionInfo() override
llvm::MachineRegionInfoPass::getRegionInfo
const MachineRegionInfo & getRegionInfo() const
Definition: MachineRegionInfo.h:96
llvm::MachineRegionInfo::recalculate
void recalculate(MachineFunction &F, MachineDominatorTree *DT, MachinePostDominatorTree *PDT, MachineDominanceFrontier *DF)
Definition: MachineRegionInfo.cpp:59
MachineLoopInfo.h
llvm::MachineRegion::~MachineRegion
~MachineRegion()
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::MachineRegionInfoPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: MachineRegionInfo.cpp:110
llvm::MachineRegionInfoPass
Definition: MachineRegionInfo.h:85
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MachineRegion
Definition: MachineRegionInfo.h:61
llvm::RegionInfoBase
Analysis that detects all canonical Regions.
Definition: RegionInfo.h:68
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::MachineRegionInfoPass::print
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
Definition: MachineRegionInfo.cpp:118
llvm::MachineDomTreeNode
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
Definition: LiveIntervalCalc.h:26
llvm::MachineLoop
Definition: MachineLoopInfo.h:45
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::MachineDominanceFrontier
Definition: MachineDominanceFrontier.h:20
llvm::GraphTraits< MachineRegionInfoPass * >::nodes_end
static nodes_iterator nodes_end(MachineRegionInfoPass *RI)
Definition: MachineRegionInfo.h:170
llvm::MachineRegionInfoPass::~MachineRegionInfoPass
~MachineRegionInfoPass() override
MachineFunctionPass.h
llvm::GraphTraits< MachineRegionInfoPass * >::nodes_begin
static nodes_iterator nodes_begin(MachineRegionInfoPass *RI)
Definition: MachineRegionInfo.h:166
llvm::GraphTraits< MachineRegionInfo * >
Definition: MachineRegionInfo.h:137
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineRegionInfoPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition: MachineRegionInfo.cpp:98
RegionIterator.h
llvm::MachineRegionInfoPass::MachineRegionInfoPass
MachineRegionInfoPass()
Definition: MachineRegionInfo.cpp:78
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::RegionNodeGraphTraits
RegionNodeGraphTraits(RegionNode, BasicBlock, Region)
llvm::MachineRegionInfoPass::getRegionInfo
MachineRegionInfo & getRegionInfo()
Definition: MachineRegionInfo.h:94
llvm::df_iterator
Definition: DepthFirstIterator.h:85
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::RegionNodeBase< RegionTraits< MachineFunction > >::isSubRegion
bool isSubRegion() const
Is this RegionNode a subregion?
Definition: RegionInfo.h:188
llvm::MachineRegionInfoPass::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition: MachineRegionInfo.cpp:84
llvm::DomTreeNodeBase
Base class for the actual dominator tree node.
Definition: LiveIntervalCalc.h:24
llvm::MachinePostDominatorTree
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
Definition: MachinePostDominators.h:27
MachineDominanceFrontier.h
llvm::RegionTraits
Definition: RegionInfo.h:75
llvm::MachineRegionInfo
Definition: MachineRegionInfo.h:73
llvm::MachineRegionNode::operator==
bool operator==(const MachineRegion &RN) const
Definition: MachineRegionInfo.h:56
llvm::RegionNodeBase
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
Definition: RegionInfo.h:117
llvm::GraphTraits< MachineRegionInfo * >::nodes_begin
static nodes_iterator nodes_begin(MachineRegionInfo *RI)
Definition: MachineRegionInfo.h:147
llvm::MachineRegionNode::MachineRegionNode
MachineRegionNode(MachineRegion *Parent, MachineBasicBlock *Entry, bool isSubRegion=false)
Definition: MachineRegionInfo.h:51
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
RN
It looks like we only need to define PPCfmarto for these because according to these instructions perform RTO on fma s src2 rnd ← FPSCR RN
Definition: README_P9.txt:262
llvm::GraphTraits< FlatIt< MachineRegionNode * > >::NodeRef
typename FlatIt< MachineRegionNode * > ::UnknownGraphTypeError NodeRef
Definition: GraphTraits.h:78
llvm::GraphTraits
Definition: GraphTraits.h:35
llvm::MachineDominatorTree
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Definition: MachineDominators.h:45
MachineFunction.h
llvm::GraphTraits< MachineRegionInfoPass * >::getEntryNode
static NodeRef getEntryNode(MachineRegionInfoPass *RI)
Definition: MachineRegionInfo.h:162
llvm::MachineRegion::operator==
bool operator==(const MachineRegionNode &RN) const
Definition: MachineRegionInfo.h:68
llvm::RegionTraits< MachineFunction >::getNumSuccessors
static unsigned getNumSuccessors(MachineBasicBlock *BB)
Definition: MachineRegionInfo.h:44
MachineDominators.h