2 * Stack-less Just-In-Time compiler
4 * Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
6 * Redistribution and use in source and binary forms, with or without modification, are
7 * permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice, this list of
10 * conditions and the following disclaimer.
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.
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.
27 /* Must be the first one. Must not depend on any other include. */
34 #if defined _WIN32 || defined _WIN64
40 #define COLOR_RED "\33[31m"
41 #define COLOR_GREEN "\33[32m"
42 #define COLOR_ARCH "\33[33m"
43 #define COLOR_DEFAULT "\33[0m"
46 union executable_code
{
48 sljit_sw (SLJIT_CALL
*func0
)(void);
49 sljit_sw (SLJIT_CALL
*func1
)(sljit_sw a
);
50 sljit_sw (SLJIT_CALL
*func2
)(sljit_sw a
, sljit_sw b
);
51 sljit_sw (SLJIT_CALL
*func3
)(sljit_sw a
, sljit_sw b
, sljit_sw c
);
53 typedef union executable_code executable_code
;
55 static sljit_si successful_tests
= 0;
56 static sljit_si verbose
= 0;
57 static sljit_si silent
= 0;
59 #define FAILED(cond, text) \
60 if (SLJIT_UNLIKELY(cond)) { \
65 #define CHECK(compiler) \
66 if (sljit_get_compiler_error(compiler) != SLJIT_ERR_COMPILED) { \
67 printf("Compiler error: %d\n", sljit_get_compiler_error(compiler)); \
68 sljit_free_compiler(compiler); \
72 static void cond_set(struct sljit_compiler
*compiler
, sljit_si dst
, sljit_sw dstw
, sljit_si type
)
74 /* Testing both sljit_emit_op_flags and sljit_emit_jump. */
75 struct sljit_jump
* jump
;
76 struct sljit_label
* label
;
78 sljit_emit_op_flags(compiler
, SLJIT_MOV
, dst
, dstw
, SLJIT_UNUSED
, 0, type
);
79 jump
= sljit_emit_jump(compiler
, type
);
80 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_KEEP_FLAGS
, dst
, dstw
, dst
, dstw
, SLJIT_IMM
, 2);
81 label
= sljit_emit_label(compiler
);
82 sljit_set_label(jump
, label
);
85 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
87 #define MALLOC_EXEC(result, size) \
88 result = SLJIT_MALLOC_EXEC(size); \
90 printf("Cannot allocate executable memory\n"); \
93 memset(result, 255, size);
95 static void test_exec_allocator(void)
97 /* This is not an sljit test. */
103 printf("Run executable allocator test\n");
105 MALLOC_EXEC(ptr1
, 32);
106 MALLOC_EXEC(ptr2
, 512);
107 MALLOC_EXEC(ptr3
, 512);
108 SLJIT_FREE_EXEC(ptr2
);
109 SLJIT_FREE_EXEC(ptr3
);
110 SLJIT_FREE_EXEC(ptr1
);
111 MALLOC_EXEC(ptr1
, 262104);
112 MALLOC_EXEC(ptr2
, 32000);
113 SLJIT_FREE_EXEC(ptr1
);
114 MALLOC_EXEC(ptr1
, 262104);
115 SLJIT_FREE_EXEC(ptr1
);
116 SLJIT_FREE_EXEC(ptr2
);
117 MALLOC_EXEC(ptr1
, 512);
118 MALLOC_EXEC(ptr2
, 512);
119 MALLOC_EXEC(ptr3
, 512);
120 SLJIT_FREE_EXEC(ptr2
);
121 MALLOC_EXEC(ptr2
, 512);
122 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
123 sljit_free_unused_memory_exec();
125 SLJIT_FREE_EXEC(ptr3
);
126 SLJIT_FREE_EXEC(ptr1
);
127 SLJIT_FREE_EXEC(ptr2
);
128 #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
129 /* Just call the global locks. */
131 sljit_release_lock();
134 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
135 sljit_free_unused_memory_exec();
141 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
143 static void test1(void)
145 /* Enter and return from an sljit function. */
146 executable_code code
;
147 struct sljit_compiler
* compiler
= sljit_create_compiler();
150 printf("Run test1\n");
152 FAILED(!compiler
, "cannot create compiler\n");
154 /* 3 arguments passed, 3 arguments used. */
155 sljit_emit_enter(compiler
, 0, 3, 3, 3, 0, 0, 0);
156 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_S1
, 0);
158 SLJIT_ASSERT(sljit_get_generated_code_size(compiler
) == 0);
159 code
.code
= sljit_generate_code(compiler
);
161 SLJIT_ASSERT(compiler
->error
== SLJIT_ERR_COMPILED
);
162 SLJIT_ASSERT(sljit_get_generated_code_size(compiler
) > 0);
163 sljit_free_compiler(compiler
);
165 FAILED(code
.func3(3, -21, 86) != -21, "test1 case 1 failed\n");
166 FAILED(code
.func3(4789, 47890, 997) != 47890, "test1 case 2 failed\n");
168 sljit_free_code(code
.code
);
172 static void test2(void)
175 executable_code code
;
176 struct sljit_compiler
* compiler
= sljit_create_compiler();
178 static sljit_sw data
[2] = { 0, -9876 };
181 printf("Run test2\n");
183 FAILED(!compiler
, "cannot create compiler\n");
193 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
194 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_UNUSED
, 0, SLJIT_MEM0(), (sljit_sw
)&buf
);
195 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 9999);
196 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_S0
, 0);
197 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_R0
, 0);
198 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
199 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 0);
200 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 2);
201 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_S0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 0);
202 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 3);
203 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_S0
), SLJIT_WORD_SHIFT
, SLJIT_MEM0(), (sljit_sw
)&buf
);
204 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
205 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&data
);
206 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
207 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0x12345678);
208 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), 0x12345678);
209 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
210 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3456);
211 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0xff890 + 6 * sizeof(sljit_sw
));
212 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0xff890, SLJIT_R0
, 0);
213 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
+ 0xff890 + 7 * sizeof(sljit_sw
));
214 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), -0xff890, SLJIT_R0
, 0);
215 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R2
, 0);
217 code
.code
= sljit_generate_code(compiler
);
219 sljit_free_compiler(compiler
);
221 FAILED(code
.func1((sljit_sw
)&buf
) != 9999, "test2 case 1 failed\n");
222 FAILED(buf
[1] != 9999, "test2 case 2 failed\n");
223 FAILED(buf
[2] != 9999, "test2 case 3 failed\n");
224 FAILED(buf
[3] != 5678, "test2 case 4 failed\n");
225 FAILED(buf
[4] != -9876, "test2 case 5 failed\n");
226 FAILED(buf
[5] != 5678, "test2 case 6 failed\n");
227 FAILED(buf
[6] != 3456, "test2 case 6 failed\n");
228 FAILED(buf
[7] != 3456, "test2 case 6 failed\n");
230 sljit_free_code(code
.code
);
234 static void test3(void)
237 executable_code code
;
238 struct sljit_compiler
* compiler
= sljit_create_compiler();
242 printf("Run test3\n");
244 FAILED(!compiler
, "cannot create compiler\n");
251 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
252 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_UNUSED
, 0, SLJIT_MEM0(), (sljit_sw
)&buf
);
253 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0);
254 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM0(), (sljit_sw
)&buf
[1], SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
255 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
256 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2);
257 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[4] - 0xff0000 - 0x20);
258 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[4] - 0xff0000);
259 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM1(SLJIT_R1
), 0xff0000 + 0x20, SLJIT_MEM1(SLJIT_R2
), 0xff0000);
260 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
262 code
.code
= sljit_generate_code(compiler
);
264 sljit_free_compiler(compiler
);
266 FAILED(code
.func1((sljit_sw
)&buf
) != ~1234, "test3 case 1 failed\n");
267 FAILED(buf
[1] != ~1234, "test3 case 2 failed\n");
268 FAILED(buf
[3] != ~9876, "test3 case 3 failed\n");
269 FAILED(buf
[4] != ~0x12345678, "test3 case 4 failed\n");
271 sljit_free_code(code
.code
);
275 static void test4(void)
278 executable_code code
;
279 struct sljit_compiler
* compiler
= sljit_create_compiler();
283 printf("Run test4\n");
285 FAILED(!compiler
, "cannot create compiler\n");
291 sljit_emit_enter(compiler
, 0, 2, 3, 2, 0, 0, 0);
292 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
293 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_S1
, 0);
294 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_MEM0(), (sljit_sw
)&buf
[0], SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
295 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_RETURN_REG
, 0, SLJIT_S1
, 0);
296 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 299);
297 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
299 code
.code
= sljit_generate_code(compiler
);
301 sljit_free_compiler(compiler
);
303 FAILED(code
.func2((sljit_sw
)&buf
, 4567) != -4567, "test4 case 1 failed\n");
304 FAILED(buf
[0] != -1234, "test4 case 2 failed\n");
305 FAILED(buf
[2] != -4567, "test4 case 3 failed\n");
306 FAILED(buf
[3] != -299, "test4 case 4 failed\n");
308 sljit_free_code(code
.code
);
312 static void test5(void)
315 executable_code code
;
316 struct sljit_compiler
* compiler
= sljit_create_compiler();
320 printf("Run test5\n");
322 FAILED(!compiler
, "cannot create compiler\n");
333 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
334 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 16, SLJIT_IMM
, 16);
335 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 255, SLJIT_IMM
, 255);
336 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_UNUSED
, 0, SLJIT_S0
, 0, SLJIT_S0
, 0);
337 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
338 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 50);
339 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 1, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 1, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 0);
340 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
) + 2);
341 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 50);
342 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
343 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
344 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, 4, SLJIT_R0
, 0);
345 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_IMM
, 50, SLJIT_R1
, 0);
346 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, 50, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
));
347 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
348 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
));
349 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
));
350 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R1
, 0);
351 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x1e7d39f2);
352 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_IMM
, 0x23de7c06);
353 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, 0x3d72e452, SLJIT_R1
, 0);
354 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_IMM
, -43, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
));
355 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, 1000, SLJIT_R0
, 0);
356 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1430);
357 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, -99, SLJIT_R0
, 0);
359 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
361 code
.code
= sljit_generate_code(compiler
);
363 sljit_free_compiler(compiler
);
365 FAILED(code
.func1((sljit_sw
)&buf
) != 2437 + 2 * sizeof(sljit_sw
), "test5 case 1 failed\n");
366 FAILED(buf
[0] != 202 + 2 * sizeof(sljit_sw
), "test5 case 2 failed\n");
367 FAILED(buf
[2] != 500, "test5 case 3 failed\n");
368 FAILED(buf
[3] != 400, "test5 case 4 failed\n");
369 FAILED(buf
[4] != 200, "test5 case 5 failed\n");
370 FAILED(buf
[5] != 250, "test5 case 6 failed\n");
371 FAILED(buf
[6] != 0x425bb5f8, "test5 case 7 failed\n");
372 FAILED(buf
[7] != 0x5bf01e44, "test5 case 8 failed\n");
373 FAILED(buf
[8] != 270, "test5 case 9 failed\n");
375 sljit_free_code(code
.code
);
379 static void test6(void)
381 /* Test addc, sub, subc. */
382 executable_code code
;
383 struct sljit_compiler
* compiler
= sljit_create_compiler();
387 printf("Run test6\n");
389 FAILED(!compiler
, "cannot create compiler\n");
401 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
402 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
403 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_C
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -1);
404 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0, SLJIT_IMM
, 0);
405 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_C
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
406 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 4);
407 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
408 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, 50);
409 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_C
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 6000);
410 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 10);
411 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 5);
412 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
413 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2);
414 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
415 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5000);
416 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
417 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
418 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R1
, 0);
419 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5000);
420 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_IMM
, 6000, SLJIT_R0
, 0);
421 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_R0
, 0);
422 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
423 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32768);
424 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_R1
, 0);
425 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -32767);
426 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_R1
, 0);
427 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x52cd3bf4);
428 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_R0
, 0, SLJIT_IMM
, 0x3da297c6);
429 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 10);
430 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_C
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 5);
431 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 2);
432 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, -2220);
433 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
435 code
.code
= sljit_generate_code(compiler
);
437 sljit_free_compiler(compiler
);
439 FAILED(code
.func1((sljit_sw
)&buf
) != 2223, "test6 case 1 failed\n");
440 FAILED(buf
[0] != 1, "test6 case 2 failed\n");
441 FAILED(buf
[1] != 5, "test6 case 3 failed\n");
442 FAILED(buf
[2] != 50, "test6 case 4 failed\n");
443 FAILED(buf
[3] != 4, "test6 case 5 failed\n");
444 FAILED(buf
[4] != 50, "test6 case 6 failed\n");
445 FAILED(buf
[5] != 50, "test6 case 7 failed\n");
446 FAILED(buf
[6] != 1000, "test6 case 8 failed\n");
447 FAILED(buf
[7] != 100 - 32768, "test6 case 9 failed\n");
448 FAILED(buf
[8] != 100 + 32767, "test6 case 10 failed\n");
449 FAILED(buf
[9] != 0x152aa42e, "test6 case 11 failed\n");
451 sljit_free_code(code
.code
);
455 static void test7(void)
457 /* Test logical operators. */
458 executable_code code
;
459 struct sljit_compiler
* compiler
= sljit_create_compiler();
463 printf("Run test7\n");
465 FAILED(!compiler
, "cannot create compiler\n");
475 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
476 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf0C000);
477 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, 0x308f);
478 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
479 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 0xf0f0f0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3);
480 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xC0F0);
481 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5);
482 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xff0000);
483 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
484 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0xC0F0);
485 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_R2
, 0, SLJIT_R2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5);
486 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R2
, 0, SLJIT_IMM
, 0xff0000);
487 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 0xFFFFFF, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
488 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_IMM
, 0xa56c82c0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6);
489 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7);
490 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_IMM
, 0xff00ff00, SLJIT_R0
, 0);
491 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xff00ff00);
492 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x0f);
493 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0x888888, SLJIT_R1
, 0);
494 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
496 code
.code
= sljit_generate_code(compiler
);
498 sljit_free_compiler(compiler
);
500 FAILED(code
.func1((sljit_sw
)&buf
) != 0x8808, "test7 case 1 failed\n");
501 FAILED(buf
[0] != 0x0F807F00, "test7 case 2 failed\n");
502 FAILED(buf
[1] != 0x0F7F7F7F, "test7 case 3 failed\n");
503 FAILED(buf
[2] != 0x00F0F08F, "test7 case 4 failed\n");
504 FAILED(buf
[3] != 0x00A0A0A0, "test7 case 5 failed\n");
505 FAILED(buf
[4] != 0x00FF80B0, "test7 case 6 failed\n");
506 FAILED(buf
[5] != 0x00FF4040, "test7 case 7 failed\n");
507 FAILED(buf
[6] != 0xa56c82c0, "test7 case 8 failed\n");
508 FAILED(buf
[7] != 0x3b3a8095, "test7 case 9 failed\n");
510 sljit_free_code(code
.code
);
514 static void test8(void)
516 /* Test flags (neg, cmp, test). */
517 executable_code code
;
518 struct sljit_compiler
* compiler
= sljit_create_compiler();
522 printf("Run test8\n");
524 FAILED(!compiler
, "cannot create compiler\n");
539 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
540 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 20);
541 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 10);
542 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 6, SLJIT_IMM
, 5);
543 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_NOT_EQUAL
);
544 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
545 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 3000);
546 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_UNUSED
, 0, SLJIT_GREATER
);
547 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_S1
, 0);
548 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_UNUSED
, 0, SLJIT_LESS
);
549 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R2
, 0);
550 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -15);
551 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_UNUSED
, 0, SLJIT_SIG_GREATER
);
552 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R2
, 0);
553 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
554 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
555 sljit_emit_op1(compiler
, SLJIT_NEG
| SLJIT_SET_E
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_IMM
, (sljit_sw
)1 << ((sizeof(sljit_sw
) << 3) - 1));
556 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_UNUSED
, 0, SLJIT_OVERFLOW
);
557 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
558 sljit_emit_op1(compiler
, SLJIT_NOT
| SLJIT_SET_E
, SLJIT_R1
, 0, SLJIT_R0
, 0);
559 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_UNUSED
, 0, SLJIT_ZERO
);
560 sljit_emit_op1(compiler
, SLJIT_NOT
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0);
561 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_UNUSED
, 0, SLJIT_ZERO
);
562 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 0xffff, SLJIT_R0
, 0);
563 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffff);
564 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
565 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 0xffff, SLJIT_R1
, 0);
566 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 0xffff);
567 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
568 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
569 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
570 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0x1);
571 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
572 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)1 << ((sizeof(sljit_sw
) << 3) - 1));
573 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
574 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
575 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 11, SLJIT_UNUSED
, 0, SLJIT_OVERFLOW
);
576 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
577 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 12, SLJIT_UNUSED
, 0, SLJIT_OVERFLOW
);
578 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
580 code
.code
= sljit_generate_code(compiler
);
582 sljit_free_compiler(compiler
);
584 code
.func1((sljit_sw
)&buf
);
585 FAILED(buf
[1] != 1, "test8 case 1 failed\n");
586 FAILED(buf
[2] != 0, "test8 case 2 failed\n");
587 FAILED(buf
[3] != 0, "test8 case 3 failed\n");
588 FAILED(buf
[4] != 1, "test8 case 4 failed\n");
589 FAILED(buf
[5] != 1, "test8 case 5 failed\n");
590 FAILED(buf
[6] != 1, "test8 case 6 failed\n");
591 FAILED(buf
[7] != 1, "test8 case 7 failed\n");
592 FAILED(buf
[8] != 0, "test8 case 8 failed\n");
593 FAILED(buf
[9] != 1, "test8 case 9 failed\n");
594 FAILED(buf
[10] != 0, "test8 case 10 failed\n");
595 FAILED(buf
[11] != 1, "test8 case 11 failed\n");
596 FAILED(buf
[12] != 0, "test8 case 12 failed\n");
598 sljit_free_code(code
.code
);
602 static void test9(void)
605 executable_code code
;
606 struct sljit_compiler
* compiler
= sljit_create_compiler();
610 printf("Run test9\n");
612 FAILED(!compiler
, "cannot create compiler\n");
627 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
628 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf);
629 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 3);
630 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
631 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
632 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2);
633 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
634 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_IMM
, 1);
635 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -64);
636 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 2);
637 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
639 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 0xff);
640 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
641 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_R0
, 0);
642 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_PREF_SHIFT_REG
, 0);
643 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 0xff);
644 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
645 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
646 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_R0
, 0);
648 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0xf);
649 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
650 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_R0
, 0);
651 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_S1
, 0);
652 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_R0
, 0);
653 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_R0
, 0);
654 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0xf00);
655 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
656 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R1
, 0, SLJIT_R2
, 0, SLJIT_R0
, 0);
657 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_R1
, 0);
659 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)buf
);
660 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 9);
661 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), SLJIT_WORD_SHIFT
);
663 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 4);
664 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 2, SLJIT_PREF_SHIFT_REG
, 0);
665 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_PREF_SHIFT_REG
, 0);
667 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xa9);
668 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
669 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x7d00);
670 sljit_emit_op2(compiler
, SLJIT_ILSHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32);
671 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
672 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
674 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
675 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xe30000);
676 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
677 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffc0);
679 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffe0);
681 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
682 sljit_emit_op1(compiler
, SLJIT_MOV_SI
| SLJIT_INT_OP
, SLJIT_R0
, 0, SLJIT_IMM
, 0x25000000);
683 sljit_emit_op2(compiler
, SLJIT_ISHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xfffe1);
684 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
685 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
687 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 11, SLJIT_R1
, 0, SLJIT_R0
, 0);
689 SLJIT_ASSERT(SLJIT_R2
== SLJIT_PREF_SHIFT_REG
);
690 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 0);
691 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x5c);
692 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
693 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf600);
694 sljit_emit_op2(compiler
, SLJIT_ILSHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
695 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
696 /* Alternative form of uint32 type cast. */
697 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffffffff);
699 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
700 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x630000);
701 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
702 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 12, SLJIT_R1
, 0, SLJIT_R0
, 0);
704 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
706 code
.code
= sljit_generate_code(compiler
);
708 sljit_free_compiler(compiler
);
710 code
.func1((sljit_sw
)&buf
);
711 FAILED(buf
[0] != 0x3c, "test9 case 1 failed\n");
712 FAILED(buf
[1] != 0xf0, "test9 case 2 failed\n");
713 FAILED(buf
[2] != -16, "test9 case 3 failed\n");
714 FAILED(buf
[3] != 0xff0, "test9 case 4 failed\n");
715 FAILED(buf
[4] != 4, "test9 case 5 failed\n");
716 FAILED(buf
[5] != 0xff00, "test9 case 6 failed\n");
717 FAILED(buf
[6] != 0x3c, "test9 case 7 failed\n");
718 FAILED(buf
[7] != 0xf0, "test9 case 8 failed\n");
719 FAILED(buf
[8] != 0xf0, "test9 case 9 failed\n");
720 FAILED(buf
[9] != 0x18, "test9 case 10 failed\n");
721 FAILED(buf
[10] != 32, "test9 case 11 failed\n");
722 FAILED(buf
[11] != 0x4ae37da9, "test9 case 12 failed\n");
723 FAILED(buf
[12] != 0x63f65c, "test9 case 13 failed\n");
725 sljit_free_code(code
.code
);
729 static void test10(void)
731 /* Test multiplications. */
732 executable_code code
;
733 struct sljit_compiler
* compiler
= sljit_create_compiler();
737 printf("Run test10\n");
739 FAILED(!compiler
, "cannot create compiler\n");
748 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
749 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
750 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
751 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
752 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 7);
753 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 8);
754 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
755 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_IMM
, -3, SLJIT_IMM
, -4);
756 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0);
757 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -2);
758 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_R0
, 0);
759 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
) / 2);
760 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[3]);
761 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 1, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 1, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 1);
762 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 9);
763 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
764 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R0
, 0);
765 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
766 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
767 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x123456789));
768 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_R0
, 0);
770 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 11, SLJIT_IMM
, 10);
771 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
773 code
.code
= sljit_generate_code(compiler
);
775 sljit_free_compiler(compiler
);
777 FAILED(code
.func1((sljit_sw
)&buf
) != 110, "test10 case 1 failed\n");
778 FAILED(buf
[0] != 15, "test10 case 2 failed\n");
779 FAILED(buf
[1] != 56, "test10 case 3 failed\n");
780 FAILED(buf
[2] != 12, "test10 case 4 failed\n");
781 FAILED(buf
[3] != -12, "test10 case 5 failed\n");
782 FAILED(buf
[4] != 100, "test10 case 6 failed\n");
783 FAILED(buf
[5] != 81, "test10 case 7 failed\n");
784 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
785 FAILED(buf
[6] != SLJIT_W(0x123456789) * 3, "test10 case 8 failed\n");
788 sljit_free_code(code
.code
);
792 static void test11(void)
794 /* Test rewritable constants. */
795 executable_code code
;
796 struct sljit_compiler
* compiler
= sljit_create_compiler();
797 struct sljit_const
* const1
;
798 struct sljit_const
* const2
;
799 struct sljit_const
* const3
;
800 struct sljit_const
* const4
;
802 sljit_uw const1_addr
;
803 sljit_uw const2_addr
;
804 sljit_uw const3_addr
;
805 sljit_uw const4_addr
;
806 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
807 sljit_sw word_value1
= SLJIT_W(0xaaaaaaaaaaaaaaaa);
808 sljit_sw word_value2
= SLJIT_W(0xfee1deadfbadf00d);
810 sljit_sw word_value1
= 0xaaaaaaaal
;
811 sljit_sw word_value2
= 0xfbadf00dl
;
816 printf("Run test11\n");
818 FAILED(!compiler
, "cannot create compiler\n");
823 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
825 const1
= sljit_emit_const(compiler
, SLJIT_MEM0(), (sljit_sw
)&buf
[0], -0x81b9);
826 SLJIT_ASSERT(!sljit_alloc_memory(compiler
, 0));
827 SLJIT_ASSERT(!sljit_alloc_memory(compiler
, 16 * sizeof(sljit_sw
) + 1));
828 value
= sljit_alloc_memory(compiler
, 16 * sizeof(sljit_sw
));
829 SLJIT_ASSERT(!((sljit_sw
)value
& (sizeof(sljit_sw
) - 1)));
830 memset(value
, 255, 16 * sizeof(sljit_sw
));
831 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
832 const2
= sljit_emit_const(compiler
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
- 1, -65535);
833 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[0] + 2 * sizeof(sljit_sw
) - 2);
834 const3
= sljit_emit_const(compiler
, SLJIT_MEM1(SLJIT_R0
), 0, word_value1
);
835 value
= sljit_alloc_memory(compiler
, 17);
836 SLJIT_ASSERT(!((sljit_sw
)value
& (sizeof(sljit_sw
) - 1)));
837 memset(value
, 255, 16);
838 const4
= sljit_emit_const(compiler
, SLJIT_RETURN_REG
, 0, 0xf7afcdb7);
840 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
842 code
.code
= sljit_generate_code(compiler
);
844 const1_addr
= sljit_get_const_addr(const1
);
845 const2_addr
= sljit_get_const_addr(const2
);
846 const3_addr
= sljit_get_const_addr(const3
);
847 const4_addr
= sljit_get_const_addr(const4
);
848 sljit_free_compiler(compiler
);
850 FAILED(code
.func1((sljit_sw
)&buf
) != 0xf7afcdb7, "test11 case 1 failed\n");
851 FAILED(buf
[0] != -0x81b9, "test11 case 2 failed\n");
852 FAILED(buf
[1] != -65535, "test11 case 3 failed\n");
853 FAILED(buf
[2] != word_value1
, "test11 case 4 failed\n");
855 sljit_set_const(const1_addr
, -1);
856 sljit_set_const(const2_addr
, word_value2
);
857 sljit_set_const(const3_addr
, 0xbab0fea1);
858 sljit_set_const(const4_addr
, -60089);
860 FAILED(code
.func1((sljit_sw
)&buf
) != -60089, "test11 case 5 failed\n");
861 FAILED(buf
[0] != -1, "test11 case 6 failed\n");
862 FAILED(buf
[1] != word_value2
, "test11 case 7 failed\n");
863 FAILED(buf
[2] != 0xbab0fea1, "test11 case 8 failed\n");
865 sljit_free_code(code
.code
);
869 static void test12(void)
871 /* Test rewriteable jumps. */
872 executable_code code
;
873 struct sljit_compiler
* compiler
= sljit_create_compiler();
874 struct sljit_label
*label1
;
875 struct sljit_label
*label2
;
876 struct sljit_label
*label3
;
877 struct sljit_jump
*jump1
;
878 struct sljit_jump
*jump2
;
879 struct sljit_jump
*jump3
;
882 sljit_uw label1_addr
;
883 sljit_uw label2_addr
;
887 printf("Run test12\n");
889 FAILED(!compiler
, "cannot create compiler\n");
892 sljit_emit_enter(compiler
, 0, 2, 3, 2, 0, 0, 0);
893 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
, SLJIT_UNUSED
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 10);
894 jump1
= sljit_emit_jump(compiler
, SLJIT_REWRITABLE_JUMP
| SLJIT_SIG_GREATER
);
895 /* Default handler. */
896 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 5);
897 jump2
= sljit_emit_jump(compiler
, SLJIT_JUMP
);
898 value
= sljit_alloc_memory(compiler
, 15);
899 SLJIT_ASSERT(!((sljit_sw
)value
& (sizeof(sljit_sw
) - 1)));
900 memset(value
, 255, 15);
902 label1
= sljit_emit_label(compiler
);
903 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 6);
904 jump3
= sljit_emit_jump(compiler
, SLJIT_JUMP
);
906 label2
= sljit_emit_label(compiler
);
907 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 7);
909 label3
= sljit_emit_label(compiler
);
910 sljit_set_label(jump2
, label3
);
911 sljit_set_label(jump3
, label3
);
912 /* By default, set to handler 1. */
913 sljit_set_label(jump1
, label1
);
914 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
916 value
= sljit_alloc_memory(compiler
, 8);
917 SLJIT_ASSERT(!((sljit_sw
)value
& (sizeof(sljit_sw
) - 1)));
918 memset(value
, 255, 8);
920 code
.code
= sljit_generate_code(compiler
);
922 jump1_addr
= sljit_get_jump_addr(jump1
);
923 label1_addr
= sljit_get_label_addr(label1
);
924 label2_addr
= sljit_get_label_addr(label2
);
925 sljit_free_compiler(compiler
);
927 code
.func2((sljit_sw
)&buf
, 4);
928 FAILED(buf
[0] != 5, "test12 case 1 failed\n");
930 code
.func2((sljit_sw
)&buf
, 11);
931 FAILED(buf
[0] != 6, "test12 case 2 failed\n");
933 sljit_set_jump_addr(jump1_addr
, label2_addr
);
934 code
.func2((sljit_sw
)&buf
, 12);
935 FAILED(buf
[0] != 7, "test12 case 3 failed\n");
937 sljit_set_jump_addr(jump1_addr
, label1_addr
);
938 code
.func2((sljit_sw
)&buf
, 13);
939 FAILED(buf
[0] != 6, "test12 case 4 failed\n");
941 sljit_free_code(code
.code
);
945 static void test13(void)
947 /* Test fpu monadic functions. */
948 executable_code code
;
949 struct sljit_compiler
* compiler
= sljit_create_compiler();
954 printf("Run test13\n");
956 if (!sljit_is_fpu_available()) {
958 printf("no fpu available, test13 skipped\n");
961 sljit_free_compiler(compiler
);
965 FAILED(!compiler
, "cannot create compiler\n");
981 sljit_emit_enter(compiler
, 0, 2, 3, 2, 6, 0, 0);
982 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM0(), (sljit_sw
)&buf
[2], SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
983 sljit_emit_fop1(compiler
, SLJIT_ABSD
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_d
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
984 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR0
, 0, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
985 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_d
));
986 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 0);
987 sljit_emit_fop1(compiler
, SLJIT_NEGD
, SLJIT_FR2
, 0, SLJIT_FR0
, 0);
988 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR3
, 0, SLJIT_FR2
, 0);
989 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM0(), (sljit_sw
)&buf
[4], SLJIT_FR3
, 0);
990 sljit_emit_fop1(compiler
, SLJIT_ABSD
, SLJIT_FR4
, 0, SLJIT_FR1
, 0);
991 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_d
), SLJIT_FR4
, 0);
992 sljit_emit_fop1(compiler
, SLJIT_NEGD
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_d
), SLJIT_FR4
, 0);
994 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
995 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_S
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
996 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_UNUSED
, 0, SLJIT_D_GREATER
);
997 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_S
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
), SLJIT_FR5
, 0);
998 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_D_GREATER
);
999 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_FR5
, 0);
1000 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_E
| SLJIT_SET_S
, SLJIT_FR1
, 0, SLJIT_FR1
, 0);
1001 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_D_EQUAL
);
1002 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_D_LESS
);
1003 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_E
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
1004 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_D_EQUAL
);
1005 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_D_NOT_EQUAL
);
1007 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1009 code
.code
= sljit_generate_code(compiler
);
1011 sljit_free_compiler(compiler
);
1013 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
1014 FAILED(buf
[2] != -4.5, "test13 case 1 failed\n");
1015 FAILED(buf
[3] != 4.5, "test13 case 2 failed\n");
1016 FAILED(buf
[4] != -7.75, "test13 case 3 failed\n");
1017 FAILED(buf
[5] != 4.5, "test13 case 4 failed\n");
1018 FAILED(buf
[6] != -4.5, "test13 case 5 failed\n");
1020 FAILED(buf2
[0] != 1, "test13 case 6 failed\n");
1021 FAILED(buf2
[1] != 0, "test13 case 7 failed\n");
1022 FAILED(buf2
[2] != 1, "test13 case 8 failed\n");
1023 FAILED(buf2
[3] != 0, "test13 case 9 failed\n");
1024 FAILED(buf2
[4] != 0, "test13 case 10 failed\n");
1025 FAILED(buf2
[5] != 1, "test13 case 11 failed\n");
1027 sljit_free_code(code
.code
);
1031 static void test14(void)
1033 /* Test fpu diadic functions. */
1034 executable_code code
;
1035 struct sljit_compiler
* compiler
= sljit_create_compiler();
1039 printf("Run test14\n");
1041 if (!sljit_is_fpu_available()) {
1043 printf("no fpu available, test14 skipped\n");
1046 sljit_free_compiler(compiler
);
1065 FAILED(!compiler
, "cannot create compiler\n");
1066 sljit_emit_enter(compiler
, 0, 1, 3, 1, 6, 0, 0);
1069 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_d
));
1070 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
1071 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 2);
1072 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 3, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
1073 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR1
, 0);
1074 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_FR1
, 0, SLJIT_FR0
, 0, SLJIT_FR1
, 0);
1075 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 4, SLJIT_FR0
, 0);
1076 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 5, SLJIT_FR1
, 0);
1079 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
1080 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 2);
1081 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
1082 sljit_emit_fop2(compiler
, SLJIT_SUBD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 6, SLJIT_FR3
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_DOUBLE_SHIFT
);
1083 sljit_emit_fop2(compiler
, SLJIT_SUBD
, SLJIT_FR2
, 0, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 2);
1084 sljit_emit_fop2(compiler
, SLJIT_SUBD
, SLJIT_FR3
, 0, SLJIT_FR2
, 0, SLJIT_FR3
, 0);
1085 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 7, SLJIT_FR2
, 0);
1086 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 8, SLJIT_FR3
, 0);
1089 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1090 sljit_emit_fop2(compiler
, SLJIT_MULD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 9, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_DOUBLE_SHIFT
, SLJIT_FR1
, 0);
1091 sljit_emit_fop2(compiler
, SLJIT_MULD
, SLJIT_FR1
, 0, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
1092 sljit_emit_fop2(compiler
, SLJIT_MULD
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 2, SLJIT_FR2
, 0);
1093 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 10, SLJIT_FR1
, 0);
1094 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 11, SLJIT_FR5
, 0);
1097 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 12);
1098 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 13);
1099 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR4
, 0, SLJIT_FR5
, 0);
1100 sljit_emit_fop2(compiler
, SLJIT_DIVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 12, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 12, SLJIT_FR1
, 0);
1101 sljit_emit_fop2(compiler
, SLJIT_DIVD
, SLJIT_FR5
, 0, SLJIT_FR5
, 0, SLJIT_FR1
, 0);
1102 sljit_emit_fop2(compiler
, SLJIT_DIVD
, SLJIT_FR4
, 0, SLJIT_FR1
, 0, SLJIT_FR4
, 0);
1103 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 13, SLJIT_FR5
, 0);
1104 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
) * 14, SLJIT_FR4
, 0);
1106 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1108 code
.code
= sljit_generate_code(compiler
);
1110 sljit_free_compiler(compiler
);
1112 code
.func1((sljit_sw
)&buf
);
1113 FAILED(buf
[3] != 10.75, "test14 case 1 failed\n");
1114 FAILED(buf
[4] != 5.25, "test14 case 2 failed\n");
1115 FAILED(buf
[5] != 7.0, "test14 case 3 failed\n");
1116 FAILED(buf
[6] != 0.0, "test14 case 4 failed\n");
1117 FAILED(buf
[7] != 5.5, "test14 case 5 failed\n");
1118 FAILED(buf
[8] != 3.75, "test14 case 6 failed\n");
1119 FAILED(buf
[9] != 24.5, "test14 case 7 failed\n");
1120 FAILED(buf
[10] != 38.5, "test14 case 8 failed\n");
1121 FAILED(buf
[11] != 9.625, "test14 case 9 failed\n");
1122 FAILED(buf
[12] != 2.0, "test14 case 10 failed\n");
1123 FAILED(buf
[13] != 2.0, "test14 case 11 failed\n");
1124 FAILED(buf
[14] != 0.5, "test14 case 12 failed\n");
1126 sljit_free_code(code
.code
);
1130 static sljit_sw SLJIT_CALL
func(sljit_sw a
, sljit_sw b
, sljit_sw c
)
1132 return a
+ b
+ c
+ 5;
1135 static void test15(void)
1137 /* Test function call. */
1138 executable_code code
;
1139 struct sljit_compiler
* compiler
= sljit_create_compiler();
1140 struct sljit_jump
* jump
;
1144 printf("Run test15\n");
1146 FAILED(!compiler
, "cannot create compiler\n");
1153 buf
[6] = SLJIT_FUNC_OFFSET(func
);
1155 sljit_emit_enter(compiler
, 0, 1, 4, 1, 0, 0, 0);
1157 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
1158 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 7);
1159 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -3);
1160 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(func
));
1161 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_RETURN_REG
, 0);
1163 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -5);
1164 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -10);
1165 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
1166 jump
= sljit_emit_jump(compiler
, SLJIT_CALL3
| SLJIT_REWRITABLE_JUMP
);
1167 sljit_set_target(jump
, (sljit_sw
)-1);
1168 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1170 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_OFFSET(func
));
1171 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 40);
1172 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -3);
1173 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_R0
, 0);
1174 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1176 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -60);
1177 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_FUNC_OFFSET(func
));
1178 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -30);
1179 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_R1
, 0);
1180 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1182 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 10);
1183 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 16);
1184 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, SLJIT_FUNC_OFFSET(func
));
1185 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_R2
, 0);
1186 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1188 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
1189 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 110);
1190 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 120);
1191 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_FUNC_OFFSET(func
));
1192 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_R3
, 0);
1193 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1195 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
1196 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -16);
1197 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 6);
1198 sljit_emit_ijump(compiler
, SLJIT_CALL3
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
));
1199 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1201 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1203 code
.code
= sljit_generate_code(compiler
);
1205 sljit_set_jump_addr(sljit_get_jump_addr(jump
), SLJIT_FUNC_OFFSET(func
));
1206 sljit_free_compiler(compiler
);
1208 FAILED(code
.func1((sljit_sw
)&buf
) != -15, "test15 case 1 failed\n");
1209 FAILED(buf
[0] != 14, "test15 case 2 failed\n");
1210 FAILED(buf
[1] != -8, "test15 case 3 failed\n");
1211 FAILED(buf
[2] != SLJIT_FUNC_OFFSET(func
) + 42, "test15 case 4 failed\n");
1212 FAILED(buf
[3] != SLJIT_FUNC_OFFSET(func
) - 85, "test15 case 5 failed\n");
1213 FAILED(buf
[4] != SLJIT_FUNC_OFFSET(func
) + 31, "test15 case 6 failed\n");
1214 FAILED(buf
[5] != 335, "test15 case 7 failed\n");
1215 FAILED(buf
[6] != -15, "test15 case 8 failed\n");
1217 sljit_free_code(code
.code
);
1221 static void test16(void)
1223 /* Ackermann benchmark. */
1224 executable_code code
;
1225 struct sljit_compiler
* compiler
= sljit_create_compiler();
1226 struct sljit_label
*entry
;
1227 struct sljit_label
*label
;
1228 struct sljit_jump
*jump
;
1229 struct sljit_jump
*jump1
;
1230 struct sljit_jump
*jump2
;
1233 printf("Run test16\n");
1235 FAILED(!compiler
, "cannot create compiler\n");
1237 entry
= sljit_emit_label(compiler
);
1238 sljit_emit_enter(compiler
, 0, 2, 3, 2, 0, 0, 0);
1240 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0);
1241 jump1
= sljit_emit_jump(compiler
, SLJIT_EQUAL
);
1243 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 0);
1244 jump2
= sljit_emit_jump(compiler
, SLJIT_EQUAL
);
1247 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
1248 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 1);
1249 jump
= sljit_emit_jump(compiler
, SLJIT_CALL2
);
1250 sljit_set_label(jump
, entry
);
1252 /* Returns with Ack(x-1, Ack(x,y-1)). */
1253 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_RETURN_REG
, 0);
1254 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
1255 jump
= sljit_emit_jump(compiler
, SLJIT_CALL2
);
1256 sljit_set_label(jump
, entry
);
1257 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1259 /* Returns with y+1. */
1260 label
= sljit_emit_label(compiler
);
1261 sljit_set_label(jump1
, label
);
1262 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 1, SLJIT_S1
, 0);
1263 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1265 /* Returns with Ack(x-1,1) */
1266 label
= sljit_emit_label(compiler
);
1267 sljit_set_label(jump2
, label
);
1268 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
1269 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1270 jump
= sljit_emit_jump(compiler
, SLJIT_CALL2
);
1271 sljit_set_label(jump
, entry
);
1272 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1274 code
.code
= sljit_generate_code(compiler
);
1276 sljit_free_compiler(compiler
);
1278 FAILED(code
.func2(3, 3) != 61, "test16 case 1 failed\n");
1279 /* For benchmarking. */
1280 /* FAILED(code.func2(3, 11) != 16381, "test16 case 1 failed\n"); */
1282 sljit_free_code(code
.code
);
1286 static void test17(void)
1288 /* Test arm constant pool. */
1289 executable_code code
;
1290 struct sljit_compiler
* compiler
= sljit_create_compiler();
1295 printf("Run test17\n");
1297 FAILED(!compiler
, "cannot create compiler\n");
1304 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
1305 for (i
= 0; i
<= 0xfff; i
++) {
1306 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x81818000 | i
);
1307 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x81818000 | i
);
1308 if ((i
& 0x3ff) == 0)
1309 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), (i
>> 10) * sizeof(sljit_sw
), SLJIT_R0
, 0);
1311 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1312 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1314 code
.code
= sljit_generate_code(compiler
);
1316 sljit_free_compiler(compiler
);
1318 code
.func1((sljit_sw
)&buf
);
1319 FAILED((sljit_uw
)buf
[0] != 0x81818000, "test17 case 1 failed\n");
1320 FAILED((sljit_uw
)buf
[1] != 0x81818400, "test17 case 2 failed\n");
1321 FAILED((sljit_uw
)buf
[2] != 0x81818800, "test17 case 3 failed\n");
1322 FAILED((sljit_uw
)buf
[3] != 0x81818c00, "test17 case 4 failed\n");
1323 FAILED((sljit_uw
)buf
[4] != 0x81818fff, "test17 case 5 failed\n");
1325 sljit_free_code(code
.code
);
1329 static void test18(void)
1332 executable_code code
;
1333 struct sljit_compiler
* compiler
= sljit_create_compiler();
1337 printf("Run test18\n");
1339 FAILED(!compiler
, "cannot create compiler\n");
1350 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1351 buf
[10] = SLJIT_W(1) << 32;
1356 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
1358 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1359 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, SLJIT_W(0x1122334455667788));
1360 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x1122334455667788));
1362 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(1000000000000));
1363 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(1000000000000));
1364 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, SLJIT_W(5000000000000), SLJIT_R0
, 0);
1366 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1367 sljit_emit_op2(compiler
, SLJIT_IADD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1369 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1370 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1371 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_UNUSED
, 0, SLJIT_ZERO
);
1372 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_S1
, 0);
1373 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1374 sljit_emit_op2(compiler
, SLJIT_IAND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1375 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_UNUSED
, 0, SLJIT_I_ZERO
);
1377 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1378 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x2208080808));
1379 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_UNUSED
, 0, SLJIT_LESS
);
1380 sljit_emit_op1(compiler
, SLJIT_MOV_SI
| SLJIT_INT_OP
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1381 sljit_emit_op2(compiler
, SLJIT_IAND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1104040404));
1382 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_UNUSED
, 0, SLJIT_I_NOT_ZERO
);
1384 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
1385 sljit_emit_op2(compiler
, SLJIT_ISHL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_IMM
, SLJIT_W(0xffff0000), SLJIT_R0
, 0);
1387 sljit_emit_op2(compiler
, SLJIT_IMUL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_IMM
, -1);
1389 /* 32 bit operations. */
1391 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0x11223344);
1392 sljit_emit_op2(compiler
, SLJIT_IADD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 0x44332211);
1396 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1398 code
.code
= sljit_generate_code(compiler
);
1400 sljit_free_compiler(compiler
);
1402 code
.func1((sljit_sw
)&buf
);
1403 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1404 FAILED(buf
[0] != SLJIT_W(0x1122334455667788), "test18 case 1 failed\n");
1405 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1406 FAILED(buf
[1] != 0x55667788, "test18 case 2 failed\n");
1408 FAILED(buf
[1] != SLJIT_W(0x5566778800000000), "test18 case 2 failed\n");
1410 FAILED(buf
[2] != SLJIT_W(2000000000000), "test18 case 3 failed\n");
1411 FAILED(buf
[3] != SLJIT_W(4000000000000), "test18 case 4 failed\n");
1412 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1413 FAILED(buf
[4] != 0x28282828, "test18 case 5 failed\n");
1415 FAILED(buf
[4] != SLJIT_W(0x2828282800000000), "test18 case 5 failed\n");
1417 FAILED(buf
[5] != 0, "test18 case 6 failed\n");
1418 FAILED(buf
[6] != 1, "test18 case 7 failed\n");
1419 FAILED(buf
[7] != 1, "test18 case 8 failed\n");
1420 FAILED(buf
[8] != 0, "test18 case 9 failed\n");
1421 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1422 FAILED(buf
[9] != 0xfff00000, "test18 case 10 failed\n");
1423 FAILED(buf
[10] != 0xffffffff, "test18 case 11 failed\n");
1425 FAILED(buf
[9] != SLJIT_W(0xfff0000000000000), "test18 case 10 failed\n");
1426 FAILED(buf
[10] != SLJIT_W(0xffffffff00000000), "test18 case 11 failed\n");
1429 FAILED(buf
[0] != 0x11223344, "test18 case 1 failed\n");
1430 FAILED(buf
[1] != 0x44332211, "test18 case 2 failed\n");
1433 sljit_free_code(code
.code
);
1437 static void test19(void)
1439 /* Test arm partial instruction caching. */
1440 executable_code code
;
1441 struct sljit_compiler
* compiler
= sljit_create_compiler();
1445 printf("Run test19\n");
1447 FAILED(!compiler
, "cannot create compiler\n");
1457 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
1458 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
1459 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM0(), (sljit_sw
)&buf
[2], SLJIT_MEM0(), (sljit_sw
)&buf
[1], SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
1460 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1461 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1462 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&buf
[0], SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&buf
[0]);
1463 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_MEM0(), (sljit_sw
)&buf
[0], SLJIT_IMM
, 2);
1464 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&buf
[0] + 4 * sizeof(sljit_sw
));
1465 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_IMM
, 10);
1466 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 7);
1467 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&buf
[5], SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&buf
[5]);
1469 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1471 code
.code
= sljit_generate_code(compiler
);
1473 sljit_free_compiler(compiler
);
1475 code
.func1((sljit_sw
)&buf
);
1476 FAILED(buf
[0] != 10, "test19 case 1 failed\n");
1477 FAILED(buf
[1] != 4, "test19 case 2 failed\n");
1478 FAILED(buf
[2] != 14, "test19 case 3 failed\n");
1479 FAILED(buf
[3] != 14, "test19 case 4 failed\n");
1480 FAILED(buf
[4] != 8, "test19 case 5 failed\n");
1481 FAILED(buf
[5] != 6, "test19 case 6 failed\n");
1482 FAILED(buf
[6] != 12, "test19 case 7 failed\n");
1483 FAILED(buf
[7] != 10, "test19 case 8 failed\n");
1485 sljit_free_code(code
.code
);
1489 static void test20(void)
1492 executable_code code
;
1493 struct sljit_compiler
* compiler
= sljit_create_compiler();
1494 struct sljit_jump
* jump
;
1495 struct sljit_label
* label
;
1497 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1498 sljit_sw offset_value
= SLJIT_W(0x1234567812345678);
1500 sljit_sw offset_value
= SLJIT_W(0x12345678);
1504 printf("Run test20\n");
1506 FAILED(!compiler
, "cannot create compiler\n");
1514 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 4 * sizeof(sljit_sw
));
1515 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_S0
), 0);
1516 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
));
1517 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -1);
1518 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, -1);
1519 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, -1);
1520 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, -1);
1521 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
));
1522 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_SP
), 0);
1523 sljit_get_local_base(compiler
, SLJIT_R0
, 0, -offset_value
);
1524 sljit_get_local_base(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, -0x1234);
1525 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
1526 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_R0
), offset_value
, SLJIT_MEM1(SLJIT_R1
), 0x1234 + sizeof(sljit_sw
));
1527 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_uw
));
1528 /* Dummy last instructions. */
1529 sljit_emit_const(compiler
, SLJIT_R0
, 0, -9);
1530 sljit_emit_label(compiler
);
1532 code
.code
= sljit_generate_code(compiler
);
1534 sljit_free_compiler(compiler
);
1536 FAILED(code
.func1((sljit_sw
)&buf
) != -12345, "test20 case 1 failed\n")
1538 FAILED(buf
[2] != 60, "test20 case 2 failed\n");
1539 FAILED(buf
[3] != 17, "test20 case 3 failed\n");
1540 FAILED(buf
[4] != 7, "test20 case 4 failed\n");
1542 sljit_free_code(code
.code
);
1544 compiler
= sljit_create_compiler();
1545 sljit_emit_enter(compiler
, 0, 0, 3, 0, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
1547 sljit_get_local_base(compiler
, SLJIT_R0
, 0, SLJIT_MAX_LOCAL_SIZE
- sizeof(sljit_sw
));
1548 sljit_get_local_base(compiler
, SLJIT_R1
, 0, -(sljit_sw
)sizeof(sljit_sw
));
1549 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -1);
1550 label
= sljit_emit_label(compiler
);
1551 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_R2
, 0);
1552 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
1553 jump
= sljit_emit_jump(compiler
, SLJIT_NOT_EQUAL
);
1554 sljit_set_label(jump
, label
);
1556 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1558 code
.code
= sljit_generate_code(compiler
);
1560 sljit_free_compiler(compiler
);
1562 /* Just survive this code. */
1565 sljit_free_code(code
.code
);
1569 static void test21(void)
1571 /* Test fake enter. The parts of the jit code can be separated in the memory. */
1572 executable_code code1
;
1573 executable_code code2
;
1574 struct sljit_compiler
* compiler
= sljit_create_compiler();
1575 struct sljit_jump
* jump
;
1580 printf("Run test21\n");
1582 FAILED(!compiler
, "cannot create compiler\n");
1588 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 2 * sizeof(sljit_sw
));
1590 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 10);
1591 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_SP
), 0);
1592 jump
= sljit_emit_jump(compiler
, SLJIT_JUMP
| SLJIT_REWRITABLE_JUMP
);
1593 sljit_set_target(jump
, 0);
1595 code1
.code
= sljit_generate_code(compiler
);
1597 addr
= sljit_get_jump_addr(jump
);
1598 sljit_free_compiler(compiler
);
1600 compiler
= sljit_create_compiler();
1601 FAILED(!compiler
, "cannot create compiler\n");
1603 /* Other part of the jit code. */
1604 sljit_set_context(compiler
, 0, 1, 3, 2, 0, 0, 2 * sizeof(sljit_sw
));
1606 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_SP
), 0);
1607 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), 0);
1608 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_sw
));
1610 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1612 code2
.code
= sljit_generate_code(compiler
);
1614 sljit_free_compiler(compiler
);
1616 sljit_set_jump_addr(addr
, SLJIT_FUNC_OFFSET(code2
.code
));
1618 FAILED(code1
.func1((sljit_sw
)&buf
) != 19, "test21 case 1 failed\n");
1619 FAILED(buf
[2] != -16, "test21 case 2 failed\n");
1620 FAILED(buf
[3] != 100, "test21 case 3 failed\n");
1622 sljit_free_code(code1
.code
);
1623 sljit_free_code(code2
.code
);
1627 static void test22(void)
1629 /* Test simple byte and half-int data transfers. */
1630 executable_code code
;
1631 struct sljit_compiler
* compiler
= sljit_create_compiler();
1637 printf("Run test22\n");
1639 FAILED(!compiler
, "cannot create compiler\n");
1664 sljit_emit_enter(compiler
, 0, 3, 3, 3, 0, 0, 0);
1666 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1667 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_S0
, 0);
1668 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_IMM
, -13);
1669 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_R2
, 0, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
));
1670 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_R2
, 0);
1671 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
));
1672 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
1673 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_R1
, 0);
1674 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1675 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 0, SLJIT_R1
, 0);
1676 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
1677 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_R1
, 0);
1679 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -13);
1680 sljit_emit_op1(compiler
, SLJIT_MOVU_UH
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sh
), SLJIT_IMM
, 0x1234);
1681 sljit_emit_op1(compiler
, SLJIT_MOVU_SH
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sh
));
1682 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1683 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sh
), SLJIT_MEM1(SLJIT_S1
), -(sljit_sw
)sizeof(sljit_sh
));
1684 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xff0000 + 8000);
1685 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
1686 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 1, SLJIT_R0
, 0);
1687 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
1688 sljit_emit_op1(compiler
, SLJIT_MOVU_SH
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 1, SLJIT_R0
, 0);
1689 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -9317);
1690 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 5 * sizeof(sljit_sh
));
1691 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -5);
1692 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 1);
1693 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sh
), SLJIT_R1
, 0);
1695 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_MEM1(SLJIT_S2
), 0, SLJIT_IMM
, -45);
1696 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sb
), SLJIT_IMM
, 0x12);
1697 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_sb
));
1698 sljit_emit_op1(compiler
, SLJIT_MOVU_SB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sb
));
1699 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_S1
, 0, SLJIT_R1
, 0);
1700 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_S1
, 0, SLJIT_S1
, 0);
1701 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_R2
, 0, SLJIT_S1
, 0);
1702 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R2
, 0);
1703 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sb
), SLJIT_S1
, 0);
1704 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R0
), 0, SLJIT_R0
, 0);
1706 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1708 code
.code
= sljit_generate_code(compiler
);
1710 sljit_free_compiler(compiler
);
1712 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&sbuf
, (sljit_sw
)&bbuf
);
1713 FAILED(buf
[1] != -13, "test22 case 1 failed\n");
1714 FAILED(buf
[2] != 5, "test22 case 2 failed\n");
1715 FAILED(buf
[3] != -13, "test22 case 3 failed\n");
1716 FAILED(buf
[4] != (sljit_sw
)&buf
[3], "test22 case 4 failed\n");
1717 FAILED(buf
[5] != (sljit_sw
)&buf
[4], "test22 case 5 failed\n");
1718 FAILED(buf
[6] != (sljit_sw
)&buf
[4], "test22 case 6 failed\n");
1719 FAILED(buf
[7] != -9, "test22 case 7 failed\n");
1720 FAILED(buf
[8] != -56, "test22 case 8 failed\n");
1722 FAILED(sbuf
[0] != -13, "test22 case 9 failed\n");
1723 FAILED(sbuf
[1] != 0x1234, "test22 case 10 failed\n");
1724 FAILED(sbuf
[3] != 0x1234, "test22 case 11 failed\n");
1725 FAILED(sbuf
[4] != 8000, "test22 case 12 failed\n");
1726 FAILED(sbuf
[5] != -9317, "test22 case 13 failed\n");
1727 FAILED(sbuf
[6] != -9317, "test22 case 14 failed\n");
1729 FAILED(bbuf
[0] != -45, "test22 case 15 failed\n");
1730 FAILED(bbuf
[1] != 0x12, "test22 case 16 failed\n");
1731 FAILED(bbuf
[3] != -56, "test22 case 17 failed\n");
1732 FAILED(bbuf
[4] != 2, "test22 case 18 failed\n");
1734 sljit_free_code(code
.code
);
1738 static void test23(void)
1740 /* Test 32 bit / 64 bit signed / unsigned int transfer and conversion.
1741 This test has do real things on 64 bit systems, but works on 32 bit systems as well. */
1742 executable_code code
;
1743 struct sljit_compiler
* compiler
= sljit_create_compiler();
1748 sljit_ub asbytes
[4];
1750 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1751 sljit_sw garbage
= SLJIT_W(0x1234567812345678);
1753 sljit_sw garbage
= 0x12345678;
1757 printf("Run test23\n");
1759 FAILED(!compiler
, "cannot create compiler\n");
1776 sljit_emit_enter(compiler
, 0, 2, 3, 3, 0, 0, 0);
1777 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, 34567);
1778 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
1779 sljit_emit_op1(compiler
, SLJIT_MOVU_SI
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), 2, SLJIT_IMM
, -7654);
1780 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1781 sljit_emit_op1(compiler
, SLJIT_MOVU_SI
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
));
1782 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
1783 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1784 sljit_emit_op1(compiler
, SLJIT_MOVU_UI
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
));
1785 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
1786 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1787 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
));
1788 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1789 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
1790 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x0f00f00);
1791 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x7777);
1792 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), 0x7777 + 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1793 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x7777);
1794 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), -0x7777 + (sljit_sw
)sizeof(sljit_sw
), SLJIT_R0
, 0);
1795 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 16 - sizeof(sljit_sw
));
1796 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1797 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
1798 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1, SLJIT_R0
, 0);
1799 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_IMM
, 64, SLJIT_MEM1(SLJIT_R0
), 0);
1800 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1801 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&buf
[6], SLJIT_MEM0(), (sljit_sw
)&buf
[6]);
1802 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_IMM
, 0x123456);
1803 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_S0
, 0);
1804 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, sizeof(sljit_sw
));
1805 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 100000 * sizeof(sljit_sw
));
1806 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), 100001 * sizeof(sljit_sw
), SLJIT_S0
, 0);
1807 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, sizeof(sljit_sw
));
1808 sljit_emit_op1(compiler
, SLJIT_MOVU_SI
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
), SLJIT_IMM
, 0x12345678);
1810 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x2bd700 | 243);
1811 sljit_emit_return(compiler
, SLJIT_MOV_SB
, SLJIT_R1
, 0);
1813 code
.code
= sljit_generate_code(compiler
);
1815 sljit_free_compiler(compiler
);
1817 FAILED(code
.func2((sljit_sw
)&buf
, (sljit_sw
)&ibuf
) != -13, "test23 case 1 failed\n");
1818 FAILED(buf
[0] != -5791, "test23 case 2 failed\n");
1819 FAILED(buf
[1] != 43579, "test23 case 3 failed\n");
1820 FAILED(buf
[2] != 658923, "test23 case 4 failed\n");
1821 FAILED(buf
[3] != 0x0f00f00, "test23 case 5 failed\n");
1822 FAILED(buf
[4] != 0x0f00f00, "test23 case 6 failed\n");
1823 FAILED(buf
[5] != 80, "test23 case 7 failed\n");
1824 FAILED(buf
[6] != 0x123456, "test23 case 8 failed\n");
1825 FAILED(buf
[7] != (sljit_sw
)&buf
[5], "test23 case 9 failed\n");
1826 FAILED(buf
[8] != (sljit_sw
)&buf
[8] - 100000 * sizeof(sljit_sw
), "test23 case 10 failed\n");
1828 FAILED(ibuf
[0] != 34567, "test23 case 11 failed\n");
1829 FAILED(ibuf
[1] != -7654, "test23 case 12 failed\n");
1831 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1832 FAILED(u
.asbytes
[0] != 0x78, "test23 case 13 failed\n");
1833 FAILED(u
.asbytes
[1] != 0x56, "test23 case 14 failed\n");
1834 FAILED(u
.asbytes
[2] != 0x34, "test23 case 15 failed\n");
1835 FAILED(u
.asbytes
[3] != 0x12, "test23 case 16 failed\n");
1837 FAILED(u
.asbytes
[0] != 0x12, "test23 case 13 failed\n");
1838 FAILED(u
.asbytes
[1] != 0x34, "test23 case 14 failed\n");
1839 FAILED(u
.asbytes
[2] != 0x56, "test23 case 15 failed\n");
1840 FAILED(u
.asbytes
[3] != 0x78, "test23 case 16 failed\n");
1843 sljit_free_code(code
.code
);
1847 static void test24(void)
1849 /* Some complicated addressing modes. */
1850 executable_code code
;
1851 struct sljit_compiler
* compiler
= sljit_create_compiler();
1857 printf("Run test24\n");
1859 FAILED(!compiler
, "cannot create compiler\n");
1885 sljit_emit_enter(compiler
, 0, 3, 3, 3, 0, 0, 0);
1887 /* Nothing should be updated. */
1888 sljit_emit_op1(compiler
, SLJIT_MOVU_SH
, SLJIT_MEM0(), (sljit_sw
)&sbuf
[1], SLJIT_MEM0(), (sljit_sw
)&sbuf
[0]);
1889 sljit_emit_op1(compiler
, SLJIT_MOVU_SB
, SLJIT_MEM0(), (sljit_sw
)&bbuf
[1], SLJIT_MEM0(), (sljit_sw
)&bbuf
[0]);
1890 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
1891 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), 1, SLJIT_MEM0(), (sljit_sw
)&sbuf
[3]);
1892 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[0]);
1893 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1894 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
1895 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R2
), SLJIT_WORD_SHIFT
, SLJIT_MEM0(), (sljit_sw
)&buf
[0], SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 0);
1896 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sb
));
1897 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sb
));
1898 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&bbuf
[1], SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&bbuf
[0]);
1899 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sb
));
1901 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sh
));
1902 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&sbuf
[3], SLJIT_R1
, 0);
1904 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
1905 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
);
1906 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
1907 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_S0
, 0);
1908 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
);
1909 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
1910 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1911 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 4);
1912 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R2
), SLJIT_WORD_SHIFT
);
1913 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1914 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
1916 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0x7fff8000 + 6 * sizeof(sljit_sw
));
1917 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 952467);
1918 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0x7fff8000, SLJIT_R1
, 0);
1919 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0x7fff8000 + sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), 0x7fff8000);
1921 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
+ 0x7fff7fff + 6 * sizeof(sljit_sw
));
1922 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff + 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff + sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff);
1923 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- 0x7fff7ffe + 3 * sizeof(sljit_sb
));
1924 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_MEM1(SLJIT_R0
), 0x7fff7fff, SLJIT_MEM1(SLJIT_R0
), 0x7fff7ffe);
1925 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
+ 0x7fff7fff + 5 * sizeof(sljit_sb
));
1926 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff, SLJIT_MEM1(SLJIT_R0
), -0x7fff8000);
1927 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1928 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- SLJIT_W(0x123456123456));
1929 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- SLJIT_W(0x123456123456));
1930 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_MEM1(SLJIT_R0
), SLJIT_W(0x123456123456) + 6 * sizeof(sljit_sb
), SLJIT_MEM1(SLJIT_R1
), SLJIT_W(0x123456123456));
1933 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
1935 code
.code
= sljit_generate_code(compiler
);
1937 sljit_free_compiler(compiler
);
1939 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&sbuf
, (sljit_sw
)&bbuf
);
1940 FAILED(buf
[2] != 176366, "test24 case 1 failed\n");
1941 FAILED(buf
[3] != 64, "test24 case 2 failed\n");
1942 FAILED(buf
[4] != -100, "test24 case 3 failed\n");
1943 FAILED(buf
[5] != -100 + (sljit_sw
)&buf
[5] + (sljit_sw
)&buf
[4], "test24 case 4 failed\n");
1944 FAILED(buf
[6] != 952467, "test24 case 5 failed\n");
1945 FAILED(buf
[7] != 952467, "test24 case 6 failed\n");
1946 FAILED(buf
[8] != 952467 * 2, "test24 case 7 failed\n");
1948 FAILED(sbuf
[1] != 30000, "test24 case 8 failed\n");
1949 FAILED(sbuf
[2] != -12345, "test24 case 9 failed\n");
1950 FAILED(sbuf
[4] != sizeof(sljit_sh
), "test24 case 10 failed\n");
1952 FAILED(bbuf
[1] != -128, "test24 case 11 failed\n");
1953 FAILED(bbuf
[2] != 99, "test24 case 12 failed\n");
1954 FAILED(bbuf
[4] != 99, "test24 case 13 failed\n");
1955 FAILED(bbuf
[5] != 99, "test24 case 14 failed\n");
1956 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1957 FAILED(bbuf
[6] != -128, "test24 case 15 failed\n");
1960 sljit_free_code(code
.code
);
1964 static void test25(void)
1966 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1968 executable_code code
;
1969 struct sljit_compiler
* compiler
= sljit_create_compiler();
1973 printf("Run test25\n");
1975 FAILED(!compiler
, "cannot create compiler\n");
1991 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
1993 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0);
1994 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 1 * sizeof(sljit_sw
), SLJIT_IMM
, 0x7fff);
1995 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_IMM
, -0x8000);
1996 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_IMM
, 0x7fffffff);
1997 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(-0x80000000));
1998 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x1234567887654321));
1999 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0xff80000000));
2000 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x3ff0000000));
2001 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0xfffffff800100000));
2002 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0xfffffff80010f000));
2003 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00000008001));
2004 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00080010000));
2005 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00080018001));
2006 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00ffff00000));
2008 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2010 code
.code
= sljit_generate_code(compiler
);
2012 sljit_free_compiler(compiler
);
2014 code
.func1((sljit_sw
)&buf
);
2015 FAILED(buf
[0] != 0, "test25 case 1 failed\n");
2016 FAILED(buf
[1] != 0x7fff, "test25 case 2 failed\n");
2017 FAILED(buf
[2] != -0x8000, "test25 case 3 failed\n");
2018 FAILED(buf
[3] != 0x7fffffff, "test25 case 4 failed\n");
2019 FAILED(buf
[4] != SLJIT_W(-0x80000000), "test25 case 5 failed\n");
2020 FAILED(buf
[5] != SLJIT_W(0x1234567887654321), "test25 case 6 failed\n");
2021 FAILED(buf
[6] != SLJIT_W(0xff80000000), "test25 case 7 failed\n");
2022 FAILED(buf
[7] != SLJIT_W(0x3ff0000000), "test25 case 8 failed\n");
2023 FAILED((sljit_uw
)buf
[8] != SLJIT_W(0xfffffff800100000), "test25 case 9 failed\n");
2024 FAILED((sljit_uw
)buf
[9] != SLJIT_W(0xfffffff80010f000), "test25 case 10 failed\n");
2025 FAILED(buf
[10] != SLJIT_W(0x07fff00000008001), "test25 case 11 failed\n");
2026 FAILED(buf
[11] != SLJIT_W(0x07fff00080010000), "test25 case 12 failed\n");
2027 FAILED(buf
[12] != SLJIT_W(0x07fff00080018001), "test25 case 13 failed\n");
2028 FAILED(buf
[13] != SLJIT_W(0x07fff00ffff00000), "test25 case 14 failed\n");
2030 sljit_free_code(code
.code
);
2035 static void test26(void)
2037 /* Aligned access without aligned offsets. */
2038 executable_code code
;
2039 struct sljit_compiler
* compiler
= sljit_create_compiler();
2045 printf("Run test26\n");
2047 FAILED(!compiler
, "cannot create compiler\n");
2064 sljit_emit_enter(compiler
, 0, 3, 3, 3, 0, 0, 0);
2066 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 3);
2067 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 1);
2068 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), -3);
2069 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
) - 1, SLJIT_R0
, 0);
2070 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), -1);
2071 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) - 3, SLJIT_R0
, 0);
2073 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 100);
2074 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
) * 2 - 103, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2 - 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3 - 3);
2075 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 100);
2076 sljit_emit_op2(compiler
, SLJIT_IMUL
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_si
) * 2 - 101, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
) * 2 - 1, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
) * 3 - 1);
2078 if (sljit_is_fpu_available()) {
2079 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 3);
2080 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_d
) - 3, SLJIT_MEM1(SLJIT_S2
), -3);
2081 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_d
) * 2 - 3, SLJIT_MEM1(SLJIT_S2
), -3, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_d
) - 3);
2082 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 2);
2083 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sizeof(sljit_d
) * 3 - 4) >> 1);
2084 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 1);
2085 sljit_emit_fop2(compiler
, SLJIT_DIVD
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_d
) * 3 - 5, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_d
) * 2 - 3, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 1);
2088 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2090 code
.code
= sljit_generate_code(compiler
);
2092 sljit_free_compiler(compiler
);
2094 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&ibuf
, (sljit_sw
)&dbuf
);
2096 FAILED(buf
[1] != -689, "test26 case 1 failed\n");
2097 FAILED(buf
[2] != -16, "test26 case 2 failed\n");
2098 FAILED(ibuf
[1] != -2789, "test26 case 3 failed\n");
2099 FAILED(ibuf
[2] != -18, "test26 case 4 failed\n");
2101 if (sljit_is_fpu_available()) {
2102 FAILED(dbuf
[1] != 5.75, "test26 case 5 failed\n");
2103 FAILED(dbuf
[2] != 11.5, "test26 case 6 failed\n");
2104 FAILED(dbuf
[3] != -2.875, "test26 case 7 failed\n");
2107 sljit_free_code(code
.code
);
2111 static void test27(void)
2113 #define SET_NEXT_BYTE(type) \
2114 cond_set(compiler, SLJIT_R2, 0, type); \
2115 sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_S0), 1, SLJIT_R2, 0);
2116 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2119 #define RESULT(i) (3 - i)
2122 /* Playing with conditional flags. */
2123 executable_code code
;
2124 struct sljit_compiler
* compiler
= sljit_create_compiler();
2129 printf("Run test27\n");
2131 for (i
= 0; i
< 37; ++i
)
2134 FAILED(!compiler
, "cannot create compiler\n");
2136 /* 3 arguments passed, 3 arguments used. */
2137 sljit_emit_enter(compiler
, 0, 1, 3, 3, 0, 0, 0);
2139 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
2141 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1001);
2142 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 20);
2143 /* 0x100100000 on 64 bit machines, 0x100000 on 32 bit machines. */
2144 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x800000);
2145 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2146 sljit_emit_op0(compiler
, SLJIT_NOP
); /* Nop should keep the flags. */
2147 SET_NEXT_BYTE(SLJIT_GREATER
);
2148 SET_NEXT_BYTE(SLJIT_LESS
);
2149 sljit_emit_op1(compiler
, SLJIT_MOV_SI
| SLJIT_INT_OP
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2150 sljit_emit_op1(compiler
, SLJIT_MOV_SI
| SLJIT_INT_OP
, SLJIT_R1
, 0, SLJIT_R1
, 0);
2151 sljit_emit_op2(compiler
, SLJIT_ISUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2152 sljit_emit_op0(compiler
, SLJIT_NOP
); /* Nop should keep the flags. */
2153 SET_NEXT_BYTE(SLJIT_I_GREATER
);
2154 SET_NEXT_BYTE(SLJIT_I_LESS
);
2156 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1000);
2157 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 20);
2158 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x10);
2159 /* 0x100000010 on 64 bit machines, 0x10 on 32 bit machines. */
2160 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2161 SET_NEXT_BYTE(SLJIT_GREATER
);
2162 SET_NEXT_BYTE(SLJIT_LESS
);
2163 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2164 sljit_emit_op2(compiler
, SLJIT_ISUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2165 SET_NEXT_BYTE(SLJIT_I_GREATER
);
2166 SET_NEXT_BYTE(SLJIT_I_LESS
);
2168 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2169 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2170 /* 0xff..ff on all machines. */
2171 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2172 SET_NEXT_BYTE(SLJIT_LESS_EQUAL
);
2173 SET_NEXT_BYTE(SLJIT_GREATER_EQUAL
);
2174 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -1);
2175 SET_NEXT_BYTE(SLJIT_SIG_GREATER
);
2176 SET_NEXT_BYTE(SLJIT_SIG_LESS
);
2177 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
2178 SET_NEXT_BYTE(SLJIT_EQUAL
);
2179 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2180 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_O
| SLJIT_SET_U
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -2);
2181 SET_NEXT_BYTE(SLJIT_OVERFLOW
);
2182 SET_NEXT_BYTE(SLJIT_NOT_OVERFLOW
);
2183 SET_NEXT_BYTE(SLJIT_GREATER_EQUAL
);
2184 SET_NEXT_BYTE(SLJIT_LESS_EQUAL
);
2186 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80000000);
2187 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 16);
2188 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 16);
2189 /* 0x80..0 on 64 bit machines, 0 on 32 bit machines. */
2190 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0xffffffff);
2191 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2192 SET_NEXT_BYTE(SLJIT_OVERFLOW
);
2193 SET_NEXT_BYTE(SLJIT_NOT_OVERFLOW
);
2194 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2195 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R1
, 0, SLJIT_R1
, 0);
2196 sljit_emit_op2(compiler
, SLJIT_ISUB
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2197 SET_NEXT_BYTE(SLJIT_I_OVERFLOW
);
2198 SET_NEXT_BYTE(SLJIT_I_NOT_OVERFLOW
);
2200 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2201 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2202 sljit_emit_op2(compiler
, SLJIT_SUBC
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2203 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_R0
, 0, SLJIT_IMM
, 6, SLJIT_R0
, 0);
2204 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R0
, 0);
2206 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
2207 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2208 sljit_emit_op2(compiler
, SLJIT_ADDC
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2209 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 9);
2210 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R0
, 0);
2212 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2213 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, (8 * sizeof(sljit_sw
)) - 1);
2214 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2215 SET_NEXT_BYTE(SLJIT_EQUAL
);
2216 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
2217 SET_NEXT_BYTE(SLJIT_EQUAL
);
2219 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2220 sljit_emit_op2(compiler
, SLJIT_ASHR
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2221 SET_NEXT_BYTE(SLJIT_EQUAL
);
2222 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2223 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffffc0);
2224 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2225 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 0);
2226 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2227 sljit_emit_op2(compiler
, SLJIT_ASHR
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
2228 SET_NEXT_BYTE(SLJIT_EQUAL
);
2229 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_PREF_SHIFT_REG
, 0, SLJIT_IMM
, 0);
2230 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2231 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_PREF_SHIFT_REG
, 0);
2232 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2234 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2235 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2236 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
2237 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_R2
, 0, SLJIT_IMM
, 1, SLJIT_R0
, 0);
2238 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R2
, 0);
2239 sljit_emit_op2(compiler
, SLJIT_SUBC
| SLJIT_SET_C
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2240 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_R2
, 0, SLJIT_IMM
, 1, SLJIT_R0
, 0);
2241 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R2
, 0);
2243 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -34);
2244 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x1234);
2245 SET_NEXT_BYTE(SLJIT_LESS
);
2246 SET_NEXT_BYTE(SLJIT_SIG_LESS
);
2247 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2248 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x12300000000) - 43);
2250 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, -43);
2252 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, -96);
2253 sljit_emit_op2(compiler
, SLJIT_ISUB
| SLJIT_SET_S
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2254 SET_NEXT_BYTE(SLJIT_I_LESS
);
2255 SET_NEXT_BYTE(SLJIT_I_SIG_GREATER
);
2257 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2259 code
.code
= sljit_generate_code(compiler
);
2261 sljit_free_compiler(compiler
);
2263 code
.func1((sljit_sw
)&buf
);
2265 FAILED(buf
[0] != RESULT(1), "test27 case 1 failed\n");
2266 FAILED(buf
[1] != RESULT(2), "test27 case 2 failed\n");
2267 FAILED(buf
[2] != 2, "test27 case 3 failed\n");
2268 FAILED(buf
[3] != 1, "test27 case 4 failed\n");
2269 FAILED(buf
[4] != RESULT(1), "test27 case 5 failed\n");
2270 FAILED(buf
[5] != RESULT(2), "test27 case 6 failed\n");
2271 FAILED(buf
[6] != 2, "test27 case 7 failed\n");
2272 FAILED(buf
[7] != 1, "test27 case 8 failed\n");
2274 FAILED(buf
[8] != 2, "test27 case 9 failed\n");
2275 FAILED(buf
[9] != 1, "test27 case 10 failed\n");
2276 FAILED(buf
[10] != 2, "test27 case 11 failed\n");
2277 FAILED(buf
[11] != 1, "test27 case 12 failed\n");
2278 FAILED(buf
[12] != 1, "test27 case 13 failed\n");
2279 FAILED(buf
[13] != 2, "test27 case 14 failed\n");
2280 FAILED(buf
[14] != 2, "test27 case 15 failed\n");
2281 FAILED(buf
[15] != 1, "test27 case 16 failed\n");
2282 FAILED(buf
[16] != 1, "test27 case 17 failed\n");
2283 FAILED(buf
[17] != 2, "test27 case 18 failed\n");
2285 FAILED(buf
[18] != RESULT(1), "test27 case 19 failed\n");
2286 FAILED(buf
[19] != RESULT(2), "test27 case 20 failed\n");
2287 FAILED(buf
[20] != 2, "test27 case 21 failed\n");
2288 FAILED(buf
[21] != 1, "test27 case 22 failed\n");
2290 FAILED(buf
[22] != 5, "test27 case 23 failed\n");
2291 FAILED(buf
[23] != 9, "test27 case 24 failed\n");
2293 FAILED(buf
[24] != 2, "test27 case 25 failed\n");
2294 FAILED(buf
[25] != 1, "test27 case 26 failed\n");
2296 FAILED(buf
[26] != 1, "test27 case 27 failed\n");
2297 FAILED(buf
[27] != 1, "test27 case 28 failed\n");
2298 FAILED(buf
[28] != 1, "test27 case 29 failed\n");
2299 FAILED(buf
[29] != 1, "test27 case 30 failed\n");
2301 FAILED(buf
[30] != 1, "test27 case 31 failed\n");
2302 FAILED(buf
[31] != 0, "test27 case 32 failed\n");
2304 FAILED(buf
[32] != 2, "test27 case 33 failed\n");
2305 FAILED(buf
[33] != 1, "test27 case 34 failed\n");
2306 FAILED(buf
[34] != 2, "test27 case 35 failed\n");
2307 FAILED(buf
[35] != 1, "test27 case 36 failed\n");
2308 FAILED(buf
[36] != 10, "test27 case 37 failed\n");
2310 sljit_free_code(code
.code
);
2312 #undef SET_NEXT_BYTE
2316 static void test28(void)
2319 executable_code code
;
2320 struct sljit_compiler
* compiler
= sljit_create_compiler();
2321 struct sljit_const
* const1
;
2322 struct sljit_label
* label
;
2323 sljit_uw label_addr
;
2327 printf("Run test28\n");
2329 FAILED(!compiler
, "cannot create compiler\n");
2337 FAILED(!compiler
, "cannot create compiler\n");
2338 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 0);
2339 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -234);
2340 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
2341 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_S3
, 0, SLJIT_R3
, 0, SLJIT_R4
, 0);
2342 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_S3
, 0);
2343 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_S3
, 0, SLJIT_IMM
, 0);
2344 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
2345 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_S3
, 0);
2346 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
));
2347 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S4
, 0, SLJIT_S4
, 0, SLJIT_R4
, 0);
2348 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_S4
, 0);
2349 const1
= sljit_emit_const(compiler
, SLJIT_S3
, 0, 0);
2350 sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_S3
, 0);
2351 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S3
, 0, SLJIT_S3
, 0, SLJIT_IMM
, 100);
2352 label
= sljit_emit_label(compiler
);
2353 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_S3
, 0);
2354 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R4
, 0);
2356 code
.code
= sljit_generate_code(compiler
);
2358 label_addr
= sljit_get_label_addr(label
);
2359 sljit_set_const(sljit_get_const_addr(const1
), label_addr
);
2360 sljit_free_compiler(compiler
);
2362 FAILED(code
.func1((sljit_sw
)&buf
) != 8, "test28 case 1 failed\n");
2363 FAILED(buf
[1] != -1872, "test28 case 2 failed\n");
2364 FAILED(buf
[2] != 1, "test28 case 3 failed\n");
2365 FAILED(buf
[3] != 2, "test28 case 4 failed\n");
2366 FAILED(buf
[4] != label_addr
, "test28 case 5 failed\n");
2368 sljit_free_code(code
.code
);
2372 static void test29(void)
2374 /* Test signed/unsigned bytes and halfs. */
2375 executable_code code
;
2376 struct sljit_compiler
* compiler
= sljit_create_compiler();
2380 printf("Run test29\n");
2408 FAILED(!compiler
, "cannot create compiler\n");
2409 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 0);
2411 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_R0
, 0, SLJIT_IMM
, -187);
2412 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
2413 sljit_emit_op1(compiler
, SLJIT_MOVU_SB
, SLJIT_R0
, 0, SLJIT_IMM
, -605);
2414 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2415 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_R0
, 0, SLJIT_IMM
, -56);
2416 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2417 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_R4
, 0, SLJIT_IMM
, 0xcde5);
2418 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2420 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_R0
, 0, SLJIT_IMM
, -45896);
2421 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2422 sljit_emit_op1(compiler
, SLJIT_MOVU_SH
, SLJIT_R0
, 0, SLJIT_IMM
, -1472797);
2423 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2424 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_R0
, 0, SLJIT_IMM
, -12890);
2425 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2426 sljit_emit_op1(compiler
, SLJIT_MOVU_UH
, SLJIT_R4
, 0, SLJIT_IMM
, 0x9cb0a6);
2427 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2429 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2430 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-3580429715));
2431 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2432 sljit_emit_op1(compiler
, SLJIT_MOVU_SI
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-100722768662));
2433 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2434 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-1457052677972));
2435 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2436 sljit_emit_op1(compiler
, SLJIT_MOVU_UI
, SLJIT_R4
, 0, SLJIT_IMM
, SLJIT_W(0xcef97a70b5));
2437 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2439 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 4 * sizeof(sljit_uw
));
2442 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -187);
2443 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2444 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2445 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -605);
2446 sljit_emit_op1(compiler
, SLJIT_MOVU_SB
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2447 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2448 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -56);
2449 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2450 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2451 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0xcde5);
2452 sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2453 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2455 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -45896);
2456 sljit_emit_op1(compiler
, SLJIT_MOV_SH
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2457 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2458 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1472797);
2459 sljit_emit_op1(compiler
, SLJIT_MOVU_SH
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2460 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2461 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -12890);
2462 sljit_emit_op1(compiler
, SLJIT_MOV_UH
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2463 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2464 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x9cb0a6);
2465 sljit_emit_op1(compiler
, SLJIT_MOVU_UH
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2466 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2468 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2469 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(-3580429715));
2470 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2471 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2472 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, SLJIT_W(-100722768662));
2473 sljit_emit_op1(compiler
, SLJIT_MOVU_SI
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2474 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2475 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, SLJIT_W(-1457052677972));
2476 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2477 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2478 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_W(0xcef97a70b5));
2479 sljit_emit_op1(compiler
, SLJIT_MOVU_UI
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2480 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R4
, 0);
2482 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 4 * sizeof(sljit_uw
));
2485 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 0x9faa5);
2486 sljit_emit_op1(compiler
, SLJIT_MOV_SB
, SLJIT_S2
, 0, SLJIT_S2
, 0);
2487 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_S2
, 0);
2489 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2491 code
.code
= sljit_generate_code(compiler
);
2493 sljit_free_compiler(compiler
);
2495 code
.func1((sljit_sw
)&buf
);
2496 FAILED(buf
[0] != 69, "test29 case 1 failed\n");
2497 FAILED(buf
[1] != -93, "test29 case 2 failed\n");
2498 FAILED(buf
[2] != 200, "test29 case 3 failed\n");
2499 FAILED(buf
[3] != 0xe5, "test29 case 4 failed\n");
2500 FAILED(buf
[4] != 19640, "test29 case 5 failed\n");
2501 FAILED(buf
[5] != -31005, "test29 case 6 failed\n");
2502 FAILED(buf
[6] != 52646, "test29 case 7 failed\n");
2503 FAILED(buf
[7] != 0xb0a6, "test29 case 8 failed\n");
2505 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2506 FAILED(buf
[8] != SLJIT_W(714537581), "test29 case 9 failed\n");
2507 FAILED(buf
[9] != SLJIT_W(-1938520854), "test29 case 10 failed\n");
2508 FAILED(buf
[10] != SLJIT_W(3236202668), "test29 case 11 failed\n");
2509 FAILED(buf
[11] != SLJIT_W(0xf97a70b5), "test29 case 12 failed\n");
2512 FAILED(buf
[12] != 69, "test29 case 13 failed\n");
2513 FAILED(buf
[13] != -93, "test29 case 14 failed\n");
2514 FAILED(buf
[14] != 200, "test29 case 15 failed\n");
2515 FAILED(buf
[15] != 0xe5, "test29 case 16 failed\n");
2516 FAILED(buf
[16] != 19640, "test29 case 17 failed\n");
2517 FAILED(buf
[17] != -31005, "test29 case 18 failed\n");
2518 FAILED(buf
[18] != 52646, "test29 case 19 failed\n");
2519 FAILED(buf
[19] != 0xb0a6, "test29 case 20 failed\n");
2521 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2522 FAILED(buf
[20] != SLJIT_W(714537581), "test29 case 21 failed\n");
2523 FAILED(buf
[21] != SLJIT_W(-1938520854), "test29 case 22 failed\n");
2524 FAILED(buf
[22] != SLJIT_W(3236202668), "test29 case 23 failed\n");
2525 FAILED(buf
[23] != SLJIT_W(0xf97a70b5), "test29 case 24 failed\n");
2528 FAILED(buf
[24] != -91, "test29 case 25 failed\n");
2530 sljit_free_code(code
.code
);
2534 static void test30(void)
2536 /* Test unused results. */
2537 executable_code code
;
2538 struct sljit_compiler
* compiler
= sljit_create_compiler();
2542 printf("Run test30\n");
2544 FAILED(!compiler
, "cannot create compiler\n");
2546 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 0);
2548 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2549 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2550 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 1);
2551 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 1);
2552 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, 1);
2553 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2554 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_S1
, 0, SLJIT_IMM
, SLJIT_W(-0x123ffffffff));
2556 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_S1
, 0, SLJIT_IMM
, 1);
2558 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 1);
2559 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 1);
2560 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, 1);
2562 /* Some calculations with unused results. */
2563 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0);
2564 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0);
2565 sljit_emit_op1(compiler
, SLJIT_NEG
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
2566 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
2567 sljit_emit_op2(compiler
, SLJIT_ISUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
2568 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_UNUSED
, 0, SLJIT_S0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
2569 sljit_emit_op2(compiler
, SLJIT_SHL
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_S3
, 0, SLJIT_R2
, 0);
2570 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 5);
2571 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0xff);
2572 sljit_emit_op1(compiler
, SLJIT_INOT
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_S1
, 0);
2574 /* Testing that any change happens. */
2575 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2576 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R2
, 0);
2577 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R3
, 0);
2578 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R4
, 0);
2579 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_S1
, 0, SLJIT_S1
, 0);
2580 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S1
, 0);
2581 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S2
, 0);
2582 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S3
, 0);
2583 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0, SLJIT_S4
, 0);
2585 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2587 code
.code
= sljit_generate_code(compiler
);
2589 sljit_free_compiler(compiler
);
2591 code
.func1((sljit_sw
)&buf
);
2592 FAILED(buf
[0] != 9, "test30 case 1 failed\n");
2594 sljit_free_code(code
.code
);
2598 static void test31(void)
2600 /* Integer mul and set flags. */
2601 executable_code code
;
2602 struct sljit_compiler
* compiler
= sljit_create_compiler();
2604 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2605 sljit_sw big_word
= SLJIT_W(0x7fffffff00000000);
2606 sljit_sw big_word2
= SLJIT_W(0x7fffffff00000012);
2608 sljit_sw big_word
= 0x7fffffff;
2609 sljit_sw big_word2
= 0x00000012;
2613 printf("Run test31\n");
2628 FAILED(!compiler
, "cannot create compiler\n");
2630 sljit_emit_enter(compiler
, 0, 1, 3, 5, 0, 0, 0);
2631 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
2632 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -45);
2633 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MUL_NOT_OVERFLOW
);
2634 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MUL_OVERFLOW
);
2636 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, big_word
);
2637 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_O
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, -2);
2638 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 33); /* Should not change flags. */
2639 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0); /* Should not change flags. */
2640 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_MUL_OVERFLOW
);
2641 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_MUL_NOT_OVERFLOW
);
2643 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_S3
, 0, SLJIT_IMM
, 0x3f6b0);
2644 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_S4
, 0, SLJIT_IMM
, 0x2a783);
2645 sljit_emit_op2(compiler
, SLJIT_IMUL
| SLJIT_SET_O
, SLJIT_R1
, 0, SLJIT_S3
, 0, SLJIT_S4
, 0);
2646 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_I_MUL_OVERFLOW
);
2647 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
2649 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, big_word2
);
2650 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R2
, 0, SLJIT_R1
, 0);
2651 sljit_emit_op2(compiler
, SLJIT_IMUL
| SLJIT_SET_O
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 23);
2652 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_I_MUL_OVERFLOW
);
2654 sljit_emit_op2(compiler
, SLJIT_IMUL
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -23);
2655 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_I_MUL_NOT_OVERFLOW
);
2656 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_O
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -23);
2657 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_MUL_NOT_OVERFLOW
);
2659 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 67);
2660 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_O
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -23);
2661 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R1
, 0);
2663 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2665 code
.code
= sljit_generate_code(compiler
);
2667 sljit_free_compiler(compiler
);
2669 code
.func1((sljit_sw
)&buf
);
2671 FAILED(buf
[0] != 1, "test31 case 1 failed\n");
2672 FAILED(buf
[1] != 2, "test31 case 2 failed\n");
2673 /* Qemu issues for 64 bit muls. */
2674 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2675 FAILED(buf
[2] != 1, "test31 case 3 failed\n");
2676 FAILED(buf
[3] != 2, "test31 case 4 failed\n");
2678 FAILED(buf
[4] != 1, "test31 case 5 failed\n");
2679 FAILED((buf
[5] & 0xffffffff) != 0x85540c10, "test31 case 6 failed\n");
2680 FAILED(buf
[6] != 2, "test31 case 7 failed\n");
2681 FAILED(buf
[7] != 1, "test31 case 8 failed\n");
2682 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2683 FAILED(buf
[8] != 1, "test31 case 9 failed\n");
2685 FAILED(buf
[9] != -1541, "test31 case 10 failed\n");
2687 sljit_free_code(code
.code
);
2691 static void test32(void)
2693 /* Floating point set flags. */
2694 executable_code code
;
2695 struct sljit_compiler
* compiler
= sljit_create_compiler();
2707 printf("Run test32\n");
2727 dbuf
[0].u
.value1
= 0x7fffffff;
2728 dbuf
[0].u
.value2
= 0x7fffffff;
2729 dbuf
[1].u
.value1
= 0x7fffffff;
2730 dbuf
[1].u
.value2
= 0x7fffffff;
2731 dbuf
[2].value
= -13.0;
2732 dbuf
[3].value
= 27.0;
2734 if (!sljit_is_fpu_available()) {
2736 printf("no fpu available, test32 skipped\n");
2739 sljit_free_compiler(compiler
);
2743 FAILED(!compiler
, "cannot create compiler\n");
2744 SLJIT_ASSERT(sizeof(sljit_d
) == 8 && sizeof(sljit_si
) == 4 && sizeof(dbuf
[0]) == 8);
2746 sljit_emit_enter(compiler
, 0, 2, 1, 2, 4, 0, 0);
2748 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
2749 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_E
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_d
), SLJIT_FR0
, 0);
2750 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_d
));
2751 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_D_UNORDERED
);
2752 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_D_ORDERED
);
2754 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_d
));
2755 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_E
| SLJIT_SET_S
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2756 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_D_UNORDERED
);
2757 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_D_ORDERED
);
2758 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_D_LESS
);
2759 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_D_GREATER_EQUAL
);
2760 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_D_GREATER
);
2761 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_D_LESS_EQUAL
);
2762 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_D_EQUAL
);
2763 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_D_NOT_EQUAL
);
2765 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_E
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_d
));
2766 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_FR3
, 0, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_d
));
2767 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_D_UNORDERED
);
2768 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_D_EQUAL
);
2770 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_S
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_d
), SLJIT_FR0
, 0);
2771 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_D_ORDERED
);
2773 sljit_emit_fop1(compiler
, SLJIT_CMPD
| SLJIT_SET_S
, SLJIT_FR3
, 0, SLJIT_FR2
, 0);
2774 sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
2775 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_D_UNORDERED
);
2777 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2779 code
.code
= sljit_generate_code(compiler
);
2781 sljit_free_compiler(compiler
);
2783 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&dbuf
);
2785 FAILED(buf
[0] != 1, "test32 case 1 failed\n");
2786 FAILED(buf
[1] != 2, "test32 case 2 failed\n");
2787 FAILED(buf
[2] != 2, "test32 case 3 failed\n");
2788 FAILED(buf
[3] != 1, "test32 case 4 failed\n");
2789 FAILED(buf
[4] != 1, "test32 case 5 failed\n");
2790 FAILED(buf
[5] != 2, "test32 case 6 failed\n");
2791 FAILED(buf
[6] != 2, "test32 case 7 failed\n");
2792 FAILED(buf
[7] != 1, "test32 case 8 failed\n");
2793 FAILED(buf
[8] != 2, "test32 case 9 failed\n");
2794 FAILED(buf
[9] != 1, "test32 case 10 failed\n");
2795 FAILED(buf
[10] != 2, "test32 case 11 failed\n");
2796 FAILED(buf
[11] != 1, "test32 case 12 failed\n");
2797 FAILED(buf
[12] != 2, "test32 case 13 failed\n");
2798 FAILED(buf
[13] != 1, "test32 case 14 failed\n");
2800 sljit_free_code(code
.code
);
2804 static void test33(void)
2806 /* Test keep flags. */
2807 executable_code code
;
2808 struct sljit_compiler
* compiler
= sljit_create_compiler();
2810 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2811 sljit_sw big_word
= SLJIT_W(0x8000000000000003);
2813 sljit_sw big_word
= 0x80000003;
2817 printf("Run test33\n");
2827 FAILED(!compiler
, "cannot create compiler\n");
2829 sljit_emit_enter(compiler
, 0, 1, 3, 3, 0, 0, 0);
2830 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, big_word
);
2831 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_E
| SLJIT_SET_C
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, big_word
);
2832 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
2833 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
2834 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_KEEP_FLAGS
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
2835 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
2836 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2837 sljit_emit_op2(compiler
, SLJIT_ADDC
| SLJIT_KEEP_FLAGS
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2838 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0, SLJIT_IMM
, 7);
2840 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
2841 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
2842 sljit_emit_op2(compiler
, SLJIT_SHL
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
2843 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
2845 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, 0x124);
2846 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
2847 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2848 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_KEEP_FLAGS
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
2849 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_NOT_EQUAL
);
2851 /* PowerPC specific test. */
2852 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
2853 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_C
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2);
2854 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2855 sljit_emit_op2(compiler
, SLJIT_ASHR
| SLJIT_KEEP_FLAGS
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2856 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
2857 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_IMM
, 0);
2859 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
2861 code
.code
= sljit_generate_code(compiler
);
2863 sljit_free_compiler(compiler
);
2865 code
.func1((sljit_sw
)&buf
);
2867 FAILED(buf
[0] != 6, "test33 case 1 failed\n");
2868 FAILED(buf
[1] != 1, "test33 case 2 failed\n");
2869 FAILED(buf
[2] != 8, "test33 case 3 failed\n");
2870 FAILED(buf
[3] != 16, "test33 case 4 failed\n");
2871 FAILED(buf
[4] != 1, "test33 case 5 failed\n");
2872 FAILED(buf
[5] != 0x125, "test33 case 6 failed\n");
2873 FAILED(buf
[6] != 1, "test33 case 7 failed\n");
2875 sljit_free_code(code
.code
);
2879 static void test34(void)
2881 /* Test fast calls. */
2882 executable_code codeA
;
2883 executable_code codeB
;
2884 executable_code codeC
;
2885 executable_code codeD
;
2886 executable_code codeE
;
2887 executable_code codeF
;
2888 struct sljit_compiler
* compiler
;
2889 struct sljit_jump
*jump
;
2890 struct sljit_label
* label
;
2895 printf("Run test34\n");
2901 compiler
= sljit_create_compiler();
2902 FAILED(!compiler
, "cannot create compiler\n");
2903 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2905 sljit_emit_fast_enter(compiler
, SLJIT_R1
, 0);
2906 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 4);
2907 sljit_emit_fast_return(compiler
, SLJIT_R1
, 0);
2909 codeA
.code
= sljit_generate_code(compiler
);
2911 sljit_free_compiler(compiler
);
2914 compiler
= sljit_create_compiler();
2915 FAILED(!compiler
, "cannot create compiler\n");
2916 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2918 sljit_emit_fast_enter(compiler
, SLJIT_R4
, 0);
2919 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 6);
2920 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_FUNC_OFFSET(codeA
.code
));
2921 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_R1
, 0);
2922 sljit_emit_fast_return(compiler
, SLJIT_R4
, 0);
2924 codeB
.code
= sljit_generate_code(compiler
);
2926 sljit_free_compiler(compiler
);
2929 compiler
= sljit_create_compiler();
2930 FAILED(!compiler
, "cannot create compiler\n");
2931 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2933 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_p
));
2934 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
2935 jump
= sljit_emit_jump(compiler
, SLJIT_REWRITABLE_JUMP
| SLJIT_FAST_CALL
);
2936 sljit_set_target(jump
, SLJIT_FUNC_OFFSET(codeB
.code
));
2937 sljit_emit_fast_return(compiler
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_p
));
2939 codeC
.code
= sljit_generate_code(compiler
);
2941 sljit_free_compiler(compiler
);
2944 compiler
= sljit_create_compiler();
2945 FAILED(!compiler
, "cannot create compiler\n");
2946 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2948 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_SP
), 0);
2949 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 10);
2950 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(codeC
.code
));
2951 sljit_emit_fast_return(compiler
, SLJIT_MEM1(SLJIT_SP
), 0);
2953 codeD
.code
= sljit_generate_code(compiler
);
2955 sljit_free_compiler(compiler
);
2958 compiler
= sljit_create_compiler();
2959 FAILED(!compiler
, "cannot create compiler\n");
2960 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2962 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_S0
), 0);
2963 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 12);
2964 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
), SLJIT_IMM
, SLJIT_FUNC_OFFSET(codeD
.code
));
2965 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
));
2966 sljit_emit_fast_return(compiler
, SLJIT_MEM1(SLJIT_S0
), 0);
2968 codeE
.code
= sljit_generate_code(compiler
);
2970 sljit_free_compiler(compiler
);
2973 compiler
= sljit_create_compiler();
2974 FAILED(!compiler
, "cannot create compiler\n");
2976 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
2977 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2978 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(codeE
.code
));
2979 label
= sljit_emit_label(compiler
);
2980 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
2982 codeF
.code
= sljit_generate_code(compiler
);
2984 addr
= sljit_get_label_addr(label
);
2985 sljit_free_compiler(compiler
);
2987 FAILED(codeF
.func1((sljit_sw
)&buf
) != 40, "test34 case 1 failed\n");
2988 FAILED(buf
[0] != addr
- SLJIT_RETURN_ADDRESS_OFFSET
, "test34 case 2 failed\n");
2990 sljit_free_code(codeA
.code
);
2991 sljit_free_code(codeB
.code
);
2992 sljit_free_code(codeC
.code
);
2993 sljit_free_code(codeD
.code
);
2994 sljit_free_code(codeE
.code
);
2995 sljit_free_code(codeF
.code
);
2999 static void test35(void)
3001 /* More complicated tests for fast calls. */
3002 executable_code codeA
;
3003 executable_code codeB
;
3004 executable_code codeC
;
3005 struct sljit_compiler
* compiler
;
3006 struct sljit_jump
*jump
;
3007 struct sljit_label
* label
;
3008 sljit_uw return_addr
, jump_addr
;
3012 printf("Run test35\n");
3017 compiler
= sljit_create_compiler();
3018 FAILED(!compiler
, "cannot create compiler\n");
3019 sljit_set_context(compiler
, 0, 0, 2, 2, 0, 0, 0);
3021 sljit_emit_fast_enter(compiler
, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
3022 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3023 jump
= sljit_emit_jump(compiler
, SLJIT_REWRITABLE_JUMP
| SLJIT_FAST_CALL
);
3024 sljit_set_target(jump
, 0);
3025 label
= sljit_emit_label(compiler
);
3026 sljit_emit_fast_return(compiler
, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
3028 codeA
.code
= sljit_generate_code(compiler
);
3030 return_addr
= sljit_get_label_addr(label
) - SLJIT_RETURN_ADDRESS_OFFSET
;
3031 jump_addr
= sljit_get_jump_addr(jump
);
3032 sljit_free_compiler(compiler
);
3035 compiler
= sljit_create_compiler();
3036 FAILED(!compiler
, "cannot create compiler\n");
3037 sljit_set_context(compiler
, 0, 0, 2, 2, 0, 0, 0);
3039 sljit_emit_fast_enter(compiler
, SLJIT_UNUSED
, 0);
3040 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 7);
3041 sljit_emit_fast_return(compiler
, SLJIT_IMM
, return_addr
);
3043 codeB
.code
= sljit_generate_code(compiler
);
3045 sljit_free_compiler(compiler
);
3046 sljit_set_jump_addr(jump_addr
, SLJIT_FUNC_OFFSET(codeB
.code
));
3049 compiler
= sljit_create_compiler();
3050 FAILED(!compiler
, "cannot create compiler\n");
3052 sljit_emit_enter(compiler
, 0, 0, 2, 2, 0, 0, 0);
3053 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3054 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(codeA
.code
));
3055 label
= sljit_emit_label(compiler
);
3056 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
3058 codeC
.code
= sljit_generate_code(compiler
);
3060 return_addr
= sljit_get_label_addr(label
);
3061 sljit_free_compiler(compiler
);
3063 FAILED(codeC
.func0() != 12, "test35 case 1 failed\n");
3064 FAILED(buf
[0] != return_addr
- SLJIT_RETURN_ADDRESS_OFFSET
, "test35 case 2 failed\n");
3066 sljit_free_code(codeA
.code
);
3067 sljit_free_code(codeB
.code
);
3068 sljit_free_code(codeC
.code
);
3072 static sljit_si
cmp_test(struct sljit_compiler
*compiler
, sljit_si type
, sljit_si src1
, sljit_sw src1w
, sljit_si src2
, sljit_sw src2w
)
3074 /* 2 = true, 1 = false */
3075 struct sljit_jump
* jump
;
3076 struct sljit_label
* label
;
3078 if (sljit_emit_op1(compiler
, SLJIT_MOVU_UB
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_IMM
, 2))
3079 return compiler
->error
;
3080 jump
= sljit_emit_cmp(compiler
, type
, src1
, src1w
, src2
, src2w
);
3082 return compiler
->error
;
3083 if (sljit_emit_op1(compiler
, SLJIT_MOV_UB
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 1))
3084 return compiler
->error
;
3085 label
= sljit_emit_label(compiler
);
3087 return compiler
->error
;
3088 sljit_set_label(jump
, label
);
3089 return SLJIT_SUCCESS
;
3092 #define TEST_CASES (7 + 10 + 12 + 11 + 4)
3093 static void test36(void)
3095 /* Compare instruction. */
3096 executable_code code
;
3097 struct sljit_compiler
* compiler
= sljit_create_compiler();
3099 sljit_sb buf
[TEST_CASES
];
3100 sljit_sb compare_buf
[TEST_CASES
] = {
3101 1, 1, 2, 2, 1, 2, 2,
3102 1, 1, 2, 2, 2, 1, 2, 2, 1, 1,
3103 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2,
3104 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2,
3111 printf("Run test36\n");
3113 FAILED(!compiler
, "cannot create compiler\n");
3114 for (i
= 0; i
< TEST_CASES
; ++i
)
3121 sljit_emit_enter(compiler
, 0, 2, 3, 2, 0, 0, 0);
3122 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
3124 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 13);
3125 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 15);
3126 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_IMM
, 9, SLJIT_R0
, 0);
3127 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3128 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
3129 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_IMM
, -13);
3130 cmp_test(compiler
, SLJIT_NOT_EQUAL
, SLJIT_IMM
, 0, SLJIT_R0
, 0);
3131 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3132 cmp_test(compiler
, SLJIT_NOT_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 0, SLJIT_R0
, 0);
3133 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
);
3134 cmp_test(compiler
, SLJIT_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3136 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, 0);
3137 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -8);
3138 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3139 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3140 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3141 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3142 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3143 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
));
3144 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_IMM
, 0, SLJIT_R1
, 0);
3145 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
));
3146 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3147 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3149 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3150 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3151 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
));
3152 cmp_test(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3153 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
3154 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3155 cmp_test(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3156 cmp_test(compiler
, SLJIT_GREATER_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3157 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3158 cmp_test(compiler
, SLJIT_LESS_EQUAL
, SLJIT_IMM
, 7, SLJIT_R0
, 0);
3159 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_IMM
, 1, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3160 cmp_test(compiler
, SLJIT_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3161 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3162 cmp_test(compiler
, SLJIT_GREATER
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3164 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -3);
3165 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3166 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3167 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3168 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3169 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -1);
3170 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -1);
3171 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3172 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3173 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_IMM
, -4, SLJIT_R0
, 0);
3174 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_IMM
, -1, SLJIT_R1
, 0);
3175 cmp_test(compiler
, SLJIT_SIG_GREATER
| SLJIT_REWRITABLE_JUMP
, SLJIT_R1
, 0, SLJIT_IMM
, -1);
3177 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3178 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xf00000004));
3179 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
3180 cmp_test(compiler
, SLJIT_I_LESS
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
3181 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3182 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xff0000004));
3183 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
3184 cmp_test(compiler
, SLJIT_I_SIG_GREATER
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
3185 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3187 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
3188 cmp_test(compiler
, SLJIT_I_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3189 cmp_test(compiler
, SLJIT_I_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3190 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf0000004);
3191 cmp_test(compiler
, SLJIT_I_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3192 cmp_test(compiler
, SLJIT_I_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3195 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
3197 code
.code
= sljit_generate_code(compiler
);
3199 sljit_free_compiler(compiler
);
3201 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&data
);
3203 for (i
= 0; i
< TEST_CASES
; ++i
)
3204 if (SLJIT_UNLIKELY(buf
[i
] != compare_buf
[i
])) {
3205 printf("test36 case %d failed\n", i
+ 1);
3209 sljit_free_code(code
.code
);
3214 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3215 #define BITN(n) (SLJIT_W(1) << (63 - (n)))
3218 #define BITN(n) (1 << (31 - ((n) & 0x1f)))
3219 #define RESN(n) ((n) & 0x1f)
3222 static void test37(void)
3224 /* Test count leading zeroes. */
3225 executable_code code
;
3226 struct sljit_compiler
* compiler
= sljit_create_compiler();
3232 printf("Run test37\n");
3234 FAILED(!compiler
, "cannot create compiler\n");
3236 for (i
= 0; i
< 15; i
++)
3242 sljit_emit_enter(compiler
, 0, 2, 1, 2, 0, 0, 0);
3243 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, BITN(27));
3244 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
3245 sljit_emit_op1(compiler
, SLJIT_CLZ
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_IMM
, BITN(47));
3246 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
3247 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_ZERO
);
3248 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
));
3249 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3250 sljit_emit_op1(compiler
, SLJIT_CLZ
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3251 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_ZERO
);
3252 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3253 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3254 sljit_emit_op1(compiler
, SLJIT_ICLZ
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_R0
, 0);
3255 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3256 sljit_emit_op1(compiler
, SLJIT_CLZ
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0);
3257 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_ZERO
);
3258 sljit_emit_op1(compiler
, SLJIT_CLZ
| SLJIT_KEEP_FLAGS
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
));
3259 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3260 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
3261 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, BITN(58));
3262 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3263 sljit_emit_op1(compiler
, SLJIT_CLZ
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
));
3264 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_NOT_ZERO
);
3265 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3266 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3267 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3268 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xff08a00000));
3270 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x08a00000);
3272 sljit_emit_op1(compiler
, SLJIT_ICLZ
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_si
), SLJIT_R0
, 0);
3273 sljit_emit_op1(compiler
, SLJIT_ICLZ
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3274 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3275 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3276 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xffc8a00000));
3278 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xc8a00000);
3280 sljit_emit_op1(compiler
, SLJIT_ICLZ
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0);
3281 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_I_ZERO
);
3282 sljit_emit_op1(compiler
, SLJIT_ICLZ
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3283 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3285 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
3287 code
.code
= sljit_generate_code(compiler
);
3289 sljit_free_compiler(compiler
);
3291 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&ibuf
);
3292 FAILED(buf
[0] != RESN(27), "test37 case 1 failed\n");
3293 FAILED(buf
[1] != RESN(47), "test37 case 2 failed\n");
3294 FAILED(buf
[2] != 0, "test37 case 3 failed\n");
3295 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3296 FAILED(buf
[3] != 64, "test37 case 4 failed\n");
3298 FAILED(buf
[3] != 32, "test37 case 4 failed\n");
3300 FAILED(buf
[4] != 1, "test37 case 5 failed\n");
3301 FAILED(buf
[5] != 0, "test37 case 6 failed\n");
3302 FAILED(ibuf
[0] != 32, "test37 case 7 failed\n");
3303 FAILED(buf
[6] != 1, "test37 case 8 failed\n");
3304 FAILED(buf
[7] != RESN(13), "test37 case 9 failed\n");
3305 #if !(defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3306 FAILED(buf
[8] != 0, "test37 case 10 failed\n");
3308 FAILED(buf
[9] != RESN(58), "test37 case 11 failed\n");
3309 FAILED(buf
[10] != 0, "test37 case 12 failed\n");
3310 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3311 FAILED(buf
[11] != 64, "test37 case 13 failed\n");
3313 FAILED(buf
[11] != 32, "test37 case 13 failed\n");
3315 FAILED(ibuf
[1] != 4, "test37 case 14 failed\n");
3316 FAILED((buf
[12] & 0xffffffff) != 4, "test37 case 15 failed\n");
3317 FAILED(buf
[13] != 1, "test37 case 16 failed\n");
3318 FAILED((buf
[14] & 0xffffffff) != 0, "test37 case 17 failed\n");
3320 sljit_free_code(code
.code
);
3326 static void test38(void)
3328 #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
3329 /* Test stack utility. */
3330 executable_code code
;
3331 struct sljit_compiler
* compiler
= sljit_create_compiler();
3332 struct sljit_jump
* alloc_fail
;
3333 struct sljit_jump
* alloc2_fail
;
3334 struct sljit_jump
* alloc3_fail
;
3335 struct sljit_jump
* jump
;
3336 struct sljit_label
* label
;
3339 printf("Run test38\n");
3341 FAILED(!compiler
, "cannot create compiler\n");
3343 sljit_emit_enter(compiler
, 0, 0, 2, 1, 0, 0, 0);
3345 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8192);
3346 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 65536);
3347 sljit_emit_ijump(compiler
, SLJIT_CALL2
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(sljit_allocate_stack
));
3348 alloc_fail
= sljit_emit_cmp(compiler
, SLJIT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3349 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_RETURN_REG
, 0);
3351 /* Write 8k data. */
3352 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, base
), SLJIT_IMM
, sizeof(sljit_sw
));
3353 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8192);
3354 label
= sljit_emit_label(compiler
);
3355 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_IMM
, -1);
3356 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3357 sljit_set_label(jump
, label
);
3360 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3361 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, base
), SLJIT_IMM
, 65536);
3362 sljit_emit_ijump(compiler
, SLJIT_CALL2
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(sljit_stack_resize
));
3363 alloc2_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3365 /* Write 64k data. */
3366 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, base
), SLJIT_IMM
, sizeof(sljit_sw
));
3367 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 65536);
3368 label
= sljit_emit_label(compiler
);
3369 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_IMM
, -1);
3370 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3371 sljit_set_label(jump
, label
);
3374 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3375 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, base
), SLJIT_IMM
, 32768);
3376 sljit_emit_ijump(compiler
, SLJIT_CALL2
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(sljit_stack_resize
));
3377 alloc3_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3379 /* Write 32k data. */
3380 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, base
), SLJIT_IMM
, sizeof(sljit_sw
));
3381 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, limit
), SLJIT_IMM
, sizeof(sljit_sw
));
3382 label
= sljit_emit_label(compiler
);
3383 sljit_emit_op1(compiler
, SLJIT_MOVU
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_IMM
, -1);
3384 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3385 sljit_set_label(jump
, label
);
3387 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3388 sljit_emit_ijump(compiler
, SLJIT_CALL1
, SLJIT_IMM
, SLJIT_FUNC_OFFSET(sljit_free_stack
));
3390 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 1);
3391 label
= sljit_emit_label(compiler
);
3392 sljit_set_label(alloc_fail
, label
);
3393 sljit_set_label(alloc2_fail
, label
);
3394 sljit_set_label(alloc3_fail
, label
);
3395 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
3397 code
.code
= sljit_generate_code(compiler
);
3399 sljit_free_compiler(compiler
);
3401 /* Just survive this. */
3402 FAILED(code
.func0() != 1, "test38 case 1 failed\n");
3404 sljit_free_code(code
.code
);
3409 static void test39(void)
3411 /* Test error handling. */
3412 executable_code code
;
3413 struct sljit_compiler
* compiler
= sljit_create_compiler();
3414 struct sljit_jump
* jump
;
3417 printf("Run test39\n");
3419 FAILED(!compiler
, "cannot create compiler\n");
3421 /* Such assignment should never happen in a regular program. */
3422 compiler
->error
= -3967;
3424 SLJIT_ASSERT(sljit_emit_enter(compiler
, 0, 2, 5, 5, 6, 0, 32) == -3967);
3425 SLJIT_ASSERT(sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R1
, 0) == -3967);
3426 SLJIT_ASSERT(sljit_emit_op0(compiler
, SLJIT_NOP
) == -3967);
3427 SLJIT_ASSERT(sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1) == -3967);
3428 SLJIT_ASSERT(sljit_emit_op2(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), 64, SLJIT_MEM1(SLJIT_S0
), -64) == -3967);
3429 SLJIT_ASSERT(sljit_emit_fop1(compiler
, SLJIT_ABSD
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_R1
), 0) == -3967);
3430 SLJIT_ASSERT(sljit_emit_fop2(compiler
, SLJIT_DIVD
, SLJIT_FR2
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_S0
), 0, SLJIT_FR2
, 0) == -3967);
3431 SLJIT_ASSERT(!sljit_emit_label(compiler
));
3432 jump
= sljit_emit_jump(compiler
, SLJIT_CALL3
);
3433 SLJIT_ASSERT(!jump
);
3434 sljit_set_label(jump
, (struct sljit_label
*)0x123450);
3435 sljit_set_target(jump
, 0x123450);
3436 jump
= sljit_emit_cmp(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3437 SLJIT_ASSERT(!jump
);
3438 SLJIT_ASSERT(sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_MEM1(SLJIT_R0
), 8) == -3967);
3439 SLJIT_ASSERT(sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_UNUSED
, 0, SLJIT_MUL_OVERFLOW
) == -3967);
3440 SLJIT_ASSERT(!sljit_emit_const(compiler
, SLJIT_R0
, 0, 99));
3442 SLJIT_ASSERT(!compiler
->labels
&& !compiler
->jumps
&& !compiler
->consts
);
3443 SLJIT_ASSERT(!compiler
->last_label
&& !compiler
->last_jump
&& !compiler
->last_const
);
3444 SLJIT_ASSERT(!compiler
->buf
->next
&& !compiler
->buf
->used_size
);
3445 SLJIT_ASSERT(!compiler
->abuf
->next
&& !compiler
->abuf
->used_size
);
3447 code
.code
= sljit_generate_code(compiler
);
3448 FAILED(sljit_get_compiler_error(compiler
) != -3967, "test39 case 1 failed\n");
3449 FAILED(!!code
.code
, "test39 case 2 failed\n");
3450 sljit_free_compiler(compiler
);
3454 static void test40(void)
3456 /* Test emit_op_flags. */
3457 executable_code code
;
3458 struct sljit_compiler
* compiler
= sljit_create_compiler();
3462 printf("Run test40\n");
3464 FAILED(!compiler
, "cannot create compiler\n");
3476 sljit_emit_enter(compiler
, 0, 1, 3, 4, 0, 0, sizeof(sljit_sw
));
3478 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -5);
3479 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
, SLJIT_UNUSED
, 0, SLJIT_IMM
, -6, SLJIT_R0
, 0);
3480 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x123456);
3481 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_SIG_LESS
);
3482 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
3484 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -13);
3485 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_IMM
, -13, SLJIT_R0
, 0);
3486 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 0);
3487 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_EQUAL
);
3488 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
3489 sljit_emit_op2(compiler
, SLJIT_OR
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_SP
), 0);
3490 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3491 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_E
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_EQUAL
);
3492 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
3494 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -13);
3495 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
3496 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_S
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
3497 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_SIG_LESS
);
3499 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -8);
3500 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 33);
3501 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
3502 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0);
3503 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_UNUSED
, 0, SLJIT_GREATER
);
3504 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_KEEP_FLAGS
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_EQUAL
);
3505 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 0x88);
3506 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_KEEP_FLAGS
, SLJIT_S3
, 0, SLJIT_S3
, 0, SLJIT_NOT_EQUAL
);
3507 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_S1
, 0);
3508 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_S3
, 0);
3510 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x84);
3511 sljit_emit_op2(compiler
, SLJIT_AND
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_IMM
, 0x180, SLJIT_R0
, 0);
3512 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_E
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_EQUAL
);
3513 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_EQUAL
);
3515 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3516 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3517 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_NOT_EQUAL
);
3518 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_UNUSED
, 0, SLJIT_NOT_EQUAL
);
3520 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x123456);
3521 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3522 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_GREATER
);
3523 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_R0
, 0);
3525 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 0xbaddead);
3526 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0);
3528 code
.code
= sljit_generate_code(compiler
);
3530 sljit_free_compiler(compiler
);
3532 FAILED(code
.func1((sljit_sw
)&buf
) != 0xbaddead, "test40 case 1 failed\n");
3533 FAILED(buf
[0] != 0x123457, "test40 case 2 failed\n");
3534 FAILED(buf
[1] != 1, "test40 case 3 failed\n");
3535 FAILED(buf
[2] != 0, "test40 case 4 failed\n");
3536 FAILED(buf
[3] != -7, "test40 case 5 failed\n");
3537 FAILED(buf
[4] != 0, "test40 case 6 failed\n");
3538 FAILED(buf
[5] != 0x89, "test40 case 7 failed\n");
3539 FAILED(buf
[6] != 0, "test40 case 8 failed\n");
3540 FAILED(buf
[7] != 1, "test40 case 9 failed\n");
3541 FAILED(buf
[8] != 1, "test40 case 10 failed\n");
3542 FAILED(buf
[9] != 0x123457, "test40 case 11 failed\n");
3544 sljit_free_code(code
.code
);
3548 static void test41(void)
3550 /* Test inline assembly. */
3551 executable_code code
;
3552 struct sljit_compiler
* compiler
= sljit_create_compiler();
3555 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3557 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3565 printf("Run test41\n");
3567 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
3568 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3569 if (SLJIT_R(i
) >= SLJIT_R3
&& SLJIT_R(i
) <= SLJIT_R6
) {
3570 SLJIT_ASSERT(sljit_get_register_index(SLJIT_R(i
)) == -1);
3574 SLJIT_ASSERT(sljit_get_register_index(SLJIT_R(i
)) >= 0 && sljit_get_register_index(SLJIT_R(i
)) < 64);
3577 FAILED(!compiler
, "cannot create compiler\n");
3578 sljit_emit_enter(compiler
, 0, 2, 3, 3, 0, 0, 0);
3580 /* Returns with the sum of SLJIT_S0 and SLJIT_S1. */
3581 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3582 /* lea SLJIT_RETURN_REG, [SLJIT_S0, SLJIT_S1] */
3585 inst
[2] = 0x04 | ((sljit_get_register_index(SLJIT_RETURN_REG
) & 0x7) << 3);
3586 inst
[3] = (sljit_get_register_index(SLJIT_S0
) & 0x7)
3587 | ((sljit_get_register_index(SLJIT_S1
) & 0x7) << 3);
3588 sljit_emit_op_custom(compiler
, inst
, 4);
3589 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3590 /* lea SLJIT_RETURN_REG, [SLJIT_S0, SLJIT_S1] */
3591 inst
[0] = 0x48; /* REX_W */
3594 reg
= sljit_get_register_index(SLJIT_RETURN_REG
);
3595 inst
[2] |= ((reg
& 0x7) << 3);
3597 inst
[0] |= 0x04; /* REX_R */
3598 reg
= sljit_get_register_index(SLJIT_S0
);
3599 inst
[3] = reg
& 0x7;
3601 inst
[0] |= 0x01; /* REX_B */
3602 reg
= sljit_get_register_index(SLJIT_S1
);
3603 inst
[3] |= (reg
& 0x7) << 3;
3605 inst
[0] |= 0x02; /* REX_X */
3606 sljit_emit_op_custom(compiler
, inst
, 4);
3607 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
3608 /* add rd, rn, rm */
3609 inst
= 0xe0800000 | (sljit_get_register_index(SLJIT_RETURN_REG
) << 12)
3610 | (sljit_get_register_index(SLJIT_S0
) << 16)
3611 | sljit_get_register_index(SLJIT_S1
);
3612 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3613 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
3614 /* add rd, rn, rm */
3615 inst
= 0xeb000000 | (sljit_get_register_index(SLJIT_RETURN_REG
) << 8)
3616 | (sljit_get_register_index(SLJIT_S0
) << 16)
3617 | sljit_get_register_index(SLJIT_S1
);
3618 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3619 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
3620 /* add rd, rn, rm */
3621 inst
= 0x8b000000 | sljit_get_register_index(SLJIT_RETURN_REG
)
3622 | (sljit_get_register_index(SLJIT_S0
) << 5)
3623 | (sljit_get_register_index(SLJIT_S1
) << 16);
3624 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3625 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
3626 /* add rD, rA, rB */
3627 inst
= (31 << 26) | (266 << 1) | (sljit_get_register_index(SLJIT_RETURN_REG
) << 21)
3628 | (sljit_get_register_index(SLJIT_S0
) << 16)
3629 | (sljit_get_register_index(SLJIT_S1
) << 11);
3630 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3631 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
3632 /* addu rd, rs, rt */
3633 inst
= 33 | (sljit_get_register_index(SLJIT_RETURN_REG
) << 11)
3634 | (sljit_get_register_index(SLJIT_S0
) << 21)
3635 | (sljit_get_register_index(SLJIT_S1
) << 16);
3636 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3637 #elif (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
3638 /* daddu rd, rs, rt */
3639 inst
= 45 | (sljit_get_register_index(SLJIT_RETURN_REG
) << 11)
3640 | (sljit_get_register_index(SLJIT_S0
) << 21)
3641 | (sljit_get_register_index(SLJIT_S1
) << 16);
3642 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3643 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3644 /* add rd, rs1, rs2 */
3645 inst
= (0x2 << 30) | (sljit_get_register_index(SLJIT_RETURN_REG
) << 25)
3646 | (sljit_get_register_index(SLJIT_S0
) << 14)
3647 | sljit_get_register_index(SLJIT_S1
);
3648 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3651 sljit_emit_op_custom(compiler
, &inst
, 0);
3654 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
3656 code
.code
= sljit_generate_code(compiler
);
3658 sljit_free_compiler(compiler
);
3660 FAILED(code
.func2(32, -11) != 21, "test41 case 1 failed\n");
3661 FAILED(code
.func2(1000, 234) != 1234, "test41 case 2 failed\n");
3662 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3663 FAILED(code
.func2(SLJIT_W(0x20f0a04090c06070), SLJIT_W(0x020f0a04090c0607)) != SLJIT_W(0x22ffaa4499cc6677), "test41 case 3 failed\n");
3666 sljit_free_code(code
.code
);
3668 if (sljit_is_fpu_available()) {
3673 compiler
= sljit_create_compiler();
3674 sljit_emit_enter(compiler
, 0, 1, 0, 1, 2, 0, 0);
3675 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
3676 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
3677 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3682 inst
[3] = 0xc0 | (sljit_get_float_register_index(SLJIT_FR0
) << 3)
3683 | sljit_get_float_register_index(SLJIT_FR1
);
3684 sljit_emit_op_custom(compiler
, inst
, 4);
3685 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3687 if (sljit_get_float_register_index(SLJIT_FR0
) > 7 || sljit_get_float_register_index(SLJIT_FR1
) > 7) {
3689 if (sljit_get_float_register_index(SLJIT_FR0
) > 7)
3690 inst
[0] |= 0x04; /* REX_R */
3691 if (sljit_get_float_register_index(SLJIT_FR1
) > 7)
3692 inst
[0] |= 0x01; /* REX_B */
3696 inst
[4] = 0xc0 | ((sljit_get_float_register_index(SLJIT_FR0
) & 0x7) << 3)
3697 | (sljit_get_float_register_index(SLJIT_FR1
) & 0x7);
3698 sljit_emit_op_custom(compiler
, inst
, 5);
3704 inst
[3] = 0xc0 | (sljit_get_float_register_index(SLJIT_FR0
) << 3)
3705 | sljit_get_float_register_index(SLJIT_FR1
);
3706 sljit_emit_op_custom(compiler
, inst
, 4);
3708 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32)
3709 /* vadd.f64 dd, dn, dm */
3710 inst
= 0xee300b00 | ((sljit_get_float_register_index(SLJIT_FR0
) >> 1) << 12)
3711 | ((sljit_get_float_register_index(SLJIT_FR0
) >> 1) << 16)
3712 | (sljit_get_float_register_index(SLJIT_FR1
) >> 1);
3713 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3714 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
3715 /* fadd rd, rn, rm */
3716 inst
= 0x1e602800 | sljit_get_float_register_index(SLJIT_FR0
)
3717 | (sljit_get_float_register_index(SLJIT_FR0
) << 5)
3718 | (sljit_get_float_register_index(SLJIT_FR1
) << 16);
3719 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3720 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
3721 /* fadd frD, frA, frB */
3722 inst
= (63 << 26) | (21 << 1) | (sljit_get_float_register_index(SLJIT_FR0
) << 21)
3723 | (sljit_get_float_register_index(SLJIT_FR0
) << 16)
3724 | (sljit_get_float_register_index(SLJIT_FR1
) << 11);
3725 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3726 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
3727 /* add.d fd, fs, ft */
3728 inst
= (17 << 26) | (17 << 21) | (sljit_get_float_register_index(SLJIT_FR0
) << 6)
3729 | (sljit_get_float_register_index(SLJIT_FR0
) << 11)
3730 | (sljit_get_float_register_index(SLJIT_FR1
) << 16);
3731 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3732 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3733 /* faddd rd, rs1, rs2 */
3734 inst
= (0x2 << 30) | (0x34 << 19) | (0x42 << 5)
3735 | (sljit_get_float_register_index(SLJIT_FR0
) << 25)
3736 | (sljit_get_float_register_index(SLJIT_FR0
) << 14)
3737 | sljit_get_float_register_index(SLJIT_FR1
);
3738 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_ui
));
3740 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_d
), SLJIT_FR0
, 0);
3741 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
3743 code
.code
= sljit_generate_code(compiler
);
3745 sljit_free_compiler(compiler
);
3747 code
.func1((sljit_sw
)&buf
);
3748 FAILED(buf
[2] != 11.25, "test41 case 3 failed\n");
3750 sljit_free_code(code
.code
);
3756 static void test42(void)
3758 /* Test long multiply and division. */
3759 executable_code code
;
3760 struct sljit_compiler
* compiler
= sljit_create_compiler();
3762 sljit_sw buf
[7 + 8 + 4];
3765 printf("Run test42\n");
3767 FAILED(!compiler
, "cannot create compiler\n");
3768 for (i
= 0; i
< 7 + 8; i
++)
3771 sljit_emit_enter(compiler
, 0, 1, 5, 5, 0, 0, 0);
3773 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -0x1fb308a);
3774 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0xf50c873);
3775 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, 0x8a0475b);
3776 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0x9dc849b);
3777 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -0x7c69a35);
3778 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 0x5a4d0c4);
3779 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, 0x9a3b06d);
3781 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3782 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3783 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3784 sljit_emit_op0(compiler
, SLJIT_UMUL
);
3785 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3786 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3788 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3789 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3790 sljit_emit_op0(compiler
, SLJIT_SMUL
);
3791 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3792 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3794 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3795 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3796 sljit_emit_op0(compiler
, SLJIT_UDIV
);
3797 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3798 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3800 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3801 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3802 sljit_emit_op0(compiler
, SLJIT_SDIV
);
3803 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3804 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3806 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x5cf783d3cf0a74b0));
3807 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3d5df42d03a28fc7));
3808 sljit_emit_op0(compiler
, SLJIT_IUDIV
);
3809 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3810 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_R1
, 0, SLJIT_R1
, 0);
3811 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3812 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3814 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x371df5197ba26a28));
3815 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x46c78a5cfd6a420c));
3816 sljit_emit_op0(compiler
, SLJIT_ISDIV
);
3817 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3818 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_R1
, 0, SLJIT_R1
, 0);
3819 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3820 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3823 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
3824 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
3825 sljit_emit_op0(compiler
, SLJIT_UMUL
);
3826 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3827 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3829 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
3830 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
3831 sljit_emit_op0(compiler
, SLJIT_SMUL
);
3832 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3833 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3835 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
3836 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
3837 sljit_emit_op0(compiler
, SLJIT_UDIV
);
3838 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3839 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3841 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
3842 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
3843 sljit_emit_op0(compiler
, SLJIT_SDIV
);
3844 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3845 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3847 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xcf0a74b0);
3848 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x03a28fc7);
3849 sljit_emit_op0(compiler
, SLJIT_IUDIV
);
3850 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3851 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3853 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x7ba26a28);
3854 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)0xfd6a420c);
3855 sljit_emit_op0(compiler
, SLJIT_ISDIV
);
3856 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3857 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3860 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R2
, 0);
3861 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R3
, 0);
3862 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R4
, 0);
3863 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_S1
, 0);
3864 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_S2
, 0);
3865 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_S3
, 0);
3866 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_S4
, 0);
3868 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
3870 code
.code
= sljit_generate_code(compiler
);
3872 sljit_free_compiler(compiler
);
3874 code
.func1((sljit_sw
)&buf
);
3876 FAILED(buf
[0] != -0x1fb308a, "test42 case 1 failed\n");
3877 FAILED(buf
[1] != 0xf50c873, "test42 case 2 failed\n");
3878 FAILED(buf
[2] != 0x8a0475b, "test42 case 3 failed\n");
3879 FAILED(buf
[3] != 0x9dc849b, "test42 case 4 failed\n");
3880 FAILED(buf
[4] != -0x7c69a35, "test42 case 5 failed\n");
3881 FAILED(buf
[5] != 0x5a4d0c4, "test42 case 6 failed\n");
3882 FAILED(buf
[6] != 0x9a3b06d, "test42 case 7 failed\n");
3884 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3885 FAILED(buf
[7] != SLJIT_W(-4388959407985636971), "test42 case 8 failed\n");
3886 FAILED(buf
[8] != SLJIT_W(2901680654366567099), "test42 case 9 failed\n");
3887 FAILED(buf
[9] != SLJIT_W(-4388959407985636971), "test42 case 10 failed\n");
3888 FAILED(buf
[10] != SLJIT_W(-1677173957268872740), "test42 case 11 failed\n");
3889 FAILED(buf
[11] != SLJIT_W(2), "test42 case 12 failed\n");
3890 FAILED(buf
[12] != SLJIT_W(2532236178951865933), "test42 case 13 failed\n");
3891 FAILED(buf
[13] != SLJIT_W(-1), "test42 case 14 failed\n");
3892 FAILED(buf
[14] != SLJIT_W(-2177944059851366166), "test42 case 15 failed\n");
3894 FAILED(buf
[7] != -1587000939, "test42 case 8 failed\n");
3895 FAILED(buf
[8] != 665003983, "test42 case 9 failed\n");
3896 FAILED(buf
[9] != -1587000939, "test42 case 10 failed\n");
3897 FAILED(buf
[10] != -353198352, "test42 case 11 failed\n");
3898 FAILED(buf
[11] != 2, "test42 case 12 failed\n");
3899 FAILED(buf
[12] != 768706125, "test42 case 13 failed\n");
3900 FAILED(buf
[13] != -1, "test42 case 14 failed\n");
3901 FAILED(buf
[14] != -471654166, "test42 case 15 failed\n");
3904 FAILED(buf
[15] != SLJIT_W(56), "test42 case 16 failed\n");
3905 FAILED(buf
[16] != SLJIT_W(58392872), "test42 case 17 failed\n");
3906 FAILED(buf
[17] != SLJIT_W(-47), "test42 case 18 failed\n");
3907 FAILED(buf
[18] != SLJIT_W(35949148), "test42 case 19 failed\n");
3909 sljit_free_code(code
.code
);
3913 static void test43(void)
3915 /* Test floating point compare. */
3916 executable_code code
;
3917 struct sljit_compiler
* compiler
= sljit_create_compiler();
3918 struct sljit_jump
* jump
;
3929 printf("Run test43\n");
3931 if (!sljit_is_fpu_available()) {
3933 printf("no fpu available, test43 skipped\n");
3936 sljit_free_compiler(compiler
);
3940 FAILED(!compiler
, "cannot create compiler\n");
3942 dbuf
[0].value
= 12.125;
3944 dbuf
[1].u
.value1
= 0x7fffffff;
3945 dbuf
[1].u
.value2
= 0x7fffffff;
3946 dbuf
[2].value
= -13.5;
3947 dbuf
[3].value
= 12.125;
3949 sljit_emit_enter(compiler
, 0, 1, 1, 1, 3, 0, 0);
3950 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
3951 /* dbuf[0] < dbuf[2] -> -2 */
3952 jump
= sljit_emit_fcmp(compiler
, SLJIT_D_GREATER_EQUAL
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_DOUBLE_SHIFT
);
3953 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, -2);
3955 sljit_set_label(jump
, sljit_emit_label(compiler
));
3956 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
3957 /* dbuf[0] and dbuf[1] is not NaN -> 5 */
3958 jump
= sljit_emit_fcmp(compiler
, SLJIT_D_UNORDERED
, SLJIT_MEM0(), (sljit_sw
)&dbuf
[1], SLJIT_FR1
, 0);
3959 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, 5);
3961 sljit_set_label(jump
, sljit_emit_label(compiler
));
3962 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_d
));
3963 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 11);
3964 /* dbuf[0] == dbuf[3] -> 11 */
3965 jump
= sljit_emit_fcmp(compiler
, SLJIT_D_EQUAL
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_FR2
, 0);
3968 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, -17);
3969 sljit_set_label(jump
, sljit_emit_label(compiler
));
3970 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
3972 code
.code
= sljit_generate_code(compiler
);
3974 sljit_free_compiler(compiler
);
3976 FAILED(code
.func1((sljit_sw
)&dbuf
) != 11, "test43 case 1 failed\n");
3978 FAILED(code
.func1((sljit_sw
)&dbuf
) != -17, "test43 case 2 failed\n");
3980 FAILED(code
.func1((sljit_sw
)&dbuf
) != 5, "test43 case 3 failed\n");
3982 FAILED(code
.func1((sljit_sw
)&dbuf
) != -2, "test43 case 4 failed\n");
3984 sljit_free_code(code
.code
);
3988 static void test44(void)
3991 executable_code code
;
3992 struct sljit_compiler
* compiler
= sljit_create_compiler();
3996 printf("Run test44\n");
3998 FAILED(!compiler
, "cannot create compiler\n");
4005 sljit_emit_enter(compiler
, 0, 1, 3, 2, 0, 0, 0);
4007 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4008 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
), SLJIT_R0
, 0);
4009 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_p
));
4010 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
4011 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_POINTER_SHIFT
, SLJIT_R0
, 0);
4012 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_p
));
4013 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
4014 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_S0
, 0);
4015 sljit_emit_op1(compiler
, SLJIT_MOVU_P
, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), SLJIT_POINTER_SHIFT
, SLJIT_R0
, 0);
4016 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_p
));
4017 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM1(SLJIT_R2
), sizeof(sljit_p
), SLJIT_R0
, 0);
4019 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
4021 code
.code
= sljit_generate_code(compiler
);
4023 sljit_free_compiler(compiler
);
4025 FAILED(code
.func1((sljit_sw
)&buf
) != (sljit_sw
)(buf
+ 2), "test44 case 1 failed\n");
4026 FAILED(buf
[1] != buf
+ 2, "test44 case 2 failed\n");
4027 FAILED(buf
[2] != buf
+ 3, "test44 case 3 failed\n");
4028 FAILED(buf
[3] != buf
+ 4, "test44 case 4 failed\n");
4029 FAILED(buf
[4] != buf
+ 2, "test44 case 5 failed\n");
4031 sljit_free_code(code
.code
);
4035 static void test45(void)
4037 /* Test single precision floating point. */
4039 executable_code code
;
4040 struct sljit_compiler
* compiler
= sljit_create_compiler();
4043 struct sljit_jump
* jump
;
4046 printf("Run test45\n");
4048 if (!sljit_is_fpu_available()) {
4050 printf("no fpu available, test45 skipped\n");
4053 sljit_free_compiler(compiler
);
4057 FAILED(!compiler
, "cannot create compiler\n");
4079 sljit_emit_enter(compiler
, 0, 2, 3, 2, 6, 0, 0);
4081 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4082 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s
));
4083 sljit_emit_fop1(compiler
, SLJIT_NEGS
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_s
), SLJIT_FR0
, 0);
4084 sljit_emit_fop1(compiler
, SLJIT_ABSS
, SLJIT_FR1
, 0, SLJIT_FR5
, 0);
4085 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_s
), SLJIT_FR1
, 0);
4086 sljit_emit_fop1(compiler
, SLJIT_ABSS
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_s
), SLJIT_FR5
, 0);
4087 sljit_emit_fop1(compiler
, SLJIT_NEGS
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4088 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_s
), SLJIT_FR4
, 0);
4090 sljit_emit_fop2(compiler
, SLJIT_ADDS
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s
));
4091 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_s
), SLJIT_FR0
, 0);
4092 sljit_emit_fop2(compiler
, SLJIT_SUBS
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_s
), SLJIT_FR5
, 0);
4093 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4094 sljit_emit_fop2(compiler
, SLJIT_MULS
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_s
), SLJIT_FR0
, 0, SLJIT_FR0
, 0);
4095 sljit_emit_fop2(compiler
, SLJIT_DIVS
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_s
), SLJIT_FR0
, 0);
4096 sljit_emit_fop1(compiler
, SLJIT_ABSS
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_s
), SLJIT_FR2
, 0);
4097 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x3d0ac);
4098 sljit_emit_fop1(compiler
, SLJIT_NEGS
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_R0
), 0x3d0ac);
4099 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x3d0ac + sizeof(sljit_s
));
4100 sljit_emit_fop1(compiler
, SLJIT_ABSS
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_R0
), -0x3d0ac);
4102 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4103 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s
));
4104 sljit_emit_fop1(compiler
, SLJIT_CMPS
| SLJIT_SET_E
| SLJIT_SET_S
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4105 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_S_EQUAL
);
4106 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_S_LESS
);
4107 sljit_emit_fop1(compiler
, SLJIT_CMPS
| SLJIT_SET_E
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
4108 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
), SLJIT_S_EQUAL
);
4109 sljit_emit_fop1(compiler
, SLJIT_CMPS
| SLJIT_SET_S
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
4110 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_S_GREATER_EQUAL
);
4112 jump
= sljit_emit_fcmp(compiler
, SLJIT_S_LESS_EQUAL
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s
));
4113 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, 7);
4114 sljit_set_label(jump
, sljit_emit_label(compiler
));
4116 jump
= sljit_emit_fcmp(compiler
, SLJIT_S_GREATER
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_FR2
, 0);
4117 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, 6);
4118 sljit_set_label(jump
, sljit_emit_label(compiler
));
4120 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
4122 code
.code
= sljit_generate_code(compiler
);
4124 sljit_free_compiler(compiler
);
4126 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
4127 FAILED(buf
[2] != -5.5, "test45 case 1 failed\n");
4128 FAILED(buf
[3] != 7.25, "test45 case 2 failed\n");
4129 FAILED(buf
[4] != 7.25, "test45 case 3 failed\n");
4130 FAILED(buf
[5] != -5.5, "test45 case 4 failed\n");
4131 FAILED(buf
[6] != -1.75, "test45 case 5 failed\n");
4132 FAILED(buf
[7] != 16.0, "test45 case 6 failed\n");
4133 FAILED(buf
[8] != 30.25, "test45 case 7 failed\n");
4134 FAILED(buf
[9] != 3, "test45 case 8 failed\n");
4135 FAILED(buf
[10] != -5.5, "test45 case 9 failed\n");
4136 FAILED(buf
[11] != 7.25, "test45 case 10 failed\n");
4137 FAILED(buf2
[0] != 1, "test45 case 11 failed\n");
4138 FAILED(buf2
[1] != 2, "test45 case 12 failed\n");
4139 FAILED(buf2
[2] != 2, "test45 case 13 failed\n");
4140 FAILED(buf2
[3] != 1, "test45 case 14 failed\n");
4141 FAILED(buf2
[4] != 7, "test45 case 15 failed\n");
4142 FAILED(buf2
[5] != -1, "test45 case 16 failed\n");
4144 sljit_free_code(code
.code
);
4148 static void test46(void)
4150 /* Test sljit_emit_op_flags with 32 bit operations. */
4152 executable_code code
;
4153 struct sljit_compiler
* compiler
= sljit_create_compiler();
4159 printf("Run test46\n");
4161 for (i
= 0; i
< 24; ++i
)
4164 for (i
= 0; i
< 6; ++i
)
4168 sljit_emit_enter(compiler
, 0, 2, 3, 3, 0, 0, 0);
4170 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4171 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 13);
4172 sljit_emit_op_flags(compiler
, SLJIT_MOV_SI
, SLJIT_MEM0(), (sljit_sw
)&buf
, SLJIT_UNUSED
, 0, SLJIT_LESS
);
4173 sljit_emit_op_flags(compiler
, SLJIT_IAND
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_si
), SLJIT_GREATER
);
4175 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4176 sljit_emit_op_flags(compiler
, SLJIT_IAND
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_si
), SLJIT_EQUAL
);
4177 sljit_emit_op_flags(compiler
, SLJIT_IAND
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_si
), SLJIT_EQUAL
);
4178 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1235);
4179 sljit_emit_op_flags(compiler
, SLJIT_IAND
| SLJIT_SET_E
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_EQUAL
);
4180 sljit_emit_op_flags(compiler
, SLJIT_IAND
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_si
), SLJIT_I_EQUAL
);
4181 sljit_emit_op1(compiler
, SLJIT_MOV_UI
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_si
), SLJIT_R0
, 0);
4183 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4184 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 12);
4185 sljit_emit_op_flags(compiler
, SLJIT_MOV_UI
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 2, SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
4186 sljit_emit_op_flags(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_UNUSED
, 0, SLJIT_EQUAL
);
4187 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_si
), SLJIT_R0
, 0);
4188 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
4189 sljit_emit_op_flags(compiler
, SLJIT_IAND
| SLJIT_SET_E
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 2, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 2, SLJIT_EQUAL
);
4190 sljit_emit_op_flags(compiler
, SLJIT_MOV_UI
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_si
), SLJIT_UNUSED
, 0, SLJIT_I_NOT_EQUAL
);
4192 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4193 sljit_emit_op_flags(compiler
, SLJIT_IXOR
| SLJIT_KEEP_FLAGS
, SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_si
), SLJIT_EQUAL
);
4194 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 39);
4195 sljit_emit_op_flags(compiler
, SLJIT_IXOR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_EQUAL
);
4196 sljit_emit_op1(compiler
, SLJIT_MOV_SI
| SLJIT_INT_OP
, SLJIT_MEM1(SLJIT_S0
), 22 * sizeof(sljit_si
), SLJIT_R0
, 0);
4198 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4199 sljit_emit_op_flags(compiler
, SLJIT_AND
, SLJIT_MEM0(), (sljit_sw
)&buf2
, SLJIT_MEM0(), (sljit_sw
)&buf2
, SLJIT_GREATER
);
4200 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_E
| SLJIT_SET_S
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 5);
4201 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
4202 sljit_emit_op_flags(compiler
, SLJIT_AND
| SLJIT_KEEP_FLAGS
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_SIG_LESS
);
4203 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
4204 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_UNUSED
, 0, SLJIT_LESS
);
4205 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_UNUSED
, 0, SLJIT_NOT_EQUAL
);
4206 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_S2
, 0);
4207 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_GREATER
);
4208 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 0);
4209 sljit_emit_op_flags(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_GREATER
);
4211 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4213 code
.code
= sljit_generate_code(compiler
);
4215 sljit_free_compiler(compiler
);
4217 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
4218 FAILED(buf
[0] != 0, "test46 case 1 failed\n");
4219 FAILED(buf
[1] != -17, "test46 case 2 failed\n");
4220 FAILED(buf
[2] != 1, "test46 case 3 failed\n");
4221 FAILED(buf
[3] != -17, "test46 case 4 failed\n");
4222 FAILED(buf
[4] != 1, "test46 case 5 failed\n");
4223 FAILED(buf
[5] != -17, "test46 case 6 failed\n");
4224 FAILED(buf
[6] != 1, "test46 case 7 failed\n");
4225 FAILED(buf
[7] != -17, "test46 case 8 failed\n");
4226 FAILED(buf
[8] != 0, "test46 case 9 failed\n");
4227 FAILED(buf
[9] != -17, "test46 case 10 failed\n");
4228 FAILED(buf
[10] != 1, "test46 case 11 failed\n");
4229 FAILED(buf
[11] != -17, "test46 case 12 failed\n");
4230 FAILED(buf
[12] != 1, "test46 case 13 failed\n");
4231 FAILED(buf
[13] != -17, "test46 case 14 failed\n");
4232 FAILED(buf
[14] != 1, "test46 case 15 failed\n");
4233 FAILED(buf
[15] != -17, "test46 case 16 failed\n");
4234 FAILED(buf
[16] != 0, "test46 case 17 failed\n");
4235 FAILED(buf
[17] != -17, "test46 case 18 failed\n");
4236 FAILED(buf
[18] != 0, "test46 case 19 failed\n");
4237 FAILED(buf
[19] != -17, "test46 case 20 failed\n");
4238 FAILED(buf
[20] != -18, "test46 case 21 failed\n");
4239 FAILED(buf
[21] != -17, "test46 case 22 failed\n");
4240 FAILED(buf
[22] != 38, "test46 case 23 failed\n");
4241 FAILED(buf
[23] != -17, "test46 case 24 failed\n");
4243 FAILED(buf2
[0] != 0, "test46 case 25 failed\n");
4244 FAILED(buf2
[1] != 1, "test46 case 26 failed\n");
4245 FAILED(buf2
[2] != 0, "test46 case 27 failed\n");
4246 FAILED(buf2
[3] != 1, "test46 case 28 failed\n");
4247 FAILED(buf2
[4] != -123, "test46 case 29 failed\n");
4248 FAILED(buf2
[5] != -14, "test46 case 30 failed\n");
4250 sljit_free_code(code
.code
);
4254 static void test47(void)
4256 /* Test jump optimizations. */
4257 executable_code code
;
4258 struct sljit_compiler
* compiler
= sljit_create_compiler();
4262 printf("Run test47\n");
4264 FAILED(!compiler
, "cannot create compiler\n");
4269 sljit_emit_enter(compiler
, 0, 1, 3, 1, 0, 0, 0);
4270 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x3a5c6f);
4271 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_U
, SLJIT_UNUSED
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 3);
4272 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), 0x11223344);
4273 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
4274 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xd37c10);
4275 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4276 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), SLJIT_W(0x112233445566));
4278 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
4279 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x59b48e);
4280 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4281 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), SLJIT_W(0x1122334455667788));
4283 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4284 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4286 code
.code
= sljit_generate_code(compiler
);
4288 sljit_free_compiler(compiler
);
4290 code
.func1((sljit_sw
)&buf
);
4291 FAILED(buf
[0] != 0x3a5c6f, "test47 case 1 failed\n");
4292 FAILED(buf
[1] != 0xd37c10, "test47 case 2 failed\n");
4293 FAILED(buf
[2] != 0x59b48e, "test47 case 3 failed\n");
4295 sljit_free_code(code
.code
);
4299 static void test48(void)
4301 /* Test floating point conversions. */
4302 executable_code code
;
4303 struct sljit_compiler
* compiler
= sljit_create_compiler();
4311 printf("Run test48\n");
4313 if (!sljit_is_fpu_available()) {
4315 printf("no fpu available, test48 skipped\n");
4318 sljit_free_compiler(compiler
);
4322 FAILED(!compiler
, "cannot create compiler\n");
4323 for (i
= 0; i
< 9; i
++) {
4342 sljit_emit_enter(compiler
, 0, 0, 3, 3, 6, 0, 0);
4343 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
4344 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, (sljit_sw
)&sbuf
);
4345 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
4346 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
4349 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMD
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_S0
), 0);
4350 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4351 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
4353 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMD
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_SINGLE_SHIFT
, SLJIT_FR5
, 0);
4354 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMS
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4356 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_d
), SLJIT_FR4
, 0);
4357 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4358 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMS
, SLJIT_FR2
, 0, SLJIT_FR3
, 0);
4360 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_d
), SLJIT_FR2
, 0);
4362 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_s
), SLJIT_FR3
, 0);
4365 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMD
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_d
));
4366 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
4367 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMD
, SLJIT_UNUSED
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_DOUBLE_SHIFT
);
4368 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMD
, SLJIT_R0
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_DOUBLE_SHIFT
);
4370 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4371 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4373 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMS
, SLJIT_MEM1(SLJIT_S2
), 3 * sizeof(sljit_sw
), SLJIT_FR5
, 0);
4374 sljit_emit_fop1(compiler
, SLJIT_NEGS
, SLJIT_FR0
, 0, SLJIT_FR5
, 0);
4375 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 4);
4377 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMS
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_FR0
, 0);
4378 sljit_emit_fop1(compiler
, SLJIT_NEGD
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_d
));
4380 sljit_emit_fop1(compiler
, SLJIT_CONVI_FROMD
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_si
), SLJIT_FR4
, 0);
4381 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s
));
4382 sljit_emit_fop1(compiler
, SLJIT_CONVI_FROMS
, SLJIT_R0
, 0, SLJIT_FR1
, 0);
4384 sljit_emit_op1(compiler
, SLJIT_MOV_SI
, SLJIT_MEM1(SLJIT_R2
), 3 * sizeof(sljit_si
), SLJIT_R0
, 0);
4387 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMW
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_d
), SLJIT_MEM1(SLJIT_S2
), 0);
4388 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMW
, SLJIT_FR2
, 0, SLJIT_IMM
, -6213);
4390 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_d
), SLJIT_FR2
, 0);
4392 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMI
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_d
), SLJIT_MEM0(), (sljit_sw
)&ibuf
[0]);
4393 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R2
), sizeof(sljit_si
));
4394 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMI
, SLJIT_FR1
, 0, SLJIT_R0
, 0);
4396 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_d
), SLJIT_FR1
, 0);
4398 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMW
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_s
), SLJIT_IMM
, -123);
4399 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_IMM
, 7190);
4400 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMW
, SLJIT_FR3
, 0, SLJIT_R0
, 0);
4402 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S1
), 6 * sizeof(sljit_s
), SLJIT_FR3
, 0);
4403 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 123);
4404 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 123 * sizeof(sljit_si
));
4405 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMI
, SLJIT_FR1
, 0, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 2);
4407 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S1
), 7 * sizeof(sljit_s
), SLJIT_FR1
, 0);
4408 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
4409 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3812);
4411 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMI
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_SINGLE_SHIFT
, SLJIT_R1
, 0);
4413 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4415 code
.code
= sljit_generate_code(compiler
);
4417 sljit_free_compiler(compiler
);
4420 FAILED(dbuf
[3] != 476.25, "test48 case 1 failed\n");
4421 FAILED(dbuf
[4] != 476.25, "test48 case 2 failed\n");
4422 FAILED(dbuf
[5] != 2345.0, "test48 case 3 failed\n");
4423 FAILED(dbuf
[6] != -6213.0, "test48 case 4 failed\n");
4424 FAILED(dbuf
[7] != 312.0, "test48 case 5 failed\n");
4425 FAILED(dbuf
[8] != -9324.0, "test48 case 6 failed\n");
4427 FAILED(sbuf
[2] != 123.5, "test48 case 7 failed\n");
4428 FAILED(sbuf
[3] != 123.5, "test48 case 8 failed\n");
4429 FAILED(sbuf
[4] != 476.25, "test48 case 9 failed\n");
4430 FAILED(sbuf
[5] != -123, "test48 case 10 failed\n");
4431 FAILED(sbuf
[6] != 7190, "test48 case 11 failed\n");
4432 FAILED(sbuf
[7] != 312, "test48 case 12 failed\n");
4433 FAILED(sbuf
[8] != 3812, "test48 case 13 failed\n");
4435 FAILED(wbuf
[1] != -367, "test48 case 14 failed\n");
4436 FAILED(wbuf
[2] != 917, "test48 case 15 failed\n");
4437 FAILED(wbuf
[3] != 476, "test48 case 16 failed\n");
4438 FAILED(wbuf
[4] != -476, "test48 case 17 failed\n");
4440 FAILED(ibuf
[2] != -917, "test48 case 18 failed\n");
4441 FAILED(ibuf
[3] != -1689, "test48 case 19 failed\n");
4443 sljit_free_code(code
.code
);
4447 static void test49(void)
4449 /* Test floating point conversions. */
4450 executable_code code
;
4451 struct sljit_compiler
* compiler
= sljit_create_compiler();
4457 sljit_si
* dbuf_ptr
= (sljit_si
*)dbuf
;
4458 sljit_si
* sbuf_ptr
= (sljit_si
*)sbuf
;
4461 printf("Run test49\n");
4463 if (!sljit_is_fpu_available()) {
4465 printf("no fpu available, test49 skipped\n");
4468 sljit_free_compiler(compiler
);
4472 FAILED(!compiler
, "cannot create compiler\n");
4474 for (i
= 0; i
< 9; i
++) {
4475 dbuf_ptr
[i
<< 1] = -1;
4476 dbuf_ptr
[(i
<< 1) + 1] = -1;
4482 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4483 dbuf
[9] = (sljit_d
)SLJIT_W(0x1122334455);
4490 sljit_emit_enter(compiler
, 0, 0, 3, 3, 3, 0, 0);
4491 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
4492 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, (sljit_sw
)&sbuf
);
4493 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
4494 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
4497 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMS
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_d
), SLJIT_MEM1(SLJIT_S1
), 0);
4499 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMD
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_S0
), 0);
4501 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMD
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0);
4503 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMS
, SLJIT_MEM1(SLJIT_S2
), 4 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S1
), 0);
4505 sljit_emit_fop1(compiler
, SLJIT_CONVI_FROMD
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S0
), 0);
4507 sljit_emit_fop1(compiler
, SLJIT_CONVI_FROMS
, SLJIT_MEM1(SLJIT_R2
), 4 * sizeof(sljit_si
), SLJIT_MEM1(SLJIT_S1
), 0);
4509 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMW
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_d
), SLJIT_MEM1(SLJIT_S2
), 0);
4511 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMW
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_S2
), 0);
4513 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMI
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_d
), SLJIT_MEM1(SLJIT_R2
), 0);
4515 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMI
, SLJIT_MEM1(SLJIT_S1
), 6 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_R2
), 0);
4517 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4518 sljit_emit_fop1(compiler
, SLJIT_CONVW_FROMD
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_d
));
4520 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), 8 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4521 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_d
));
4522 sljit_emit_fop1(compiler
, SLJIT_CONVI_FROMD
, SLJIT_R0
, 0, SLJIT_FR2
, 0);
4523 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4524 sljit_emit_op2(compiler
, SLJIT_IAND
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffff);
4526 sljit_emit_op1(compiler
, SLJIT_IMOV
, SLJIT_MEM1(SLJIT_R2
), 8 * sizeof(sljit_si
), SLJIT_R0
, 0);
4527 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x4455667788));
4529 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMW
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_d
), SLJIT_R0
, 0);
4531 sljit_emit_fop1(compiler
, SLJIT_CONVD_FROMI
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_d
), SLJIT_IMM
, SLJIT_W(0x7766554433));
4534 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4536 code
.code
= sljit_generate_code(compiler
);
4538 sljit_free_compiler(compiler
);
4542 FAILED(dbuf_ptr
[(1 * 2) + 0] != -1, "test49 case 1 failed\n");
4543 FAILED(dbuf_ptr
[(1 * 2) + 1] != -1, "test49 case 2 failed\n");
4544 FAILED(dbuf
[2] != -879.75, "test49 case 3 failed\n");
4545 FAILED(dbuf_ptr
[(3 * 2) + 0] != -1, "test49 case 4 failed\n");
4546 FAILED(dbuf_ptr
[(3 * 2) + 1] != -1, "test49 case 5 failed\n");
4547 FAILED(dbuf
[4] != 345, "test49 case 6 failed\n");
4548 FAILED(dbuf_ptr
[(5 * 2) + 0] != -1, "test49 case 7 failed\n");
4549 FAILED(dbuf_ptr
[(5 * 2) + 1] != -1, "test49 case 8 failed\n");
4550 FAILED(dbuf
[6] != -249, "test49 case 9 failed\n");
4551 FAILED(dbuf_ptr
[(7 * 2) + 0] != -1, "test49 case 10 failed\n");
4552 FAILED(dbuf_ptr
[(7 * 2) + 1] != -1, "test49 case 11 failed\n");
4554 FAILED(sbuf_ptr
[1] != -1, "test49 case 12 failed\n");
4555 FAILED(sbuf
[2] != 673.75, "test49 case 13 failed\n");
4556 FAILED(sbuf_ptr
[3] != -1, "test49 case 14 failed\n");
4557 FAILED(sbuf
[4] != 345, "test49 case 15 failed\n");
4558 FAILED(sbuf_ptr
[5] != -1, "test49 case 16 failed\n");
4559 FAILED(sbuf
[6] != -249, "test49 case 17 failed\n");
4560 FAILED(sbuf_ptr
[7] != -1, "test49 case 18 failed\n");
4562 FAILED(wbuf
[1] != -1, "test49 case 19 failed\n");
4563 FAILED(wbuf
[2] != 673, "test49 case 20 failed\n");
4564 FAILED(wbuf
[3] != -1, "test49 case 21 failed\n");
4565 FAILED(wbuf
[4] != -879, "test49 case 22 failed\n");
4566 FAILED(wbuf
[5] != -1, "test49 case 23 failed\n");
4568 FAILED(ibuf
[1] != -1, "test49 case 24 failed\n");
4569 FAILED(ibuf
[2] != 673, "test49 case 25 failed\n");
4570 FAILED(ibuf
[3] != -1, "test49 case 26 failed\n");
4571 FAILED(ibuf
[4] != -879, "test49 case 27 failed\n");
4572 FAILED(ibuf
[5] != -1, "test49 case 28 failed\n");
4574 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4575 FAILED(dbuf
[8] != (sljit_d
)SLJIT_W(0x4455667788), "test49 case 29 failed\n");
4576 FAILED(dbuf
[9] != (sljit_d
)SLJIT_W(0x66554433), "test49 case 30 failed\n");
4577 FAILED(wbuf
[8] != SLJIT_W(0x1122334455), "test48 case 31 failed\n");
4578 FAILED(ibuf
[8] == 0x4455, "test48 case 32 failed\n");
4581 sljit_free_code(code
.code
);
4585 static void test50(void)
4587 /* Test stack and floating point operations. */
4588 executable_code code
;
4589 struct sljit_compiler
* compiler
= sljit_create_compiler();
4590 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4591 sljit_uw size1
, size2
, size3
;
4597 printf("Run test50\n");
4599 if (!sljit_is_fpu_available()) {
4601 printf("no fpu available, test50 skipped\n");
4604 sljit_free_compiler(compiler
);
4608 FAILED(!compiler
, "cannot create compiler\n");
4614 sljit_emit_enter(compiler
, 0, 1, 3, 3, 6, 0, 8 * sizeof(sljit_s
));
4616 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
4617 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), 0);
4619 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_s
));
4620 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_s
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s
));
4621 sljit_emit_fop2(compiler
, SLJIT_ADDS
, SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_s
));
4623 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_s
));
4624 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_s
), SLJIT_IMM
, 5934);
4625 sljit_emit_fop1(compiler
, SLJIT_CONVS_FROMW
, SLJIT_MEM1(SLJIT_SP
), 3 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_s
));
4627 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_s
), SLJIT_MEM1(SLJIT_SP
), 3 * sizeof(sljit_s
));
4629 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4630 size1
= compiler
->size
;
4632 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_s
));
4633 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4634 size2
= compiler
->size
;
4636 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_FR5
, 0, SLJIT_FR2
, 0);
4637 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4638 size3
= compiler
->size
;
4641 sljit_emit_fop1(compiler
, SLJIT_MOVS
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_s
), SLJIT_FR5
, 0);
4642 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4643 result
= (compiler
->size
- size3
) == (size3
- size2
) && (size3
- size2
) == (size2
- size1
);
4646 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4648 code
.code
= sljit_generate_code(compiler
);
4650 sljit_free_compiler(compiler
);
4652 code
.func1((sljit_sw
)&sbuf
);
4654 FAILED(sbuf
[3] != 245.5, "test50 case 1 failed\n");
4655 FAILED(sbuf
[4] != 145.25, "test50 case 2 failed\n");
4656 FAILED(sbuf
[5] != 5934, "test50 case 3 failed\n");
4657 FAILED(sbuf
[6] != 713.75, "test50 case 4 failed\n");
4658 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4659 FAILED(!result
, "test50 case 5 failed\n");
4662 sljit_free_code(code
.code
);
4666 static void test51(void)
4668 /* Test all registers provided by the CPU. */
4669 executable_code code
;
4670 struct sljit_compiler
* compiler
= sljit_create_compiler();
4671 struct sljit_jump
* jump
;
4675 FAILED(!compiler
, "cannot create compiler\n");
4679 sljit_emit_enter(compiler
, 0, 0, SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, 0);
4681 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4682 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 32);
4684 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)buf
);
4685 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
4687 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4688 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4689 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_R0
, 0);
4690 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_R(i
)), 0);
4692 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, buf
[0]);
4695 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32);
4696 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4697 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4698 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_R0
, 0);
4699 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_R(i
)), 32);
4701 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, buf
[0]);
4704 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4705 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4706 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 32);
4707 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R(i
), SLJIT_R0
), 0);
4708 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R(i
)), 0);
4709 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 8);
4710 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R(i
)), 2);
4712 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 3 * buf
[0]);
4715 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 32 + sizeof(sljit_sw
), SLJIT_R1
, 0);
4717 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4719 code
.code
= sljit_generate_code(compiler
);
4721 sljit_free_compiler(compiler
);
4725 FAILED(buf
[1] != (39 * 5 * (SLJIT_NUMBER_OF_REGISTERS
- 2)), "test51 case 1 failed\n");
4727 sljit_free_code(code
.code
);
4731 compiler
= sljit_create_compiler();
4733 FAILED(!compiler
, "cannot create compiler\n");
4735 sljit_emit_enter(compiler
, 0, 0, SLJIT_NUMBER_OF_SCRATCH_REGISTERS
, SLJIT_NUMBER_OF_SAVED_REGISTERS
, 0, 0, 0);
4737 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4738 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 17);
4740 jump
= sljit_emit_jump(compiler
, SLJIT_CALL0
);
4741 /* SLJIT_R0 contains the first value. */
4742 for (i
= 1; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4743 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
4745 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
4747 sljit_set_label(jump
, sljit_emit_label(compiler
));
4748 sljit_emit_enter(compiler
, 0, 0, SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, 0);
4749 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4750 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 35);
4751 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4753 code
.code
= sljit_generate_code(compiler
);
4755 sljit_free_compiler(compiler
);
4757 FAILED(code
.func0() != (SLJIT_NUMBER_OF_SCRATCH_REGISTERS
* 35 + SLJIT_NUMBER_OF_SAVED_REGISTERS
* 17), "test51 case 2 failed\n");
4759 sljit_free_code(code
.code
);
4763 compiler
= sljit_create_compiler();
4765 FAILED(!compiler
, "cannot create compiler\n");
4767 sljit_emit_enter(compiler
, 0, 0, SLJIT_NUMBER_OF_SCRATCH_REGISTERS
, SLJIT_NUMBER_OF_SAVED_REGISTERS
, 0, 0, 0);
4769 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4770 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 68);
4772 jump
= sljit_emit_jump(compiler
, SLJIT_CALL0
);
4773 /* SLJIT_R0 contains the first value. */
4774 for (i
= 1; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4775 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
4777 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
4779 sljit_set_label(jump
, sljit_emit_label(compiler
));
4780 sljit_emit_enter(compiler
, 0, 0, 0, SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0);
4781 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4782 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S(i
), 0, SLJIT_IMM
, 43);
4783 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4785 code
.code
= sljit_generate_code(compiler
);
4787 sljit_free_compiler(compiler
);
4789 FAILED(code
.func0() != (SLJIT_NUMBER_OF_SCRATCH_REGISTERS
* 43 + SLJIT_NUMBER_OF_SAVED_REGISTERS
* 68), "test51 case 3 failed\n");
4791 sljit_free_code(code
.code
);
4795 static void test52(void)
4797 /* Test all registers provided by the CPU. */
4798 executable_code code
;
4799 struct sljit_compiler
* compiler
;
4800 struct sljit_jump
* jump
;
4804 if (!sljit_is_fpu_available()) {
4806 printf("no fpu available, test52 skipped\n");
4813 compiler
= sljit_create_compiler();
4814 FAILED(!compiler
, "cannot create compiler\n");
4818 sljit_emit_enter(compiler
, 0, 1, 0, 1, SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
, SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
, 0);
4820 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4821 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
4823 jump
= sljit_emit_jump(compiler
, SLJIT_CALL0
);
4824 /* SLJIT_FR0 contains the first value. */
4825 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4826 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR(i
), 0);
4827 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_d
), SLJIT_FR0
, 0);
4829 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4831 sljit_set_label(jump
, sljit_emit_label(compiler
));
4832 sljit_emit_enter(compiler
, 0, 0, 1, 0, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
4833 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[1]);
4834 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4835 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_R0
), 0);
4836 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4838 code
.code
= sljit_generate_code(compiler
);
4840 sljit_free_compiler(compiler
);
4842 code
.func1((sljit_sw
)&buf
);
4843 FAILED(buf
[2] != (SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
* 17.75 + SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
* 6.25), "test52 case 1 failed\n");
4845 sljit_free_code(code
.code
);
4849 compiler
= sljit_create_compiler();
4850 FAILED(!compiler
, "cannot create compiler\n");
4854 sljit_emit_enter(compiler
, 0, 1, 0, 1, SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
, SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
, 0);
4856 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4857 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
4859 jump
= sljit_emit_jump(compiler
, SLJIT_CALL0
);
4860 /* SLJIT_FR0 contains the first value. */
4861 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4862 sljit_emit_fop2(compiler
, SLJIT_ADDD
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR(i
), 0);
4863 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_d
), SLJIT_FR0
, 0);
4865 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4867 sljit_set_label(jump
, sljit_emit_label(compiler
));
4868 sljit_emit_enter(compiler
, 0, 0, 1, 0, 0, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0);
4869 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[1]);
4870 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
4871 sljit_emit_fop1(compiler
, SLJIT_MOVD
, SLJIT_FS(i
), 0, SLJIT_MEM1(SLJIT_R0
), 0);
4872 sljit_emit_return(compiler
, SLJIT_UNUSED
, 0, 0);
4874 code
.code
= sljit_generate_code(compiler
);
4876 sljit_free_compiler(compiler
);
4878 code
.func1((sljit_sw
)&buf
);
4879 FAILED(buf
[2] != (SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
* -11.25 + SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
* -32.5), "test52 case 2 failed\n");
4881 sljit_free_code(code
.code
);
4885 void sljit_test(int argc
, char* argv
[])
4887 sljit_si has_arg
= (argc
>= 2 && argv
[1][0] == '-' && argv
[1][2] == '\0');
4888 verbose
= has_arg
&& argv
[1][1] == 'v';
4889 silent
= has_arg
&& argv
[1][1] == 's';
4891 if (!verbose
&& !silent
)
4892 printf("Pass -v to enable verbose, -s to disable this hint.\n\n");
4894 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
4895 test_exec_allocator();
4950 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
4951 sljit_free_unused_memory_exec();
4954 # define TEST_COUNT 52
4956 printf("SLJIT tests: ");
4957 if (successful_tests
== TEST_COUNT
)
4958 printf("all tests are " COLOR_GREEN
"PASSED" COLOR_DEFAULT
" ");
4960 printf(COLOR_RED
"%d" COLOR_DEFAULT
" (" COLOR_RED
"%d%%" COLOR_DEFAULT
") tests are failed ", TEST_COUNT
- successful_tests
, (TEST_COUNT
- successful_tests
) * 100 / 47);
4961 printf("on " COLOR_ARCH
"%s" COLOR_DEFAULT
"%s\n", sljit_get_platform_name(), sljit_is_fpu_available() ? " (with fpu)" : " (without fpu)");