From: Misha Brukman Date: Fri, 9 Jul 2004 15:37:16 +0000 (+0000) Subject: Read/write the offset value for stack-relative loads via correct instr operand. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c1ef127ae2326d0565163169d361b4b9e145d828;p=oota-llvm.git Read/write the offset value for stack-relative loads via correct instr operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14722 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/PowerPC/PowerPCRegisterInfo.cpp b/lib/Target/PowerPC/PowerPCRegisterInfo.cpp index 67759ef48bb..148196e8db2 100644 --- a/lib/Target/PowerPC/PowerPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PowerPCRegisterInfo.cpp @@ -153,21 +153,19 @@ PowerPCRegisterInfo::eliminateFrameIndex(MachineFunction &MF, int FrameIndex = MI.getOperand(i).getFrameIndex(); - // This must be part of a four operand memory reference. Replace the - // FrameIndex with base register with GPR1. + // Replace the FrameIndex with base register with GPR1. MI.SetMachineOperandReg(i, PPC32::R1); - // Take into account whether its an add or mem instruction - if (i == 2) i--; - + // Take into account whether it's an add or mem instruction + unsigned OffIdx = (i == 2) ? 1 : 2; // Now add the frame object offset to the offset from r1. int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) + - MI.getOperand(i).getImmedValue()+4; + MI.getOperand(OffIdx).getImmedValue()+4; if (!hasFP(MF)) Offset += MF.getFrameInfo()->getStackSize(); - MI.SetMachineOperandConst(i, MachineOperand::MO_SignExtendedImmed, Offset); + MI.SetMachineOperandConst(OffIdx, MachineOperand::MO_SignExtendedImmed, Offset); DEBUG(std::cerr << "offset = " << Offset << std::endl); }