From 08303f54448b909a8cb6fc19cb45c6fc2cddca01 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Tue, 4 Dec 2018 16:06:39 -0800 Subject: [PATCH 1/3] Improve BMI2 MultiplyNoFlags APIs (dotnet/coreclr#21362) Signed-off-by: dotnet-bot --- .../X86/Bmi2.PlatformNotSupported.cs | 21 +++++++++++++++++-- .../System/Runtime/Intrinsics/X86/Bmi2.cs | 21 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs b/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs index fd0a2d8fb900..77d3fbfc7359 100644 --- a/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs +++ b/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs @@ -33,9 +33,18 @@ internal X64() { } /// /// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi) /// MULX r64a, r64b, reg/m64 + /// The above native signature does not directly correspond to the managed signature. /// This intrinisc is only available on 64-bit processes /// - public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) { throw new PlatformNotSupportedException(); } + public static ulong MultiplyNoFlags(ulong left, ulong right) { throw new PlatformNotSupportedException(); } + + /// + /// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi) + /// MULX r64a, r64b, reg/m64 + /// The above native signature does not directly correspond to the managed signature. + /// This intrinisc is only available on 64-bit processes + /// + public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* low) { throw new PlatformNotSupportedException(); } /// /// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask) @@ -61,8 +70,16 @@ internal X64() { } /// /// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi) /// MULX r32a, r32b, reg/m32 + /// The above native signature does not directly correspond to the managed signature. + /// + public static uint MultiplyNoFlags(uint left, uint right) { throw new PlatformNotSupportedException(); } + + /// + /// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi) + /// MULX r32a, r32b, reg/m32 + /// The above native signature does not directly correspond to the managed signature. /// - public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) { throw new PlatformNotSupportedException(); } + public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* low) { throw new PlatformNotSupportedException(); } /// /// unsigned int _pdep_u32 (unsigned int a, unsigned int mask) diff --git a/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.cs b/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.cs index f535e0abd823..b701fd093f15 100644 --- a/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.cs +++ b/src/Common/src/CoreLib/System/Runtime/Intrinsics/X86/Bmi2.cs @@ -33,9 +33,18 @@ internal X64() { } /// /// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi) /// MULX r64a, r64b, reg/m64 + /// The above native signature does not directly correspond to the managed signature. /// This intrinisc is only available on 64-bit processes /// - public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* high) => MultiplyNoFlags(left, right, high); + public static ulong MultiplyNoFlags(ulong left, ulong right) => MultiplyNoFlags(left, right); + + /// + /// unsigned __int64 _mulx_u64 (unsigned __int64 a, unsigned __int64 b, unsigned __int64* hi) + /// MULX r64a, r64b, reg/m64 + /// The above native signature does not directly correspond to the managed signature. + /// This intrinisc is only available on 64-bit processes + /// + public static unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* low) => MultiplyNoFlags(left, right, low); /// /// unsigned __int64 _pdep_u64 (unsigned __int64 a, unsigned __int64 mask) @@ -61,8 +70,16 @@ internal X64() { } /// /// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi) /// MULX r32a, r32b, reg/m32 + /// The above native signature does not directly correspond to the managed signature. + /// + public static uint MultiplyNoFlags(uint left, uint right) => MultiplyNoFlags(left, right); + + /// + /// unsigned int _mulx_u32 (unsigned int a, unsigned int b, unsigned int* hi) + /// MULX r32a, r32b, reg/m32 + /// The above native signature does not directly correspond to the managed signature. /// - public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* high) => MultiplyNoFlags(left, right, high); + public static unsafe uint MultiplyNoFlags(uint left, uint right, uint* low) => MultiplyNoFlags(left, right, low); /// /// unsigned int _pdep_u32 (unsigned int a, unsigned int mask) From d7d86fc483a93284799ae7d068b1d80677ac068c Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 30 Nov 2018 17:24:19 -0500 Subject: [PATCH 2/3] Add AsyncIteratorStateMachineAttribute Exactly follows the design of AsyncStateMachineAttribute and IteratorStateMachineAttribute; the only thing different is the type name, "AsyncIterator" instead of "Async" and "Iterator". Signed-off-by: dotnet-bot --- .../System.Private.CoreLib.Shared.projitems | 1 + .../AsyncIteratorStateMachineAttribute.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs diff --git a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems index fc59dfd76319..56a0b1387f4f 100644 --- a/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems +++ b/src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems @@ -481,6 +481,7 @@ + diff --git a/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs b/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs new file mode 100644 index 000000000000..c93156be4fa1 --- /dev/null +++ b/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs @@ -0,0 +1,15 @@ +// 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. + +namespace System.Runtime.CompilerServices +{ + [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)] + public sealed class AsyncIteratorStateMachineAttribute : StateMachineAttribute + { + public AsyncIteratorStateMachineAttribute(Type stateMachineType) + : base(stateMachineType) + { + } + } +} From b581df2bb268f36c06957a9d91cb850885d98daa Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 30 Nov 2018 23:31:11 -0500 Subject: [PATCH 3/3] Address PR feedback Signed-off-by: dotnet-bot --- .../CompilerServices/AsyncIteratorStateMachineAttribute.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs b/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs index c93156be4fa1..489195569de2 100644 --- a/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs +++ b/src/Common/src/CoreLib/System/Runtime/CompilerServices/AsyncIteratorStateMachineAttribute.cs @@ -4,9 +4,12 @@ namespace System.Runtime.CompilerServices { + /// Indicates whether a method is an asynchronous iterator. [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)] public sealed class AsyncIteratorStateMachineAttribute : StateMachineAttribute { + /// Initializes a new instance of the class. + /// The type object for the underlying state machine type that's used to implement a state machine method. public AsyncIteratorStateMachineAttribute(Type stateMachineType) : base(stateMachineType) {