This repository was archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 503
[JustForView] Helps move x86 HW intrinsics files to shared in corert #5931
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,6 @@ launchSettings.json | |
| [Dd]ebugPublic/ | ||
| [Rr]elease/ | ||
| [Rr]eleases/ | ||
| x64/ | ||
| x86/ | ||
| build/ | ||
| bld/ | ||
| [Bb]in/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 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 ulong _00; | ||
| private 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; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
118 changes: 118 additions & 0 deletions
118
src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128DebugView.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| // 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 Internal.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Runtime.Intrinsics | ||
| { | ||
| internal struct Vector128DebugView<T> where T : struct | ||
| { | ||
| private Vector128<T> _value; | ||
|
|
||
| public Vector128DebugView(Vector128<T> value) | ||
| { | ||
| _value = value; | ||
| } | ||
|
|
||
| public byte[] ByteView | ||
| { | ||
| get | ||
| { | ||
| var items = new byte[16]; | ||
| Unsafe.WriteUnaligned(ref items[0], _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public double[] DoubleView | ||
| { | ||
| get | ||
| { | ||
| var items = new double[2]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public short[] Int16View | ||
| { | ||
| get | ||
| { | ||
| var items = new short[8]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public int[] Int32View | ||
| { | ||
| get | ||
| { | ||
| var items = new int[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public long[] Int64View | ||
| { | ||
| get | ||
| { | ||
| var items = new long[2]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public sbyte[] SByteView | ||
| { | ||
| get | ||
| { | ||
| var items = new sbyte[16]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public float[] SingleView | ||
| { | ||
| get | ||
| { | ||
| var items = new float[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public ushort[] UInt16View | ||
| { | ||
| get | ||
| { | ||
| var items = new ushort[8]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public uint[] UInt32View | ||
| { | ||
| get | ||
| { | ||
| var items = new uint[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public ulong[] UInt64View | ||
| { | ||
| get | ||
| { | ||
| var items = new ulong[2]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 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 ulong _00; | ||
| private ulong _01; | ||
| private ulong _02; | ||
| private 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; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
118 changes: 118 additions & 0 deletions
118
src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256DebugView.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| // 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 Internal.Runtime.CompilerServices; | ||
|
|
||
| namespace System.Runtime.Intrinsics | ||
| { | ||
| internal struct Vector256DebugView<T> where T : struct | ||
| { | ||
| private Vector256<T> _value; | ||
|
|
||
| public Vector256DebugView(Vector256<T> value) | ||
| { | ||
| _value = value; | ||
| } | ||
|
|
||
| public byte[] ByteView | ||
| { | ||
| get | ||
| { | ||
| var items = new byte[32]; | ||
| Unsafe.WriteUnaligned(ref items[0], _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public double[] DoubleView | ||
| { | ||
| get | ||
| { | ||
| var items = new double[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public short[] Int16View | ||
| { | ||
| get | ||
| { | ||
| var items = new short[16]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<short, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public int[] Int32View | ||
| { | ||
| get | ||
| { | ||
| var items = new int[8]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<int, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public long[] Int64View | ||
| { | ||
| get | ||
| { | ||
| var items = new long[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<long, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public sbyte[] SByteView | ||
| { | ||
| get | ||
| { | ||
| var items = new sbyte[32]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<sbyte, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public float[] SingleView | ||
| { | ||
| get | ||
| { | ||
| var items = new float[8]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<float, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public ushort[] UInt16View | ||
| { | ||
| get | ||
| { | ||
| var items = new ushort[16]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<ushort, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public uint[] UInt32View | ||
| { | ||
| get | ||
| { | ||
| var items = new uint[8]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<uint, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
|
|
||
| public ulong[] UInt64View | ||
| { | ||
| get | ||
| { | ||
| var items = new ulong[4]; | ||
| Unsafe.WriteUnaligned(ref Unsafe.As<ulong, byte>(ref items[0]), _value); | ||
| return items; | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CoreRT and ProjectN need to include the "PlatformNotSupported" files as well, for now at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you mean for corert the condition on line 879 should always be true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.