From b191e0ab51174cfb86502308f520f139daa9e4a0 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 31 Oct 2006 13:03:26 +0000 Subject: [PATCH] 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 --- lib/Target/ARM/ARMRegisterInfo.cpp | 20 +++++++++++++++++++- test/CodeGen/ARM/alloca.ll | 5 ++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp index 885c5a7b9eb..817c9faf451 100644 --- a/lib/Target/ARM/ARMRegisterInfo.cpp +++ b/lib/Target/ARM/ARMRegisterInfo.cpp @@ -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 @@ -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); } diff --git a/test/CodeGen/ARM/alloca.ll b/test/CodeGen/ARM/alloca.ll index d5510d3e51f..b77f234e108 100644 --- a/test/CodeGen/ARM/alloca.ll +++ b/test/CodeGen/ARM/alloca.ll @@ -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) -- 2.34.1