This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Adding a DebugView for Vector64<T>, Vector128<T>, and Vector256<T> #15897
Merged
tannergooding
merged 1 commit into
dotnet:master
from
tannergooding:hwintrin-debuggerdisplay
Jan 17, 2018
Merged
Changes from all commits
Commits
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
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
118 changes: 118 additions & 0 deletions
118
src/mscorlib/src/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; | ||
} | ||
} | ||
} | ||
} |
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
118 changes: 118 additions & 0 deletions
118
src/mscorlib/src/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; | ||
} | ||
} | ||
} | ||
} |
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
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.
As per the comment, this ends up working for
bool
,char
,IntPtr
, andUIntPtr
at debug time, but makes the subsequent code much simpler.Given that this only works under a debugger, and users still can't do anything useful with such a type, I think this should be fine.