|
version 1.1.1.1, 2012/02/21 23:05:52
|
version 1.1.1.2, 2012/02/21 23:50:25
|
|
Line 1
|
Line 1
|
| /* |
/* |
| * Stack-less Just-In-Time compiler |
* Stack-less Just-In-Time compiler |
| * |
* |
| * Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved. | * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved. |
| * |
* |
| * Redistribution and use in source and binary forms, with or without modification, are |
* Redistribution and use in source and binary forms, with or without modification, are |
| * permitted provided that the following conditions are met: |
* permitted provided that the following conditions are met: |
|
Line 44
|
Line 44
|
| - The compiler is thread-safe |
- The compiler is thread-safe |
| Disadvantages: |
Disadvantages: |
| - Limited number of registers (only 6+4 integer registers, max 3+2 |
- Limited number of registers (only 6+4 integer registers, max 3+2 |
| temporary and max 3+2 general, and 4 floating point registers) | temporary, max 3+2 saved and 4 floating point registers) |
| In practice: |
In practice: |
| - This approach is very effective for interpreters |
- This approach is very effective for interpreters |
| - One of the general registers typically points to a stack interface | - One of the saved registers typically points to a stack interface |
| - It can jump to any exception handler anytime (even for another |
- It can jump to any exception handler anytime (even for another |
| function. It is safe for SLJIT.) |
function. It is safe for SLJIT.) |
| - Fast paths can be modified during runtime reflecting the changes |
- Fast paths can be modified during runtime reflecting the changes |
|
Line 64
|
Line 64
|
| #if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG) |
#if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG) |
| #include "sljitConfig.h" |
#include "sljitConfig.h" |
| #endif |
#endif |
| |
|
| |
/* The following header file defines useful macros for fine tuning |
| |
sljit based code generators. They are listed in the begining |
| |
of sljitConfigInternal.h */ |
| |
|
| #include "sljitConfigInternal.h" |
#include "sljitConfigInternal.h" |
| |
|
| /* --------------------------------------------------------------------- */ |
/* --------------------------------------------------------------------- */ |
|
Line 99
|
Line 104
|
| #define SLJIT_TEMPORARY_EREG1 4 |
#define SLJIT_TEMPORARY_EREG1 4 |
| #define SLJIT_TEMPORARY_EREG2 5 |
#define SLJIT_TEMPORARY_EREG2 5 |
| |
|
| /* General (saved) registers preserve their values across function calls. */ | /* Saved registers whose preserve their values across function calls. */ |
| #define SLJIT_GENERAL_REG1 6 | #define SLJIT_SAVED_REG1 6 |
| #define SLJIT_GENERAL_REG2 7 | #define SLJIT_SAVED_REG2 7 |
| #define SLJIT_GENERAL_REG3 8 | #define SLJIT_SAVED_REG3 8 |
| /* Note: Extra Registers cannot be used for memory addressing. */ |
/* Note: Extra Registers cannot be used for memory addressing. */ |
| /* Note: on x86-32, these registers are emulated (using stack loads & stores). */ |
/* Note: on x86-32, these registers are emulated (using stack loads & stores). */ |
| #define SLJIT_GENERAL_EREG1 9 | #define SLJIT_SAVED_EREG1 9 |
| #define SLJIT_GENERAL_EREG2 10 | #define SLJIT_SAVED_EREG2 10 |
| |
|
| /* Read-only register (cannot be the destination of an operation). */ |
/* Read-only register (cannot be the destination of an operation). */ |
| /* Note: SLJIT_MEM2( ... , SLJIT_LOCALS_REG) is not supported (x86 limitation). */ |
/* Note: SLJIT_MEM2( ... , SLJIT_LOCALS_REG) is not supported (x86 limitation). */ |
|
Line 122
|
Line 127
|
| |
|
| #define SLJIT_RETURN_REG SLJIT_TEMPORARY_REG1 |
#define SLJIT_RETURN_REG SLJIT_TEMPORARY_REG1 |
| |
|
| /* x86 prefers temporary registers for special purposes. If other | /* x86 prefers specific registers for special purposes. In case of shift |
| registers are used such purpose, it costs a little performance | by register it supports only SLJIT_TEMPORARY_REG3 for shift argument |
| drawback. It doesn't matter for other archs. */ | (which is the src2 argument of sljit_emit_op2). If another register is |
| | used, sljit must exchange data between registers which cause a minor |
| | slowdown. Other architectures has no such limitation. */ |
| |
|
| #define SLJIT_PREF_SHIFT_REG SLJIT_TEMPORARY_REG3 |
#define SLJIT_PREF_SHIFT_REG SLJIT_TEMPORARY_REG3 |
| |
|
|
Line 189 struct sljit_compiler {
|
Line 196 struct sljit_compiler {
|
| |
|
| /* Used local registers. */ |
/* Used local registers. */ |
| int temporaries; |
int temporaries; |
| /* Used general registers. */ | /* Used saved registers. */ |
| int generals; | int saveds; |
| /* Local stack size. */ |
/* Local stack size. */ |
| int local_size; |
int local_size; |
| /* Code size. */ |
/* Code size. */ |
|
Line 201 struct sljit_compiler {
|
Line 208 struct sljit_compiler {
|
| #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) |
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) |
| int args; |
int args; |
| int temporaries_start; |
int temporaries_start; |
| int generals_start; | int saveds_start; |
| #endif |
#endif |
| |
|
| #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) |
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) |
|
Line 221 struct sljit_compiler {
|
Line 228 struct sljit_compiler {
|
| sljit_ub *cpool_unique; |
sljit_ub *cpool_unique; |
| sljit_uw cpool_diff; |
sljit_uw cpool_diff; |
| sljit_uw cpool_fill; |
sljit_uw cpool_fill; |
| /* General fields. */ | /* Other members. */ |
| /* Contains pointer, "ldr pc, [...]" pairs. */ |
/* Contains pointer, "ldr pc, [...]" pairs. */ |
| sljit_uw patches; |
sljit_uw patches; |
| #endif |
#endif |
|
Line 305 static SLJIT_INLINE sljit_uw sljit_get_generated_code_
|
Line 312 static SLJIT_INLINE sljit_uw sljit_get_generated_code_
|
| /* Instruction generation. Returns with error code. */ |
/* Instruction generation. Returns with error code. */ |
| |
|
| /* |
/* |
| Entry instruction. The instruction has "args" number of arguments | The executable code is basically a function call from the viewpoint of |
| and will use the first "general" number of general registers. | the C language. The function calls must obey to the ABI (Application |
| The arguments are passed into the general registers (arg1 to general_reg1, and so on). | Binary Interface) of the platform, which specify the purpose of machine |
| Thus, "args" must be less or equal than "general". A local_size extra | registers and stack handling among other things. The sljit_emit_enter |
| stack space is allocated for the jit code (must be less or equal than | function emits the necessary instructions for setting up a new context |
| SLJIT_MAX_LOCAL_SIZE), which can accessed through SLJIT_LOCALS_REG (see | for the executable code and moves function arguments to the saved |
| the notes there). SLJIT_LOCALS_REG is not necessary the real stack pointer! | registers. The number of arguments are specified in the "args" |
| It just points somewhere in the stack if local_size > 0 (!). Thus, the only | parameter and the first argument goes to SLJIT_SAVED_REG1, the second |
| thing which is known that the memory area between SLJIT_LOCALS_REG and | goes to SLJIT_SAVED_REG2 and so on. The number of temporary and |
| SLJIT_LOCALS_REG + local_size is a valid stack area if local_size > 0 | saved registers are passed in "temporaries" and "saveds" arguments |
| */ | respectively. Since the saved registers contains the arguments, |
| | "args" must be less or equal than "saveds". The sljit_emit_enter |
| | is also capable of allocating a stack space for local variables. The |
| | "local_size" argument contains the size in bytes of this local area |
| | and its staring address is stored in SLJIT_LOCALS_REG. However |
| | the SLJIT_LOCALS_REG is not necessary the machine stack pointer. |
| | The memory bytes between SLJIT_LOCALS_REG (inclusive) and |
| | SLJIT_LOCALS_REG + local_size (exclusive) can be modified freely |
| | until the function returns. The stack space is uninitialized. |
| |
|
| /* Note: multiple calls of this function overwrites the previous call. */ | Note: every call of sljit_emit_enter and sljit_set_context overwrites |
| | the previous context. */ |
| |
|
| #define SLJIT_MAX_LOCAL_SIZE 65536 |
#define SLJIT_MAX_LOCAL_SIZE 65536 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size); | SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, |
| | int args, int temporaries, int saveds, int local_size); |
| |
|
| /* Since sljit_emit_return (and many asserts) uses variables which are initialized | /* The machine code has a context (which contains the local stack space size, |
| by sljit_emit_enter, a simple return is not possible if these variables are not | number of used registers, etc.) which initialized by sljit_emit_enter. Several |
| initialized. sljit_fake_enter does not emit any instruction, just initialize | functions (like sljit_emit_return) requres this context to be able to generate |
| those variables. */ | the appropriate code. However, some code fragments (like inline cache) may have |
| | no normal entry point so their context is unknown for the compiler. Using the |
| | function below we can specify thir context. |
| |
|
| |
Note: every call of sljit_emit_enter and sljit_set_context overwrites |
| |
the previous context. */ |
| |
|
| /* Note: multiple calls of this function overwrites the previous call. */ |
/* Note: multiple calls of this function overwrites the previous call. */ |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size); | SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, |
| | int args, int temporaries, int saveds, int local_size); |
| |
|
| /* Return from jit. See below the possible values for src and srcw. */ | /* Return from machine code. The op argument can be SLJIT_UNUSED which means the |
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw); | function does not return with anything or any opcode between SLJIT_MOV and |
| | SLJIT_MOV_SI (see sljit_emit_op1). As for src and srcw they must be 0 if op |
| | is SLJIT_UNUSED, otherwise see below the description about source and |
| | destination arguments. */ |
| | SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int op, |
| | int src, sljit_w srcw); |
| |
|
| /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL). |
/* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL). |
| All registers and even the stack frame is passed to the callee. The return address is |
All registers and even the stack frame is passed to the callee. The return address is |
|
Line 341 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
Line 369 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
| use this as a return value later. */ |
use this as a return value later. */ |
| |
|
| /* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine instructions |
/* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine instructions |
| are needed. Excellent for small uility functions, where saving general registers and setting up | are needed. Excellent for small uility functions, where saving registers and setting up |
| a new stack frame would cost too much performance. However, it is still possible to return |
a new stack frame would cost too much performance. However, it is still possible to return |
| to the address of the caller (or anywhere else). */ |
to the address of the caller (or anywhere else). */ |
| |
|
|
Line 350 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
Line 378 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct
|
| /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested, |
/* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested, |
| since many architectures do clever branch prediction on call / return instruction pairs. */ |
since many architectures do clever branch prediction on call / return instruction pairs. */ |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size); | SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size); |
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw); |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw); |
| |
|
| /* |
/* |
|
Line 365 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
Line 393 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
| */ |
*/ |
| |
|
| /* |
/* |
| IMPORATNT NOTE: memory access MUST be naturally aligned. | IMPORATNT NOTE: memory access MUST be naturally aligned except |
| | SLJIT_UNALIGNED macro is defined and its value is 1. |
| | |
| length | alignment |
length | alignment |
| ---------+----------- |
---------+----------- |
| byte | 1 byte (not aligned) |
byte | 1 byte (not aligned) |
| half | 2 byte (real_address & 0x1 == 0) |
half | 2 byte (real_address & 0x1 == 0) |
| int | 4 byte (real_address & 0x3 == 0) |
int | 4 byte (real_address & 0x3 == 0) |
| sljit_w | 4 byte if SLJIT_32BIT_ARCHITECTURE defined | sljit_w | 4 byte if SLJIT_32BIT_ARCHITECTURE is defined and its value is 1 |
| | 8 byte if SLJIT_64BIT_ARCHITECTURE defined | | 8 byte if SLJIT_64BIT_ARCHITECTURE is defined and its value is 1 |
| (This is a strict requirement for embedded systems.) | |
| |
|
| Note: different architectures have different addressing limitations |
Note: different architectures have different addressing limitations |
| Thus sljit may generate several instructions for other addressing modes |
Thus sljit may generate several instructions for other addressing modes |
|
Line 445 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
Line 474 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(st
|
| Note: may or may not cause an extra cycle wait |
Note: may or may not cause an extra cycle wait |
| it can even decrease the runtime in a few cases. */ |
it can even decrease the runtime in a few cases. */ |
| #define SLJIT_NOP 1 |
#define SLJIT_NOP 1 |
| |
/* Flags: may destroy flags |
| |
Unsigned multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2. |
| |
Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */ |
| |
#define SLJIT_UMUL 2 |
| |
/* Flags: may destroy flags |
| |
Signed multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2. |
| |
Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */ |
| |
#define SLJIT_SMUL 3 |
| |
/* Flags: I | may destroy flags |
| |
Unsigned divide of the value in SLJIT_TEMPORARY_REG1 by the value in SLJIT_TEMPORARY_REG2. |
| |
The result is placed in SLJIT_TEMPORARY_REG1 and the remainder goes to SLJIT_TEMPORARY_REG2. |
| |
Note: if SLJIT_TEMPORARY_REG2 contains 0, the behaviour is undefined. */ |
| |
#define SLJIT_UDIV 4 |
| |
/* Flags: I | may destroy flags |
| |
Signed divide of the value in SLJIT_TEMPORARY_REG1 by the value in SLJIT_TEMPORARY_REG2. |
| |
The result is placed in SLJIT_TEMPORARY_REG1 and the remainder goes to SLJIT_TEMPORARY_REG2. |
| |
Note: if SLJIT_TEMPORARY_REG2 contains 0, the behaviour is undefined. */ |
| |
#define SLJIT_SDIV 5 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op); |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op); |
| |
|
|
Line 457 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct slj
|
Line 504 SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct slj
|
| SH = unsgined half (16 bit) */ |
SH = unsgined half (16 bit) */ |
| |
|
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV 2 | #define SLJIT_MOV 6 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_UB 3 | #define SLJIT_MOV_UB 7 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_SB 4 | #define SLJIT_MOV_SB 8 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_UH 5 | #define SLJIT_MOV_UH 9 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_SH 6 | #define SLJIT_MOV_SH 10 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_UI 7 | #define SLJIT_MOV_UI 11 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOV_SI 8 | #define SLJIT_MOV_SI 12 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU 9 | #define SLJIT_MOVU 13 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_UB 10 | #define SLJIT_MOVU_UB 14 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_SB 11 | #define SLJIT_MOVU_SB 15 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_UH 12 | #define SLJIT_MOVU_UH 16 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_SH 13 | #define SLJIT_MOVU_SH 17 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_UI 14 | #define SLJIT_MOVU_UI 18 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_MOVU_SI 15 | #define SLJIT_MOVU_SI 19 |
| /* Flags: I | E | K */ |
/* Flags: I | E | K */ |
| #define SLJIT_NOT 16 | #define SLJIT_NOT 20 |
| /* Flags: I | E | O | K */ |
/* Flags: I | E | O | K */ |
| #define SLJIT_NEG 17 | #define SLJIT_NEG 21 |
| /* Count leading zeroes |
/* Count leading zeroes |
| Flags: I | E | K */ |
Flags: I | E | K */ |
| #define SLJIT_CLZ 18 | #define SLJIT_CLZ 22 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op, |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op, |
| int dst, sljit_w dstw, |
int dst, sljit_w dstw, |
| int src, sljit_w srcw); |
int src, sljit_w srcw); |
| |
|
| /* Flags: I | E | O | C | K */ |
/* Flags: I | E | O | C | K */ |
| #define SLJIT_ADD 19 | #define SLJIT_ADD 23 |
| /* Flags: I | C | K */ |
/* Flags: I | C | K */ |
| #define SLJIT_ADDC 20 | #define SLJIT_ADDC 24 |
| /* Flags: I | E | S | U | O | C | K */ |
/* Flags: I | E | S | U | O | C | K */ |
| #define SLJIT_SUB 21 | #define SLJIT_SUB 25 |
| /* Flags: I | C | K */ |
/* Flags: I | C | K */ |
| #define SLJIT_SUBC 22 | #define SLJIT_SUBC 26 |
| /* Note: integer mul */ | /* Note: integer mul |
| /* Flags: I | O (see SLJIT_C_MUL_*) | K */ | Flags: I | O (see SLJIT_C_MUL_*) | K */ |
| #define SLJIT_MUL 23 | #define SLJIT_MUL 27 |
| /* Flags: I | E | K */ |
/* Flags: I | E | K */ |
| #define SLJIT_AND 24 | #define SLJIT_AND 28 |
| /* Flags: I | E | K */ |
/* Flags: I | E | K */ |
| #define SLJIT_OR 25 | #define SLJIT_OR 29 |
| /* Flags: I | E | K */ |
/* Flags: I | E | K */ |
| #define SLJIT_XOR 26 | #define SLJIT_XOR 30 |
| /* Flags: I | E | K */ | /* Flags: I | E | K |
| #define SLJIT_SHL 27 | Let bit_length be the length of the shift operation: 32 or 64. |
| /* Flags: I | E | K */ | If src2 is immediate, src2w is masked by (bit_length - 1). |
| #define SLJIT_LSHR 28 | Otherwise, if the content of src2 is outside the range from 0 |
| /* Flags: I | E | K */ | to bit_length - 1, the operation is undefined. */ |
| #define SLJIT_ASHR 29 | #define SLJIT_SHL 31 |
| | /* Flags: I | E | K |
| | Let bit_length be the length of the shift operation: 32 or 64. |
| | If src2 is immediate, src2w is masked by (bit_length - 1). |
| | Otherwise, if the content of src2 is outside the range from 0 |
| | to bit_length - 1, the operation is undefined. */ |
| | #define SLJIT_LSHR 32 |
| | /* Flags: I | E | K |
| | Let bit_length be the length of the shift operation: 32 or 64. |
| | If src2 is immediate, src2w is masked by (bit_length - 1). |
| | Otherwise, if the content of src2 is outside the range from 0 |
| | to bit_length - 1, the operation is undefined. */ |
| | #define SLJIT_ASHR 33 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op, |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op, |
| int dst, sljit_w dstw, |
int dst, sljit_w dstw, |
| int src1, sljit_w src1w, |
int src1, sljit_w src1w, |
| int src2, sljit_w src2w); |
int src2, sljit_w src2w); |
| |
|
| |
/* The following function is a helper function for sljit_emit_op_custom. |
| |
It returns with the real machine register index of any SLJIT_TEMPORARY |
| |
SLJIT_SAVED or SLJIT_LOCALS register. |
| |
Note: it returns with -1 for virtual registers (all EREGs on x86-32). |
| |
Note: register returned by SLJIT_LOCALS_REG is not necessary the real |
| |
stack pointer register of the target architecture. */ |
| |
|
| |
SLJIT_API_FUNC_ATTRIBUTE int sljit_get_register_index(int reg); |
| |
|
| |
/* Any instruction can be inserted into the instruction stream by |
| |
sljit_emit_op_custom. It has a similar purpose as inline assembly. |
| |
The size parameter must match to the instruction size of the target |
| |
architecture: |
| |
|
| |
x86: 0 < size <= 15. The instruction argument can be byte aligned. |
| |
Thumb2: if size == 2, the instruction argument must be 2 byte aligned. |
| |
if size == 4, the instruction argument must be 4 byte aligned. |
| |
Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */ |
| |
|
| |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler, |
| |
void *instruction, int size); |
| |
|
| |
/* Returns with non-zero if fpu is available. */ |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void); |
SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void); |
| |
|
| /* Note: dst is the left and src is the right operand for SLJIT_FCMP. |
/* Note: dst is the left and src is the right operand for SLJIT_FCMP. |
| Note: NaN check is always performed. If SLJIT_C_FLOAT_NAN is set, |
Note: NaN check is always performed. If SLJIT_C_FLOAT_NAN is set, |
| the comparison result is unpredictable. |
the comparison result is unpredictable. |
| Flags: E | S (see SLJIT_C_FLOAT_*) */ |
Flags: E | S (see SLJIT_C_FLOAT_*) */ |
| #define SLJIT_FCMP 30 | #define SLJIT_FCMP 34 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FMOV 31 | #define SLJIT_FMOV 35 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FNEG 32 | #define SLJIT_FNEG 36 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FABS 33 | #define SLJIT_FABS 37 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op, |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op, |
| int dst, sljit_w dstw, |
int dst, sljit_w dstw, |
| int src, sljit_w srcw); |
int src, sljit_w srcw); |
| |
|
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FADD 34 | #define SLJIT_FADD 38 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FSUB 35 | #define SLJIT_FSUB 39 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FMUL 36 | #define SLJIT_FMUL 40 |
| /* Flags: - (never set any flags) */ |
/* Flags: - (never set any flags) */ |
| #define SLJIT_FDIV 37 | #define SLJIT_FDIV 41 |
| |
|
| SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op, |
SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op, |
| int dst, sljit_w dstw, |
int dst, sljit_w dstw, |
|
Line 610 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emi
|
Line 693 SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emi
|
| Flags: destroy all flags for calls. */ |
Flags: destroy all flags for calls. */ |
| SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type); |
SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type); |
| |
|
| /* Basic arithmetic comparison. In most architectures it is equal to | /* Basic arithmetic comparison. In most architectures it is implemented as |
| an SLJIT_SUB operation (with SLJIT_UNUSED destination) followed by a | an SLJIT_SUB operation (with SLJIT_UNUSED destination and setting |
| sljit_emit_jump. However some architectures (i.e: MIPS) may employ | appropriate flags) followed by a sljit_emit_jump. However some |
| special optimizations here. It is suggested to use this comparison | architectures (i.e: MIPS) may employ special optimizations here. It is |
| form when flags are unimportant. | suggested to use this comparison form when appropriate. |
| type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL |
type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL |
| type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP |
type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP |
| Flags: destroy flags. */ |
Flags: destroy flags. */ |
|
Line 622 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit
|
Line 705 SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit
|
| int src1, sljit_w src1w, |
int src1, sljit_w src1w, |
| int src2, sljit_w src2w); |
int src2, sljit_w src2w); |
| |
|
| |
/* Basic floating point comparison. In most architectures it is implemented as |
| |
an SLJIT_FCMP operation (setting appropriate flags) followed by a |
| |
sljit_emit_jump. However some architectures (i.e: MIPS) may employ |
| |
special optimizations here. It is suggested to use this comparison form |
| |
when appropriate. |
| |
type must be between SLJIT_C_FLOAT_EQUAL and SLJIT_C_FLOAT_NOT_NAN |
| |
type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP |
| |
Flags: destroy flags. |
| |
Note: if either operand is NaN, the behaviour is undefined for |
| |
type <= SLJIT_C_FLOAT_LESS_EQUAL. */ |
| |
SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, int type, |
| |
int src1, sljit_w src1w, |
| |
int src2, sljit_w src2w); |
| |
|
| /* Set the destination of the jump to this label. */ |
/* Set the destination of the jump to this label. */ |
| SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label); |
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label); |
| /* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag. |
/* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag. |
|
Line 667 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw
|
Line 764 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw
|
| /* --------------------------------------------------------------------- */ |
/* --------------------------------------------------------------------- */ |
| |
|
| #define SLJIT_MAJOR_VERSION 0 |
#define SLJIT_MAJOR_VERSION 0 |
| #define SLJIT_MINOR_VERSION 82 | #define SLJIT_MINOR_VERSION 87 |
| |
|
| /* Get the human readable name of the platfrom. |
/* Get the human readable name of the platfrom. |
| Can be useful for debugging on platforms like ARM, where ARM and |
Can be useful for debugging on platforms like ARM, where ARM and |
|
Line 675 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw
|
Line 772 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw
|
| SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void); |
SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void); |
| |
|
| /* Portble helper function to get an offset of a member. */ |
/* Portble helper function to get an offset of a member. */ |
| #define SLJIT_OFFSETOF(base, member) ((sljit_w)(&((base*)0x10)->member) - 0x10) | #define SLJIT_OFFSETOF(base, member) ((sljit_w)(&((base*)0x10)->member) - 0x10) |
| |
|
| #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK) |
#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK) |
| /* This global lock is useful to compile common functions. */ |
/* This global lock is useful to compile common functions. */ |