LLVM: include/llvm/CodeGen/VirtRegMap.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef LLVM_CODEGEN_VIRTREGMAP_H
17#define LLVM_CODEGEN_VIRTREGMAP_H
18
26#include
27
28namespace llvm {
29
34
40
41
42
43
44
45
47
48
49
50
51
53
54
55
57
58
59
61
62
64
65public:
67
72
74
76 assert(MF && "getMachineFunction called before runOnMachineFunction");
77 return *MF;
78 }
79
82
84
85
86
88
89
90
93 return Virt2PhysMap[virtReg];
94 }
95
96
97
99
101
103 return Virt2ShapeMap.contains(virtReg);
104 }
105
108 return Virt2ShapeMap.lookup(virtReg);
109 }
110
112 Virt2ShapeMap[virtReg] = shape;
113 }
114
115
116
119 assert(Virt2PhysMap[virtReg] &&
120 "attempt to clear a not assigned virtual register");
121 Virt2PhysMap[virtReg] = MCRegister();
122 }
123
124
126 Virt2PhysMap.clear();
128 }
129
130
132
133
134
135
137
138
140 Virt2SplitMap[virtReg] = SReg;
142 Virt2ShapeMap[virtReg] = getShape(SReg);
143 }
144 }
145
146
148 return Virt2SplitMap[virtReg];
149 }
150
151
152
153
154
157 return Orig ? Orig : VirtReg;
158 }
159
160
161
164 return true;
165
166
167 return (Virt2SplitMap[virtReg] && Virt2PhysMap[virtReg]);
168 }
169
170
171
174 return Virt2StackSlotMap[virtReg];
175 }
176
177
178
180
181
182
184
187};
188
193
196
197public:
199
201
203 VRM.print(OS, M);
204 }
205
208
210 VRM.init(MF);
211 return false;
212 }
213
218};
219
230
240
242 bool ClearVirtRegs = true;
243
244public:
246 : ClearVirtRegs(ClearVirtRegs) {}
249
251
254
256 if (ClearVirtRegs)
258 return {};
259 }
260};
261
262}
263
264#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This header defines various interfaces for pass management in LLVM.
This file implements an indexed map.
ModuleAnalysisManager MAM
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
MachineFunctionPass(char &ID)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition VirtRegMap.h:220
LLVM_ABI VirtRegMap run(MachineFunction &MF, MachineFunctionAnalysisManager &MAM)
VirtRegMap Result
Definition VirtRegMap.h:225
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
VirtRegMapPrinterPass(raw_ostream &OS)
Definition VirtRegMap.h:235
static bool isRequired()
Definition VirtRegMap.h:238
VirtRegMapWrapperLegacy()
Definition VirtRegMap.h:200
const VirtRegMap & getVRM() const
Definition VirtRegMap.h:207
VirtRegMap & getVRM()
Definition VirtRegMap.h:206
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition VirtRegMap.h:202
static LLVM_ABI char ID
Definition VirtRegMap.h:198
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition VirtRegMap.h:209
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition VirtRegMap.h:214
Definition VirtRegMap.h:35
LLVM_ABI bool hasKnownPreference(Register VirtReg) const
returns true if VirtReg has a known preferred register.
LLVM_ABI int assignVirt2StackSlot(Register virtReg)
create a mapping for the specifed virtual register to the next available stack slot
void clearVirt(Register virtReg)
clears the specified virtual register's, physical register mapping
Definition VirtRegMap.h:117
int getStackSlot(Register virtReg) const
returns the stack slot mapped to the specified virtual register
Definition VirtRegMap.h:172
void clearAllVirt()
clears all virtual to physical register mappings
Definition VirtRegMap.h:125
void setIsSplitFromReg(Register virtReg, Register SReg)
records virtReg is a split live interval from SReg.
Definition VirtRegMap.h:139
bool hasShape(Register virtReg) const
Definition VirtRegMap.h:102
LLVM_ABI void init(MachineFunction &MF)
LLVM_ABI bool hasPreferredPhys(Register VirtReg) const
returns true if VirtReg is assigned to its preferred physreg.
Register getOriginal(Register VirtReg) const
getOriginal - Return the original virtual register that VirtReg descends from through splitting.
Definition VirtRegMap.h:155
LLVM_ABI void dump() const
Register getPreSplitReg(Register virtReg) const
returns the live interval virtReg is split from.
Definition VirtRegMap.h:147
MachineRegisterInfo & getRegInfo() const
Definition VirtRegMap.h:80
ShapeT getShape(Register virtReg) const
Definition VirtRegMap.h:106
VirtRegMap()
Definition VirtRegMap.h:68
LLVM_ABI void assignVirt2Phys(Register virtReg, MCRegister physReg)
creates a mapping for the specified virtual register to the specified physical register
MachineFunction & getMachineFunction() const
Definition VirtRegMap.h:75
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
Definition VirtRegMap.h:91
LLVM_ABI void print(raw_ostream &OS, const Module *M=nullptr) const
VirtRegMap(VirtRegMap &&)=default
VirtRegMap(const VirtRegMap &)=delete
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
Definition VirtRegMap.h:87
void assignVirt2Shape(Register virtReg, ShapeT shape)
Definition VirtRegMap.h:111
bool isAssignedReg(Register virtReg) const
returns true if the specified virtual register is not mapped to a stack slot or rematerialized.
Definition VirtRegMap.h:162
static constexpr int NO_STACK_SLOT
Definition VirtRegMap.h:66
const TargetRegisterInfo & getTargetRegInfo() const
Definition VirtRegMap.h:81
VirtRegMap & operator=(const VirtRegMap &)=delete
bool isShapeMapEmpty() const
Definition VirtRegMap.h:100
static bool isRequired()
Definition VirtRegMap.h:250
VirtRegRewriterPass(bool ClearVirtRegs=true)
Definition VirtRegMap.h:245
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)>) const
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
MachineFunctionProperties getSetProperties() const
Definition VirtRegMap.h:255
An efficient, type-erasing, non-owning reference to a callable.
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.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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...
A CRTP mix-in to automatically provide informational APIs needed for passes.