@@ -138,32 +138,38 @@ ABIPassingInformation RiscV64Classifier::Classify(Compiler* comp,
138
138
else
139
139
{
140
140
// Integer calling convention
141
- auto passSlot = [this ](unsigned offset, unsigned size) -> ABIPassingSegment {
141
+ auto passOnStack = [this ](unsigned offset, unsigned size) -> ABIPassingSegment {
142
142
assert (size > 0 );
143
- assert (size <= TARGET_POINTER_SIZE);
144
- if (m_intRegs.Count () > 0 )
143
+ assert (size <= 2 * TARGET_POINTER_SIZE);
144
+ assert ((m_stackArgSize % TARGET_POINTER_SIZE) == 0 );
145
+ ABIPassingSegment seg = ABIPassingSegment::OnStack (m_stackArgSize, offset, size);
146
+ m_stackArgSize += (size > TARGET_POINTER_SIZE) ? (2 * TARGET_POINTER_SIZE) : TARGET_POINTER_SIZE;
147
+ return seg;
148
+ };
149
+
150
+ if (m_intRegs.Count () > 0 )
151
+ {
152
+ if (passedSize <= TARGET_POINTER_SIZE)
145
153
{
146
- return ABIPassingSegment::InRegister (m_intRegs.Dequeue (), offset, size);
154
+ ABIPassingSegment seg = ABIPassingSegment::InRegister (m_intRegs.Dequeue (), 0 , passedSize);
155
+ return ABIPassingInformation::FromSegment (comp, seg);
147
156
}
148
157
else
149
158
{
150
- assert ((m_stackArgSize % TARGET_POINTER_SIZE) == 0 );
151
- ABIPassingSegment seg = ABIPassingSegment::OnStack (m_stackArgSize, offset, size);
152
- m_stackArgSize += TARGET_POINTER_SIZE;
153
- return seg;
159
+ assert (varTypeIsStruct (type));
160
+ unsigned int tailSize = passedSize - TARGET_POINTER_SIZE;
161
+
162
+ ABIPassingSegment head = ABIPassingSegment::InRegister (m_intRegs.Dequeue (), 0 , TARGET_POINTER_SIZE);
163
+ ABIPassingSegment tail =
164
+ (m_intRegs.Count () > 0 )
165
+ ? ABIPassingSegment::InRegister (m_intRegs.Dequeue (), TARGET_POINTER_SIZE, tailSize)
166
+ : passOnStack (TARGET_POINTER_SIZE, tailSize);
167
+ return {2 , new (comp, CMK_ABI) ABIPassingSegment[2 ]{head, tail}};
154
168
}
155
- };
156
-
157
- if (passedSize <= TARGET_POINTER_SIZE)
158
- {
159
- return ABIPassingInformation::FromSegment (comp, passSlot (0 , passedSize));
160
169
}
161
170
else
162
171
{
163
- assert (varTypeIsStruct (type));
164
- return {2 , new (comp, CMK_ABI)
165
- ABIPassingSegment[2 ]{passSlot (0 , TARGET_POINTER_SIZE),
166
- passSlot (TARGET_POINTER_SIZE, passedSize - TARGET_POINTER_SIZE)}};
172
+ return ABIPassingInformation::FromSegment (comp, passOnStack (0 , passedSize));
167
173
}
168
174
}
169
175
}
0 commit comments