+//-----------------------------------------------------------------------------
+// This method marks the registers used for a given register number.
+// This marks a single register for Float regs, but the R,R+1 pair
+// for double-precision registers.
+//-----------------------------------------------------------------------------
+
+void SparcV9FloatRegClass::markColorsUsed(unsigned RegInClass,
+ int UserRegType,
+ int RegTypeWanted,
+ std::vector<bool> &IsColorUsedArr) const
+{
+ if (UserRegType == SparcV9RegInfo::FPDoubleRegType ||
+ RegTypeWanted == SparcV9RegInfo::FPDoubleRegType) {
+ // This register is used as or is needed as a double-precision reg.
+ // We need to mark the [even,odd] pair corresponding to this reg.
+ // Get the even numbered register corresponding to this reg.
+ unsigned EvenRegInClass = RegInClass & ~1u;
+ assert(EvenRegInClass+1 < NumOfAllRegs &&
+ EvenRegInClass+1 < IsColorUsedArr.size());
+ IsColorUsedArr[EvenRegInClass] = true;
+ IsColorUsedArr[EvenRegInClass+1] = true;
+ }
+ else {
+ assert(RegInClass < NumOfAllRegs && RegInClass < IsColorUsedArr.size());
+ assert(UserRegType == RegTypeWanted
+ && "Something other than FP single/double types share a reg class?");
+ IsColorUsedArr[RegInClass] = true;
+ }
+}
+
+// This method finds unused registers of the specified register type,
+// using the given "used" flag array IsColorUsedArr. It checks a single
+// entry in the array directly for float regs, and checks the pair [R,R+1]
+// for double-precision registers
+// It returns -1 if no unused color is found.
+//
+int SparcV9FloatRegClass::findUnusedColor(int RegTypeWanted,
+ const std::vector<bool> &IsColorUsedArr) const
+{
+ if (RegTypeWanted == SparcV9RegInfo::FPDoubleRegType) {
+ unsigned NC = 2 * this->getNumOfAvailRegs();
+ assert(IsColorUsedArr.size() == NC && "Invalid colors-used array");
+ for (unsigned c = 0; c < NC; c+=2)
+ if (!IsColorUsedArr[c]) {
+ assert(!IsColorUsedArr[c+1] && "Incorrect used regs for FP double!");
+ return c;
+ }
+ return -1;
+ }
+ else
+ return TargetRegClassInfo::findUnusedColor(RegTypeWanted, IsColorUsedArr);
+}