1 /*===---- wasm_simd128.h - WebAssembly portable SIMD intrinsics ------------=== 2 * 3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 * See https://llvm.org/LICENSE.txt for license information. 5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 * 7 *===-----------------------------------------------------------------------=== 8 */ 9 10 #ifndef __WASM_SIMD128_H 11 #define __WASM_SIMD128_H 12 13 #include <stdbool.h> 14 #include <stdint.h> 15 16 // User-facing type 17 typedef int32_t v128_t __attribute__((__vector_size__(16), __aligned__(16))); 18 19 // Internal types determined by clang builtin definitions 20 typedef int32_t __v128_u __attribute__((__vector_size__(16), __aligned__(1))); 21 typedef signed char __i8x16 22 __attribute__((__vector_size__(16), __aligned__(16))); 23 typedef unsigned char __u8x16 24 __attribute__((__vector_size__(16), __aligned__(16))); 25 typedef short __i16x8 __attribute__((__vector_size__(16), __aligned__(16))); 26 typedef unsigned short __u16x8 27 __attribute__((__vector_size__(16), __aligned__(16))); 28 typedef int __i32x4 __attribute__((__vector_size__(16), __aligned__(16))); 29 typedef unsigned int __u32x4 30 __attribute__((__vector_size__(16), __aligned__(16))); 31 typedef long long __i64x2 __attribute__((__vector_size__(16), __aligned__(16))); 32 typedef unsigned long long __u64x2 33 __attribute__((__vector_size__(16), __aligned__(16))); 34 typedef float __f32x4 __attribute__((__vector_size__(16), __aligned__(16))); 35 typedef double __f64x2 __attribute__((__vector_size__(16), __aligned__(16))); 36 37 typedef signed char __i8x8 __attribute__((__vector_size__(8), __aligned__(8))); 38 typedef unsigned char __u8x8 39 __attribute__((__vector_size__(8), __aligned__(8))); 40 typedef short __i16x4 __attribute__((__vector_size__(8), __aligned__(8))); 41 typedef unsigned short __u16x4 42 __attribute__((__vector_size__(8), __aligned__(8))); 43 44 #define __DEFAULT_FN_ATTRS \ 45 __attribute__((__always_inline__, __nodebug__, __target__("simd128"), \ 46 __min_vector_width__(128))) 47 48 #define __REQUIRE_CONSTANT(e) \ 49 _Static_assert(__builtin_constant_p(e), "Expected constant") 50 51 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load(const void *__mem) { 52 // UB-free unaligned access copied from xmmintrin.h 53 struct __wasm_v128_load_struct { 54 __v128_u __v; 55 } __attribute__((__packed__, __may_alias__)); 56 return ((const struct __wasm_v128_load_struct *)__mem)->__v; 57 } 58 59 static __inline__ v128_t __DEFAULT_FN_ATTRS 60 wasm_v8x16_load_splat(const void *__mem) { 61 struct __wasm_v8x16_load_splat_struct { 62 uint8_t __v; 63 } __attribute__((__packed__, __may_alias__)); 64 uint8_t __v = ((const struct __wasm_v8x16_load_splat_struct *)__mem)->__v; 65 return (v128_t)(__u8x16){__v, __v, __v, __v, __v, __v, __v, __v, 66 __v, __v, __v, __v, __v, __v, __v, __v}; 67 } 68 69 static __inline__ v128_t __DEFAULT_FN_ATTRS 70 wasm_v16x8_load_splat(const void *__mem) { 71 struct __wasm_v16x8_load_splat_struct { 72 uint16_t __v; 73 } __attribute__((__packed__, __may_alias__)); 74 uint16_t __v = ((const struct __wasm_v16x8_load_splat_struct *)__mem)->__v; 75 return (v128_t)(__u16x8){__v, __v, __v, __v, __v, __v, __v, __v}; 76 } 77 78 static __inline__ v128_t __DEFAULT_FN_ATTRS 79 wasm_v32x4_load_splat(const void *__mem) { 80 struct __wasm_v32x4_load_splat_struct { 81 uint32_t __v; 82 } __attribute__((__packed__, __may_alias__)); 83 uint32_t __v = ((const struct __wasm_v32x4_load_splat_struct *)__mem)->__v; 84 return (v128_t)(__u32x4){__v, __v, __v, __v}; 85 } 86 87 static __inline__ v128_t __DEFAULT_FN_ATTRS 88 wasm_v64x2_load_splat(const void *__mem) { 89 struct __wasm_v64x2_load_splat_struct { 90 uint64_t __v; 91 } __attribute__((__packed__, __may_alias__)); 92 uint64_t __v = ((const struct __wasm_v64x2_load_splat_struct *)__mem)->__v; 93 return (v128_t)(__u64x2){__v, __v}; 94 } 95 96 static __inline__ v128_t __DEFAULT_FN_ATTRS 97 wasm_i16x8_load_8x8(const void *__mem) { 98 typedef int8_t __i8x8 __attribute__((__vector_size__(8), __aligned__(8))); 99 struct __wasm_i16x8_load_8x8_struct { 100 __i8x8 __v; 101 } __attribute__((__packed__, __may_alias__)); 102 __i8x8 __v = ((const struct __wasm_i16x8_load_8x8_struct *)__mem)->__v; 103 return (v128_t) __builtin_convertvector(__v, __i16x8); 104 } 105 106 static __inline__ v128_t __DEFAULT_FN_ATTRS 107 wasm_u16x8_load_8x8(const void *__mem) { 108 typedef uint8_t __u8x8 __attribute__((__vector_size__(8), __aligned__(8))); 109 struct __wasm_u16x8_load_8x8_struct { 110 __u8x8 __v; 111 } __attribute__((__packed__, __may_alias__)); 112 __u8x8 __v = ((const struct __wasm_u16x8_load_8x8_struct *)__mem)->__v; 113 return (v128_t) __builtin_convertvector(__v, __u16x8); 114 } 115 116 static __inline__ v128_t __DEFAULT_FN_ATTRS 117 wasm_i32x4_load_16x4(const void *__mem) { 118 typedef int16_t __i16x4 __attribute__((__vector_size__(8), __aligned__(8))); 119 struct __wasm_i32x4_load_16x4_struct { 120 __i16x4 __v; 121 } __attribute__((__packed__, __may_alias__)); 122 __i16x4 __v = ((const struct __wasm_i32x4_load_16x4_struct *)__mem)->__v; 123 return (v128_t) __builtin_convertvector(__v, __i32x4); 124 } 125 126 static __inline__ v128_t __DEFAULT_FN_ATTRS 127 wasm_u32x4_load_16x4(const void *__mem) { 128 typedef uint16_t __u16x4 __attribute__((__vector_size__(8), __aligned__(8))); 129 struct __wasm_u32x4_load_16x4_struct { 130 __u16x4 __v; 131 } __attribute__((__packed__, __may_alias__)); 132 __u16x4 __v = ((const struct __wasm_u32x4_load_16x4_struct *)__mem)->__v; 133 return (v128_t) __builtin_convertvector(__v, __u32x4); 134 } 135 136 static __inline__ v128_t __DEFAULT_FN_ATTRS 137 wasm_i64x2_load_32x2(const void *__mem) { 138 typedef int32_t __i32x2 __attribute__((__vector_size__(8), __aligned__(8))); 139 struct __wasm_i64x2_load_32x2_struct { 140 __i32x2 __v; 141 } __attribute__((__packed__, __may_alias__)); 142 __i32x2 __v = ((const struct __wasm_i64x2_load_32x2_struct *)__mem)->__v; 143 return (v128_t) __builtin_convertvector(__v, __i64x2); 144 } 145 146 static __inline__ v128_t __DEFAULT_FN_ATTRS 147 wasm_u64x2_load_32x2(const void *__mem) { 148 typedef uint32_t __u32x2 __attribute__((__vector_size__(8), __aligned__(8))); 149 struct __wasm_u64x2_load_32x2_struct { 150 __u32x2 __v; 151 } __attribute__((__packed__, __may_alias__)); 152 __u32x2 __v = ((const struct __wasm_u64x2_load_32x2_struct *)__mem)->__v; 153 return (v128_t) __builtin_convertvector(__v, __u64x2); 154 } 155 156 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store(void *__mem, 157 v128_t __a) { 158 // UB-free unaligned access copied from xmmintrin.h 159 struct __wasm_v128_store_struct { 160 __v128_u __v; 161 } __attribute__((__packed__, __may_alias__)); 162 ((struct __wasm_v128_store_struct *)__mem)->__v = __a; 163 } 164 165 static __inline__ v128_t __DEFAULT_FN_ATTRS 166 wasm_i8x16_make(int8_t __c0, int8_t __c1, int8_t __c2, int8_t __c3, int8_t __c4, 167 int8_t __c5, int8_t __c6, int8_t __c7, int8_t __c8, int8_t __c9, 168 int8_t __c10, int8_t __c11, int8_t __c12, int8_t __c13, 169 int8_t __c14, int8_t __c15) { 170 return (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, 171 __c6, __c7, __c8, __c9, __c10, __c11, 172 __c12, __c13, __c14, __c15}; 173 } 174 175 static __inline__ v128_t __DEFAULT_FN_ATTRS 176 wasm_i16x8_make(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3, 177 int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) { 178 return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; 179 } 180 181 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_make(int32_t __c0, 182 int32_t __c1, 183 int32_t __c2, 184 int32_t __c3) { 185 return (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; 186 } 187 188 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_make(float __c0, 189 float __c1, 190 float __c2, 191 float __c3) { 192 return (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; 193 } 194 195 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_make(int64_t __c0, 196 int64_t __c1) { 197 return (v128_t)(__i64x2){__c0, __c1}; 198 } 199 200 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double __c0, 201 double __c1) { 202 return (v128_t)(__f64x2){__c0, __c1}; 203 } 204 205 #define wasm_i8x16_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, __c8, \ 206 __c9, __c10, __c11, __c12, __c13, __c14, __c15) \ 207 __extension__({ \ 208 __REQUIRE_CONSTANT(__c0); \ 209 __REQUIRE_CONSTANT(__c1); \ 210 __REQUIRE_CONSTANT(__c2); \ 211 __REQUIRE_CONSTANT(__c3); \ 212 __REQUIRE_CONSTANT(__c4); \ 213 __REQUIRE_CONSTANT(__c5); \ 214 __REQUIRE_CONSTANT(__c6); \ 215 __REQUIRE_CONSTANT(__c7); \ 216 __REQUIRE_CONSTANT(__c8); \ 217 __REQUIRE_CONSTANT(__c9); \ 218 __REQUIRE_CONSTANT(__c10); \ 219 __REQUIRE_CONSTANT(__c11); \ 220 __REQUIRE_CONSTANT(__c12); \ 221 __REQUIRE_CONSTANT(__c13); \ 222 __REQUIRE_CONSTANT(__c14); \ 223 __REQUIRE_CONSTANT(__c15); \ 224 (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, \ 225 __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15}; \ 226 }) 227 228 #define wasm_i16x8_const(__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7) \ 229 __extension__({ \ 230 __REQUIRE_CONSTANT(__c0); \ 231 __REQUIRE_CONSTANT(__c1); \ 232 __REQUIRE_CONSTANT(__c2); \ 233 __REQUIRE_CONSTANT(__c3); \ 234 __REQUIRE_CONSTANT(__c4); \ 235 __REQUIRE_CONSTANT(__c5); \ 236 __REQUIRE_CONSTANT(__c6); \ 237 __REQUIRE_CONSTANT(__c7); \ 238 (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; \ 239 }) 240 241 #define wasm_i32x4_const(__c0, __c1, __c2, __c3) \ 242 __extension__({ \ 243 __REQUIRE_CONSTANT(__c0); \ 244 __REQUIRE_CONSTANT(__c1); \ 245 __REQUIRE_CONSTANT(__c2); \ 246 __REQUIRE_CONSTANT(__c3); \ 247 (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; \ 248 }) 249 250 #define wasm_f32x4_const(__c0, __c1, __c2, __c3) \ 251 __extension__({ \ 252 __REQUIRE_CONSTANT(__c0); \ 253 __REQUIRE_CONSTANT(__c1); \ 254 __REQUIRE_CONSTANT(__c2); \ 255 __REQUIRE_CONSTANT(__c3); \ 256 (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; \ 257 }) 258 259 #define wasm_i64x2_const(__c0, __c1) \ 260 __extension__({ \ 261 __REQUIRE_CONSTANT(__c0); \ 262 __REQUIRE_CONSTANT(__c1); \ 263 (v128_t)(__i64x2){__c0, __c1}; \ 264 }) 265 266 #define wasm_f64x2_const(__c0, __c1) \ 267 __extension__({ \ 268 __REQUIRE_CONSTANT(__c0); \ 269 __REQUIRE_CONSTANT(__c1); \ 270 (v128_t)(__f64x2){__c0, __c1}; \ 271 }) 272 273 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_splat(int8_t __a) { 274 return (v128_t)(__i8x16){__a, __a, __a, __a, __a, __a, __a, __a, 275 __a, __a, __a, __a, __a, __a, __a, __a}; 276 } 277 278 #define wasm_i8x16_extract_lane(__a, __i) \ 279 (__builtin_wasm_extract_lane_s_i8x16((__i8x16)(__a), __i)) 280 281 #define wasm_u8x16_extract_lane(__a, __i) \ 282 (__builtin_wasm_extract_lane_u_i8x16((__u8x16)(__a), __i)) 283 284 #define wasm_i8x16_replace_lane(__a, __i, __b) \ 285 ((v128_t)__builtin_wasm_replace_lane_i8x16((__i8x16)(__a), __i, __b)) 286 287 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_splat(int16_t __a) { 288 return (v128_t)(__i16x8){__a, __a, __a, __a, __a, __a, __a, __a}; 289 } 290 291 #define wasm_i16x8_extract_lane(__a, __i) \ 292 (__builtin_wasm_extract_lane_s_i16x8((__i16x8)(__a), __i)) 293 294 #define wasm_u16x8_extract_lane(__a, __i) \ 295 (__builtin_wasm_extract_lane_u_i16x8((__u16x8)(__a), __i)) 296 297 #define wasm_i16x8_replace_lane(__a, __i, __b) \ 298 ((v128_t)__builtin_wasm_replace_lane_i16x8((__i16x8)(__a), __i, __b)) 299 300 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_splat(int32_t __a) { 301 return (v128_t)(__i32x4){__a, __a, __a, __a}; 302 } 303 304 #define wasm_i32x4_extract_lane(__a, __i) \ 305 (__builtin_wasm_extract_lane_i32x4((__i32x4)(__a), __i)) 306 307 #define wasm_i32x4_replace_lane(__a, __i, __b) \ 308 ((v128_t)__builtin_wasm_replace_lane_i32x4((__i32x4)(__a), __i, __b)) 309 310 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_splat(int64_t __a) { 311 return (v128_t)(__i64x2){__a, __a}; 312 } 313 314 #define wasm_i64x2_extract_lane(__a, __i) \ 315 (__builtin_wasm_extract_lane_i64x2((__i64x2)(__a), __i)) 316 317 #define wasm_i64x2_replace_lane(__a, __i, __b) \ 318 ((v128_t)__builtin_wasm_replace_lane_i64x2((__i64x2)(__a), __i, __b)) 319 320 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_splat(float __a) { 321 return (v128_t)(__f32x4){__a, __a, __a, __a}; 322 } 323 324 #define wasm_f32x4_extract_lane(__a, __i) \ 325 (__builtin_wasm_extract_lane_f32x4((__f32x4)(__a), __i)) 326 327 #define wasm_f32x4_replace_lane(__a, __i, __b) \ 328 ((v128_t)__builtin_wasm_replace_lane_f32x4((__f32x4)(__a), __i, __b)) 329 330 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_splat(double __a) { 331 return (v128_t)(__f64x2){__a, __a}; 332 } 333 334 #define wasm_f64x2_extract_lane(__a, __i) \ 335 (__builtin_wasm_extract_lane_f64x2((__f64x2)(__a), __i)) 336 337 #define wasm_f64x2_replace_lane(__a, __i, __b) \ 338 ((v128_t)__builtin_wasm_replace_lane_f64x2((__f64x2)(__a), __i, __b)) 339 340 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_eq(v128_t __a, 341 v128_t __b) { 342 return (v128_t)((__i8x16)__a == (__i8x16)__b); 343 } 344 345 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ne(v128_t __a, 346 v128_t __b) { 347 return (v128_t)((__i8x16)__a != (__i8x16)__b); 348 } 349 350 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_lt(v128_t __a, 351 v128_t __b) { 352 return (v128_t)((__i8x16)__a < (__i8x16)__b); 353 } 354 355 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_lt(v128_t __a, 356 v128_t __b) { 357 return (v128_t)((__u8x16)__a < (__u8x16)__b); 358 } 359 360 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_gt(v128_t __a, 361 v128_t __b) { 362 return (v128_t)((__i8x16)__a > (__i8x16)__b); 363 } 364 365 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_gt(v128_t __a, 366 v128_t __b) { 367 return (v128_t)((__u8x16)__a > (__u8x16)__b); 368 } 369 370 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_le(v128_t __a, 371 v128_t __b) { 372 return (v128_t)((__i8x16)__a <= (__i8x16)__b); 373 } 374 375 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_le(v128_t __a, 376 v128_t __b) { 377 return (v128_t)((__u8x16)__a <= (__u8x16)__b); 378 } 379 380 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ge(v128_t __a, 381 v128_t __b) { 382 return (v128_t)((__i8x16)__a >= (__i8x16)__b); 383 } 384 385 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_ge(v128_t __a, 386 v128_t __b) { 387 return (v128_t)((__u8x16)__a >= (__u8x16)__b); 388 } 389 390 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_eq(v128_t __a, 391 v128_t __b) { 392 return (v128_t)((__i16x8)__a == (__i16x8)__b); 393 } 394 395 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ne(v128_t __a, 396 v128_t __b) { 397 return (v128_t)((__u16x8)__a != (__u16x8)__b); 398 } 399 400 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_lt(v128_t __a, 401 v128_t __b) { 402 return (v128_t)((__i16x8)__a < (__i16x8)__b); 403 } 404 405 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_lt(v128_t __a, 406 v128_t __b) { 407 return (v128_t)((__u16x8)__a < (__u16x8)__b); 408 } 409 410 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_gt(v128_t __a, 411 v128_t __b) { 412 return (v128_t)((__i16x8)__a > (__i16x8)__b); 413 } 414 415 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_gt(v128_t __a, 416 v128_t __b) { 417 return (v128_t)((__u16x8)__a > (__u16x8)__b); 418 } 419 420 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_le(v128_t __a, 421 v128_t __b) { 422 return (v128_t)((__i16x8)__a <= (__i16x8)__b); 423 } 424 425 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_le(v128_t __a, 426 v128_t __b) { 427 return (v128_t)((__u16x8)__a <= (__u16x8)__b); 428 } 429 430 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ge(v128_t __a, 431 v128_t __b) { 432 return (v128_t)((__i16x8)__a >= (__i16x8)__b); 433 } 434 435 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_ge(v128_t __a, 436 v128_t __b) { 437 return (v128_t)((__u16x8)__a >= (__u16x8)__b); 438 } 439 440 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_eq(v128_t __a, 441 v128_t __b) { 442 return (v128_t)((__i32x4)__a == (__i32x4)__b); 443 } 444 445 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ne(v128_t __a, 446 v128_t __b) { 447 return (v128_t)((__i32x4)__a != (__i32x4)__b); 448 } 449 450 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_lt(v128_t __a, 451 v128_t __b) { 452 return (v128_t)((__i32x4)__a < (__i32x4)__b); 453 } 454 455 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_lt(v128_t __a, 456 v128_t __b) { 457 return (v128_t)((__u32x4)__a < (__u32x4)__b); 458 } 459 460 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_gt(v128_t __a, 461 v128_t __b) { 462 return (v128_t)((__i32x4)__a > (__i32x4)__b); 463 } 464 465 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_gt(v128_t __a, 466 v128_t __b) { 467 return (v128_t)((__u32x4)__a > (__u32x4)__b); 468 } 469 470 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_le(v128_t __a, 471 v128_t __b) { 472 return (v128_t)((__i32x4)__a <= (__i32x4)__b); 473 } 474 475 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_le(v128_t __a, 476 v128_t __b) { 477 return (v128_t)((__u32x4)__a <= (__u32x4)__b); 478 } 479 480 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ge(v128_t __a, 481 v128_t __b) { 482 return (v128_t)((__i32x4)__a >= (__i32x4)__b); 483 } 484 485 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_ge(v128_t __a, 486 v128_t __b) { 487 return (v128_t)((__u32x4)__a >= (__u32x4)__b); 488 } 489 490 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_eq(v128_t __a, 491 v128_t __b) { 492 return (v128_t)((__f32x4)__a == (__f32x4)__b); 493 } 494 495 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ne(v128_t __a, 496 v128_t __b) { 497 return (v128_t)((__f32x4)__a != (__f32x4)__b); 498 } 499 500 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_lt(v128_t __a, 501 v128_t __b) { 502 return (v128_t)((__f32x4)__a < (__f32x4)__b); 503 } 504 505 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_gt(v128_t __a, 506 v128_t __b) { 507 return (v128_t)((__f32x4)__a > (__f32x4)__b); 508 } 509 510 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_le(v128_t __a, 511 v128_t __b) { 512 return (v128_t)((__f32x4)__a <= (__f32x4)__b); 513 } 514 515 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ge(v128_t __a, 516 v128_t __b) { 517 return (v128_t)((__f32x4)__a >= (__f32x4)__b); 518 } 519 520 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_eq(v128_t __a, 521 v128_t __b) { 522 return (v128_t)((__f64x2)__a == (__f64x2)__b); 523 } 524 525 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ne(v128_t __a, 526 v128_t __b) { 527 return (v128_t)((__f64x2)__a != (__f64x2)__b); 528 } 529 530 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_lt(v128_t __a, 531 v128_t __b) { 532 return (v128_t)((__f64x2)__a < (__f64x2)__b); 533 } 534 535 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_gt(v128_t __a, 536 v128_t __b) { 537 return (v128_t)((__f64x2)__a > (__f64x2)__b); 538 } 539 540 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_le(v128_t __a, 541 v128_t __b) { 542 return (v128_t)((__f64x2)__a <= (__f64x2)__b); 543 } 544 545 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ge(v128_t __a, 546 v128_t __b) { 547 return (v128_t)((__f64x2)__a >= (__f64x2)__b); 548 } 549 550 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_not(v128_t __a) { 551 return ~__a; 552 } 553 554 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_and(v128_t __a, 555 v128_t __b) { 556 return __a & __b; 557 } 558 559 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_or(v128_t __a, 560 v128_t __b) { 561 return __a | __b; 562 } 563 564 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_xor(v128_t __a, 565 v128_t __b) { 566 return __a ^ __b; 567 } 568 569 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_andnot(v128_t __a, 570 v128_t __b) { 571 return __a & ~__b; 572 } 573 574 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_bitselect(v128_t __a, 575 v128_t __b, 576 v128_t __mask) { 577 return (v128_t)__builtin_wasm_bitselect((__i32x4)__a, (__i32x4)__b, 578 (__i32x4)__mask); 579 } 580 581 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_abs(v128_t __a) { 582 return (v128_t)__builtin_wasm_abs_i8x16((__i8x16)__a); 583 } 584 585 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_neg(v128_t __a) { 586 return (v128_t)(-(__u8x16)__a); 587 } 588 589 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i8x16_any_true(v128_t __a) { 590 return __builtin_wasm_any_true_i8x16((__i8x16)__a); 591 } 592 593 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i8x16_all_true(v128_t __a) { 594 return __builtin_wasm_all_true_i8x16((__i8x16)__a); 595 } 596 597 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shl(v128_t __a, 598 int32_t __b) { 599 return (v128_t)((__i8x16)__a << __b); 600 } 601 602 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shr(v128_t __a, 603 int32_t __b) { 604 return (v128_t)((__i8x16)__a >> __b); 605 } 606 607 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_shr(v128_t __a, 608 int32_t __b) { 609 return (v128_t)((__u8x16)__a >> __b); 610 } 611 612 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add(v128_t __a, 613 v128_t __b) { 614 return (v128_t)((__u8x16)__a + (__u8x16)__b); 615 } 616 617 static __inline__ v128_t __DEFAULT_FN_ATTRS 618 wasm_i8x16_add_saturate(v128_t __a, v128_t __b) { 619 return (v128_t)__builtin_wasm_add_saturate_s_i8x16((__i8x16)__a, 620 (__i8x16)__b); 621 } 622 623 static __inline__ v128_t __DEFAULT_FN_ATTRS 624 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) { 625 return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a, 626 (__u8x16)__b); 627 } 628 629 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a, 630 v128_t __b) { 631 return (v128_t)((__u8x16)__a - (__u8x16)__b); 632 } 633 634 static __inline__ v128_t __DEFAULT_FN_ATTRS 635 wasm_i8x16_sub_saturate(v128_t __a, v128_t __b) { 636 return (v128_t)__builtin_wasm_sub_saturate_s_i8x16((__i8x16)__a, 637 (__i8x16)__b); 638 } 639 640 static __inline__ v128_t __DEFAULT_FN_ATTRS 641 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) { 642 return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__u8x16)__a, 643 (__u8x16)__b); 644 } 645 646 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a, 647 v128_t __b) { 648 return (v128_t)__builtin_wasm_min_s_i8x16((__i8x16)__a, (__i8x16)__b); 649 } 650 651 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a, 652 v128_t __b) { 653 return (v128_t)__builtin_wasm_min_u_i8x16((__u8x16)__a, (__u8x16)__b); 654 } 655 656 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a, 657 v128_t __b) { 658 return (v128_t)__builtin_wasm_max_s_i8x16((__i8x16)__a, (__i8x16)__b); 659 } 660 661 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a, 662 v128_t __b) { 663 return (v128_t)__builtin_wasm_max_u_i8x16((__u8x16)__a, (__u8x16)__b); 664 } 665 666 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a, 667 v128_t __b) { 668 return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b); 669 } 670 671 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) { 672 return (v128_t)__builtin_wasm_abs_i16x8((__i16x8)__a); 673 } 674 675 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_neg(v128_t __a) { 676 return (v128_t)(-(__u16x8)__a); 677 } 678 679 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i16x8_any_true(v128_t __a) { 680 return __builtin_wasm_any_true_i16x8((__i16x8)__a); 681 } 682 683 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i16x8_all_true(v128_t __a) { 684 return __builtin_wasm_all_true_i16x8((__i16x8)__a); 685 } 686 687 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shl(v128_t __a, 688 int32_t __b) { 689 return (v128_t)((__i16x8)__a << __b); 690 } 691 692 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shr(v128_t __a, 693 int32_t __b) { 694 return (v128_t)((__i16x8)__a >> __b); 695 } 696 697 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_shr(v128_t __a, 698 int32_t __b) { 699 return (v128_t)((__u16x8)__a >> __b); 700 } 701 702 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add(v128_t __a, 703 v128_t __b) { 704 return (v128_t)((__u16x8)__a + (__u16x8)__b); 705 } 706 707 static __inline__ v128_t __DEFAULT_FN_ATTRS 708 wasm_i16x8_add_saturate(v128_t __a, v128_t __b) { 709 return (v128_t)__builtin_wasm_add_saturate_s_i16x8((__i16x8)__a, 710 (__i16x8)__b); 711 } 712 713 static __inline__ v128_t __DEFAULT_FN_ATTRS 714 wasm_u16x8_add_saturate(v128_t __a, v128_t __b) { 715 return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__u16x8)__a, 716 (__u16x8)__b); 717 } 718 719 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a, 720 v128_t __b) { 721 return (v128_t)((__i16x8)__a - (__i16x8)__b); 722 } 723 724 static __inline__ v128_t __DEFAULT_FN_ATTRS 725 wasm_i16x8_sub_saturate(v128_t __a, v128_t __b) { 726 return (v128_t)__builtin_wasm_sub_saturate_s_i16x8((__i16x8)__a, 727 (__i16x8)__b); 728 } 729 730 static __inline__ v128_t __DEFAULT_FN_ATTRS 731 wasm_u16x8_sub_saturate(v128_t __a, v128_t __b) { 732 return (v128_t)__builtin_wasm_sub_saturate_u_i16x8((__u16x8)__a, 733 (__u16x8)__b); 734 } 735 736 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_mul(v128_t __a, 737 v128_t __b) { 738 return (v128_t)((__u16x8)__a * (__u16x8)__b); 739 } 740 741 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a, 742 v128_t __b) { 743 return (v128_t)__builtin_wasm_min_s_i16x8((__i16x8)__a, (__i16x8)__b); 744 } 745 746 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a, 747 v128_t __b) { 748 return (v128_t)__builtin_wasm_min_u_i16x8((__u16x8)__a, (__u16x8)__b); 749 } 750 751 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a, 752 v128_t __b) { 753 return (v128_t)__builtin_wasm_max_s_i16x8((__i16x8)__a, (__i16x8)__b); 754 } 755 756 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a, 757 v128_t __b) { 758 return (v128_t)__builtin_wasm_max_u_i16x8((__u16x8)__a, (__u16x8)__b); 759 } 760 761 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_avgr(v128_t __a, 762 v128_t __b) { 763 return (v128_t)__builtin_wasm_avgr_u_i16x8((__u16x8)__a, (__u16x8)__b); 764 } 765 766 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_abs(v128_t __a) { 767 return (v128_t)__builtin_wasm_abs_i32x4((__i32x4)__a); 768 } 769 770 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_neg(v128_t __a) { 771 return (v128_t)(-(__u32x4)__a); 772 } 773 774 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i32x4_any_true(v128_t __a) { 775 return __builtin_wasm_any_true_i32x4((__i32x4)__a); 776 } 777 778 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i32x4_all_true(v128_t __a) { 779 return __builtin_wasm_all_true_i32x4((__i32x4)__a); 780 } 781 782 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shl(v128_t __a, 783 int32_t __b) { 784 return (v128_t)((__i32x4)__a << __b); 785 } 786 787 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shr(v128_t __a, 788 int32_t __b) { 789 return (v128_t)((__i32x4)__a >> __b); 790 } 791 792 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_shr(v128_t __a, 793 int32_t __b) { 794 return (v128_t)((__u32x4)__a >> __b); 795 } 796 797 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_add(v128_t __a, 798 v128_t __b) { 799 return (v128_t)((__u32x4)__a + (__u32x4)__b); 800 } 801 802 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_sub(v128_t __a, 803 v128_t __b) { 804 return (v128_t)((__u32x4)__a - (__u32x4)__b); 805 } 806 807 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_mul(v128_t __a, 808 v128_t __b) { 809 return (v128_t)((__u32x4)__a * (__u32x4)__b); 810 } 811 812 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min(v128_t __a, 813 v128_t __b) { 814 return (v128_t)__builtin_wasm_min_s_i32x4((__i32x4)__a, (__i32x4)__b); 815 } 816 817 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_min(v128_t __a, 818 v128_t __b) { 819 return (v128_t)__builtin_wasm_min_u_i32x4((__u32x4)__a, (__u32x4)__b); 820 } 821 822 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_max(v128_t __a, 823 v128_t __b) { 824 return (v128_t)__builtin_wasm_max_s_i32x4((__i32x4)__a, (__i32x4)__b); 825 } 826 827 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_max(v128_t __a, 828 v128_t __b) { 829 return (v128_t)__builtin_wasm_max_u_i32x4((__u32x4)__a, (__u32x4)__b); 830 } 831 832 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_neg(v128_t __a) { 833 return (v128_t)(-(__u64x2)__a); 834 } 835 836 #ifdef __wasm_unimplemented_simd128__ 837 838 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_any_true(v128_t __a) { 839 return __builtin_wasm_any_true_i64x2((__i64x2)__a); 840 } 841 842 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_all_true(v128_t __a) { 843 return __builtin_wasm_all_true_i64x2((__i64x2)__a); 844 } 845 846 #endif // __wasm_unimplemented_simd128__ 847 848 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t __a, 849 int32_t __b) { 850 return (v128_t)((__i64x2)__a << (int64_t)__b); 851 } 852 853 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shr(v128_t __a, 854 int32_t __b) { 855 return (v128_t)((__i64x2)__a >> (int64_t)__b); 856 } 857 858 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_shr(v128_t __a, 859 int32_t __b) { 860 return (v128_t)((__u64x2)__a >> (int64_t)__b); 861 } 862 863 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_add(v128_t __a, 864 v128_t __b) { 865 return (v128_t)((__u64x2)__a + (__u64x2)__b); 866 } 867 868 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_sub(v128_t __a, 869 v128_t __b) { 870 return (v128_t)((__u64x2)__a - (__u64x2)__b); 871 } 872 873 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a, 874 v128_t __b) { 875 return (v128_t)((__u64x2)__a * (__u64x2)__b); 876 } 877 878 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) { 879 return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a); 880 } 881 882 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_neg(v128_t __a) { 883 return (v128_t)(-(__f32x4)__a); 884 } 885 886 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sqrt(v128_t __a) { 887 return (v128_t)__builtin_wasm_sqrt_f32x4((__f32x4)__a); 888 } 889 890 #ifdef __wasm_unimplemented_simd128__ 891 892 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_qfma(v128_t __a, 893 v128_t __b, 894 v128_t __c) { 895 return (v128_t)__builtin_wasm_qfma_f32x4((__f32x4)__a, (__f32x4)__b, 896 (__f32x4)__c); 897 } 898 899 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_qfms(v128_t __a, 900 v128_t __b, 901 v128_t __c) { 902 return (v128_t)__builtin_wasm_qfms_f32x4((__f32x4)__a, (__f32x4)__b, 903 (__f32x4)__c); 904 } 905 906 #endif // __wasm_unimplemented_simd128__ 907 908 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_add(v128_t __a, 909 v128_t __b) { 910 return (v128_t)((__f32x4)__a + (__f32x4)__b); 911 } 912 913 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sub(v128_t __a, 914 v128_t __b) { 915 return (v128_t)((__f32x4)__a - (__f32x4)__b); 916 } 917 918 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_mul(v128_t __a, 919 v128_t __b) { 920 return (v128_t)((__f32x4)__a * (__f32x4)__b); 921 } 922 923 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_div(v128_t __a, 924 v128_t __b) { 925 return (v128_t)((__f32x4)__a / (__f32x4)__b); 926 } 927 928 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_min(v128_t __a, 929 v128_t __b) { 930 return (v128_t)__builtin_wasm_min_f32x4((__f32x4)__a, (__f32x4)__b); 931 } 932 933 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_max(v128_t __a, 934 v128_t __b) { 935 return (v128_t)__builtin_wasm_max_f32x4((__f32x4)__a, (__f32x4)__b); 936 } 937 938 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmin(v128_t __a, 939 v128_t __b) { 940 return (v128_t)__builtin_wasm_pmin_f32x4((__f32x4)__a, (__f32x4)__b); 941 } 942 943 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmax(v128_t __a, 944 v128_t __b) { 945 return (v128_t)__builtin_wasm_pmax_f32x4((__f32x4)__a, (__f32x4)__b); 946 } 947 948 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t __a) { 949 return (v128_t)__builtin_wasm_abs_f64x2((__f64x2)__a); 950 } 951 952 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_neg(v128_t __a) { 953 return (v128_t)(-(__f64x2)__a); 954 } 955 956 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sqrt(v128_t __a) { 957 return (v128_t)__builtin_wasm_sqrt_f64x2((__f64x2)__a); 958 } 959 960 #ifdef __wasm_unimplemented_simd128__ 961 962 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_qfma(v128_t __a, 963 v128_t __b, 964 v128_t __c) { 965 return (v128_t)__builtin_wasm_qfma_f64x2((__f64x2)__a, (__f64x2)__b, 966 (__f64x2)__c); 967 } 968 969 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_qfms(v128_t __a, 970 v128_t __b, 971 v128_t __c) { 972 return (v128_t)__builtin_wasm_qfms_f64x2((__f64x2)__a, (__f64x2)__b, 973 (__f64x2)__c); 974 } 975 976 #endif // __wasm_unimplemented_simd128__ 977 978 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_add(v128_t __a, 979 v128_t __b) { 980 return (v128_t)((__f64x2)__a + (__f64x2)__b); 981 } 982 983 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sub(v128_t __a, 984 v128_t __b) { 985 return (v128_t)((__f64x2)__a - (__f64x2)__b); 986 } 987 988 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_mul(v128_t __a, 989 v128_t __b) { 990 return (v128_t)((__f64x2)__a * (__f64x2)__b); 991 } 992 993 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_div(v128_t __a, 994 v128_t __b) { 995 return (v128_t)((__f64x2)__a / (__f64x2)__b); 996 } 997 998 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_min(v128_t __a, 999 v128_t __b) { 1000 return (v128_t)__builtin_wasm_min_f64x2((__f64x2)__a, (__f64x2)__b); 1001 } 1002 1003 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_max(v128_t __a, 1004 v128_t __b) { 1005 return (v128_t)__builtin_wasm_max_f64x2((__f64x2)__a, (__f64x2)__b); 1006 } 1007 1008 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmin(v128_t __a, 1009 v128_t __b) { 1010 return (v128_t)__builtin_wasm_pmin_f64x2((__f64x2)__a, (__f64x2)__b); 1011 } 1012 1013 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmax(v128_t __a, 1014 v128_t __b) { 1015 return (v128_t)__builtin_wasm_pmax_f64x2((__f64x2)__a, (__f64x2)__b); 1016 } 1017 1018 static __inline__ v128_t __DEFAULT_FN_ATTRS 1019 wasm_i32x4_trunc_saturate_f32x4(v128_t __a) { 1020 return (v128_t)__builtin_wasm_trunc_saturate_s_i32x4_f32x4((__f32x4)__a); 1021 } 1022 1023 static __inline__ v128_t __DEFAULT_FN_ATTRS 1024 wasm_u32x4_trunc_saturate_f32x4(v128_t __a) { 1025 return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a); 1026 } 1027 1028 static __inline__ v128_t __DEFAULT_FN_ATTRS 1029 wasm_f32x4_convert_i32x4(v128_t __a) { 1030 return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4); 1031 } 1032 1033 static __inline__ v128_t __DEFAULT_FN_ATTRS 1034 wasm_f32x4_convert_u32x4(v128_t __a) { 1035 return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4); 1036 } 1037 1038 #define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1039 __c7, __c8, __c9, __c10, __c11, __c12, __c13, \ 1040 __c14, __c15) \ 1041 ((v128_t)__builtin_wasm_shuffle_v8x16( \ 1042 (__i8x16)(__a), (__i8x16)(__b), __c0, __c1, __c2, __c3, __c4, __c5, \ 1043 __c6, __c7, __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15)) 1044 1045 #define wasm_v16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1046 __c7) \ 1047 ((v128_t)__builtin_wasm_shuffle_v8x16( \ 1048 (__i8x16)(__a), (__i8x16)(__b), (__c0)*2, (__c0)*2 + 1, (__c1)*2, \ 1049 (__c1)*2 + 1, (__c2)*2, (__c2)*2 + 1, (__c3)*2, (__c3)*2 + 1, (__c4)*2, \ 1050 (__c4)*2 + 1, (__c5)*2, (__c5)*2 + 1, (__c6)*2, (__c6)*2 + 1, (__c7)*2, \ 1051 (__c7)*2 + 1)) 1052 1053 #define wasm_v32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \ 1054 ((v128_t)__builtin_wasm_shuffle_v8x16( \ 1055 (__i8x16)(__a), (__i8x16)(__b), (__c0)*4, (__c0)*4 + 1, (__c0)*4 + 2, \ 1056 (__c0)*4 + 3, (__c1)*4, (__c1)*4 + 1, (__c1)*4 + 2, (__c1)*4 + 3, \ 1057 (__c2)*4, (__c2)*4 + 1, (__c2)*4 + 2, (__c2)*4 + 3, (__c3)*4, \ 1058 (__c3)*4 + 1, (__c3)*4 + 2, (__c3)*4 + 3)) 1059 1060 #define wasm_v64x2_shuffle(__a, __b, __c0, __c1) \ 1061 ((v128_t)__builtin_wasm_shuffle_v8x16( \ 1062 (__i8x16)(__a), (__i8x16)(__b), (__c0)*8, (__c0)*8 + 1, (__c0)*8 + 2, \ 1063 (__c0)*8 + 3, (__c0)*8 + 4, (__c0)*8 + 5, (__c0)*8 + 6, (__c0)*8 + 7, \ 1064 (__c1)*8, (__c1)*8 + 1, (__c1)*8 + 2, (__c1)*8 + 3, (__c1)*8 + 4, \ 1065 (__c1)*8 + 5, (__c1)*8 + 6, (__c1)*8 + 7)) 1066 1067 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v8x16_swizzle(v128_t __a, 1068 v128_t __b) { 1069 return (v128_t)__builtin_wasm_swizzle_v8x16((__i8x16)__a, (__i8x16)__b); 1070 } 1071 1072 static __inline__ v128_t __DEFAULT_FN_ATTRS 1073 wasm_i8x16_narrow_i16x8(v128_t __a, v128_t __b) { 1074 return (v128_t)__builtin_wasm_narrow_s_i8x16_i16x8((__i16x8)__a, 1075 (__i16x8)__b); 1076 } 1077 1078 static __inline__ v128_t __DEFAULT_FN_ATTRS 1079 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) { 1080 return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__u16x8)__a, 1081 (__u16x8)__b); 1082 } 1083 1084 static __inline__ v128_t __DEFAULT_FN_ATTRS 1085 wasm_i16x8_narrow_i32x4(v128_t __a, v128_t __b) { 1086 return (v128_t)__builtin_wasm_narrow_s_i16x8_i32x4((__i32x4)__a, 1087 (__i32x4)__b); 1088 } 1089 1090 static __inline__ v128_t __DEFAULT_FN_ATTRS 1091 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) { 1092 return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__u32x4)__a, 1093 (__u32x4)__b); 1094 } 1095 1096 static __inline__ v128_t __DEFAULT_FN_ATTRS 1097 wasm_i16x8_widen_low_i8x16(v128_t __a) { 1098 return (v128_t) __builtin_convertvector( 1099 (__i8x8){((__i8x16)__a)[0], ((__i8x16)__a)[1], ((__i8x16)__a)[2], 1100 ((__i8x16)__a)[3], ((__i8x16)__a)[4], ((__i8x16)__a)[5], 1101 ((__i8x16)__a)[6], ((__i8x16)__a)[7]}, 1102 __i16x8); 1103 } 1104 1105 static __inline__ v128_t __DEFAULT_FN_ATTRS 1106 wasm_i16x8_widen_high_i8x16(v128_t __a) { 1107 return (v128_t) __builtin_convertvector( 1108 (__i8x8){((__i8x16)__a)[8], ((__i8x16)__a)[9], ((__i8x16)__a)[10], 1109 ((__i8x16)__a)[11], ((__i8x16)__a)[12], ((__i8x16)__a)[13], 1110 ((__i8x16)__a)[14], ((__i8x16)__a)[15]}, 1111 __i16x8); 1112 } 1113 1114 static __inline__ v128_t __DEFAULT_FN_ATTRS 1115 wasm_i16x8_widen_low_u8x16(v128_t __a) { 1116 return (v128_t) __builtin_convertvector( 1117 (__u8x8){((__u8x16)__a)[0], ((__u8x16)__a)[1], ((__u8x16)__a)[2], 1118 ((__u8x16)__a)[3], ((__u8x16)__a)[4], ((__u8x16)__a)[5], 1119 ((__u8x16)__a)[6], ((__u8x16)__a)[7]}, 1120 __u16x8); 1121 } 1122 1123 static __inline__ v128_t __DEFAULT_FN_ATTRS 1124 wasm_i16x8_widen_high_u8x16(v128_t __a) { 1125 return (v128_t) __builtin_convertvector( 1126 (__u8x8){((__u8x16)__a)[8], ((__u8x16)__a)[9], ((__u8x16)__a)[10], 1127 ((__u8x16)__a)[11], ((__u8x16)__a)[12], ((__u8x16)__a)[13], 1128 ((__u8x16)__a)[14], ((__u8x16)__a)[15]}, 1129 __u16x8); 1130 } 1131 1132 static __inline__ v128_t __DEFAULT_FN_ATTRS 1133 wasm_i32x4_widen_low_i16x8(v128_t __a) { 1134 return (v128_t) __builtin_convertvector( 1135 (__i16x4){((__i16x8)__a)[0], ((__i16x8)__a)[1], ((__i16x8)__a)[2], 1136 ((__i16x8)__a)[3]}, 1137 __i32x4); 1138 } 1139 1140 static __inline__ v128_t __DEFAULT_FN_ATTRS 1141 wasm_i32x4_widen_high_i16x8(v128_t __a) { 1142 return (v128_t) __builtin_convertvector( 1143 (__i16x4){((__i16x8)__a)[4], ((__i16x8)__a)[5], ((__i16x8)__a)[6], 1144 ((__i16x8)__a)[7]}, 1145 __i32x4); 1146 } 1147 1148 static __inline__ v128_t __DEFAULT_FN_ATTRS 1149 wasm_i32x4_widen_low_u16x8(v128_t __a) { 1150 return (v128_t) __builtin_convertvector( 1151 (__u16x4){((__u16x8)__a)[0], ((__u16x8)__a)[1], ((__u16x8)__a)[2], 1152 ((__u16x8)__a)[3]}, 1153 __u32x4); 1154 } 1155 1156 static __inline__ v128_t __DEFAULT_FN_ATTRS 1157 wasm_i32x4_widen_high_u16x8(v128_t __a) { 1158 return (v128_t) __builtin_convertvector( 1159 (__u16x4){((__u16x8)__a)[4], ((__u16x8)__a)[5], ((__u16x8)__a)[6], 1160 ((__u16x8)__a)[7]}, 1161 __u32x4); 1162 } 1163 1164 // Undefine helper macros 1165 #undef __DEFAULT_FN_ATTRS 1166 1167 #endif // __WASM_SIMD128_H 1168