aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-04-06 22:10:22 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-04-06 22:10:22 +0000
commit3a8ad62d4ffa9de99f8835fe9592d4d6ef0a2730 (patch)
tree0b98c67008f1df12461e7e8e2e3a2aed8f4ac8af
parent1c38175d6b7978768645fac271db435bef337a13 (diff)
downloadexternal_llvm-3a8ad62d4ffa9de99f8835fe9592d4d6ef0a2730.zip
external_llvm-3a8ad62d4ffa9de99f8835fe9592d4d6ef0a2730.tar.gz
external_llvm-3a8ad62d4ffa9de99f8835fe9592d4d6ef0a2730.tar.bz2
First attempt at handling frame index elimination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12728 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/Sparc/SparcRegisterInfo.cpp19
-rw-r--r--lib/Target/SparcV8/SparcV8RegisterInfo.cpp19
2 files changed, 22 insertions, 16 deletions
diff --git a/lib/Target/Sparc/SparcRegisterInfo.cpp b/lib/Target/Sparc/SparcRegisterInfo.cpp
index 8d74d8a..5ca69e0 100644
--- a/lib/Target/Sparc/SparcRegisterInfo.cpp
+++ b/lib/Target/Sparc/SparcRegisterInfo.cpp
@@ -33,7 +33,7 @@ int SparcV8RegisterInfo::storeRegToStackSlot(
assert (RC == SparcV8::IntRegsRegisterClass
&& "Can only store 32-bit values to stack slots");
MachineInstr *I =
- BuildMI (V8::STrm, 2).addFrameIndex (FrameIdx).addReg (SrcReg);
+ BuildMI (V8::STrm, 3).addFrameIndex (FrameIdx).addSImm (0).addReg (SrcReg);
MBB.insert(MBBI, I);
return 1;
}
@@ -47,7 +47,7 @@ int SparcV8RegisterInfo::loadRegFromStackSlot(
assert (RC == SparcV8::IntRegsRegisterClass
&& "Can only load 32-bit registers from stack slots");
MachineInstr *I =
- BuildMI (V8::LDmr, 2).addReg (DestReg).addFrameIndex (FrameIdx);
+ BuildMI (V8::LDmr, 2).addReg (DestReg).addFrameIndex (FrameIdx).addSImm (0);
MBB.insert(MBBI, I);
return 1;
}
@@ -84,11 +84,14 @@ SparcV8RegisterInfo::eliminateFrameIndex(MachineFunction &MF,
int FrameIndex = MI.getOperand(i).getFrameIndex();
- std::cerr
- << "Sorry, I don't know how to eliminate frame indices yet\n"
- << "Frame index was " << FrameIndex << ", in\n"
- << __FUNCTION__ << "() at " << __FILE__ << ":" << __LINE__ << "\n";
- abort();
+ // Replace frame index with a frame pointer reference
+ MI.SetMachineOperandReg (i, V8::FP);
+
+ // Addressable stack objects are accessed using neg. offsets from %fp
+ int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
+ MI.getOperand(i+1).getImmedValue();
+ // note: Offset < 0
+ MI.SetMachineOperandConst (i+1, MachineOperand::MO_SignExtendedImmed, Offset);
}
void SparcV8RegisterInfo::
@@ -99,7 +102,7 @@ void SparcV8RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineFrameInfo *MFI = MF.getFrameInfo();
// Get the number of bytes to allocate from the FrameInfo
- int NumBytes = (int) MFI->getStackSize();
+ int NumBytes = (int) MFI->getStackSize() + 4;
// Emit the correct save instruction based on the number of bytes in the frame.
// Minimum stack frame size according to V8 ABI is:
diff --git a/lib/Target/SparcV8/SparcV8RegisterInfo.cpp b/lib/Target/SparcV8/SparcV8RegisterInfo.cpp
index 8d74d8a..5ca69e0 100644
--- a/lib/Target/SparcV8/SparcV8RegisterInfo.cpp
+++ b/lib/Target/SparcV8/SparcV8RegisterInfo.cpp
@@ -33,7 +33,7 @@ int SparcV8RegisterInfo::storeRegToStackSlot(
assert (RC == SparcV8::IntRegsRegisterClass
&& "Can only store 32-bit values to stack slots");
MachineInstr *I =
- BuildMI (V8::STrm, 2).addFrameIndex (FrameIdx).addReg (SrcReg);
+ BuildMI (V8::STrm, 3).addFrameIndex (FrameIdx).addSImm (0).addReg (SrcReg);
MBB.insert(MBBI, I);
return 1;
}
@@ -47,7 +47,7 @@ int SparcV8RegisterInfo::loadRegFromStackSlot(
assert (RC == SparcV8::IntRegsRegisterClass
&& "Can only load 32-bit registers from stack slots");
MachineInstr *I =
- BuildMI (V8::LDmr, 2).addReg (DestReg).addFrameIndex (FrameIdx);
+ BuildMI (V8::LDmr, 2).addReg (DestReg).addFrameIndex (FrameIdx).addSImm (0);
MBB.insert(MBBI, I);
return 1;
}
@@ -84,11 +84,14 @@ SparcV8RegisterInfo::eliminateFrameIndex(MachineFunction &MF,
int FrameIndex = MI.getOperand(i).getFrameIndex();
- std::cerr
- << "Sorry, I don't know how to eliminate frame indices yet\n"
- << "Frame index was " << FrameIndex << ", in\n"
- << __FUNCTION__ << "() at " << __FILE__ << ":" << __LINE__ << "\n";
- abort();
+ // Replace frame index with a frame pointer reference
+ MI.SetMachineOperandReg (i, V8::FP);
+
+ // Addressable stack objects are accessed using neg. offsets from %fp
+ int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
+ MI.getOperand(i+1).getImmedValue();
+ // note: Offset < 0
+ MI.SetMachineOperandConst (i+1, MachineOperand::MO_SignExtendedImmed, Offset);
}
void SparcV8RegisterInfo::
@@ -99,7 +102,7 @@ void SparcV8RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineFrameInfo *MFI = MF.getFrameInfo();
// Get the number of bytes to allocate from the FrameInfo
- int NumBytes = (int) MFI->getStackSize();
+ int NumBytes = (int) MFI->getStackSize() + 4;
// Emit the correct save instruction based on the number of bytes in the frame.
// Minimum stack frame size according to V8 ABI is: