aboutsummaryrefslogtreecommitdiff
path: root/src/ejit.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-06-28 18:32:56 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-06-28 18:38:43 +0300
commit2fc4f728643f78577c26e548619bc7db90a7c6ae (patch)
tree760d2ae310737b0ff39e37aa896d182f7df58c51 /src/ejit.c
parentd65c2461d26bf485b88276984bbc33054d5bce20 (diff)
downloadejit-2fc4f728643f78577c26e548619bc7db90a7c6ae.tar.gz
ejit-2fc4f728643f78577c26e548619bc7db90a7c6ae.zip
implement enough for fibonacci
Diffstat (limited to 'src/ejit.c')
-rw-r--r--src/ejit.c17
1 files changed, 17 insertions, 0 deletions
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);