mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-25 12:58:46 +00:00
refactor(test): exclude platform-specific Unpack impl
can't have coverage on SSE3/AVX2 instructions if CPU doesn't support it.
This commit is contained in:
parent
d022a71ce6
commit
db96c9e6fb
@ -1,4 +1,5 @@
|
|||||||
#if NET7_0_OR_GREATER
|
#if NET7_0_OR_GREATER
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@ -48,6 +49,28 @@ public static class BinaryIntegerExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnpackInternal(value, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||||
|
private static void UnpackInternal_Fallback<TInteger>(this TInteger value, Span<bool> destination)
|
||||||
|
where TInteger : unmanaged, IBinaryInteger<TInteger>
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
int bitCount = sizeof(TInteger) * 8;
|
||||||
|
for (var index = 0; index < bitCount; index++)
|
||||||
|
{
|
||||||
|
destination[index] = (value & (TInteger.One << index)) != TInteger.Zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ExcludeFromCodeCoverage]
|
||||||
|
[MethodImpl(CompilerResources.MaxOptimization)]
|
||||||
|
private static void UnpackInternal<TInteger>(TInteger value, Span<bool> destination)
|
||||||
|
where TInteger : unmanaged, IBinaryInteger<TInteger>
|
||||||
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case byte valueByte when Sse3.IsSupported:
|
case byte valueByte when Sse3.IsSupported:
|
||||||
@ -71,19 +94,5 @@ public static class BinaryIntegerExtensions
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(CompilerResources.MaxOptimization)]
|
|
||||||
internal static void UnpackInternal_Fallback<TInteger>(this TInteger value, Span<bool> destination)
|
|
||||||
where TInteger : unmanaged, IBinaryInteger<TInteger>
|
|
||||||
{
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
int bitCount = sizeof(TInteger) * 8;
|
|
||||||
for (var index = 0; index < bitCount; index++)
|
|
||||||
{
|
|
||||||
destination[index] = (value & (TInteger.One << index)) != TInteger.Zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user