Quellcode durchsuchen

Enable detection of HW intrinsics (dotnet/corert#6836)

I took the liberty of marking the types containing the hardware intrinsics as [Intrinsic] to avoid doing a name check on everything in the system module. It feels like we should take advantage of this attribute in CoreCLR too.

This doesn't actually enable the support because RyuJIT unconditionally disables HW intrinsics for prejit (both CoreRT and CPAOT are considered prejit). We might want to do something about this on the RyuJIT side to address that (for CPAOT, to be able to pregenerate best code possible ahead of time, assuming a fixed ISA; and for CoreRT without JIT, where the concerns about AVX-SSE penalty don't apply). See conversation in dotnet/coreclr#21603

Signed-off-by: dotnet-bot <[email protected]>
Michal Strehovský vor 7 Jahren
Ursprung
Commit
3c0c8adbf8
25 geänderte Dateien mit 81 neuen und 4 gelöschten Zeilen
  1. 4 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs
  2. 5 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs
  3. 4 1
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs
  4. 5 1
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.cs
  5. 4 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs
  6. 5 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs
  7. 4 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs
  8. 5 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs
  9. 4 1
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs
  10. 5 1
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs
  11. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.cs
  12. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs
  13. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.cs
  14. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.cs
  15. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.cs
  16. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.cs
  17. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.cs
  18. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.cs
  19. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.cs
  20. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.cs
  21. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs
  22. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.cs
  23. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs
  24. 3 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.cs
  25. 2 0
      netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.cs

+ 4 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 

+ 5 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
@@ -9,6 +13,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     /// Arm64 CPU indicate support for this feature by setting
     /// ID_AA64ISAR0_EL1.AES is 1 or better
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public static class Aes
     {

+ 4 - 1
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs

@@ -1,7 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
-
 namespace System.Runtime.Intrinsics.Arm.Arm64
 {
     /// <summary>

+ 5 - 1
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.cs

@@ -1,7 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
-
 namespace System.Runtime.Intrinsics.Arm.Arm64
 {
     /// <summary>
@@ -9,6 +12,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     ///
     /// These intrinsics are supported by all Arm64 CPUs
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public static class Base
     {

+ 4 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 

+ 5 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
@@ -9,6 +13,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     /// Arm64 CPU indicate support for this feature by setting
     /// ID_AA64ISAR0_EL1.SHA1 is 1 or better
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public static class Sha1
     {

+ 4 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 

+ 5 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs

@@ -1,3 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
@@ -9,6 +13,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     /// Arm64 CPU indicate support for this feature by setting
     /// ID_AA64ISAR0_EL1.SHA2 is 1 or better
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public static class Sha256
     {

+ 4 - 1
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs

@@ -1,7 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
-
 namespace System.Runtime.Intrinsics.Arm.Arm64
 {
     /// <summary>

+ 5 - 1
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs

@@ -1,7 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
 using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
-
 namespace System.Runtime.Intrinsics.Arm.Arm64
 {
     /// <summary>
@@ -10,6 +13,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     /// Arm64 CPU indicate support for this feature by setting
     /// ID_AA64PFR0_EL1.AdvSIMD == 0 or better.
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public static class Simd
     {

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel AES hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Aes : Sse2
     {

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 using Internal.Runtime.CompilerServices;
 
@@ -11,6 +12,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel AVX hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Avx : Sse42
     {

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel AVX2 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Avx2 : Avx
     {

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel BMI1 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Bmi1
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public abstract class X64
         {
             internal X64() { }

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel BMI2 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Bmi2
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public abstract class X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel FMA hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Fma : Avx
     {

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel LZCNT hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Lzcnt
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public abstract class X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel PCLMULQDQ hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Pclmulqdq : Sse2
     {

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel POPCNT hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Popcnt : Sse42
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public new static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public new abstract class X64 : Sse41.X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.cs

@@ -11,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSE hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Sse
     {
@@ -18,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public abstract class X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs

@@ -11,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSE2 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Sse2 : Sse
     {
@@ -18,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public new static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public new abstract class X64 : Sse.X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSE3 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Sse3 : Sse2
     {

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSE4.1 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Sse41 : Ssse3
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public new static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public new abstract class X64 : Sse2.X64
         {
             internal X64() { }

+ 3 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSE4.2 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Sse42 : Sse41
     {
@@ -17,6 +19,7 @@ namespace System.Runtime.Intrinsics.X86
 
         public new static bool IsSupported { get => IsSupported; }
 
+        [Intrinsic]
         public new abstract class X64 : Sse41.X64
         {
             internal X64() { }

+ 2 - 0
netcore/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Runtime.CompilerServices;
 using System.Runtime.Intrinsics;
 
 namespace System.Runtime.Intrinsics.X86
@@ -10,6 +11,7 @@ namespace System.Runtime.Intrinsics.X86
     /// <summary>
     /// This class provides access to Intel SSSE3 hardware instructions via intrinsics
     /// </summary>
+    [Intrinsic]
     [CLSCompliant(false)]
     public abstract class Ssse3 : Sse3
     {