[WebAssembly] Use functions instead of macros for const SIMD intrinsics
authorThomas Lively <tlively@google.com>
Fri, 7 May 2021 18:50:19 +0000 (11:50 -0700)
committerThomas Lively <tlively@google.com>
Fri, 7 May 2021 18:50:19 +0000 (11:50 -0700)
commit1e9c39a3f982fe2f50cd19c74be8b64dfba4baad
tree0011d9a1d95bbe9c42a4084778990200e1b2b52e
parent724604901a104d8ba9e48ca0330e164a66c1c7ac
[WebAssembly] Use functions instead of macros for const SIMD intrinsics

To improve hygiene, consistency, and usability, it would be good to replace all
the macro intrinsics in wasm_simd128.h with functions. The reason for using
macros in the first place was to enforce the use of constants for some arguments
using `_Static_assert` with `__builtin_constant_p`. This commit switches to
using functions and uses the `__diagnose_if__` attribute rather than
`_Static_assert` to enforce constantness.

The remaining macro intrinsics cannot be made into functions until the builtin
functions they are implemented with can be replaced with normal code patterns
because the builtin functions themselves require that their arguments are
constants.

This commit also fixes a bug with the const_splat intrinsics in which the f32x4
and f64x2 variants were incorrectly producing integer vectors.

Differential Revision: https://reviews.llvm.org/D102018
clang/lib/Headers/wasm_simd128.h
clang/test/Headers/wasm.c