Skip to content

Commit b449152

Browse files
a74nhkunalspathak
andauthored
Add Sve.IsSupported support (#97814)
* Add Sve.IsSupported support * Remove debugging * Add RequiresPreviewFeaturesAttribute in PlatformNotSupported file * fix the base class name * Add mono checks * Review cleanups * Remove dummy sve test * Fix Sve.PlatformNotSupported.cs * Remove intrinsic marking --------- Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
1 parent 9655619 commit b449152

File tree

15 files changed

+167
-0
lines changed

15 files changed

+167
-0
lines changed

src/coreclr/jit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ set( JIT_ARM64_HEADERS
402402
emitfmtsarm64.h
403403
emitfmtsarm64sve.h
404404
hwintrinsiclistarm64.h
405+
hwintrinsiclistarm64sve.h
405406
instrsarm64.h
406407
instrsarm64sve.h
407408
registerarm64.h

src/coreclr/jit/hwintrinsiclistarm64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ HARDWARE_INTRINSIC(Sha256, ScheduleUpdate1,
806806

807807
#endif // FEATURE_HW_INTRINSIC
808808

809+
#include "hwintrinsiclistarm64sve.h"
810+
809811
#undef HARDWARE_INTRINSIC
810812

811813
// clang-format on
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
/*****************************************************************************/
5+
#ifndef HARDWARE_INTRINSIC
6+
#error Define HARDWARE_INTRINSIC before including this file
7+
#endif
8+
/*****************************************************************************/
9+
10+
// clang-format off
11+
12+
#ifdef FEATURE_HW_INTRINSICS
13+
// ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
14+
// ISA Function name SIMD size NumArg EncodesExtraTypeArg Instructions Category Flags
15+
// {TYP_BYTE, TYP_UBYTE, TYP_SHORT, TYP_USHORT, TYP_INT, TYP_UINT, TYP_LONG, TYP_ULONG, TYP_FLOAT, TYP_DOUBLE}
16+
// ***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
17+
// SVE Intrinsics
18+
19+
20+
#endif // FEATURE_HW_INTRINSIC
21+
22+
#undef HARDWARE_INTRINSIC
23+
24+
// clang-format on

src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.NoArmIntrinsics.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,11 @@
5151
<type fullname="System.Runtime.Intrinsics.Arm.Sha256/Arm64">
5252
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
5353
</type>
54+
<type fullname="System.Runtime.Intrinsics.Arm.Sve">
55+
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
56+
</type>
57+
<type fullname="System.Runtime.Intrinsics.Arm.Sve/Arm64">
58+
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
59+
</type>
5460
</assembly>
5561
</linker>

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,7 @@
26332633
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Rdm.cs" />
26342634
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.cs" />
26352635
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.cs" />
2636+
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sve.cs" />
26362637
</ItemGroup>
26372638
<ItemGroup Condition="'$(SupportsArmIntrinsics)' != 'true'">
26382639
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\AdvSimd.PlatformNotSupported.cs" />
@@ -2643,6 +2644,7 @@
26432644
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Rdm.PlatformNotSupported.cs" />
26442645
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha1.PlatformNotSupported.cs" />
26452646
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sha256.PlatformNotSupported.cs" />
2647+
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Arm\Sve.PlatformNotSupported.cs" />
26462648
</ItemGroup>
26472649
<ItemGroup Condition="'$(SupportsWasmIntrinsics)' == 'true'">
26482650
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Wasm\WasmBase.cs" />
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics.CodeAnalysis;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.Intrinsics;
7+
using System.Numerics;
8+
9+
namespace System.Runtime.Intrinsics.Arm
10+
{
11+
/// <summary>
12+
/// This class provides access to the ARM SVE hardware instructions via intrinsics
13+
/// </summary>
14+
[CLSCompliant(false)]
15+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
16+
#if SYSTEM_PRIVATE_CORELIB
17+
public
18+
#else
19+
internal
20+
#endif
21+
abstract class Sve : AdvSimd
22+
{
23+
internal Sve() { }
24+
25+
public static new bool IsSupported { [Intrinsic] get { return false; } }
26+
27+
public new abstract class Arm64 : AdvSimd.Arm64
28+
{
29+
internal Arm64() { }
30+
31+
public static new bool IsSupported { [Intrinsic] get { return false; } }
32+
}
33+
}
34+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics.CodeAnalysis;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.Intrinsics;
7+
using System.Numerics;
8+
9+
namespace System.Runtime.Intrinsics.Arm
10+
{
11+
/// <summary>
12+
/// This class provides access to the ARM SVE hardware instructions via intrinsics
13+
/// </summary>
14+
[Intrinsic]
15+
[CLSCompliant(false)]
16+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
17+
public abstract class Sve : AdvSimd
18+
{
19+
internal Sve() { }
20+
21+
public static new bool IsSupported { get => IsSupported; }
22+
23+
[Intrinsic]
24+
public new abstract class Arm64 : AdvSimd.Arm64
25+
{
26+
internal Arm64() { }
27+
28+
public static new bool IsSupported { get => IsSupported; }
29+
}
30+
}
31+
}

src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,6 +4150,19 @@ internal Arm64() { }
41504150
public static new bool IsSupported { get { throw null; } }
41514151
}
41524152
}
4153+
[System.CLSCompliantAttribute(false)]
4154+
[System.Runtime.Versioning.RequiresPreviewFeaturesAttribute("Sve is in preview.")]
4155+
public abstract partial class Sve : System.Runtime.Intrinsics.Arm.AdvSimd
4156+
{
4157+
internal Sve() { }
4158+
public static new bool IsSupported { get { throw null; } }
4159+
4160+
public new abstract partial class Arm64 : System.Runtime.Intrinsics.Arm.AdvSimd.Arm64
4161+
{
4162+
internal Arm64() { }
4163+
public static new bool IsSupported { get { throw null; } }
4164+
}
4165+
}
41534166
}
41544167
namespace System.Runtime.Intrinsics.X86
41554168
{

src/mono/mono/mini/mini.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,6 +2920,7 @@ typedef enum {
29202920
MONO_CPU_ARM64_NEON = 1 << 4,
29212921
MONO_CPU_ARM64_RDM = 1 << 5,
29222922
MONO_CPU_ARM64_DP = 1 << 6,
2923+
MONO_CPU_ARM64_SVE = 1 << 7,
29232924
#endif
29242925
} MonoCPUFeatures;
29252926

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,6 +3920,7 @@ static const IntrinGroup supported_arm_intrinsics [] = {
39203920
{ "Rdm", MONO_CPU_ARM64_RDM, rdm_methods, sizeof (rdm_methods) },
39213921
{ "Sha1", MONO_CPU_ARM64_CRYPTO, sha1_methods, sizeof (sha1_methods) },
39223922
{ "Sha256", MONO_CPU_ARM64_CRYPTO, sha256_methods, sizeof (sha256_methods) },
3923+
{ "Sve", MONO_CPU_ARM64_SVE, unsupported, sizeof (unsupported) },
39233924
};
39243925

39253926
static MonoInst*

src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,6 +2893,12 @@
28932893
("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}"}),
28942894
};
28952895

2896+
(string templateFileName, Dictionary<string, string> templateData)[] SveInputs = Array.Empty<(string templateFileName, Dictionary<string, string> templateData)>();
2897+
{
2898+
//TODO-SVE: Add SVE tests
2899+
};
2900+
2901+
28962902
string projectName = args[0];
28972903
string templateDirectory = args[1];
28982904
string outputDirectory = args[2];
@@ -2910,6 +2916,7 @@
29102916
ProcessInputs("Rdm.Arm64", Rdm_Arm64Inputs);
29112917
ProcessInputs("Sha1", Sha1Inputs);
29122918
ProcessInputs("Sha256", Sha256Inputs);
2919+
ProcessInputs("Sve", SveInputs);
29132920

29142921
void ProcessInputs(string groupName, (string templateFileName, Dictionary<string, string> templateData)[] inputs)
29152922
{

src/tests/JIT/HardwareIntrinsics/Arm/Shared/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static void PrintSupportedIsa()
2121
TestLibrary.TestFramework.LogInformation($" Rdm: {Rdm.IsSupported}");
2222
TestLibrary.TestFramework.LogInformation($" Sha1: {Sha1.IsSupported}");
2323
TestLibrary.TestFramework.LogInformation($" Sha256: {Sha256.IsSupported}");
24+
TestLibrary.TestFramework.LogInformation($" Sve: {Sve.IsSupported}");
2425
TestLibrary.TestFramework.LogInformation(string.Empty);
2526
}
2627
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
7+
namespace JIT.HardwareIntrinsics.Arm._Sve
8+
{
9+
public static partial class Program
10+
{
11+
static Program()
12+
{
13+
JIT.HardwareIntrinsics.Arm.Program.PrintSupportedIsa();
14+
}
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<DebugType>Embedded</DebugType>
7+
<Optimize />
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="Program.Sve.cs" />
11+
<Compile Include="..\Shared\Helpers.cs" />
12+
<Compile Include="..\Shared\Program.cs" />
13+
</ItemGroup>
14+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4+
</PropertyGroup>
5+
<PropertyGroup>
6+
<DebugType>Embedded</DebugType>
7+
<Optimize>True</Optimize>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<Compile Include="Program.Sve.cs" />
11+
<Compile Include="..\Shared\Helpers.cs" />
12+
<Compile Include="..\Shared\Program.cs" />
13+
</ItemGroup>
14+
</Project>

0 commit comments

Comments
 (0)