aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-05-18 14:44:49 -0300
committergdkchan <gab.dark.100@gmail.com>2018-05-18 14:44:49 -0300
commit7ac5f40532e4bd96641867035dfda86d2a9d7260 (patch)
tree1c098e4cba5951fc132015340ac58083ae869610
parentb19c4740823ed8fcebf62bf5741a7614a2ac0aa0 (diff)
Add scalar variants of FCVTZS/FCVTZU, fix a issue on Ryushader
-rw-r--r--ChocolArm64/AOpCodeTable.cs2
-rw-r--r--ChocolArm64/Instruction/AInstEmitSimdCvt.cs54
-rw-r--r--Ryushader/Program.cs2
3 files changed, 57 insertions, 1 deletions
diff --git a/ChocolArm64/AOpCodeTable.cs b/ChocolArm64/AOpCodeTable.cs
index 64b7e10f..754c8abc 100644
--- a/ChocolArm64/AOpCodeTable.cs
+++ b/ChocolArm64/AOpCodeTable.cs
@@ -231,10 +231,12 @@ namespace ChocolArm64
Set("x00111100x101001000000xxxxxxxxxx", AInstEmit.Fcvtpu_Gp, typeof(AOpCodeSimdCvt));
Set("x00111100x111000000000xxxxxxxxxx", AInstEmit.Fcvtzs_Gp, typeof(AOpCodeSimdCvt));
Set("x00111100x011000xxxxxxxxxxxxxxxx", AInstEmit.Fcvtzs_Gp_Fix, typeof(AOpCodeSimdCvt));
+ Set("010111101x100001101110xxxxxxxxxx", AInstEmit.Fcvtzs_S, typeof(AOpCodeSimd));
Set("0>0011101<100001101110xxxxxxxxxx", AInstEmit.Fcvtzs_V, typeof(AOpCodeSimd));
Set("0x0011110>>xxxxx111111xxxxxxxxxx", AInstEmit.Fcvtzs_V, typeof(AOpCodeSimdShImm));
Set("x00111100x111001000000xxxxxxxxxx", AInstEmit.Fcvtzu_Gp, typeof(AOpCodeSimdCvt));
Set("x00111100x011001xxxxxxxxxxxxxxxx", AInstEmit.Fcvtzu_Gp_Fix, typeof(AOpCodeSimdCvt));
+ Set("011111101x100001101110xxxxxxxxxx", AInstEmit.Fcvtzu_S, typeof(AOpCodeSimd));
Set("0>1011101<100001101110xxxxxxxxxx", AInstEmit.Fcvtzu_V, typeof(AOpCodeSimd));
Set("0x1011110>>xxxxx111111xxxxxxxxxx", AInstEmit.Fcvtzu_V, typeof(AOpCodeSimdShImm));
Set("000111100x1xxxxx000110xxxxxxxxxx", AInstEmit.Fdiv_S, typeof(AOpCodeSimdReg));
diff --git a/ChocolArm64/Instruction/AInstEmitSimdCvt.cs b/ChocolArm64/Instruction/AInstEmitSimdCvt.cs
index 444638e6..98bb972a 100644
--- a/ChocolArm64/Instruction/AInstEmitSimdCvt.cs
+++ b/ChocolArm64/Instruction/AInstEmitSimdCvt.cs
@@ -126,6 +126,11 @@ namespace ChocolArm64.Instruction
EmitFcvtzs_Gp_Fix(Context);
}
+ public static void Fcvtzs_S(AILEmitterCtx Context)
+ {
+ EmitScalarFcvtzs(Context);
+ }
+
public static void Fcvtzs_V(AILEmitterCtx Context)
{
EmitVectorFcvtzs(Context);
@@ -141,6 +146,11 @@ namespace ChocolArm64.Instruction
EmitFcvtzu_Gp_Fix(Context);
}
+ public static void Fcvtzu_S(AILEmitterCtx Context)
+ {
+ EmitScalarFcvtzu(Context);
+ }
+
public static void Fcvtzu_V(AILEmitterCtx Context)
{
EmitVectorFcvtzu(Context);
@@ -353,6 +363,50 @@ namespace ChocolArm64.Instruction
}
}
+ private static void EmitScalarFcvtzs(AILEmitterCtx Context)
+ {
+ EmitScalarFcvtz(Context, true);
+ }
+
+ private static void EmitScalarFcvtzu(AILEmitterCtx Context)
+ {
+ EmitScalarFcvtz(Context, false);
+ }
+
+ private static void EmitScalarFcvtz(AILEmitterCtx Context, bool Signed)
+ {
+ AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
+
+ int SizeF = Op.Size & 1;
+ int SizeI = SizeF + 2;
+
+ int FBits = GetFBits(Context);
+
+ EmitVectorExtractF(Context, Op.Rn, 0, SizeF);
+
+ EmitF2iFBitsMul(Context, SizeF, FBits);
+
+ if (SizeF == 0)
+ {
+ AVectorHelper.EmitCall(Context, Signed
+ ? nameof(AVectorHelper.SatF32ToS32)
+ : nameof(AVectorHelper.SatF32ToU32));
+ }
+ else /* if (SizeF == 1) */
+ {
+ AVectorHelper.EmitCall(Context, Signed
+ ? nameof(AVectorHelper.SatF64ToS64)
+ : nameof(AVectorHelper.SatF64ToU64));
+ }
+
+ if (SizeF == 0)
+ {
+ Context.Emit(OpCodes.Conv_U8);
+ }
+
+ EmitScalarSet(Context, Op.Rd, SizeI);
+ }
+
private static void EmitVectorFcvtzs(AILEmitterCtx Context)
{
EmitVectorFcvtz(Context, true);
diff --git a/Ryushader/Program.cs b/Ryushader/Program.cs
index 21eb3d79..6fec744d 100644
--- a/Ryushader/Program.cs
+++ b/Ryushader/Program.cs
@@ -28,7 +28,7 @@ namespace Ryushader
int[] Code = new int[Data.Length / 4];
- for (int Offset = 0; Offset < Data.Length; Offset += 4)
+ for (int Offset = 0; Offset + 4 <= Data.Length; Offset += 4)
{
int Value = BitConverter.ToInt32(Data, Offset);