diff --git a/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs b/ChocolArm64/Instructions/InstEmitSimdArithmetic.cs index acb9f7f093..e126796d25 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); @@ -1107,7 +1107,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); @@ -1123,7 +1123,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); @@ -1154,7 +1154,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); @@ -1173,7 +1173,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); @@ -1290,7 +1290,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); @@ -1308,7 +1308,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); @@ -1344,7 +1344,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); @@ -1365,7 +1365,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); @@ -1627,10 +1627,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); @@ -1649,10 +1649,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); @@ -1689,10 +1689,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); @@ -1714,10 +1714,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); @@ -2079,7 +2079,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(); @@ -2421,7 +2421,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 2844dfdf4c..9f08d89033 100644 --- a/ChocolArm64/Instructions/InstEmitSimdMove.cs +++ b/ChocolArm64/Instructions/InstEmitSimdMove.cs @@ -57,7 +57,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); } @@ -106,7 +106,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); } @@ -423,7 +423,7 @@ namespace ChocolArm64.Instructions context.EmitLdc_I8(_masksE0_TrnUzpXtn[op.Size]); // mask context.Emit(OpCodes.Dup); // mask - 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), GetTypesSflUpk(0))); diff --git a/ChocolArm64/Instructions/SoftFallback.cs b/ChocolArm64/Instructions/SoftFallback.cs index 1663889457..6e0cc6b3c3 100644 --- a/ChocolArm64/Instructions/SoftFallback.cs +++ b/ChocolArm64/Instructions/SoftFallback.cs @@ -895,8 +895,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); @@ -919,7 +919,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; @@ -1049,8 +1049,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 47feb573eb..a83e2b60da 100644 --- a/Ryujinx.Tests/Cpu/CpuTest.cs +++ b/Ryujinx.Tests/Cpu/CpuTest.cs @@ -437,7 +437,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) @@ -447,8 +447,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) @@ -458,7 +457,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) @@ -468,7 +467,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); } @@ -480,7 +479,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); } @@ -492,7 +491,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) @@ -502,7 +501,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) @@ -512,7 +511,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) @@ -522,7 +521,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) @@ -532,7 +531,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);