sourcepawn/vm/jit/x86/opcode_helpers.h
author David Anderson <dvander@alliedmods.net>
Wed Sep 20 08:44:21 2006 +0000 (2006-09-20)
changeset 75 55682fa202ea
parent 74 935d64738275
child 76 0af1d530c4d3
permissions -rw-r--r--
I'm proud to present the first non-backpatched error checking routine!
all of this is untested
dvander@70
     1
#ifndef _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
dvander@70
     2
#define _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
dvander@70
     3
dvander@70
     4
#include "..\jit_helpers.h"
dvander@70
     5
dvander@74
     6
/**
dvander@74
     7
 * This outputs the execution function for a plugin.
dvander@74
     8
 * It also returns the 'return' offset, which is used for 
dvander@74
     9
 * breaking out of the JIT during runtime.
dvander@74
    10
 */
dvander@75
    11
jitoffs_t Write_Execute_Function(JitWriter *jit);
dvander@75
    12
dvander@75
    13
/**
dvander@75
    14
 * Generates code to set an error state in the VM and return.
dvander@75
    15
 * Note that this should only be called from inside an error
dvander@75
    16
 * checking function.
dvander@75
    17
 */
dvander@75
    18
void Write_Error(JitWriter *jit, int error);
dvander@75
    19
dvander@75
    20
/**
dvander@75
    21
 * Verifies an address by register.
dvander@75
    22
 */
dvander@75
    23
void Write_Check_VerifyAddr(JitWriter *jit, jit_uint8_t reg, bool firstcall);
dvander@74
    24
dvander@74
    25
/** 
dvander@74
    26
 * These are for writing the PushN opcodes.
dvander@74
    27
 */
dvander@70
    28
void Macro_PushN_Addr(JitWriter *jit, int i);
dvander@70
    29
void Macro_PushN_S(JitWriter *jit, int i);
dvander@70
    30
void Macro_PushN_C(JitWriter *jit, int i);
dvander@70
    31
void Macro_PushN(JitWriter *jit, int i);
dvander@70
    32
dvander@70
    33
typedef enum
dvander@70
    34
{
dvander@70
    35
	OP_NONE,              /* invalid opcode */
dvander@71
    36
	OP_LOAD_PRI,			//DONE
dvander@71
    37
	OP_LOAD_ALT,			//DONE
dvander@71
    38
	OP_LOAD_S_PRI,			//DONE
dvander@71
    39
	OP_LOAD_S_ALT,			//DONE
dvander@71
    40
	OP_LREF_PRI,			//DONE
dvander@71
    41
	OP_LREF_ALT,			//DONE
dvander@71
    42
	OP_LREF_S_PRI,			//DONE
dvander@71
    43
	OP_LREF_S_ALT,			//DONE
dvander@75
    44
	OP_LOAD_I,				//DONE
dvander@70
    45
	OP_LODB_I,
dvander@71
    46
	OP_CONST_PRI,			//DONE
dvander@71
    47
	OP_CONST_ALT,			//DONE
dvander@71
    48
	OP_ADDR_PRI,			//DONE
dvander@71
    49
	OP_ADDR_ALT,			//DONE
dvander@71
    50
	OP_STOR_PRI,			//DONE
dvander@71
    51
	OP_STOR_ALT,			//DONE
dvander@71
    52
	OP_STOR_S_PRI,			//DONE
dvander@71
    53
	OP_STOR_S_ALT,			//DONE
dvander@71
    54
	OP_SREF_PRI,			//DONE
dvander@71
    55
	OP_SREF_ALT,			//DONE
dvander@71
    56
	OP_SREF_S_PRI,			//DONE
dvander@71
    57
	OP_SREF_S_ALT,			//DONE
dvander@71
    58
	OP_STOR_I,
dvander@70
    59
	OP_STRB_I,
dvander@71
    60
	OP_LIDX,
dvander@70
    61
	OP_LIDX_B,
dvander@71
    62
	OP_IDXADDR,				//DONE
dvander@70
    63
	OP_IDXADDR_B,
dvander@71
    64
	OP_ALIGN_PRI,			//DONE
dvander@71
    65
	OP_ALIGN_ALT,			//DONE
dvander@70
    66
	OP_LCTRL,
dvander@70
    67
	OP_SCTRL,
dvander@71
    68
	OP_MOVE_PRI,			//DONE
dvander@71
    69
	OP_MOVE_ALT,			//DONE
dvander@71
    70
	OP_XCHG,				//DONE
dvander@71
    71
	OP_PUSH_PRI,			//DONE
dvander@71
    72
	OP_PUSH_ALT,			//DONE
dvander@71
    73
	OP_PUSH_R,				//DEPRECATED
dvander@71
    74
	OP_PUSH_C,				//DONE
dvander@71
    75
	OP_PUSH,				//DONE
dvander@71
    76
	OP_PUSH_S,				//DONE
dvander@71
    77
	OP_POP_PRI,				//DONE
dvander@71
    78
	OP_POP_ALT,				//DONE
dvander@71
    79
	OP_STACK,
dvander@71
    80
	OP_HEAP,
dvander@71
    81
	OP_PROC,				//DONE
dvander@70
    82
	OP_RET,
dvander@71
    83
	OP_RETN,
dvander@70
    84
	OP_CALL,
dvander@70
    85
	OP_CALL_PRI,
dvander@71
    86
	OP_JUMP,
dvander@71
    87
	OP_JREL,
dvander@71
    88
	OP_JZER,
dvander@71
    89
	OP_JNZ,
dvander@71
    90
	OP_JEQ,
dvander@71
    91
	OP_JNEQ,
dvander@71
    92
	OP_JLESS,
dvander@71
    93
	OP_JLEQ,
dvander@71
    94
	OP_JGRTR,
dvander@71
    95
	OP_JGEQ,
dvander@71
    96
	OP_JSLESS,
dvander@71
    97
	OP_JSLEQ,
dvander@71
    98
	OP_JSGRTR,
dvander@71
    99
	OP_JSGEQ,
dvander@71
   100
	OP_SHL,					//DONE
dvander@71
   101
	OP_SHR,					//DONE
dvander@71
   102
	OP_SSHR,				//DONE
dvander@71
   103
	OP_SHL_C_PRI,			//DONE
dvander@71
   104
	OP_SHL_C_ALT,			//DONE
dvander@71
   105
	OP_SHR_C_PRI,			//DONE
dvander@71
   106
	OP_SHR_C_ALT,			//DONE
dvander@71
   107
	OP_SMUL,				//DONE
dvander@71
   108
	OP_SDIV,
dvander@71
   109
	OP_SDIV_ALT,
dvander@71
   110
	OP_UMUL,				//DONE
dvander@71
   111
	OP_UDIV,
dvander@71
   112
	OP_UDIV_ALT,
dvander@71
   113
	OP_ADD,					//DONE
dvander@71
   114
	OP_SUB,					//DONE
dvander@71
   115
	OP_SUB_ALT,				//DONE
dvander@71
   116
	OP_AND,					//DONE
dvander@71
   117
	OP_OR,					//DONE
dvander@71
   118
	OP_XOR,					//DONE
dvander@71
   119
	OP_NOT,					//DONE
dvander@71
   120
	OP_NEG,					//DONE
dvander@71
   121
	OP_INVERT,				//DONE
dvander@71
   122
	OP_ADD_C,				//DONE
dvander@71
   123
	OP_SMUL_C,				//DONE
dvander@71
   124
	OP_ZERO_PRI,			//DONE
dvander@71
   125
	OP_ZERO_ALT,			//DONE
dvander@71
   126
	OP_ZERO,				//DONE
dvander@71
   127
	OP_ZERO_S,				//DONE
dvander@71
   128
	OP_SIGN_PRI,			//DONE
dvander@71
   129
	OP_SIGN_ALT,			//DONE
dvander@71
   130
	OP_EQ,					//DONE
dvander@71
   131
	OP_NEQ,					//DONE
dvander@71
   132
	OP_LESS,				//DONE
dvander@71
   133
	OP_LEQ,					//DONE
dvander@71
   134
	OP_GRTR,				//DONE
dvander@71
   135
	OP_GEQ,					//DONE
dvander@71
   136
	OP_SLESS,				//DONE
dvander@71
   137
	OP_SLEQ,				//DONE
dvander@71
   138
	OP_SGRTR,				//DONE
dvander@71
   139
	OP_SGEQ,				//DONE
dvander@71
   140
	OP_EQ_C_PRI,			//DONE
dvander@71
   141
	OP_EQ_C_ALT,			//DONE
dvander@71
   142
	OP_INC_PRI,				//DONE
dvander@71
   143
	OP_INC_ALT,				//DONE
dvander@71
   144
	OP_INC,					//DONE
dvander@71
   145
	OP_INC_S,				//DONE
dvander@71
   146
	OP_INC_I,				//DONE
dvander@71
   147
	OP_DEC_PRI,				//DONE
dvander@71
   148
	OP_DEC_ALT,				//DONE
dvander@71
   149
	OP_DEC,					//DONE
dvander@71
   150
	OP_DEC_S,				//DONE
dvander@71
   151
	OP_DEC_I,				//DONE
dvander@71
   152
	OP_MOVS,				//DONE
dvander@71
   153
	OP_CMPS,
dvander@71
   154
	OP_FILL,				//DONE
dvander@71
   155
	OP_HALT,
dvander@70
   156
	OP_BOUNDS,
dvander@70
   157
	OP_SYSREQ_PRI,
dvander@70
   158
	OP_SYSREQ_C,
dvander@71
   159
	OP_FILE,				//DEPRECATED
dvander@71
   160
	OP_LINE,				//DEPRECATED
dvander@71
   161
	OP_SYMBOL,				//DEPRECATED
dvander@71
   162
	OP_SRANGE,				//DEPRECATED
dvander@70
   163
	OP_JUMP_PRI,
dvander@70
   164
	OP_SWITCH,
dvander@71
   165
	OP_CASETBL,
dvander@71
   166
	OP_SWAP_PRI,			//DONE
dvander@71
   167
	OP_SWAP_ALT,			//DONE
dvander@72
   168
	OP_PUSH_ADR,			//DONE
dvander@71
   169
	OP_NOP,					//DONE
dvander@70
   170
	OP_SYSREQ_N,
dvander@71
   171
	OP_SYMTAG,				//DEPRECATED
dvander@70
   172
	OP_BREAK,
dvander@71
   173
	OP_PUSH2_C,				//DONE
dvander@71
   174
	OP_PUSH2,				//DONE
dvander@71
   175
	OP_PUSH2_S,				//DONE
dvander@71
   176
	OP_PUSH2_ADR,			//DONE
dvander@71
   177
	OP_PUSH3_C,				//DONE
dvander@71
   178
	OP_PUSH3,				//DONE
dvander@71
   179
	OP_PUSH3_S,				//DONE
dvander@71
   180
	OP_PUSH3_ADR,			//DONE
dvander@71
   181
	OP_PUSH4_C,				//DONE
dvander@71
   182
	OP_PUSH4,				//DONE
dvander@71
   183
	OP_PUSH4_S,				//DONE
dvander@71
   184
	OP_PUSH4_ADR,			//DONE
dvander@71
   185
	OP_PUSH5_C,				//DONE
dvander@71
   186
	OP_PUSH5,				//DONE
dvander@71
   187
	OP_PUSH5_S,				//DONE
dvander@71
   188
	OP_PUSH5_ADR,			//DONE
dvander@72
   189
	OP_LOAD_BOTH,			//DONE
dvander@72
   190
	OP_LOAD_S_BOTH,			//DONE
dvander@72
   191
	OP_CONST,				//DONE
dvander@72
   192
	OP_CONST_S,				//DONE
dvander@70
   193
	/* ----- */
dvander@71
   194
	OP_SYSREQ_D,			//UNSUPPORTED
dvander@71
   195
	OP_SYSREQ_ND,			//UNSUPPORTED
dvander@70
   196
	/* ----- */
dvander@71
   197
	OP_HEAP_PRI,			//DONE
dvander@71
   198
	OP_PUSH_HEAP_C,			//DONE
dvander@71
   199
	OP_POP_HEAP_PRI,		//DONE
dvander@70
   200
	/* ----- */
dvander@70
   201
	OP_NUM_OPCODES
dvander@70
   202
} OPCODE;
dvander@70
   203
dvander@70
   204
extern int OpAdvTable[];
dvander@70
   205
dvander@70
   206
#endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_