2006-09-20 04:56:20 +02:00
|
|
|
#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
|
|
|
|
#define _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
|
|
|
|
|
|
|
|
#include "..\jit_helpers.h"
|
|
|
|
|
2006-09-20 09:07:49 +02:00
|
|
|
/**
|
|
|
|
* This outputs the execution function for a plugin.
|
|
|
|
* It also returns the 'return' offset, which is used for
|
|
|
|
* breaking out of the JIT during runtime.
|
|
|
|
*/
|
2006-09-20 10:44:21 +02:00
|
|
|
jitoffs_t Write_Execute_Function(JitWriter *jit);
|
|
|
|
|
|
|
|
/**
|
2006-10-10 03:55:08 +02:00
|
|
|
* Writes the Sysreq.n opcode as a function call.
|
2006-09-20 10:44:21 +02:00
|
|
|
*/
|
2006-10-10 03:55:08 +02:00
|
|
|
void WriteOp_Sysreq_N_Function(JitWriter *jit);
|
2006-09-20 10:44:21 +02:00
|
|
|
|
|
|
|
/**
|
2006-10-10 03:55:08 +02:00
|
|
|
* Generates code to set an error state in the VM and return.
|
|
|
|
* This is used for generating the error set points in the VM.
|
2006-10-12 01:47:04 +02:00
|
|
|
* GetError writes the error from the context. SetError hardcodes.
|
2006-09-20 10:44:21 +02:00
|
|
|
*/
|
2006-10-12 01:47:04 +02:00
|
|
|
void Write_GetError(JitWriter *jit);
|
|
|
|
void Write_SetError(JitWriter *jit, int error);
|
2006-09-20 09:07:49 +02:00
|
|
|
|
2006-09-20 23:23:48 +02:00
|
|
|
/**
|
2006-10-10 03:55:08 +02:00
|
|
|
* Checks the stacks for min and low errors.
|
|
|
|
* :TODO: Should a variation of this go in the pushN opcodes?
|
2006-09-20 23:23:48 +02:00
|
|
|
*/
|
2006-10-10 03:55:08 +02:00
|
|
|
void Write_CheckStack_Min(JitWriter *jit);
|
|
|
|
void Write_CheckStack_Low(JitWriter *jit);
|
2006-09-20 23:23:48 +02:00
|
|
|
|
2006-10-10 03:55:08 +02:00
|
|
|
/**
|
|
|
|
* Checks the heap for min and low errors.
|
2006-09-21 01:33:40 +02:00
|
|
|
*/
|
2006-10-10 03:55:08 +02:00
|
|
|
void Write_CheckHeap_Min(JitWriter *jit);
|
|
|
|
void Write_CheckHeap_Low(JitWriter *jit);
|
2006-09-21 04:58:59 +02:00
|
|
|
|
2006-09-21 00:12:55 +02:00
|
|
|
/**
|
2006-10-10 03:55:08 +02:00
|
|
|
* Verifies an address by register. The address must reside
|
|
|
|
* between DAT and HP and SP and STP.
|
2006-09-21 04:58:59 +02:00
|
|
|
*/
|
2006-10-10 03:55:08 +02:00
|
|
|
void Write_Check_VerifyAddr(JitWriter *jit, jit_uint8_t reg);
|
2006-09-21 00:12:55 +02:00
|
|
|
|
2006-09-21 04:58:59 +02:00
|
|
|
/**
|
2006-10-10 03:55:08 +02:00
|
|
|
* Checks for division by zero.
|
2006-09-21 04:58:59 +02:00
|
|
|
*/
|
2006-10-10 03:55:08 +02:00
|
|
|
void Write_Check_DivZero(JitWriter *jit, jit_uint8_t reg);
|
2006-09-20 23:23:48 +02:00
|
|
|
|
2006-09-21 07:04:51 +02:00
|
|
|
/**
|
|
|
|
* Writes the break debug function.
|
|
|
|
*/
|
|
|
|
void Write_BreakDebug(JitWriter *jit);
|
|
|
|
|
2006-09-20 09:07:49 +02:00
|
|
|
/**
|
|
|
|
* These are for writing the PushN opcodes.
|
|
|
|
*/
|
2006-09-20 04:56:20 +02:00
|
|
|
void Macro_PushN_Addr(JitWriter *jit, int i);
|
|
|
|
void Macro_PushN_S(JitWriter *jit, int i);
|
|
|
|
void Macro_PushN_C(JitWriter *jit, int i);
|
|
|
|
void Macro_PushN(JitWriter *jit, int i);
|
|
|
|
|
2006-10-10 03:55:08 +02:00
|
|
|
/**
|
|
|
|
* Legend for Statuses:
|
|
|
|
* ****** *** ********
|
|
|
|
* DONE -> code generation is done
|
|
|
|
* !GEN -> code generation is deliberate skipped because:
|
|
|
|
* (default): compiler does not generate
|
|
|
|
* DEPRECATED: this feature no longer exists/supported
|
|
|
|
* UNSUPPORTED: this opcode is not supported
|
|
|
|
* TODO: done in case needed
|
|
|
|
* VERIFIED -> code generation is checked as run-time working. prefixes:
|
|
|
|
* ! errors are not checked yet.
|
|
|
|
* - non-inline errors are not checked yet.
|
|
|
|
* ~ assumed checked because of related variation, but not actually checked
|
|
|
|
*/
|
|
|
|
|
2006-09-20 04:56:20 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
OP_NONE, /* invalid opcode */
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_LOAD_PRI, //!VERIFIED
|
|
|
|
OP_LOAD_ALT, //~!VERIFIED (load.pri)
|
|
|
|
OP_LOAD_S_PRI, //VERIFIED
|
|
|
|
OP_LOAD_S_ALT, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_LREF_PRI, // !GEN :TODO: we will need this for dynarrays
|
|
|
|
OP_LREF_ALT, // !GEN :TODO: we will need this for dynarrays
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_LREF_S_PRI, //VERIFIED
|
|
|
|
OP_LREF_S_ALT, //~VERIFIED (lref.s.pri)
|
|
|
|
OP_LOAD_I, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_LODB_I, // !GEN :TODO: - only used for pack access - drop support in compiler first
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_CONST_PRI, //VERIFIED
|
|
|
|
OP_CONST_ALT, //~VERIFIED (const.pri)
|
|
|
|
OP_ADDR_PRI, //VERIFIED
|
|
|
|
OP_ADDR_ALT, //VERIFIED
|
|
|
|
OP_STOR_PRI, //VERIFIED
|
|
|
|
OP_STOR_ALT, //~VERIFIED (stor.pri)
|
|
|
|
OP_STOR_S_PRI, //VERIFIED
|
|
|
|
OP_STOR_S_ALT, //~VERIFIED (stor.s.pri)
|
|
|
|
OP_SREF_PRI, // !GEN :TODO: we will need this for dynarrays
|
|
|
|
OP_SREF_ALT, // !GEN :TODO: we will need this for dynarrays
|
|
|
|
OP_SREF_S_PRI, //VERIFIED
|
|
|
|
OP_SREF_S_ALT, //~VERIFIED (stor.s.alt)
|
|
|
|
OP_STOR_I, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_STRB_I, // !GEN :TODO: - only used for pack access, drop support in compiler first
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_LIDX, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_LIDX_B, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_IDXADDR, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_IDXADDR_B, //DONE
|
|
|
|
OP_ALIGN_PRI, // !GEN :TODO: - only used for pack access, drop support in compiler first
|
|
|
|
OP_ALIGN_ALT, // !GEN :TODO: - only used for pack access, drop support in compiler first
|
|
|
|
OP_LCTRL, // !GEN
|
|
|
|
OP_SCTRL, // !GEN
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_MOVE_PRI, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_MOVE_ALT, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_XCHG, //DONE
|
|
|
|
OP_PUSH_PRI, //DONE
|
|
|
|
OP_PUSH_ALT, //DONE
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_PUSH_R, // !GEN DEPRECATED
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_PUSH_C, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_PUSH, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_PUSH_S, //VERIFIED
|
|
|
|
OP_POP_PRI, //VERIFIED
|
|
|
|
OP_POP_ALT, //VERIFIED
|
|
|
|
OP_STACK, //VERIFIED
|
2006-09-21 01:33:40 +02:00
|
|
|
OP_HEAP, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_PROC, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_RET, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_RETN, //VERIFIED
|
|
|
|
OP_CALL, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_CALL_PRI, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_JUMP, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_JREL, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_JZER, //VERIFIED
|
2006-09-23 06:11:01 +02:00
|
|
|
OP_JNZ, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_JEQ, //VERIFIED
|
|
|
|
OP_JNEQ, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_JLESS, // !GEN
|
|
|
|
OP_JLEQ, // !GEN
|
|
|
|
OP_JGRTR, // !GEN
|
|
|
|
OP_JGEQ, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_JSLESS, //VERIFIED
|
|
|
|
OP_JSLEQ, //VERIFIED
|
|
|
|
OP_JSGRTR, //VERIFIED
|
|
|
|
OP_JSGEQ, //VERIFIED
|
|
|
|
OP_SHL, //VERIFIED
|
|
|
|
OP_SHR, //VERIFIED (Note: operator >>>)
|
|
|
|
OP_SSHR, //VERIFIED (Note: operator >>)
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_SHL_C_PRI, //DONE
|
|
|
|
OP_SHL_C_ALT, //DONE
|
|
|
|
OP_SHR_C_PRI, //DONE
|
|
|
|
OP_SHR_C_ALT, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SMUL, //VERIFIED
|
2006-09-21 00:12:55 +02:00
|
|
|
OP_SDIV, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SDIV_ALT, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_UMUL, // !GEN
|
|
|
|
OP_UDIV, // !GEN
|
|
|
|
OP_UDIV_ALT, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_ADD, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_SUB, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SUB_ALT, //VERIFIED
|
|
|
|
OP_AND, //VERIFIED
|
|
|
|
OP_OR, //VERIFIED
|
|
|
|
OP_XOR, //VERIFIED
|
|
|
|
OP_NOT, //VERIFIED
|
|
|
|
OP_NEG, //VERIFIED
|
|
|
|
OP_INVERT, //VERIFIED
|
|
|
|
OP_ADD_C, //VERIFIED
|
|
|
|
OP_SMUL_C, //VERIFIED
|
|
|
|
OP_ZERO_PRI, //VERIFIED
|
|
|
|
OP_ZERO_ALT, //~VERIFIED
|
|
|
|
OP_ZERO, //VERIFIED
|
|
|
|
OP_ZERO_S, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_SIGN_PRI, //DONE
|
|
|
|
OP_SIGN_ALT, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_EQ, //VERIFIED
|
|
|
|
OP_NEQ, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_LESS, // !GEN
|
|
|
|
OP_LEQ, // !GEN
|
|
|
|
OP_GRTR, // !GEN
|
|
|
|
OP_GEQ, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SLESS, //VERIFIED
|
|
|
|
OP_SLEQ, //VERIFIED
|
|
|
|
OP_SGRTR, //VERIFIED
|
|
|
|
OP_SGEQ, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_EQ_C_PRI, //DONE
|
|
|
|
OP_EQ_C_ALT, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_INC_PRI, //VERIFIED
|
|
|
|
OP_INC_ALT, //~VERIFIED (inc.pri)
|
|
|
|
OP_INC, //VERIFIED
|
|
|
|
OP_INC_S, //VERIFIED
|
|
|
|
OP_INC_I, //VERIFIED
|
|
|
|
OP_DEC_PRI, //VERIFIED
|
|
|
|
OP_DEC_ALT, //~VERIFIED (dec.pri)
|
|
|
|
OP_DEC, //VERIFIED
|
|
|
|
OP_DEC_S, //VERIFIED
|
|
|
|
OP_DEC_I, //VERIFIED
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_MOVS, //DONE
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_CMPS, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_FILL, //VERIFIED
|
2006-09-21 04:58:59 +02:00
|
|
|
OP_HALT, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_BOUNDS, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_SYSREQ_PRI, // !GEN
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SYSREQ_C, // !GEN DEPRECATED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_FILE, // !GEN DEPRECATED
|
|
|
|
OP_LINE, // !GEN DEPRECATED
|
|
|
|
OP_SYMBOL, // !GEN DEPRECATED
|
|
|
|
OP_SRANGE, // !GEN DEPRECATED
|
|
|
|
OP_JUMP_PRI, // !GEN
|
2006-10-10 19:33:05 +02:00
|
|
|
OP_SWITCH, //VERIFIED
|
|
|
|
OP_CASETBL, //VERIFIED
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_SWAP_PRI, //VERIFIED
|
|
|
|
OP_SWAP_ALT, //~VERIFIED (swap.alt)
|
|
|
|
OP_PUSH_ADR, //VERIFIED
|
|
|
|
OP_NOP, //VERIFIED (lol)
|
2006-10-12 01:47:04 +02:00
|
|
|
OP_SYSREQ_N, //VERIFIED
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_SYMTAG, // !GEN DEPRECATED
|
2006-09-21 07:04:51 +02:00
|
|
|
OP_BREAK, //DONE
|
2006-10-10 03:55:08 +02:00
|
|
|
OP_PUSH2_C, //~VERIFIED (push3.c)
|
|
|
|
OP_PUSH2, //VERIFIED
|
|
|
|
OP_PUSH2_S, //VERIFIED
|
|
|
|
OP_PUSH2_ADR, //VERIFIED
|
|
|
|
OP_PUSH3_C, //VERIFIED
|
|
|
|
OP_PUSH3, //~VERIFIED (push2)
|
|
|
|
OP_PUSH3_S, //~VERIFIED (push2.s)
|
|
|
|
OP_PUSH3_ADR, //~VERIFIED (push2.adr)
|
|
|
|
OP_PUSH4_C, //~VERIFIED (push3.c)
|
|
|
|
OP_PUSH4, //~VERIFIED (push2)
|
|
|
|
OP_PUSH4_S, //~VERIFIED (push2.s)
|
|
|
|
OP_PUSH4_ADR, //~VERIFIED (push2.adr)
|
|
|
|
OP_PUSH5_C, //~VERIFIED (push3.c)
|
|
|
|
OP_PUSH5, //~VERIFIED (push2)
|
|
|
|
OP_PUSH5_S, //~VERIFIED (push2.s)
|
|
|
|
OP_PUSH5_ADR, //~VERIFIED (push2.adr)
|
|
|
|
OP_LOAD_BOTH, //VERIFIED
|
|
|
|
OP_LOAD_S_BOTH, //VERIFIED
|
|
|
|
OP_CONST, //VERIFIED
|
2006-09-20 06:14:53 +02:00
|
|
|
OP_CONST_S, //DONE
|
2006-09-20 04:56:20 +02:00
|
|
|
/* ----- */
|
2006-09-24 08:17:10 +02:00
|
|
|
OP_SYSREQ_D, // !GEN UNSUPPORT
|
|
|
|
OP_SYSREQ_ND, // !GEN UNSUPPORT
|
2006-09-20 04:56:20 +02:00
|
|
|
/* ----- */
|
2006-09-20 05:56:24 +02:00
|
|
|
OP_HEAP_PRI, //DONE
|
|
|
|
OP_PUSH_HEAP_C, //DONE
|
|
|
|
OP_POP_HEAP_PRI, //DONE
|
2006-09-20 04:56:20 +02:00
|
|
|
/* ----- */
|
|
|
|
OP_NUM_OPCODES
|
|
|
|
} OPCODE;
|
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
|