aboutsummaryrefslogtreecommitdiff
path: root/src/routines/section/ops.c
blob: a81c8e700a7e6743bd7770d97acc62af624d8abd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
 * 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/ops.h>
#include <nw/opcodes.h>

static const struct nwp_check_op ops[] =
{
    {
        OP_UNREACHABLE,
        OP_NOP,
        nwp_op_check_no_immediate
    },

    {
        OP_BLOCK,
        OP_IF,
        nwp_op_check_block
    },

    {
        OP_ELSE,
        OP_ELSE,
        nwp_op_check_no_immediate
    },

    {
        OP_END,
        OP_END,
        nwp_op_check_end
    },

    {
        OP_BR,
        OP_BR_IF,
        nwp_op_check_relative_depth
    },

    {
        OP_BR_TABLE,
        OP_BR_TABLE,
        nwp_op_check_br_table
    },

    {
        OP_RETURN,
        OP_RETURN,
        nwp_op_check_no_immediate
    },

    {
        OP_CALL,
        OP_CALL,
        nwp_op_check_call
    },

    {
        OP_CALL_INDIRECT,
        OP_CALL_INDIRECT,
        nwp_op_check_call_indirect
    },

    {
        OP_DROP,
        OP_SELECT,
        nwp_op_check_no_immediate
    },

    {
        OP_GET_LOCAL,
        OP_TEE_LOCAL,
        nwp_op_check_local_index,
    },

    {
        OP_GET_GLOBAL,
        OP_SET_GLOBAL,
        nwp_op_check_global_index
    },

    {
        OP_I32_LOAD,
        OP_I64_STORE32,
        nwp_op_check_memory_immediate
    },

    {
        OP_CURRENT_MEMORY,
        OP_GROW_MEMORY,
        nwp_op_check_varuint1
    },

    {
        OP_I32_CONST,
        OP_I32_CONST,
        nwp_op_check_varint32
    },

    {
        OP_I64_CONST,
        OP_I64_CONST,
        nwp_op_check_varint64
    },

    {
        OP_F32_CONST,
        OP_F32_CONST,
        nwp_op_check_uint32
    },

    {
        OP_F64_CONST,
        OP_F64_CONST,
        nwp_op_check_uint64
    },

    {
        OP_I32_EQZ,
        OP_F64_PROMOTE_F32,
        nwp_op_check_no_immediate
    },

    {
        OP_MISC,
        OP_MISC,
        nwp_op_check_misc
    }
};

const struct nwp_check_ops nwp_check_ops =
{
    ops,
    sizeof ops / sizeof *ops
};