Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sve.IsSupported support #97814

Merged
merged 9 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ set( JIT_ARM64_HEADERS
emitfmtsarm64.h
emitfmtsarm64sve.h
hwintrinsiclistarm64.h
hwintrinsiclistarm64sve.h
instrsarm64.h
instrsarm64sve.h
registerarm64.h
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/hwintrinsiclistarm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ HARDWARE_INTRINSIC(Sha256, ScheduleUpdate1,

#endif // FEATURE_HW_INTRINSIC

#include "hwintrinsiclistarm64sve.h"

#undef HARDWARE_INTRINSIC

// clang-format on
24 changes: 24 additions & 0 deletions src/coreclr/jit/hwintrinsiclistarm64sve.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/*****************************************************************************/
#ifndef HARDWARE_INTRINSIC
#error Define HARDWARE_INTRINSIC before including this file
#endif
/*****************************************************************************/

// clang-format off

#ifdef FEATURE_HW_INTRINSICS
// ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
// ISA Function name SIMD size NumArg EncodesExtraTypeArg Instructions Category Flags
// {TYP_BYTE, TYP_UBYTE, TYP_SHORT, TYP_USHORT, TYP_INT, TYP_UINT, TYP_LONG, TYP_ULONG, TYP_FLOAT, TYP_DOUBLE}
// ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
// SVE Intrinsics


#endif // FEATURE_HW_INTRINSIC

#undef HARDWARE_INTRINSIC

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@
<type fullname="System.Runtime.Intrinsics.Arm.Sha256/Arm64">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.Intrinsics.Arm.Sve">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
<type fullname="System.Runtime.Intrinsics.Arm.Sve/Arm64">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -2632,6 +2632,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Rdm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sve.cs" />
</ItemGroup>
<ItemGroup Condition="'$(SupportsArmIntrinsics)' != 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\AdvSimd.PlatformNotSupported.cs" />
Expand All @@ -2642,6 +2643,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Rdm.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.PlatformNotSupported.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sve.PlatformNotSupported.cs" />
</ItemGroup>
<ItemGroup Condition="'$(SupportsWasmIntrinsics)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Wasm\WasmBase.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Numerics;

namespace System.Runtime.Intrinsics.Arm
{
/// <summary>
/// This class provides access to the ARM SVE hardware instructions via intrinsics
/// </summary>
[CLSCompliant(false)]
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
#if SYSTEM_PRIVATE_CORELIB
public
#else
internal
#endif
abstract class Sve : AdvSimd
{
internal Sve() { }

public static new bool IsSupported { [Intrinsic] get { return false; } }

public new abstract class Arm64 : AdvSimd.Arm64
{
internal Arm64() { }

public static new bool IsSupported { [Intrinsic] get { return false; } }
}
}
a74nh marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Numerics;

namespace System.Runtime.Intrinsics.Arm
{
/// <summary>
/// This class provides access to the ARM SVE hardware instructions via intrinsics
/// </summary>
[Intrinsic]
[CLSCompliant(false)]
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
public abstract class Sve : AdvSimd
{
internal Sve() { }

public static new bool IsSupported { get => IsSupported; }

[Intrinsic]
public new abstract class Arm64 : AdvSimd.Arm64
{
internal Arm64() { }

public static new bool IsSupported { get => IsSupported; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4142,6 +4142,19 @@ internal Arm64() { }
public static new bool IsSupported { get { throw null; } }
}
}
[System.CLSCompliantAttribute(false)]
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
public abstract partial class Sve : System.Runtime.Intrinsics.Arm.AdvSimd
{
internal Sve() { }
public static new bool IsSupported { get { throw null; } }

public new abstract partial class Arm64 : System.Runtime.Intrinsics.Arm.AdvSimd.Arm64
{
internal Arm64() { }
public static new bool IsSupported { get { throw null; } }
}
}
}
namespace System.Runtime.Intrinsics.X86
{
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,7 @@ typedef enum {
MONO_CPU_ARM64_NEON = 1 << 4,
MONO_CPU_ARM64_RDM = 1 << 5,
MONO_CPU_ARM64_DP = 1 << 6,
MONO_CPU_ARM64_SVE = 1 << 7,
#endif
} MonoCPUFeatures;

Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,7 @@ static const IntrinGroup supported_arm_intrinsics [] = {
{ "Rdm", MONO_CPU_ARM64_RDM, rdm_methods, sizeof (rdm_methods) },
{ "Sha1", MONO_CPU_ARM64_CRYPTO, sha1_methods, sizeof (sha1_methods) },
{ "Sha256", MONO_CPU_ARM64_CRYPTO, sha256_methods, sizeof (sha256_methods) },
{ "Sve", MONO_CPU_ARM64_SVE, unsupported, sizeof (unsupported) },
};

static MonoInst*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,12 @@
("SecureHashTernOpTest.template", new Dictionary<string, string> { ["TestName"] = "ScheduleUpdate1_Vector128_UInt32", ["Isa"] = "Sha256", ["LoadIsa"] = "AdvSimd", ["Method"] = "ScheduleUpdate1", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "0x00112233", ["NextValueOp2"] = "0x44556677", ["NextValueOp3"] = "0x8899AABB", ["ExpectedResult"] = "{0x248F1BDF, 0x248F1BDF, 0xB303DDBA, 0xF74821FE}"}),
};

(string templateFileName, Dictionary<string, string> templateData)[] SveInputs = Array.Empty<(string templateFileName, Dictionary<string, string> templateData)>();
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
{
//TODO-SVE: Add SVE tests
};
a74nh marked this conversation as resolved.
Show resolved Hide resolved


string projectName = args[0];
string templateDirectory = args[1];
string outputDirectory = args[2];
Expand All @@ -2910,6 +2916,7 @@
ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs);
ProcessInputs("Sha1", Sha1Inputs);
ProcessInputs("Sha256", Sha256Inputs);
ProcessInputs("Sve", SveInputs);

void ProcessInputs(string groupName, (string templateFileName, Dictionary<string, string> templateData)[] inputs)
{
Expand Down
1 change: 1 addition & 0 deletions src/tests/JIT/HardwareIntrinsics/Arm/Shared/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void PrintSupportedIsa()
TestLibrary.TestFramework.LogInformation($" Rdm: {Rdm.IsSupported}");
TestLibrary.TestFramework.LogInformation($" Sha1: {Sha1.IsSupported}");
TestLibrary.TestFramework.LogInformation($" Sha256: {Sha256.IsSupported}");
TestLibrary.TestFramework.LogInformation($" Sve: {Sve.IsSupported}");
TestLibrary.TestFramework.LogInformation(string.Empty);
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/tests/JIT/HardwareIntrinsics/Arm/Sve/Program.Sve.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;

namespace JIT.HardwareIntrinsics.Arm._Sve
{
public static partial class Program
{
static Program()
{
JIT.HardwareIntrinsics.Arm.Program.PrintSupportedIsa();
}
}
}
14 changes: 14 additions & 0 deletions src/tests/JIT/HardwareIntrinsics/Arm/Sve/Sve_r.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<DebugType>Embedded</DebugType>
<Optimize />
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.Sve.cs" />
<Compile Include="..\Shared\Helpers.cs" />
<Compile Include="..\Shared\Program.cs" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions src/tests/JIT/HardwareIntrinsics/Arm/Sve/Sve_ro.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<DebugType>Embedded</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.Sve.cs" />
<Compile Include="..\Shared\Helpers.cs" />
<Compile Include="..\Shared\Program.cs" />
</ItemGroup>
</Project>
Loading