aboutsummaryrefslogtreecommitdiff
path: root/src/ejit.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-06-30 16:39:24 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-06-30 16:40:12 +0300
commite618924df98d4ee5037db86c768a8c8014e49c4c (patch)
treeabf7e2457f49c52d3ea6c6c5fb79577e5a4ad011 /src/ejit.c
parent451797936119d8236843c4e9aee4a47dc5cddd56 (diff)
downloadejit-e618924df98d4ee5037db86c768a8c8014e49c4c.tar.gz
ejit-e618924df98d4ee5037db86c768a8c8014e49c4c.zip
work through loads and stores
Diffstat (limited to 'src/ejit.c')
-rw-r--r--src/ejit.c247
1 files changed, 242 insertions, 5 deletions
diff --git a/src/ejit.c b/src/ejit.c
index c4e82b1..4f407aa 100644
--- a/src/ejit.c
+++ b/src/ejit.c
@@ -233,8 +233,58 @@ void ejit_stxi_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1,
emit_insn_i(s, STXID, r0.f, r1.r, o);
}
+void ejit_ldi_i8(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDI8, r0.r, 0, p);
+}
+
+void ejit_ldi_i16(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDI16, r0.r, 0, p);
+}
+
+void ejit_ldi_i32(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDI32, r0.r, 0, p);
+}
+
+void ejit_ldi_i64(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDI64, r0.r, 0, p);
+}
+
+void ejit_ldi_u8(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDIU8, r0.r, 0, p);
+}
+
+void ejit_ldi_u16(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDIU16, r0.r, 0, p);
+}
+
+void ejit_ldi_u32(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDIU32, r0.r, 0, p);
+}
+
+void ejit_ldi_u64(struct ejit_func *s, struct ejit_gpr r0, void *p)
+{
+ emit_insn_p(s, LDIU64, r0.r, 0, p);
+}
+
+void ejit_ldi_f(struct ejit_func *s, struct ejit_fpr r0, void *p)
+{
+ emit_insn_p(s, LDIF, r0.f, 0, p);
+}
+
+void ejit_ldi_d(struct ejit_func *s, struct ejit_fpr r0, void *p)
+{
+ emit_insn_p(s, LDID, r0.f, 0, p);
+}
+
void ejit_ldxi_i8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
- int64_t o)
+ int64_t o)
{
emit_insn_i(s, LDXI8, r0.r, r1.r, o);
}
@@ -258,7 +308,7 @@ void ejit_ldxi_i64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
}
void ejit_ldxi_u8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
- int64_t o)
+ int64_t o)
{
emit_insn_i(s, LDXIU8, r0.r, r1.r, o);
}
@@ -282,17 +332,77 @@ void ejit_ldxi_u64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
}
void ejit_ldxi_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1,
- int64_t o)
+ int64_t o)
{
emit_insn_i(s, LDXIF, r0.f, r1.r, o);
}
void ejit_ldxi_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1,
- int64_t o)
+ int64_t o)
{
emit_insn_i(s, LDXID, r0.f, r1.r, o);
}
+void ejit_ldxr_i8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXR8, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_i16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXR16, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_i32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXR32, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_i64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXR64, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_u8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXRU8, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_u16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXRU16, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_u32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXRU32, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_u64(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXIU64, r0.r, r1.r, r2.r);
+}
+
+void ejit_ldxr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXRF, r0.f, r1.r, r2.r);
+}
+
+void ejit_ldxr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LDXRD, r0.f, r1.r, r2.r);
+}
+
void ejit_retr(struct ejit_func *s, struct ejit_gpr r0)
{
emit_insn_r(s, RETR, r0.r, 0, 0);
@@ -313,6 +423,36 @@ void ejit_reti_f(struct ejit_func *s, double f)
emit_insn_f(s, RETI_F, 0, 0, f);
}
+void ejit_extr_8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTR8, r0.r, r1.r, 0);
+}
+
+void ejit_extr_16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTR16, r0.r, r1.r, 0);
+}
+
+void ejit_extr_32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTR32, r0.r, r1.r, 0);
+}
+
+void ejit_extr_u8(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTRU8, r0.r, r1.r, 0);
+}
+
+void ejit_extr_u16(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTRU16, r0.r, r1.r, 0);
+}
+
+void ejit_extr_u32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+{
+ emit_insn_i(s, EXTRU32, r0.r, r1.r, 0);
+}
+
void ejit_addr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
struct ejit_gpr r2)
{
@@ -378,6 +518,30 @@ void ejit_divr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1,
emit_insn_r(s, DIVR_F, r0.f, r1.f, r2.f);
}
+void ejit_lshi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ int64_t o)
+{
+ emit_insn_i(s, LSHI, r0.r, r1.r, o);
+}
+
+void ejit_lshr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, LSHR, r0.r, r1.r, r2.r);
+}
+
+void ejit_rshi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ int64_t o)
+{
+ emit_insn_i(s, RSHI, r0.r, r1.r, o);
+}
+
+void ejit_rshr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, RSHR, 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)
{
@@ -420,17 +584,83 @@ void ejit_eqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
}
void ejit_eqr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1,
- struct ejit_fpr r2)
+ struct ejit_fpr r2)
{
emit_insn_r(s, EQR_F, r0.r, r1.f, r2.f);
}
+void ejit_gtr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GTR, r0.r, r1.r, r2.r);
+}
+
+void ejit_gtr_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GTR_U, r0.r, r1.r, r2.r);
+}
+
+void ejit_gtr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1,
+ struct ejit_fpr r2)
+{
+ emit_insn_r(s, GTR_F, r0.r, r1.f, r2.f);
+}
+
void ejit_ltr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
struct ejit_gpr r2)
{
emit_insn_r(s, GER, r0.r, r2.r, r1.r);
}
+void ejit_ltr_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GER_U, r0.r, r2.r, r1.r);
+}
+
+void ejit_ltr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1,
+ struct ejit_fpr r2)
+{
+ emit_insn_r(s, GER_F, r0.r, r2.f, r1.f);
+}
+
+void ejit_ger(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GER, r0.r, r1.r, r2.r);
+}
+
+void ejit_ger_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GER_U, r0.r, r1.r, r2.r);
+}
+
+void ejit_ger_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1,
+ struct ejit_fpr r2)
+{
+ emit_insn_r(s, GER_F, r0.r, r1.f, r2.f);
+}
+
+void ejit_ler(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GTR, r0.r, r2.r, r1.r);
+}
+
+void ejit_ler_u(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2)
+{
+ emit_insn_r(s, GTR_U, r0.r, r2.r, r1.r);
+}
+
+void ejit_ler_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1,
+ struct ejit_fpr r2)
+{
+ emit_insn_r(s, GTR_F, r0.r, r2.f, r1.f);
+}
+
struct ejit_reloc ejit_bner(struct ejit_func *s, struct ejit_gpr r0,
struct ejit_gpr r1)
{
@@ -648,6 +878,13 @@ struct ejit_reloc ejit_jmp(struct ejit_func *s)
return (struct ejit_reloc){.insn = addr};
}
+struct ejit_reloc ejit_jmpr(struct ejit_func *s, struct ejit_gpr r0)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, JMPR, 0, r0.r, 0);
+ return (struct ejit_reloc){.insn = addr};
+}
+
struct ejit_reloc ejit_bmci(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
{
size_t addr = vec_len(&s->insns);