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 typedef __fp16 __f16x8 __attribute__((__vector_size__(16), __aligned__(16))); 37 38 typedef signed char __i8x8 __attribute__((__vector_size__(8), __aligned__(8))); 39 typedef unsigned char __u8x8 40 __attribute__((__vector_size__(8), __aligned__(8))); 41 typedef short __i16x4 __attribute__((__vector_size__(8), __aligned__(8))); 42 typedef unsigned short __u16x4 43 __attribute__((__vector_size__(8), __aligned__(8))); 44 typedef int __i32x2 __attribute__((__vector_size__(8), __aligned__(8))); 45 typedef unsigned int __u32x2 46 __attribute__((__vector_size__(8), __aligned__(8))); 47 typedef float __f32x2 __attribute__((__vector_size__(8), __aligned__(8))); 48 49 #define __DEFAULT_FN_ATTRS \ 50 __attribute__((__always_inline__, __nodebug__, __target__("simd128"), \ 51 __min_vector_width__(128))) 52 53 #define __REQUIRE_CONSTANT(c) \ 54 __attribute__((__diagnose_if__(!__builtin_constant_p(c), \ 55 #c " must be constant", "error"))) 56 57 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load(const void *__mem) { 58 // UB-free unaligned access copied from xmmintrin.h 59 struct __wasm_v128_load_struct { 60 __v128_u __v; 61 } __attribute__((__packed__, __may_alias__)); 62 return ((const struct __wasm_v128_load_struct *)__mem)->__v; 63 } 64 65 static __inline__ v128_t __DEFAULT_FN_ATTRS 66 wasm_v128_load8_splat(const void *__mem) { 67 struct __wasm_v128_load8_splat_struct { 68 uint8_t __v; 69 } __attribute__((__packed__, __may_alias__)); 70 uint8_t __v = ((const struct __wasm_v128_load8_splat_struct *)__mem)->__v; 71 return (v128_t)(__u8x16){__v, __v, __v, __v, __v, __v, __v, __v, 72 __v, __v, __v, __v, __v, __v, __v, __v}; 73 } 74 75 static __inline__ v128_t __DEFAULT_FN_ATTRS 76 wasm_v128_load16_splat(const void *__mem) { 77 struct __wasm_v128_load16_splat_struct { 78 uint16_t __v; 79 } __attribute__((__packed__, __may_alias__)); 80 uint16_t __v = ((const struct __wasm_v128_load16_splat_struct *)__mem)->__v; 81 return (v128_t)(__u16x8){__v, __v, __v, __v, __v, __v, __v, __v}; 82 } 83 84 static __inline__ v128_t __DEFAULT_FN_ATTRS 85 wasm_v128_load32_splat(const void *__mem) { 86 struct __wasm_v128_load32_splat_struct { 87 uint32_t __v; 88 } __attribute__((__packed__, __may_alias__)); 89 uint32_t __v = ((const struct __wasm_v128_load32_splat_struct *)__mem)->__v; 90 return (v128_t)(__u32x4){__v, __v, __v, __v}; 91 } 92 93 static __inline__ v128_t __DEFAULT_FN_ATTRS 94 wasm_v128_load64_splat(const void *__mem) { 95 struct __wasm_v128_load64_splat_struct { 96 uint64_t __v; 97 } __attribute__((__packed__, __may_alias__)); 98 uint64_t __v = ((const struct __wasm_v128_load64_splat_struct *)__mem)->__v; 99 return (v128_t)(__u64x2){__v, __v}; 100 } 101 102 static __inline__ v128_t __DEFAULT_FN_ATTRS 103 wasm_i16x8_load8x8(const void *__mem) { 104 struct __wasm_i16x8_load8x8_struct { 105 __i8x8 __v; 106 } __attribute__((__packed__, __may_alias__)); 107 __i8x8 __v = ((const struct __wasm_i16x8_load8x8_struct *)__mem)->__v; 108 return (v128_t) __builtin_convertvector(__v, __i16x8); 109 } 110 111 static __inline__ v128_t __DEFAULT_FN_ATTRS 112 wasm_u16x8_load8x8(const void *__mem) { 113 struct __wasm_u16x8_load8x8_struct { 114 __u8x8 __v; 115 } __attribute__((__packed__, __may_alias__)); 116 __u8x8 __v = ((const struct __wasm_u16x8_load8x8_struct *)__mem)->__v; 117 return (v128_t) __builtin_convertvector(__v, __u16x8); 118 } 119 120 static __inline__ v128_t __DEFAULT_FN_ATTRS 121 wasm_i32x4_load16x4(const void *__mem) { 122 struct __wasm_i32x4_load16x4_struct { 123 __i16x4 __v; 124 } __attribute__((__packed__, __may_alias__)); 125 __i16x4 __v = ((const struct __wasm_i32x4_load16x4_struct *)__mem)->__v; 126 return (v128_t) __builtin_convertvector(__v, __i32x4); 127 } 128 129 static __inline__ v128_t __DEFAULT_FN_ATTRS 130 wasm_u32x4_load16x4(const void *__mem) { 131 struct __wasm_u32x4_load16x4_struct { 132 __u16x4 __v; 133 } __attribute__((__packed__, __may_alias__)); 134 __u16x4 __v = ((const struct __wasm_u32x4_load16x4_struct *)__mem)->__v; 135 return (v128_t) __builtin_convertvector(__v, __u32x4); 136 } 137 138 static __inline__ v128_t __DEFAULT_FN_ATTRS 139 wasm_i64x2_load32x2(const void *__mem) { 140 struct __wasm_i64x2_load32x2_struct { 141 __i32x2 __v; 142 } __attribute__((__packed__, __may_alias__)); 143 __i32x2 __v = ((const struct __wasm_i64x2_load32x2_struct *)__mem)->__v; 144 return (v128_t) __builtin_convertvector(__v, __i64x2); 145 } 146 147 static __inline__ v128_t __DEFAULT_FN_ATTRS 148 wasm_u64x2_load32x2(const void *__mem) { 149 struct __wasm_u64x2_load32x2_struct { 150 __u32x2 __v; 151 } __attribute__((__packed__, __may_alias__)); 152 __u32x2 __v = ((const struct __wasm_u64x2_load32x2_struct *)__mem)->__v; 153 return (v128_t) __builtin_convertvector(__v, __u64x2); 154 } 155 156 static __inline__ v128_t __DEFAULT_FN_ATTRS 157 wasm_v128_load32_zero(const void *__mem) { 158 struct __wasm_v128_load32_zero_struct { 159 int32_t __v; 160 } __attribute__((__packed__, __may_alias__)); 161 int32_t __v = ((const struct __wasm_v128_load32_zero_struct *)__mem)->__v; 162 return (v128_t)(__i32x4){__v, 0, 0, 0}; 163 } 164 165 static __inline__ v128_t __DEFAULT_FN_ATTRS 166 wasm_v128_load64_zero(const void *__mem) { 167 struct __wasm_v128_load64_zero_struct { 168 int64_t __v; 169 } __attribute__((__packed__, __may_alias__)); 170 int64_t __v = ((const struct __wasm_v128_load64_zero_struct *)__mem)->__v; 171 return (v128_t)(__i64x2){__v, 0}; 172 } 173 174 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load8_lane( 175 const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { 176 struct __wasm_v128_load8_lane_struct { 177 int8_t __v; 178 } __attribute__((__packed__, __may_alias__)); 179 int8_t __v = ((const struct __wasm_v128_load8_lane_struct *)__mem)->__v; 180 __i8x16 __ret = (__i8x16)__vec; 181 __ret[__i] = __v; 182 return (v128_t)__ret; 183 } 184 185 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load16_lane( 186 const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { 187 struct __wasm_v128_load16_lane_struct { 188 int16_t __v; 189 } __attribute__((__packed__, __may_alias__)); 190 int16_t __v = ((const struct __wasm_v128_load16_lane_struct *)__mem)->__v; 191 __i16x8 __ret = (__i16x8)__vec; 192 __ret[__i] = __v; 193 return (v128_t)__ret; 194 } 195 196 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load32_lane( 197 const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { 198 struct __wasm_v128_load32_lane_struct { 199 int32_t __v; 200 } __attribute__((__packed__, __may_alias__)); 201 int32_t __v = ((const struct __wasm_v128_load32_lane_struct *)__mem)->__v; 202 __i32x4 __ret = (__i32x4)__vec; 203 __ret[__i] = __v; 204 return (v128_t)__ret; 205 } 206 207 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_load64_lane( 208 const void *__mem, v128_t __vec, int __i) __REQUIRE_CONSTANT(__i) { 209 struct __wasm_v128_load64_lane_struct { 210 int64_t __v; 211 } __attribute__((__packed__, __may_alias__)); 212 int64_t __v = ((const struct __wasm_v128_load64_lane_struct *)__mem)->__v; 213 __i64x2 __ret = (__i64x2)__vec; 214 __ret[__i] = __v; 215 return (v128_t)__ret; 216 } 217 218 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store(void *__mem, 219 v128_t __a) { 220 // UB-free unaligned access copied from xmmintrin.h 221 struct __wasm_v128_store_struct { 222 __v128_u __v; 223 } __attribute__((__packed__, __may_alias__)); 224 ((struct __wasm_v128_store_struct *)__mem)->__v = __a; 225 } 226 227 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store8_lane(void *__mem, 228 v128_t __vec, 229 int __i) 230 __REQUIRE_CONSTANT(__i) { 231 struct __wasm_v128_store8_lane_struct { 232 int8_t __v; 233 } __attribute__((__packed__, __may_alias__)); 234 ((struct __wasm_v128_store8_lane_struct *)__mem)->__v = ((__i8x16)__vec)[__i]; 235 } 236 237 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store16_lane(void *__mem, 238 v128_t __vec, 239 int __i) 240 __REQUIRE_CONSTANT(__i) { 241 struct __wasm_v128_store16_lane_struct { 242 int16_t __v; 243 } __attribute__((__packed__, __may_alias__)); 244 ((struct __wasm_v128_store16_lane_struct *)__mem)->__v = 245 ((__i16x8)__vec)[__i]; 246 } 247 248 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store32_lane(void *__mem, 249 v128_t __vec, 250 int __i) 251 __REQUIRE_CONSTANT(__i) { 252 struct __wasm_v128_store32_lane_struct { 253 int32_t __v; 254 } __attribute__((__packed__, __may_alias__)); 255 ((struct __wasm_v128_store32_lane_struct *)__mem)->__v = 256 ((__i32x4)__vec)[__i]; 257 } 258 259 static __inline__ void __DEFAULT_FN_ATTRS wasm_v128_store64_lane(void *__mem, 260 v128_t __vec, 261 int __i) 262 __REQUIRE_CONSTANT(__i) { 263 struct __wasm_v128_store64_lane_struct { 264 int64_t __v; 265 } __attribute__((__packed__, __may_alias__)); 266 ((struct __wasm_v128_store64_lane_struct *)__mem)->__v = 267 ((__i64x2)__vec)[__i]; 268 } 269 270 static __inline__ v128_t __DEFAULT_FN_ATTRS 271 wasm_i8x16_make(int8_t __c0, int8_t __c1, int8_t __c2, int8_t __c3, int8_t __c4, 272 int8_t __c5, int8_t __c6, int8_t __c7, int8_t __c8, int8_t __c9, 273 int8_t __c10, int8_t __c11, int8_t __c12, int8_t __c13, 274 int8_t __c14, int8_t __c15) { 275 return (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, 276 __c6, __c7, __c8, __c9, __c10, __c11, 277 __c12, __c13, __c14, __c15}; 278 } 279 280 static __inline__ v128_t __DEFAULT_FN_ATTRS 281 wasm_u8x16_make(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3, 282 uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7, 283 uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11, 284 uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15) { 285 return (v128_t)(__u8x16){__c0, __c1, __c2, __c3, __c4, __c5, 286 __c6, __c7, __c8, __c9, __c10, __c11, 287 __c12, __c13, __c14, __c15}; 288 } 289 290 static __inline__ v128_t __DEFAULT_FN_ATTRS 291 wasm_i16x8_make(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3, 292 int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) { 293 return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; 294 } 295 296 static __inline__ v128_t __DEFAULT_FN_ATTRS 297 wasm_u16x8_make(uint16_t __c0, uint16_t __c1, uint16_t __c2, uint16_t __c3, 298 uint16_t __c4, uint16_t __c5, uint16_t __c6, uint16_t __c7) { 299 return (v128_t)(__u16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; 300 } 301 302 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_make(int32_t __c0, 303 int32_t __c1, 304 int32_t __c2, 305 int32_t __c3) { 306 return (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; 307 } 308 309 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_make(uint32_t __c0, 310 uint32_t __c1, 311 uint32_t __c2, 312 uint32_t __c3) { 313 return (v128_t)(__u32x4){__c0, __c1, __c2, __c3}; 314 } 315 316 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_make(int64_t __c0, 317 int64_t __c1) { 318 return (v128_t)(__i64x2){__c0, __c1}; 319 } 320 321 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_make(uint64_t __c0, 322 uint64_t __c1) { 323 return (v128_t)(__u64x2){__c0, __c1}; 324 } 325 326 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_make(float __c0, 327 float __c1, 328 float __c2, 329 float __c3) { 330 return (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; 331 } 332 333 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_make(double __c0, 334 double __c1) { 335 return (v128_t)(__f64x2){__c0, __c1}; 336 } 337 338 static __inline__ v128_t __DEFAULT_FN_ATTRS 339 wasm_i8x16_const(int8_t __c0, int8_t __c1, int8_t __c2, int8_t __c3, 340 int8_t __c4, int8_t __c5, int8_t __c6, int8_t __c7, 341 int8_t __c8, int8_t __c9, int8_t __c10, int8_t __c11, 342 int8_t __c12, int8_t __c13, int8_t __c14, int8_t __c15) 343 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 344 __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) 345 __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) 346 __REQUIRE_CONSTANT(__c7) __REQUIRE_CONSTANT(__c8) 347 __REQUIRE_CONSTANT(__c9) __REQUIRE_CONSTANT(__c10) 348 __REQUIRE_CONSTANT(__c11) __REQUIRE_CONSTANT(__c12) 349 __REQUIRE_CONSTANT(__c13) __REQUIRE_CONSTANT(__c14) 350 __REQUIRE_CONSTANT(__c15) { 351 return (v128_t)(__i8x16){__c0, __c1, __c2, __c3, __c4, __c5, 352 __c6, __c7, __c8, __c9, __c10, __c11, 353 __c12, __c13, __c14, __c15}; 354 } 355 356 static __inline__ v128_t __DEFAULT_FN_ATTRS 357 wasm_u8x16_const(uint8_t __c0, uint8_t __c1, uint8_t __c2, uint8_t __c3, 358 uint8_t __c4, uint8_t __c5, uint8_t __c6, uint8_t __c7, 359 uint8_t __c8, uint8_t __c9, uint8_t __c10, uint8_t __c11, 360 uint8_t __c12, uint8_t __c13, uint8_t __c14, uint8_t __c15) 361 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 362 __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) 363 __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) 364 __REQUIRE_CONSTANT(__c7) __REQUIRE_CONSTANT(__c8) 365 __REQUIRE_CONSTANT(__c9) __REQUIRE_CONSTANT(__c10) 366 __REQUIRE_CONSTANT(__c11) __REQUIRE_CONSTANT(__c12) 367 __REQUIRE_CONSTANT(__c13) __REQUIRE_CONSTANT(__c14) 368 __REQUIRE_CONSTANT(__c15) { 369 return (v128_t)(__u8x16){__c0, __c1, __c2, __c3, __c4, __c5, 370 __c6, __c7, __c8, __c9, __c10, __c11, 371 __c12, __c13, __c14, __c15}; 372 } 373 374 static __inline__ v128_t __DEFAULT_FN_ATTRS 375 wasm_i16x8_const(int16_t __c0, int16_t __c1, int16_t __c2, int16_t __c3, 376 int16_t __c4, int16_t __c5, int16_t __c6, int16_t __c7) 377 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 378 __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) 379 __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) 380 __REQUIRE_CONSTANT(__c7) { 381 return (v128_t)(__i16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; 382 } 383 384 static __inline__ v128_t __DEFAULT_FN_ATTRS 385 wasm_u16x8_const(uint16_t __c0, uint16_t __c1, uint16_t __c2, uint16_t __c3, 386 uint16_t __c4, uint16_t __c5, uint16_t __c6, uint16_t __c7) 387 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 388 __REQUIRE_CONSTANT(__c3) __REQUIRE_CONSTANT(__c4) 389 __REQUIRE_CONSTANT(__c5) __REQUIRE_CONSTANT(__c6) 390 __REQUIRE_CONSTANT(__c7) { 391 return (v128_t)(__u16x8){__c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7}; 392 } 393 394 static __inline__ v128_t __DEFAULT_FN_ATTRS 395 wasm_i32x4_const(int32_t __c0, int32_t __c1, int32_t __c2, int32_t __c3) 396 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 397 __REQUIRE_CONSTANT(__c3) { 398 return (v128_t)(__i32x4){__c0, __c1, __c2, __c3}; 399 } 400 401 static __inline__ v128_t __DEFAULT_FN_ATTRS 402 wasm_u32x4_const(uint32_t __c0, uint32_t __c1, uint32_t __c2, uint32_t __c3) 403 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 404 __REQUIRE_CONSTANT(__c3) { 405 return (v128_t)(__u32x4){__c0, __c1, __c2, __c3}; 406 } 407 408 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_const(int64_t __c0, 409 int64_t __c1) 410 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { 411 return (v128_t)(__i64x2){__c0, __c1}; 412 } 413 414 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_const(uint64_t __c0, 415 uint64_t __c1) 416 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { 417 return (v128_t)(__u64x2){__c0, __c1}; 418 } 419 420 static __inline__ v128_t __DEFAULT_FN_ATTRS 421 wasm_f32x4_const(float __c0, float __c1, float __c2, float __c3) 422 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) __REQUIRE_CONSTANT(__c2) 423 __REQUIRE_CONSTANT(__c3) { 424 return (v128_t)(__f32x4){__c0, __c1, __c2, __c3}; 425 } 426 427 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_const(double __c0, 428 double __c1) 429 __REQUIRE_CONSTANT(__c0) __REQUIRE_CONSTANT(__c1) { 430 return (v128_t)(__f64x2){__c0, __c1}; 431 } 432 433 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_const_splat(int8_t __c) 434 __REQUIRE_CONSTANT(__c) { 435 return (v128_t)(__i8x16){__c, __c, __c, __c, __c, __c, __c, __c, 436 __c, __c, __c, __c, __c, __c, __c, __c}; 437 } 438 439 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_const_splat(uint8_t __c) 440 __REQUIRE_CONSTANT(__c) { 441 return (v128_t)(__u8x16){__c, __c, __c, __c, __c, __c, __c, __c, 442 __c, __c, __c, __c, __c, __c, __c, __c}; 443 } 444 445 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_const_splat(int16_t __c) 446 __REQUIRE_CONSTANT(__c) { 447 return (v128_t)(__i16x8){__c, __c, __c, __c, __c, __c, __c, __c}; 448 } 449 450 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_const_splat(uint16_t __c) 451 __REQUIRE_CONSTANT(__c) { 452 return (v128_t)(__u16x8){__c, __c, __c, __c, __c, __c, __c, __c}; 453 } 454 455 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_const_splat(int32_t __c) 456 __REQUIRE_CONSTANT(__c) { 457 return (v128_t)(__i32x4){__c, __c, __c, __c}; 458 } 459 460 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_const_splat(uint32_t __c) 461 __REQUIRE_CONSTANT(__c) { 462 return (v128_t)(__u32x4){__c, __c, __c, __c}; 463 } 464 465 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_const_splat(int64_t __c) 466 __REQUIRE_CONSTANT(__c) { 467 return (v128_t)(__i64x2){__c, __c}; 468 } 469 470 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_const_splat(uint64_t __c) 471 __REQUIRE_CONSTANT(__c) { 472 return (v128_t)(__u64x2){__c, __c}; 473 } 474 475 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_const_splat(float __c) 476 __REQUIRE_CONSTANT(__c) { 477 return (v128_t)(__f32x4){__c, __c, __c, __c}; 478 } 479 480 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_const_splat(double __c) 481 __REQUIRE_CONSTANT(__c) { 482 return (v128_t)(__f64x2){__c, __c}; 483 } 484 485 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_splat(int8_t __a) { 486 return (v128_t)(__i8x16){__a, __a, __a, __a, __a, __a, __a, __a, 487 __a, __a, __a, __a, __a, __a, __a, __a}; 488 } 489 490 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_splat(uint8_t __a) { 491 return (v128_t)(__u8x16){__a, __a, __a, __a, __a, __a, __a, __a, 492 __a, __a, __a, __a, __a, __a, __a, __a}; 493 } 494 495 static __inline__ int8_t __DEFAULT_FN_ATTRS wasm_i8x16_extract_lane(v128_t __a, 496 int __i) 497 __REQUIRE_CONSTANT(__i) { 498 return ((__i8x16)__a)[__i]; 499 } 500 501 static __inline__ uint8_t __DEFAULT_FN_ATTRS wasm_u8x16_extract_lane(v128_t __a, 502 int __i) 503 __REQUIRE_CONSTANT(__i) { 504 return ((__u8x16)__a)[__i]; 505 } 506 507 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_replace_lane(v128_t __a, 508 int __i, 509 int8_t __b) 510 __REQUIRE_CONSTANT(__i) { 511 __i8x16 __v = (__i8x16)__a; 512 __v[__i] = __b; 513 return (v128_t)__v; 514 } 515 516 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_replace_lane(v128_t __a, 517 int __i, 518 uint8_t __b) 519 __REQUIRE_CONSTANT(__i) { 520 __u8x16 __v = (__u8x16)__a; 521 __v[__i] = __b; 522 return (v128_t)__v; 523 } 524 525 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_splat(int16_t __a) { 526 return (v128_t)(__i16x8){__a, __a, __a, __a, __a, __a, __a, __a}; 527 } 528 529 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_splat(uint16_t __a) { 530 return (v128_t)(__u16x8){__a, __a, __a, __a, __a, __a, __a, __a}; 531 } 532 533 static __inline__ int16_t __DEFAULT_FN_ATTRS wasm_i16x8_extract_lane(v128_t __a, 534 int __i) 535 __REQUIRE_CONSTANT(__i) { 536 return ((__i16x8)__a)[__i]; 537 } 538 539 static __inline__ uint16_t __DEFAULT_FN_ATTRS 540 wasm_u16x8_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { 541 return ((__u16x8)__a)[__i]; 542 } 543 544 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_replace_lane(v128_t __a, 545 int __i, 546 int16_t __b) 547 __REQUIRE_CONSTANT(__i) { 548 __i16x8 __v = (__i16x8)__a; 549 __v[__i] = __b; 550 return (v128_t)__v; 551 } 552 553 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_replace_lane( 554 v128_t __a, int __i, uint16_t __b) __REQUIRE_CONSTANT(__i) { 555 __u16x8 __v = (__u16x8)__a; 556 __v[__i] = __b; 557 return (v128_t)__v; 558 } 559 560 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_splat(int32_t __a) { 561 return (v128_t)(__i32x4){__a, __a, __a, __a}; 562 } 563 564 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_splat(uint32_t __a) { 565 return (v128_t)(__u32x4){__a, __a, __a, __a}; 566 } 567 568 static __inline__ int32_t __DEFAULT_FN_ATTRS wasm_i32x4_extract_lane(v128_t __a, 569 int __i) 570 __REQUIRE_CONSTANT(__i) { 571 return ((__i32x4)__a)[__i]; 572 } 573 574 static __inline__ uint32_t __DEFAULT_FN_ATTRS 575 wasm_u32x4_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { 576 return ((__u32x4)__a)[__i]; 577 } 578 579 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_replace_lane(v128_t __a, 580 int __i, 581 int32_t __b) 582 __REQUIRE_CONSTANT(__i) { 583 __i32x4 __v = (__i32x4)__a; 584 __v[__i] = __b; 585 return (v128_t)__v; 586 } 587 588 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_replace_lane( 589 v128_t __a, int __i, uint32_t __b) __REQUIRE_CONSTANT(__i) { 590 __u32x4 __v = (__u32x4)__a; 591 __v[__i] = __b; 592 return (v128_t)__v; 593 } 594 595 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_splat(int64_t __a) { 596 return (v128_t)(__i64x2){__a, __a}; 597 } 598 599 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_splat(uint64_t __a) { 600 return (v128_t)(__u64x2){__a, __a}; 601 } 602 603 static __inline__ int64_t __DEFAULT_FN_ATTRS wasm_i64x2_extract_lane(v128_t __a, 604 int __i) 605 __REQUIRE_CONSTANT(__i) { 606 return ((__i64x2)__a)[__i]; 607 } 608 609 static __inline__ uint64_t __DEFAULT_FN_ATTRS 610 wasm_u64x2_extract_lane(v128_t __a, int __i) __REQUIRE_CONSTANT(__i) { 611 return ((__u64x2)__a)[__i]; 612 } 613 614 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_replace_lane(v128_t __a, 615 int __i, 616 int64_t __b) 617 __REQUIRE_CONSTANT(__i) { 618 __i64x2 __v = (__i64x2)__a; 619 __v[__i] = __b; 620 return (v128_t)__v; 621 } 622 623 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_replace_lane( 624 v128_t __a, int __i, uint64_t __b) __REQUIRE_CONSTANT(__i) { 625 __u64x2 __v = (__u64x2)__a; 626 __v[__i] = __b; 627 return (v128_t)__v; 628 } 629 630 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_splat(float __a) { 631 return (v128_t)(__f32x4){__a, __a, __a, __a}; 632 } 633 634 static __inline__ float __DEFAULT_FN_ATTRS wasm_f32x4_extract_lane(v128_t __a, 635 int __i) 636 __REQUIRE_CONSTANT(__i) { 637 return ((__f32x4)__a)[__i]; 638 } 639 640 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_replace_lane(v128_t __a, 641 int __i, 642 float __b) 643 __REQUIRE_CONSTANT(__i) { 644 __f32x4 __v = (__f32x4)__a; 645 __v[__i] = __b; 646 return (v128_t)__v; 647 } 648 649 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_splat(double __a) { 650 return (v128_t)(__f64x2){__a, __a}; 651 } 652 653 static __inline__ double __DEFAULT_FN_ATTRS wasm_f64x2_extract_lane(v128_t __a, 654 int __i) 655 __REQUIRE_CONSTANT(__i) { 656 return ((__f64x2)__a)[__i]; 657 } 658 659 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_replace_lane(v128_t __a, 660 int __i, 661 double __b) 662 __REQUIRE_CONSTANT(__i) { 663 __f64x2 __v = (__f64x2)__a; 664 __v[__i] = __b; 665 return (v128_t)__v; 666 } 667 668 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_eq(v128_t __a, 669 v128_t __b) { 670 return (v128_t)((__i8x16)__a == (__i8x16)__b); 671 } 672 673 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ne(v128_t __a, 674 v128_t __b) { 675 return (v128_t)((__i8x16)__a != (__i8x16)__b); 676 } 677 678 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_lt(v128_t __a, 679 v128_t __b) { 680 return (v128_t)((__i8x16)__a < (__i8x16)__b); 681 } 682 683 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_lt(v128_t __a, 684 v128_t __b) { 685 return (v128_t)((__u8x16)__a < (__u8x16)__b); 686 } 687 688 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_gt(v128_t __a, 689 v128_t __b) { 690 return (v128_t)((__i8x16)__a > (__i8x16)__b); 691 } 692 693 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_gt(v128_t __a, 694 v128_t __b) { 695 return (v128_t)((__u8x16)__a > (__u8x16)__b); 696 } 697 698 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_le(v128_t __a, 699 v128_t __b) { 700 return (v128_t)((__i8x16)__a <= (__i8x16)__b); 701 } 702 703 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_le(v128_t __a, 704 v128_t __b) { 705 return (v128_t)((__u8x16)__a <= (__u8x16)__b); 706 } 707 708 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_ge(v128_t __a, 709 v128_t __b) { 710 return (v128_t)((__i8x16)__a >= (__i8x16)__b); 711 } 712 713 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_ge(v128_t __a, 714 v128_t __b) { 715 return (v128_t)((__u8x16)__a >= (__u8x16)__b); 716 } 717 718 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_eq(v128_t __a, 719 v128_t __b) { 720 return (v128_t)((__i16x8)__a == (__i16x8)__b); 721 } 722 723 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ne(v128_t __a, 724 v128_t __b) { 725 return (v128_t)((__u16x8)__a != (__u16x8)__b); 726 } 727 728 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_lt(v128_t __a, 729 v128_t __b) { 730 return (v128_t)((__i16x8)__a < (__i16x8)__b); 731 } 732 733 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_lt(v128_t __a, 734 v128_t __b) { 735 return (v128_t)((__u16x8)__a < (__u16x8)__b); 736 } 737 738 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_gt(v128_t __a, 739 v128_t __b) { 740 return (v128_t)((__i16x8)__a > (__i16x8)__b); 741 } 742 743 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_gt(v128_t __a, 744 v128_t __b) { 745 return (v128_t)((__u16x8)__a > (__u16x8)__b); 746 } 747 748 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_le(v128_t __a, 749 v128_t __b) { 750 return (v128_t)((__i16x8)__a <= (__i16x8)__b); 751 } 752 753 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_le(v128_t __a, 754 v128_t __b) { 755 return (v128_t)((__u16x8)__a <= (__u16x8)__b); 756 } 757 758 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_ge(v128_t __a, 759 v128_t __b) { 760 return (v128_t)((__i16x8)__a >= (__i16x8)__b); 761 } 762 763 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_ge(v128_t __a, 764 v128_t __b) { 765 return (v128_t)((__u16x8)__a >= (__u16x8)__b); 766 } 767 768 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_eq(v128_t __a, 769 v128_t __b) { 770 return (v128_t)((__i32x4)__a == (__i32x4)__b); 771 } 772 773 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ne(v128_t __a, 774 v128_t __b) { 775 return (v128_t)((__i32x4)__a != (__i32x4)__b); 776 } 777 778 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_lt(v128_t __a, 779 v128_t __b) { 780 return (v128_t)((__i32x4)__a < (__i32x4)__b); 781 } 782 783 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_lt(v128_t __a, 784 v128_t __b) { 785 return (v128_t)((__u32x4)__a < (__u32x4)__b); 786 } 787 788 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_gt(v128_t __a, 789 v128_t __b) { 790 return (v128_t)((__i32x4)__a > (__i32x4)__b); 791 } 792 793 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_gt(v128_t __a, 794 v128_t __b) { 795 return (v128_t)((__u32x4)__a > (__u32x4)__b); 796 } 797 798 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_le(v128_t __a, 799 v128_t __b) { 800 return (v128_t)((__i32x4)__a <= (__i32x4)__b); 801 } 802 803 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_le(v128_t __a, 804 v128_t __b) { 805 return (v128_t)((__u32x4)__a <= (__u32x4)__b); 806 } 807 808 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_ge(v128_t __a, 809 v128_t __b) { 810 return (v128_t)((__i32x4)__a >= (__i32x4)__b); 811 } 812 813 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_ge(v128_t __a, 814 v128_t __b) { 815 return (v128_t)((__u32x4)__a >= (__u32x4)__b); 816 } 817 818 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_eq(v128_t __a, 819 v128_t __b) { 820 return (v128_t)((__i64x2)__a == (__i64x2)__b); 821 } 822 823 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_ne(v128_t __a, 824 v128_t __b) { 825 return (v128_t)((__i64x2)__a != (__i64x2)__b); 826 } 827 828 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_lt(v128_t __a, 829 v128_t __b) { 830 return (v128_t)((__i64x2)__a < (__i64x2)__b); 831 } 832 833 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_gt(v128_t __a, 834 v128_t __b) { 835 return (v128_t)((__i64x2)__a > (__i64x2)__b); 836 } 837 838 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_le(v128_t __a, 839 v128_t __b) { 840 return (v128_t)((__i64x2)__a <= (__i64x2)__b); 841 } 842 843 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_ge(v128_t __a, 844 v128_t __b) { 845 return (v128_t)((__i64x2)__a >= (__i64x2)__b); 846 } 847 848 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_eq(v128_t __a, 849 v128_t __b) { 850 return (v128_t)((__f32x4)__a == (__f32x4)__b); 851 } 852 853 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ne(v128_t __a, 854 v128_t __b) { 855 return (v128_t)((__f32x4)__a != (__f32x4)__b); 856 } 857 858 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_lt(v128_t __a, 859 v128_t __b) { 860 return (v128_t)((__f32x4)__a < (__f32x4)__b); 861 } 862 863 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_gt(v128_t __a, 864 v128_t __b) { 865 return (v128_t)((__f32x4)__a > (__f32x4)__b); 866 } 867 868 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_le(v128_t __a, 869 v128_t __b) { 870 return (v128_t)((__f32x4)__a <= (__f32x4)__b); 871 } 872 873 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ge(v128_t __a, 874 v128_t __b) { 875 return (v128_t)((__f32x4)__a >= (__f32x4)__b); 876 } 877 878 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_eq(v128_t __a, 879 v128_t __b) { 880 return (v128_t)((__f64x2)__a == (__f64x2)__b); 881 } 882 883 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ne(v128_t __a, 884 v128_t __b) { 885 return (v128_t)((__f64x2)__a != (__f64x2)__b); 886 } 887 888 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_lt(v128_t __a, 889 v128_t __b) { 890 return (v128_t)((__f64x2)__a < (__f64x2)__b); 891 } 892 893 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_gt(v128_t __a, 894 v128_t __b) { 895 return (v128_t)((__f64x2)__a > (__f64x2)__b); 896 } 897 898 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_le(v128_t __a, 899 v128_t __b) { 900 return (v128_t)((__f64x2)__a <= (__f64x2)__b); 901 } 902 903 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ge(v128_t __a, 904 v128_t __b) { 905 return (v128_t)((__f64x2)__a >= (__f64x2)__b); 906 } 907 908 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_not(v128_t __a) { 909 return ~__a; 910 } 911 912 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_and(v128_t __a, 913 v128_t __b) { 914 return __a & __b; 915 } 916 917 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_or(v128_t __a, 918 v128_t __b) { 919 return __a | __b; 920 } 921 922 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_xor(v128_t __a, 923 v128_t __b) { 924 return __a ^ __b; 925 } 926 927 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_andnot(v128_t __a, 928 v128_t __b) { 929 return __a & ~__b; 930 } 931 932 static __inline__ bool __DEFAULT_FN_ATTRS wasm_v128_any_true(v128_t __a) { 933 return __builtin_wasm_any_true_v128((__i8x16)__a); 934 } 935 936 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_v128_bitselect(v128_t __a, 937 v128_t __b, 938 v128_t __mask) { 939 return (v128_t)__builtin_wasm_bitselect((__i32x4)__a, (__i32x4)__b, 940 (__i32x4)__mask); 941 } 942 943 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_abs(v128_t __a) { 944 return (v128_t)__builtin_wasm_abs_i8x16((__i8x16)__a); 945 } 946 947 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_neg(v128_t __a) { 948 return (v128_t)(-(__u8x16)__a); 949 } 950 951 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i8x16_all_true(v128_t __a) { 952 return __builtin_wasm_all_true_i8x16((__i8x16)__a); 953 } 954 955 static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i8x16_bitmask(v128_t __a) { 956 return __builtin_wasm_bitmask_i8x16((__i8x16)__a); 957 } 958 959 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_popcnt(v128_t __a) { 960 return (v128_t)__builtin_elementwise_popcount((__i8x16)__a); 961 } 962 963 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shl(v128_t __a, 964 uint32_t __b) { 965 return (v128_t)((__i8x16)__a << (__b & 0x7)); 966 } 967 968 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_shr(v128_t __a, 969 uint32_t __b) { 970 return (v128_t)((__i8x16)__a >> (__b & 0x7)); 971 } 972 973 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_shr(v128_t __a, 974 uint32_t __b) { 975 return (v128_t)((__u8x16)__a >> (__b & 0x7)); 976 } 977 978 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add(v128_t __a, 979 v128_t __b) { 980 return (v128_t)((__u8x16)__a + (__u8x16)__b); 981 } 982 983 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_add_sat(v128_t __a, 984 v128_t __b) { 985 return (v128_t)__builtin_elementwise_add_sat((__i8x16)__a, (__i8x16)__b); 986 } 987 988 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_add_sat(v128_t __a, 989 v128_t __b) { 990 return (v128_t)__builtin_elementwise_add_sat((__u8x16)__a, (__u8x16)__b); 991 } 992 993 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a, 994 v128_t __b) { 995 return (v128_t)((__u8x16)__a - (__u8x16)__b); 996 } 997 998 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub_sat(v128_t __a, 999 v128_t __b) { 1000 return (v128_t)__builtin_elementwise_sub_sat((__i8x16)__a, (__i8x16)__b); 1001 } 1002 1003 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_sub_sat(v128_t __a, 1004 v128_t __b) { 1005 return (v128_t)__builtin_elementwise_sub_sat((__u8x16)__a, (__u8x16)__b); 1006 } 1007 1008 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a, 1009 v128_t __b) { 1010 return (v128_t)__builtin_elementwise_min((__i8x16)__a, (__i8x16)__b); 1011 } 1012 1013 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a, 1014 v128_t __b) { 1015 return (v128_t)__builtin_elementwise_min((__u8x16)__a, (__u8x16)__b); 1016 } 1017 1018 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a, 1019 v128_t __b) { 1020 return (v128_t)__builtin_elementwise_max((__i8x16)__a, (__i8x16)__b); 1021 } 1022 1023 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a, 1024 v128_t __b) { 1025 return (v128_t)__builtin_elementwise_max((__u8x16)__a, (__u8x16)__b); 1026 } 1027 1028 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a, 1029 v128_t __b) { 1030 return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b); 1031 } 1032 1033 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) { 1034 return (v128_t)__builtin_wasm_abs_i16x8((__i16x8)__a); 1035 } 1036 1037 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_neg(v128_t __a) { 1038 return (v128_t)(-(__u16x8)__a); 1039 } 1040 1041 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i16x8_all_true(v128_t __a) { 1042 return __builtin_wasm_all_true_i16x8((__i16x8)__a); 1043 } 1044 1045 static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i16x8_bitmask(v128_t __a) { 1046 return __builtin_wasm_bitmask_i16x8((__i16x8)__a); 1047 } 1048 1049 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shl(v128_t __a, 1050 uint32_t __b) { 1051 return (v128_t)((__i16x8)__a << (__b & 0xF)); 1052 } 1053 1054 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_shr(v128_t __a, 1055 uint32_t __b) { 1056 return (v128_t)((__i16x8)__a >> (__b & 0xF)); 1057 } 1058 1059 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_shr(v128_t __a, 1060 uint32_t __b) { 1061 return (v128_t)((__u16x8)__a >> (__b & 0xF)); 1062 } 1063 1064 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add(v128_t __a, 1065 v128_t __b) { 1066 return (v128_t)((__u16x8)__a + (__u16x8)__b); 1067 } 1068 1069 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_add_sat(v128_t __a, 1070 v128_t __b) { 1071 return (v128_t)__builtin_elementwise_add_sat((__i16x8)__a, (__i16x8)__b); 1072 } 1073 1074 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_add_sat(v128_t __a, 1075 v128_t __b) { 1076 return (v128_t)__builtin_elementwise_add_sat((__u16x8)__a, (__u16x8)__b); 1077 } 1078 1079 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a, 1080 v128_t __b) { 1081 return (v128_t)((__i16x8)__a - (__i16x8)__b); 1082 } 1083 1084 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub_sat(v128_t __a, 1085 v128_t __b) { 1086 return (v128_t)__builtin_elementwise_sub_sat((__i16x8)__a, (__i16x8)__b); 1087 } 1088 1089 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_sub_sat(v128_t __a, 1090 v128_t __b) { 1091 return (v128_t)__builtin_elementwise_sub_sat((__u16x8)__a, (__u16x8)__b); 1092 } 1093 1094 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_mul(v128_t __a, 1095 v128_t __b) { 1096 return (v128_t)((__u16x8)__a * (__u16x8)__b); 1097 } 1098 1099 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_min(v128_t __a, 1100 v128_t __b) { 1101 return (v128_t)__builtin_elementwise_min((__i16x8)__a, (__i16x8)__b); 1102 } 1103 1104 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a, 1105 v128_t __b) { 1106 return (v128_t)__builtin_elementwise_min((__u16x8)__a, (__u16x8)__b); 1107 } 1108 1109 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a, 1110 v128_t __b) { 1111 return (v128_t)__builtin_elementwise_max((__i16x8)__a, (__i16x8)__b); 1112 } 1113 1114 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_max(v128_t __a, 1115 v128_t __b) { 1116 return (v128_t)__builtin_elementwise_max((__u16x8)__a, (__u16x8)__b); 1117 } 1118 1119 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_avgr(v128_t __a, 1120 v128_t __b) { 1121 return (v128_t)__builtin_wasm_avgr_u_i16x8((__u16x8)__a, (__u16x8)__b); 1122 } 1123 1124 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_abs(v128_t __a) { 1125 return (v128_t)__builtin_wasm_abs_i32x4((__i32x4)__a); 1126 } 1127 1128 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_neg(v128_t __a) { 1129 return (v128_t)(-(__u32x4)__a); 1130 } 1131 1132 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i32x4_all_true(v128_t __a) { 1133 return __builtin_wasm_all_true_i32x4((__i32x4)__a); 1134 } 1135 1136 static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i32x4_bitmask(v128_t __a) { 1137 return __builtin_wasm_bitmask_i32x4((__i32x4)__a); 1138 } 1139 1140 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shl(v128_t __a, 1141 uint32_t __b) { 1142 return (v128_t)((__i32x4)__a << (__b & 0x1F)); 1143 } 1144 1145 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_shr(v128_t __a, 1146 uint32_t __b) { 1147 return (v128_t)((__i32x4)__a >> (__b & 0x1F)); 1148 } 1149 1150 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_shr(v128_t __a, 1151 uint32_t __b) { 1152 return (v128_t)((__u32x4)__a >> (__b & 0x1F)); 1153 } 1154 1155 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_add(v128_t __a, 1156 v128_t __b) { 1157 return (v128_t)((__u32x4)__a + (__u32x4)__b); 1158 } 1159 1160 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_sub(v128_t __a, 1161 v128_t __b) { 1162 return (v128_t)((__u32x4)__a - (__u32x4)__b); 1163 } 1164 1165 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_mul(v128_t __a, 1166 v128_t __b) { 1167 return (v128_t)((__u32x4)__a * (__u32x4)__b); 1168 } 1169 1170 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_min(v128_t __a, 1171 v128_t __b) { 1172 return (v128_t)__builtin_elementwise_min((__i32x4)__a, (__i32x4)__b); 1173 } 1174 1175 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_min(v128_t __a, 1176 v128_t __b) { 1177 return (v128_t)__builtin_elementwise_min((__u32x4)__a, (__u32x4)__b); 1178 } 1179 1180 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_max(v128_t __a, 1181 v128_t __b) { 1182 return (v128_t)__builtin_elementwise_max((__i32x4)__a, (__i32x4)__b); 1183 } 1184 1185 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u32x4_max(v128_t __a, 1186 v128_t __b) { 1187 return (v128_t)__builtin_elementwise_max((__u32x4)__a, (__u32x4)__b); 1188 } 1189 1190 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i32x4_dot_i16x8(v128_t __a, 1191 v128_t __b) { 1192 return (v128_t)__builtin_wasm_dot_s_i32x4_i16x8((__i16x8)__a, (__i16x8)__b); 1193 } 1194 1195 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_abs(v128_t __a) { 1196 return (v128_t)__builtin_wasm_abs_i64x2((__i64x2)__a); 1197 } 1198 1199 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_neg(v128_t __a) { 1200 return (v128_t)(-(__u64x2)__a); 1201 } 1202 1203 static __inline__ bool __DEFAULT_FN_ATTRS wasm_i64x2_all_true(v128_t __a) { 1204 return __builtin_wasm_all_true_i64x2((__i64x2)__a); 1205 } 1206 1207 static __inline__ uint32_t __DEFAULT_FN_ATTRS wasm_i64x2_bitmask(v128_t __a) { 1208 return __builtin_wasm_bitmask_i64x2((__i64x2)__a); 1209 } 1210 1211 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shl(v128_t __a, 1212 uint32_t __b) { 1213 return (v128_t)((__i64x2)__a << ((int64_t)__b & 0x3F)); 1214 } 1215 1216 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_shr(v128_t __a, 1217 uint32_t __b) { 1218 return (v128_t)((__i64x2)__a >> ((int64_t)__b & 0x3F)); 1219 } 1220 1221 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u64x2_shr(v128_t __a, 1222 uint32_t __b) { 1223 return (v128_t)((__u64x2)__a >> ((int64_t)__b & 0x3F)); 1224 } 1225 1226 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_add(v128_t __a, 1227 v128_t __b) { 1228 return (v128_t)((__u64x2)__a + (__u64x2)__b); 1229 } 1230 1231 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_sub(v128_t __a, 1232 v128_t __b) { 1233 return (v128_t)((__u64x2)__a - (__u64x2)__b); 1234 } 1235 1236 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i64x2_mul(v128_t __a, 1237 v128_t __b) { 1238 return (v128_t)((__u64x2)__a * (__u64x2)__b); 1239 } 1240 1241 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_abs(v128_t __a) { 1242 return (v128_t)__builtin_wasm_abs_f32x4((__f32x4)__a); 1243 } 1244 1245 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_neg(v128_t __a) { 1246 return (v128_t)(-(__f32x4)__a); 1247 } 1248 1249 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sqrt(v128_t __a) { 1250 return (v128_t)__builtin_wasm_sqrt_f32x4((__f32x4)__a); 1251 } 1252 1253 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_ceil(v128_t __a) { 1254 return (v128_t)__builtin_wasm_ceil_f32x4((__f32x4)__a); 1255 } 1256 1257 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_floor(v128_t __a) { 1258 return (v128_t)__builtin_wasm_floor_f32x4((__f32x4)__a); 1259 } 1260 1261 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_trunc(v128_t __a) { 1262 return (v128_t)__builtin_wasm_trunc_f32x4((__f32x4)__a); 1263 } 1264 1265 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_nearest(v128_t __a) { 1266 return (v128_t)__builtin_wasm_nearest_f32x4((__f32x4)__a); 1267 } 1268 1269 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_add(v128_t __a, 1270 v128_t __b) { 1271 return (v128_t)((__f32x4)__a + (__f32x4)__b); 1272 } 1273 1274 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_sub(v128_t __a, 1275 v128_t __b) { 1276 return (v128_t)((__f32x4)__a - (__f32x4)__b); 1277 } 1278 1279 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_mul(v128_t __a, 1280 v128_t __b) { 1281 return (v128_t)((__f32x4)__a * (__f32x4)__b); 1282 } 1283 1284 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_div(v128_t __a, 1285 v128_t __b) { 1286 return (v128_t)((__f32x4)__a / (__f32x4)__b); 1287 } 1288 1289 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_min(v128_t __a, 1290 v128_t __b) { 1291 return (v128_t)__builtin_wasm_min_f32x4((__f32x4)__a, (__f32x4)__b); 1292 } 1293 1294 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_max(v128_t __a, 1295 v128_t __b) { 1296 return (v128_t)__builtin_wasm_max_f32x4((__f32x4)__a, (__f32x4)__b); 1297 } 1298 1299 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmin(v128_t __a, 1300 v128_t __b) { 1301 return (v128_t)__builtin_wasm_pmin_f32x4((__f32x4)__a, (__f32x4)__b); 1302 } 1303 1304 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f32x4_pmax(v128_t __a, 1305 v128_t __b) { 1306 return (v128_t)__builtin_wasm_pmax_f32x4((__f32x4)__a, (__f32x4)__b); 1307 } 1308 1309 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_abs(v128_t __a) { 1310 return (v128_t)__builtin_wasm_abs_f64x2((__f64x2)__a); 1311 } 1312 1313 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_neg(v128_t __a) { 1314 return (v128_t)(-(__f64x2)__a); 1315 } 1316 1317 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sqrt(v128_t __a) { 1318 return (v128_t)__builtin_wasm_sqrt_f64x2((__f64x2)__a); 1319 } 1320 1321 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_ceil(v128_t __a) { 1322 return (v128_t)__builtin_wasm_ceil_f64x2((__f64x2)__a); 1323 } 1324 1325 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_floor(v128_t __a) { 1326 return (v128_t)__builtin_wasm_floor_f64x2((__f64x2)__a); 1327 } 1328 1329 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_trunc(v128_t __a) { 1330 return (v128_t)__builtin_wasm_trunc_f64x2((__f64x2)__a); 1331 } 1332 1333 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_nearest(v128_t __a) { 1334 return (v128_t)__builtin_wasm_nearest_f64x2((__f64x2)__a); 1335 } 1336 1337 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_add(v128_t __a, 1338 v128_t __b) { 1339 return (v128_t)((__f64x2)__a + (__f64x2)__b); 1340 } 1341 1342 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_sub(v128_t __a, 1343 v128_t __b) { 1344 return (v128_t)((__f64x2)__a - (__f64x2)__b); 1345 } 1346 1347 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_mul(v128_t __a, 1348 v128_t __b) { 1349 return (v128_t)((__f64x2)__a * (__f64x2)__b); 1350 } 1351 1352 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_div(v128_t __a, 1353 v128_t __b) { 1354 return (v128_t)((__f64x2)__a / (__f64x2)__b); 1355 } 1356 1357 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_min(v128_t __a, 1358 v128_t __b) { 1359 return (v128_t)__builtin_wasm_min_f64x2((__f64x2)__a, (__f64x2)__b); 1360 } 1361 1362 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_max(v128_t __a, 1363 v128_t __b) { 1364 return (v128_t)__builtin_wasm_max_f64x2((__f64x2)__a, (__f64x2)__b); 1365 } 1366 1367 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmin(v128_t __a, 1368 v128_t __b) { 1369 return (v128_t)__builtin_wasm_pmin_f64x2((__f64x2)__a, (__f64x2)__b); 1370 } 1371 1372 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_f64x2_pmax(v128_t __a, 1373 v128_t __b) { 1374 return (v128_t)__builtin_wasm_pmax_f64x2((__f64x2)__a, (__f64x2)__b); 1375 } 1376 1377 static __inline__ v128_t __DEFAULT_FN_ATTRS 1378 wasm_i32x4_trunc_sat_f32x4(v128_t __a) { 1379 return (v128_t)__builtin_wasm_trunc_saturate_s_i32x4_f32x4((__f32x4)__a); 1380 } 1381 1382 static __inline__ v128_t __DEFAULT_FN_ATTRS 1383 wasm_u32x4_trunc_sat_f32x4(v128_t __a) { 1384 return (v128_t)__builtin_wasm_trunc_saturate_u_i32x4_f32x4((__f32x4)__a); 1385 } 1386 1387 static __inline__ v128_t __DEFAULT_FN_ATTRS 1388 wasm_f32x4_convert_i32x4(v128_t __a) { 1389 return (v128_t) __builtin_convertvector((__i32x4)__a, __f32x4); 1390 } 1391 1392 static __inline__ v128_t __DEFAULT_FN_ATTRS 1393 wasm_f32x4_convert_u32x4(v128_t __a) { 1394 return (v128_t) __builtin_convertvector((__u32x4)__a, __f32x4); 1395 } 1396 1397 static __inline__ v128_t __DEFAULT_FN_ATTRS 1398 wasm_f64x2_convert_low_i32x4(v128_t __a) { 1399 return (v128_t) __builtin_convertvector((__i32x2){__a[0], __a[1]}, __f64x2); 1400 } 1401 1402 static __inline__ v128_t __DEFAULT_FN_ATTRS 1403 wasm_f64x2_convert_low_u32x4(v128_t __a) { 1404 return (v128_t) __builtin_convertvector((__u32x2){__a[0], __a[1]}, __f64x2); 1405 } 1406 1407 static __inline__ v128_t __DEFAULT_FN_ATTRS 1408 wasm_i32x4_trunc_sat_f64x2_zero(v128_t __a) { 1409 return (v128_t)__builtin_wasm_trunc_sat_s_zero_f64x2_i32x4((__f64x2)__a); 1410 } 1411 1412 static __inline__ v128_t __DEFAULT_FN_ATTRS 1413 wasm_u32x4_trunc_sat_f64x2_zero(v128_t __a) { 1414 return (v128_t)__builtin_wasm_trunc_sat_u_zero_f64x2_i32x4((__f64x2)__a); 1415 } 1416 1417 static __inline__ v128_t __DEFAULT_FN_ATTRS 1418 wasm_f32x4_demote_f64x2_zero(v128_t __a) { 1419 return (v128_t) __builtin_convertvector( 1420 __builtin_shufflevector((__f64x2)__a, (__f64x2){0, 0}, 0, 1, 2, 3), 1421 __f32x4); 1422 } 1423 1424 static __inline__ v128_t __DEFAULT_FN_ATTRS 1425 wasm_f64x2_promote_low_f32x4(v128_t __a) { 1426 return (v128_t) __builtin_convertvector( 1427 (__f32x2){((__f32x4)__a)[0], ((__f32x4)__a)[1]}, __f64x2); 1428 } 1429 1430 #define wasm_i8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1431 __c7, __c8, __c9, __c10, __c11, __c12, __c13, \ 1432 __c14, __c15) \ 1433 ((v128_t)__builtin_wasm_shuffle_i8x16( \ 1434 (__i8x16)(__a), (__i8x16)(__b), __c0, __c1, __c2, __c3, __c4, __c5, \ 1435 __c6, __c7, __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15)) 1436 1437 #define wasm_i16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1438 __c7) \ 1439 ((v128_t)__builtin_wasm_shuffle_i8x16( \ 1440 (__i8x16)(__a), (__i8x16)(__b), (__c0)*2, (__c0)*2 + 1, (__c1)*2, \ 1441 (__c1)*2 + 1, (__c2)*2, (__c2)*2 + 1, (__c3)*2, (__c3)*2 + 1, (__c4)*2, \ 1442 (__c4)*2 + 1, (__c5)*2, (__c5)*2 + 1, (__c6)*2, (__c6)*2 + 1, (__c7)*2, \ 1443 (__c7)*2 + 1)) 1444 1445 #define wasm_i32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \ 1446 ((v128_t)__builtin_wasm_shuffle_i8x16( \ 1447 (__i8x16)(__a), (__i8x16)(__b), (__c0)*4, (__c0)*4 + 1, (__c0)*4 + 2, \ 1448 (__c0)*4 + 3, (__c1)*4, (__c1)*4 + 1, (__c1)*4 + 2, (__c1)*4 + 3, \ 1449 (__c2)*4, (__c2)*4 + 1, (__c2)*4 + 2, (__c2)*4 + 3, (__c3)*4, \ 1450 (__c3)*4 + 1, (__c3)*4 + 2, (__c3)*4 + 3)) 1451 1452 #define wasm_i64x2_shuffle(__a, __b, __c0, __c1) \ 1453 ((v128_t)__builtin_wasm_shuffle_i8x16( \ 1454 (__i8x16)(__a), (__i8x16)(__b), (__c0)*8, (__c0)*8 + 1, (__c0)*8 + 2, \ 1455 (__c0)*8 + 3, (__c0)*8 + 4, (__c0)*8 + 5, (__c0)*8 + 6, (__c0)*8 + 7, \ 1456 (__c1)*8, (__c1)*8 + 1, (__c1)*8 + 2, (__c1)*8 + 3, (__c1)*8 + 4, \ 1457 (__c1)*8 + 5, (__c1)*8 + 6, (__c1)*8 + 7)) 1458 1459 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_swizzle(v128_t __a, 1460 v128_t __b) { 1461 return (v128_t)__builtin_wasm_swizzle_i8x16((__i8x16)__a, (__i8x16)__b); 1462 } 1463 1464 static __inline__ v128_t __DEFAULT_FN_ATTRS 1465 wasm_i8x16_narrow_i16x8(v128_t __a, v128_t __b) { 1466 return (v128_t)__builtin_wasm_narrow_s_i8x16_i16x8((__i16x8)__a, 1467 (__i16x8)__b); 1468 } 1469 1470 static __inline__ v128_t __DEFAULT_FN_ATTRS 1471 wasm_u8x16_narrow_i16x8(v128_t __a, v128_t __b) { 1472 return (v128_t)__builtin_wasm_narrow_u_i8x16_i16x8((__i16x8)__a, 1473 (__i16x8)__b); 1474 } 1475 1476 static __inline__ v128_t __DEFAULT_FN_ATTRS 1477 wasm_i16x8_narrow_i32x4(v128_t __a, v128_t __b) { 1478 return (v128_t)__builtin_wasm_narrow_s_i16x8_i32x4((__i32x4)__a, 1479 (__i32x4)__b); 1480 } 1481 1482 static __inline__ v128_t __DEFAULT_FN_ATTRS 1483 wasm_u16x8_narrow_i32x4(v128_t __a, v128_t __b) { 1484 return (v128_t)__builtin_wasm_narrow_u_i16x8_i32x4((__i32x4)__a, 1485 (__i32x4)__b); 1486 } 1487 1488 static __inline__ v128_t __DEFAULT_FN_ATTRS 1489 wasm_i16x8_extend_low_i8x16(v128_t __a) { 1490 return (v128_t) __builtin_convertvector( 1491 (__i8x8){((__i8x16)__a)[0], ((__i8x16)__a)[1], ((__i8x16)__a)[2], 1492 ((__i8x16)__a)[3], ((__i8x16)__a)[4], ((__i8x16)__a)[5], 1493 ((__i8x16)__a)[6], ((__i8x16)__a)[7]}, 1494 __i16x8); 1495 } 1496 1497 static __inline__ v128_t __DEFAULT_FN_ATTRS 1498 wasm_i16x8_extend_high_i8x16(v128_t __a) { 1499 return (v128_t) __builtin_convertvector( 1500 (__i8x8){((__i8x16)__a)[8], ((__i8x16)__a)[9], ((__i8x16)__a)[10], 1501 ((__i8x16)__a)[11], ((__i8x16)__a)[12], ((__i8x16)__a)[13], 1502 ((__i8x16)__a)[14], ((__i8x16)__a)[15]}, 1503 __i16x8); 1504 } 1505 1506 static __inline__ v128_t __DEFAULT_FN_ATTRS 1507 wasm_u16x8_extend_low_u8x16(v128_t __a) { 1508 return (v128_t) __builtin_convertvector( 1509 (__u8x8){((__u8x16)__a)[0], ((__u8x16)__a)[1], ((__u8x16)__a)[2], 1510 ((__u8x16)__a)[3], ((__u8x16)__a)[4], ((__u8x16)__a)[5], 1511 ((__u8x16)__a)[6], ((__u8x16)__a)[7]}, 1512 __u16x8); 1513 } 1514 1515 static __inline__ v128_t __DEFAULT_FN_ATTRS 1516 wasm_u16x8_extend_high_u8x16(v128_t __a) { 1517 return (v128_t) __builtin_convertvector( 1518 (__u8x8){((__u8x16)__a)[8], ((__u8x16)__a)[9], ((__u8x16)__a)[10], 1519 ((__u8x16)__a)[11], ((__u8x16)__a)[12], ((__u8x16)__a)[13], 1520 ((__u8x16)__a)[14], ((__u8x16)__a)[15]}, 1521 __u16x8); 1522 } 1523 1524 static __inline__ v128_t __DEFAULT_FN_ATTRS 1525 wasm_i32x4_extend_low_i16x8(v128_t __a) { 1526 return (v128_t) __builtin_convertvector( 1527 (__i16x4){((__i16x8)__a)[0], ((__i16x8)__a)[1], ((__i16x8)__a)[2], 1528 ((__i16x8)__a)[3]}, 1529 __i32x4); 1530 } 1531 1532 static __inline__ v128_t __DEFAULT_FN_ATTRS 1533 wasm_i32x4_extend_high_i16x8(v128_t __a) { 1534 return (v128_t) __builtin_convertvector( 1535 (__i16x4){((__i16x8)__a)[4], ((__i16x8)__a)[5], ((__i16x8)__a)[6], 1536 ((__i16x8)__a)[7]}, 1537 __i32x4); 1538 } 1539 1540 static __inline__ v128_t __DEFAULT_FN_ATTRS 1541 wasm_u32x4_extend_low_u16x8(v128_t __a) { 1542 return (v128_t) __builtin_convertvector( 1543 (__u16x4){((__u16x8)__a)[0], ((__u16x8)__a)[1], ((__u16x8)__a)[2], 1544 ((__u16x8)__a)[3]}, 1545 __u32x4); 1546 } 1547 1548 static __inline__ v128_t __DEFAULT_FN_ATTRS 1549 wasm_u32x4_extend_high_u16x8(v128_t __a) { 1550 return (v128_t) __builtin_convertvector( 1551 (__u16x4){((__u16x8)__a)[4], ((__u16x8)__a)[5], ((__u16x8)__a)[6], 1552 ((__u16x8)__a)[7]}, 1553 __u32x4); 1554 } 1555 1556 static __inline__ v128_t __DEFAULT_FN_ATTRS 1557 wasm_i64x2_extend_low_i32x4(v128_t __a) { 1558 return (v128_t) __builtin_convertvector( 1559 (__i32x2){((__i32x4)__a)[0], ((__i32x4)__a)[1]}, __i64x2); 1560 } 1561 1562 static __inline__ v128_t __DEFAULT_FN_ATTRS 1563 wasm_i64x2_extend_high_i32x4(v128_t __a) { 1564 return (v128_t) __builtin_convertvector( 1565 (__i32x2){((__i32x4)__a)[2], ((__i32x4)__a)[3]}, __i64x2); 1566 } 1567 1568 static __inline__ v128_t __DEFAULT_FN_ATTRS 1569 wasm_u64x2_extend_low_u32x4(v128_t __a) { 1570 return (v128_t) __builtin_convertvector( 1571 (__u32x2){((__u32x4)__a)[0], ((__u32x4)__a)[1]}, __u64x2); 1572 } 1573 1574 static __inline__ v128_t __DEFAULT_FN_ATTRS 1575 wasm_u64x2_extend_high_u32x4(v128_t __a) { 1576 return (v128_t) __builtin_convertvector( 1577 (__u32x2){((__u32x4)__a)[2], ((__u32x4)__a)[3]}, __u64x2); 1578 } 1579 1580 static __inline__ v128_t __DEFAULT_FN_ATTRS 1581 wasm_i16x8_extadd_pairwise_i8x16(v128_t __a) { 1582 return (v128_t)__builtin_wasm_extadd_pairwise_i8x16_s_i16x8((__i8x16)__a); 1583 } 1584 1585 static __inline__ v128_t __DEFAULT_FN_ATTRS 1586 wasm_u16x8_extadd_pairwise_u8x16(v128_t __a) { 1587 return (v128_t)__builtin_wasm_extadd_pairwise_i8x16_u_i16x8((__u8x16)__a); 1588 } 1589 1590 static __inline__ v128_t __DEFAULT_FN_ATTRS 1591 wasm_i32x4_extadd_pairwise_i16x8(v128_t __a) { 1592 return (v128_t)__builtin_wasm_extadd_pairwise_i16x8_s_i32x4((__i16x8)__a); 1593 } 1594 1595 static __inline__ v128_t __DEFAULT_FN_ATTRS 1596 wasm_u32x4_extadd_pairwise_u16x8(v128_t __a) { 1597 return (v128_t)__builtin_wasm_extadd_pairwise_i16x8_u_i32x4((__u16x8)__a); 1598 } 1599 1600 static __inline__ v128_t __DEFAULT_FN_ATTRS 1601 wasm_i16x8_extmul_low_i8x16(v128_t __a, v128_t __b) { 1602 return (v128_t)((__i16x8)wasm_i16x8_extend_low_i8x16(__a) * 1603 (__i16x8)wasm_i16x8_extend_low_i8x16(__b)); 1604 } 1605 1606 static __inline__ v128_t __DEFAULT_FN_ATTRS 1607 wasm_i16x8_extmul_high_i8x16(v128_t __a, v128_t __b) { 1608 return (v128_t)((__i16x8)wasm_i16x8_extend_high_i8x16(__a) * 1609 (__i16x8)wasm_i16x8_extend_high_i8x16(__b)); 1610 } 1611 1612 static __inline__ v128_t __DEFAULT_FN_ATTRS 1613 wasm_u16x8_extmul_low_u8x16(v128_t __a, v128_t __b) { 1614 return (v128_t)((__u16x8)wasm_u16x8_extend_low_u8x16(__a) * 1615 (__u16x8)wasm_u16x8_extend_low_u8x16(__b)); 1616 } 1617 1618 static __inline__ v128_t __DEFAULT_FN_ATTRS 1619 wasm_u16x8_extmul_high_u8x16(v128_t __a, v128_t __b) { 1620 return (v128_t)((__u16x8)wasm_u16x8_extend_high_u8x16(__a) * 1621 (__u16x8)wasm_u16x8_extend_high_u8x16(__b)); 1622 } 1623 1624 static __inline__ v128_t __DEFAULT_FN_ATTRS 1625 wasm_i32x4_extmul_low_i16x8(v128_t __a, v128_t __b) { 1626 return (v128_t)((__i32x4)wasm_i32x4_extend_low_i16x8(__a) * 1627 (__i32x4)wasm_i32x4_extend_low_i16x8(__b)); 1628 } 1629 1630 static __inline__ v128_t __DEFAULT_FN_ATTRS 1631 wasm_i32x4_extmul_high_i16x8(v128_t __a, v128_t __b) { 1632 return (v128_t)((__i32x4)wasm_i32x4_extend_high_i16x8(__a) * 1633 (__i32x4)wasm_i32x4_extend_high_i16x8(__b)); 1634 } 1635 1636 static __inline__ v128_t __DEFAULT_FN_ATTRS 1637 wasm_u32x4_extmul_low_u16x8(v128_t __a, v128_t __b) { 1638 return (v128_t)((__u32x4)wasm_u32x4_extend_low_u16x8(__a) * 1639 (__u32x4)wasm_u32x4_extend_low_u16x8(__b)); 1640 } 1641 1642 static __inline__ v128_t __DEFAULT_FN_ATTRS 1643 wasm_u32x4_extmul_high_u16x8(v128_t __a, v128_t __b) { 1644 return (v128_t)((__u32x4)wasm_u32x4_extend_high_u16x8(__a) * 1645 (__u32x4)wasm_u32x4_extend_high_u16x8(__b)); 1646 } 1647 1648 static __inline__ v128_t __DEFAULT_FN_ATTRS 1649 wasm_i64x2_extmul_low_i32x4(v128_t __a, v128_t __b) { 1650 return (v128_t)((__i64x2)wasm_i64x2_extend_low_i32x4(__a) * 1651 (__i64x2)wasm_i64x2_extend_low_i32x4(__b)); 1652 } 1653 1654 static __inline__ v128_t __DEFAULT_FN_ATTRS 1655 wasm_i64x2_extmul_high_i32x4(v128_t __a, v128_t __b) { 1656 return (v128_t)((__i64x2)wasm_i64x2_extend_high_i32x4(__a) * 1657 (__i64x2)wasm_i64x2_extend_high_i32x4(__b)); 1658 } 1659 1660 static __inline__ v128_t __DEFAULT_FN_ATTRS 1661 wasm_u64x2_extmul_low_u32x4(v128_t __a, v128_t __b) { 1662 return (v128_t)((__u64x2)wasm_u64x2_extend_low_u32x4(__a) * 1663 (__u64x2)wasm_u64x2_extend_low_u32x4(__b)); 1664 } 1665 1666 static __inline__ v128_t __DEFAULT_FN_ATTRS 1667 wasm_u64x2_extmul_high_u32x4(v128_t __a, v128_t __b) { 1668 return (v128_t)((__u64x2)wasm_u64x2_extend_high_u32x4(__a) * 1669 (__u64x2)wasm_u64x2_extend_high_u32x4(__b)); 1670 } 1671 1672 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_q15mulr_sat(v128_t __a, 1673 v128_t __b) { 1674 return (v128_t)__builtin_wasm_q15mulr_sat_s_i16x8((__i16x8)__a, (__i16x8)__b); 1675 } 1676 1677 // Old intrinsic names supported to ease transitioning to the standard names. Do 1678 // not use these; they will be removed in the near future. 1679 1680 #define __DEPRECATED_FN_ATTRS(__replacement) \ 1681 __DEFAULT_FN_ATTRS __attribute__( \ 1682 (deprecated("use " __replacement " instead", __replacement))) 1683 1684 #define __WASM_STR(X) #X 1685 1686 #ifdef __DEPRECATED 1687 #define __DEPRECATED_WASM_MACRO(__name, __replacement) \ 1688 _Pragma(__WASM_STR(GCC warning( \ 1689 "'" __name "' is deprecated: use '" __replacement "' instead"))) 1690 #else 1691 #define __DEPRECATED_WASM_MACRO(__name, __replacement) 1692 #endif 1693 1694 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load8_splat") 1695 wasm_v8x16_load_splat(const void *__mem) { 1696 return wasm_v128_load8_splat(__mem); 1697 } 1698 1699 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load16_splat") 1700 wasm_v16x8_load_splat(const void *__mem) { 1701 return wasm_v128_load16_splat(__mem); 1702 } 1703 1704 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load32_splat") 1705 wasm_v32x4_load_splat(const void *__mem) { 1706 return wasm_v128_load32_splat(__mem); 1707 } 1708 1709 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_v128_load64_splat") 1710 wasm_v64x2_load_splat(const void *__mem) { 1711 return wasm_v128_load64_splat(__mem); 1712 } 1713 1714 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_load8x8") 1715 wasm_i16x8_load_8x8(const void *__mem) { 1716 return wasm_i16x8_load8x8(__mem); 1717 } 1718 1719 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_load8x8") 1720 wasm_u16x8_load_8x8(const void *__mem) { 1721 return wasm_u16x8_load8x8(__mem); 1722 } 1723 1724 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_load16x4") 1725 wasm_i32x4_load_16x4(const void *__mem) { 1726 return wasm_i32x4_load16x4(__mem); 1727 } 1728 1729 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_load16x4") 1730 wasm_u32x4_load_16x4(const void *__mem) { 1731 return wasm_u32x4_load16x4(__mem); 1732 } 1733 1734 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i64x2_load32x2") 1735 wasm_i64x2_load_32x2(const void *__mem) { 1736 return wasm_i64x2_load32x2(__mem); 1737 } 1738 1739 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u64x2_load32x2") 1740 wasm_u64x2_load_32x2(const void *__mem) { 1741 return wasm_u64x2_load32x2(__mem); 1742 } 1743 1744 #define wasm_v8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1745 __c7, __c8, __c9, __c10, __c11, __c12, __c13, \ 1746 __c14, __c15) \ 1747 __DEPRECATED_WASM_MACRO("wasm_v8x16_shuffle", "wasm_i8x16_shuffle") \ 1748 wasm_i8x16_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7, \ 1749 __c8, __c9, __c10, __c11, __c12, __c13, __c14, __c15) 1750 1751 #define wasm_v16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, \ 1752 __c7) \ 1753 __DEPRECATED_WASM_MACRO("wasm_v16x8_shuffle", "wasm_i16x8_shuffle") \ 1754 wasm_i16x8_shuffle(__a, __b, __c0, __c1, __c2, __c3, __c4, __c5, __c6, __c7) 1755 1756 #define wasm_v32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) \ 1757 __DEPRECATED_WASM_MACRO("wasm_v32x4_shuffle", "wasm_i32x4_shuffle") \ 1758 wasm_i32x4_shuffle(__a, __b, __c0, __c1, __c2, __c3) 1759 1760 #define wasm_v64x2_shuffle(__a, __b, __c0, __c1) \ 1761 __DEPRECATED_WASM_MACRO("wasm_v64x2_shuffle", "wasm_i64x2_shuffle") \ 1762 wasm_i64x2_shuffle(__a, __b, __c0, __c1) 1763 1764 // Relaxed SIMD intrinsics 1765 1766 #define __RELAXED_FN_ATTRS \ 1767 __attribute__((__always_inline__, __nodebug__, __target__("relaxed-simd"), \ 1768 __min_vector_width__(128))) 1769 1770 static __inline__ v128_t __RELAXED_FN_ATTRS 1771 wasm_f32x4_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) { 1772 return (v128_t)__builtin_wasm_relaxed_madd_f32x4((__f32x4)__a, (__f32x4)__b, 1773 (__f32x4)__c); 1774 } 1775 1776 static __inline__ v128_t __RELAXED_FN_ATTRS 1777 wasm_f32x4_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) { 1778 return (v128_t)__builtin_wasm_relaxed_nmadd_f32x4((__f32x4)__a, (__f32x4)__b, 1779 (__f32x4)__c); 1780 } 1781 1782 static __inline__ v128_t __RELAXED_FN_ATTRS 1783 wasm_f64x2_relaxed_madd(v128_t __a, v128_t __b, v128_t __c) { 1784 return (v128_t)__builtin_wasm_relaxed_madd_f64x2((__f64x2)__a, (__f64x2)__b, 1785 (__f64x2)__c); 1786 } 1787 1788 static __inline__ v128_t __RELAXED_FN_ATTRS 1789 wasm_f64x2_relaxed_nmadd(v128_t __a, v128_t __b, v128_t __c) { 1790 return (v128_t)__builtin_wasm_relaxed_nmadd_f64x2((__f64x2)__a, (__f64x2)__b, 1791 (__f64x2)__c); 1792 } 1793 1794 static __inline__ v128_t __RELAXED_FN_ATTRS 1795 wasm_i8x16_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { 1796 return (v128_t)__builtin_wasm_relaxed_laneselect_i8x16( 1797 (__i8x16)__a, (__i8x16)__b, (__i8x16)__m); 1798 } 1799 1800 static __inline__ v128_t __RELAXED_FN_ATTRS 1801 wasm_i16x8_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { 1802 return (v128_t)__builtin_wasm_relaxed_laneselect_i16x8( 1803 (__i16x8)__a, (__i16x8)__b, (__i16x8)__m); 1804 } 1805 1806 static __inline__ v128_t __RELAXED_FN_ATTRS 1807 wasm_i32x4_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { 1808 return (v128_t)__builtin_wasm_relaxed_laneselect_i32x4( 1809 (__i32x4)__a, (__i32x4)__b, (__i32x4)__m); 1810 } 1811 1812 static __inline__ v128_t __RELAXED_FN_ATTRS 1813 wasm_i64x2_relaxed_laneselect(v128_t __a, v128_t __b, v128_t __m) { 1814 return (v128_t)__builtin_wasm_relaxed_laneselect_i64x2( 1815 (__i64x2)__a, (__i64x2)__b, (__i64x2)__m); 1816 } 1817 1818 static __inline__ v128_t __RELAXED_FN_ATTRS 1819 wasm_i8x16_relaxed_swizzle(v128_t __a, v128_t __s) { 1820 return (v128_t)__builtin_wasm_relaxed_swizzle_i8x16((__i8x16)__a, 1821 (__i8x16)__s); 1822 } 1823 1824 static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_min(v128_t __a, 1825 v128_t __b) { 1826 return (v128_t)__builtin_wasm_relaxed_min_f32x4((__f32x4)__a, (__f32x4)__b); 1827 } 1828 1829 static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f32x4_relaxed_max(v128_t __a, 1830 v128_t __b) { 1831 return (v128_t)__builtin_wasm_relaxed_max_f32x4((__f32x4)__a, (__f32x4)__b); 1832 } 1833 1834 static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_min(v128_t __a, 1835 v128_t __b) { 1836 return (v128_t)__builtin_wasm_relaxed_min_f64x2((__f64x2)__a, (__f64x2)__b); 1837 } 1838 1839 static __inline__ v128_t __RELAXED_FN_ATTRS wasm_f64x2_relaxed_max(v128_t __a, 1840 v128_t __b) { 1841 return (v128_t)__builtin_wasm_relaxed_max_f64x2((__f64x2)__a, (__f64x2)__b); 1842 } 1843 1844 static __inline__ v128_t __RELAXED_FN_ATTRS 1845 wasm_i32x4_relaxed_trunc_f32x4(v128_t __a) { 1846 return (v128_t)__builtin_wasm_relaxed_trunc_s_i32x4_f32x4((__f32x4)__a); 1847 } 1848 1849 static __inline__ v128_t __RELAXED_FN_ATTRS 1850 wasm_u32x4_relaxed_trunc_f32x4(v128_t __a) { 1851 return (v128_t)__builtin_wasm_relaxed_trunc_u_i32x4_f32x4((__f32x4)__a); 1852 } 1853 1854 static __inline__ v128_t __RELAXED_FN_ATTRS 1855 wasm_i32x4_relaxed_trunc_f64x2_zero(v128_t __a) { 1856 return (v128_t)__builtin_wasm_relaxed_trunc_s_zero_i32x4_f64x2((__f64x2)__a); 1857 } 1858 1859 static __inline__ v128_t __RELAXED_FN_ATTRS 1860 wasm_u32x4_relaxed_trunc_f64x2_zero(v128_t __a) { 1861 return (v128_t)__builtin_wasm_relaxed_trunc_u_zero_i32x4_f64x2((__f64x2)__a); 1862 } 1863 1864 static __inline__ v128_t __RELAXED_FN_ATTRS 1865 wasm_i16x8_relaxed_q15mulr(v128_t __a, v128_t __b) { 1866 return (v128_t)__builtin_wasm_relaxed_q15mulr_s_i16x8((__i16x8)__a, 1867 (__i16x8)__b); 1868 } 1869 1870 static __inline__ v128_t __RELAXED_FN_ATTRS 1871 wasm_i16x8_relaxed_dot_i8x16_i7x16(v128_t __a, v128_t __b) { 1872 return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_s_i16x8((__i8x16)__a, 1873 (__i8x16)__b); 1874 } 1875 1876 static __inline__ v128_t __RELAXED_FN_ATTRS 1877 wasm_i32x4_relaxed_dot_i8x16_i7x16_add(v128_t __a, v128_t __b, v128_t __c) { 1878 return (v128_t)__builtin_wasm_relaxed_dot_i8x16_i7x16_add_s_i32x4( 1879 (__i8x16)__a, (__i8x16)__b, (__i32x4)__c); 1880 } 1881 1882 // FP16 intrinsics 1883 #define __FP16_FN_ATTRS \ 1884 __attribute__((__always_inline__, __nodebug__, __target__("fp16"), \ 1885 __min_vector_width__(128))) 1886 1887 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_splat(float __a) { 1888 return (v128_t)__builtin_wasm_splat_f16x8(__a); 1889 } 1890 1891 #ifdef __wasm_fp16__ 1892 // TODO Replace the following macros with regular C functions and use normal 1893 // target-independent vector code like the other replace/extract instructions. 1894 1895 #define wasm_f16x8_extract_lane(__a, __i) \ 1896 (__builtin_wasm_extract_lane_f16x8((__f16x8)(__a), __i)) 1897 1898 #define wasm_f16x8_replace_lane(__a, __i, __b) \ 1899 ((v128_t)__builtin_wasm_replace_lane_f16x8((__f16x8)(__a), __i, __b)) 1900 1901 #endif 1902 1903 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_abs(v128_t __a) { 1904 return (v128_t)__builtin_wasm_abs_f16x8((__f16x8)__a); 1905 } 1906 1907 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_neg(v128_t __a) { 1908 return (v128_t)(-(__f16x8)__a); 1909 } 1910 1911 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_sqrt(v128_t __a) { 1912 return (v128_t)__builtin_wasm_sqrt_f16x8((__f16x8)__a); 1913 } 1914 1915 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ceil(v128_t __a) { 1916 return (v128_t)__builtin_wasm_ceil_f16x8((__f16x8)__a); 1917 } 1918 1919 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_floor(v128_t __a) { 1920 return (v128_t)__builtin_wasm_floor_f16x8((__f16x8)__a); 1921 } 1922 1923 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_trunc(v128_t __a) { 1924 return (v128_t)__builtin_wasm_trunc_f16x8((__f16x8)__a); 1925 } 1926 1927 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_nearest(v128_t __a) { 1928 return (v128_t)__builtin_wasm_nearest_f16x8((__f16x8)__a); 1929 } 1930 1931 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_eq(v128_t __a, v128_t __b) { 1932 return (v128_t)((__f16x8)__a == (__f16x8)__b); 1933 } 1934 1935 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ne(v128_t __a, v128_t __b) { 1936 return (v128_t)((__f16x8)__a != (__f16x8)__b); 1937 } 1938 1939 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_lt(v128_t __a, v128_t __b) { 1940 return (v128_t)((__f16x8)__a < (__f16x8)__b); 1941 } 1942 1943 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_gt(v128_t __a, v128_t __b) { 1944 return (v128_t)((__f16x8)__a > (__f16x8)__b); 1945 } 1946 1947 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_le(v128_t __a, v128_t __b) { 1948 return (v128_t)((__f16x8)__a <= (__f16x8)__b); 1949 } 1950 1951 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_ge(v128_t __a, v128_t __b) { 1952 return (v128_t)((__f16x8)__a >= (__f16x8)__b); 1953 } 1954 1955 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_add(v128_t __a, 1956 v128_t __b) { 1957 return (v128_t)((__f16x8)__a + (__f16x8)__b); 1958 } 1959 1960 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_sub(v128_t __a, 1961 v128_t __b) { 1962 return (v128_t)((__f16x8)__a - (__f16x8)__b); 1963 } 1964 1965 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_mul(v128_t __a, 1966 v128_t __b) { 1967 return (v128_t)((__f16x8)__a * (__f16x8)__b); 1968 } 1969 1970 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_div(v128_t __a, 1971 v128_t __b) { 1972 return (v128_t)((__f16x8)__a / (__f16x8)__b); 1973 } 1974 1975 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_min(v128_t __a, 1976 v128_t __b) { 1977 return (v128_t)__builtin_wasm_min_f16x8((__f16x8)__a, (__f16x8)__b); 1978 } 1979 1980 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_max(v128_t __a, 1981 v128_t __b) { 1982 return (v128_t)__builtin_wasm_max_f16x8((__f16x8)__a, (__f16x8)__b); 1983 } 1984 1985 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_pmin(v128_t __a, 1986 v128_t __b) { 1987 return (v128_t)__builtin_wasm_pmin_f16x8((__f16x8)__a, (__f16x8)__b); 1988 } 1989 1990 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_pmax(v128_t __a, 1991 v128_t __b) { 1992 return (v128_t)__builtin_wasm_pmax_f16x8((__f16x8)__a, (__f16x8)__b); 1993 } 1994 1995 static __inline__ v128_t __FP16_FN_ATTRS 1996 wasm_i16x8_trunc_sat_f16x8(v128_t __a) { 1997 return (v128_t)__builtin_wasm_trunc_saturate_s_i16x8_f16x8((__f16x8)__a); 1998 } 1999 2000 static __inline__ v128_t __FP16_FN_ATTRS 2001 wasm_u16x8_trunc_sat_f16x8(v128_t __a) { 2002 return (v128_t)__builtin_wasm_trunc_saturate_u_i16x8_f16x8((__f16x8)__a); 2003 } 2004 2005 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_convert_i16x8(v128_t __a) { 2006 return (v128_t) __builtin_convertvector((__i16x8)__a, __f16x8); 2007 } 2008 2009 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_convert_u16x8(v128_t __a) { 2010 return (v128_t) __builtin_convertvector((__u16x8)__a, __f16x8); 2011 } 2012 2013 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_relaxed_madd(v128_t __a, 2014 v128_t __b, 2015 v128_t __c) { 2016 return (v128_t)__builtin_wasm_relaxed_madd_f16x8((__f16x8)__a, (__f16x8)__b, 2017 (__f16x8)__c); 2018 } 2019 2020 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_relaxed_nmadd(v128_t __a, 2021 v128_t __b, 2022 v128_t __c) { 2023 return (v128_t)__builtin_wasm_relaxed_nmadd_f16x8((__f16x8)__a, (__f16x8)__b, 2024 (__f16x8)__c); 2025 } 2026 2027 // Deprecated intrinsics 2028 2029 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_swizzle") 2030 wasm_v8x16_swizzle(v128_t __a, v128_t __b) { 2031 return wasm_i8x16_swizzle(__a, __b); 2032 } 2033 2034 static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") 2035 wasm_i8x16_any_true(v128_t __a) { 2036 return wasm_v128_any_true(__a); 2037 } 2038 2039 static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") 2040 wasm_i16x8_any_true(v128_t __a) { 2041 return wasm_v128_any_true(__a); 2042 } 2043 2044 static __inline__ bool __DEPRECATED_FN_ATTRS("wasm_v128_any_true") 2045 wasm_i32x4_any_true(v128_t __a) { 2046 return wasm_v128_any_true(__a); 2047 } 2048 2049 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_add_sat") 2050 wasm_i8x16_add_saturate(v128_t __a, v128_t __b) { 2051 return wasm_i8x16_add_sat(__a, __b); 2052 } 2053 2054 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u8x16_add_sat") 2055 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) { 2056 return wasm_u8x16_add_sat(__a, __b); 2057 } 2058 2059 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i8x16_sub_sat") 2060 wasm_i8x16_sub_saturate(v128_t __a, v128_t __b) { 2061 return wasm_i8x16_sub_sat(__a, __b); 2062 } 2063 2064 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u8x16_sub_sat") 2065 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) { 2066 return wasm_u8x16_sub_sat(__a, __b); 2067 } 2068 2069 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_add_sat") 2070 wasm_i16x8_add_saturate(v128_t __a, v128_t __b) { 2071 return wasm_i16x8_add_sat(__a, __b); 2072 } 2073 2074 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_add_sat") 2075 wasm_u16x8_add_saturate(v128_t __a, v128_t __b) { 2076 return wasm_u16x8_add_sat(__a, __b); 2077 } 2078 2079 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_sub_sat") 2080 wasm_i16x8_sub_saturate(v128_t __a, v128_t __b) { 2081 return wasm_i16x8_sub_sat(__a, __b); 2082 } 2083 2084 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_sub_sat") 2085 wasm_u16x8_sub_saturate(v128_t __a, v128_t __b) { 2086 return wasm_u16x8_sub_sat(__a, __b); 2087 } 2088 2089 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_extend_low_i8x16") 2090 wasm_i16x8_widen_low_i8x16(v128_t __a) { 2091 return wasm_i16x8_extend_low_i8x16(__a); 2092 } 2093 2094 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i16x8_extend_high_i8x16") 2095 wasm_i16x8_widen_high_i8x16(v128_t __a) { 2096 return wasm_i16x8_extend_high_i8x16(__a); 2097 } 2098 2099 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_extend_low_u8x16") 2100 wasm_i16x8_widen_low_u8x16(v128_t __a) { 2101 return wasm_u16x8_extend_low_u8x16(__a); 2102 } 2103 2104 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u16x8_extend_high_u8x16") 2105 wasm_i16x8_widen_high_u8x16(v128_t __a) { 2106 return wasm_u16x8_extend_high_u8x16(__a); 2107 } 2108 2109 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_extend_low_i16x8") 2110 wasm_i32x4_widen_low_i16x8(v128_t __a) { 2111 return wasm_i32x4_extend_low_i16x8(__a); 2112 } 2113 2114 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_extend_high_i16x8") 2115 wasm_i32x4_widen_high_i16x8(v128_t __a) { 2116 return wasm_i32x4_extend_high_i16x8(__a); 2117 } 2118 2119 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_extend_low_u16x8") 2120 wasm_i32x4_widen_low_u16x8(v128_t __a) { 2121 return wasm_u32x4_extend_low_u16x8(__a); 2122 } 2123 2124 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_extend_high_u16x8") 2125 wasm_i32x4_widen_high_u16x8(v128_t __a) { 2126 return wasm_u32x4_extend_high_u16x8(__a); 2127 } 2128 2129 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_i32x4_trunc_sat_f32x4") 2130 wasm_i32x4_trunc_saturate_f32x4(v128_t __a) { 2131 return wasm_i32x4_trunc_sat_f32x4(__a); 2132 } 2133 2134 static __inline__ v128_t __DEPRECATED_FN_ATTRS("wasm_u32x4_trunc_sat_f32x4") 2135 wasm_u32x4_trunc_saturate_f32x4(v128_t __a) { 2136 return wasm_u32x4_trunc_sat_f32x4(__a); 2137 } 2138 2139 // Undefine helper macros 2140 #undef __DEFAULT_FN_ATTRS 2141 #undef __DEPRECATED_FN_ATTRS 2142 2143 #endif // __WASM_SIMD128_H 2144