Skip to content

Commit

Permalink
Classify stack arguments as single segment (dotnet#103619)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeksowi authored Jun 18, 2024
1 parent b2ccd98 commit aa0a7e9
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/coreclr/jit/targetriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,38 @@ ABIPassingInformation RiscV64Classifier::Classify(Compiler* comp,
else
{
// Integer calling convention
auto passSlot = [this](unsigned offset, unsigned size) -> ABIPassingSegment {
auto passOnStack = [this](unsigned offset, unsigned size) -> ABIPassingSegment {
assert(size > 0);
assert(size <= TARGET_POINTER_SIZE);
if (m_intRegs.Count() > 0)
assert(size <= 2 * TARGET_POINTER_SIZE);
assert((m_stackArgSize % TARGET_POINTER_SIZE) == 0);
ABIPassingSegment seg = ABIPassingSegment::OnStack(m_stackArgSize, offset, size);
m_stackArgSize += (size > TARGET_POINTER_SIZE) ? (2 * TARGET_POINTER_SIZE) : TARGET_POINTER_SIZE;
return seg;
};

if (m_intRegs.Count() > 0)
{
if (passedSize <= TARGET_POINTER_SIZE)
{
return ABIPassingSegment::InRegister(m_intRegs.Dequeue(), offset, size);
ABIPassingSegment seg = ABIPassingSegment::InRegister(m_intRegs.Dequeue(), 0, passedSize);
return ABIPassingInformation::FromSegment(comp, seg);
}
else
{
assert((m_stackArgSize % TARGET_POINTER_SIZE) == 0);
ABIPassingSegment seg = ABIPassingSegment::OnStack(m_stackArgSize, offset, size);
m_stackArgSize += TARGET_POINTER_SIZE;
return seg;
assert(varTypeIsStruct(type));
unsigned int tailSize = passedSize - TARGET_POINTER_SIZE;

ABIPassingSegment head = ABIPassingSegment::InRegister(m_intRegs.Dequeue(), 0, TARGET_POINTER_SIZE);
ABIPassingSegment tail =
(m_intRegs.Count() > 0)
? ABIPassingSegment::InRegister(m_intRegs.Dequeue(), TARGET_POINTER_SIZE, tailSize)
: passOnStack(TARGET_POINTER_SIZE, tailSize);
return {2, new (comp, CMK_ABI) ABIPassingSegment[2]{head, tail}};
}
};

if (passedSize <= TARGET_POINTER_SIZE)
{
return ABIPassingInformation::FromSegment(comp, passSlot(0, passedSize));
}
else
{
assert(varTypeIsStruct(type));
return {2, new (comp, CMK_ABI)
ABIPassingSegment[2]{passSlot(0, TARGET_POINTER_SIZE),
passSlot(TARGET_POINTER_SIZE, passedSize - TARGET_POINTER_SIZE)}};
return ABIPassingInformation::FromSegment(comp, passOnStack(0, passedSize));
}
}
}
Expand Down

0 comments on commit aa0a7e9

Please sign in to comment.