diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-14 14:46:40 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-14 14:46:40 +0300 |
commit | dcca95ebeef7ad047b437c7e65bcd2d33784cae4 (patch) | |
tree | 39a3f9834df0dc7c27d080efef15c22889730dc5 /src/ejit.c | |
parent | 215ac4569f897b10215248c4caa3191919a555df (diff) | |
download | ejit-dcca95ebeef7ad047b437c7e65bcd2d33784cae4.tar.gz ejit-dcca95ebeef7ad047b437c7e65bcd2d33784cae4.zip |
add float + double instead of just double
Diffstat (limited to 'src/ejit.c')
-rw-r--r-- | src/ejit.c | 158 |
1 files changed, 148 insertions, 10 deletions
@@ -27,6 +27,13 @@ static void emit_insn_p(struct ejit_func *f, enum ejit_opcode op, size_t r0, } static void emit_insn_f(struct ejit_func *f, enum ejit_opcode op, size_t r0, + size_t r1, float d) +{ + struct ejit_insn i = {.op = op, .r0 = r0, .r1 = r1, .f = d}; + vec_append(&f->insns, &i); +} + +static void emit_insn_d(struct ejit_func *f, enum ejit_opcode op, size_t r0, size_t r1, double d) { struct ejit_insn i = {.op = op, .r0 = r0, .r1 = r1, .d = d}; @@ -484,16 +491,26 @@ void ejit_retr_f(struct ejit_func *s, struct ejit_fpr r0) emit_insn_r(s, RETR_F, r0.f, 0, 0); } +void ejit_retr_d(struct ejit_func *s, struct ejit_fpr r0) +{ + emit_insn_r(s, RETR_D, r0.f, 0, 0); +} + void ejit_reti(struct ejit_func *s, int64_t i) { emit_insn_i(s, RETI, 0, 0, i); } -void ejit_reti_f(struct ejit_func *s, double f) +void ejit_reti_f(struct ejit_func *s, float f) { emit_insn_f(s, RETI_F, 0, 0, f); } +void ejit_reti_d(struct ejit_func *s, double f) +{ + emit_insn_d(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); @@ -536,6 +553,12 @@ void ejit_addr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, emit_insn_r(s, ADDR_F, r0.f, r1.f, r2.f); } +void ejit_addr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, ADDR_D, r0.f, r1.f, r2.f); +} + void ejit_addi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, int64_t o) { @@ -547,6 +570,11 @@ void ejit_absr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) emit_insn_i(s, ABSR_F, r0.f, r1.f, 0); } +void ejit_absr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) +{ + emit_insn_i(s, ABSR_D, r0.f, r1.f, 0); +} + void ejit_subr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { @@ -559,6 +587,12 @@ void ejit_subr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, emit_insn_r(s, SUBR_F, r0.f, r1.f, r2.f); } +void ejit_subr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, SUBR_D, r0.f, r1.f, r2.f); +} + void ejit_subi(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, long o) { @@ -577,6 +611,12 @@ void ejit_mulr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, emit_insn_r(s, MULR_F, r0.f, r1.f, r2.f); } +void ejit_mulr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, MULR_D, r0.f, r1.f, r2.f); +} + void ejit_divr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { @@ -595,6 +635,12 @@ 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_divr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, DIVR_D, r0.f, r1.f, r2.f); +} + void ejit_remr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { @@ -694,16 +740,26 @@ void ejit_negr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) emit_insn_i(s, NEGR_F, r0.f, r1.f, 0); } +void ejit_negr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) +{ + emit_insn_i(s, NEGR_D, r0.f, r1.f, 0); +} + void ejit_movi(struct ejit_func *s, struct ejit_gpr r0, int64_t o) { emit_insn_i(s, MOVI, r0.r, 0, o); } -void ejit_movi_f(struct ejit_func *s, struct ejit_fpr r0, double o) +void ejit_movi_f(struct ejit_func *s, struct ejit_fpr r0, float o) { emit_insn_f(s, MOVI_F, r0.f, 0, o); } +void ejit_movi_d(struct ejit_func *s, struct ejit_fpr r0, double o) +{ + emit_insn_d(s, MOVI_D, r0.f, 0, o); +} + void ejit_movr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1) { if (r0.r == r1.r) @@ -720,6 +776,14 @@ void ejit_movr_f(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) emit_insn_i(s, MOVR_F, r0.f, r1.f, 0); } +void ejit_movr_d(struct ejit_func *s, struct ejit_fpr r0, struct ejit_fpr r1) +{ + if (r0.f == r1.f) + return; + + emit_insn_i(s, MOVR_D, r0.f, r1.f, 0); +} + void ejit_eqr(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { @@ -732,6 +796,12 @@ void ejit_eqr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, emit_insn_r(s, EQR_F, r0.r, r1.f, r2.f); } +void ejit_eqr_d(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, EQR_D, r0.r, r1.f, r2.f); +} + void ejit_ner(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1, struct ejit_gpr r2) { @@ -744,6 +814,12 @@ void ejit_ner_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, emit_insn_r(s, NER_F, r0.r, r1.f, r2.f); } +void ejit_ner_d(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, NER_D, 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) { @@ -762,6 +838,12 @@ void ejit_gtr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, emit_insn_r(s, GTR_F, r0.r, r1.f, r2.f); } +void ejit_gtr_d(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, GTR_D, 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) { @@ -780,6 +862,12 @@ void ejit_ltr_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, emit_insn_r(s, GTR_F, r0.r, r2.f, r1.f); } +void ejit_ltr_d(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, GTR_D, 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) { @@ -816,6 +904,12 @@ void ejit_ler_f(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, emit_insn_r(s, GER_F, r0.r, r2.f, r1.f); } +void ejit_ler_d(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1, + struct ejit_fpr r2) +{ + emit_insn_r(s, GER_D, r0.r, r2.f, r1.f); +} + void ejit_truncr_d_32(struct ejit_func *s, struct ejit_gpr r0, struct ejit_fpr r1) { @@ -828,6 +922,18 @@ void ejit_truncr_d_64(struct ejit_func *s, struct ejit_gpr r0, emit_insn_i(s, TRUNCR_D_64, r0.r, r1.f, 0); } +void ejit_truncr_f_32(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_fpr r1) +{ + emit_insn_i(s, TRUNCR_F_32, r0.r, r1.f, 0); +} + +void ejit_truncr_f_64(struct ejit_func *s, struct ejit_gpr r0, + struct ejit_fpr r1) +{ + emit_insn_i(s, TRUNCR_F_64, r0.r, r1.f, 0); +} + struct ejit_reloc ejit_bner(struct ejit_func *s, struct ejit_gpr r0, struct ejit_gpr r1) { @@ -851,6 +957,14 @@ struct ejit_reloc ejit_bner_f(struct ejit_func *s, struct ejit_fpr r0, return (struct ejit_reloc){.insn = addr}; } +struct ejit_reloc ejit_bner_d(struct ejit_func *s, struct ejit_fpr r0, + struct ejit_fpr r1) +{ + size_t addr = vec_len(&s->insns); + emit_insn_r(s, BNER_D, 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) { @@ -874,6 +988,14 @@ struct ejit_reloc ejit_beqr_f(struct ejit_func *s, struct ejit_fpr r0, return (struct ejit_reloc){.insn = addr}; } +struct ejit_reloc ejit_beqr_d(struct ejit_func *s, struct ejit_fpr r0, + struct ejit_fpr r1) +{ + size_t addr = vec_len(&s->insns); + emit_insn_r(s, BEQR_D, 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) { @@ -937,6 +1059,14 @@ struct ejit_reloc ejit_bler_f(struct ejit_func *s, struct ejit_fpr r0, return (struct ejit_reloc){.insn = addr}; } +struct ejit_reloc ejit_bler_d(struct ejit_func *s, struct ejit_fpr r0, + struct ejit_fpr r1) +{ + size_t addr = vec_len(&s->insns); + emit_insn_r(s, BGER_D, 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); @@ -991,6 +1121,14 @@ struct ejit_reloc ejit_bgtr_f(struct ejit_func *s, struct ejit_fpr r0, return (struct ejit_reloc){.insn = addr}; } +struct ejit_reloc ejit_bgtr_d(struct ejit_func *s, struct ejit_fpr r0, + struct ejit_fpr r1) +{ + size_t addr = vec_len(&s->insns); + emit_insn_r(s, BGTR_D, 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) { @@ -1015,26 +1153,26 @@ struct ejit_reloc ejit_bltr_f(struct ejit_func *s, struct ejit_fpr r0, return (struct ejit_reloc){.insn = addr}; } -struct ejit_reloc ejit_blti(struct ejit_func *s, struct ejit_gpr r0, int64_t o) +struct ejit_reloc ejit_bltr_d(struct ejit_func *s, struct ejit_fpr r0, + struct ejit_fpr r1) { size_t addr = vec_len(&s->insns); - emit_insn_i(s, BLTI, 0, r0.r, o); + emit_insn_r(s, BGTR_D, 0, r1.f, r0.f); return (struct ejit_reloc){.insn = addr}; } -struct ejit_reloc ejit_blti_u(struct ejit_func *s, struct ejit_gpr r0, - int64_t o) +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_U, 0, r0.r, o); + emit_insn_i(s, BLTI, 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) +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_r(s, BLTGTR_F, 0, r0.f, r1.f); + emit_insn_i(s, BLTI_U, 0, r0.r, o); return (struct ejit_reloc){.insn = addr}; } |