Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 1 | //===-- TwoAddressInstructionPass.cpp - Two-Address instruction pass ------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Alkis Evlogimenos | 50c047d | 2004-01-04 23:09:24 +0000 | [diff] [blame] | 10 | // This file implements the TwoAddress instruction pass which is used |
| 11 | // by most register allocators. Two-Address instructions are rewritten |
| 12 | // from: |
| 13 | // |
| 14 | // A = B op C |
| 15 | // |
| 16 | // to: |
| 17 | // |
| 18 | // A = B |
Alkis Evlogimenos | 14be640 | 2004-02-04 22:17:40 +0000 | [diff] [blame] | 19 | // A op= C |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 20 | // |
Alkis Evlogimenos | 14be640 | 2004-02-04 22:17:40 +0000 | [diff] [blame] | 21 | // Note that if a register allocator chooses to use this pass, that it |
| 22 | // has to be capable of handling the non-SSA nature of these rewritten |
| 23 | // virtual registers. |
| 24 | // |
| 25 | // It is also worth noting that the duplicate operand of the two |
| 26 | // address instruction is removed. |
Chris Lattner | bd91c1c | 2004-01-31 21:07:15 +0000 | [diff] [blame] | 27 | // |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 28 | //===----------------------------------------------------------------------===// |
| 29 | |
| 30 | #define DEBUG_TYPE "twoaddrinstr" |
Chris Lattner | bd91c1c | 2004-01-31 21:07:15 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/Passes.h" |
Chris Lattner | 1e31363 | 2004-07-21 23:17:57 +0000 | [diff] [blame] | 32 | #include "llvm/Function.h" |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 33 | #include "llvm/CodeGen/LiveVariables.h" |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 34 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 35 | #include "llvm/CodeGen/MachineInstr.h" |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 36 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
Dan Gohman | 6f0d024 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 37 | #include "llvm/Target/TargetRegisterInfo.h" |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 38 | #include "llvm/Target/TargetInstrInfo.h" |
| 39 | #include "llvm/Target/TargetMachine.h" |
Owen Anderson | 95dad83 | 2008-10-07 20:22:28 +0000 | [diff] [blame] | 40 | #include "llvm/Target/TargetOptions.h" |
Chris Lattner | a4f0b3a | 2006-08-27 12:54:02 +0000 | [diff] [blame] | 41 | #include "llvm/Support/Compiler.h" |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 42 | #include "llvm/Support/Debug.h" |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 43 | #include "llvm/ADT/BitVector.h" |
| 44 | #include "llvm/ADT/DenseMap.h" |
Dan Gohman | d68a076 | 2009-01-05 17:59:02 +0000 | [diff] [blame] | 45 | #include "llvm/ADT/SmallSet.h" |
Reid Spencer | 551ccae | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 46 | #include "llvm/ADT/Statistic.h" |
| 47 | #include "llvm/ADT/STLExtras.h" |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 48 | using namespace llvm; |
| 49 | |
Chris Lattner | cd3245a | 2006-12-19 22:41:21 +0000 | [diff] [blame] | 50 | STATISTIC(NumTwoAddressInstrs, "Number of two-address instructions"); |
| 51 | STATISTIC(NumCommuted , "Number of instructions commuted to coalesce"); |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 52 | STATISTIC(NumAggrCommuted , "Number of instructions aggressively commuted"); |
Chris Lattner | cd3245a | 2006-12-19 22:41:21 +0000 | [diff] [blame] | 53 | STATISTIC(NumConvertedTo3Addr, "Number of instructions promoted to 3-address"); |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 54 | STATISTIC(Num3AddrSunk, "Number of 3-address instructions sunk"); |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 55 | STATISTIC(NumReMats, "Number of instructions re-materialized"); |
Evan Cheng | 28c7ce3 | 2009-02-21 03:14:25 +0000 | [diff] [blame] | 56 | STATISTIC(NumDeletes, "Number of dead instructions deleted"); |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 57 | |
| 58 | namespace { |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 59 | class VISIBILITY_HIDDEN TwoAddressInstructionPass |
| 60 | : public MachineFunctionPass { |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 61 | const TargetInstrInfo *TII; |
| 62 | const TargetRegisterInfo *TRI; |
| 63 | MachineRegisterInfo *MRI; |
| 64 | LiveVariables *LV; |
| 65 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 66 | // DistanceMap - Keep track the distance of a MI from the start of the |
| 67 | // current basic block. |
| 68 | DenseMap<MachineInstr*, unsigned> DistanceMap; |
| 69 | |
| 70 | // SrcRegMap - A map from virtual registers to physical registers which |
| 71 | // are likely targets to be coalesced to due to copies from physical |
| 72 | // registers to virtual registers. e.g. v1024 = move r0. |
| 73 | DenseMap<unsigned, unsigned> SrcRegMap; |
| 74 | |
| 75 | // DstRegMap - A map from virtual registers to physical registers which |
| 76 | // are likely targets to be coalesced to due to copies to physical |
| 77 | // registers from virtual registers. e.g. r1 = move v1024. |
| 78 | DenseMap<unsigned, unsigned> DstRegMap; |
| 79 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 80 | bool Sink3AddrInstruction(MachineBasicBlock *MBB, MachineInstr *MI, |
| 81 | unsigned Reg, |
| 82 | MachineBasicBlock::iterator OldPos); |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 83 | |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 84 | bool isProfitableToReMat(unsigned Reg, const TargetRegisterClass *RC, |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 85 | MachineInstr *MI, MachineInstr *DefMI, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 86 | MachineBasicBlock *MBB, unsigned Loc); |
Evan Cheng | 8191371 | 2009-01-23 23:27:33 +0000 | [diff] [blame] | 87 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 88 | bool NoUseAfterLastDef(unsigned Reg, MachineBasicBlock *MBB, unsigned Dist, |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 89 | unsigned &LastDef); |
| 90 | |
| 91 | bool isProfitableToCommute(unsigned regB, unsigned regC, |
| 92 | MachineInstr *MI, MachineBasicBlock *MBB, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 93 | unsigned Dist); |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 94 | |
Evan Cheng | 8191371 | 2009-01-23 23:27:33 +0000 | [diff] [blame] | 95 | bool CommuteInstruction(MachineBasicBlock::iterator &mi, |
| 96 | MachineFunction::iterator &mbbi, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 97 | unsigned RegB, unsigned RegC, unsigned Dist); |
| 98 | |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 99 | bool isProfitableToConv3Addr(unsigned RegA); |
| 100 | |
| 101 | bool ConvertInstTo3Addr(MachineBasicBlock::iterator &mi, |
| 102 | MachineBasicBlock::iterator &nmi, |
| 103 | MachineFunction::iterator &mbbi, |
| 104 | unsigned RegB, unsigned Dist); |
| 105 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 106 | void ProcessCopy(MachineInstr *MI, MachineBasicBlock *MBB, |
| 107 | SmallPtrSet<MachineInstr*, 8> &Processed); |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 108 | public: |
Nick Lewycky | ecd94c8 | 2007-05-06 13:37:16 +0000 | [diff] [blame] | 109 | static char ID; // Pass identification, replacement for typeid |
Dan Gohman | ae73dc1 | 2008-09-04 17:05:41 +0000 | [diff] [blame] | 110 | TwoAddressInstructionPass() : MachineFunctionPass(&ID) {} |
Devang Patel | 794fd75 | 2007-05-01 21:15:47 +0000 | [diff] [blame] | 111 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 112 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 113 | AU.addPreserved<LiveVariables>(); |
| 114 | AU.addPreservedID(MachineLoopInfoID); |
| 115 | AU.addPreservedID(MachineDominatorsID); |
Owen Anderson | 95dad83 | 2008-10-07 20:22:28 +0000 | [diff] [blame] | 116 | if (StrongPHIElim) |
| 117 | AU.addPreservedID(StrongPHIEliminationID); |
| 118 | else |
| 119 | AU.addPreservedID(PHIEliminationID); |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 120 | MachineFunctionPass::getAnalysisUsage(AU); |
| 121 | } |
Alkis Evlogimenos | 4c08086 | 2003-12-18 22:40:24 +0000 | [diff] [blame] | 122 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 123 | /// runOnMachineFunction - Pass entry point. |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 124 | bool runOnMachineFunction(MachineFunction&); |
| 125 | }; |
Chris Lattner | d74ea2b | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 126 | } |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 127 | |
Dan Gohman | 844731a | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 128 | char TwoAddressInstructionPass::ID = 0; |
| 129 | static RegisterPass<TwoAddressInstructionPass> |
| 130 | X("twoaddressinstruction", "Two-Address instruction pass"); |
| 131 | |
Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 132 | const PassInfo *const llvm::TwoAddressInstructionPassID = &X; |
Alkis Evlogimenos | 4c08086 | 2003-12-18 22:40:24 +0000 | [diff] [blame] | 133 | |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 134 | /// Sink3AddrInstruction - A two-address instruction has been converted to a |
| 135 | /// three-address instruction to avoid clobbering a register. Try to sink it |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 136 | /// past the instruction that would kill the above mentioned register to reduce |
| 137 | /// register pressure. |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 138 | bool TwoAddressInstructionPass::Sink3AddrInstruction(MachineBasicBlock *MBB, |
| 139 | MachineInstr *MI, unsigned SavedReg, |
| 140 | MachineBasicBlock::iterator OldPos) { |
| 141 | // Check if it's safe to move this instruction. |
| 142 | bool SeenStore = true; // Be conservative. |
| 143 | if (!MI->isSafeToMove(TII, SeenStore)) |
| 144 | return false; |
| 145 | |
| 146 | unsigned DefReg = 0; |
| 147 | SmallSet<unsigned, 4> UseRegs; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 148 | |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 149 | for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { |
| 150 | const MachineOperand &MO = MI->getOperand(i); |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 151 | if (!MO.isReg()) |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 152 | continue; |
| 153 | unsigned MOReg = MO.getReg(); |
| 154 | if (!MOReg) |
| 155 | continue; |
| 156 | if (MO.isUse() && MOReg != SavedReg) |
| 157 | UseRegs.insert(MO.getReg()); |
| 158 | if (!MO.isDef()) |
| 159 | continue; |
| 160 | if (MO.isImplicit()) |
| 161 | // Don't try to move it if it implicitly defines a register. |
| 162 | return false; |
| 163 | if (DefReg) |
| 164 | // For now, don't move any instructions that define multiple registers. |
| 165 | return false; |
| 166 | DefReg = MO.getReg(); |
| 167 | } |
| 168 | |
| 169 | // Find the instruction that kills SavedReg. |
| 170 | MachineInstr *KillMI = NULL; |
| 171 | for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(SavedReg), |
| 172 | UE = MRI->use_end(); UI != UE; ++UI) { |
| 173 | MachineOperand &UseMO = UI.getOperand(); |
| 174 | if (!UseMO.isKill()) |
| 175 | continue; |
| 176 | KillMI = UseMO.getParent(); |
| 177 | break; |
| 178 | } |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 179 | |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 180 | if (!KillMI || KillMI->getParent() != MBB || KillMI == MI) |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 181 | return false; |
| 182 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 183 | // If any of the definitions are used by another instruction between the |
| 184 | // position and the kill use, then it's not safe to sink it. |
| 185 | // |
| 186 | // FIXME: This can be sped up if there is an easy way to query whether an |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 187 | // instruction is before or after another instruction. Then we can use |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 188 | // MachineRegisterInfo def / use instead. |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 189 | MachineOperand *KillMO = NULL; |
| 190 | MachineBasicBlock::iterator KillPos = KillMI; |
| 191 | ++KillPos; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 192 | |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 193 | unsigned NumVisited = 0; |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 194 | for (MachineBasicBlock::iterator I = next(OldPos); I != KillPos; ++I) { |
| 195 | MachineInstr *OtherMI = I; |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 196 | if (NumVisited > 30) // FIXME: Arbitrary limit to reduce compile time cost. |
| 197 | return false; |
| 198 | ++NumVisited; |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 199 | for (unsigned i = 0, e = OtherMI->getNumOperands(); i != e; ++i) { |
| 200 | MachineOperand &MO = OtherMI->getOperand(i); |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 201 | if (!MO.isReg()) |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 202 | continue; |
| 203 | unsigned MOReg = MO.getReg(); |
| 204 | if (!MOReg) |
| 205 | continue; |
| 206 | if (DefReg == MOReg) |
| 207 | return false; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 208 | |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 209 | if (MO.isKill()) { |
| 210 | if (OtherMI == KillMI && MOReg == SavedReg) |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 211 | // Save the operand that kills the register. We want to unset the kill |
| 212 | // marker if we can sink MI past it. |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 213 | KillMO = &MO; |
| 214 | else if (UseRegs.count(MOReg)) |
| 215 | // One of the uses is killed before the destination. |
| 216 | return false; |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 221 | // Update kill and LV information. |
| 222 | KillMO->setIsKill(false); |
| 223 | KillMO = MI->findRegisterUseOperand(SavedReg, false, TRI); |
| 224 | KillMO->setIsKill(true); |
Owen Anderson | 802af11 | 2008-07-02 21:28:58 +0000 | [diff] [blame] | 225 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 226 | if (LV) |
| 227 | LV->replaceKillInstruction(SavedReg, KillMI, MI); |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 228 | |
| 229 | // Move instruction to its destination. |
| 230 | MBB->remove(MI); |
| 231 | MBB->insert(KillPos, MI); |
| 232 | |
| 233 | ++Num3AddrSunk; |
| 234 | return true; |
| 235 | } |
| 236 | |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 237 | /// isTwoAddrUse - Return true if the specified MI is using the specified |
| 238 | /// register as a two-address operand. |
| 239 | static bool isTwoAddrUse(MachineInstr *UseMI, unsigned Reg) { |
| 240 | const TargetInstrDesc &TID = UseMI->getDesc(); |
| 241 | for (unsigned i = 0, e = TID.getNumOperands(); i != e; ++i) { |
| 242 | MachineOperand &MO = UseMI->getOperand(i); |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 243 | if (MO.isReg() && MO.getReg() == Reg && |
Evan Cheng | a24752f | 2009-03-19 20:30:06 +0000 | [diff] [blame] | 244 | (MO.isDef() || UseMI->isRegTiedToDefOperand(i))) |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 245 | // Earlier use is a two-address one. |
| 246 | return true; |
| 247 | } |
| 248 | return false; |
| 249 | } |
| 250 | |
| 251 | /// isProfitableToReMat - Return true if the heuristics determines it is likely |
| 252 | /// to be profitable to re-materialize the definition of Reg rather than copy |
| 253 | /// the register. |
| 254 | bool |
| 255 | TwoAddressInstructionPass::isProfitableToReMat(unsigned Reg, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 256 | const TargetRegisterClass *RC, |
| 257 | MachineInstr *MI, MachineInstr *DefMI, |
| 258 | MachineBasicBlock *MBB, unsigned Loc) { |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 259 | bool OtherUse = false; |
| 260 | for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(Reg), |
| 261 | UE = MRI->use_end(); UI != UE; ++UI) { |
| 262 | MachineOperand &UseMO = UI.getOperand(); |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 263 | MachineInstr *UseMI = UseMO.getParent(); |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 264 | MachineBasicBlock *UseMBB = UseMI->getParent(); |
| 265 | if (UseMBB == MBB) { |
| 266 | DenseMap<MachineInstr*, unsigned>::iterator DI = DistanceMap.find(UseMI); |
| 267 | if (DI != DistanceMap.end() && DI->second == Loc) |
| 268 | continue; // Current use. |
| 269 | OtherUse = true; |
| 270 | // There is at least one other use in the MBB that will clobber the |
| 271 | // register. |
| 272 | if (isTwoAddrUse(UseMI, Reg)) |
| 273 | return true; |
| 274 | } |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 275 | } |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 276 | |
| 277 | // If other uses in MBB are not two-address uses, then don't remat. |
| 278 | if (OtherUse) |
| 279 | return false; |
| 280 | |
| 281 | // No other uses in the same block, remat if it's defined in the same |
| 282 | // block so it does not unnecessarily extend the live range. |
| 283 | return MBB == DefMI->getParent(); |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 284 | } |
| 285 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 286 | /// NoUseAfterLastDef - Return true if there are no intervening uses between the |
| 287 | /// last instruction in the MBB that defines the specified register and the |
| 288 | /// two-address instruction which is being processed. It also returns the last |
| 289 | /// def location by reference |
| 290 | bool TwoAddressInstructionPass::NoUseAfterLastDef(unsigned Reg, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 291 | MachineBasicBlock *MBB, unsigned Dist, |
| 292 | unsigned &LastDef) { |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 293 | LastDef = 0; |
| 294 | unsigned LastUse = Dist; |
| 295 | for (MachineRegisterInfo::reg_iterator I = MRI->reg_begin(Reg), |
| 296 | E = MRI->reg_end(); I != E; ++I) { |
| 297 | MachineOperand &MO = I.getOperand(); |
| 298 | MachineInstr *MI = MO.getParent(); |
| 299 | if (MI->getParent() != MBB) |
| 300 | continue; |
| 301 | DenseMap<MachineInstr*, unsigned>::iterator DI = DistanceMap.find(MI); |
| 302 | if (DI == DistanceMap.end()) |
| 303 | continue; |
| 304 | if (MO.isUse() && DI->second < LastUse) |
| 305 | LastUse = DI->second; |
| 306 | if (MO.isDef() && DI->second > LastDef) |
| 307 | LastDef = DI->second; |
| 308 | } |
| 309 | |
| 310 | return !(LastUse > LastDef && LastUse < Dist); |
| 311 | } |
| 312 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 313 | /// isCopyToReg - Return true if the specified MI is a copy instruction or |
| 314 | /// a extract_subreg instruction. It also returns the source and destination |
| 315 | /// registers and whether they are physical registers by reference. |
| 316 | static bool isCopyToReg(MachineInstr &MI, const TargetInstrInfo *TII, |
| 317 | unsigned &SrcReg, unsigned &DstReg, |
| 318 | bool &IsSrcPhys, bool &IsDstPhys) { |
| 319 | SrcReg = 0; |
| 320 | DstReg = 0; |
| 321 | unsigned SrcSubIdx, DstSubIdx; |
| 322 | if (!TII->isMoveInstr(MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) { |
| 323 | if (MI.getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) { |
| 324 | DstReg = MI.getOperand(0).getReg(); |
| 325 | SrcReg = MI.getOperand(1).getReg(); |
| 326 | } else if (MI.getOpcode() == TargetInstrInfo::INSERT_SUBREG) { |
| 327 | DstReg = MI.getOperand(0).getReg(); |
| 328 | SrcReg = MI.getOperand(2).getReg(); |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 329 | } else if (MI.getOpcode() == TargetInstrInfo::SUBREG_TO_REG) { |
| 330 | DstReg = MI.getOperand(0).getReg(); |
| 331 | SrcReg = MI.getOperand(2).getReg(); |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | |
| 335 | if (DstReg) { |
| 336 | IsSrcPhys = TargetRegisterInfo::isPhysicalRegister(SrcReg); |
| 337 | IsDstPhys = TargetRegisterInfo::isPhysicalRegister(DstReg); |
| 338 | return true; |
| 339 | } |
| 340 | return false; |
| 341 | } |
| 342 | |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 343 | /// isKilled - Test if the given register value, which is used by the given |
| 344 | /// instruction, is killed by the given instruction. This looks through |
| 345 | /// coalescable copies to see if the original value is potentially not killed. |
| 346 | /// |
| 347 | /// For example, in this code: |
| 348 | /// |
| 349 | /// %reg1034 = copy %reg1024 |
| 350 | /// %reg1035 = copy %reg1025<kill> |
| 351 | /// %reg1036 = add %reg1034<kill>, %reg1035<kill> |
| 352 | /// |
| 353 | /// %reg1034 is not considered to be killed, since it is copied from a |
| 354 | /// register which is not killed. Treating it as not killed lets the |
| 355 | /// normal heuristics commute the (two-address) add, which lets |
| 356 | /// coalescing eliminate the extra copy. |
| 357 | /// |
| 358 | static bool isKilled(MachineInstr &MI, unsigned Reg, |
| 359 | const MachineRegisterInfo *MRI, |
| 360 | const TargetInstrInfo *TII) { |
| 361 | MachineInstr *DefMI = &MI; |
| 362 | for (;;) { |
| 363 | if (!DefMI->killsRegister(Reg)) |
| 364 | return false; |
| 365 | if (TargetRegisterInfo::isPhysicalRegister(Reg)) |
| 366 | return true; |
| 367 | MachineRegisterInfo::def_iterator Begin = MRI->def_begin(Reg); |
| 368 | // If there are multiple defs, we can't do a simple analysis, so just |
| 369 | // go with what the kill flag says. |
| 370 | if (next(Begin) != MRI->def_end()) |
| 371 | return true; |
| 372 | DefMI = &*Begin; |
| 373 | bool IsSrcPhys, IsDstPhys; |
| 374 | unsigned SrcReg, DstReg; |
| 375 | // If the def is something other than a copy, then it isn't going to |
| 376 | // be coalesced, so follow the kill flag. |
| 377 | if (!isCopyToReg(*DefMI, TII, SrcReg, DstReg, IsSrcPhys, IsDstPhys)) |
| 378 | return true; |
| 379 | Reg = SrcReg; |
| 380 | } |
| 381 | } |
| 382 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 383 | /// isTwoAddrUse - Return true if the specified MI uses the specified register |
| 384 | /// as a two-address use. If so, return the destination register by reference. |
| 385 | static bool isTwoAddrUse(MachineInstr &MI, unsigned Reg, unsigned &DstReg) { |
| 386 | const TargetInstrDesc &TID = MI.getDesc(); |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 387 | unsigned NumOps = (MI.getOpcode() == TargetInstrInfo::INLINEASM) |
| 388 | ? MI.getNumOperands() : TID.getNumOperands(); |
| 389 | for (unsigned i = 0; i != NumOps; ++i) { |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 390 | const MachineOperand &MO = MI.getOperand(i); |
| 391 | if (!MO.isReg() || !MO.isUse() || MO.getReg() != Reg) |
| 392 | continue; |
Evan Cheng | a24752f | 2009-03-19 20:30:06 +0000 | [diff] [blame] | 393 | unsigned ti; |
| 394 | if (MI.isRegTiedToDefOperand(i, &ti)) { |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 395 | DstReg = MI.getOperand(ti).getReg(); |
| 396 | return true; |
| 397 | } |
| 398 | } |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | /// findOnlyInterestingUse - Given a register, if has a single in-basic block |
| 403 | /// use, return the use instruction if it's a copy or a two-address use. |
| 404 | static |
| 405 | MachineInstr *findOnlyInterestingUse(unsigned Reg, MachineBasicBlock *MBB, |
| 406 | MachineRegisterInfo *MRI, |
| 407 | const TargetInstrInfo *TII, |
| 408 | bool &isCopy, |
| 409 | unsigned &DstReg, bool &IsDstPhys) { |
| 410 | MachineRegisterInfo::use_iterator UI = MRI->use_begin(Reg); |
| 411 | if (UI == MRI->use_end()) |
| 412 | return 0; |
| 413 | MachineInstr &UseMI = *UI; |
| 414 | if (++UI != MRI->use_end()) |
| 415 | // More than one use. |
| 416 | return 0; |
| 417 | if (UseMI.getParent() != MBB) |
| 418 | return 0; |
| 419 | unsigned SrcReg; |
| 420 | bool IsSrcPhys; |
| 421 | if (isCopyToReg(UseMI, TII, SrcReg, DstReg, IsSrcPhys, IsDstPhys)) |
| 422 | return &UseMI; |
| 423 | IsDstPhys = false; |
| 424 | if (isTwoAddrUse(UseMI, Reg, DstReg)) |
| 425 | return &UseMI; |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | /// getMappedReg - Return the physical register the specified virtual register |
| 430 | /// might be mapped to. |
| 431 | static unsigned |
| 432 | getMappedReg(unsigned Reg, DenseMap<unsigned, unsigned> &RegMap) { |
| 433 | while (TargetRegisterInfo::isVirtualRegister(Reg)) { |
| 434 | DenseMap<unsigned, unsigned>::iterator SI = RegMap.find(Reg); |
| 435 | if (SI == RegMap.end()) |
| 436 | return 0; |
| 437 | Reg = SI->second; |
| 438 | } |
| 439 | if (TargetRegisterInfo::isPhysicalRegister(Reg)) |
| 440 | return Reg; |
| 441 | return 0; |
| 442 | } |
| 443 | |
| 444 | /// regsAreCompatible - Return true if the two registers are equal or aliased. |
| 445 | /// |
| 446 | static bool |
| 447 | regsAreCompatible(unsigned RegA, unsigned RegB, const TargetRegisterInfo *TRI) { |
| 448 | if (RegA == RegB) |
| 449 | return true; |
| 450 | if (!RegA || !RegB) |
| 451 | return false; |
| 452 | return TRI->regsOverlap(RegA, RegB); |
| 453 | } |
| 454 | |
| 455 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 456 | /// isProfitableToReMat - Return true if it's potentially profitable to commute |
| 457 | /// the two-address instruction that's being processed. |
| 458 | bool |
| 459 | TwoAddressInstructionPass::isProfitableToCommute(unsigned regB, unsigned regC, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 460 | MachineInstr *MI, MachineBasicBlock *MBB, |
| 461 | unsigned Dist) { |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 462 | // Determine if it's profitable to commute this two address instruction. In |
| 463 | // general, we want no uses between this instruction and the definition of |
| 464 | // the two-address register. |
| 465 | // e.g. |
| 466 | // %reg1028<def> = EXTRACT_SUBREG %reg1027<kill>, 1 |
| 467 | // %reg1029<def> = MOV8rr %reg1028 |
| 468 | // %reg1029<def> = SHR8ri %reg1029, 7, %EFLAGS<imp-def,dead> |
| 469 | // insert => %reg1030<def> = MOV8rr %reg1028 |
| 470 | // %reg1030<def> = ADD8rr %reg1028<kill>, %reg1029<kill>, %EFLAGS<imp-def,dead> |
| 471 | // In this case, it might not be possible to coalesce the second MOV8rr |
| 472 | // instruction if the first one is coalesced. So it would be profitable to |
| 473 | // commute it: |
| 474 | // %reg1028<def> = EXTRACT_SUBREG %reg1027<kill>, 1 |
| 475 | // %reg1029<def> = MOV8rr %reg1028 |
| 476 | // %reg1029<def> = SHR8ri %reg1029, 7, %EFLAGS<imp-def,dead> |
| 477 | // insert => %reg1030<def> = MOV8rr %reg1029 |
| 478 | // %reg1030<def> = ADD8rr %reg1029<kill>, %reg1028<kill>, %EFLAGS<imp-def,dead> |
| 479 | |
| 480 | if (!MI->killsRegister(regC)) |
| 481 | return false; |
| 482 | |
| 483 | // Ok, we have something like: |
| 484 | // %reg1030<def> = ADD8rr %reg1028<kill>, %reg1029<kill>, %EFLAGS<imp-def,dead> |
| 485 | // let's see if it's worth commuting it. |
| 486 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 487 | // Look for situations like this: |
| 488 | // %reg1024<def> = MOV r1 |
| 489 | // %reg1025<def> = MOV r0 |
| 490 | // %reg1026<def> = ADD %reg1024, %reg1025 |
| 491 | // r0 = MOV %reg1026 |
| 492 | // Commute the ADD to hopefully eliminate an otherwise unavoidable copy. |
| 493 | unsigned FromRegB = getMappedReg(regB, SrcRegMap); |
| 494 | unsigned FromRegC = getMappedReg(regC, SrcRegMap); |
| 495 | unsigned ToRegB = getMappedReg(regB, DstRegMap); |
| 496 | unsigned ToRegC = getMappedReg(regC, DstRegMap); |
| 497 | if (!regsAreCompatible(FromRegB, ToRegB, TRI) && |
| 498 | (regsAreCompatible(FromRegB, ToRegC, TRI) || |
| 499 | regsAreCompatible(FromRegC, ToRegB, TRI))) |
| 500 | return true; |
| 501 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 502 | // If there is a use of regC between its last def (could be livein) and this |
| 503 | // instruction, then bail. |
| 504 | unsigned LastDefC = 0; |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 505 | if (!NoUseAfterLastDef(regC, MBB, Dist, LastDefC)) |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 506 | return false; |
| 507 | |
| 508 | // If there is a use of regB between its last def (could be livein) and this |
| 509 | // instruction, then go ahead and make this transformation. |
| 510 | unsigned LastDefB = 0; |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 511 | if (!NoUseAfterLastDef(regB, MBB, Dist, LastDefB)) |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 512 | return true; |
| 513 | |
| 514 | // Since there are no intervening uses for both registers, then commute |
| 515 | // if the def of regC is closer. Its live interval is shorter. |
| 516 | return LastDefB && LastDefC && LastDefC > LastDefB; |
| 517 | } |
| 518 | |
Evan Cheng | 8191371 | 2009-01-23 23:27:33 +0000 | [diff] [blame] | 519 | /// CommuteInstruction - Commute a two-address instruction and update the basic |
| 520 | /// block, distance map, and live variables if needed. Return true if it is |
| 521 | /// successful. |
| 522 | bool |
| 523 | TwoAddressInstructionPass::CommuteInstruction(MachineBasicBlock::iterator &mi, |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 524 | MachineFunction::iterator &mbbi, |
| 525 | unsigned RegB, unsigned RegC, unsigned Dist) { |
Evan Cheng | 8191371 | 2009-01-23 23:27:33 +0000 | [diff] [blame] | 526 | MachineInstr *MI = mi; |
| 527 | DOUT << "2addr: COMMUTING : " << *MI; |
| 528 | MachineInstr *NewMI = TII->commuteInstruction(MI); |
| 529 | |
| 530 | if (NewMI == 0) { |
| 531 | DOUT << "2addr: COMMUTING FAILED!\n"; |
| 532 | return false; |
| 533 | } |
| 534 | |
| 535 | DOUT << "2addr: COMMUTED TO: " << *NewMI; |
| 536 | // If the instruction changed to commute it, update livevar. |
| 537 | if (NewMI != MI) { |
| 538 | if (LV) |
| 539 | // Update live variables |
| 540 | LV->replaceKillInstruction(RegC, MI, NewMI); |
| 541 | |
| 542 | mbbi->insert(mi, NewMI); // Insert the new inst |
| 543 | mbbi->erase(mi); // Nuke the old inst. |
| 544 | mi = NewMI; |
| 545 | DistanceMap.insert(std::make_pair(NewMI, Dist)); |
| 546 | } |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 547 | |
| 548 | // Update source register map. |
| 549 | unsigned FromRegC = getMappedReg(RegC, SrcRegMap); |
| 550 | if (FromRegC) { |
| 551 | unsigned RegA = MI->getOperand(0).getReg(); |
| 552 | SrcRegMap[RegA] = FromRegC; |
| 553 | } |
| 554 | |
Evan Cheng | 8191371 | 2009-01-23 23:27:33 +0000 | [diff] [blame] | 555 | return true; |
| 556 | } |
| 557 | |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 558 | /// isProfitableToConv3Addr - Return true if it is profitable to convert the |
| 559 | /// given 2-address instruction to a 3-address one. |
| 560 | bool |
| 561 | TwoAddressInstructionPass::isProfitableToConv3Addr(unsigned RegA) { |
| 562 | // Look for situations like this: |
| 563 | // %reg1024<def> = MOV r1 |
| 564 | // %reg1025<def> = MOV r0 |
| 565 | // %reg1026<def> = ADD %reg1024, %reg1025 |
| 566 | // r2 = MOV %reg1026 |
| 567 | // Turn ADD into a 3-address instruction to avoid a copy. |
| 568 | unsigned FromRegA = getMappedReg(RegA, SrcRegMap); |
| 569 | unsigned ToRegA = getMappedReg(RegA, DstRegMap); |
| 570 | return (FromRegA && ToRegA && !regsAreCompatible(FromRegA, ToRegA, TRI)); |
| 571 | } |
| 572 | |
| 573 | /// ConvertInstTo3Addr - Convert the specified two-address instruction into a |
| 574 | /// three address one. Return true if this transformation was successful. |
| 575 | bool |
| 576 | TwoAddressInstructionPass::ConvertInstTo3Addr(MachineBasicBlock::iterator &mi, |
| 577 | MachineBasicBlock::iterator &nmi, |
| 578 | MachineFunction::iterator &mbbi, |
| 579 | unsigned RegB, unsigned Dist) { |
| 580 | MachineInstr *NewMI = TII->convertToThreeAddress(mbbi, mi, LV); |
| 581 | if (NewMI) { |
| 582 | DOUT << "2addr: CONVERTING 2-ADDR: " << *mi; |
| 583 | DOUT << "2addr: TO 3-ADDR: " << *NewMI; |
| 584 | bool Sunk = false; |
| 585 | |
| 586 | if (NewMI->findRegisterUseOperand(RegB, false, TRI)) |
| 587 | // FIXME: Temporary workaround. If the new instruction doesn't |
| 588 | // uses RegB, convertToThreeAddress must have created more |
| 589 | // then one instruction. |
| 590 | Sunk = Sink3AddrInstruction(mbbi, NewMI, RegB, mi); |
| 591 | |
| 592 | mbbi->erase(mi); // Nuke the old inst. |
| 593 | |
| 594 | if (!Sunk) { |
| 595 | DistanceMap.insert(std::make_pair(NewMI, Dist)); |
| 596 | mi = NewMI; |
| 597 | nmi = next(mi); |
| 598 | } |
| 599 | return true; |
| 600 | } |
| 601 | |
| 602 | return false; |
| 603 | } |
| 604 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 605 | /// ProcessCopy - If the specified instruction is not yet processed, process it |
| 606 | /// if it's a copy. For a copy instruction, we find the physical registers the |
| 607 | /// source and destination registers might be mapped to. These are kept in |
| 608 | /// point-to maps used to determine future optimizations. e.g. |
| 609 | /// v1024 = mov r0 |
| 610 | /// v1025 = mov r1 |
| 611 | /// v1026 = add v1024, v1025 |
| 612 | /// r1 = mov r1026 |
| 613 | /// If 'add' is a two-address instruction, v1024, v1026 are both potentially |
| 614 | /// coalesced to r0 (from the input side). v1025 is mapped to r1. v1026 is |
| 615 | /// potentially joined with r1 on the output side. It's worthwhile to commute |
| 616 | /// 'add' to eliminate a copy. |
| 617 | void TwoAddressInstructionPass::ProcessCopy(MachineInstr *MI, |
| 618 | MachineBasicBlock *MBB, |
| 619 | SmallPtrSet<MachineInstr*, 8> &Processed) { |
| 620 | if (Processed.count(MI)) |
| 621 | return; |
| 622 | |
| 623 | bool IsSrcPhys, IsDstPhys; |
| 624 | unsigned SrcReg, DstReg; |
| 625 | if (!isCopyToReg(*MI, TII, SrcReg, DstReg, IsSrcPhys, IsDstPhys)) |
| 626 | return; |
| 627 | |
| 628 | if (IsDstPhys && !IsSrcPhys) |
| 629 | DstRegMap.insert(std::make_pair(SrcReg, DstReg)); |
| 630 | else if (!IsDstPhys && IsSrcPhys) { |
| 631 | bool isNew = |
| 632 | SrcRegMap.insert(std::make_pair(DstReg, SrcReg)).second; |
| 633 | isNew = isNew; // Silence compiler warning. |
| 634 | assert(isNew && "Can't map to two src physical registers!"); |
| 635 | |
| 636 | SmallVector<unsigned, 4> VirtRegPairs; |
| 637 | bool isCopy = false; |
| 638 | unsigned NewReg = 0; |
| 639 | while (MachineInstr *UseMI = findOnlyInterestingUse(DstReg, MBB, MRI,TII, |
| 640 | isCopy, NewReg, IsDstPhys)) { |
| 641 | if (isCopy) { |
| 642 | if (Processed.insert(UseMI)) |
| 643 | break; |
| 644 | } |
| 645 | |
| 646 | DenseMap<MachineInstr*, unsigned>::iterator DI = DistanceMap.find(UseMI); |
| 647 | if (DI != DistanceMap.end()) |
| 648 | // Earlier in the same MBB.Reached via a back edge. |
| 649 | break; |
| 650 | |
| 651 | if (IsDstPhys) { |
| 652 | VirtRegPairs.push_back(NewReg); |
| 653 | break; |
| 654 | } |
| 655 | bool isNew = SrcRegMap.insert(std::make_pair(NewReg, DstReg)).second; |
| 656 | isNew = isNew; // Silence compiler warning. |
| 657 | assert(isNew && "Can't map to two src physical registers!"); |
| 658 | VirtRegPairs.push_back(NewReg); |
| 659 | DstReg = NewReg; |
| 660 | } |
| 661 | |
| 662 | if (!VirtRegPairs.empty()) { |
| 663 | unsigned ToReg = VirtRegPairs.back(); |
| 664 | VirtRegPairs.pop_back(); |
| 665 | while (!VirtRegPairs.empty()) { |
| 666 | unsigned FromReg = VirtRegPairs.back(); |
| 667 | VirtRegPairs.pop_back(); |
| 668 | bool isNew = DstRegMap.insert(std::make_pair(FromReg, ToReg)).second; |
| 669 | isNew = isNew; // Silence compiler warning. |
| 670 | assert(isNew && "Can't map to two dst physical registers!"); |
| 671 | ToReg = FromReg; |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | Processed.insert(MI); |
| 677 | } |
| 678 | |
Evan Cheng | 28c7ce3 | 2009-02-21 03:14:25 +0000 | [diff] [blame] | 679 | /// isSafeToDelete - If the specified instruction does not produce any side |
| 680 | /// effects and all of its defs are dead, then it's safe to delete. |
| 681 | static bool isSafeToDelete(MachineInstr *MI, const TargetInstrInfo *TII) { |
| 682 | const TargetInstrDesc &TID = MI->getDesc(); |
| 683 | if (TID.mayStore() || TID.isCall()) |
| 684 | return false; |
| 685 | if (TID.isTerminator() || TID.hasUnmodeledSideEffects()) |
| 686 | return false; |
| 687 | |
| 688 | for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { |
| 689 | MachineOperand &MO = MI->getOperand(i); |
| 690 | if (!MO.isReg() || !MO.isDef()) |
| 691 | continue; |
| 692 | if (!MO.isDead()) |
| 693 | return false; |
| 694 | } |
| 695 | |
| 696 | return true; |
| 697 | } |
| 698 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 699 | /// runOnMachineFunction - Reduce two-address instructions to two operands. |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 700 | /// |
Chris Lattner | 163c1e7 | 2004-01-31 21:14:04 +0000 | [diff] [blame] | 701 | bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) { |
Bill Wendling | a09362e | 2006-11-28 22:48:48 +0000 | [diff] [blame] | 702 | DOUT << "Machine Function\n"; |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 703 | const TargetMachine &TM = MF.getTarget(); |
Evan Cheng | 875357d | 2008-03-13 06:37:55 +0000 | [diff] [blame] | 704 | MRI = &MF.getRegInfo(); |
| 705 | TII = TM.getInstrInfo(); |
| 706 | TRI = TM.getRegisterInfo(); |
Duncan Sands | 1465d61 | 2009-01-28 13:14:17 +0000 | [diff] [blame] | 707 | LV = getAnalysisIfAvailable<LiveVariables>(); |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 708 | |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 709 | bool MadeChange = false; |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 710 | |
Bill Wendling | a09362e | 2006-11-28 22:48:48 +0000 | [diff] [blame] | 711 | DOUT << "********** REWRITING TWO-ADDR INSTRS **********\n"; |
| 712 | DOUT << "********** Function: " << MF.getFunction()->getName() << '\n'; |
Alkis Evlogimenos | 3a9986f | 2004-02-18 00:35:06 +0000 | [diff] [blame] | 713 | |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 714 | // ReMatRegs - Keep track of the registers whose def's are remat'ed. |
| 715 | BitVector ReMatRegs; |
| 716 | ReMatRegs.resize(MRI->getLastVirtReg()+1); |
| 717 | |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 718 | SmallPtrSet<MachineInstr*, 8> Processed; |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 719 | for (MachineFunction::iterator mbbi = MF.begin(), mbbe = MF.end(); |
| 720 | mbbi != mbbe; ++mbbi) { |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 721 | unsigned Dist = 0; |
| 722 | DistanceMap.clear(); |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 723 | SrcRegMap.clear(); |
| 724 | DstRegMap.clear(); |
| 725 | Processed.clear(); |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 726 | for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); |
Evan Cheng | 7a963fa | 2008-03-27 01:27:25 +0000 | [diff] [blame] | 727 | mi != me; ) { |
| 728 | MachineBasicBlock::iterator nmi = next(mi); |
Chris Lattner | 749c6f6 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 729 | const TargetInstrDesc &TID = mi->getDesc(); |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 730 | bool FirstTied = true; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 731 | |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 732 | DistanceMap.insert(std::make_pair(mi, ++Dist)); |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 733 | |
| 734 | ProcessCopy(&*mi, &*mbbi, Processed); |
| 735 | |
Evan Cheng | fb11288 | 2009-03-23 08:01:15 +0000 | [diff] [blame] | 736 | unsigned NumOps = (mi->getOpcode() == TargetInstrInfo::INLINEASM) |
| 737 | ? mi->getNumOperands() : TID.getNumOperands(); |
| 738 | for (unsigned si = 0; si < NumOps; ++si) { |
Evan Cheng | a24752f | 2009-03-19 20:30:06 +0000 | [diff] [blame] | 739 | unsigned ti = 0; |
| 740 | if (!mi->isRegTiedToDefOperand(si, &ti)) |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 741 | continue; |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 742 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 743 | if (FirstTied) { |
| 744 | ++NumTwoAddressInstrs; |
Bill Wendling | bcd2498 | 2006-12-07 20:28:15 +0000 | [diff] [blame] | 745 | DOUT << '\t'; DEBUG(mi->print(*cerr.stream(), &TM)); |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 746 | } |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 747 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 748 | FirstTied = false; |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 749 | |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 750 | assert(mi->getOperand(si).isReg() && mi->getOperand(si).getReg() && |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 751 | mi->getOperand(si).isUse() && "two address instruction invalid"); |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 752 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 753 | // If the two operands are the same we just remove the use |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 754 | // and mark the def as def&use, otherwise we have to insert a copy. |
| 755 | if (mi->getOperand(ti).getReg() != mi->getOperand(si).getReg()) { |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 756 | // Rewrite: |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 757 | // a = b op c |
| 758 | // to: |
| 759 | // a = b |
| 760 | // a = a op c |
| 761 | unsigned regA = mi->getOperand(ti).getReg(); |
| 762 | unsigned regB = mi->getOperand(si).getReg(); |
| 763 | |
Evan Cheng | fb11288 | 2009-03-23 08:01:15 +0000 | [diff] [blame] | 764 | assert(TargetRegisterInfo::isVirtualRegister(regB) && |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 765 | "cannot update physical register live information"); |
Chris Lattner | 6b50767 | 2004-01-31 21:21:43 +0000 | [diff] [blame] | 766 | |
Chris Lattner | 1e31363 | 2004-07-21 23:17:57 +0000 | [diff] [blame] | 767 | #ifndef NDEBUG |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 768 | // First, verify that we don't have a use of a in the instruction (a = |
| 769 | // b + a for example) because our transformation will not work. This |
| 770 | // should never occur because we are in SSA form. |
| 771 | for (unsigned i = 0; i != mi->getNumOperands(); ++i) |
Evan Cheng | a24752f | 2009-03-19 20:30:06 +0000 | [diff] [blame] | 772 | assert(i == ti || |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 773 | !mi->getOperand(i).isReg() || |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 774 | mi->getOperand(i).getReg() != regA); |
Chris Lattner | 1e31363 | 2004-07-21 23:17:57 +0000 | [diff] [blame] | 775 | #endif |
Alkis Evlogimenos | 14be640 | 2004-02-04 22:17:40 +0000 | [diff] [blame] | 776 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 777 | // If this instruction is not the killing user of B, see if we can |
| 778 | // rearrange the code to make it so. Making it the killing user will |
| 779 | // allow us to coalesce A and B together, eliminating the copy we are |
| 780 | // about to insert. |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 781 | if (!isKilled(*mi, regB, MRI, TII)) { |
Evan Cheng | 28c7ce3 | 2009-02-21 03:14:25 +0000 | [diff] [blame] | 782 | // If regA is dead and the instruction can be deleted, just delete |
| 783 | // it so it doesn't clobber regB. |
| 784 | if (mi->getOperand(ti).isDead() && isSafeToDelete(mi, TII)) { |
| 785 | mbbi->erase(mi); // Nuke the old inst. |
| 786 | mi = nmi; |
| 787 | ++NumDeletes; |
| 788 | break; // Done with this instruction. |
| 789 | } |
| 790 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 791 | // If this instruction is commutative, check to see if C dies. If |
| 792 | // so, swap the B and C operands. This makes the live ranges of A |
| 793 | // and C joinable. |
| 794 | // FIXME: This code also works for A := B op C instructions. |
Chris Lattner | 749c6f6 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 795 | if (TID.isCommutable() && mi->getNumOperands() >= 3) { |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 796 | assert(mi->getOperand(3-si).isReg() && |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 797 | "Not a proper commutative instruction!"); |
| 798 | unsigned regC = mi->getOperand(3-si).getReg(); |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 799 | if (isKilled(*mi, regC, MRI, TII)) { |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 800 | if (CommuteInstruction(mi, mbbi, regB, regC, Dist)) { |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 801 | ++NumCommuted; |
| 802 | regB = regC; |
| 803 | goto InstructionRearranged; |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 804 | } |
Chris Lattner | c71d694 | 2005-01-19 07:08:42 +0000 | [diff] [blame] | 805 | } |
Chris Lattner | cfa0f2e | 2005-01-02 02:34:12 +0000 | [diff] [blame] | 806 | } |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 807 | |
| 808 | // If this instruction is potentially convertible to a true |
| 809 | // three-address instruction, |
Chris Lattner | 749c6f6 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 810 | if (TID.isConvertibleTo3Addr()) { |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 811 | // FIXME: This assumes there are no more operands which are tied |
| 812 | // to another register. |
| 813 | #ifndef NDEBUG |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 814 | for (unsigned i = si + 1, e = TID.getNumOperands(); i < e; ++i) |
Chris Lattner | 749c6f6 | 2008-01-07 07:27:27 +0000 | [diff] [blame] | 815 | assert(TID.getOperandConstraint(i, TOI::TIED_TO) == -1); |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 816 | #endif |
| 817 | |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 818 | if (ConvertInstTo3Addr(mi, nmi, mbbi, regB, Dist)) { |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 819 | ++NumConvertedTo3Addr; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 820 | break; // Done with this instruction. |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 821 | } |
Evan Cheng | b9d5e7c | 2007-10-20 04:01:47 +0000 | [diff] [blame] | 822 | } |
Chris Lattner | cfa0f2e | 2005-01-02 02:34:12 +0000 | [diff] [blame] | 823 | } |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 824 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 825 | // If it's profitable to commute the instruction, do so. |
| 826 | if (TID.isCommutable() && mi->getNumOperands() >= 3) { |
| 827 | unsigned regC = mi->getOperand(3-si).getReg(); |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 828 | if (isProfitableToCommute(regB, regC, mi, mbbi, Dist)) |
| 829 | if (CommuteInstruction(mi, mbbi, regB, regC, Dist)) { |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 830 | ++NumAggrCommuted; |
| 831 | ++NumCommuted; |
| 832 | regB = regC; |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 833 | goto InstructionRearranged; |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | |
Evan Cheng | e6f350d | 2009-03-30 21:34:07 +0000 | [diff] [blame] | 837 | // If it's profitable to convert the 2-address instruction to a |
| 838 | // 3-address one, do so. |
| 839 | if (TID.isConvertibleTo3Addr() && isProfitableToConv3Addr(regA)) { |
| 840 | if (ConvertInstTo3Addr(mi, nmi, mbbi, regB, Dist)) { |
| 841 | ++NumConvertedTo3Addr; |
| 842 | break; // Done with this instruction. |
| 843 | } |
| 844 | } |
| 845 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 846 | InstructionRearranged: |
Evan Cheng | fb11288 | 2009-03-23 08:01:15 +0000 | [diff] [blame] | 847 | const TargetRegisterClass* rc = MRI->getRegClass(regB); |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 848 | MachineInstr *DefMI = MRI->getVRegDef(regB); |
| 849 | // If it's safe and profitable, remat the definition instead of |
| 850 | // copying it. |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 851 | if (DefMI && |
Evan Cheng | 8763c1c | 2008-08-27 20:58:54 +0000 | [diff] [blame] | 852 | DefMI->getDesc().isAsCheapAsAMove() && |
Evan Cheng | df3b993 | 2008-08-27 20:33:50 +0000 | [diff] [blame] | 853 | DefMI->isSafeToReMat(TII, regB) && |
Evan Cheng | 870b807 | 2009-03-01 02:03:43 +0000 | [diff] [blame] | 854 | isProfitableToReMat(regB, rc, mi, DefMI, mbbi, Dist)){ |
Evan Cheng | 7543e58 | 2008-06-18 07:49:14 +0000 | [diff] [blame] | 855 | DEBUG(cerr << "2addr: REMATTING : " << *DefMI << "\n"); |
| 856 | TII->reMaterialize(*mbbi, mi, regA, DefMI); |
| 857 | ReMatRegs.set(regB); |
| 858 | ++NumReMats; |
Bill Wendling | 48f7f23 | 2008-05-26 05:18:34 +0000 | [diff] [blame] | 859 | } else { |
| 860 | TII->copyRegToReg(*mbbi, mi, regA, regB, rc, rc); |
| 861 | } |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 862 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 863 | MachineBasicBlock::iterator prevMI = prior(mi); |
| 864 | // Update DistanceMap. |
| 865 | DistanceMap.insert(std::make_pair(prevMI, Dist)); |
| 866 | DistanceMap[mi] = ++Dist; |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 867 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 868 | // Update live variables for regB. |
Owen Anderson | 802af11 | 2008-07-02 21:28:58 +0000 | [diff] [blame] | 869 | if (LV) { |
| 870 | LiveVariables::VarInfo& varInfoB = LV->getVarInfo(regB); |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 871 | |
Owen Anderson | 802af11 | 2008-07-02 21:28:58 +0000 | [diff] [blame] | 872 | // regB is used in this BB. |
| 873 | varInfoB.UsedBlocks[mbbi->getNumber()] = true; |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 874 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 875 | if (LV->removeVirtualRegisterKilled(regB, mi)) |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 876 | LV->addVirtualRegisterKilled(regB, prevMI); |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 877 | |
Evan Cheng | 9f1c831 | 2008-07-03 09:09:37 +0000 | [diff] [blame] | 878 | if (LV->removeVirtualRegisterDead(regB, mi)) |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 879 | LV->addVirtualRegisterDead(regB, prevMI); |
Owen Anderson | 802af11 | 2008-07-02 21:28:58 +0000 | [diff] [blame] | 880 | } |
Dan Gohman | 2d9716f | 2008-11-12 17:15:19 +0000 | [diff] [blame] | 881 | |
Evan Cheng | d498c8f | 2009-01-25 03:53:59 +0000 | [diff] [blame] | 882 | DOUT << "\t\tprepend:\t"; DEBUG(prevMI->print(*cerr.stream(), &TM)); |
Owen Anderson | 802af11 | 2008-07-02 21:28:58 +0000 | [diff] [blame] | 883 | |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 884 | // Replace all occurences of regB with regA. |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 885 | for (unsigned i = 0, e = mi->getNumOperands(); i != e; ++i) { |
Dan Gohman | d735b80 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 886 | if (mi->getOperand(i).isReg() && |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 887 | mi->getOperand(i).getReg() == regB) |
| 888 | mi->getOperand(i).setReg(regA); |
| 889 | } |
Chris Lattner | cfa0f2e | 2005-01-02 02:34:12 +0000 | [diff] [blame] | 890 | } |
Alkis Evlogimenos | 14be640 | 2004-02-04 22:17:40 +0000 | [diff] [blame] | 891 | |
Evan Cheng | 360c2dd | 2006-11-01 23:06:55 +0000 | [diff] [blame] | 892 | assert(mi->getOperand(ti).isDef() && mi->getOperand(si).isUse()); |
| 893 | mi->getOperand(ti).setReg(mi->getOperand(si).getReg()); |
| 894 | MadeChange = true; |
Alkis Evlogimenos | 14be640 | 2004-02-04 22:17:40 +0000 | [diff] [blame] | 895 | |
Bill Wendling | bcd2498 | 2006-12-07 20:28:15 +0000 | [diff] [blame] | 896 | DOUT << "\t\trewrite to:\t"; DEBUG(mi->print(*cerr.stream(), &TM)); |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 897 | } |
Bill Wendling | 637980e | 2008-05-10 00:12:52 +0000 | [diff] [blame] | 898 | |
Evan Cheng | 7a963fa | 2008-03-27 01:27:25 +0000 | [diff] [blame] | 899 | mi = nmi; |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 900 | } |
| 901 | } |
| 902 | |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 903 | // Some remat'ed instructions are dead. |
| 904 | int VReg = ReMatRegs.find_first(); |
| 905 | while (VReg != -1) { |
| 906 | if (MRI->use_empty(VReg)) { |
| 907 | MachineInstr *DefMI = MRI->getVRegDef(VReg); |
| 908 | DefMI->eraseFromParent(); |
Bill Wendling | a16157a | 2008-05-26 05:49:49 +0000 | [diff] [blame] | 909 | } |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 910 | VReg = ReMatRegs.find_next(VReg); |
Bill Wendling | 48f7f23 | 2008-05-26 05:18:34 +0000 | [diff] [blame] | 911 | } |
| 912 | |
Misha Brukman | 75fa4e4 | 2004-07-22 15:26:23 +0000 | [diff] [blame] | 913 | return MadeChange; |
Alkis Evlogimenos | 71499de | 2003-12-18 13:06:04 +0000 | [diff] [blame] | 914 | } |