Skip to content

Commit

Permalink
Intrinsics support for WidenFourAsciiBytesToUtf16AndWriteToBuffer (#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashanth Govindarajan authored Jul 10, 2020
1 parent 8ed502f commit 7fab504
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/libraries/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@
<Target Name="GetDocumentationFile"
Returns="$(DocumentationFile)"/>

<PropertyGroup>
<DefineConstants Condition="'$(IsPrerelease)' != 'false' and '$(TargetFramework)' != '$(NetCoreAppCurrent)'">$(DefineConstants),USE_INTERNAL_ACCESSIBILITY</DefineConstants>
</PropertyGroup>

<!-- Adds Nullable annotation attributes to netstandard <= 2.0 builds -->
<Choose>
<When Condition="'$(Nullable)' != '' and ($(TargetFramework.StartsWith('netstandard1')) or '$(TargetFramework)' == 'netstandard2.0' or $(TargetFramework.StartsWith('netcoreapp2')) or '$(TargetFrameworkIdentifier)' == '.NETFramework')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ namespace System.Runtime.Intrinsics.Arm
/// This class provides access to the ARM AdvSIMD hardware instructions via intrinsics
/// </summary>
[CLSCompliant(false)]
public abstract class AdvSimd : ArmBase
#if USE_INTERNAL_ACCESSIBILITY
internal
#else
public
#endif
abstract class AdvSimd : ArmBase
{
internal AdvSimd() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ namespace System.Runtime.Intrinsics.Arm
/// This class provides access to the ARM base hardware instructions via intrinsics
/// </summary>
[CLSCompliant(false)]
public abstract class ArmBase
#if USE_INTERNAL_ACCESSIBILITY
internal
#else
public
#endif
abstract class ArmBase
{
internal ArmBase() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;

#if SYSTEM_PRIVATE_CORELIB
Expand Down Expand Up @@ -1700,6 +1701,12 @@ internal static void WidenFourAsciiBytesToUtf16AndWriteToBuffer(ref char outputB
Vector128<ulong> vecWide = Sse2.UnpackLow(vecNarrow, Vector128<byte>.Zero).AsUInt64();
Unsafe.WriteUnaligned<ulong>(ref Unsafe.As<char, byte>(ref outputBuffer), Sse2.X64.ConvertToUInt64(vecWide));
}
else if (AdvSimd.Arm64.IsSupported)
{
Vector128<byte> vecNarrow = AdvSimd.DuplicateToVector128(value).AsByte();
Vector128<ulong> vecWide = AdvSimd.Arm64.ZipLow(vecNarrow, Vector128<byte>.Zero).AsUInt64();
Unsafe.WriteUnaligned<ulong>(ref Unsafe.As<char, byte>(ref outputBuffer), vecWide.ToScalar());
}
else
{
if (BitConverter.IsLittleEndian)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<ItemGroup Condition="'$(IsPrerelease)' != 'false' AND '$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<Compile Include="System\Globalization\GlobalizationMode.cs" />
<Compile Include="System\Runtime\Intrinsics\Intrinsics.Shims.cs" />
<Compile Include="$(CoreLibSharedDir)\System\Runtime\Intrinsics\Arm\AdvSimd.PlatformNotSupported.cs" Link="System\Runtime\Intrinsics\Arm\AdvSimd.PlatformNotSupported.cs" />
<Compile Include="$(CoreLibSharedDir)\System\Runtime\Intrinsics\Arm\ArmBase.PlatformNotSupported.cs" Link="System\Runtime\Intrinsics\Arm\ArmBase.PlatformNotSupported.cs" />
<Compile Include="System\ThrowHelper.cs" />
<Compile Include="System\Utf8Extensions.Portable.cs" />
<Compile Include="System\Utf8String.Portable.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ internal static class Vector128
public static Vector128<ulong> AsUInt64<T>(this Vector128<T> vector) where T : struct => throw new PlatformNotSupportedException();
public static T GetElement<T>(this Vector128<T> vector, int index) where T : struct => throw new PlatformNotSupportedException();
public static T ToScalar<T>(this Vector64<T> vector) where T : struct => throw new PlatformNotSupportedException();
public static unsafe Vector128<ulong> CreateScalar(ulong value) => throw new PlatformNotSupportedException();
public static T ToScalar<T>(this Vector128<T> vector) where T : struct => throw new PlatformNotSupportedException();
}
internal readonly struct Vector128<T>
where T : struct
Expand Down Expand Up @@ -127,27 +129,13 @@ public abstract class X64
}
}

namespace System.Runtime.Intrinsics.Arm
namespace System.Runtime.CompilerServices
{
internal abstract class ArmBase
// Calls to methods or references to fields marked with this attribute may be replaced at
// some call sites with jit intrinsic expansions.
// Types marked with this attribute may be specially treated by the runtime/compiler.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
internal sealed class IntrinsicAttribute : Attribute
{
public abstract class Arm64
{
public const bool IsSupported = false;
public static int LeadingZeroCount(ulong value) => throw new PlatformNotSupportedException();
public static uint ReverseElementBits(ulong value) => throw new PlatformNotSupportedException();
}
public const bool IsSupported = false;
public static int LeadingZeroCount(uint value) => throw new PlatformNotSupportedException();
public static uint ReverseElementBits(uint value) => throw new PlatformNotSupportedException();
}

internal abstract class AdvSimd : ArmBase
{
public new abstract class Arm64 : ArmBase.Arm64
{
public static Vector64<byte> AddAcross(Vector64<byte> value) => throw new PlatformNotSupportedException();
}
public static Vector64<byte> PopCount(Vector64<byte> value) => throw new PlatformNotSupportedException();
}
}

0 comments on commit 7fab504

Please sign in to comment.