Chris Lattner | a3b8b5c | 2004-07-23 17:56:30 +0000 | [diff] [blame] | 1 | //===-- LiveIntervalAnalysis.h - Live Interval Analysis ---------*- C++ -*-===// |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 7ed47a1 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Chris Lattner | 6b92906 | 2004-07-19 02:13:59 +0000 | [diff] [blame] | 10 | // This file implements the LiveInterval analysis pass. Given some numbering of |
| 11 | // each the machine instructions (in this implemention depth-first order) an |
| 12 | // interval [i, j) is said to be a live interval for register v if there is no |
Dan Gohman | 8131a50 | 2008-03-13 23:04:27 +0000 | [diff] [blame] | 13 | // instruction with number j' > j such that v is live at j' and there is no |
Chris Lattner | 6b92906 | 2004-07-19 02:13:59 +0000 | [diff] [blame] | 14 | // instruction with number i' < i such that v is live at i'. In this |
| 15 | // implementation intervals can have holes, i.e. an interval might look like |
| 16 | // [1,20), [50,65), [1000,1001). |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
Chris Lattner | a3b8b5c | 2004-07-23 17:56:30 +0000 | [diff] [blame] | 20 | #ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H |
| 21 | #define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 22 | |
| 23 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Chris Lattner | 779a651 | 2005-09-21 04:18:25 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/LiveInterval.h" |
Evan Cheng | 61de82d | 2007-02-15 05:59:24 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/BitVector.h" |
Evan Cheng | 20b0abc | 2007-04-17 20:32:26 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/DenseMap.h" |
Evan Cheng | 8f90b6e | 2009-01-07 02:08:57 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/SmallPtrSet.h" |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/SmallVector.h" |
Evan Cheng | f3bb2e6 | 2007-09-05 21:46:51 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Allocator.h" |
Hartmut Kaiser | ffb15de | 2007-11-13 23:04:28 +0000 | [diff] [blame] | 30 | #include <cmath> |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 31 | |
| 32 | namespace llvm { |
| 33 | |
Dan Gohman | 6d69ba8 | 2008-07-25 00:02:30 +0000 | [diff] [blame] | 34 | class AliasAnalysis; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 35 | class LiveVariables; |
Evan Cheng | 22f07ff | 2007-12-11 02:09:15 +0000 | [diff] [blame] | 36 | class MachineLoopInfo; |
Dan Gohman | 6f0d024 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 37 | class TargetRegisterInfo; |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 38 | class MachineRegisterInfo; |
Chris Lattner | f768bba | 2005-03-09 23:05:19 +0000 | [diff] [blame] | 39 | class TargetInstrInfo; |
Evan Cheng | 20b0abc | 2007-04-17 20:32:26 +0000 | [diff] [blame] | 40 | class TargetRegisterClass; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 41 | class VirtRegMap; |
Evan Cheng | 4ca980e | 2007-10-17 02:10:22 +0000 | [diff] [blame] | 42 | typedef std::pair<unsigned, MachineBasicBlock*> IdxMBBPair; |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 43 | |
Roman Levenstein | 8dd2528 | 2008-02-18 09:35:30 +0000 | [diff] [blame] | 44 | inline bool operator<(unsigned V, const IdxMBBPair &IM) { |
| 45 | return V < IM.first; |
| 46 | } |
| 47 | |
| 48 | inline bool operator<(const IdxMBBPair &IM, unsigned V) { |
| 49 | return IM.first < V; |
| 50 | } |
| 51 | |
| 52 | struct Idx2MBBCompare { |
| 53 | bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const { |
| 54 | return LHS.first < RHS.first; |
| 55 | } |
| 56 | }; |
Owen Anderson | 20e2839 | 2008-08-13 22:08:30 +0000 | [diff] [blame] | 57 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 58 | class LiveIntervals : public MachineFunctionPass { |
| 59 | MachineFunction* mf_; |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 60 | MachineRegisterInfo* mri_; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 61 | const TargetMachine* tm_; |
Dan Gohman | 6f0d024 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 62 | const TargetRegisterInfo* tri_; |
Chris Lattner | f768bba | 2005-03-09 23:05:19 +0000 | [diff] [blame] | 63 | const TargetInstrInfo* tii_; |
Dan Gohman | 6d69ba8 | 2008-07-25 00:02:30 +0000 | [diff] [blame] | 64 | AliasAnalysis *aa_; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 65 | LiveVariables* lv_; |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 66 | |
Evan Cheng | f3bb2e6 | 2007-09-05 21:46:51 +0000 | [diff] [blame] | 67 | /// Special pool allocator for VNInfo's (LiveInterval val#). |
| 68 | /// |
| 69 | BumpPtrAllocator VNInfoAllocator; |
| 70 | |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 71 | /// MBB2IdxMap - The indexes of the first and last instructions in the |
| 72 | /// specified basic block. |
| 73 | std::vector<std::pair<unsigned, unsigned> > MBB2IdxMap; |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 74 | |
Evan Cheng | 4ca980e | 2007-10-17 02:10:22 +0000 | [diff] [blame] | 75 | /// Idx2MBBMap - Sorted list of pairs of index of first instruction |
| 76 | /// and MBB id. |
| 77 | std::vector<IdxMBBPair> Idx2MBBMap; |
| 78 | |
Owen Anderson | a1566f2 | 2008-07-22 22:46:49 +0000 | [diff] [blame] | 79 | /// FunctionSize - The number of instructions present in the function |
| 80 | uint64_t FunctionSize; |
| 81 | |
Owen Anderson | 49bfdd6 | 2008-08-13 21:24:24 +0000 | [diff] [blame] | 82 | typedef DenseMap<MachineInstr*, unsigned> Mi2IndexMap; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 83 | Mi2IndexMap mi2iMap_; |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 84 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 85 | typedef std::vector<MachineInstr*> Index2MiMap; |
| 86 | Index2MiMap i2miMap_; |
Alkis Evlogimenos | 843b160 | 2004-02-15 10:24:21 +0000 | [diff] [blame] | 87 | |
Owen Anderson | 20e2839 | 2008-08-13 22:08:30 +0000 | [diff] [blame] | 88 | typedef DenseMap<unsigned, LiveInterval*> Reg2IntervalMap; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 89 | Reg2IntervalMap r2iMap_; |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 90 | |
Evan Cheng | 61de82d | 2007-02-15 05:59:24 +0000 | [diff] [blame] | 91 | BitVector allocatableRegs_; |
Evan Cheng | 88d1f58 | 2007-03-01 02:03:03 +0000 | [diff] [blame] | 92 | |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 93 | std::vector<MachineInstr*> ClonedMIs; |
| 94 | |
Lang Hames | f41538d | 2009-06-02 16:53:25 +0000 | [diff] [blame] | 95 | typedef LiveInterval::InstrSlots InstrSlots; |
| 96 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 97 | public: |
Nick Lewycky | ecd94c8 | 2007-05-06 13:37:16 +0000 | [diff] [blame] | 98 | static char ID; // Pass identification, replacement for typeid |
Dan Gohman | ae73dc1 | 2008-09-04 17:05:41 +0000 | [diff] [blame] | 99 | LiveIntervals() : MachineFunctionPass(&ID) {} |
Devang Patel | 794fd75 | 2007-05-01 21:15:47 +0000 | [diff] [blame] | 100 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 101 | static unsigned getBaseIndex(unsigned index) { |
| 102 | return index - (index % InstrSlots::NUM); |
| 103 | } |
| 104 | static unsigned getBoundaryIndex(unsigned index) { |
| 105 | return getBaseIndex(index + InstrSlots::NUM - 1); |
| 106 | } |
| 107 | static unsigned getLoadIndex(unsigned index) { |
| 108 | return getBaseIndex(index) + InstrSlots::LOAD; |
| 109 | } |
| 110 | static unsigned getUseIndex(unsigned index) { |
| 111 | return getBaseIndex(index) + InstrSlots::USE; |
| 112 | } |
| 113 | static unsigned getDefIndex(unsigned index) { |
| 114 | return getBaseIndex(index) + InstrSlots::DEF; |
| 115 | } |
| 116 | static unsigned getStoreIndex(unsigned index) { |
| 117 | return getBaseIndex(index) + InstrSlots::STORE; |
| 118 | } |
| 119 | |
Evan Cheng | c341760 | 2008-06-21 06:45:54 +0000 | [diff] [blame] | 120 | static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) { |
| 121 | return (isDef + isUse) * powf(10.0F, (float)loopDepth); |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 124 | typedef Reg2IntervalMap::iterator iterator; |
Chris Lattner | 70ca358 | 2004-09-30 15:59:17 +0000 | [diff] [blame] | 125 | typedef Reg2IntervalMap::const_iterator const_iterator; |
| 126 | const_iterator begin() const { return r2iMap_.begin(); } |
| 127 | const_iterator end() const { return r2iMap_.end(); } |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 128 | iterator begin() { return r2iMap_.begin(); } |
| 129 | iterator end() { return r2iMap_.end(); } |
Evan Cheng | 34cd4a4 | 2008-05-05 18:30:58 +0000 | [diff] [blame] | 130 | unsigned getNumIntervals() const { return (unsigned)r2iMap_.size(); } |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 131 | |
| 132 | LiveInterval &getInterval(unsigned reg) { |
| 133 | Reg2IntervalMap::iterator I = r2iMap_.find(reg); |
| 134 | assert(I != r2iMap_.end() && "Interval does not exist for register"); |
Owen Anderson | 03857b2 | 2008-08-13 21:49:13 +0000 | [diff] [blame] | 135 | return *I->second; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | const LiveInterval &getInterval(unsigned reg) const { |
| 139 | Reg2IntervalMap::const_iterator I = r2iMap_.find(reg); |
| 140 | assert(I != r2iMap_.end() && "Interval does not exist for register"); |
Owen Anderson | 03857b2 | 2008-08-13 21:49:13 +0000 | [diff] [blame] | 141 | return *I->second; |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Evan Cheng | b371f45 | 2007-02-19 21:49:54 +0000 | [diff] [blame] | 144 | bool hasInterval(unsigned reg) const { |
Evan Cheng | 88d1f58 | 2007-03-01 02:03:03 +0000 | [diff] [blame] | 145 | return r2iMap_.count(reg); |
Evan Cheng | b371f45 | 2007-02-19 21:49:54 +0000 | [diff] [blame] | 146 | } |
| 147 | |
Chris Lattner | 428b92e | 2006-09-15 03:57:23 +0000 | [diff] [blame] | 148 | /// getMBBStartIdx - Return the base index of the first instruction in the |
| 149 | /// specified MachineBasicBlock. |
| 150 | unsigned getMBBStartIdx(MachineBasicBlock *MBB) const { |
| 151 | return getMBBStartIdx(MBB->getNumber()); |
| 152 | } |
Chris Lattner | 428b92e | 2006-09-15 03:57:23 +0000 | [diff] [blame] | 153 | unsigned getMBBStartIdx(unsigned MBBNo) const { |
| 154 | assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 155 | return MBB2IdxMap[MBBNo].first; |
| 156 | } |
| 157 | |
| 158 | /// getMBBEndIdx - Return the store index of the last instruction in the |
| 159 | /// specified MachineBasicBlock. |
| 160 | unsigned getMBBEndIdx(MachineBasicBlock *MBB) const { |
| 161 | return getMBBEndIdx(MBB->getNumber()); |
| 162 | } |
| 163 | unsigned getMBBEndIdx(unsigned MBBNo) const { |
| 164 | assert(MBBNo < MBB2IdxMap.size() && "Invalid MBB number!"); |
| 165 | return MBB2IdxMap[MBBNo].second; |
Chris Lattner | 428b92e | 2006-09-15 03:57:23 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Owen Anderson | a1566f2 | 2008-07-22 22:46:49 +0000 | [diff] [blame] | 168 | /// getScaledIntervalSize - get the size of an interval in "units," |
Owen Anderson | 72e0409 | 2008-06-23 23:25:37 +0000 | [diff] [blame] | 169 | /// where every function is composed of one thousand units. This |
| 170 | /// measure scales properly with empty index slots in the function. |
Owen Anderson | a1566f2 | 2008-07-22 22:46:49 +0000 | [diff] [blame] | 171 | double getScaledIntervalSize(LiveInterval& I) { |
| 172 | return (1000.0 / InstrSlots::NUM * I.getSize()) / i2miMap_.size(); |
| 173 | } |
| 174 | |
| 175 | /// getApproximateInstructionCount - computes an estimate of the number |
| 176 | /// of instructions in a given LiveInterval. |
| 177 | unsigned getApproximateInstructionCount(LiveInterval& I) { |
| 178 | double IntervalPercentage = getScaledIntervalSize(I) / 1000.0; |
Matthijs Kooijman | b3e15c0 | 2008-08-07 13:36:30 +0000 | [diff] [blame] | 179 | return (unsigned)(IntervalPercentage * FunctionSize); |
Owen Anderson | 72e0409 | 2008-06-23 23:25:37 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Roman Levenstein | 8dd2528 | 2008-02-18 09:35:30 +0000 | [diff] [blame] | 182 | /// getMBBFromIndex - given an index in any instruction of an |
| 183 | /// MBB return a pointer the MBB |
| 184 | MachineBasicBlock* getMBBFromIndex(unsigned index) const { |
| 185 | std::vector<IdxMBBPair>::const_iterator I = |
Bill Wendling | e85fe66 | 2008-02-26 10:49:39 +0000 | [diff] [blame] | 186 | std::lower_bound(Idx2MBBMap.begin(), Idx2MBBMap.end(), index); |
Roman Levenstein | 8dd2528 | 2008-02-18 09:35:30 +0000 | [diff] [blame] | 187 | // Take the pair containing the index |
| 188 | std::vector<IdxMBBPair>::const_iterator J = |
Bill Wendling | e85fe66 | 2008-02-26 10:49:39 +0000 | [diff] [blame] | 189 | ((I != Idx2MBBMap.end() && I->first > index) || |
| 190 | (I == Idx2MBBMap.end() && Idx2MBBMap.size()>0)) ? (I-1): I; |
Roman Levenstein | 8dd2528 | 2008-02-18 09:35:30 +0000 | [diff] [blame] | 191 | |
| 192 | assert(J != Idx2MBBMap.end() && J->first < index+1 && |
Bill Wendling | e85fe66 | 2008-02-26 10:49:39 +0000 | [diff] [blame] | 193 | index <= getMBBEndIdx(J->second) && |
| 194 | "index does not correspond to an MBB"); |
Roman Levenstein | 8dd2528 | 2008-02-18 09:35:30 +0000 | [diff] [blame] | 195 | return J->second; |
| 196 | } |
| 197 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 198 | /// getInstructionIndex - returns the base index of instr |
| 199 | unsigned getInstructionIndex(MachineInstr* instr) const { |
| 200 | Mi2IndexMap::const_iterator it = mi2iMap_.find(instr); |
| 201 | assert(it != mi2iMap_.end() && "Invalid instruction!"); |
| 202 | return it->second; |
| 203 | } |
| 204 | |
| 205 | /// getInstructionFromIndex - given an index in any slot of an |
| 206 | /// instruction return a pointer the instruction |
| 207 | MachineInstr* getInstructionFromIndex(unsigned index) const { |
| 208 | index /= InstrSlots::NUM; // convert index to vector index |
| 209 | assert(index < i2miMap_.size() && |
| 210 | "index does not correspond to an instruction"); |
| 211 | return i2miMap_[index]; |
| 212 | } |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 213 | |
Evan Cheng | f5cd4f0 | 2008-10-23 20:43:13 +0000 | [diff] [blame] | 214 | /// hasGapBeforeInstr - Return true if the previous instruction slot, |
| 215 | /// i.e. Index - InstrSlots::NUM, is not occupied. |
| 216 | bool hasGapBeforeInstr(unsigned Index) { |
| 217 | Index = getBaseIndex(Index - InstrSlots::NUM); |
| 218 | return getInstructionFromIndex(Index) == 0; |
| 219 | } |
| 220 | |
Lang Hames | f41538d | 2009-06-02 16:53:25 +0000 | [diff] [blame] | 221 | /// hasGapAfterInstr - Return true if the successive instruction slot, |
| 222 | /// i.e. Index + InstrSlots::Num, is not occupied. |
| 223 | bool hasGapAfterInstr(unsigned Index) { |
| 224 | Index = getBaseIndex(Index + InstrSlots::NUM); |
| 225 | return getInstructionFromIndex(Index) == 0; |
| 226 | } |
| 227 | |
Evan Cheng | f5cd4f0 | 2008-10-23 20:43:13 +0000 | [diff] [blame] | 228 | /// findGapBeforeInstr - Find an empty instruction slot before the |
| 229 | /// specified index. If "Furthest" is true, find one that's furthest |
| 230 | /// away from the index (but before any index that's occupied). |
| 231 | unsigned findGapBeforeInstr(unsigned Index, bool Furthest = false) { |
| 232 | Index = getBaseIndex(Index - InstrSlots::NUM); |
| 233 | if (getInstructionFromIndex(Index)) |
| 234 | return 0; // No gap! |
| 235 | if (!Furthest) |
| 236 | return Index; |
| 237 | unsigned PrevIndex = getBaseIndex(Index - InstrSlots::NUM); |
| 238 | while (getInstructionFromIndex(Index)) { |
| 239 | Index = PrevIndex; |
| 240 | PrevIndex = getBaseIndex(Index - InstrSlots::NUM); |
| 241 | } |
| 242 | return Index; |
| 243 | } |
| 244 | |
| 245 | /// InsertMachineInstrInMaps - Insert the specified machine instruction |
| 246 | /// into the instruction index map at the given index. |
| 247 | void InsertMachineInstrInMaps(MachineInstr *MI, unsigned Index) { |
| 248 | i2miMap_[Index / InstrSlots::NUM] = MI; |
| 249 | Mi2IndexMap::iterator it = mi2iMap_.find(MI); |
| 250 | assert(it == mi2iMap_.end() && "Already in map!"); |
| 251 | mi2iMap_[MI] = Index; |
| 252 | } |
| 253 | |
Evan Cheng | c92da38 | 2007-11-03 07:20:12 +0000 | [diff] [blame] | 254 | /// conflictsWithPhysRegDef - Returns true if the specified register |
| 255 | /// is defined during the duration of the specified interval. |
| 256 | bool conflictsWithPhysRegDef(const LiveInterval &li, VirtRegMap &vrm, |
| 257 | unsigned reg); |
| 258 | |
Evan Cheng | 8f90b6e | 2009-01-07 02:08:57 +0000 | [diff] [blame] | 259 | /// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except |
| 260 | /// it can check use as well. |
| 261 | bool conflictsWithPhysRegRef(LiveInterval &li, unsigned Reg, |
| 262 | bool CheckUse, |
| 263 | SmallPtrSet<MachineInstr*,32> &JoinedCopies); |
| 264 | |
Evan Cheng | 4ca980e | 2007-10-17 02:10:22 +0000 | [diff] [blame] | 265 | /// findLiveInMBBs - Given a live range, if the value of the range |
| 266 | /// is live in any MBB returns true as well as the list of basic blocks |
Dan Gohman | ca425a2 | 2008-07-28 18:42:57 +0000 | [diff] [blame] | 267 | /// in which the value is live. |
Evan Cheng | d0e32c5 | 2008-10-29 05:06:14 +0000 | [diff] [blame] | 268 | bool findLiveInMBBs(unsigned Start, unsigned End, |
| 269 | SmallVectorImpl<MachineBasicBlock*> &MBBs) const; |
| 270 | |
| 271 | /// findReachableMBBs - Return a list MBB that can be reached via any |
| 272 | /// branch or fallthroughs. Return true if the list is not empty. |
| 273 | bool findReachableMBBs(unsigned Start, unsigned End, |
Evan Cheng | a5bfc97 | 2007-10-17 06:53:44 +0000 | [diff] [blame] | 274 | SmallVectorImpl<MachineBasicBlock*> &MBBs) const; |
Evan Cheng | 4ca980e | 2007-10-17 02:10:22 +0000 | [diff] [blame] | 275 | |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 276 | // Interval creation |
| 277 | |
| 278 | LiveInterval &getOrCreateInterval(unsigned reg) { |
| 279 | Reg2IntervalMap::iterator I = r2iMap_.find(reg); |
| 280 | if (I == r2iMap_.end()) |
Owen Anderson | 20e2839 | 2008-08-13 22:08:30 +0000 | [diff] [blame] | 281 | I = r2iMap_.insert(std::make_pair(reg, createInterval(reg))).first; |
Owen Anderson | 03857b2 | 2008-08-13 21:49:13 +0000 | [diff] [blame] | 282 | return *I->second; |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 283 | } |
Evan Cheng | 0a1fcce | 2009-02-08 11:04:35 +0000 | [diff] [blame] | 284 | |
| 285 | /// dupInterval - Duplicate a live interval. The caller is responsible for |
| 286 | /// managing the allocated memory. |
| 287 | LiveInterval *dupInterval(LiveInterval *li); |
Owen Anderson | c4dc132 | 2008-06-05 17:15:43 +0000 | [diff] [blame] | 288 | |
| 289 | /// addLiveRangeToEndOfBlock - Given a register and an instruction, |
| 290 | /// adds a live range from that instruction to the end of its MBB. |
| 291 | LiveRange addLiveRangeToEndOfBlock(unsigned reg, |
| 292 | MachineInstr* startInst); |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 293 | |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 294 | // Interval removal |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 295 | |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 296 | void removeInterval(unsigned Reg) { |
Owen Anderson | 20e2839 | 2008-08-13 22:08:30 +0000 | [diff] [blame] | 297 | DenseMap<unsigned, LiveInterval*>::iterator I = r2iMap_.find(Reg); |
Owen Anderson | 03857b2 | 2008-08-13 21:49:13 +0000 | [diff] [blame] | 298 | delete I->second; |
| 299 | r2iMap_.erase(I); |
Bill Wendling | 5c7e326 | 2006-12-17 05:15:13 +0000 | [diff] [blame] | 300 | } |
Chris Lattner | 70ca358 | 2004-09-30 15:59:17 +0000 | [diff] [blame] | 301 | |
Evan Cheng | 5b69eba | 2009-04-21 22:46:52 +0000 | [diff] [blame] | 302 | /// isNotInMIMap - returns true if the specified machine instr has been |
| 303 | /// removed or was never entered in the map. |
| 304 | bool isNotInMIMap(MachineInstr* instr) const { |
Evan Cheng | 7d35c0e | 2007-02-22 23:52:23 +0000 | [diff] [blame] | 305 | return !mi2iMap_.count(instr); |
Evan Cheng | 30cac02 | 2007-02-22 23:03:39 +0000 | [diff] [blame] | 306 | } |
| 307 | |
Chris Lattner | f7da2c7 | 2006-08-24 22:43:55 +0000 | [diff] [blame] | 308 | /// RemoveMachineInstrFromMaps - This marks the specified machine instr as |
| 309 | /// deleted. |
| 310 | void RemoveMachineInstrFromMaps(MachineInstr *MI) { |
| 311 | // remove index -> MachineInstr and |
| 312 | // MachineInstr -> index mappings |
| 313 | Mi2IndexMap::iterator mi2i = mi2iMap_.find(MI); |
| 314 | if (mi2i != mi2iMap_.end()) { |
| 315 | i2miMap_[mi2i->second/InstrSlots::NUM] = 0; |
| 316 | mi2iMap_.erase(mi2i); |
| 317 | } |
| 318 | } |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 319 | |
Evan Cheng | 7007143 | 2008-02-13 03:01:43 +0000 | [diff] [blame] | 320 | /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in |
| 321 | /// maps used by register allocator. |
| 322 | void ReplaceMachineInstrInMaps(MachineInstr *MI, MachineInstr *NewMI) { |
| 323 | Mi2IndexMap::iterator mi2i = mi2iMap_.find(MI); |
Evan Cheng | b1f6f91 | 2008-02-13 09:18:16 +0000 | [diff] [blame] | 324 | if (mi2i == mi2iMap_.end()) |
| 325 | return; |
| 326 | i2miMap_[mi2i->second/InstrSlots::NUM] = NewMI; |
| 327 | Mi2IndexMap::iterator it = mi2iMap_.find(MI); |
| 328 | assert(it != mi2iMap_.end() && "Invalid instruction!"); |
| 329 | unsigned Index = it->second; |
| 330 | mi2iMap_.erase(it); |
| 331 | mi2iMap_[NewMI] = Index; |
Evan Cheng | 7007143 | 2008-02-13 03:01:43 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Evan Cheng | f3bb2e6 | 2007-09-05 21:46:51 +0000 | [diff] [blame] | 334 | BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; } |
| 335 | |
Evan Cheng | c8d044e | 2008-02-15 18:24:29 +0000 | [diff] [blame] | 336 | /// getVNInfoSourceReg - Helper function that parses the specified VNInfo |
| 337 | /// copy field and returns the source register that defines it. |
| 338 | unsigned getVNInfoSourceReg(const VNInfo *VNI) const; |
| 339 | |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 340 | virtual void getAnalysisUsage(AnalysisUsage &AU) const; |
| 341 | virtual void releaseMemory(); |
| 342 | |
| 343 | /// runOnMachineFunction - pass entry point |
| 344 | virtual bool runOnMachineFunction(MachineFunction&); |
| 345 | |
| 346 | /// print - Implement the dump method. |
| 347 | virtual void print(std::ostream &O, const Module* = 0) const; |
| 348 | void print(std::ostream *O, const Module* M = 0) const { |
| 349 | if (O) print(*O, M); |
| 350 | } |
| 351 | |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 352 | /// addIntervalsForSpills - Create new intervals for spilled defs / uses of |
Evan Cheng | 9c3c221 | 2008-06-06 07:54:39 +0000 | [diff] [blame] | 353 | /// the given interval. FIXME: It also returns the weight of the spill slot |
| 354 | /// (if any is created) by reference. This is temporary. |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 355 | std::vector<LiveInterval*> |
Evan Cheng | 81a0382 | 2007-11-17 00:40:40 +0000 | [diff] [blame] | 356 | addIntervalsForSpills(const LiveInterval& i, |
Evan Cheng | dc37786 | 2008-09-30 15:44:16 +0000 | [diff] [blame] | 357 | SmallVectorImpl<LiveInterval*> &SpillIs, |
Evan Cheng | c781a24 | 2009-05-03 18:32:42 +0000 | [diff] [blame] | 358 | const MachineLoopInfo *loopInfo, VirtRegMap& vrm); |
Owen Anderson | d666431 | 2008-08-18 18:05:32 +0000 | [diff] [blame] | 359 | |
| 360 | /// addIntervalsForSpillsFast - Quickly create new intervals for spilled |
| 361 | /// defs / uses without remat or splitting. |
| 362 | std::vector<LiveInterval*> |
| 363 | addIntervalsForSpillsFast(const LiveInterval &li, |
Evan Cheng | c781a24 | 2009-05-03 18:32:42 +0000 | [diff] [blame] | 364 | const MachineLoopInfo *loopInfo, VirtRegMap &vrm); |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 365 | |
Evan Cheng | 676dd7c | 2008-03-11 07:19:34 +0000 | [diff] [blame] | 366 | /// spillPhysRegAroundRegDefsUses - Spill the specified physical register |
Evan Cheng | 2824a65 | 2009-03-23 18:24:37 +0000 | [diff] [blame] | 367 | /// around all defs and uses of the specified interval. Return true if it |
| 368 | /// was able to cut its interval. |
| 369 | bool spillPhysRegAroundRegDefsUses(const LiveInterval &li, |
Evan Cheng | 676dd7c | 2008-03-11 07:19:34 +0000 | [diff] [blame] | 370 | unsigned PhysReg, VirtRegMap &vrm); |
| 371 | |
Evan Cheng | 5ef3a04 | 2007-12-06 00:01:56 +0000 | [diff] [blame] | 372 | /// isReMaterializable - Returns true if every definition of MI of every |
| 373 | /// val# of the specified interval is re-materializable. Also returns true |
| 374 | /// by reference if all of the defs are load instructions. |
Evan Cheng | dc37786 | 2008-09-30 15:44:16 +0000 | [diff] [blame] | 375 | bool isReMaterializable(const LiveInterval &li, |
| 376 | SmallVectorImpl<LiveInterval*> &SpillIs, |
| 377 | bool &isLoad); |
Evan Cheng | 5ef3a04 | 2007-12-06 00:01:56 +0000 | [diff] [blame] | 378 | |
Evan Cheng | 0658749 | 2008-10-24 02:05:00 +0000 | [diff] [blame] | 379 | /// isReMaterializable - Returns true if the definition MI of the specified |
| 380 | /// val# of the specified interval is re-materializable. |
| 381 | bool isReMaterializable(const LiveInterval &li, const VNInfo *ValNo, |
| 382 | MachineInstr *MI); |
| 383 | |
Evan Cheng | 676dd7c | 2008-03-11 07:19:34 +0000 | [diff] [blame] | 384 | /// getRepresentativeReg - Find the largest super register of the specified |
| 385 | /// physical register. |
| 386 | unsigned getRepresentativeReg(unsigned Reg) const; |
| 387 | |
| 388 | /// getNumConflictsWithPhysReg - Return the number of uses and defs of the |
| 389 | /// specified interval that conflicts with the specified physical register. |
| 390 | unsigned getNumConflictsWithPhysReg(const LiveInterval &li, |
| 391 | unsigned PhysReg) const; |
| 392 | |
Evan Cheng | 2578ba2 | 2009-07-01 01:59:31 +0000 | [diff] [blame^] | 393 | /// processImplicitDefs - Process IMPLICIT_DEF instructions. Add isUndef |
| 394 | /// marker to implicit_def defs and their uses. |
| 395 | void processImplicitDefs(); |
| 396 | |
Owen Anderson | 15a17f5 | 2008-05-30 20:14:04 +0000 | [diff] [blame] | 397 | /// computeNumbering - Compute the index numbering. |
| 398 | void computeNumbering(); |
| 399 | |
Lang Hames | f41538d | 2009-06-02 16:53:25 +0000 | [diff] [blame] | 400 | /// scaleNumbering - Rescale interval numbers to introduce gaps for new |
| 401 | /// instructions |
| 402 | void scaleNumbering(int factor); |
| 403 | |
Owen Anderson | 0c2e7b9 | 2009-01-13 06:05:10 +0000 | [diff] [blame] | 404 | /// intervalIsInOneMBB - Returns true if the specified interval is entirely |
| 405 | /// within a single basic block. |
| 406 | bool intervalIsInOneMBB(const LiveInterval &li) const; |
| 407 | |
David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 408 | private: |
Chris Lattner | 428b92e | 2006-09-15 03:57:23 +0000 | [diff] [blame] | 409 | /// computeIntervals - Compute live intervals. |
Chris Lattner | c7695eb | 2006-09-14 06:42:17 +0000 | [diff] [blame] | 410 | void computeIntervals(); |
Chris Lattner | 6bda49f | 2006-09-02 05:26:01 +0000 | [diff] [blame] | 411 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 412 | /// handleRegisterDef - update intervals for a register def |
| 413 | /// (calls handlePhysicalRegisterDef and |
| 414 | /// handleVirtualRegisterDef) |
Chris Lattner | 6b128bd | 2006-09-03 08:07:11 +0000 | [diff] [blame] | 415 | void handleRegisterDef(MachineBasicBlock *MBB, |
| 416 | MachineBasicBlock::iterator MI, unsigned MIIdx, |
Evan Cheng | ef0732d | 2008-07-10 07:35:43 +0000 | [diff] [blame] | 417 | MachineOperand& MO, unsigned MOIdx); |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 418 | |
| 419 | /// handleVirtualRegisterDef - update intervals for a virtual |
| 420 | /// register def |
Chris Lattner | 6b128bd | 2006-09-03 08:07:11 +0000 | [diff] [blame] | 421 | void handleVirtualRegisterDef(MachineBasicBlock *MBB, |
| 422 | MachineBasicBlock::iterator MI, |
Owen Anderson | 6b098de | 2008-06-25 23:39:39 +0000 | [diff] [blame] | 423 | unsigned MIIdx, MachineOperand& MO, |
Evan Cheng | ef0732d | 2008-07-10 07:35:43 +0000 | [diff] [blame] | 424 | unsigned MOIdx, LiveInterval& interval); |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 425 | |
Chris Lattner | f768bba | 2005-03-09 23:05:19 +0000 | [diff] [blame] | 426 | /// handlePhysicalRegisterDef - update intervals for a physical register |
Chris Lattner | f7da2c7 | 2006-08-24 22:43:55 +0000 | [diff] [blame] | 427 | /// def. |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 428 | void handlePhysicalRegisterDef(MachineBasicBlock* mbb, |
| 429 | MachineBasicBlock::iterator mi, |
Owen Anderson | 6b098de | 2008-06-25 23:39:39 +0000 | [diff] [blame] | 430 | unsigned MIIdx, MachineOperand& MO, |
Chris Lattner | 91725b7 | 2006-08-31 05:54:43 +0000 | [diff] [blame] | 431 | LiveInterval &interval, |
Evan Cheng | c8d044e | 2008-02-15 18:24:29 +0000 | [diff] [blame] | 432 | MachineInstr *CopyMI); |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 433 | |
Evan Cheng | b371f45 | 2007-02-19 21:49:54 +0000 | [diff] [blame] | 434 | /// handleLiveInRegister - Create interval for a livein register. |
Jim Laskey | 9b25b8c | 2007-02-21 22:41:17 +0000 | [diff] [blame] | 435 | void handleLiveInRegister(MachineBasicBlock* mbb, |
| 436 | unsigned MIIdx, |
Evan Cheng | 24a3cc4 | 2007-04-25 07:30:23 +0000 | [diff] [blame] | 437 | LiveInterval &interval, bool isAlias = false); |
Evan Cheng | b371f45 | 2007-02-19 21:49:54 +0000 | [diff] [blame] | 438 | |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 439 | /// getReMatImplicitUse - If the remat definition MI has one (for now, we |
| 440 | /// only allow one) virtual register operand, then its uses are implicitly |
| 441 | /// using the register. Returns the virtual register. |
| 442 | unsigned getReMatImplicitUse(const LiveInterval &li, |
| 443 | MachineInstr *MI) const; |
| 444 | |
| 445 | /// isValNoAvailableAt - Return true if the val# of the specified interval |
| 446 | /// which reaches the given instruction also reaches the specified use |
| 447 | /// index. |
| 448 | bool isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI, |
| 449 | unsigned UseIdx) const; |
| 450 | |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 451 | /// isReMaterializable - Returns true if the definition MI of the specified |
Evan Cheng | 5ef3a04 | 2007-12-06 00:01:56 +0000 | [diff] [blame] | 452 | /// val# of the specified interval is re-materializable. Also returns true |
| 453 | /// by reference if the def is a load. |
Evan Cheng | 7ecb38b | 2007-08-29 20:45:00 +0000 | [diff] [blame] | 454 | bool isReMaterializable(const LiveInterval &li, const VNInfo *ValNo, |
Evan Cheng | dc37786 | 2008-09-30 15:44:16 +0000 | [diff] [blame] | 455 | MachineInstr *MI, |
| 456 | SmallVectorImpl<LiveInterval*> &SpillIs, |
| 457 | bool &isLoad); |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 458 | |
Evan Cheng | 35b35c5 | 2007-08-30 05:52:20 +0000 | [diff] [blame] | 459 | /// tryFoldMemoryOperand - Attempts to fold either a spill / restore from |
| 460 | /// slot / to reg or any rematerialized load into ith operand of specified |
| 461 | /// MI. If it is successul, MI is updated with the newly created MI and |
| 462 | /// returns true. |
| 463 | bool tryFoldMemoryOperand(MachineInstr* &MI, VirtRegMap &vrm, |
Evan Cheng | cddbb83 | 2007-11-30 21:23:43 +0000 | [diff] [blame] | 464 | MachineInstr *DefMI, unsigned InstrIdx, |
Evan Cheng | aee4af6 | 2007-12-02 08:30:39 +0000 | [diff] [blame] | 465 | SmallVector<unsigned, 2> &Ops, |
Evan Cheng | cddbb83 | 2007-11-30 21:23:43 +0000 | [diff] [blame] | 466 | bool isSS, int Slot, unsigned Reg); |
Evan Cheng | 549f27d3 | 2007-08-13 23:45:17 +0000 | [diff] [blame] | 467 | |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 468 | /// canFoldMemoryOperand - Return true if the specified load / store |
Evan Cheng | 018f9b0 | 2007-12-05 03:22:34 +0000 | [diff] [blame] | 469 | /// folding is possible. |
Evan Cheng | d64b5c8 | 2007-12-05 03:14:33 +0000 | [diff] [blame] | 470 | bool canFoldMemoryOperand(MachineInstr *MI, |
Evan Cheng | 79a0c1e | 2008-02-25 08:50:41 +0000 | [diff] [blame] | 471 | SmallVector<unsigned, 2> &Ops, |
| 472 | bool ReMatLoadSS) const; |
Evan Cheng | d64b5c8 | 2007-12-05 03:14:33 +0000 | [diff] [blame] | 473 | |
Evan Cheng | 0cbb116 | 2007-11-29 01:06:25 +0000 | [diff] [blame] | 474 | /// anyKillInMBBAfterIdx - Returns true if there is a kill of the specified |
| 475 | /// VNInfo that's after the specified index but is within the basic block. |
| 476 | bool anyKillInMBBAfterIdx(const LiveInterval &li, const VNInfo *VNI, |
| 477 | MachineBasicBlock *MBB, unsigned Idx) const; |
Evan Cheng | 81a0382 | 2007-11-17 00:40:40 +0000 | [diff] [blame] | 478 | |
Evan Cheng | 676dd7c | 2008-03-11 07:19:34 +0000 | [diff] [blame] | 479 | /// hasAllocatableSuperReg - Return true if the specified physical register |
| 480 | /// has any super register that's allocatable. |
| 481 | bool hasAllocatableSuperReg(unsigned Reg) const; |
| 482 | |
Evan Cheng | 1953d0c | 2007-11-29 10:12:14 +0000 | [diff] [blame] | 483 | /// SRInfo - Spill / restore info. |
| 484 | struct SRInfo { |
| 485 | int index; |
| 486 | unsigned vreg; |
| 487 | bool canFold; |
| 488 | SRInfo(int i, unsigned vr, bool f) : index(i), vreg(vr), canFold(f) {}; |
| 489 | }; |
| 490 | |
| 491 | bool alsoFoldARestore(int Id, int index, unsigned vr, |
| 492 | BitVector &RestoreMBBs, |
Owen Anderson | 2899831 | 2008-08-13 22:28:50 +0000 | [diff] [blame] | 493 | DenseMap<unsigned,std::vector<SRInfo> >&RestoreIdxes); |
Evan Cheng | 1953d0c | 2007-11-29 10:12:14 +0000 | [diff] [blame] | 494 | void eraseRestoreInfo(int Id, int index, unsigned vr, |
| 495 | BitVector &RestoreMBBs, |
Owen Anderson | 2899831 | 2008-08-13 22:28:50 +0000 | [diff] [blame] | 496 | DenseMap<unsigned,std::vector<SRInfo> >&RestoreIdxes); |
Evan Cheng | 1953d0c | 2007-11-29 10:12:14 +0000 | [diff] [blame] | 497 | |
Evan Cheng | 4cce6b4 | 2008-04-11 17:53:36 +0000 | [diff] [blame] | 498 | /// handleSpilledImpDefs - Remove IMPLICIT_DEF instructions which are being |
| 499 | /// spilled and create empty intervals for their uses. |
| 500 | void handleSpilledImpDefs(const LiveInterval &li, VirtRegMap &vrm, |
| 501 | const TargetRegisterClass* rc, |
| 502 | std::vector<LiveInterval*> &NewLIs); |
Evan Cheng | 419852c | 2008-04-03 16:39:43 +0000 | [diff] [blame] | 503 | |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 504 | /// rewriteImplicitOps - Rewrite implicit use operands of MI (i.e. uses of |
| 505 | /// interval on to-be re-materialized operands of MI) with new register. |
| 506 | void rewriteImplicitOps(const LiveInterval &li, |
| 507 | MachineInstr *MI, unsigned NewVReg, VirtRegMap &vrm); |
| 508 | |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 509 | /// rewriteInstructionForSpills, rewriteInstructionsForSpills - Helper |
| 510 | /// functions for addIntervalsForSpills to rewrite uses / defs for the given |
| 511 | /// live range. |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 512 | bool rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI, |
| 513 | bool TrySplit, unsigned index, unsigned end, MachineInstr *MI, |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 514 | MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot, |
| 515 | bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 516 | VirtRegMap &vrm, const TargetRegisterClass* rc, |
| 517 | SmallVector<int, 4> &ReMatIds, const MachineLoopInfo *loopInfo, |
Evan Cheng | 0cc83b6 | 2008-02-23 00:46:11 +0000 | [diff] [blame] | 518 | unsigned &NewVReg, unsigned ImpUse, bool &HasDef, bool &HasUse, |
Owen Anderson | 2899831 | 2008-08-13 22:28:50 +0000 | [diff] [blame] | 519 | DenseMap<unsigned,unsigned> &MBBVRegsMap, |
Evan Cheng | c781a24 | 2009-05-03 18:32:42 +0000 | [diff] [blame] | 520 | std::vector<LiveInterval*> &NewLIs); |
Evan Cheng | 81a0382 | 2007-11-17 00:40:40 +0000 | [diff] [blame] | 521 | void rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit, |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 522 | LiveInterval::Ranges::const_iterator &I, |
| 523 | MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot, |
| 524 | bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, |
Evan Cheng | d70dbb5 | 2008-02-22 09:24:50 +0000 | [diff] [blame] | 525 | VirtRegMap &vrm, const TargetRegisterClass* rc, |
Evan Cheng | 22f07ff | 2007-12-11 02:09:15 +0000 | [diff] [blame] | 526 | SmallVector<int, 4> &ReMatIds, const MachineLoopInfo *loopInfo, |
Evan Cheng | 81a0382 | 2007-11-17 00:40:40 +0000 | [diff] [blame] | 527 | BitVector &SpillMBBs, |
Owen Anderson | 2899831 | 2008-08-13 22:28:50 +0000 | [diff] [blame] | 528 | DenseMap<unsigned,std::vector<SRInfo> > &SpillIdxes, |
Evan Cheng | 0cbb116 | 2007-11-29 01:06:25 +0000 | [diff] [blame] | 529 | BitVector &RestoreMBBs, |
Owen Anderson | 2899831 | 2008-08-13 22:28:50 +0000 | [diff] [blame] | 530 | DenseMap<unsigned,std::vector<SRInfo> > &RestoreIdxes, |
| 531 | DenseMap<unsigned,unsigned> &MBBVRegsMap, |
Evan Cheng | c781a24 | 2009-05-03 18:32:42 +0000 | [diff] [blame] | 532 | std::vector<LiveInterval*> &NewLIs); |
Evan Cheng | f2fbca6 | 2007-11-12 06:35:08 +0000 | [diff] [blame] | 533 | |
Owen Anderson | 03857b2 | 2008-08-13 21:49:13 +0000 | [diff] [blame] | 534 | static LiveInterval* createInterval(unsigned Reg); |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 535 | |
Alkis Evlogimenos | 1a8ea01 | 2004-08-04 09:46:26 +0000 | [diff] [blame] | 536 | void printRegName(unsigned reg) const; |
| 537 | }; |
| 538 | |
Alkis Evlogimenos | ff0cbe1 | 2003-11-20 03:32:25 +0000 | [diff] [blame] | 539 | } // End llvm namespace |
| 540 | |
| 541 | #endif |