diff options
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs new file mode 100644 index 000000000..b2e72ddf8 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs @@ -0,0 +1,44 @@ +// 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(Vector128DebugView<>))] + [StructLayout(LayoutKind.Sequential, Size = 16)] + public readonly struct Vector128<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 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[16 / Unsafe.SizeOf<T>()]; + Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref items[0]), this); + return $"({string.Join(", ", items)})"; + } + else + { + return SR.NotSupported_Type; + } + } + } + } +} |