Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we define a scalar intrinsics header? #123

Open
tlively opened this issue Aug 19, 2019 · 1 comment
Open

Should we define a scalar intrinsics header? #123

tlively opened this issue Aug 19, 2019 · 1 comment

Comments

@tlively
Copy link
Member

tlively commented Aug 19, 2019

@Maratyszcza suggested to me that we should have a portable intrinsics header for non-SIMD WebAssembly instructions that are not directly expressible in C, so I wanted to gauge wider interest in such a header. On hand there is only one production C/C++ compiler for WebAssembly at the moment so portability isn't so important, but on the other hand it may be important in the future and having proper intrinsics is certainly more ergonomic than writing __builtin_wasm_* everwhere. What do people think?

There is precedent for scalar intrinsics on other platforms, for example arm_acle.h documented in http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf.

Some instructions such a header would include would be i32.clz, i32.ctz, i32.popcnt, i32.shr_s, i32.rotl, i32.rotr, f32.min, f32.max, etc.

@sunfishcode
Copy link
Member

My preference would be to not add a header file. We already have most instructions covered:

  • some via target-independent builtins like __builtin_clz
  • some via wasm-specific ones like __builtin_wasm_min_f32 (though now with IEEE 754-2019, we could probably add target-independent versions of min/max) and __builtin_wasm_memory_grow
  • some with pattern-matching like shr_s (which isn't perfect, but to the extent that it isn't, we can always add more __builtin_wasm_* functions as needed).

__builtin_-style functions on other targets are already common between clang, GCC, and other compilers, so it seems reasonable to expect any new C compiler targeting WebAssembly to support them as well if it wants to be compatible with existing codebases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants