[llvm-commits] [llvm] r42700 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
Anton Korobeynikov
asl at math.spbu.ru
Sat Oct 6 09:39:43 PDT 2007
Author: asl
Date: Sat Oct 6 11:39:43 2007
New Revision: 42700
URL: http://llvm.org/viewvc/llvm-project?rev=42700&view=rev
Log:
Oops, I really wanted to commit this part also :)
Modified:
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=42700&r1=42699&r2=42700&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Sat Oct 6 11:39:43 2007
@@ -1500,6 +1500,31 @@
}
}
+// mergeSPUpdatesUp - Merge two stack-manipulating instructions lower iterator.
+static
+void mergeSPUpdatesDown(MachineBasicBlock &MBB,MachineBasicBlock::iterator &MBBI,
+ unsigned StackPtr, uint64_t *NumBytes = NULL) {
+ if (MBBI != MBB.end()) {
+ MachineBasicBlock::iterator NI = next(MBBI);
+ unsigned Opc = NI->getOpcode();
+ if ((Opc == X86::ADD64ri32 || Opc == X86::ADD64ri8 ||
+ Opc == X86::ADD32ri || Opc == X86::ADD32ri8) &&
+ NI->getOperand(0).getReg() == StackPtr) {
+ if (NumBytes)
+ *NumBytes -= NI->getOperand(2).getImm();
+ MBB.erase(NI);
+ MBBI = NI;
+ } else if ((Opc == X86::SUB64ri32 || Opc == X86::SUB64ri8 ||
+ Opc == X86::SUB32ri || Opc == X86::SUB32ri8) &&
+ NI->getOperand(0).getReg() == StackPtr) {
+ if (NumBytes)
+ *NumBytes += NI->getOperand(2).getImm();
+ MBB.erase(NI);
+ MBBI = NI;
+ }
+ }
+}
+
void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
MachineFrameInfo *MFI = MF.getFrameInfo();
@@ -1585,9 +1610,9 @@
MBB.insert(MBBI, MI);
}
} else {
- // If there is an ADD32ri or SUB32ri of ESP immediately before this
+ // If there is an ADD32ri or SUB32ri of ESP immediately after this
// instruction, merge the two instructions.
- mergeSPUpdatesUp(MBB, MBBI, StackPtr, &NumBytes);
+ mergeSPUpdatesDown(MBB, MBBI, StackPtr, &NumBytes);
if (NumBytes)
emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII);
More information about the llvm-commits
mailing list