llvm.org GIT mirror llvm / c1c7283
Prologue and epilogue bugs for non-Darwin targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33390 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 13 years ago
1 changed file(s) with 46 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
483483 // There is alloca()'s in this function, must reference off the frame
484484 // pointer instead.
485485 FrameReg = getFrameRegister(MF);
486 Offset -= AFI->getFramePtrSpillOffset();
486 if (STI.isTargetDarwin())
487 Offset -= AFI->getFramePtrSpillOffset();
487488 }
488489
489490 unsigned Opcode = MI.getOpcode();
723724 if (Spilled) {
724725 NumGPRSpills++;
725726
727 if (!STI.isTargetDarwin()) {
728 if (Reg == ARM::LR)
729 LRSpilled = true;
730 else
731 CS1Spilled = true;
732 continue;
733 }
734
726735 // Keep track if LR and any of R4, R5, R6, and R7 is spilled.
727736 switch (Reg) {
728737 case ARM::LR:
738747 break;
739748 }
740749 } else {
750 if (!STI.isTargetDarwin()) {
751 UnspilledCS1GPRs.push_back(Reg);
752 continue;
753 }
754
741755 switch (Reg) {
742756 case ARM::R4:
743757 case ARM::R5:
767781 UnspilledCS1GPRs.end(), (unsigned)ARM::LR));
768782 }
769783
770 // If stack and double are 8-byte aligned and we are spilling a odd number
784 if (STI.isTargetDarwin()) {
785 MF.changePhyRegUsed(FramePtr, true);
786 NumGPRSpills++;
787 }
788
789 // If stack and double are 8-byte aligned and we are spilling an odd number
771790 // of GPRs. Spill one extra callee save GPR so we won't have to pad between
772791 // the integer and double callee save areas.
773792 unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
774793 if (TargetAlign == 8 && (NumGPRSpills & 1)) {
775794 if (CS1Spilled && !UnspilledCS1GPRs.empty())
776795 MF.changePhyRegUsed(UnspilledCS1GPRs.front(), true);
777 else
796 else if (!UnspilledCS2GPRs.empty())
778797 MF.changePhyRegUsed(UnspilledCS2GPRs.front(), true);
779798 }
780 MF.changePhyRegUsed(FramePtr, true);
781799 }
782800 }
783801
870888 }
871889 }
872890
891 if (Align == 8 && (GPRCS1Size & 7) != 0)
892 // Pad CS1 to ensure proper alignment.
893 GPRCS1Size += 4;
894
873895 if (!isThumb) {
874896 // Build the new SUBri to adjust SP for integer callee-save spill area 1.
875897 emitSPUpdate(MBB, MBBI, -GPRCS1Size, isThumb, TII);
876898 movePastCSLoadStoreOps(MBB, MBBI, ARM::STR, 1, STI);
877 } else {
878 if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
879 ++MBBI;
880 }
899 } else if (MBBI != MBB.end() && MBBI->getOpcode() == ARM::tPUSH)
900 ++MBBI;
881901
882902 // Point FP to the stack slot that contains the previous FP.
883 BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
884 .addFrameIndex(FramePtrSpillFI).addImm(0);
903 if (STI.isTargetDarwin())
904 BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tADDrSPi : ARM::ADDri), FramePtr)
905 .addFrameIndex(FramePtrSpillFI).addImm(0);
885906
886907 if (!isThumb) {
887908 // Build the new SUBri to adjust SP for integer callee-save spill area 2.
976997 if (isThumb)
977998 emitSPUpdate(MBB, MBBI, -NumBytes, isThumb, TII);
978999 else {
979 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
980 // Reset SP based on frame pointer only if the stack frame extends beyond
981 // frame pointer stack slot.
982 if (AFI->getGPRCalleeSavedArea2Size() ||
983 AFI->getDPRCalleeSavedAreaSize() ||
984 AFI->getDPRCalleeSavedAreaOffset())
985 if (NumBytes)
986 BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
987 .addImm(NumBytes);
988 else
989 BuildMI(MBB, MBBI, TII.get(isThumb ? ARM::tMOVrr : ARM::MOVrr),
990 ARM::SP).addReg(FramePtr);
1000 if (STI.isTargetDarwin()) {
1001 NumBytes = AFI->getFramePtrSpillOffset() - NumBytes;
1002 // Reset SP based on frame pointer only if the stack frame extends beyond
1003 // frame pointer stack slot.
1004 if (AFI->getGPRCalleeSavedArea2Size() ||
1005 AFI->getDPRCalleeSavedAreaSize() ||
1006 AFI->getDPRCalleeSavedAreaOffset())
1007 if (NumBytes)
1008 BuildMI(MBB, MBBI, TII.get(ARM::SUBri), ARM::SP).addReg(FramePtr)
1009 .addImm(NumBytes);
1010 else
1011 BuildMI(MBB, MBBI, TII.get(ARM::MOVrr), ARM::SP).addReg(FramePtr);
1012 } else if (NumBytes) {
1013 emitSPUpdate(MBB, MBBI, NumBytes, false, TII);
1014 }
9911015
9921016 // Move SP to start of integer callee save spill area 2.
9931017 movePastCSLoadStoreOps(MBB, MBBI, ARM::FLDD, 3, STI);