2 * Stack-less Just-In-Time compiler
4 * Copyright 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. */
36 #pragma warning(disable: 4127) /* conditional expression is constant */
39 #if defined _WIN32 || defined _WIN64
45 #define COLOR_RED "\33[31m"
46 #define COLOR_GREEN "\33[32m"
47 #define COLOR_ARCH "\33[33m"
48 #define COLOR_DEFAULT "\33[0m"
51 union executable_code
{
53 sljit_sw (SLJIT_FUNC
*func0
)(void);
54 sljit_sw (SLJIT_FUNC
*func1
)(sljit_sw a
);
55 sljit_sw (SLJIT_FUNC
*func2
)(sljit_sw a
, sljit_sw b
);
56 sljit_sw (SLJIT_FUNC
*func3
)(sljit_sw a
, sljit_sw b
, sljit_sw c
);
58 sljit_sw (*test53_f1
)(sljit_sw a
, sljit_sw b
, sljit_sw c
);
60 void (SLJIT_FUNC
*test70_f1
)(sljit_s32 a
, sljit_uw b
, sljit_u32 c
, sljit_sw d
);
61 void (*test70_f2
)(sljit_s32 a
, sljit_u32 b
, sljit_sw c
, sljit_sw d
);
62 void (SLJIT_FUNC
*test70_f3
)(sljit_s32 a
, sljit_f32 b
, sljit_uw c
, sljit_f64 d
);
63 void (SLJIT_FUNC
*test70_f4
)(sljit_f32 a
, sljit_f64 b
, sljit_f32 c
, sljit_s32 d
);
64 void (SLJIT_FUNC
*test70_f5
)(sljit_f64 a
, sljit_f32 b
, sljit_u32 c
, sljit_f32 d
);
65 void (SLJIT_FUNC
*test70_f6
)(sljit_f64 a
, sljit_s32 b
, sljit_f32 c
, sljit_f64 d
);
66 void (SLJIT_FUNC
*test70_f7
)(sljit_f32 a
, sljit_s32 b
, sljit_uw c
, sljit_u32 d
);
67 void (SLJIT_FUNC
*test70_f8
)(sljit_f64 a
, sljit_f64 b
, sljit_uw c
, sljit_sw d
);
68 void (SLJIT_FUNC
*test70_f9
)(sljit_f64 a
, sljit_f64 b
, sljit_uw c
, sljit_f64 d
);
69 void (SLJIT_FUNC
*test70_f10
)(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
, sljit_s32 d
);
71 sljit_sw (*test71_f1
)(sljit_sw a
, sljit_sw b
, sljit_sw c
, sljit_sw d
);
72 sljit_sw (*test71_f2
)(sljit_f64 a
, sljit_f64 b
);
73 sljit_sw (SLJIT_FUNC
*test71_f3
)(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
, sljit_f64 d
);
74 sljit_sw (SLJIT_FUNC
*test71_f4
)(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
);
76 void (SLJIT_FUNC
*test73_f1
)(sljit_s32 a
, sljit_sw b
, sljit_sw c
, sljit_s32 d
);
77 void (*test73_f2
)(sljit_sw a
, sljit_sw b
, sljit_s32 c
, sljit_s32 d
);
78 void (SLJIT_FUNC
*test73_f3
)(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
, sljit_sw d
);
79 void (SLJIT_FUNC
*test73_f4
)(sljit_f64 a
, sljit_f64 b
, sljit_sw c
, sljit_sw d
);
81 typedef union executable_code executable_code
;
83 static sljit_s32 successful_tests
= 0;
84 static sljit_s32 verbose
= 0;
85 static sljit_s32 silent
= 0;
87 #define FAILED(cond, text) \
88 if (SLJIT_UNLIKELY(cond)) { \
93 #define CHECK(compiler) \
94 if (sljit_get_compiler_error(compiler) != SLJIT_ERR_COMPILED) { \
95 printf("Compiler error: %d\n", sljit_get_compiler_error(compiler)); \
96 sljit_free_compiler(compiler); \
100 static void cond_set(struct sljit_compiler
*compiler
, sljit_s32 dst
, sljit_sw dstw
, sljit_s32 type
)
102 /* Testing both sljit_emit_op_flags and sljit_emit_jump. */
103 struct sljit_jump
* jump
;
104 struct sljit_label
* label
;
106 sljit_emit_op_flags(compiler
, SLJIT_MOV
, dst
, dstw
, type
);
107 jump
= sljit_emit_jump(compiler
, type
);
108 sljit_emit_op2(compiler
, SLJIT_ADD
, dst
, dstw
, dst
, dstw
, SLJIT_IMM
, 2);
109 label
= sljit_emit_label(compiler
);
110 sljit_set_label(jump
, label
);
113 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
115 /* For interface testing and for test64. */
116 void *sljit_test_malloc_exec(sljit_uw size
, void *exec_allocator_data
)
118 if (exec_allocator_data
)
119 return exec_allocator_data
;
121 return SLJIT_BUILTIN_MALLOC_EXEC(size
, exec_allocator_data
);
124 /* For interface testing. */
125 void sljit_test_free_code(void* code
, void *exec_allocator_data
)
127 SLJIT_UNUSED_ARG(exec_allocator_data
);
128 SLJIT_BUILTIN_FREE_EXEC(code
, exec_allocator_data
);
131 #define MALLOC_EXEC(result, size) \
132 result = SLJIT_MALLOC_EXEC(size, NULL); \
134 printf("Cannot allocate executable memory\n"); \
137 memset(result, 255, size);
139 #define FREE_EXEC(ptr) \
140 SLJIT_FREE_EXEC(((sljit_u8*)(ptr)) + SLJIT_EXEC_OFFSET(ptr), NULL);
142 static void test_exec_allocator(void)
144 /* This is not an sljit test. */
150 printf("Run executable allocator test\n");
152 MALLOC_EXEC(ptr1
, 32);
153 MALLOC_EXEC(ptr2
, 512);
154 MALLOC_EXEC(ptr3
, 512);
158 MALLOC_EXEC(ptr1
, 262104);
159 MALLOC_EXEC(ptr2
, 32000);
161 MALLOC_EXEC(ptr1
, 262104);
164 MALLOC_EXEC(ptr1
, 512);
165 MALLOC_EXEC(ptr2
, 512);
166 MALLOC_EXEC(ptr3
, 512);
168 MALLOC_EXEC(ptr2
, 512);
169 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
170 sljit_free_unused_memory_exec();
176 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
177 sljit_free_unused_memory_exec();
183 #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
185 static void test1(void)
187 /* Enter and return from an sljit function. */
188 executable_code code
;
189 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
192 printf("Run test1\n");
194 FAILED(!compiler
, "cannot create compiler\n");
196 /* 3 arguments passed, 3 arguments used. */
197 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, W
, W
, W
), 3, 3, 0, 0, 0);
198 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_S1
, 0);
200 SLJIT_ASSERT(sljit_get_generated_code_size(compiler
) == 0);
201 code
.code
= sljit_generate_code(compiler
);
203 SLJIT_ASSERT(compiler
->error
== SLJIT_ERR_COMPILED
);
204 SLJIT_ASSERT(sljit_get_generated_code_size(compiler
) > 0);
205 sljit_free_compiler(compiler
);
207 FAILED(code
.func3(3, -21, 86) != -21, "test1 case 1 failed\n");
208 FAILED(code
.func3(4789, 47890, 997) != 47890, "test1 case 2 failed\n");
210 sljit_free_code(code
.code
, NULL
);
214 static void test2(void)
217 executable_code code
;
218 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
220 static sljit_sw data
[2] = { 0, -9876 };
223 printf("Run test2\n");
225 FAILED(!compiler
, "cannot create compiler\n");
235 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 2, 0, 0, 0);
236 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 9999);
237 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_S0
, 0);
238 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_R0
, 0);
239 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
240 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 0);
241 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 2);
242 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_S0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 0);
243 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 3);
244 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_S0
), SLJIT_WORD_SHIFT
, SLJIT_MEM0(), (sljit_sw
)&buf
);
245 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
246 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&data
);
247 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
248 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0x12345678);
249 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), 0x12345678);
250 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
251 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3456);
252 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0xff890 + 6 * (sljit_sw
)sizeof(sljit_sw
));
253 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0xff890, SLJIT_R0
, 0);
254 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
+ 0xff890 + 7 * (sljit_sw
)sizeof(sljit_sw
));
255 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), -0xff890, SLJIT_R0
, 0);
256 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R2
, 0);
258 code
.code
= sljit_generate_code(compiler
);
260 sljit_free_compiler(compiler
);
262 FAILED(code
.func1((sljit_sw
)&buf
) != 9999, "test2 case 1 failed\n");
263 FAILED(buf
[1] != 9999, "test2 case 2 failed\n");
264 FAILED(buf
[2] != 9999, "test2 case 3 failed\n");
265 FAILED(buf
[3] != 5678, "test2 case 4 failed\n");
266 FAILED(buf
[4] != -9876, "test2 case 5 failed\n");
267 FAILED(buf
[5] != 5678, "test2 case 6 failed\n");
268 FAILED(buf
[6] != 3456, "test2 case 6 failed\n");
269 FAILED(buf
[7] != 3456, "test2 case 6 failed\n");
271 sljit_free_code(code
.code
, NULL
);
275 static void test3(void)
278 executable_code code
;
279 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
283 printf("Run test3\n");
285 FAILED(!compiler
, "cannot create compiler\n");
292 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
293 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0);
294 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM0(), (sljit_sw
)&buf
[1], SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
295 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
296 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2);
297 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[4] - 0xff0000 - 0x20);
298 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[4] - 0xff0000);
299 sljit_emit_op1(compiler
, SLJIT_NOT
, SLJIT_MEM1(SLJIT_R1
), 0xff0000 + 0x20, SLJIT_MEM1(SLJIT_R2
), 0xff0000);
300 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
302 code
.code
= sljit_generate_code(compiler
);
304 sljit_free_compiler(compiler
);
306 FAILED(code
.func1((sljit_sw
)&buf
) != ~1234, "test3 case 1 failed\n");
307 FAILED(buf
[1] != ~1234, "test3 case 2 failed\n");
308 FAILED(buf
[3] != ~9876, "test3 case 3 failed\n");
309 FAILED(buf
[4] != ~0x12345678, "test3 case 4 failed\n");
311 sljit_free_code(code
.code
, NULL
);
315 static void test4(void)
318 executable_code code
;
319 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
323 printf("Run test4\n");
325 FAILED(!compiler
, "cannot create compiler\n");
331 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, P
, W
), 3, 2, 0, 0, 0);
332 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_IMM
, 0, SLJIT_S1
, 0);
333 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM0(), (sljit_sw
)&buf
[0], SLJIT_IMM
, 0, SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
334 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 299);
335 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 0, SLJIT_R1
, 0);
336 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0, SLJIT_S1
, 0);
337 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
339 code
.code
= sljit_generate_code(compiler
);
341 sljit_free_compiler(compiler
);
343 FAILED(code
.func2((sljit_sw
)&buf
, 4567) != -4567, "test4 case 1 failed\n");
344 FAILED(buf
[0] != -1234, "test4 case 2 failed\n");
345 FAILED(buf
[2] != -4567, "test4 case 3 failed\n");
346 FAILED(buf
[3] != -299, "test4 case 4 failed\n");
348 sljit_free_code(code
.code
, NULL
);
352 static void test5(void)
355 executable_code code
;
356 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
360 printf("Run test5\n");
362 FAILED(!compiler
, "cannot create compiler\n");
373 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 2, 0, 0, 0);
374 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
375 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 50);
376 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);
377 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
) + 2);
378 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 50);
379 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
380 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
381 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, 4, SLJIT_R0
, 0);
382 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_IMM
, 50, SLJIT_R1
, 0);
383 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
));
384 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
385 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
));
386 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
));
387 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);
388 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x1e7d39f2);
389 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_IMM
, 0x23de7c06);
390 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, 0x3d72e452, SLJIT_R1
, 0);
391 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
));
392 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, 1000, SLJIT_R0
, 0);
393 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1430);
394 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_IMM
, -99, SLJIT_R0
, 0);
396 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
398 code
.code
= sljit_generate_code(compiler
);
400 sljit_free_compiler(compiler
);
402 FAILED(code
.func1((sljit_sw
)&buf
) != 2437 + 2 * sizeof(sljit_sw
), "test5 case 1 failed\n");
403 FAILED(buf
[0] != 202 + 2 * sizeof(sljit_sw
), "test5 case 2 failed\n");
404 FAILED(buf
[2] != 500, "test5 case 3 failed\n");
405 FAILED(buf
[3] != 400, "test5 case 4 failed\n");
406 FAILED(buf
[4] != 200, "test5 case 5 failed\n");
407 FAILED(buf
[5] != 250, "test5 case 6 failed\n");
408 FAILED(buf
[6] != 0x425bb5f8, "test5 case 7 failed\n");
409 FAILED(buf
[7] != 0x5bf01e44, "test5 case 8 failed\n");
410 FAILED(buf
[8] != 270, "test5 case 9 failed\n");
412 sljit_free_code(code
.code
, NULL
);
416 static void test6(void)
418 /* Test addc, sub, subc. */
419 executable_code code
;
420 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
424 printf("Run test6\n");
426 FAILED(!compiler
, "cannot create compiler\n");
439 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
440 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
441 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -1);
442 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0, SLJIT_IMM
, 0);
443 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
444 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 4);
445 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
446 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, 50);
447 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 6000);
448 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, 10);
449 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);
450 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
451 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2);
452 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
453 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5000);
454 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
455 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
456 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R1
, 0);
457 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5000);
458 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_IMM
, 6000, SLJIT_R0
, 0);
459 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_R0
, 0);
460 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
461 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32768);
462 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_R1
, 0);
463 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -32767);
464 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_R1
, 0);
465 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x52cd3bf4);
466 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_R0
, 0, SLJIT_IMM
, 0x3da297c6);
467 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 6000);
468 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_R1
, 0);
469 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_R1
, 0);
470 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 10);
471 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 5);
472 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 2);
473 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_RETURN_REG
, 0, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, -2220);
474 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
476 code
.code
= sljit_generate_code(compiler
);
478 sljit_free_compiler(compiler
);
480 FAILED(code
.func1((sljit_sw
)&buf
) != 2223, "test6 case 1 failed\n");
481 FAILED(buf
[0] != 1, "test6 case 2 failed\n");
482 FAILED(buf
[1] != 5, "test6 case 3 failed\n");
483 FAILED(buf
[2] != 50, "test6 case 4 failed\n");
484 FAILED(buf
[3] != 4, "test6 case 5 failed\n");
485 FAILED(buf
[4] != 50, "test6 case 6 failed\n");
486 FAILED(buf
[5] != 50, "test6 case 7 failed\n");
487 FAILED(buf
[6] != 1000, "test6 case 8 failed\n");
488 FAILED(buf
[7] != 100 - 32768, "test6 case 9 failed\n");
489 FAILED(buf
[8] != 100 + 32767, "test6 case 10 failed\n");
490 FAILED(buf
[9] != 0x152aa42e, "test6 case 11 failed\n");
491 FAILED(buf
[10] != -2000, "test6 case 12 failed\n");
493 sljit_free_code(code
.code
, NULL
);
497 static void test7(void)
499 /* Test logical operators. */
500 executable_code code
;
501 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
505 printf("Run test7\n");
507 FAILED(!compiler
, "cannot create compiler\n");
515 buf
[7] = (sljit_sw
)0xc43a7f95;
517 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
518 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf0C000);
519 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, 0x308f);
520 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
521 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);
522 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xC0F0);
523 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5);
524 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xff0000);
525 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R0
, 0);
526 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0xC0F0);
527 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_R2
, 0, SLJIT_R2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5);
528 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R2
, 0, SLJIT_IMM
, 0xff0000);
529 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 0xFFFFFF, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
530 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_IMM
, (sljit_sw
)0xa56c82c0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6);
531 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7);
532 sljit_emit_op2(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_IMM
, (sljit_sw
)0xff00ff00, SLJIT_R0
, 0);
533 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0xff00ff00);
534 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x0f);
535 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0x888888, SLJIT_R1
, 0);
536 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
538 code
.code
= sljit_generate_code(compiler
);
540 sljit_free_compiler(compiler
);
542 FAILED(code
.func1((sljit_sw
)&buf
) != 0x8808, "test7 case 1 failed\n");
543 FAILED(buf
[0] != 0x0F807F00, "test7 case 2 failed\n");
544 FAILED(buf
[1] != 0x0F7F7F7F, "test7 case 3 failed\n");
545 FAILED(buf
[2] != 0x00F0F08F, "test7 case 4 failed\n");
546 FAILED(buf
[3] != 0x00A0A0A0, "test7 case 5 failed\n");
547 FAILED(buf
[4] != 0x00FF80B0, "test7 case 6 failed\n");
548 FAILED(buf
[5] != 0x00FF4040, "test7 case 7 failed\n");
549 FAILED(buf
[6] != (sljit_sw
)0xa56c82c0, "test7 case 8 failed\n");
550 FAILED(buf
[7] != 0x3b3a8095, "test7 case 9 failed\n");
552 sljit_free_code(code
.code
, NULL
);
556 static void test8(void)
558 /* Test flags (neg, cmp, test). */
559 executable_code code
;
560 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
565 printf("Run test8\n");
567 FAILED(!compiler
, "cannot create compiler\n");
569 for (i
= 1; i
< 19; i
++)
572 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 2, 0, 0, 0);
573 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 20);
574 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 10);
575 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_IMM
, 6, SLJIT_IMM
, 5);
576 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_NOT_EQUAL
);
577 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_EQUAL
);
578 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 3000);
579 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_GREATER
);
580 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 3000);
581 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_S1
, 0);
582 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_LESS
);
583 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R2
, 0);
584 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, -15);
585 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_SIG_GREATER
);
586 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R2
, 0);
587 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -(sljit_sw
)(~(sljit_uw
)0 >> 1) - 1);
588 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0);
589 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
590 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
591 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_OVERFLOW
);
592 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
593 sljit_emit_op1(compiler
, SLJIT_NOT
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_R0
, 0);
594 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_ZERO
);
595 sljit_emit_op1(compiler
, SLJIT_NOT
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R1
, 0);
596 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_ZERO
);
597 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_IMM
, 0xffff, SLJIT_R0
, 0);
598 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 0xffff);
599 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_NOT_ZERO
);
600 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_IMM
, 0xffff, SLJIT_R1
, 0);
601 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_IMM
, 0xffff);
602 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
603 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
604 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
605 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0x1);
606 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_NOT_ZERO
);
607 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -(sljit_sw
)(~(sljit_uw
)0 >> 1) - 1);
608 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
609 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0);
610 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 11, SLJIT_OVERFLOW
);
611 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0);
612 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 12, SLJIT_OVERFLOW
);
613 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 9);
614 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
615 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 13, SLJIT_LESS
);
616 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 14, SLJIT_ZERO
);
617 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
618 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
619 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 15, SLJIT_LESS
);
620 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 16, SLJIT_ZERO
);
621 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -9);
622 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
623 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 17, SLJIT_SIG_LESS
);
624 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -9);
625 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
626 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 18, SLJIT_SIG_GREATER
);
628 sljit_emit_return_void(compiler
);
630 code
.code
= sljit_generate_code(compiler
);
632 sljit_free_compiler(compiler
);
634 code
.func1((sljit_sw
)&buf
);
635 FAILED(buf
[1] != 1, "test8 case 1 failed\n");
636 FAILED(buf
[2] != 0, "test8 case 2 failed\n");
637 FAILED(buf
[3] != 0, "test8 case 3 failed\n");
638 FAILED(buf
[4] != 1, "test8 case 4 failed\n");
639 FAILED(buf
[5] != 1, "test8 case 5 failed\n");
640 FAILED(buf
[6] != 1, "test8 case 6 failed\n");
641 FAILED(buf
[7] != 1, "test8 case 7 failed\n");
642 FAILED(buf
[8] != 0, "test8 case 8 failed\n");
643 FAILED(buf
[9] != 1, "test8 case 9 failed\n");
644 FAILED(buf
[10] != 0, "test8 case 10 failed\n");
645 FAILED(buf
[11] != 1, "test8 case 11 failed\n");
646 FAILED(buf
[12] != 0, "test8 case 12 failed\n");
647 FAILED(buf
[13] != 1, "test8 case 13 failed\n");
648 FAILED(buf
[14] != 0, "test8 case 14 failed\n");
649 FAILED(buf
[15] != 0, "test8 case 15 failed\n");
650 FAILED(buf
[16] != 1, "test8 case 16 failed\n");
651 FAILED(buf
[17] != 0, "test8 case 17 failed\n");
652 FAILED(buf
[18] != 1, "test8 case 18 failed\n");
654 sljit_free_code(code
.code
, NULL
);
658 static void test9(void)
661 executable_code code
;
662 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
664 #ifdef SLJIT_PREF_SHIFT_REG
665 sljit_s32 shift_reg
= SLJIT_PREF_SHIFT_REG
;
667 sljit_s32 shift_reg
= SLJIT_R2
;
670 SLJIT_ASSERT(shift_reg
>= SLJIT_R2
&& shift_reg
<= SLJIT_R3
);
673 printf("Run test9\n");
675 FAILED(!compiler
, "cannot create compiler\n");
690 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 4, 2, 0, 0, 0);
691 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf);
692 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 3);
693 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
694 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
695 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
696 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R1
, 0, SLJIT_IMM
, 1);
697 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -64);
698 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 2);
699 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, shift_reg
, 0);
701 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 0xff);
702 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
703 sljit_emit_op2(compiler
, SLJIT_SHL
, shift_reg
, 0, shift_reg
, 0, SLJIT_R0
, 0);
704 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, shift_reg
, 0);
705 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 0xff);
706 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
707 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);
708 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, shift_reg
, 0, SLJIT_R0
, 0);
710 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0xf);
711 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
712 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_R0
, 0);
713 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_S1
, 0);
714 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_R0
, 0);
715 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_R0
, 0);
716 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0xf00);
717 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
718 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R1
, 0, SLJIT_R2
, 0, SLJIT_R0
, 0);
719 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_R1
, 0);
721 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)buf
);
722 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 9);
723 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
);
725 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 4);
726 sljit_emit_op2(compiler
, SLJIT_SHL
, shift_reg
, 0, SLJIT_IMM
, 2, shift_reg
, 0);
727 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, shift_reg
, 0);
729 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xa9);
730 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
731 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x7d00);
732 sljit_emit_op2(compiler
, SLJIT_LSHR32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32);
733 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
734 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
736 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
737 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xe30000);
738 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
739 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffc0);
741 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffe0);
743 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
744 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x25000000);
745 sljit_emit_op2(compiler
, SLJIT_SHL32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xfffe1);
746 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
747 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
749 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 11, SLJIT_R1
, 0, SLJIT_R0
, 0);
751 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 0);
752 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x5c);
753 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R1
, 0, SLJIT_R0
, 0, shift_reg
, 0);
754 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0xf600);
755 sljit_emit_op2(compiler
, SLJIT_LSHR32
, SLJIT_R0
, 0, SLJIT_R0
, 0, shift_reg
, 0);
756 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
757 /* Alternative form of uint32 type cast. */
758 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffffffff);
760 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
761 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x630000);
762 sljit_emit_op2(compiler
, SLJIT_ASHR
, SLJIT_R0
, 0, SLJIT_R0
, 0, shift_reg
, 0);
763 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 12, SLJIT_R1
, 0, SLJIT_R0
, 0);
765 sljit_emit_return_void(compiler
);
767 code
.code
= sljit_generate_code(compiler
);
769 sljit_free_compiler(compiler
);
771 code
.func1((sljit_sw
)&buf
);
772 FAILED(buf
[0] != 0x3c, "test9 case 1 failed\n");
773 FAILED(buf
[1] != 0xf0, "test9 case 2 failed\n");
774 FAILED(buf
[2] != -16, "test9 case 3 failed\n");
775 FAILED(buf
[3] != 0xff0, "test9 case 4 failed\n");
776 FAILED(buf
[4] != 4, "test9 case 5 failed\n");
777 FAILED(buf
[5] != 0xff00, "test9 case 6 failed\n");
778 FAILED(buf
[6] != 0x3c, "test9 case 7 failed\n");
779 FAILED(buf
[7] != 0xf0, "test9 case 8 failed\n");
780 FAILED(buf
[8] != 0xf0, "test9 case 9 failed\n");
781 FAILED(buf
[9] != 0x18, "test9 case 10 failed\n");
782 FAILED(buf
[10] != 32, "test9 case 11 failed\n");
783 FAILED(buf
[11] != 0x4ae37da9, "test9 case 12 failed\n");
784 FAILED(buf
[12] != 0x63f65c, "test9 case 13 failed\n");
786 sljit_free_code(code
.code
, NULL
);
790 static void test10(void)
792 /* Test multiplications. */
793 executable_code code
;
794 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
798 printf("Run test10\n");
800 FAILED(!compiler
, "cannot create compiler\n");
809 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
810 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
811 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
812 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
813 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 7);
814 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 8);
815 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
816 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_IMM
, -3, SLJIT_IMM
, -4);
817 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0);
818 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -2);
819 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);
820 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
) / 2);
821 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[3]);
822 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);
823 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 9);
824 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
825 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_R0
, 0);
826 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
827 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
828 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x123456789));
829 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_R0
, 0);
831 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 11, SLJIT_IMM
, 10);
832 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
834 code
.code
= sljit_generate_code(compiler
);
836 sljit_free_compiler(compiler
);
838 FAILED(code
.func1((sljit_sw
)&buf
) != 110, "test10 case 1 failed\n");
839 FAILED(buf
[0] != 15, "test10 case 2 failed\n");
840 FAILED(buf
[1] != 56, "test10 case 3 failed\n");
841 FAILED(buf
[2] != 12, "test10 case 4 failed\n");
842 FAILED(buf
[3] != -12, "test10 case 5 failed\n");
843 FAILED(buf
[4] != 100, "test10 case 6 failed\n");
844 FAILED(buf
[5] != 81, "test10 case 7 failed\n");
845 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
846 FAILED(buf
[6] != SLJIT_W(0x123456789) * 3, "test10 case 8 failed\n");
849 sljit_free_code(code
.code
, NULL
);
853 static void test11(void)
855 /* Test rewritable constants. */
856 executable_code code
;
857 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
858 struct sljit_const
* const1
;
859 struct sljit_const
* const2
;
860 struct sljit_const
* const3
;
861 struct sljit_const
* const4
;
863 sljit_sw executable_offset
;
864 sljit_uw const1_addr
;
865 sljit_uw const2_addr
;
866 sljit_uw const3_addr
;
867 sljit_uw const4_addr
;
868 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
869 sljit_sw word_value1
= (sljit_sw
)SLJIT_W(0xaaaaaaaaaaaaaaaa);
870 sljit_sw word_value2
= (sljit_sw
)SLJIT_W(0xfee1deadfbadf00d);
872 sljit_sw word_value1
= (sljit_sw
)0xaaaaaaaal
;
873 sljit_sw word_value2
= (sljit_sw
)0xfbadf00dl
;
878 printf("Run test11\n");
880 FAILED(!compiler
, "cannot create compiler\n");
885 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
887 SLJIT_ASSERT(!sljit_alloc_memory(compiler
, 0));
888 SLJIT_ASSERT(!sljit_alloc_memory(compiler
, 16 * sizeof(sljit_sw
) + 1));
890 const1
= sljit_emit_const(compiler
, SLJIT_MEM0(), (sljit_sw
)&buf
[0], -0x81b9);
892 value
= sljit_alloc_memory(compiler
, 16 * sizeof(sljit_sw
));
895 SLJIT_ASSERT(!((sljit_sw
)value
& ((sljit_sw
)sizeof(sljit_sw
) - 1)));
896 memset(value
, 255, 16 * sizeof(sljit_sw
));
899 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
900 const2
= sljit_emit_const(compiler
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_WORD_SHIFT
- 1, -65535);
901 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[0] + 2 * (sljit_sw
)sizeof(sljit_sw
) - 2);
902 const3
= sljit_emit_const(compiler
, SLJIT_MEM1(SLJIT_R0
), 0, word_value1
);
904 value
= sljit_alloc_memory(compiler
, 17);
907 SLJIT_ASSERT(!((sljit_sw
)value
& ((sljit_sw
)sizeof(sljit_sw
) - 1)));
908 memset(value
, 255, 16);
911 const4
= sljit_emit_const(compiler
, SLJIT_RETURN_REG
, 0, (sljit_sw
)0xf7afcdb7);
913 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
915 code
.code
= sljit_generate_code(compiler
);
917 executable_offset
= sljit_get_executable_offset(compiler
);
918 const1_addr
= sljit_get_const_addr(const1
);
919 const2_addr
= sljit_get_const_addr(const2
);
920 const3_addr
= sljit_get_const_addr(const3
);
921 const4_addr
= sljit_get_const_addr(const4
);
922 sljit_free_compiler(compiler
);
924 FAILED(code
.func1((sljit_sw
)&buf
) != (sljit_sw
)0xf7afcdb7, "test11 case 1 failed\n");
925 FAILED(buf
[0] != -0x81b9, "test11 case 2 failed\n");
926 FAILED(buf
[1] != -65535, "test11 case 3 failed\n");
927 FAILED(buf
[2] != word_value1
, "test11 case 4 failed\n");
929 sljit_set_const(const1_addr
, -1, executable_offset
);
930 sljit_set_const(const2_addr
, word_value2
, executable_offset
);
931 sljit_set_const(const3_addr
, (sljit_sw
)0xbab0fea1, executable_offset
);
932 sljit_set_const(const4_addr
, -60089, executable_offset
);
934 FAILED(code
.func1((sljit_sw
)&buf
) != -60089, "test11 case 5 failed\n");
935 FAILED(buf
[0] != -1, "test11 case 6 failed\n");
936 FAILED(buf
[1] != word_value2
, "test11 case 7 failed\n");
937 FAILED(buf
[2] != (sljit_sw
)0xbab0fea1, "test11 case 8 failed\n");
939 sljit_free_code(code
.code
, NULL
);
943 static void test12(void)
945 /* Test rewriteable jumps. */
946 executable_code code
;
947 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
948 struct sljit_label
*label1
;
949 struct sljit_label
*label2
;
950 struct sljit_label
*label3
;
951 struct sljit_jump
*jump1
;
952 struct sljit_jump
*jump2
;
953 struct sljit_jump
*jump3
;
954 sljit_sw executable_offset
;
957 sljit_uw label1_addr
;
958 sljit_uw label2_addr
;
962 printf("Run test12\n");
964 FAILED(!compiler
, "cannot create compiler\n");
967 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, W
), 3, 2, 0, 0, 0);
968 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_S1
, 0, SLJIT_IMM
, 10);
969 jump1
= sljit_emit_jump(compiler
, SLJIT_REWRITABLE_JUMP
| SLJIT_SIG_GREATER
);
970 /* Default handler. */
971 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 5);
972 jump2
= sljit_emit_jump(compiler
, SLJIT_JUMP
);
974 value
= sljit_alloc_memory(compiler
, 15);
977 SLJIT_ASSERT(!((sljit_sw
)value
& ((sljit_sw
)sizeof(sljit_sw
) - 1)));
978 memset(value
, 255, 15);
982 label1
= sljit_emit_label(compiler
);
983 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
984 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 6);
985 jump3
= sljit_emit_jump(compiler
, SLJIT_JUMP
);
987 label2
= sljit_emit_label(compiler
);
988 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
989 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 7);
991 label3
= sljit_emit_label(compiler
);
992 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
993 sljit_set_label(jump2
, label3
);
994 sljit_set_label(jump3
, label3
);
995 /* By default, set to handler 1. */
996 sljit_set_label(jump1
, label1
);
997 sljit_emit_return_void(compiler
);
999 value
= sljit_alloc_memory(compiler
, 8);
1002 SLJIT_ASSERT(!((sljit_sw
)value
& ((sljit_sw
)sizeof(sljit_sw
) - 1)));
1003 memset(value
, 255, 8);
1006 code
.code
= sljit_generate_code(compiler
);
1008 executable_offset
= sljit_get_executable_offset(compiler
);
1009 jump1_addr
= sljit_get_jump_addr(jump1
);
1010 label1_addr
= sljit_get_label_addr(label1
);
1011 label2_addr
= sljit_get_label_addr(label2
);
1012 sljit_free_compiler(compiler
);
1014 code
.func2((sljit_sw
)&buf
, 4);
1015 FAILED(buf
[0] != 5, "test12 case 1 failed\n");
1017 code
.func2((sljit_sw
)&buf
, 11);
1018 FAILED(buf
[0] != 6, "test12 case 2 failed\n");
1020 sljit_set_jump_addr(jump1_addr
, label2_addr
, executable_offset
);
1021 code
.func2((sljit_sw
)&buf
, 12);
1022 FAILED(buf
[0] != 7, "test12 case 3 failed\n");
1024 sljit_set_jump_addr(jump1_addr
, label1_addr
, executable_offset
);
1025 code
.func2((sljit_sw
)&buf
, 13);
1026 FAILED(buf
[0] != 6, "test12 case 4 failed\n");
1028 sljit_free_code(code
.code
, NULL
);
1032 static void test13(void)
1034 /* Test fpu monadic functions. */
1035 executable_code code
;
1036 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1041 printf("Run test13\n");
1043 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
1045 printf("no fpu available, test13 skipped\n");
1048 sljit_free_compiler(compiler
);
1052 FAILED(!compiler
, "cannot create compiler\n");
1068 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 3, 2, 6, 0, 0);
1069 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM0(), (sljit_sw
)&buf
[2], SLJIT_MEM0(), (sljit_sw
)&buf
[1]);
1070 sljit_emit_fop1(compiler
, SLJIT_ABS_F64
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f64
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
1071 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
1072 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_f64
));
1073 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 0);
1074 sljit_emit_fop1(compiler
, SLJIT_NEG_F64
, SLJIT_FR2
, 0, SLJIT_FR0
, 0);
1075 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR3
, 0, SLJIT_FR2
, 0);
1076 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM0(), (sljit_sw
)&buf
[4], SLJIT_FR3
, 0);
1077 sljit_emit_fop1(compiler
, SLJIT_ABS_F64
, SLJIT_FR4
, 0, SLJIT_FR1
, 0);
1078 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_f64
), SLJIT_FR4
, 0);
1079 sljit_emit_fop1(compiler
, SLJIT_NEG_F64
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f64
), SLJIT_FR4
, 0);
1081 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
1082 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_GREATER
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
1083 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_F_GREATER
);
1084 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_GREATER
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
), SLJIT_FR5
, 0);
1085 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_F_GREATER
);
1086 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_FR5
, 0);
1087 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR1
, 0);
1088 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
), SLJIT_F_EQUAL
);
1089 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_LESS
, SLJIT_FR1
, 0, SLJIT_FR1
, 0);
1090 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_F_LESS
);
1091 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
1092 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_F_EQUAL
);
1093 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_NOT_EQUAL
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
1094 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_F_NOT_EQUAL
);
1096 sljit_emit_return_void(compiler
);
1098 code
.code
= sljit_generate_code(compiler
);
1100 sljit_free_compiler(compiler
);
1102 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
1103 FAILED(buf
[2] != -4.5, "test13 case 1 failed\n");
1104 FAILED(buf
[3] != 4.5, "test13 case 2 failed\n");
1105 FAILED(buf
[4] != -7.75, "test13 case 3 failed\n");
1106 FAILED(buf
[5] != 4.5, "test13 case 4 failed\n");
1107 FAILED(buf
[6] != -4.5, "test13 case 5 failed\n");
1109 FAILED(buf2
[0] != 1, "test13 case 6 failed\n");
1110 FAILED(buf2
[1] != 0, "test13 case 7 failed\n");
1111 FAILED(buf2
[2] != 1, "test13 case 8 failed\n");
1112 FAILED(buf2
[3] != 0, "test13 case 9 failed\n");
1113 FAILED(buf2
[4] != 0, "test13 case 10 failed\n");
1114 FAILED(buf2
[5] != 1, "test13 case 11 failed\n");
1116 sljit_free_code(code
.code
, NULL
);
1120 static void test14(void)
1122 /* Test fpu diadic functions. */
1123 executable_code code
;
1124 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1128 printf("Run test14\n");
1130 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
1132 printf("no fpu available, test14 skipped\n");
1135 sljit_free_compiler(compiler
);
1154 FAILED(!compiler
, "cannot create compiler\n");
1155 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 6, 0, 0);
1158 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_f64
));
1159 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
1160 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 2);
1161 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 3, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
1162 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR1
, 0);
1163 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_FR1
, 0, SLJIT_FR0
, 0, SLJIT_FR1
, 0);
1164 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 4, SLJIT_FR0
, 0);
1165 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 5, SLJIT_FR1
, 0);
1168 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
1169 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 2);
1170 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
1171 sljit_emit_fop2(compiler
, SLJIT_SUB_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 6, SLJIT_FR3
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_F64_SHIFT
);
1172 sljit_emit_fop2(compiler
, SLJIT_SUB_F64
, SLJIT_FR2
, 0, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 2);
1173 sljit_emit_fop2(compiler
, SLJIT_SUB_F64
, SLJIT_FR3
, 0, SLJIT_FR2
, 0, SLJIT_FR3
, 0);
1174 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 7, SLJIT_FR2
, 0);
1175 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 8, SLJIT_FR3
, 0);
1178 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1179 sljit_emit_fop2(compiler
, SLJIT_MUL_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 9, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_F64_SHIFT
, SLJIT_FR1
, 0);
1180 sljit_emit_fop2(compiler
, SLJIT_MUL_F64
, SLJIT_FR1
, 0, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
1181 sljit_emit_fop2(compiler
, SLJIT_MUL_F64
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 2, SLJIT_FR2
, 0);
1182 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 10, SLJIT_FR1
, 0);
1183 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 11, SLJIT_FR5
, 0);
1186 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 12);
1187 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 13);
1188 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR4
, 0, SLJIT_FR5
, 0);
1189 sljit_emit_fop2(compiler
, SLJIT_DIV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 12, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 12, SLJIT_FR1
, 0);
1190 sljit_emit_fop2(compiler
, SLJIT_DIV_F64
, SLJIT_FR5
, 0, SLJIT_FR5
, 0, SLJIT_FR1
, 0);
1191 sljit_emit_fop2(compiler
, SLJIT_DIV_F64
, SLJIT_FR4
, 0, SLJIT_FR1
, 0, SLJIT_FR4
, 0);
1192 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 13, SLJIT_FR5
, 0);
1193 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
) * 14, SLJIT_FR4
, 0);
1195 sljit_emit_return_void(compiler
);
1197 code
.code
= sljit_generate_code(compiler
);
1199 sljit_free_compiler(compiler
);
1201 code
.func1((sljit_sw
)&buf
);
1202 FAILED(buf
[3] != 10.75, "test14 case 1 failed\n");
1203 FAILED(buf
[4] != 5.25, "test14 case 2 failed\n");
1204 FAILED(buf
[5] != 7.0, "test14 case 3 failed\n");
1205 FAILED(buf
[6] != 0.0, "test14 case 4 failed\n");
1206 FAILED(buf
[7] != 5.5, "test14 case 5 failed\n");
1207 FAILED(buf
[8] != 3.75, "test14 case 6 failed\n");
1208 FAILED(buf
[9] != 24.5, "test14 case 7 failed\n");
1209 FAILED(buf
[10] != 38.5, "test14 case 8 failed\n");
1210 FAILED(buf
[11] != 9.625, "test14 case 9 failed\n");
1211 FAILED(buf
[12] != 2.0, "test14 case 10 failed\n");
1212 FAILED(buf
[13] != 2.0, "test14 case 11 failed\n");
1213 FAILED(buf
[14] != 0.5, "test14 case 12 failed\n");
1215 sljit_free_code(code
.code
, NULL
);
1219 static sljit_sw SLJIT_FUNC
func(sljit_sw a
, sljit_sw b
, sljit_sw c
)
1221 return a
+ b
+ c
+ 5;
1224 static void test15(void)
1226 /* Test function call. */
1227 executable_code code
;
1228 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1229 struct sljit_jump
* jump
= NULL
;
1233 printf("Run test15\n");
1235 FAILED(!compiler
, "cannot create compiler\n");
1242 buf
[6] = SLJIT_FUNC_ADDR(func
);
1244 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 4, 1, 0, 0, 0);
1246 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
1247 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 7);
1248 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -3);
1249 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(func
));
1250 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_RETURN_REG
, 0);
1252 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -5);
1253 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -10);
1254 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
1255 jump
= sljit_emit_call(compiler
, SLJIT_CALL
| SLJIT_REWRITABLE_JUMP
, SLJIT_ARGS3(W
, W
, W
, W
));
1256 sljit_set_target(jump
, (sljit_uw
)-1);
1257 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1259 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(func
));
1260 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 40);
1261 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -3);
1262 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_R0
, 0);
1263 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1265 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -60);
1266 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(func
));
1267 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -30);
1268 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_R1
, 0);
1269 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1271 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 10);
1272 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 16);
1273 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(func
));
1274 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_R2
, 0);
1275 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1277 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 100);
1278 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 110);
1279 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 120);
1280 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(func
));
1281 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_R3
, 0);
1282 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1284 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
1285 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -16);
1286 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 6);
1287 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(W
, W
, W
, W
), SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
));
1288 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_RETURN_REG
, 0);
1290 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1292 code
.code
= sljit_generate_code(compiler
);
1294 sljit_set_jump_addr(sljit_get_jump_addr(jump
), SLJIT_FUNC_UADDR(func
), sljit_get_executable_offset(compiler
));
1295 sljit_free_compiler(compiler
);
1297 FAILED(code
.func1((sljit_sw
)&buf
) != -15, "test15 case 1 failed\n");
1298 FAILED(buf
[0] != 14, "test15 case 2 failed\n");
1299 FAILED(buf
[1] != -8, "test15 case 3 failed\n");
1300 FAILED(buf
[2] != SLJIT_FUNC_ADDR(func
) + 42, "test15 case 4 failed\n");
1301 FAILED(buf
[3] != SLJIT_FUNC_ADDR(func
) - 85, "test15 case 5 failed\n");
1302 FAILED(buf
[4] != SLJIT_FUNC_ADDR(func
) + 31, "test15 case 6 failed\n");
1303 FAILED(buf
[5] != 335, "test15 case 7 failed\n");
1304 FAILED(buf
[6] != -15, "test15 case 8 failed\n");
1306 sljit_free_code(code
.code
, NULL
);
1310 static void test16(void)
1312 /* Ackermann benchmark. */
1313 executable_code code
;
1314 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1315 struct sljit_label
*entry
;
1316 struct sljit_label
*label
;
1317 struct sljit_jump
*jump
;
1318 struct sljit_jump
*jump1
;
1319 struct sljit_jump
*jump2
;
1322 printf("Run test16\n");
1324 FAILED(!compiler
, "cannot create compiler\n");
1326 entry
= sljit_emit_label(compiler
);
1327 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, W
, W
), 3, 2, 0, 0, 0);
1329 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_S0
, 0, SLJIT_IMM
, 0);
1330 jump1
= sljit_emit_jump(compiler
, SLJIT_EQUAL
);
1332 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_S1
, 0, SLJIT_IMM
, 0);
1333 jump2
= sljit_emit_jump(compiler
, SLJIT_EQUAL
);
1336 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
1337 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 1);
1338 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS2(W
, W
, W
));
1339 sljit_set_label(jump
, entry
);
1341 /* Returns with Ack(x-1, Ack(x,y-1)). */
1342 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_RETURN_REG
, 0);
1343 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
1344 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS2(W
, W
, W
));
1345 sljit_set_label(jump
, entry
);
1346 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1348 /* Returns with y+1. */
1349 label
= sljit_emit_label(compiler
);
1350 sljit_set_label(jump1
, label
);
1351 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 1, SLJIT_S1
, 0);
1352 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1354 /* Returns with Ack(x-1,1) */
1355 label
= sljit_emit_label(compiler
);
1356 sljit_set_label(jump2
, label
);
1357 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
1358 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1359 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS2(W
, W
, W
));
1360 sljit_set_label(jump
, entry
);
1361 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1363 code
.code
= sljit_generate_code(compiler
);
1365 sljit_free_compiler(compiler
);
1367 FAILED(code
.func2(3, 3) != 61, "test16 case 1 failed\n");
1368 /* For benchmarking. */
1369 /* FAILED(code.func2(3, 11) != 16381, "test16 case 1 failed\n"); */
1371 sljit_free_code(code
.code
, NULL
);
1375 static void test17(void)
1377 /* Test arm constant pool. */
1378 executable_code code
;
1379 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1384 printf("Run test17\n");
1386 FAILED(!compiler
, "cannot create compiler\n");
1388 for (i
= 0; i
< 5; i
++)
1391 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 0, 0, 0);
1392 for (i
= 0; i
<= 0xfff; i
++) {
1393 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x81818000 | i
);
1394 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x81818000 | i
);
1395 if ((i
& 0x3ff) == 0)
1396 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), (i
>> 10) * (sljit_sw
)sizeof(sljit_sw
), SLJIT_R0
, 0);
1398 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1399 sljit_emit_return_void(compiler
);
1401 code
.code
= sljit_generate_code(compiler
);
1403 sljit_free_compiler(compiler
);
1405 code
.func1((sljit_sw
)&buf
);
1406 FAILED((sljit_uw
)buf
[0] != 0x81818000, "test17 case 1 failed\n");
1407 FAILED((sljit_uw
)buf
[1] != 0x81818400, "test17 case 2 failed\n");
1408 FAILED((sljit_uw
)buf
[2] != 0x81818800, "test17 case 3 failed\n");
1409 FAILED((sljit_uw
)buf
[3] != 0x81818c00, "test17 case 4 failed\n");
1410 FAILED((sljit_uw
)buf
[4] != 0x81818fff, "test17 case 5 failed\n");
1412 sljit_free_code(code
.code
, NULL
);
1416 static void test18(void)
1419 executable_code code
;
1420 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1424 printf("Run test18\n");
1426 FAILED(!compiler
, "cannot create compiler\n");
1437 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1438 buf
[10] = SLJIT_W(1) << 32;
1443 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 2, 0, 0, 0);
1445 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1446 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, SLJIT_W(0x1122334455667788));
1447 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x1122334455667788));
1449 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(1000000000000));
1450 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(1000000000000));
1451 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_IMM
, SLJIT_W(5000000000000), SLJIT_R0
, 0);
1453 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1454 sljit_emit_op2(compiler
, SLJIT_ADD32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1456 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1457 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1458 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_ZERO
);
1459 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_S1
, 0);
1460 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1461 sljit_emit_op2u(compiler
, SLJIT_AND32
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1120202020));
1462 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_ZERO
);
1464 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1108080808));
1465 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x2208080808));
1466 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_LESS
);
1467 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1468 sljit_emit_op2u(compiler
, SLJIT_AND32
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x1104040404));
1469 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_NOT_ZERO
);
1471 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
1472 sljit_emit_op2(compiler
, SLJIT_SHL32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_IMM
, SLJIT_W(0xffff0000), SLJIT_R0
, 0);
1474 sljit_emit_op2(compiler
, SLJIT_MUL32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 10, SLJIT_IMM
, -1);
1476 /* 32 bit operations. */
1478 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0x11223344);
1479 sljit_emit_op2(compiler
, SLJIT_ADD32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 0x44332211);
1483 sljit_emit_return_void(compiler
);
1485 code
.code
= sljit_generate_code(compiler
);
1487 sljit_free_compiler(compiler
);
1489 code
.func1((sljit_sw
)&buf
);
1490 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1491 FAILED(buf
[0] != SLJIT_W(0x1122334455667788), "test18 case 1 failed\n");
1492 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1493 FAILED(buf
[1] != 0x55667788, "test18 case 2 failed\n");
1495 FAILED(buf
[1] != SLJIT_W(0x5566778800000000), "test18 case 2 failed\n");
1497 FAILED(buf
[2] != SLJIT_W(2000000000000), "test18 case 3 failed\n");
1498 FAILED(buf
[3] != SLJIT_W(4000000000000), "test18 case 4 failed\n");
1499 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1500 FAILED(buf
[4] != 0x28282828, "test18 case 5 failed\n");
1502 FAILED(buf
[4] != SLJIT_W(0x2828282800000000), "test18 case 5 failed\n");
1504 FAILED(buf
[5] != 0, "test18 case 6 failed\n");
1505 FAILED(buf
[6] != 1, "test18 case 7 failed\n");
1506 FAILED(buf
[7] != 1, "test18 case 8 failed\n");
1507 FAILED(buf
[8] != 0, "test18 case 9 failed\n");
1508 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1509 FAILED(buf
[9] != (sljit_sw
)0xfff00000, "test18 case 10 failed\n");
1510 FAILED(buf
[10] != (sljit_sw
)0xffffffff, "test18 case 11 failed\n");
1512 FAILED(buf
[9] != (sljit_sw
)SLJIT_W(0xfff0000000000000), "test18 case 10 failed\n");
1513 FAILED(buf
[10] != (sljit_sw
)SLJIT_W(0xffffffff00000000), "test18 case 11 failed\n");
1516 FAILED(buf
[0] != 0x11223344, "test18 case 1 failed\n");
1517 FAILED(buf
[1] != 0x44332211, "test18 case 2 failed\n");
1520 sljit_free_code(code
.code
, NULL
);
1524 static void test19(void)
1526 /* Test arm partial instruction caching. */
1527 executable_code code
;
1528 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1532 printf("Run test19\n");
1534 FAILED(!compiler
, "cannot create compiler\n");
1544 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 0, 0, 0);
1545 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
1546 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM0(), (sljit_sw
)&buf
[2], SLJIT_MEM0(), (sljit_sw
)&buf
[1], SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
1547 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1548 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1549 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]);
1550 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_MEM0(), (sljit_sw
)&buf
[0], SLJIT_IMM
, 2);
1551 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&buf
[0] + 4 * (sljit_sw
)sizeof(sljit_sw
));
1552 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_IMM
, 10);
1553 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 7);
1554 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]);
1556 sljit_emit_return_void(compiler
);
1558 code
.code
= sljit_generate_code(compiler
);
1560 sljit_free_compiler(compiler
);
1562 code
.func1((sljit_sw
)&buf
);
1563 FAILED(buf
[0] != 10, "test19 case 1 failed\n");
1564 FAILED(buf
[1] != 4, "test19 case 2 failed\n");
1565 FAILED(buf
[2] != 14, "test19 case 3 failed\n");
1566 FAILED(buf
[3] != 14, "test19 case 4 failed\n");
1567 FAILED(buf
[4] != 8, "test19 case 5 failed\n");
1568 FAILED(buf
[5] != 6, "test19 case 6 failed\n");
1569 FAILED(buf
[6] != 12, "test19 case 7 failed\n");
1570 FAILED(buf
[7] != 10, "test19 case 8 failed\n");
1572 sljit_free_code(code
.code
, NULL
);
1576 static void test20(void)
1579 executable_code code
;
1580 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1581 struct sljit_jump
* jump
;
1582 struct sljit_label
* label
;
1584 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1585 sljit_sw offset_value
= SLJIT_W(0x1234567812345678);
1587 sljit_sw offset_value
= SLJIT_W(0x12345678);
1591 printf("Run test20\n");
1593 FAILED(!compiler
, "cannot create compiler\n");
1601 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 5, 5, 0, 0, 4 * sizeof(sljit_sw
));
1602 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_S0
), 0);
1603 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
));
1604 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -1);
1605 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, -1);
1606 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, -1);
1607 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, -1);
1608 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
));
1609 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);
1610 sljit_get_local_base(compiler
, SLJIT_R0
, 0, -offset_value
);
1611 sljit_get_local_base(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, -0x1234);
1612 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
1613 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
));
1614 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_uw
));
1615 /* Dummy last instructions. */
1616 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 23);
1617 sljit_emit_label(compiler
);
1619 code
.code
= sljit_generate_code(compiler
);
1621 sljit_free_compiler(compiler
);
1623 FAILED(code
.func1((sljit_sw
)&buf
) != -12345, "test20 case 1 failed\n")
1625 FAILED(buf
[2] != 60, "test20 case 2 failed\n");
1626 FAILED(buf
[3] != 17, "test20 case 3 failed\n");
1627 FAILED(buf
[4] != 7, "test20 case 4 failed\n");
1629 sljit_free_code(code
.code
, NULL
);
1631 compiler
= sljit_create_compiler(NULL
, NULL
);
1632 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, W
, W
, W
), 3, 3, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
1634 sljit_get_local_base(compiler
, SLJIT_R0
, 0, SLJIT_MAX_LOCAL_SIZE
- sizeof(sljit_sw
));
1635 sljit_get_local_base(compiler
, SLJIT_R1
, 0, -(sljit_sw
)sizeof(sljit_sw
));
1636 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -1);
1637 label
= sljit_emit_label(compiler
);
1638 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1639 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R2
, 0);
1640 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_R0
, 0);
1641 jump
= sljit_emit_jump(compiler
, SLJIT_NOT_EQUAL
);
1642 sljit_set_label(jump
, label
);
1644 /* Saved registers should keep their value. */
1645 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_S1
, 0);
1646 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_S2
, 0);
1647 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
1649 code
.code
= sljit_generate_code(compiler
);
1651 sljit_free_compiler(compiler
);
1653 FAILED(code
.func3(1234, 5678, 9012) != 15924, "test20 case 5 failed\n");
1655 sljit_free_code(code
.code
, NULL
);
1659 static void test21(void)
1661 /* Test set context. The parts of the jit code can be separated in the memory. */
1662 executable_code code1
;
1663 executable_code code2
;
1664 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1665 struct sljit_jump
* jump
= NULL
;
1667 sljit_sw executable_offset
;
1671 printf("Run test21\n");
1673 FAILED(!compiler
, "cannot create compiler\n");
1679 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 2, 0, 0, 2 * sizeof(sljit_sw
));
1681 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 10);
1682 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_SP
), 0);
1684 jump
= sljit_emit_jump(compiler
, SLJIT_JUMP
| SLJIT_REWRITABLE_JUMP
);
1685 sljit_set_target(jump
, 0);
1687 code1
.code
= sljit_generate_code(compiler
);
1690 executable_offset
= sljit_get_executable_offset(compiler
);
1691 addr
= sljit_get_jump_addr(jump
);
1693 sljit_free_compiler(compiler
);
1695 compiler
= sljit_create_compiler(NULL
, NULL
);
1696 FAILED(!compiler
, "cannot create compiler\n");
1698 /* Other part of the jit code. */
1699 sljit_set_context(compiler
, 0, 1, 3, 2, 0, 0, 2 * sizeof(sljit_sw
));
1701 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
1702 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);
1703 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), 0);
1704 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_sw
));
1706 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
1708 code2
.code
= sljit_generate_code(compiler
);
1710 sljit_free_compiler(compiler
);
1712 sljit_set_jump_addr(addr
, SLJIT_FUNC_UADDR(code2
.code
), executable_offset
);
1714 FAILED(code1
.func1((sljit_sw
)&buf
) != 19, "test21 case 1 failed\n");
1715 FAILED(buf
[2] != -16, "test21 case 2 failed\n");
1716 FAILED(buf
[3] != 100, "test21 case 3 failed\n");
1718 sljit_free_code(code1
.code
, NULL
);
1719 sljit_free_code(code2
.code
, NULL
);
1723 static void test22(void)
1725 /* Test simple byte and half-int data transfers. */
1726 executable_code code
;
1727 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1733 printf("Run test22\n");
1735 FAILED(!compiler
, "cannot create compiler\n");
1755 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 3, 3, 0, 0, 0);
1757 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -13);
1758 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s16
), SLJIT_IMM
, 0x1234);
1759 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_s16
));
1760 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
1761 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 2 * sizeof(sljit_s16
));
1762 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s16
), SLJIT_MEM1(SLJIT_S1
), -(sljit_sw
)sizeof(sljit_s16
));
1763 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xff0000 + 8000);
1764 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
1765 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 1, SLJIT_R0
, 0);
1766 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R2
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 0x1234 - 3 * sizeof(sljit_s16
));
1767 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_R2
), 0x1234, SLJIT_IMM
, -9317);
1768 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 0x1234 + 4 * sizeof(sljit_s16
));
1769 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_R2
), -0x1234, SLJIT_IMM
, -9317);
1770 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R2
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 0x12348 - 5 * sizeof(sljit_s16
));
1771 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_R2
), 0x12348, SLJIT_IMM
, -8888);
1772 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 0x12348 + 6 * sizeof(sljit_s16
));
1773 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_R2
), -0x12348, SLJIT_IMM
, -8888);
1775 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_MEM1(SLJIT_S2
), 0, SLJIT_IMM
, -45);
1776 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_s8
), SLJIT_IMM
, 0x12);
1777 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4 * sizeof(sljit_s8
));
1778 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_s8
));
1779 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_S1
, 0, SLJIT_R1
, 0);
1780 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_S1
, 0, SLJIT_S1
, 0);
1781 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R2
, 0, SLJIT_S1
, 0);
1782 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R2
, 0);
1783 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S2
), 3 * sizeof(sljit_s8
), SLJIT_S1
, 0);
1784 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R0
), 0, SLJIT_R0
, 0);
1785 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
1786 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1787 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1788 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
1789 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1790 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1792 sljit_emit_return_void(compiler
);
1794 code
.code
= sljit_generate_code(compiler
);
1796 sljit_free_compiler(compiler
);
1798 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&sbuf
, (sljit_sw
)&bbuf
);
1799 FAILED(buf
[0] != -9, "test22 case 1 failed\n");
1800 FAILED(buf
[1] != -56, "test22 case 2 failed\n");
1801 FAILED(buf
[2] != 0, "test22 case 3 failed\n");
1802 FAILED(buf
[3] != 0, "test22 case 4 failed\n");
1804 FAILED(sbuf
[0] != -13, "test22 case 5 failed\n");
1805 FAILED(sbuf
[1] != 0x1234, "test22 case 6 failed\n");
1806 FAILED(sbuf
[3] != 0x1234, "test22 case 7 failed\n");
1807 FAILED(sbuf
[4] != 8000, "test22 case 8 failed\n");
1808 FAILED(sbuf
[5] != -9317, "test22 case 9 failed\n");
1809 FAILED(sbuf
[6] != -9317, "test22 case 10 failed\n");
1810 FAILED(sbuf
[7] != -8888, "test22 case 11 failed\n");
1811 FAILED(sbuf
[8] != -8888, "test22 case 12 failed\n");
1813 FAILED(bbuf
[0] != -45, "test22 case 13 failed\n");
1814 FAILED(bbuf
[1] != 0x12, "test22 case 14 failed\n");
1815 FAILED(bbuf
[3] != -56, "test22 case 15 failed\n");
1816 FAILED(bbuf
[4] != 4, "test22 case 16 failed\n");
1818 sljit_free_code(code
.code
, NULL
);
1822 static void test23(void)
1824 /* Test 32 bit / 64 bit signed / unsigned int transfer and conversion.
1825 This test has do real things on 64 bit systems, but works on 32 bit systems as well. */
1826 executable_code code
;
1827 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1832 sljit_u8 asbytes
[4];
1834 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1835 sljit_sw garbage
= SLJIT_W(0x1234567812345678);
1837 sljit_sw garbage
= 0x12345678;
1841 printf("Run test23\n");
1843 FAILED(!compiler
, "cannot create compiler\n");
1860 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, P
, P
), 3, 3, 0, 0, 0);
1861 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, 34567);
1862 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
1863 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), 0, SLJIT_IMM
, -7654);
1864 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1865 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_s32
));
1866 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
1867 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1868 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_s32
));
1869 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
1870 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, garbage
);
1871 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_s32
));
1872 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
1873 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1874 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x0f00f00);
1875 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x7777);
1876 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0x7777 + 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
1877 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x7777);
1878 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), -0x7777 + 4 * (sljit_sw
)sizeof(sljit_sw
), SLJIT_R0
, 0);
1879 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 5 * sizeof(sljit_sw
));
1880 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 1);
1881 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R1
), 0, SLJIT_IMM
, 16);
1882 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
1883 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1, SLJIT_IMM
, 64, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1);
1884 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&buf
[7], SLJIT_IMM
, 0x123456);
1885 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&buf
[6], SLJIT_MEM0(), (sljit_sw
)&buf
[7]);
1886 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 5 * sizeof(sljit_sw
));
1887 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_R1
, 0);
1888 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 7 * sizeof(sljit_sw
));
1889 sljit_emit_op2(compiler
, SLJIT_LSHR
, SLJIT_R2
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 1);
1890 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_MEM2(SLJIT_R2
, SLJIT_R2
), 0);
1891 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[8] - 0x12340);
1892 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0x12340, SLJIT_R2
, 0);
1893 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_R0
), 0x12340, SLJIT_MEM1(SLJIT_R2
), 3 * sizeof(sljit_sw
), SLJIT_IMM
, 6);
1894 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_s32
), SLJIT_IMM
, 0x12345678);
1895 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x2bd700 | 243);
1896 sljit_emit_return(compiler
, SLJIT_MOV_S8
, SLJIT_R1
, 0);
1898 code
.code
= sljit_generate_code(compiler
);
1900 sljit_free_compiler(compiler
);
1902 FAILED(code
.func2((sljit_sw
)&buf
, (sljit_sw
)&ibuf
) != -13, "test23 case 1 failed\n");
1903 FAILED(buf
[0] != -5791, "test23 case 2 failed\n");
1904 FAILED(buf
[1] != 43579, "test23 case 3 failed\n");
1905 FAILED(buf
[2] != 658923, "test23 case 4 failed\n");
1906 FAILED(buf
[3] != 0x0f00f00, "test23 case 5 failed\n");
1907 FAILED(buf
[4] != 0x0f00f00, "test23 case 6 failed\n");
1908 FAILED(buf
[5] != 80, "test23 case 7 failed\n");
1909 FAILED(buf
[6] != 0x123456, "test23 case 8 failed\n");
1910 FAILED(buf
[7] != (sljit_sw
)&buf
[5], "test23 case 9 failed\n");
1911 FAILED(buf
[8] != (sljit_sw
)&buf
[5] + 6, "test23 case 10 failed\n");
1913 FAILED(ibuf
[0] != 34567, "test23 case 11 failed\n");
1914 FAILED(ibuf
[1] != -7654, "test23 case 12 failed\n");
1916 #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1917 FAILED(u
.asbytes
[0] != 0x78, "test23 case 13 failed\n");
1918 FAILED(u
.asbytes
[1] != 0x56, "test23 case 14 failed\n");
1919 FAILED(u
.asbytes
[2] != 0x34, "test23 case 15 failed\n");
1920 FAILED(u
.asbytes
[3] != 0x12, "test23 case 16 failed\n");
1922 FAILED(u
.asbytes
[0] != 0x12, "test23 case 13 failed\n");
1923 FAILED(u
.asbytes
[1] != 0x34, "test23 case 14 failed\n");
1924 FAILED(u
.asbytes
[2] != 0x56, "test23 case 15 failed\n");
1925 FAILED(u
.asbytes
[3] != 0x78, "test23 case 16 failed\n");
1928 sljit_free_code(code
.code
, NULL
);
1932 static void test24(void)
1934 /* Some complicated addressing modes. */
1935 executable_code code
;
1936 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
1942 printf("Run test24\n");
1944 FAILED(!compiler
, "cannot create compiler\n");
1970 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 3, 3, 0, 0, 0);
1972 /* Nothing should be updated. */
1973 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM0(), (sljit_sw
)&sbuf
[1], SLJIT_MEM0(), (sljit_sw
)&sbuf
[0]);
1974 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_MEM0(), (sljit_sw
)&bbuf
[1], SLJIT_MEM0(), (sljit_sw
)&bbuf
[0]);
1975 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
1976 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), 1, SLJIT_MEM0(), (sljit_sw
)&sbuf
[3]);
1977 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[0]);
1978 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
1979 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
1980 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);
1981 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_s8
));
1982 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&bbuf
[1], SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)&bbuf
[2]);
1984 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, sizeof(sljit_s16
));
1985 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_MEM1(SLJIT_R1
), (sljit_sw
)&sbuf
[3], SLJIT_R1
, 0);
1987 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
1988 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
);
1989 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
1990 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_S0
, 0);
1991 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
);
1993 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 9 * sizeof(sljit_sw
));
1994 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 4 * sizeof(sljit_sw
));
1995 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -(4 << SLJIT_WORD_SHIFT
));
1996 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R2
), 0, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
1998 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
- 0x7fff8000 + 6 * (sljit_sw
)sizeof(sljit_sw
));
1999 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 952467);
2000 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0x7fff8000, SLJIT_R1
, 0);
2001 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0x7fff8000 + sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), 0x7fff8000);
2003 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
+ 0x7fff7fff + 6 * (sljit_sw
)sizeof(sljit_sw
));
2004 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff + 2 * (sljit_sw
)sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff + (sljit_sw
)sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff);
2005 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- 0x7fff7ffe + 3 * (sljit_sw
)sizeof(sljit_s8
));
2006 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_MEM1(SLJIT_R0
), 0x7fff7fff, SLJIT_MEM1(SLJIT_R0
), 0x7fff7ffe);
2007 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
+ 0x7fff7fff + 5 * (sljit_sw
)sizeof(sljit_s8
));
2008 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_MEM1(SLJIT_R0
), -0x7fff7fff, SLJIT_MEM1(SLJIT_R0
), -0x7fff8000);
2009 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2010 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- SLJIT_W(0x123456123456));
2011 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&bbuf
- SLJIT_W(0x123456123456));
2012 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_MEM1(SLJIT_R0
), SLJIT_W(0x123456123456) + 6 * sizeof(sljit_s8
), SLJIT_MEM1(SLJIT_R1
), SLJIT_W(0x123456123456));
2015 sljit_emit_return_void(compiler
);
2017 code
.code
= sljit_generate_code(compiler
);
2019 sljit_free_compiler(compiler
);
2021 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&sbuf
, (sljit_sw
)&bbuf
);
2022 FAILED(buf
[2] != 176366, "test24 case 1 failed\n");
2023 FAILED(buf
[3] != 64, "test24 case 2 failed\n");
2024 FAILED(buf
[4] != -100, "test24 case 3 failed\n");
2025 FAILED(buf
[5] != 100567, "test24 case 4 failed\n");
2026 FAILED(buf
[6] != 952467, "test24 case 5 failed\n");
2027 FAILED(buf
[7] != 952467, "test24 case 6 failed\n");
2028 FAILED(buf
[8] != 952467 * 2, "test24 case 7 failed\n");
2030 FAILED(sbuf
[1] != 30000, "test24 case 8 failed\n");
2031 FAILED(sbuf
[2] != -12345, "test24 case 9 failed\n");
2032 FAILED(sbuf
[4] != sizeof(sljit_s16
), "test24 case 10 failed\n");
2034 FAILED(bbuf
[1] != -128, "test24 case 11 failed\n");
2035 FAILED(bbuf
[2] != 99, "test24 case 12 failed\n");
2036 FAILED(bbuf
[4] != 99, "test24 case 13 failed\n");
2037 FAILED(bbuf
[5] != 99, "test24 case 14 failed\n");
2038 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2039 FAILED(bbuf
[6] != -128, "test24 case 15 failed\n");
2042 sljit_free_code(code
.code
, NULL
);
2046 static void test25(void)
2048 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2050 executable_code code
;
2051 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2055 printf("Run test25\n");
2057 FAILED(!compiler
, "cannot create compiler\n");
2073 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 0, 0, 0);
2075 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0);
2076 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 1 * sizeof(sljit_sw
), SLJIT_IMM
, 0x7fff);
2077 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_IMM
, -0x8000);
2078 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_IMM
, 0x7fffffff);
2079 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(-0x80000000));
2080 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x1234567887654321));
2081 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0xff80000000));
2082 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x3ff0000000));
2083 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_IMM
, (sljit_sw
)SLJIT_W(0xfffffff800100000));
2084 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_IMM
, (sljit_sw
)SLJIT_W(0xfffffff80010f000));
2085 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00000008001));
2086 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00080010000));
2087 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00080018001));
2088 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_IMM
, SLJIT_W(0x07fff00ffff00000));
2090 sljit_emit_return_void(compiler
);
2092 code
.code
= sljit_generate_code(compiler
);
2094 sljit_free_compiler(compiler
);
2096 code
.func1((sljit_sw
)&buf
);
2097 FAILED(buf
[0] != 0, "test25 case 1 failed\n");
2098 FAILED(buf
[1] != 0x7fff, "test25 case 2 failed\n");
2099 FAILED(buf
[2] != -0x8000, "test25 case 3 failed\n");
2100 FAILED(buf
[3] != 0x7fffffff, "test25 case 4 failed\n");
2101 FAILED(buf
[4] != SLJIT_W(-0x80000000), "test25 case 5 failed\n");
2102 FAILED(buf
[5] != SLJIT_W(0x1234567887654321), "test25 case 6 failed\n");
2103 FAILED(buf
[6] != SLJIT_W(0xff80000000), "test25 case 7 failed\n");
2104 FAILED(buf
[7] != SLJIT_W(0x3ff0000000), "test25 case 8 failed\n");
2105 FAILED((sljit_uw
)buf
[8] != SLJIT_W(0xfffffff800100000), "test25 case 9 failed\n");
2106 FAILED((sljit_uw
)buf
[9] != SLJIT_W(0xfffffff80010f000), "test25 case 10 failed\n");
2107 FAILED(buf
[10] != SLJIT_W(0x07fff00000008001), "test25 case 11 failed\n");
2108 FAILED(buf
[11] != SLJIT_W(0x07fff00080010000), "test25 case 12 failed\n");
2109 FAILED(buf
[12] != SLJIT_W(0x07fff00080018001), "test25 case 13 failed\n");
2110 FAILED(buf
[13] != SLJIT_W(0x07fff00ffff00000), "test25 case 14 failed\n");
2112 sljit_free_code(code
.code
, NULL
);
2117 static void test26(void)
2119 /* Aligned access without aligned offsets. */
2120 executable_code code
;
2121 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2127 printf("Run test26\n");
2129 FAILED(!compiler
, "cannot create compiler\n");
2146 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 3, 3, 0, 0, 0);
2148 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 3);
2149 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 1);
2150 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), -3);
2151 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s32
) - 1, SLJIT_R0
, 0);
2152 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), -1);
2153 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) - 3, SLJIT_R0
, 0);
2155 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 100);
2156 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)sizeof(sljit_sw
) * 2 - 103, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2 - 3, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 3 - 3);
2157 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 100);
2158 sljit_emit_op2(compiler
, SLJIT_MUL32
, SLJIT_MEM1(SLJIT_R0
), (sljit_sw
)sizeof(sljit_s32
) * 2 - 101, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s32
) * 2 - 1, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s32
) * 3 - 1);
2160 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
2161 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 3);
2162 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f64
) - 3, SLJIT_MEM1(SLJIT_S2
), -3);
2163 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f64
) * 2 - 3, SLJIT_MEM1(SLJIT_S2
), -3, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f64
) - 3);
2164 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 2);
2165 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sizeof(sljit_f64
) * 3 - 4) >> 1);
2166 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 1);
2167 sljit_emit_fop2(compiler
, SLJIT_DIV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
) * 3 - 5, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f64
) * 2 - 3, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 1);
2170 sljit_emit_return_void(compiler
);
2172 code
.code
= sljit_generate_code(compiler
);
2174 sljit_free_compiler(compiler
);
2176 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&ibuf
, (sljit_sw
)&dbuf
);
2178 FAILED(buf
[1] != -689, "test26 case 1 failed\n");
2179 FAILED(buf
[2] != -16, "test26 case 2 failed\n");
2180 FAILED(ibuf
[1] != -2789, "test26 case 3 failed\n");
2181 FAILED(ibuf
[2] != -18, "test26 case 4 failed\n");
2183 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
2184 FAILED(dbuf
[1] != 5.75, "test26 case 5 failed\n");
2185 FAILED(dbuf
[2] != 11.5, "test26 case 6 failed\n");
2186 FAILED(dbuf
[3] != -2.875, "test26 case 7 failed\n");
2189 sljit_free_code(code
.code
, NULL
);
2193 static void test27(void)
2195 #define SET_NEXT_BYTE(type) \
2196 cond_set(compiler, SLJIT_R2, 0, type); \
2197 sljit_emit_op1(compiler, SLJIT_MOV_U8, SLJIT_MEM1(SLJIT_S0), 1, SLJIT_R2, 0); \
2198 sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_S0, 0, SLJIT_S0, 0, SLJIT_IMM, 1);
2199 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2202 #define RESULT(i) (3 - i)
2205 /* Playing with conditional flags. */
2206 executable_code code
;
2207 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2210 #ifdef SLJIT_PREF_SHIFT_REG
2211 sljit_s32 shift_reg
= SLJIT_PREF_SHIFT_REG
;
2213 sljit_s32 shift_reg
= SLJIT_R2
;
2216 SLJIT_ASSERT(shift_reg
>= SLJIT_R2
&& shift_reg
<= SLJIT_R3
);
2219 printf("Run test27\n");
2221 for (i
= 0; i
< sizeof(buf
); ++i
)
2224 FAILED(!compiler
, "cannot create compiler\n");
2226 /* 3 arguments passed, 3 arguments used. */
2227 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 4, 3, 0, 0, 0);
2229 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
2231 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1001);
2232 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 20);
2233 /* 0x100100000 on 64 bit machines, 0x100000 on 32 bit machines. */
2234 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x800000);
2235 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2236 sljit_emit_op0(compiler
, SLJIT_ENDBR
); /* ENDBR should keep the flags. */
2237 sljit_emit_op0(compiler
, SLJIT_NOP
); /* Nop should keep the flags. */
2238 SET_NEXT_BYTE(SLJIT_GREATER
);
2239 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2240 SET_NEXT_BYTE(SLJIT_LESS
);
2241 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2242 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
2243 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2244 sljit_emit_op0(compiler
, SLJIT_ENDBR
); /* ENDBR should keep the flags. */
2245 sljit_emit_op0(compiler
, SLJIT_NOP
); /* Nop should keep the flags. */
2246 SET_NEXT_BYTE(SLJIT_GREATER
);
2247 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2248 SET_NEXT_BYTE(SLJIT_LESS
);
2250 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1000);
2251 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 20);
2252 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0x10);
2253 /* 0x100000010 on 64 bit machines, 0x10 on 32 bit machines. */
2254 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2255 SET_NEXT_BYTE(SLJIT_GREATER
);
2256 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2257 SET_NEXT_BYTE(SLJIT_LESS
);
2258 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2259 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2260 SET_NEXT_BYTE(SLJIT_GREATER
);
2261 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0x80);
2262 SET_NEXT_BYTE(SLJIT_LESS
);
2264 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2265 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2266 /* 0xff..ff on all machines. */
2267 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_LESS_EQUAL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2268 SET_NEXT_BYTE(SLJIT_LESS_EQUAL
);
2269 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER_EQUAL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2270 SET_NEXT_BYTE(SLJIT_GREATER_EQUAL
);
2271 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R2
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -1);
2272 SET_NEXT_BYTE(SLJIT_SIG_GREATER
);
2273 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -1);
2274 SET_NEXT_BYTE(SLJIT_SIG_LESS
);
2275 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R2
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
2276 SET_NEXT_BYTE(SLJIT_EQUAL
);
2277 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
2278 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2279 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -2);
2280 SET_NEXT_BYTE(SLJIT_OVERFLOW
);
2281 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -2);
2282 SET_NEXT_BYTE(SLJIT_NOT_OVERFLOW
);
2283 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -2);
2284 SET_NEXT_BYTE(SLJIT_GREATER_EQUAL
);
2285 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -2);
2286 SET_NEXT_BYTE(SLJIT_LESS_EQUAL
);
2287 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)((sljit_uw
)1 << ((8 * sizeof(sljit_uw
)) - 1)));
2288 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2289 SET_NEXT_BYTE(SLJIT_SIG_LESS
);
2290 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -1);
2291 SET_NEXT_BYTE(SLJIT_SIG_GREATER
);
2292 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2293 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -2);
2294 SET_NEXT_BYTE(SLJIT_SIG_GREATER_EQUAL
);
2295 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2);
2296 SET_NEXT_BYTE(SLJIT_SIG_GREATER
);
2298 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x80000000);
2299 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 16);
2300 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 16);
2301 /* 0x80..0 on 64 bit machines, 0 on 32 bit machines. */
2302 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)0xffffffff);
2303 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2304 SET_NEXT_BYTE(SLJIT_OVERFLOW
);
2305 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2306 SET_NEXT_BYTE(SLJIT_NOT_OVERFLOW
);
2307 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2308 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
2309 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2310 SET_NEXT_BYTE(SLJIT_OVERFLOW
);
2311 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2312 SET_NEXT_BYTE(SLJIT_NOT_OVERFLOW
);
2314 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2315 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2316 sljit_emit_op2u(compiler
, SLJIT_SUBC
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2317 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_R0
, 0, SLJIT_IMM
, 6, SLJIT_R0
, 0);
2318 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R0
, 0);
2319 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
2321 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
2322 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2323 sljit_emit_op2u(compiler
, SLJIT_ADDC
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2324 sljit_emit_op2(compiler
, SLJIT_ADDC
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 9);
2325 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R0
, 0);
2326 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
2328 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2329 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, (8 * sizeof(sljit_sw
)) - 1);
2330 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2331 SET_NEXT_BYTE(SLJIT_EQUAL
);
2332 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2333 SET_NEXT_BYTE(SLJIT_EQUAL
);
2335 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2336 sljit_emit_op2(compiler
, SLJIT_ASHR
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2337 SET_NEXT_BYTE(SLJIT_EQUAL
);
2338 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2339 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffffc0);
2340 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2341 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 0);
2342 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2343 sljit_emit_op2(compiler
, SLJIT_ASHR
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R0
, 0, shift_reg
, 0);
2344 SET_NEXT_BYTE(SLJIT_EQUAL
);
2345 sljit_emit_op1(compiler
, SLJIT_MOV
, shift_reg
, 0, SLJIT_IMM
, 0);
2346 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2347 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R0
, 0, shift_reg
, 0);
2348 SET_NEXT_BYTE(SLJIT_NOT_EQUAL
);
2350 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
2351 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2352 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0);
2353 sljit_emit_op2(compiler
, SLJIT_SUBC
| SLJIT_SET_CARRY
, SLJIT_R2
, 0, SLJIT_IMM
, 1, SLJIT_R0
, 0);
2354 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_R2
, 0);
2355 sljit_emit_op2u(compiler
, SLJIT_SUBC
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2356 sljit_emit_op2(compiler
, SLJIT_SUBC
, SLJIT_R2
, 0, SLJIT_IMM
, 1, SLJIT_R0
, 0);
2357 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 2, SLJIT_R2
, 0);
2358 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 2);
2360 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -34);
2361 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1234);
2362 SET_NEXT_BYTE(SLJIT_LESS
);
2363 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1234);
2364 SET_NEXT_BYTE(SLJIT_SIG_LESS
);
2365 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2366 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x12300000000) - 43);
2368 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, -43);
2370 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -96);
2371 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2372 SET_NEXT_BYTE(SLJIT_LESS
);
2373 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2374 SET_NEXT_BYTE(SLJIT_SIG_GREATER
);
2376 sljit_emit_return_void(compiler
);
2378 code
.code
= sljit_generate_code(compiler
);
2380 sljit_free_compiler(compiler
);
2382 code
.func1((sljit_sw
)&buf
);
2384 FAILED(buf
[0] != RESULT(1), "test27 case 1 failed\n");
2385 FAILED(buf
[1] != RESULT(2), "test27 case 2 failed\n");
2386 FAILED(buf
[2] != 2, "test27 case 3 failed\n");
2387 FAILED(buf
[3] != 1, "test27 case 4 failed\n");
2388 FAILED(buf
[4] != RESULT(1), "test27 case 5 failed\n");
2389 FAILED(buf
[5] != RESULT(2), "test27 case 6 failed\n");
2390 FAILED(buf
[6] != 2, "test27 case 7 failed\n");
2391 FAILED(buf
[7] != 1, "test27 case 8 failed\n");
2393 FAILED(buf
[8] != 2, "test27 case 9 failed\n");
2394 FAILED(buf
[9] != 1, "test27 case 10 failed\n");
2395 FAILED(buf
[10] != 2, "test27 case 11 failed\n");
2396 FAILED(buf
[11] != 1, "test27 case 12 failed\n");
2397 FAILED(buf
[12] != 1, "test27 case 13 failed\n");
2398 FAILED(buf
[13] != 2, "test27 case 14 failed\n");
2399 FAILED(buf
[14] != 2, "test27 case 15 failed\n");
2400 FAILED(buf
[15] != 1, "test27 case 16 failed\n");
2401 FAILED(buf
[16] != 1, "test27 case 17 failed\n");
2402 FAILED(buf
[17] != 2, "test27 case 18 failed\n");
2403 FAILED(buf
[18] != 1, "test27 case 19 failed\n");
2404 FAILED(buf
[19] != 1, "test27 case 20 failed\n");
2405 FAILED(buf
[20] != 1, "test27 case 21 failed\n");
2406 FAILED(buf
[21] != 2, "test27 case 22 failed\n");
2408 FAILED(buf
[22] != RESULT(1), "test27 case 23 failed\n");
2409 FAILED(buf
[23] != RESULT(2), "test27 case 24 failed\n");
2410 FAILED(buf
[24] != 2, "test27 case 25 failed\n");
2411 FAILED(buf
[25] != 1, "test27 case 26 failed\n");
2413 FAILED(buf
[26] != 5, "test27 case 27 failed\n");
2414 FAILED(buf
[27] != 9, "test27 case 28 failed\n");
2416 FAILED(buf
[28] != 2, "test27 case 29 failed\n");
2417 FAILED(buf
[29] != 1, "test27 case 30 failed\n");
2419 FAILED(buf
[30] != 1, "test27 case 31 failed\n");
2420 FAILED(buf
[31] != 1, "test27 case 32 failed\n");
2421 FAILED(buf
[32] != 1, "test27 case 33 failed\n");
2422 FAILED(buf
[33] != 1, "test27 case 34 failed\n");
2424 FAILED(buf
[34] != 1, "test27 case 35 failed\n");
2425 FAILED(buf
[35] != 0, "test27 case 36 failed\n");
2427 FAILED(buf
[36] != 2, "test27 case 37 failed\n");
2428 FAILED(buf
[37] != 1, "test27 case 38 failed\n");
2429 FAILED(buf
[38] != 2, "test27 case 39 failed\n");
2430 FAILED(buf
[39] != 1, "test27 case 40 failed\n");
2431 FAILED(buf
[40] != 10, "test27 case 41 failed\n");
2433 sljit_free_code(code
.code
, NULL
);
2435 #undef SET_NEXT_BYTE
2439 static void test28(void)
2442 executable_code code
;
2443 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2444 struct sljit_const
* const1
= NULL
;
2445 struct sljit_label
* label
= NULL
;
2446 sljit_uw label_addr
= 0;
2450 printf("Run test28\n");
2452 FAILED(!compiler
, "cannot create compiler\n");
2460 FAILED(!compiler
, "cannot create compiler\n");
2461 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 5, 5, 0, 0, 0);
2462 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -234);
2463 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
));
2464 sljit_emit_op2(compiler
, SLJIT_MUL
, SLJIT_S3
, 0, SLJIT_R3
, 0, SLJIT_R4
, 0);
2465 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_S3
, 0);
2466 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_S3
, 0, SLJIT_IMM
, 0);
2467 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_NOT_ZERO
);
2468 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_S3
, 0);
2469 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
));
2470 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S4
, 0, SLJIT_S4
, 0, SLJIT_R4
, 0);
2471 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_S4
, 0);
2473 const1
= sljit_emit_const(compiler
, SLJIT_S3
, 0, 0);
2474 sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_S3
, 0);
2475 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S3
, 0, SLJIT_S3
, 0, SLJIT_IMM
, 100);
2476 label
= sljit_emit_label(compiler
);
2477 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
2478 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_S3
, 0);
2480 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R4
, 0);
2482 code
.code
= sljit_generate_code(compiler
);
2485 label_addr
= sljit_get_label_addr(label
);
2486 sljit_set_const(sljit_get_const_addr(const1
), (sljit_sw
)label_addr
, sljit_get_executable_offset(compiler
));
2488 sljit_free_compiler(compiler
);
2490 FAILED(code
.func1((sljit_sw
)&buf
) != 8, "test28 case 1 failed\n");
2491 FAILED(buf
[1] != -1872, "test28 case 2 failed\n");
2492 FAILED(buf
[2] != 1, "test28 case 3 failed\n");
2493 FAILED(buf
[3] != 2, "test28 case 4 failed\n");
2494 FAILED(buf
[4] != (sljit_sw
)label_addr
, "test28 case 5 failed\n");
2496 sljit_free_code(code
.code
, NULL
);
2500 static void test29(void)
2502 /* Test signed/unsigned bytes and halfs. */
2503 executable_code code
;
2504 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2509 printf("Run test29\n");
2511 for (i
= 0; i
< 25; i
++)
2514 FAILED(!compiler
, "cannot create compiler\n");
2515 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 5, 5, 0, 0, 0);
2517 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R0
, 0, SLJIT_IMM
, -187);
2518 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
2519 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R0
, 0, SLJIT_IMM
, -605);
2520 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_R0
, 0);
2521 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_R0
, 0, SLJIT_IMM
, -56);
2522 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2523 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_R4
, 0, SLJIT_IMM
, 0xcde5);
2524 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2526 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_IMM
, -45896);
2527 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2528 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_IMM
, -1472797);
2529 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2530 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_R0
, 0, SLJIT_IMM
, -12890);
2531 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2532 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_R4
, 0, SLJIT_IMM
, 0x9cb0a6);
2533 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2535 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2536 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-3580429715));
2537 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2538 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-100722768662));
2539 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2540 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-1457052677972));
2541 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2542 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R4
, 0, SLJIT_IMM
, SLJIT_W(0xcef97a70b5));
2543 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2546 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -187);
2547 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2548 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2549 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -605);
2550 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2551 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2552 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -56);
2553 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2554 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2555 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0xcde5);
2556 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2557 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2559 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -45896);
2560 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2561 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2562 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1472797);
2563 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2564 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2565 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -12890);
2566 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2567 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2568 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x9cb0a6);
2569 sljit_emit_op1(compiler
, SLJIT_MOV_U16
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2570 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 19 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2572 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2573 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(-3580429715));
2574 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R1
, 0);
2575 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2576 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, SLJIT_W(-100722768662));
2577 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_S2
, 0);
2578 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 21 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2579 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, SLJIT_W(-1457052677972));
2580 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R2
, 0);
2581 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 22 * sizeof(sljit_uw
), SLJIT_R0
, 0);
2582 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_W(0xcef97a70b5));
2583 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R4
, 0, SLJIT_R3
, 0);
2584 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 23 * sizeof(sljit_uw
), SLJIT_R4
, 0);
2587 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 0x9faa5);
2588 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_S2
, 0, SLJIT_S2
, 0);
2589 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 24 * sizeof(sljit_uw
), SLJIT_S2
, 0);
2591 sljit_emit_return_void(compiler
);
2593 code
.code
= sljit_generate_code(compiler
);
2595 sljit_free_compiler(compiler
);
2597 code
.func1((sljit_sw
)&buf
);
2598 FAILED(buf
[0] != 69, "test29 case 1 failed\n");
2599 FAILED(buf
[1] != -93, "test29 case 2 failed\n");
2600 FAILED(buf
[2] != 200, "test29 case 3 failed\n");
2601 FAILED(buf
[3] != 0xe5, "test29 case 4 failed\n");
2602 FAILED(buf
[4] != 19640, "test29 case 5 failed\n");
2603 FAILED(buf
[5] != -31005, "test29 case 6 failed\n");
2604 FAILED(buf
[6] != 52646, "test29 case 7 failed\n");
2605 FAILED(buf
[7] != 0xb0a6, "test29 case 8 failed\n");
2607 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2608 FAILED(buf
[8] != SLJIT_W(714537581), "test29 case 9 failed\n");
2609 FAILED(buf
[9] != SLJIT_W(-1938520854), "test29 case 10 failed\n");
2610 FAILED(buf
[10] != SLJIT_W(3236202668), "test29 case 11 failed\n");
2611 FAILED(buf
[11] != SLJIT_W(0xf97a70b5), "test29 case 12 failed\n");
2614 FAILED(buf
[12] != 69, "test29 case 13 failed\n");
2615 FAILED(buf
[13] != -93, "test29 case 14 failed\n");
2616 FAILED(buf
[14] != 200, "test29 case 15 failed\n");
2617 FAILED(buf
[15] != 0xe5, "test29 case 16 failed\n");
2618 FAILED(buf
[16] != 19640, "test29 case 17 failed\n");
2619 FAILED(buf
[17] != -31005, "test29 case 18 failed\n");
2620 FAILED(buf
[18] != 52646, "test29 case 19 failed\n");
2621 FAILED(buf
[19] != 0xb0a6, "test29 case 20 failed\n");
2623 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2624 FAILED(buf
[20] != SLJIT_W(714537581), "test29 case 21 failed\n");
2625 FAILED(buf
[21] != SLJIT_W(-1938520854), "test29 case 22 failed\n");
2626 FAILED(buf
[22] != SLJIT_W(3236202668), "test29 case 23 failed\n");
2627 FAILED(buf
[23] != SLJIT_W(0xf97a70b5), "test29 case 24 failed\n");
2630 FAILED(buf
[24] != -91, "test29 case 25 failed\n");
2632 sljit_free_code(code
.code
, NULL
);
2636 static void test30(void)
2638 /* Test unused results. */
2639 executable_code code
;
2640 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2644 printf("Run test30\n");
2646 FAILED(!compiler
, "cannot create compiler\n");
2648 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 5, 5, 0, 0, 0);
2650 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
2651 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2652 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 1);
2653 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 1);
2654 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, 1);
2655 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2656 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_S1
, 0, SLJIT_IMM
, SLJIT_W(-0x123ffffffff));
2658 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_S1
, 0, SLJIT_IMM
, 1);
2660 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 1);
2661 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 1);
2662 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, 1);
2664 /* Some calculations with unused results. */
2665 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
2666 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_GREATER_EQUAL
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
2667 sljit_emit_op2u(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_S0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
2668 sljit_emit_op2u(compiler
, SLJIT_SHL
| SLJIT_SET_Z
, SLJIT_S3
, 0, SLJIT_R2
, 0);
2669 sljit_emit_op2u(compiler
, SLJIT_LSHR
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 5);
2670 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_IMM
, 0xff);
2672 /* Testing that any change happens. */
2673 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2674 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R2
, 0);
2675 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R3
, 0);
2676 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R4
, 0);
2677 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_S1
, 0, SLJIT_S1
, 0);
2678 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S1
, 0);
2679 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S2
, 0);
2680 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S3
, 0);
2681 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0, SLJIT_S4
, 0);
2683 sljit_emit_return_void(compiler
);
2685 code
.code
= sljit_generate_code(compiler
);
2687 sljit_free_compiler(compiler
);
2689 code
.func1((sljit_sw
)&buf
);
2690 FAILED(buf
[0] != 9, "test30 case 1 failed\n");
2692 sljit_free_code(code
.code
, NULL
);
2696 static void test31(void)
2698 /* Integer mul and set flags. */
2699 executable_code code
;
2700 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2703 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2704 sljit_sw big_word
= SLJIT_W(0x7fffffff00000000);
2705 sljit_sw big_word2
= SLJIT_W(0x7fffffff00000012);
2707 sljit_sw big_word
= 0x7fffffff;
2708 sljit_sw big_word2
= 0x00000012;
2712 printf("Run test31\n");
2714 for (i
= 0; i
< 12; i
++)
2717 FAILED(!compiler
, "cannot create compiler\n");
2719 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 5, 0, 0, 0);
2720 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
2721 sljit_emit_op2u(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_IMM
, -45);
2722 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_NOT_OVERFLOW
);
2723 sljit_emit_op2u(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_IMM
, -45);
2724 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_OVERFLOW
);
2726 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, big_word
);
2727 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, -2);
2728 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 33); /* Should not change flags. */
2729 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0); /* Should not change flags. */
2730 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
2731 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, -2);
2732 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_NOT_OVERFLOW
);
2734 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_S3
, 0, SLJIT_IMM
, 0x3f6b0);
2735 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_S4
, 0, SLJIT_IMM
, 0x2a783);
2736 sljit_emit_op2(compiler
, SLJIT_MUL32
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_S3
, 0, SLJIT_S4
, 0);
2737 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
2738 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
2740 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, big_word2
);
2741 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_R1
, 0);
2742 sljit_emit_op2(compiler
, SLJIT_MUL32
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 23);
2743 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
2745 sljit_emit_op2u(compiler
, SLJIT_MUL32
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_IMM
, -23);
2746 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_NOT_OVERFLOW
);
2747 sljit_emit_op2u(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_IMM
, -23);
2748 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_NOT_OVERFLOW
);
2750 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 67);
2751 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, -23);
2752 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R1
, 0);
2754 sljit_emit_return_void(compiler
);
2756 code
.code
= sljit_generate_code(compiler
);
2758 sljit_free_compiler(compiler
);
2760 code
.func1((sljit_sw
)&buf
);
2762 FAILED(buf
[0] != 1, "test31 case 1 failed\n");
2763 FAILED(buf
[1] != 2, "test31 case 2 failed\n");
2764 /* Qemu issues for 64 bit muls. */
2765 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2766 FAILED(buf
[2] != 1, "test31 case 3 failed\n");
2767 FAILED(buf
[3] != 2, "test31 case 4 failed\n");
2769 FAILED(buf
[4] != 1, "test31 case 5 failed\n");
2770 FAILED((buf
[5] & (sljit_sw
)0xffffffff) != (sljit_sw
)0x85540c10, "test31 case 6 failed\n");
2771 FAILED(buf
[6] != 2, "test31 case 7 failed\n");
2772 FAILED(buf
[7] != 1, "test31 case 8 failed\n");
2773 #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2774 FAILED(buf
[8] != 1, "test31 case 9 failed\n");
2776 FAILED(buf
[9] != -1541, "test31 case 10 failed\n");
2778 sljit_free_code(code
.code
, NULL
);
2782 static void test32(void)
2784 /* Floating point set flags. */
2785 executable_code code
;
2786 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2799 printf("Run test32\n");
2801 for (i
= 0; i
< 16; i
++)
2805 dbuf
[0].u
.value1
= 0x7fffffff;
2806 dbuf
[0].u
.value2
= 0x7fffffff;
2807 dbuf
[1].u
.value1
= 0x7fffffff;
2808 dbuf
[1].u
.value2
= 0x7fffffff;
2809 dbuf
[2].value
= -13.0;
2810 dbuf
[3].value
= 27.0;
2812 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
2814 printf("no fpu available, test32 skipped\n");
2817 sljit_free_compiler(compiler
);
2821 FAILED(!compiler
, "cannot create compiler\n");
2822 SLJIT_ASSERT(sizeof(sljit_f64
) == 8 && sizeof(sljit_s32
) == 4 && sizeof(dbuf
[0]) == 8);
2824 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 1, 2, 4, 0, 0);
2826 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
2827 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_UNORDERED
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
2828 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f64
));
2829 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_UNORDERED
);
2830 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_ORDERED
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
2831 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_ORDERED
);
2833 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
));
2834 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_UNORDERED
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2835 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_UNORDERED
);
2836 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_ORDERED
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2837 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_ORDERED
);
2838 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_LESS
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2839 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_F_LESS
);
2840 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_GREATER_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2841 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_F_GREATER_EQUAL
);
2842 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_GREATER
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2843 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_F_GREATER
);
2844 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_LESS_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2845 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_F_LESS_EQUAL
);
2846 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2847 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_F_EQUAL
);
2848 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_NOT_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
2849 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_F_NOT_EQUAL
);
2851 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_FR3
, 0, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
));
2852 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_UNORDERED
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
));
2853 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_UNORDERED
);
2854 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_F_EQUAL
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
));
2855 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_F_EQUAL
);
2857 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_ORDERED
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
), SLJIT_FR0
, 0);
2858 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_ORDERED
);
2860 sljit_emit_fop1(compiler
, SLJIT_CMP_F64
| SLJIT_SET_UNORDERED
, SLJIT_FR3
, 0, SLJIT_FR2
, 0);
2861 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
2862 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_UNORDERED
);
2864 sljit_emit_return_void(compiler
);
2866 code
.code
= sljit_generate_code(compiler
);
2868 sljit_free_compiler(compiler
);
2870 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&dbuf
);
2872 FAILED(buf
[0] != 1, "test32 case 1 failed\n");
2873 FAILED(buf
[1] != 2, "test32 case 2 failed\n");
2874 FAILED(buf
[2] != 2, "test32 case 3 failed\n");
2875 FAILED(buf
[3] != 1, "test32 case 4 failed\n");
2876 FAILED(buf
[4] != 1, "test32 case 5 failed\n");
2877 FAILED(buf
[5] != 2, "test32 case 6 failed\n");
2878 FAILED(buf
[6] != 2, "test32 case 7 failed\n");
2879 FAILED(buf
[7] != 1, "test32 case 8 failed\n");
2880 FAILED(buf
[8] != 2, "test32 case 9 failed\n");
2881 FAILED(buf
[9] != 1, "test32 case 10 failed\n");
2882 FAILED(buf
[10] != 2, "test32 case 11 failed\n");
2883 FAILED(buf
[11] != 1, "test32 case 12 failed\n");
2884 FAILED(buf
[12] != 2, "test32 case 13 failed\n");
2885 FAILED(buf
[13] != 1, "test32 case 14 failed\n");
2887 sljit_free_code(code
.code
, NULL
);
2891 static void test33(void)
2893 /* Test setting multiple flags. */
2894 executable_code code
;
2895 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
2896 struct sljit_jump
* jump
;
2900 printf("Run test33\n");
2913 FAILED(!compiler
, "cannot create compiler\n");
2915 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 3, 0, 0, 0);
2917 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 20);
2918 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 10);
2919 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_R2
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2920 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_ZERO
);
2921 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -10);
2922 jump
= sljit_emit_jump(compiler
, SLJIT_LESS
);
2923 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_IMM
, 11);
2924 sljit_set_label(jump
, sljit_emit_label(compiler
));
2926 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_SIG_GREATER
, SLJIT_R2
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2927 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_SIG_GREATER
);
2928 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_IMM
, 45);
2929 jump
= sljit_emit_jump(compiler
, SLJIT_NOT_EQUAL
);
2930 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_IMM
, 55);
2931 sljit_set_label(jump
, sljit_emit_label(compiler
));
2933 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2934 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)SLJIT_W(0x8000000000000000));
2936 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)SLJIT_W(0x80000000));
2938 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
2939 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2940 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, 33);
2941 jump
= sljit_emit_jump(compiler
, SLJIT_NOT_OVERFLOW
);
2942 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_ZERO
);
2943 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, 13);
2944 sljit_set_label(jump
, sljit_emit_label(compiler
));
2946 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x80000000);
2947 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_R0
, 0);
2948 sljit_emit_op2(compiler
, SLJIT_SUB32
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2949 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
2950 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_NOT_ZERO
);
2951 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, 78);
2952 jump
= sljit_emit_jump(compiler
, SLJIT_OVERFLOW
);
2953 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_IMM
, 48);
2954 sljit_set_label(jump
, sljit_emit_label(compiler
));
2956 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2957 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)SLJIT_W(0x8000000000000000));
2959 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)SLJIT_W(0x80000000));
2961 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
2962 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_Z
| SLJIT_SET_OVERFLOW
, SLJIT_R2
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
2963 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_IMM
, 30);
2964 jump
= sljit_emit_jump(compiler
, SLJIT_NOT_OVERFLOW
);
2965 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_IMM
, 50);
2966 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_ZERO
);
2967 sljit_set_label(jump
, sljit_emit_label(compiler
));
2969 sljit_emit_return_void(compiler
);
2971 code
.code
= sljit_generate_code(compiler
);
2973 sljit_free_compiler(compiler
);
2975 code
.func1((sljit_sw
)&buf
);
2977 FAILED(buf
[0] != 0, "test33 case 1 failed\n");
2978 FAILED(buf
[1] != 11, "test33 case 2 failed\n");
2979 FAILED(buf
[2] != 1, "test33 case 3 failed\n");
2980 FAILED(buf
[3] != 45, "test33 case 4 failed\n");
2981 FAILED(buf
[4] != 13, "test33 case 5 failed\n");
2982 FAILED(buf
[5] != 0, "test33 case 6 failed\n");
2983 FAILED(buf
[6] != 0, "test33 case 7 failed\n");
2984 FAILED(buf
[7] != 48, "test33 case 8 failed\n");
2985 FAILED(buf
[8] != 50, "test33 case 9 failed\n");
2986 FAILED(buf
[9] != 1, "test33 case 10 failed\n");
2988 sljit_free_code(code
.code
, NULL
);
2992 static void test34(void)
2994 /* Test fast calls. */
2995 executable_code codeA
;
2996 executable_code codeB
;
2997 executable_code codeC
;
2998 executable_code codeD
;
2999 executable_code codeE
;
3000 executable_code codeF
;
3001 struct sljit_compiler
* compiler
;
3002 struct sljit_jump
*jump
;
3003 struct sljit_label
* label
;
3008 printf("Run test34\n");
3014 compiler
= sljit_create_compiler(NULL
, NULL
);
3015 FAILED(!compiler
, "cannot create compiler\n");
3016 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3018 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3019 sljit_emit_fast_enter(compiler
, SLJIT_R1
, 0);
3020 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 4);
3021 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_R1
, 0);
3023 codeA
.code
= sljit_generate_code(compiler
);
3025 sljit_free_compiler(compiler
);
3028 compiler
= sljit_create_compiler(NULL
, NULL
);
3029 FAILED(!compiler
, "cannot create compiler\n");
3030 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3032 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3033 sljit_emit_fast_enter(compiler
, SLJIT_R4
, 0);
3034 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 6);
3035 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(codeA
.code
));
3036 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_R1
, 0);
3037 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_R4
, 0);
3039 codeB
.code
= sljit_generate_code(compiler
);
3041 sljit_free_compiler(compiler
);
3044 compiler
= sljit_create_compiler(NULL
, NULL
);
3045 FAILED(!compiler
, "cannot create compiler\n");
3046 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3048 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3049 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_p
));
3050 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3051 jump
= sljit_emit_jump(compiler
, SLJIT_FAST_CALL
| SLJIT_REWRITABLE_JUMP
);
3052 sljit_set_target(jump
, SLJIT_FUNC_UADDR(codeB
.code
));
3053 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_p
));
3055 codeC
.code
= sljit_generate_code(compiler
);
3057 sljit_free_compiler(compiler
);
3060 compiler
= sljit_create_compiler(NULL
, NULL
);
3061 FAILED(!compiler
, "cannot create compiler\n");
3062 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3064 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3065 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_SP
), 0);
3066 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 10);
3067 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_ADDR(codeC
.code
));
3068 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_MEM1(SLJIT_SP
), 0);
3070 codeD
.code
= sljit_generate_code(compiler
);
3072 sljit_free_compiler(compiler
);
3075 compiler
= sljit_create_compiler(NULL
, NULL
);
3076 FAILED(!compiler
, "cannot create compiler\n");
3077 sljit_set_context(compiler
, 0, 1, 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3079 sljit_emit_fast_enter(compiler
, SLJIT_MEM1(SLJIT_S0
), 0);
3080 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 12);
3081 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
), SLJIT_IMM
, SLJIT_FUNC_ADDR(codeD
.code
));
3082 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
));
3083 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_MEM1(SLJIT_S0
), 0);
3085 codeE
.code
= sljit_generate_code(compiler
);
3087 sljit_free_compiler(compiler
);
3090 compiler
= sljit_create_compiler(NULL
, NULL
);
3091 FAILED(!compiler
, "cannot create compiler\n");
3093 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 5, 5, 0, 0, 2 * sizeof(sljit_p
));
3094 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3095 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_ADDR(codeE
.code
));
3096 label
= sljit_emit_label(compiler
);
3097 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
3099 codeF
.code
= sljit_generate_code(compiler
);
3101 addr
= sljit_get_label_addr(label
);
3102 sljit_free_compiler(compiler
);
3104 FAILED(codeF
.func1((sljit_sw
)&buf
) != 40, "test34 case 1 failed\n");
3105 FAILED(buf
[0] != addr
- SLJIT_RETURN_ADDRESS_OFFSET
, "test34 case 2 failed\n");
3107 sljit_free_code(codeA
.code
, NULL
);
3108 sljit_free_code(codeB
.code
, NULL
);
3109 sljit_free_code(codeC
.code
, NULL
);
3110 sljit_free_code(codeD
.code
, NULL
);
3111 sljit_free_code(codeE
.code
, NULL
);
3112 sljit_free_code(codeF
.code
, NULL
);
3116 static void test35(void)
3118 /* More complicated tests for fast calls. */
3119 executable_code codeA
;
3120 executable_code codeB
;
3121 executable_code codeC
;
3122 struct sljit_compiler
* compiler
;
3123 struct sljit_jump
*jump
= NULL
;
3124 struct sljit_label
* label
;
3125 sljit_sw executable_offset
;
3126 sljit_uw return_addr
;
3127 sljit_uw jump_addr
= 0;
3131 printf("Run test35\n");
3136 compiler
= sljit_create_compiler(NULL
, NULL
);
3137 FAILED(!compiler
, "cannot create compiler\n");
3138 sljit_set_context(compiler
, 0, 0, 2, 2, 0, 0, 0);
3140 sljit_emit_fast_enter(compiler
, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
3141 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3143 jump
= sljit_emit_jump(compiler
, SLJIT_FAST_CALL
| SLJIT_REWRITABLE_JUMP
);
3144 sljit_set_target(jump
, 0);
3146 label
= sljit_emit_label(compiler
);
3147 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_MEM0(), (sljit_sw
)&buf
[0]);
3149 codeA
.code
= sljit_generate_code(compiler
);
3151 executable_offset
= sljit_get_executable_offset(compiler
);
3152 jump_addr
= sljit_get_jump_addr(jump
);
3153 sljit_free_compiler(compiler
);
3156 compiler
= sljit_create_compiler(NULL
, NULL
);
3157 FAILED(!compiler
, "cannot create compiler\n");
3158 sljit_set_context(compiler
, 0, 0, 2, 2, 0, 0, 0);
3160 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3161 sljit_emit_fast_enter(compiler
, SLJIT_R1
, 0);
3162 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 7);
3163 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_R1
, 0);
3165 codeB
.code
= sljit_generate_code(compiler
);
3167 sljit_free_compiler(compiler
);
3169 sljit_set_jump_addr(jump_addr
, SLJIT_FUNC_UADDR(codeB
.code
), executable_offset
);
3172 compiler
= sljit_create_compiler(NULL
, NULL
);
3173 FAILED(!compiler
, "cannot create compiler\n");
3175 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 2, 2, 0, 0, 0);
3176 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3177 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_ADDR(codeA
.code
));
3178 label
= sljit_emit_label(compiler
);
3179 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
3181 codeC
.code
= sljit_generate_code(compiler
);
3183 return_addr
= sljit_get_label_addr(label
);
3184 sljit_free_compiler(compiler
);
3186 FAILED(codeC
.func0() != 12, "test35 case 1 failed\n");
3187 FAILED(buf
[0] != return_addr
- SLJIT_RETURN_ADDRESS_OFFSET
, "test35 case 2 failed\n");
3189 sljit_free_code(codeA
.code
, NULL
);
3190 sljit_free_code(codeB
.code
, NULL
);
3191 sljit_free_code(codeC
.code
, NULL
);
3195 static void cmp_test(struct sljit_compiler
*compiler
, sljit_s32 type
, sljit_s32 src1
, sljit_sw src1w
, sljit_s32 src2
, sljit_sw src2w
)
3197 /* 2 = true, 1 = false */
3198 struct sljit_jump
* jump
;
3199 struct sljit_label
* label
;
3201 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_IMM
, 2);
3202 jump
= sljit_emit_cmp(compiler
, type
, src1
, src1w
, src2
, src2w
);
3203 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 1, SLJIT_IMM
, 1);
3204 label
= sljit_emit_label(compiler
);
3205 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
3206 sljit_set_label(jump
, label
);
3207 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
3210 #define TEST_CASES (7 + 10 + 12 + 11 + 4)
3211 static void test36(void)
3213 /* Compare instruction. */
3214 executable_code code
;
3215 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3217 sljit_s8 buf
[TEST_CASES
];
3218 sljit_s8 compare_buf
[TEST_CASES
] = {
3219 1, 1, 2, 2, 1, 2, 2,
3220 1, 1, 2, 2, 2, 1, 2, 2, 1, 1,
3221 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2,
3222 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2,
3229 printf("Run test36\n");
3231 FAILED(!compiler
, "cannot create compiler\n");
3232 for (i
= 0; i
< TEST_CASES
; ++i
)
3239 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 3, 2, 0, 0, 0);
3240 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
3242 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 13);
3243 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 15);
3244 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_IMM
, 9, SLJIT_R0
, 0);
3245 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3246 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
3247 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_IMM
, -13);
3248 cmp_test(compiler
, SLJIT_NOT_EQUAL
, SLJIT_IMM
, 0, SLJIT_R0
, 0);
3249 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3250 cmp_test(compiler
, SLJIT_NOT_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 0, SLJIT_R0
, 0);
3251 cmp_test(compiler
, SLJIT_EQUAL
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
);
3252 cmp_test(compiler
, SLJIT_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3254 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, 0);
3255 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -8);
3256 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3257 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3258 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3259 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3260 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3261 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
));
3262 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_IMM
, 0, SLJIT_R1
, 0);
3263 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
));
3264 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3265 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 0, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3267 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3268 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3269 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
));
3270 cmp_test(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3271 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
3272 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
3273 cmp_test(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3274 cmp_test(compiler
, SLJIT_GREATER_EQUAL
| SLJIT_REWRITABLE_JUMP
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3275 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_IMM
, 8, SLJIT_R1
, 0);
3276 cmp_test(compiler
, SLJIT_LESS_EQUAL
, SLJIT_IMM
, 7, SLJIT_R0
, 0);
3277 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_IMM
, 1, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
));
3278 cmp_test(compiler
, SLJIT_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3279 cmp_test(compiler
, SLJIT_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3280 cmp_test(compiler
, SLJIT_GREATER
| SLJIT_REWRITABLE_JUMP
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3282 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -3);
3283 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3284 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3285 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3286 cmp_test(compiler
, SLJIT_SIG_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3287 cmp_test(compiler
, SLJIT_SIG_LESS
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -1);
3288 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_REWRITABLE_JUMP
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_IMM
, -1);
3289 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3290 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3291 cmp_test(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_IMM
, -4, SLJIT_R0
, 0);
3292 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_IMM
, -1, SLJIT_R1
, 0);
3293 cmp_test(compiler
, SLJIT_SIG_GREATER
| SLJIT_REWRITABLE_JUMP
, SLJIT_R1
, 0, SLJIT_IMM
, -1);
3295 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3296 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xf00000004));
3297 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
3298 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
3299 cmp_test(compiler
, SLJIT_LESS
| SLJIT_32
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
3300 cmp_test(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3301 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xff0000004));
3302 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_R0
, 0);
3303 cmp_test(compiler
, SLJIT_SIG_GREATER
| SLJIT_32
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
3304 cmp_test(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3306 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
3307 cmp_test(compiler
, SLJIT_LESS
| SLJIT_32
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3308 cmp_test(compiler
, SLJIT_GREATER
| SLJIT_32
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3309 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0xf0000004);
3310 cmp_test(compiler
, SLJIT_SIG_GREATER
| SLJIT_32
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3311 cmp_test(compiler
, SLJIT_SIG_LESS
| SLJIT_32
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
3314 sljit_emit_return_void(compiler
);
3316 code
.code
= sljit_generate_code(compiler
);
3318 sljit_free_compiler(compiler
);
3320 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&data
);
3322 for (i
= 0; i
< TEST_CASES
; ++i
)
3323 if (SLJIT_UNLIKELY(buf
[i
] != compare_buf
[i
])) {
3324 printf("test36 case %d failed\n", i
+ 1);
3328 sljit_free_code(code
.code
, NULL
);
3333 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3334 #define BITN(n) (SLJIT_W(1) << (63 - (n)))
3337 #define BITN(n) (1 << (31 - ((n) & 0x1f)))
3338 #define RESN(n) ((n) & 0x1f)
3341 static void test37(void)
3343 /* Test count leading zeroes. */
3344 executable_code code
;
3345 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3351 printf("Run test37\n");
3353 FAILED(!compiler
, "cannot create compiler\n");
3355 for (i
= 0; i
< 9; i
++)
3361 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 1, 3, 0, 0, 0);
3362 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, BITN(27));
3363 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
3364 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, BITN(47));
3365 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_R0
, 0, SLJIT_S2
, 0);
3366 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
3367 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
));
3368 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3369 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3370 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3371 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3372 sljit_emit_op1(compiler
, SLJIT_CLZ32
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_R0
, 0);
3373 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
3374 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
));
3375 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3376 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, BITN(58));
3377 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3378 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
3379 sljit_emit_op1(compiler
, SLJIT_CLZ
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3380 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3381 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xff08a00000));
3383 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x08a00000);
3385 sljit_emit_op1(compiler
, SLJIT_CLZ32
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s32
), SLJIT_R0
, 0);
3386 sljit_emit_op1(compiler
, SLJIT_CLZ32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3387 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3388 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3389 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xffc8a00000));
3391 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0xc8a00000);
3393 sljit_emit_op1(compiler
, SLJIT_CLZ32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3394 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3396 sljit_emit_return_void(compiler
);
3398 code
.code
= sljit_generate_code(compiler
);
3400 sljit_free_compiler(compiler
);
3402 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&ibuf
);
3403 FAILED(buf
[0] != RESN(27), "test37 case 1 failed\n");
3404 FAILED(buf
[1] != RESN(47), "test37 case 2 failed\n");
3405 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3406 FAILED(buf
[2] != 64, "test37 case 3 failed\n");
3408 FAILED(buf
[2] != 32, "test37 case 3 failed\n");
3410 FAILED(buf
[3] != 0, "test37 case 4 failed\n");
3411 FAILED(ibuf
[0] != 32, "test37 case 5 failed\n");
3412 FAILED(buf
[4] != RESN(13), "test37 case 6 failed\n");
3413 FAILED(buf
[5] != RESN(58), "test37 case 7 failed\n");
3414 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3415 FAILED(buf
[6] != 64, "test37 case 8 failed\n");
3417 FAILED(buf
[6] != 32, "test37 case 8 failed\n");
3419 FAILED(ibuf
[1] != 4, "test37 case 9 failed\n");
3421 FAILED((buf
[7] & (sljit_sw
)0xffffffff) != 4, "test37 case 10 failed\n");
3422 FAILED((buf
[8] & (sljit_sw
)0xffffffff) != 0, "test37 case 11 failed\n");
3424 sljit_free_code(code
.code
, NULL
);
3430 static void test38(void)
3432 #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
3433 /* Test stack utility. */
3434 executable_code code
;
3435 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3436 struct sljit_jump
* alloc1_fail
;
3437 struct sljit_jump
* alloc2_fail
;
3438 struct sljit_jump
* alloc3_fail
;
3439 struct sljit_jump
* sanity1_fail
;
3440 struct sljit_jump
* sanity2_fail
;
3441 struct sljit_jump
* sanity3_fail
;
3442 struct sljit_jump
* sanity4_fail
;
3443 struct sljit_jump
* jump
;
3444 struct sljit_label
* label
;
3447 printf("Run test38\n");
3449 FAILED(!compiler
, "cannot create compiler\n");
3451 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 3, 1, 0, 0, 0);
3453 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8192);
3454 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 65536);
3455 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0);
3456 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(P
, W
, W
, P
), SLJIT_IMM
, SLJIT_FUNC_ADDR(sljit_allocate_stack
));
3457 alloc1_fail
= sljit_emit_cmp(compiler
, SLJIT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3458 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_RETURN_REG
, 0);
3460 /* Write 8k data. */
3461 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, start
));
3462 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8192);
3463 label
= sljit_emit_label(compiler
);
3464 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_IMM
, -1);
3465 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
3466 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3467 sljit_set_label(jump
, label
);
3470 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3471 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, end
), SLJIT_IMM
, 65536);
3472 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS2(P
, P
, P
), SLJIT_IMM
, SLJIT_FUNC_ADDR(sljit_stack_resize
));
3473 alloc2_fail
= sljit_emit_cmp(compiler
, SLJIT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3474 sanity1_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, start
));
3476 /* Write 64k data. */
3477 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, start
));
3478 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 65536);
3479 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, min_start
));
3480 sanity2_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_R0
, 0, SLJIT_R2
, 0);
3481 label
= sljit_emit_label(compiler
);
3482 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_IMM
, -1);
3483 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
3484 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3485 sljit_set_label(jump
, label
);
3488 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3489 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, end
), SLJIT_IMM
, 32768);
3490 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS2(P
, P
, P
), SLJIT_IMM
, SLJIT_FUNC_ADDR(sljit_stack_resize
));
3491 alloc3_fail
= sljit_emit_cmp(compiler
, SLJIT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 0);
3492 sanity3_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_RETURN_REG
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, start
));
3494 /* Write 32k data. */
3495 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, start
));
3496 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_S0
), SLJIT_OFFSETOF(struct sljit_stack
, end
));
3497 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R2
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 32768);
3498 sanity4_fail
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_R0
, 0, SLJIT_R2
, 0);
3499 label
= sljit_emit_label(compiler
);
3500 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_IMM
, -1);
3501 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_sw
));
3502 jump
= sljit_emit_cmp(compiler
, SLJIT_LESS
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3503 sljit_set_label(jump
, label
);
3505 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
3506 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3507 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS2(VOID
, P
, P
), SLJIT_IMM
, SLJIT_FUNC_ADDR(sljit_free_stack
));
3509 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, 4567);
3511 label
= sljit_emit_label(compiler
);
3512 sljit_set_label(alloc1_fail
, label
);
3513 sljit_set_label(alloc2_fail
, label
);
3514 sljit_set_label(alloc3_fail
, label
);
3515 sljit_set_label(sanity1_fail
, label
);
3516 sljit_set_label(sanity2_fail
, label
);
3517 sljit_set_label(sanity3_fail
, label
);
3518 sljit_set_label(sanity4_fail
, label
);
3519 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, 0);
3521 code
.code
= sljit_generate_code(compiler
);
3523 sljit_free_compiler(compiler
);
3525 /* Just survive this. */
3526 FAILED(code
.func0() != 4567, "test38 case 1 failed\n");
3528 sljit_free_code(code
.code
, NULL
);
3533 static void test39(void)
3535 /* Test error handling. */
3536 executable_code code
;
3537 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3538 struct sljit_jump
* jump
;
3541 printf("Run test39\n");
3543 FAILED(!compiler
, "cannot create compiler\n");
3545 /* Such assignment should never happen in a regular program. */
3546 compiler
->error
= -3967;
3548 SLJIT_ASSERT(sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, W
, W
), 5, 5, 6, 0, 32) == -3967);
3549 SLJIT_ASSERT(sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R1
, 0) == -3967);
3550 SLJIT_ASSERT(sljit_emit_op0(compiler
, SLJIT_NOP
) == -3967);
3551 SLJIT_ASSERT(sljit_emit_op0(compiler
, SLJIT_ENDBR
) == -3967);
3552 SLJIT_ASSERT(sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1) == -3967);
3553 SLJIT_ASSERT(sljit_emit_op2(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R0
), 64, SLJIT_MEM1(SLJIT_S0
), -64) == -3967);
3554 SLJIT_ASSERT(sljit_emit_fop1(compiler
, SLJIT_ABS_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_R1
), 0) == -3967);
3555 SLJIT_ASSERT(sljit_emit_fop2(compiler
, SLJIT_DIV_F64
, SLJIT_FR2
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_S0
), 0, SLJIT_FR2
, 0) == -3967);
3556 SLJIT_ASSERT(!sljit_emit_label(compiler
));
3557 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, 32, P
, F32
, F64
));
3558 SLJIT_ASSERT(!jump
);
3559 sljit_set_label(jump
, (struct sljit_label
*)0x123450);
3560 sljit_set_target(jump
, 0x123450);
3561 jump
= sljit_emit_cmp(compiler
, SLJIT_SIG_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3562 SLJIT_ASSERT(!jump
);
3563 SLJIT_ASSERT(sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_MEM1(SLJIT_R0
), 8) == -3967);
3564 SLJIT_ASSERT(sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_OVERFLOW
) == -3967);
3565 SLJIT_ASSERT(!sljit_emit_const(compiler
, SLJIT_R0
, 0, 99));
3567 SLJIT_ASSERT(!compiler
->labels
&& !compiler
->jumps
&& !compiler
->consts
);
3568 SLJIT_ASSERT(!compiler
->last_label
&& !compiler
->last_jump
&& !compiler
->last_const
);
3569 SLJIT_ASSERT(!compiler
->buf
->next
&& !compiler
->buf
->used_size
);
3570 SLJIT_ASSERT(!compiler
->abuf
->next
&& !compiler
->abuf
->used_size
);
3572 sljit_set_compiler_memory_error(compiler
);
3573 FAILED(sljit_get_compiler_error(compiler
) != -3967, "test39 case 1 failed\n");
3575 code
.code
= sljit_generate_code(compiler
);
3576 FAILED(sljit_get_compiler_error(compiler
) != -3967, "test39 case 2 failed\n");
3577 FAILED(!!code
.code
, "test39 case 3 failed\n");
3578 sljit_free_compiler(compiler
);
3580 compiler
= sljit_create_compiler(NULL
, NULL
);
3581 FAILED(!compiler
, "cannot create compiler\n");
3583 FAILED(sljit_get_compiler_error(compiler
) != SLJIT_SUCCESS
, "test39 case 4 failed\n");
3584 sljit_set_compiler_memory_error(compiler
);
3585 FAILED(sljit_get_compiler_error(compiler
) != SLJIT_ERR_ALLOC_FAILED
, "test39 case 5 failed\n");
3586 sljit_free_compiler(compiler
);
3591 static void test40(void)
3593 /* Test emit_op_flags. */
3594 executable_code code
;
3595 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3599 printf("Run test40\n");
3601 FAILED(!compiler
, "cannot create compiler\n");
3613 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 4, 0, 0, sizeof(sljit_sw
));
3615 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -5);
3616 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_IMM
, -6, SLJIT_R0
, 0);
3617 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x123456);
3618 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_R1
, 0, SLJIT_SIG_LESS
);
3619 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
3621 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -13);
3622 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_IMM
, -13, SLJIT_R0
, 0);
3623 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 0);
3624 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_EQUAL
);
3625 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_NOT_EQUAL
);
3626 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_SP
), 0);
3627 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_IMM
, -13, SLJIT_R0
, 0);
3628 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
3629 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_EQUAL
);
3630 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 2, SLJIT_EQUAL
);
3632 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -13);
3633 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3);
3634 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
3635 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_SIG_LESS
);
3637 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -8);
3638 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 33);
3639 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3640 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0);
3641 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_Z
, SLJIT_R2
, 0, SLJIT_GREATER
);
3642 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_S1
, 0, SLJIT_EQUAL
);
3643 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_R1
, 0);
3644 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 0x88);
3645 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_S3
, 0, SLJIT_NOT_EQUAL
);
3646 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 4, SLJIT_S1
, 0);
3647 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 5, SLJIT_S3
, 0);
3649 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x84);
3650 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_IMM
, 0x180, SLJIT_R0
, 0);
3651 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 6, SLJIT_EQUAL
);
3652 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 7, SLJIT_EQUAL
);
3654 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3655 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3656 sljit_emit_op_flags(compiler
, SLJIT_OR
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_NOT_EQUAL
);
3657 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 8, SLJIT_NOT_EQUAL
);
3659 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x123456);
3660 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
3661 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_GREATER
);
3662 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
) * 9, SLJIT_R0
, 0);
3664 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 0xbaddead);
3665 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0);
3667 code
.code
= sljit_generate_code(compiler
);
3669 sljit_free_compiler(compiler
);
3671 FAILED(code
.func1((sljit_sw
)&buf
) != 0xbaddead, "test40 case 1 failed\n");
3672 FAILED(buf
[0] != 0x123457, "test40 case 2 failed\n");
3673 FAILED(buf
[1] != 1, "test40 case 3 failed\n");
3674 FAILED(buf
[2] != 0, "test40 case 4 failed\n");
3675 FAILED(buf
[3] != -7, "test40 case 5 failed\n");
3676 FAILED(buf
[4] != 0, "test40 case 6 failed\n");
3677 FAILED(buf
[5] != 0x89, "test40 case 7 failed\n");
3678 FAILED(buf
[6] != 0, "test40 case 8 failed\n");
3679 FAILED(buf
[7] != 1, "test40 case 9 failed\n");
3680 FAILED(buf
[8] != 1, "test40 case 10 failed\n");
3681 FAILED(buf
[9] != 0x123457, "test40 case 11 failed\n");
3683 sljit_free_code(code
.code
, NULL
);
3687 static void test41(void)
3689 /* Test inline assembly. */
3690 executable_code code
;
3691 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3694 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3696 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3704 printf("Run test41\n");
3706 #if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3707 SLJIT_ASSERT(sljit_has_cpu_feature(SLJIT_HAS_VIRTUAL_REGISTERS
) == 0);
3710 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
3711 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3712 if (SLJIT_R(i
) >= SLJIT_R3
&& SLJIT_R(i
) <= SLJIT_R8
) {
3713 SLJIT_ASSERT(sljit_get_register_index(SLJIT_R(i
)) == -1);
3717 SLJIT_ASSERT(sljit_get_register_index(SLJIT_R(i
)) >= 0 && sljit_get_register_index(SLJIT_R(i
)) < 64);
3720 FAILED(!compiler
, "cannot create compiler\n");
3721 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, W
, W
), 3, 3, 0, 0, 0);
3723 /* Returns with the sum of SLJIT_S0 and SLJIT_S1. */
3724 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3725 /* lea SLJIT_RETURN_REG, [SLJIT_S0, SLJIT_S1] */
3728 inst
[2] = (sljit_u8
)(0x04 | ((sljit_get_register_index(SLJIT_RETURN_REG
) & 0x7) << 3));
3729 inst
[3] = (sljit_u8
)((sljit_get_register_index(SLJIT_S0
) & 0x7)
3730 | ((sljit_get_register_index(SLJIT_S1
) & 0x7) << 3));
3731 sljit_emit_op_custom(compiler
, inst
, 4);
3732 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3733 /* lea SLJIT_RETURN_REG, [SLJIT_S0, SLJIT_S1] */
3734 inst
[0] = 0x48; /* REX_W */
3736 reg
= sljit_get_register_index(SLJIT_RETURN_REG
);
3737 inst
[2] = (sljit_u8
)(0x04 | ((reg
& 0x7) << 3));
3739 inst
[0] |= 0x04; /* REX_R */
3740 reg
= sljit_get_register_index(SLJIT_S0
);
3741 inst
[3] = (sljit_u8
)(reg
& 0x7);
3743 inst
[0] |= 0x01; /* REX_B */
3744 reg
= sljit_get_register_index(SLJIT_S1
);
3745 inst
[3] = (sljit_u8
)(inst
[3] | ((reg
& 0x7) << 3));
3747 inst
[0] |= 0x02; /* REX_X */
3748 sljit_emit_op_custom(compiler
, inst
, 4);
3749 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
3750 /* add rd, rn, rm */
3751 inst
= 0xe0800000 | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 12)
3752 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 16)
3753 | (sljit_u32
)sljit_get_register_index(SLJIT_S1
);
3754 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3755 #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
3756 /* add rd, rn, rm */
3757 inst
= 0xeb000000 | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 8)
3758 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 16)
3759 | (sljit_u32
)sljit_get_register_index(SLJIT_S1
);
3760 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3761 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
3762 /* add rd, rn, rm */
3763 inst
= 0x8b000000 | (sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
)
3764 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 5)
3765 | ((sljit_u32
)sljit_get_register_index(SLJIT_S1
) << 16);
3766 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3767 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
3768 /* add rD, rA, rB */
3769 inst
= (31 << 26) | (266 << 1) | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 21)
3770 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 16)
3771 | ((sljit_u32
)sljit_get_register_index(SLJIT_S1
) << 11);
3772 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3773 #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
3774 /* addu rd, rs, rt */
3775 inst
= 33 | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 11)
3776 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 21)
3777 | ((sljit_u32
)sljit_get_register_index(SLJIT_S1
) << 16);
3778 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3779 #elif (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
3780 /* daddu rd, rs, rt */
3781 inst
= 45 | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 11)
3782 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 21)
3783 | ((sljit_u32
)sljit_get_register_index(SLJIT_S1
) << 16);
3784 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3785 #elif (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV)
3786 /* add rd, rs1, rs2 */
3787 inst
= 0x33 | (0 << 12) | (0 << 25) | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 7)
3788 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 15)
3789 | ((sljit_u32
)sljit_get_register_index(SLJIT_S1
) << 20);
3790 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3791 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3792 /* add rd, rs1, rs2 */
3793 inst
= (0x2u
<< 30) | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 25)
3794 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 14)
3795 | (sljit_u32
)sljit_get_register_index(SLJIT_S1
);
3796 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3797 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
3798 /* agrk rd, rs1, rs2 */
3799 inst
= (0xb9e8u
<< 16)
3800 | ((sljit_u32
)sljit_get_register_index(SLJIT_RETURN_REG
) << 4)
3801 | ((sljit_u32
)sljit_get_register_index(SLJIT_S0
) << 12)
3802 | (sljit_u32
)sljit_get_register_index(SLJIT_S1
);
3803 sljit_emit_op_custom(compiler
, &inst
, sizeof(inst
));
3806 sljit_emit_op_custom(compiler
, &inst
, 0);
3809 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
3811 code
.code
= sljit_generate_code(compiler
);
3813 sljit_free_compiler(compiler
);
3815 FAILED(code
.func2(32, -11) != 21, "test41 case 1 failed\n");
3816 FAILED(code
.func2(1000, 234) != 1234, "test41 case 2 failed\n");
3817 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3818 FAILED(code
.func2(SLJIT_W(0x20f0a04090c06070), SLJIT_W(0x020f0a04090c0607)) != SLJIT_W(0x22ffaa4499cc6677), "test41 case 3 failed\n");
3821 sljit_free_code(code
.code
, NULL
);
3823 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
3828 compiler
= sljit_create_compiler(NULL
, NULL
);
3829 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, 2, 0, 0);
3830 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
3831 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
3832 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3837 inst
[3] = (sljit_u8
)(0xc0 | (sljit_get_float_register_index(SLJIT_FR0
) << 3)
3838 | sljit_get_float_register_index(SLJIT_FR1
));
3839 sljit_emit_op_custom(compiler
, inst
, 4);
3840 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3842 if (sljit_get_float_register_index(SLJIT_FR0
) > 7 || sljit_get_float_register_index(SLJIT_FR1
) > 7) {
3844 if (sljit_get_float_register_index(SLJIT_FR0
) > 7)
3845 inst
[0] |= 0x04; /* REX_R */
3846 if (sljit_get_float_register_index(SLJIT_FR1
) > 7)
3847 inst
[0] |= 0x01; /* REX_B */
3851 inst
[4] = (sljit_u8
)(0xc0 | ((sljit_get_float_register_index(SLJIT_FR0
) & 0x7) << 3)
3852 | (sljit_get_float_register_index(SLJIT_FR1
) & 0x7));
3853 sljit_emit_op_custom(compiler
, inst
, 5);
3859 inst
[3] = (sljit_u8
)(0xc0 | (sljit_get_float_register_index(SLJIT_FR0
) << 3)
3860 | sljit_get_float_register_index(SLJIT_FR1
));
3861 sljit_emit_op_custom(compiler
, inst
, 4);
3863 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32)
3864 /* vadd.f64 dd, dn, dm */
3865 inst
= 0xee300b00 | (((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) >> 1) << 12)
3866 | (((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) >> 1) << 16)
3867 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
) >> 1);
3868 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3869 #elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
3870 /* fadd rd, rn, rm */
3871 inst
= 0x1e602800 | (sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
)
3872 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 5)
3873 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
) << 16);
3874 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3875 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
3876 /* fadd frD, frA, frB */
3877 inst
= (63u << 26) | (21u << 1) | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 21)
3878 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 16)
3879 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
) << 11);
3880 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3881 #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
3882 /* add.d fd, fs, ft */
3883 inst
= (17u << 26) | (17u << 21) | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 6)
3884 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 11)
3885 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
) << 16);
3886 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3887 #elif (defined SLJIT_CONFIG_RISCV && SLJIT_CONFIG_RISCV)
3888 /* fadd.d rd, rs1, rs2 */
3889 inst
= (0x1u
<< 25) | (0x7u
<< 12) | (0x53u
)
3890 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 7)
3891 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 15)
3892 | (sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
) << 20;
3893 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3894 #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3895 /* faddd rd, rs1, rs2 */
3896 inst
= (0x2u
<< 30) | (0x34u
<< 19) | (0x42u
<< 5)
3897 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 25)
3898 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 14)
3899 | (sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
);
3900 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3901 #elif (defined SLJIT_CONFIG_S390X && SLJIT_CONFIG_S390X)
3904 | ((sljit_u32
)sljit_get_float_register_index(SLJIT_FR0
) << 4)
3905 | (sljit_u32
)sljit_get_float_register_index(SLJIT_FR1
);
3906 sljit_emit_op_custom(compiler
, &inst
, sizeof(sljit_u32
));
3908 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
3909 sljit_emit_return_void(compiler
);
3911 code
.code
= sljit_generate_code(compiler
);
3913 sljit_free_compiler(compiler
);
3915 code
.func1((sljit_sw
)&buf
);
3916 FAILED(buf
[2] != 11.25, "test41 case 4 failed\n");
3918 sljit_free_code(code
.code
, NULL
);
3924 static void test42(void)
3926 /* Test long multiply and division. */
3927 executable_code code
;
3928 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
3930 sljit_sw buf
[7 + 4 + 8 + 8];
3933 printf("Run test42\n");
3935 FAILED(!compiler
, "cannot create compiler\n");
3936 for (i
= 0; i
< 7 + 4 + 8 + 8; i
++)
3939 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 5, 5, 0, 0, 0);
3941 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -0x1fb308a);
3942 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0xf50c873);
3943 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, 0x8a0475b);
3944 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 0x9dc849b);
3945 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -0x7c69a35);
3946 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, 0x5a4d0c4);
3947 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S4
, 0, SLJIT_IMM
, 0x9a3b06d);
3949 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3950 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3951 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3952 sljit_emit_op0(compiler
, SLJIT_LMUL_UW
);
3953 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3954 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3956 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3957 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3958 sljit_emit_op0(compiler
, SLJIT_LMUL_SW
);
3959 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3960 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3962 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3963 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3964 sljit_emit_op0(compiler
, SLJIT_DIVMOD_UW
);
3965 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3966 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3968 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x5dc4f897b8cd67f5));
3969 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3f8b5c026cb088df));
3970 sljit_emit_op0(compiler
, SLJIT_DIVMOD_SW
);
3971 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3972 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3974 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x5cf783d3cf0a74b0));
3975 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3d5df42d03a28fc7));
3976 sljit_emit_op0(compiler
, SLJIT_DIVMOD_U32
);
3977 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3978 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
3979 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3980 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3982 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x371df5197ba26a28));
3983 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x46c78a5cfd6a420c));
3984 sljit_emit_op0(compiler
, SLJIT_DIVMOD_S32
);
3985 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
3986 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
3987 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3988 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3990 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)SLJIT_W(0xc456f048c28a611b));
3991 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x3d4af2c543));
3992 sljit_emit_op0(compiler
, SLJIT_DIV_UW
);
3993 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 19 * sizeof(sljit_sw
), SLJIT_R0
, 0);
3994 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_sw
), SLJIT_R1
, 0);
3996 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(-0x720fa4b74c329b14));
3997 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0xa64ae42b7d6));
3998 sljit_emit_op0(compiler
, SLJIT_DIV_SW
);
3999 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 21 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4000 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 22 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4002 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x4af51c027b34));
4003 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(0x9ba4ff2906b14));
4004 sljit_emit_op0(compiler
, SLJIT_DIV_U32
);
4005 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4006 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
4007 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 23 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4008 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 24 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4010 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0xc40b58a3f20d));
4011 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_W(-0xa63c923));
4012 sljit_emit_op0(compiler
, SLJIT_DIV_S32
);
4013 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4014 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
4015 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 25 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4016 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 26 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4019 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
4020 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
4021 sljit_emit_op0(compiler
, SLJIT_LMUL_UW
);
4022 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4023 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4025 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
4026 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
4027 sljit_emit_op0(compiler
, SLJIT_LMUL_SW
);
4028 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4029 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4031 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
4032 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
4033 sljit_emit_op0(compiler
, SLJIT_DIVMOD_UW
);
4034 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4035 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4037 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58cd67f5);
4038 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x3cb088df);
4039 sljit_emit_op0(compiler
, SLJIT_DIVMOD_SW
);
4040 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4041 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4043 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0xcf0a74b0);
4044 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 0x03a28fc7);
4045 sljit_emit_op0(compiler
, SLJIT_DIVMOD_U32
);
4046 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4047 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4049 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x7ba26a28);
4050 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)0xfd6a420c);
4051 sljit_emit_op0(compiler
, SLJIT_DIVMOD_S32
);
4052 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4053 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4055 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x9d4b7036);
4056 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0xb86d0);
4057 sljit_emit_op0(compiler
, SLJIT_DIV_UW
);
4058 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 19 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4059 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4061 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -0x58b0692c);
4062 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0xd357);
4063 sljit_emit_op0(compiler
, SLJIT_DIV_SW
);
4064 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 21 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4065 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 22 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4067 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1c027b34);
4068 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)0xf2906b14);
4069 sljit_emit_op0(compiler
, SLJIT_DIV_U32
);
4070 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4071 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
4072 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 23 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4073 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 24 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4075 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0x58a3f20d);
4076 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -0xa63c923);
4077 sljit_emit_op0(compiler
, SLJIT_DIV_S32
);
4078 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4079 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R1
, 0, SLJIT_R1
, 0);
4080 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 25 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4081 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 26 * sizeof(sljit_sw
), SLJIT_R1
, 0);
4084 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R2
, 0);
4085 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R3
, 0);
4086 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R4
, 0);
4087 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_S1
, 0);
4088 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_S2
, 0);
4089 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_S3
, 0);
4090 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_S4
, 0);
4092 sljit_emit_return_void(compiler
);
4094 code
.code
= sljit_generate_code(compiler
);
4096 sljit_free_compiler(compiler
);
4098 code
.func1((sljit_sw
)&buf
);
4100 FAILED(buf
[0] != -0x1fb308a, "test42 case 1 failed\n");
4101 FAILED(buf
[1] != 0xf50c873, "test42 case 2 failed\n");
4102 FAILED(buf
[2] != 0x8a0475b, "test42 case 3 failed\n");
4103 FAILED(buf
[3] != 0x9dc849b, "test42 case 4 failed\n");
4104 FAILED(buf
[4] != -0x7c69a35, "test42 case 5 failed\n");
4105 FAILED(buf
[5] != 0x5a4d0c4, "test42 case 6 failed\n");
4106 FAILED(buf
[6] != 0x9a3b06d, "test42 case 7 failed\n");
4108 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4109 FAILED(buf
[7] != SLJIT_W(-4388959407985636971), "test42 case 8 failed\n");
4110 FAILED(buf
[8] != SLJIT_W(2901680654366567099), "test42 case 9 failed\n");
4111 FAILED(buf
[9] != SLJIT_W(-4388959407985636971), "test42 case 10 failed\n");
4112 FAILED(buf
[10] != SLJIT_W(-1677173957268872740), "test42 case 11 failed\n");
4113 FAILED(buf
[11] != SLJIT_W(2), "test42 case 12 failed\n");
4114 FAILED(buf
[12] != SLJIT_W(2532236178951865933), "test42 case 13 failed\n");
4115 FAILED(buf
[13] != SLJIT_W(-1), "test42 case 14 failed\n");
4116 FAILED(buf
[14] != SLJIT_W(-2177944059851366166), "test42 case 15 failed\n");
4118 FAILED(buf
[7] != -1587000939, "test42 case 8 failed\n");
4119 FAILED(buf
[8] != 665003983, "test42 case 9 failed\n");
4120 FAILED(buf
[9] != -1587000939, "test42 case 10 failed\n");
4121 FAILED(buf
[10] != -353198352, "test42 case 11 failed\n");
4122 FAILED(buf
[11] != 2, "test42 case 12 failed\n");
4123 FAILED(buf
[12] != 768706125, "test42 case 13 failed\n");
4124 FAILED(buf
[13] != -1, "test42 case 14 failed\n");
4125 FAILED(buf
[14] != -471654166, "test42 case 15 failed\n");
4128 FAILED(buf
[15] != 56, "test42 case 16 failed\n");
4129 FAILED(buf
[16] != 58392872, "test42 case 17 failed\n");
4130 FAILED(buf
[17] != -47, "test42 case 18 failed\n");
4131 FAILED(buf
[18] != 35949148, "test42 case 19 failed\n");
4133 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4134 FAILED(buf
[19] != SLJIT_W(0x3340bfc), "test42 case 20 failed\n");
4135 FAILED(buf
[20] != SLJIT_W(0x3d4af2c543), "test42 case 21 failed\n");
4136 FAILED(buf
[21] != SLJIT_W(-0xaf978), "test42 case 22 failed\n");
4137 FAILED(buf
[22] != SLJIT_W(0xa64ae42b7d6), "test42 case 23 failed\n");
4139 FAILED(buf
[19] != SLJIT_W(0xda5), "test42 case 20 failed\n");
4140 FAILED(buf
[20] != SLJIT_W(0xb86d0), "test42 case 21 failed\n");
4141 FAILED(buf
[21] != SLJIT_W(-0x6b6e), "test42 case 22 failed\n");
4142 FAILED(buf
[22] != SLJIT_W(0xd357), "test42 case 23 failed\n");
4145 FAILED(buf
[23] != 0x0, "test42 case 24 failed\n");
4146 FAILED(buf
[24] != (sljit_sw
)0xf2906b14, "test42 case 25 failed\n");
4147 FAILED(buf
[25] != -0x8, "test42 case 26 failed\n");
4148 FAILED(buf
[26] != -0xa63c923, "test42 case 27 failed\n");
4150 sljit_free_code(code
.code
, NULL
);
4154 static void test43(void)
4156 /* Test floating point compare. */
4157 executable_code code
;
4158 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4159 struct sljit_jump
* jump
;
4170 printf("Run test43\n");
4172 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
4174 printf("no fpu available, test43 skipped\n");
4177 sljit_free_compiler(compiler
);
4181 FAILED(!compiler
, "cannot create compiler\n");
4183 dbuf
[0].value
= 12.125;
4185 dbuf
[1].u
.value1
= 0x7fffffff;
4186 dbuf
[1].u
.value2
= 0x7fffffff;
4187 dbuf
[2].value
= -13.5;
4188 dbuf
[3].value
= 12.125;
4190 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 1, 1, 3, 0, 0);
4191 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
4192 /* dbuf[0] < dbuf[2] -> -2 */
4193 jump
= sljit_emit_fcmp(compiler
, SLJIT_F_GREATER_EQUAL
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_F64_SHIFT
);
4194 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, -2);
4196 sljit_set_label(jump
, sljit_emit_label(compiler
));
4197 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4198 /* dbuf[0] and dbuf[1] is not NaN -> 5 */
4199 jump
= sljit_emit_fcmp(compiler
, SLJIT_UNORDERED
, SLJIT_MEM0(), (sljit_sw
)&dbuf
[1], SLJIT_FR1
, 0);
4200 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, 5);
4202 sljit_set_label(jump
, sljit_emit_label(compiler
));
4203 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f64
));
4204 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, 11);
4205 /* dbuf[0] == dbuf[3] -> 11 */
4206 jump
= sljit_emit_fcmp(compiler
, SLJIT_F_EQUAL
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_FR2
, 0);
4209 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0, SLJIT_IMM
, -17);
4210 sljit_set_label(jump
, sljit_emit_label(compiler
));
4211 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4213 code
.code
= sljit_generate_code(compiler
);
4215 sljit_free_compiler(compiler
);
4217 FAILED(code
.func1((sljit_sw
)&dbuf
) != 11, "test43 case 1 failed\n");
4219 FAILED(code
.func1((sljit_sw
)&dbuf
) != -17, "test43 case 2 failed\n");
4221 FAILED(code
.func1((sljit_sw
)&dbuf
) != 5, "test43 case 3 failed\n");
4223 FAILED(code
.func1((sljit_sw
)&dbuf
) != -2, "test43 case 4 failed\n");
4225 sljit_free_code(code
.code
, NULL
);
4229 static void test44(void)
4232 executable_code code
;
4233 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4237 printf("Run test44\n");
4239 FAILED(!compiler
, "cannot create compiler\n");
4246 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(P
, P
), 3, 2, 0, 0, 0);
4248 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4249 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_p
), SLJIT_R0
, 0);
4250 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_p
));
4251 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 2);
4252 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R1
), SLJIT_POINTER_SHIFT
, SLJIT_R0
, 0);
4253 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, sizeof(sljit_p
));
4254 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3 << SLJIT_POINTER_SHIFT
);
4255 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_S0
, 0);
4256 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 0, SLJIT_R0
, 0);
4257 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_p
));
4258 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 1 << SLJIT_POINTER_SHIFT
);
4259 sljit_emit_op1(compiler
, SLJIT_MOV_P
, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 2, SLJIT_R0
, 0);
4261 sljit_emit_return(compiler
, SLJIT_MOV_P
, SLJIT_R0
, 0);
4263 code
.code
= sljit_generate_code(compiler
);
4265 sljit_free_compiler(compiler
);
4267 FAILED(code
.func1((sljit_sw
)&buf
) != (sljit_sw
)(buf
+ 2), "test44 case 1 failed\n");
4268 FAILED(buf
[1] != buf
+ 2, "test44 case 2 failed\n");
4269 FAILED(buf
[2] != buf
+ 3, "test44 case 3 failed\n");
4270 FAILED(buf
[3] != buf
+ 4, "test44 case 4 failed\n");
4271 FAILED(buf
[4] != buf
+ 2, "test44 case 5 failed\n");
4273 sljit_free_code(code
.code
, NULL
);
4277 static void test45(void)
4279 /* Test single precision floating point. */
4281 executable_code code
;
4282 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4285 struct sljit_jump
* jump
;
4288 printf("Run test45\n");
4290 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
4292 printf("no fpu available, test45 skipped\n");
4295 sljit_free_compiler(compiler
);
4299 FAILED(!compiler
, "cannot create compiler\n");
4321 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 3, 2, 6, 0, 0);
4323 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4324 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f32
));
4325 sljit_emit_fop1(compiler
, SLJIT_NEG_F32
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
4326 sljit_emit_fop1(compiler
, SLJIT_ABS_F32
, SLJIT_FR1
, 0, SLJIT_FR5
, 0);
4327 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f32
), SLJIT_FR1
, 0);
4328 sljit_emit_fop1(compiler
, SLJIT_ABS_F32
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f32
), SLJIT_FR5
, 0);
4329 sljit_emit_fop1(compiler
, SLJIT_NEG_F32
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4330 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_f32
), SLJIT_FR4
, 0);
4332 sljit_emit_fop2(compiler
, SLJIT_ADD_F32
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f32
));
4333 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
4334 sljit_emit_fop2(compiler
, SLJIT_SUB_F32
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_f32
), SLJIT_FR5
, 0);
4335 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4336 sljit_emit_fop2(compiler
, SLJIT_MUL_F32
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_f32
), SLJIT_FR0
, 0, SLJIT_FR0
, 0);
4337 sljit_emit_fop2(compiler
, SLJIT_DIV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
4338 sljit_emit_fop1(compiler
, SLJIT_ABS_F32
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_f32
), SLJIT_FR2
, 0);
4339 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x3d0ac);
4340 sljit_emit_fop1(compiler
, SLJIT_NEG_F32
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_R0
), 0x3d0ac);
4341 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 0x3d0ac + sizeof(sljit_f32
));
4342 sljit_emit_fop1(compiler
, SLJIT_ABS_F32
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_R0
), -0x3d0ac);
4344 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4345 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f32
));
4346 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4347 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_F_EQUAL
);
4348 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_LESS
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4349 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_sw
), SLJIT_F_LESS
);
4350 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
4351 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_sw
), SLJIT_F_EQUAL
);
4352 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_GREATER_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
4353 cond_set(compiler
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_F_GREATER_EQUAL
);
4355 jump
= sljit_emit_fcmp(compiler
, SLJIT_F_LESS_EQUAL
| SLJIT_32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f32
));
4356 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_IMM
, 7);
4357 sljit_set_label(jump
, sljit_emit_label(compiler
));
4359 jump
= sljit_emit_fcmp(compiler
, SLJIT_F_GREATER
| SLJIT_32
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_FR2
, 0);
4360 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_IMM
, 6);
4361 sljit_set_label(jump
, sljit_emit_label(compiler
));
4363 sljit_emit_return_void(compiler
);
4365 code
.code
= sljit_generate_code(compiler
);
4367 sljit_free_compiler(compiler
);
4369 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
4370 FAILED(buf
[2] != -5.5, "test45 case 1 failed\n");
4371 FAILED(buf
[3] != 7.25, "test45 case 2 failed\n");
4372 FAILED(buf
[4] != 7.25, "test45 case 3 failed\n");
4373 FAILED(buf
[5] != -5.5, "test45 case 4 failed\n");
4374 FAILED(buf
[6] != -1.75, "test45 case 5 failed\n");
4375 FAILED(buf
[7] != 16.0, "test45 case 6 failed\n");
4376 FAILED(buf
[8] != 30.25, "test45 case 7 failed\n");
4377 FAILED(buf
[9] != 3, "test45 case 8 failed\n");
4378 FAILED(buf
[10] != -5.5, "test45 case 9 failed\n");
4379 FAILED(buf
[11] != 7.25, "test45 case 10 failed\n");
4380 FAILED(buf2
[0] != 1, "test45 case 11 failed\n");
4381 FAILED(buf2
[1] != 2, "test45 case 12 failed\n");
4382 FAILED(buf2
[2] != 2, "test45 case 13 failed\n");
4383 FAILED(buf2
[3] != 1, "test45 case 14 failed\n");
4384 FAILED(buf2
[4] != 7, "test45 case 15 failed\n");
4385 FAILED(buf2
[5] != -1, "test45 case 16 failed\n");
4387 sljit_free_code(code
.code
, NULL
);
4391 static void test46(void)
4393 /* Test sljit_emit_op_flags with 32 bit operations. */
4395 executable_code code
;
4396 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4402 printf("Run test46\n");
4404 for (i
= 0; i
< 24; ++i
)
4407 for (i
= 0; i
< 6; ++i
)
4411 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 3, 3, 0, 0, 0);
4413 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4414 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_R2
, 0, SLJIT_IMM
, 13);
4415 sljit_emit_op_flags(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&buf
, SLJIT_LESS
);
4416 sljit_emit_op_flags(compiler
, SLJIT_AND32
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_s32
), SLJIT_NOT_ZERO
);
4418 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4419 sljit_emit_op_flags(compiler
, SLJIT_AND32
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_s32
), SLJIT_EQUAL
);
4420 sljit_emit_op_flags(compiler
, SLJIT_AND32
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_s32
), SLJIT_NOT_EQUAL
);
4421 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1235);
4422 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 0x1235);
4423 sljit_emit_op_flags(compiler
, SLJIT_AND32
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_ZERO
);
4424 sljit_emit_op_flags(compiler
, SLJIT_AND32
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_s32
), SLJIT_ZERO
);
4425 sljit_emit_op1(compiler
, SLJIT_MOV_U32
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_s32
), SLJIT_R0
, 0);
4427 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4428 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 12);
4429 sljit_emit_op_flags(compiler
, SLJIT_MOV32
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 2, SLJIT_EQUAL
);
4430 sljit_emit_op_flags(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_EQUAL
);
4431 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_s32
), SLJIT_R0
, 0);
4432 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
4433 sljit_emit_op_flags(compiler
, SLJIT_AND32
| SLJIT_SET_Z
, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), 2, SLJIT_EQUAL
);
4434 sljit_emit_op_flags(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_s32
), SLJIT_NOT_EQUAL
);
4436 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4437 sljit_emit_op_flags(compiler
, SLJIT_XOR32
| SLJIT_SET_Z
, SLJIT_MEM1(SLJIT_S0
), 20 * sizeof(sljit_s32
), SLJIT_ZERO
);
4438 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 39);
4439 sljit_emit_op_flags(compiler
, SLJIT_XOR32
, SLJIT_R0
, 0, SLJIT_NOT_ZERO
);
4440 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), 22 * sizeof(sljit_s32
), SLJIT_R0
, 0);
4442 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R2
, 0, SLJIT_IMM
, -7);
4443 sljit_emit_op_flags(compiler
, SLJIT_AND
, SLJIT_MEM0(), (sljit_sw
)&buf2
, SLJIT_GREATER
);
4444 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R2
, 0, SLJIT_IMM
, 5);
4445 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
4446 sljit_emit_op_flags(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_SIG_LESS
);
4447 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
4448 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_R2
, 0, SLJIT_IMM
, 5);
4449 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_LESS
);
4450 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_NOT_EQUAL
);
4451 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R2
, 0, SLJIT_IMM
, 5);
4452 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_sw
), SLJIT_S2
, 0);
4453 sljit_emit_op_flags(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_WORD_SHIFT
, SLJIT_SIG_LESS
);
4454 sljit_emit_op_flags(compiler
, SLJIT_OR
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_sw
), SLJIT_ZERO
);
4455 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R2
, 0, SLJIT_IMM
, 0);
4456 sljit_emit_op_flags(compiler
, SLJIT_XOR
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_sw
), SLJIT_GREATER
);
4458 sljit_emit_return_void(compiler
);
4460 code
.code
= sljit_generate_code(compiler
);
4462 sljit_free_compiler(compiler
);
4464 code
.func2((sljit_sw
)&buf
, (sljit_sw
)&buf2
);
4465 FAILED(buf
[0] != 0, "test46 case 1 failed\n");
4466 FAILED(buf
[1] != -17, "test46 case 2 failed\n");
4467 FAILED(buf
[2] != 1, "test46 case 3 failed\n");
4468 FAILED(buf
[3] != -17, "test46 case 4 failed\n");
4469 FAILED(buf
[4] != 1, "test46 case 5 failed\n");
4470 FAILED(buf
[5] != -17, "test46 case 6 failed\n");
4471 FAILED(buf
[6] != 1, "test46 case 7 failed\n");
4472 FAILED(buf
[7] != -17, "test46 case 8 failed\n");
4473 FAILED(buf
[8] != 0, "test46 case 9 failed\n");
4474 FAILED(buf
[9] != -17, "test46 case 10 failed\n");
4475 FAILED(buf
[10] != 1, "test46 case 11 failed\n");
4476 FAILED(buf
[11] != -17, "test46 case 12 failed\n");
4477 FAILED(buf
[12] != 1, "test46 case 13 failed\n");
4478 FAILED(buf
[13] != -17, "test46 case 14 failed\n");
4479 FAILED(buf
[14] != 1, "test46 case 15 failed\n");
4480 FAILED(buf
[15] != -17, "test46 case 16 failed\n");
4481 FAILED(buf
[16] != 0, "test46 case 17 failed\n");
4482 FAILED(buf
[17] != -17, "test46 case 18 failed\n");
4483 FAILED(buf
[18] != 0, "test46 case 19 failed\n");
4484 FAILED(buf
[19] != -17, "test46 case 20 failed\n");
4485 FAILED(buf
[20] != -18, "test46 case 21 failed\n");
4486 FAILED(buf
[21] != -17, "test46 case 22 failed\n");
4487 FAILED(buf
[22] != 38, "test46 case 23 failed\n");
4488 FAILED(buf
[23] != -17, "test46 case 24 failed\n");
4490 FAILED(buf2
[0] != 0, "test46 case 25 failed\n");
4491 FAILED(buf2
[1] != 1, "test46 case 26 failed\n");
4492 FAILED(buf2
[2] != 0, "test46 case 27 failed\n");
4493 FAILED(buf2
[3] != 1, "test46 case 28 failed\n");
4494 FAILED(buf2
[4] != -123, "test46 case 29 failed\n");
4495 FAILED(buf2
[5] != -14, "test46 case 30 failed\n");
4497 sljit_free_code(code
.code
, NULL
);
4501 static void test47(void)
4503 /* Test jump optimizations. */
4504 executable_code code
;
4505 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4509 printf("Run test47\n");
4511 FAILED(!compiler
, "cannot create compiler\n");
4516 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 0);
4517 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x3a5c6f);
4518 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
4519 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), 0x11223344);
4520 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
4521 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0xd37c10);
4522 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4523 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), SLJIT_W(0x112233445566));
4525 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
4526 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x59b48e);
4527 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4528 sljit_set_target(sljit_emit_jump(compiler
, SLJIT_LESS
), SLJIT_W(0x1122334455667788));
4530 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4531 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
4533 code
.code
= sljit_generate_code(compiler
);
4535 sljit_free_compiler(compiler
);
4537 FAILED(code
.func1((sljit_sw
)&buf
) != 0x59b48e, "test47 case 1 failed\n");
4538 FAILED(buf
[0] != 0x3a5c6f, "test47 case 2 failed\n");
4539 FAILED(buf
[1] != 0xd37c10, "test47 case 3 failed\n");
4540 FAILED(buf
[2] != 0x59b48e, "test47 case 4 failed\n");
4542 sljit_free_code(code
.code
, NULL
);
4546 static void test48(void)
4548 /* Test floating point conversions. */
4549 executable_code code
;
4550 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4558 printf("Run test48\n");
4560 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
4562 printf("no fpu available, test48 skipped\n");
4565 sljit_free_compiler(compiler
);
4569 FAILED(!compiler
, "cannot create compiler\n");
4570 for (i
= 0; i
< 10; i
++) {
4589 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 3, 3, 6, 0, 0);
4590 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
4591 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, (sljit_sw
)&sbuf
);
4592 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
4593 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
4596 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_F64
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_S0
), 0);
4597 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
4598 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 3);
4600 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_F64
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_F32_SHIFT
, SLJIT_FR5
, 0);
4601 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_F32
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4603 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f64
), SLJIT_FR4
, 0);
4604 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4605 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_F32
, SLJIT_FR2
, 0, SLJIT_FR3
, 0);
4607 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f64
), SLJIT_FR2
, 0);
4609 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_f32
), SLJIT_FR3
, 0);
4612 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F64
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
4613 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
4614 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F64
, SLJIT_R0
, 0, SLJIT_MEM2(SLJIT_S0
, SLJIT_R0
), SLJIT_F64_SHIFT
);
4616 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4617 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR5
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
4619 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F32
, SLJIT_MEM1(SLJIT_S2
), 3 * sizeof(sljit_sw
), SLJIT_FR5
, 0);
4620 sljit_emit_fop1(compiler
, SLJIT_NEG_F32
, SLJIT_FR0
, 0, SLJIT_FR5
, 0);
4621 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 4);
4623 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F32
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R1
), SLJIT_WORD_SHIFT
, SLJIT_FR0
, 0);
4624 sljit_emit_fop1(compiler
, SLJIT_NEG_F64
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
));
4626 sljit_emit_fop1(compiler
, SLJIT_CONV_S32_FROM_F64
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_s32
), SLJIT_FR4
, 0);
4627 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
));
4628 sljit_emit_fop1(compiler
, SLJIT_CONV_S32_FROM_F32
, SLJIT_R0
, 0, SLJIT_FR1
, 0);
4630 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_MEM1(SLJIT_R2
), 3 * sizeof(sljit_s32
), SLJIT_R0
, 0);
4633 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_SW
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_f64
), SLJIT_MEM1(SLJIT_S2
), 0);
4634 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_SW
, SLJIT_FR2
, 0, SLJIT_IMM
, -6213);
4636 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f64
), SLJIT_FR2
, 0);
4638 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_S32
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_f64
), SLJIT_MEM0(), (sljit_sw
)&ibuf
[0]);
4639 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_R2
), sizeof(sljit_s32
));
4640 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_S32
, SLJIT_FR1
, 0, SLJIT_R0
, 0);
4642 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_f64
), SLJIT_FR1
, 0);
4644 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_SW
, SLJIT_MEM0(), (sljit_sw
)(dbuf
+ 9), SLJIT_IMM
, -77);
4646 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_SW
, SLJIT_MEM1(SLJIT_S1
), 5 * sizeof(sljit_f32
), SLJIT_IMM
, -123);
4647 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 7190);
4648 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_SW
, SLJIT_FR3
, 0, SLJIT_R0
, 0);
4650 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 6 * sizeof(sljit_f32
), SLJIT_FR3
, 0);
4651 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 123);
4652 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_R2
, 0, SLJIT_IMM
, 123 * sizeof(sljit_s32
));
4653 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_S32
, SLJIT_FR1
, 0, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 2);
4655 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 7 * sizeof(sljit_f32
), SLJIT_FR1
, 0);
4656 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
4657 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 3812);
4659 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_S32
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), SLJIT_F32_SHIFT
, SLJIT_R1
, 0);
4661 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_SW
, SLJIT_MEM0(), (sljit_sw
)(sbuf
+ 9), SLJIT_IMM
, -79);
4663 sljit_emit_return_void(compiler
);
4665 code
.code
= sljit_generate_code(compiler
);
4667 sljit_free_compiler(compiler
);
4670 FAILED(dbuf
[3] != 476.25, "test48 case 1 failed\n");
4671 FAILED(dbuf
[4] != 476.25, "test48 case 2 failed\n");
4672 FAILED(dbuf
[5] != 2345.0, "test48 case 3 failed\n");
4673 FAILED(dbuf
[6] != -6213.0, "test48 case 4 failed\n");
4674 FAILED(dbuf
[7] != 312.0, "test48 case 5 failed\n");
4675 FAILED(dbuf
[8] != -9324.0, "test48 case 6 failed\n");
4676 FAILED(dbuf
[9] != -77.0, "test48 case 7 failed\n");
4678 FAILED(sbuf
[2] != 123.5, "test48 case 8 failed\n");
4679 FAILED(sbuf
[3] != 123.5, "test48 case 9 failed\n");
4680 FAILED(sbuf
[4] != 476.25, "test48 case 10 failed\n");
4681 FAILED(sbuf
[5] != -123, "test48 case 11 failed\n");
4682 FAILED(sbuf
[6] != 7190, "test48 case 12 failed\n");
4683 FAILED(sbuf
[7] != 312, "test48 case 13 failed\n");
4684 FAILED(sbuf
[8] != 3812, "test48 case 14 failed\n");
4685 FAILED(sbuf
[9] != -79.0, "test48 case 15 failed\n");
4687 FAILED(wbuf
[1] != -367, "test48 case 16 failed\n");
4688 FAILED(wbuf
[2] != 917, "test48 case 17 failed\n");
4689 FAILED(wbuf
[3] != 476, "test48 case 18 failed\n");
4690 FAILED(wbuf
[4] != -476, "test48 case 19 failed\n");
4692 FAILED(ibuf
[2] != -917, "test48 case 20 failed\n");
4693 FAILED(ibuf
[3] != -1689, "test48 case 21 failed\n");
4695 sljit_free_code(code
.code
, NULL
);
4699 static void test49(void)
4701 /* Test floating point conversions. */
4702 executable_code code
;
4703 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4709 sljit_s32
* dbuf_ptr
= (sljit_s32
*)dbuf
;
4710 sljit_s32
* sbuf_ptr
= (sljit_s32
*)sbuf
;
4713 printf("Run test49\n");
4715 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
4717 printf("no fpu available, test49 skipped\n");
4720 sljit_free_compiler(compiler
);
4724 FAILED(!compiler
, "cannot create compiler\n");
4726 for (i
= 0; i
< 9; i
++) {
4727 dbuf_ptr
[i
<< 1] = -1;
4728 dbuf_ptr
[(i
<< 1) + 1] = -1;
4734 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4735 dbuf
[9] = (sljit_f64
)SLJIT_W(0x1122334455);
4742 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 3, 3, 3, 0, 0);
4743 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
4744 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, (sljit_sw
)&sbuf
);
4745 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
4746 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
4749 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_F32
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
), SLJIT_MEM1(SLJIT_S1
), 0);
4751 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_F64
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_S0
), 0);
4753 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F64
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S0
), 0);
4755 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F32
, SLJIT_MEM1(SLJIT_S2
), 4 * sizeof(sljit_sw
), SLJIT_MEM1(SLJIT_S1
), 0);
4757 sljit_emit_fop1(compiler
, SLJIT_CONV_S32_FROM_F64
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_s32
), SLJIT_MEM1(SLJIT_S0
), 0);
4759 sljit_emit_fop1(compiler
, SLJIT_CONV_S32_FROM_F32
, SLJIT_MEM1(SLJIT_R2
), 4 * sizeof(sljit_s32
), SLJIT_MEM1(SLJIT_S1
), 0);
4761 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_SW
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f64
), SLJIT_MEM1(SLJIT_S2
), 0);
4763 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_SW
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_S2
), 0);
4765 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_S32
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f64
), SLJIT_MEM1(SLJIT_R2
), 0);
4767 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_S32
, SLJIT_MEM1(SLJIT_S1
), 6 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_R2
), 0);
4769 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4770 sljit_emit_fop1(compiler
, SLJIT_CONV_SW_FROM_F64
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_f64
));
4772 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), 8 * sizeof(sljit_sw
), SLJIT_R0
, 0);
4773 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_f64
));
4774 sljit_emit_fop1(compiler
, SLJIT_CONV_S32_FROM_F64
, SLJIT_R0
, 0, SLJIT_FR2
, 0);
4775 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
4776 sljit_emit_op2(compiler
, SLJIT_AND32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0xffff);
4778 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R2
), 8 * sizeof(sljit_s32
), SLJIT_R0
, 0);
4779 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_W(0x4455667788));
4781 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_SW
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_f64
), SLJIT_R0
, 0);
4783 sljit_emit_fop1(compiler
, SLJIT_CONV_F64_FROM_S32
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_f64
), SLJIT_IMM
, SLJIT_W(0x7766554433));
4786 sljit_emit_return_void(compiler
);
4788 code
.code
= sljit_generate_code(compiler
);
4790 sljit_free_compiler(compiler
);
4794 FAILED(dbuf_ptr
[(1 * 2) + 0] != -1, "test49 case 1 failed\n");
4795 FAILED(dbuf_ptr
[(1 * 2) + 1] != -1, "test49 case 2 failed\n");
4796 FAILED(dbuf
[2] != -879.75, "test49 case 3 failed\n");
4797 FAILED(dbuf_ptr
[(3 * 2) + 0] != -1, "test49 case 4 failed\n");
4798 FAILED(dbuf_ptr
[(3 * 2) + 1] != -1, "test49 case 5 failed\n");
4799 FAILED(dbuf
[4] != 345, "test49 case 6 failed\n");
4800 FAILED(dbuf_ptr
[(5 * 2) + 0] != -1, "test49 case 7 failed\n");
4801 FAILED(dbuf_ptr
[(5 * 2) + 1] != -1, "test49 case 8 failed\n");
4802 FAILED(dbuf
[6] != -249, "test49 case 9 failed\n");
4803 FAILED(dbuf_ptr
[(7 * 2) + 0] != -1, "test49 case 10 failed\n");
4804 FAILED(dbuf_ptr
[(7 * 2) + 1] != -1, "test49 case 11 failed\n");
4806 FAILED(sbuf_ptr
[1] != -1, "test49 case 12 failed\n");
4807 FAILED(sbuf
[2] != 673.75, "test49 case 13 failed\n");
4808 FAILED(sbuf_ptr
[3] != -1, "test49 case 14 failed\n");
4809 FAILED(sbuf
[4] != 345, "test49 case 15 failed\n");
4810 FAILED(sbuf_ptr
[5] != -1, "test49 case 16 failed\n");
4811 FAILED(sbuf
[6] != -249, "test49 case 17 failed\n");
4812 FAILED(sbuf_ptr
[7] != -1, "test49 case 18 failed\n");
4814 FAILED(wbuf
[1] != -1, "test49 case 19 failed\n");
4815 FAILED(wbuf
[2] != 673, "test49 case 20 failed\n");
4816 FAILED(wbuf
[3] != -1, "test49 case 21 failed\n");
4817 FAILED(wbuf
[4] != -879, "test49 case 22 failed\n");
4818 FAILED(wbuf
[5] != -1, "test49 case 23 failed\n");
4820 FAILED(ibuf
[1] != -1, "test49 case 24 failed\n");
4821 FAILED(ibuf
[2] != 673, "test49 case 25 failed\n");
4822 FAILED(ibuf
[3] != -1, "test49 case 26 failed\n");
4823 FAILED(ibuf
[4] != -879, "test49 case 27 failed\n");
4824 FAILED(ibuf
[5] != -1, "test49 case 28 failed\n");
4826 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
4827 FAILED(dbuf
[8] != (sljit_f64
)SLJIT_W(0x4455667788), "test49 case 29 failed\n");
4828 FAILED(dbuf
[9] != (sljit_f64
)SLJIT_W(0x66554433), "test49 case 30 failed\n");
4829 FAILED(wbuf
[8] != SLJIT_W(0x1122334455), "test48 case 31 failed\n");
4830 FAILED(ibuf
[8] == 0x4455, "test48 case 32 failed\n");
4833 sljit_free_code(code
.code
, NULL
);
4837 static void test50(void)
4839 /* Test stack and floating point operations. */
4840 executable_code code
;
4841 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4842 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4843 sljit_uw size1
, size2
, size3
;
4849 printf("Run test50\n");
4851 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
4853 printf("no fpu available, test50 skipped\n");
4856 sljit_free_compiler(compiler
);
4860 FAILED(!compiler
, "cannot create compiler\n");
4866 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 3, 6, 0, 8 * sizeof(sljit_f32
));
4868 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
4869 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), 0);
4871 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_f32
));
4872 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f32
));
4873 sljit_emit_fop2(compiler
, SLJIT_ADD_F32
, SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_f32
));
4875 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_f32
));
4876 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_f32
), SLJIT_IMM
, 5934);
4877 sljit_emit_fop1(compiler
, SLJIT_CONV_F32_FROM_SW
, SLJIT_MEM1(SLJIT_SP
), 3 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), 2 * sizeof(sljit_f32
));
4879 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_f32
), SLJIT_MEM1(SLJIT_SP
), 3 * sizeof(sljit_f32
));
4881 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4882 size1
= compiler
->size
;
4884 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f32
));
4885 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4886 size2
= compiler
->size
;
4888 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR5
, 0, SLJIT_FR2
, 0);
4889 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4890 size3
= compiler
->size
;
4893 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f32
), SLJIT_FR5
, 0);
4894 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4895 result
= (compiler
->size
- size3
) == (size3
- size2
) && (size3
- size2
) == (size2
- size1
);
4898 sljit_emit_return_void(compiler
);
4900 code
.code
= sljit_generate_code(compiler
);
4902 sljit_free_compiler(compiler
);
4904 code
.func1((sljit_sw
)&sbuf
);
4906 FAILED(sbuf
[3] != 245.5, "test50 case 1 failed\n");
4907 FAILED(sbuf
[4] != 145.25, "test50 case 2 failed\n");
4908 FAILED(sbuf
[5] != 5934, "test50 case 3 failed\n");
4909 FAILED(sbuf
[6] != 713.75, "test50 case 4 failed\n");
4910 #if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4911 FAILED(!result
, "test50 case 5 failed\n");
4914 sljit_free_code(code
.code
, NULL
);
4918 static void test51(void)
4920 /* Test all registers provided by the CPU. */
4921 executable_code code
;
4922 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
4923 struct sljit_jump
* jump
;
4928 printf("Run test51\n");
4930 FAILED(!compiler
, "cannot create compiler\n");
4934 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, 0);
4936 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4937 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 32);
4939 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)buf
);
4940 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
4942 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4943 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4944 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_R0
, 0);
4945 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_R(i
)), 0);
4947 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, buf
[0]);
4950 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 32);
4951 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4952 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4953 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_R0
, 0);
4954 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM1(SLJIT_R(i
)), 32);
4956 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, buf
[0]);
4959 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++) {
4960 if (sljit_get_register_index(SLJIT_R(i
)) >= 0) {
4961 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 32);
4962 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R(i
), SLJIT_R0
), 0);
4963 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R(i
)), 0);
4964 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 8);
4965 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_MEM2(SLJIT_R0
, SLJIT_R(i
)), 2);
4967 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_IMM
, 3 * buf
[0]);
4970 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 32 + sizeof(sljit_sw
), SLJIT_R1
, 0);
4972 sljit_emit_return_void(compiler
);
4974 code
.code
= sljit_generate_code(compiler
);
4976 sljit_free_compiler(compiler
);
4980 FAILED(buf
[1] != (39 * 5 * (SLJIT_NUMBER_OF_REGISTERS
- 2)), "test51 case 1 failed\n");
4982 sljit_free_code(code
.code
, NULL
);
4986 compiler
= sljit_create_compiler(NULL
, NULL
);
4988 FAILED(!compiler
, "cannot create compiler\n");
4990 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), SLJIT_NUMBER_OF_SCRATCH_REGISTERS
, SLJIT_NUMBER_OF_SAVED_REGISTERS
, 0, 0, 0);
4992 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4993 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 17);
4995 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS0(W
));
4996 /* SLJIT_R0 contains the first value. */
4997 for (i
= 1; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
4998 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
5000 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
5002 sljit_set_label(jump
, sljit_emit_label(compiler
));
5003 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, 0);
5004 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5005 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 35);
5006 sljit_emit_return_void(compiler
);
5008 code
.code
= sljit_generate_code(compiler
);
5010 sljit_free_compiler(compiler
);
5012 FAILED(code
.func0() != (SLJIT_NUMBER_OF_SCRATCH_REGISTERS
* 35 + SLJIT_NUMBER_OF_SAVED_REGISTERS
* 17), "test51 case 2 failed\n");
5014 sljit_free_code(code
.code
, NULL
);
5018 compiler
= sljit_create_compiler(NULL
, NULL
);
5020 FAILED(!compiler
, "cannot create compiler\n");
5022 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), SLJIT_NUMBER_OF_SCRATCH_REGISTERS
, SLJIT_NUMBER_OF_SAVED_REGISTERS
, 0, 0, 0);
5024 for (i
= 0; i
< SLJIT_NUMBER_OF_SCRATCH_REGISTERS
; i
++)
5025 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 68);
5026 for (i
= 0; i
< SLJIT_NUMBER_OF_SAVED_REGISTERS
; i
++)
5027 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S(i
), 0, SLJIT_IMM
, 68);
5029 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS0(W
));
5030 /* SLJIT_R0 contains the first value. */
5031 for (i
= 1; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5032 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
5034 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
5036 sljit_set_label(jump
, sljit_emit_label(compiler
));
5037 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, 0);
5038 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5039 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 43);
5040 sljit_emit_return_void(compiler
);
5042 code
.code
= sljit_generate_code(compiler
);
5044 sljit_free_compiler(compiler
);
5046 FAILED(code
.func0() != (SLJIT_NUMBER_OF_SCRATCH_REGISTERS
* 43 + SLJIT_NUMBER_OF_SAVED_REGISTERS
* 68), "test51 case 3 failed\n");
5048 sljit_free_code(code
.code
, NULL
);
5052 static void test52(void)
5054 /* Test all registers provided by the CPU. */
5055 executable_code code
;
5056 struct sljit_compiler
* compiler
;
5057 struct sljit_jump
* jump
;
5062 printf("Run test52\n");
5064 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5066 printf("no fpu available, test52 skipped\n");
5073 compiler
= sljit_create_compiler(NULL
, NULL
);
5074 FAILED(!compiler
, "cannot create compiler\n");
5078 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
, SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
, 0);
5080 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
5081 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
5083 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS0(VOID
));
5084 /* SLJIT_FR0 contains the first value. */
5085 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
5086 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR(i
), 0);
5087 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
5089 sljit_emit_return_void(compiler
);
5091 sljit_set_label(jump
, sljit_emit_label(compiler
));
5092 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 1, 0, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
5093 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[1]);
5094 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
5095 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_R0
), 0);
5096 sljit_emit_return_void(compiler
);
5098 code
.code
= sljit_generate_code(compiler
);
5100 sljit_free_compiler(compiler
);
5102 code
.func1((sljit_sw
)&buf
);
5103 FAILED(buf
[2] != (SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
* 17.75 + SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
* 6.25), "test52 case 1 failed\n");
5105 sljit_free_code(code
.code
, NULL
);
5109 compiler
= sljit_create_compiler(NULL
, NULL
);
5110 FAILED(!compiler
, "cannot create compiler\n");
5114 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
, SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
, 0);
5116 for (i
= 0; i
< SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
; i
++)
5117 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
5118 for (i
= 0; i
< SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
; i
++)
5119 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FS(i
), 0, SLJIT_MEM1(SLJIT_S0
), 0);
5121 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS0(VOID
));
5122 /* SLJIT_FR0 contains the first value. */
5123 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
5124 sljit_emit_fop2(compiler
, SLJIT_ADD_F64
, SLJIT_FR0
, 0, SLJIT_FR0
, 0, SLJIT_FR(i
), 0);
5125 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
5127 sljit_emit_return_void(compiler
);
5129 sljit_set_label(jump
, sljit_emit_label(compiler
));
5130 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 1, 0, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
5131 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
[1]);
5132 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
5133 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_MEM1(SLJIT_R0
), 0);
5134 sljit_emit_return_void(compiler
);
5136 code
.code
= sljit_generate_code(compiler
);
5138 sljit_free_compiler(compiler
);
5140 code
.func1((sljit_sw
)&buf
);
5141 FAILED(buf
[2] != (SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
* -11.25 + SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
* -32.5), "test52 case 2 failed\n");
5143 sljit_free_code(code
.code
, NULL
);
5147 static void test53(void)
5149 /* Check cdecl calls. */
5150 executable_code code
;
5151 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5155 printf("Run test53\n");
5157 FAILED(!compiler
, "cannot create compiler\n");
5160 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS3(VOID
, W
, W
, W
), 1, 3, 0, 0, 2 * sizeof(sljit_sw
));
5162 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)buf
);
5163 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
5164 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S1
, 0);
5165 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_sw
), SLJIT_S2
, 0);
5167 sljit_emit_return_void(compiler
);
5169 code
.code
= sljit_generate_code(compiler
);
5171 sljit_free_compiler(compiler
);
5173 code
.test53_f1(7895, -3812, 4087);
5175 FAILED(buf
[0] != 7895, "test53 case 1 failed\n");
5176 FAILED(buf
[1] != -3812, "test53 case 2 failed\n");
5177 FAILED(buf
[2] != 4087, "test53 case 3 failed\n");
5179 sljit_free_code(code
.code
, NULL
);
5184 static void test54(void)
5187 executable_code code
;
5188 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5189 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
5190 sljit_sw large_num
= SLJIT_W(0x1234567812345678);
5192 sljit_sw large_num
= SLJIT_W(0x12345678);
5200 sljit_s32 s32_value
;
5203 sbuf
[0].s32_value
= 0x7fffffff;
5204 sbuf
[1].value
= 7.5;
5205 sbuf
[2].value
= -14.75;
5208 printf("Run test54\n");
5210 FAILED(!compiler
, "cannot create compiler\n");
5212 for (i
= 0; i
< 19; i
++)
5214 for (i
= 0; i
< 4; i
++)
5217 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 5, 3, 3, 0, 0);
5219 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 17);
5220 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 34);
5221 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
5222 sljit_emit_cmov(compiler
, SLJIT_SIG_LESS
, SLJIT_R0
, SLJIT_R1
, 0);
5223 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
5224 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_IMM
, -10);
5225 sljit_emit_cmov(compiler
, SLJIT_SIG_GREATER
, SLJIT_R0
, SLJIT_R1
, 0);
5226 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
5228 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 24);
5229 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 24);
5230 sljit_emit_cmov(compiler
, SLJIT_NOT_EQUAL
, SLJIT_R0
, SLJIT_IMM
, 66);
5231 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5232 sljit_emit_cmov(compiler
, SLJIT_EQUAL
, SLJIT_R0
, SLJIT_IMM
, 78);
5233 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5234 sljit_emit_cmov(compiler
, SLJIT_EQUAL
, SLJIT_R0
, SLJIT_IMM
, large_num
);
5235 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5237 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
5238 SLJIT_ASSERT(sljit_get_register_index(SLJIT_R3
) == -1 && sljit_get_register_index(SLJIT_R4
) == -1);
5240 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 7);
5241 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -45);
5242 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5243 sljit_emit_cmov(compiler
, SLJIT_OVERFLOW
, SLJIT_R3
, SLJIT_IMM
, 35);
5244 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5245 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, large_num
);
5246 sljit_emit_op2u(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_IMM
, large_num
);
5247 sljit_emit_cmov(compiler
, SLJIT_OVERFLOW
, SLJIT_R3
, SLJIT_IMM
, 35);
5248 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5250 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 71);
5251 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 13);
5252 sljit_emit_op2(compiler
, SLJIT_LSHR
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5253 sljit_emit_cmov(compiler
, SLJIT_EQUAL
, SLJIT_R3
, SLJIT_R0
, 0);
5254 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5256 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 12);
5257 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -29);
5258 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5259 sljit_emit_cmov(compiler
, SLJIT_NOT_OVERFLOW
, SLJIT_R0
, SLJIT_R3
, 0);
5260 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5262 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
5263 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -12);
5264 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R4
, 0, SLJIT_IMM
, 21);
5265 sljit_emit_op2u(compiler
, SLJIT_AND
| SLJIT_SET_Z
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5266 sljit_emit_cmov(compiler
, SLJIT_NOT_EQUAL
, SLJIT_R3
, SLJIT_R4
, 0);
5267 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5268 sljit_emit_cmov(compiler
, SLJIT_EQUAL
, SLJIT_R3
, SLJIT_R4
, 0);
5269 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R3
, 0);
5271 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5272 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S2
), 0);
5273 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
5274 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_f32
));
5276 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
5277 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
5278 sljit_emit_cmov(compiler
, SLJIT_F_EQUAL
, SLJIT_R0
, SLJIT_IMM
, -45);
5279 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5280 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_GREATER
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
5281 sljit_emit_cmov(compiler
, SLJIT_F_GREATER
, SLJIT_R0
, SLJIT_IMM
, -45);
5282 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5283 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_GREATER_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
5284 sljit_emit_cmov(compiler
, SLJIT_F_GREATER_EQUAL
, SLJIT_R0
, SLJIT_IMM
, 33);
5285 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5287 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5288 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_LESS
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
5289 sljit_emit_cmov(compiler
, SLJIT_F_LESS
, SLJIT_R0
, SLJIT_IMM
, -70);
5290 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5291 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_LESS_EQUAL
, SLJIT_FR2
, 0, SLJIT_FR1
, 0);
5292 sljit_emit_cmov(compiler
, SLJIT_F_LESS_EQUAL
, SLJIT_R0
, SLJIT_IMM
, -60);
5293 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5294 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_F_NOT_EQUAL
, SLJIT_FR1
, 0, SLJIT_FR2
, 0);
5295 sljit_emit_cmov(compiler
, SLJIT_F_NOT_EQUAL
, SLJIT_R0
, SLJIT_IMM
, 31);
5296 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5298 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 53);
5299 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_ORDERED
, SLJIT_FR1
, 0, SLJIT_FR0
, 0);
5300 sljit_emit_cmov(compiler
, SLJIT_ORDERED
, SLJIT_R0
, SLJIT_IMM
, 17);
5301 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5302 sljit_emit_fop1(compiler
, SLJIT_CMP_F32
| SLJIT_SET_UNORDERED
, SLJIT_FR1
, 0, SLJIT_FR0
, 0);
5303 sljit_emit_cmov(compiler
, SLJIT_UNORDERED
, SLJIT_R0
, SLJIT_IMM
, 59);
5304 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 18 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5307 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 177);
5308 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_LESS
, SLJIT_R0
, 0, SLJIT_IMM
, 178);
5309 sljit_emit_cmov(compiler
, SLJIT_LESS
, SLJIT_R0
| SLJIT_32
, SLJIT_IMM
, 200);
5310 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S1
), 0, SLJIT_R0
, 0);
5312 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 95);
5313 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R3
, 0, SLJIT_IMM
, 177);
5314 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 95);
5315 sljit_emit_cmov(compiler
, SLJIT_LESS_EQUAL
, SLJIT_R3
| SLJIT_32
, SLJIT_R0
, 0);
5316 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
5317 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s32
), SLJIT_R3
, 0);
5319 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R3
, 0, SLJIT_IMM
, 56);
5320 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R4
, 0, SLJIT_IMM
, -63);
5321 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_SIG_LESS
, SLJIT_R3
, 0, SLJIT_R4
, 0);
5322 sljit_emit_cmov(compiler
, SLJIT_SIG_LESS
, SLJIT_R3
| SLJIT_32
, SLJIT_R4
, 0);
5323 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_s32
), SLJIT_R3
, 0);
5324 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_SIG_GREATER
, SLJIT_R3
, 0, SLJIT_R4
, 0);
5325 sljit_emit_cmov(compiler
, SLJIT_SIG_GREATER
, SLJIT_R3
| SLJIT_32
, SLJIT_R4
, 0);
5326 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_s32
), SLJIT_R3
, 0);
5328 sljit_emit_return_void(compiler
);
5330 code
.code
= sljit_generate_code(compiler
);
5332 sljit_free_compiler(compiler
);
5334 code
.func3((sljit_sw
)&buf
, (sljit_sw
)&ibuf
, (sljit_sw
)&sbuf
);
5336 FAILED(buf
[0] != 17, "test54 case 1 failed\n");
5337 FAILED(buf
[1] != 34, "test54 case 2 failed\n");
5338 FAILED(buf
[2] != 24, "test54 case 3 failed\n");
5339 FAILED(buf
[3] != 78, "test54 case 4 failed\n");
5340 FAILED(buf
[4] != large_num
, "test54 case 5 failed\n");
5341 FAILED(buf
[5] != -45, "test54 case 6 failed\n");
5342 FAILED(buf
[6] != 35, "test54 case 7 failed\n");
5343 FAILED(buf
[7] != 71, "test54 case 8 failed\n");
5344 FAILED(buf
[8] != -29, "test54 case 9 failed\n");
5345 FAILED(buf
[9] != -12, "test54 case 10 failed\n");
5346 FAILED(buf
[10] != 21, "test54 case 11 failed\n");
5348 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5349 FAILED(buf
[11] != 16, "test54 case 12 failed\n");
5350 FAILED(buf
[12] != -45, "test54 case 13 failed\n");
5351 FAILED(buf
[13] != 33, "test54 case 14 failed\n");
5352 FAILED(buf
[14] != 8, "test54 case 15 failed\n");
5353 FAILED(buf
[15] != -60, "test54 case 16 failed\n");
5354 FAILED(buf
[16] != 31, "test54 case 17 failed\n");
5355 FAILED(buf
[17] != 53, "test54 case 18 failed\n");
5356 FAILED(buf
[18] != 59, "test54 case 19 failed\n");
5359 FAILED(ibuf
[0] != 200, "test54 case 12 failed\n");
5360 FAILED(ibuf
[1] != 95, "test54 case 13 failed\n");
5361 FAILED(ibuf
[2] != 56, "test54 case 14 failed\n");
5362 FAILED(ibuf
[3] != -63, "test54 case 15 failed\n");
5364 sljit_free_code(code
.code
, NULL
);
5368 static void test55(void)
5370 /* Check value preservation. */
5371 executable_code code
;
5372 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5377 printf("Run test55\n");
5379 FAILED(!compiler
, "cannot create compiler\n");
5383 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), SLJIT_NUMBER_OF_REGISTERS
, 0, 0, 0, sizeof (sljit_sw
));
5385 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, 217);
5388 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5389 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 118);
5391 sljit_emit_op0(compiler
, SLJIT_DIVMOD_SW
);
5393 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
5395 for (i
= 2; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5396 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
5397 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_SP
), 0);
5399 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)(buf
+ 0), SLJIT_R0
, 0);
5402 for (i
= 0; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5403 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R(i
), 0, SLJIT_IMM
, 146);
5405 sljit_emit_op0(compiler
, SLJIT_DIV_SW
);
5407 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
5409 for (i
= 1; i
< SLJIT_NUMBER_OF_REGISTERS
; i
++)
5410 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R(i
), 0);
5411 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_SP
), 0);
5413 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)(buf
+ 1), SLJIT_R0
, 0);
5415 sljit_emit_return_void(compiler
);
5417 code
.code
= sljit_generate_code(compiler
);
5419 sljit_free_compiler(compiler
);
5423 FAILED(buf
[0] != (SLJIT_NUMBER_OF_REGISTERS
- 2) * 118 + 217, "test55 case 1 failed\n");
5424 FAILED(buf
[1] != (SLJIT_NUMBER_OF_REGISTERS
- 1) * 146 + 217, "test55 case 2 failed\n");
5426 sljit_free_code(code
.code
, NULL
);
5430 static void test56(void)
5432 /* Check integer substraction with negative immediate. */
5433 executable_code code
;
5434 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5439 printf("Run test56\n");
5441 for (i
= 0; i
< 13; i
++)
5444 FAILED(!compiler
, "cannot create compiler\n");
5446 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 0, 0, 0);
5448 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 90 << 12);
5449 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5450 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
5451 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_SIG_GREATER
);
5452 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_LESS
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5453 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5454 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_LESS
);
5455 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER_EQUAL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5456 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_SIG_GREATER_EQUAL
);
5457 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_LESS_EQUAL
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5458 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_LESS_EQUAL
);
5459 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5460 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_GREATER
);
5461 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_LESS
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5462 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_SIG_LESS
);
5464 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 90);
5465 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_SIG_GREATER
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -91);
5466 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5467 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_SIG_GREATER
);
5468 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 90);
5469 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_LESS_EQUAL
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -91);
5470 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_LESS_EQUAL
);
5472 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, -0x7fffffff);
5473 sljit_emit_op2(compiler
, SLJIT_ADD32
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -(91 << 12));
5474 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
5476 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, -0x7fffffff-1);
5477 sljit_emit_op2(compiler
, SLJIT_SUB32
| SLJIT_SET_OVERFLOW
, SLJIT_R0
, 0, SLJIT_IMM
, 0, SLJIT_R0
, 0);
5478 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
5480 sljit_emit_return_void(compiler
);
5482 code
.code
= sljit_generate_code(compiler
);
5484 sljit_free_compiler(compiler
);
5486 code
.func1((sljit_sw
)&buf
);
5488 FAILED(buf
[0] != (181 << 12), "test56 case 1 failed\n");
5489 FAILED(buf
[1] != 1, "test56 case 2 failed\n");
5490 FAILED(buf
[2] != (181 << 12), "test56 case 3 failed\n");
5491 FAILED(buf
[3] != 1, "test56 case 4 failed\n");
5492 FAILED(buf
[4] != 1, "test56 case 5 failed\n");
5493 FAILED(buf
[5] != 1, "test56 case 6 failed\n");
5494 FAILED(buf
[6] != 0, "test56 case 7 failed\n");
5495 FAILED(buf
[7] != 0, "test56 case 8 failed\n");
5496 FAILED(buf
[8] != 181, "test56 case 9 failed\n");
5497 FAILED(buf
[9] != 1, "test56 case 10 failed\n");
5498 FAILED(buf
[10] != 1, "test56 case 11 failed\n");
5499 FAILED(buf
[11] != 1, "test56 case 12 failed\n");
5500 FAILED(buf
[12] != 1, "test56 case 13 failed\n");
5502 sljit_free_code(code
.code
, NULL
);
5506 static void test57(void)
5508 /* Check prefetch instructions. */
5509 executable_code code
;
5510 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5511 struct sljit_label
* labels
[5];
5516 printf("Run test57\n");
5518 FAILED(!compiler
, "cannot create compiler\n");
5520 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 3, 1, 0, 0, 0);
5522 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
5523 labels
[0] = sljit_emit_label(compiler
);
5524 /* Should never crash. */
5525 sljit_emit_op_src(compiler
, SLJIT_PREFETCH_L1
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R0
), 2);
5526 labels
[1] = sljit_emit_label(compiler
);
5527 sljit_emit_op_src(compiler
, SLJIT_PREFETCH_L2
, SLJIT_MEM0(), 0);
5528 labels
[2] = sljit_emit_label(compiler
);
5529 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
5530 sljit_emit_op_src(compiler
, SLJIT_PREFETCH_L3
, SLJIT_MEM1(SLJIT_R0
), SLJIT_W(0x1122334455667788));
5532 sljit_emit_op_src(compiler
, SLJIT_PREFETCH_L3
, SLJIT_MEM1(SLJIT_R0
), 0x11223344);
5534 labels
[3] = sljit_emit_label(compiler
);
5535 sljit_emit_op_src(compiler
, SLJIT_PREFETCH_ONCE
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
));
5536 labels
[4] = sljit_emit_label(compiler
);
5538 sljit_emit_return_void(compiler
);
5540 code
.code
= sljit_generate_code(compiler
);
5543 for (i
= 0; i
< 5; i
++)
5544 addr
[i
] = sljit_get_label_addr(labels
[i
]);
5546 sljit_free_compiler(compiler
);
5550 if (sljit_has_cpu_feature(SLJIT_HAS_PREFETCH
)) {
5551 FAILED(addr
[0] == addr
[1], "test57 case 1 failed\n");
5552 FAILED(addr
[1] == addr
[2], "test57 case 2 failed\n");
5553 FAILED(addr
[2] == addr
[3], "test57 case 3 failed\n");
5554 FAILED(addr
[3] == addr
[4], "test57 case 4 failed\n");
5557 FAILED(addr
[0] != addr
[1], "test57 case 1 failed\n");
5558 FAILED(addr
[1] != addr
[2], "test57 case 2 failed\n");
5559 FAILED(addr
[2] != addr
[3], "test57 case 3 failed\n");
5560 FAILED(addr
[3] != addr
[4], "test57 case 4 failed\n");
5563 sljit_free_code(code
.code
, NULL
);
5567 static sljit_f64 SLJIT_FUNC
test58_f1(sljit_f32 a
, sljit_f32 b
, sljit_f64 c
)
5569 return (sljit_f64
)a
+ (sljit_f64
)b
+ c
;
5572 static sljit_f32 SLJIT_FUNC
test58_f2(sljit_sw a
, sljit_f64 b
, sljit_f32 c
)
5574 return (sljit_f32
)((sljit_f64
)a
+ b
+ (sljit_f64
)c
);
5577 static sljit_f64 SLJIT_FUNC
test58_f3(sljit_sw a
, sljit_f32 b
, sljit_sw c
)
5579 return (sljit_f64
)a
+ (sljit_f64
)b
+ (sljit_f64
)c
;
5582 static sljit_f64
test58_f4(sljit_f32 a
, sljit_sw b
)
5584 return (sljit_f64
)a
+ (sljit_f64
)b
;
5587 static sljit_f32
test58_f5(sljit_f32 a
, sljit_f64 b
, sljit_s32 c
)
5589 return (sljit_f32
)((sljit_f64
)a
+ b
+ (sljit_f64
)c
);
5592 static sljit_sw SLJIT_FUNC
test58_f6(sljit_f64 a
, sljit_sw b
)
5594 return (sljit_sw
)(a
+ (sljit_f64
)b
);
5597 static void test58(void)
5599 /* Check function calls with floating point arguments. */
5600 executable_code code
;
5601 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5602 struct sljit_jump
* jump
= NULL
;
5608 printf("Run test58\n");
5610 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5612 printf("no fpu available, test58 skipped\n");
5615 sljit_free_compiler(compiler
);
5636 FAILED(!compiler
, "cannot create compiler\n");
5638 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 3, 3, 4, 0, sizeof(sljit_sw
));
5640 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
5641 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
));
5642 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
5643 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(F64
, F32
, F32
, F64
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test58_f1
));
5645 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
), SLJIT_FR0
, 0);
5647 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
));
5648 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f32
));
5649 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
));
5650 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS3(F64
, F32
, F32
, F64
));
5651 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test58_f1
));
5653 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
5655 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test58_f2
));
5656 sljit_get_local_base(compiler
, SLJIT_R1
, 0, -16);
5657 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
5658 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
5659 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
));
5660 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS3(F32
, W
, F64
, F32
), SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 0);
5662 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
5664 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -4);
5665 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 9);
5666 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0);
5667 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
5668 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS3(F64
, W
, F32
, W
));
5669 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test58_f3
));
5671 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
5673 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
));
5674 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -6);
5675 jump
= sljit_emit_call(compiler
, SLJIT_CALL_CDECL
, SLJIT_ARGS2(F64
, F32
, W
));
5676 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test58_f4
));
5678 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
5680 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test58_f5
));
5681 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f32
));
5682 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
));
5683 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8);
5684 sljit_emit_icall(compiler
, SLJIT_CALL_CDECL
, SLJIT_ARGS3(F32
, F32
, F64
, 32), SLJIT_MEM1(SLJIT_SP
), 0);
5686 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 4 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
5688 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f64
));
5689 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test58_f6
));
5690 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS2(W
, F64
, W
), SLJIT_R0
, 0);
5692 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), 0, SLJIT_R0
, 0);
5694 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_f64
));
5695 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 319);
5696 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test58_f6
));
5697 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS2(W
, F64
, W
), SLJIT_R1
, 0);
5699 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_sw
), SLJIT_R0
, 0);
5701 sljit_emit_return_void(compiler
);
5703 code
.code
= sljit_generate_code(compiler
);
5705 sljit_free_compiler(compiler
);
5707 code
.func3((sljit_sw
)&dbuf
, (sljit_sw
)&sbuf
, (sljit_sw
)&wbuf
);
5709 FAILED(dbuf
[1] != 8.5, "test58 case 1 failed\n");
5710 FAILED(dbuf
[3] != 0.5, "test58 case 2 failed\n");
5711 FAILED(sbuf
[3] != 17.75, "test58 case 3 failed\n");
5712 FAILED(dbuf
[4] != 11.75, "test58 case 4 failed\n");
5713 FAILED(dbuf
[5] != -9.5, "test58 case 5 failed\n");
5714 FAILED(sbuf
[4] != 12, "test58 case 6 failed\n");
5715 FAILED(wbuf
[0] != SLJIT_FUNC_ADDR(test58_f6
) - 18, "test58 case 7 failed\n");
5716 FAILED(wbuf
[1] != 301, "test58 case 8 failed\n");
5718 sljit_free_code(code
.code
, NULL
);
5722 static sljit_sw SLJIT_FUNC
test59_f1(sljit_sw a
, sljit_s32 b
, sljit_sw c
, sljit_sw d
)
5724 return (sljit_sw
)(a
+ b
+ c
+ d
- SLJIT_FUNC_ADDR(test59_f1
));
5727 static sljit_sw
test59_f2(sljit_sw a
, sljit_s32 b
, sljit_sw c
, sljit_sw d
)
5729 return (sljit_sw
)(a
+ b
+ c
+ d
- SLJIT_FUNC_ADDR(test59_f2
));
5732 static sljit_s32 SLJIT_FUNC
test59_f3(sljit_f64 a
, sljit_f32 b
, sljit_f64 c
, sljit_sw d
)
5734 return (sljit_s32
)(a
+ b
+ c
+ (sljit_f64
)d
);
5737 static sljit_f32 SLJIT_FUNC
test59_f4(sljit_f32 a
, sljit_s32 b
, sljit_f64 c
, sljit_sw d
)
5739 return (sljit_f32
)(a
+ (sljit_f64
)b
+ c
+ (sljit_f64
)d
);
5742 static sljit_f32 SLJIT_FUNC
test59_f5(sljit_f32 a
, sljit_f64 b
, sljit_f32 c
, sljit_f64 d
)
5744 return (sljit_f32
)(a
+ b
+ c
+ (sljit_f64
)d
);
5747 static void test59(void)
5749 /* Check function calls with four arguments. */
5750 executable_code code
;
5751 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5752 struct sljit_jump
* jump
= NULL
;
5758 printf("Run test59\n");
5763 wbuf
[3] = SLJIT_FUNC_ADDR(test59_f1
);
5767 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5778 FAILED(!compiler
, "cannot create compiler\n");
5780 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 4, 3, 4, 0, sizeof(sljit_sw
));
5782 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 33);
5783 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -20);
5784 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f1
));
5785 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -40);
5786 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, W
, 32, W
, W
), SLJIT_R2
, 0);
5788 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
5790 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 16);
5791 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -30);
5792 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 50);
5793 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f2
));
5794 sljit_emit_icall(compiler
, SLJIT_CALL_CDECL
, SLJIT_ARGS4(W
, W
, 32, W
, W
), SLJIT_R3
, 0);
5796 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
5798 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f1
));
5799 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -25);
5800 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 100);
5801 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -10);
5802 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, W
, 32, W
, W
), SLJIT_R0
, 0);
5804 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5806 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
5807 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 231);
5808 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 3);
5809 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f1
) - 100);
5810 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, W
, 32, W
, W
), SLJIT_MEM2(SLJIT_R0
, SLJIT_R2
), SLJIT_WORD_SHIFT
);
5812 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5814 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5815 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
5816 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S2
), 0);
5817 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
));
5818 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -100);
5819 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS4(32, F64
, F32
, F64
, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f3
));
5820 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_R0
, 0);
5822 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5824 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
5825 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f64
));
5826 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 36);
5827 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 41);
5828 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(F32
, F32
, 32, F64
, W
));
5829 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test59_f4
));
5831 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
5833 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test59_f5
));
5834 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S2
), 0);
5835 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
5836 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
5837 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f64
));
5838 sljit_emit_icall(compiler
, SLJIT_CALL
, SLJIT_ARGS4(F32
, F32
, F64
, F32
, F64
), SLJIT_R0
, 0);
5840 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S2
), 3 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
5843 sljit_emit_return_void(compiler
);
5845 code
.code
= sljit_generate_code(compiler
);
5847 sljit_free_compiler(compiler
);
5849 code
.func3((sljit_sw
)&wbuf
, (sljit_sw
)&dbuf
, (sljit_sw
)&sbuf
);
5851 FAILED(wbuf
[0] != -27, "test59 case 1 failed\n");
5852 FAILED(wbuf
[1] != 36, "test59 case 2 failed\n");
5853 FAILED(wbuf
[2] != 65, "test59 case 3 failed\n");
5854 FAILED(wbuf
[4] != (sljit_sw
)wbuf
+ 134, "test59 case 4 failed\n");
5856 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
5857 FAILED(wbuf
[5] != -88, "test59 case 5 failed\n");
5858 FAILED(sbuf
[2] != 79.75, "test59 case 6 failed\n");
5859 FAILED(sbuf
[3] != 8.625, "test59 case 7 failed\n");
5862 sljit_free_code(code
.code
, NULL
);
5866 static void test60(void)
5868 /* Test memory accesses with pre/post updates. */
5869 executable_code code
;
5870 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
5872 sljit_s32 supported
[10];
5877 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
5878 static sljit_u8 expected
[10] = { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 };
5879 #elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32)
5880 static sljit_u8 expected
[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
5881 #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
5882 static sljit_u8 expected
[10] = { 1, 0, 1, 1, 0, 1, 1, 1, 0, 0 };
5883 #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
5884 static sljit_u8 expected
[10] = { 1, 0, 0, 1, 0, 0, 1, 1, 0, 0 };
5886 static sljit_u8 expected
[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
5890 printf("Run test60\n");
5892 for (i
= 0; i
< 18; i
++)
5904 FAILED(!compiler
, "cannot create compiler\n");
5906 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 4, 3, 4, 0, sizeof(sljit_sw
));
5908 supported
[0] = sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_sw
));
5909 if (supported
[0] == SLJIT_SUCCESS
) {
5910 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
5911 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_sw
));
5912 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
5913 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
5916 supported
[1] = sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R2
), -2 * (sljit_sw
)sizeof(sljit_s8
));
5917 if (supported
[1] == SLJIT_SUCCESS
) {
5918 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 2 * sizeof(sljit_s8
));
5919 sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R2
), -2 * (sljit_sw
)sizeof(sljit_s8
));
5920 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5921 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R2
, 0);
5924 supported
[2] = sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_R2
, SLJIT_MEM1(SLJIT_R1
), -2 * (sljit_sw
)sizeof(sljit_s32
));
5925 if (supported
[2] == SLJIT_SUCCESS
) {
5926 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 2 * sizeof(sljit_s32
));
5927 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_PRE
, SLJIT_R2
, SLJIT_MEM1(SLJIT_R1
), -2 * (sljit_sw
)sizeof(sljit_s32
));
5928 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R2
, 0);
5929 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5932 supported
[3] = sljit_emit_mem(compiler
, SLJIT_MOV32
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_s32
));
5933 if (supported
[3] == SLJIT_SUCCESS
) {
5934 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, -8765);
5935 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, sizeof(sljit_s32
));
5936 sljit_emit_mem(compiler
, SLJIT_MOV32
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R2
), 2 * sizeof(sljit_s32
));
5937 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R2
, 0);
5940 supported
[4] = sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_POST
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R2
), -128 * (sljit_sw
)sizeof(sljit_s8
));
5941 if (supported
[4] == SLJIT_SUCCESS
) {
5942 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -121);
5943 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_S1
, 0);
5944 sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_STORE
| SLJIT_MEM_POST
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R2
), -128 * (sljit_sw
)sizeof(sljit_s8
));
5945 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R2
, 0);
5948 supported
[5] = sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), 1);
5949 if (supported
[5] == SLJIT_SUCCESS
) {
5950 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 9 * sizeof(sljit_sw
) - 1);
5951 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -881199);
5952 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), 1);
5953 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5956 supported
[6] = sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5957 if (supported
[6] == SLJIT_SUCCESS
) {
5958 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 213);
5959 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -213);
5960 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_PRE
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5961 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5962 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5965 supported
[7] = sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5966 if (supported
[7] == SLJIT_SUCCESS
) {
5967 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_S2
, 0);
5968 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2 * sizeof(sljit_s32
));
5969 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -7890);
5970 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5971 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5974 supported
[8] = sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 2);
5975 if (supported
[8] == SLJIT_SUCCESS
) {
5976 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 2 * sizeof(sljit_sw
));
5977 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2 * sizeof(sljit_sw
));
5978 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 2);
5979 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5980 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 15 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5983 supported
[9] = sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5984 if (supported
[9] == SLJIT_SUCCESS
) {
5985 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 2 * sizeof(sljit_s8
));
5986 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -2 * (sljit_sw
)sizeof(sljit_s8
));
5987 sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0);
5988 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 16 * sizeof(sljit_sw
), SLJIT_R0
, 0);
5989 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 17 * sizeof(sljit_sw
), SLJIT_R1
, 0);
5992 SLJIT_ASSERT(sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 1) == SLJIT_ERR_UNSUPPORTED
);
5993 SLJIT_ASSERT(sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 1) == SLJIT_ERR_UNSUPPORTED
);
5995 #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
5996 /* TODO: at least for ARM (both V5 and V7) the range below needs further fixing */
5997 SLJIT_ASSERT(sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), 256) == SLJIT_ERR_UNSUPPORTED
);
5998 SLJIT_ASSERT(sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_R1
, SLJIT_MEM1(SLJIT_R0
), -257) == SLJIT_ERR_UNSUPPORTED
);
6001 sljit_emit_return_void(compiler
);
6003 code
.code
= sljit_generate_code(compiler
);
6005 sljit_free_compiler(compiler
);
6007 code
.func3((sljit_sw
)&wbuf
, (sljit_sw
)&bbuf
, (sljit_sw
)&ibuf
);
6009 FAILED(sizeof(expected
) != sizeof(supported
) / sizeof(sljit_s32
), "test60 case 1 failed\n");
6011 for (i
= 0; i
< sizeof(expected
); i
++) {
6013 if (supported
[i
] != SLJIT_SUCCESS
) {
6014 printf("tast60 case %d should be supported\n", i
+ 1);
6018 if (supported
[i
] == SLJIT_SUCCESS
) {
6019 printf("test60 case %d should not be supported\n", i
+ 1);
6025 FAILED(supported
[0] == SLJIT_SUCCESS
&& wbuf
[0] != -887766, "test60 case 2 failed\n");
6026 FAILED(supported
[0] == SLJIT_SUCCESS
&& wbuf
[1] != (sljit_sw
)(wbuf
+ 2), "test60 case 3 failed\n");
6027 FAILED(supported
[1] == SLJIT_SUCCESS
&& wbuf
[3] != -13, "test60 case 4 failed\n");
6028 FAILED(supported
[1] == SLJIT_SUCCESS
&& wbuf
[4] != (sljit_sw
)(bbuf
), "test60 case 5 failed\n");
6029 FAILED(supported
[2] == SLJIT_SUCCESS
&& wbuf
[5] != -5678, "test60 case 6 failed\n");
6030 FAILED(supported
[2] == SLJIT_SUCCESS
&& wbuf
[6] != (sljit_sw
)(ibuf
), "test60 case 7 failed\n");
6031 FAILED(supported
[3] == SLJIT_SUCCESS
&& ibuf
[1] != -8765, "test60 case 8 failed\n");
6032 FAILED(supported
[3] == SLJIT_SUCCESS
&& wbuf
[7] != (sljit_sw
)(ibuf
+ 1), "test60 case 9 failed\n");
6033 FAILED(supported
[4] == SLJIT_SUCCESS
&& bbuf
[0] != -121, "test60 case 10 failed\n");
6034 FAILED(supported
[4] == SLJIT_SUCCESS
&& wbuf
[8] != (sljit_sw
)(bbuf
) - 128 * (sljit_sw
)sizeof(sljit_s8
), "test60 case 11 failed\n");
6035 FAILED(supported
[5] == SLJIT_SUCCESS
&& wbuf
[9] != -881199, "test60 case 12 failed\n");
6036 FAILED(supported
[5] == SLJIT_SUCCESS
&& wbuf
[10] != (sljit_sw
)(wbuf
+ 9), "test60 case 13 failed\n");
6037 FAILED(supported
[6] == SLJIT_SUCCESS
&& wbuf
[11] != -5678, "test60 case 14 failed\n");
6038 FAILED(supported
[6] == SLJIT_SUCCESS
&& wbuf
[12] != (sljit_sw
)(ibuf
), "test60 case 15 failed\n");
6039 FAILED(supported
[7] == SLJIT_SUCCESS
&& ibuf
[2] != -7890, "test60 case 16 failed\n");
6040 FAILED(supported
[7] == SLJIT_SUCCESS
&& wbuf
[13] != (sljit_sw
)(ibuf
+ 2), "test60 case 17 failed\n");
6041 FAILED(supported
[8] == SLJIT_SUCCESS
&& wbuf
[14] != -887766, "test60 case 18 failed\n");
6042 FAILED(supported
[8] == SLJIT_SUCCESS
&& wbuf
[15] != (sljit_sw
)(wbuf
+ 10), "test60 case 19 failed\n");
6043 FAILED(supported
[9] == SLJIT_SUCCESS
&& wbuf
[16] != -13, "test60 case 20 failed\n");
6044 FAILED(supported
[9] == SLJIT_SUCCESS
&& wbuf
[17] != (sljit_sw
)(bbuf
), "test60 case 21 failed\n");
6046 sljit_free_code(code
.code
, NULL
);
6050 static void test61(void)
6052 /* Test float memory accesses with pre/post updates. */
6053 executable_code code
;
6054 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6056 sljit_s32 supported
[6];
6060 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
6061 static sljit_u8 expected
[6] = { 1, 1, 1, 1, 0, 0 };
6062 #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
6063 static sljit_u8 expected
[6] = { 1, 0, 1, 0, 1, 1 };
6065 static sljit_u8 expected
[6] = { 0, 0, 0, 0, 0, 0 };
6068 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
6070 printf("no fpu available, test61 skipped\n");
6073 sljit_free_compiler(compiler
);
6078 printf("Run test61\n");
6080 for (i
= 0; i
< 6; i
++)
6093 FAILED(!compiler
, "cannot create compiler\n");
6095 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 4, 3, 4, 0, sizeof(sljit_sw
));
6097 supported
[0] = sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_f64
));
6098 if (supported
[0] == SLJIT_SUCCESS
) {
6099 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 4 * sizeof(sljit_f64
));
6100 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_PRE
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_f64
));
6101 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
), SLJIT_FR0
, 0);
6102 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
6105 supported
[1] = sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_POST
, SLJIT_FR2
, SLJIT_MEM1(SLJIT_R0
), -(sljit_sw
)sizeof(sljit_f64
));
6106 if (supported
[1] == SLJIT_SUCCESS
) {
6107 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 2 * sizeof(sljit_f64
));
6108 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
6109 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_STORE
| SLJIT_MEM_POST
, SLJIT_FR2
, SLJIT_MEM1(SLJIT_R0
), -(sljit_sw
)sizeof(sljit_f64
));
6110 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
6113 supported
[2] = sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_FR1
, SLJIT_MEM1(SLJIT_R2
), -4 * (sljit_sw
)sizeof(sljit_f32
));
6114 if (supported
[2] == SLJIT_SUCCESS
) {
6115 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R2
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 4 * sizeof(sljit_f32
));
6116 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
6117 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_FR1
, SLJIT_MEM1(SLJIT_R2
), -4 * (sljit_sw
)sizeof(sljit_f32
));
6118 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R2
, 0);
6121 supported
[3] = sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_FR1
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_f32
));
6122 if (supported
[3] == SLJIT_SUCCESS
) {
6123 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S2
, 0, SLJIT_IMM
, sizeof(sljit_f32
));
6124 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_POST
, SLJIT_FR1
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_f32
));
6125 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_f32
), SLJIT_FR1
, 0);
6126 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R1
, 0);
6129 supported
[4] = sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 0);
6130 if (supported
[4] == SLJIT_SUCCESS
) {
6131 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 8 * sizeof(sljit_f64
));
6132 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -8 * (sljit_sw
)sizeof(sljit_f64
));
6133 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_PRE
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R0
), 0);
6134 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S1
), 3 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
6135 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R1
, 0);
6138 supported
[5] = sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_FR2
, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 0);
6139 if (supported
[5] == SLJIT_SUCCESS
) {
6140 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_S2
, 0);
6141 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 3 * sizeof(sljit_f32
));
6142 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
6143 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_STORE
| SLJIT_MEM_PRE
, SLJIT_FR2
, SLJIT_MEM2(SLJIT_R2
, SLJIT_R1
), 0);
6144 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R2
, 0);
6147 SLJIT_ASSERT(sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0) == SLJIT_ERR_UNSUPPORTED
);
6148 SLJIT_ASSERT(sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_SUPP
| SLJIT_MEM_STORE
| SLJIT_MEM_POST
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_R1
, SLJIT_R2
), 0) == SLJIT_ERR_UNSUPPORTED
);
6150 #if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
6151 /* TODO: at least for ARM (both V5 and V7) the range below needs further fixing */
6152 SLJIT_ASSERT(sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_PRE
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), 256) == SLJIT_ERR_UNSUPPORTED
);
6153 SLJIT_ASSERT(sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_SUPP
| SLJIT_MEM_POST
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), -257) == SLJIT_ERR_UNSUPPORTED
);
6156 sljit_emit_return_void(compiler
);
6158 code
.code
= sljit_generate_code(compiler
);
6160 sljit_free_compiler(compiler
);
6162 code
.func3((sljit_sw
)&wbuf
, (sljit_sw
)&dbuf
, (sljit_sw
)&sbuf
);
6164 FAILED(sizeof(expected
) != sizeof(supported
) / sizeof(sljit_s32
), "test61 case 1 failed\n");
6166 for (i
= 0; i
< sizeof(expected
); i
++) {
6168 if (supported
[i
] != SLJIT_SUCCESS
) {
6169 printf("tast61 case %d should be supported\n", i
+ 1);
6173 if (supported
[i
] == SLJIT_SUCCESS
) {
6174 printf("test61 case %d should not be supported\n", i
+ 1);
6180 FAILED(supported
[0] == SLJIT_SUCCESS
&& dbuf
[1] != 66.725, "test61 case 2 failed\n");
6181 FAILED(supported
[0] == SLJIT_SUCCESS
&& wbuf
[0] != (sljit_sw
)(dbuf
), "test61 case 3 failed\n");
6182 FAILED(supported
[1] == SLJIT_SUCCESS
&& dbuf
[2] != 66.725, "test61 case 4 failed\n");
6183 FAILED(supported
[1] == SLJIT_SUCCESS
&& wbuf
[1] != (sljit_sw
)(dbuf
+ 1), "test61 case 5 failed\n");
6184 FAILED(supported
[2] == SLJIT_SUCCESS
&& sbuf
[0] != -22.125, "test61 case 6 failed\n");
6185 FAILED(supported
[2] == SLJIT_SUCCESS
&& wbuf
[2] != (sljit_sw
)(sbuf
), "test61 case 7 failed\n");
6186 FAILED(supported
[3] == SLJIT_SUCCESS
&& sbuf
[2] != -22.125, "test61 case 8 failed\n");
6187 FAILED(supported
[3] == SLJIT_SUCCESS
&& wbuf
[3] != (sljit_sw
)(sbuf
+ 2), "test61 case 9 failed\n");
6188 FAILED(supported
[4] == SLJIT_SUCCESS
&& dbuf
[3] != 66.725, "test61 case 10 failed\n");
6189 FAILED(supported
[4] == SLJIT_SUCCESS
&& wbuf
[4] != (sljit_sw
)(dbuf
), "test61 case 11 failed\n");
6190 FAILED(supported
[5] == SLJIT_SUCCESS
&& sbuf
[3] != -22.125, "test61 case 12 failed\n");
6191 FAILED(supported
[5] == SLJIT_SUCCESS
&& wbuf
[5] != (sljit_sw
)(sbuf
+ 3), "test61 case 13 failed\n");
6193 sljit_free_code(code
.code
, NULL
);
6197 static void test62(void)
6199 /* Test fast calls flag preservation. */
6200 executable_code code1
;
6201 executable_code code2
;
6202 struct sljit_compiler
* compiler
;
6205 printf("Run test62\n");
6208 compiler
= sljit_create_compiler(NULL
, NULL
);
6209 FAILED(!compiler
, "cannot create compiler\n");
6210 sljit_set_context(compiler
, 0, SLJIT_ARGS1(W
, W
), 1, 1, 0, 0, 0);
6212 sljit_emit_fast_enter(compiler
, SLJIT_R0
, 0);
6213 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
| SLJIT_SET_LESS
, SLJIT_S0
, 0, SLJIT_IMM
, 42);
6214 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_R0
, 0);
6216 code1
.code
= sljit_generate_code(compiler
);
6218 sljit_free_compiler(compiler
);
6221 compiler
= sljit_create_compiler(NULL
, NULL
);
6222 FAILED(!compiler
, "cannot create compiler\n");
6224 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, W
), 1, 1, 0, 0, 0);
6225 sljit_emit_ijump(compiler
, SLJIT_FAST_CALL
, SLJIT_IMM
, SLJIT_FUNC_ADDR(code1
.code
));
6226 sljit_set_current_flags(compiler
, SLJIT_CURRENT_FLAGS_SUB
| SLJIT_CURRENT_FLAGS_COMPARE
| SLJIT_SET_Z
| SLJIT_SET_LESS
);
6227 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_ZERO
);
6228 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_LESS
);
6229 sljit_emit_op2(compiler
, SLJIT_SHL
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, 1);
6230 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_S0
, 0);
6231 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
6233 code2
.code
= sljit_generate_code(compiler
);
6235 sljit_free_compiler(compiler
);
6237 FAILED(code2
.func1(88) != 0, "test62 case 1 failed\n");
6238 FAILED(code2
.func1(42) != 1, "test62 case 2 failed\n");
6239 FAILED(code2
.func1(0) != 2, "test62 case 3 failed\n");
6241 sljit_free_code(code1
.code
, NULL
);
6242 sljit_free_code(code2
.code
, NULL
);
6246 static void test63(void)
6248 /* Test put label. */
6249 executable_code code
;
6250 struct sljit_label
*label
[2];
6251 struct sljit_put_label
*put_label
[5];
6252 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6255 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
6256 sljit_sw offs
= SLJIT_W(0x123456789012);
6258 sljit_sw offs
= 0x12345678;
6262 printf("Run test63\n");
6264 FAILED(!compiler
, "cannot create compiler\n");
6270 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 2 * sizeof(sljit_sw
));
6272 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_R0
, 0);
6273 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
6275 put_label
[1] = sljit_emit_put_label(compiler
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
));
6276 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
));
6278 label
[0] = sljit_emit_label(compiler
);
6279 sljit_set_put_label(put_label
[0], label
[0]);
6280 sljit_set_put_label(put_label
[1], label
[0]);
6282 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)(buf
+ 2) - offs
);
6283 put_label
[2] = sljit_emit_put_label(compiler
, SLJIT_MEM1(SLJIT_R0
), offs
);
6285 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (offs
+ (sljit_sw
)sizeof(sljit_uw
)) >> 1);
6286 put_label
[3] = sljit_emit_put_label(compiler
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1);
6288 label
[1] = sljit_emit_label(compiler
);
6289 sljit_set_put_label(put_label
[2], label
[1]);
6290 sljit_set_put_label(put_label
[3], label
[1]);
6292 put_label
[4] = sljit_emit_put_label(compiler
, SLJIT_RETURN_REG
, 0);
6293 sljit_set_put_label(put_label
[4], label
[0]);
6294 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
6296 code
.code
= sljit_generate_code(compiler
);
6299 addr
[0] = sljit_get_label_addr(label
[0]);
6300 addr
[1] = sljit_get_label_addr(label
[1]);
6302 sljit_free_compiler(compiler
);
6304 FAILED(code
.func1((sljit_sw
)&buf
) != (sljit_sw
)addr
[0], "test63 case 1 failed\n");
6305 FAILED(buf
[0] != addr
[0], "test63 case 2 failed\n");
6306 FAILED(buf
[1] != addr
[0], "test63 case 3 failed\n");
6307 FAILED(buf
[2] != addr
[1], "test63 case 4 failed\n");
6308 FAILED(buf
[3] != addr
[1], "test63 case 5 failed\n");
6310 sljit_free_code(code
.code
, NULL
);
6314 static void test64(void)
6316 /* Test put label with absolute label addresses */
6317 executable_code code
;
6318 sljit_uw malloc_addr
;
6319 struct sljit_label label
[6];
6320 struct sljit_put_label
*put_label
[2];
6321 struct sljit_compiler
* compiler
;
6324 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
6325 /* Must be even because it is also used for addressing. */
6326 sljit_sw offs1
= SLJIT_W(0x1234567812l
);
6327 sljit_sw offs2
= SLJIT_W(0x123456781122l
);
6328 sljit_sw offs3
= SLJIT_W(0x7fffffff7ffl
);
6329 sljit_sw offs4
= SLJIT_W(0x1234567811223344l
);
6330 #else /* !SLJIT_64BIT_ARCHITECTURE */
6331 sljit_sw offs1
= (sljit_sw
)0x80000000;
6332 sljit_sw offs2
= (sljit_sw
)0xe0000000;
6333 sljit_sw offs3
= (sljit_sw
)0x87654321;
6334 sljit_sw offs4
= (sljit_sw
)0xffffffff;
6335 #endif /* SLJIT_64BIT_ARCHITECTURE */
6338 printf("Run test64\n");
6340 /* lock next allocation; see sljit_test_malloc_exec() */
6341 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
6342 malloc_addr
= (sljit_uw
)SLJIT_MALLOC_EXEC(1024, NULL
);
6345 printf("Cannot allocate executable memory\n");
6349 compiler
= sljit_create_compiler(NULL
, (void*)malloc_addr
);
6350 malloc_addr
+= (sljit_uw
)SLJIT_EXEC_OFFSET((void*)malloc_addr
);
6351 #else /* SLJIT_CONFIG_UNSUPPORTED */
6353 compiler
= sljit_create_compiler(NULL
, (void*)malloc_addr
);
6354 #endif /* !SLJIT_CONFIG_UNSUPPORTED */
6356 label
[0].addr
= 0x1234;
6357 label
[0].size
= (sljit_uw
)0x1234 - malloc_addr
;
6359 label
[1].addr
= 0x12345678;
6360 label
[1].size
= (sljit_uw
)0x12345678 - malloc_addr
;
6362 label
[2].addr
= (sljit_uw
)offs1
;
6363 label
[2].size
= (sljit_uw
)offs1
- malloc_addr
;
6365 label
[3].addr
= (sljit_uw
)offs2
;
6366 label
[3].size
= (sljit_uw
)offs2
- malloc_addr
;
6368 label
[4].addr
= (sljit_uw
)offs3
;
6369 label
[4].size
= (sljit_uw
)offs3
- malloc_addr
;
6371 label
[5].addr
= (sljit_uw
)offs4
;
6372 label
[5].size
= (sljit_uw
)offs4
- malloc_addr
;
6374 FAILED(!compiler
, "cannot create compiler\n");
6376 for (i
= 0; i
< 6; i
++)
6379 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, P
), 3, 1, 0, 0, 2 * sizeof(sljit_sw
));
6381 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_R0
, 0);
6382 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
6384 put_label
[1] = sljit_emit_put_label(compiler
, SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
));
6385 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_uw
), SLJIT_MEM1(SLJIT_SP
), sizeof(sljit_uw
));
6387 sljit_set_put_label(put_label
[0], &label
[0]);
6388 sljit_set_put_label(put_label
[1], &label
[0]);
6390 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)(buf
+ 2) - offs1
);
6391 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_MEM1(SLJIT_R0
), offs1
);
6393 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (offs1
+ (sljit_sw
)sizeof(sljit_uw
)) >> 1);
6394 put_label
[1] = sljit_emit_put_label(compiler
, SLJIT_MEM2(SLJIT_R0
, SLJIT_R1
), 1);
6396 sljit_set_put_label(put_label
[0], &label
[1]);
6397 sljit_set_put_label(put_label
[1], &label
[1]);
6399 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_R1
, 0);
6400 sljit_set_put_label(put_label
[0], &label
[2]);
6401 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_uw
), SLJIT_R1
, 0);
6403 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_R2
, 0);
6404 sljit_set_put_label(put_label
[0], &label
[3]);
6405 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_uw
), SLJIT_R2
, 0);
6407 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_R1
, 0);
6408 sljit_set_put_label(put_label
[0], &label
[4]);
6409 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_uw
), SLJIT_R1
, 0);
6411 put_label
[0] = sljit_emit_put_label(compiler
, SLJIT_RETURN_REG
, 0);
6412 sljit_set_put_label(put_label
[0], &label
[5]);
6413 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
6415 code
.code
= sljit_generate_code(compiler
);
6417 sljit_free_compiler(compiler
);
6418 SLJIT_ASSERT(SLJIT_FUNC_UADDR(code
.code
) >= malloc_addr
&& SLJIT_FUNC_UADDR(code
.code
) <= malloc_addr
+ 8);
6420 FAILED(code
.func1((sljit_sw
)&buf
) != (sljit_sw
)label
[5].addr
, "test64 case 1 failed\n");
6421 FAILED(buf
[0] != label
[0].addr
, "test64 case 2 failed\n");
6422 FAILED(buf
[1] != label
[0].addr
, "test64 case 3 failed\n");
6423 FAILED(buf
[2] != label
[1].addr
, "test64 case 4 failed\n");
6424 FAILED(buf
[3] != label
[1].addr
, "test64 case 5 failed\n");
6425 FAILED(buf
[4] != label
[2].addr
, "test64 case 6 failed\n");
6426 FAILED(buf
[5] != label
[3].addr
, "test64 case 7 failed\n");
6427 FAILED(buf
[6] != label
[4].addr
, "test64 case 8 failed\n");
6429 sljit_free_code(code
.code
, NULL
);
6434 static void test65(void)
6436 /* Test jump tables. */
6437 executable_code code
;
6438 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6440 /* Normally this table is allocated on the heap. */
6442 struct sljit_label
*labels
[64];
6443 struct sljit_jump
*jump
;
6446 printf("Run test65\n");
6448 FAILED(!compiler
, "cannot create compiler\n");
6450 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, W
, W
), 1, 2, 0, 0, 0);
6452 jump
= sljit_emit_cmp(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_S0
, 0, SLJIT_IMM
, 64);
6453 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)addr
);
6454 sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_MEM2(SLJIT_R0
, SLJIT_S0
), SLJIT_WORD_SHIFT
);
6456 for (i
= 0; i
< 64; i
++) {
6457 labels
[i
] = sljit_emit_label(compiler
);
6458 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
6459 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, i
* 2);
6460 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
6463 sljit_set_label(jump
, sljit_emit_label(compiler
));
6464 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_IMM
, -1);
6466 code
.code
= sljit_generate_code(compiler
);
6469 for (i
= 0; i
< 64; i
++) {
6470 addr
[i
] = sljit_get_label_addr(labels
[i
]);
6473 sljit_free_compiler(compiler
);
6475 FAILED(code
.func2(64, 0) != -1, "test65 case 1 failed\n");
6477 for (i
= 0; i
< 64; i
++) {
6478 FAILED(code
.func2(i
, i
* 2) != i
* 4, "test65 case 2 failed\n");
6481 sljit_free_code(code
.code
, NULL
);
6485 static void test66(void)
6487 /* Test direct jumps (computed goto). */
6488 executable_code code
;
6489 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6492 struct sljit_label
*labels
[64];
6495 printf("Run test66\n");
6497 FAILED(!compiler
, "cannot create compiler\n");
6499 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(W
, W
, W
), 1, 2, 0, 0, 0);
6500 sljit_emit_ijump(compiler
, SLJIT_JUMP
, SLJIT_S0
, 0);
6502 for (i
= 0; i
< 64; i
++) {
6503 labels
[i
] = sljit_emit_label(compiler
);
6504 sljit_emit_op0(compiler
, SLJIT_ENDBR
);
6505 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, i
* 2);
6506 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_RETURN_REG
, 0);
6509 code
.code
= sljit_generate_code(compiler
);
6512 for (i
= 0; i
< 64; i
++) {
6513 addr
[i
] = sljit_get_label_addr(labels
[i
]);
6516 sljit_free_compiler(compiler
);
6518 for (i
= 0; i
< 64; i
++) {
6519 FAILED(code
.func2((sljit_sw
)addr
[i
], i
) != i
* 3, "test66 case 1 failed\n");
6522 sljit_free_code(code
.code
, NULL
);
6526 static void test67(void)
6528 /* Test skipping returns from fast calls (return type is fast). */
6529 executable_code code
;
6530 struct sljit_compiler
*compiler
= sljit_create_compiler(NULL
, NULL
);
6531 struct sljit_jump
*call
, *jump
;
6532 struct sljit_label
*label
;
6535 printf("Run test67\n");
6537 FAILED(!compiler
, "cannot create compiler\n");
6539 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 3, 1, 0, 0, 0);
6541 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
6542 call
= sljit_emit_jump(compiler
, SLJIT_FAST_CALL
);
6544 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
6546 /* First function, never returns. */
6547 label
= sljit_emit_label(compiler
);
6548 sljit_set_label(call
, label
);
6549 sljit_emit_fast_enter(compiler
, SLJIT_R1
, 0);
6551 call
= sljit_emit_jump(compiler
, SLJIT_FAST_CALL
);
6553 /* Should never return here, marked by a segmentation fault if it does. */
6554 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
6556 /* Second function, skips the first function. */
6557 sljit_set_label(call
, sljit_emit_label(compiler
));
6558 sljit_emit_fast_enter(compiler
, SLJIT_R2
, 0);
6560 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
6562 jump
= sljit_emit_cmp(compiler
, SLJIT_NOT_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
6564 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_R1
, 0);
6565 sljit_set_label(sljit_emit_jump(compiler
, SLJIT_FAST_CALL
), label
);
6566 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
6567 sljit_emit_op_src(compiler
, SLJIT_SKIP_FRAMES_BEFORE_FAST_RETURN
, SLJIT_S0
, 0);
6568 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_S0
, 0);
6570 sljit_set_label(jump
, sljit_emit_label(compiler
));
6571 sljit_emit_op_src(compiler
, SLJIT_SKIP_FRAMES_BEFORE_FAST_RETURN
, SLJIT_R1
, 0);
6572 sljit_emit_op_src(compiler
, SLJIT_FAST_RETURN
, SLJIT_R1
, 0);
6574 code
.code
= sljit_generate_code(compiler
);
6577 sljit_free_compiler(compiler
);
6579 FAILED(code
.func0() != 3, "test67 case 1 failed\n");
6581 sljit_free_code(code
.code
, NULL
);
6585 static void test68(void)
6587 /* Test skipping returns from fast calls (return type is normal). */
6588 executable_code code
;
6589 struct sljit_compiler
*compiler
;
6590 struct sljit_jump
*call
, *jump
;
6591 struct sljit_label
*label
;
6595 printf("Run test68\n");
6597 for (i
= 0; i
< 6; i
++) {
6598 compiler
= sljit_create_compiler(NULL
, NULL
);
6599 FAILED(!compiler
, "cannot create compiler\n");
6601 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 2 + (i
% 6), (i
% 6), 0, 0, 0);
6603 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
6604 call
= sljit_emit_jump(compiler
, SLJIT_FAST_CALL
);
6606 /* Should never return here, marked by a segmentation fault if it does. */
6607 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
6609 /* Recursive fast call. */
6610 label
= sljit_emit_label(compiler
);
6611 sljit_set_label(call
, label
);
6612 sljit_emit_fast_enter(compiler
, SLJIT_R1
, 0);
6614 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
6616 jump
= sljit_emit_cmp(compiler
, SLJIT_GREATER_EQUAL
, SLJIT_R0
, 0, SLJIT_IMM
, 4);
6618 sljit_set_label(sljit_emit_jump(compiler
, SLJIT_FAST_CALL
), label
);
6620 sljit_set_label(jump
, sljit_emit_label(compiler
));
6621 sljit_emit_op0(compiler
, SLJIT_SKIP_FRAMES_BEFORE_RETURN
);
6622 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
6624 code
.code
= sljit_generate_code(compiler
);
6627 sljit_free_compiler(compiler
);
6629 if (SLJIT_UNLIKELY(code
.func0() != 4)) {
6630 printf("test68 case %d failed\n", i
+ 1);
6633 sljit_free_code(code
.code
, NULL
);
6639 static void test69(void)
6641 /* Test sljit_set_current_flags. */
6642 executable_code code
;
6643 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6648 printf("Run test69\n");
6650 for (i
= 0; i
< 8; i
++)
6653 FAILED(!compiler
, "cannot create compiler\n");
6655 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 3, 1, 0, 0, 0);
6657 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)1 << ((sizeof (sljit_sw
) * 8) - 2));
6658 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
6659 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
6660 sljit_emit_label(compiler
);
6661 sljit_set_current_flags(compiler
, SLJIT_SET_OVERFLOW
| SLJIT_CURRENT_FLAGS_ADD
);
6662 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_OVERFLOW
);
6664 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
6665 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
6666 sljit_emit_label(compiler
);
6667 sljit_set_current_flags(compiler
, SLJIT_SET_OVERFLOW
| SLJIT_CURRENT_FLAGS_ADD
);
6668 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_OVERFLOW
);
6670 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_R0
, 0);
6671 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
6672 sljit_emit_label(compiler
);
6673 sljit_set_current_flags(compiler
, SLJIT_SET_OVERFLOW
);
6674 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
6676 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 5);
6677 sljit_emit_op2(compiler
, SLJIT_MUL
| SLJIT_SET_OVERFLOW
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R1
, 0);
6678 sljit_emit_label(compiler
);
6679 sljit_set_current_flags(compiler
, SLJIT_SET_OVERFLOW
);
6680 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_OVERFLOW
);
6682 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 6);
6683 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 5);
6684 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_GREATER
, SLJIT_R1
, 0, SLJIT_R2
, 0);
6685 sljit_emit_label(compiler
);
6686 sljit_set_current_flags(compiler
, SLJIT_SET_GREATER
| SLJIT_CURRENT_FLAGS_SUB
| SLJIT_CURRENT_FLAGS_COMPARE
);
6687 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_GREATER
);
6689 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_R2
, 0);
6690 sljit_emit_label(compiler
);
6691 sljit_set_current_flags(compiler
, SLJIT_SET_Z
| SLJIT_CURRENT_FLAGS_SUB
| SLJIT_CURRENT_FLAGS_COMPARE
);
6692 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_ZERO
);
6694 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)(1u << 31));
6695 sljit_emit_op2u(compiler
, SLJIT_ADD32
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_R1
, 0);
6696 sljit_emit_label(compiler
);
6697 sljit_set_current_flags(compiler
, SLJIT_SET_Z
| SLJIT_CURRENT_FLAGS_32
| SLJIT_CURRENT_FLAGS_ADD
);
6698 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_ZERO
);
6700 sljit_emit_op2u(compiler
, SLJIT_SHL32
| SLJIT_SET_Z
, SLJIT_R1
, 0, SLJIT_IMM
, 1);
6701 sljit_emit_label(compiler
);
6702 sljit_set_current_flags(compiler
, SLJIT_SET_Z
| SLJIT_CURRENT_FLAGS_32
);
6703 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_NOT_ZERO
);
6705 sljit_emit_return_void(compiler
);
6707 code
.code
= sljit_generate_code(compiler
);
6709 sljit_free_compiler(compiler
);
6711 code
.func1((sljit_sw
)&buf
);
6713 FAILED(buf
[0] != 1, "test69 case 1 failed\n");
6714 FAILED(buf
[1] != 2, "test69 case 2 failed\n");
6715 FAILED(buf
[2] != 1, "test69 case 3 failed\n");
6716 FAILED(buf
[3] != 2, "test69 case 4 failed\n");
6717 FAILED(buf
[4] != 1, "test69 case 5 failed\n");
6718 FAILED(buf
[5] != 2, "test69 case 6 failed\n");
6719 FAILED(buf
[6] != 1, "test69 case 7 failed\n");
6720 FAILED(buf
[7] != 2, "test69 case 8 failed\n");
6722 sljit_free_code(code
.code
, NULL
);
6726 static void test70(void)
6728 /* Test argument passing to sljit_emit_enter. */
6729 executable_code code
;
6730 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
6737 printf("Run test70\n");
6744 FAILED(!compiler
, "cannot create compiler\n");
6746 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, 32, W
, 32, W
), 1, 4, 0, 0, 0);
6747 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
6748 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S1
, 0);
6749 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S3
, 0);
6750 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
6751 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
6752 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_s32
), SLJIT_S2
, 0);
6753 sljit_emit_return_void(compiler
);
6755 code
.code
= sljit_generate_code(compiler
);
6757 sljit_free_compiler(compiler
);
6759 code
.test70_f1(-1478, 9476, 4928, -6832);
6761 FAILED(wbuf
[0] != 9476, "test70 case 1 failed\n");
6762 FAILED(wbuf
[1] != -6832, "test70 case 2 failed\n");
6763 FAILED(ibuf
[0] != -1478, "test70 case 3 failed\n");
6764 FAILED(ibuf
[1] != 4928, "test70 case 4 failed\n");
6766 sljit_free_code(code
.code
, NULL
);
6768 compiler
= sljit_create_compiler(NULL
, NULL
);
6769 FAILED(!compiler
, "cannot create compiler\n");
6771 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS4(VOID
, 32, 32, W
, W
), 1, 4, 0, 0, 0);
6772 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
6773 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
6774 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S1
, 0);
6775 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
6776 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S2
, 0);
6777 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_s32
), SLJIT_S3
, 0);
6778 sljit_emit_return_void(compiler
);
6780 code
.code
= sljit_generate_code(compiler
);
6782 sljit_free_compiler(compiler
);
6784 code
.test70_f2(4721, 7892, -3579, -4830);
6786 FAILED(wbuf
[0] != 4721, "test70 case 5 failed\n");
6787 FAILED(wbuf
[1] != 7892, "test70 case 6 failed\n");
6788 FAILED(ibuf
[0] != -3579, "test70 case 7 failed\n");
6789 FAILED(ibuf
[1] != -4830, "test70 case 8 failed\n");
6791 sljit_free_code(code
.code
, NULL
);
6793 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
6799 compiler
= sljit_create_compiler(NULL
, NULL
);
6800 FAILED(!compiler
, "cannot create compiler\n");
6802 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, 32, F32
, W
, F64
), 2, 2, 2, 0, 0);
6803 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&wbuf
, SLJIT_S1
, 0);
6804 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&ibuf
, SLJIT_S0
, 0);
6805 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM0(), (sljit_sw
)&dbuf
, SLJIT_FR1
, 0);
6806 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM0(), (sljit_sw
)&fbuf
, SLJIT_FR0
, 0);
6807 sljit_emit_return_void(compiler
);
6809 code
.code
= sljit_generate_code(compiler
);
6811 sljit_free_compiler(compiler
);
6813 code
.test70_f3(-6834, 674.5, 2789, -895.25);
6815 FAILED(wbuf
[0] != 2789, "test70 case 9 failed\n");
6816 FAILED(ibuf
[0] != -6834, "test70 case 10 failed\n");
6817 FAILED(dbuf
[0] != -895.25, "test70 case 11 failed\n");
6818 FAILED(fbuf
[0] != 674.5, "test70 case 12 failed\n");
6825 compiler
= sljit_create_compiler(NULL
, NULL
);
6826 FAILED(!compiler
, "cannot create compiler\n");
6828 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F32
, F64
, F32
, 32), 1, 1, 3, 0, 0);
6829 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&ibuf
, SLJIT_S0
, 0);
6830 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM0(), (sljit_sw
)&dbuf
, SLJIT_FR1
, 0);
6831 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&fbuf
);
6832 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
6833 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f32
), SLJIT_FR2
, 0);
6834 sljit_emit_return_void(compiler
);
6836 code
.code
= sljit_generate_code(compiler
);
6838 sljit_free_compiler(compiler
);
6840 code
.test70_f4(-4712.5, 5342.25, 2904.25, -4607);
6842 FAILED(ibuf
[0] != -4607, "test70 case 13 failed\n");
6843 FAILED(dbuf
[0] != 5342.25, "test70 case 14 failed\n");
6844 FAILED(fbuf
[0] != -4712.5, "test70 case 15 failed\n");
6845 FAILED(fbuf
[1] != 2904.25, "test70 case 16 failed\n");
6852 compiler
= sljit_create_compiler(NULL
, NULL
);
6853 FAILED(!compiler
, "cannot create compiler\n");
6855 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F32
, 32, F32
), 1, 1, 3, 0, 0);
6856 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&ibuf
, SLJIT_S0
, 0);
6857 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM0(), (sljit_sw
)&dbuf
, SLJIT_FR0
, 0);
6858 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&fbuf
);
6859 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR1
, 0);
6860 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f32
), SLJIT_FR2
, 0);
6862 sljit_emit_return_void(compiler
);
6864 code
.code
= sljit_generate_code(compiler
);
6866 sljit_free_compiler(compiler
);
6868 code
.test70_f5(3578.5, 4619.25, 6859, -1807.75);
6870 FAILED(ibuf
[0] != 6859, "test70 case 17 failed\n");
6871 FAILED(dbuf
[0] != 3578.5, "test70 case 18 failed\n");
6872 FAILED(fbuf
[0] != 4619.25, "test70 case 19 failed\n");
6873 FAILED(fbuf
[1] != -1807.75, "test70 case 20 failed\n");
6880 compiler
= sljit_create_compiler(NULL
, NULL
);
6881 FAILED(!compiler
, "cannot create compiler\n");
6883 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, 32, F32
, F64
), SLJIT_NUMBER_OF_SCRATCH_REGISTERS
+ 2, 1, 3, 0, 33);
6884 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&ibuf
, SLJIT_S0
, 0);
6885 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
6886 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
6887 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR2
, 0);
6888 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM0(), (sljit_sw
)&fbuf
, SLJIT_FR1
, 0);
6889 sljit_emit_return_void(compiler
);
6891 code
.code
= sljit_generate_code(compiler
);
6893 sljit_free_compiler(compiler
);
6895 code
.test70_f6(2740.75, -2651, -7909.25, 3671.5);
6897 FAILED(ibuf
[0] != -2651, "test70 case 21 failed\n");
6898 FAILED(dbuf
[0] != 2740.75, "test70 case 22 failed\n");
6899 FAILED(dbuf
[1] != 3671.5, "test70 case 23 failed\n");
6900 FAILED(fbuf
[0] != -7909.25, "test70 case 24 failed\n");
6907 compiler
= sljit_create_compiler(NULL
, NULL
);
6908 FAILED(!compiler
, "cannot create compiler\n");
6910 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F32
, 32, W
, 32), 1, 3, 1, 0, 1);
6911 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&wbuf
, SLJIT_S1
, 0);
6912 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
6913 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
6914 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_s32
), SLJIT_S2
, 0);
6915 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM0(), (sljit_sw
)&fbuf
, SLJIT_FR0
, 0);
6916 sljit_emit_return_void(compiler
);
6918 code
.code
= sljit_generate_code(compiler
);
6920 sljit_free_compiler(compiler
);
6922 code
.test70_f7(-5219.25, -4530, 7214, 6741);
6924 FAILED(wbuf
[0] != 7214, "test70 case 25 failed\n");
6925 FAILED(ibuf
[0] != -4530, "test70 case 26 failed\n");
6926 FAILED(ibuf
[1] != 6741, "test70 case 27 failed\n");
6927 FAILED(fbuf
[0] != -5219.25, "test70 case 28 failed\n");
6934 compiler
= sljit_create_compiler(NULL
, NULL
);
6935 FAILED(!compiler
, "cannot create compiler\n");
6937 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F64
, W
, W
), 1, 5, 2, 0, SLJIT_MAX_LOCAL_SIZE
- 1);
6938 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_S0
, 0);
6939 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_SP
), SLJIT_MAX_LOCAL_SIZE
- 2 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
6940 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
6941 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
6942 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S1
, 0);
6943 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
6944 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
6945 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR1
, 0);
6946 sljit_emit_return_void(compiler
);
6948 code
.code
= sljit_generate_code(compiler
);
6950 sljit_free_compiler(compiler
);
6952 code
.test70_f8(-3749.75, 5280.5, 9134, -6506);
6954 FAILED(wbuf
[0] != 9134, "test70 case 29 failed\n");
6955 FAILED(wbuf
[1] != -6506, "test70 case 30 failed\n");
6956 FAILED(dbuf
[0] != -3749.75, "test70 case 31 failed\n");
6957 FAILED(dbuf
[1] != 5280.5, "test70 case 32 failed\n");
6964 compiler
= sljit_create_compiler(NULL
, NULL
);
6965 FAILED(!compiler
, "cannot create compiler\n");
6967 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F64
, W
, F64
), 1, 1, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
6968 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&wbuf
, SLJIT_S0
, 0);
6969 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
6970 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
6971 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR1
, 0);
6972 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_f64
), SLJIT_FR2
, 0);
6974 sljit_emit_return_void(compiler
);
6976 code
.code
= sljit_generate_code(compiler
);
6978 sljit_free_compiler(compiler
);
6980 code
.test70_f9(-6049.25, 7301.5, 4610, -4312.75);
6982 FAILED(wbuf
[0] != 4610, "test70 case 33 failed\n");
6983 FAILED(dbuf
[0] != -6049.25, "test70 case 34 failed\n");
6984 FAILED(dbuf
[1] != 7301.5, "test70 case 35 failed\n");
6985 FAILED(dbuf
[2] != -4312.75, "test70 case 36 failed\n");
6992 compiler
= sljit_create_compiler(NULL
, NULL
);
6993 FAILED(!compiler
, "cannot create compiler\n");
6995 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F64
, F64
, 32), 1, 1, 3, 0, 0);
6996 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM0(), (sljit_sw
)&ibuf
, SLJIT_S0
, 0);
6997 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
6998 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
6999 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR1
, 0);
7000 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_f64
), SLJIT_FR2
, 0);
7002 sljit_emit_return_void(compiler
);
7004 code
.code
= sljit_generate_code(compiler
);
7006 sljit_free_compiler(compiler
);
7008 code
.test70_f10(4810.5, -9148.75, 8601.25, 6703);
7010 FAILED(ibuf
[0] != 6703, "test70 case 37 failed\n");
7011 FAILED(dbuf
[0] != 4810.5, "test70 case 38 failed\n");
7012 FAILED(dbuf
[1] != -9148.75, "test70 case 39 failed\n");
7013 FAILED(dbuf
[2] != 8601.25, "test70 case 40 failed\n");
7019 #if !(defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
7021 static sljit_sw SLJIT_FUNC
test71_f1(sljit_sw a
)
7026 static sljit_sw SLJIT_FUNC
test71_f2(sljit_sw a
, sljit_s32 b
, sljit_s32 c
, sljit_sw d
)
7028 return a
| b
| c
| d
;
7031 static sljit_sw
test71_f3(sljit_sw a
, sljit_s32 b
, sljit_s32 c
, sljit_sw d
)
7033 return a
| b
| c
| d
;
7036 static sljit_sw
test71_f4(sljit_sw a
, sljit_s32 b
, sljit_s32 c
, sljit_sw d
)
7038 SLJIT_UNUSED_ARG(a
);
7042 static sljit_sw
test71_f5(void)
7047 static sljit_sw SLJIT_FUNC
test71_f6(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
, sljit_f64 d
)
7049 if (a
== 1345.5 && b
== -8724.25 && c
== 9034.75 && d
== 6307.5)
7054 static sljit_sw SLJIT_FUNC
test71_f7(sljit_f64 a
, sljit_f64 b
, sljit_f64 c
, sljit_sw d
)
7056 if (a
== 4061.25 && b
== -3291.75 && c
== 8703.5 && d
== 1706)
7061 #endif /* !SLJIT_CONFIG_SPARC */
7063 static void test71(void)
7065 #if !(defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
7066 /* Test tail calls. */
7067 executable_code code
;
7068 struct sljit_compiler
* compiler
;
7069 struct sljit_jump
*jump
;
7071 sljit_sw executable_offset
;
7076 printf("Run test71\n");
7080 compiler
= sljit_create_compiler(NULL
, NULL
);
7081 FAILED(!compiler
, "cannot create compiler\n");
7083 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, W
), 4, 4, 0, 0, 0);
7084 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
7085 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0);
7086 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0);
7087 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0);
7088 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -1);
7089 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
7090 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
7091 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, -1);
7092 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS1(W
, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f1
));
7094 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7096 code
.code
= sljit_generate_code(compiler
);
7098 sljit_free_compiler(compiler
);
7100 FAILED(code
.func1(7987) != 17987, "test71 case 1 failed\n");
7104 compiler
= sljit_create_compiler(NULL
, NULL
);
7105 FAILED(!compiler
, "cannot create compiler\n");
7107 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(W
, W
), 1, 4, 0, 0, 0);
7108 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
7109 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -1);
7110 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
7111 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
7112 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, -1);
7113 jump
= sljit_emit_call(compiler
, SLJIT_CALL
| SLJIT_REWRITABLE_JUMP
| SLJIT_CALL_RETURN
, SLJIT_ARGS1(W
, W
));
7114 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7116 sljit_set_target(jump
, 0);
7118 code
.code
= sljit_generate_code(compiler
);
7121 executable_offset
= sljit_get_executable_offset(compiler
);
7122 jump_addr
= sljit_get_jump_addr(jump
);
7123 sljit_free_compiler(compiler
);
7125 sljit_set_jump_addr(jump_addr
, SLJIT_FUNC_UADDR(test71_f1
), executable_offset
);
7127 FAILED(code
.func1(3903) != 13903, "test71 case 2 failed\n");
7131 compiler
= sljit_create_compiler(NULL
, NULL
);
7132 FAILED(!compiler
, "cannot create compiler\n");
7134 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 4, 2, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
7135 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_SP
), 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f2
));
7136 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x28000000);
7137 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 0x00140000);
7138 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_IMM
, 0x00002800);
7139 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x00000041);
7140 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -1);
7141 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
7142 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_MEM1(SLJIT_SP
), 0);
7143 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7145 code
.code
= sljit_generate_code(compiler
);
7147 sljit_free_compiler(compiler
);
7149 FAILED(code
.func0() != 0x28142841, "test71 case 3 failed\n");
7153 compiler
= sljit_create_compiler(NULL
, NULL
);
7154 FAILED(!compiler
, "cannot create compiler\n");
7156 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS4(W
, W
, 32, 32, W
), 4, 4, 0, 0, 9);
7157 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
7158 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_S1
, 0);
7159 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_S2
, 0);
7160 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_S3
, 0);
7161 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f2
));
7162 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7164 code
.code
= sljit_generate_code(compiler
);
7166 sljit_free_compiler(compiler
);
7168 FAILED(code
.test71_f1(0x650000, 0x13, 0x8400, 0x29000000) != 0x29658413, "test71 case 4 failed\n");
7170 sljit_free_code(code
.code
, NULL
);
7174 compiler
= sljit_create_compiler(NULL
, NULL
);
7175 FAILED(!compiler
, "cannot create compiler\n");
7177 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(W
), 4, 4, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
7178 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f2
));
7179 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)0x81000000);
7180 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 0x00480000);
7181 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_IMM
, 0x00002100);
7182 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x00000014);
7183 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -1);
7184 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
7185 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
7186 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_S3
, 0);
7187 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7189 code
.code
= sljit_generate_code(compiler
);
7191 sljit_free_compiler(compiler
);
7193 FAILED(code
.func0() != (sljit_sw
)0x81482114, "test71 case 5 failed\n");
7195 sljit_free_code(code
.code
, NULL
);
7199 compiler
= sljit_create_compiler(NULL
, NULL
);
7200 FAILED(!compiler
, "cannot create compiler\n");
7202 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, W
, W
, W
), 4, 4, 0, 0, 0);
7203 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S0
, 0);
7204 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_S1
, 0);
7205 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_S2
, 0);
7206 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x48000000);
7207 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -1);
7208 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
7209 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
7210 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S3
, 0, SLJIT_IMM
, -1);
7211 sljit_emit_icall(compiler
, SLJIT_CALL_CDECL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f3
));
7212 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7214 code
.code
= sljit_generate_code(compiler
);
7216 sljit_free_compiler(compiler
);
7218 FAILED(code
.func3(0x12, 0x8800, 0x240000) != 0x48248812, "test71 case 6 failed\n");
7220 sljit_free_code(code
.code
, NULL
);
7224 compiler
= sljit_create_compiler(NULL
, NULL
);
7225 FAILED(!compiler
, "cannot create compiler\n");
7227 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS0(W
), 4, 0, 0, 0, 0);
7228 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f4
));
7229 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R1
, 0, SLJIT_IMM
, 0x342);
7230 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R2
, 0, SLJIT_IMM
, 0x451000);
7231 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x21000000);
7232 sljit_emit_icall(compiler
, SLJIT_CALL_CDECL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_R0
, 0);
7233 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7235 code
.code
= sljit_generate_code(compiler
);
7237 sljit_free_compiler(compiler
);
7239 FAILED(code
.func0() != 0x21451342, "test71 case 7 failed\n");
7241 sljit_free_code(code
.code
, NULL
);
7245 compiler
= sljit_create_compiler(NULL
, NULL
);
7246 FAILED(!compiler
, "cannot create compiler\n");
7248 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS0(W
), 1, 0, 0, 0, 9);
7249 sljit_emit_icall(compiler
, SLJIT_CALL_CDECL
| SLJIT_CALL_RETURN
, SLJIT_ARGS0(W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f5
));
7250 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7252 code
.code
= sljit_generate_code(compiler
);
7254 sljit_free_compiler(compiler
);
7256 FAILED(code
.func0() != 7461932, "test71 case 8 failed\n");
7258 sljit_free_code(code
.code
, NULL
);
7260 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
7266 compiler
= sljit_create_compiler(NULL
, NULL
);
7267 FAILED(!compiler
, "cannot create compiler\n");
7269 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS2(W
, F64
, F64
), 1, 1, 4, 0, 0);
7270 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
7271 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_R0
), 0);
7272 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
));
7273 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, F64
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f6
));
7274 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7276 code
.code
= sljit_generate_code(compiler
);
7278 sljit_free_compiler(compiler
);
7280 FAILED(code
.test71_f2(1345.5, -8724.25) != 8920567, "test71 case 9 failed\n");
7282 sljit_free_code(code
.code
, NULL
);
7286 wbuf
[0] = SLJIT_FUNC_ADDR(test71_f6
);
7288 compiler
= sljit_create_compiler(NULL
, NULL
);
7289 FAILED(!compiler
, "cannot create compiler\n");
7291 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(W
, F64
, F64
, F64
, F64
), 1, 0, 4, 0, 0);
7292 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, F64
), SLJIT_MEM0(), (sljit_sw
)wbuf
);
7293 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7295 code
.code
= sljit_generate_code(compiler
);
7297 sljit_free_compiler(compiler
);
7299 FAILED(code
.test71_f3(1345.5, -8724.25, 9034.75, 6307.5) != 8920567, "test71 case 10 failed\n");
7301 sljit_free_code(code
.code
, NULL
);
7305 compiler
= sljit_create_compiler(NULL
, NULL
);
7306 FAILED(!compiler
, "cannot create compiler\n");
7308 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, F64
, F64
, F64
), 1, 0, 4, 0, 0);
7309 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1706);
7310 jump
= sljit_emit_call(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
));
7311 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7313 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test71_f7
));
7315 code
.code
= sljit_generate_code(compiler
);
7317 sljit_free_compiler(compiler
);
7319 FAILED(code
.test71_f4(4061.25, -3291.75, 8703.5) != 5074526, "test71 case 11 failed\n");
7321 sljit_free_code(code
.code
, NULL
);
7325 compiler
= sljit_create_compiler(NULL
, NULL
);
7326 FAILED(!compiler
, "cannot create compiler\n");
7328 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, F64
, F64
, F64
), SLJIT_NUMBER_OF_SCRATCH_REGISTERS
+ 1, 0, 4, 0, 0);
7329 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1706);
7330 jump
= sljit_emit_call(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
));
7331 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7333 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test71_f7
));
7335 code
.code
= sljit_generate_code(compiler
);
7337 sljit_free_compiler(compiler
);
7339 FAILED(code
.test71_f4(4061.25, -3291.75, 8703.5) != 5074526, "test71 case 12 failed\n");
7341 sljit_free_code(code
.code
, NULL
);
7345 compiler
= sljit_create_compiler(NULL
, NULL
);
7346 FAILED(!compiler
, "cannot create compiler\n");
7348 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(W
, F64
, F64
, F64
), SLJIT_NUMBER_OF_SCRATCH_REGISTERS
+ 1, 1, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
7349 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1706);
7350 jump
= sljit_emit_call(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
));
7351 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
7353 sljit_set_target(jump
, SLJIT_FUNC_UADDR(test71_f7
));
7355 code
.code
= sljit_generate_code(compiler
);
7357 sljit_free_compiler(compiler
);
7359 FAILED(code
.test71_f4(4061.25, -3291.75, 8703.5) != 5074526, "test71 case 13 failed\n");
7361 sljit_free_code(code
.code
, NULL
);
7363 #endif /* !SLJIT_CONFIG_SPARC */
7368 static void test72(void)
7370 /* Test using all fpu registers. */
7371 executable_code code
;
7372 struct sljit_compiler
* compiler
= sljit_create_compiler(NULL
, NULL
);
7373 sljit_f64 buf
[SLJIT_NUMBER_OF_FLOAT_REGISTERS
];
7375 struct sljit_jump
*jump
;
7379 printf("Run test72\n");
7381 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
7383 printf("no fpu available, test72 skipped\n");
7386 sljit_free_compiler(compiler
);
7391 FAILED(!compiler
, "cannot create compiler\n");
7396 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7399 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 1, 2, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
7400 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
7401 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7402 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_FR0
, 0);
7404 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S1
, 0);
7405 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS1(VOID
, W
));
7407 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7408 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), i
* (sljit_sw
)sizeof(sljit_f64
), SLJIT_FR(i
), 0);
7409 sljit_emit_return_void(compiler
);
7411 /* Called function. */
7412 sljit_set_label(jump
, sljit_emit_label(compiler
));
7413 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
7415 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
7416 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7417 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_FR0
, 0);
7419 sljit_set_context(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, 0);
7420 sljit_emit_return_void(compiler
);
7422 code
.code
= sljit_generate_code(compiler
);
7424 sljit_free_compiler(compiler
);
7426 code
.func2((sljit_sw
)buf
, (sljit_sw
)buf2
);
7428 for (i
= 0; i
< SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
; i
++) {
7429 FAILED(buf
[i
] != -8.25, "test72 case 1 failed\n");
7432 for (i
= SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++) {
7433 FAILED(buf
[i
] != 7.75, "test72 case 2 failed\n");
7436 sljit_free_code(code
.code
, NULL
);
7439 if (SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS
>= 3) {
7440 compiler
= sljit_create_compiler(NULL
, NULL
);
7441 FAILED(!compiler
, "cannot create compiler\n");
7446 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7449 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 1, 2, SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 2, 1, SLJIT_MAX_LOCAL_SIZE
);
7450 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FS0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
7451 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 2; i
++)
7452 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_FS0
, 0);
7454 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_S1
, 0);
7455 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS1(VOID
, W
));
7457 for (i
= 0; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 2; i
++)
7458 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), i
* (sljit_sw
)sizeof(sljit_f64
), SLJIT_FR(i
), 0);
7459 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), (SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 1) * (sljit_sw
)sizeof(sljit_f64
), SLJIT_FS0
, 0);
7460 sljit_emit_return_void(compiler
);
7462 /* Called function. */
7463 sljit_set_label(jump
, sljit_emit_label(compiler
));
7464 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, SLJIT_MAX_LOCAL_SIZE
);
7466 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
));
7467 for (i
= 1; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
; i
++)
7468 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR(i
), 0, SLJIT_FR0
, 0);
7470 sljit_set_context(compiler
, 0, SLJIT_ARGS1(VOID
, P
), 0, 1, SLJIT_NUMBER_OF_FLOAT_REGISTERS
, 0, SLJIT_MAX_LOCAL_SIZE
);
7471 sljit_emit_return_void(compiler
);
7473 code
.code
= sljit_generate_code(compiler
);
7475 sljit_free_compiler(compiler
);
7477 code
.func2((sljit_sw
)buf
, (sljit_sw
)buf2
);
7479 for (i
= 0; i
< SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
; i
++) {
7480 FAILED(buf
[i
] != 3.75, "test72 case 3 failed\n");
7483 for (i
= SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
; i
< SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 2; i
++) {
7484 FAILED(buf
[i
] != -6.25, "test72 case 4 failed\n");
7487 FAILED(buf
[SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 2] != 0, "test72 case 5 failed\n");
7488 FAILED(buf
[SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 1] != -6.25, "test72 case 6 failed\n");
7490 sljit_free_code(code
.code
, NULL
);
7495 static void test73(void)
7497 /* Test tail calls. */
7498 executable_code code
;
7499 struct sljit_compiler
* compiler
;
7505 printf("Run test73\n");
7509 compiler
= sljit_create_compiler(NULL
, NULL
);
7510 FAILED(!compiler
, "cannot create compiler\n");
7512 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, 32_R
, W
, W_R
, 32), 3, 2, 0, 0, 0);
7513 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
7514 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_S0
, 0);
7515 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_R2
, 0);
7516 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
7517 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
7518 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_s32
), SLJIT_S1
, 0);
7519 sljit_emit_return_void(compiler
);
7521 code
.code
= sljit_generate_code(compiler
);
7523 sljit_free_compiler(compiler
);
7525 code
.test73_f1(3467, -6781, 5038, 6310);
7527 FAILED(wbuf
[0] != -6781, "test73 case 1 failed\n");
7528 FAILED(wbuf
[1] != 5038, "test73 case 2 failed\n");
7529 FAILED(ibuf
[0] != 3467, "test73 case 3 failed\n");
7530 FAILED(ibuf
[1] != 6310, "test73 case 4 failed\n");
7531 sljit_free_code(code
.code
, NULL
);
7535 compiler
= sljit_create_compiler(NULL
, NULL
);
7536 FAILED(!compiler
, "cannot create compiler\n");
7538 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, 32, W_R
, W
, 32_R
), 4, 2, 0, 0, 8192);
7539 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
7540 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_R1
, 0);
7541 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S1
, 0);
7542 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
7543 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
7544 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_s32
), SLJIT_R3
, 0);
7545 sljit_emit_return_void(compiler
);
7547 code
.code
= sljit_generate_code(compiler
);
7549 sljit_free_compiler(compiler
);
7551 code
.test73_f1(-9723, 5208, 4761, 5084);
7553 FAILED(wbuf
[0] != 5208, "test73 case 5 failed\n");
7554 FAILED(wbuf
[1] != 4761, "test73 case 6 failed\n");
7555 FAILED(ibuf
[0] != -9723, "test73 case 7 failed\n");
7556 FAILED(ibuf
[1] != 5084, "test73 case 8 failed\n");
7557 sljit_free_code(code
.code
, NULL
);
7561 compiler
= sljit_create_compiler(NULL
, NULL
);
7562 FAILED(!compiler
, "cannot create compiler\n");
7564 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, 32_R
, W_R
, W_R
, 32_R
), 4, 1, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
7565 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
7566 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
7567 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R2
, 0);
7568 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
7569 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
7570 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s32
), SLJIT_R3
, 0);
7571 sljit_emit_return_void(compiler
);
7573 code
.code
= sljit_generate_code(compiler
);
7575 sljit_free_compiler(compiler
);
7577 code
.test73_f1(5934, 6043, -8572, -3861);
7579 FAILED(wbuf
[0] != 6043, "test73 case 9 failed\n");
7580 FAILED(wbuf
[1] != -8572, "test73 case 10 failed\n");
7581 FAILED(ibuf
[0] != 5934, "test73 case 11 failed\n");
7582 FAILED(ibuf
[1] != -3861, "test73 case 12 failed\n");
7583 sljit_free_code(code
.code
, NULL
);
7587 compiler
= sljit_create_compiler(NULL
, NULL
);
7588 FAILED(!compiler
, "cannot create compiler\n");
7590 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS4(VOID
, W_R
, W_R
, 32_R
, 32_R
), 4, 1, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
7591 sljit_set_context(compiler
, SLJIT_ENTER_CDECL
, SLJIT_ARGS4(VOID
, W_R
, W_R
, 32_R
, 32_R
), 4, 1, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
7592 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
7593 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
7594 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R1
, 0);
7595 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, (sljit_sw
)&ibuf
);
7596 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R2
, 0);
7597 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_s32
), SLJIT_R3
, 0);
7598 sljit_emit_return_void(compiler
);
7600 code
.code
= sljit_generate_code(compiler
);
7602 sljit_free_compiler(compiler
);
7604 code
.test73_f2(6732, -5916, 2740, -3621);
7606 FAILED(wbuf
[0] != 6732, "test73 case 13 failed\n");
7607 FAILED(wbuf
[1] != -5916, "test73 case 14 failed\n");
7608 FAILED(ibuf
[0] != 2740, "test73 case 15 failed\n");
7609 FAILED(ibuf
[1] != -3621, "test73 case 16 failed\n");
7610 sljit_free_code(code
.code
, NULL
);
7612 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
7615 compiler
= sljit_create_compiler(NULL
, NULL
);
7616 FAILED(!compiler
, "cannot create compiler\n");
7618 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F64
, F64
, W_R
), 1, 0, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
7619 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&wbuf
, SLJIT_R0
, 0);
7620 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
7621 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
7622 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR1
, 0);
7623 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_f64
), SLJIT_FR2
, 0);
7625 sljit_emit_return_void(compiler
);
7627 code
.code
= sljit_generate_code(compiler
);
7629 sljit_free_compiler(compiler
);
7631 code
.test73_f3(7390.25, -8045.5, 1390.75, 8201);
7633 FAILED(wbuf
[0] != 8201, "test73 case 17 failed\n");
7634 FAILED(dbuf
[0] != 7390.25, "test73 case 18 failed\n");
7635 FAILED(dbuf
[1] != -8045.5, "test73 case 19 failed\n");
7636 FAILED(dbuf
[2] != 1390.75, "test73 case 20 failed\n");
7640 compiler
= sljit_create_compiler(NULL
, NULL
);
7641 FAILED(!compiler
, "cannot create compiler\n");
7643 sljit_emit_enter(compiler
, 0, SLJIT_ARGS4(VOID
, F64
, F64
, W
, W_R
), 2, 1, 2, 0, SLJIT_MAX_LOCAL_SIZE
);
7644 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&wbuf
);
7645 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
7646 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_R1
, 0);
7647 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
7648 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR0
, 0);
7649 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR1
, 0);
7651 sljit_emit_return_void(compiler
);
7653 code
.code
= sljit_generate_code(compiler
);
7655 sljit_free_compiler(compiler
);
7657 code
.test73_f4(4892.75, -3702.5, 4731, 8530);
7659 FAILED(wbuf
[0] != 4731, "test73 case 21 failed\n");
7660 FAILED(wbuf
[1] != 8530, "test73 case 22 failed\n");
7661 FAILED(dbuf
[0] != 4892.75, "test73 case 23 failed\n");
7662 FAILED(dbuf
[1] != -3702.5, "test73 case 24 failed\n");
7668 static void test74(void)
7670 /* Test carry flag. */
7671 executable_code code
;
7672 struct sljit_compiler
* compiler
;
7677 printf("Run test74\n");
7679 for (i
= 0; i
< 15; i
++)
7682 compiler
= sljit_create_compiler(NULL
, NULL
);
7683 FAILED(!compiler
, "cannot create compiler\n");
7685 sljit_emit_enter(compiler
, 0, SLJIT_ARGS1(VOID
, W
), 3, 2, 0, 0, 0);
7687 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
7688 sljit_emit_op2u(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7689 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_CARRY
);
7691 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R1
, 0);
7692 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7694 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R1
, 0);
7696 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2);
7697 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -1);
7698 sljit_set_current_flags(compiler
, SLJIT_SET_CARRY
| SLJIT_CURRENT_FLAGS_ADD
);
7700 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_NOT_CARRY
);
7702 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7703 sljit_emit_op2(compiler
, SLJIT_SHL32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 31);
7704 sljit_emit_op2u(compiler
, SLJIT_ADD32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0);
7705 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7707 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7709 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
7710 sljit_emit_op2(compiler
, SLJIT_ADD32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 5);
7711 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7713 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7715 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7716 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7717 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7719 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7721 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7722 sljit_emit_op2u(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7723 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_NOT_CARRY
);
7725 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7727 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7728 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7730 cond_set(compiler
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_CARRY
);
7732 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7733 sljit_emit_op2u(compiler
, SLJIT_SUB32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7734 sljit_set_current_flags(compiler
, SLJIT_SET_CARRY
| SLJIT_CURRENT_FLAGS_32
| SLJIT_CURRENT_FLAGS_SUB
);
7735 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_NOT_CARRY
);
7737 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7739 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7740 sljit_emit_op2(compiler
, SLJIT_SHL32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 31);
7741 sljit_emit_op2(compiler
, SLJIT_SUB32
, SLJIT_R1
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7742 sljit_emit_op2(compiler
, SLJIT_SUB32
| SLJIT_SET_CARRY
, SLJIT_R1
, 0, SLJIT_R1
, 0, SLJIT_R0
, 0);
7743 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_NOT_CARRY
);
7745 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7747 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -1);
7748 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, -2);
7749 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_NOT_CARRY
);
7751 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7753 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7754 sljit_emit_op2(compiler
, SLJIT_ADD
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7755 sljit_emit_op2(compiler
, SLJIT_ADDC
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
7756 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7758 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7760 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7761 sljit_emit_op2(compiler
, SLJIT_SHL32
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 31);
7762 sljit_emit_op2(compiler
, SLJIT_ADD32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7763 sljit_emit_op2(compiler
, SLJIT_ADDC32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R0
, 0);
7764 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7766 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7768 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7769 sljit_emit_op2(compiler
, SLJIT_SUB
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7770 sljit_emit_op2(compiler
, SLJIT_SUBC
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7771 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_CARRY
);
7773 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 13 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7775 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
7776 sljit_emit_op2(compiler
, SLJIT_SUB32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7777 sljit_emit_op2(compiler
, SLJIT_SUBC32
| SLJIT_SET_CARRY
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 1);
7778 cond_set(compiler
, SLJIT_R1
, 0, SLJIT_NOT_CARRY
);
7780 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 14 * sizeof(sljit_sw
), SLJIT_R1
, 0);
7782 sljit_emit_return_void(compiler
);
7784 code
.code
= sljit_generate_code(compiler
);
7786 sljit_free_compiler(compiler
);
7788 code
.func1((sljit_sw
)&wbuf
);
7790 FAILED(wbuf
[0] != 1, "test74 case 1 failed\n");
7791 FAILED(wbuf
[1] != 1, "test74 case 2 failed\n");
7792 FAILED(wbuf
[2] != 2, "test74 case 3 failed\n");
7793 FAILED(wbuf
[3] != 1, "test74 case 4 failed\n");
7794 FAILED(wbuf
[4] != 2, "test74 case 5 failed\n");
7795 FAILED(wbuf
[5] != 1, "test74 case 6 failed\n");
7796 FAILED(wbuf
[6] != 1, "test74 case 7 failed\n");
7797 FAILED(wbuf
[7] != 1, "test74 case 8 failed\n");
7798 FAILED(wbuf
[8] != 2, "test74 case 9 failed\n");
7799 FAILED(wbuf
[9] != 2, "test74 case 10 failed\n");
7800 FAILED(wbuf
[10] != 1, "test74 case 11 failed\n");
7801 FAILED(wbuf
[11] != 2, "test74 case 12 failed\n");
7802 FAILED(wbuf
[12] != 1, "test74 case 13 failed\n");
7803 FAILED(wbuf
[13] != 1, "test74 case 14 failed\n");
7804 FAILED(wbuf
[14] != 1, "test74 case 15 failed\n");
7809 static void test75_set(struct sljit_compiler
*compiler
, sljit_s32 compare
, sljit_s32 type
, sljit_s32 left_fr
, sljit_s32 right_fr
)
7811 /* Testing both sljit_emit_op_flags and sljit_emit_jump. */
7812 struct sljit_jump
* jump1
;
7813 struct sljit_jump
* jump2
;
7814 sljit_s32 is_ordered
;
7816 if (sljit_cmp_info(type
)) {
7817 sljit_emit_fop1(compiler
, compare
| SLJIT_SET(type
), left_fr
, 0, right_fr
, 0);
7818 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, type
);
7819 jump1
= sljit_emit_jump(compiler
, type
);
7820 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_IMM
, 2);
7821 sljit_set_label(jump1
, sljit_emit_label(compiler
));
7823 if (type
< SLJIT_UNORDERED_OR_EQUAL
) {
7824 is_ordered
= (type
& 0x1) ^ 0x1;
7825 type
+= SLJIT_UNORDERED_OR_EQUAL
- SLJIT_ORDERED_EQUAL
;
7827 is_ordered
= type
& 0x1;
7828 type
-= SLJIT_UNORDERED_OR_EQUAL
- SLJIT_ORDERED_EQUAL
;
7830 SLJIT_ASSERT(sljit_cmp_info(type
) && sljit_cmp_info(SLJIT_UNORDERED
) && sljit_cmp_info(SLJIT_ORDERED
));
7832 sljit_emit_fop1(compiler
, compare
| SLJIT_SET(type
), left_fr
, 0, right_fr
, 0);
7833 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, type
);
7834 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0);
7837 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_ORDERED
);
7839 jump1
= sljit_emit_jump(compiler
, SLJIT_UNORDERED
);
7840 jump2
= sljit_emit_jump(compiler
, type
);
7841 sljit_set_label(jump1
, sljit_emit_label(compiler
));
7842 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
7843 sljit_set_label(jump2
, sljit_emit_label(compiler
));
7845 sljit_emit_op2(compiler
, SLJIT_AND
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
7847 sljit_emit_op_flags(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_UNORDERED
);
7849 jump1
= sljit_emit_jump(compiler
, SLJIT_UNORDERED
);
7850 jump2
= sljit_emit_jump(compiler
, type
);
7851 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2);
7852 sljit_set_label(jump1
, sljit_emit_label(compiler
));
7853 sljit_set_label(jump2
, sljit_emit_label(compiler
));
7855 sljit_emit_op2(compiler
, SLJIT_OR
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R1
, 0);
7858 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_R0
, 0, SLJIT_R2
, 0);
7861 sljit_emit_op1(compiler
, SLJIT_MOV_U8
, SLJIT_MEM1(SLJIT_S0
), 0, SLJIT_R0
, 0);
7862 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_S0
, 0, SLJIT_S0
, 0, SLJIT_IMM
, sizeof(sljit_s8
));
7865 static void test75(void)
7867 /* Test floating point comparison. */
7868 executable_code code
;
7869 struct sljit_compiler
* compiler
;
7886 dbuf
[0].u
.value1
= 0x7fffffff;
7887 dbuf
[0].u
.value2
= 0x7fffffff;
7888 dbuf
[1].value
= -13.0;
7889 dbuf
[2].value
= 27.0;
7891 sbuf
[0].value1
= 0x7fffffff;
7892 sbuf
[1].value
= -13.0;
7893 sbuf
[2].value
= 27.0;
7896 printf("Run test75\n");
7898 if (!sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
7900 printf("no fpu available, test75 skipped\n");
7905 for (i
= 0; i
< 96; i
++)
7908 compiler
= sljit_create_compiler(NULL
, NULL
);
7909 FAILED(!compiler
, "cannot create compiler\n");
7911 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 3, 3, 6, 0, 0);
7914 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
7915 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
7916 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
));
7917 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f64
));
7918 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f64
));
7921 /* bbuf[0] and bbuf[48] */
7922 test75_set(compiler
, i
, SLJIT_ORDERED_EQUAL
, SLJIT_FR2
, SLJIT_FR3
);
7923 /* bbuf[1] and bbuf[49] */
7924 test75_set(compiler
, i
, SLJIT_ORDERED_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7925 /* bbuf[2] and bbuf[50] */
7926 test75_set(compiler
, i
, SLJIT_ORDERED_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7927 /* bbuf[3] and bbuf[51] */
7928 test75_set(compiler
, i
, SLJIT_ORDERED_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7930 /* bbuf[4] and bbuf[52] */
7931 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_NOT_EQUAL
, SLJIT_FR2
, SLJIT_FR3
);
7932 /* bbuf[5] and bbuf[53] */
7933 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_NOT_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7934 /* bbuf[6] and bbuf[54] */
7935 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_NOT_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7936 /* bbuf[7] and bbuf[55] */
7937 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_NOT_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7939 /* bbuf[8] and bbuf[56] */
7940 test75_set(compiler
, i
, SLJIT_ORDERED_LESS
, SLJIT_FR2
, SLJIT_FR3
);
7941 /* bbuf[9] and bbuf[57] */
7942 test75_set(compiler
, i
, SLJIT_ORDERED_LESS
, SLJIT_FR2
, SLJIT_FR4
);
7943 /* bbuf[10] and bbuf[58] */
7944 test75_set(compiler
, i
, SLJIT_ORDERED_LESS
, SLJIT_FR0
, SLJIT_FR1
);
7945 /* bbuf[11] and bbuf[59] */
7946 test75_set(compiler
, i
, SLJIT_ORDERED_LESS
, SLJIT_FR0
, SLJIT_FR2
);
7948 /* bbuf[12] and bbuf[60] */
7949 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7950 /* bbuf[13] and bbuf[61] */
7951 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER_EQUAL
, SLJIT_FR4
, SLJIT_FR2
);
7952 /* bbuf[14] and bbuf[62] */
7953 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7954 /* bbuf[15] and bbuf[63] */
7955 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7957 /* bbuf[16] and bbuf[64] */
7958 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER
, SLJIT_FR2
, SLJIT_FR4
);
7959 /* bbuf[17] and bbuf[65] */
7960 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER
, SLJIT_FR4
, SLJIT_FR2
);
7961 /* bbuf[18] and bbuf[66] */
7962 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER
, SLJIT_FR0
, SLJIT_FR1
);
7963 /* bbuf[19] and bbuf[67] */
7964 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER
, SLJIT_FR0
, SLJIT_FR2
);
7966 /* bbuf[20] and bbuf[68] */
7967 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7968 /* bbuf[21] and bbuf[69] */
7969 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS_EQUAL
, SLJIT_FR4
, SLJIT_FR2
);
7970 /* bbuf[22] and bbuf[70] */
7971 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7972 /* bbuf[23] and bbuf[71] */
7973 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7975 /* bbuf[24] and bbuf[72] */
7976 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7977 /* bbuf[25] and bbuf[73] */
7978 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_EQUAL
, SLJIT_FR2
, SLJIT_FR3
);
7979 /* bbuf[26] and bbuf[74] */
7980 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7981 /* bbuf[27] and bbuf[75] */
7982 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7984 /* bbuf[28] and bbuf[76] */
7985 test75_set(compiler
, i
, SLJIT_ORDERED_NOT_EQUAL
, SLJIT_FR2
, SLJIT_FR3
);
7986 /* bbuf[29] and bbuf[77] */
7987 test75_set(compiler
, i
, SLJIT_ORDERED_NOT_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
7988 /* bbuf[30] and bbuf[78] */
7989 test75_set(compiler
, i
, SLJIT_ORDERED_NOT_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
7990 /* bbuf[31] and bbuf[79] */
7991 test75_set(compiler
, i
, SLJIT_ORDERED_NOT_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
7993 /* bbuf[32] and bbuf[80] */
7994 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS
, SLJIT_FR2
, SLJIT_FR4
);
7995 /* bbuf[33] and bbuf[81] */
7996 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS
, SLJIT_FR2
, SLJIT_FR3
);
7997 /* bbuf[34] and bbuf[82] */
7998 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS
, SLJIT_FR0
, SLJIT_FR1
);
7999 /* bbuf[35] and bbuf[83] */
8000 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_LESS
, SLJIT_FR0
, SLJIT_FR2
);
8002 /* bbuf[36] and bbuf[84] */
8003 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER_EQUAL
, SLJIT_FR2
, SLJIT_FR4
);
8004 /* bbuf[37] and bbuf[85] */
8005 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER_EQUAL
, SLJIT_FR4
, SLJIT_FR2
);
8006 /* bbuf[38] and bbuf[86] */
8007 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
8008 /* bbuf[39] and bbuf[87] */
8009 test75_set(compiler
, i
, SLJIT_ORDERED_GREATER_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
8011 /* bbuf[40] and bbuf[88] */
8012 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER
, SLJIT_FR2
, SLJIT_FR4
);
8013 /* bbuf[41] and bbuf[89] */
8014 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER
, SLJIT_FR4
, SLJIT_FR2
);
8015 /* bbuf[42] and bbuf[90] */
8016 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER
, SLJIT_FR0
, SLJIT_FR1
);
8017 /* bbuf[43] and bbuf[91] */
8018 test75_set(compiler
, i
, SLJIT_UNORDERED_OR_GREATER
, SLJIT_FR0
, SLJIT_FR2
);
8020 /* bbuf[44] and bbuf[92] */
8021 test75_set(compiler
, i
, SLJIT_ORDERED_LESS_EQUAL
, SLJIT_FR2
, SLJIT_FR3
);
8022 /* bbuf[45] and bbuf[93] */
8023 test75_set(compiler
, i
, SLJIT_ORDERED_LESS_EQUAL
, SLJIT_FR4
, SLJIT_FR2
);
8024 /* bbuf[46] and bbuf[94] */
8025 test75_set(compiler
, i
, SLJIT_ORDERED_LESS_EQUAL
, SLJIT_FR0
, SLJIT_FR1
);
8026 /* bbuf[47] and bbuf[95] */
8027 test75_set(compiler
, i
, SLJIT_ORDERED_LESS_EQUAL
, SLJIT_FR0
, SLJIT_FR2
);
8029 if (i
== SLJIT_CMP_F32
)
8033 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S2
), 0);
8034 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_S2
), 0);
8035 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
8036 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR3
, 0, SLJIT_MEM1(SLJIT_S2
), sizeof(sljit_f32
));
8037 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR4
, 0, SLJIT_MEM1(SLJIT_S2
), 2 * sizeof(sljit_f32
));
8040 sljit_emit_return_void(compiler
);
8042 code
.code
= sljit_generate_code(compiler
);
8044 sljit_free_compiler(compiler
);
8046 code
.func3((sljit_sw
)&bbuf
, (sljit_sw
)&dbuf
, (sljit_sw
)&sbuf
);
8049 FAILED(bbuf
[0] != 1, "test75 case 1 failed\n");
8050 FAILED(bbuf
[1] != 2, "test75 case 2 failed\n");
8051 FAILED(bbuf
[2] != 2, "test75 case 3 failed\n");
8052 FAILED(bbuf
[3] != 2, "test75 case 4 failed\n");
8054 FAILED(bbuf
[4] != 2, "test75 case 5 failed\n");
8055 FAILED(bbuf
[5] != 1, "test75 case 6 failed\n");
8056 FAILED(bbuf
[6] != 1, "test75 case 7 failed\n");
8057 FAILED(bbuf
[7] != 1, "test75 case 8 failed\n");
8059 FAILED(bbuf
[8] != 2, "test75 case 9 failed\n");
8060 FAILED(bbuf
[9] != 1, "test75 case 10 failed\n");
8061 FAILED(bbuf
[10] != 2, "test75 case 11 failed\n");
8062 FAILED(bbuf
[11] != 2, "test75 case 12 failed\n");
8064 FAILED(bbuf
[12] != 2, "test75 case 13 failed\n");
8065 FAILED(bbuf
[13] != 1, "test75 case 14 failed\n");
8066 FAILED(bbuf
[14] != 1, "test75 case 15 failed\n");
8067 FAILED(bbuf
[15] != 1, "test75 case 16 failed\n");
8069 FAILED(bbuf
[16] != 2, "test75 case 17 failed\n");
8070 FAILED(bbuf
[17] != 1, "test75 case 18 failed\n");
8071 FAILED(bbuf
[18] != 2, "test75 case 19 failed\n");
8072 FAILED(bbuf
[19] != 2, "test75 case 20 failed\n");
8074 FAILED(bbuf
[20] != 1, "test75 case 21 failed\n");
8075 FAILED(bbuf
[21] != 2, "test75 case 22 failed\n");
8076 FAILED(bbuf
[22] != 1, "test75 case 23 failed\n");
8077 FAILED(bbuf
[23] != 1, "test75 case 24 failed\n");
8079 FAILED(bbuf
[24] != 2, "test75 case 25 failed\n");
8080 FAILED(bbuf
[25] != 1, "test75 case 26 failed\n");
8081 FAILED(bbuf
[26] != 1, "test75 case 27 failed\n");
8082 FAILED(bbuf
[27] != 1, "test75 case 28 failed\n");
8084 FAILED(bbuf
[28] != 2, "test75 case 29 failed\n");
8085 FAILED(bbuf
[29] != 1, "test75 case 30 failed\n");
8086 FAILED(bbuf
[30] != 2, "test75 case 31 failed\n");
8087 FAILED(bbuf
[31] != 2, "test75 case 32 failed\n");
8089 FAILED(bbuf
[32] != 1, "test75 case 33 failed\n");
8090 FAILED(bbuf
[33] != 2, "test75 case 34 failed\n");
8091 FAILED(bbuf
[34] != 1, "test75 case 35 failed\n");
8092 FAILED(bbuf
[35] != 1, "test75 case 36 failed\n");
8094 FAILED(bbuf
[36] != 2, "test75 case 37 failed\n");
8095 FAILED(bbuf
[37] != 1, "test75 case 38 failed\n");
8096 FAILED(bbuf
[38] != 2, "test75 case 39 failed\n");
8097 FAILED(bbuf
[39] != 2, "test75 case 40 failed\n");
8099 FAILED(bbuf
[40] != 2, "test75 case 41 failed\n");
8100 FAILED(bbuf
[41] != 1, "test75 case 42 failed\n");
8101 FAILED(bbuf
[42] != 1, "test75 case 43 failed\n");
8102 FAILED(bbuf
[43] != 1, "test75 case 44 failed\n");
8104 FAILED(bbuf
[44] != 1, "test75 case 45 failed\n");
8105 FAILED(bbuf
[45] != 2, "test75 case 46 failed\n");
8106 FAILED(bbuf
[46] != 2, "test75 case 47 failed\n");
8107 FAILED(bbuf
[47] != 2, "test75 case 48 failed\n");
8110 FAILED(bbuf
[48] != 1, "test75 case 49 failed\n");
8111 FAILED(bbuf
[49] != 2, "test75 case 50 failed\n");
8112 FAILED(bbuf
[50] != 2, "test75 case 51 failed\n");
8113 FAILED(bbuf
[51] != 2, "test75 case 52 failed\n");
8115 FAILED(bbuf
[52] != 2, "test75 case 53 failed\n");
8116 FAILED(bbuf
[53] != 1, "test75 case 54 failed\n");
8117 FAILED(bbuf
[54] != 1, "test75 case 55 failed\n");
8118 FAILED(bbuf
[55] != 1, "test75 case 56 failed\n");
8120 FAILED(bbuf
[56] != 2, "test75 case 57 failed\n");
8121 FAILED(bbuf
[57] != 1, "test75 case 58 failed\n");
8122 FAILED(bbuf
[58] != 2, "test75 case 59 failed\n");
8123 FAILED(bbuf
[59] != 2, "test75 case 60 failed\n");
8125 FAILED(bbuf
[60] != 2, "test75 case 61 failed\n");
8126 FAILED(bbuf
[61] != 1, "test75 case 62 failed\n");
8127 FAILED(bbuf
[62] != 1, "test75 case 63 failed\n");
8128 FAILED(bbuf
[63] != 1, "test75 case 64 failed\n");
8130 FAILED(bbuf
[64] != 2, "test75 case 65 failed\n");
8131 FAILED(bbuf
[65] != 1, "test75 case 66 failed\n");
8132 FAILED(bbuf
[66] != 2, "test75 case 67 failed\n");
8133 FAILED(bbuf
[67] != 2, "test75 case 68 failed\n");
8135 FAILED(bbuf
[68] != 1, "test75 case 69 failed\n");
8136 FAILED(bbuf
[69] != 2, "test75 case 70 failed\n");
8137 FAILED(bbuf
[70] != 1, "test75 case 71 failed\n");
8138 FAILED(bbuf
[71] != 1, "test75 case 72 failed\n");
8140 FAILED(bbuf
[72] != 2, "test75 case 73 failed\n");
8141 FAILED(bbuf
[73] != 1, "test75 case 74 failed\n");
8142 FAILED(bbuf
[74] != 1, "test75 case 75 failed\n");
8143 FAILED(bbuf
[75] != 1, "test75 case 76 failed\n");
8145 FAILED(bbuf
[76] != 2, "test75 case 77 failed\n");
8146 FAILED(bbuf
[77] != 1, "test75 case 78 failed\n");
8147 FAILED(bbuf
[78] != 2, "test75 case 79 failed\n");
8148 FAILED(bbuf
[79] != 2, "test75 case 80 failed\n");
8150 FAILED(bbuf
[80] != 1, "test75 case 81 failed\n");
8151 FAILED(bbuf
[81] != 2, "test75 case 82 failed\n");
8152 FAILED(bbuf
[82] != 1, "test75 case 83 failed\n");
8153 FAILED(bbuf
[83] != 1, "test75 case 84 failed\n");
8155 FAILED(bbuf
[84] != 2, "test75 case 85 failed\n");
8156 FAILED(bbuf
[85] != 1, "test75 case 86 failed\n");
8157 FAILED(bbuf
[86] != 2, "test75 case 87 failed\n");
8158 FAILED(bbuf
[87] != 2, "test75 case 88 failed\n");
8160 FAILED(bbuf
[88] != 2, "test75 case 89 failed\n");
8161 FAILED(bbuf
[89] != 1, "test75 case 90 failed\n");
8162 FAILED(bbuf
[90] != 1, "test75 case 91 failed\n");
8163 FAILED(bbuf
[91] != 1, "test75 case 92 failed\n");
8165 FAILED(bbuf
[92] != 1, "test75 case 93 failed\n");
8166 FAILED(bbuf
[93] != 2, "test75 case 94 failed\n");
8167 FAILED(bbuf
[94] != 2, "test75 case 95 failed\n");
8168 FAILED(bbuf
[95] != 2, "test75 case 96 failed\n");
8173 static void test76(void)
8175 #if !(defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
8176 /* Test keep saved registers. */
8177 executable_code code
;
8178 struct sljit_compiler
* compiler
;
8179 struct sljit_jump
* jump
;
8185 printf("Run test76\n");
8188 for (i
= 0; i
< 9; i
++)
8191 compiler
= sljit_create_compiler(NULL
, NULL
);
8192 FAILED(!compiler
, "cannot create compiler\n");
8194 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 4, 2, 0, 0, 0);
8196 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 7945);
8197 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -9267);
8198 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 4309);
8199 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -8321);
8201 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 6803);
8202 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -5497);
8204 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, W
, W
, W
, W
));
8206 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8207 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
8208 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8209 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8210 sljit_emit_return_void(compiler
);
8212 sljit_set_label(jump
, sljit_emit_label(compiler
));
8213 sljit_emit_enter(compiler
, SLJIT_ENTER_KEEP_S0_S1
, SLJIT_ARGS4(W
, W
, W
, W
, W
), 1, 6, 0, 0, 32);
8215 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8216 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 3 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8217 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8218 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 5 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8219 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 6 * sizeof(sljit_sw
), SLJIT_S3
, 0);
8220 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 7 * sizeof(sljit_sw
), SLJIT_S4
, 0);
8221 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 8 * sizeof(sljit_sw
), SLJIT_S5
, 0);
8223 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 6028);
8224 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 4982);
8225 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1289);
8227 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
8229 code
.code
= sljit_generate_code(compiler
);
8231 sljit_free_compiler(compiler
);
8233 code
.func1((sljit_sw
)&buf
);
8235 FAILED(buf
[0] != 6028, "test76 case 1 failed\n");
8236 FAILED(buf
[1] != 4982, "test76 case 2 failed\n");
8237 FAILED(buf
[2] != -1289, "test76 case 3 failed\n");
8238 FAILED(buf
[3] != 6803, "test76 case 4 failed\n");
8239 FAILED(buf
[4] != -5497, "test76 case 5 failed\n");
8240 FAILED(buf
[5] != 7945, "test76 case 6 failed\n");
8241 FAILED(buf
[6] != -9267, "test76 case 7 failed\n");
8242 FAILED(buf
[7] != 4309, "test76 case 8 failed\n");
8243 FAILED(buf
[8] != -8321, "test76 case 9 failed\n");
8247 for (i
= 0; i
< 9; i
++)
8250 compiler
= sljit_create_compiler(NULL
, NULL
);
8251 FAILED(!compiler
, "cannot create compiler\n");
8253 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 4, 1, 0, 0, 0);
8255 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -2608);
8256 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 4751);
8257 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 5740);
8258 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, -9704);
8260 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -8749);
8262 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, W
, W
, W
, W
));
8264 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8265 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
8266 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8267 sljit_emit_return_void(compiler
);
8269 sljit_set_label(jump
, sljit_emit_label(compiler
));
8270 sljit_emit_enter(compiler
, SLJIT_ENTER_KEEP_S0
, SLJIT_ARGS4(W
, W_R
, W
, W_R
, W
), 3, 3, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
8271 sljit_set_context(compiler
, SLJIT_ENTER_KEEP_S0
, SLJIT_ARGS4(W
, W_R
, W
, W_R
, W
), 3, 3, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
8273 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8274 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8275 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8276 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 4 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8277 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 5 * sizeof(sljit_sw
), SLJIT_R2
, 0);
8278 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 6 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8280 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, -7351);
8281 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 3628);
8283 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
8285 code
.code
= sljit_generate_code(compiler
);
8287 sljit_free_compiler(compiler
);
8289 code
.func1((sljit_sw
)&buf
);
8291 FAILED(buf
[0] != -7351, "test76 case 10 failed\n");
8292 FAILED(buf
[1] != 3628, "test76 case 11 failed\n");
8293 FAILED(buf
[2] != -8749, "test76 case 12 failed\n");
8294 FAILED(buf
[3] != -2608, "test76 case 13 failed\n");
8295 FAILED(buf
[4] != 4751, "test76 case 14 failed\n");
8296 FAILED(buf
[5] != 5740, "test76 case 15 failed\n");
8297 FAILED(buf
[6] != -9704, "test76 case 16 failed\n");
8298 FAILED(buf
[7] != -1, "test76 case 17 failed\n");
8302 for (i
= 0; i
< 9; i
++)
8305 compiler
= sljit_create_compiler(NULL
, NULL
);
8306 FAILED(!compiler
, "cannot create compiler\n");
8308 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 4, 1, 0, 0, 0);
8310 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8653);
8311 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 7245);
8312 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, -3610);
8313 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 4591);
8315 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -2865);
8317 jump
= sljit_emit_call(compiler
, SLJIT_CALL_CDECL
, SLJIT_ARGS4(VOID
, W
, W
, W
, W
));
8319 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM0(), (sljit_sw
)&buf
, SLJIT_S0
, 0);
8320 sljit_emit_return_void(compiler
);
8322 sljit_set_label(jump
, sljit_emit_label(compiler
));
8323 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
| SLJIT_ENTER_KEEP_S0
, SLJIT_ARGS4(W
, W_R
, W
, W
, W_R
), 4, 3, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
8325 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8326 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8327 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8328 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 3 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8329 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 4 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8330 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 5 * sizeof(sljit_sw
), SLJIT_R3
, 0);
8332 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 5789);
8334 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
8336 code
.code
= sljit_generate_code(compiler
);
8338 sljit_free_compiler(compiler
);
8340 code
.func1((sljit_sw
)&buf
);
8342 FAILED(buf
[0] != 5789, "test76 case 18 failed\n");
8343 FAILED(buf
[1] != -2865, "test76 case 19 failed\n");
8344 FAILED(buf
[2] != 8653, "test76 case 20 failed\n");
8345 FAILED(buf
[3] != 7245, "test76 case 21 failed\n");
8346 FAILED(buf
[4] != -3610, "test76 case 22 failed\n");
8347 FAILED(buf
[5] != 4591, "test76 case 23 failed\n");
8348 FAILED(buf
[6] != -1, "test76 case 24 failed\n");
8352 for (i
= 0; i
< 9; i
++)
8355 compiler
= sljit_create_compiler(NULL
, NULL
);
8356 FAILED(!compiler
, "cannot create compiler\n");
8358 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 2, 3, 0, 0, 0);
8360 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 6071);
8361 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -3817);
8362 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 9250);
8364 jump
= sljit_emit_call(compiler
, SLJIT_CALL_CDECL
, SLJIT_ARGS0(W
));
8366 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8367 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
8368 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8369 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8370 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 3 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8371 sljit_emit_return_void(compiler
);
8373 sljit_set_label(jump
, sljit_emit_label(compiler
));
8374 sljit_emit_enter(compiler
, SLJIT_ENTER_CDECL
| SLJIT_ENTER_KEEP_S0_S1
, SLJIT_ARGS0(W
), 4, 3, 0, 0, SLJIT_MAX_LOCAL_SIZE
);
8376 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8377 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8378 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 5 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8380 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0x15000000);
8381 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 0x93);
8382 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 0x280000);
8383 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R3
, 0, SLJIT_IMM
, 0x4600);
8385 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 4892);
8386 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -7513);
8387 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
8389 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, W
, 32, 32, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f2
));
8390 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
8392 code
.code
= sljit_generate_code(compiler
);
8394 sljit_free_compiler(compiler
);
8396 code
.func1((sljit_sw
)&buf
);
8398 FAILED(buf
[0] != 0x15284693, "test76 case 25 failed\n");
8399 FAILED(buf
[1] != 4892, "test76 case 26 failed\n");
8400 FAILED(buf
[2] != -7513, "test76 case 27 failed\n");
8401 FAILED(buf
[3] != 9250, "test76 case 28 failed\n");
8402 FAILED(buf
[4] != 6071, "test76 case 29 failed\n");
8403 FAILED(buf
[5] != -3817, "test76 case 30 failed\n");
8404 FAILED(buf
[6] != -1, "test76 case 31 failed\n");
8406 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
8409 for (i
= 0; i
< 9; i
++)
8416 compiler
= sljit_create_compiler(NULL
, NULL
);
8417 FAILED(!compiler
, "cannot create compiler\n");
8419 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 2, 3, 3, 0, 0);
8421 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
8422 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_R1
), 0);
8423 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_f64
));
8424 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_f64
));
8426 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1706);
8427 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, -8956);
8428 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, 4381);
8429 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -5314);
8431 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
));
8433 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8434 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
8435 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8436 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8437 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 3 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8438 sljit_emit_return_void(compiler
);
8440 sljit_set_label(jump
, sljit_emit_label(compiler
));
8441 sljit_emit_enter(compiler
, SLJIT_ENTER_KEEP_S0
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
), 1, 3, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
8443 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8444 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8445 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 5 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8447 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
8448 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_FR2
, 0);
8449 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
), SLJIT_FR0
, 0);
8450 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_f64
), SLJIT_FR1
, 0);
8452 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 2784);
8453 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 1503);
8454 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1);
8455 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
8457 sljit_emit_return(compiler
, SLJIT_MOV
, SLJIT_R0
, 0);
8459 code
.code
= sljit_generate_code(compiler
);
8461 sljit_free_compiler(compiler
);
8463 code
.func1((sljit_sw
)&buf
);
8465 FAILED(buf
[0] != 2784, "test76 case 32 failed\n");
8466 FAILED(buf
[1] != 1503, "test76 case 33 failed\n");
8467 FAILED(buf
[2] != 4381, "test76 case 34 failed\n");
8468 FAILED(buf
[3] != -5314, "test76 case 35 failed\n");
8469 FAILED(buf
[4] != -8956, "test76 case 36 failed\n");
8470 FAILED(buf
[5] != 1706, "test76 case 37 failed\n");
8471 FAILED(buf
[6] != -1, "test76 case 38 failed\n");
8472 FAILED(dbuf
[0] != 8703.5, "test76 case 39 failed\n");
8473 FAILED(dbuf
[1] != 4061.25, "test76 case 40 failed\n");
8474 FAILED(dbuf
[2] != -3291.75, "test76 case 41 failed\n");
8478 for (i
= 0; i
< 9; i
++)
8483 compiler
= sljit_create_compiler(NULL
, NULL
);
8484 FAILED(!compiler
, "cannot create compiler\n");
8486 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 3, 3, 1, 0, 0);
8488 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM0(), (sljit_sw
)&dbuf
);
8490 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 8793);
8491 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, -4027);
8492 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R2
, 0, SLJIT_IMM
, 2910);
8493 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 4619);
8494 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -1502);
8495 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 5316);
8497 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS4(VOID
, F64
, W
, W
, W
));
8499 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8500 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 0, SLJIT_S0
, 0);
8501 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_sw
), SLJIT_S1
, 0);
8502 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8503 sljit_emit_return_void(compiler
);
8505 sljit_set_label(jump
, sljit_emit_label(compiler
));
8506 sljit_emit_enter(compiler
, SLJIT_ENTER_KEEP_S0_S1
, SLJIT_ARGS4(VOID
, F64
, W
, W
, W
), 1, 5, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
8508 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8509 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 3 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8510 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8511 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 5 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8512 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 6 * sizeof(sljit_sw
), SLJIT_S3
, 0);
8513 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 7 * sizeof(sljit_sw
), SLJIT_S4
, 0);
8515 sljit_emit_fop1(compiler
, SLJIT_NEG_F64
, SLJIT_MEM0(), (sljit_sw
)&dbuf
, SLJIT_FR0
, 0);
8517 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 7839);
8518 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -9215);
8519 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
8521 sljit_emit_return_void(compiler
);
8523 code
.code
= sljit_generate_code(compiler
);
8525 sljit_free_compiler(compiler
);
8527 code
.func1((sljit_sw
)&buf
);
8529 FAILED(buf
[0] != 7839, "test76 case 42 failed\n");
8530 FAILED(buf
[1] != -9215, "test76 case 43 failed\n");
8531 FAILED(buf
[2] != 5316, "test76 case 44 failed\n");
8532 FAILED(buf
[3] != 4619, "test76 case 45 failed\n");
8533 FAILED(buf
[4] != -1502, "test76 case 46 failed\n");
8534 FAILED(buf
[5] != 8793, "test76 case 47 failed\n");
8535 FAILED(buf
[6] != -4027, "test76 case 48 failed\n");
8536 FAILED(buf
[7] != 2910, "test76 case 49 failed\n");
8537 FAILED(buf
[8] != -1, "test76 case 50 failed\n");
8538 FAILED(dbuf
[0] != -4061.25, "test76 case 51 failed\n");
8542 for (i
= 0; i
< 9; i
++)
8549 compiler
= sljit_create_compiler(NULL
, NULL
);
8550 FAILED(!compiler
, "cannot create compiler\n");
8552 sljit_emit_enter(compiler
, 0, SLJIT_ARGS0(VOID
), 2, 3, 0, 0, 0);
8554 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 7869);
8555 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -5406);
8556 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, 4951);
8558 jump
= sljit_emit_call(compiler
, SLJIT_CALL
, SLJIT_ARGS0(W
));
8560 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8561 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 0, SLJIT_R0
, 0);
8562 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), sizeof(sljit_sw
), SLJIT_S0
, 0);
8563 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 2 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8564 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R1
), 3 * sizeof(sljit_sw
), SLJIT_S2
, 0);
8565 sljit_emit_return_void(compiler
);
8567 sljit_set_label(jump
, sljit_emit_label(compiler
));
8568 sljit_emit_enter(compiler
, SLJIT_ENTER_KEEP_S0_S1
, SLJIT_ARGS0(W
), 1, 3, 3, 0, SLJIT_MAX_LOCAL_SIZE
);
8570 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&buf
);
8571 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 4 * sizeof(sljit_sw
), SLJIT_S0
, 0);
8572 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_R0
), 5 * sizeof(sljit_sw
), SLJIT_S1
, 0);
8574 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, (sljit_sw
)&dbuf
);
8575 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_R0
), 0);
8576 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR1
, 0, SLJIT_MEM1(SLJIT_R0
), sizeof(sljit_f64
));
8577 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR2
, 0, SLJIT_MEM1(SLJIT_R0
), 2 * sizeof(sljit_f64
));
8579 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 1706);
8581 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S0
, 0, SLJIT_IMM
, 4713);
8582 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S1
, 0, SLJIT_IMM
, -2078);
8583 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_S2
, 0, SLJIT_IMM
, -1);
8585 sljit_emit_icall(compiler
, SLJIT_CALL
| SLJIT_CALL_RETURN
, SLJIT_ARGS4(W
, F64
, F64
, F64
, W
), SLJIT_IMM
, SLJIT_FUNC_ADDR(test71_f7
));
8586 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM0(), 0);
8588 code
.code
= sljit_generate_code(compiler
);
8590 sljit_free_compiler(compiler
);
8592 code
.func1((sljit_sw
)&buf
);
8594 FAILED(buf
[0] != 5074526, "test76 case 52 failed\n");
8595 FAILED(buf
[1] != 4713, "test76 case 53 failed\n");
8596 FAILED(buf
[2] != -2078, "test76 case 54 failed\n");
8597 FAILED(buf
[3] != 4951, "test76 case 55 failed\n");
8598 FAILED(buf
[4] != 7869, "test76 case 56 failed\n");
8599 FAILED(buf
[5] != -5406, "test76 case 57 failed\n");
8600 FAILED(buf
[6] != -1, "test76 case 58 failed\n");
8602 #endif /* !SLJIT_CONFIG_SPARC */
8607 static void copy_u8(void *dst
, sljit_sw offset
, const void *src
, sljit_uw length
)
8609 sljit_u8
*dst_p
= (sljit_u8
*)dst
+ offset
;
8610 const sljit_u8
*src_p
= (sljit_u8
*)src
;
8612 while (length
-- != 0)
8613 *dst_p
++ = *src_p
++;
8616 static int cmp_u8(const void *src1
, sljit_sw offset
, const void *src2
, sljit_uw length
)
8618 const sljit_u8
*src1_p
= (sljit_u8
*)src1
+ offset
;
8619 const sljit_u8
*src2_p
= (sljit_u8
*)src2
;
8621 while (--length
!= 0) {
8622 if (*src1_p
!= *src2_p
)
8630 static void test77(void)
8632 /* Test unaligned access */
8633 executable_code code
;
8634 struct sljit_compiler
* compiler
;
8641 sljit_s8 bbuf_start
[40 + 8 /* for alignment */];
8642 sljit_s8
*bbuf
= (sljit_s8
*)(((sljit_uw
)bbuf_start
+ 7) & ~(sljit_uw
)7);
8644 SLJIT_ASSERT(((sljit_uw
)bbuf
& 0x7) == 0);
8647 printf("Run test77\n");
8649 for (i
= 0; i
< 13; i
++)
8652 for (i
= 0; i
< 40; i
++)
8658 copy_u8(bbuf
, 3, hbuf
, sizeof(sljit_s16
));
8659 copy_u8(bbuf
, 5, ibuf
, sizeof(sljit_s32
));
8660 copy_u8(bbuf
, 9, wbuf
, sizeof(sljit_sw
));
8661 copy_u8(bbuf
, 18, ibuf
, sizeof(sljit_s32
));
8662 copy_u8(bbuf
, 22, wbuf
, sizeof(sljit_sw
));
8663 copy_u8(bbuf
, 32, wbuf
, sizeof(sljit_sw
));
8670 compiler
= sljit_create_compiler(NULL
, NULL
);
8671 FAILED(!compiler
, "cannot create compiler\n");
8673 sljit_emit_enter(compiler
, 0, SLJIT_ARGS2(VOID
, P
, P
), 2, 2, 0, 0, 0);
8675 sljit_emit_mem(compiler
, SLJIT_MOV_S8
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM0(), (sljit_sw
)bbuf
);
8677 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_sw
), SLJIT_R0
, 0);
8679 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 0);
8680 sljit_emit_mem(compiler
, SLJIT_MOV_U8
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R0
), 0);
8682 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8684 sljit_emit_op1(compiler
, SLJIT_MOV_S8
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
8686 sljit_emit_mem(compiler
, SLJIT_MOV_U8
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_s8
));
8688 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 100000);
8689 sljit_emit_mem(compiler
, SLJIT_MOV_S16
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), 100000 + 3);
8691 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8693 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 1000);
8694 sljit_emit_mem(compiler
, SLJIT_MOV_U16
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), -1000 + 3);
8696 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8698 sljit_emit_op1(compiler
, SLJIT_MOV_S16
, SLJIT_R0
, 0, SLJIT_MEM0(), (sljit_sw
)&hbuf
);
8700 sljit_emit_mem(compiler
, SLJIT_MOV_S16
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_S1
), 3);
8702 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_S1
), 5);
8704 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 5 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8706 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 5);
8707 sljit_emit_mem(compiler
, SLJIT_MOV_U32
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM2(SLJIT_R0
, SLJIT_S1
), 0);
8709 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 6 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8711 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 100000);
8712 sljit_emit_op1(compiler
, SLJIT_MOV32
, SLJIT_R0
, 0, SLJIT_MEM0(), (sljit_sw
)&ibuf
);
8714 sljit_emit_mem(compiler
, SLJIT_MOV32
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), 100000 + 5);
8716 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 100000);
8717 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), -100000 + 9);
8719 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 7 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8721 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8723 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), -100000 + 9);
8725 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R1
, 0, SLJIT_IMM
, 18 >> 1);
8726 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_R0
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 1);
8728 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 8 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8730 sljit_emit_op1(compiler
, SLJIT_MOV_S32
, SLJIT_R0
, 0, SLJIT_MEM0(), (sljit_sw
)&ibuf
);
8732 sljit_emit_mem(compiler
, SLJIT_MOV_S32
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_R0
, SLJIT_MEM2(SLJIT_S1
, SLJIT_R1
), 1);
8734 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_R0
, SLJIT_MEM0(), (sljit_sw
)bbuf
+ 22);
8736 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 9 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8738 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8740 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_R0
, SLJIT_MEM0(), (sljit_sw
)bbuf
+ 22);
8742 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 128);
8743 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R0
), -128 + 32);
8745 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_MEM1(SLJIT_S0
), 10 * sizeof(sljit_sw
), SLJIT_R0
, 0);
8747 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R1
, 0, SLJIT_S1
, 0, SLJIT_IMM
, 128);
8748 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8750 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_R0
, SLJIT_MEM1(SLJIT_R1
), -128 + 32);
8752 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_S0
), 0);
8754 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_R0
, SLJIT_MEM1(SLJIT_S0
), 11 * sizeof(sljit_sw
));
8756 sljit_emit_mem(compiler
, SLJIT_MOV
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_S0
, SLJIT_MEM1(SLJIT_S0
), 12 * sizeof(sljit_sw
));
8758 sljit_emit_return_void(compiler
);
8760 code
.code
= sljit_generate_code(compiler
);
8762 sljit_free_compiler(compiler
);
8764 code
.func2((sljit_sw
)&wbuf
, (sljit_sw
)bbuf
);
8766 FAILED(wbuf
[1] != -73, "test77 case 1 failed\n");
8767 FAILED(wbuf
[2] != (sljit_u8
)-73, "test77 case 2 failed\n");
8768 FAILED(bbuf
[1] != -73, "test77 case 3 failed\n");
8769 FAILED(wbuf
[3] != -28531, "test77 case 4 failed\n");
8770 FAILED(wbuf
[4] != (sljit_u16
)-28531, "test77 case 5 failed\n");
8771 FAILED(cmp_u8(bbuf
, 3, hbuf
, sizeof(sljit_s16
)) != 1, "test77 case 6 failed\n");
8772 FAILED(wbuf
[5] != -38512, "test77 case 7 failed\n");
8773 #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
8774 FAILED(wbuf
[6] != (sljit_u32
)-38512, "test77 case 8 failed\n");
8776 FAILED(wbuf
[6] != -38512, "test77 case 8 failed\n");
8778 FAILED(cmp_u8(bbuf
, 5, ibuf
, sizeof(sljit_s32
)) != 1, "test77 case 9 failed\n");
8779 FAILED(wbuf
[7] != -46870, "test77 case 10 failed\n");
8780 FAILED(cmp_u8(bbuf
, 9, wbuf
, sizeof(sljit_sw
)) != 1, "test77 case 11 failed\n");
8781 FAILED(wbuf
[8] != -38512, "test77 case 12 failed\n");
8782 FAILED(cmp_u8(bbuf
, 18, ibuf
, sizeof(sljit_s32
)) != 1, "test77 case 13 failed\n");
8783 FAILED(wbuf
[9] != -46870, "test77 case 14 failed\n");
8784 FAILED(cmp_u8(bbuf
, 22, wbuf
, sizeof(sljit_sw
)) != 1, "test77 case 15 failed\n");
8785 FAILED(wbuf
[10] != -46870, "test77 case 16 failed\n");
8786 FAILED(cmp_u8(bbuf
, 32, wbuf
, sizeof(sljit_sw
)) != 1, "test77 case 17 failed\n");
8787 FAILED(wbuf
[11] != -62945, "test77 case 18 failed\n");
8788 FAILED(wbuf
[12] != (sljit_sw
)&wbuf
, "test77 case 19 failed\n");
8790 sljit_free_code(code
.code
, NULL
);
8792 if (sljit_has_cpu_feature(SLJIT_HAS_FPU
)) {
8793 for (i
= 0; i
< 40; i
++)
8796 for (i
= 0; i
< 5; i
++)
8801 copy_u8(bbuf
, 1, sbuf
, sizeof(sljit_f32
));
8802 copy_u8(bbuf
, 5, dbuf
, sizeof(sljit_f64
));
8803 copy_u8(bbuf
, 14, sbuf
, sizeof(sljit_f32
));
8804 copy_u8(bbuf
, 18, dbuf
, sizeof(sljit_f64
));
8805 copy_u8(bbuf
, 28, dbuf
, sizeof(sljit_f64
));
8810 compiler
= sljit_create_compiler(NULL
, NULL
);
8811 FAILED(!compiler
, "cannot create compiler\n");
8813 sljit_emit_enter(compiler
, 0, SLJIT_ARGS3(VOID
, P
, P
, P
), 1, 3, 1, 0, 0);
8815 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_UNALIGNED
, SLJIT_FR0
, SLJIT_MEM0(), (sljit_sw
)bbuf
+ 1);
8817 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), sizeof(sljit_f32
), SLJIT_FR0
, 0);
8819 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
8821 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_FR0
, SLJIT_MEM0(), (sljit_sw
)bbuf
+ 1);
8823 sljit_emit_op2(compiler
, SLJIT_SUB
, SLJIT_R0
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 100000);
8824 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_UNALIGNED
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), 100000 + 5);
8826 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), sizeof(sljit_f64
), SLJIT_FR0
, 0);
8828 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8830 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), 100000 + 5);
8832 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_S2
), 14);
8834 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_MEM1(SLJIT_S1
), 2 * sizeof(sljit_f32
), SLJIT_FR0
, 0);
8836 sljit_emit_fop1(compiler
, SLJIT_MOV_F32
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S1
), 0);
8838 sljit_emit_fmem(compiler
, SLJIT_MOV_F32
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_S2
), 14);
8840 sljit_emit_op1(compiler
, SLJIT_MOV
, SLJIT_R0
, 0, SLJIT_IMM
, 18 >> 1);
8841 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R0
), 1);
8843 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 2 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
8845 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8847 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_16
, SLJIT_FR0
, SLJIT_MEM2(SLJIT_S2
, SLJIT_R0
), 1);
8849 sljit_emit_op2(compiler
, SLJIT_ADD
, SLJIT_R0
, 0, SLJIT_S2
, 0, SLJIT_IMM
, 128);
8850 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), -128 + 28);
8852 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_MEM1(SLJIT_S0
), 3 * sizeof(sljit_f64
), SLJIT_FR0
, 0);
8854 sljit_emit_fop1(compiler
, SLJIT_MOV_F64
, SLJIT_FR0
, 0, SLJIT_MEM1(SLJIT_S0
), 0);
8856 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_R0
), -128 + 28);
8858 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_S0
), 0);
8860 sljit_emit_fmem(compiler
, SLJIT_MOV_F64
| SLJIT_MEM_STORE
| SLJIT_MEM_UNALIGNED
| SLJIT_MEM_ALIGNED_32
, SLJIT_FR0
, SLJIT_MEM1(SLJIT_S0
), 4 * sizeof(sljit_f64
));
8862 sljit_emit_return_void(compiler
);
8864 code
.code
= sljit_generate_code(compiler
);
8866 sljit_free_compiler(compiler
);
8868 code
.func3((sljit_sw
)&dbuf
, (sljit_sw
)&sbuf
, (sljit_sw
)bbuf
);
8870 FAILED(sbuf
[1] != -8812.25, "test77 case 20 failed\n");
8871 FAILED(cmp_u8(bbuf
, 1, sbuf
, sizeof(sljit_f32
)) != 1, "test77 case 21 failed\n");
8872 FAILED(dbuf
[1] != 6897.75, "test77 case 22 failed\n");
8873 FAILED(cmp_u8(bbuf
, 5, dbuf
, sizeof(sljit_f64
)) != 1, "test77 case 23 failed\n");
8874 FAILED(sbuf
[2] != -8812.25, "test77 case 24 failed\n");
8875 FAILED(cmp_u8(bbuf
, 14, sbuf
, sizeof(sljit_f32
)) != 1, "test77 case 25 failed\n");
8876 FAILED(dbuf
[2] != 6897.75, "test77 case 26 failed\n");
8877 FAILED(cmp_u8(bbuf
, 18, dbuf
, sizeof(sljit_f64
)) != 1, "test77 case 27 failed\n");
8878 FAILED(dbuf
[3] != 6897.75, "test77 case 28 failed\n");
8879 FAILED(cmp_u8(bbuf
, 28, dbuf
, sizeof(sljit_f64
)) != 1, "test77 case 29 failed\n");
8880 FAILED(dbuf
[4] != -18046.5, "test77 case 30 failed\n");
8882 sljit_free_code(code
.code
, NULL
);
8888 int sljit_test(int argc
, char* argv
[])
8890 sljit_s32 has_arg
= (argc
>= 2 && argv
[1][0] == '-' && argv
[1][2] == '\0');
8891 verbose
= has_arg
&& argv
[1][1] == 'v';
8892 silent
= has_arg
&& argv
[1][1] == 's';
8894 if (!verbose
&& !silent
)
8895 printf("Pass -v to enable verbose, -s to disable this hint.\n\n");
8897 #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
8898 test_exec_allocator();
8978 #if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
8979 sljit_free_unused_memory_exec();
8982 # define TEST_COUNT 77
8984 printf("SLJIT tests: ");
8985 if (successful_tests
== TEST_COUNT
)
8986 printf("all tests are " COLOR_GREEN
"PASSED" COLOR_DEFAULT
" ");
8988 printf(COLOR_RED
"%d" COLOR_DEFAULT
" (" COLOR_RED
"%d%%" COLOR_DEFAULT
") tests are " COLOR_RED
"FAILED" COLOR_DEFAULT
" ", TEST_COUNT
- successful_tests
, (TEST_COUNT
- successful_tests
) * 100 / TEST_COUNT
);
8989 printf("on " COLOR_ARCH
"%s" COLOR_DEFAULT
"%s\n", sljit_get_platform_name(), sljit_has_cpu_feature(SLJIT_HAS_FPU
) ? " (with fpu)" : " (without fpu)");
8991 return TEST_COUNT
- successful_tests
;
8997 #pragma warning(pop)