diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-09 20:03:57 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-09 20:03:57 +0100 |
| commit | 015c7edfa0e0460b7978fcfd724699af8fb6ec21 (patch) | |
| tree | 1b52152e796aae0c239fdaad2552ee94e923f5fa | |
| parent | 18f901125ad1b97ee3f79cb2f5d87704b52191ee (diff) | |
Add i32.shl
| -rw-r--r-- | private_include/nw/ops.h | 1 | ||||
| -rw-r--r-- | src/interp/ops.c | 2 | ||||
| -rw-r--r-- | src/op/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/op/i32_shl.c | 23 |
4 files changed, 26 insertions, 1 deletions
diff --git a/private_include/nw/ops.h b/private_include/nw/ops.h index b8288ab..9646c5c 100644 --- a/private_include/nw/ops.h +++ b/private_include/nw/ops.h @@ -55,6 +55,7 @@ void nwp_op_i32_ne(struct nw_interp *i); void nwp_op_i32_lt_s(struct nw_interp *i); void nwp_op_i32_ge_s(struct nw_interp *i); void nwp_op_i32_ge_u(struct nw_interp *i); +void nwp_op_i32_shl(struct nw_interp *i); void nwp_op_check_no_immediate(struct nw_mod *m); void nwp_op_check_block(struct nw_mod *m); diff --git a/src/interp/ops.c b/src/interp/ops.c index 6a5f82e..871b07e 100644 --- a/src/interp/ops.c +++ b/src/interp/ops.c @@ -130,7 +130,7 @@ static void (*const ops[])(struct nw_interp *) = nwp_op_i32_and, /* OP_I32_AND */ nwp_op_i32_or, /* OP_I32_OR */ NULL, /* OP_I32_XOR */ - NULL, /* OP_I32_SHL */ + nwp_op_i32_shl, /* OP_I32_SHL */ NULL, /* OP_I32_SHR_S */ NULL, /* OP_I32_SHR_U */ NULL, /* OP_I32_ROTL */ diff --git a/src/op/CMakeLists.txt b/src/op/CMakeLists.txt index d537327..15c28f3 100644 --- a/src/op/CMakeLists.txt +++ b/src/op/CMakeLists.txt @@ -28,6 +28,7 @@ target_sources(${PROJECT_NAME} PRIVATE i32_mul.c i32_ne.c i32_or.c + i32_shl.c i32_store.c i32_store8.c i32_sub.c diff --git a/src/op/i32_shl.c b/src/op/i32_shl.c new file mode 100644 index 0000000..7121c6a --- /dev/null +++ b/src/op/i32_shl.c @@ -0,0 +1,23 @@ +/* + * nanowasm, a tiny WebAssembly/Wasm interpreter + * Copyright (C) 2023-2025 Xavier Del Campo Romero + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#include <nanowasm/nw.h> +#include <nw/routines.h> + +static int shl(const struct nw_i_sm_arithm_out *const o, + union nw_value *const res) +{ + res->i32 = (unsigned long)o->left.i32 << (unsigned long)o->right.i32; + return 0; +} + +void nwp_op_i32_shl(struct nw_interp *const i) +{ + nwp_arithm(i, NW_TYPE_I32, shl); +} |
