diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-10-31 22:02:45 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-10-31 22:02:45 -0700 |
commit | 70e280d07d9bdc54d299daf85dfcf0cefd614232 (patch) | |
tree | 734125010e4b536b56cb1b25b7b7fa6f2748450b /test/int_ops.c | |
parent | 4536c4935aa936505c56d600c78e814a07393430 (diff) | |
download | binaryen-70e280d07d9bdc54d299daf85dfcf0cefd614232.tar.gz binaryen-70e280d07d9bdc54d299daf85dfcf0cefd614232.tar.bz2 binaryen-70e280d07d9bdc54d299daf85dfcf0cefd614232.zip |
int ops test
Diffstat (limited to 'test/int_ops.c')
-rw-r--r-- | test/int_ops.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/int_ops.c b/test/int_ops.c new file mode 100644 index 000000000..2e4a9b17d --- /dev/null +++ b/test/int_ops.c @@ -0,0 +1,32 @@ +#include <emscripten.h> + +// unary +int EMSCRIPTEN_KEEPALIVE clz(int x) { return __builtin_clz(x); } + +// binary +int EMSCRIPTEN_KEEPALIVE add(int x, int y) { return x + y; } +int EMSCRIPTEN_KEEPALIVE sub(int x, int y) { return x - y; } +int EMSCRIPTEN_KEEPALIVE mul(int x, int y) { return x * y; } +int EMSCRIPTEN_KEEPALIVE sdiv(int x, int y) { return x / y; } +unsigned EMSCRIPTEN_KEEPALIVE udiv(unsigned x, unsigned y) { return x / y; } +int EMSCRIPTEN_KEEPALIVE srem(int x, int y) { return x % y; } +unsigned EMSCRIPTEN_KEEPALIVE urem(unsigned x, unsigned y) { return x % y; } +int EMSCRIPTEN_KEEPALIVE and(int x, int y) { return x & y; } +int EMSCRIPTEN_KEEPALIVE or(int x, int y) { return x | y; } +int EMSCRIPTEN_KEEPALIVE xor(int x, int y) { return x ^ y; } +int EMSCRIPTEN_KEEPALIVE shl(int x, int y) { return x << y; } +int EMSCRIPTEN_KEEPALIVE sshr(int x, int y) { return x >> y; } +unsigned EMSCRIPTEN_KEEPALIVE ushr(unsigned x, unsigned y) { return x >> y; } + +// comparisons +int EMSCRIPTEN_KEEPALIVE eq(int x, int y) { return x == y; } +int EMSCRIPTEN_KEEPALIVE ne(int x, int y) { return x != y; } +int EMSCRIPTEN_KEEPALIVE lts(int x, int y) { return x < y; } +int EMSCRIPTEN_KEEPALIVE ltu(unsigned x, unsigned y) { return x < y; } +int EMSCRIPTEN_KEEPALIVE les(int x, int y) { return x <= y; } +int EMSCRIPTEN_KEEPALIVE leu(unsigned x, unsigned y) { return x <= y; } +int EMSCRIPTEN_KEEPALIVE gts(int x, int y) { return x > y; } +int EMSCRIPTEN_KEEPALIVE gtu(unsigned x, unsigned y) { return x > y; } +int EMSCRIPTEN_KEEPALIVE ges(int x, int y) { return x >= y; } +int EMSCRIPTEN_KEEPALIVE geu(unsigned x, unsigned y) { return x >= y; } + |