Skip to content

Commit

Permalink
Update Mono to handle various other vector bitcast APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Jun 28, 2024
1 parent 1d272e6 commit 09ee415
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 135 deletions.
8 changes: 8 additions & 0 deletions src/mono/mono/mini/interp/interp-simd-intrins.def
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_MULTIPLY, interp_v128_

INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_DIVISION, interp_v128_r4_op_division, 231)

INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_AS_V2, interp_v128_as_v2, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_AS_V3, interp_v128_as_v3, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_BITCAST, interp_v128_bitcast, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V2, interp_v128_from_v2, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V2_UNSAFE, interp_v128_from_v2_unsafe, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V3, interp_v128_from_v3, -1)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V3_UNSAFE, interp_v128_from_v3_unsafe, -1)

INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I1_NEGATION, interp_v128_i1_op_negation, 97)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I2_NEGATION, interp_v128_i2_op_negation, 129)
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I4_NEGATION, interp_v128_i4_op_negation, 161)
Expand Down
82 changes: 82 additions & 0 deletions src/mono/mono/mini/interp/interp-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,88 @@ interp_v128_i4_all_bits_set (gpointer res)
memset (res, 0xff, SIZEOF_V128);
}

// Vector2 AsVector2(Vector128<float> v1)
static void
interp_v128_as_v2 (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
}

// Vector3 AsVector3(Vector128<float> v1)
static void
interp_v128_as_v3 (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
res_typed [2] = v1_typed [2];
}

// Vector128<TTo> As<TFrom, TTo>(Vector128<TFrom> v1)
static void
interp_v128_bitcast (gpointer res, gpointer v1)
{
*(v128_i1*)res = *(v128_i1*)v1;
}

// Vector128<float> AsVector128(Vector2 v1)
static void
interp_v128_from_v2 (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
res_typed [2] = 0;
res_typed [3] = 0;
}

// Vector128<float> AsVector128Unsafe(Vector2 v1)
static void
interp_v128_from_v2_unsafe (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
res_typed [2] = 0;
res_typed [3] = 0;
}

// Vector128<float> AsVector128(Vector3 v1)
static void
interp_v128_from_v3 (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
res_typed [2] = v1_typed [2];
res_typed [3] = 0;
}

// Vector128<float> AsVector128Unsafe(Vector3 v1)
static void
interp_v128_from_v3_unsafe (gpointer res, gpointer v1)
{
float *res_typed = (float*)res;
float *v1_typed = (float*)v1;

res_typed [0] = v1_typed [0];
res_typed [1] = v1_typed [1];
res_typed [2] = v1_typed [2];
res_typed [3] = 0;
}

// op_Addition
static void
interp_v128_i1_op_addition (gpointer res, gpointer v1, gpointer v2)
Expand Down
21 changes: 21 additions & 0 deletions src/mono/mono/mini/interp/simd-methods.def
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ SIMD_METHOD(op_UnaryNegation)
SIMD_METHOD(op_UnsignedRightShift)

SIMD_METHOD(AndNot)
SIMD_METHOD(As)
SIMD_METHOD(AsByte)
SIMD_METHOD(AsDouble)
SIMD_METHOD(AsInt16)
SIMD_METHOD(AsInt32)
SIMD_METHOD(AsInt64)
SIMD_METHOD(AsNInt)
SIMD_METHOD(AsNUInt)
SIMD_METHOD(AsPlane)
SIMD_METHOD(AsQuaternion)
SIMD_METHOD(AsSByte)
SIMD_METHOD(AsSingle)
SIMD_METHOD(AsUInt16)
SIMD_METHOD(AsUInt32)
SIMD_METHOD(AsUInt64)
SIMD_METHOD(AsVector)
SIMD_METHOD(AsVector2)
SIMD_METHOD(AsVector3)
SIMD_METHOD(AsVector4)
SIMD_METHOD(AsVector128)
SIMD_METHOD(AsVector128Unsafe)
SIMD_METHOD(ConditionalSelect)
SIMD_METHOD(Create)
SIMD_METHOD(CreateScalar)
Expand Down
Loading

0 comments on commit 09ee415

Please sign in to comment.