aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Instruction
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-24 11:19:28 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-24 11:19:28 -0300
commit035efc913e7f2a68315d4206cef46672005b8442 (patch)
treeeeb130850da914eb18e50ab5106db801b2eb4b14 /ChocolArm64/Instruction
parent3936c934482a587635bc5a1e47962551aeb53aeb (diff)
Fix cpu issue with cmp optimization, add HINT and FRINTX (scalar) instructions, fix for NvFlinger sometimes missing free buffers
Diffstat (limited to 'ChocolArm64/Instruction')
-rw-r--r--ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs26
-rw-r--r--ChocolArm64/Instruction/AInstEmitSystem.cs5
-rw-r--r--ChocolArm64/Instruction/ASoftFallback.cs26
3 files changed, 57 insertions, 0 deletions
diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
index 6665f219..e1fd56e0 100644
--- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
+++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs
@@ -265,6 +265,32 @@ namespace ChocolArm64.Instruction
});
}
+ public static void Frintx_S(AILEmitterCtx Context)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ EmitVectorExtractF(Context, Op.Rn, 0, Op.Size);
+
+ 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();
+ }
+
+ EmitScalarSetF(Context, Op.Rd, Op.Size);
+ }
+
public static void Fsqrt_S(AILEmitterCtx Context)
{
EmitScalarUnaryOpF(Context, () =>
diff --git a/ChocolArm64/Instruction/AInstEmitSystem.cs b/ChocolArm64/Instruction/AInstEmitSystem.cs
index 6754be7a..f9d18602 100644
--- a/ChocolArm64/Instruction/AInstEmitSystem.cs
+++ b/ChocolArm64/Instruction/AInstEmitSystem.cs
@@ -9,6 +9,11 @@ namespace ChocolArm64.Instruction
{
static partial class AInstEmit
{
+ public static void Hint(AILEmitterCtx Context)
+ {
+ //Execute as no-op.
+ }
+
public static void Mrs(AILEmitterCtx Context)
{
AOpCodeSystem Op = (AOpCodeSystem)Context.CurrOp;
diff --git a/ChocolArm64/Instruction/ASoftFallback.cs b/ChocolArm64/Instruction/ASoftFallback.cs
index a57966ba..5127182d 100644
--- a/ChocolArm64/Instruction/ASoftFallback.cs
+++ b/ChocolArm64/Instruction/ASoftFallback.cs
@@ -189,6 +189,32 @@ namespace ChocolArm64.Instruction
(Value >> 6) & 1 + (Value >> 7);
}
+ public static float RoundF(float Value, int Fpcr)
+ {
+ switch ((ARoundMode)((Fpcr >> 22) & 3))
+ {
+ case ARoundMode.ToNearest: return MathF.Round (Value);
+ case ARoundMode.TowardsPlusInfinity: return MathF.Ceiling (Value);
+ case ARoundMode.TowardsMinusInfinity: return MathF.Floor (Value);
+ case ARoundMode.TowardsZero: return MathF.Truncate(Value);
+ }
+
+ throw new InvalidOperationException();
+ }
+
+ public static double Round(double Value, int Fpcr)
+ {
+ switch ((ARoundMode)((Fpcr >> 22) & 3))
+ {
+ case ARoundMode.ToNearest: return Math.Round (Value);
+ case ARoundMode.TowardsPlusInfinity: return Math.Ceiling (Value);
+ case ARoundMode.TowardsMinusInfinity: return Math.Floor (Value);
+ case ARoundMode.TowardsZero: return Math.Truncate(Value);
+ }
+
+ throw new InvalidOperationException();
+ }
+
public static AVec Tbl1_V64(AVec Vector, AVec Tb0)
{
return Tbl(Vector, 8, Tb0);