LLVM 23.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
22#include <cassert>
23
24namespace llvm {
25
27class MachineRegion;
30
49
50class MachineRegionNode : public RegionNodeBase<RegionTraits<MachineFunction>> {
51public:
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
62class MachineRegion : public RegionBase<RegionTraits<MachineFunction>> {
63public:
66 MachineRegion *Parent = nullptr);
68
69 bool operator==(const MachineRegionNode &RN) const {
70 return &RN == reinterpret_cast<const MachineRegionNode *>(this);
71 }
72};
73
75 : public RegionInfoBase<RegionTraits<MachineFunction>> {
76public:
77 using Base = RegionInfoBase<RegionTraits<MachineFunction>>;
78
81
83 : Base(std::move(static_cast<Base &>(Arg))) {
84 updateRegionTree(*this, TopLevelRegion);
85 }
86
88 Base::operator=(std::move(static_cast<Base &>(RHS)));
89 updateRegionTree(*this, TopLevelRegion);
90 return *this;
91 }
92
93 /// Handle invalidation explicitly.
94 bool invalidate(MachineFunction &F, const PreservedAnalyses &PA,
95 MachineFunctionAnalysisManager::Invalidator &);
96
97 // updateStatistics - Update statistic about created regions.
98 void updateStatistics(MachineRegion *R) final;
99
100 void recalculate(MachineFunction &F, MachineDominatorTree *DT,
102};
103
105 : public AnalysisInfoMixin<MachineRegionInfoAnalysis> {
107
108 static AnalysisKey Key;
109
110public:
112
114};
115
117 : public RequiredPassInfoMixin<MachineRegionInfoPrinterPass> {
118 raw_ostream &OS;
119
120public:
124};
125
128
129public:
130 static char ID;
131
132 explicit MachineRegionInfoPass();
134
136
137 const MachineRegionInfo &getRegionInfo() const { return RI; }
138
139 /// @name MachineFunctionPass interface
140 //@{
141 bool runOnMachineFunction(MachineFunction &F) override;
142 void releaseMemory() override;
143 void verifyAnalysis() const override;
144 void getAnalysisUsage(AnalysisUsage &AU) const override;
145 void print(raw_ostream &OS, const Module *) const override;
146 void dump() const;
147 //@}
148};
149
150template <>
151template <>
154 const {
155 assert(!isSubRegion() && "This is not a MachineBasicBlock RegionNode!");
156 return getEntry();
157}
158
159template <>
160template <>
163 const {
164 assert(isSubRegion() && "This is not a subregion RegionNode!");
165 auto Unconst =
167 return reinterpret_cast<MachineRegion *>(Unconst);
168}
169
173
176
177template <>
196
197template <>
215
216extern template class RegionBase<RegionTraits<MachineFunction>>;
217extern template class RegionNodeBase<RegionTraits<MachineFunction>>;
218extern template class RegionInfoBase<RegionTraits<MachineFunction>>;
219
220} // end namespace llvm
221
222#endif // LLVM_CODEGEN_MACHINEREGIONINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define LLVM_ABI
Definition Compiler.h:215
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
#define F(x, y, z)
Definition MD5.cpp:54
#define RegionNodeGraphTraits(NodeT, BlockT, RegionT)
#define RegionGraphTraits(RegionT, NodeT)
Value * RHS
Represent the analysis usage information of a pass.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
MachinePostDominatorTree - an analysis pass wrapper for DominatorTree used to compute the post-domina...
Result run(MachineFunction &F, MachineFunctionAnalysisManager &AM)
MachineRegionInfo & getRegionInfo()
const MachineRegionInfo & getRegionInfo() const
~MachineRegionInfo() override
RegionInfoBase< RegionTraits< MachineFunction > > Base
MachineRegionInfo & operator=(MachineRegionInfo &&RHS)
MachineRegionInfo(MachineRegionInfo &&Arg)
bool operator==(const MachineRegion &RN) const
MachineRegionNode(MachineRegion *Parent, MachineBasicBlock *Entry, bool isSubRegion=false)
LLVM_ABI ~MachineRegion()
LLVM_ABI MachineRegion(MachineBasicBlock *Entry, MachineBasicBlock *Exit, MachineRegionInfo *RI, MachineDominatorTree *DT, MachineRegion *Parent=nullptr)
bool operator==(const MachineRegionNode &RN) const
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
RegionBase(BlockT *Entry, BlockT *Exit, RegionInfoT *RI, DomTreeT *DT, RegionT *Parent=nullptr)
void updateRegionTree(RegionInfoT &RI, TheRegionT *R)
Definition RegionInfo.h:729
RegionT * getTopLevelRegion() const
Definition RegionInfo.h:864
RegionNodeBase(RegionT *Parent, BlockT *Entry, bool isSubRegion=false)
Definition RegionInfo.h:148
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
DomTreeNodeBase< MachineBasicBlock > MachineDomTreeNode
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1916
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:860
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
static NodeRef getEntryNode(MachineRegionInfoPass *RI)
df_iterator< NodeRef, df_iterator_default_set< NodeRef >, false, GraphTraits< FlatIt< NodeRef > > > nodes_iterator
static nodes_iterator nodes_end(MachineRegionInfoPass *RI)
static nodes_iterator nodes_begin(MachineRegionInfoPass *RI)
df_iterator< NodeRef, df_iterator_default_set< NodeRef >, false, GraphTraits< FlatIt< NodeRef > > > nodes_iterator
static nodes_iterator nodes_end(MachineRegionInfo *RI)
static NodeRef getEntryNode(MachineRegionInfo *RI)
static nodes_iterator nodes_begin(MachineRegionInfo *RI)
typename MachineRegionInfo *::UnknownGraphTypeError NodeRef
Definition GraphTraits.h:95
static unsigned getNumSuccessors(MachineBasicBlock *BB)
A CRTP mix-in for passes that should not be skipped.