From 23068aad8c3a2891c582c12050234f2b75716fc6 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Wed, 28 Dec 2005 14:11:38 +0000 Subject: [PATCH] implement JIT_OP_MEMMOVE --- ChangeLog | 5 +++++ jit/jit-rules-x86.sel | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 706bd42..3032193 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-12-28 Aleksey Demakov + + * jit/jit-rules-x86.sel: implement JIT_OP_MEMMOVE rule. Get rid of + compiler warnings in JIT_OP_MEMSET. + 2005-12-24 Avinash Atreya * dpas/dpas-parser.y: implement array expressions (committed by Aleksey diff --git a/jit/jit-rules-x86.sel b/jit/jit-rules-x86.sel index 9628931..a8893e9 100644 --- a/jit/jit-rules-x86.sel +++ b/jit/jit-rules-x86.sel @@ -3146,8 +3146,37 @@ JIT_OP_MEMCPY: manual JIT_OP_MEMMOVE: manual [] -> { - /* TODO */ - TODO(); + unsigned char *inst; + int reg, reg2, reg3; + + reg = _jit_regs_load_value + (gen, insn->dest, 0, + (insn->flags & (JIT_INSN_DEST_NEXT_USE | JIT_INSN_DEST_LIVE))); + reg2 = _jit_regs_load_value + (gen, insn->value1, 0, + (insn->flags & (JIT_INSN_VALUE1_NEXT_USE | JIT_INSN_VALUE1_LIVE))); + reg3 = _jit_regs_load_value + (gen, insn->value2, 0, + (insn->flags & (JIT_INSN_VALUE2_NEXT_USE | JIT_INSN_VALUE2_LIVE))); + + /* A function call may destroy EAX,EBX,ECX,EDX registers. */ + /* TODO: do not spill ESI and EDI. */ + _jit_regs_spill_all(gen); + + inst = gen->posn.ptr; + if(!jit_cache_check_for_n(&(gen->posn), 32)) + { + jit_cache_mark_full(&(gen->posn)); + return; + } + + x86_push_reg(inst, _jit_reg_info[reg3].cpu_reg); + x86_push_reg(inst, _jit_reg_info[reg2].cpu_reg); + x86_push_reg(inst, _jit_reg_info[reg].cpu_reg); + x86_call_code(inst, jit_memmove); + x86_alu_reg_imm(inst, X86_ADD, X86_ESP, 3 * sizeof(void *)); + + gen->posn.ptr = inst; } JIT_OP_MEMSET: manual @@ -3162,12 +3191,14 @@ JIT_OP_MEMSET: manual } else if(insn->value2->is_constant && insn->value2->address <= 32) { - save_reg3 = 0; - reg = _jit_regs_load_value (gen, insn->dest, 0, (insn->flags & (JIT_INSN_DEST_NEXT_USE | JIT_INSN_DEST_LIVE))); + reg2 = -1; + reg3 = -1; + save_reg3 = 0; + if(insn->value1->is_constant) { inst = gen->posn.ptr; @@ -3309,6 +3340,9 @@ JIT_OP_MEMSET: manual reg3 = _jit_regs_load_value (gen, insn->value2, 0, (insn->flags & (JIT_INSN_VALUE2_NEXT_USE | JIT_INSN_VALUE2_LIVE))); + + /* A function call may destroy EAX,EBX,ECX,EDX registers. */ + /* TODO: do not spill ESI and EDI. */ _jit_regs_spill_all(gen); inst = gen->posn.ptr;