diff options
author | Diana Picus <diana.picus@linaro.org> | 2017-03-01 15:35:14 +0000 |
---|---|---|
committer | Diana Picus <diana.picus@linaro.org> | 2017-03-01 15:35:14 +0000 |
commit | 9c52309b372137479b872b88daff5ffd135f4bf7 (patch) | |
tree | 0b0c3fa539d741cabc8d626bac6a2067788e4df0 /llvm/lib/Target/ARM/ARMCallLowering.cpp | |
parent | 88a1b8b4660481114428c6aed377f7c546195207 (diff) | |
download | bcm5719-llvm-9c52309b372137479b872b88daff5ffd135f4bf7.tar.gz bcm5719-llvm-9c52309b372137479b872b88daff5ffd135f4bf7.zip |
[ARM] GlobalISel: Lower call params that need extensions
Lower i1, i8 and i16 call parameters by extending them before storing them on
the stack. Also make sure we encode the correct, extended size in the
corresponding memory operand, and that we compute the correct stack size in the
end.
The latter is a bit more complicated because we used to compute the stack size
in the getStackAddress method, based on the Size and Offset of the parameters.
However, if the last parameter is sign extended, we'd be using the wrong,
non-extended size, and we'd end up with a smaller stack than we need to hold the
extended value. Instead of hacking this up based on the value of Size in
getStackAddress, we move our stack size handling logic to assignArg, where we
have access to the CCState which knows everything we could possibly want to know
about the stack. This way we don't need to duplicate any knowledge or resort to
any ugly hacks.
On this same occasion, update the IRTranslator test to check the sizes of the
stores everywhere, not just for sign extended paramteres.
llvm-svn: 296631
Diffstat (limited to 'llvm/lib/Target/ARM/ARMCallLowering.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMCallLowering.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/Target/ARM/ARMCallLowering.cpp b/llvm/lib/Target/ARM/ARMCallLowering.cpp index a827fd9de19..4731cbbe0f0 100644 --- a/llvm/lib/Target/ARM/ARMCallLowering.cpp +++ b/llvm/lib/Target/ARM/ARMCallLowering.cpp @@ -57,8 +57,7 @@ struct OutgoingValueHandler : public CallLowering::ValueHandler { unsigned getStackAddress(uint64_t Size, int64_t Offset, MachinePointerInfo &MPO) override { - // FIXME: Support smaller sizes (which may require extensions). - assert((Size == 4 || Size == 8) && "Unsupported size"); + assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) && "Unsupported size"); LLT p0 = LLT::pointer(0, 32); LLT s32 = LLT::scalar(32); @@ -72,7 +71,6 @@ struct OutgoingValueHandler : public CallLowering::ValueHandler { MIRBuilder.buildGEP(AddrReg, SPReg, OffsetReg); MPO = MachinePointerInfo::getStack(MIRBuilder.getMF(), Offset); - StackSize = std::max(StackSize, Size + Offset); return AddrReg; } @@ -91,12 +89,14 @@ struct OutgoingValueHandler : public CallLowering::ValueHandler { void assignValueToAddress(unsigned ValVReg, unsigned Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA) override { - // FIXME: Support smaller sizes (which may require extensions). - assert((Size == 4 || Size == 8) && "Unsupported size"); + assert((Size == 1 || Size == 2 || Size == 4 || Size == 8) && + "Unsupported size"); + unsigned ExtReg = extendRegister(ValVReg, VA); auto MMO = MIRBuilder.getMF().getMachineMemOperand( - MPO, MachineMemOperand::MOStore, Size, /* Alignment */ 0); - MIRBuilder.buildStore(ValVReg, Addr, *MMO); + MPO, MachineMemOperand::MOStore, VA.getLocVT().getStoreSize(), + /* Alignment */ 0); + MIRBuilder.buildStore(ExtReg, Addr, *MMO); } unsigned assignCustomValue(const CallLowering::ArgInfo &Arg, @@ -130,6 +130,17 @@ struct OutgoingValueHandler : public CallLowering::ValueHandler { return 1; } + bool assignArg(unsigned ValNo, MVT ValVT, MVT LocVT, + CCValAssign::LocInfo LocInfo, const CallLowering::ArgInfo &Info, + CCState &State) override { + if (AssignFn(ValNo, ValVT, LocVT, LocInfo, Info.Flags, State)) + return true; + + StackSize = std::max(StackSize, + static_cast<uint64_t>(State.getNextStackOffset())); + return false; + } + MachineInstrBuilder &MIB; uint64_t StackSize; }; |