#ifndef EJIT_COMMON_H #define EJIT_COMMON_H #include #include "vec.h" enum ejit_opcode { MOVI, MOVR, MOVR_F, LDI8, LDI16, LDI32, LDI64, LDIU8, LDIU16, LDIU32, LDIU64, LDIF, LDID, LDXI8, LDXI16, LDXI32, LDXI64, LDXIU8, LDXIU16, LDXIU32, LDXIU64, LDXIF, LDXID, STI8, STI16, STI32, STI64, STIU8, STIU16, STIU32, STIU64, STIF, STID, STXI8, STXI16, STXI32, STXI64, STXIU8, STXIU16, STXIU32, STXIU64, STXIF, STXID, ADDR, ADDR_F, ADDI, ABSR_F, SUBR, SUBR_F, SUBI, MULR, DIVR, NEGR, ANDR, ANDI, EQR, LTR, BLTR, BNEI, BEQR, BEQI, BGTI, JMP, PARAM, PARAM_F, ARG, ARG_I, ARG_F, ARG_FI, ESCAPEI, ESCAPEI_F, CALLI, CALLI_F, RETR, RETI, RETR_F, RETI_F, RETVAL, RETVAL_F, START, END, OPCODE_COUNT, }; struct ejit_insn { union { enum ejit_opcode op; void *addr; }; size_t r0; size_t r1; union { size_t r2; void *p; int64_t o; double d; }; }; struct ejit_func { struct vec insns; struct vec labels; enum ejit_type rtype; size_t gpr; size_t fpr; void *arena; size_t size; }; union interp_ret { int64_t r; double d; }; struct interp_state { struct vec gprs; struct vec fprs; struct vec args; }; union interp_ret ejit_interp(struct ejit_func *f, size_t argc, struct ejit_arg args[argc], struct interp_state *state, bool run, void ***labels_wb); int64_t ejit_run_interp(struct ejit_func *f, size_t argc, struct ejit_arg args[argc], struct interp_state *state); bool ejit_compile(struct ejit_func *f, bool use_64); #endif /* EJIT_COMMON_H */