forked from wasm3/wasm3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm3_exec_defs.h
63 lines (49 loc) · 2.33 KB
/
m3_exec_defs.h
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
//
// m3_exec_defs.h
//
// Created by Steven Massey on 5/1/19.
// Copyright © 2019 Steven Massey. All rights reserved.
//
#ifndef m3_exec_defs_h
#define m3_exec_defs_h
#include "m3_core.h"
d_m3BeginExternC
# 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);
#define d_m3RetSig static inline m3ret_t vectorcall
#define d_m3Op(NAME) M3_NO_UBSAN d_m3RetSig op_##NAME (d_m3OpSig)
#define nextOpImpl() ((IM3Operation)(* _pc))(_pc + 1, d_m3OpArgs)
#define jumpOpImpl(PC) ((IM3Operation)(* PC))( PC + 1, d_m3OpArgs)
#define nextOpDirect() M3_MUSTTAIL return nextOpImpl()
#define jumpOpDirect(PC) M3_MUSTTAIL return jumpOpImpl((pc_t)(PC))
d_m3RetSig RunCode (d_m3OpSig)
{
nextOpDirect();
}
d_m3EndExternC
#endif // m3_exec_defs_h