blob: 8a827187aee650e9936a9046d0811a622d9d9367 [file] [log] [blame]
Brian Gaeke3ca4fcc2004-04-25 07:04:49 +00001//===-- SparcV9RegInfo.cpp - SparcV9 Target Register Information ----------===//
John Criswellb576c942003-10-20 19:43:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattnered5171e2002-02-03 07:52:04 +00009//
Brian Gaeke3ca4fcc2004-04-25 07:04:49 +000010// This file contains implementations of SparcV9 specific helper methods
Chris Lattnered5171e2002-02-03 07:52:04 +000011// used for register allocation.
12//
13//===----------------------------------------------------------------------===//
14
Misha Brukmanfce11432002-10-28 00:28:31 +000015#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner00dca912003-01-15 17:47:49 +000016#include "llvm/CodeGen/MachineInstrBuilder.h"
Chris Lattner85015a02004-08-16 21:55:02 +000017#include "MachineFunctionInfo.h"
18#include "MachineCodeForInstruction.h"
Chris Lattner08d49632004-02-29 19:12:51 +000019#include "MachineInstrAnnot.h"
Chris Lattner1d415a92004-01-09 16:17:09 +000020#include "RegAlloc/LiveRangeInfo.h"
21#include "RegAlloc/LiveRange.h"
Misha Brukmand71295a2003-12-17 22:04:00 +000022#include "llvm/DerivedTypes.h"
23#include "llvm/Function.h"
Chris Lattner9670eec2004-07-29 17:11:37 +000024#include "llvm/Instructions.h"
Brian Gaekee3d68072004-02-25 18:44:15 +000025#include "SparcV9Internals.h"
26#include "SparcV9RegClassInfo.h"
27#include "SparcV9RegInfo.h"
Chris Lattner750d7232004-08-12 18:29:05 +000028#include "SparcV9FrameInfo.h"
Brian Gaekee3d68072004-02-25 18:44:15 +000029#include "SparcV9TargetMachine.h"
Brian Gaeke98ac7ac2004-08-04 07:29:53 +000030#include "SparcV9TmpInstr.h"
Reid Spencer954da372004-07-04 12:19:56 +000031#include <iostream>
Chris Lattner20b1ea02001-09-14 03:47:57 +000032
Brian Gaeked0fde302003-11-11 22:41:34 +000033namespace llvm {
34
Chris Lattner92ba2aa2003-01-14 23:05:08 +000035enum {
36 BadRegClass = ~0
37};
38
Brian Gaekee3d68072004-02-25 18:44:15 +000039SparcV9RegInfo::SparcV9RegInfo(const SparcV9TargetMachine &tgt)
Brian Gaeke498231b2004-06-03 02:45:09 +000040 : target (tgt), NumOfIntArgRegs (6), NumOfFloatArgRegs (32)
Vikram S. Adved0d06ad2003-05-31 07:32:01 +000041{
Brian Gaekee3d68072004-02-25 18:44:15 +000042 MachineRegClassArr.push_back(new SparcV9IntRegClass(IntRegClassID));
43 MachineRegClassArr.push_back(new SparcV9FloatRegClass(FloatRegClassID));
44 MachineRegClassArr.push_back(new SparcV9IntCCRegClass(IntCCRegClassID));
45 MachineRegClassArr.push_back(new SparcV9FloatCCRegClass(FloatCCRegClassID));
46 MachineRegClassArr.push_back(new SparcV9SpecialRegClass(SpecialRegClassID));
Vikram S. Adve76ee6f72002-07-08 23:23:12 +000047
Brian Gaekee3d68072004-02-25 18:44:15 +000048 assert(SparcV9FloatRegClass::StartOfNonVolatileRegs == 32 &&
Chris Lattner699683c2002-02-04 05:59:25 +000049 "32 Float regs are used for float arg passing");
50}
51
52
Vikram S. Advef1c15ee2002-03-18 03:12:16 +000053// getZeroRegNum - returns the register that contains always zero.
54// this is the unified register number
Chris Lattner699683c2002-02-04 05:59:25 +000055//
Brian Gaekee3d68072004-02-25 18:44:15 +000056unsigned SparcV9RegInfo::getZeroRegNum() const {
57 return getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,
58 SparcV9IntRegClass::g0);
Vikram S. Advef1c15ee2002-03-18 03:12:16 +000059}
Chris Lattner699683c2002-02-04 05:59:25 +000060
61// getCallAddressReg - returns the reg used for pushing the address when a
62// method is called. This can be used for other purposes between calls
63//
Brian Gaekee3d68072004-02-25 18:44:15 +000064unsigned SparcV9RegInfo::getCallAddressReg() const {
65 return getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,
66 SparcV9IntRegClass::o7);
Chris Lattner699683c2002-02-04 05:59:25 +000067}
68
69// Returns the register containing the return address.
70// It should be made sure that this register contains the return
71// value when a return instruction is reached.
72//
Brian Gaekee3d68072004-02-25 18:44:15 +000073unsigned SparcV9RegInfo::getReturnAddressReg() const {
74 return getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,
75 SparcV9IntRegClass::i7);
Chris Lattner95685682002-08-12 21:25:05 +000076}
77
78// Register get name implementations...
79
Brian Gaekee3d68072004-02-25 18:44:15 +000080// Int register names in same order as enum in class SparcV9IntRegClass
Chris Lattner95685682002-08-12 21:25:05 +000081static const char * const IntRegNames[] = {
82 "o0", "o1", "o2", "o3", "o4", "o5", "o7",
83 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
84 "i0", "i1", "i2", "i3", "i4", "i5",
85 "i6", "i7",
86 "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
87 "o6"
88};
89
Brian Gaekee3d68072004-02-25 18:44:15 +000090const char * const SparcV9IntRegClass::getRegName(unsigned reg) const {
Chris Lattner95685682002-08-12 21:25:05 +000091 assert(reg < NumOfAllRegs);
92 return IntRegNames[reg];
93}
94
95static const char * const FloatRegNames[] = {
96 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9",
97 "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
98 "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
99 "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
100 "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49",
101 "f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59",
102 "f60", "f61", "f62", "f63"
103};
104
Brian Gaekee3d68072004-02-25 18:44:15 +0000105const char * const SparcV9FloatRegClass::getRegName(unsigned reg) const {
Chris Lattner95685682002-08-12 21:25:05 +0000106 assert (reg < NumOfAllRegs);
107 return FloatRegNames[reg];
108}
109
Chris Lattner95685682002-08-12 21:25:05 +0000110static const char * const IntCCRegNames[] = {
Vikram S. Adve786833a2003-07-06 20:13:59 +0000111 "xcc", "icc", "ccr"
Chris Lattner95685682002-08-12 21:25:05 +0000112};
113
Brian Gaekee3d68072004-02-25 18:44:15 +0000114const char * const SparcV9IntCCRegClass::getRegName(unsigned reg) const {
Vikram S. Adve786833a2003-07-06 20:13:59 +0000115 assert(reg < 3);
Chris Lattner95685682002-08-12 21:25:05 +0000116 return IntCCRegNames[reg];
117}
118
119static const char * const FloatCCRegNames[] = {
120 "fcc0", "fcc1", "fcc2", "fcc3"
121};
122
Brian Gaekee3d68072004-02-25 18:44:15 +0000123const char * const SparcV9FloatCCRegClass::getRegName(unsigned reg) const {
Brian Gaeke03b562a2004-04-19 18:53:43 +0000124 assert (reg < 4);
Chris Lattner95685682002-08-12 21:25:05 +0000125 return FloatCCRegNames[reg];
Chris Lattner699683c2002-02-04 05:59:25 +0000126}
127
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000128static const char * const SpecialRegNames[] = {
129 "fsr"
130};
131
Brian Gaekee3d68072004-02-25 18:44:15 +0000132const char * const SparcV9SpecialRegClass::getRegName(unsigned reg) const {
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000133 assert (reg < 1);
134 return SpecialRegNames[reg];
Chris Lattner699683c2002-02-04 05:59:25 +0000135}
136
Vikram S. Advef1c15ee2002-03-18 03:12:16 +0000137// Get unified reg number for frame pointer
Brian Gaekee3d68072004-02-25 18:44:15 +0000138unsigned SparcV9RegInfo::getFramePointer() const {
139 return getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,
140 SparcV9IntRegClass::i6);
Chris Lattner699683c2002-02-04 05:59:25 +0000141}
142
Vikram S. Advef1c15ee2002-03-18 03:12:16 +0000143// Get unified reg number for stack pointer
Brian Gaekee3d68072004-02-25 18:44:15 +0000144unsigned SparcV9RegInfo::getStackPointer() const {
145 return getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,
146 SparcV9IntRegClass::o6);
Chris Lattner699683c2002-02-04 05:59:25 +0000147}
148
149
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000150//---------------------------------------------------------------------------
151// Finds whether a call is an indirect call
152//---------------------------------------------------------------------------
153
154inline bool
155isVarArgsFunction(const Type *funcType) {
156 return cast<FunctionType>(cast<PointerType>(funcType)
157 ->getElementType())->isVarArg();
158}
159
160inline bool
161isVarArgsCall(const MachineInstr *CallMI) {
162 Value* callee = CallMI->getOperand(0).getVRegValue();
163 // const Type* funcType = isa<Function>(callee)? callee->getType()
164 // : cast<PointerType>(callee->getType())->getElementType();
165 const Type* funcType = callee->getType();
166 return isVarArgsFunction(funcType);
167}
168
169
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000170// Get the register number for the specified argument #argNo,
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000171//
172// Return value:
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000173// getInvalidRegNum(), if there is no int register available for the arg.
174// regNum, otherwise (this is NOT the unified reg. num).
175// regClassId is set to the register class ID.
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000176//
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000177int
Brian Gaekee3d68072004-02-25 18:44:15 +0000178SparcV9RegInfo::regNumForIntArg(bool inCallee, bool isVarArgsCall,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000179 unsigned argNo, unsigned& regClassId) const
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000180{
Vikram S. Adve242a8082002-05-19 15:25:51 +0000181 regClassId = IntRegClassID;
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000182 if (argNo >= NumOfIntArgRegs)
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000183 return getInvalidRegNum();
Vikram S. Adve242a8082002-05-19 15:25:51 +0000184 else
Brian Gaekee3d68072004-02-25 18:44:15 +0000185 return argNo + (inCallee? SparcV9IntRegClass::i0 : SparcV9IntRegClass::o0);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000186}
187
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000188// Get the register number for the specified FP argument #argNo,
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000189// Use INT regs for FP args if this is a varargs call.
190//
191// Return value:
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000192// getInvalidRegNum(), if there is no int register available for the arg.
193// regNum, otherwise (this is NOT the unified reg. num).
194// regClassId is set to the register class ID.
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000195//
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000196int
Brian Gaekee3d68072004-02-25 18:44:15 +0000197SparcV9RegInfo::regNumForFPArg(unsigned regType,
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000198 bool inCallee, bool isVarArgsCall,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000199 unsigned argNo, unsigned& regClassId) const
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000200{
Vikram S. Adve242a8082002-05-19 15:25:51 +0000201 if (isVarArgsCall)
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000202 return regNumForIntArg(inCallee, isVarArgsCall, argNo, regClassId);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000203 else
204 {
205 regClassId = FloatRegClassID;
206 if (regType == FPSingleRegType)
207 return (argNo*2+1 >= NumOfFloatArgRegs)?
Brian Gaekee3d68072004-02-25 18:44:15 +0000208 getInvalidRegNum() : SparcV9FloatRegClass::f0 + (argNo * 2 + 1);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000209 else if (regType == FPDoubleRegType)
210 return (argNo*2 >= NumOfFloatArgRegs)?
Brian Gaekee3d68072004-02-25 18:44:15 +0000211 getInvalidRegNum() : SparcV9FloatRegClass::f0 + (argNo * 2);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000212 else
213 assert(0 && "Illegal FP register type");
Chris Lattnerb82d97e2002-07-25 06:08:32 +0000214 return 0;
Vikram S. Adve242a8082002-05-19 15:25:51 +0000215 }
Vikram S. Advea44c6c02002-03-31 19:04:50 +0000216}
217
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000218
219//---------------------------------------------------------------------------
220// Finds the return address of a call sparc specific call instruction
221//---------------------------------------------------------------------------
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000222
Brian Gaekee3d68072004-02-25 18:44:15 +0000223// The following 4 methods are used to find the RegType (SparcV9Internals.h)
Vikram S. Adve242a8082002-05-19 15:25:51 +0000224// of a LiveRange, a Value, and for a given register unified reg number.
Chris Lattner699683c2002-02-04 05:59:25 +0000225//
Brian Gaekee3d68072004-02-25 18:44:15 +0000226int SparcV9RegInfo::getRegTypeForClassAndType(unsigned regClassID,
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000227 const Type* type) const
228{
Vikram S. Adve242a8082002-05-19 15:25:51 +0000229 switch (regClassID) {
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000230 case IntRegClassID: return IntRegType;
231 case FloatRegClassID:
232 if (type == Type::FloatTy) return FPSingleRegType;
233 else if (type == Type::DoubleTy) return FPDoubleRegType;
234 assert(0 && "Unknown type in FloatRegClass"); return 0;
235 case IntCCRegClassID: return IntCCRegType;
236 case FloatCCRegClassID: return FloatCCRegType;
237 case SpecialRegClassID: return SpecialRegType;
Vikram S. Adve242a8082002-05-19 15:25:51 +0000238 default: assert( 0 && "Unknown reg class ID"); return 0;
Chris Lattner699683c2002-02-04 05:59:25 +0000239 }
240}
241
Brian Gaekee3d68072004-02-25 18:44:15 +0000242int SparcV9RegInfo::getRegTypeForDataType(const Type* type) const
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000243{
244 return getRegTypeForClassAndType(getRegClassIDOfType(type), type);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000245}
246
Brian Gaekee3d68072004-02-25 18:44:15 +0000247int SparcV9RegInfo::getRegTypeForLR(const LiveRange *LR) const
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000248{
249 return getRegTypeForClassAndType(LR->getRegClassID(), LR->getType());
250}
Chris Lattner699683c2002-02-04 05:59:25 +0000251
Brian Gaekee3d68072004-02-25 18:44:15 +0000252int SparcV9RegInfo::getRegType(int unifiedRegNum) const
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000253{
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000254 if (unifiedRegNum < 32)
Chris Lattner699683c2002-02-04 05:59:25 +0000255 return IntRegType;
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000256 else if (unifiedRegNum < (32 + 32))
Chris Lattner699683c2002-02-04 05:59:25 +0000257 return FPSingleRegType;
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000258 else if (unifiedRegNum < (64 + 32))
Chris Lattner699683c2002-02-04 05:59:25 +0000259 return FPDoubleRegType;
Brian Gaeke6896a7d2004-04-21 17:53:58 +0000260 else if (unifiedRegNum < (64+32+3))
261 return IntCCRegType;
262 else if (unifiedRegNum < (64+32+3+4))
263 return FloatCCRegType;
264 else if (unifiedRegNum < (64+32+3+4+1))
Brian Gaeke3f083d52004-04-20 20:12:57 +0000265 return SpecialRegType;
Chris Lattner699683c2002-02-04 05:59:25 +0000266 else
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000267 assert(0 && "Invalid unified register number in getRegType");
Chris Lattner49b8a9c2002-02-24 23:02:40 +0000268 return 0;
Chris Lattner699683c2002-02-04 05:59:25 +0000269}
270
271
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000272// To find the register class used for a specified Type
273//
Brian Gaekee3d68072004-02-25 18:44:15 +0000274unsigned SparcV9RegInfo::getRegClassIDOfType(const Type *type,
Chris Lattnerb82d97e2002-07-25 06:08:32 +0000275 bool isCCReg) const {
Chris Lattnerf70c22b2004-06-17 18:19:28 +0000276 Type::TypeID ty = type->getTypeID();
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000277 unsigned res;
278
279 // FIXME: Comparing types like this isn't very safe...
280 if ((ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
281 (ty == Type::FunctionTyID) || (ty == Type::PointerTyID) )
282 res = IntRegClassID; // sparc int reg (ty=0: void)
283 else if (ty <= Type::DoubleTyID)
284 res = FloatRegClassID; // sparc float reg class
285 else {
286 //std::cerr << "TypeID: " << ty << "\n";
287 assert(0 && "Cannot resolve register class for type");
288 return 0;
289 }
290
Chris Lattner3c3c82d2003-01-15 21:14:32 +0000291 if (isCCReg)
292 return res + 2; // corresponding condition code register
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000293 else
294 return res;
295}
296
Brian Gaekee3d68072004-02-25 18:44:15 +0000297unsigned SparcV9RegInfo::getRegClassIDOfRegType(int regType) const {
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000298 switch(regType) {
299 case IntRegType: return IntRegClassID;
300 case FPSingleRegType:
301 case FPDoubleRegType: return FloatRegClassID;
302 case IntCCRegType: return IntCCRegClassID;
303 case FloatCCRegType: return FloatCCRegClassID;
Brian Gaeke6896a7d2004-04-21 17:53:58 +0000304 case SpecialRegType: return SpecialRegClassID;
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000305 default:
306 assert(0 && "Invalid register type in getRegClassIDOfRegType");
307 return 0;
308 }
309}
310
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000311//---------------------------------------------------------------------------
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000312// Suggests a register for the ret address in the RET machine instruction.
313// We always suggest %i7 by convention.
314//---------------------------------------------------------------------------
Brian Gaekee3d68072004-02-25 18:44:15 +0000315void SparcV9RegInfo::suggestReg4RetAddr(MachineInstr *RetMI,
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000316 LiveRangeInfo& LRI) const {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000317
Chris Lattnerd029cd22004-06-02 05:55:25 +0000318 assert(target.getInstrInfo()->isReturn(RetMI->getOpcode()));
Vikram S. Adve53fec862001-10-22 13:41:12 +0000319
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000320 // return address is always mapped to i7 so set it immediately
321 RetMI->SetRegForOperand(0, getUnifiedRegNum(IntRegClassID,
Brian Gaekee3d68072004-02-25 18:44:15 +0000322 SparcV9IntRegClass::i7));
Vikram S. Adve53fec862001-10-22 13:41:12 +0000323
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000324 // Possible Optimization:
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000325 // Instead of setting the color, we can suggest one. In that case,
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000326 // we have to test later whether it received the suggested color.
327 // In that case, a LR has to be created at the start of method.
328 // It has to be done as follows (remove the setRegVal above):
Ruchira Sasanka91442282001-09-30 23:16:47 +0000329
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000330 // MachineOperand & MO = RetMI->getOperand(0);
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000331 // const Value *RetAddrVal = MO.getVRegValue();
332 // assert( RetAddrVal && "LR for ret address must be created at start");
333 // LiveRange * RetAddrLR = LRI.getLiveRangeForValue( RetAddrVal);
334 // RetAddrLR->setSuggestedColor(getUnifiedRegNum( IntRegClassID,
Brian Gaekee3d68072004-02-25 18:44:15 +0000335 // SparcV9IntRegOrdr::i7) );
Ruchira Sasanka91442282001-09-30 23:16:47 +0000336}
337
338
339//---------------------------------------------------------------------------
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000340// Suggests a register for the ret address in the JMPL/CALL machine instr.
Brian Gaekee3d68072004-02-25 18:44:15 +0000341// SparcV9 ABI dictates that %o7 be used for this purpose.
Ruchira Sasanka91442282001-09-30 23:16:47 +0000342//---------------------------------------------------------------------------
Vikram S. Adve87817652002-09-28 16:59:05 +0000343void
Brian Gaekee3d68072004-02-25 18:44:15 +0000344SparcV9RegInfo::suggestReg4CallAddr(MachineInstr * CallMI,
Vikram S. Adve87817652002-09-28 16:59:05 +0000345 LiveRangeInfo& LRI) const
346{
Vikram S. Adve242a8082002-05-19 15:25:51 +0000347 CallArgsDescriptor* argDesc = CallArgsDescriptor::get(CallMI);
348 const Value *RetAddrVal = argDesc->getReturnAddrReg();
Vikram S. Adve87817652002-09-28 16:59:05 +0000349 assert(RetAddrVal && "INTERNAL ERROR: Return address value is required");
Ruchira Sasanka91442282001-09-30 23:16:47 +0000350
Vikram S. Adve87817652002-09-28 16:59:05 +0000351 // A LR must already exist for the return address.
352 LiveRange *RetAddrLR = LRI.getLiveRangeForValue(RetAddrVal);
353 assert(RetAddrLR && "INTERNAL ERROR: No LR for return address of call!");
354
Chris Lattner3c3c82d2003-01-15 21:14:32 +0000355 unsigned RegClassID = RetAddrLR->getRegClassID();
Brian Gaekee3d68072004-02-25 18:44:15 +0000356 RetAddrLR->setColor(getUnifiedRegNum(IntRegClassID, SparcV9IntRegClass::o7));
Vikram S. Adve87817652002-09-28 16:59:05 +0000357}
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000358
359
Ruchira Sasanka91442282001-09-30 23:16:47 +0000360
361//---------------------------------------------------------------------------
362// This method will suggest colors to incoming args to a method.
Brian Gaekee3d68072004-02-25 18:44:15 +0000363// According to the SparcV9 ABI, the first 6 incoming args are in
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000364// %i0 - %i5 (if they are integer) OR in %f0 - %f31 (if they are float).
Ruchira Sasanka91442282001-09-30 23:16:47 +0000365// If the arg is passed on stack due to the lack of regs, NOTHING will be
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000366// done - it will be colored (or spilled) as a normal live range.
Ruchira Sasanka91442282001-09-30 23:16:47 +0000367//---------------------------------------------------------------------------
Brian Gaekee3d68072004-02-25 18:44:15 +0000368void SparcV9RegInfo::suggestRegs4MethodArgs(const Function *Meth,
Ruchira Sasanka91442282001-09-30 23:16:47 +0000369 LiveRangeInfo& LRI) const
Chris Lattner20b1ea02001-09-14 03:47:57 +0000370{
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000371 // Check if this is a varArgs function. needed for choosing regs.
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000372 bool isVarArgs = isVarArgsFunction(Meth->getType());
373
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000374 // Count the arguments, *ignoring* whether they are int or FP args.
375 // Use this common arg numbering to pick the right int or fp register.
376 unsigned argNo=0;
Chris Lattnere4d5c442005-03-15 04:54:21 +0000377 for(Function::const_arg_iterator I = Meth->arg_begin(), E = Meth->arg_end();
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000378 I != E; ++I, ++argNo) {
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000379 LiveRange *LR = LRI.getLiveRangeForValue(I);
380 assert(LR && "No live range found for method arg");
381
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000382 unsigned regType = getRegTypeForLR(LR);
383 unsigned regClassIDOfArgReg = BadRegClass; // for chosen reg (unused)
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000384
385 int regNum = (regType == IntRegType)
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000386 ? regNumForIntArg(/*inCallee*/ true, isVarArgs, argNo, regClassIDOfArgReg)
387 : regNumForFPArg(regType, /*inCallee*/ true, isVarArgs, argNo,
388 regClassIDOfArgReg);
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000389
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000390 if (regNum != getInvalidRegNum())
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000391 LR->setSuggestedColor(regNum);
392 }
Chris Lattner20b1ea02001-09-14 03:47:57 +0000393}
394
Ruchira Sasanka91442282001-09-30 23:16:47 +0000395
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000396//---------------------------------------------------------------------------
397// This method is called after graph coloring to move incoming args to
398// the correct hardware registers if they did not receive the correct
399// (suggested) color through graph coloring.
400//---------------------------------------------------------------------------
Brian Gaekee3d68072004-02-25 18:44:15 +0000401void SparcV9RegInfo::colorMethodArgs(const Function *Meth,
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000402 LiveRangeInfo &LRI,
403 std::vector<MachineInstr*>& InstrnsBefore,
404 std::vector<MachineInstr*>& InstrnsAfter) const {
Ruchira Sasanka91442282001-09-30 23:16:47 +0000405
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000406 // check if this is a varArgs function. needed for choosing regs.
407 bool isVarArgs = isVarArgsFunction(Meth->getType());
Ruchira Sasanka91442282001-09-30 23:16:47 +0000408 MachineInstr *AdMI;
409
Ruchira Sasanka91442282001-09-30 23:16:47 +0000410 // for each argument
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000411 // for each argument. count INT and FP arguments separately.
412 unsigned argNo=0, intArgNo=0, fpArgNo=0;
Chris Lattnere4d5c442005-03-15 04:54:21 +0000413 for(Function::const_arg_iterator I = Meth->arg_begin(), E = Meth->arg_end();
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000414 I != E; ++I, ++argNo) {
Ruchira Sasanka91442282001-09-30 23:16:47 +0000415 // get the LR of arg
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000416 LiveRange *LR = LRI.getLiveRangeForValue(I);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000417 assert( LR && "No live range found for method arg");
418
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000419 unsigned regType = getRegTypeForLR(LR);
Chris Lattner3c3c82d2003-01-15 21:14:32 +0000420 unsigned RegClassID = LR->getRegClassID();
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000421
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000422 // Find whether this argument is coming in a register (if not, on stack)
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000423 // Also find the correct register the argument must use (UniArgReg)
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000424 //
Ruchira Sasanka91442282001-09-30 23:16:47 +0000425 bool isArgInReg = false;
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000426 unsigned UniArgReg = getInvalidRegNum(); // reg that LR MUST be colored with
Chris Lattner92ba2aa2003-01-14 23:05:08 +0000427 unsigned regClassIDOfArgReg = BadRegClass; // reg class of chosen reg
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000428
429 int regNum = (regType == IntRegType)
Vikram S. Adve242a8082002-05-19 15:25:51 +0000430 ? regNumForIntArg(/*inCallee*/ true, isVarArgs,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000431 argNo, regClassIDOfArgReg)
Vikram S. Adve242a8082002-05-19 15:25:51 +0000432 : regNumForFPArg(regType, /*inCallee*/ true, isVarArgs,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000433 argNo, regClassIDOfArgReg);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000434
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000435 if(regNum != getInvalidRegNum()) {
Ruchira Sasanka91442282001-09-30 23:16:47 +0000436 isArgInReg = true;
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000437 UniArgReg = getUnifiedRegNum( regClassIDOfArgReg, regNum);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000438 }
Ruchira Sasanka91442282001-09-30 23:16:47 +0000439
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000440 if( ! LR->isMarkedForSpill() ) { // if this arg received a register
Ruchira Sasanka91442282001-09-30 23:16:47 +0000441
Ruchira Sasankac74a7202001-10-24 15:56:58 +0000442 unsigned UniLRReg = getUnifiedRegNum( RegClassID, LR->getColor() );
443
444 // if LR received the correct color, nothing to do
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000445 //
Ruchira Sasankac74a7202001-10-24 15:56:58 +0000446 if( UniLRReg == UniArgReg )
447 continue;
448
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000449 // We are here because the LR did not receive the suggested
450 // but LR received another register.
451 // Now we have to copy the %i reg (or stack pos of arg)
452 // to the register the LR was colored with.
Ruchira Sasankac74a7202001-10-24 15:56:58 +0000453
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000454 // if the arg is coming in UniArgReg register, it MUST go into
Ruchira Sasankac74a7202001-10-24 15:56:58 +0000455 // the UniLRReg register
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000456 //
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000457 if( isArgInReg ) {
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000458 if( regClassIDOfArgReg != RegClassID ) {
Brian Gaeke2ff1e672004-08-24 06:41:40 +0000459 // NOTE: This code has not been well-tested.
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000460
461 // It is a variable argument call: the float reg must go in a %o reg.
462 // We have to move an int reg to a float reg via memory.
463 //
464 assert(isVarArgs &&
465 RegClassID == FloatRegClassID &&
466 regClassIDOfArgReg == IntRegClassID &&
467 "This should only be an Int register for an FP argument");
468
Chris Lattnera1e51ff2004-08-18 18:13:37 +0000469 int TmpOff = MachineFunction::get(Meth).getInfo<SparcV9FunctionInfo>()->pushTempValue(
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000470 getSpilledRegSize(regType));
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000471 cpReg2MemMI(InstrnsBefore,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000472 UniArgReg, getFramePointer(), TmpOff, IntRegType);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000473
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000474 cpMem2RegMI(InstrnsBefore,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000475 getFramePointer(), TmpOff, UniLRReg, regType);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000476 }
477 else {
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000478 cpReg2RegMI(InstrnsBefore, UniArgReg, UniLRReg, regType);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000479 }
480 }
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000481 else {
Ruchira Sasanka91442282001-09-30 23:16:47 +0000482
Misha Brukmancf00c4a2003-10-10 17:57:28 +0000483 // Now the arg is coming on stack. Since the LR received a register,
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000484 // we just have to load the arg on stack into that register
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000485 //
Chris Lattnerd029cd22004-06-02 05:55:25 +0000486 const TargetFrameInfo& frameInfo = *target.getFrameInfo();
Vikram S. Adve1c0fba62001-11-08 04:56:41 +0000487 int offsetFromFP =
Misha Brukmanfce11432002-10-28 00:28:31 +0000488 frameInfo.getIncomingArgOffset(MachineFunction::get(Meth),
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000489 argNo);
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000490
491 // float arguments on stack are right justified so adjust the offset!
492 // int arguments are also right justified but they are always loaded as
493 // a full double-word so the offset does not need to be adjusted.
494 if (regType == FPSingleRegType) {
495 unsigned argSize = target.getTargetData().getTypeSize(LR->getType());
Chris Lattner750d7232004-08-12 18:29:05 +0000496 unsigned slotSize = SparcV9FrameInfo::SizeOfEachArgOnStack;
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000497 assert(argSize <= slotSize && "Insufficient slot size!");
498 offsetFromFP += slotSize - argSize;
499 }
500
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000501 cpMem2RegMI(InstrnsBefore,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000502 getFramePointer(), offsetFromFP, UniLRReg, regType);
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000503 }
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000504
505 } // if LR received a color
506
507 else {
508
509 // Now, the LR did not receive a color. But it has a stack offset for
510 // spilling.
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000511 // So, if the arg is coming in UniArgReg register, we can just move
512 // that on to the stack pos of LR
513
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000514 if( isArgInReg ) {
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000515
516 if( regClassIDOfArgReg != RegClassID ) {
517 assert(0 &&
518 "FP arguments to a varargs function should be explicitly "
519 "copied to/from int registers by instruction selection!");
520
521 // It must be a float arg for a variable argument call, which
522 // must come in a %o reg. Move the int reg to the stack.
523 //
524 assert(isVarArgs && regClassIDOfArgReg == IntRegClassID &&
525 "This should only be an Int register for an FP argument");
526
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000527 cpReg2MemMI(InstrnsBefore, UniArgReg,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000528 getFramePointer(), LR->getSpillOffFromFP(), IntRegType);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000529 }
530 else {
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000531 cpReg2MemMI(InstrnsBefore, UniArgReg,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000532 getFramePointer(), LR->getSpillOffFromFP(), regType);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000533 }
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000534 }
535
536 else {
537
538 // Now the arg is coming on stack. Since the LR did NOT
Misha Brukmancf00c4a2003-10-10 17:57:28 +0000539 // received a register as well, it is allocated a stack position. We
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000540 // can simply change the stack position of the LR. We can do this,
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000541 // since this method is called before any other method that makes
542 // uses of the stack pos of the LR (e.g., updateMachineInstr)
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000543 //
Chris Lattnerd029cd22004-06-02 05:55:25 +0000544 const TargetFrameInfo& frameInfo = *target.getFrameInfo();
Vikram S. Adve1c0fba62001-11-08 04:56:41 +0000545 int offsetFromFP =
Misha Brukmanfce11432002-10-28 00:28:31 +0000546 frameInfo.getIncomingArgOffset(MachineFunction::get(Meth),
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000547 argNo);
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000548
549 // FP arguments on stack are right justified so adjust offset!
550 // int arguments are also right justified but they are always loaded as
551 // a full double-word so the offset does not need to be adjusted.
552 if (regType == FPSingleRegType) {
553 unsigned argSize = target.getTargetData().getTypeSize(LR->getType());
Chris Lattner750d7232004-08-12 18:29:05 +0000554 unsigned slotSize = SparcV9FrameInfo::SizeOfEachArgOnStack;
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000555 assert(argSize <= slotSize && "Insufficient slot size!");
556 offsetFromFP += slotSize - argSize;
557 }
Vikram S. Adve1c0fba62001-11-08 04:56:41 +0000558
559 LR->modifySpillOffFromFP( offsetFromFP );
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000560 }
Ruchira Sasanka91442282001-09-30 23:16:47 +0000561
562 }
563
Ruchira Sasanka91442282001-09-30 23:16:47 +0000564 } // for each incoming argument
565
566}
567
Chris Lattner20b1ea02001-09-14 03:47:57 +0000568
569
Ruchira Sasanka91442282001-09-30 23:16:47 +0000570//---------------------------------------------------------------------------
571// This method is called before graph coloring to suggest colors to the
572// outgoing call args and the return value of the call.
573//---------------------------------------------------------------------------
Brian Gaekee3d68072004-02-25 18:44:15 +0000574void SparcV9RegInfo::suggestRegs4CallArgs(MachineInstr *CallMI,
Vikram S. Adve87817652002-09-28 16:59:05 +0000575 LiveRangeInfo& LRI) const {
Chris Lattnerd029cd22004-06-02 05:55:25 +0000576 assert ( (target.getInstrInfo())->isCall(CallMI->getOpcode()) );
Chris Lattner20b1ea02001-09-14 03:47:57 +0000577
Vikram S. Adve242a8082002-05-19 15:25:51 +0000578 CallArgsDescriptor* argDesc = CallArgsDescriptor::get(CallMI);
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000579
Vikram S. Adve87817652002-09-28 16:59:05 +0000580 suggestReg4CallAddr(CallMI, LRI);
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000581
Vikram S. Adve87817652002-09-28 16:59:05 +0000582 // First color the return value of the call instruction, if any.
583 // The return value will be in %o0 if the value is an integer type,
584 // or in %f0 if the value is a float type.
585 //
586 if (const Value *RetVal = argDesc->getReturnValue()) {
587 LiveRange *RetValLR = LRI.getLiveRangeForValue(RetVal);
588 assert(RetValLR && "No LR for return Value of call!");
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000589
Chris Lattner3c3c82d2003-01-15 21:14:32 +0000590 unsigned RegClassID = RetValLR->getRegClassID();
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000591
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000592 // now suggest a register depending on the register class of ret arg
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000593 if( RegClassID == IntRegClassID )
Brian Gaekee3d68072004-02-25 18:44:15 +0000594 RetValLR->setSuggestedColor(SparcV9IntRegClass::o0);
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000595 else if (RegClassID == FloatRegClassID )
Brian Gaekee3d68072004-02-25 18:44:15 +0000596 RetValLR->setSuggestedColor(SparcV9FloatRegClass::f0 );
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000597 else assert( 0 && "Unknown reg class for return value of call\n");
Chris Lattner20b1ea02001-09-14 03:47:57 +0000598 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000599
Ruchira Sasanka91442282001-09-30 23:16:47 +0000600 // Now suggest colors for arguments (operands) of the call instruction.
601 // Colors are suggested only if the arg number is smaller than the
602 // the number of registers allocated for argument passing.
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000603 // Now, go thru call args - implicit operands of the call MI
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000604
Vikram S. Adve242a8082002-05-19 15:25:51 +0000605 unsigned NumOfCallArgs = argDesc->getNumArgs();
Ruchira Sasanka91442282001-09-30 23:16:47 +0000606
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000607 for(unsigned argNo=0, i=0, intArgNo=0, fpArgNo=0;
608 i < NumOfCallArgs; ++i, ++argNo) {
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000609
Vikram S. Adve242a8082002-05-19 15:25:51 +0000610 const Value *CallArg = argDesc->getArgInfo(i).getArgVal();
Ruchira Sasanka91442282001-09-30 23:16:47 +0000611
612 // get the LR of call operand (parameter)
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000613 LiveRange *const LR = LRI.getLiveRangeForValue(CallArg);
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000614 if (!LR)
615 continue; // no live ranges for constants and labels
Vikram S. Adve87817652002-09-28 16:59:05 +0000616
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000617 unsigned regType = getRegTypeForLR(LR);
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000618 unsigned regClassIDOfArgReg = BadRegClass; // chosen reg class (unused)
Vikram S. Adve87817652002-09-28 16:59:05 +0000619
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000620 // Choose a register for this arg depending on whether it is
Vikram S. Adve242a8082002-05-19 15:25:51 +0000621 // an INT or FP value. Here we ignore whether or not it is a
622 // varargs calls, because FP arguments will be explicitly copied
623 // to an integer Value and handled under (argCopy != NULL) below.
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000624 int regNum = (regType == IntRegType)
Vikram S. Adve242a8082002-05-19 15:25:51 +0000625 ? regNumForIntArg(/*inCallee*/ false, /*isVarArgs*/ false,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000626 argNo, regClassIDOfArgReg)
Vikram S. Adve242a8082002-05-19 15:25:51 +0000627 : regNumForFPArg(regType, /*inCallee*/ false, /*isVarArgs*/ false,
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000628 argNo, regClassIDOfArgReg);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000629
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000630 // If a register could be allocated, use it.
631 // If not, do NOTHING as this will be colored as a normal value.
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000632 if(regNum != getInvalidRegNum())
Vikram S. Adve31f78c42002-04-25 04:42:21 +0000633 LR->setSuggestedColor(regNum);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000634 } // for all call arguments
Chris Lattner20b1ea02001-09-14 03:47:57 +0000635}
636
637
Ruchira Sasanka91442282001-09-30 23:16:47 +0000638//---------------------------------------------------------------------------
Anand Shukla55afc332003-06-01 02:48:23 +0000639// this method is called for an LLVM return instruction to identify which
Ruchira Sasanka91442282001-09-30 23:16:47 +0000640// values will be returned from this method and to suggest colors.
641//---------------------------------------------------------------------------
Brian Gaekee3d68072004-02-25 18:44:15 +0000642void SparcV9RegInfo::suggestReg4RetValue(MachineInstr *RetMI,
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000643 LiveRangeInfo& LRI) const {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000644
Chris Lattnerd029cd22004-06-02 05:55:25 +0000645 assert( target.getInstrInfo()->isReturn( RetMI->getOpcode() ) );
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000646
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000647 suggestReg4RetAddr(RetMI, LRI);
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000648
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000649 // To find the return value (if any), we can get the LLVM return instr.
650 // from the return address register, which is the first operand
651 Value* tmpI = RetMI->getOperand(0).getVRegValue();
652 ReturnInst* retI=cast<ReturnInst>(cast<TmpInstruction>(tmpI)->getOperand(0));
653 if (const Value *RetVal = retI->getReturnValue())
654 if (LiveRange *const LR = LRI.getLiveRangeForValue(RetVal))
655 LR->setSuggestedColor(LR->getRegClassID() == IntRegClassID
Brian Gaekee3d68072004-02-25 18:44:15 +0000656 ? (unsigned) SparcV9IntRegClass::i0
657 : (unsigned) SparcV9FloatRegClass::f0);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000658}
659
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000660//---------------------------------------------------------------------------
661// Check if a specified register type needs a scratch register to be
662// copied to/from memory. If it does, the reg. type that must be used
663// for scratch registers is returned in scratchRegType.
664//
665// Only the int CC register needs such a scratch register.
666// The FP CC registers can (and must) be copied directly to/from memory.
667//---------------------------------------------------------------------------
668
669bool
Brian Gaekee3d68072004-02-25 18:44:15 +0000670SparcV9RegInfo::regTypeNeedsScratchReg(int RegType,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000671 int& scratchRegType) const
672{
673 if (RegType == IntCCRegType)
674 {
675 scratchRegType = IntRegType;
676 return true;
677 }
678 return false;
679}
Ruchira Sasanka91442282001-09-30 23:16:47 +0000680
681//---------------------------------------------------------------------------
682// Copy from a register to register. Register number must be the unified
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000683// register number.
Ruchira Sasanka91442282001-09-30 23:16:47 +0000684//---------------------------------------------------------------------------
685
Vikram S. Adve242a8082002-05-19 15:25:51 +0000686void
Brian Gaekee3d68072004-02-25 18:44:15 +0000687SparcV9RegInfo::cpReg2RegMI(std::vector<MachineInstr*>& mvec,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000688 unsigned SrcReg,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000689 unsigned DestReg,
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000690 int RegType) const {
Misha Brukmand36e30e2003-06-06 09:52:23 +0000691 assert( ((int)SrcReg != getInvalidRegNum()) &&
692 ((int)DestReg != getInvalidRegNum()) &&
Ruchira Sasanka91442282001-09-30 23:16:47 +0000693 "Invalid Register");
694
695 MachineInstr * MI = NULL;
Vikram S. Adve242a8082002-05-19 15:25:51 +0000696
Ruchira Sasanka91442282001-09-30 23:16:47 +0000697 switch( RegType ) {
698
Ruchira Sasanka735d6e32001-10-18 22:38:52 +0000699 case IntCCRegType:
Misha Brukmana98cd452003-05-20 20:32:24 +0000700 if (getRegType(DestReg) == IntRegType) {
701 // copy intCC reg to int reg
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000702 MI = (BuildMI(V9::RDCCR, 2)
Brian Gaekee3d68072004-02-25 18:44:15 +0000703 .addMReg(getUnifiedRegNum(SparcV9RegInfo::IntCCRegClassID,
704 SparcV9IntCCRegClass::ccr))
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000705 .addMReg(DestReg,MachineOperand::Def));
Misha Brukmana98cd452003-05-20 20:32:24 +0000706 } else {
707 // copy int reg to intCC reg
Misha Brukmana98cd452003-05-20 20:32:24 +0000708 assert(getRegType(SrcReg) == IntRegType
709 && "Can only copy CC reg to/from integer reg");
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000710 MI = (BuildMI(V9::WRCCRr, 3)
711 .addMReg(SrcReg)
Brian Gaekee3d68072004-02-25 18:44:15 +0000712 .addMReg(SparcV9IntRegClass::g0)
713 .addMReg(getUnifiedRegNum(SparcV9RegInfo::IntCCRegClassID,
714 SparcV9IntCCRegClass::ccr),
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000715 MachineOperand::Def));
Misha Brukmana98cd452003-05-20 20:32:24 +0000716 }
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000717 break;
718
Ruchira Sasanka735d6e32001-10-18 22:38:52 +0000719 case FloatCCRegType:
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000720 assert(0 && "Cannot copy FPCC register to any other register");
Vikram S. Adve242a8082002-05-19 15:25:51 +0000721 break;
722
723 case IntRegType:
Misha Brukmanaf6f38e2003-05-27 22:40:34 +0000724 MI = BuildMI(V9::ADDr, 3).addMReg(SrcReg).addMReg(getZeroRegNum())
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000725 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000726 break;
Vikram S. Adve242a8082002-05-19 15:25:51 +0000727
Ruchira Sasanka91442282001-09-30 23:16:47 +0000728 case FPSingleRegType:
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000729 MI = BuildMI(V9::FMOVS, 2).addMReg(SrcReg)
730 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000731 break;
732
733 case FPDoubleRegType:
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000734 MI = BuildMI(V9::FMOVD, 2).addMReg(SrcReg)
735 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000736 break;
737
738 default:
Vikram S. Adve242a8082002-05-19 15:25:51 +0000739 assert(0 && "Unknown RegType");
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000740 break;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000741 }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000742
743 if (MI)
744 mvec.push_back(MI);
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000745}
Chris Lattner20b1ea02001-09-14 03:47:57 +0000746
Brian Gaeke66149922004-08-18 17:44:14 +0000747/// cpReg2MemMI - Generate SparcV9 MachineInstrs to store a register
748/// (SrcReg) to memory, at [PtrReg + Offset]. Register numbers must be the
749/// unified register numbers. RegType must be the SparcV9 register type
750/// of SrcReg. When SrcReg is %ccr, scratchReg must be the
751/// number of a free integer register. The newly-generated MachineInstrs
752/// are appended to mvec.
753///
754void SparcV9RegInfo::cpReg2MemMI(std::vector<MachineInstr*>& mvec,
755 unsigned SrcReg, unsigned PtrReg, int Offset,
756 int RegType, int scratchReg) const {
757 unsigned OffReg = SparcV9::g4; // Use register g4 for holding large offsets
758 bool useImmediateOffset = true;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000759
Brian Gaeke66149922004-08-18 17:44:14 +0000760 // If the Offset will not fit in the signed-immediate field, we put it in
761 // register g4. This takes advantage of the fact that all the opcodes
762 // used below have the same size immed. field.
763 if (RegType != IntCCRegType
764 && !target.getInstrInfo()->constantFitsInImmedField(V9::LDXi, Offset)) {
765 // Put the offset into a register. We could do this in fewer steps,
766 // in some cases (see CreateSETSWConst()) but we're being lazy.
767 MachineInstr *MI = BuildMI(V9::SETHI, 2).addZImm(Offset).addMReg(OffReg,
768 MachineOperand::Def);
769 MI->getOperand(0).markHi32();
770 mvec.push_back(MI);
771 MI = BuildMI(V9::ORi,3).addMReg(OffReg).addZImm(Offset).addMReg(OffReg,
772 MachineOperand::Def);
773 MI->getOperand(1).markLo32();
774 mvec.push_back(MI);
775 MI = BuildMI(V9::SRAi5,3).addMReg(OffReg).addZImm(0).addMReg(OffReg,
776 MachineOperand::Def);
777 mvec.push_back(MI);
778 useImmediateOffset = false;
779 }
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000780
Brian Gaeke66149922004-08-18 17:44:14 +0000781 MachineInstr *MI = 0;
Chris Lattner00dca912003-01-15 17:47:49 +0000782 switch (RegType) {
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000783 case IntRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000784 if (useImmediateOffset)
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000785 MI = BuildMI(V9::STXi,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
786 else
787 MI = BuildMI(V9::STXr,3).addMReg(SrcReg).addMReg(PtrReg).addMReg(OffReg);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000788 break;
789
790 case FPSingleRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000791 if (useImmediateOffset)
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000792 MI = BuildMI(V9::STFi, 3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
793 else
794 MI = BuildMI(V9::STFr, 3).addMReg(SrcReg).addMReg(PtrReg).addMReg(OffReg);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000795 break;
796
797 case FPDoubleRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000798 if (useImmediateOffset)
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000799 MI = BuildMI(V9::STDFi,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(Offset);
800 else
801 MI = BuildMI(V9::STDFr,3).addMReg(SrcReg).addMReg(PtrReg).addSImm(OffReg);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000802 break;
803
Ruchira Sasanka3839e6e2001-11-03 19:59:59 +0000804 case IntCCRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000805 assert(scratchReg >= 0 && getRegType(scratchReg) == IntRegType
806 && "Need a scratch reg of integer type to load or store %ccr");
807 MI = BuildMI(V9::RDCCR, 2).addMReg(SparcV9::ccr)
808 .addMReg(scratchReg, MachineOperand::Def);
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000809 mvec.push_back(MI);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000810 cpReg2MemMI(mvec, scratchReg, PtrReg, Offset, IntRegType);
Chris Lattner00dca912003-01-15 17:47:49 +0000811 return;
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000812
Brian Gaeke0eb61032004-04-19 19:12:12 +0000813 case SpecialRegType: // used only for %fsr itself.
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000814 case FloatCCRegType: {
Brian Gaeke66149922004-08-18 17:44:14 +0000815 if (useImmediateOffset)
816 MI = BuildMI(V9::STXFSRi,3).addMReg(SparcV9::fsr).addMReg(PtrReg)
817 .addSImm(Offset);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000818 else
Brian Gaeke66149922004-08-18 17:44:14 +0000819 MI = BuildMI(V9::STXFSRr,3).addMReg(SparcV9::fsr).addMReg(PtrReg)
820 .addMReg(OffReg);
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000821 break;
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000822 }
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000823 default:
Vikram S. Adve242a8082002-05-19 15:25:51 +0000824 assert(0 && "Unknown RegType in cpReg2MemMI");
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000825 }
Chris Lattner00dca912003-01-15 17:47:49 +0000826 mvec.push_back(MI);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000827}
828
Brian Gaeke66149922004-08-18 17:44:14 +0000829/// cpMem2RegMI - Generate SparcV9 MachineInstrs to load a register
830/// (DestReg) from memory, at [PtrReg + Offset]. Register numbers must be the
831/// unified register numbers. RegType must be the SparcV9 register type
832/// of DestReg. When DestReg is %ccr, scratchReg must be the
833/// number of a free integer register. The newly-generated MachineInstrs
834/// are appended to mvec.
835///
836void SparcV9RegInfo::cpMem2RegMI(std::vector<MachineInstr*>& mvec,
837 unsigned PtrReg, int Offset, unsigned DestReg,
838 int RegType, int scratchReg) const {
839 unsigned OffReg = SparcV9::g4; // Use register g4 for holding large offsets
840 bool useImmediateOffset = true;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000841
Brian Gaeke66149922004-08-18 17:44:14 +0000842 // If the Offset will not fit in the signed-immediate field, we put it in
843 // register g4. This takes advantage of the fact that all the opcodes
844 // used below have the same size immed. field.
845 if (RegType != IntCCRegType
846 && !target.getInstrInfo()->constantFitsInImmedField(V9::LDXi, Offset)) {
847 MachineInstr *MI = BuildMI(V9::SETHI, 2).addZImm(Offset).addMReg(OffReg,
848 MachineOperand::Def);
849 MI->getOperand(0).markHi32();
850 mvec.push_back(MI);
851 MI = BuildMI(V9::ORi,3).addMReg(OffReg).addZImm(Offset).addMReg(OffReg,
852 MachineOperand::Def);
853 MI->getOperand(1).markLo32();
854 mvec.push_back(MI);
855 MI = BuildMI(V9::SRAi5,3).addMReg(OffReg).addZImm(0).addMReg(OffReg,
856 MachineOperand::Def);
857 mvec.push_back(MI);
858 useImmediateOffset = false;
859 }
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000860
Brian Gaeke66149922004-08-18 17:44:14 +0000861 MachineInstr *MI = 0;
Chris Lattner699683c2002-02-04 05:59:25 +0000862 switch (RegType) {
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000863 case IntRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000864 if (useImmediateOffset)
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000865 MI = BuildMI(V9::LDXi, 3).addMReg(PtrReg).addSImm(Offset)
866 .addMReg(DestReg, MachineOperand::Def);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000867 else
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000868 MI = BuildMI(V9::LDXr, 3).addMReg(PtrReg).addMReg(OffReg)
869 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000870 break;
871
872 case FPSingleRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000873 if (useImmediateOffset)
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000874 MI = BuildMI(V9::LDFi, 3).addMReg(PtrReg).addSImm(Offset)
875 .addMReg(DestReg, MachineOperand::Def);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000876 else
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000877 MI = BuildMI(V9::LDFr, 3).addMReg(PtrReg).addMReg(OffReg)
878 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000879 break;
880
881 case FPDoubleRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000882 if (useImmediateOffset)
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000883 MI= BuildMI(V9::LDDFi, 3).addMReg(PtrReg).addSImm(Offset)
884 .addMReg(DestReg, MachineOperand::Def);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000885 else
Alkis Evlogimenos890f9232004-02-22 19:23:26 +0000886 MI= BuildMI(V9::LDDFr, 3).addMReg(PtrReg).addMReg(OffReg)
887 .addMReg(DestReg, MachineOperand::Def);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000888 break;
889
Ruchira Sasanka3839e6e2001-11-03 19:59:59 +0000890 case IntCCRegType:
Brian Gaeke66149922004-08-18 17:44:14 +0000891 assert(scratchReg >= 0 && getRegType(scratchReg) == IntRegType
892 && "Need a scratch reg of integer type to load or store %ccr");
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000893 cpMem2RegMI(mvec, PtrReg, Offset, scratchReg, IntRegType);
Brian Gaeke66149922004-08-18 17:44:14 +0000894 MI = BuildMI(V9::WRCCRr, 3).addMReg(scratchReg).addMReg(SparcV9::g0)
895 .addMReg(SparcV9::ccr, MachineOperand::Def);
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000896 break;
897
Brian Gaeke0eb61032004-04-19 19:12:12 +0000898 case SpecialRegType: // used only for %fsr itself
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000899 case FloatCCRegType: {
Brian Gaeke66149922004-08-18 17:44:14 +0000900 if (useImmediateOffset)
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000901 MI = BuildMI(V9::LDXFSRi, 3).addMReg(PtrReg).addSImm(Offset)
Brian Gaeke66149922004-08-18 17:44:14 +0000902 .addMReg(SparcV9::fsr, MachineOperand::Def);
Vikram S. Adve83d30c82003-07-29 19:53:21 +0000903 else
904 MI = BuildMI(V9::LDXFSRr, 3).addMReg(PtrReg).addMReg(OffReg)
Brian Gaeke66149922004-08-18 17:44:14 +0000905 .addMReg(SparcV9::fsr, MachineOperand::Def);
Vikram S. Adve76ee6f72002-07-08 23:23:12 +0000906 break;
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000907 }
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000908 default:
Ruchira Sasankaae4bcd72001-11-10 21:20:43 +0000909 assert(0 && "Unknown RegType in cpMem2RegMI");
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000910 }
Chris Lattner00dca912003-01-15 17:47:49 +0000911 mvec.push_back(MI);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000912}
913
914
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000915//---------------------------------------------------------------------------
916// Generate a copy instruction to copy a value to another. Temporarily
917// used by PhiElimination code.
918//---------------------------------------------------------------------------
919
920
Vikram S. Adve242a8082002-05-19 15:25:51 +0000921void
Brian Gaekee3d68072004-02-25 18:44:15 +0000922SparcV9RegInfo::cpValue2Value(Value *Src, Value *Dest,
Brian Gaekee7c77612004-06-04 20:51:40 +0000923 std::vector<MachineInstr*>& mvec) const {
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000924 int RegType = getRegTypeForDataType(Src->getType());
Ruchira Sasankaef1b0cb2001-11-03 17:13:27 +0000925 MachineInstr * MI = NULL;
926
Brian Gaekee7c77612004-06-04 20:51:40 +0000927 switch (RegType) {
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000928 case IntRegType:
Misha Brukmanaf6f38e2003-05-27 22:40:34 +0000929 MI = BuildMI(V9::ADDr, 3).addReg(Src).addMReg(getZeroRegNum())
Misha Brukmana98cd452003-05-20 20:32:24 +0000930 .addRegDef(Dest);
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000931 break;
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000932 case FPSingleRegType:
Misha Brukmana98cd452003-05-20 20:32:24 +0000933 MI = BuildMI(V9::FMOVS, 2).addReg(Src).addRegDef(Dest);
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000934 break;
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000935 case FPDoubleRegType:
Misha Brukmana98cd452003-05-20 20:32:24 +0000936 MI = BuildMI(V9::FMOVD, 2).addReg(Src).addRegDef(Dest);
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000937 break;
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000938 default:
Brian Gaekee7c77612004-06-04 20:51:40 +0000939 assert(0 && "Unknown RegType in cpValue2Value");
Ruchira Sasanka67a463a2001-11-12 14:45:33 +0000940 }
Ruchira Sasankaef1b0cb2001-11-03 17:13:27 +0000941
Chris Lattner0fa600d2002-10-28 20:10:56 +0000942 mvec.push_back(MI);
Ruchira Sasankaef1b0cb2001-11-03 17:13:27 +0000943}
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000944
945
946
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000947//---------------------------------------------------------------------------
948// Print the register assigned to a LR
949//---------------------------------------------------------------------------
950
Brian Gaekee3d68072004-02-25 18:44:15 +0000951void SparcV9RegInfo::printReg(const LiveRange *LR) const {
Chris Lattner3c3c82d2003-01-15 21:14:32 +0000952 unsigned RegClassID = LR->getRegClassID();
Chris Lattnerfdba3932003-09-01 19:58:02 +0000953 std::cerr << " Node ";
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000954
Chris Lattner699683c2002-02-04 05:59:25 +0000955 if (!LR->hasColor()) {
Misha Brukmanee563cb2003-05-21 17:59:06 +0000956 std::cerr << " - could not find a color\n";
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000957 return;
958 }
959
960 // if a color is found
961
Misha Brukmanee563cb2003-05-21 17:59:06 +0000962 std::cerr << " colored with color "<< LR->getColor();
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000963
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000964 unsigned uRegName = getUnifiedRegNum(RegClassID, LR->getColor());
965
966 std::cerr << "[";
967 std::cerr<< getUnifiedRegName(uRegName);
968 if (RegClassID == FloatRegClassID && LR->getType() == Type::DoubleTy)
969 std::cerr << "+" << getUnifiedRegName(uRegName+1);
970 std::cerr << "]\n";
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000971}
Brian Gaeked0fde302003-11-11 22:41:34 +0000972
973} // End llvm namespace