add support for calling functions when the caller has variable sized objects

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31312 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2006-10-31 13:03:26 +00:00
parent ab4022f196
commit b191e0ab51
2 changed files with 23 additions and 2 deletions

View File

@ -19,6 +19,8 @@
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Type.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/ADT/STLExtras.h"
#include <iostream>
@ -99,7 +101,23 @@ void ARMRegisterInfo::
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const {
if (hasFP(MF)) {
assert(0);
MachineInstr *Old = I;
unsigned Amount = Old->getOperand(0).getImmedValue();
if (Amount != 0) {
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
Amount = (Amount+Align-1)/Align*Align;
if (Old->getOpcode() == ARM::ADJCALLSTACKDOWN) {
// sub sp, sp, amount
BuildMI(MBB, I, ARM::SUB, 2, ARM::R13).addReg(ARM::R13).addImm(Amount)
.addImm(0).addImm(ARMShift::LSL);
} else {
// add sp, sp, amount
assert(Old->getOpcode() == ARM::ADJCALLSTACKUP);
BuildMI(MBB, I, ARM::ADD, 2, ARM::R13).addReg(ARM::R13).addImm(Amount)
.addImm(0).addImm(ARMShift::LSL);
}
}
}
MBB.erase(I);
}

View File

@ -1,6 +1,9 @@
; RUN: llvm-as < %s | llc -march=arm
void %f(uint %a) {
entry:
%tmp1032 = alloca ubyte, uint %a
%tmp = alloca sbyte, uint %a
call void %g( sbyte* %tmp, uint %a, uint 1, uint 2, uint 3 )
ret void
}
declare void %g(sbyte*, uint, uint, uint, uint)