[llvm] [GISel][RISCV]Implement indirect parameter passing (PR #95429)
Gábor Spaits via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 11:33:16 PDT 2024
================
@@ -845,30 +898,58 @@ bool CallLowering::handleAssignments(ValueHandler &Handler,
DstMPO, DstAlign, SrcMPO, SrcAlign,
MemSize, VA);
}
- continue;
- }
-
- assert(!VA.needsCustom() && "custom loc should have been handled already");
-
- if (i == 0 && !ThisReturnRegs.empty() &&
- Handler.isIncomingArgumentHandler() &&
- isTypeIsValidForThisReturn(ValVT)) {
+ } else if (i == 0 && !ThisReturnRegs.empty() &&
+ Handler.isIncomingArgumentHandler() &&
+ isTypeIsValidForThisReturn(ValVT)) {
Handler.assignValueToReg(ArgReg, ThisReturnRegs[Part], VA);
- continue;
- }
-
- if (Handler.isIncomingArgumentHandler())
+ } else if (Handler.isIncomingArgumentHandler()) {
Handler.assignValueToReg(ArgReg, VA.getLocReg(), VA);
- else {
+ } else {
DelayedOutgoingRegAssignments.emplace_back([=, &Handler]() {
Handler.assignValueToReg(ArgReg, VA.getLocReg(), VA);
});
}
+
+ // Finish the handling of indirect parameter passing when receiving
+ // the value (we are in the called function or the caller when receiving
+ // the return value).
+ if (VA.getLocInfo() == CCValAssign::Indirect &&
+ Handler.isIncomingArgumentHandler()) {
+ Align Alignment = DL.getABITypeAlign(Args[i].Ty);
+ MachinePointerInfo MPO;
+
+ if (VA.isMemLoc()) {
+ if (!Flags.isByRef()) {
+ LLT MemTy = Handler.getStackValueStoreType(DL, VA, Flags);
+ Handler.getStackAddress(
+ MemTy.getSizeInBytes(), VA.getLocMemOffset(), MPO, Flags);
+ } else {
+ uint64_t MemSize = Flags.getByValSize();
+ int64_t Offset = VA.getLocMemOffset();
+
+ Handler.getStackAddress(MemSize, Offset, MPO, Flags);
----------------
spaits wrote:
Yes I have looked at the implementation too, there are multiple targets and multiple target handlers that implement this and they all do this to set this, so it would make sense to replace it with the concrete setting of this variable, but in the current form, if a target decides to change how it wants to set the MPO it can.
The question is basically that, whether in the future will there be a target, that needs to set MPO differently for the stack address?
I don't know how likely it is that there will be.
https://github.com/llvm/llvm-project/pull/95429
More information about the llvm-commits
mailing list