diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-06-29 18:00:51 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-06-29 18:00:51 +0300 |
commit | 322c7fba3d2f4c9b5b0d78b44feefd38ae44d017 (patch) | |
tree | de20ed83ee9231e853cefb46bb8ba60cf65e09dd /src/ejit.c | |
parent | d4c1d32e0aa21677e72c54ed220fdc70cea732c8 (diff) | |
download | ejit-322c7fba3d2f4c9b5b0d78b44feefd38ae44d017.tar.gz ejit-322c7fba3d2f4c9b5b0d78b44feefd38ae44d017.zip |
continue working through bytecode ops
Diffstat (limited to 'src/ejit.c')
-rw-r--r-- | src/ejit.c | 39 |
1 files changed, 29 insertions, 10 deletions
@@ -6,7 +6,7 @@ #include "common.h" static void emit_insn_i(struct ejit_func *f, enum ejit_opcode op, size_t r0, - size_t r1, long o) + size_t r1, int64_t o) { struct ejit_insn i = {.op = op, .r0 = r0, .r1 = r1, .o = o}; vec_append(&f->insns, &i); @@ -183,13 +183,13 @@ void ejit_retval(struct ejit_func *s, struct ejit_gpr r0) } void ejit_stxi_64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, - long o) + int64_t o) { emit_insn_i(s, STXI64, r0.r, r1.r, o); } void ejit_ldxi_u64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, - long o) + int64_t o) { emit_insn_i(s, LDXIU64, r0.r, r1.r, o); } @@ -204,7 +204,7 @@ void ejit_retr_f(struct ejit_func *s, struct ejit_fpr r0) emit_insn_r(s, RETR_F, r0.f, 0, 0); } -void ejit_reti(struct ejit_func *s, long i) +void ejit_reti(struct ejit_func *s, int64_t i) { emit_insn_i(s, RETI, 0, 0, i); } @@ -227,7 +227,7 @@ void ejit_addr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, } void ejit_addi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, - long o) + int64_t o) { emit_insn_i(s, ADDI, r0.r, r1.r, o); } @@ -267,12 +267,24 @@ void ejit_divr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, emit_insn_r(s, DIVR, r0.r, r1.r, r2.r); } +void ejit_andr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + struct ejit_gpr r2) +{ + emit_insn_r(s, ANDR, r0.r, r1.r, r2.r); +} + +void ejit_andi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, + int64_t o) +{ + emit_insn_i(s, ANDI, r0.r, r1.r, o); +} + void ejit_negr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1) { emit_insn_i(s, NEGR, r0.r, r1.r, 0); } -void ejit_movi(struct ejit_func *s, struct ejit_gpr r0, long o) +void ejit_movi(struct ejit_func *s, struct ejit_gpr r0, int64_t o) { emit_insn_i(s, MOVI, r0.r, 0, o); } @@ -305,21 +317,28 @@ struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0, return (struct ejit_reloc){.insn = addr}; } -struct ejit_reloc ejit_bnei(struct ejit_func *s, struct ejit_gpr r0, long o) +struct ejit_reloc ejit_bnei(struct ejit_func *s, struct ejit_gpr r0, int64_t o) { size_t addr = vec_len(&s->insns); emit_insn_i(s, BNEI, 0, r0.r, o); return (struct ejit_reloc){.insn = addr}; } -struct ejit_reloc ejit_beqi(struct ejit_func *s, struct ejit_gpr r0, long o) +struct ejit_reloc ejit_beqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1) +{ + size_t addr = vec_len(&s->insns); + emit_insn_r(s, BEQR, 0, r0.r, r1.r); + return (struct ejit_reloc){.insn = addr}; +} + +struct ejit_reloc ejit_beqi(struct ejit_func *s, struct ejit_gpr r0, int64_t o) { size_t addr = vec_len(&s->insns); emit_insn_i(s, BEQI, 0, r0.r, o); return (struct ejit_reloc){.insn = addr}; } -struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, long o) +struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, int64_t o) { size_t addr = vec_len(&s->insns); emit_insn_i(s, BGTI, 0, r0.r, o); @@ -336,7 +355,7 @@ struct ejit_reloc ejit_jmp(struct ejit_func *s) static struct interp_state create_interp_state() { struct interp_state state; - state.gprs = vec_create(sizeof(long)); + state.gprs = vec_create(sizeof(int64_t)); state.fprs = vec_create(sizeof(double)); state.args = vec_create(sizeof(struct ejit_arg)); return state; |