/*
* nwc, a NanoWasm compiler
* Copyright (C) 2025 Xavier Del Campo Romero
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
#ifndef INSTR_H
#define INSTR_H
#include "types.h"
#include
enum
{
OP_UNREACHABLE,
OP_NOP,
OP_BLOCK,
OP_LOOP,
OP_IF,
OP_ELSE,
OP_END = 0xb,
OP_BR,
OP_BR_IF,
OP_BR_TABLE,
OP_RETURN,
OP_CALL,
OP_CALL_INDIRECT,
OP_DROP = 0x1a,
OP_SELECT,
OP_GET_LOCAL = 0x20,
OP_SET_LOCAL,
OP_TEE_LOCAL,
OP_GET_GLOBAL,
OP_SET_GLOBAL,
OP_I32_LOAD = 0x28,
OP_I64_LOAD,
OP_F32_LOAD,
OP_F64_LOAD,
OP_I32_LOAD8_S,
OP_I32_LOAD8_U,
OP_I32_LOAD16_S,
OP_I32_LOAD16_U,
OP_I64_LOAD8_S,
OP_I64_LOAD8_U,
OP_I64_LOAD16_S,
OP_I64_LOAD16_U,
OP_I64_LOAD32_S,
OP_I64_LOAD32_U,
OP_I32_STORE,
OP_I64_STORE,
OP_F32_STORE,
OP_F64_STORE,
OP_I32_STORE8,
OP_I32_STORE16,
OP_I64_STORE8,
OP_I64_STORE16,
OP_I64_STORE132,
OP_CURRENT_MEMORY,
OP_GROW_MEMORY,
OP_I32_CONST,
OP_I64_CONST,
OP_F32_CONST,
OP_F64_CONST,
OP_I32_EQZ,
OP_I32_EQ,
OP_I32_NE,
OP_I32_LT_S,
OP_I32_LT_U,
OP_I32_GT_S,
OP_I32_GT_U,
OP_I32_LE_S,
OP_I32_LE_U,
OP_I32_GE_S,
OP_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AP_I64,
OP_I32_TRUNC_S_F32,
OP_I32_TRUNC_U_F32,
OP_I32_TRUNC_S_F64,
OP_I32_TRUNC_U_F64,
OP_I64_EXTEND_S_I32,
OP_I64_EXTEND_U_I32,
OP_I64_TRUNC_S_F32,
OP_I64_TRUNC_U_F32,
OP_I64_TRUNC_S_F64,
OP_I64_TRUNC_U_F64,
OP_F32_CONVERT_S_I32,
OP_F32_CONVERT_U_I32,
OP_F32_CONVERT_S_I64,
OP_F32_CONVERT_U_I64,
OP_F32_DEMOTE_F64,
OP_F64_CONVERT_S_I32,
OP_F64_CONVERT_U_I32,
OP_F64_CONVERT_S_I64,
OP_F64_CONVERT_U_I64,
OP_F64_PROMOTE_F32,
OP_I32_REINTERPRET_F32,
OP_I64_REINTERPRET_F64,
OP_F32_REINTERPRET_I32,
OP_F64_REINTERPRET_I64,
OP_EXTRA = 0xfc,
};
#endif