Skip to content

Commit d8f796b

Browse files
authored
[RISC-V] Add RiscV64 arch to tests/JIT/Stress/ABI/ (#103830)
1 parent 8e92aef commit d8f796b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/tests/JIT/Stress/ABI/ABIs.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,34 @@ public int ApproximateArgStackAreaSize(List<TypeEx> parameters)
186186
return size;
187187
}
188188
}
189+
190+
internal class Riscv64Abi : IAbi
191+
{
192+
// For Riscv64 structs larger than 16 bytes are passed by-ref and will
193+
// inhibit tailcalls, so we exclude those.
194+
public Type[] TailCalleeCandidateArgTypes { get; } =
195+
new[]
196+
{
197+
typeof(byte), typeof(short), typeof(int), typeof(long),
198+
typeof(float), typeof(double), typeof(Int128),
199+
typeof(Vector<int>), typeof(Vector128<int>),
200+
typeof(S1P), typeof(S2P), typeof(S2U), typeof(S3U),
201+
typeof(S4P), typeof(S4U), typeof(S5U), typeof(S6U),
202+
typeof(S7U), typeof(S8P), typeof(S8U), typeof(S9U),
203+
typeof(S10U), typeof(S11U), typeof(S12U), typeof(S13U),
204+
typeof(S14U), typeof(S15U), typeof(S16U),
205+
typeof(Hfa1), typeof(I128_1)
206+
};
207+
208+
public CallingConvention[] PInvokeConventions { get; } = { CallingConvention.Cdecl };
209+
210+
public int ApproximateArgStackAreaSize(List<TypeEx> parameters)
211+
{
212+
int size = 0;
213+
foreach (TypeEx pm in parameters)
214+
size += Util.RoundUp(pm.Size, 8);
215+
216+
return size;
217+
}
218+
}
189219
}

src/tests/JIT/Stress/ABI/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,11 @@ private static IAbi SelectAbi()
408408
Console.WriteLine("Selecting armhf ABI.");
409409
return new Arm32Abi();
410410
}
411+
if (RuntimeInformation.ProcessArchitecture == Architecture.RiscV64)
412+
{
413+
Console.WriteLine("Selecting riscv64 ABI.");
414+
return new Riscv64Abi();
415+
}
411416

412417
Trace.Assert(RuntimeInformation.ProcessArchitecture == Architecture.X64);
413418
Console.WriteLine("Selecting SysV ABI");

0 commit comments

Comments
 (0)