From d0eabc1ee04ed742e115ab33c233f7db5fd51427 Mon Sep 17 00:00:00 2001 From: Andy Adshead Date: Mon, 21 Jan 2019 20:05:43 +0000 Subject: [PATCH] Updated lots of renamed/relocated methods --- ChocolArm64/Instructions/CryptoHelper.cs | 4 +- .../Instructions/InstEmitSimdArithmetic.cs | 52 ++++----- .../Instructions/InstEmitSimdLogical.cs | 10 +- ChocolArm64/Instructions/InstEmitSimdMove.cs | 6 +- ChocolArm64/Instructions/SoftFallback.cs | 10 +- ChocolArm64/Instructions/VectorHelper.cs | 108 +++++++++--------- ChocolArm64/Memory/MemoryManager.cs | 14 +-- Ryujinx.Tests/Cpu/CpuTest.cs | 21 ++-- Ryujinx.Tests/Cpu/CpuTestMisc.cs | 9 +- 9 files changed, 117 insertions(+), 117 deletions(-) diff --git a/ChocolArm64/Instructions/CryptoHelper.cs b/ChocolArm64/Instructions/CryptoHelper.cs index b38d79a8c7..fefb08ccc3 100644 --- a/ChocolArm64/Instructions/CryptoHelper.cs +++ b/ChocolArm64/Instructions/CryptoHelper.cs @@ -318,11 +318,11 @@ namespace ChocolArm64.Instructions throw new PlatformNotSupportedException(); } - op = Sse.StaticCast(Sse2.SetVector128( + op = Vector128.Create( state[15], state[14], state[13], state[12], state[11], state[10], state[9], state[8], state[7], state[6], state[5], state[4], - state[3], state[2], state[1], state[0])); + state[3], state[2], state[1], state[0]).As(); } } } diff --git a/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs b/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs index d1e71ecbf4..760d08ebfe 100644 --- a/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs +++ b/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs @@ -188,7 +188,7 @@ namespace ChocolArm64.Instructions Type[] typesSubAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -207,7 +207,7 @@ namespace ChocolArm64.Instructions Type[] typesSubAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -246,7 +246,7 @@ namespace ChocolArm64.Instructions Type[] typesSubAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -268,7 +268,7 @@ namespace ChocolArm64.Instructions Type[] typesSubAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -303,7 +303,7 @@ namespace ChocolArm64.Instructions Type[] typesAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdvec(op.Rn); @@ -319,7 +319,7 @@ namespace ChocolArm64.Instructions Type[] typesAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); EmitLdvecWithCastToDouble(context, op.Rn); @@ -353,7 +353,7 @@ namespace ChocolArm64.Instructions Type[] typesAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdvec(op.Rn); @@ -372,7 +372,7 @@ namespace ChocolArm64.Instructions Type[] typesAndNot = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitLdvecWithCastToDouble(context, op.Rn); @@ -1120,7 +1120,7 @@ namespace ChocolArm64.Instructions Type[] typesXor = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdvec(op.Rn); @@ -1136,7 +1136,7 @@ namespace ChocolArm64.Instructions Type[] typesXor = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); EmitLdvecWithCastToDouble(context, op.Rn); @@ -1167,7 +1167,7 @@ namespace ChocolArm64.Instructions Type[] typesXor = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(-0f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdvec(op.Rn); @@ -1186,7 +1186,7 @@ namespace ChocolArm64.Instructions Type[] typesXor = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(-0d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitLdvecWithCastToDouble(context, op.Rn); @@ -1303,7 +1303,7 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(2f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -1321,7 +1321,7 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(2d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -1357,7 +1357,7 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(2f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -1378,7 +1378,7 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(2d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -1640,10 +1640,10 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(0.5f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdc_R4(3f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -1662,10 +1662,10 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(0.5d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); context.EmitLdc_R8(3d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetScalarVector128), typesSsv)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.CreateScalarUnsafe), typesSsv)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -1702,10 +1702,10 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R4(0.5f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdc_R4(3f); - context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdvec(op.Rn); context.EmitLdvec(op.Rm); @@ -1727,10 +1727,10 @@ namespace ChocolArm64.Instructions Type[] typesMulSub = new Type[] { typeof(Vector128), typeof(Vector128) }; context.EmitLdc_R8(0.5d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitLdc_R8(3d); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitLdvecWithCastToDouble(context, op.Rn); EmitLdvecWithCastToDouble(context, op.Rm); @@ -2096,7 +2096,7 @@ namespace ChocolArm64.Instructions Type[] typesAvg = new Type[] { VectorUIntTypesPerSizeLog2[op.Size], VectorUIntTypesPerSizeLog2[op.Size] }; context.EmitLdc_I4(op.Size == 0 ? sbyte.MinValue : short.MinValue); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitStvectmp(); @@ -2415,7 +2415,7 @@ namespace ChocolArm64.Instructions Type[] typesAvg = new Type[] { VectorUIntTypesPerSizeLog2[op.Size], VectorUIntTypesPerSizeLog2[op.Size] }; context.EmitLdc_I4(op.Size == 0 ? sbyte.MinValue : short.MinValue); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.Emit(OpCodes.Dup); context.EmitStvectmp(); diff --git a/ChocolArm64/Instructions/InstEmitSimdLogical.cs b/ChocolArm64/Instructions/InstEmitSimdLogical.cs index 3473fc5d98..915eef6372 100644 --- a/ChocolArm64/Instructions/InstEmitSimdLogical.cs +++ b/ChocolArm64/Instructions/InstEmitSimdLogical.cs @@ -202,7 +202,7 @@ namespace ChocolArm64.Instructions EmitLdvecWithUnsignedCast(context, op.Rn, 0); context.EmitLdc_I4(byte.MaxValue); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.AndNot), typesAndNot)); @@ -232,7 +232,7 @@ namespace ChocolArm64.Instructions EmitLdvecWithUnsignedCast(context, op.Rm, 0); context.EmitLdc_I4(byte.MaxValue); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.AndNot), typesAndNotOr)); context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Or), typesAndNotOr)); @@ -310,7 +310,7 @@ namespace ChocolArm64.Instructions context.EmitLdc_I8(14L << 56 | 15L << 48 | 12L << 40 | 13L << 32 | 10L << 24 | 11L << 16 | 08L << 8 | 09L << 0); // maskE1 context.EmitLdc_I8(06L << 56 | 07L << 48 | 04L << 40 | 05L << 32 | 02L << 24 | 03L << 16 | 00L << 8 | 01L << 0); // maskE0 - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSve)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSve)); context.EmitCall(typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), typesSfl)); @@ -349,7 +349,7 @@ namespace ChocolArm64.Instructions context.EmitLdc_I8(05L << 56 | 04L << 48 | 07L << 40 | 06L << 32 | 01L << 24 | 00L << 16 | 03L << 8 | 02L << 0); // maskE0 } - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSve)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSve)); context.EmitCall(typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), typesSfl)); @@ -393,7 +393,7 @@ namespace ChocolArm64.Instructions context.EmitLdc_I8(03L << 56 | 02L << 48 | 01L << 40 | 00L << 32 | 07L << 24 | 06L << 16 | 05L << 8 | 04L << 0); // maskE0 } - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSve)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSve)); context.EmitCall(typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), typesSfl)); diff --git a/ChocolArm64/Instructions/InstEmitSimdMove.cs b/ChocolArm64/Instructions/InstEmitSimdMove.cs index d40ccff915..8aa9964f45 100644 --- a/ChocolArm64/Instructions/InstEmitSimdMove.cs +++ b/ChocolArm64/Instructions/InstEmitSimdMove.cs @@ -29,7 +29,7 @@ namespace ChocolArm64.Instructions case 2: context.Emit(OpCodes.Conv_U4); break; } - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitStvecWithUnsignedCast(context, op.Rd, op.Size); } @@ -78,7 +78,7 @@ namespace ChocolArm64.Instructions case 2: context.Emit(OpCodes.Conv_U4); break; } - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSav)); EmitStvecWithUnsignedCast(context, op.Rd, op.Size); } @@ -404,7 +404,7 @@ namespace ChocolArm64.Instructions context.EmitLdc_I8(masks[op.Size]); context.Emit(OpCodes.Dup); - context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSve)); + context.EmitCall(typeof(Vector128).GetMethod(nameof(Vector128.Create), typesSve)); context.EmitCall(typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), typesSfl)); diff --git a/ChocolArm64/Instructions/SoftFallback.cs b/ChocolArm64/Instructions/SoftFallback.cs index def953434e..159610765c 100644 --- a/ChocolArm64/Instructions/SoftFallback.cs +++ b/ChocolArm64/Instructions/SoftFallback.cs @@ -900,8 +900,8 @@ namespace ChocolArm64.Instructions Vector128 result = new Vector128(); - Vector128 t = Sse.Xor(tw0_3, Sse.StaticCast( - Sse2.ShiftRightLogical128BitLane(Sse.StaticCast(w12_15), (byte)4))); + Vector128 t = Sse.Xor(tw0_3, + Sse2.ShiftRightLogical128BitLane(w12_15.As(), (byte)4).As()); uint tE0 = (uint)VectorExtractIntZx(t, (byte)0, 2); uint tE1 = (uint)VectorExtractIntZx(t, (byte)1, 2); @@ -924,7 +924,7 @@ namespace ChocolArm64.Instructions uint xE3 = (uint)VectorExtractIntZx(x, (byte)3, 2); - x = Sse.StaticCast(Sse2.ShiftLeftLogical128BitLane(Sse.StaticCast(x), (byte)4)); + x = Sse2.ShiftLeftLogical128BitLane(x.As(), (byte)4).As(); x = VectorInsertInt((ulong)y, x, (byte)0, 2); y = xE3; @@ -1054,8 +1054,8 @@ namespace ChocolArm64.Instructions uint yE3 = (uint)VectorExtractIntZx(y, (byte)3, 2); uint xE3 = (uint)VectorExtractIntZx(x, (byte)3, 2); - y = Sse.StaticCast(Sse2.ShiftLeftLogical128BitLane(Sse.StaticCast(y), (byte)4)); - x = Sse.StaticCast(Sse2.ShiftLeftLogical128BitLane(Sse.StaticCast(x), (byte)4)); + y = Sse2.ShiftLeftLogical128BitLane(y.As(), (byte)4).As(); + x = Sse2.ShiftLeftLogical128BitLane(x.As(), (byte)4).As(); y = VectorInsertInt((ulong)xE3, y, (byte)0, 2); x = VectorInsertInt((ulong)yE3, x, (byte)0, 2); diff --git a/ChocolArm64/Instructions/VectorHelper.cs b/ChocolArm64/Instructions/VectorHelper.cs index f02c131e68..a3ae5df688 100644 --- a/ChocolArm64/Instructions/VectorHelper.cs +++ b/ChocolArm64/Instructions/VectorHelper.cs @@ -217,7 +217,7 @@ namespace ChocolArm64.Instructions { if (Sse41.IsSupported) { - return BitConverter.Int64BitsToDouble(Sse41.Extract(Sse.StaticCast(vector), index)); + return BitConverter.Int64BitsToDouble(Sse41.Extract(vector.As(), index)); } else if (Sse2.IsSupported) { @@ -234,19 +234,19 @@ namespace ChocolArm64.Instructions { if (size == 0) { - return (sbyte)Sse41.Extract(Sse.StaticCast(vector), index); + return (sbyte)Sse41.Extract(vector.As(), index); } else if (size == 1) { - return (short)Sse2.Extract(Sse.StaticCast(vector), index); + return (short)Sse2.Extract(vector.As(), index); } else if (size == 2) { - return Sse41.Extract(Sse.StaticCast(vector), index); + return Sse41.Extract(vector.As(), index); } else if (size == 3) { - return Sse41.Extract(Sse.StaticCast(vector), index); + return Sse41.Extract(vector.As(), index); } else { @@ -287,19 +287,19 @@ namespace ChocolArm64.Instructions { if (size == 0) { - return Sse41.Extract(Sse.StaticCast(vector), index); + return Sse41.Extract(vector.As(), index); } else if (size == 1) { - return Sse2.Extract(Sse.StaticCast(vector), index); + return Sse2.Extract(vector.As(), index); } else if (size == 2) { - return Sse41.Extract(Sse.StaticCast(vector), index); + return Sse41.Extract(vector.As(), index); } else if (size == 3) { - return Sse41.Extract(Sse.StaticCast(vector), index); + return Sse41.Extract(vector.As(), index); } else { @@ -312,7 +312,7 @@ namespace ChocolArm64.Instructions ? index >> 1 : index << (size - 1); - ushort value = Sse2.Extract(Sse.StaticCast(vector), (byte)shortIdx); + ushort value = Sse2.Extract(vector.As(), (byte)shortIdx); if (size == 0) { @@ -324,15 +324,15 @@ namespace ChocolArm64.Instructions } else if (size == 2 || size == 3) { - ushort value1 = Sse2.Extract(Sse.StaticCast(vector), (byte)(shortIdx + 1)); + ushort value1 = Sse2.Extract(vector.As(), (byte)(shortIdx + 1)); if (size == 2) { return (uint)(value | (value1 << 16)); } - ushort value2 = Sse2.Extract(Sse.StaticCast(vector), (byte)(shortIdx + 2)); - ushort value3 = Sse2.Extract(Sse.StaticCast(vector), (byte)(shortIdx + 3)); + ushort value2 = Sse2.Extract(vector.As(), (byte)(shortIdx + 2)); + ushort value3 = Sse2.Extract(vector.As(), (byte)(shortIdx + 3)); return ((ulong)value << 0) | ((ulong)value1 << 16) | @@ -357,7 +357,7 @@ namespace ChocolArm64.Instructions } else if (Sse2.IsSupported) { - Vector128 shortVector = Sse.StaticCast(vector); + Vector128 shortVector = vector.As(); int low = Sse2.Extract(shortVector, (byte)(index * 2 + 0)); int high = Sse2.Extract(shortVector, (byte)(index * 2 + 1)); @@ -381,19 +381,19 @@ namespace ChocolArm64.Instructions { if (size == 0) { - return Sse.StaticCast(Sse41.Insert(Sse.StaticCast(vector), (byte)value, index)); + return Sse41.Insert(vector.As(), (byte)value, index).As(); } else if (size == 1) { - return Sse.StaticCast(Sse2.Insert(Sse.StaticCast(vector), (ushort)value, index)); + return Sse2.Insert(vector.As(), (ushort)value, index).As(); } else if (size == 2) { - return Sse.StaticCast(Sse41.Insert(Sse.StaticCast(vector), (uint)value, index)); + return Sse41.Insert(vector.As(), (uint)value, index).As(); } else if (size == 3) { - return Sse.StaticCast(Sse41.Insert(Sse.StaticCast(vector), value, index)); + return Sse41.Insert(vector.As(), value, index).As(); } else { @@ -402,7 +402,7 @@ namespace ChocolArm64.Instructions } else if (Sse2.IsSupported) { - Vector128 shortVector = Sse.StaticCast(vector); + Vector128 shortVector = vector.As(); int shortIdx = size == 0 ? index >> 1 @@ -410,7 +410,7 @@ namespace ChocolArm64.Instructions if (size == 0) { - ushort shortVal = Sse2.Extract(Sse.StaticCast(vector), (byte)shortIdx); + ushort shortVal = Sse2.Extract(vector.As(), (byte)shortIdx); int shift = (index & 1) * 8; @@ -418,11 +418,11 @@ namespace ChocolArm64.Instructions shortVal |= (ushort)((byte)value << shift); - return Sse.StaticCast(Sse2.Insert(shortVector, shortVal, (byte)shortIdx)); + return Sse2.Insert(shortVector, shortVal, (byte)shortIdx).As(); } else if (size == 1) { - return Sse.StaticCast(Sse2.Insert(Sse.StaticCast(vector), (ushort)value, index)); + return Sse2.Insert(vector.As(), (ushort)value, index).As(); } else if (size == 2 || size == 3) { @@ -435,7 +435,7 @@ namespace ChocolArm64.Instructions shortVector = Sse2.Insert(shortVector, (ushort)(value >> 48), (byte)(shortIdx + 3)); } - return Sse.StaticCast(shortVector); + return shortVector.As(); } else { @@ -456,19 +456,19 @@ namespace ChocolArm64.Instructions //jump table fallback. if (index == 0) { - return Sse41.Insert(vector, value, 0x00); + return Sse41.Insert(vector, Vector128.CreateScalarUnsafe(value), 0x00); } else if (index == 1) { - return Sse41.Insert(vector, value, 0x10); + return Sse41.Insert(vector, Vector128.CreateScalarUnsafe(value), 0x10); } else if (index == 2) { - return Sse41.Insert(vector, value, 0x20); + return Sse41.Insert(vector, Vector128.CreateScalarUnsafe(value), 0x20); } else if (index == 3) { - return Sse41.Insert(vector, value, 0x30); + return Sse41.Insert(vector, Vector128.CreateScalarUnsafe(value), 0x30); } else { @@ -482,12 +482,12 @@ namespace ChocolArm64.Instructions ushort low = (ushort)(intValue >> 0); ushort high = (ushort)(intValue >> 16); - Vector128 shortVector = Sse.StaticCast(vector); + Vector128 shortVector = vector.As(); shortVector = Sse2.Insert(shortVector, low, (byte)(index * 2 + 0)); shortVector = Sse2.Insert(shortVector, high, (byte)(index * 2 + 1)); - return Sse.StaticCast(shortVector); + return shortVector.As(); } throw new PlatformNotSupportedException(); @@ -497,7 +497,7 @@ namespace ChocolArm64.Instructions public static Vector128 Sse41VectorInsertScalarSingle(float value, Vector128 vector) { //Note: 0b1110 is the mask to zero the upper bits. - return Sse41.Insert(vector, value, 0b1110); + return Sse41.Insert(vector, Vector128.CreateScalarUnsafe(value), 0b1110); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -505,7 +505,7 @@ namespace ChocolArm64.Instructions { if (Sse2.IsSupported) { - return Sse2.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -516,7 +516,7 @@ namespace ChocolArm64.Instructions { if (Sse2.IsSupported) { - return Sse2.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -527,7 +527,7 @@ namespace ChocolArm64.Instructions { if (Sse2.IsSupported) { - return Sse2.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -538,7 +538,7 @@ namespace ChocolArm64.Instructions { if (Sse2.IsSupported) { - return Sse2.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -549,7 +549,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -560,7 +560,7 @@ namespace ChocolArm64.Instructions { if (Sse2.IsSupported) { - return Sse2.SetZeroVector128(); + return Vector128.Zero; } throw new PlatformNotSupportedException(); @@ -571,7 +571,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -582,7 +582,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -593,7 +593,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -604,7 +604,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -615,7 +615,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -626,7 +626,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -637,7 +637,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -648,7 +648,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -659,7 +659,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -670,7 +670,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -681,7 +681,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -692,7 +692,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -703,7 +703,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -714,7 +714,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -725,7 +725,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -736,7 +736,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -747,7 +747,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); @@ -758,7 +758,7 @@ namespace ChocolArm64.Instructions { if (Sse.IsSupported) { - return Sse.StaticCast(vector); + return vector.As(); } throw new PlatformNotSupportedException(); diff --git a/ChocolArm64/Memory/MemoryManager.cs b/ChocolArm64/Memory/MemoryManager.cs index 1f21256807..2a1af93460 100644 --- a/ChocolArm64/Memory/MemoryManager.cs +++ b/ChocolArm64/Memory/MemoryManager.cs @@ -243,7 +243,7 @@ namespace ChocolArm64.Memory { if (Sse2.IsSupported) { - return Sse.StaticCast(Sse2.SetVector128(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ReadByte(position))); + return Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ReadByte(position)).As(); } else { @@ -260,7 +260,7 @@ namespace ChocolArm64.Memory { if (Sse2.IsSupported && (position & 1) == 0) { - return Sse.StaticCast(Sse2.Insert(Sse2.SetZeroVector128(), ReadUInt16(position), 0)); + return Sse2.Insert(Vector128.Zero, ReadUInt16(position), 0).As(); } else { @@ -294,7 +294,7 @@ namespace ChocolArm64.Memory { if (Sse2.IsSupported && (position & 7) == 0) { - return Sse.StaticCast(Sse2.LoadScalarVector128((double*)Translate(position))); + return Sse2.LoadScalarVector128((double*)Translate(position)).As(); } else { @@ -466,11 +466,11 @@ namespace ChocolArm64.Memory { if (Sse41.IsSupported) { - WriteByte(position, Sse41.Extract(Sse.StaticCast(value), 0)); + WriteByte(position, Sse41.Extract(value.As(), 0)); } else if (Sse2.IsSupported) { - WriteByte(position, (byte)Sse2.Extract(Sse.StaticCast(value), 0)); + WriteByte(position, (byte)Sse2.Extract(value.As(), 0)); } else { @@ -483,7 +483,7 @@ namespace ChocolArm64.Memory { if (Sse2.IsSupported) { - WriteUInt16(position, Sse2.Extract(Sse.StaticCast(value), 0)); + WriteUInt16(position, Sse2.Extract(value.As(), 0)); } else { @@ -509,7 +509,7 @@ namespace ChocolArm64.Memory { if (Sse2.IsSupported && (position & 7) == 0) { - Sse2.StoreScalar((double*)TranslateWrite(position), Sse.StaticCast(value)); + Sse2.StoreScalar((double*)TranslateWrite(position), value.As()); } else { diff --git a/Ryujinx.Tests/Cpu/CpuTest.cs b/Ryujinx.Tests/Cpu/CpuTest.cs index b970e05540..8a94420ce0 100644 --- a/Ryujinx.Tests/Cpu/CpuTest.cs +++ b/Ryujinx.Tests/Cpu/CpuTest.cs @@ -434,7 +434,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast(Sse2.SetVector128(0, BitConverter.DoubleToInt64Bits(e0))); + return Vector128.Create(0, BitConverter.DoubleToInt64Bits(e0)).As(); } protected static Vector128 MakeVectorE0E1(double e0, double e1) @@ -444,8 +444,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast( - Sse2.SetVector128(BitConverter.DoubleToInt64Bits(e1), BitConverter.DoubleToInt64Bits(e0))); + return Vector128.Create(BitConverter.DoubleToInt64Bits(e1), BitConverter.DoubleToInt64Bits(e0)).As(); } protected static Vector128 MakeVectorE1(double e1) @@ -455,7 +454,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast(Sse2.SetVector128(BitConverter.DoubleToInt64Bits(e1), 0)); + return Vector128.Create(BitConverter.DoubleToInt64Bits(e1), 0).As(); } protected static float VectorExtractSingle(Vector128 vector, byte index) @@ -465,7 +464,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - int value = Sse41.Extract(Sse.StaticCast(vector), index); + int value = Sse41.Extract(vector.As(), index); return BitConverter.Int32BitsToSingle(value); } @@ -477,7 +476,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - long value = Sse41.Extract(Sse.StaticCast(vector), index); + long value = Sse41.Extract(vector.As(), index); return BitConverter.Int64BitsToDouble(value); } @@ -489,7 +488,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast(Sse2.SetVector128(0, e0)); + return Vector128.Create(0, e0).As(); } protected static Vector128 MakeVectorE0E1(ulong e0, ulong e1) @@ -499,7 +498,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast(Sse2.SetVector128(e1, e0)); + return Vector128.Create(e1, e0).As(); } protected static Vector128 MakeVectorE1(ulong e1) @@ -509,7 +508,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse.StaticCast(Sse2.SetVector128(e1, 0)); + return Vector128.Create(e1, 0).As(); } protected static ulong GetVectorE0(Vector128 vector) @@ -519,7 +518,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse41.Extract(Sse.StaticCast(vector), (byte)0); + return Sse41.Extract(vector.As(), (byte)0); } protected static ulong GetVectorE1(Vector128 vector) @@ -529,7 +528,7 @@ namespace Ryujinx.Tests.Cpu throw new PlatformNotSupportedException(); } - return Sse41.Extract(Sse.StaticCast(vector), (byte)1); + return Sse41.Extract(vector.As(), (byte)1); } protected static ushort GenNormalH() diff --git a/Ryujinx.Tests/Cpu/CpuTestMisc.cs b/Ryujinx.Tests/Cpu/CpuTestMisc.cs index 4d6783f71e..87cdeb8872 100644 --- a/Ryujinx.Tests/Cpu/CpuTestMisc.cs +++ b/Ryujinx.Tests/Cpu/CpuTestMisc.cs @@ -1,3 +1,4 @@ +using System.Runtime.Intrinsics; using ChocolArm64.State; using NUnit.Framework; @@ -76,8 +77,8 @@ namespace Ryujinx.Tests.Cpu */ SetThreadState( - v0: Sse.SetScalarVector128(a), - v1: Sse.SetScalarVector128(b)); + v0: Vector128.CreateScalar(a), + v1: Vector128.CreateScalar(b)); Opcode(0x1E2E1002); Opcode(0x1E201840); Opcode(0x1E211841); @@ -125,8 +126,8 @@ namespace Ryujinx.Tests.Cpu */ SetThreadState( - v0: Sse.StaticCast(Sse2.SetScalarVector128(a)), - v1: Sse.StaticCast(Sse2.SetScalarVector128(b))); + v0: Vector128.CreateScalar(a).As(), + v1: Vector128.CreateScalar(b).As()); Opcode(0x1E6E1002); Opcode(0x1E601840); Opcode(0x1E611841);