1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

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

llvm-svn: 31312
This commit is contained in:
Rafael Espindola 2006-10-31 13:03:26 +00:00
parent e6ba8a819c
commit ba8771a3db
2 changed files with 23 additions and 2 deletions

View File

@ -19,6 +19,8 @@
#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineLocation.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetOptions.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include <iostream> #include <iostream>
@ -99,7 +101,23 @@ void ARMRegisterInfo::
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const { MachineBasicBlock::iterator I) const {
if (hasFP(MF)) { 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); MBB.erase(I);
} }

View File

@ -1,6 +1,9 @@
; RUN: llvm-as < %s | llc -march=arm ; RUN: llvm-as < %s | llc -march=arm
void %f(uint %a) { void %f(uint %a) {
entry: 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 ret void
} }
declare void %g(sbyte*, uint, uint, uint, uint)