/[pcre]/code/trunk/sljit/sljitLir.h
ViewVC logotype

Contents of /code/trunk/sljit/sljitLir.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1195 - (show annotations)
Thu Nov 1 15:21:27 2012 UTC (6 years, 9 months ago) by zherczeg
File MIME type: text/plain
File size: 41622 byte(s)
Another huge JIT compiler update.
1 /*
2 * Stack-less Just-In-Time compiler
3 *
4 * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 * of conditions and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef _SLJIT_LIR_H_
28 #define _SLJIT_LIR_H_
29
30 /*
31 ------------------------------------------------------------------------
32 Stack-Less JIT compiler for multiple architectures (x86, ARM, PowerPC)
33 ------------------------------------------------------------------------
34
35 Short description
36 Advantages:
37 - The execution can be continued from any LIR instruction
38 In other words, jump into and out of the code is safe
39 - Both target of (conditional) jump and call instructions
40 and constants can be dynamically modified during runtime
41 - although it is not suggested to do it frequently
42 - very effective to cache an important value once
43 - A fixed stack space can be allocated for local variables
44 - The compiler is thread-safe
45 - The compiler is highly configurable through preprocessor macros.
46 You can disable unneeded features (multithreading in single
47 threaded applications), and you can use your own system functions
48 (including memory allocators). See sljitConfig.h
49 Disadvantages:
50 - Limited number of registers (only 6+4 integer registers, max 3+2
51 temporary, max 3+2 saved and 4 floating point registers)
52 In practice:
53 - This approach is very effective for interpreters
54 - One of the saved registers typically points to a stack interface
55 - It can jump to any exception handler anytime (even for another
56 function. It is safe for SLJIT.)
57 - Fast paths can be modified during runtime reflecting the changes
58 of the fastest execution path of the dynamic language
59 - SLJIT supports complex memory addressing modes
60 - mainly position independent code
61 - Optimizations (perhaps later)
62 - Only for basic blocks (when no labels inserted between LIR instructions)
63
64 For valgrind users:
65 - pass --smc-check=all argument to valgrind, since JIT is a "self-modifying code"
66 */
67
68 #if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)
69 #include "sljitConfig.h"
70 #endif
71
72 /* The following header file defines useful macros for fine tuning
73 sljit based code generators. They are listed in the begining
74 of sljitConfigInternal.h */
75
76 #include "sljitConfigInternal.h"
77
78 /* --------------------------------------------------------------------- */
79 /* Error codes */
80 /* --------------------------------------------------------------------- */
81
82 /* Indicates no error. */
83 #define SLJIT_SUCCESS 0
84 /* After the call of sljit_generate_code(), the error code of the compiler
85 is set to this value to avoid future sljit calls (in debug mode at least).
86 The complier should be freed after sljit_generate_code(). */
87 #define SLJIT_ERR_COMPILED 1
88 /* Cannot allocate non executable memory. */
89 #define SLJIT_ERR_ALLOC_FAILED 2
90 /* Cannot allocate executable memory.
91 Only for sljit_generate_code() */
92 #define SLJIT_ERR_EX_ALLOC_FAILED 3
93 /* return value for SLJIT_CONFIG_UNSUPPORTED empty architecture. */
94 #define SLJIT_ERR_UNSUPPORTED 4
95
96 /* --------------------------------------------------------------------- */
97 /* Registers */
98 /* --------------------------------------------------------------------- */
99
100 #define SLJIT_UNUSED 0
101
102 /* Temporary (scratch) registers may not preserve their values across function calls. */
103 #define SLJIT_TEMPORARY_REG1 1
104 #define SLJIT_TEMPORARY_REG2 2
105 #define SLJIT_TEMPORARY_REG3 3
106 /* Note: Extra Registers cannot be used for memory addressing. */
107 /* Note: on x86-32, these registers are emulated (using stack loads & stores). */
108 #define SLJIT_TEMPORARY_EREG1 4
109 #define SLJIT_TEMPORARY_EREG2 5
110
111 /* Saved registers whose preserve their values across function calls. */
112 #define SLJIT_SAVED_REG1 6
113 #define SLJIT_SAVED_REG2 7
114 #define SLJIT_SAVED_REG3 8
115 /* Note: Extra Registers cannot be used for memory addressing. */
116 /* Note: on x86-32, these registers are emulated (using stack loads & stores). */
117 #define SLJIT_SAVED_EREG1 9
118 #define SLJIT_SAVED_EREG2 10
119
120 /* Read-only register (cannot be the destination of an operation).
121 Only SLJIT_MEM1(SLJIT_LOCALS_REG) addressing mode is allowed since
122 several ABIs has certain limitations about the stack layout. However
123 sljit_get_local_base() can be used to obtain the offset of a value. */
124 #define SLJIT_LOCALS_REG 11
125
126 /* Number of registers. */
127 #define SLJIT_NO_TMP_REGISTERS 5
128 #define SLJIT_NO_GEN_REGISTERS 5
129 #define SLJIT_NO_REGISTERS 11
130
131 /* Return with machine word. */
132
133 #define SLJIT_RETURN_REG SLJIT_TEMPORARY_REG1
134
135 /* x86 prefers specific registers for special purposes. In case of shift
136 by register it supports only SLJIT_TEMPORARY_REG3 for shift argument
137 (which is the src2 argument of sljit_emit_op2). If another register is
138 used, sljit must exchange data between registers which cause a minor
139 slowdown. Other architectures has no such limitation. */
140
141 #define SLJIT_PREF_SHIFT_REG SLJIT_TEMPORARY_REG3
142
143 /* --------------------------------------------------------------------- */
144 /* Floating point registers */
145 /* --------------------------------------------------------------------- */
146
147 /* Note: SLJIT_UNUSED as destination is not valid for floating point
148 operations, since they cannot be used for setting flags. */
149
150 /* Floating point operations are performed on double precision values. */
151
152 #define SLJIT_FLOAT_REG1 1
153 #define SLJIT_FLOAT_REG2 2
154 #define SLJIT_FLOAT_REG3 3
155 #define SLJIT_FLOAT_REG4 4
156 #define SLJIT_FLOAT_REG5 5
157 #define SLJIT_FLOAT_REG6 6
158
159 /* --------------------------------------------------------------------- */
160 /* Main structures and functions */
161 /* --------------------------------------------------------------------- */
162
163 struct sljit_memory_fragment {
164 struct sljit_memory_fragment *next;
165 sljit_uw used_size;
166 /* Must be aligned to sljit_sw. */
167 sljit_ub memory[1];
168 };
169
170 struct sljit_label {
171 struct sljit_label *next;
172 sljit_uw addr;
173 /* The maximum size difference. */
174 sljit_uw size;
175 };
176
177 struct sljit_jump {
178 struct sljit_jump *next;
179 sljit_uw addr;
180 sljit_sw flags;
181 union {
182 sljit_uw target;
183 struct sljit_label* label;
184 } u;
185 };
186
187 struct sljit_const {
188 struct sljit_const *next;
189 sljit_uw addr;
190 };
191
192 struct sljit_compiler {
193 sljit_si error;
194
195 struct sljit_label *labels;
196 struct sljit_jump *jumps;
197 struct sljit_const *consts;
198 struct sljit_label *last_label;
199 struct sljit_jump *last_jump;
200 struct sljit_const *last_const;
201
202 struct sljit_memory_fragment *buf;
203 struct sljit_memory_fragment *abuf;
204
205 /* Used local registers. */
206 sljit_si temporaries;
207 /* Used saved registers. */
208 sljit_si saveds;
209 /* Local stack size. */
210 sljit_si local_size;
211 /* Code size. */
212 sljit_uw size;
213 /* For statistical purposes. */
214 sljit_uw executable_size;
215
216 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
217 sljit_si args;
218 sljit_si locals_offset;
219 sljit_si temporaries_start;
220 sljit_si saveds_start;
221 #endif
222
223 #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
224 sljit_si mode32;
225 #endif
226
227 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
228 sljit_si flags_saved;
229 #endif
230
231 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
232 /* Constant pool handling. */
233 sljit_uw *cpool;
234 sljit_ub *cpool_unique;
235 sljit_uw cpool_diff;
236 sljit_uw cpool_fill;
237 /* Other members. */
238 /* Contains pointer, "ldr pc, [...]" pairs. */
239 sljit_uw patches;
240 #endif
241
242 #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
243 /* Temporary fields. */
244 sljit_uw shift_imm;
245 sljit_si cache_arg;
246 sljit_sw cache_argw;
247 #endif
248
249 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
250 sljit_si cache_arg;
251 sljit_sw cache_argw;
252 #endif
253
254 #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
255 sljit_sw imm;
256 sljit_si cache_arg;
257 sljit_sw cache_argw;
258 #endif
259
260 #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
261 sljit_si delay_slot;
262 sljit_si cache_arg;
263 sljit_sw cache_argw;
264 #endif
265
266 #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
267 sljit_si delay_slot;
268 sljit_si cache_arg;
269 sljit_sw cache_argw;
270 #endif
271
272 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
273 FILE* verbose;
274 #endif
275
276 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)
277 /* Local size passed to the functions. */
278 sljit_si logical_local_size;
279 #endif
280
281 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG)
282 sljit_si skip_checks;
283 #endif
284 };
285
286 /* --------------------------------------------------------------------- */
287 /* Main functions */
288 /* --------------------------------------------------------------------- */
289
290 /* Creates an sljit compiler.
291 Returns NULL if failed. */
292 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void);
293 /* Free everything except the codes. */
294 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
295
296 static SLJIT_INLINE sljit_si sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }
297
298 /*
299 Allocate a small amount of memory. The size must be <= 64 bytes on 32 bit,
300 and <= 128 bytes on 64 bit architectures. The memory area is owned by the compiler,
301 and freed by sljit_free_compiler. The returned pointer is sizeof(sljit_sw) aligned.
302 Excellent for allocating small blocks during the compiling, and no need to worry
303 about freeing them. The size is enough to contain at most 16 pointers.
304 If the size is outside of the range, the function will return with NULL,
305 but this return value does not indicate that there is no more memory (does
306 not set the compiler to out-of-memory status).
307 */
308 SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_si size);
309
310 #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
311 /* Passing NULL disables verbose. */
312 SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose);
313 #endif
314
315 SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler);
316 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code);
317
318 /*
319 After the code generation we can retrieve the allocated executable memory size,
320 although this area may not be fully filled with instructions depending on some
321 optimizations. This function is useful only for statistical purposes.
322
323 Before a successful code generation, this function returns with 0.
324 */
325 static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler *compiler) { return compiler->executable_size; }
326
327 /* Instruction generation. Returns with error code. */
328
329 /*
330 The executable code is basically a function call from the viewpoint of
331 the C language. The function calls must obey to the ABI (Application
332 Binary Interface) of the platform, which specify the purpose of machine
333 registers and stack handling among other things. The sljit_emit_enter
334 function emits the necessary instructions for setting up a new context
335 for the executable code and moves function arguments to the saved
336 registers. The number of arguments are specified in the "args"
337 parameter and the first argument goes to SLJIT_SAVED_REG1, the second
338 goes to SLJIT_SAVED_REG2 and so on. The number of temporary and
339 saved registers are passed in "temporaries" and "saveds" arguments
340 respectively. Since the saved registers contains the arguments,
341 "args" must be less or equal than "saveds". The sljit_emit_enter
342 is also capable of allocating a stack space for local variables. The
343 "local_size" argument contains the size in bytes of this local area
344 and its staring address is stored in SLJIT_LOCALS_REG. However
345 the SLJIT_LOCALS_REG is not necessary the machine stack pointer.
346 The memory bytes between SLJIT_LOCALS_REG (inclusive) and
347 SLJIT_LOCALS_REG + local_size (exclusive) can be modified freely
348 until the function returns. The stack space is uninitialized.
349
350 Note: every call of sljit_emit_enter and sljit_set_context overwrites
351 the previous context. */
352
353 #define SLJIT_MAX_LOCAL_SIZE 65536
354
355 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
356 sljit_si args, sljit_si temporaries, sljit_si saveds, sljit_si local_size);
357
358 /* The machine code has a context (which contains the local stack space size,
359 number of used registers, etc.) which initialized by sljit_emit_enter. Several
360 functions (like sljit_emit_return) requres this context to be able to generate
361 the appropriate code. However, some code fragments (like inline cache) may have
362 no normal entry point so their context is unknown for the compiler. Using the
363 function below we can specify thir context.
364
365 Note: every call of sljit_emit_enter and sljit_set_context overwrites
366 the previous context. */
367
368 /* Note: multiple calls of this function overwrites the previous call. */
369
370 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
371 sljit_si args, sljit_si temporaries, sljit_si saveds, sljit_si local_size);
372
373 /* Return from machine code. The op argument can be SLJIT_UNUSED which means the
374 function does not return with anything or any opcode between SLJIT_MOV and
375 SLJIT_MOV_P (see sljit_emit_op1). As for src and srcw they must be 0 if op
376 is SLJIT_UNUSED, otherwise see below the description about source and
377 destination arguments. */
378 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op,
379 sljit_si src, sljit_sw srcw);
380
381 /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL).
382 All registers and even the stack frame is passed to the callee. The return address is
383 preserved in dst/dstw by sljit_emit_fast_enter (the type of the value stored by this
384 function is sljit_p), and sljit_emit_fast_return can use this as a return value later. */
385
386 /* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine
387 instructions are needed. Excellent for small uility functions, where saving registers
388 and setting up a new stack frame would cost too much performance. However, it is still
389 possible to return to the address of the caller (or anywhere else). */
390
391 /* Note: flags are not changed (unlike sljit_emit_enter / sljit_emit_return). */
392
393 /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,
394 since many architectures do clever branch prediction on call / return instruction pairs. */
395
396 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw);
397 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw);
398
399 /*
400 Source and destination values for arithmetical instructions
401 imm - a simple immediate value (cannot be used as a destination)
402 reg - any of the registers (immediate argument must be 0)
403 [imm] - absolute immediate memory address
404 [reg+imm] - indirect memory address
405 [reg+(reg<<imm)] - indirect indexed memory address (shift must be between 0 and 3)
406 useful for (byte, half, int, sljit_sw) array access
407 (fully supported by both x86 and ARM architectures, and cheap operation on others)
408 */
409
410 /*
411 IMPORATNT NOTE: memory access MUST be naturally aligned except
412 SLJIT_UNALIGNED macro is defined and its value is 1.
413
414 length | alignment
415 ---------+-----------
416 byte | 1 byte (any physical_address is accepted)
417 half | 2 byte (physical_address & 0x1 == 0)
418 int | 4 byte (physical_address & 0x3 == 0)
419 word | 4 byte if SLJIT_32BIT_ARCHITECTURE is defined and its value is 1
420 | 8 byte if SLJIT_64BIT_ARCHITECTURE is defined and its value is 1
421 pointer | size of sljit_p type (4 byte on 32 bit machines, 4 or 8 byte
422 | on 64 bit machines)
423
424 Note: Different architectures have different addressing limitations.
425 A single instruction is enough for the following addressing
426 modes. Other adrressing modes are emulated by instruction
427 sequences. This information could help to improve those code
428 generators which focuses only a few architectures.
429
430 x86: [reg+imm], -2^32+1 <= imm <= 2^32-1 (full adress space on x86-32)
431 [reg+(reg<<imm)] is supported
432 [imm], -2^32+1 <= imm <= 2^32-1 is supported
433 Write-back is not supported
434 arm: [reg+imm], -4095 <= imm <= 4095 or -255 <= imm <= 255 for signed
435 bytes, any halfs or floating point values)
436 [reg+(reg<<imm)] is supported
437 Write-back is supported
438 arm-t2: [reg+imm], -255 <= imm <= 4095
439 [reg+(reg<<imm)] is supported
440 Write back is supported only for [reg+imm], where -255 <= imm <= 255
441 ppc: [reg+imm], -65536 <= imm <= 65535. 64 bit loads/stores and 32 bit
442 signed load on 64 bit requires immediates divisible by 4.
443 [reg+imm] is not supported for signed 8 bit values.
444 [reg+reg] is supported
445 Write-back is supported except for one instruction: 32 bit signed
446 load with [reg+imm] addressing mode on 64 bit.
447 mips: [reg+imm], -65536 <= imm <= 65535
448 Nothing else is supported
449 sparc: [reg+imm], -4096 <= imm <= 4095
450 [reg+reg] is supported
451 Nothing else is supported
452 */
453
454 /* Register output: simply the name of the register.
455 For destination, you can use SLJIT_UNUSED as well. */
456 #define SLJIT_MEM 0x100
457 #define SLJIT_MEM0() (SLJIT_MEM)
458 #define SLJIT_MEM1(r1) (SLJIT_MEM | (r1))
459 #define SLJIT_MEM2(r1, r2) (SLJIT_MEM | (r1) | ((r2) << 4))
460 #define SLJIT_IMM 0x200
461
462 /* Set 32 bit operation mode (I) on 64 bit CPUs. The flag is totally ignored on
463 32 bit CPUs. If this flag is set for an arithmetic operation, it uses only the
464 lower 32 bit of the input register(s), and set the CPU status flags according
465 to the 32 bit result. The higher 32 bits are undefined for both the input and
466 output. However, the CPU might not ignore those higher 32 bits, like MIPS, which
467 expects it to be the sign extension of the lower 32 bit. All 32 bit operations
468 are undefined, if this condition is not fulfilled. Therefore, when SLJIT_INT_OP
469 is specified, all register arguments must be the result of other operations with
470 the same SLJIT_INT_OP flag. In other words, although a register can hold either
471 a 64 or 32 bit value, these values cannot be mixed. The only exceptions are
472 SLJIT_IMOV and SLJIT_IMOVU (SLJIT_MOV_SI/SLJIT_MOV_UI/SLJIT_MOVU_SI/SLJIT_MOV_UI
473 with SLJIT_INT_OP flag) which can convert any source argument to SLJIT_INT_OP
474 compatible result. This conversion might be unnecessary on some CPUs like x86-64,
475 since the upper 32 bit is always ignored. In this case SLJIT is clever enough
476 to not generate any instructions if the source and destination operands are the
477 same registers. Affects sljit_emit_op0, sljit_emit_op1 and sljit_emit_op2. */
478 #define SLJIT_INT_OP 0x100
479
480 /* Single precision mode (SP). This flag is similar to SLJIT_INT_OP, just
481 it applies to floating point registers (it is even the same bit). When
482 this flag is passed, the CPU performs single precision floating point
483 operations. Similar to SLJIT_INT_OP, all register arguments must be the
484 result of other floating point operations with this flag. Affects
485 sljit_emit_fop1, sljit_emit_fop2 and sljit_emit_fcmp. */
486 #define SLJIT_SINGLE_OP 0x100
487
488 /* Common CPU status flags for all architectures (x86, ARM, PPC)
489 - carry flag
490 - overflow flag
491 - zero flag
492 - negative/positive flag (depends on arc)
493 On mips, these flags are emulated by software. */
494
495 /* By default, the instructions may, or may not set the CPU status flags.
496 Forcing to set or keep status flags can be done with the following flags: */
497
498 /* Note: sljit tries to emit the minimum number of instructions. Using these
499 flags can increase them, so use them wisely to avoid unnecessary code generation. */
500
501 /* Set Equal (Zero) status flag (E). */
502 #define SLJIT_SET_E 0x0200
503 /* Set signed status flag (S). */
504 #define SLJIT_SET_S 0x0400
505 /* Set unsgined status flag (U). */
506 #define SLJIT_SET_U 0x0800
507 /* Set signed overflow flag (O). */
508 #define SLJIT_SET_O 0x1000
509 /* Set carry flag (C).
510 Note: Kinda unsigned overflow, but behaves differently on various cpus. */
511 #define SLJIT_SET_C 0x2000
512 /* Do not modify the flags (K).
513 Note: This flag cannot be combined with any other SLJIT_SET_* flag. */
514 #define SLJIT_KEEP_FLAGS 0x4000
515
516 /* Notes:
517 - you cannot postpone conditional jump instructions except if noted that
518 the instruction does not set flags (See: SLJIT_KEEP_FLAGS).
519 - flag combinations: '|' means 'logical or'. */
520
521 /* Flags: - (never set any flags)
522 Note: breakpoint instruction is not supported by all architectures (namely ppc)
523 It falls back to SLJIT_NOP in those cases. */
524 #define SLJIT_BREAKPOINT 0
525 /* Flags: - (never set any flags)
526 Note: may or may not cause an extra cycle wait
527 it can even decrease the runtime in a few cases. */
528 #define SLJIT_NOP 1
529 /* Flags: - (may destroy flags)
530 Unsigned multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2.
531 Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */
532 #define SLJIT_UMUL 2
533 /* Flags: - (may destroy flags)
534 Signed multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2.
535 Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */
536 #define SLJIT_SMUL 3
537 /* Flags: I - (may destroy flags)
538 Unsigned divide of the value in SLJIT_TEMPORARY_REG1 by the value in SLJIT_TEMPORARY_REG2.
539 The result is placed in SLJIT_TEMPORARY_REG1 and the remainder goes to SLJIT_TEMPORARY_REG2.
540 Note: if SLJIT_TEMPORARY_REG2 contains 0, the behaviour is undefined. */
541 #define SLJIT_UDIV 4
542 #define SLJIT_IUDIV (SLJIT_UDIV | SLJIT_INT_OP)
543 /* Flags: I - (may destroy flags)
544 Signed divide of the value in SLJIT_TEMPORARY_REG1 by the value in SLJIT_TEMPORARY_REG2.
545 The result is placed in SLJIT_TEMPORARY_REG1 and the remainder goes to SLJIT_TEMPORARY_REG2.
546 Note: if SLJIT_TEMPORARY_REG2 contains 0, the behaviour is undefined. */
547 #define SLJIT_SDIV 5
548 #define SLJIT_ISDIV (SLJIT_SDIV | SLJIT_INT_OP)
549
550 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op);
551
552 /* Notes for MOV instructions:
553 U = Mov with update (post form). If source or destination defined as SLJIT_MEM1(r1)
554 or SLJIT_MEM2(r1, r2), r1 is increased by the sum of r2 and the constant argument
555 UB = unsigned byte (8 bit)
556 SB = signed byte (8 bit)
557 UH = unsigned half (16 bit)
558 SH = signed half (16 bit)
559 UI = unsigned int (32 bit)
560 SI = signed int (32 bit)
561 P = pointer (sljit_p) size */
562
563 /* Flags: - (never set any flags) */
564 #define SLJIT_MOV 6
565 /* Flags: I - (never set any flags) */
566 #define SLJIT_MOV_UB 7
567 #define SLJIT_IMOV_UB (SLJIT_MOV_UB | SLJIT_INT_OP)
568 /* Flags: I - (never set any flags) */
569 #define SLJIT_MOV_SB 8
570 #define SLJIT_IMOV_SB (SLJIT_MOV_SB | SLJIT_INT_OP)
571 /* Flags: I - (never set any flags) */
572 #define SLJIT_MOV_UH 9
573 #define SLJIT_IMOV_UH (SLJIT_MOV_UH | SLJIT_INT_OP)
574 /* Flags: I - (never set any flags) */
575 #define SLJIT_MOV_SH 10
576 #define SLJIT_IMOV_SH (SLJIT_MOV_SH | SLJIT_INT_OP)
577 /* Flags: I - (never set any flags)
578 Note: see SLJIT_INT_OP for further details. */
579 #define SLJIT_MOV_UI 11
580 /* No SLJIT_INT_OP form, since it the same as SLJIT_IMOVU. */
581 /* Flags: I - (never set any flags)
582 Note: see SLJIT_INT_OP for further details. */
583 #define SLJIT_MOV_SI 12
584 #define SLJIT_IMOV (SLJIT_MOV_SI | SLJIT_INT_OP)
585 /* Flags: - (never set any flags) */
586 #define SLJIT_MOV_P 13
587 /* Flags: - (never set any flags) */
588 #define SLJIT_MOVU 14
589 /* Flags: I - (never set any flags) */
590 #define SLJIT_MOVU_UB 15
591 #define SLJIT_IMOVU_UB (SLJIT_MOVU_UB | SLJIT_INT_OP)
592 /* Flags: I - (never set any flags) */
593 #define SLJIT_MOVU_SB 16
594 #define SLJIT_IMOVU_SB (SLJIT_MOVU_SB | SLJIT_INT_OP)
595 /* Flags: I - (never set any flags) */
596 #define SLJIT_MOVU_UH 17
597 #define SLJIT_IMOVU_UH (SLJIT_MOVU_UH | SLJIT_INT_OP)
598 /* Flags: I - (never set any flags) */
599 #define SLJIT_MOVU_SH 18
600 #define SLJIT_IMOVU_SH (SLJIT_MOVU_SH | SLJIT_INT_OP)
601 /* Flags: I - (never set any flags)
602 Note: see SLJIT_INT_OP for further details. */
603 #define SLJIT_MOVU_UI 19
604 /* No SLJIT_INT_OP form, since it the same as SLJIT_IMOVU. */
605 /* Flags: I - (never set any flags)
606 Note: see SLJIT_INT_OP for further details. */
607 #define SLJIT_MOVU_SI 20
608 #define SLJIT_IMOVU (SLJIT_MOVU_SI | SLJIT_INT_OP)
609 /* Flags: - (never set any flags) */
610 #define SLJIT_MOVU_P 21
611 /* Flags: I | E | K */
612 #define SLJIT_NOT 22
613 #define SLJIT_INOT (SLJIT_NOT | SLJIT_INT_OP)
614 /* Flags: I | E | O | K */
615 #define SLJIT_NEG 23
616 #define SLJIT_INEG (SLJIT_NEG | SLJIT_INT_OP)
617 /* Count leading zeroes
618 Flags: I | E | K
619 Important note! Sparc 32 does not support K flag, since
620 the required popc instruction is introduced only in sparc 64. */
621 #define SLJIT_CLZ 24
622 #define SLJIT_ICLZ (SLJIT_CLZ | SLJIT_INT_OP)
623
624 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
625 sljit_si dst, sljit_sw dstw,
626 sljit_si src, sljit_sw srcw);
627
628 /* Flags: I | E | O | C | K */
629 #define SLJIT_ADD 25
630 #define SLJIT_IADD (SLJIT_ADD | SLJIT_INT_OP)
631 /* Flags: I | C | K */
632 #define SLJIT_ADDC 26
633 #define SLJIT_IADDC (SLJIT_ADDC | SLJIT_INT_OP)
634 /* Flags: I | E | S | U | O | C | K */
635 #define SLJIT_SUB 27
636 #define SLJIT_ISUB (SLJIT_SUB | SLJIT_INT_OP)
637 /* Flags: I | C | K */
638 #define SLJIT_SUBC 28
639 #define SLJIT_ISUBC (SLJIT_SUBC | SLJIT_INT_OP)
640 /* Note: integer mul
641 Flags: I | O (see SLJIT_C_MUL_*) | K */
642 #define SLJIT_MUL 29
643 #define SLJIT_IMUL (SLJIT_MUL | SLJIT_INT_OP)
644 /* Flags: I | E | K */
645 #define SLJIT_AND 30
646 #define SLJIT_IAND (SLJIT_AND | SLJIT_INT_OP)
647 /* Flags: I | E | K */
648 #define SLJIT_OR 31
649 #define SLJIT_IOR (SLJIT_OR | SLJIT_INT_OP)
650 /* Flags: I | E | K */
651 #define SLJIT_XOR 32
652 #define SLJIT_IXOR (SLJIT_XOR | SLJIT_INT_OP)
653 /* Flags: I | E | K
654 Let bit_length be the length of the shift operation: 32 or 64.
655 If src2 is immediate, src2w is masked by (bit_length - 1).
656 Otherwise, if the content of src2 is outside the range from 0
657 to bit_length - 1, the operation is undefined. */
658 #define SLJIT_SHL 33
659 #define SLJIT_ISHL (SLJIT_SHL | SLJIT_INT_OP)
660 /* Flags: I | E | K
661 Let bit_length be the length of the shift operation: 32 or 64.
662 If src2 is immediate, src2w is masked by (bit_length - 1).
663 Otherwise, if the content of src2 is outside the range from 0
664 to bit_length - 1, the operation is undefined. */
665 #define SLJIT_LSHR 34
666 #define SLJIT_ILSHR (SLJIT_LSHR | SLJIT_INT_OP)
667 /* Flags: I | E | K
668 Let bit_length be the length of the shift operation: 32 or 64.
669 If src2 is immediate, src2w is masked by (bit_length - 1).
670 Otherwise, if the content of src2 is outside the range from 0
671 to bit_length - 1, the operation is undefined. */
672 #define SLJIT_ASHR 35
673 #define SLJIT_IASHR (SLJIT_ASHR | SLJIT_INT_OP)
674
675 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
676 sljit_si dst, sljit_sw dstw,
677 sljit_si src1, sljit_sw src1w,
678 sljit_si src2, sljit_sw src2w);
679
680 /* The following function is a helper function for sljit_emit_op_custom.
681 It returns with the real machine register index of any SLJIT_TEMPORARY
682 SLJIT_SAVED or SLJIT_LOCALS register.
683 Note: it returns with -1 for virtual registers (all EREGs on x86-32).
684 Note: register returned by SLJIT_LOCALS_REG is not necessary the real
685 stack pointer register of the target architecture. */
686
687 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
688
689 /* Any instruction can be inserted into the instruction stream by
690 sljit_emit_op_custom. It has a similar purpose as inline assembly.
691 The size parameter must match to the instruction size of the target
692 architecture:
693
694 x86: 0 < size <= 15. The instruction argument can be byte aligned.
695 Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
696 if size == 4, the instruction argument must be 4 byte aligned.
697 Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
698
699 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
700 void *instruction, sljit_si size);
701
702 /* Returns with non-zero if fpu is available. */
703
704 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void);
705
706 /* Note: dst is the left and src is the right operand for SLJIT_FCMP.
707 Note: NaN check is always performed. If SLJIT_C_FLOAT_UNORDERED is set,
708 the comparison result is unpredictable.
709 Flags: SP | E | S (see SLJIT_C_FLOAT_*) */
710 #define SLJIT_CMPD 36
711 #define SLJIT_CMPS (SLJIT_CMPD | SLJIT_SINGLE_OP)
712 /* Flags: SP - (never set any flags) */
713 #define SLJIT_MOVD 37
714 #define SLJIT_MOVS (SLJIT_MOVD | SLJIT_SINGLE_OP)
715 /* Flags: SP - (never set any flags) */
716 #define SLJIT_NEGD 38
717 #define SLJIT_NEGS (SLJIT_NEGD | SLJIT_SINGLE_OP)
718 /* Flags: SP - (never set any flags) */
719 #define SLJIT_ABSD 39
720 #define SLJIT_ABSS (SLJIT_ABSD | SLJIT_SINGLE_OP)
721
722 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
723 sljit_si dst, sljit_sw dstw,
724 sljit_si src, sljit_sw srcw);
725
726 /* Flags: SP - (never set any flags) */
727 #define SLJIT_ADDD 40
728 #define SLJIT_ADDS (SLJIT_ADDD | SLJIT_SINGLE_OP)
729 /* Flags: SP - (never set any flags) */
730 #define SLJIT_SUBD 41
731 #define SLJIT_SUBS (SLJIT_SUBD | SLJIT_SINGLE_OP)
732 /* Flags: SP - (never set any flags) */
733 #define SLJIT_MULD 42
734 #define SLJIT_MULS (SLJIT_MULD | SLJIT_SINGLE_OP)
735 /* Flags: SP - (never set any flags) */
736 #define SLJIT_DIVD 43
737 #define SLJIT_DIVS (SLJIT_DIVD | SLJIT_SINGLE_OP)
738
739 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
740 sljit_si dst, sljit_sw dstw,
741 sljit_si src1, sljit_sw src1w,
742 sljit_si src2, sljit_sw src2w);
743
744 /* Label and jump instructions. */
745
746 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler);
747
748 /* Invert conditional instruction: xor (^) with 0x1 */
749 #define SLJIT_C_EQUAL 0
750 #define SLJIT_C_ZERO 0
751 #define SLJIT_C_NOT_EQUAL 1
752 #define SLJIT_C_NOT_ZERO 1
753
754 #define SLJIT_C_LESS 2
755 #define SLJIT_C_GREATER_EQUAL 3
756 #define SLJIT_C_GREATER 4
757 #define SLJIT_C_LESS_EQUAL 5
758 #define SLJIT_C_SIG_LESS 6
759 #define SLJIT_C_SIG_GREATER_EQUAL 7
760 #define SLJIT_C_SIG_GREATER 8
761 #define SLJIT_C_SIG_LESS_EQUAL 9
762
763 #define SLJIT_C_OVERFLOW 10
764 #define SLJIT_C_NOT_OVERFLOW 11
765
766 #define SLJIT_C_MUL_OVERFLOW 12
767 #define SLJIT_C_MUL_NOT_OVERFLOW 13
768
769 #define SLJIT_C_FLOAT_EQUAL 14
770 #define SLJIT_C_FLOAT_NOT_EQUAL 15
771 #define SLJIT_C_FLOAT_LESS 16
772 #define SLJIT_C_FLOAT_GREATER_EQUAL 17
773 #define SLJIT_C_FLOAT_GREATER 18
774 #define SLJIT_C_FLOAT_LESS_EQUAL 19
775 #define SLJIT_C_FLOAT_UNORDERED 20
776 #define SLJIT_C_FLOAT_ORDERED 21
777
778 #define SLJIT_JUMP 22
779 #define SLJIT_FAST_CALL 23
780 #define SLJIT_CALL0 24
781 #define SLJIT_CALL1 25
782 #define SLJIT_CALL2 26
783 #define SLJIT_CALL3 27
784
785 /* Fast calling method. See sljit_emit_fast_enter / sljit_emit_fast_return. */
786
787 /* The target can be changed during runtime (see: sljit_set_jump_addr). */
788 #define SLJIT_REWRITABLE_JUMP 0x1000
789
790 /* Emit a jump instruction. The destination is not set, only the type of the jump.
791 type must be between SLJIT_C_EQUAL and SLJIT_CALL3
792 type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP
793 Flags: - (never set any flags) for both conditional and unconditional jumps.
794 Flags: destroy all flags for calls. */
795 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type);
796
797 /* Basic arithmetic comparison. In most architectures it is implemented as
798 an SLJIT_SUB operation (with SLJIT_UNUSED destination and setting
799 appropriate flags) followed by a sljit_emit_jump. However some
800 architectures (i.e: MIPS) may employ special optimizations here. It is
801 suggested to use this comparison form when appropriate.
802 type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL
803 type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP
804 Flags: destroy flags. */
805 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
806 sljit_si src1, sljit_sw src1w,
807 sljit_si src2, sljit_sw src2w);
808
809 /* Basic floating point comparison. In most architectures it is implemented as
810 an SLJIT_FCMP operation (setting appropriate flags) followed by a
811 sljit_emit_jump. However some architectures (i.e: MIPS) may employ
812 special optimizations here. It is suggested to use this comparison form
813 when appropriate.
814 type must be between SLJIT_C_FLOAT_EQUAL and SLJIT_C_FLOAT_ORDERED
815 type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP and SLJIT_SINGLE_OP
816 Flags: destroy flags.
817 Note: if either operand is NaN, the behaviour is undefined for
818 type <= SLJIT_C_FLOAT_LESS_EQUAL. */
819 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
820 sljit_si src1, sljit_sw src1w,
821 sljit_si src2, sljit_sw src2w);
822
823 /* Set the destination of the jump to this label. */
824 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label);
825 /* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag.
826 Note: use sljit_emit_ijump for fixed jumps. */
827 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target);
828
829 /* Call function or jump anywhere. Both direct and indirect form
830 type must be between SLJIT_JUMP and SLJIT_CALL3
831 Direct form: set src to SLJIT_IMM() and srcw to the address
832 Indirect form: any other valid addressing mode
833 Flags: - (never set any flags) for unconditional jumps.
834 Flags: destroy all flags for calls. */
835 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw);
836
837 /* If op == SLJIT_MOV:
838 Set dst to 1 if condition is fulfilled, 0 otherwise
839 type must be between SLJIT_C_EQUAL and SLJIT_C_FLOAT_ORDERED
840 Flags: - (never set any flags)
841 If op == SLJIT_OR
842 Dst is used as src as well, and set its lowest bit to 1 if
843 the condition is fulfilled. Otherwise it does nothing.
844 Flags: E | K
845 Note: sljit_emit_cond_value does nothing, if dst is SLJIT_UNUSED (regardless of op). */
846 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_cond_value(struct sljit_compiler *compiler, sljit_si op, sljit_si dst, sljit_sw dstw, sljit_si type);
847
848 /* Copies the base address of SLJIT_LOCALS_REG+offset to dst.
849 Flags: - (never set any flags) */
850 SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset);
851
852 /* The constant can be changed runtime (see: sljit_set_const)
853 Flags: - (never set any flags) */
854 SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value);
855
856 /* After the code generation the address for label, jump and const instructions
857 are computed. Since these structures are freed sljit_free_compiler, the
858 addresses must be preserved by the user program elsewere. */
859 static SLJIT_INLINE sljit_uw sljit_get_label_addr(struct sljit_label *label) { return label->addr; }
860 static SLJIT_INLINE sljit_uw sljit_get_jump_addr(struct sljit_jump *jump) { return jump->addr; }
861 static SLJIT_INLINE sljit_uw sljit_get_const_addr(struct sljit_const *const_) { return const_->addr; }
862
863 /* Only the address is required to rewrite the code. */
864 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr);
865 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant);
866
867 /* --------------------------------------------------------------------- */
868 /* Miscellaneous utility functions */
869 /* --------------------------------------------------------------------- */
870
871 #define SLJIT_MAJOR_VERSION 0
872 #define SLJIT_MINOR_VERSION 90
873
874 /* Get the human readable name of the platfrom.
875 Can be useful for debugging on platforms like ARM, where ARM and
876 Thumb2 functions can be mixed. */
877 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void);
878
879 /* Portble helper function to get an offset of a member. */
880 #define SLJIT_OFFSETOF(base, member) ((sljit_sw)(&((base*)0x10)->member) - 0x10)
881
882 #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
883 /* This global lock is useful to compile common functions. */
884 SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void);
885 SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void);
886 #endif
887
888 #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
889
890 /* The sljit_stack is a utiliy feature of sljit, which allocates a
891 writable memory region between base (inclusive) and limit (exclusive).
892 Both base and limit is a pointer, and base is always <= than limit.
893 This feature uses the "address space reserve" feature
894 of modern operating systems. Basically we don't need to allocate a
895 huge memory block in one step for the worst case, we can start with
896 a smaller chunk and extend it later. Since the address space is
897 reserved, the data never copied to other regions, thus it is safe
898 to store pointers here. */
899
900 /* Note: The base field is aligned to PAGE_SIZE bytes (usually 4k or more).
901 Note: stack growing should not happen in small steps: 4k, 16k or even
902 bigger growth is better.
903 Note: this structure may not be supported by all operating systems.
904 Some kind of fallback mechanism is suggested when SLJIT_UTIL_STACK
905 is not defined. */
906
907 struct sljit_stack {
908 /* User data, anything can be stored here.
909 Starting with the same value as base. */
910 sljit_uw top;
911 /* These members are read only. */
912 sljit_uw base;
913 sljit_uw limit;
914 sljit_uw max_limit;
915 };
916
917 /* Returns NULL if unsuccessful.
918 Note: limit and max_limit contains the size for stack allocation
919 Note: the top field is initialized to base. */
920 SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit);
921 SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack);
922
923 /* Can be used to increase (allocate) or decrease (free) the memory area.
924 Returns with a non-zero value if unsuccessful. If new_limit is greater than
925 max_limit, it will fail. It is very easy to implement a stack data structure,
926 since the growth ratio can be added to the current limit, and sljit_stack_resize
927 will do all the necessary checks. The fields of the stack are not changed if
928 sljit_stack_resize fails. */
929 SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit);
930
931 #endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */
932
933 #if !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
934
935 /* Get the entry address of a given function. */
936 #define SLJIT_FUNC_OFFSET(func_name) ((sljit_sw)func_name)
937
938 #else /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
939
940 /* All JIT related code should be placed in the same context (library, binary, etc.). */
941
942 #define SLJIT_FUNC_OFFSET(func_name) ((sljit_sw)*(void**)func_name)
943
944 /* For powerpc64, the function pointers point to a context descriptor. */
945 struct sljit_function_context {
946 sljit_sw addr;
947 sljit_sw r2;
948 sljit_sw r11;
949 };
950
951 /* Fill the context arguments using the addr and the function.
952 If func_ptr is NULL, it will not be set to the address of context
953 If addr is NULL, the function address also comes from the func pointer. */
954 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_sw addr, void* func);
955
956 #endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
957
958 #endif /* _SLJIT_LIR_H_ */

  ViewVC Help
Powered by ViewVC 1.1.5