LLVM: include/llvm/CodeGen/LivePhysRegs.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#ifndef LLVM_CODEGEN_LIVEPHYSREGS_H
30#define LLVM_CODEGEN_LIVEPHYSREGS_H
31
37#include
38#include
39
40namespace llvm {
41
42template class ArrayRef;
43
49
50
51
55 RegisterSet LiveRegs;
56
57public:
58
60
61
63 LiveRegs.setUniverse(TRI.getNumRegs());
64 }
65
68
69
71 this->TRI = &TRI;
72 LiveRegs.clear();
73 LiveRegs.setUniverse(TRI.getNumRegs());
74 }
75
76
77 void clear() { LiveRegs.clear(); }
78
79
80 bool empty() const { return LiveRegs.empty(); }
81
82
84 assert(TRI && "LivePhysRegs is not initialized.");
85 assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
87 LiveRegs.insert(SubReg);
88 }
89
90
91
93 assert(TRI && "LivePhysRegs is not initialized.");
94 assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
96 LiveRegs.erase((*R).id());
97 }
98
99
101 SmallVectorImpl<std::pair<MCPhysReg, const MachineOperand*>> *Clobbers =
102 nullptr);
103
104
105
106
107
108
110
111
113
114
116
117
119
120
121
122
124
125
126
127
128
129
130
132 SmallVectorImpl<std::pair<MCPhysReg, const MachineOperand*>> &Clobbers);
133
134
135
136
138
139
140
142
143
144
145
146
147
148
149
151
152
153
155
157
160
161
163
164
165 void dump() const;
166
167private:
168
170
171
172
174
175
176
178
179
180
182};
183
188
189
190
191
193
194
196
197
198
200
201
203 MachineBasicBlock &MBB);
204
205
207
208
209
212 std::vectorMachineBasicBlock::RegisterMaskPair OldLiveIns;
213
214 MBB.clearLiveIns(OldLiveIns);
216 MBB.sortUniqueLiveIns();
217
218 const std::vectorMachineBasicBlock::RegisterMaskPair &NewLiveIns =
219 MBB.getLiveIns();
220 return OldLiveIns != NewLiveIns;
221}
222
223
224
227 const size_t Len = MBBs.size();
228 while (true) {
229 bool AnyChange = false;
230 for (size_t I = 0; I < Len; ++I)
232 AnyChange = true;
233 if (!AnyChange)
234 return;
235 }
236}
237
238
239}
240
241#endif
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void addBlockLiveOuts(LiveRegUnits &LiveUnits, const MachineBasicBlock &MBB)
Add live-out registers of basic block MBB to LiveUnits.
static void addBlockLiveIns(LiveRegUnits &LiveUnits, const MachineBasicBlock &MBB)
Add live-in registers of basic block MBB to LiveUnits.
Promote Memory to Register
This file defines the SparseSet class derived from the version described in Briggs,...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
Definition LivePhysRegs.h:52
void addReg(MCRegister Reg)
Adds a physical register and all its sub-registers to the set.
Definition LivePhysRegs.h:83
RegisterSet::const_iterator const_iterator
Definition LivePhysRegs.h:156
const_iterator end() const
Definition LivePhysRegs.h:159
void clear()
Clears the set.
Definition LivePhysRegs.h:77
void stepForward(const MachineInstr &MI, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand * > > &Clobbers)
Simulates liveness when stepping forward over an instruction(bundle).
LivePhysRegs(const LivePhysRegs &)=delete
void print(raw_ostream &OS) const
Prints the currently live registers to OS.
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
Definition LivePhysRegs.h:70
void addLiveIns(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB.
bool available(const MachineRegisterInfo &MRI, MCRegister Reg) const
Returns true if register Reg and no aliasing register is in the set.
void addUses(const MachineInstr &MI)
Add uses to the set.
void removeDefs(const MachineInstr &MI)
Remove defined registers and regmask kills from the set.
void addLiveOutsNoPristines(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB but skips pristine registers.
LivePhysRegs(const TargetRegisterInfo &TRI)
Constructs and initializes an empty set.
Definition LivePhysRegs.h:62
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
LivePhysRegs()=default
Constructs an unitialized set. init() needs to be called to initialize it.
void removeReg(MCRegister Reg)
Removes a physical register, all its sub-registers, and all its super-registers from the set.
Definition LivePhysRegs.h:92
const_iterator begin() const
Definition LivePhysRegs.h:158
void addLiveInsNoPristines(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB but skips pristine registers.
bool contains(MCRegister Reg) const
Returns true if register Reg is contained in the set.
Definition LivePhysRegs.h:109
LivePhysRegs & operator=(const LivePhysRegs &)=delete
void removeRegsInMask(const MachineOperand &MO, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand * > > *Clobbers=nullptr)
Removes physical registers clobbered by the regmask operand MO.
bool empty() const
Returns true if the set is empty.
Definition LivePhysRegs.h:80
void dump() const
Dumps the currently live registers to the debug output.
MCRegAliasIterator enumerates all registers aliasing Reg.
Wrapper class representing physical registers. Should be passed by value.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
SparseSet - Fast set implementation for objects that can be identified by small unsigned keys.
typename DenseT::const_iterator const_iterator
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
void recomputeLivenessFlags(MachineBasicBlock &MBB)
Recomputes dead and kill flags in MBB.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool isPhysRegUsedAfter(Register Reg, MachineBasicBlock::iterator MBI)
Check if physical register Reg is used after MBI.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
void computeAndAddLiveIns(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB)
Convenience function combining computeLiveIns() and addLiveIns().
void computeLiveIns(LivePhysRegs &LiveRegs, const MachineBasicBlock &MBB)
Computes registers live-in to MBB assuming all of its successors live-in lists are up-to-date.
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.
Definition LivePhysRegs.h:225
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
static bool recomputeLiveIns(MachineBasicBlock &MBB)
Convenience function for recomputing live-in's for a MBB.
Definition LivePhysRegs.h:210
Pair of physical register and lane mask.