Skip to content

Commit 993586f

Browse files
authored
Move more SIMD intrinsics out of -munimplemented-simd128 (#10366)
Updates the intrinsics and tests to reflect the latest updates to the SIMD operations in LLVM and clang. Notably, many i64x2 and f64x2 operations can now be used with -msimd128 rather than -munimplemented-simd128.
1 parent 491f9f8 commit 993586f

File tree

4 files changed

+158
-329
lines changed

4 files changed

+158
-329
lines changed

system/include/wasm_simd128.h

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_make(float c0, float c1,
172172
return (v128_t)(__f32x4){c0, c1, c2, c3};
173173
}
174174

175-
#ifdef __wasm_unimplemented_simd128__
176-
177175
// wasm_i64x2_make(...)
178176
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_make(int64_t c0, int64_t c1) {
179177
return (v128_t)(__i64x2){c0, c1};
@@ -184,8 +182,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double c0, double c1
184182
return (v128_t)(__f64x2){c0, c1};
185183
}
186184

187-
#endif // __wasm_unimplemented_simd128__
188-
189185
// v128_t wasm_i8x16_constant(...)
190186
#define wasm_i8x16_const(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15) \
191187
__extension__({ \
@@ -222,7 +218,7 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double c0, double c1
222218
(v128_t)(__i16x8){c0, c1, c2, c3, c4, c5, c6, c7}; \
223219
})
224220

225-
// v128_t wasm_i32x4_constant(...)
221+
// v128_t wasm_i32x4_const(...)
226222
#define wasm_i32x4_const(c0, c1, c2, c3) \
227223
__extension__({ \
228224
__REQUIRE_CONSTANT(c0); \
@@ -242,8 +238,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double c0, double c1
242238
(v128_t)(__f32x4){c0, c1, c2, c3}; \
243239
})
244240

245-
#ifdef __wasm_unimplemented_simd128__
246-
247241
// v128_t wasm_i64x2_constant(...)
248242
#define wasm_i64x2_const(c0, c1) \
249243
__extension__({ \
@@ -260,8 +254,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double c0, double c1
260254
(v128_t)(__f64x2){c0, c1}; \
261255
})
262256

263-
#endif // __wasm_unimplemented_simd128__
264-
265257
// v128_t wasm_i8x16_splat(int8_t a)
266258
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_splat(int8_t a) {
267259
return (v128_t)(__i8x16){a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a};
@@ -285,13 +277,9 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_splat(int16_t a) {
285277
// int16_t wasm_i16x8_extract_lane(v128_t a, imm i)
286278
#define wasm_i16x8_extract_lane(a, i) (__builtin_wasm_extract_lane_s_i16x8((__i16x8)(a), i))
287279

288-
#ifdef __wasm_unimplemented_simd128__
289-
290280
// int16_t wasm_u16x8_extract_lane(v128_t a, imm i)
291281
#define wasm_u16x8_extract_lane(a, i) (__builtin_wasm_extract_lane_u_i16x8((__i16x8)(a), i))
292282

293-
#endif // __wasm_unimplemented_simd128__
294-
295283
// v128_t wasm_i16x8_replace_lane(v128_t a, imm i, int16_t b)
296284
#define wasm_i16x8_replace_lane(a, i, b) \
297285
((v128_t)__builtin_wasm_replace_lane_i16x8((__i16x8)(a), i, b))
@@ -308,15 +296,11 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_splat(int32_t a) {
308296
#define wasm_i32x4_replace_lane(a, i, b) \
309297
((v128_t)__builtin_wasm_replace_lane_i32x4((__i32x4)(a), i, b))
310298

311-
#ifdef __wasm_unimplemented_simd128__
312-
313299
// v128_t wasm_i64x2_splat(int64_t a)
314300
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_splat(int64_t a) {
315301
return (v128_t)(__i64x2){a, a};
316302
}
317303

318-
#endif // __wasm_unimplemented_simd128__
319-
320304
// int64_t wasm_i64x2_extract_lane(v128_t a, imm i)
321305
#define wasm_i64x2_extract_lane(a, i) (__builtin_wasm_extract_lane_i64x2((__i64x2)(a), i))
322306

@@ -336,8 +320,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_splat(float a) {
336320
#define wasm_f32x4_replace_lane(a, i, b) \
337321
((v128_t)__builtin_wasm_replace_lane_f32x4((__f32x4)(a), i, b))
338322

339-
#ifdef __wasm_unimplemented_simd128__
340-
341323
// v128_t wasm_f64x2_splat(double a)
342324
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_splat(double a) {
343325
return (v128_t)(__f64x2){a, a};
@@ -350,8 +332,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_splat(double a) {
350332
#define wasm_f64x2_replace_lane(a, i, b) \
351333
((v128_t)__builtin_wasm_replace_lane_f64x2((__f64x2)(a), i, b))
352334

353-
#endif // __wasm_unimplemented_simd128__
354-
355335
// v128_t wasm_i8x16_eq(v128_t a, v128_t b)
356336
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_eq(v128_t a, v128_t b) {
357337
return (v128_t)((__i8x16)a == (__i8x16)b);
@@ -532,8 +512,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ge(v128_t a, v128_t b) {
532512
return (v128_t)((__f32x4)a >= (__f32x4)b);
533513
}
534514

535-
#ifdef __wasm_unimplemented_simd128__
536-
537515
// v128_t wasm_f64x2_eq(v128_t a, v128_t b)
538516
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_eq(v128_t a, v128_t b) {
539517
return (v128_t)((__f64x2)a == (__f64x2)b);
@@ -564,8 +542,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ge(v128_t a, v128_t b) {
564542
return (v128_t)((__f64x2)a >= (__f64x2)b);
565543
}
566544

567-
#endif // __wasm_unimplemented_simd128__
568-
569545
// v128_t wasm_v128_not(v128 a)
570546
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_not(v128_t a) { return ~a; }
571547

@@ -752,15 +728,11 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max_u(v128_t a, v128_t b)
752728
};
753729
}
754730

755-
#ifdef __wasm_unimplemented_simd__
756-
757731
// v128_t wasm_i8x16_avgr_u(v128_t a, v128_t b)
758732
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_avgr_u(v128_t a, v128_t b) {
759733
return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)a, (__i8x16)b);
760734
}
761735

762-
#endif // __wasm_unimplemented_simd__
763-
764736
// v128_t wasm_i16x8_neg(v128_t a)
765737
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_neg(v128_t a) {
766738
return (v128_t)(-(__u16x8)a);
@@ -890,15 +862,11 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max_u(v128_t a, v128_t b)
890862
};
891863
}
892864

893-
#ifdef __wasm_unimplemented_simd__
894-
895865
// v128_t wasm_i16x8_avgr_u(v128_t a, v128_t b)
896866
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_avgr_u(v128_t a, v128_t b) {
897867
return (v128_t)__builtin_wasm_avgr_u_i16x8((__i16x8)a, (__i16x8)b);
898868
}
899869

900-
#endif // __wasm_unimplemented_simd__
901-
902870
// v128_t wasm_i32x4_neg(v128_t a)
903871
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_neg(v128_t a) {
904872
return (v128_t)(-(__u32x4)a);
@@ -992,13 +960,13 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_max_u(v128_t a, v128_t b)
992960
};
993961
}
994962

995-
#ifdef __wasm_unimplemented_simd128__
996-
997963
// v128_t wasm_i64x2_neg(v128_t a)
998964
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_neg(v128_t a) {
999965
return (v128_t)(-(__u64x2)a);
1000966
}
1001967

968+
#ifdef __wasm_unimplemented_simd128__
969+
1002970
// bool wasm_i64x2_any_true(v128_t a)
1003971
static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_any_true(v128_t a) {
1004972
return __builtin_wasm_any_true_i64x2((__i64x2)a);
@@ -1009,6 +977,8 @@ static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_all_true(v128_t a) {
1009977
return __builtin_wasm_all_true_i64x2((__i64x2)a);
1010978
}
1011979

980+
#endif // __wasm_unimplemented_simd128__
981+
1012982
// v128_t wasm_i64x2_shl(v128_t a, int32_t b)
1013983
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t a, int32_t b) {
1014984
return (v128_t)((__i64x2)a << (int64_t)b);
@@ -1034,8 +1004,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_sub(v128_t a, v128_t b) {
10341004
return (v128_t)((__u64x2)a - (__u64x2)b);
10351005
}
10361006

1037-
#endif // __wasm_unimplemented_simd128__
1038-
10391007
// v128_t wasm_f32x4_abs(v128_t a)
10401008
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t a) {
10411009
return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)a);
@@ -1051,6 +1019,8 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sqrt(v128_t a) {
10511019
return (v128_t)__builtin_wasm_sqrt_f32x4((__f32x4)a);
10521020
}
10531021

1022+
#ifdef __wasm_unimplemented_simd128__
1023+
10541024
// v128_t wasm_f32x4_qfma(v128_t a, v128_t b, v128_t c)
10551025
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_qfma(v128_t a, v128_t b, v128_t c) {
10561026
return (v128_t) __builtin_wasm_qfma_f32x4((__f32x4)a, (__f32x4)b, (__f32x4)c);
@@ -1061,6 +1031,8 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_qfms(v128_t a, v128_t b,
10611031
return (v128_t) __builtin_wasm_qfms_f32x4((__f32x4)a, (__f32x4)b, (__f32x4)c);
10621032
}
10631033

1034+
#endif // __wasm_unimplemented_simd128__
1035+
10641036
// v128_t wasm_f32x4_add(v128_t a, v128_t b)
10651037
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_add(v128_t a, v128_t b) {
10661038
return (v128_t)((__f32x4)a + (__f32x4)b);
@@ -1091,8 +1063,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_max(v128_t a, v128_t b) {
10911063
return (v128_t)__builtin_wasm_max_f32x4((__f32x4)a, (__f32x4)b);
10921064
}
10931065

1094-
#ifdef __wasm_unimplemented_simd128__
1095-
10961066
// v128_t wasm_f64x2_abs(v128_t a)
10971067
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t a) {
10981068
return (v128_t)__builtin_wasm_abs_f64x2((__f64x2)a);
@@ -1108,6 +1078,8 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sqrt(v128_t a) {
11081078
return (v128_t)__builtin_wasm_sqrt_f64x2((__f64x2)a);
11091079
}
11101080

1081+
#ifdef __wasm_unimplemented_simd128__
1082+
11111083
// v128_t wasm_f64x2_qfma(v128_t a, v128_t b, v128_t c)
11121084
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_qfma(v128_t a, v128_t b, v128_t c) {
11131085
return (v128_t) __builtin_wasm_qfma_f64x2((__f64x2)a, (__f64x2)b, (__f64x2)c);
@@ -1118,6 +1090,8 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_qfms(v128_t a, v128_t b,
11181090
return (v128_t) __builtin_wasm_qfms_f64x2((__f64x2)a, (__f64x2)b, (__f64x2)c);
11191091
}
11201092

1093+
#endif // __wasm_unimplemented_simd128__
1094+
11211095
// v128_t wasm_f64x2_add(v128_t a, v128_t b)
11221096
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_add(v128_t a, v128_t b) {
11231097
return (v128_t)((__f64x2)a + (__f64x2)b);
@@ -1148,8 +1122,6 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_max(v128_t a, v128_t b) {
11481122
return (v128_t)__builtin_wasm_max_f64x2((__f64x2)a, (__f64x2)b);
11491123
}
11501124

1151-
#endif // __wasm_unimplemented_simd128__
1152-
11531125
// v128_t wasm_i32x4_trunc_saturate_f32x4(v128_t a)
11541126
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_trunc_saturate_f32x4(v128_t a) {
11551127
return (v128_t)__builtin_wasm_trunc_saturate_s_i32x4_f32x4((__f32x4)a);
@@ -1204,11 +1176,15 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_convert_u64x2(v128_t a) {
12041176
((v128_t)(__builtin_shufflevector((__u8x16)(a), (__u8x16)(b), c0, c1, c2, c3, c4, c5, c6, c7, \
12051177
c8, c9, c10, c11, c12, c13, c14, c15)))
12061178

1179+
#ifdef __wasm_unimplemented_simd128__
1180+
12071181
// v128_t wasm_v8x16_swizzle(v128_t a, v128_t b)
12081182
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v8x16_swizzle(v128_t a, v128_t b) {
12091183
return (v128_t)__builtin_wasm_swizzle_v8x16((__i8x16)a, (__i8x16)b);
12101184
}
12111185

1186+
#endif // __wasm_unimplemented_simd128__
1187+
12121188
// v128_t wasm_i8x16_narrow_i16x8(v128_t a, v128_t b)
12131189
static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_narrow_i16x8(v128_t a, v128_t b) {
12141190
return (v128_t) __builtin_wasm_narrow_s_i8x16_i16x8((__i16x8)a, (__i16x8)b);

tests/test_core.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5954,7 +5954,6 @@ def test_relocatable_void_function(self):
59545954
self.do_run_in_out_file_test('tests', 'core', 'test_relocatable_void_function')
59555955

59565956
@wasm_simd
5957-
@unittest.skip("Temporarily disabled to update LLVM")
59585957
def test_wasm_builtin_simd(self, js_engines):
59595958
self.do_run(open(path_from_root('tests', 'test_wasm_builtin_simd.c')).read(), 'Success!',
59605959
js_engines=js_engines)
@@ -5963,7 +5962,6 @@ def test_wasm_builtin_simd(self, js_engines):
59635962
self.get_dir(), os.path.join(self.get_dir(), 'src.cpp'))
59645963

59655964
@wasm_simd
5966-
@unittest.skip("Temporarily disabled to update LLVM")
59675965
def test_wasm_intrinsics_simd(self, js_engines):
59685966
self.emcc_args.extend(['-Wpedantic', '-Werror', '-Wall'])
59695967
self.do_run(open(path_from_root('tests', 'test_wasm_intrinsics_simd.c')).read(), 'Success!',

0 commit comments

Comments
 (0)