3 * ================================================================
4 * SourcePawn (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ================================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
16 #define _INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
18 #include "../jit_helpers.h"
21 * This outputs the execution function for a plugin.
22 * It also returns the 'return' offset, which is used for
23 * breaking out of the JIT during runtime.
25 jitoffs_t Write_Execute_Function(JitWriter *jit);
28 * Writes the Sysreq.* opcodes as a function call.
30 void WriteOp_Sysreq_N_Function(JitWriter *jit);
31 void WriteOp_Sysreq_C_Function(JitWriter *jit);
34 * Write the GENARRAY intrinsic function.
36 void WriteIntrinsic_GenArray(JitWriter *jit);
39 * Generates code to set an error state in the VM and return.
40 * This is used for generating the error set points in the VM.
41 * GetError writes the error from the context. SetError hardcodes.
43 void Write_GetError(JitWriter *jit);
44 void Write_SetError(JitWriter *jit, int error);
47 * Checks the stacks for min and low errors.
48 * :TODO: Should a variation of this go in the pushN opcodes?
50 void Write_CheckStack_Min(JitWriter *jit);
51 void Write_CheckStack_Low(JitWriter *jit);
54 * Checks the heap for min and low errors.
56 void Write_CheckHeap_Min(JitWriter *jit);
57 void Write_CheckHeap_Low(JitWriter *jit);
60 * Verifies an address by register. The address must reside
61 * between DAT and HP and SP and STP.
63 void Write_Check_VerifyAddr(JitWriter *jit, jit_uint8_t reg);
66 * Checks for division by zero.
68 void Write_Check_DivZero(JitWriter *jit, jit_uint8_t reg);
71 * Writes the break debug function.
73 void Write_BreakDebug(JitWriter *jit);
76 * These are for writing the PushN opcodes.
78 void Macro_PushN_Addr(JitWriter *jit, int i);
79 void Macro_PushN_S(JitWriter *jit, int i);
80 void Macro_PushN_C(JitWriter *jit, int i);
81 void Macro_PushN(JitWriter *jit, int i);
84 * Bound checking for the tracker stack,
86 int JIT_VerifyLowBoundTracker(sp_context_t *ctx);
87 int JIT_VerifyOrAllocateTracker(sp_context_t *ctx);
90 * Writes the push into tracker function.
92 void WriteOp_Tracker_Push_Reg(JitWriter *jit, uint8_t reg);
95 * Writes the rounding table for the float compare opcode.
97 void Write_RoundingTable(JitWriter *jit);
100 * Aligns the current code position to 16 bytes.
102 void AlignMe(JitWriter *jit);
105 * Legend for Statuses:
106 * ****** *** ********
107 * DONE -> code generation is done
108 * !GEN -> code generation is deliberate skipped because:
109 * (default): compiler does not generate
110 * DEPRECATED: this feature no longer exists/supported
111 * UNSUPPORTED: this opcode is not supported
112 * TODO: done in case needed
113 * VERIFIED -> code generation is checked as run-time working. prefixes:
114 * ! errors are not checked yet.
115 * - non-inline errors are not checked yet.
116 * ~ assumed checked because of related variation, but not actually checked
121 OP_NONE, /* invalid opcode */
122 OP_LOAD_PRI, //!VERIFIED
123 OP_LOAD_ALT, //~!VERIFIED (load.pri)
124 OP_LOAD_S_PRI, //VERIFIED
125 OP_LOAD_S_ALT, //VERIFIED
126 OP_LREF_PRI, // !GEN :TODO: we will need this for dynarrays
127 OP_LREF_ALT, // !GEN :TODO: we will need this for dynarrays
128 OP_LREF_S_PRI, //VERIFIED
129 OP_LREF_S_ALT, //~VERIFIED (lref.s.pri)
130 OP_LOAD_I, //VERIFIED
131 OP_LODB_I, //VERIFIED
132 OP_CONST_PRI, //VERIFIED
133 OP_CONST_ALT, //~VERIFIED (const.pri)
134 OP_ADDR_PRI, //VERIFIED
135 OP_ADDR_ALT, //VERIFIED
136 OP_STOR_PRI, //VERIFIED
137 OP_STOR_ALT, //~VERIFIED (stor.pri)
138 OP_STOR_S_PRI, //VERIFIED
139 OP_STOR_S_ALT, //~VERIFIED (stor.s.pri)
140 OP_SREF_PRI, // !GEN :TODO: we will need this for dynarrays
141 OP_SREF_ALT, // !GEN :TODO: we will need this for dynarrays
142 OP_SREF_S_PRI, //VERIFIED
143 OP_SREF_S_ALT, //~VERIFIED (stor.s.alt)
144 OP_STOR_I, //VERIFIED
145 OP_STRB_I, //VERIFIED
148 OP_IDXADDR, //VERIFIED
150 OP_ALIGN_PRI, // !GEN :TODO: - only used for pack access, drop support in compiler first
151 OP_ALIGN_ALT, // !GEN :TODO: - only used for pack access, drop support in compiler first
154 OP_MOVE_PRI, //~VERIFIED (move.alt)
155 OP_MOVE_ALT, //VERIFIED
159 OP_PUSH_R, // !GEN DEPRECATED
160 OP_PUSH_C, //VERIFIED
162 OP_PUSH_S, //VERIFIED
163 OP_POP_PRI, //VERIFIED
164 OP_POP_ALT, //VERIFIED
182 OP_JSLESS, //VERIFIED
184 OP_JSGRTR, //VERIFIED
187 OP_SHR, //VERIFIED (Note: operator >>>)
188 OP_SSHR, //VERIFIED (Note: operator >>)
195 OP_SDIV_ALT, //VERIFIED
201 OP_SUB_ALT, //VERIFIED
207 OP_INVERT, //VERIFIED
209 OP_SMUL_C, //VERIFIED
210 OP_ZERO_PRI, //VERIFIED
211 OP_ZERO_ALT, //~VERIFIED
213 OP_ZERO_S, //VERIFIED
228 OP_INC_PRI, //VERIFIED
229 OP_INC_ALT, //~VERIFIED (inc.pri)
233 OP_DEC_PRI, //VERIFIED
234 OP_DEC_ALT, //~VERIFIED (dec.pri)
242 OP_BOUNDS, //VERIFIED
243 OP_SYSREQ_PRI, // !GEN
244 OP_SYSREQ_C, //VERIFIED
245 OP_FILE, // !GEN DEPRECATED
246 OP_LINE, // !GEN DEPRECATED
247 OP_SYMBOL, // !GEN DEPRECATED
248 OP_SRANGE, // !GEN DEPRECATED
250 OP_SWITCH, //VERIFIED
251 OP_CASETBL, //VERIFIED
252 OP_SWAP_PRI, //VERIFIED
253 OP_SWAP_ALT, //~VERIFIED (swap.alt)
254 OP_PUSH_ADR, //VERIFIED
255 OP_NOP, //VERIFIED (lol)
256 OP_SYSREQ_N, //VERIFIED
257 OP_SYMTAG, // !GEN DEPRECATED
259 OP_PUSH2_C, //~VERIFIED (push3.c)
261 OP_PUSH2_S, //VERIFIED
262 OP_PUSH2_ADR, //VERIFIED
263 OP_PUSH3_C, //VERIFIED
264 OP_PUSH3, //~VERIFIED (push2)
265 OP_PUSH3_S, //~VERIFIED (push2.s)
266 OP_PUSH3_ADR, //~VERIFIED (push2.adr)
267 OP_PUSH4_C, //~VERIFIED (push3.c)
268 OP_PUSH4, //~VERIFIED (push2)
269 OP_PUSH4_S, //~VERIFIED (push2.s)
270 OP_PUSH4_ADR, //~VERIFIED (push2.adr)
271 OP_PUSH5_C, //~VERIFIED (push3.c)
272 OP_PUSH5, //~VERIFIED (push2)
273 OP_PUSH5_S, //~VERIFIED (push2.s)
274 OP_PUSH5_ADR, //~VERIFIED (push2.adr)
275 OP_LOAD_BOTH, //VERIFIED
276 OP_LOAD_S_BOTH, //VERIFIED
280 OP_SYSREQ_D, // !GEN UNSUPPORT
281 OP_SYSREQ_ND, // !GEN UNSUPPORT
283 OP_TRACKER_PUSH_C, //DONE
284 OP_TRACKER_POP_SETHEAP, //VERIFIED
285 OP_GENARRAY, //VERIFIED
286 OP_GENARRAY_Z, //-VERIFIED (not tested for 1D arrays)
287 OP_STRADJUST_PRI, //VERIFIED
290 OP_FLOATADD, //VERIFIED
291 OP_FLOATSUB, //VERIFIED
292 OP_FLOATMUL, //VERIFIED
293 OP_FLOATDIV, //VERIFIED
294 OP_RND_TO_NEAREST, //VERIFIED
295 OP_RND_TO_FLOOR, //VERIFIED
296 OP_RND_TO_CEIL, //VERIFIED
297 OP_RND_TO_ZERO, //VERIFIED
298 OP_FLOATCMP, //VERIFIED
304 * :TODO: List of ASM Opts
306 * DONE: Rest of opcodes including the SYSREQ.N inlined version (rev2)
307 * Including genarray and the 2 tracker ones
308 * DONE: ALL ungen opcodes (rev1)
309 * from opcode_helpers.cpp
310 * DONE: SYSREQ.N .C (rev2)
311 * MACRO OPCODES (rev2)
312 * ERROR CHECKS\{VERIFY ADDR} (rev2)
318 * Oh and ALIGN to 16BYTES all stuff that is called via CALL and frequently used jump labels like what's done with PROC.
321 #endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_