aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs')
-rw-r--r--ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs110
1 files changed, 110 insertions, 0 deletions
diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
index 989b470e..abe47d74 100644
--- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
+++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
@@ -248,6 +248,56 @@ namespace ChocolArm64.Instruction
EmitScalarSetF(Context, Op.Rd, SizeF);
}
+ public static void Frinti_S(AILEmitterCtx Context)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ EmitScalarUnaryOpF(Context, () =>
+ {
+ Context.EmitLdarg(ATranslatedSub.StateArgIdx);
+
+ Context.EmitCallPropGet(typeof(AThreadState), nameof(AThreadState.Fpcr));
+
+ if (Op.Size == 0)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.RoundF));
+ }
+ else if (Op.Size == 1)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Round));
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+ });
+ }
+
+ public static void Frinti_V(AILEmitterCtx Context)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ EmitVectorUnaryOpF(Context, () =>
+ {
+ Context.EmitLdarg(ATranslatedSub.StateArgIdx);
+
+ Context.EmitCallPropGet(typeof(AThreadState), nameof(AThreadState.Fpcr));
+
+ if (Op.Size == 2)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.RoundF));
+ }
+ else if (Op.Size == 3)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Round));
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+ });
+ }
+
public static void Frinta_S(AILEmitterCtx Context)
{
AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
@@ -259,6 +309,14 @@ namespace ChocolArm64.Instruction
EmitScalarSetF(Context, Op.Rd, Op.Size);
}
+ public static void Frinta_V(AILEmitterCtx Context)
+ {
+ EmitVectorUnaryOpF(Context, () =>
+ {
+ EmitRoundMathCall(Context, MidpointRounding.AwayFromZero);
+ });
+ }
+
public static void Frintm_S(AILEmitterCtx Context)
{
EmitScalarUnaryOpF(Context, () =>
@@ -275,6 +333,25 @@ namespace ChocolArm64.Instruction
});
}
+ public static void Frintn_S(AILEmitterCtx Context)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ EmitVectorExtractF(Context, Op.Rn, 0, Op.Size);
+
+ EmitRoundMathCall(Context, MidpointRounding.ToEven);
+
+ EmitScalarSetF(Context, Op.Rd, Op.Size);
+ }
+
+ public static void Frintn_V(AILEmitterCtx Context)
+ {
+ EmitVectorUnaryOpF(Context, () =>
+ {
+ EmitRoundMathCall(Context, MidpointRounding.ToEven);
+ });
+ }
+
public static void Frintp_S(AILEmitterCtx Context)
{
EmitScalarUnaryOpF(Context, () =>
@@ -283,6 +360,14 @@ namespace ChocolArm64.Instruction
});
}
+ public static void Frintp_V(AILEmitterCtx Context)
+ {
+ EmitVectorUnaryOpF(Context, () =>
+ {
+ EmitUnaryMathCall(Context, nameof(Math.Ceiling));
+ });
+ }
+
public static void Frintx_S(AILEmitterCtx Context)
{
AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
@@ -308,6 +393,31 @@ namespace ChocolArm64.Instruction
});
}
+ public static void Frintx_V(AILEmitterCtx Context)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ EmitVectorUnaryOpF(Context, () =>
+ {
+ Context.EmitLdarg(ATranslatedSub.StateArgIdx);
+
+ Context.EmitCallPropGet(typeof(AThreadState), nameof(AThreadState.Fpcr));
+
+ if (Op.Size == 0)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.RoundF));
+ }
+ else if (Op.Size == 1)
+ {
+ ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Round));
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+ });
+ }
+
public static void Fsqrt_S(AILEmitterCtx Context)
{
EmitScalarUnaryOpF(Context, () =>