Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,

switch (simdBaseJitType)
{
case CORINFO_TYPE_CHAR:
case CORINFO_TYPE_BYTE:
case CORINFO_TYPE_UBYTE:
case CORINFO_TYPE_SHORT:
Expand All @@ -3396,10 +3397,10 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
case CORINFO_TYPE_UINT:
case CORINFO_TYPE_LONG:
case CORINFO_TYPE_ULONG:
case CORINFO_TYPE_FLOAT:
case CORINFO_TYPE_DOUBLE:
case CORINFO_TYPE_NATIVEINT:
case CORINFO_TYPE_NATIVEUINT:
case CORINFO_TYPE_FLOAT:
case CORINFO_TYPE_DOUBLE:
{
return gtNewIconNode(true);
}
Expand Down Expand Up @@ -3427,6 +3428,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,

switch (simdBaseJitType)
{
case CORINFO_TYPE_CHAR:
case CORINFO_TYPE_BYTE:
case CORINFO_TYPE_UBYTE:
case CORINFO_TYPE_SHORT:
Expand All @@ -3435,10 +3437,10 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
case CORINFO_TYPE_UINT:
case CORINFO_TYPE_LONG:
case CORINFO_TYPE_ULONG:
case CORINFO_TYPE_FLOAT:
case CORINFO_TYPE_DOUBLE:
case CORINFO_TYPE_NATIVEINT:
case CORINFO_TYPE_NATIVEUINT:
case CORINFO_TYPE_FLOAT:
case CORINFO_TYPE_DOUBLE:
{
return evalVectorCount(clsHnd, JitType2PreciseVarType(simdBaseJitType));
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public bool IsPrimitiveNumeric
{
switch (GetTypeFlags(TypeFlags.CategoryMask))
{
case TypeFlags.Char:
case TypeFlags.SByte:
case TypeFlags.Byte:
case TypeFlags.Int16:
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4160,6 +4160,9 @@ CorInfoType CEEInfo::getTypeForPrimitiveNumericClass(
CorElementType ty = th.GetSignatureCorElementType();
switch (ty)
{
case ELEMENT_TYPE_CHAR:
result = CORINFO_TYPE_CHAR;
break;
case ELEMENT_TYPE_I1:
result = CORINFO_TYPE_BYTE;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public static partial class Vector
public unsafe static System.Numerics.Vector4 AsVector4Unsafe(this System.Numerics.Vector2 value) { throw null; }
public unsafe static System.Numerics.Vector4 AsVector4Unsafe(this System.Numerics.Vector3 value) { throw null; }
public static System.Numerics.Vector<byte> AsVectorByte<T>(System.Numerics.Vector<T> value) { throw null; }
public static System.Numerics.Vector<char> AsVectorChar<T>(System.Numerics.Vector<T> value) { throw null; }
public static System.Numerics.Vector<double> AsVectorDouble<T>(System.Numerics.Vector<T> value) { throw null; }
public static System.Numerics.Vector<short> AsVectorInt16<T>(System.Numerics.Vector<T> value) { throw null; }
public static System.Numerics.Vector<int> AsVectorInt32<T>(System.Numerics.Vector<T> value) { throw null; }
Expand Down Expand Up @@ -464,6 +465,7 @@ public static partial class Vector
public static System.Numerics.Vector<double> Round(System.Numerics.Vector<double> vector, System.MidpointRounding mode) { throw null; }
public static System.Numerics.Vector<float> Round(System.Numerics.Vector<float> vector, System.MidpointRounding mode) { throw null; }
public static System.Numerics.Vector<byte> ShiftLeft(System.Numerics.Vector<byte> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<char> ShiftLeft(System.Numerics.Vector<char> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<short> ShiftLeft(System.Numerics.Vector<short> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<int> ShiftLeft(System.Numerics.Vector<int> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<long> ShiftLeft(System.Numerics.Vector<long> value, int shiftCount) { throw null; }
Expand All @@ -485,6 +487,7 @@ public static partial class Vector
[System.CLSCompliantAttribute(false)]
public static System.Numerics.Vector<sbyte> ShiftRightArithmetic(System.Numerics.Vector<sbyte> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<byte> ShiftRightLogical(System.Numerics.Vector<byte> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<char> ShiftRightLogical(System.Numerics.Vector<char> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<short> ShiftRightLogical(System.Numerics.Vector<short> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<int> ShiftRightLogical(System.Numerics.Vector<int> value, int shiftCount) { throw null; }
public static System.Numerics.Vector<long> ShiftRightLogical(System.Numerics.Vector<long> value, int shiftCount) { throw null; }
Expand Down Expand Up @@ -1141,6 +1144,7 @@ public void CopyTo(T[] destination, int startIndex) { }
public static bool operator ==(System.Numerics.Vector<T> left, System.Numerics.Vector<T> right) { throw null; }
public static System.Numerics.Vector<T> operator ^(System.Numerics.Vector<T> left, System.Numerics.Vector<T> right) { throw null; }
public static explicit operator System.Numerics.Vector<byte> (System.Numerics.Vector<T> value) { throw null; }
public static explicit operator System.Numerics.Vector<char>(System.Numerics.Vector<T> value) { throw null; }
public static explicit operator System.Numerics.Vector<double> (System.Numerics.Vector<T> value) { throw null; }
public static explicit operator System.Numerics.Vector<short> (System.Numerics.Vector<T> value) { throw null; }
public static explicit operator System.Numerics.Vector<int> (System.Numerics.Vector<T> value) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ private void TestArrayIndexBasedConstructorLessElements<T>() where T : struct
public void ConstructorWithUnsupportedTypes_Guid() => TestConstructorWithUnsupportedTypes<Guid>();
[Fact]
public void ConstructorWithUnsupportedTypes_DateTime() => TestConstructorWithUnsupportedTypes<DateTime>();
[Fact]
public void ConstructorWithUnsupportedTypes_Char() => TestConstructorWithUnsupportedTypes<Char>();

private void TestConstructorWithUnsupportedTypes<T>() where T : struct
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ public void AsToTest()
[Fact]
public void IsNotSupportedBoolean() => TestIsNotSupported<bool>();

[Fact]
public void IsNotSupportedChar() => TestIsNotSupported<char>();

[Fact]
public void IsNotSupportedHalf() => TestIsNotSupported<Half>();

Expand Down
22 changes: 22 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ public static Vector<TTo> As<TFrom, TTo>(this Vector<TFrom> vector)
[Intrinsic]
public static Vector<byte> AsVectorByte<T>(Vector<T> value) => value.As<T, byte>();

/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see langword="Vector&lt;Char&gt;" />.</summary>
/// <typeparam name="T">The type of the input vector.</typeparam>
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector&lt;Char&gt;" />.</returns>
/// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
[Intrinsic]
public static Vector<char> AsVectorChar<T>(Vector<T> value) => value.As<T, char>();

/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see langword="Vector&lt;Double&gt;" />.</summary>
/// <typeparam name="T">The type of the input vector.</typeparam>
/// <param name="value">The vector to reinterpret.</param>
Expand Down Expand Up @@ -2915,6 +2923,13 @@ internal static Vector<T> Round<T>(Vector<T> vector)
[Intrinsic]
public static Vector<byte> ShiftLeft(Vector<byte> value, int shiftCount) => value << shiftCount;

/// <summary>Shifts each element of a vector left by the specified amount.</summary>
/// <param name="value">The vector whose elements are to be shifted.</param>
/// <param name="shiftCount">The number of bits by which to shift each element.</param>
/// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
[Intrinsic]
public static Vector<char> ShiftLeft(Vector<char> value, int shiftCount) => value << shiftCount;

/// <summary>Shifts each element of a vector left by the specified amount.</summary>
/// <param name="value">The vector whose elements are to be shifted.</param>
/// <param name="shiftCount">The number of bits by which to shift each element.</param>
Expand Down Expand Up @@ -3062,6 +3077,13 @@ internal static Vector<ulong> ShiftLeft(Vector<ulong> vector, Vector<ulong> shif
[Intrinsic]
public static Vector<byte> ShiftRightLogical(Vector<byte> value, int shiftCount) => value >>> shiftCount;

/// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
/// <param name="value">The vector whose elements are to be shifted.</param>
/// <param name="shiftCount">The number of bits by which to shift each element.</param>
/// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
[Intrinsic]
public static Vector<char> ShiftRightLogical(Vector<char> value, int shiftCount) => value >>> shiftCount;

/// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
/// <param name="value">The vector whose elements are to be shifted.</param>
/// <param name="shiftCount">The number of bits by which to shift each element.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;

namespace System.Numerics
{
Expand All @@ -25,6 +26,16 @@ public byte[] ByteView
}
}

public char[] CharView
{
get
{
var items = new char[Vector<char>.Count];
Unsafe.WriteUnaligned(ref Unsafe.As<char, byte>(ref items[0]), _value);
return items;
}
}

public double[] DoubleView
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ public T this[int index]
[Intrinsic]
public static explicit operator Vector<byte>(Vector<T> value) => value.As<T, byte>();

/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see langword="Vector&lt;Char&gt;" />.</summary>
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector&lt;Char&gt;" />.</returns>
/// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
[Intrinsic]
public static explicit operator Vector<char>(Vector<T> value) => value.As<T, char>();

/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see langword="Vector&lt;Double&gt;" />.</summary>
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector&lt;Double&gt;" />.</returns>
Expand Down
Loading
Loading