mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
[ARM] GlobalISel: Lower calls to void() functions
For now, we hardcode a BLX instruction, and generate an ADJCALLSTACKDOWN/UP pair with amount 0. llvm-svn: 295716
This commit is contained in:
parent
4666520529
commit
eff0bb64c9
@ -304,3 +304,38 @@ bool ARMCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
|
||||
AssignFn);
|
||||
return handleAssignments(MIRBuilder, ArgInfos, ArgHandler);
|
||||
}
|
||||
|
||||
bool ARMCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
|
||||
const MachineOperand &Callee,
|
||||
const ArgInfo &OrigRet,
|
||||
ArrayRef<ArgInfo> OrigArgs) const {
|
||||
const MachineFunction &MF = MIRBuilder.getMF();
|
||||
const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
|
||||
|
||||
if (MF.getSubtarget<ARMSubtarget>().genLongCalls())
|
||||
return false;
|
||||
|
||||
// FIXME: Support calling functions with arguments.
|
||||
if (OrigArgs.size() > 0)
|
||||
return false;
|
||||
|
||||
// FIXME: Support calling functions with return types.
|
||||
if (!OrigRet.Ty->isVoidTy())
|
||||
return false;
|
||||
|
||||
MIRBuilder.buildInstr(ARM::ADJCALLSTACKDOWN)
|
||||
.addImm(0)
|
||||
.add(predOps(ARMCC::AL));
|
||||
|
||||
MIRBuilder.buildInstr(ARM::BLX)
|
||||
.add(Callee)
|
||||
// FIXME: Don't hardcode the calling conv here...
|
||||
.addRegMask(TRI->getCallPreservedMask(MF, CallingConv::ARM_AAPCS));
|
||||
|
||||
MIRBuilder.buildInstr(ARM::ADJCALLSTACKUP)
|
||||
.addImm(0)
|
||||
.addImm(0)
|
||||
.add(predOps(ARMCC::AL));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public:
|
||||
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
|
||||
ArrayRef<unsigned> VRegs) const override;
|
||||
|
||||
bool lowerCall(MachineIRBuilder &MIRBuilder, const MachineOperand &Callee,
|
||||
const ArgInfo &OrigRet,
|
||||
ArrayRef<ArgInfo> OrigArgs) const override;
|
||||
|
||||
private:
|
||||
bool lowerReturnVal(MachineIRBuilder &MIRBuilder, const Value *Val,
|
||||
unsigned VReg, MachineInstrBuilder &Ret) const;
|
||||
|
@ -335,3 +335,26 @@ entry:
|
||||
%v = fadd double %p0, %p1
|
||||
ret double %v
|
||||
}
|
||||
|
||||
define arm_aapcscc void @test_indirect_call(void() *%fptr) {
|
||||
; CHECK-LABEL: name: test_indirect_call
|
||||
; CHECK: [[FPTR:%[0-9]+]](p0) = COPY %r0
|
||||
; CHECK: ADJCALLSTACKDOWN 0, 14, _, implicit-def %sp, implicit %sp
|
||||
; CHECK: BLX [[FPTR]](p0), csr_aapcs, implicit-def %lr, implicit %sp
|
||||
; CHECK: ADJCALLSTACKUP 0, 0, 14, _, implicit-def %sp, implicit %sp
|
||||
entry:
|
||||
notail call arm_aapcscc void %fptr()
|
||||
ret void
|
||||
}
|
||||
|
||||
declare arm_aapcscc void @call_target()
|
||||
|
||||
define arm_aapcscc void @test_direct_call() {
|
||||
; CHECK-LABEL: name: test_direct_call
|
||||
; CHECK: ADJCALLSTACKDOWN 0, 14, _, implicit-def %sp, implicit %sp
|
||||
; CHECK: BLX @call_target, csr_aapcs, implicit-def %lr, implicit %sp
|
||||
; CHECK: ADJCALLSTACKUP 0, 0, 14, _, implicit-def %sp, implicit %sp
|
||||
entry:
|
||||
notail call arm_aapcscc void @call_target()
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user