aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-06-29 20:11:34 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-06-29 20:11:34 +0300
commit9fe8ccf4ae09018fdde01a9d83f9db10ad354221 (patch)
tree664f802240a2810b5db3e783400351f1eb51c1a0
parent322c7fba3d2f4c9b5b0d78b44feefd38ae44d017 (diff)
downloadejit-9fe8ccf4ae09018fdde01a9d83f9db10ad354221.tar.gz
ejit-9fe8ccf4ae09018fdde01a9d83f9db10ad354221.zip
work through branching instructions
-rw-r--r--include/ejit/ejit.h67
-rw-r--r--src/common.h43
-rw-r--r--src/compile/compile.c17
-rw-r--r--src/ejit.c234
-rw-r--r--src/interp.c208
-rw-r--r--tests/andr.c4
-rw-r--r--tests/beqi.c4
-rw-r--r--tests/beqr.c12
-rw-r--r--tests/beqr_d.c35
-rw-r--r--tests/beqr_f.c70
-rw-r--r--tests/bgei.c41
-rw-r--r--tests/bgei_u.c39
-rw-r--r--tests/bger.c46
-rw-r--r--tests/bger_d.c34
-rw-r--r--tests/bger_f.c34
-rw-r--r--tests/bger_u.c46
-rw-r--r--tests/bgti.c41
-rw-r--r--tests/bgti_u.c41
-rw-r--r--tests/bgtr.c46
-rw-r--r--tests/bgtr_d.c34
-rw-r--r--tests/bgtr_f.c57
-rw-r--r--tests/bgtr_u.c46
-rw-r--r--tests/blei.c41
-rw-r--r--tests/blei_u.c39
-rw-r--r--tests/bler.c46
-rw-r--r--tests/bler_d.c34
-rw-r--r--tests/bler_f.c57
-rw-r--r--tests/bler_u.c46
-rw-r--r--tests/bltgtr_d.c36
-rw-r--r--tests/bltgtr_f.c61
-rw-r--r--tests/blti.c41
-rw-r--r--tests/blti_u.c41
-rw-r--r--tests/bltr.c46
-rw-r--r--tests/bltr_d.c34
-rw-r--r--tests/bltr_f.c57
-rw-r--r--tests/bltr_u.c46
-rw-r--r--tests/bmci.c42
-rw-r--r--tests/bmcr.c54
-rw-r--r--tests/bmsi.c42
-rw-r--r--tests/bmsr.c54
-rw-r--r--tests/bnei.c41
-rw-r--r--tests/bner.c48
-rw-r--r--tests/bner_d.c36
-rw-r--r--tests/bner_f.c85
-rw-r--r--tests/eqr.c30
-rw-r--r--tests/eqr_f.c32
-rw-r--r--tests/ger.c30
-rw-r--r--tests/gtr.c30
-rw-r--r--tests/gtr_f.c25
-rw-r--r--tests/ler.c30
-rw-r--r--tests/ler_f.c30
-rw-r--r--tests/ltr.c30
-rw-r--r--tests/ltr_f.c32
-rw-r--r--tests/ner.c30
54 files changed, 1526 insertions, 999 deletions
diff --git a/include/ejit/ejit.h b/include/ejit/ejit.h
index 1869be9..a910366 100644
--- a/include/ejit/ejit.h
+++ b/include/ejit/ejit.h
@@ -427,7 +427,8 @@ void ejit_divr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
void ejit_divr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1,
struct ejit_fpr r2);
-void ejit_andr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2);
+void ejit_andr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
+ struct ejit_gpr r2);
void ejit_andi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
int64_t o);
@@ -440,12 +441,74 @@ void ejit_ltr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0,
struct ejit_gpr r1);
+struct ejit_reloc ejit_bner(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
struct ejit_reloc ejit_bnei(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
-struct ejit_reloc ejit_beqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1);
+struct ejit_reloc ejit_bner_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
+struct ejit_reloc ejit_beqr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
struct ejit_reloc ejit_beqi(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_beqr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
+struct ejit_reloc ejit_bger(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bger_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bger_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
+struct ejit_reloc ejit_bgei(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_bgei_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o);
+
+struct ejit_reloc ejit_bler(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bler_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bler_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
+struct ejit_reloc ejit_blei(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_blei_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o);
+
+struct ejit_reloc ejit_bgtr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bgtr_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bgtr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_bgti_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o);
+
+struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bltr_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bltr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
+struct ejit_reloc ejit_blti(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_blti_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o);
+
+struct ejit_reloc ejit_bltgtr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1);
+
struct ejit_reloc ejit_jmp(struct ejit_func *s);
+struct ejit_reloc ejit_bmci(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_bmcr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+struct ejit_reloc ejit_bmsi(struct ejit_func *s, struct ejit_gpr r0, int64_t o);
+struct ejit_reloc ejit_bmsr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1);
+
void ejit_patch(struct ejit_func *s, struct ejit_reloc r, struct ejit_label l);
#endif /* EJIT_H */
diff --git a/src/common.h b/src/common.h
index 37332aa..1f21c74 100644
--- a/src/common.h
+++ b/src/common.h
@@ -71,15 +71,52 @@ enum ejit_opcode {
ANDI,
EQR,
- LTR,
-
- BLTR,
+ NER,
+ GTR,
+ GTR_U,
+ GER,
+ GER_U,
+
+ EQR_F,
+ NER_F,
+ GTR_F,
+ GER_F,
+
+ BNER,
BNEI,
+ BNER_F,
+
BEQR,
BEQI,
+ BEQR_F,
+
+ BGER,
+ BGER_U,
+ BGEI,
+ BGEI_U,
+ BGER_F,
+
+ BLEI,
+ BLEI_U,
+
+ BGTR,
+ BGTR_U,
BGTI,
+ BGTI_U,
+ BGTR_F,
+
+ BLTI,
+ BLTI_U,
+
+ BLTGTR_F,
+
JMP,
+ BMCI,
+ BMCR,
+ BMSI,
+ BMSR,
+
PARAM,
PARAM_F,
diff --git a/src/compile/compile.c b/src/compile/compile.c
index 4ac68d3..014b7d3 100644
--- a/src/compile/compile.c
+++ b/src/compile/compile.c
@@ -190,21 +190,6 @@ static void compile_eqr(struct ejit_func *f, jit_state_t *j, struct ejit_insn i)
compile_reg_cmp(f, j, i, jit_beqr, 1);
}
-static void compile_ltr(struct ejit_func *f, jit_state_t *j, struct ejit_insn i)
-{
- compile_reg_cmp(f, j, i, jit_bltr, 0);
-}
-
-static void compile_bltr(struct ejit_func *f, jit_state_t *j,
- struct ejit_insn i, struct vec *relocs)
-{
- jit_gpr_t c0 = getloc(f, j, i.r1, 0);
- jit_gpr_t c1 = getloc(f, j, i.r2, 1);
- jit_reloc_t r = jit_bltr(j, c0, c1);
- struct reloc_helper h = {.r = r, .to = i.r0};
- vect_append(struct reloc_helper, *relocs, &h);
-}
-
static void compile_beqi(struct ejit_func *f, jit_state_t *j,
struct ejit_insn i, struct vec *relocs)
{
@@ -377,9 +362,7 @@ static size_t compile_fn_body(struct ejit_func *f, jit_state_t *j, void *arena,
case LDXIU64: compile_ldxiu64(f, j, i); break;
case EQR: compile_eqr(f, j, i); break;
- case LTR: compile_ltr(f, j, i); break;
- case BLTR: compile_bltr(f, j, i, &relocs); break;
case BEQI: compile_beqi(f, j, i, &relocs); break;
case BNEI: compile_bnei(f, j, i, &relocs); break;
case BGTI: compile_bgti(f, j, i, &relocs); break;
diff --git a/src/ejit.c b/src/ejit.c
index e708740..adba1cc 100644
--- a/src/ejit.c
+++ b/src/ejit.c
@@ -48,10 +48,17 @@ struct ejit_func *ejit_create_func(enum ejit_type rtype, size_t argc,
for (size_t i = 0; i < argc; ++i) {
switch (args[i].kind) {
- case EJIT_OPERAND_GPR: emit_insn_r(f, PARAM, i, args[i].type,
- args[i].r); break;
- case EJIT_OPERAND_FPR: emit_insn_r(f, PARAM_F, i, args[i].type,
- args[i].r); break;
+ case EJIT_OPERAND_GPR: {
+ assert(ejit_int_type(args[i].type));
+ emit_insn_r(f, PARAM, i, args[i].type, args[i].r);
+ break;
+ }
+
+ case EJIT_OPERAND_FPR: {
+ assert(ejit_float_type(args[i].type));
+ emit_insn_r(f, PARAM_F, i, args[i].type, args[i].r);
+ break;
+ }
default: abort();
}
}
@@ -90,6 +97,9 @@ void ejit_select_compile_func(struct ejit_func *f, size_t gpr, size_t fpr,
i.addr = addr;
vect_at(struct ejit_insn, f->insns, ii) = i;
}
+
+ /* doesn't really matter what we put here as long as it isn't 0 */
+ f->size = 1;
}
void ejit_destroy_func(struct ejit_func *f)
@@ -306,14 +316,14 @@ void ejit_eqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
void ejit_ltr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1,
struct ejit_gpr r2)
{
- emit_insn_r(s, LTR, r0.r, r1.r, r2.r);
+ emit_insn_r(s, GER, r0.r, r2.r, r1.r);
}
-struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0,
+struct ejit_reloc ejit_bner(struct ejit_func *s, struct ejit_gpr r0,
struct ejit_gpr r1)
{
size_t addr = vec_len(&s->insns);
- emit_insn_r(s, BLTR, 0, r0.r, r1.r);
+ emit_insn_r(s, BNER, 0, r0.r, r1.r);
return (struct ejit_reloc){.insn = addr};
}
@@ -324,7 +334,16 @@ struct ejit_reloc ejit_bnei(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
return (struct ejit_reloc){.insn = addr};
}
-struct ejit_reloc ejit_beqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1)
+struct ejit_reloc ejit_bner_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BNER_F, 0, r0.f, r1.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+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);
@@ -338,6 +357,92 @@ struct ejit_reloc ejit_beqi(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
return (struct ejit_reloc){.insn = addr};
}
+struct ejit_reloc ejit_beqr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BEQR_F, 0, r0.f, r1.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bger(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bger_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER_U, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bger_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER_F, 0, r0.f, r1.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bgei(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BGEI, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bgei_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BGEI_U, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bler(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER, 0, r1.r, r0.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bler_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER_U, 0, r1.r, r0.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bler_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGER_F, 0, r1.f, r0.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_blei(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BLEI, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_blei_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BLEI_U, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
{
size_t addr = vec_len(&s->insns);
@@ -345,6 +450,85 @@ struct ejit_reloc ejit_bgti(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
return (struct ejit_reloc){.insn = addr};
}
+struct ejit_reloc ejit_bgti_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BGTI_U, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bgtr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bgtr_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR_U, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bgtr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR_F, 0, r0.f, r1.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bltr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR, 0, r1.r, r0.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bltr_u(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR_U, 0, r1.r, r0.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bltr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BGTR_F, 0, r1.f, r0.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_blti(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BLTI, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_blti_u(struct ejit_func *s, struct ejit_gpr r0,
+ int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BLTI_U, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bltgtr_f(struct ejit_func *s, struct ejit_fpr r0,
+ struct ejit_fpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_r(s, BLTGTR_F, 0, r0.f, r1.f);
+ return (struct ejit_reloc){.insn = addr};
+}
+
struct ejit_reloc ejit_jmp(struct ejit_func *s)
{
size_t addr = vec_len(&s->insns);
@@ -352,6 +536,36 @@ struct ejit_reloc ejit_jmp(struct ejit_func *s)
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);
+ emit_insn_i(s, BMCI, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bmcr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BMCR, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bmsi(struct ejit_func *s, struct ejit_gpr r0, int64_t o)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BMSI, 0, r0.r, o);
+ return (struct ejit_reloc){.insn = addr};
+}
+
+struct ejit_reloc ejit_bmsr(struct ejit_func *s, struct ejit_gpr r0,
+ struct ejit_gpr r1)
+{
+ size_t addr = vec_len(&s->insns);
+ emit_insn_i(s, BMSR, 0, r0.r, r1.r);
+ return (struct ejit_reloc){.insn = addr};
+}
+
static struct interp_state create_interp_state()
{
struct interp_state state;
@@ -381,7 +595,7 @@ long ejit_run_interp(struct ejit_func *f, size_t argc,
long ejit_run_func(struct ejit_func *f, size_t argc, struct ejit_arg args[argc])
{
- assert(f->gpr && "trying to run a function that hasn't been compiled");
+ assert(f->size && "trying to run a function that hasn't been compiled");
assert(f->rtype == EJIT_VOID || ejit_int_type(f->rtype));
if (f->arena)
return ((ejit_escape_t)f->arena)(argc, args);
@@ -395,7 +609,7 @@ long ejit_run_func(struct ejit_func *f, size_t argc, struct ejit_arg args[argc])
double ejit_run_func_f(struct ejit_func *f, size_t argc,
struct ejit_arg args[argc])
{
- assert(f->fpr && "trying to run a function that hasn't been compiled");
+ assert(f->size && "trying to run a function that hasn't been compiled");
assert(ejit_float_type(f->rtype));
if (f->arena)
return ((ejit_escape_f_t)f->arena)(argc, args);
diff --git a/src/interp.c b/src/interp.c
index 059b1d3..fe61c36 100644
--- a/src/interp.c
+++ b/src/interp.c
@@ -30,19 +30,57 @@ union interp_ret ejit_interp(struct ejit_func *f, size_t argc,
[ANDI] = &&ANDI,
[EQR] = &&EQR,
- [LTR] = &&LTR,
+ [EQR_F] = &&EQR_F,
+
+ [NER] = &&NER,
+ [NER_F] = &&NER_F,
+
+ [GTR] = &&GTR,
+ [GTR_U] = &&GTR_U,
+ [GTR_F] = &&GTR_F,
+
+ [GER] = &&GER,
+ [GER_U] = &&GER_U,
+ [GER_F] = &&GER_F,
[STXI64] = &&STXI64,
[LDXIU64] = &&LDXIU64,
- [BLTR] = &&BLTR,
+ [BNER] = &&BNER,
[BNEI] = &&BNEI,
+ [BNER_F] = &&BNER_F,
+
[BEQR] = &&BEQR,
[BEQI] = &&BEQI,
+ [BEQR_F] = &&BEQR_F,
+
+ [BGER] = &&BGER,
+ [BGER_U] = &&BGER_U,
+ [BGEI] = &&BGEI,
+ [BGEI_U] = &&BGEI_U,
+ [BGER_F] = &&BGER_F,
+
+ [BLEI] = &&BLEI,
+ [BLEI_U] = &&BLEI_U,
+
+ [BGTR] = &&BGTR,
+ [BGTR_U] = &&BGTR_U,
[BGTI] = &&BGTI,
+ [BGTI_U] = &&BGTI_U,
+ [BGTR_F] = &&BGTR_F,
+
+ [BLTI] = &&BLTI,
+ [BLTI_U] = &&BLTI_U,
+
+ [BLTGTR_F] = &&BLTGTR_F,
[JMP] = &&JMP,
+ [BMCI] = &&BMCI,
+ [BMCR] = &&BMCR,
+ [BMSI] = &&BMSI,
+ [BMSR] = &&BMSR,
+
[RETR] = &&RETR,
[RETI] = &&RETI,
[RETR_F] = &&RETR_F,
@@ -162,8 +200,40 @@ union interp_ret ejit_interp(struct ejit_func *f, size_t argc,
gpr[i.r0] = gpr[i.r1] == gpr[i.r2];
DISPATCH();
- DO(LTR);
- gpr[i.r0] = gpr[i.r1] < gpr[i.r2];
+ DO(EQR_F);
+ gpr[i.r0] = fpr[i.r1] == fpr[i.r2];
+ DISPATCH();
+
+ DO(NER);
+ gpr[i.r0] = gpr[i.r1] != gpr[i.r2];
+ DISPATCH();
+
+ DO(NER_F);
+ gpr[i.r0] = fpr[i.r1] != fpr[i.r2];
+ DISPATCH();
+
+ DO(GTR);
+ gpr[i.r0] = gpr[i.r1] > gpr[i.r2];
+ DISPATCH();
+
+ DO(GTR_U);
+ gpr[i.r0] = (uint64_t)gpr[i.r1] > (uint64_t)gpr[i.r2];
+ DISPATCH();
+
+ DO(GTR_F);
+ gpr[i.r0] = fpr[i.r1] > fpr[i.r2];
+ DISPATCH();
+
+ DO(GER);
+ gpr[i.r0] = gpr[i.r1] >= gpr[i.r2];
+ DISPATCH();
+
+ DO(GER_U);
+ gpr[i.r0] = (uint64_t)gpr[i.r1] >= (uint64_t)gpr[i.r2];
+ DISPATCH();
+
+ DO(GER_F);
+ gpr[i.r0] = fpr[i.r1] >= fpr[i.r2];
DISPATCH();
DO(STXI64);
@@ -176,8 +246,8 @@ union interp_ret ejit_interp(struct ejit_func *f, size_t argc,
gpr[i.r0] = *addr;
DISPATCH();
- DO(BLTR);
- if (gpr[i.r1] < gpr[i.r2])
+ DO(BNER);
+ if (gpr[i.r1] != gpr[i.r2])
JUMP(i.r0);
DISPATCH();
@@ -188,6 +258,12 @@ union interp_ret ejit_interp(struct ejit_func *f, size_t argc,
DISPATCH();
+ DO(BNER_F);
+ if (fpr[i.r1] != fpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
DO(BEQR);
if (gpr[i.r1] == gpr[i.r2])
JUMP(i.r0);
@@ -200,16 +276,136 @@ union interp_ret ejit_interp(struct ejit_func *f, size_t argc,
DISPATCH();
+ DO(BEQR_F);
+ if (fpr[i.r1] == fpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGTR);
+ if (gpr[i.r1] > gpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGTR_U);
+ if ((uint64_t)gpr[i.r1] > (uint64_t)gpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
DO(BGTI);
if (gpr[i.r1] > i.o)
JUMP(i.r0);
DISPATCH();
+ DO(BGTI_U);
+ if ((uint64_t)gpr[i.r1] > (uint64_t)i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGTR_F);
+ if (fpr[i.r1] > fpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BLTI);
+ if (gpr[i.r1] < i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BLTI_U);
+ if ((uint64_t)gpr[i.r1] < (uint64_t)i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGER);
+ if (gpr[i.r1] >= gpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGER_U);
+ if ((uint64_t)gpr[i.r1] >= (uint64_t)gpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGEI);
+ if (gpr[i.r1] >= i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGEI_U);
+ if ((uint64_t)gpr[i.r1] >= (uint64_t)i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BGER_F);
+ if (fpr[i.r1] >= fpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BLEI);
+ if (gpr[i.r1] <= i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BLEI_U);
+ if ((uint64_t)gpr[i.r1] <= (uint64_t)i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BLTGTR_F);
+ double f0 = fpr[i.r1];
+ double f1 = fpr[i.r2];
+
+ if (isnan(f0) || isnan(f1))
+ JUMP(++pc);
+
+ if (!(f0 >= f1) || !(f0 <= f1))
+ JUMP(i.r0);
+
+ DISPATCH();
+
DO(JMP);
JUMP(i.r0);
DISPATCH();
+ DO(BMSR);
+ if (gpr[i.r1] & gpr[i.r2])
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BMSI);
+ if (gpr[i.r1] & i.o)
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BMCR);
+ if (!(gpr[i.r1] & gpr[i.r2]))
+ JUMP(i.r0);
+
+ DISPATCH();
+
+ DO(BMCI);
+ if (!(gpr[i.r1] & i.o))
+ JUMP(i.r0);
+
+ DISPATCH();
+
DO(RETVAL);
gpr[i.r0] = retval;
DISPATCH();
diff --git a/tests/andr.c b/tests/andr.c
index e714794..ada0751 100644
--- a/tests/andr.c
+++ b/tests/andr.c
@@ -94,7 +94,7 @@ int main()
== 0x7fffffffffffffff);
assert((uint64_t)ejit_run_func_2(f,
- EJIT_ARG(0xffffffffffffffff, long),
- EJIT_ARG(0xffffffffffffffff, long))
+ EJIT_ARG(0xffffffffffffffff, long),
+ EJIT_ARG(0xffffffffffffffff, long))
== 0xffffffffffffffff);
}
diff --git a/tests/beqi.c b/tests/beqi.c
index 147cd50..ebf149f 100644
--- a/tests/beqi.c
+++ b/tests/beqi.c
@@ -19,8 +19,8 @@ int main()
ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
- assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
- assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 0);
assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
ejit_destroy_func(f);
diff --git a/tests/beqr.c b/tests/beqr.c
index 109b48c..9fc74a6 100644
--- a/tests/beqr.c
+++ b/tests/beqr.c
@@ -20,12 +20,12 @@ int main()
ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
- assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1);
- assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0);
- assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
- assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0);
- assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0);
- assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 1);
ejit_destroy_func(f);
}
diff --git a/tests/beqr_d.c b/tests/beqr_d.c
deleted file mode 100644
index 8d61e6e..0000000
--- a/tests/beqr_d.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_beqr_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 0);
- ASSERT(f(1, 1) == 1);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/beqr_f.c b/tests/beqr_f.c
index 7463ed6..2f12db7 100644
--- a/tests/beqr_f.c
+++ b/tests/beqr_f.c
@@ -1,35 +1,43 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
-
- jit_reloc_t r = jit_beqr_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 0);
- ASSERT(f(1, 1) == 1);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ struct ejit_reloc r = ejit_beqr_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
+
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+
+ ejit_reti(f, 1);
+
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 1);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgei.c b/tests/bgei.c
index e0b8e1a..c6fefc4 100644
--- a/tests/bgei.c
+++ b/tests/bgei.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgei(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bgei(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 1);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 0);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgei_u.c b/tests/bgei_u.c
index d2997ff..eb649a2 100644
--- a/tests/bgei_u.c
+++ b/tests/bgei_u.c
@@ -1,28 +1,25 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgei_u(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bgei_u(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 1);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 1);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
}
diff --git a/tests/bger.c b/tests/bger.c
index 651a9e8..473296b 100644
--- a/tests/bger.c
+++ b/tests/bger.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bger(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bger(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bger_d.c b/tests/bger_d.c
deleted file mode 100644
index 6a9cea3..0000000
--- a/tests/bger_d.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bger_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bger_f.c b/tests/bger_f.c
deleted file mode 100644
index 7c4974f..0000000
--- a/tests/bger_f.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
-
- jit_reloc_t r = jit_bger_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bger_u.c b/tests/bger_u.c
index 05038d5..e720cca 100644
--- a/tests/bger_u.c
+++ b/tests/bger_u.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bger_u(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bger_u(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgti.c b/tests/bgti.c
index 79ea2d4..8e89d52 100644
--- a/tests/bgti.c
+++ b/tests/bgti.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgti(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bgti(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 0);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgti_u.c b/tests/bgti_u.c
index 69325df..8701fa6 100644
--- a/tests/bgti_u.c
+++ b/tests/bgti_u.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgti_u(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bgti_u(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 1);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgtr.c b/tests/bgtr.c
index c6c1fda..ae59e5b 100644
--- a/tests/bgtr.c
+++ b/tests/bgtr.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgtr(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bgtr(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgtr_d.c b/tests/bgtr_d.c
deleted file mode 100644
index aa9b23a..0000000
--- a/tests/bgtr_d.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bgtr_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bgtr_f.c b/tests/bgtr_f.c
index 6245644..0b5b7f4 100644
--- a/tests/bgtr_f.c
+++ b/tests/bgtr_f.c
@@ -1,34 +1,39 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
- jit_reloc_t r = jit_bgtr_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bgtr_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit);
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bgtr_u.c b/tests/bgtr_u.c
index 53373f0..5334825 100644
--- a/tests/bgtr_u.c
+++ b/tests/bgtr_u.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bgtr_u(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bgtr_u(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/blei.c b/tests/blei.c
index 46ce461..3aabad6 100644
--- a/tests/blei.c
+++ b/tests/blei.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_blei(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_blei(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 1);
- ASSERT(f(1) == 0);
- ASSERT(f(-1) == 1);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/blei_u.c b/tests/blei_u.c
index f8ed875..b4fb009 100644
--- a/tests/blei_u.c
+++ b/tests/blei_u.c
@@ -1,28 +1,25 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_blei_u(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_blei_u(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 1);
- ASSERT(f(1) == 0);
- ASSERT(f(-1) == 0);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
}
diff --git a/tests/bler.c b/tests/bler.c
index cf835e0..72582b0 100644
--- a/tests/bler.c
+++ b/tests/bler.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bler(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bler(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bler_d.c b/tests/bler_d.c
deleted file mode 100644
index f67df1a..0000000
--- a/tests/bler_d.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bler_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bler_f.c b/tests/bler_f.c
index ff18190..f3ff780 100644
--- a/tests/bler_f.c
+++ b/tests/bler_f.c
@@ -1,34 +1,39 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
- jit_reloc_t r = jit_bler_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bler_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit);
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 0);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bler_u.c b/tests/bler_u.c
index 87ac322..8bcd8ef 100644
--- a/tests/bler_u.c
+++ b/tests/bler_u.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bler_u(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bler_u(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bltgtr_d.c b/tests/bltgtr_d.c
deleted file mode 100644
index d549d08..0000000
--- a/tests/bltgtr_d.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bltgtr_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
- ASSERT(f(1, 1) == 0);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
- ASSERT(f(0.0/0.0, 0.0/0.0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bltgtr_f.c b/tests/bltgtr_f.c
index 6f4e6ac..32b2a96 100644
--- a/tests/bltgtr_f.c
+++ b/tests/bltgtr_f.c
@@ -1,36 +1,41 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double)),
+ };
- jit_reloc_t r = jit_bltgtr_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bltgtr_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
- ASSERT(f(1, 1) == 0);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
- ASSERT(f(0.0/0.0, 0.0/0.0) == 0);
-}
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 0);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
}
diff --git a/tests/blti.c b/tests/blti.c
index dd9c907..9f7fbcb 100644
--- a/tests/blti.c
+++ b/tests/blti.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_blti(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_blti(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 0);
- ASSERT(f(-1) == 1);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/blti_u.c b/tests/blti_u.c
index 13582c3..ca30e7e 100644
--- a/tests/blti_u.c
+++ b/tests/blti_u.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_blti_u(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_blti_u(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 0);
- ASSERT(f(-1) == 0);
-}
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bltr.c b/tests/bltr.c
index b5c7976..c5b3b87 100644
--- a/tests/bltr.c
+++ b/tests/bltr.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bltr(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bltr(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bltr_d.c b/tests/bltr_d.c
deleted file mode 100644
index d19be55..0000000
--- a/tests/bltr_d.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bltr_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
-
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bltr_f.c b/tests/bltr_f.c
index 35eb77b..e69569a 100644
--- a/tests/bltr_f.c
+++ b/tests/bltr_f.c
@@ -1,34 +1,39 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
- jit_reloc_t r = jit_bltr_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bltr_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 0);
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(long), do_jit);
- ASSERT(f(0, 0.0/0.0) == 0);
- ASSERT(f(0.0/0.0, 0) == 0);
-}
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 0);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bltr_u.c b/tests/bltr_u.c
index d0a9f39..c96cd4d 100644
--- a/tests/bltr_u.c
+++ b/tests/bltr_u.c
@@ -1,31 +1,29 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bltr_u(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bltr_u(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 1);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bmci.c b/tests/bmci.c
index e8310e0..75f235d 100644
--- a/tests/bmci.c
+++ b/tests/bmci.c
@@ -1,29 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bmci(j, JIT_R0, 1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bmci(f, EJIT_GPR(0), 1);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0) == 1);
- ASSERT(f(1) == 0);
- ASSERT(f(-1) == 0);
- ASSERT(f(2) == 1);
-}
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG( 2, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bmcr.c b/tests/bmcr.c
index 3dbc98a..731b9a6 100644
--- a/tests/bmcr.c
+++ b/tests/bmcr.c
@@ -1,35 +1,33 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bmcr(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bmcr(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 1);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
- ASSERT(f(1, 1) == 0);
- ASSERT(f(1, -1) == 0);
- ASSERT(f(-1, 1) == 0);
- ASSERT(f(-1, -1) == 0);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG(-1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(-1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bmsi.c b/tests/bmsi.c
index aaad68a..f189218 100644
--- a/tests/bmsi.c
+++ b/tests/bmsi.c
@@ -1,29 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bmsi(j, JIT_R0, 1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
+ struct ejit_reloc r = ejit_bmsi(f, EJIT_GPR(0), 1);
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 1);
- ASSERT(f(2) == 0);
-}
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG( 2, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bmsr.c b/tests/bmsr.c
index d471fdf..b4e344e 100644
--- a/tests/bmsr.c
+++ b/tests/bmsr.c
@@ -1,35 +1,33 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bmsr(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+ struct ejit_reloc r = ejit_bmsr(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 0);
- ASSERT(f(1, 0) == 0);
- ASSERT(f(-1, 0) == 0);
- ASSERT(f(0, -1) == 0);
- ASSERT(f(1, 1) == 1);
- ASSERT(f(1, -1) == 1);
- ASSERT(f(-1, 1) == 1);
- ASSERT(f(-1, -1) == 1);
-}
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG(-1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bnei.c b/tests/bnei.c
index 3e9e376..7ac32a6 100644
--- a/tests/bnei.c
+++ b/tests/bnei.c
@@ -1,28 +1,27 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_1(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0));
+ struct ejit_operand operands[1] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bnei(j, JIT_R0, 0);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 1, operands);
- jit_word_t (*f)(jit_word_t) = jit_end(j, NULL);
+ struct ejit_reloc r = ejit_bnei(f, EJIT_GPR(0), 0);
+ ejit_reti(f, 0);
- ASSERT(f(0) == 0);
- ASSERT(f(1) == 1);
- ASSERT(f(-1) == 1);
-}
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 1, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_1(f, EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_1(f, EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_1(f, EJIT_ARG(-1, long)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bner.c b/tests/bner.c
index d9b2305..7d96f95 100644
--- a/tests/bner.c
+++ b/tests/bner.c
@@ -1,31 +1,31 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R0),
- jit_operand_gpr (JIT_OPERAND_ABI_WORD, JIT_R1));
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long)),
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
- jit_reloc_t r = jit_bner(j, JIT_R0, JIT_R1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
- jit_word_t (*f)(jit_word_t, jit_word_t) = jit_end(j, NULL);
+ struct ejit_reloc r = ejit_bner(f, EJIT_GPR(0), EJIT_GPR(1));
+ ejit_reti(f, 0);
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
-}
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+ ejit_reti(f, 1);
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 0, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG( 1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(-1, long), EJIT_ARG( 0, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 0, long), EJIT_ARG(-1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG( 1, long), EJIT_ARG( 1, long)) == 0);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/bner_d.c b/tests/bner_d.c
deleted file mode 100644
index b45deed..0000000
--- a/tests/bner_d.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "test.h"
-
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
-{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_DOUBLE, JIT_F1));
-
- jit_reloc_t r = jit_bner_d(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(double, double) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
- ASSERT(f(1, 1) == 0);
-
- ASSERT(f(0, 0.0/0.0) == 1);
- ASSERT(f(0.0/0.0, 0) == 1);
- ASSERT(f(0.0/0.0, 0.0/0.0) == 1);
-}
-
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
-}
diff --git a/tests/bner_f.c b/tests/bner_f.c
index f57bbc4..5ac83bd 100644
--- a/tests/bner_f.c
+++ b/tests/bner_f.c
@@ -1,36 +1,57 @@
-#include "test.h"
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
-static void
-run_test(jit_state_t *j, uint8_t *arena_base, size_t arena_size)
+int main()
{
- jit_begin(j, arena_base, arena_size);
- size_t align = jit_enter_jit_abi(j, 0, 0, 0);
- jit_load_args_2(j, jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F0),
- jit_operand_fpr (JIT_OPERAND_ABI_FLOAT, JIT_F1));
-
- jit_reloc_t r = jit_bner_f(j, JIT_F0, JIT_F1);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 0);
- jit_patch_here(j, r);
- jit_leave_jit_abi(j, 0, 0, align);
- jit_reti(j, 1);
-
- jit_word_t (*f)(float, float) = jit_end(j, NULL);
-
- ASSERT(f(0, 0) == 0);
- ASSERT(f(0, 1) == 1);
- ASSERT(f(1, 0) == 1);
- ASSERT(f(-1, 0) == 1);
- ASSERT(f(0, -1) == 1);
- ASSERT(f(1, 1) == 0);
-
- ASSERT(f(0, 0.0/0.0) == 1);
- ASSERT(f(0.0/0.0, 0) == 1);
- ASSERT(f(0.0/0.0, 0.0/0.0) == 1);
-}
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double)),
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
-int
-main (int argc, char *argv[])
-{
- return main_helper(argc, argv, run_test);
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ struct ejit_reloc r = ejit_bner_f(f, EJIT_FPR(0), EJIT_FPR(1));
+ ejit_reti(f, 0);
+
+ struct ejit_label l = ejit_label(f);
+ ejit_patch(f, r, l);
+
+ ejit_reti(f, 1);
+
+ ejit_select_compile_func(f, 0, 2, EJIT_USE64(double), do_jit);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0, double),
+ EJIT_ARG(0, double)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(-1, double),
+ EJIT_ARG(0, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0, double),
+ EJIT_ARG(-1, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0, double),
+ EJIT_ARG(0.0/0.0, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0.0/0.0, double),
+ EJIT_ARG(0, double)) == 1);
+
+ ejit_destroy_func(f);
}
diff --git a/tests/eqr.c b/tests/eqr.c
new file mode 100644
index 0000000..7f33b19
--- /dev/null
+++ b/tests/eqr.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_eqr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x7ffffffffffffff0, long)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x6fffffffffffffff, long),
+ EJIT_ARG(0x7fffffffffffffff, long)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/eqr_f.c b/tests/eqr_f.c
new file mode 100644
index 0000000..7afe002
--- /dev/null
+++ b/tests/eqr_f.c
@@ -0,0 +1,32 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_eqr_f(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, double),
+ EJIT_ARG(0x7ffffffffffffff0, double)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x6fffffffffffffff, double),
+ EJIT_ARG(0x7fffffffffffffff, double)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ger.c b/tests/ger.c
new file mode 100644
index 0000000..195d4c1
--- /dev/null
+++ b/tests/ger.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_gtr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, long),
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x6fffffffffffffff, long)) == 1);
+ ejit_destroy_func(f);
+}
diff --git a/tests/gtr.c b/tests/gtr.c
new file mode 100644
index 0000000..34dfd39
--- /dev/null
+++ b/tests/gtr.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_gtr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, long), EJIT_ARG(1, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, long),
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 0);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x6fffffffffffffff, long)) == 1);
+ ejit_destroy_func(f);
+}
diff --git a/tests/gtr_f.c b/tests/gtr_f.c
new file mode 100644
index 0000000..4c07bfe
--- /dev/null
+++ b/tests/gtr_f.c
@@ -0,0 +1,25 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_gtr(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(0, double),
+ EJIT_ARG(1, double)) == 1);
+
+ ejit_destroy_func(f);
+}
diff --git a/tests/ler.c b/tests/ler.c
new file mode 100644
index 0000000..0bd6e26
--- /dev/null
+++ b/tests/ler.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_ler(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, long),
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x6fffffffffffffff, long)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ler_f.c b/tests/ler_f.c
new file mode 100644
index 0000000..00fe9ef
--- /dev/null
+++ b/tests/ler_f.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(double), 2, operands);
+
+ ejit_ler(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 1);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, long),
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x6fffffffffffffff, long)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ltr.c b/tests/ltr.c
new file mode 100644
index 0000000..2deb6ae
--- /dev/null
+++ b/tests/ltr.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_ltr(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, long),
+ EJIT_ARG(0x0ffffffffffffff0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x6fffffffffffffff, long)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ltr_f.c b/tests/ltr_f.c
new file mode 100644
index 0000000..5e5a98b
--- /dev/null
+++ b/tests/ltr_f.c
@@ -0,0 +1,32 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_FPR(0, EJIT_TYPE(double))
+ EJIT_OPERAND_FPR(1, EJIT_TYPE(double))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_ltr_f(f, EJIT_GPR(0), EJIT_FPR(0), EJIT_FPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 1, 2, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(1, double)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, double),
+ EJIT_ARG(0, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x0fffffffffffffff, double),
+ EJIT_ARG(0x0ffffffffffffff0, double)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, double),
+ EJIT_ARG(0x6fffffffffffffff, double)) == 0);
+ ejit_destroy_func(f);
+}
diff --git a/tests/ner.c b/tests/ner.c
new file mode 100644
index 0000000..ca615d0
--- /dev/null
+++ b/tests/ner.c
@@ -0,0 +1,30 @@
+#include <ejit/ejit.h>
+#include <assert.h>
+#include "do_jit.h"
+
+int main()
+{
+ struct ejit_operand operands[2] = {
+ EJIT_OPERAND_GPR(0, EJIT_TYPE(long))
+ EJIT_OPERAND_GPR(1, EJIT_TYPE(long))
+ };
+
+ struct ejit_func *f = ejit_create_func(EJIT_TYPE(long), 2, operands);
+
+ ejit_ner(f, EJIT_GPR(0), EJIT_GPR(0), EJIT_GPR(1));
+ ejit_retr(f, EJIT_GPR(0));
+
+ ejit_select_compile_func(f, 2, 0, EJIT_USE64(long), do_jit);
+
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(1, long)) == 0);
+ assert(ejit_run_func_2(f, EJIT_ARG(1, long), EJIT_ARG(0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x7fffffffffffffff, long),
+ EJIT_ARG(0x7ffffffffffffff0, long)) == 1);
+
+ assert(ejit_run_func_2(f,
+ EJIT_ARG(0x6fffffffffffffff, long),
+ EJIT_ARG(0x7fffffffffffffff, long)) == 1);
+ ejit_destroy_func(f);
+}