Ruchira Sasanka | 94d86e9 | 2001-09-14 20:31:39 +0000 | [diff] [blame] | 1 | #include "llvm/Target/Sparc.h" |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 2 | #include "SparcInternals.h" |
| 3 | #include "llvm/Method.h" |
| 4 | #include "llvm/iTerminators.h" |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 5 | #include "llvm/iOther.h" |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 6 | #include "llvm/CodeGen/InstrScheduling.h" |
| 7 | #include "llvm/CodeGen/InstrSelection.h" |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 8 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 9 | #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" |
| 10 | #include "llvm/CodeGen/PhyRegAlloc.h" |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 11 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | |
| 15 | //--------------------------------------------------------------------------- |
| 16 | // UltraSparcRegInfo |
| 17 | //--------------------------------------------------------------------------- |
| 18 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 19 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 20 | // Finds the return value of a call instruction |
| 21 | //--------------------------------------------------------------------------- |
| 22 | |
| 23 | const Value * |
| 24 | UltraSparcRegInfo::getCallInstRetVal(const MachineInstr *CallMI) const{ |
| 25 | |
| 26 | unsigned OpCode = CallMI->getOpCode(); |
| 27 | unsigned NumOfImpRefs = CallMI->getNumImplicitRefs(); |
| 28 | |
| 29 | if( OpCode == CALL ) { |
| 30 | |
| 31 | // The one before the last implicit operand is the return value of |
| 32 | // a CALL instr |
| 33 | if( NumOfImpRefs > 1 ) |
| 34 | if( CallMI->implicitRefIsDefined(NumOfImpRefs-2) ) |
| 35 | return CallMI->getImplicitRef(NumOfImpRefs-2); |
| 36 | |
| 37 | } |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 38 | else if( OpCode == JMPLCALL) { |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 39 | |
| 40 | // The last implicit operand is the return value of a JMPL in |
| 41 | if( NumOfImpRefs > 0 ) |
| 42 | if( CallMI->implicitRefIsDefined(NumOfImpRefs-1) ) |
| 43 | return CallMI->getImplicitRef(NumOfImpRefs-1); |
| 44 | } |
| 45 | else |
| 46 | assert(0 && "OpCode must be CALL/JMPL for a call instr"); |
| 47 | |
| 48 | return NULL; |
| 49 | |
| 50 | } |
| 51 | |
| 52 | //--------------------------------------------------------------------------- |
| 53 | // Finds the return address of a call instruction |
| 54 | //--------------------------------------------------------------------------- |
| 55 | |
| 56 | const Value * |
| 57 | UltraSparcRegInfo::getCallInstRetAddr(const MachineInstr *CallMI)const { |
| 58 | |
| 59 | unsigned OpCode = CallMI->getOpCode(); |
| 60 | |
| 61 | if( OpCode == CALL) { |
| 62 | |
| 63 | unsigned NumOfImpRefs = CallMI->getNumImplicitRefs(); |
| 64 | |
| 65 | assert( NumOfImpRefs && "CALL instr must have at least on ImpRef"); |
| 66 | // The last implicit operand is the return address of a CALL instr |
| 67 | return CallMI->getImplicitRef(NumOfImpRefs-1); |
| 68 | |
| 69 | } |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 70 | else if( OpCode == JMPLCALL ) { |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 71 | |
| 72 | MachineOperand & MO = ( MachineOperand &) CallMI->getOperand(2); |
| 73 | return MO.getVRegValue(); |
| 74 | |
| 75 | } |
| 76 | else |
| 77 | assert(0 && "OpCode must be CALL/JMPL for a call instr"); |
| 78 | |
| 79 | assert(0 && "There must be a return addr for a call instr"); |
| 80 | |
| 81 | return NULL; |
| 82 | |
| 83 | } |
| 84 | |
| 85 | |
| 86 | //--------------------------------------------------------------------------- |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 87 | // Finds the # of actual arguments of the call instruction |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 88 | //--------------------------------------------------------------------------- |
| 89 | |
| 90 | const unsigned |
| 91 | UltraSparcRegInfo::getCallInstNumArgs(const MachineInstr *CallMI) const { |
| 92 | |
| 93 | unsigned OpCode = CallMI->getOpCode(); |
| 94 | unsigned NumOfImpRefs = CallMI->getNumImplicitRefs(); |
| 95 | int NumArgs = -1; |
| 96 | |
| 97 | if( OpCode == CALL ) { |
| 98 | |
| 99 | switch( NumOfImpRefs ) { |
| 100 | |
| 101 | case 0: assert(0 && "A CALL inst must have at least one ImpRef (RetAddr)"); |
| 102 | |
| 103 | case 1: NumArgs = 0; |
| 104 | break; |
| 105 | |
| 106 | default: // two or more implicit refs |
| 107 | if( CallMI->implicitRefIsDefined(NumOfImpRefs-2) ) |
| 108 | NumArgs = NumOfImpRefs - 2; // i.e., NumOfImpRef-2 is the ret val |
| 109 | else |
| 110 | NumArgs = NumOfImpRefs - 1; |
| 111 | } |
| 112 | |
| 113 | } |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 114 | else if( OpCode == JMPLCALL ) { |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 115 | |
| 116 | // The last implicit operand is the return value of a JMPL instr |
| 117 | if( NumOfImpRefs > 0 ) { |
| 118 | if( CallMI->implicitRefIsDefined(NumOfImpRefs-1) ) |
| 119 | NumArgs = NumOfImpRefs - 1; // i.e., NumOfImpRef-1 is the ret val |
| 120 | else |
| 121 | NumArgs = NumOfImpRefs; |
| 122 | } |
| 123 | else |
| 124 | NumArgs = NumOfImpRefs; |
| 125 | } |
| 126 | else |
| 127 | assert(0 && "OpCode must be CALL/JMPL for a call instr"); |
| 128 | |
| 129 | assert( (NumArgs != -1) && "Internal error in getCallInstNumArgs" ); |
| 130 | return (unsigned) NumArgs; |
| 131 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 132 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | |
| 136 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 137 | // Suggests a register for the ret address in the RET machine instruction |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 138 | //--------------------------------------------------------------------------- |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 139 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 140 | void UltraSparcRegInfo::suggestReg4RetAddr(const MachineInstr * RetMI, |
| 141 | LiveRangeInfo& LRI) const { |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 142 | |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 143 | assert( (RetMI->getNumOperands() >= 2) |
| 144 | && "JMPL/RETURN must have 3 and 2 operands respectively"); |
| 145 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 146 | MachineOperand & MO = ( MachineOperand &) RetMI->getOperand(0); |
| 147 | |
| 148 | MO.setRegForValue( getUnifiedRegNum( IntRegClassID, SparcIntRegOrder::i7) ); |
Vikram S. Adve | 53fec86 | 2001-10-22 13:41:12 +0000 | [diff] [blame] | 149 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 150 | // TODO (Optimize): |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 151 | // Instead of setting the color, we can suggest one. In that case, |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 152 | // we have to test later whether it received the suggested color. |
| 153 | // In that case, a LR has to be created at the start of method. |
| 154 | // It has to be done as follows (remove the setRegVal above): |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 155 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 156 | /* |
| 157 | const Value *RetAddrVal = MO.getVRegValue(); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 158 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 159 | assert( RetAddrVal && "LR for ret address must be created at start"); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 160 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 161 | LiveRange * RetAddrLR = LRI.getLiveRangeForValue( RetAddrVal); |
| 162 | RetAddrLR->setSuggestedColor(getUnifiedRegNum( IntRegClassID, |
| 163 | SparcIntRegOrdr::i7) ); |
| 164 | */ |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 165 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 166 | |
| 167 | } |
| 168 | |
| 169 | |
| 170 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 171 | // Suggests a register for the ret address in the JMPL/CALL machine instr |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 172 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 173 | void UltraSparcRegInfo::suggestReg4CallAddr(const MachineInstr * CallMI, |
| 174 | LiveRangeInfo& LRI, |
| 175 | vector<RegClass *> RCList) const { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 176 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 177 | |
| 178 | const Value *RetAddrVal = getCallInstRetAddr( CallMI ); |
| 179 | |
| 180 | // RetAddrVal cannot be NULL (asserted in getCallInstRetAddr) |
| 181 | // create a new LR for the return address and color it |
| 182 | |
| 183 | LiveRange * RetAddrLR = new LiveRange(); |
| 184 | RetAddrLR->add( RetAddrVal ); |
| 185 | unsigned RegClassID = getRegClassIDOfValue( RetAddrVal ); |
| 186 | RetAddrLR->setRegClass( RCList[RegClassID] ); |
| 187 | RetAddrLR->setColor(getUnifiedRegNum(IntRegClassID,SparcIntRegOrder::o7)); |
| 188 | LRI.addLRToMap( RetAddrVal, RetAddrLR); |
| 189 | |
| 190 | |
| 191 | /* |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 192 | assert( (CallMI->getNumOperands() == 3) && "JMPL must have 3 operands"); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 193 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 194 | // directly set color since the LR of ret address (if there were one) |
| 195 | // will not extend after the call instr |
| 196 | |
| 197 | MachineOperand & MO = ( MachineOperand &) CallMI->getOperand(2); |
| 198 | MO.setRegForValue( getUnifiedRegNum( IntRegClassID,SparcIntRegOrder::o7) ); |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 199 | |
| 200 | */ |
| 201 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 204 | |
| 205 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 206 | |
| 207 | //--------------------------------------------------------------------------- |
| 208 | // This method will suggest colors to incoming args to a method. |
| 209 | // If the arg is passed on stack due to the lack of regs, NOTHING will be |
| 210 | // done - it will be colored (or spilled) as a normal value. |
| 211 | //--------------------------------------------------------------------------- |
| 212 | |
| 213 | void UltraSparcRegInfo::suggestRegs4MethodArgs(const Method *const Meth, |
| 214 | LiveRangeInfo& LRI) const |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 215 | { |
| 216 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 217 | // get the argument list |
| 218 | const Method::ArgumentListType& ArgList = Meth->getArgumentList(); |
| 219 | // get an iterator to arg list |
| 220 | Method::ArgumentListType::const_iterator ArgIt = ArgList.begin(); |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 221 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 222 | // for each argument |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 223 | for( unsigned argNo=0; ArgIt != ArgList.end() ; ++ArgIt, ++argNo) { |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 224 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 225 | // get the LR of arg |
| 226 | LiveRange *const LR = LRI.getLiveRangeForValue((const Value *) *ArgIt); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 227 | assert( LR && "No live range found for method arg"); |
| 228 | |
| 229 | unsigned RegType = getRegType( LR ); |
| 230 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 231 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 232 | // if the arg is in int class - allocate a reg for an int arg |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 233 | if( RegType == IntRegType ) { |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 234 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 235 | if( argNo < NumOfIntArgRegs) { |
| 236 | LR->setSuggestedColor( SparcIntRegOrder::i0 + argNo ); |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 237 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | else { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 241 | // Do NOTHING as this will be colored as a normal value. |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 242 | if (DEBUG_RA) cerr << " Int Regr not suggested for method arg\n"; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 243 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 244 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 245 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 246 | else if( RegType==FPSingleRegType && (argNo*2+1) < NumOfFloatArgRegs) |
| 247 | LR->setSuggestedColor( SparcFloatRegOrder::f0 + (argNo * 2 + 1) ); |
| 248 | |
| 249 | |
| 250 | else if( RegType == FPDoubleRegType && (argNo*2) < NumOfFloatArgRegs) |
| 251 | LR->setSuggestedColor( SparcFloatRegOrder::f0 + (argNo * 2) ); |
| 252 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 253 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 254 | } |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 255 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 258 | //--------------------------------------------------------------------------- |
| 259 | // |
| 260 | //--------------------------------------------------------------------------- |
| 261 | |
| 262 | void UltraSparcRegInfo::colorMethodArgs(const Method *const Meth, |
| 263 | LiveRangeInfo& LRI, |
| 264 | AddedInstrns *const FirstAI) const { |
| 265 | |
| 266 | // get the argument list |
| 267 | const Method::ArgumentListType& ArgList = Meth->getArgumentList(); |
| 268 | // get an iterator to arg list |
| 269 | Method::ArgumentListType::const_iterator ArgIt = ArgList.begin(); |
| 270 | |
| 271 | MachineInstr *AdMI; |
| 272 | |
| 273 | |
| 274 | // for each argument |
| 275 | for( unsigned argNo=0; ArgIt != ArgList.end() ; ++ArgIt, ++argNo) { |
| 276 | |
| 277 | // get the LR of arg |
| 278 | LiveRange *const LR = LRI.getLiveRangeForValue((const Value *) *ArgIt); |
| 279 | assert( LR && "No live range found for method arg"); |
| 280 | |
| 281 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 282 | unsigned RegType = getRegType( LR ); |
| 283 | unsigned RegClassID = (LR->getRegClass())->getID(); |
| 284 | |
| 285 | |
| 286 | // find whether this argument is coming in a register (if not, on stack) |
| 287 | |
| 288 | bool isArgInReg = false; |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 289 | unsigned UniArgReg = InvalidRegNum; // reg that LR MUST be colored with |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 290 | |
| 291 | if( (RegType== IntRegType && argNo < NumOfIntArgRegs)) { |
| 292 | isArgInReg = true; |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 293 | UniArgReg = getUnifiedRegNum( RegClassID, SparcIntRegOrder::i0 + argNo ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 294 | } |
| 295 | else if(RegType == FPSingleRegType && argNo < NumOfFloatArgRegs) { |
| 296 | isArgInReg = true; |
| 297 | UniArgReg = getUnifiedRegNum( RegClassID, |
| 298 | SparcFloatRegOrder::f0 + argNo*2 + 1 ) ; |
| 299 | } |
| 300 | else if(RegType == FPDoubleRegType && argNo < NumOfFloatArgRegs) { |
| 301 | isArgInReg = true; |
| 302 | UniArgReg = getUnifiedRegNum(RegClassID, SparcFloatRegOrder::f0+argNo*2); |
| 303 | } |
| 304 | |
| 305 | |
| 306 | if( LR->hasColor() ) { |
| 307 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 308 | unsigned UniLRReg = getUnifiedRegNum( RegClassID, LR->getColor() ); |
| 309 | |
| 310 | // if LR received the correct color, nothing to do |
| 311 | if( UniLRReg == UniArgReg ) |
| 312 | continue; |
| 313 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 314 | // We are here because the LR did not have a suggested |
| 315 | // color or did not receive the suggested color but LR got a register. |
| 316 | // Now we have to copy %ix reg (or stack pos of arg) |
| 317 | // to the register it was colored with. |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 318 | |
| 319 | // if the arg is coming in UniArgReg register MUST go into |
| 320 | // the UniLRReg register |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 321 | if( isArgInReg ) |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 322 | AdMI = cpReg2RegMI( UniArgReg, UniLRReg, RegType ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 323 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 324 | else { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 325 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 326 | // Now the arg is coming on stack. Since the LR recieved a register, |
| 327 | // we just have to load the arg on stack into that register |
| 328 | int ArgStakOffFromFP = |
| 329 | UltraSparcFrameInfo::FirstIncomingArgOffsetFromFP + |
| 330 | argNo * SizeOfOperandOnStack; |
| 331 | |
| 332 | AdMI = cpMem2RegMI(getFramePointer(), ArgStakOffFromFP, |
| 333 | UniLRReg, RegType ); |
| 334 | } |
| 335 | |
| 336 | FirstAI->InstrnsBefore.push_back( AdMI ); |
| 337 | |
| 338 | } // if LR received a color |
| 339 | |
| 340 | else { |
| 341 | |
| 342 | // Now, the LR did not receive a color. But it has a stack offset for |
| 343 | // spilling. |
| 344 | |
| 345 | // So, if the arg is coming in UniArgReg register, we can just move |
| 346 | // that on to the stack pos of LR |
| 347 | |
| 348 | |
| 349 | if( isArgInReg ) { |
| 350 | |
| 351 | MachineInstr *AdIBef = |
| 352 | cpReg2MemMI(UniArgReg, getFramePointer(), |
| 353 | LR->getSpillOffFromFP(), RegType ); |
| 354 | |
| 355 | FirstAI->InstrnsBefore.push_back( AdMI ); |
| 356 | } |
| 357 | |
| 358 | else { |
| 359 | |
| 360 | // Now the arg is coming on stack. Since the LR did NOT |
| 361 | // recieved a register as well, it is allocated a stack position. We |
| 362 | // can simply change the stack poistion of the LR. We can do this, |
| 363 | // since this method is called before any other method that makes |
| 364 | // uses of the stack pos of the LR (e.g., updateMachineInstr) |
| 365 | |
| 366 | int ArgStakOffFromFP = |
| 367 | UltraSparcFrameInfo::FirstIncomingArgOffsetFromFP + |
| 368 | argNo * SizeOfOperandOnStack; |
| 369 | |
| 370 | LR->modifySpillOffFromFP( ArgStakOffFromFP ); |
| 371 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 372 | |
| 373 | } |
| 374 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 375 | } // for each incoming argument |
| 376 | |
| 377 | } |
| 378 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 379 | |
| 380 | |
| 381 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 382 | //--------------------------------------------------------------------------- |
| 383 | // This method is called before graph coloring to suggest colors to the |
| 384 | // outgoing call args and the return value of the call. |
| 385 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 386 | void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI, |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 387 | LiveRangeInfo& LRI, |
| 388 | vector<RegClass *> RCList) const { |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 389 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 390 | assert ( (UltraSparcInfo->getInstrInfo()).isCall(CallMI->getOpCode()) ); |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 391 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 392 | suggestReg4CallAddr(CallMI, LRI, RCList); |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 393 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 394 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 395 | // First color the return value of the call instruction. The return value |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 396 | // will be in %o0 if the value is an integer type, or in %f0 if the |
| 397 | // value is a float type. |
| 398 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 399 | // the return value cannot have a LR in machine instruction since it is |
| 400 | // only defined by the call instruction |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 401 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 402 | // if type is not void, create a new live range and set its |
| 403 | // register class and add to LRI |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 404 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 405 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 406 | const Value *RetVal = getCallInstRetVal( CallMI ); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 407 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 408 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 409 | if( RetVal ) { |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 410 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 411 | assert( (! LRI.getLiveRangeForValue( RetVal ) ) && |
| 412 | "LR for ret Value of call already definded!"); |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 413 | |
| 414 | |
| 415 | // create a new LR for the return value |
| 416 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 417 | LiveRange * RetValLR = new LiveRange(); |
| 418 | RetValLR->add( RetVal ); |
| 419 | unsigned RegClassID = getRegClassIDOfValue( RetVal ); |
| 420 | RetValLR->setRegClass( RCList[RegClassID] ); |
| 421 | LRI.addLRToMap( RetVal, RetValLR); |
| 422 | |
| 423 | // now suggest a register depending on the register class of ret arg |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 424 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 425 | if( RegClassID == IntRegClassID ) |
| 426 | RetValLR->setSuggestedColor(SparcIntRegOrder::o0); |
| 427 | else if (RegClassID == FloatRegClassID ) |
| 428 | RetValLR->setSuggestedColor(SparcFloatRegOrder::f0 ); |
| 429 | else assert( 0 && "Unknown reg class for return value of call\n"); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 430 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 431 | } |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 432 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 433 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 434 | // Now suggest colors for arguments (operands) of the call instruction. |
| 435 | // Colors are suggested only if the arg number is smaller than the |
| 436 | // the number of registers allocated for argument passing. |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 437 | // Now, go thru call args - implicit operands of the call MI |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 438 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 439 | unsigned NumOfCallArgs = getCallInstNumArgs( CallMI ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 440 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 441 | for(unsigned argNo=0, i=0; i < NumOfCallArgs; ++i, ++argNo ) { |
| 442 | |
| 443 | const Value *CallArg = CallMI->getImplicitRef(i); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 444 | |
| 445 | // get the LR of call operand (parameter) |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 446 | LiveRange *const LR = LRI.getLiveRangeForValue(CallArg); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 447 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 448 | // not possible to have a null LR since all args (even consts) |
| 449 | // must be defined before |
| 450 | if( !LR ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 451 | if( DEBUG_RA) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 452 | cerr << " ERROR: In call instr, no LR for arg: " ; |
| 453 | printValue(CallArg); cerr << endl; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 454 | } |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 455 | assert(0 && "NO LR for call arg"); |
| 456 | // continue; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | unsigned RegType = getRegType( LR ); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 460 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 461 | // if the arg is in int class - allocate a reg for an int arg |
| 462 | if( RegType == IntRegType ) { |
| 463 | |
| 464 | if( argNo < NumOfIntArgRegs) |
| 465 | LR->setSuggestedColor( SparcIntRegOrder::o0 + argNo ); |
| 466 | |
| 467 | else if (DEBUG_RA) |
| 468 | // Do NOTHING as this will be colored as a normal value. |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 469 | cerr << " Regr not suggested for int call arg" << endl; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 470 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 471 | } |
| 472 | else if( RegType == FPSingleRegType && (argNo*2 +1)< NumOfFloatArgRegs) |
| 473 | LR->setSuggestedColor( SparcFloatRegOrder::f0 + (argNo * 2 + 1) ); |
| 474 | |
| 475 | |
| 476 | else if( RegType == FPDoubleRegType && (argNo*2) < NumOfFloatArgRegs) |
| 477 | LR->setSuggestedColor( SparcFloatRegOrder::f0 + (argNo * 2) ); |
| 478 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 479 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 480 | } // for all call arguments |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 481 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 485 | //--------------------------------------------------------------------------- |
| 486 | // After graph coloring, we have call this method to see whehter the return |
| 487 | // value and the call args received the correct colors. If not, we have |
| 488 | // to instert copy instructions. |
| 489 | //--------------------------------------------------------------------------- |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 490 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 491 | void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI, |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 492 | LiveRangeInfo& LRI, |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 493 | AddedInstrns *const CallAI, |
| 494 | PhyRegAlloc &PRA) const { |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 495 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 496 | assert ( (UltraSparcInfo->getInstrInfo()).isCall(CallMI->getOpCode()) ); |
| 497 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 498 | // First color the return value of the call. |
| 499 | // If there is a LR for the return value, it means this |
| 500 | // method returns a value |
| 501 | |
| 502 | MachineInstr *AdMI; |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 503 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 504 | const Value *RetVal = getCallInstRetVal( CallMI ); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 505 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 506 | if( RetVal ) { |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 507 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 508 | LiveRange * RetValLR = LRI.getLiveRangeForValue( RetVal ); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 509 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 510 | if( !RetValLR ) { |
| 511 | cerr << "\nNo LR for:"; |
| 512 | printValue( RetVal ); |
| 513 | cerr << endl; |
| 514 | assert( RetValLR && "ERR:No LR for non-void return value"); |
| 515 | //return; |
| 516 | } |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 517 | |
| 518 | unsigned RegClassID = (RetValLR->getRegClass())->getID(); |
| 519 | bool recvCorrectColor = false; |
| 520 | |
| 521 | unsigned CorrectCol; // correct color for ret value |
| 522 | if(RegClassID == IntRegClassID) |
| 523 | CorrectCol = SparcIntRegOrder::o0; |
| 524 | else if(RegClassID == FloatRegClassID) |
| 525 | CorrectCol = SparcFloatRegOrder::f0; |
| 526 | else |
| 527 | assert( 0 && "Unknown RegClass"); |
| 528 | |
| 529 | |
| 530 | // if the LR received the correct color, NOTHING to do |
| 531 | |
| 532 | if( RetValLR->hasColor() ) |
| 533 | if( RetValLR->getColor() == CorrectCol ) |
| 534 | recvCorrectColor = true; |
| 535 | |
| 536 | |
| 537 | // if we didn't receive the correct color for some reason, |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 538 | // put copy instruction |
| 539 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 540 | if( !recvCorrectColor ) { |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 541 | |
| 542 | unsigned RegType = getRegType( RetValLR ); |
| 543 | |
| 544 | // the reg that LR must be colored with |
| 545 | unsigned UniRetReg = getUnifiedRegNum( RegClassID, CorrectCol); |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 546 | |
| 547 | if( RetValLR->hasColor() ) { |
| 548 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 549 | unsigned |
| 550 | UniRetLRReg=getUnifiedRegNum(RegClassID,RetValLR->getColor()); |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 551 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 552 | // the return value is coming in UniRetReg but has to go into |
| 553 | // the UniRetLRReg |
| 554 | |
| 555 | AdMI = cpReg2RegMI( UniRetReg, UniRetLRReg, RegType ); |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 556 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 557 | } // if LR has color |
| 558 | else { |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 559 | |
| 560 | // if the LR did NOT receive a color, we have to move the return |
| 561 | // value coming in UniRetReg to the stack pos of spilled LR |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 562 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 563 | AdMI = cpReg2MemMI(UniRetReg, getFramePointer(), |
| 564 | RetValLR->getSpillOffFromFP(), RegType ); |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 565 | } |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 566 | |
| 567 | CallAI->InstrnsAfter.push_back( AdMI ); |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 568 | |
| 569 | } // the LR didn't receive the suggested color |
| 570 | |
| 571 | } // if there a return value |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 572 | |
| 573 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 574 | // Now color all args of the call instruction |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 575 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 576 | unsigned NumOfCallArgs = getCallInstNumArgs( CallMI ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 577 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 578 | for(unsigned argNo=0, i=0; i < NumOfCallArgs; ++i, ++argNo ) { |
| 579 | |
| 580 | const Value *CallArg = CallMI->getImplicitRef(i); |
| 581 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 582 | // get the LR of call operand (parameter) |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 583 | LiveRange *const LR = LRI.getLiveRangeForValue(CallArg); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 584 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 585 | unsigned RegType = getRegType( CallArg ); |
| 586 | unsigned RegClassID = getRegClassIDOfValue( CallArg); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 587 | |
| 588 | // find whether this argument is coming in a register (if not, on stack) |
| 589 | |
| 590 | bool isArgInReg = false; |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 591 | unsigned UniArgReg = InvalidRegNum; // reg that LR must be colored with |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 592 | |
| 593 | if( (RegType== IntRegType && argNo < NumOfIntArgRegs)) { |
| 594 | isArgInReg = true; |
| 595 | UniArgReg = getUnifiedRegNum(RegClassID, SparcIntRegOrder::o0 + argNo ); |
| 596 | } |
| 597 | else if(RegType == FPSingleRegType && argNo < NumOfFloatArgRegs) { |
| 598 | isArgInReg = true; |
| 599 | UniArgReg = getUnifiedRegNum(RegClassID, |
| 600 | SparcFloatRegOrder::f0 + (argNo*2 + 1) ); |
| 601 | } |
| 602 | else if(RegType == FPDoubleRegType && argNo < NumOfFloatArgRegs) { |
| 603 | isArgInReg = true; |
| 604 | UniArgReg = getUnifiedRegNum(RegClassID, SparcFloatRegOrder::f0+argNo*2); |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 605 | } |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 606 | |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 607 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 608 | // not possible to have a null LR since all args (even consts) |
| 609 | // must be defined before |
| 610 | if( !LR ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 611 | if( DEBUG_RA) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 612 | cerr << " ERROR: In call instr, no LR for arg: " ; |
| 613 | printValue(CallArg); cerr << endl; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 614 | } |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 615 | assert(0 && "NO LR for call arg"); |
| 616 | // continue; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 617 | } |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 618 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 619 | |
| 620 | // if the LR received the suggested color, NOTHING to do |
| 621 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 622 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 623 | if( LR->hasColor() ) { |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 624 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 625 | |
| 626 | unsigned UniLRReg = getUnifiedRegNum( RegClassID, LR->getColor() ); |
| 627 | |
| 628 | // if LR received the correct color, nothing to do |
| 629 | if( UniLRReg == UniArgReg ) |
| 630 | continue; |
| 631 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 632 | // We are here because though the LR is allocated a register, it |
| 633 | // was not allocated the suggested register. So, we have to copy %ix reg |
| 634 | // (or stack pos of arg) to the register it was colored with |
| 635 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 636 | // the LR is colored with UniLRReg but has to go into UniArgReg |
| 637 | // to pass it as an argument |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 638 | |
| 639 | if( isArgInReg ) |
| 640 | AdMI = cpReg2RegMI(UniLRReg, UniArgReg, RegType ); |
| 641 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 642 | else { |
| 643 | // Now, we have to pass the arg on stack. Since LR received a register |
| 644 | // we just have to move that register to the stack position where |
| 645 | // the argument must be passed |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 646 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 647 | int ArgStakOffFromSP = |
| 648 | UltraSparcFrameInfo::FirstOutgoingArgOffsetFromSP + |
| 649 | argNo * SizeOfOperandOnStack; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 650 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 651 | AdMI = cpReg2MemMI(UniLRReg, getStackPointer(), ArgStakOffFromSP, |
| 652 | RegType ); |
| 653 | } |
| 654 | |
| 655 | CallAI->InstrnsBefore.push_back( AdMI ); // Now add the instruction |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 656 | } |
| 657 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 658 | else { // LR is not colored (i.e., spilled) |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 659 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 660 | if( isArgInReg ) { |
| 661 | |
| 662 | // Now the LR did NOT recieve a register but has a stack poistion. |
| 663 | // Since, the outgoing arg goes in a register we just have to insert |
| 664 | // a load instruction to load the LR to outgoing register |
| 665 | |
| 666 | |
| 667 | AdMI = cpMem2RegMI(getStackPointer(), LR->getSpillOffFromFP(), |
| 668 | UniArgReg, RegType ); |
| 669 | |
| 670 | CallAI->InstrnsBefore.push_back( AdMI ); // Now add the instruction |
| 671 | } |
| 672 | |
| 673 | else { |
| 674 | // Now, we have to pass the arg on stack. Since LR also did NOT |
| 675 | // receive a register we have to move an argument in memory to |
| 676 | // outgoing parameter on stack. |
| 677 | |
| 678 | // Optoimize: Optimize when reverse pointers in MahineInstr are |
| 679 | // introduced. |
| 680 | // call PRA.getUnusedRegAtMI(....) to get an unused reg. Only if this |
| 681 | // fails, then use the following code. Currently, we cannot call the |
| 682 | // above method since we cannot find LVSetBefore without the BB |
| 683 | |
| 684 | int TReg = PRA.getRegNotUsedByThisInst( LR->getRegClass(), CallMI ); |
| 685 | int TmpOff = PRA.getStackOffsets().getNewTmpPosOffFromFP(); |
| 686 | int ArgStakOffFromSP = |
| 687 | UltraSparcFrameInfo::FirstOutgoingArgOffsetFromSP + |
| 688 | argNo * SizeOfOperandOnStack; |
| 689 | |
| 690 | MachineInstr *Ad1, *Ad2, *Ad3, *Ad4; |
| 691 | |
| 692 | // Sequence: |
| 693 | // (1) Save TReg on stack |
| 694 | // (2) Load LR value into TReg from stack pos of LR |
| 695 | // (3) Store Treg on outgoing Arg pos on stack |
| 696 | // (4) Load the old value of TReg from stack to TReg (restore it) |
| 697 | |
| 698 | Ad1 = cpReg2MemMI(TReg, getFramePointer(), TmpOff, RegType ); |
| 699 | Ad2 = cpMem2RegMI(getFramePointer(), LR->getSpillOffFromFP(), |
| 700 | TReg, RegType ); |
| 701 | Ad3 = cpReg2MemMI(TReg, getStackPointer(), ArgStakOffFromSP, RegType ); |
| 702 | Ad4 = cpMem2RegMI(getFramePointer(), TmpOff, TReg, RegType ); |
| 703 | |
| 704 | CallAI->InstrnsBefore.push_back( Ad1 ); |
| 705 | CallAI->InstrnsBefore.push_back( Ad2 ); |
| 706 | CallAI->InstrnsBefore.push_back( Ad3 ); |
| 707 | CallAI->InstrnsBefore.push_back( Ad4 ); |
| 708 | } |
| 709 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | } // for each parameter in call instruction |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 713 | |
| 714 | } |
| 715 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 716 | //--------------------------------------------------------------------------- |
| 717 | // This method is called for an LLVM return instruction to identify which |
| 718 | // values will be returned from this method and to suggest colors. |
| 719 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 720 | void UltraSparcRegInfo::suggestReg4RetValue(const MachineInstr *const RetMI, |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 721 | LiveRangeInfo& LRI) const { |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 722 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 723 | assert( (UltraSparcInfo->getInstrInfo()).isReturn( RetMI->getOpCode() ) ); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 724 | |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 725 | suggestReg4RetAddr(RetMI, LRI); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 726 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 727 | // if there is an implicit ref, that has to be the ret value |
| 728 | if( RetMI->getNumImplicitRefs() > 0 ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 729 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 730 | // The first implicit operand is the return value of a return instr |
| 731 | const Value *RetVal = RetMI->getImplicitRef(0); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 732 | |
| 733 | MachineInstr *AdMI; |
| 734 | LiveRange *const LR = LRI.getLiveRangeForValue( RetVal ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 735 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 736 | if( !LR ) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 737 | cerr << "\nNo LR for:"; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 738 | printValue( RetVal ); |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 739 | cerr << endl; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 740 | assert( LR && "No LR for return value of non-void method"); |
| 741 | //return; |
| 742 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 743 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 744 | unsigned RegClassID = (LR->getRegClass())->getID(); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 745 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 746 | if( RegClassID == IntRegClassID ) |
| 747 | LR->setSuggestedColor(SparcIntRegOrder::i0); |
| 748 | |
| 749 | else if ( RegClassID == FloatRegClassID ) |
| 750 | LR->setSuggestedColor(SparcFloatRegOrder::f0); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 751 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 752 | } |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 753 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 754 | } |
| 755 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 756 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 757 | |
| 758 | //--------------------------------------------------------------------------- |
| 759 | // Colors the return value of a method to %i0 or %f0, if possible. If it is |
| 760 | // not possilbe to directly color the LR, insert a copy instruction to move |
| 761 | // the LR to %i0 or %f0. When the LR is spilled, instead of the copy, we |
| 762 | // have to put a load instruction. |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 763 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 764 | void UltraSparcRegInfo::colorRetValue(const MachineInstr *const RetMI, |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 765 | LiveRangeInfo& LRI, |
| 766 | AddedInstrns *const RetAI) const { |
| 767 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 768 | assert( (UltraSparcInfo->getInstrInfo()).isReturn( RetMI->getOpCode() ) ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 769 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 770 | // if there is an implicit ref, that has to be the ret value |
| 771 | if( RetMI->getNumImplicitRefs() > 0 ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 772 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 773 | // The first implicit operand is the return value of a return instr |
| 774 | const Value *RetVal = RetMI->getImplicitRef(0); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 775 | |
| 776 | MachineInstr *AdMI; |
| 777 | LiveRange *const LR = LRI.getLiveRangeForValue( RetVal ); |
| 778 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 779 | if( ! LR ) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 780 | cerr << "\nNo LR for:"; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 781 | printValue( RetVal ); |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 782 | cerr << endl; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 783 | // assert( LR && "No LR for return value of non-void method"); |
| 784 | return; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 785 | } |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 786 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 787 | unsigned RegClassID = getRegClassIDOfValue(RetVal); |
| 788 | unsigned RegType = getRegType( RetVal ); |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 789 | |
| 790 | |
| 791 | unsigned CorrectCol; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 792 | if(RegClassID == IntRegClassID) |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 793 | CorrectCol = SparcIntRegOrder::i0; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 794 | else if(RegClassID == FloatRegClassID) |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 795 | CorrectCol = SparcFloatRegOrder::f0; |
| 796 | else |
| 797 | assert( 0 && "Unknown RegClass"); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 798 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 799 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 800 | // if the LR received the correct color, NOTHING to do |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 801 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 802 | if( LR->hasColor() ) |
| 803 | if( LR->getColor() == CorrectCol ) |
| 804 | return; |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 805 | |
| 806 | unsigned UniRetReg = getUnifiedRegNum( RegClassID, CorrectCol ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 807 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 808 | if( LR->hasColor() ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 809 | |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 810 | // We are here because the LR was allocted a regiter |
| 811 | // It may be the suggested register or not |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 812 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 813 | // copy the LR of retun value to i0 or f0 |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 814 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 815 | unsigned UniLRReg =getUnifiedRegNum( RegClassID, LR->getColor()); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 816 | |
Ruchira Sasanka | c74a720 | 2001-10-24 15:56:58 +0000 | [diff] [blame] | 817 | // the LR received UniLRReg but must be colored with UniRetReg |
| 818 | // to pass as the return value |
| 819 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 820 | AdMI = cpReg2RegMI( UniLRReg, UniRetReg, RegType); |
Ruchira Sasanka | 88dedc1 | 2001-10-23 21:40:39 +0000 | [diff] [blame] | 821 | RetAI->InstrnsBefore.push_back( AdMI ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 822 | } |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 823 | else { // if the LR is spilled |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 824 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 825 | AdMI = cpMem2RegMI(getFramePointer(), LR->getSpillOffFromFP(), |
| 826 | UniRetReg, RegType); |
| 827 | RetAI->InstrnsBefore.push_back( AdMI ); |
| 828 | cout << "\nCopied the return value from stack"; |
| 829 | } |
| 830 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 831 | } // if there is a return value |
| 832 | |
| 833 | } |
| 834 | |
| 835 | |
| 836 | //--------------------------------------------------------------------------- |
| 837 | // Copy from a register to register. Register number must be the unified |
| 838 | // register number |
| 839 | //--------------------------------------------------------------------------- |
| 840 | |
| 841 | |
| 842 | MachineInstr * UltraSparcRegInfo::cpReg2RegMI(const unsigned SrcReg, |
| 843 | const unsigned DestReg, |
| 844 | const int RegType) const { |
| 845 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 846 | assert( ((int)SrcReg != InvalidRegNum) && ((int)DestReg != InvalidRegNum) && |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 847 | "Invalid Register"); |
| 848 | |
| 849 | MachineInstr * MI = NULL; |
| 850 | |
| 851 | switch( RegType ) { |
| 852 | |
| 853 | case IntRegType: |
Ruchira Sasanka | 735d6e3 | 2001-10-18 22:38:52 +0000 | [diff] [blame] | 854 | case IntCCRegType: |
| 855 | case FloatCCRegType: |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 856 | MI = new MachineInstr(ADD, 3); |
| 857 | MI->SetMachineOperand(0, SrcReg, false); |
| 858 | MI->SetMachineOperand(1, SparcIntRegOrder::g0, false); |
| 859 | MI->SetMachineOperand(2, DestReg, true); |
| 860 | break; |
| 861 | |
| 862 | case FPSingleRegType: |
| 863 | MI = new MachineInstr(FMOVS, 2); |
| 864 | MI->SetMachineOperand(0, SrcReg, false); |
| 865 | MI->SetMachineOperand(1, DestReg, true); |
| 866 | break; |
| 867 | |
| 868 | case FPDoubleRegType: |
| 869 | MI = new MachineInstr(FMOVD, 2); |
| 870 | MI->SetMachineOperand(0, SrcReg, false); |
| 871 | MI->SetMachineOperand(1, DestReg, true); |
| 872 | break; |
| 873 | |
| 874 | default: |
| 875 | assert(0 && "Unknow RegType"); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | return MI; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 879 | } |
Chris Lattner | 20b1ea0 | 2001-09-14 03:47:57 +0000 | [diff] [blame] | 880 | |
| 881 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 882 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | 7dcd612 | 2001-10-24 22:05:34 +0000 | [diff] [blame] | 883 | // Copy from a register to memory (i.e., Store). Register number must |
| 884 | // be the unified register number |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 885 | //--------------------------------------------------------------------------- |
| 886 | |
| 887 | |
| 888 | MachineInstr * UltraSparcRegInfo::cpReg2MemMI(const unsigned SrcReg, |
| 889 | const unsigned DestPtrReg, |
| 890 | const int Offset, |
| 891 | const int RegType) const { |
| 892 | |
| 893 | |
| 894 | MachineInstr * MI = NULL; |
| 895 | |
| 896 | switch( RegType ) { |
| 897 | |
| 898 | case IntRegType: |
Ruchira Sasanka | 735d6e3 | 2001-10-18 22:38:52 +0000 | [diff] [blame] | 899 | case FloatCCRegType: |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 900 | MI = new MachineInstr(STX, 3); |
Ruchira Sasanka | 7dcd612 | 2001-10-24 22:05:34 +0000 | [diff] [blame] | 901 | MI->SetMachineOperand(0, SrcReg, false); |
| 902 | MI->SetMachineOperand(1, DestPtrReg, false); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 903 | MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, |
| 904 | (int64_t) Offset, false); |
| 905 | break; |
| 906 | |
| 907 | case FPSingleRegType: |
| 908 | MI = new MachineInstr(ST, 3); |
Ruchira Sasanka | 7dcd612 | 2001-10-24 22:05:34 +0000 | [diff] [blame] | 909 | MI->SetMachineOperand(0, SrcReg, false); |
| 910 | MI->SetMachineOperand(1, DestPtrReg, false); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 911 | MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, |
| 912 | (int64_t) Offset, false); |
| 913 | break; |
| 914 | |
| 915 | case FPDoubleRegType: |
| 916 | MI = new MachineInstr(STD, 3); |
Ruchira Sasanka | 7dcd612 | 2001-10-24 22:05:34 +0000 | [diff] [blame] | 917 | MI->SetMachineOperand(0, SrcReg, false); |
| 918 | MI->SetMachineOperand(1, DestPtrReg, false); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 919 | MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, |
| 920 | (int64_t) Offset, false); |
| 921 | break; |
| 922 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 923 | case IntCCRegType: |
| 924 | assert( 0 && "Cannot directly store %ccr to memory"); |
| 925 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 926 | default: |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 927 | assert(0 && "Unknow RegType in cpReg2MemMI"); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | return MI; |
| 931 | } |
| 932 | |
| 933 | |
| 934 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | 7dcd612 | 2001-10-24 22:05:34 +0000 | [diff] [blame] | 935 | // Copy from memory to a reg (i.e., Load) Register number must be the unified |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 936 | // register number |
| 937 | //--------------------------------------------------------------------------- |
| 938 | |
| 939 | |
| 940 | MachineInstr * UltraSparcRegInfo::cpMem2RegMI(const unsigned SrcPtrReg, |
| 941 | const int Offset, |
| 942 | const unsigned DestReg, |
| 943 | const int RegType) const { |
| 944 | |
| 945 | MachineInstr * MI = NULL; |
| 946 | |
| 947 | switch( RegType ) { |
| 948 | |
| 949 | case IntRegType: |
Ruchira Sasanka | 735d6e3 | 2001-10-18 22:38:52 +0000 | [diff] [blame] | 950 | case FloatCCRegType: |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 951 | MI = new MachineInstr(LDX, 3); |
| 952 | MI->SetMachineOperand(0, SrcPtrReg, false); |
| 953 | MI->SetMachineOperand(1, MachineOperand:: MO_SignExtendedImmed, |
| 954 | (int64_t) Offset, false); |
| 955 | MI->SetMachineOperand(2, DestReg, false); |
| 956 | break; |
| 957 | |
| 958 | case FPSingleRegType: |
| 959 | MI = new MachineInstr(LD, 3); |
| 960 | MI->SetMachineOperand(0, SrcPtrReg, false); |
| 961 | MI->SetMachineOperand(1, MachineOperand:: MO_SignExtendedImmed, |
| 962 | (int64_t) Offset, false); |
| 963 | MI->SetMachineOperand(2, DestReg, false); |
| 964 | |
| 965 | break; |
| 966 | |
| 967 | case FPDoubleRegType: |
| 968 | MI = new MachineInstr(LDD, 3); |
| 969 | MI->SetMachineOperand(0, SrcPtrReg, false); |
| 970 | MI->SetMachineOperand(1, MachineOperand:: MO_SignExtendedImmed, |
| 971 | (int64_t) Offset, false); |
| 972 | MI->SetMachineOperand(2, DestReg, false); |
| 973 | break; |
| 974 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 975 | case IntCCRegType: |
| 976 | assert( 0 && "Cannot directly load into %ccr from memory"); |
| 977 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 978 | default: |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 979 | assert(0 && "Unknow RegType in cpMem2RegMI"); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | return MI; |
| 983 | } |
| 984 | |
| 985 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 986 | |
| 987 | |
| 988 | // Following method is Not needed now |
| 989 | |
Ruchira Sasanka | ef1b0cb | 2001-11-03 17:13:27 +0000 | [diff] [blame] | 990 | MachineInstr* UltraSparcRegInfo::cpValue2Value(Value *Src, Value *Dest) const { |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 991 | |
Ruchira Sasanka | ef1b0cb | 2001-11-03 17:13:27 +0000 | [diff] [blame] | 992 | MachineInstr * MI = NULL; |
| 993 | |
| 994 | MI = new MachineInstr(ADD, 3); |
| 995 | MI->SetMachineOperand(0, MachineOperand:: MO_VirtualRegister, Src, false); |
| 996 | MI->SetMachineOperand(1, SparcIntRegOrder::g0, false); |
| 997 | MI->SetMachineOperand(2, MachineOperand:: MO_VirtualRegister, Dest, true); |
| 998 | |
| 999 | |
| 1000 | return MI; |
| 1001 | |
| 1002 | } |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 1003 | |
| 1004 | |
| 1005 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1006 | //---------------------------------------------------------------------------- |
| 1007 | // This method inserts caller saving/restoring instructons before/after |
| 1008 | // a call machine instruction. |
| 1009 | //---------------------------------------------------------------------------- |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 1010 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1011 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1012 | void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst, |
| 1013 | const BasicBlock *BB, |
| 1014 | PhyRegAlloc &PRA) const { |
| 1015 | // assert( (getInstrInfo()).isCall( MInst->getOpCode() ) ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1016 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1017 | |
| 1018 | PRA.StackOffsets.resetTmpPos(); |
| 1019 | |
| 1020 | hash_set<unsigned> PushedRegSet; |
| 1021 | |
| 1022 | // Now find the LR of the return value of the call |
| 1023 | // The last *implicit operand* is the return value of a call |
| 1024 | // Insert it to to he PushedRegSet since we must not save that register |
| 1025 | // and restore it after the call. |
| 1026 | // We do this because, we look at the LV set *after* the instruction |
| 1027 | // to determine, which LRs must be saved across calls. The return value |
| 1028 | // of the call is live in this set - but we must not save/restore it. |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1029 | |
| 1030 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1031 | const Value *RetVal = getCallInstRetVal( MInst ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1032 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1033 | if( RetVal ) { |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1034 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1035 | LiveRange *RetValLR = PRA.LRI.getLiveRangeForValue( RetVal ); |
| 1036 | assert( RetValLR && "No LR for RetValue of call"); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1037 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1038 | PushedRegSet.insert( |
| 1039 | getUnifiedRegNum((RetValLR->getRegClass())->getID(), |
| 1040 | RetValLR->getColor() ) ); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1044 | const LiveVarSet *LVSetAft = PRA.LVI->getLiveVarSetAfterMInst(MInst, BB); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1045 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1046 | LiveVarSet::const_iterator LIt = LVSetAft->begin(); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1047 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1048 | // for each live var in live variable set after machine inst |
| 1049 | for( ; LIt != LVSetAft->end(); ++LIt) { |
| 1050 | |
| 1051 | // get the live range corresponding to live var |
| 1052 | LiveRange *const LR = PRA.LRI.getLiveRangeForValue(*LIt ); |
| 1053 | |
| 1054 | // LR can be null if it is a const since a const |
| 1055 | // doesn't have a dominating def - see Assumptions above |
| 1056 | if( LR ) { |
| 1057 | |
| 1058 | if( LR->hasColor() ) { |
| 1059 | |
| 1060 | unsigned RCID = (LR->getRegClass())->getID(); |
| 1061 | unsigned Color = LR->getColor(); |
| 1062 | |
| 1063 | if ( isRegVolatile(RCID, Color) ) { |
| 1064 | |
| 1065 | // if the value is in both LV sets (i.e., live before and after |
| 1066 | // the call machine instruction) |
| 1067 | |
| 1068 | unsigned Reg = getUnifiedRegNum(RCID, Color); |
| 1069 | |
| 1070 | if( PushedRegSet.find(Reg) == PushedRegSet.end() ) { |
| 1071 | |
| 1072 | // if we haven't already pushed that register |
| 1073 | |
| 1074 | unsigned RegType = getRegType( LR ); |
| 1075 | |
| 1076 | // Now get two instructions - to push on stack and pop from stack |
| 1077 | // and add them to InstrnsBefore and InstrnsAfter of the |
| 1078 | // call instruction |
| 1079 | |
| 1080 | int StackOff = PRA.StackOffsets. getNewTmpPosOffFromFP(); |
| 1081 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1082 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1083 | MachineInstr *AdIBefCC, *AdIAftCC, *AdICpCC; |
| 1084 | |
| 1085 | |
| 1086 | //---- Insert code for pushing the reg on stack ---------- |
| 1087 | |
| 1088 | if( RegType == IntCCRegType ) { |
| 1089 | |
| 1090 | // Handle IntCCRegType specially since we cannot directly |
| 1091 | // push %ccr on to the stack |
| 1092 | |
| 1093 | const LiveVarSet *LVSetBef = |
| 1094 | PRA.LVI->getLiveVarSetBeforeMInst(MInst, BB); |
| 1095 | |
| 1096 | // get a free INTEGER register |
| 1097 | int FreeIntReg = |
| 1098 | PRA.getUsableRegAtMI(LR->getRegClass(), IntRegType, MInst, |
| 1099 | LVSetBef, AdIBefCC, AdIAftCC); |
| 1100 | |
| 1101 | // insert the instructions in reverse order since we are |
| 1102 | // adding them to the front of InstrnsBefore |
| 1103 | |
| 1104 | if(AdIAftCC) |
| 1105 | (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdIAftCC); |
| 1106 | |
| 1107 | AdICpCC = cpCCR2IntMI(FreeIntReg); |
| 1108 | (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdICpCC); |
| 1109 | |
| 1110 | if(AdIBefCC) |
| 1111 | (PRA.AddedInstrMap[MInst]->InstrnsBefore).push_front(AdIBefCC); |
| 1112 | |
| 1113 | cerr << "\n!! Inserted caller saving (push) inst for %ccr:"; |
| 1114 | if(AdIBefCC) cerr << "\t" << *(AdIBefCC); |
| 1115 | cerr << "\t" << *AdICpCC; |
| 1116 | if(AdIAftCC) cerr << "\t" << *(AdIAftCC); |
| 1117 | |
| 1118 | } else { |
| 1119 | // for any other register type, just add the push inst |
| 1120 | MachineInstr *AdIBef = |
| 1121 | cpReg2MemMI(Reg, getStackPointer(), StackOff, RegType ); |
| 1122 | ((PRA.AddedInstrMap[MInst])->InstrnsBefore).push_front(AdIBef); |
| 1123 | } |
| 1124 | |
| 1125 | |
| 1126 | //---- Insert code for popping the reg from the stack ---------- |
| 1127 | |
| 1128 | if( RegType == IntCCRegType ) { |
| 1129 | |
| 1130 | // Handle IntCCRegType specially since we cannot directly |
| 1131 | // pop %ccr on from the stack |
| 1132 | |
| 1133 | // get a free INT register |
| 1134 | int FreeIntReg = |
| 1135 | PRA.getUsableRegAtMI(LR->getRegClass(), IntRegType, MInst, |
| 1136 | LVSetAft, AdIBefCC, AdIAftCC); |
| 1137 | |
| 1138 | if(AdIBefCC) |
| 1139 | (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdIBefCC); |
| 1140 | |
| 1141 | AdICpCC = cpInt2CCRMI(FreeIntReg); |
| 1142 | (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdICpCC); |
| 1143 | |
| 1144 | if(AdIAftCC) |
| 1145 | (PRA.AddedInstrMap[MInst]->InstrnsAfter).push_back(AdIAftCC); |
| 1146 | |
| 1147 | cerr << "\n!! Inserted caller saving (pop) inst for %ccr:"; |
| 1148 | if(AdIBefCC) cerr << "\t" << *(AdIBefCC); |
| 1149 | cerr << "\t" << *AdICpCC; |
| 1150 | if(AdIAftCC) cerr << "\t" << *(AdIAftCC); |
| 1151 | |
| 1152 | } else { |
| 1153 | // for any other register type, just add the pop inst |
| 1154 | MachineInstr *AdIAft = |
| 1155 | cpMem2RegMI(getStackPointer(), StackOff, Reg, RegType ); |
| 1156 | |
| 1157 | ((PRA.AddedInstrMap[MInst])->InstrnsAfter).push_back(AdIAft); |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1158 | |
| 1159 | } |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1160 | |
| 1161 | PushedRegSet.insert( Reg ); |
| 1162 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1163 | if(1) { |
| 1164 | cerr << "\nFor call inst:" << *MInst; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1165 | cerr << "\n -inserted caller saving instrs:\n\t "; |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1166 | cerr << *AdIBefCC << "\n\t" << *AdIAftCC ; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1167 | } |
| 1168 | } // if not already pushed |
| 1169 | |
| 1170 | } // if LR has a volatile color |
| 1171 | |
| 1172 | } // if LR has color |
| 1173 | |
| 1174 | } // if there is a LR for Var |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1175 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1176 | } // for each value in the LV set after instruction |
| 1177 | |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1180 | //--------------------------------------------------------------------------- |
| 1181 | // Copies %ccr into an integer register. IntReg is the UNIFIED register |
| 1182 | // number. |
| 1183 | //--------------------------------------------------------------------------- |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1184 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1185 | MachineInstr * UltraSparcRegInfo::cpCCR2IntMI(const unsigned IntReg) const { |
| 1186 | MachineInstr * MI = NULL; |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1187 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1188 | MI = new MachineInstr(RDCCR, 2); |
| 1189 | MI->SetMachineOperand(0, SparcIntCCRegOrder::ccr, false); |
| 1190 | MI->SetMachineOperand(1, IntReg, true); |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1191 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1192 | return MI; |
| 1193 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1194 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 1195 | //--------------------------------------------------------------------------- |
| 1196 | // Copies an integer register into %ccr. IntReg is the UNIFIED register |
| 1197 | // number. |
| 1198 | //--------------------------------------------------------------------------- |
| 1199 | |
| 1200 | MachineInstr * UltraSparcRegInfo::cpInt2CCRMI(const unsigned IntReg) const { |
| 1201 | MachineInstr * MI = NULL; |
| 1202 | |
| 1203 | MI = new MachineInstr(WRCCR, 3); |
| 1204 | MI->SetMachineOperand(0, IntReg, false); |
| 1205 | MI->SetMachineOperand(1, SparcIntRegOrder::g0, false); |
| 1206 | MI->SetMachineOperand(2, SparcIntCCRegOrder::ccr, true); |
| 1207 | |
| 1208 | return MI; |
| 1209 | } |
Ruchira Sasanka | 9144228 | 2001-09-30 23:16:47 +0000 | [diff] [blame] | 1210 | |
| 1211 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 1212 | |
| 1213 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1214 | //--------------------------------------------------------------------------- |
| 1215 | // Print the register assigned to a LR |
| 1216 | //--------------------------------------------------------------------------- |
| 1217 | |
| 1218 | void UltraSparcRegInfo::printReg(const LiveRange *const LR) { |
| 1219 | |
| 1220 | unsigned RegClassID = (LR->getRegClass())->getID(); |
| 1221 | |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1222 | cerr << " *Node " << (LR->getUserIGNode())->getIndex(); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1223 | |
| 1224 | if( ! LR->hasColor() ) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1225 | cerr << " - could not find a color" << endl; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1226 | return; |
| 1227 | } |
| 1228 | |
| 1229 | // if a color is found |
| 1230 | |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1231 | cerr << " colored with color "<< LR->getColor(); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1232 | |
| 1233 | if( RegClassID == IntRegClassID ) { |
| 1234 | |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1235 | cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) ; |
| 1236 | cerr << "]" << endl; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1237 | } |
| 1238 | else if ( RegClassID == FloatRegClassID) { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1239 | cerr << "[" << SparcFloatRegOrder::getRegName(LR->getColor()); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1240 | if( LR->getTypeID() == Type::DoubleTyID ) |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 1241 | cerr << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1); |
| 1242 | cerr << "]" << endl; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1243 | } |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 1244 | } |