d_m3HasFloat=0 build fixes

extensions
Steven Massey 3 years ago
parent 29c81a5622
commit 67b96cc96a

@ -305,8 +305,10 @@ M3Result repl_call (const char* name, int argc, const char* argv[])
switch (m3_GetRetType(func, i)) {
case c_m3Type_i32: fprintf (stderr, "Result: %" PRIi32 "\n", *(i32*)valptrs[i]); break;
case c_m3Type_i64: fprintf (stderr, "Result: %" PRIi64 "\n", *(i64*)valptrs[i]); break;
# if d_m3HasFloat
case c_m3Type_f32: fprintf (stderr, "Result: %" PRIf32 "\n", *(f32*)valptrs[i]); break;
case c_m3Type_f64: fprintf (stderr, "Result: %" PRIf64 "\n", *(f64*)valptrs[i]); break;
# endif
default: return "unknown return type";
}
}

@ -1073,7 +1073,7 @@ _ (PushConst (o, value, c_m3Type_i64)); m3log (compile,
}
#if d_m3HasFloat
#if d_m3ImplementFloat
M3Result Compile_Const_f32 (IM3Compilation o, m3opcode_t i_opcode)
{
M3Result result;
@ -2367,7 +2367,12 @@ const M3OpInfo c_operations [] =
# ifdef DEBUG // for codepage logging. the order doesn't matter:
# define d_m3DebugOp(OP) M3OP (#OP, 0, none, { op_##OP })
# if d_m3HasFloat
# define d_m3DebugTypedOp(OP) M3OP (#OP, 0, none, { op_##OP##_i32, op_##OP##_i64, op_##OP##_f32, op_##OP##_f64, })
# else
# define d_m3DebugTypedOp(OP) M3OP (#OP, 0, none, { op_##OP##_i32, op_##OP##_i64 })
# endif
d_m3DebugOp (Compile), d_m3DebugOp (Entry), d_m3DebugOp (End),
d_m3DebugOp (Unsupported), d_m3DebugOp (CallRawFunction),
@ -2380,11 +2385,13 @@ const M3OpInfo c_operations [] =
d_m3DebugOp (Select_i32_rss), d_m3DebugOp (Select_i32_srs), d_m3DebugOp (Select_i32_ssr), d_m3DebugOp (Select_i32_sss),
d_m3DebugOp (Select_i64_rss), d_m3DebugOp (Select_i64_srs), d_m3DebugOp (Select_i64_ssr), d_m3DebugOp (Select_i64_sss),
# if d_m3HasFloat
d_m3DebugOp (Select_f32_sss), d_m3DebugOp (Select_f32_srs), d_m3DebugOp (Select_f32_ssr),
d_m3DebugOp (Select_f32_rss), d_m3DebugOp (Select_f32_rrs), d_m3DebugOp (Select_f32_rsr),
d_m3DebugOp (Select_f64_sss), d_m3DebugOp (Select_f64_srs), d_m3DebugOp (Select_f64_ssr),
d_m3DebugOp (Select_f64_rss), d_m3DebugOp (Select_f64_rrs), d_m3DebugOp (Select_f64_rsr),
# endif
d_m3DebugTypedOp (SetGlobal), d_m3DebugOp (SetGlobal_s32), d_m3DebugOp (SetGlobal_s64),

@ -263,7 +263,7 @@ M3Result Read_u32 (u32 * o_value, bytes_t * io_bytes, cbytes_t i_end)
else return m3Err_wasmUnderrun;
}
#if d_m3HasFloat || d_m3NoFloatDynamic
#if d_m3ImplementFloat
M3Result Read_f64 (f64 * o_value, bytes_t * io_bytes, cbytes_t i_end)
{

@ -27,11 +27,9 @@
d_m3BeginExternC
#define d_m3ImplementFloat (d_m3HasFloat || d_m3NoFloatDynamic)
#if !defined(d_m3ShortTypesDefined)
#if d_m3HasFloat || d_m3NoFloatDynamic
typedef double f64;
typedef float f32;
#endif
typedef uint64_t u64;
typedef int64_t i64;
@ -41,6 +39,12 @@ typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;
#if d_m3ImplementFloat
typedef double f64;
typedef float f32;
#endif
#endif // d_m3ShortTypesDefined
#define PRIf32 "f"
@ -224,7 +228,7 @@ u32 SizeOfType (u8 i_m3Type);
M3Result Read_u64 (u64 * o_value, bytes_t * io_bytes, cbytes_t i_end);
M3Result Read_u32 (u32 * o_value, bytes_t * io_bytes, cbytes_t i_end);
#if d_m3HasFloat || d_m3NoFloatDynamic
#if d_m3ImplementFloat
M3Result Read_f64 (f64 * o_value, bytes_t * io_bytes, cbytes_t i_end);
M3Result Read_f32 (f32 * o_value, bytes_t * io_bytes, cbytes_t i_end);
#endif

@ -611,8 +611,10 @@ M3Result m3_GetGlobal (IM3Global i_global,
switch (i_global->type) {
case c_m3Type_i32: o_value->value.i32 = i_global->intValue; break;
case c_m3Type_i64: o_value->value.i64 = i_global->intValue; break;
# if d_m3HasFloat
case c_m3Type_f32: o_value->value.f32 = i_global->f32Value; break;
case c_m3Type_f64: o_value->value.f64 = i_global->f64Value; break;
# endif
default: return m3Err_invalidTypeId;
}
@ -631,8 +633,10 @@ M3Result m3_SetGlobal (IM3Global i_global,
switch (i_value->type) {
case c_m3Type_i32: i_global->intValue = i_value->value.i32; break;
case c_m3Type_i64: i_global->intValue = i_value->value.i64; break;
# if d_m3HasFloat
case c_m3Type_f32: i_global->f32Value = i_value->value.f32; break;
case c_m3Type_f64: i_global->f64Value = i_value->value.f64; break;
# endif
default: return m3Err_invalidTypeId;
}
@ -790,8 +794,10 @@ M3Result m3_CallVL (IM3Function i_function, va_list i_args)
switch (d_FuncArgType(ftype, i)) {
case c_m3Type_i32: *(i32*)(s) = va_arg(i_args, i32); s += 8; break;
case c_m3Type_i64: *(i64*)(s) = va_arg(i_args, i64); s += 8; break;
# if d_m3HasFloat
case c_m3Type_f32: *(f32*)(s) = va_arg(i_args, f64); s += 8; break; // f32 is passed as f64
case c_m3Type_f64: *(f64*)(s) = va_arg(i_args, f64); s += 8; break;
# endif
default: return "unknown argument type";
}
}
@ -831,8 +837,10 @@ M3Result m3_Call (IM3Function i_function, uint32_t i_argc, const void * i_argp
switch (d_FuncArgType(ftype, i)) {
case c_m3Type_i32: *(i32*)(s) = *(i32*)i_argptrs[i]; s += 8; break;
case c_m3Type_i64: *(i64*)(s) = *(i64*)i_argptrs[i]; s += 8; break;
# if d_m3HasFloat
case c_m3Type_f32: *(f32*)(s) = *(f32*)i_argptrs[i]; s += 8; break;
case c_m3Type_f64: *(f64*)(s) = *(f64*)i_argptrs[i]; s += 8; break;
# endif
default: return "unknown argument type";
}
}
@ -873,8 +881,10 @@ M3Result m3_CallArgv (IM3Function i_function, uint32_t i_argc, const char * i_
switch (d_FuncArgType(ftype, i)) {
case c_m3Type_i32: *(i32*)(s) = strtoul(i_argv[i], NULL, 10); s += 8; break;
case c_m3Type_i64: *(i64*)(s) = strtoull(i_argv[i], NULL, 10); s += 8; break;
case c_m3Type_f32: *(f32*)(s) = strtod(i_argv[i], NULL); s += 8; break; // strtof would be less portable
# if d_m3HasFloat
case c_m3Type_f32: *(f32*)(s) = strtod(i_argv[i], NULL); s += 8; break; // strtof would be less portable
case c_m3Type_f64: *(f64*)(s) = strtod(i_argv[i], NULL); s += 8; break;
# endif
default: return "unknown argument type";
}
}
@ -919,8 +929,10 @@ M3Result m3_GetResults (IM3Function i_function, uint32_t i_retc, const void *
switch (d_FuncRetType(ftype, i)) {
case c_m3Type_i32: *(i32*)o_retptrs[i] = *(i32*)(s); s += 8; break;
case c_m3Type_i64: *(i64*)o_retptrs[i] = *(i64*)(s); s += 8; break;
# if d_m3HasFloat
case c_m3Type_f32: *(f32*)o_retptrs[i] = *(f32*)(s); s += 8; break;
case c_m3Type_f64: *(f64*)o_retptrs[i] = *(f64*)(s); s += 8; break;
# endif
default: return "unknown return type";
}
}
@ -951,8 +963,10 @@ M3Result m3_GetResultsVL (IM3Function i_function, va_list o_rets)
switch (d_FuncRetType(ftype, i)) {
case c_m3Type_i32: *va_arg(o_rets, i32*) = *(i32*)(s); s += 8; break;
case c_m3Type_i64: *va_arg(o_rets, i64*) = *(i64*)(s); s += 8; break;
# if d_m3HasFloat
case c_m3Type_f32: *va_arg(o_rets, f32*) = *(f32*)(s); s += 8; break;
case c_m3Type_f64: *va_arg(o_rets, f64*) = *(f64*)(s); s += 8; break;
# endif
default: return "unknown argument type";
}
}

@ -12,27 +12,35 @@
d_m3BeginExternC
#define m3MemData(mem) (u8*)(((M3MemoryHeader*)(mem))+1)
#define m3MemRuntime(mem) (((M3MemoryHeader*)(mem))->runtime)
#define m3MemInfo(mem) (&(((M3MemoryHeader*)(mem))->runtime->memory))
#if d_m3HasFloat
# define d_m3OpSig pc_t _pc, m3stack_t _sp, M3MemoryHeader * _mem, m3reg_t _r0, f64 _fp0
# define d_m3OpArgs _sp, _mem, _r0, _fp0
# define d_m3OpAllArgs _pc, _sp, _mem, _r0, _fp0
# define d_m3OpDefaultArgs 0, 0.0
# define d_m3ClearRegisters _r0 = 0; _fp0 = 0.0;
#else
# define d_m3OpSig pc_t _pc, m3stack_t _sp, M3MemoryHeader * _mem, m3reg_t _r0
# define d_m3OpArgs _sp, _mem, _r0
# define d_m3OpAllArgs _pc, _sp, _mem, _r0
# define d_m3OpDefaultArgs 0
# define d_m3ClearRegisters _r0 = 0;
#endif
# define m3MemData(mem) (u8*)(((M3MemoryHeader*)(mem))+1)
# define m3MemRuntime(mem) (((M3MemoryHeader*)(mem))->runtime)
# define m3MemInfo(mem) (&(((M3MemoryHeader*)(mem))->runtime->memory))
# define d_m3BaseOpSig pc_t _pc, m3stack_t _sp, M3MemoryHeader * _mem, m3reg_t _r0
# define d_m3BaseOpArgs _sp, _mem, _r0
# define d_m3BaseOpAllArgs _pc, _sp, _mem, _r0
# define d_m3BaseOpDefaultArgs 0
# define d_m3BaseClearRegisters _r0 = 0;
# define d_m3ExpOpSig(...) d_m3BaseOpSig, __VA_ARGS__
# define d_m3ExpOpArgs(...) d_m3BaseOpArgs, __VA_ARGS__
# define d_m3ExpOpAllArgs(...) d_m3BaseOpAllArgs, __VA_ARGS__
# define d_m3ExpOpDefaultArgs(...) d_m3BaseOpDefaultArgs, __VA_ARGS__
# define d_m3ExpClearRegisters(...) d_m3BaseClearRegisters; __VA_ARGS__
# if d_m3HasFloat
# define d_m3OpSig d_m3ExpOpSig (f64 _fp0)
# define d_m3OpArgs d_m3ExpOpArgs (_fp0)
# define d_m3OpAllArgs d_m3ExpOpAllArgs (_fp0)
# define d_m3OpDefaultArgs d_m3ExpOpDefaultArgs (0.)
# define d_m3ClearRegisters d_m3ExpClearRegisters (_fp0 = 0.;)
# else
# define d_m3OpSig d_m3BaseOpSig
# define d_m3OpArgs d_m3BaseOpArgs
# define d_m3OpAllArgs d_m3BaseOpAllArgs
# define d_m3OpDefaultArgs d_m3BaseOpDefaultArgs
# define d_m3ClearRegisters d_m3BaseClearRegisters
# endif
typedef m3ret_t (vectorcall * IM3Operation) (d_m3OpSig);

Loading…
Cancel
Save