From 7d0bb148488450235145a327869057604be31eb0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 20 Sep 2006 04:14:53 +0000 Subject: [PATCH] added some more macro opcodes --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4077 --- sourcepawn/vm/jit/x86/jit_x86.cpp | 65 +++++++++++++++++++++++++- sourcepawn/vm/jit/x86/opcode_helpers.h | 10 ++-- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/sourcepawn/vm/jit/x86/jit_x86.cpp b/sourcepawn/vm/jit/x86/jit_x86.cpp index bbffe74c..4f178a64 100644 --- a/sourcepawn/vm/jit/x86/jit_x86.cpp +++ b/sourcepawn/vm/jit/x86/jit_x86.cpp @@ -963,6 +963,46 @@ inline void WriteOp_Pop_Heap_Pri(JitWriter *jit) IA32_Mov_Reg_Rm_Disp_Reg(jit, AMX_REG_PRI, AMX_REG_DAT, AMX_REG_TMP, NOSCALE); } +inline void WriteOp_Load_Both(JitWriter *jit) +{ + WriteOp_Const_Pri(jit); + WriteOp_Const_Alt(jit); +} + +inline void WriteOp_Load_S_Both(JitWriter *jit) +{ + WriteOp_Load_S_Pri(jit); + WriteOp_Load_S_Alt(jit); +} + +inline void WriteOp_Const(JitWriter *jit) +{ + //mov [edi+], + cell_t addr = jit->read_cell(); + cell_t val = jit->read_cell(); + if (addr < SCHAR_MAX && addr > SCHAR_MIN) + { + IA32_Mov_Rm_Imm32_Disp8(jit, AMX_REG_DAT, val, (jit_int8_t)addr); + } else { + IA32_Mov_Rm_Imm32_Disp32(jit, AMX_REG_DAT, val, addr); + } +} + +inline void WriteOp_Const_S(JitWriter *jit) +{ + //mov [ebx+], + cell_t offs = jit->read_cell(); + cell_t val = jit->read_cell(); + + if (offs < SCHAR_MAX && offs > SCHAR_MIN) + { + IA32_Mov_Rm_Imm32_Disp8(jit, AMX_REG_FRM, val, (jit_int8_t)offs); + } else { + IA32_Mov_Rm_Imm32_Disp32(jit, AMX_REG_FRM, val, offs); + } +} + + /************************************************* ************************************************* * JIT PROPER ************************************ @@ -1591,10 +1631,31 @@ IPluginContext *JITX86::CompileToContext(ICompilation *co, int *err) WriteOp_Push_Alt(jit); break; } + case OP_LOAD_BOTH: + { + WriteOp_Load_Both(jit); + break; + } + case OP_LOAD_S_BOTH: + { + WriteOp_Load_S_Both(jit); + break; + } + case OP_CONST: + { + WriteOp_Const(jit); + break; + } + case OP_CONST_S: + { + WriteOp_Const_S(jit); + break; + } default: { - /* :TODO: error! */ - break; + AbortCompilation(co); + *err = SP_ERR_INVALID_INSTRUCTION; + return NULL; } } } diff --git a/sourcepawn/vm/jit/x86/opcode_helpers.h b/sourcepawn/vm/jit/x86/opcode_helpers.h index e21c4d6a..bfd86db9 100644 --- a/sourcepawn/vm/jit/x86/opcode_helpers.h +++ b/sourcepawn/vm/jit/x86/opcode_helpers.h @@ -143,7 +143,7 @@ typedef enum OP_CASETBL, OP_SWAP_PRI, //DONE OP_SWAP_ALT, //DONE - OP_PUSH_ADR, + OP_PUSH_ADR, //DONE OP_NOP, //DONE OP_SYSREQ_N, OP_SYMTAG, //DEPRECATED @@ -164,10 +164,10 @@ typedef enum OP_PUSH5, //DONE OP_PUSH5_S, //DONE OP_PUSH5_ADR, //DONE - OP_LOAD_BOTH, - OP_LOAD_S_BOTH, - OP_CONST, - OP_CONST_S, + OP_LOAD_BOTH, //DONE + OP_LOAD_S_BOTH, //DONE + OP_CONST, //DONE + OP_CONST_S, //DONE /* ----- */ OP_SYSREQ_D, //UNSUPPORTED OP_SYSREQ_ND, //UNSUPPORTED