Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MONO ifdef from Vector128 bitcasts #104694

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ public static Vector128<TTo> As<TFrom, TTo>(this Vector128<TFrom> vector)
ThrowHelper.ThrowForUnsupportedIntrinsicsVector128BaseType<TFrom>();
ThrowHelper.ThrowForUnsupportedIntrinsicsVector128BaseType<TTo>();

#if MONO
return Unsafe.As<Vector128<TFrom>, Vector128<TTo>>(ref vector);
#else
return Unsafe.BitCast<Vector128<TFrom>, Vector128<TTo>>(vector);
#endif
}

/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see langword="Vector128&lt;Byte&gt;" />.</summary>
Expand Down Expand Up @@ -174,27 +170,13 @@ public static Vector128<TTo> As<TFrom, TTo>(this Vector128<TFrom> vector)
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Plane" />.</returns>
[Intrinsic]
internal static Plane AsPlane(this Vector128<float> value)
{
#if MONO
return Unsafe.As<Vector128<float>, Plane>(ref value);
#else
return Unsafe.BitCast<Vector128<float>, Plane>(value);
#endif
}
internal static Plane AsPlane(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Plane>(value);

/// <summary>Reinterprets a <see langword="Vector128&lt;Single&gt;" /> as a new <see cref="Quaternion" />.</summary>
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Quaternion" />.</returns>
[Intrinsic]
internal static Quaternion AsQuaternion(this Vector128<float> value)
{
#if MONO
return Unsafe.As<Vector128<float>, Quaternion>(ref value);
#else
return Unsafe.BitCast<Vector128<float>, Quaternion>(value);
#endif
}
internal static Quaternion AsQuaternion(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Quaternion>(value);

/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see langword="Vector128&lt;SByte&gt;" />.</summary>
/// <typeparam name="T">The type of the elements in the vector.</typeparam>
Expand Down Expand Up @@ -244,27 +226,13 @@ internal static Quaternion AsQuaternion(this Vector128<float> value)
/// <param name="value">The plane to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector128&lt;Single&gt;" />.</returns>
[Intrinsic]
internal static Vector128<float> AsVector128(this Plane value)
{
#if MONO
return Unsafe.As<Plane, Vector128<float>>(ref value);
#else
return Unsafe.BitCast<Plane, Vector128<float>>(value);
#endif
}
internal static Vector128<float> AsVector128(this Plane value) => Unsafe.BitCast<Plane, Vector128<float>>(value);

/// <summary>Reinterprets a <see cref="Quaternion" /> as a new <see langword="Vector128&lt;Single&gt;" />.</summary>
/// <param name="value">The quaternion to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector128&lt;Single&gt;" />.</returns>
[Intrinsic]
internal static Vector128<float> AsVector128(this Quaternion value)
{
#if MONO
return Unsafe.As<Quaternion, Vector128<float>>(ref value);
#else
return Unsafe.BitCast<Quaternion, Vector128<float>>(value);
#endif
}
internal static Vector128<float> AsVector128(this Quaternion value) => Unsafe.BitCast<Quaternion, Vector128<float>>(value);

/// <summary>Reinterprets a <see langword="Vector2" /> as a new <see cref="Vector128&lt;Single&gt;" /> with the new elements zeroed.</summary>
/// <param name="value">The vector to reinterpret.</param>
Expand All @@ -282,14 +250,7 @@ internal static Vector128<float> AsVector128(this Quaternion value)
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see langword="Vector128&lt;Single&gt;" />.</returns>
[Intrinsic]
public static Vector128<float> AsVector128(this Vector4 value)
{
#if MONO
return Unsafe.As<Vector4, Vector128<float>>(ref value);
#else
return Unsafe.BitCast<Vector4, Vector128<float>>(value);
#endif
}
public static Vector128<float> AsVector128(this Vector4 value) => Unsafe.BitCast<Vector4, Vector128<float>>(value);

/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see cref="Vector128{T}" />.</summary>
/// <typeparam name="T">The type of the elements in the vector.</typeparam>
Expand Down Expand Up @@ -361,14 +322,7 @@ public static Vector3 AsVector3(this Vector128<float> value)
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector4" />.</returns>
[Intrinsic]
public static Vector4 AsVector4(this Vector128<float> value)
{
#if MONO
return Unsafe.As<Vector128<float>, Vector4>(ref value);
#else
return Unsafe.BitCast<Vector128<float>, Vector4>(value);
#endif
}
public static Vector4 AsVector4(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Vector4>(value);

/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see cref="Vector{T}" />.</summary>
/// <typeparam name="T">The type of the elements in the vector.</typeparam>
Expand Down
Loading