Skip to content

Commit

Permalink
Remove MONO ifdef from Vector128 bitcasts
Browse files Browse the repository at this point in the history
Follow-up to #104309.
  • Loading branch information
xtqqczze committed Jul 10, 2024
1 parent 9efc798 commit 9e28938
Showing 1 changed file with 6 additions and 52 deletions.
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 cref="Vector128{Byte}" />.</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 cref="Vector128{Single}" /> 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 cref="Vector128{SByte}" />.</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 cref="Vector128{Single}" />.</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 cref="Vector128{Single}" />.</summary>
/// <param name="value">The quaternion to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</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 cref="Vector2" /> as a new <see cref="Vector128{Single}" /> 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 cref="Vector128{Single}" />.</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

0 comments on commit 9e28938

Please sign in to comment.