From 4269b6d3d0aeff1cf1bae3eac5f40cceb75576e0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 26 Aug 2023 17:13:56 +0300 Subject: apply fixes to make jit-comparison easier --- lib/imm.h | 6 ++++++ lib/imm_decls.h | 1 + lib/imm_defns.h | 8 ++++++++ lib/op_decls.h | 3 +++ lib/op_defns.h | 21 +++++++++++++++++++++ 5 files changed, 39 insertions(+) (limited to 'lib') diff --git a/lib/imm.h b/lib/imm.h index 1ee7e1e..97580f4 100644 --- a/lib/imm.h +++ b/lib/imm.h @@ -40,4 +40,10 @@ unsigned char gen_liy[] = { 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned int gen_liy_len = 20; +unsigned char gen_bani[] = { + 0x48, 0x85, 0xf6, 0x48, 0x8d, 0x05, 0x12, 0x00, 0x00, 0x00, 0x48, 0x0f, + 0x45, 0x05, 0x02, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x0f, 0x1f, 0x84, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; +unsigned int gen_bani_len = 28; #endif /* COPYJIT_OPS_H */ diff --git a/lib/imm_decls.h b/lib/imm_decls.h index 5a2f840..f520e1f 100644 --- a/lib/imm_decls.h +++ b/lib/imm_decls.h @@ -8,4 +8,5 @@ void *compile_lia(ctx_t *ctx, unsigned long i); void *compile_lio(ctx_t *ctx, unsigned long i); void *compile_lix(ctx_t *ctx, unsigned long i); void *compile_liy(ctx_t *ctx, unsigned long i); +void *compile_bani(ctx_t *ctx, unsigned long i); #endif /* COPYJIT_DECLS_H */ diff --git a/lib/imm_defns.h b/lib/imm_defns.h index 6b9c52a..f3b8baa 100644 --- a/lib/imm_defns.h +++ b/lib/imm_defns.h @@ -64,4 +64,12 @@ void *compile_liy(ctx_t *ctx, unsigned long i) ctx->pc += gen_liy_len; return pc; } +void *compile_bani(ctx_t *ctx, unsigned long i) + { + void *pc = ctx->pc; + memcpy(ctx->pc, gen_bani, gen_bani_len); + *(unsigned long *)(ctx->pc + gen_bani_len - 8) = i; + ctx->pc += gen_bani_len; + return pc; + } #endif /* COPYJIT_DEFNS_H */ diff --git a/lib/op_decls.h b/lib/op_decls.h index 147a6ac..c7eb3fb 100644 --- a/lib/op_decls.h +++ b/lib/op_decls.h @@ -14,6 +14,9 @@ void *compile_movxa(ctx_t *ctx); void *compile_movxo(ctx_t *ctx); void *compile_movya(ctx_t *ctx); void *compile_movyo(ctx_t *ctx); +void *compile_peeko(ctx_t *ctx); +void *compile_popo(ctx_t *ctx); +void *compile_pusha(ctx_t *ctx); void *compile_sub(ctx_t *ctx); void *compile_subxo(ctx_t *ctx); void *compile_subyo(ctx_t *ctx); diff --git a/lib/op_defns.h b/lib/op_defns.h index 5b9cdb2..f930abe 100644 --- a/lib/op_defns.h +++ b/lib/op_defns.h @@ -98,6 +98,27 @@ void *compile_movyo(ctx_t *ctx) ctx->pc += gen_movyo_len; return pc; } +void *compile_peeko(ctx_t *ctx) + { + void *pc = ctx->pc; + memcpy(pc, gen_peeko, gen_peeko_len); + ctx->pc += gen_peeko_len; + return pc; + } +void *compile_popo(ctx_t *ctx) + { + void *pc = ctx->pc; + memcpy(pc, gen_popo, gen_popo_len); + ctx->pc += gen_popo_len; + return pc; + } +void *compile_pusha(ctx_t *ctx) + { + void *pc = ctx->pc; + memcpy(pc, gen_pusha, gen_pusha_len); + ctx->pc += gen_pusha_len; + return pc; + } void *compile_sub(ctx_t *ctx) { void *pc = ctx->pc; -- cgit v1.3