aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs')
-rw-r--r--src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs
index bec36e2d..dcdcc65d 100644
--- a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs
+++ b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs
@@ -5,7 +5,6 @@ using ARMeilleure.Translation;
using System;
using System.Diagnostics;
using System.Reflection;
-
using static ARMeilleure.Instructions.InstEmitHelper;
using static ARMeilleure.Instructions.InstEmitSimdHelper;
using static ARMeilleure.Instructions.InstEmitSimdHelper32;
@@ -217,33 +216,22 @@ namespace ARMeilleure.Instructions
string name = nameof(Math.Round);
MethodInfo info = (op.Size & 1) == 0
- ? typeof(MathF).GetMethod(name, new Type[] { typeof(float), typeof(MidpointRounding) })
- : typeof(Math). GetMethod(name, new Type[] { typeof(double), typeof(MidpointRounding) });
+ ? typeof(MathF).GetMethod(name, new Type[] { typeof(float), typeof(MidpointRounding) })
+ : typeof(Math).GetMethod(name, new Type[] { typeof(double), typeof(MidpointRounding) });
return context.Call(info, n, Const((int)roundMode));
}
private static FPRoundingMode RMToRoundMode(int rm)
{
- FPRoundingMode roundMode;
- switch (rm)
- {
- case 0b00:
- roundMode = FPRoundingMode.ToNearestAway;
- break;
- case 0b01:
- roundMode = FPRoundingMode.ToNearest;
- break;
- case 0b10:
- roundMode = FPRoundingMode.TowardsPlusInfinity;
- break;
- case 0b11:
- roundMode = FPRoundingMode.TowardsMinusInfinity;
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(rm));
- }
- return roundMode;
+ return rm switch
+ {
+ 0b00 => FPRoundingMode.ToNearestAway,
+ 0b01 => FPRoundingMode.ToNearest,
+ 0b10 => FPRoundingMode.TowardsPlusInfinity,
+ 0b11 => FPRoundingMode.TowardsMinusInfinity,
+ _ => throw new ArgumentOutOfRangeException(nameof(rm)),
+ };
}
// VCVTA/M/N/P (floating-point).
@@ -270,22 +258,24 @@ namespace ARMeilleure.Instructions
if (unsigned)
{
- inst = rm switch {
+ inst = rm switch
+ {
0b00 => Intrinsic.Arm64FcvtauGp,
0b01 => Intrinsic.Arm64FcvtnuGp,
0b10 => Intrinsic.Arm64FcvtpuGp,
0b11 => Intrinsic.Arm64FcvtmuGp,
- _ => throw new ArgumentOutOfRangeException(nameof(rm))
+ _ => throw new InvalidOperationException($"{nameof(rm)} contains an invalid value: {rm}"),
};
}
else
{
- inst = rm switch {
+ inst = rm switch
+ {
0b00 => Intrinsic.Arm64FcvtasGp,
0b01 => Intrinsic.Arm64FcvtnsGp,
0b10 => Intrinsic.Arm64FcvtpsGp,
0b11 => Intrinsic.Arm64FcvtmsGp,
- _ => throw new ArgumentOutOfRangeException(nameof(rm))
+ _ => throw new InvalidOperationException($"{nameof(rm)} contains an invalid value: {rm}"),
};
}
@@ -297,22 +287,24 @@ namespace ARMeilleure.Instructions
{
if (unsigned)
{
- inst = rm switch {
+ inst = rm switch
+ {
0b00 => Intrinsic.Arm64FcvtauS,
0b01 => Intrinsic.Arm64FcvtnuS,
0b10 => Intrinsic.Arm64FcvtpuS,
0b11 => Intrinsic.Arm64FcvtmuS,
- _ => throw new ArgumentOutOfRangeException(nameof(rm))
+ _ => throw new InvalidOperationException($"{nameof(rm)} contains an invalid value: {rm}"),
};
}
else
{
- inst = rm switch {
+ inst = rm switch
+ {
0b00 => Intrinsic.Arm64FcvtasS,
0b01 => Intrinsic.Arm64FcvtnsS,
0b10 => Intrinsic.Arm64FcvtpsS,
0b11 => Intrinsic.Arm64FcvtmsS,
- _ => throw new ArgumentOutOfRangeException(nameof(rm))
+ _ => throw new InvalidOperationException($"{nameof(rm)} contains an invalid value: {rm}"),
};
}
@@ -432,12 +424,13 @@ namespace ARMeilleure.Instructions
if (Optimizations.UseAdvSimd)
{
- Intrinsic inst = rm switch {
+ Intrinsic inst = rm switch
+ {
0b00 => Intrinsic.Arm64FrintaS,
0b01 => Intrinsic.Arm64FrintnS,
0b10 => Intrinsic.Arm64FrintpS,
0b11 => Intrinsic.Arm64FrintmS,
- _ => throw new ArgumentOutOfRangeException(nameof(rm))
+ _ => throw new InvalidOperationException($"{nameof(rm)} contains an invalid value: {rm}"),
};
InstEmitSimdHelper32Arm64.EmitScalarUnaryOpF32(context, inst);