-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Extend Vector64<T>, Vector128<T>, and Vector256<T> to support nint and nuint #52017
Comments
Tagging subscribers to this area: @tannergooding Issue DetailsProposalExtend Additionally, the following non-generic APIs should be added for parity with the existing surface area: namespace System.Runtime.Intrinsics
{
public static partial class Vector64
{
public static Vector64<nint> AsNInt<T>(Vector64<T> value);
public static Vector64<nuint> AsNUInt<T>(Vector64<T> value);
public static Vector64<nint> Create(nint value);
public static Vector64<nuint> Create(nuint value);
public static Vector64<nint> CreateScalar(nint value);
public static Vector64<nuint> CreateScalar(nuint value);
public static Vector64<nint> CreateScalarUnsafe(nint value);
public static Vector64<nuint> CreateScalarUnsafe(nuint value);
}
public static partial class Vector128
{
public static Vector128<nint> AsNInt<T>(Vector128<T> value);
public static Vector128<nuint> AsNUInt<T>(Vector128<T> value);
public static Vector128<nint> Create(nint value);
public static Vector128<nuint> Create(nuint value);
public static Vector128<nint> Create(Vector64<nint> lower, Vector64<nint> upper);
public static Vector128<nuint> Create(Vector64<nuint> lower, Vector64<nuint> upper);
public static Vector128<nint> CreateScalar(nint value);
public static Vector128<nuint> CreateScalar(nuint value);
public static Vector128<nint> CreateScalarUnsafe(nint value);
public static Vector128<nuint> CreateScalarUnsafe(nuint value);
}
public static partial class Vector256
{
public static Vector256<nint> AsNInt<T>(Vector256<T> value);
public static Vector256<nuint> AsNUInt<T>(Vector256<T> value);
public static Vector256<nint> Create(nint value);
public static Vector256<nuint> Create(nuint value);
public static Vector256<nint> Create(Vector128<nint> lower, Vector128<nint> upper);
public static Vector256<nuint> Create(Vector128<nuint> lower, Vector128<nuint> upper);
public static Vector256<nint> CreateScalar(nint value);
public static Vector256<nuint> CreateScalar(nuint value);
public static Vector256<nint> CreateScalarUnsafe(nint value);
public static Vector256<nuint> CreateScalarUnsafe(nuint value);
}
}
|
#52021 represents the x86 ISA changes that would be appropriate |
#52027 represents the Arm ISA changes that would be appropriate |
Hm, maybe I miss something now, but in simple words * please remember: that's in simple words 😉 |
We use 64-bit ( |
Got it. Thanks (nice example linked). |
Looks good as proposed. A very forward looking question of "what about when nint is bigger than 64 bits?" was asked, and deferred to such a hypothetical date. namespace System.Runtime.Intrinsics
{
public static partial class Vector64
{
public static Vector64<nint> AsNInt<T>(Vector64<T> value);
public static Vector64<nuint> AsNUInt<T>(Vector64<T> value);
public static Vector64<nint> Create(nint value);
public static Vector64<nuint> Create(nuint value);
public static Vector64<nint> CreateScalar(nint value);
public static Vector64<nuint> CreateScalar(nuint value);
public static Vector64<nint> CreateScalarUnsafe(nint value);
public static Vector64<nuint> CreateScalarUnsafe(nuint value);
}
public static partial class Vector128
{
public static Vector128<nint> AsNInt<T>(Vector128<T> value);
public static Vector128<nuint> AsNUInt<T>(Vector128<T> value);
public static Vector128<nint> Create(nint value);
public static Vector128<nuint> Create(nuint value);
public static Vector128<nint> Create(Vector64<nint> lower, Vector64<nint> upper);
public static Vector128<nuint> Create(Vector64<nuint> lower, Vector64<nuint> upper);
public static Vector128<nint> CreateScalar(nint value);
public static Vector128<nuint> CreateScalar(nuint value);
public static Vector128<nint> CreateScalarUnsafe(nint value);
public static Vector128<nuint> CreateScalarUnsafe(nuint value);
}
public static partial class Vector256
{
public static Vector256<nint> AsNInt<T>(Vector256<T> value);
public static Vector256<nuint> AsNUInt<T>(Vector256<T> value);
public static Vector256<nint> Create(nint value);
public static Vector256<nuint> Create(nuint value);
public static Vector256<nint> Create(Vector128<nint> lower, Vector128<nint> upper);
public static Vector256<nuint> Create(Vector128<nuint> lower, Vector128<nuint> upper);
public static Vector256<nint> CreateScalar(nint value);
public static Vector256<nuint> CreateScalar(nuint value);
public static Vector256<nint> CreateScalarUnsafe(nint value);
public static Vector256<nuint> CreateScalarUnsafe(nuint value);
}
} |
You're welcome to assign me 😄 Edit: I was bored and couldn't wait for the issue to be assigned to me.... Therefore I have created a PR |
What puzzles me a bit about the proposal is the naming of the methods. - public static Vector64<nint> AsNInt<T>(Vector64<T> value);
- public static Vector64<nuint> AsNUInt<T>(Vector64<T> value);
+ public static Vector64<nint> AsIntPtr<T>(Vector64<T> value);
+ public static Vector64<nuint> AsUIntPtr<T>(Vector64<T> value); Have you considered this? |
|
(just posting our Discord conversation for completeness). I was on vacation and not checking work related GitHub so this got missed. I've actually already done the work here and its in a local branch waiting for other PRs, such as #61649 to get merged before it gets put up. |
Proposal
Extend
Vector64<T>
,Vector128<T>
, andVector256<T>
to supportnint
andnuint
as valid primitive types. This will extend a number of existing generic functions which take aVector<T>
to also support taking the new types rather than throwing aPlatformNotSupportedException
.Additionally, the following non-generic APIs should be added for parity with the existing surface area:
The text was updated successfully, but these errors were encountered: