From e4ee61d6c3984d108a9fd9e29c86dd154a04d0c5 Mon Sep 17 00:00:00 2001 From: Ficture Seven Date: Fri, 17 Apr 2020 02:19:20 +0400 Subject: [PATCH] Improve V128 (#1097) * Improve V128 * Use LayoutKind.Sequential instead * Add As, Get & Set * Fix CpuTest * Rename Get & Set to Extract & Insert * Add XML documentation * Nit --- ARMeilleure/Instructions/NativeInterface.cs | 4 +- ARMeilleure/Instructions/SoftFallback.cs | 78 ++--- ARMeilleure/Memory/MemoryManager.cs | 4 +- ARMeilleure/State/NativeContext.cs | 4 +- ARMeilleure/State/V128.cs | 350 ++++++++++++-------- Ryujinx.Tests/Cpu/CpuTest.cs | 22 +- Ryujinx.Tests/Cpu/CpuTest32.cs | 22 +- Ryujinx.Tests/Cpu/CpuTestMisc.cs | 4 +- 8 files changed, 288 insertions(+), 200 deletions(-) diff --git a/ARMeilleure/Instructions/NativeInterface.cs b/ARMeilleure/Instructions/NativeInterface.cs index 4514c0da..610a1209 100644 --- a/ARMeilleure/Instructions/NativeInterface.cs +++ b/ARMeilleure/Instructions/NativeInterface.cs @@ -245,8 +245,8 @@ namespace ARMeilleure.Instructions V128 value = _context.Memory.AtomicLoadInt128((long)address); _context.ExclusiveAddress = GetMaskedExclusiveAddress(address); - _context.ExclusiveValueLow = value.GetUInt64(0); - _context.ExclusiveValueHigh = value.GetUInt64(1); + _context.ExclusiveValueLow = value.Extract(0); + _context.ExclusiveValueHigh = value.Extract(1); return value; } diff --git a/ARMeilleure/Instructions/SoftFallback.cs b/ARMeilleure/Instructions/SoftFallback.cs index 611e8d6a..ef00fd9d 100644 --- a/ARMeilleure/Instructions/SoftFallback.cs +++ b/ARMeilleure/Instructions/SoftFallback.cs @@ -1017,13 +1017,13 @@ namespace ARMeilleure.Instructions { for (int e = 0; e <= 3; e++) { - uint t = ShaChoose(hash_abcd.GetUInt32(1), - hash_abcd.GetUInt32(2), - hash_abcd.GetUInt32(3)); + uint t = ShaChoose(hash_abcd.Extract(1), + hash_abcd.Extract(2), + hash_abcd.Extract(3)); - hash_e += Rol(hash_abcd.GetUInt32(0), 5) + t + wk.GetUInt32(e); + hash_e += Rol(hash_abcd.Extract(0), 5) + t + wk.Extract(e); - t = Rol(hash_abcd.GetUInt32(1), 30); + t = Rol(hash_abcd.Extract(1), 30); hash_abcd.Insert(1, t); @@ -1042,13 +1042,13 @@ namespace ARMeilleure.Instructions { for (int e = 0; e <= 3; e++) { - uint t = ShaMajority(hash_abcd.GetUInt32(1), - hash_abcd.GetUInt32(2), - hash_abcd.GetUInt32(3)); + uint t = ShaMajority(hash_abcd.Extract(1), + hash_abcd.Extract(2), + hash_abcd.Extract(3)); - hash_e += Rol(hash_abcd.GetUInt32(0), 5) + t + wk.GetUInt32(e); + hash_e += Rol(hash_abcd.Extract(0), 5) + t + wk.Extract(e); - t = Rol(hash_abcd.GetUInt32(1), 30); + t = Rol(hash_abcd.Extract(1), 30); hash_abcd.Insert(1, t); @@ -1062,13 +1062,13 @@ namespace ARMeilleure.Instructions { for (int e = 0; e <= 3; e++) { - uint t = ShaParity(hash_abcd.GetUInt32(1), - hash_abcd.GetUInt32(2), - hash_abcd.GetUInt32(3)); + uint t = ShaParity(hash_abcd.Extract(1), + hash_abcd.Extract(2), + hash_abcd.Extract(3)); - hash_e += Rol(hash_abcd.GetUInt32(0), 5) + t + wk.GetUInt32(e); + hash_e += Rol(hash_abcd.Extract(0), 5) + t + wk.Extract(e); - t = Rol(hash_abcd.GetUInt32(1), 30); + t = Rol(hash_abcd.Extract(1), 30); hash_abcd.Insert(1, t); @@ -1080,8 +1080,8 @@ namespace ARMeilleure.Instructions public static V128 Sha1SchedulePart1(V128 w0_3, V128 w4_7, V128 w8_11) { - ulong t2 = w4_7.GetUInt64(0); - ulong t1 = w0_3.GetUInt64(1); + ulong t2 = w4_7.Extract(0); + ulong t1 = w0_3.Extract(1); V128 result = new V128(t1, t2); @@ -1092,17 +1092,17 @@ namespace ARMeilleure.Instructions { V128 t = tw0_3 ^ (w12_15 >> 32); - uint tE0 = t.GetUInt32(0); - uint tE1 = t.GetUInt32(1); - uint tE2 = t.GetUInt32(2); - uint tE3 = t.GetUInt32(3); + uint tE0 = t.Extract(0); + uint tE1 = t.Extract(1); + uint tE2 = t.Extract(2); + uint tE3 = t.Extract(3); return new V128(tE0.Rol(1), tE1.Rol(1), tE2.Rol(1), tE3.Rol(1) ^ tE0.Rol(2)); } private static void Rol32_160(ref uint y, ref V128 x) { - uint xE3 = x.GetUInt32(3); + uint xE3 = x.Extract(3); x <<= 32; x.Insert(0, y); @@ -1148,11 +1148,11 @@ namespace ARMeilleure.Instructions for (int e = 0; e <= 3; e++) { - uint elt = (e <= 2 ? w0_3 : w4_7).GetUInt32(e <= 2 ? e + 1 : 0); + uint elt = (e <= 2 ? w0_3 : w4_7).Extract(e <= 2 ? e + 1 : 0); elt = elt.Ror(7) ^ elt.Ror(18) ^ elt.Lsr(3); - elt += w0_3.GetUInt32(e); + elt += w0_3.Extract(e); result.Insert(e, elt); } @@ -1164,7 +1164,7 @@ namespace ARMeilleure.Instructions { V128 result = new V128(); - ulong t1 = w12_15.GetUInt64(1); + ulong t1 = w12_15.Extract(1); for (int e = 0; e <= 1; e++) { @@ -1172,12 +1172,12 @@ namespace ARMeilleure.Instructions elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10); - elt += w0_3.GetUInt32(e) + w8_11.GetUInt32(e + 1); + elt += w0_3.Extract(e) + w8_11.Extract(e + 1); result.Insert(e, elt); } - t1 = result.GetUInt64(0); + t1 = result.Extract(0); for (int e = 2; e <= 3; e++) { @@ -1185,7 +1185,7 @@ namespace ARMeilleure.Instructions elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10); - elt += w0_3.GetUInt32(e) + (e == 2 ? w8_11 : w12_15).GetUInt32(e == 2 ? 3 : 0); + elt += w0_3.Extract(e) + (e == 2 ? w8_11 : w12_15).Extract(e == 2 ? 3 : 0); result.Insert(e, elt); } @@ -1197,21 +1197,21 @@ namespace ARMeilleure.Instructions { for (int e = 0; e <= 3; e++) { - uint chs = ShaChoose(y.GetUInt32(0), - y.GetUInt32(1), - y.GetUInt32(2)); + uint chs = ShaChoose(y.Extract(0), + y.Extract(1), + y.Extract(2)); - uint maj = ShaMajority(x.GetUInt32(0), - x.GetUInt32(1), - x.GetUInt32(2)); + uint maj = ShaMajority(x.Extract(0), + x.Extract(1), + x.Extract(2)); - uint t1 = y.GetUInt32(3) + ShaHashSigma1(y.GetUInt32(0)) + chs + w.GetUInt32(e); + uint t1 = y.Extract(3) + ShaHashSigma1(y.Extract(0)) + chs + w.Extract(e); - uint t2 = t1 + x.GetUInt32(3); + uint t2 = t1 + x.Extract(3); x.Insert(3, t2); - t2 = t1 + ShaHashSigma0(x.GetUInt32(0)) + maj; + t2 = t1 + ShaHashSigma0(x.Extract(0)) + maj; y.Insert(3, t2); @@ -1223,8 +1223,8 @@ namespace ARMeilleure.Instructions private static void Rol32_256(ref V128 y, ref V128 x) { - uint yE3 = y.GetUInt32(3); - uint xE3 = x.GetUInt32(3); + uint yE3 = y.Extract(3); + uint xE3 = x.Extract(3); y <<= 32; x <<= 32; diff --git a/ARMeilleure/Memory/MemoryManager.cs b/ARMeilleure/Memory/MemoryManager.cs index e4e8b2d2..c5a0323b 100644 --- a/ARMeilleure/Memory/MemoryManager.cs +++ b/ARMeilleure/Memory/MemoryManager.cs @@ -663,8 +663,8 @@ namespace ARMeilleure.Memory public void WriteVector128(long position, V128 value) { - WriteUInt64(position + 0, value.GetUInt64(0)); - WriteUInt64(position + 8, value.GetUInt64(1)); + WriteUInt64(position + 0, value.Extract(0)); + WriteUInt64(position + 8, value.Extract(1)); } public void WriteBytes(long position, byte[] data) diff --git a/ARMeilleure/State/NativeContext.cs b/ARMeilleure/State/NativeContext.cs index 0ab9a3fd..95d976ee 100644 --- a/ARMeilleure/State/NativeContext.cs +++ b/ARMeilleure/State/NativeContext.cs @@ -67,8 +67,8 @@ namespace ARMeilleure.State int offset = RegisterConsts.IntRegsCount * IntSize + index * VecSize; - Marshal.WriteInt64(BasePtr, offset + 0, value.GetInt64(0)); - Marshal.WriteInt64(BasePtr, offset + 8, value.GetInt64(1)); + Marshal.WriteInt64(BasePtr, offset + 0, value.Extract(0)); + Marshal.WriteInt64(BasePtr, offset + 8, value.Extract(1)); } public bool GetPstateFlag(PState flag) diff --git a/ARMeilleure/State/V128.cs b/ARMeilleure/State/V128.cs index eeb9ff1c..399cea13 100644 --- a/ARMeilleure/State/V128.cs +++ b/ARMeilleure/State/V128.cs @@ -1,20 +1,58 @@ using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ARMeilleure.State { + /// + /// Represents a 128-bit vector. + /// + [StructLayout(LayoutKind.Sequential, Size = 16)] public struct V128 : IEquatable { + // _e0 & _e1 could be marked as readonly, however they are not readonly because we modify them through the Unsafe + // APIs. This also means that one should be careful when changing the layout of this struct. + private ulong _e0; private ulong _e1; - private static V128 _zero = new V128(0, 0); - - public static V128 Zero => _zero; - - public V128(float value) : this(value, 0, 0, 0) { } + /// + /// Gets a new with all bits set to zero. + /// + public static V128 Zero => new V128(0, 0); + /// + /// Initializes a new instance of the struct with the specified value + /// as a scalar. + /// + /// Scalar value public V128(double value) : this(value, 0) { } + /// + /// Initializes a new instance of the struct with the specified elements. + /// + /// Element 0 + /// Element 1 + public V128(double e0, double e1) + { + _e0 = (ulong)BitConverter.DoubleToInt64Bits(e0); + _e1 = (ulong)BitConverter.DoubleToInt64Bits(e1); + } + + /// + /// Initializes a new instance of the struct with the specified value as a + /// scalar. + /// + /// Scalar value + public V128(float value) : this(value, 0, 0, 0) { } + + /// + /// Initializes a new instance of the struct with the specified elements. + /// + /// Element 0 + /// Element 1 + /// Element 2 + /// Element 3 public V128(float e0, float e1, float e2, float e3) { _e0 = (ulong)(uint)BitConverter.SingleToInt32Bits(e0) << 0; @@ -23,20 +61,41 @@ namespace ARMeilleure.State _e1 |= (ulong)(uint)BitConverter.SingleToInt32Bits(e3) << 32; } - public V128(double e0, double e1) + /// + /// Initializes a new instance of the struct with the specified + /// elements. + /// + /// Element 0 + /// Element 1 + public V128(long e0, long e1) : this((ulong)e0, (ulong)e1) { } + + /// + /// Initializes a new instance of the struct with the specified elements. + /// + /// Element 0 + /// Element 1 + public V128(ulong e0, ulong e1) { - _e0 = (ulong)BitConverter.DoubleToInt64Bits(e0); - _e1 = (ulong)BitConverter.DoubleToInt64Bits(e1); + _e0 = e0; + _e1 = e1; } - public V128(int e0, int e1, int e2, int e3) - { - _e0 = (ulong)(uint)e0 << 0; - _e0 |= (ulong)(uint)e1 << 32; - _e1 = (ulong)(uint)e2 << 0; - _e1 |= (ulong)(uint)e3 << 32; - } + /// + /// Initializes a new instance of the struct with the specified elements. + /// + /// Element 0 + /// Element 1 + /// Element 2 + /// Element 3 + public V128(int e0, int e1, int e2, int e3) : this((uint)e0, (uint)e1, (uint)e2, (uint)e3) { } + /// + /// Initializes a new instance of the struct with the specified elements. + /// + /// Element 0 + /// Element 1 + /// Element 2 + /// Element 3 public V128(uint e0, uint e1, uint e2, uint e3) { _e0 = (ulong)e0 << 0; @@ -45,133 +104,89 @@ namespace ARMeilleure.State _e1 |= (ulong)e3 << 32; } - public V128(long e0, long e1) - { - _e0 = (ulong)e0; - _e1 = (ulong)e1; - } - - public V128(ulong e0, ulong e1) - { - _e0 = e0; - _e1 = e1; - } - + /// + /// Initializes a new instance of the struct from the specified array. + /// + /// array to use public V128(byte[] data) { _e0 = (ulong)BitConverter.ToInt64(data, 0); _e1 = (ulong)BitConverter.ToInt64(data, 8); } - public void Insert(int index, uint value) + /// + /// Returns the value of the as a scalar. + /// + /// Type of scalar + /// Value of the as a scalar + /// Size of is larger than 16 bytes + public T As() where T : unmanaged { - switch (index) - { - case 0: _e0 = (_e0 & 0xffffffff00000000) | ((ulong)value << 0); break; - case 1: _e0 = (_e0 & 0x00000000ffffffff) | ((ulong)value << 32); break; - case 2: _e1 = (_e1 & 0xffffffff00000000) | ((ulong)value << 0); break; - case 3: _e1 = (_e1 & 0x00000000ffffffff) | ((ulong)value << 32); break; - - default: throw new ArgumentOutOfRangeException(nameof(index)); - } + return Extract(0); } - public void Insert(int index, ulong value) + /// + /// Extracts the element at the specified index as a from the . + /// + /// Element type + /// Index of element + /// Element at the specified index as a from the + /// + /// is out of bound or the size of is larger than 16 bytes + /// + public T Extract(int index) where T : unmanaged { - switch (index) - { - case 0: _e0 = value; break; - case 1: _e1 = value; break; + if ((uint)index >= GetElementCount()) + ThrowIndexOutOfRange(); - default: throw new ArgumentOutOfRangeException(nameof(index)); - } + // Performs: + // return *((*T)this + index); + return Unsafe.Add(ref Unsafe.As(ref this), index); } - public float AsFloat() + /// + /// Inserts the specified value into the element at the specified index in the . + /// + /// Element type + /// Index of element + /// Value to insert + /// + /// is out of bound or the size of is larger than 16 bytes + /// + public void Insert(int index, T value) where T : unmanaged { - return GetFloat(0); - } - - public double AsDouble() - { - return GetDouble(0); - } - - public float GetFloat(int index) - { - return BitConverter.Int32BitsToSingle(GetInt32(index)); - } - - public double GetDouble(int index) - { - return BitConverter.Int64BitsToDouble(GetInt64(index)); - } - - public int GetInt32(int index) => (int)GetUInt32(index); - public long GetInt64(int index) => (long)GetUInt64(index); - - public uint GetUInt32(int index) - { - switch (index) - { - case 0: return (uint)(_e0 >> 0); - case 1: return (uint)(_e0 >> 32); - case 2: return (uint)(_e1 >> 0); - case 3: return (uint)(_e1 >> 32); - } - - throw new ArgumentOutOfRangeException(nameof(index)); - } - - public ulong GetUInt64(int index) - { - switch (index) - { - case 0: return _e0; - case 1: return _e1; - } - - throw new ArgumentOutOfRangeException(nameof(index)); + if ((uint)index >= GetElementCount()) + ThrowIndexOutOfRange(); + + // Performs: + // *((*T)this + index) = value; + Unsafe.Add(ref Unsafe.As(ref this), index) = value; } + /// + /// Returns a new array which represents the . + /// + /// A new array which represents the public byte[] ToArray() { - byte[] e0Data = BitConverter.GetBytes(_e0); - byte[] e1Data = BitConverter.GetBytes(_e1); + byte[] data = new byte[16]; + Span span = data; - byte[] data = new byte[16]; - - Buffer.BlockCopy(e0Data, 0, data, 0, 8); - Buffer.BlockCopy(e1Data, 0, data, 8, 8); + BitConverter.TryWriteBytes(span, _e0); + BitConverter.TryWriteBytes(span.Slice(8), _e1); return data; } - public override int GetHashCode() - { - return HashCode.Combine(_e0, _e1); - } - - public static V128 operator ~(V128 x) - { - return new V128(~x._e0, ~x._e1); - } - - public static V128 operator &(V128 x, V128 y) - { - return new V128(x._e0 & y._e0, x._e1 & y._e1); - } - - public static V128 operator |(V128 x, V128 y) - { - return new V128(x._e0 | y._e0, x._e1 | y._e1); - } - - public static V128 operator ^(V128 x, V128 y) - { - return new V128(x._e0 ^ y._e0, x._e1 ^ y._e1); - } - + /// + /// Performs a bitwise logical left shift on the specified by the specified shift count. + /// + /// instance + /// Number of shifts + /// Result of left shift + /// + /// This supports shift counts up to 63; anything above may result in unexpected behaviour. + /// public static V128 operator <<(V128 x, int shift) { ulong shiftOut = x._e0 >> (64 - shift); @@ -179,6 +194,15 @@ namespace ARMeilleure.State return new V128(x._e0 << shift, (x._e1 << shift) | shiftOut); } + /// + /// Performs a bitwise logical right shift on the specified by the specified shift count. + /// + /// instance + /// Number of shifts + /// Result of right shift + /// + /// This supports shift counts up to 63; anything above may result in unexpected behaviour. + /// public static V128 operator >>(V128 x, int shift) { ulong shiftOut = x._e1 & ((1UL << shift) - 1); @@ -186,29 +210,93 @@ namespace ARMeilleure.State return new V128((x._e0 >> shift) | (shiftOut << (64 - shift)), x._e1 >> shift); } - public static bool operator ==(V128 x, V128 y) - { - return x.Equals(y); - } + /// + /// Performs a bitwise not on the specified . + /// + /// Target + /// Result of not operation + public static V128 operator ~(V128 x) => new V128(~x._e0, ~x._e1); - public static bool operator !=(V128 x, V128 y) - { - return !x.Equals(y); - } + /// + /// Performs a bitwise and on the specified instances. + /// + /// First instance + /// Second instance + /// Result of and operation + public static V128 operator &(V128 x, V128 y) => new V128(x._e0 & y._e0, x._e1 & y._e1); - public override bool Equals(object obj) - { - return obj is V128 vector && Equals(vector); - } + /// + /// Performs a bitwise or on the specified instances. + /// + /// First instance + /// Second instance + /// Result of or operation + public static V128 operator |(V128 x, V128 y) => new V128(x._e0 | y._e0, x._e1 | y._e1); + /// + /// Performs a bitwise exlusive or on the specified instances. + /// + /// First instance + /// Second instance + /// Result of exclusive or operation + public static V128 operator ^(V128 x, V128 y) => new V128(x._e0 ^ y._e0, x._e1 ^ y._e1); + + /// + /// Determines if the specified instances are equal. + /// + /// First instance + /// Second instance + /// true if equal; otherwise false + public static bool operator ==(V128 x, V128 y) => x.Equals(y); + + /// + /// Determines if the specified instances are not equal. + /// + /// First instance + /// Second instance + /// true if not equal; otherwise false + public static bool operator !=(V128 x, V128 y) => !x.Equals(y); + + /// + /// Determines if the specified is equal to this instance. + /// + /// Other instance + /// true if equal; otherwise false public bool Equals(V128 other) { return other._e0 == _e0 && other._e1 == _e1; } + /// + /// Determines if the specified is equal to this instance. + /// + /// Other instance + /// true if equal; otherwise false + public override bool Equals(object obj) + { + return obj is V128 vector && Equals(vector); + } + + /// + public override int GetHashCode() + { + return HashCode.Combine(_e0, _e1); + } + + /// public override string ToString() { return $"0x{_e1:X16}{_e0:X16}"; } + + private uint GetElementCount() where T : unmanaged + { + return (uint)(Unsafe.SizeOf() / Unsafe.SizeOf()); + } + + private static void ThrowIndexOutOfRange() + { + throw new ArgumentOutOfRangeException("index"); + } } } \ No newline at end of file diff --git a/Ryujinx.Tests/Cpu/CpuTest.cs b/Ryujinx.Tests/Cpu/CpuTest.cs index 4b7b0f6b..fb9a8f17 100644 --- a/Ryujinx.Tests/Cpu/CpuTest.cs +++ b/Ryujinx.Tests/Cpu/CpuTest.cs @@ -414,15 +414,15 @@ namespace Ryujinx.Tests.Cpu if (fpTolerances == FpTolerances.UpToOneUlpsS) { if (IsNormalOrSubnormalS(_unicornEmu.Q[0].AsFloat()) && - IsNormalOrSubnormalS(_context.GetV(0).AsFloat())) + IsNormalOrSubnormalS(_context.GetV(0).As())) { - Assert.That (_context.GetV(0).GetFloat(0), + Assert.That (_context.GetV(0).Extract(0), Is.EqualTo(_unicornEmu.Q[0].GetFloat(0)).Within(1).Ulps); - Assert.That (_context.GetV(0).GetFloat(1), + Assert.That (_context.GetV(0).Extract(1), Is.EqualTo(_unicornEmu.Q[0].GetFloat(1)).Within(1).Ulps); - Assert.That (_context.GetV(0).GetFloat(2), + Assert.That (_context.GetV(0).Extract(2), Is.EqualTo(_unicornEmu.Q[0].GetFloat(2)).Within(1).Ulps); - Assert.That (_context.GetV(0).GetFloat(3), + Assert.That (_context.GetV(0).Extract(3), Is.EqualTo(_unicornEmu.Q[0].GetFloat(3)).Within(1).Ulps); Console.WriteLine(fpTolerances); @@ -436,11 +436,11 @@ namespace Ryujinx.Tests.Cpu if (fpTolerances == FpTolerances.UpToOneUlpsD) { if (IsNormalOrSubnormalD(_unicornEmu.Q[0].AsDouble()) && - IsNormalOrSubnormalD(_context.GetV(0).AsDouble())) + IsNormalOrSubnormalD(_context.GetV(0).As())) { - Assert.That (_context.GetV(0).GetDouble(0), + Assert.That (_context.GetV(0).Extract(0), Is.EqualTo(_unicornEmu.Q[0].GetDouble(0)).Within(1).Ulps); - Assert.That (_context.GetV(0).GetDouble(1), + Assert.That (_context.GetV(0).Extract(1), Is.EqualTo(_unicornEmu.Q[0].GetDouble(1)).Within(1).Ulps); Console.WriteLine(fpTolerances); @@ -455,7 +455,7 @@ namespace Ryujinx.Tests.Cpu private static SimdValue V128ToSimdValue(V128 value) { - return new SimdValue(value.GetUInt64(0), value.GetUInt64(1)); + return new SimdValue(value.Extract(0), value.Extract(1)); } protected static V128 MakeVectorScalar(float value) => new V128(value); @@ -466,8 +466,8 @@ namespace Ryujinx.Tests.Cpu protected static V128 MakeVectorE0E1(ulong e0, ulong e1) => new V128(e0, e1); - protected static ulong GetVectorE0(V128 vector) => vector.GetUInt64(0); - protected static ulong GetVectorE1(V128 vector) => vector.GetUInt64(1); + protected static ulong GetVectorE0(V128 vector) => vector.Extract(0); + protected static ulong GetVectorE1(V128 vector) => vector.Extract(1); protected static ushort GenNormalH() { diff --git a/Ryujinx.Tests/Cpu/CpuTest32.cs b/Ryujinx.Tests/Cpu/CpuTest32.cs index 07354442..0cd8f4df 100644 --- a/Ryujinx.Tests/Cpu/CpuTest32.cs +++ b/Ryujinx.Tests/Cpu/CpuTest32.cs @@ -411,15 +411,15 @@ namespace Ryujinx.Tests.Cpu if (fpTolerances == FpTolerances.UpToOneUlpsS) { if (IsNormalOrSubnormalS(_unicornEmu.Q[0].AsFloat()) && - IsNormalOrSubnormalS(_context.GetV(0).AsFloat())) + IsNormalOrSubnormalS(_context.GetV(0).As())) { - Assert.That(_context.GetV(0).GetFloat(0), + Assert.That(_context.GetV(0).Extract(0), Is.EqualTo(_unicornEmu.Q[0].GetFloat(0)).Within(1).Ulps); - Assert.That(_context.GetV(0).GetFloat(1), + Assert.That(_context.GetV(0).Extract(1), Is.EqualTo(_unicornEmu.Q[0].GetFloat(1)).Within(1).Ulps); - Assert.That(_context.GetV(0).GetFloat(2), + Assert.That(_context.GetV(0).Extract(2), Is.EqualTo(_unicornEmu.Q[0].GetFloat(2)).Within(1).Ulps); - Assert.That(_context.GetV(0).GetFloat(3), + Assert.That(_context.GetV(0).Extract(3), Is.EqualTo(_unicornEmu.Q[0].GetFloat(3)).Within(1).Ulps); Console.WriteLine(fpTolerances); @@ -433,11 +433,11 @@ namespace Ryujinx.Tests.Cpu if (fpTolerances == FpTolerances.UpToOneUlpsD) { if (IsNormalOrSubnormalD(_unicornEmu.Q[0].AsDouble()) && - IsNormalOrSubnormalD(_context.GetV(0).AsDouble())) + IsNormalOrSubnormalD(_context.GetV(0).As())) { - Assert.That(_context.GetV(0).GetDouble(0), + Assert.That(_context.GetV(0).Extract(0), Is.EqualTo(_unicornEmu.Q[0].GetDouble(0)).Within(1).Ulps); - Assert.That(_context.GetV(0).GetDouble(1), + Assert.That(_context.GetV(0).Extract(1), Is.EqualTo(_unicornEmu.Q[0].GetDouble(1)).Within(1).Ulps); Console.WriteLine(fpTolerances); @@ -452,7 +452,7 @@ namespace Ryujinx.Tests.Cpu private static SimdValue V128ToSimdValue(V128 value) { - return new SimdValue(value.GetUInt64(0), value.GetUInt64(1)); + return new SimdValue(value.Extract(0), value.Extract(1)); } protected static V128 MakeVectorScalar(float value) => new V128(value); @@ -463,8 +463,8 @@ namespace Ryujinx.Tests.Cpu protected static V128 MakeVectorE0E1(ulong e0, ulong e1) => new V128(e0, e1); - protected static ulong GetVectorE0(V128 vector) => vector.GetUInt64(0); - protected static ulong GetVectorE1(V128 vector) => vector.GetUInt64(1); + protected static ulong GetVectorE0(V128 vector) => vector.Extract(0); + protected static ulong GetVectorE1(V128 vector) => vector.Extract(1); protected static ushort GenNormalH() { diff --git a/Ryujinx.Tests/Cpu/CpuTestMisc.cs b/Ryujinx.Tests/Cpu/CpuTestMisc.cs index 6d2440c1..9b31e68e 100644 --- a/Ryujinx.Tests/Cpu/CpuTestMisc.cs +++ b/Ryujinx.Tests/Cpu/CpuTestMisc.cs @@ -190,7 +190,7 @@ namespace Ryujinx.Tests.Cpu Opcode(0xD65F03C0); ExecuteOpcodes(); - Assert.That(GetContext().GetV(0).AsFloat(), Is.EqualTo(16f)); + Assert.That(GetContext().GetV(0).As(), Is.EqualTo(16f)); } [Explicit] @@ -236,7 +236,7 @@ namespace Ryujinx.Tests.Cpu Opcode(0xD65F03C0); ExecuteOpcodes(); - Assert.That(GetContext().GetV(0).AsDouble(), Is.EqualTo(16d)); + Assert.That(GetContext().GetV(0).As(), Is.EqualTo(16d)); } [Test, Ignore("The Tester supports only one return point.")]