LLVM 24.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
52
53// The explicit instantiation declarations of the region base classes must come
54// before the classes deriving from them. Defining a derived class implicitly
55// instantiates its base. Declaring the explicit instantiation after the derived
56// class will cause clang-cl to silently drop the dllimport attribute, resulting
57// in incorrect linkage.
58extern template class LLVM_TEMPLATE_ABI
60
61class MachineRegionNode : public RegionNodeBase<RegionTraits<MachineFunction>> {
62public:
64 bool isSubRegion = false)
66 isSubRegion) {}
67
68 bool operator==(const MachineRegion &RN) const {
69 return this == reinterpret_cast<const MachineRegionNode *>(&RN);
70 }
71};
72
73extern template class LLVM_TEMPLATE_ABI
74 RegionBase<RegionTraits<MachineFunction>>;
75
76class MachineRegion : public RegionBase<RegionTraits<MachineFunction>> {
77public:
80 MachineRegion *Parent = nullptr);
82
83 bool operator==(const MachineRegionNode &RN) const {
84 return &RN == reinterpret_cast<const MachineRegionNode *>(this);
85 }
86};
87
88extern template class LLVM_TEMPLATE_ABI
89 RegionInfoBase<RegionTraits<MachineFunction>>;
90
91class MachineRegionInfo : public RegionInfoBase<RegionTraits<MachineFunction>> {
92public:
93 using Base = RegionInfoBase<RegionTraits<MachineFunction>>;
94
97
99 : Base(std::move(static_cast<Base &>(Arg))) {
100 updateRegionTree(*this, TopLevelRegion);
101 }
102
104 Base::operator=(std::move(static_cast<Base &>(RHS)));
105 updateRegionTree(*this, TopLevelRegion);
106 return *this;
107 }
108
109 /// Handle invalidation explicitly.
111 MachineFunctionAnalysisManager::Invalidator &);
112
116};
117
119 : public AnalysisInfoMixin<MachineRegionInfoAnalysis> {
121
122 static AnalysisKey Key;
123
124public:
126
128};
129
131 : public RequiredPassInfoMixin<MachineRegionInfoPrinterPass> {
132 raw_ostream &OS;
133
134public:
138};
139
142
143public:
144 static char ID;
145
146 explicit MachineRegionInfoPass();
148
150
151 const MachineRegionInfo &getRegionInfo() const { return RI; }
152
153 /// @name MachineFunctionPass interface
154 //@{
155 bool runOnMachineFunction(MachineFunction &F) override;
156 void releaseMemory() override;
157 void verifyAnalysis() const override;
158 void getAnalysisUsage(AnalysisUsage &AU) const override;
159 void print(raw_ostream &OS, const Module *) const override;
160 void dump() const;
161 //@}
162};
163
164template <>
165template <>
168 const {
169 assert(!isSubRegion() && "This is not a MachineBasicBlock RegionNode!");
170 return getEntry();
171}
172
173template <>
174template <>
177 const {
178 assert(isSubRegion() && "This is not a subregion RegionNode!");
179 auto Unconst =
181 return reinterpret_cast<MachineRegion *>(Unconst);
182}
183
187
190
191template <>
210
211template <>
229
230} // end namespace llvm
231
232#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
#define LLVM_TEMPLATE_ABI
Definition Compiler.h:216
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
RegionInfoBase< RegionTraits< MachineFunction > > Base
LLVM_ABI MachineRegionInfo()
LLVM_ABI void recalculate(MachineFunction &F, MachineDominatorTree *DT, MachinePostDominatorTree *PDT, MachineDominanceFrontier *DF)
MachineRegionInfo & operator=(MachineRegionInfo &&RHS)
MachineRegionInfo(MachineRegionInfo &&Arg)
LLVM_ABI ~MachineRegionInfo()
LLVM_ABI bool invalidate(MachineFunction &F, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
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:68
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:732
RegionT * getTopLevelRegion() const
Definition RegionInfo.h:864
A RegionNode represents a subregion or a BasicBlock that is part of a Region.
Definition RegionInfo.h:118
RegionNodeBase(RegionT *Parent, BlockT *Entry, bool isSubRegion=false)
Definition RegionInfo.h:151
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:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
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:94
static LLVM_ABI void updateStatistics(MachineRegion *R)
Update statistics about created regions.
static unsigned getNumSuccessors(MachineBasicBlock *BB)
A CRTP mix-in for passes that should not be skipped.