| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790 |
- using ChocolArm64.State;
- using ChocolArm64.Translation;
- using System;
- using System.Runtime.CompilerServices;
- using System.Runtime.Intrinsics;
- using System.Runtime.Intrinsics.X86;
- namespace ChocolArm64.Instruction
- {
- static class AVectorHelper
- {
- private static readonly Vector128<float> Zero32_128Mask;
- static AVectorHelper()
- {
- if (!Sse2.IsSupported)
- {
- throw new PlatformNotSupportedException();
- }
- Zero32_128Mask = Sse.StaticCast<uint, float>(Sse2.SetVector128(0, 0, 0, 0xffffffff));
- }
- public static void EmitCall(AILEmitterCtx Context, string Name64, string Name128)
- {
- bool IsSimd64 = Context.CurrOp.RegisterSize == ARegisterSize.SIMD64;
- Context.EmitCall(typeof(AVectorHelper), IsSimd64 ? Name64 : Name128);
- }
- public static void EmitCall(AILEmitterCtx Context, string MthdName)
- {
- Context.EmitCall(typeof(AVectorHelper), MthdName);
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int SatF32ToS32(float Value)
- {
- if (float.IsNaN(Value)) return 0;
- return Value > int.MaxValue ? int.MaxValue :
- Value < int.MinValue ? int.MinValue : (int)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static long SatF32ToS64(float Value)
- {
- if (float.IsNaN(Value)) return 0;
- return Value > long.MaxValue ? long.MaxValue :
- Value < long.MinValue ? long.MinValue : (long)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static uint SatF32ToU32(float Value)
- {
- if (float.IsNaN(Value)) return 0;
- return Value > uint.MaxValue ? uint.MaxValue :
- Value < uint.MinValue ? uint.MinValue : (uint)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ulong SatF32ToU64(float Value)
- {
- if (float.IsNaN(Value)) return 0;
- return Value > ulong.MaxValue ? ulong.MaxValue :
- Value < ulong.MinValue ? ulong.MinValue : (ulong)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int SatF64ToS32(double Value)
- {
- if (double.IsNaN(Value)) return 0;
- return Value > int.MaxValue ? int.MaxValue :
- Value < int.MinValue ? int.MinValue : (int)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static long SatF64ToS64(double Value)
- {
- if (double.IsNaN(Value)) return 0;
- return Value > long.MaxValue ? long.MaxValue :
- Value < long.MinValue ? long.MinValue : (long)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static uint SatF64ToU32(double Value)
- {
- if (double.IsNaN(Value)) return 0;
- return Value > uint.MaxValue ? uint.MaxValue :
- Value < uint.MinValue ? uint.MinValue : (uint)Value;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ulong SatF64ToU64(double Value)
- {
- if (double.IsNaN(Value)) return 0;
- return Value > ulong.MaxValue ? ulong.MaxValue :
- Value < ulong.MinValue ? ulong.MinValue : (ulong)Value;
- }
- public static double Round(double Value, AThreadState State)
- {
- switch (State.FPRoundingMode())
- {
- 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 float RoundF(float Value, AThreadState State)
- {
- switch (State.FPRoundingMode())
- {
- 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 Vector128<float> Tbl1_V64(
- Vector128<float> Vector,
- Vector128<float> Tb0)
- {
- return Tbl(Vector, 8, Tb0);
- }
- public static Vector128<float> Tbl1_V128(
- Vector128<float> Vector,
- Vector128<float> Tb0)
- {
- return Tbl(Vector, 16, Tb0);
- }
- public static Vector128<float> Tbl2_V64(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1)
- {
- return Tbl(Vector, 8, Tb0, Tb1);
- }
- public static Vector128<float> Tbl2_V128(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1)
- {
- return Tbl(Vector, 16, Tb0, Tb1);
- }
- public static Vector128<float> Tbl3_V64(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1,
- Vector128<float> Tb2)
- {
- return Tbl(Vector, 8, Tb0, Tb1, Tb2);
- }
- public static Vector128<float> Tbl3_V128(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1,
- Vector128<float> Tb2)
- {
- return Tbl(Vector, 16, Tb0, Tb1, Tb2);
- }
- public static Vector128<float> Tbl4_V64(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1,
- Vector128<float> Tb2,
- Vector128<float> Tb3)
- {
- return Tbl(Vector, 8, Tb0, Tb1, Tb2, Tb3);
- }
- public static Vector128<float> Tbl4_V128(
- Vector128<float> Vector,
- Vector128<float> Tb0,
- Vector128<float> Tb1,
- Vector128<float> Tb2,
- Vector128<float> Tb3)
- {
- return Tbl(Vector, 16, Tb0, Tb1, Tb2, Tb3);
- }
- private static Vector128<float> Tbl(Vector128<float> Vector, int Bytes, params Vector128<float>[] Tb)
- {
- Vector128<float> Res = new Vector128<float>();
- byte[] Table = new byte[Tb.Length * 16];
- for (byte Index = 0; Index < Tb.Length; Index++)
- for (byte Index2 = 0; Index2 < 16; Index2++)
- {
- Table[Index * 16 + Index2] = (byte)VectorExtractIntZx(Tb[Index], Index2, 0);
- }
- for (byte Index = 0; Index < Bytes; Index++)
- {
- byte TblIdx = (byte)VectorExtractIntZx(Vector, Index, 0);
- if (TblIdx < Table.Length)
- {
- Res = VectorInsertInt(Table[TblIdx], Res, Index, 0);
- }
- }
- return Res;
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static double VectorExtractDouble(Vector128<float> Vector, byte Index)
- {
- if (Sse41.IsSupported)
- {
- return BitConverter.Int64BitsToDouble(Sse41.Extract(Sse.StaticCast<float, long>(Vector), Index));
- }
- else if (Sse2.IsSupported)
- {
- return BitConverter.Int64BitsToDouble((long)VectorExtractIntZx(Vector, Index, 3));
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static long VectorExtractIntSx(Vector128<float> Vector, byte Index, int Size)
- {
- if (Sse41.IsSupported)
- {
- if (Size == 0)
- {
- return (sbyte)Sse41.Extract(Sse.StaticCast<float, byte>(Vector), Index);
- }
- else if (Size == 1)
- {
- return (short)Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), Index);
- }
- else if (Size == 2)
- {
- return Sse41.Extract(Sse.StaticCast<float, int>(Vector), Index);
- }
- else if (Size == 3)
- {
- return Sse41.Extract(Sse.StaticCast<float, long>(Vector), Index);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- else if (Sse2.IsSupported)
- {
- if (Size == 0)
- {
- return (sbyte)VectorExtractIntZx(Vector, Index, Size);
- }
- else if (Size == 1)
- {
- return (short)VectorExtractIntZx(Vector, Index, Size);
- }
- else if (Size == 2)
- {
- return (int)VectorExtractIntZx(Vector, Index, Size);
- }
- else if (Size == 3)
- {
- return (long)VectorExtractIntZx(Vector, Index, Size);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ulong VectorExtractIntZx(Vector128<float> Vector, byte Index, int Size)
- {
- if (Sse41.IsSupported)
- {
- if (Size == 0)
- {
- return Sse41.Extract(Sse.StaticCast<float, byte>(Vector), Index);
- }
- else if (Size == 1)
- {
- return Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), Index);
- }
- else if (Size == 2)
- {
- return Sse41.Extract(Sse.StaticCast<float, uint>(Vector), Index);
- }
- else if (Size == 3)
- {
- return Sse41.Extract(Sse.StaticCast<float, ulong>(Vector), Index);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- else if (Sse2.IsSupported)
- {
- int ShortIdx = Size == 0
- ? Index >> 1
- : Index << (Size - 1);
- ushort Value = Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), (byte)ShortIdx);
- if (Size == 0)
- {
- return (byte)(Value >> (Index & 1) * 8);
- }
- else if (Size == 1)
- {
- return Value;
- }
- else if (Size == 2 || Size == 3)
- {
- ushort Value1 = Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), (byte)(ShortIdx + 1));
- if (Size == 2)
- {
- return (uint)(Value | (Value1 << 16));
- }
- ushort Value2 = Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), (byte)(ShortIdx + 2));
- ushort Value3 = Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), (byte)(ShortIdx + 3));
- return ((ulong)Value << 0) |
- ((ulong)Value1 << 16) |
- ((ulong)Value2 << 32) |
- ((ulong)Value3 << 48);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static float VectorExtractSingle(Vector128<float> Vector, byte Index)
- {
- if (Sse41.IsSupported)
- {
- return Sse41.Extract(Vector, Index);
- }
- else if (Sse2.IsSupported)
- {
- Vector128<ushort> ShortVector = Sse.StaticCast<float, ushort>(Vector);
- int Low = Sse2.Extract(ShortVector, (byte)(Index * 2 + 0));
- int High = Sse2.Extract(ShortVector, (byte)(Index * 2 + 1));
- return BitConverter.Int32BitsToSingle(Low | (High << 16));
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInsertDouble(double Value, Vector128<float> Vector, byte Index)
- {
- return VectorInsertInt((ulong)BitConverter.DoubleToInt64Bits(Value), Vector, Index, 3);
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInsertInt(ulong Value, Vector128<float> Vector, byte Index, int Size)
- {
- if (Sse41.IsSupported)
- {
- if (Size == 0)
- {
- return Sse.StaticCast<byte, float>(Sse41.Insert(Sse.StaticCast<float, byte>(Vector), (byte)Value, Index));
- }
- else if (Size == 1)
- {
- return Sse.StaticCast<ushort, float>(Sse2.Insert(Sse.StaticCast<float, ushort>(Vector), (ushort)Value, Index));
- }
- else if (Size == 2)
- {
- return Sse.StaticCast<uint, float>(Sse41.Insert(Sse.StaticCast<float, uint>(Vector), (uint)Value, Index));
- }
- else if (Size == 3)
- {
- return Sse.StaticCast<ulong, float>(Sse41.Insert(Sse.StaticCast<float, ulong>(Vector), Value, Index));
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- else if (Sse2.IsSupported)
- {
- Vector128<ushort> ShortVector = Sse.StaticCast<float, ushort>(Vector);
- int ShortIdx = Size == 0
- ? Index >> 1
- : Index << (Size - 1);
- if (Size == 0)
- {
- ushort ShortVal = Sse2.Extract(Sse.StaticCast<float, ushort>(Vector), (byte)ShortIdx);
- int Shift = (Index & 1) * 8;
- ShortVal &= (ushort)(0xff00 >> Shift);
- ShortVal |= (ushort)((byte)Value << Shift);
- return Sse.StaticCast<ushort, float>(Sse2.Insert(ShortVector, ShortVal, (byte)ShortIdx));
- }
- else if (Size == 1)
- {
- return Sse.StaticCast<ushort, float>(Sse2.Insert(Sse.StaticCast<float, ushort>(Vector), (ushort)Value, Index));
- }
- else if (Size == 2 || Size == 3)
- {
- ShortVector = Sse2.Insert(ShortVector, (ushort)(Value >> 0), (byte)(ShortIdx + 0));
- ShortVector = Sse2.Insert(ShortVector, (ushort)(Value >> 16), (byte)(ShortIdx + 1));
- if (Size == 3)
- {
- ShortVector = Sse2.Insert(ShortVector, (ushort)(Value >> 32), (byte)(ShortIdx + 2));
- ShortVector = Sse2.Insert(ShortVector, (ushort)(Value >> 48), (byte)(ShortIdx + 3));
- }
- return Sse.StaticCast<ushort, float>(ShortVector);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Size));
- }
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInsertSingle(float Value, Vector128<float> Vector, byte Index)
- {
- if (Sse41.IsSupported)
- {
- //Note: The if/else if is necessary to enable the JIT to
- //produce a single INSERTPS instruction instead of the
- //jump table fallback.
- if (Index == 0)
- {
- return Sse41.Insert(Vector, Value, 0x00);
- }
- else if (Index == 1)
- {
- return Sse41.Insert(Vector, Value, 0x10);
- }
- else if (Index == 2)
- {
- return Sse41.Insert(Vector, Value, 0x20);
- }
- else if (Index == 3)
- {
- return Sse41.Insert(Vector, Value, 0x30);
- }
- else
- {
- throw new ArgumentOutOfRangeException(nameof(Index));
- }
- }
- else if (Sse2.IsSupported)
- {
- int IntValue = BitConverter.SingleToInt32Bits(Value);
- ushort Low = (ushort)(IntValue >> 0);
- ushort High = (ushort)(IntValue >> 16);
- Vector128<ushort> ShortVector = Sse.StaticCast<float, ushort>(Vector);
- ShortVector = Sse2.Insert(ShortVector, Low, (byte)(Index * 2 + 0));
- ShortVector = Sse2.Insert(ShortVector, High, (byte)(Index * 2 + 1));
- return Sse.StaticCast<ushort, float>(ShortVector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> Sse41VectorInsertScalarSingle(float Value, Vector128<float> Vector)
- {
- //Note: 0b1110 is the mask to zero the upper bits.
- return Sse41.Insert(Vector, Value, 0b1110);
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<sbyte> VectorSByteZero()
- {
- if (Sse2.IsSupported)
- {
- return Sse2.SetZeroVector128<sbyte>();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<short> VectorInt16Zero()
- {
- if (Sse2.IsSupported)
- {
- return Sse2.SetZeroVector128<short>();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<int> VectorInt32Zero()
- {
- if (Sse2.IsSupported)
- {
- return Sse2.SetZeroVector128<int>();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<long> VectorInt64Zero()
- {
- if (Sse2.IsSupported)
- {
- return Sse2.SetZeroVector128<long>();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorSingleZero()
- {
- if (Sse.IsSupported)
- {
- return Sse.SetZeroVector128();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<double> VectorDoubleZero()
- {
- if (Sse2.IsSupported)
- {
- return Sse2.SetZeroVector128<double>();
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorZero32_128(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.And(Vector, Zero32_128Mask);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<sbyte> VectorSingleToSByte(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, sbyte>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<short> VectorSingleToInt16(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, short>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<int> VectorSingleToInt32(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, int>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<long> VectorSingleToInt64(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, long>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<byte> VectorSingleToByte(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, byte>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<ushort> VectorSingleToUInt16(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, ushort>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<uint> VectorSingleToUInt32(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, uint>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<ulong> VectorSingleToUInt64(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, ulong>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<double> VectorSingleToDouble(Vector128<float> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<float, double>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorSByteToSingle(Vector128<sbyte> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<sbyte, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInt16ToSingle(Vector128<short> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<short, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInt32ToSingle(Vector128<int> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<int, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorInt64ToSingle(Vector128<long> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<long, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorByteToSingle(Vector128<byte> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<byte, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorUInt16ToSingle(Vector128<ushort> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<ushort, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorUInt32ToSingle(Vector128<uint> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<uint, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorUInt64ToSingle(Vector128<ulong> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<ulong, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Vector128<float> VectorDoubleToSingle(Vector128<double> Vector)
- {
- if (Sse.IsSupported)
- {
- return Sse.StaticCast<double, float>(Vector);
- }
- throw new PlatformNotSupportedException();
- }
- }
- }
|