extensions
Volodymyr Shymanskyy 4 years ago
parent 4ee513ee73
commit 640bf0cc26

@ -25,17 +25,23 @@
#define any (u8)-1
#if d_m3HasFloat
static const IM3Operation c_preserveSetSlot [] = { NULL, op_PreserveSetSlot_i32, op_PreserveSetSlot_i64, op_PreserveSetSlot_f32, op_PreserveSetSlot_f64 };
static const IM3Operation c_setSetOps [] = { NULL, op_SetSlot_i32, op_SetSlot_i64, op_SetSlot_f32, op_SetSlot_f64 };
static const IM3Operation c_setGlobalOps [] = { NULL, op_SetGlobal_i32, op_SetGlobal_i64, op_SetGlobal_f32, op_SetGlobal_f64 };
static const IM3Operation c_setRegisterOps [] = { NULL, op_SetRegister_i32, op_SetRegister_i64, op_SetRegister_f32, op_SetRegister_f64 };
#define FPOP(x) x
#else
static const IM3Operation c_preserveSetSlot [] = { NULL, op_PreserveSetSlot_i32, op_PreserveSetSlot_i64, NULL, NULL };
static const IM3Operation c_setSetOps [] = { NULL, op_SetSlot_i32, op_SetSlot_i64, NULL, NULL };
static const IM3Operation c_setGlobalOps [] = { NULL, op_SetGlobal_i32, op_SetGlobal_i64, NULL, NULL };
static const IM3Operation c_setRegisterOps [] = { NULL, op_SetRegister_i32, op_SetRegister_i64, NULL, NULL };
#define FPOP(x) NULL
#endif
static const IM3Operation c_preserveSetSlot [] = { NULL, op_PreserveSetSlot_i32, op_PreserveSetSlot_i64,
FPOP(op_PreserveSetSlot_f32), FPOP(op_PreserveSetSlot_f64) };
static const IM3Operation c_setSetOps [] = { NULL, op_SetSlot_i32, op_SetSlot_i64,
FPOP(op_SetSlot_f32), FPOP(op_SetSlot_f64) };
static const IM3Operation c_setGlobalOps [] = { NULL, op_SetGlobal_i32, op_SetGlobal_i64,
FPOP(op_SetGlobal_f32), FPOP(op_SetGlobal_f64) };
static const IM3Operation c_setRegisterOps [] = { NULL, op_SetRegister_i32, op_SetRegister_i64,
FPOP(op_SetRegister_f32), FPOP(op_SetRegister_f64) };
static const IM3Operation c_ifOps [2] [2] = { { op_i32_BranchIf_ss, op_i32_BranchIf_rs },
{ op_i64_BranchIf_ss, op_i64_BranchIf_rs } };
static const IM3Operation c_intSelectOps [2] [4] = { { op_Select_i32_rss, op_Select_i32_srs, op_Select_i32_ssr, op_Select_i32_sss },
{ op_Select_i64_rss, op_Select_i64_srs, op_Select_i64_ssr, op_Select_i64_sss } };
@ -1219,9 +1225,7 @@ _ (MoveStackTopToRegister (o));
{
valueSlot = GetStackTopSlotIndex (o);
const IM3Operation ifOps [2][2] = { { op_i32_BranchIf_ss, op_i32_BranchIf_rs }, { op_i64_BranchIf_ss, op_i64_BranchIf_rs } };
op = ifOps [valueType - c_m3Type_i32] [conditionInRegister];
op = c_ifOps [valueType - c_m3Type_i32] [conditionInRegister];
}
}
}

@ -242,12 +242,12 @@
# define M3_BSWAP_f64(X) {}
# endif
# if defined(M3_COMPILER_MSVC)
# define UNLIKELY(x) (x)
# define LIKELY(x) (x)
# else
# if defined(M3_COMPILER_GCC) || defined(M3_COMPILER_CLANG) || defined(M3_COMPILER_ICC)
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
# define LIKELY(x) __builtin_expect(!!(x), 1)
# else
# define UNLIKELY(x) (x)
# define LIKELY(x) (x)
# endif

@ -70,8 +70,6 @@ typedef struct M3Function
}
M3Function;
typedef M3Function * IM3Function;
void Function_Release (IM3Function i_function);
void Function_FreeCompiledCode (IM3Function i_function);
@ -191,9 +189,6 @@ typedef struct M3Module
}
M3Module;
typedef M3Module * IM3Module;
M3Result Module_AddGlobal (IM3Module io_module, IM3Global * o_global, u8 i_type, bool i_mutable, bool i_isImported);
M3Result Module_AddFunction (IM3Module io_module, u32 i_typeIndex, IM3ImportInfo i_importInfo /* can be null */);
@ -220,8 +215,6 @@ void Environment_Release (IM3Environment i_enviro
// takes ownership of io_funcType and returns a pointer to the persistent version (could be same or different)
void Environment_AddFuncType (IM3Environment i_environment, IM3FuncType * io_funcType);
typedef M3Environment * IM3Environment;
//---------------------------------------------------------------------------------------------------------------------------------
// OPTZ: function types need to move to the runtime structure so that all modules can share types
@ -260,9 +253,6 @@ typedef struct M3Runtime
}
M3Runtime;
typedef M3Runtime * IM3Runtime;
void InitRuntime (IM3Runtime io_runtime, u32 i_stackSizeInBytes);
void Runtime_Release (IM3Runtime io_runtime);

@ -26,7 +26,6 @@
#include "m3_exec_defs.h"
#include "m3_math_utils.h"
#include <math.h>
#include <limits.h>
d_m3BeginExternC

@ -10,7 +10,6 @@
#include "m3_core.h"
#include <math.h>
#include <limits.h>
#if defined(M3_COMPILER_MSVC)
@ -234,6 +233,9 @@ u64 rotr64(u64 n, unsigned c) {
*/
#if d_m3HasFloat
#include <math.h>
static inline
f32 min_f32(f32 a, f32 b) {
if (UNLIKELY(isnan(a) or isnan(b))) return NAN;

Loading…
Cancel
Save