summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 14:33:52 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 14:33:52 +0000
commit7fa0ce1a21963a6c043e77dfb03b01512b0b5833 (patch)
tree627363c82724c01a4be284d0b1fc28a7547f5bd4 /llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
parent30e1cb2ab9014a5ba09a8e895f1a4e3ec760645d (diff)
downloadbcm5719-llvm-7fa0ce1a21963a6c043e77dfb03b01512b0b5833.tar.gz
bcm5719-llvm-7fa0ce1a21963a6c043e77dfb03b01512b0b5833.zip
Handle long-disp stuff more consistently
llvm-svn: 76059
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
index c829e43fb17..643d681563d 100644
--- a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
@@ -133,8 +133,7 @@ void SystemZRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
int Offset = getFrameIndexOffset(MF, FrameIndex) + MI.getOperand(i+1).getImm();
// Check whether displacement is too long to fit into 12 bit zext field.
- if (Offset < 0 || Offset >= 4096)
- MI.setDesc(TII.getLongDispOpc(MI.getOpcode()));
+ MI.setDesc(TII.getMemoryInstr(MI.getOpcode(), Offset));
MI.getOperand(i+1).ChangeToImmediate(Offset);
}
@@ -179,11 +178,18 @@ SystemZRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
static
void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI,
int64_t NumBytes, const TargetInstrInfo &TII) {
- // FIXME: Handle different stack sizes here.
+ unsigned Opc; uint64_t Chunk;
bool isSub = NumBytes < 0;
uint64_t Offset = isSub ? -NumBytes : NumBytes;
- unsigned Opc = SystemZ::ADD64ri16;
- uint64_t Chunk = (1LL << 15) - 1;
+
+ if (Offset >= (1LL << 15) - 1) {
+ Opc = SystemZ::ADD64ri32;
+ Chunk = (1LL << 31) - 1;
+ } else {
+ Opc = SystemZ::ADD64ri16;
+ Chunk = (1LL << 15) - 1;
+ }
+
DebugLoc DL = (MBBI != MBB.end() ? MBBI->getDebugLoc() :
DebugLoc::getUnknownLoc());
@@ -293,7 +299,17 @@ void SystemZRegisterInfo::emitEpilogue(MachineFunction &MF,
assert(i < MI.getNumOperands() && "Unexpected restore code!");
}
- MI.getOperand(i).ChangeToImmediate(NumBytes + MI.getOperand(i).getImm());
+ uint64_t Offset = NumBytes + MI.getOperand(i).getImm();
+ // If Offset does not fit into 20-bit signed displacement field we need to
+ // emit some additional code...
+ if (Offset > 524287) {
+ // Fold the displacement into load instruction as much as possible.
+ NumBytes = Offset - 524287;
+ Offset = 524287;
+ emitSPUpdate(MBB, MBBI, NumBytes, TII);
+ }
+
+ MI.getOperand(i).ChangeToImmediate(Offset);
}
}
OpenPOWER on IntegriCloud