diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs new file mode 100644 index 000000000..48744bb5e --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs @@ -0,0 +1,46 @@ +// 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.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Internal.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics +{ + [Intrinsic] + [DebuggerDisplay("{DisplayString,nq}")] + [DebuggerTypeProxy(typeof(Vector256DebugView<>))] + [StructLayout(LayoutKind.Sequential, Size = 32)] + public readonly struct Vector256<T> where T : struct + { + // These fields exist to ensure the alignment is 8, rather than 1. + // This also allows the debug view to work https://github.com/dotnet/coreclr/issues/15694) + private readonly ulong _00; + private readonly ulong _01; + private readonly ulong _02; + private readonly ulong _03; + + private unsafe string DisplayString + { + get + { + // The IsPrimitive check ends up working for `bool`, `char`, `IntPtr`, and `UIntPtr` + // which are not actually supported by any current architecture. This shouldn't be + // an issue however and greatly simplifies the check + + if (typeof(T).IsPrimitive) + { + var items = new T[32 / Unsafe.SizeOf<T>()]; + Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref items[0]), this); + return $"({string.Join(", ", items)})"; + } + else + { + return SR.NotSupported_Type; + } + } + } + } +} |