blob: d1c14f662eef8da85c2c1f451772f44dcff162bb [file] [log] [blame]
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +00001//===-- llvm/CodeGen/VirtRegMap.h - Virtual Register Map -*- C++ -*--------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner8c4d88d2004-09-30 01:54:45 +000010// This file implements a virtual register map. This maps virtual registers to
11// physical registers and virtual registers to stack slots. It is created and
12// updated by a register allocator and then used by a machine code rewriter that
13// adds spill code and rewrites virtual into physical register references.
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000014//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_CODEGEN_VIRTREGMAP_H
18#define LLVM_CODEGEN_VIRTREGMAP_H
19
Dan Gohman6f0d0242008-02-10 18:45:23 +000020#include "llvm/Target/TargetRegisterInfo.h"
Evan Cheng81a03822007-11-17 00:40:40 +000021#include "llvm/ADT/DenseMap.h"
Chris Lattner94c002a2007-02-01 05:32:05 +000022#include "llvm/ADT/IndexedMap.h"
Evan Chengd3653122008-02-27 03:04:06 +000023#include "llvm/ADT/SmallPtrSet.h"
Bill Wendlinge8156192006-12-07 01:30:32 +000024#include "llvm/Support/Streams.h"
Alkis Evlogimenos5f375022004-03-01 20:05:10 +000025#include <map>
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000026
27namespace llvm {
Chris Lattner8c4d88d2004-09-30 01:54:45 +000028 class MachineInstr;
David Greene7e231462007-08-07 16:34:05 +000029 class MachineFunction;
Chris Lattner29268692006-09-05 02:12:02 +000030 class TargetInstrInfo;
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +000031
Chris Lattner8c4d88d2004-09-30 01:54:45 +000032 class VirtRegMap {
33 public:
Evan Cheng2638e1a2007-03-20 08:13:50 +000034 enum {
35 NO_PHYS_REG = 0,
Evan Cheng91935142007-04-04 07:40:01 +000036 NO_STACK_SLOT = (1L << 30)-1,
37 MAX_STACK_SLOT = (1L << 18)-1
Evan Cheng2638e1a2007-03-20 08:13:50 +000038 };
39
Chris Lattner35f27052006-05-01 21:16:03 +000040 enum ModRef { isRef = 1, isMod = 2, isModRef = 3 };
Chris Lattnerbec6a9e2004-10-01 23:15:36 +000041 typedef std::multimap<MachineInstr*,
42 std::pair<unsigned, ModRef> > MI2VirtMapTy;
Alkis Evlogimenos5f375022004-03-01 20:05:10 +000043
Chris Lattner8c4d88d2004-09-30 01:54:45 +000044 private:
Chris Lattner29268692006-09-05 02:12:02 +000045 const TargetInstrInfo &TII;
46
Chris Lattner7f690e62004-09-30 02:15:18 +000047 MachineFunction &MF;
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +000048 /// Virt2PhysMap - This is a virtual to physical register
49 /// mapping. Each virtual register is required to have an entry in
50 /// it; even spilled virtual registers (the register mapped to a
51 /// spilled register is the temporary used to load it from the
52 /// stack).
Chris Lattner94c002a2007-02-01 05:32:05 +000053 IndexedMap<unsigned, VirtReg2IndexFunctor> Virt2PhysMap;
Evan Cheng81a03822007-11-17 00:40:40 +000054
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +000055 /// Virt2StackSlotMap - This is virtual register to stack slot
56 /// mapping. Each spilled virtual register has an entry in it
57 /// which corresponds to the stack slot this register is spilled
58 /// at.
Chris Lattner94c002a2007-02-01 05:32:05 +000059 IndexedMap<int, VirtReg2IndexFunctor> Virt2StackSlotMap;
Evan Cheng81a03822007-11-17 00:40:40 +000060
61 /// Virt2StackSlotMap - This is virtual register to rematerialization id
62 /// mapping. Each spilled virtual register that should be remat'd has an
63 /// entry in it which corresponds to the remat id.
Evan Cheng549f27d32007-08-13 23:45:17 +000064 IndexedMap<int, VirtReg2IndexFunctor> Virt2ReMatIdMap;
Evan Cheng81a03822007-11-17 00:40:40 +000065
66 /// Virt2SplitMap - This is virtual register to splitted virtual register
67 /// mapping.
68 IndexedMap<unsigned, VirtReg2IndexFunctor> Virt2SplitMap;
69
Evan Chengadf85902007-12-05 09:51:10 +000070 /// Virt2SplitKillMap - This is splitted virtual register to its last use
Evan Chengd120ffd2007-12-05 10:24:35 +000071 /// (kill) index mapping.
72 IndexedMap<unsigned> Virt2SplitKillMap;
Evan Chengadf85902007-12-05 09:51:10 +000073
Evan Cheng81a03822007-11-17 00:40:40 +000074 /// ReMatMap - This is virtual register to re-materialized instruction
75 /// mapping. Each virtual register whose definition is going to be
76 /// re-materialized has an entry in it.
77 IndexedMap<MachineInstr*, VirtReg2IndexFunctor> ReMatMap;
78
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +000079 /// MI2VirtMap - This is MachineInstr to virtual register
80 /// mapping. In the case of memory spill code being folded into
81 /// instructions, we need to know which virtual register was
82 /// read/written by this instruction.
Chris Lattner7f690e62004-09-30 02:15:18 +000083 MI2VirtMapTy MI2VirtMap;
Misha Brukmanedf128a2005-04-21 22:36:52 +000084
Evan Cheng81a03822007-11-17 00:40:40 +000085 /// SpillPt2VirtMap - This records the virtual registers which should
86 /// be spilled right after the MachineInstr due to live interval
87 /// splitting.
Evan Chengb50bb8c2007-12-05 08:16:32 +000088 std::map<MachineInstr*, std::vector<std::pair<unsigned,bool> > >
89 SpillPt2VirtMap;
Evan Cheng2638e1a2007-03-20 08:13:50 +000090
Evan Cheng0cbb1162007-11-29 01:06:25 +000091 /// RestorePt2VirtMap - This records the virtual registers which should
92 /// be restored right before the MachineInstr due to live interval
93 /// splitting.
94 std::map<MachineInstr*, std::vector<unsigned> > RestorePt2VirtMap;
95
Evan Cheng2638e1a2007-03-20 08:13:50 +000096 /// ReMatId - Instead of assigning a stack slot to a to be rematerialized
Evan Cheng91935142007-04-04 07:40:01 +000097 /// virtual register, an unique id is being assigned. This keeps track of
Evan Cheng2638e1a2007-03-20 08:13:50 +000098 /// the highest id used so far. Note, this starts at (1<<18) to avoid
99 /// conflicts with stack slot numbers.
100 int ReMatId;
101
Evan Chengd3653122008-02-27 03:04:06 +0000102 /// LowSpillSlot, HighSpillSlot - Lowest and highest spill slot indexes.
103 int LowSpillSlot, HighSpillSlot;
104
105 /// SpillSlotToUsesMap - Records uses for each register spill slot.
106 SmallVector<SmallPtrSet<MachineInstr*, 4>, 8> SpillSlotToUsesMap;
107
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000108 VirtRegMap(const VirtRegMap&); // DO NOT IMPLEMENT
109 void operator=(const VirtRegMap&); // DO NOT IMPLEMENT
Alkis Evlogimenos79742872004-02-23 23:47:10 +0000110
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000111 public:
Dan Gohman61e729e2007-08-02 21:21:54 +0000112 explicit VirtRegMap(MachineFunction &mf);
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +0000113
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000114 void grow();
Alkis Evlogimenosdd420e02004-03-01 23:18:15 +0000115
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000116 /// @brief returns true if the specified virtual register is
117 /// mapped to a physical register
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000118 bool hasPhys(unsigned virtReg) const {
119 return getPhys(virtReg) != NO_PHYS_REG;
120 }
Alkis Evlogimenosdd420e02004-03-01 23:18:15 +0000121
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000122 /// @brief returns the physical register mapped to the specified
123 /// virtual register
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000124 unsigned getPhys(unsigned virtReg) const {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000125 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000126 return Virt2PhysMap[virtReg];
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000127 }
Alkis Evlogimenosdd420e02004-03-01 23:18:15 +0000128
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000129 /// @brief creates a mapping for the specified virtual register to
130 /// the specified physical register
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000131 void assignVirt2Phys(unsigned virtReg, unsigned physReg) {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000132 assert(TargetRegisterInfo::isVirtualRegister(virtReg) &&
133 TargetRegisterInfo::isPhysicalRegister(physReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000134 assert(Virt2PhysMap[virtReg] == NO_PHYS_REG &&
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000135 "attempt to assign physical register to already mapped "
136 "virtual register");
Chris Lattner7f690e62004-09-30 02:15:18 +0000137 Virt2PhysMap[virtReg] = physReg;
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000138 }
139
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000140 /// @brief clears the specified virtual register's, physical
141 /// register mapping
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000142 void clearVirt(unsigned virtReg) {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000143 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000144 assert(Virt2PhysMap[virtReg] != NO_PHYS_REG &&
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000145 "attempt to clear a not assigned virtual register");
Chris Lattner7f690e62004-09-30 02:15:18 +0000146 Virt2PhysMap[virtReg] = NO_PHYS_REG;
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000147 }
148
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000149 /// @brief clears all virtual to physical register mappings
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000150 void clearAllVirt() {
Chris Lattner7f690e62004-09-30 02:15:18 +0000151 Virt2PhysMap.clear();
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000152 grow();
153 }
154
Evan Cheng81a03822007-11-17 00:40:40 +0000155 /// @brief records virtReg is a split live interval from SReg.
156 void setIsSplitFromReg(unsigned virtReg, unsigned SReg) {
157 Virt2SplitMap[virtReg] = SReg;
158 }
159
160 /// @brief returns the live interval virtReg is split from.
161 unsigned getPreSplitReg(unsigned virtReg) {
162 return Virt2SplitMap[virtReg];
163 }
164
Evan Cheng549f27d32007-08-13 23:45:17 +0000165 /// @brief returns true is the specified virtual register is not
166 /// mapped to a stack slot or rematerialized.
167 bool isAssignedReg(unsigned virtReg) const {
Evan Cheng81a03822007-11-17 00:40:40 +0000168 if (getStackSlot(virtReg) == NO_STACK_SLOT &&
169 getReMatId(virtReg) == NO_STACK_SLOT)
170 return true;
171 // Split register can be assigned a physical register as well as a
172 // stack slot or remat id.
173 return (Virt2SplitMap[virtReg] && Virt2PhysMap[virtReg] != NO_PHYS_REG);
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000174 }
175
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000176 /// @brief returns the stack slot mapped to the specified virtual
177 /// register
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000178 int getStackSlot(unsigned virtReg) const {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000179 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Chris Lattner7f690e62004-09-30 02:15:18 +0000180 return Virt2StackSlotMap[virtReg];
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000181 }
182
Evan Cheng549f27d32007-08-13 23:45:17 +0000183 /// @brief returns the rematerialization id mapped to the specified virtual
184 /// register
185 int getReMatId(unsigned virtReg) const {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000186 assert(TargetRegisterInfo::isVirtualRegister(virtReg));
Evan Cheng549f27d32007-08-13 23:45:17 +0000187 return Virt2ReMatIdMap[virtReg];
188 }
189
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000190 /// @brief create a mapping for the specifed virtual register to
191 /// the next available stack slot
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000192 int assignVirt2StackSlot(unsigned virtReg);
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000193 /// @brief create a mapping for the specified virtual register to
194 /// the specified stack slot
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000195 void assignVirt2StackSlot(unsigned virtReg, int frameIndex);
196
Evan Cheng2638e1a2007-03-20 08:13:50 +0000197 /// @brief assign an unique re-materialization id to the specified
198 /// virtual register.
199 int assignVirtReMatId(unsigned virtReg);
Evan Cheng549f27d32007-08-13 23:45:17 +0000200 /// @brief assign an unique re-materialization id to the specified
201 /// virtual register.
202 void assignVirtReMatId(unsigned virtReg, int id);
Evan Cheng2638e1a2007-03-20 08:13:50 +0000203
204 /// @brief returns true if the specified virtual register is being
205 /// re-materialized.
206 bool isReMaterialized(unsigned virtReg) const {
Evan Cheng549f27d32007-08-13 23:45:17 +0000207 return ReMatMap[virtReg] != NULL;
Evan Cheng2638e1a2007-03-20 08:13:50 +0000208 }
209
210 /// @brief returns the original machine instruction being re-issued
211 /// to re-materialize the specified virtual register.
Evan Cheng549f27d32007-08-13 23:45:17 +0000212 MachineInstr *getReMaterializedMI(unsigned virtReg) const {
Evan Cheng2638e1a2007-03-20 08:13:50 +0000213 return ReMatMap[virtReg];
214 }
215
216 /// @brief records the specified virtual register will be
217 /// re-materialized and the original instruction which will be re-issed
Evan Cheng549f27d32007-08-13 23:45:17 +0000218 /// for this purpose. If parameter all is true, then all uses of the
219 /// registers are rematerialized and it's safe to delete the definition.
Evan Cheng2638e1a2007-03-20 08:13:50 +0000220 void setVirtIsReMaterialized(unsigned virtReg, MachineInstr *def) {
221 ReMatMap[virtReg] = def;
222 }
223
Evan Chengadf85902007-12-05 09:51:10 +0000224 /// @brief record the last use (kill) of a split virtual register.
Evan Chengd120ffd2007-12-05 10:24:35 +0000225 void addKillPoint(unsigned virtReg, unsigned index) {
226 Virt2SplitKillMap[virtReg] = index;
Evan Chengadf85902007-12-05 09:51:10 +0000227 }
228
Evan Chengd120ffd2007-12-05 10:24:35 +0000229 unsigned getKillPoint(unsigned virtReg) const {
230 return Virt2SplitKillMap[virtReg];
231 }
232
233 /// @brief remove the last use (kill) of a split virtual register.
Evan Chengadf85902007-12-05 09:51:10 +0000234 void removeKillPoint(unsigned virtReg) {
Evan Chengd120ffd2007-12-05 10:24:35 +0000235 Virt2SplitKillMap[virtReg] = 0;
Evan Chengadf85902007-12-05 09:51:10 +0000236 }
237
Evan Chengcada2452007-11-28 01:28:46 +0000238 /// @brief returns true if the specified MachineInstr is a spill point.
239 bool isSpillPt(MachineInstr *Pt) const {
240 return SpillPt2VirtMap.find(Pt) != SpillPt2VirtMap.end();
241 }
242
Evan Cheng81a03822007-11-17 00:40:40 +0000243 /// @brief returns the virtual registers that should be spilled due to
244 /// splitting right after the specified MachineInstr.
Evan Chengb50bb8c2007-12-05 08:16:32 +0000245 std::vector<std::pair<unsigned,bool> > &getSpillPtSpills(MachineInstr *Pt) {
Evan Cheng81a03822007-11-17 00:40:40 +0000246 return SpillPt2VirtMap[Pt];
247 }
248
249 /// @brief records the specified MachineInstr as a spill point for virtReg.
Evan Chengb50bb8c2007-12-05 08:16:32 +0000250 void addSpillPoint(unsigned virtReg, bool isKill, MachineInstr *Pt) {
Evan Chengcada2452007-11-28 01:28:46 +0000251 if (SpillPt2VirtMap.find(Pt) != SpillPt2VirtMap.end())
Evan Chengb50bb8c2007-12-05 08:16:32 +0000252 SpillPt2VirtMap[Pt].push_back(std::make_pair(virtReg, isKill));
Evan Chengcada2452007-11-28 01:28:46 +0000253 else {
Evan Chengb50bb8c2007-12-05 08:16:32 +0000254 std::vector<std::pair<unsigned,bool> > Virts;
255 Virts.push_back(std::make_pair(virtReg, isKill));
Evan Chengcada2452007-11-28 01:28:46 +0000256 SpillPt2VirtMap.insert(std::make_pair(Pt, Virts));
257 }
Evan Cheng81a03822007-11-17 00:40:40 +0000258 }
259
260 void transferSpillPts(MachineInstr *Old, MachineInstr *New) {
Evan Chengb50bb8c2007-12-05 08:16:32 +0000261 std::map<MachineInstr*,std::vector<std::pair<unsigned,bool> > >::iterator
262 I = SpillPt2VirtMap.find(Old);
Evan Chengcada2452007-11-28 01:28:46 +0000263 if (I == SpillPt2VirtMap.end())
264 return;
265 while (!I->second.empty()) {
Evan Chengb50bb8c2007-12-05 08:16:32 +0000266 unsigned virtReg = I->second.back().first;
267 bool isKill = I->second.back().second;
Evan Chengcada2452007-11-28 01:28:46 +0000268 I->second.pop_back();
Evan Chengb50bb8c2007-12-05 08:16:32 +0000269 addSpillPoint(virtReg, isKill, New);
Evan Cheng81a03822007-11-17 00:40:40 +0000270 }
Evan Chengcada2452007-11-28 01:28:46 +0000271 SpillPt2VirtMap.erase(I);
Evan Cheng81a03822007-11-17 00:40:40 +0000272 }
273
Evan Cheng0cbb1162007-11-29 01:06:25 +0000274 /// @brief returns true if the specified MachineInstr is a restore point.
275 bool isRestorePt(MachineInstr *Pt) const {
276 return RestorePt2VirtMap.find(Pt) != RestorePt2VirtMap.end();
277 }
278
279 /// @brief returns the virtual registers that should be restoreed due to
280 /// splitting right after the specified MachineInstr.
281 std::vector<unsigned> &getRestorePtRestores(MachineInstr *Pt) {
282 return RestorePt2VirtMap[Pt];
283 }
284
285 /// @brief records the specified MachineInstr as a restore point for virtReg.
286 void addRestorePoint(unsigned virtReg, MachineInstr *Pt) {
287 if (RestorePt2VirtMap.find(Pt) != RestorePt2VirtMap.end())
288 RestorePt2VirtMap[Pt].push_back(virtReg);
289 else {
290 std::vector<unsigned> Virts;
291 Virts.push_back(virtReg);
292 RestorePt2VirtMap.insert(std::make_pair(Pt, Virts));
293 }
294 }
295
296 void transferRestorePts(MachineInstr *Old, MachineInstr *New) {
297 std::map<MachineInstr*,std::vector<unsigned> >::iterator I =
298 RestorePt2VirtMap.find(Old);
299 if (I == RestorePt2VirtMap.end())
300 return;
301 while (!I->second.empty()) {
302 unsigned virtReg = I->second.back();
303 I->second.pop_back();
304 addRestorePoint(virtReg, New);
305 }
306 RestorePt2VirtMap.erase(I);
307 }
308
Evan Chengd3653122008-02-27 03:04:06 +0000309 /// @brief Return lowest spill slot index.
310 int getLowSpillSlot() const {
311 return LowSpillSlot;
312 }
313
314 /// @brief Return highest spill slot index.
315 int getHighSpillSlot() const {
316 return HighSpillSlot;
317 }
318
319 /// @brief Records a spill slot use.
320 void addSpillSlotUse(int FrameIndex, MachineInstr *MI);
321
322 /// @brief Returns true if spill slot has been used.
323 bool isSpillSlotUsed(int FrameIndex) const {
324 assert(FrameIndex >= 0 && "Spill slot index should not be negative!");
325 return !SpillSlotToUsesMap[FrameIndex-LowSpillSlot].empty();
326 }
327
Chris Lattnerbec6a9e2004-10-01 23:15:36 +0000328 /// @brief Updates information about the specified virtual register's value
Evan Chengaee4af62007-12-02 08:30:39 +0000329 /// folded into newMI machine instruction.
330 void virtFolded(unsigned VirtReg, MachineInstr *OldMI, MachineInstr *NewMI,
331 ModRef MRInfo);
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000332
Evan Cheng7f566252007-10-13 02:50:24 +0000333 /// @brief Updates information about the specified virtual register's value
334 /// folded into the specified machine instruction.
335 void virtFolded(unsigned VirtReg, MachineInstr *MI, ModRef MRInfo);
336
Alkis Evlogimenosc736b3a2004-10-01 00:35:07 +0000337 /// @brief returns the virtual registers' values folded in memory
338 /// operands of this instruction
Chris Lattner7f690e62004-09-30 02:15:18 +0000339 std::pair<MI2VirtMapTy::const_iterator, MI2VirtMapTy::const_iterator>
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000340 getFoldedVirts(MachineInstr* MI) const {
Chris Lattner7f690e62004-09-30 02:15:18 +0000341 return MI2VirtMap.equal_range(MI);
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000342 }
Chris Lattner35f27052006-05-01 21:16:03 +0000343
Evan Chengcada2452007-11-28 01:28:46 +0000344 /// RemoveMachineInstrFromMaps - MI is being erased, remove it from the
345 /// the folded instruction map and spill point map.
Evan Chengd3653122008-02-27 03:04:06 +0000346 void RemoveMachineInstrFromMaps(MachineInstr *MI);
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000347
348 void print(std::ostream &OS) const;
Bill Wendling5c7e3262006-12-17 05:15:13 +0000349 void print(std::ostream *OS) const { if (OS) print(*OS); }
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000350 void dump() const;
351 };
352
Bill Wendling5c7e3262006-12-17 05:15:13 +0000353 inline std::ostream *operator<<(std::ostream *OS, const VirtRegMap &VRM) {
354 VRM.print(OS);
355 return OS;
356 }
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000357 inline std::ostream &operator<<(std::ostream &OS, const VirtRegMap &VRM) {
358 VRM.print(OS);
359 return OS;
360 }
361
362 /// Spiller interface: Implementations of this interface assign spilled
363 /// virtual registers to stack slots, rewriting the code.
364 struct Spiller {
365 virtual ~Spiller();
366 virtual bool runOnMachineFunction(MachineFunction &MF,
Chris Lattner35f27052006-05-01 21:16:03 +0000367 VirtRegMap &VRM) = 0;
Chris Lattner8c4d88d2004-09-30 01:54:45 +0000368 };
369
370 /// createSpiller - Create an return a spiller object, as specified on the
371 /// command line.
372 Spiller* createSpiller();
Alkis Evlogimenos0d6c5b62004-02-24 08:58:30 +0000373
Alkis Evlogimenos34d9bc92004-02-23 23:08:11 +0000374} // End llvm namespace
375
376#endif