Bug/case fixes:

(1) select: Ok to convert a pointer to a float or double.
(2) regalloc: Some MachineInstr* for caller-saving code before a call
    were being inserted before and after the call!
(3) Don't insert the caller-saving instructions in the
    MachineCodeForInstruction for the Call instruction.
    *All* instructions generated by register allocation need to be
    recorded in those maps, but it needs to be done uniformly.

llvm-svn: 7051
This commit is contained in:
Vikram S. Adve 2003-07-02 01:13:57 +00:00
parent 29eafac9ff
commit b5f8ada255
2 changed files with 25 additions and 12 deletions

View File

@ -477,14 +477,15 @@ ChooseConvertToFloatInstr(OpLabel vopCode, const Type* opType)
opType == Type::ShortTy || opType == Type::UShortTy || opType == Type::ShortTy || opType == Type::UShortTy ||
opType == Type::IntTy || opType == Type::UIntTy) opType == Type::IntTy || opType == Type::UIntTy)
opCode = (vopCode == ToFloatTy? V9::FITOS : V9::FITOD); opCode = (vopCode == ToFloatTy? V9::FITOS : V9::FITOD);
else if (opType == Type::LongTy || opType == Type::ULongTy) else if (opType == Type::LongTy || opType == Type::ULongTy ||
isa<PointerType>(opType))
opCode = (vopCode == ToFloatTy? V9::FXTOS : V9::FXTOD); opCode = (vopCode == ToFloatTy? V9::FXTOS : V9::FXTOD);
else if (opType == Type::FloatTy) else if (opType == Type::FloatTy)
opCode = (vopCode == ToFloatTy? V9::INVALID_OPCODE : V9::FSTOD); opCode = (vopCode == ToFloatTy? V9::INVALID_OPCODE : V9::FSTOD);
else if (opType == Type::DoubleTy) else if (opType == Type::DoubleTy)
opCode = (vopCode == ToFloatTy? V9::FDTOS : V9::INVALID_OPCODE); opCode = (vopCode == ToFloatTy? V9::FDTOS : V9::INVALID_OPCODE);
else else
assert(0 && "Cannot convert this type to DOUBLE on SPARC"); assert(0 && "Trying to convert a non-scalar type to DOUBLE?");
return opCode; return opCode;
} }

View File

@ -942,14 +942,23 @@ void UltraSparcRegInfo::colorCallArgs(MachineInstr *CallMI,
for(unsigned i=0; i < ReorderedVec.size(); i++) for(unsigned i=0; i < ReorderedVec.size(); i++)
CallAI->InstrnsBefore.push_back( ReorderedVec[i] ); CallAI->InstrnsBefore.push_back( ReorderedVec[i] );
//Insert machine instructions before and after call into the #ifndef NDEBUG
//call instructions map --- Anand // Temporary sanity checking code to detect whether the same machine
const CallInst *callInst = argDesc->getCallInst(); // instruction is ever inserted twice before/after a call.
MachineCodeForInstruction &mvec = MachineCodeForInstruction::get(callInst); // I suspect this is happening but am not sure. --Vikram, 7/1/03.
mvec.insert(mvec.begin(), CallAI->InstrnsBefore.begin(), //
CallAI->InstrnsBefore.end()); std::set<const MachineInstr*> instrsSeen;
mvec.insert(mvec.end(), CallAI->InstrnsAfter.begin(), for (int i = 0, N = CallAI->InstrnsBefore.size(); i < N; ++i) {
CallAI->InstrnsAfter.end()); assert(instrsSeen.find(CallAI->InstrnsBefore[i]) == instrsSeen.end() &&
"Duplicate machine instruction in InstrnsBefore!");
instrsSeen.insert(CallAI->InstrnsBefore[i]);
}
for (int i = 0, N = CallAI->InstrnsAfter.size(); i < N; ++i) {
assert(instrsSeen.find(CallAI->InstrnsAfter[i]) == instrsSeen.end() &&
"Duplicate machine instruction in InstrnsBefore/After!");
instrsSeen.insert(CallAI->InstrnsAfter[i]);
}
#endif
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1361,10 +1370,10 @@ UltraSparcRegInfo::insertCallerSavingCode
int StackOff = int StackOff =
PRA.MF.getInfo()->pushTempValue(getSpilledRegSize(RegType)); PRA.MF.getInfo()->pushTempValue(getSpilledRegSize(RegType));
std::vector<MachineInstr*> AdIBef, AdIAft;
//---- Insert code for pushing the reg on stack ---------- //---- Insert code for pushing the reg on stack ----------
std::vector<MachineInstr*> AdIBef, AdIAft;
// We may need a scratch register to copy the saved value // We may need a scratch register to copy the saved value
// to/from memory. This may itself have to insert code to // to/from memory. This may itself have to insert code to
// free up a scratch register. Any such code should go before // free up a scratch register. Any such code should go before
@ -1395,6 +1404,9 @@ UltraSparcRegInfo::insertCallerSavingCode
//---- Insert code for popping the reg from the stack ---------- //---- Insert code for popping the reg from the stack ----------
AdIBef.clear();
AdIAft.clear();
// We may need a scratch register to copy the saved value // We may need a scratch register to copy the saved value
// from memory. This may itself have to insert code to // from memory. This may itself have to insert code to
// free up a scratch register. Any such code should go // free up a scratch register. Any such code should go