From 2fc4f728643f78577c26e548619bc7db90a7c6ae Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 28 Jun 2024 18:32:56 +0300 Subject: implement enough for fibonacci --- src/ejit.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ejit.c') diff --git a/src/ejit.c b/src/ejit.c index 2040865..1fcae9d 100644 --- a/src/ejit.c +++ b/src/ejit.c @@ -199,6 +199,11 @@ void ejit_addr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, st emit_insn_r(s, ADDR_F, r0.f, r1.f, r2.f); } +void ejit_addi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, long o) +{ + emit_insn_i(s, ADDI, r0.r, r1.r, o); +} + void ejit_subr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { emit_insn_r(s, SUBR, r0.r, r1.r, r2.r); @@ -209,6 +214,11 @@ void ejit_subr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, st emit_insn_r(s, SUBR_F, r0.f, r1.f, r2.f); } +void ejit_subi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, long o) +{ + emit_insn_i(s, SUBI, r0.r, r1.r, o); +} + void ejit_mulr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { emit_insn_r(s, MULR, r0.r, r1.r, r2.r); @@ -268,6 +278,13 @@ struct ejit_reloc ejit_beqi(struct ejit_func *s, struct ejit_gpr r0, long o) return (struct ejit_reloc){.insn = addr}; } +struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, long o) +{ + size_t addr = vec_len(&s->insns); + emit_insn_i(s, BGTI, 0, r0.r, o); + return (struct ejit_reloc){.insn = addr}; +} + struct ejit_reloc ejit_jmp(struct ejit_func *s) { size_t addr = vec_len(&s->insns); -- cgit v1.2.3