aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Instructions/SoftFallback.cs
diff options
context:
space:
mode:
authorLDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>2022-09-09 00:40:41 +0200
committerGitHub <noreply@github.com>2022-09-08 19:40:41 -0300
commit7baa08dcb4b38fe36bb19bf84b3fcd386d143463 (patch)
treebfbbd817e56b3d47a1ca9662bf0c69c0119ddd58 /ARMeilleure/Instructions/SoftFallback.cs
parent408bd63b08cbde8ba55bb05a39868271a9e40ba4 (diff)
Implemented in IR the managed methods of the Saturating region ... (#3665)1.1.252
* Implemented in IR the managed methods of the Saturating region ... ... of the SoftFallback class (the SatQ ones). The need to natively manage the Fpcr and Fpsr system registers is still a fact. Contributes to https://github.com/Ryujinx/Ryujinx/issues/2917 ; I will open another PR to implement in Intrinsics-branchless the methods of the Saturation region as well (the SatXXXToXXX ones). All instructions involved have been tested locally in both release and debug modes, in both lowcq and highcq. * Ptc.InternalVersion = 3665 * Addressed PR feedback.
Diffstat (limited to 'ARMeilleure/Instructions/SoftFallback.cs')
-rw-r--r--ARMeilleure/Instructions/SoftFallback.cs257
1 files changed, 4 insertions, 253 deletions
diff --git a/ARMeilleure/Instructions/SoftFallback.cs b/ARMeilleure/Instructions/SoftFallback.cs
index f83afc16..829dd37a 100644
--- a/ARMeilleure/Instructions/SoftFallback.cs
+++ b/ARMeilleure/Instructions/SoftFallback.cs
@@ -91,7 +91,7 @@ namespace ARMeilleure.Instructions
}
else /* if (eSize != 64) */
{
- return SignedSrcSignedDstSatQ(value << shiftLsB, size);
+ return SignedSrcSignedDstSatQ(value << shiftLsB, size); // InstEmitSimdHelper.EmitSignedSrcSatQ(signedDst: true).
}
}
else /* if (shiftLsB == 0) */
@@ -135,7 +135,7 @@ namespace ARMeilleure.Instructions
}
else /* if (eSize != 64) */
{
- return UnsignedSrcUnsignedDstSatQ(value << shiftLsB, size);
+ return UnsignedSrcUnsignedDstSatQ(value << shiftLsB, size); // InstEmitSimdHelper.EmitUnsignedSrcSatQ(signedDst: false).
}
}
else /* if (shiftLsB == 0) */
@@ -509,7 +509,7 @@ namespace ARMeilleure.Instructions
#endregion
#region "Saturating"
- public static long SignedSrcSignedDstSatQ(long op, int size)
+ private static long SignedSrcSignedDstSatQ(long op, int size)
{
ExecutionContext context = NativeInterface.GetContext();
@@ -536,54 +536,7 @@ namespace ARMeilleure.Instructions
}
}
- public static ulong SignedSrcUnsignedDstSatQ(long op, int size)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- int eSize = 8 << size;
-
- ulong tMaxValue = (1UL << eSize) - 1UL;
- ulong tMinValue = 0UL;
-
- if (op > (long)tMaxValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return tMaxValue;
- }
- else if (op < (long)tMinValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return tMinValue;
- }
- else
- {
- return (ulong)op;
- }
- }
-
- public static long UnsignedSrcSignedDstSatQ(ulong op, int size)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- int eSize = 8 << size;
-
- long tMaxValue = (1L << (eSize - 1)) - 1L;
-
- if (op > (ulong)tMaxValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return tMaxValue;
- }
- else
- {
- return (long)op;
- }
- }
-
- public static ulong UnsignedSrcUnsignedDstSatQ(ulong op, int size)
+ private static ulong UnsignedSrcUnsignedDstSatQ(ulong op, int size)
{
ExecutionContext context = NativeInterface.GetContext();
@@ -602,208 +555,6 @@ namespace ARMeilleure.Instructions
return op;
}
}
-
- public static long UnarySignedSatQAbsOrNeg(long op)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- if (op == long.MinValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return long.MaxValue;
- }
- else
- {
- return op;
- }
- }
-
- public static long BinarySignedSatQAdd(long op1, long op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- long add = op1 + op2;
-
- if ((~(op1 ^ op2) & (op1 ^ add)) < 0L)
- {
- context.Fpsr |= FPSR.Qc;
-
- if (op1 < 0L)
- {
- return long.MinValue;
- }
- else
- {
- return long.MaxValue;
- }
- }
- else
- {
- return add;
- }
- }
-
- public static ulong BinaryUnsignedSatQAdd(ulong op1, ulong op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- ulong add = op1 + op2;
-
- if ((add < op1) && (add < op2))
- {
- context.Fpsr |= FPSR.Qc;
-
- return ulong.MaxValue;
- }
- else
- {
- return add;
- }
- }
-
- public static long BinarySignedSatQSub(long op1, long op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- long sub = op1 - op2;
-
- if (((op1 ^ op2) & (op1 ^ sub)) < 0L)
- {
- context.Fpsr |= FPSR.Qc;
-
- if (op1 < 0L)
- {
- return long.MinValue;
- }
- else
- {
- return long.MaxValue;
- }
- }
- else
- {
- return sub;
- }
- }
-
- public static ulong BinaryUnsignedSatQSub(ulong op1, ulong op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- ulong sub = op1 - op2;
-
- if (op1 < op2)
- {
- context.Fpsr |= FPSR.Qc;
-
- return ulong.MinValue;
- }
- else
- {
- return sub;
- }
- }
-
- public static long BinarySignedSatQAcc(ulong op1, long op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- if (op1 <= (ulong)long.MaxValue)
- {
- // op1 from ulong.MinValue to (ulong)long.MaxValue
- // op2 from long.MinValue to long.MaxValue
-
- long add = (long)op1 + op2;
-
- if ((~op2 & add) < 0L)
- {
- context.Fpsr |= FPSR.Qc;
-
- return long.MaxValue;
- }
- else
- {
- return add;
- }
- }
- else if (op2 >= 0L)
- {
- // op1 from (ulong)long.MaxValue + 1UL to ulong.MaxValue
- // op2 from (long)ulong.MinValue to long.MaxValue
-
- context.Fpsr |= FPSR.Qc;
-
- return long.MaxValue;
- }
- else
- {
- // op1 from (ulong)long.MaxValue + 1UL to ulong.MaxValue
- // op2 from long.MinValue to (long)ulong.MinValue - 1L
-
- ulong add = op1 + (ulong)op2;
-
- if (add > (ulong)long.MaxValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return long.MaxValue;
- }
- else
- {
- return (long)add;
- }
- }
- }
-
- public static ulong BinaryUnsignedSatQAcc(long op1, ulong op2)
- {
- ExecutionContext context = NativeInterface.GetContext();
-
- if (op1 >= 0L)
- {
- // op1 from (long)ulong.MinValue to long.MaxValue
- // op2 from ulong.MinValue to ulong.MaxValue
-
- ulong add = (ulong)op1 + op2;
-
- if ((add < (ulong)op1) && (add < op2))
- {
- context.Fpsr |= FPSR.Qc;
-
- return ulong.MaxValue;
- }
- else
- {
- return add;
- }
- }
- else if (op2 > (ulong)long.MaxValue)
- {
- // op1 from long.MinValue to (long)ulong.MinValue - 1L
- // op2 from (ulong)long.MaxValue + 1UL to ulong.MaxValue
-
- return (ulong)op1 + op2;
- }
- else
- {
- // op1 from long.MinValue to (long)ulong.MinValue - 1L
- // op2 from ulong.MinValue to (ulong)long.MaxValue
-
- long add = op1 + (long)op2;
-
- if (add < (long)ulong.MinValue)
- {
- context.Fpsr |= FPSR.Qc;
-
- return ulong.MinValue;
- }
- else
- {
- return (ulong)add;
- }
- }
- }
#endregion
#region "Count"