Skip to content

Commit 8b0b476

Browse files
committed
Update Mono to handle various other vector bitcast APIs
1 parent 1d272e6 commit 8b0b476

7 files changed

+480
-135
lines changed

src/mono/mono/mini/interp/interp-internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define MINT_STACK_ALIGNMENT (2 * MINT_STACK_SLOT_SIZE)
3232
#define MINT_SIMD_ALIGNMENT (MINT_STACK_ALIGNMENT)
3333
#define SIZEOF_V128 16
34+
#define SIZEOF_V2 8
35+
#define SIZEOF_V3 12
3436

3537
#define INTERP_STACK_SIZE (1024*1024)
3638
#define INTERP_REDZONE_SIZE (8*1024)

src/mono/mono/mini/interp/interp-simd-intrins.def

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_MULTIPLY, interp_v128_
7070

7171
INTERP_SIMD_INTRINSIC_P_PP (INTERP_SIMD_INTRINSIC_V128_R4_DIVISION, interp_v128_r4_op_division, 231)
7272

73+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_AS_V2, interp_v128_as_v2, -1)
74+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_AS_V3, interp_v128_as_v3, -1)
75+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_BITCAST, interp_v128_bitcast, -1)
76+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V2, interp_v128_from_v2, -1)
77+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V2_UNSAFE, interp_v128_from_v2_unsafe, -1)
78+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V3, interp_v128_from_v3, -1)
79+
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_FROM_V3_UNSAFE, interp_v128_from_v3_unsafe, -1)
80+
7381
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I1_NEGATION, interp_v128_i1_op_negation, 97)
7482
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I2_NEGATION, interp_v128_i2_op_negation, 129)
7583
INTERP_SIMD_INTRINSIC_P_P (INTERP_SIMD_INTRINSIC_V128_I4_NEGATION, interp_v128_i4_op_negation, 161)

src/mono/mono/mini/interp/interp-simd.c

+82
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,88 @@ interp_v128_i4_all_bits_set (gpointer res)
2828
memset (res, 0xff, SIZEOF_V128);
2929
}
3030

31+
// Vector2 AsVector2(Vector128<float> v1)
32+
static void
33+
interp_v128_as_v2 (gpointer res, gpointer v1)
34+
{
35+
float *res_typed = (float*)res;
36+
float *v1_typed = (float*)v1;
37+
38+
res_typed [0] = v1_typed [0];
39+
res_typed [1] = v1_typed [1];
40+
}
41+
42+
// Vector3 AsVector3(Vector128<float> v1)
43+
static void
44+
interp_v128_as_v3 (gpointer res, gpointer v1)
45+
{
46+
float *res_typed = (float*)res;
47+
float *v1_typed = (float*)v1;
48+
49+
res_typed [0] = v1_typed [0];
50+
res_typed [1] = v1_typed [1];
51+
res_typed [2] = v1_typed [2];
52+
}
53+
54+
// Vector128<TTo> As<TFrom, TTo>(Vector128<TFrom> v1)
55+
static void
56+
interp_v128_bitcast (gpointer res, gpointer v1)
57+
{
58+
*(v128_i1*)res = *(v128_i1*)v1;
59+
}
60+
61+
// Vector128<float> AsVector128(Vector2 v1)
62+
static void
63+
interp_v128_from_v2 (gpointer res, gpointer v1)
64+
{
65+
float *res_typed = (float*)res;
66+
float *v1_typed = (float*)v1;
67+
68+
res_typed [0] = v1_typed [0];
69+
res_typed [1] = v1_typed [1];
70+
res_typed [2] = 0;
71+
res_typed [3] = 0;
72+
}
73+
74+
// Vector128<float> AsVector128Unsafe(Vector2 v1)
75+
static void
76+
interp_v128_from_v2_unsafe (gpointer res, gpointer v1)
77+
{
78+
float *res_typed = (float*)res;
79+
float *v1_typed = (float*)v1;
80+
81+
res_typed [0] = v1_typed [0];
82+
res_typed [1] = v1_typed [1];
83+
res_typed [2] = 0;
84+
res_typed [3] = 0;
85+
}
86+
87+
// Vector128<float> AsVector128(Vector3 v1)
88+
static void
89+
interp_v128_from_v3 (gpointer res, gpointer v1)
90+
{
91+
float *res_typed = (float*)res;
92+
float *v1_typed = (float*)v1;
93+
94+
res_typed [0] = v1_typed [0];
95+
res_typed [1] = v1_typed [1];
96+
res_typed [2] = v1_typed [2];
97+
res_typed [3] = 0;
98+
}
99+
100+
// Vector128<float> AsVector128Unsafe(Vector3 v1)
101+
static void
102+
interp_v128_from_v3_unsafe (gpointer res, gpointer v1)
103+
{
104+
float *res_typed = (float*)res;
105+
float *v1_typed = (float*)v1;
106+
107+
res_typed [0] = v1_typed [0];
108+
res_typed [1] = v1_typed [1];
109+
res_typed [2] = v1_typed [2];
110+
res_typed [3] = 0;
111+
}
112+
31113
// op_Addition
32114
static void
33115
interp_v128_i1_op_addition (gpointer res, gpointer v1, gpointer v2)

src/mono/mono/mini/interp/simd-methods.def

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ SIMD_METHOD(op_UnaryNegation)
2323
SIMD_METHOD(op_UnsignedRightShift)
2424

2525
SIMD_METHOD(AndNot)
26+
SIMD_METHOD(As)
27+
SIMD_METHOD(AsByte)
28+
SIMD_METHOD(AsDouble)
29+
SIMD_METHOD(AsInt16)
30+
SIMD_METHOD(AsInt32)
31+
SIMD_METHOD(AsInt64)
32+
SIMD_METHOD(AsNInt)
33+
SIMD_METHOD(AsNUInt)
34+
SIMD_METHOD(AsPlane)
35+
SIMD_METHOD(AsQuaternion)
36+
SIMD_METHOD(AsSByte)
37+
SIMD_METHOD(AsSingle)
38+
SIMD_METHOD(AsUInt16)
39+
SIMD_METHOD(AsUInt32)
40+
SIMD_METHOD(AsUInt64)
41+
SIMD_METHOD(AsVector)
42+
SIMD_METHOD(AsVector2)
43+
SIMD_METHOD(AsVector3)
44+
SIMD_METHOD(AsVector4)
45+
SIMD_METHOD(AsVector128)
46+
SIMD_METHOD(AsVector128Unsafe)
2647
SIMD_METHOD(ConditionalSelect)
2748
SIMD_METHOD(Create)
2849
SIMD_METHOD(CreateScalar)

0 commit comments

Comments
 (0)