sljitTest.c revision 1.1.1.2.2.3 1 1.1.1.2.2.2 yamt /*
2 1.1.1.2.2.2 yamt * Stack-less Just-In-Time compiler
3 1.1.1.2.2.2 yamt *
4 1.1.1.2.2.2 yamt * Copyright 2009-2010 Zoltan Herczeg (hzmester (at) freemail.hu). All rights reserved.
5 1.1.1.2.2.2 yamt *
6 1.1.1.2.2.2 yamt * Redistribution and use in source and binary forms, with or without modification, are
7 1.1.1.2.2.2 yamt * permitted provided that the following conditions are met:
8 1.1.1.2.2.2 yamt *
9 1.1.1.2.2.2 yamt * 1. Redistributions of source code must retain the above copyright notice, this list of
10 1.1.1.2.2.2 yamt * conditions and the following disclaimer.
11 1.1.1.2.2.2 yamt *
12 1.1.1.2.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 1.1.1.2.2.2 yamt * of conditions and the following disclaimer in the documentation and/or other materials
14 1.1.1.2.2.2 yamt * provided with the distribution.
15 1.1.1.2.2.2 yamt *
16 1.1.1.2.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
17 1.1.1.2.2.2 yamt * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1.1.2.2.2 yamt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 1.1.1.2.2.2 yamt * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1.1.2.2.2 yamt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 1.1.1.2.2.2 yamt * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 1.1.1.2.2.2 yamt * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1.1.2.2.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 1.1.1.2.2.2 yamt * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 1.1.1.2.2.2 yamt */
26 1.1.1.2.2.2 yamt
27 1.1.1.2.2.2 yamt #include "sljitLir.h"
28 1.1.1.2.2.2 yamt
29 1.1.1.2.2.2 yamt #include <stdio.h>
30 1.1.1.2.2.2 yamt #include <stdlib.h>
31 1.1.1.2.2.2 yamt #include <string.h>
32 1.1.1.2.2.2 yamt
33 1.1.1.2.2.2 yamt union executable_code {
34 1.1.1.2.2.2 yamt void* code;
35 1.1.1.2.2.2 yamt sljit_w (SLJIT_CALL *func0)(void);
36 1.1.1.2.2.2 yamt sljit_w (SLJIT_CALL *func1)(sljit_w a);
37 1.1.1.2.2.2 yamt sljit_w (SLJIT_CALL *func2)(sljit_w a, sljit_w b);
38 1.1.1.2.2.2 yamt sljit_w (SLJIT_CALL *func3)(sljit_w a, sljit_w b, sljit_w c);
39 1.1.1.2.2.2 yamt };
40 1.1.1.2.2.2 yamt typedef union executable_code executable_code;
41 1.1.1.2.2.2 yamt
42 1.1.1.2.2.2 yamt static int successful_tests = 0;
43 1.1.1.2.2.2 yamt
44 1.1.1.2.2.2 yamt #define FAILED(cond, text) \
45 1.1.1.2.2.2 yamt if (SLJIT_UNLIKELY(cond)) { \
46 1.1.1.2.2.2 yamt printf(text); \
47 1.1.1.2.2.2 yamt return; \
48 1.1.1.2.2.2 yamt }
49 1.1.1.2.2.2 yamt
50 1.1.1.2.2.2 yamt #define CHECK(compiler) \
51 1.1.1.2.2.2 yamt if (sljit_get_compiler_error(compiler) != SLJIT_ERR_COMPILED) { \
52 1.1.1.2.2.2 yamt printf("Compiler error: %d\n", sljit_get_compiler_error(compiler)); \
53 1.1.1.2.2.2 yamt sljit_free_compiler(compiler); \
54 1.1.1.2.2.2 yamt return; \
55 1.1.1.2.2.2 yamt }
56 1.1.1.2.2.2 yamt
57 1.1.1.2.2.2 yamt static void cond_set(struct sljit_compiler *compiler, int dst, sljit_w dstw, int type)
58 1.1.1.2.2.2 yamt {
59 1.1.1.2.2.2 yamt /* Testing both sljit_emit_cond_value and sljit_emit_jump. */
60 1.1.1.2.2.2 yamt struct sljit_jump* jump;
61 1.1.1.2.2.2 yamt struct sljit_label* label;
62 1.1.1.2.2.2 yamt
63 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, dst, dstw, type);
64 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, type);
65 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, dst, dstw, SLJIT_IMM, 2);
66 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
67 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
68 1.1.1.2.2.2 yamt }
69 1.1.1.2.2.2 yamt
70 1.1.1.2.2.2 yamt #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
71 1.1.1.2.2.2 yamt
72 1.1.1.2.2.2 yamt #define MALLOC_EXEC(result, size) \
73 1.1.1.2.2.2 yamt result = SLJIT_MALLOC_EXEC(size); \
74 1.1.1.2.2.2 yamt if (!result) { \
75 1.1.1.2.2.2 yamt printf("Cannot allocate executable memory\n"); \
76 1.1.1.2.2.2 yamt return; \
77 1.1.1.2.2.2 yamt } \
78 1.1.1.2.2.2 yamt memset(result, 255, size);
79 1.1.1.2.2.2 yamt
80 1.1.1.2.2.2 yamt static void test_exec_allocator(void)
81 1.1.1.2.2.2 yamt {
82 1.1.1.2.2.2 yamt /* This is not an sljit test. */
83 1.1.1.2.2.2 yamt void *ptr1;
84 1.1.1.2.2.2 yamt void *ptr2;
85 1.1.1.2.2.2 yamt void *ptr3;
86 1.1.1.2.2.2 yamt
87 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr1, 32);
88 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr2, 512);
89 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr3, 512);
90 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr2);
91 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr3);
92 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr1);
93 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr1, 262104);
94 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr2, 32000);
95 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr1);
96 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr1, 262104);
97 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr1);
98 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr2);
99 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr1, 512);
100 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr2, 512);
101 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr3, 512);
102 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr2);
103 1.1.1.2.2.2 yamt MALLOC_EXEC(ptr2, 512);
104 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr3);
105 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr1);
106 1.1.1.2.2.2 yamt SLJIT_FREE_EXEC(ptr2);
107 1.1.1.2.2.2 yamt #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
108 1.1.1.2.2.2 yamt /* Just call the global locks. */
109 1.1.1.2.2.2 yamt sljit_grab_lock();
110 1.1.1.2.2.2 yamt sljit_release_lock();
111 1.1.1.2.2.2 yamt #endif
112 1.1.1.2.2.2 yamt printf("Executable allocator: ok\n");
113 1.1.1.2.2.2 yamt }
114 1.1.1.2.2.2 yamt
115 1.1.1.2.2.2 yamt #undef MALLOC_EXEC
116 1.1.1.2.2.2 yamt
117 1.1.1.2.2.2 yamt #endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
118 1.1.1.2.2.2 yamt
119 1.1.1.2.2.2 yamt static void test1(void)
120 1.1.1.2.2.2 yamt {
121 1.1.1.2.2.2 yamt /* Enter and return from an sljit function. */
122 1.1.1.2.2.2 yamt executable_code code;
123 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
124 1.1.1.2.2.2 yamt
125 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
126 1.1.1.2.2.2 yamt
127 1.1.1.2.2.2 yamt /* 3 arguments passed, 3 arguments used. */
128 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 3, 3, 3, 0);
129 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0);
130 1.1.1.2.2.2 yamt
131 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_get_generated_code_size(compiler) == 0);
132 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
133 1.1.1.2.2.2 yamt CHECK(compiler);
134 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->error == SLJIT_ERR_COMPILED);
135 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_get_generated_code_size(compiler) > 0);
136 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
137 1.1.1.2.2.2 yamt
138 1.1.1.2.2.2 yamt FAILED(code.func3(3, -21, 86) != -21, "test1 case 1 failed\n");
139 1.1.1.2.2.2 yamt FAILED(code.func3(4789, 47890, 997) != 47890, "test1 case 2 failed\n");
140 1.1.1.2.2.2 yamt sljit_free_code(code.code);
141 1.1.1.2.2.2 yamt printf("test1 ok\n");
142 1.1.1.2.2.2 yamt successful_tests++;
143 1.1.1.2.2.2 yamt }
144 1.1.1.2.2.2 yamt
145 1.1.1.2.2.2 yamt static void test2(void)
146 1.1.1.2.2.2 yamt {
147 1.1.1.2.2.2 yamt /* Test mov. */
148 1.1.1.2.2.2 yamt executable_code code;
149 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
150 1.1.1.2.2.2 yamt sljit_w buf[6];
151 1.1.1.2.2.2 yamt static sljit_w data[2] = { 0, -9876 };
152 1.1.1.2.2.2 yamt
153 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
154 1.1.1.2.2.2 yamt
155 1.1.1.2.2.2 yamt buf[0] = 5678;
156 1.1.1.2.2.2 yamt buf[1] = 0;
157 1.1.1.2.2.2 yamt buf[2] = 0;
158 1.1.1.2.2.2 yamt buf[3] = 0;
159 1.1.1.2.2.2 yamt buf[4] = 0;
160 1.1.1.2.2.2 yamt buf[5] = 0;
161 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 0);
162 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_UNUSED, 0, SLJIT_MEM0(), (sljit_w)&buf);
163 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9999);
164 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG1, 0);
165 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
166 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
167 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 0);
168 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 2);
169 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_SAVED_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 0);
170 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 3);
171 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_SAVED_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM0(), (sljit_w)&buf);
172 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
173 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&data);
174 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
175 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf - 0x12345678);
176 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0x12345678);
177 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
178 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0);
179 1.1.1.2.2.2 yamt
180 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
181 1.1.1.2.2.2 yamt CHECK(compiler);
182 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
183 1.1.1.2.2.2 yamt
184 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 9999, "test2 case 1 failed\n");
185 1.1.1.2.2.2 yamt FAILED(buf[1] != 9999, "test2 case 2 failed\n");
186 1.1.1.2.2.2 yamt FAILED(buf[2] != 9999, "test2 case 3 failed\n");
187 1.1.1.2.2.2 yamt FAILED(buf[3] != 5678, "test2 case 4 failed\n");
188 1.1.1.2.2.2 yamt FAILED(buf[4] != -9876, "test2 case 5 failed\n");
189 1.1.1.2.2.2 yamt FAILED(buf[5] != 5678, "test2 case 6 failed\n");
190 1.1.1.2.2.2 yamt sljit_free_code(code.code);
191 1.1.1.2.2.2 yamt printf("test2 ok\n");
192 1.1.1.2.2.2 yamt successful_tests++;
193 1.1.1.2.2.2 yamt }
194 1.1.1.2.2.2 yamt
195 1.1.1.2.2.2 yamt static void test3(void)
196 1.1.1.2.2.2 yamt {
197 1.1.1.2.2.2 yamt /* Test not. */
198 1.1.1.2.2.2 yamt executable_code code;
199 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
200 1.1.1.2.2.2 yamt sljit_w buf[5];
201 1.1.1.2.2.2 yamt
202 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
203 1.1.1.2.2.2 yamt buf[0] = 1234;
204 1.1.1.2.2.2 yamt buf[1] = 0;
205 1.1.1.2.2.2 yamt buf[2] = 9876;
206 1.1.1.2.2.2 yamt buf[3] = 0;
207 1.1.1.2.2.2 yamt buf[4] = 0x12345678;
208 1.1.1.2.2.2 yamt
209 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
210 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_UNUSED, 0, SLJIT_MEM0(), (sljit_w)&buf);
211 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
212 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM0(), (sljit_w)&buf[1], SLJIT_MEM0(), (sljit_w)&buf[1]);
213 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_RETURN_REG, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
214 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2);
215 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)&buf[4] - 0xff0000 - 0x20);
216 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, (sljit_w)&buf[4] - 0xff0000);
217 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0xff0000 + 0x20, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), 0xff0000);
218 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
219 1.1.1.2.2.2 yamt
220 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
221 1.1.1.2.2.2 yamt CHECK(compiler);
222 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
223 1.1.1.2.2.2 yamt
224 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != ~1234, "test3 case 1 failed\n");
225 1.1.1.2.2.2 yamt FAILED(buf[1] != ~1234, "test3 case 2 failed\n");
226 1.1.1.2.2.2 yamt FAILED(buf[3] != ~9876, "test3 case 3 failed\n");
227 1.1.1.2.2.2 yamt FAILED(buf[4] != ~0x12345678, "test3 case 4 failed\n");
228 1.1.1.2.2.2 yamt
229 1.1.1.2.2.2 yamt sljit_free_code(code.code);
230 1.1.1.2.2.2 yamt printf("test3 ok\n");
231 1.1.1.2.2.2 yamt successful_tests++;
232 1.1.1.2.2.2 yamt }
233 1.1.1.2.2.2 yamt
234 1.1.1.2.2.2 yamt static void test4(void)
235 1.1.1.2.2.2 yamt {
236 1.1.1.2.2.2 yamt /* Test neg. */
237 1.1.1.2.2.2 yamt executable_code code;
238 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
239 1.1.1.2.2.2 yamt sljit_w buf[4];
240 1.1.1.2.2.2 yamt
241 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
242 1.1.1.2.2.2 yamt buf[0] = 0;
243 1.1.1.2.2.2 yamt buf[1] = 1234;
244 1.1.1.2.2.2 yamt buf[2] = 0;
245 1.1.1.2.2.2 yamt buf[3] = 0;
246 1.1.1.2.2.2 yamt
247 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 2, 0);
248 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
249 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_SAVED_REG2, 0);
250 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_MEM0(), (sljit_w)&buf[1]);
251 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_RETURN_REG, 0, SLJIT_SAVED_REG2, 0);
252 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 299);
253 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
254 1.1.1.2.2.2 yamt
255 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
256 1.1.1.2.2.2 yamt CHECK(compiler);
257 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
258 1.1.1.2.2.2 yamt
259 1.1.1.2.2.2 yamt FAILED(code.func2((sljit_w)&buf, 4567) != -4567, "test4 case 1 failed\n");
260 1.1.1.2.2.2 yamt FAILED(buf[0] != -1234, "test4 case 2 failed\n");
261 1.1.1.2.2.2 yamt FAILED(buf[2] != -4567, "test4 case 3 failed\n");
262 1.1.1.2.2.2 yamt FAILED(buf[3] != -299, "test4 case 4 failed\n");
263 1.1.1.2.2.2 yamt
264 1.1.1.2.2.2 yamt sljit_free_code(code.code);
265 1.1.1.2.2.2 yamt printf("test4 ok\n");
266 1.1.1.2.2.2 yamt successful_tests++;
267 1.1.1.2.2.2 yamt }
268 1.1.1.2.2.2 yamt
269 1.1.1.2.2.2 yamt static void test5(void)
270 1.1.1.2.2.2 yamt {
271 1.1.1.2.2.2 yamt /* Test add. */
272 1.1.1.2.2.2 yamt executable_code code;
273 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
274 1.1.1.2.2.2 yamt sljit_w buf[9];
275 1.1.1.2.2.2 yamt
276 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
277 1.1.1.2.2.2 yamt buf[0] = 100;
278 1.1.1.2.2.2 yamt buf[1] = 200;
279 1.1.1.2.2.2 yamt buf[2] = 300;
280 1.1.1.2.2.2 yamt buf[3] = 0;
281 1.1.1.2.2.2 yamt buf[4] = 0;
282 1.1.1.2.2.2 yamt buf[5] = 0;
283 1.1.1.2.2.2 yamt buf[6] = 0;
284 1.1.1.2.2.2 yamt buf[7] = 0;
285 1.1.1.2.2.2 yamt buf[8] = 313;
286 1.1.1.2.2.2 yamt
287 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 0);
288 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_IMM, 16, SLJIT_IMM, 16);
289 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_IMM, 255, SLJIT_IMM, 255);
290 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0);
291 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
292 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50);
293 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0);
294 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w) + 2);
295 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50);
296 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
297 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
298 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4, SLJIT_TEMPORARY_REG1, 0);
299 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 50, SLJIT_TEMPORARY_REG2, 0);
300 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, 50, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w));
301 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
302 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w));
303 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w));
304 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
305 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x1e7d39f2);
306 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x23de7c06);
307 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_IMM, 0x3d72e452, SLJIT_TEMPORARY_REG2, 0);
308 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_IMM, -43, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w));
309 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1000, SLJIT_TEMPORARY_REG1, 0);
310 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1430);
311 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -99, SLJIT_TEMPORARY_REG1, 0);
312 1.1.1.2.2.2 yamt
313 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
314 1.1.1.2.2.2 yamt
315 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
316 1.1.1.2.2.2 yamt CHECK(compiler);
317 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
318 1.1.1.2.2.2 yamt
319 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 2437 + 2 * sizeof(sljit_w), "test5 case 1 failed\n");
320 1.1.1.2.2.2 yamt FAILED(buf[0] != 202 + 2 * sizeof(sljit_w), "test5 case 2 failed\n");
321 1.1.1.2.2.2 yamt FAILED(buf[2] != 500, "test5 case 3 failed\n");
322 1.1.1.2.2.2 yamt FAILED(buf[3] != 400, "test5 case 4 failed\n");
323 1.1.1.2.2.2 yamt FAILED(buf[4] != 200, "test5 case 5 failed\n");
324 1.1.1.2.2.2 yamt FAILED(buf[5] != 250, "test5 case 6 failed\n");
325 1.1.1.2.2.2 yamt FAILED(buf[6] != 0x425bb5f8, "test5 case 7 failed\n");
326 1.1.1.2.2.2 yamt FAILED(buf[7] != 0x5bf01e44, "test5 case 8 failed\n");
327 1.1.1.2.2.2 yamt FAILED(buf[8] != 270, "test5 case 9 failed\n");
328 1.1.1.2.2.2 yamt
329 1.1.1.2.2.2 yamt sljit_free_code(code.code);
330 1.1.1.2.2.2 yamt printf("test5 ok\n");
331 1.1.1.2.2.2 yamt successful_tests++;
332 1.1.1.2.2.2 yamt }
333 1.1.1.2.2.2 yamt
334 1.1.1.2.2.2 yamt static void test6(void)
335 1.1.1.2.2.2 yamt {
336 1.1.1.2.2.2 yamt /* Test addc, sub, subc. */
337 1.1.1.2.2.2 yamt executable_code code;
338 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
339 1.1.1.2.2.2 yamt sljit_w buf[10];
340 1.1.1.2.2.2 yamt
341 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
342 1.1.1.2.2.2 yamt buf[0] = 0;
343 1.1.1.2.2.2 yamt buf[1] = 0;
344 1.1.1.2.2.2 yamt buf[2] = 0;
345 1.1.1.2.2.2 yamt buf[3] = 0;
346 1.1.1.2.2.2 yamt buf[4] = 0;
347 1.1.1.2.2.2 yamt buf[5] = 0;
348 1.1.1.2.2.2 yamt buf[6] = 0;
349 1.1.1.2.2.2 yamt buf[7] = 0;
350 1.1.1.2.2.2 yamt buf[8] = 0;
351 1.1.1.2.2.2 yamt buf[9] = 0;
352 1.1.1.2.2.2 yamt
353 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
354 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
355 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
356 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0, SLJIT_IMM, 0);
357 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
358 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 4);
359 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
360 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 50);
361 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6000);
362 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 10);
363 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 5);
364 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
365 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2);
366 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
367 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5000);
368 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
369 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
370 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG2, 0);
371 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5000);
372 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6000, SLJIT_TEMPORARY_REG1, 0);
373 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_TEMPORARY_REG1, 0);
374 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
375 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 32768);
376 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_TEMPORARY_REG2, 0);
377 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -32767);
378 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_TEMPORARY_REG2, 0);
379 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x52cd3bf4);
380 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x3da297c6);
381 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 10);
382 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 5);
383 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 2);
384 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, -2220);
385 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
386 1.1.1.2.2.2 yamt
387 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
388 1.1.1.2.2.2 yamt CHECK(compiler);
389 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
390 1.1.1.2.2.2 yamt
391 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 2223, "test6 case 1 failed\n");
392 1.1.1.2.2.2 yamt FAILED(buf[0] != 1, "test6 case 2 failed\n");
393 1.1.1.2.2.2 yamt FAILED(buf[1] != 5, "test6 case 3 failed\n");
394 1.1.1.2.2.2 yamt FAILED(buf[2] != 50, "test6 case 4 failed\n");
395 1.1.1.2.2.2 yamt FAILED(buf[3] != 4, "test6 case 5 failed\n");
396 1.1.1.2.2.2 yamt FAILED(buf[4] != 50, "test6 case 6 failed\n");
397 1.1.1.2.2.2 yamt FAILED(buf[5] != 50, "test6 case 7 failed\n");
398 1.1.1.2.2.2 yamt FAILED(buf[6] != 1000, "test6 case 8 failed\n");
399 1.1.1.2.2.2 yamt FAILED(buf[7] != 100 - 32768, "test6 case 9 failed\n");
400 1.1.1.2.2.2 yamt FAILED(buf[8] != 100 + 32767, "test6 case 10 failed\n");
401 1.1.1.2.2.2 yamt FAILED(buf[9] != 0x152aa42e, "test6 case 11 failed\n");
402 1.1.1.2.2.2 yamt
403 1.1.1.2.2.2 yamt sljit_free_code(code.code);
404 1.1.1.2.2.2 yamt printf("test6 ok\n");
405 1.1.1.2.2.2 yamt successful_tests++;
406 1.1.1.2.2.2 yamt }
407 1.1.1.2.2.2 yamt
408 1.1.1.2.2.2 yamt static void test7(void)
409 1.1.1.2.2.2 yamt {
410 1.1.1.2.2.2 yamt /* Test logical operators. */
411 1.1.1.2.2.2 yamt executable_code code;
412 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
413 1.1.1.2.2.2 yamt sljit_w buf[8];
414 1.1.1.2.2.2 yamt
415 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
416 1.1.1.2.2.2 yamt buf[0] = 0xff80;
417 1.1.1.2.2.2 yamt buf[1] = 0x0f808080;
418 1.1.1.2.2.2 yamt buf[2] = 0;
419 1.1.1.2.2.2 yamt buf[3] = 0xaaaaaa;
420 1.1.1.2.2.2 yamt buf[4] = 0;
421 1.1.1.2.2.2 yamt buf[5] = 0x4040;
422 1.1.1.2.2.2 yamt buf[6] = 0;
423 1.1.1.2.2.2 yamt buf[7] = 0xc43a7f95;
424 1.1.1.2.2.2 yamt
425 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
426 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf0C000);
427 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x308f);
428 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
429 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, 0xf0f0f0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3);
430 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xC0F0);
431 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5);
432 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff0000);
433 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
434 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xC0F0);
435 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5);
436 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xff0000);
437 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 0xFFFFFF, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
438 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_IMM, 0xa56c82c0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6);
439 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7);
440 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_XOR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_IMM, 0xff00ff00, SLJIT_TEMPORARY_REG1, 0);
441 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff00ff00);
442 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x0f);
443 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0x888888, SLJIT_TEMPORARY_REG2, 0);
444 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
445 1.1.1.2.2.2 yamt
446 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
447 1.1.1.2.2.2 yamt CHECK(compiler);
448 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
449 1.1.1.2.2.2 yamt
450 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 0x8808, "test7 case 1 failed\n");
451 1.1.1.2.2.2 yamt FAILED(buf[0] != 0x0F807F00, "test7 case 2 failed\n");
452 1.1.1.2.2.2 yamt FAILED(buf[1] != 0x0F7F7F7F, "test7 case 3 failed\n");
453 1.1.1.2.2.2 yamt FAILED(buf[2] != 0x00F0F08F, "test7 case 4 failed\n");
454 1.1.1.2.2.2 yamt FAILED(buf[3] != 0x00A0A0A0, "test7 case 5 failed\n");
455 1.1.1.2.2.2 yamt FAILED(buf[4] != 0x00FF80B0, "test7 case 6 failed\n");
456 1.1.1.2.2.2 yamt FAILED(buf[5] != 0x00FF4040, "test7 case 7 failed\n");
457 1.1.1.2.2.2 yamt FAILED(buf[6] != 0xa56c82c0, "test7 case 8 failed\n");
458 1.1.1.2.2.2 yamt FAILED(buf[7] != 0x3b3a8095, "test7 case 9 failed\n");
459 1.1.1.2.2.2 yamt
460 1.1.1.2.2.2 yamt sljit_free_code(code.code);
461 1.1.1.2.2.2 yamt printf("test7 ok\n");
462 1.1.1.2.2.2 yamt successful_tests++;
463 1.1.1.2.2.2 yamt }
464 1.1.1.2.2.2 yamt
465 1.1.1.2.2.2 yamt static void test8(void)
466 1.1.1.2.2.2 yamt {
467 1.1.1.2.2.2 yamt /* Test flags (neg, cmp, test). */
468 1.1.1.2.2.2 yamt executable_code code;
469 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
470 1.1.1.2.2.2 yamt sljit_w buf[20];
471 1.1.1.2.2.2 yamt
472 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
473 1.1.1.2.2.2 yamt buf[0] = 100;
474 1.1.1.2.2.2 yamt buf[1] = 3;
475 1.1.1.2.2.2 yamt buf[2] = 3;
476 1.1.1.2.2.2 yamt buf[3] = 3;
477 1.1.1.2.2.2 yamt buf[4] = 3;
478 1.1.1.2.2.2 yamt buf[5] = 3;
479 1.1.1.2.2.2 yamt buf[6] = 3;
480 1.1.1.2.2.2 yamt buf[7] = 3;
481 1.1.1.2.2.2 yamt buf[8] = 3;
482 1.1.1.2.2.2 yamt buf[9] = 3;
483 1.1.1.2.2.2 yamt
484 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 0);
485 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
486 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 10);
487 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 6, SLJIT_IMM, 5);
488 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_NOT_EQUAL);
489 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_C_EQUAL);
490 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3000);
491 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_C_GREATER);
492 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_SAVED_REG2, 0);
493 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_C_LESS);
494 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG3, 0);
495 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -15);
496 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_C_SIG_GREATER);
497 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG3, 0);
498 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
499 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
500 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG | SLJIT_SET_E | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_IMM, (sljit_w)1 << ((sizeof(sljit_w) << 3) - 1));
501 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_OVERFLOW);
502 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
503 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
504 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_ZERO);
505 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0);
506 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_ZERO);
507 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0xffff, SLJIT_TEMPORARY_REG1, 0);
508 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffff);
509 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_C_NOT_ZERO);
510 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0xffff, SLJIT_TEMPORARY_REG2, 0);
511 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0xffff);
512 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
513 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
514 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
515 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0x1);
516 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_C_NOT_ZERO);
517 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
518 1.1.1.2.2.2 yamt
519 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
520 1.1.1.2.2.2 yamt CHECK(compiler);
521 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
522 1.1.1.2.2.2 yamt
523 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
524 1.1.1.2.2.2 yamt FAILED(buf[1] != 1, "test8 case 1 failed\n");
525 1.1.1.2.2.2 yamt FAILED(buf[2] != 0, "test8 case 2 failed\n");
526 1.1.1.2.2.2 yamt FAILED(buf[3] != 0, "test8 case 3 failed\n");
527 1.1.1.2.2.2 yamt FAILED(buf[4] != 1, "test8 case 4 failed\n");
528 1.1.1.2.2.2 yamt FAILED(buf[5] != 1, "test8 case 5 failed\n");
529 1.1.1.2.2.2 yamt FAILED(buf[6] != 1, "test8 case 6 failed\n");
530 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test8 case 7 failed\n");
531 1.1.1.2.2.2 yamt FAILED(buf[8] != 0, "test8 case 8 failed\n");
532 1.1.1.2.2.2 yamt FAILED(buf[9] != 1, "test8 case 9 failed\n");
533 1.1.1.2.2.2 yamt FAILED(buf[10] != 0, "test8 case 10 failed\n");
534 1.1.1.2.2.2 yamt
535 1.1.1.2.2.2 yamt sljit_free_code(code.code);
536 1.1.1.2.2.2 yamt printf("test8 ok\n");
537 1.1.1.2.2.2 yamt successful_tests++;
538 1.1.1.2.2.2 yamt }
539 1.1.1.2.2.2 yamt
540 1.1.1.2.2.2 yamt static void test9(void)
541 1.1.1.2.2.2 yamt {
542 1.1.1.2.2.2 yamt /* Test shift. */
543 1.1.1.2.2.2 yamt executable_code code;
544 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
545 1.1.1.2.2.2 yamt sljit_w buf[13];
546 1.1.1.2.2.2 yamt
547 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
548 1.1.1.2.2.2 yamt buf[0] = 0;
549 1.1.1.2.2.2 yamt buf[1] = 0;
550 1.1.1.2.2.2 yamt buf[2] = 0;
551 1.1.1.2.2.2 yamt buf[3] = 0;
552 1.1.1.2.2.2 yamt buf[4] = 1 << 10;
553 1.1.1.2.2.2 yamt buf[5] = 0;
554 1.1.1.2.2.2 yamt buf[6] = 0;
555 1.1.1.2.2.2 yamt buf[7] = 0;
556 1.1.1.2.2.2 yamt buf[8] = 0;
557 1.1.1.2.2.2 yamt buf[9] = 3;
558 1.1.1.2.2.2 yamt buf[10] = 0;
559 1.1.1.2.2.2 yamt buf[11] = 0;
560 1.1.1.2.2.2 yamt buf[12] = 0;
561 1.1.1.2.2.2 yamt
562 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 0);
563 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf);
564 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
565 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
566 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
567 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
568 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
569 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
570 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -64);
571 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 2);
572 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
573 1.1.1.2.2.2 yamt
574 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0xff);
575 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
576 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_PREF_SHIFT_REG, 0, SLJIT_PREF_SHIFT_REG, 0, SLJIT_TEMPORARY_REG1, 0);
577 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_PREF_SHIFT_REG, 0);
578 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0xff);
579 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
580 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG1, 0);
581 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_PREF_SHIFT_REG, 0, SLJIT_TEMPORARY_REG1, 0);
582 1.1.1.2.2.2 yamt
583 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0xf);
584 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
585 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
586 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_SAVED_REG2, 0);
587 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
588 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_TEMPORARY_REG1, 0);
589 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 0xf00);
590 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
591 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG1, 0);
592 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_TEMPORARY_REG2, 0);
593 1.1.1.2.2.2 yamt
594 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)buf);
595 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 9);
596 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT);
597 1.1.1.2.2.2 yamt
598 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 4);
599 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 2, SLJIT_PREF_SHIFT_REG, 0);
600 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_PREF_SHIFT_REG, 0);
601 1.1.1.2.2.2 yamt
602 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xa9);
603 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
604 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x7d00);
605 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 32);
606 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
607 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
608 1.1.1.2.2.2 yamt #endif
609 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
610 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xe30000);
611 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
612 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffc0);
613 1.1.1.2.2.2 yamt #else
614 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffe0);
615 1.1.1.2.2.2 yamt #endif
616 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
617 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x25000000);
618 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xfffe1);
619 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
620 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
621 1.1.1.2.2.2 yamt #endif
622 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 11, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
623 1.1.1.2.2.2 yamt
624 1.1.1.2.2.2 yamt SLJIT_ASSERT(SLJIT_TEMPORARY_REG3 == SLJIT_PREF_SHIFT_REG);
625 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
626 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x5c);
627 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
628 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf600);
629 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
630 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
631 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffffff);
632 1.1.1.2.2.2 yamt #endif
633 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
634 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x630000);
635 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
636 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 12, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
637 1.1.1.2.2.2 yamt
638 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
639 1.1.1.2.2.2 yamt
640 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
641 1.1.1.2.2.2 yamt CHECK(compiler);
642 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
643 1.1.1.2.2.2 yamt
644 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
645 1.1.1.2.2.2 yamt FAILED(buf[0] != 0x3c, "test9 case 1 failed\n");
646 1.1.1.2.2.2 yamt FAILED(buf[1] != 0xf0, "test9 case 2 failed\n");
647 1.1.1.2.2.2 yamt FAILED(buf[2] != -16, "test9 case 3 failed\n");
648 1.1.1.2.2.2 yamt FAILED(buf[3] != 0xff0, "test9 case 4 failed\n");
649 1.1.1.2.2.2 yamt FAILED(buf[4] != 4, "test9 case 5 failed\n");
650 1.1.1.2.2.2 yamt FAILED(buf[5] != 0xff00, "test9 case 6 failed\n");
651 1.1.1.2.2.2 yamt FAILED(buf[6] != 0x3c, "test9 case 7 failed\n");
652 1.1.1.2.2.2 yamt FAILED(buf[7] != 0xf0, "test9 case 8 failed\n");
653 1.1.1.2.2.2 yamt FAILED(buf[8] != 0xf0, "test9 case 9 failed\n");
654 1.1.1.2.2.2 yamt FAILED(buf[9] != 0x18, "test9 case 10 failed\n");
655 1.1.1.2.2.2 yamt FAILED(buf[10] != 32, "test9 case 11 failed\n");
656 1.1.1.2.2.2 yamt FAILED(buf[11] != 0x4ae37da9, "test9 case 12 failed\n");
657 1.1.1.2.2.2 yamt FAILED(buf[12] != 0x63f65c, "test9 case 13 failed\n");
658 1.1.1.2.2.2 yamt
659 1.1.1.2.2.2 yamt sljit_free_code(code.code);
660 1.1.1.2.2.2 yamt printf("test9 ok\n");
661 1.1.1.2.2.2 yamt successful_tests++;
662 1.1.1.2.2.2 yamt }
663 1.1.1.2.2.2 yamt
664 1.1.1.2.2.2 yamt static void test10(void)
665 1.1.1.2.2.2 yamt {
666 1.1.1.2.2.2 yamt /* Test multiplications. */
667 1.1.1.2.2.2 yamt executable_code code;
668 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
669 1.1.1.2.2.2 yamt sljit_w buf[6];
670 1.1.1.2.2.2 yamt
671 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
672 1.1.1.2.2.2 yamt buf[0] = 3;
673 1.1.1.2.2.2 yamt buf[1] = 0;
674 1.1.1.2.2.2 yamt buf[2] = 0;
675 1.1.1.2.2.2 yamt buf[3] = 6;
676 1.1.1.2.2.2 yamt buf[4] = -10;
677 1.1.1.2.2.2 yamt buf[5] = 0;
678 1.1.1.2.2.2 yamt
679 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
680 1.1.1.2.2.2 yamt
681 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
682 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
683 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
684 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 7);
685 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 8);
686 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
687 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -3, SLJIT_IMM, -4);
688 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0);
689 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -2);
690 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_TEMPORARY_REG1, 0);
691 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w) / 2);
692 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)&buf[3]);
693 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1);
694 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9);
695 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
696 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_TEMPORARY_REG1, 0);
697 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 11, SLJIT_IMM, 10);
698 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
699 1.1.1.2.2.2 yamt
700 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
701 1.1.1.2.2.2 yamt CHECK(compiler);
702 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
703 1.1.1.2.2.2 yamt
704 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 110, "test10 case 1 failed\n");
705 1.1.1.2.2.2 yamt FAILED(buf[0] != 15, "test10 case 2 failed\n");
706 1.1.1.2.2.2 yamt FAILED(buf[1] != 56, "test10 case 3 failed\n");
707 1.1.1.2.2.2 yamt FAILED(buf[2] != 12, "test10 case 4 failed\n");
708 1.1.1.2.2.2 yamt FAILED(buf[3] != -12, "test10 case 5 failed\n");
709 1.1.1.2.2.2 yamt FAILED(buf[4] != 100, "test10 case 6 failed\n");
710 1.1.1.2.2.2 yamt FAILED(buf[5] != 81, "test10 case 7 failed\n");
711 1.1.1.2.2.2 yamt
712 1.1.1.2.2.2 yamt sljit_free_code(code.code);
713 1.1.1.2.2.2 yamt printf("test10 ok\n");
714 1.1.1.2.2.2 yamt successful_tests++;
715 1.1.1.2.2.2 yamt }
716 1.1.1.2.2.2 yamt
717 1.1.1.2.2.2 yamt static void test11(void)
718 1.1.1.2.2.2 yamt {
719 1.1.1.2.2.2 yamt /* Test rewritable constants. */
720 1.1.1.2.2.2 yamt executable_code code;
721 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
722 1.1.1.2.2.2 yamt struct sljit_const* const1;
723 1.1.1.2.2.2 yamt struct sljit_const* const2;
724 1.1.1.2.2.2 yamt struct sljit_const* const3;
725 1.1.1.2.2.2 yamt struct sljit_const* const4;
726 1.1.1.2.2.2 yamt void* value;
727 1.1.1.2.2.2 yamt sljit_uw const1_addr;
728 1.1.1.2.2.2 yamt sljit_uw const2_addr;
729 1.1.1.2.2.2 yamt sljit_uw const3_addr;
730 1.1.1.2.2.2 yamt sljit_uw const4_addr;
731 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
732 1.1.1.2.2.2 yamt sljit_w word_value1 = SLJIT_W(0xaaaaaaaaaaaaaaaa);
733 1.1.1.2.2.2 yamt sljit_w word_value2 = SLJIT_W(0xfee1deadfbadf00d);
734 1.1.1.2.2.2 yamt #else
735 1.1.1.2.2.2 yamt sljit_w word_value1 = 0xaaaaaaaal;
736 1.1.1.2.2.2 yamt sljit_w word_value2 = 0xfbadf00dl;
737 1.1.1.2.2.2 yamt #endif
738 1.1.1.2.2.2 yamt sljit_w buf[3];
739 1.1.1.2.2.2 yamt
740 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
741 1.1.1.2.2.2 yamt buf[0] = 0;
742 1.1.1.2.2.2 yamt buf[1] = 0;
743 1.1.1.2.2.2 yamt buf[2] = 0;
744 1.1.1.2.2.2 yamt
745 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
746 1.1.1.2.2.2 yamt
747 1.1.1.2.2.2 yamt const1 = sljit_emit_const(compiler, SLJIT_MEM0(), (sljit_w)&buf[0], -0x81b9);
748 1.1.1.2.2.2 yamt SLJIT_ASSERT(!sljit_alloc_memory(compiler, 0));
749 1.1.1.2.2.2 yamt SLJIT_ASSERT(!sljit_alloc_memory(compiler, 16 * sizeof(sljit_w) + 1));
750 1.1.1.2.2.2 yamt value = sljit_alloc_memory(compiler, 16 * sizeof(sljit_w));
751 1.1.1.2.2.2 yamt SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
752 1.1.1.2.2.2 yamt memset(value, 255, 16 * sizeof(sljit_w));
753 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
754 1.1.1.2.2.2 yamt const2 = sljit_emit_const(compiler, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT - 1, -65535);
755 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf[0] + 2 * sizeof(sljit_w) - 2);
756 1.1.1.2.2.2 yamt const3 = sljit_emit_const(compiler, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, word_value1);
757 1.1.1.2.2.2 yamt value = sljit_alloc_memory(compiler, 17);
758 1.1.1.2.2.2 yamt SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
759 1.1.1.2.2.2 yamt memset(value, 255, 16);
760 1.1.1.2.2.2 yamt const4 = sljit_emit_const(compiler, SLJIT_RETURN_REG, 0, 0xf7afcdb7);
761 1.1.1.2.2.2 yamt
762 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
763 1.1.1.2.2.2 yamt
764 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
765 1.1.1.2.2.2 yamt CHECK(compiler);
766 1.1.1.2.2.2 yamt const1_addr = sljit_get_const_addr(const1);
767 1.1.1.2.2.2 yamt const2_addr = sljit_get_const_addr(const2);
768 1.1.1.2.2.2 yamt const3_addr = sljit_get_const_addr(const3);
769 1.1.1.2.2.2 yamt const4_addr = sljit_get_const_addr(const4);
770 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
771 1.1.1.2.2.2 yamt
772 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 0xf7afcdb7, "test11 case 1 failed\n");
773 1.1.1.2.2.2 yamt FAILED(buf[0] != -0x81b9, "test11 case 2 failed\n");
774 1.1.1.2.2.2 yamt FAILED(buf[1] != -65535, "test11 case 3 failed\n");
775 1.1.1.2.2.2 yamt FAILED(buf[2] != word_value1, "test11 case 4 failed\n");
776 1.1.1.2.2.2 yamt
777 1.1.1.2.2.2 yamt sljit_set_const(const1_addr, -1);
778 1.1.1.2.2.2 yamt sljit_set_const(const2_addr, word_value2);
779 1.1.1.2.2.2 yamt sljit_set_const(const3_addr, 0xbab0fea1);
780 1.1.1.2.2.2 yamt sljit_set_const(const4_addr, -60089);
781 1.1.1.2.2.2 yamt
782 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != -60089, "test11 case 5 failed\n");
783 1.1.1.2.2.2 yamt FAILED(buf[0] != -1, "test11 case 6 failed\n");
784 1.1.1.2.2.2 yamt FAILED(buf[1] != word_value2, "test11 case 7 failed\n");
785 1.1.1.2.2.2 yamt FAILED(buf[2] != 0xbab0fea1, "test11 case 8 failed\n");
786 1.1.1.2.2.2 yamt
787 1.1.1.2.2.2 yamt sljit_free_code(code.code);
788 1.1.1.2.2.2 yamt printf("test11 ok\n");
789 1.1.1.2.2.2 yamt successful_tests++;
790 1.1.1.2.2.2 yamt }
791 1.1.1.2.2.2 yamt
792 1.1.1.2.2.2 yamt static void test12(void)
793 1.1.1.2.2.2 yamt {
794 1.1.1.2.2.2 yamt /* Test rewriteable jumps. */
795 1.1.1.2.2.2 yamt executable_code code;
796 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
797 1.1.1.2.2.2 yamt struct sljit_label *label1;
798 1.1.1.2.2.2 yamt struct sljit_label *label2;
799 1.1.1.2.2.2 yamt struct sljit_label *label3;
800 1.1.1.2.2.2 yamt struct sljit_jump *jump1;
801 1.1.1.2.2.2 yamt struct sljit_jump *jump2;
802 1.1.1.2.2.2 yamt struct sljit_jump *jump3;
803 1.1.1.2.2.2 yamt void* value;
804 1.1.1.2.2.2 yamt sljit_uw jump1_addr;
805 1.1.1.2.2.2 yamt sljit_uw label1_addr;
806 1.1.1.2.2.2 yamt sljit_uw label2_addr;
807 1.1.1.2.2.2 yamt sljit_w buf[1];
808 1.1.1.2.2.2 yamt
809 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
810 1.1.1.2.2.2 yamt buf[0] = 0;
811 1.1.1.2.2.2 yamt
812 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 2, 0);
813 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 10);
814 1.1.1.2.2.2 yamt jump1 = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_C_SIG_GREATER);
815 1.1.1.2.2.2 yamt /* Default handler. */
816 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 5);
817 1.1.1.2.2.2 yamt jump2 = sljit_emit_jump(compiler, SLJIT_JUMP);
818 1.1.1.2.2.2 yamt value = sljit_alloc_memory(compiler, 15);
819 1.1.1.2.2.2 yamt SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
820 1.1.1.2.2.2 yamt memset(value, 255, 15);
821 1.1.1.2.2.2 yamt /* Handler 1. */
822 1.1.1.2.2.2 yamt label1 = sljit_emit_label(compiler);
823 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 6);
824 1.1.1.2.2.2 yamt jump3 = sljit_emit_jump(compiler, SLJIT_JUMP);
825 1.1.1.2.2.2 yamt /* Handler 2. */
826 1.1.1.2.2.2 yamt label2 = sljit_emit_label(compiler);
827 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 7);
828 1.1.1.2.2.2 yamt /* Exit. */
829 1.1.1.2.2.2 yamt label3 = sljit_emit_label(compiler);
830 1.1.1.2.2.2 yamt sljit_set_label(jump2, label3);
831 1.1.1.2.2.2 yamt sljit_set_label(jump3, label3);
832 1.1.1.2.2.2 yamt /* By default, set to handler 1. */
833 1.1.1.2.2.2 yamt sljit_set_label(jump1, label1);
834 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
835 1.1.1.2.2.2 yamt
836 1.1.1.2.2.2 yamt value = sljit_alloc_memory(compiler, 8);
837 1.1.1.2.2.2 yamt SLJIT_ASSERT(!((sljit_w)value & (sizeof(sljit_w) - 1)));
838 1.1.1.2.2.2 yamt memset(value, 255, 8);
839 1.1.1.2.2.2 yamt
840 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
841 1.1.1.2.2.2 yamt CHECK(compiler);
842 1.1.1.2.2.2 yamt jump1_addr = sljit_get_jump_addr(jump1);
843 1.1.1.2.2.2 yamt label1_addr = sljit_get_label_addr(label1);
844 1.1.1.2.2.2 yamt label2_addr = sljit_get_label_addr(label2);
845 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
846 1.1.1.2.2.2 yamt
847 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, 4);
848 1.1.1.2.2.2 yamt FAILED(buf[0] != 5, "test12 case 1 failed\n");
849 1.1.1.2.2.2 yamt
850 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, 11);
851 1.1.1.2.2.2 yamt FAILED(buf[0] != 6, "test12 case 2 failed\n");
852 1.1.1.2.2.2 yamt
853 1.1.1.2.2.2 yamt sljit_set_jump_addr(jump1_addr, label2_addr);
854 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, 12);
855 1.1.1.2.2.2 yamt FAILED(buf[0] != 7, "test12 case 3 failed\n");
856 1.1.1.2.2.2 yamt
857 1.1.1.2.2.2 yamt sljit_set_jump_addr(jump1_addr, label1_addr);
858 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, 13);
859 1.1.1.2.2.2 yamt FAILED(buf[0] != 6, "test12 case 4 failed\n");
860 1.1.1.2.2.2 yamt
861 1.1.1.2.2.2 yamt sljit_free_code(code.code);
862 1.1.1.2.2.2 yamt printf("test12 ok\n");
863 1.1.1.2.2.2 yamt successful_tests++;
864 1.1.1.2.2.2 yamt }
865 1.1.1.2.2.2 yamt
866 1.1.1.2.2.2 yamt static void test13(void)
867 1.1.1.2.2.2 yamt {
868 1.1.1.2.2.2 yamt /* Test fpu monadic functions. */
869 1.1.1.2.2.2 yamt executable_code code;
870 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
871 1.1.1.2.2.2 yamt double buf[7];
872 1.1.1.2.2.2 yamt sljit_w buf2[6];
873 1.1.1.2.2.2 yamt
874 1.1.1.2.2.2 yamt if (!sljit_is_fpu_available()) {
875 1.1.1.2.2.2 yamt printf("no fpu available, test13 skipped\n");
876 1.1.1.2.2.2 yamt successful_tests++;
877 1.1.1.2.2.2 yamt if (compiler)
878 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
879 1.1.1.2.2.2 yamt return;
880 1.1.1.2.2.2 yamt }
881 1.1.1.2.2.2 yamt
882 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
883 1.1.1.2.2.2 yamt buf[0] = 7.75;
884 1.1.1.2.2.2 yamt buf[1] = -4.5;
885 1.1.1.2.2.2 yamt buf[2] = 0.0;
886 1.1.1.2.2.2 yamt buf[3] = 0.0;
887 1.1.1.2.2.2 yamt buf[4] = 0.0;
888 1.1.1.2.2.2 yamt buf[5] = 0.0;
889 1.1.1.2.2.2 yamt buf[6] = 0.0;
890 1.1.1.2.2.2 yamt
891 1.1.1.2.2.2 yamt buf2[0] = 10;
892 1.1.1.2.2.2 yamt buf2[1] = 10;
893 1.1.1.2.2.2 yamt buf2[2] = 10;
894 1.1.1.2.2.2 yamt buf2[3] = 10;
895 1.1.1.2.2.2 yamt buf2[4] = 10;
896 1.1.1.2.2.2 yamt buf2[5] = 10;
897 1.1.1.2.2.2 yamt
898 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 2, 0);
899 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM0(), (sljit_w)&buf[2], SLJIT_MEM0(), (sljit_w)&buf[1]);
900 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(double), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
901 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM0(), (sljit_w)&buf[0]);
902 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2 * sizeof(double));
903 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0);
904 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FNEG, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG1, 0);
905 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0);
906 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM0(), (sljit_w)&buf[4], SLJIT_FLOAT_REG4, 0);
907 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG2, 0);
908 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(double), SLJIT_FLOAT_REG3, 0);
909 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FNEG, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(double), SLJIT_FLOAT_REG3, 0);
910 1.1.1.2.2.2 yamt
911 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
912 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
913 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_C_FLOAT_GREATER);
914 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double), SLJIT_FLOAT_REG2, 0);
915 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w), SLJIT_C_FLOAT_GREATER);
916 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG2, 0);
917 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
918 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS);
919 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
920 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 4 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
921 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG2), 5 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_EQUAL);
922 1.1.1.2.2.2 yamt
923 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
924 1.1.1.2.2.2 yamt
925 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
926 1.1.1.2.2.2 yamt CHECK(compiler);
927 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
928 1.1.1.2.2.2 yamt
929 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, (sljit_w)&buf2);
930 1.1.1.2.2.2 yamt FAILED(buf[2] != -4.5, "test13 case 1 failed\n");
931 1.1.1.2.2.2 yamt FAILED(buf[3] != 4.5, "test13 case 2 failed\n");
932 1.1.1.2.2.2 yamt FAILED(buf[4] != -7.75, "test13 case 3 failed\n");
933 1.1.1.2.2.2 yamt FAILED(buf[5] != 4.5, "test13 case 4 failed\n");
934 1.1.1.2.2.2 yamt FAILED(buf[6] != -4.5, "test13 case 5 failed\n");
935 1.1.1.2.2.2 yamt
936 1.1.1.2.2.2 yamt FAILED(buf2[0] != 1, "test13 case 6 failed\n");
937 1.1.1.2.2.2 yamt FAILED(buf2[1] != 0, "test13 case 7 failed\n");
938 1.1.1.2.2.2 yamt FAILED(buf2[2] != 1, "test13 case 8 failed\n");
939 1.1.1.2.2.2 yamt FAILED(buf2[3] != 0, "test13 case 9 failed\n");
940 1.1.1.2.2.2 yamt FAILED(buf2[4] != 0, "test13 case 10 failed\n");
941 1.1.1.2.2.2 yamt FAILED(buf2[5] != 1, "test13 case 11 failed\n");
942 1.1.1.2.2.2 yamt
943 1.1.1.2.2.2 yamt sljit_free_code(code.code);
944 1.1.1.2.2.2 yamt printf("test13 ok\n");
945 1.1.1.2.2.2 yamt successful_tests++;
946 1.1.1.2.2.2 yamt }
947 1.1.1.2.2.2 yamt
948 1.1.1.2.2.2 yamt static void test14(void)
949 1.1.1.2.2.2 yamt {
950 1.1.1.2.2.2 yamt /* Test fpu diadic functions. */
951 1.1.1.2.2.2 yamt executable_code code;
952 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
953 1.1.1.2.2.2 yamt double buf[15];
954 1.1.1.2.2.2 yamt
955 1.1.1.2.2.2 yamt if (!sljit_is_fpu_available()) {
956 1.1.1.2.2.2 yamt printf("no fpu available, test14 skipped\n");
957 1.1.1.2.2.2 yamt successful_tests++;
958 1.1.1.2.2.2 yamt if (compiler)
959 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
960 1.1.1.2.2.2 yamt return;
961 1.1.1.2.2.2 yamt }
962 1.1.1.2.2.2 yamt buf[0] = 7.25;
963 1.1.1.2.2.2 yamt buf[1] = 3.5;
964 1.1.1.2.2.2 yamt buf[2] = 1.75;
965 1.1.1.2.2.2 yamt buf[3] = 0.0;
966 1.1.1.2.2.2 yamt buf[4] = 0.0;
967 1.1.1.2.2.2 yamt buf[5] = 0.0;
968 1.1.1.2.2.2 yamt buf[6] = 0.0;
969 1.1.1.2.2.2 yamt buf[7] = 0.0;
970 1.1.1.2.2.2 yamt buf[8] = 0.0;
971 1.1.1.2.2.2 yamt buf[9] = 0.0;
972 1.1.1.2.2.2 yamt buf[10] = 0.0;
973 1.1.1.2.2.2 yamt buf[11] = 0.0;
974 1.1.1.2.2.2 yamt buf[12] = 8.0;
975 1.1.1.2.2.2 yamt buf[13] = 4.0;
976 1.1.1.2.2.2 yamt buf[14] = 0.0;
977 1.1.1.2.2.2 yamt
978 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
979 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
980 1.1.1.2.2.2 yamt
981 1.1.1.2.2.2 yamt /* ADD */
982 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(double));
983 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double));
984 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
985 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 3, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
986 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
987 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
988 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 4, SLJIT_FLOAT_REG1, 0);
989 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 5, SLJIT_FLOAT_REG2, 0);
990 1.1.1.2.2.2 yamt
991 1.1.1.2.2.2 yamt /* SUB */
992 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
993 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG4, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
994 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 2);
995 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 6, SLJIT_FLOAT_REG4, 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_FLOAT_SHIFT);
996 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2);
997 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FSUB, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG4, 0);
998 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 7, SLJIT_FLOAT_REG3, 0);
999 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 8, SLJIT_FLOAT_REG4, 0);
1000 1.1.1.2.2.2 yamt
1001 1.1.1.2.2.2 yamt /* MUL */
1002 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1003 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 9, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_FLOAT_SHIFT, SLJIT_FLOAT_REG2, 0);
1004 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
1005 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FMUL, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 2, SLJIT_FLOAT_REG3, 0);
1006 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 10, SLJIT_FLOAT_REG2, 0);
1007 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 11, SLJIT_FLOAT_REG3, 0);
1008 1.1.1.2.2.2 yamt
1009 1.1.1.2.2.2 yamt /* DIV */
1010 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12);
1011 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 13);
1012 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG1, 0);
1013 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 12, SLJIT_FLOAT_REG2, 0);
1014 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG1, 0, SLJIT_FLOAT_REG2, 0);
1015 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG3, 0, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
1016 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 13, SLJIT_FLOAT_REG1, 0);
1017 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(double) * 14, SLJIT_FLOAT_REG3, 0);
1018 1.1.1.2.2.2 yamt
1019 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1020 1.1.1.2.2.2 yamt
1021 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1022 1.1.1.2.2.2 yamt CHECK(compiler);
1023 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1024 1.1.1.2.2.2 yamt
1025 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
1026 1.1.1.2.2.2 yamt FAILED(buf[3] != 10.75, "test14 case 1 failed\n");
1027 1.1.1.2.2.2 yamt FAILED(buf[4] != 5.25, "test14 case 2 failed\n");
1028 1.1.1.2.2.2 yamt FAILED(buf[5] != 7.0, "test14 case 3 failed\n");
1029 1.1.1.2.2.2 yamt FAILED(buf[6] != 0.0, "test14 case 4 failed\n");
1030 1.1.1.2.2.2 yamt FAILED(buf[7] != 5.5, "test14 case 5 failed\n");
1031 1.1.1.2.2.2 yamt FAILED(buf[8] != 3.75, "test14 case 6 failed\n");
1032 1.1.1.2.2.2 yamt FAILED(buf[9] != 24.5, "test14 case 7 failed\n");
1033 1.1.1.2.2.2 yamt FAILED(buf[10] != 38.5, "test14 case 8 failed\n");
1034 1.1.1.2.2.2 yamt FAILED(buf[11] != 9.625, "test14 case 9 failed\n");
1035 1.1.1.2.2.2 yamt FAILED(buf[12] != 2.0, "test14 case 10 failed\n");
1036 1.1.1.2.2.2 yamt FAILED(buf[13] != 2.0, "test14 case 11 failed\n");
1037 1.1.1.2.2.2 yamt FAILED(buf[14] != 0.5, "test14 case 11 failed\n");
1038 1.1.1.2.2.2 yamt
1039 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1040 1.1.1.2.2.2 yamt printf("test14 ok\n");
1041 1.1.1.2.2.2 yamt successful_tests++;
1042 1.1.1.2.2.2 yamt }
1043 1.1.1.2.2.2 yamt
1044 1.1.1.2.2.2 yamt static sljit_w SLJIT_CALL func(sljit_w a, sljit_w b, sljit_w c)
1045 1.1.1.2.2.2 yamt {
1046 1.1.1.2.2.2 yamt return a + b + c + 5;
1047 1.1.1.2.2.2 yamt }
1048 1.1.1.2.2.2 yamt
1049 1.1.1.2.2.2 yamt static void test15(void)
1050 1.1.1.2.2.2 yamt {
1051 1.1.1.2.2.2 yamt /* Test function call. */
1052 1.1.1.2.2.2 yamt executable_code code;
1053 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1054 1.1.1.2.2.2 yamt struct sljit_jump* jump;
1055 1.1.1.2.2.2 yamt sljit_w buf[7];
1056 1.1.1.2.2.2 yamt
1057 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1058 1.1.1.2.2.2 yamt buf[0] = 0;
1059 1.1.1.2.2.2 yamt buf[1] = 0;
1060 1.1.1.2.2.2 yamt buf[2] = 0;
1061 1.1.1.2.2.2 yamt buf[3] = 0;
1062 1.1.1.2.2.2 yamt buf[4] = 0;
1063 1.1.1.2.2.2 yamt buf[5] = 0;
1064 1.1.1.2.2.2 yamt buf[6] = SLJIT_FUNC_OFFSET(func);
1065 1.1.1.2.2.2 yamt
1066 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 4, 1, 0);
1067 1.1.1.2.2.2 yamt
1068 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
1069 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 7);
1070 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -3);
1071 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
1072 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_RETURN_REG, 0);
1073 1.1.1.2.2.2 yamt
1074 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
1075 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -10);
1076 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 2);
1077 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_CALL3 | SLJIT_REWRITABLE_JUMP);
1078 1.1.1.2.2.2 yamt sljit_set_target(jump, (sljit_w)-1);
1079 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1080 1.1.1.2.2.2 yamt
1081 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
1082 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 40);
1083 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -3);
1084 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG1, 0);
1085 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1086 1.1.1.2.2.2 yamt
1087 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -60);
1088 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
1089 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -30);
1090 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG2, 0);
1091 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1092 1.1.1.2.2.2 yamt
1093 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 10);
1094 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 16);
1095 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
1096 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_REG3, 0);
1097 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1098 1.1.1.2.2.2 yamt
1099 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 100);
1100 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 110);
1101 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 120);
1102 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(func));
1103 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_TEMPORARY_EREG1, 0);
1104 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1105 1.1.1.2.2.2 yamt
1106 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -10);
1107 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -16);
1108 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 6);
1109 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w));
1110 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_RETURN_REG, 0);
1111 1.1.1.2.2.2 yamt
1112 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
1113 1.1.1.2.2.2 yamt
1114 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1115 1.1.1.2.2.2 yamt CHECK(compiler);
1116 1.1.1.2.2.2 yamt sljit_set_jump_addr(sljit_get_jump_addr(jump), SLJIT_FUNC_OFFSET(func));
1117 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1118 1.1.1.2.2.2 yamt
1119 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != -15, "test15 case 1 failed\n");
1120 1.1.1.2.2.2 yamt FAILED(buf[0] != 14, "test15 case 2 failed\n");
1121 1.1.1.2.2.2 yamt FAILED(buf[1] != -8, "test15 case 3 failed\n");
1122 1.1.1.2.2.2 yamt FAILED(buf[2] != SLJIT_FUNC_OFFSET(func) + 42, "test15 case 4 failed\n");
1123 1.1.1.2.2.2 yamt FAILED(buf[3] != SLJIT_FUNC_OFFSET(func) - 85, "test15 case 5 failed\n");
1124 1.1.1.2.2.2 yamt FAILED(buf[4] != SLJIT_FUNC_OFFSET(func) + 31, "test15 case 6 failed\n");
1125 1.1.1.2.2.2 yamt FAILED(buf[5] != 335, "test15 case 7 failed\n");
1126 1.1.1.2.2.2 yamt FAILED(buf[6] != -15, "test15 case 8 failed\n");
1127 1.1.1.2.2.2 yamt
1128 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1129 1.1.1.2.2.2 yamt printf("test15 ok\n");
1130 1.1.1.2.2.2 yamt successful_tests++;
1131 1.1.1.2.2.2 yamt }
1132 1.1.1.2.2.2 yamt
1133 1.1.1.2.2.2 yamt static void test16(void)
1134 1.1.1.2.2.2 yamt {
1135 1.1.1.2.2.2 yamt /* Ackermann benchmark. */
1136 1.1.1.2.2.2 yamt executable_code code;
1137 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1138 1.1.1.2.2.2 yamt struct sljit_label *entry;
1139 1.1.1.2.2.2 yamt struct sljit_label *label;
1140 1.1.1.2.2.2 yamt struct sljit_jump *jump;
1141 1.1.1.2.2.2 yamt struct sljit_jump *jump1;
1142 1.1.1.2.2.2 yamt struct sljit_jump *jump2;
1143 1.1.1.2.2.2 yamt
1144 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1145 1.1.1.2.2.2 yamt
1146 1.1.1.2.2.2 yamt entry = sljit_emit_label(compiler);
1147 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 2, 0);
1148 1.1.1.2.2.2 yamt /* If x == 0. */
1149 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0);
1150 1.1.1.2.2.2 yamt jump1 = sljit_emit_jump(compiler, SLJIT_C_EQUAL);
1151 1.1.1.2.2.2 yamt /* If y == 0. */
1152 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0);
1153 1.1.1.2.2.2 yamt jump2 = sljit_emit_jump(compiler, SLJIT_C_EQUAL);
1154 1.1.1.2.2.2 yamt
1155 1.1.1.2.2.2 yamt /* Ack(x,y-1). */
1156 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
1157 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
1158 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_CALL2);
1159 1.1.1.2.2.2 yamt sljit_set_label(jump, entry);
1160 1.1.1.2.2.2 yamt
1161 1.1.1.2.2.2 yamt /* Returns with Ack(x-1, Ack(x,y-1)). */
1162 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_RETURN_REG, 0);
1163 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
1164 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_CALL2);
1165 1.1.1.2.2.2 yamt sljit_set_label(jump, entry);
1166 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
1167 1.1.1.2.2.2 yamt
1168 1.1.1.2.2.2 yamt /* Returns with y+1. */
1169 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
1170 1.1.1.2.2.2 yamt sljit_set_label(jump1, label);
1171 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1, SLJIT_SAVED_REG2, 0);
1172 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
1173 1.1.1.2.2.2 yamt
1174 1.1.1.2.2.2 yamt /* Returns with Ack(x-1,1) */
1175 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
1176 1.1.1.2.2.2 yamt sljit_set_label(jump2, label);
1177 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
1178 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1179 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_CALL2);
1180 1.1.1.2.2.2 yamt sljit_set_label(jump, entry);
1181 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
1182 1.1.1.2.2.2 yamt
1183 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1184 1.1.1.2.2.2 yamt CHECK(compiler);
1185 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1186 1.1.1.2.2.2 yamt
1187 1.1.1.2.2.2 yamt FAILED(code.func2(3, 3) != 61, "test16 case 1 failed\n");
1188 1.1.1.2.2.2 yamt /* For benchmarking. */
1189 1.1.1.2.2.2 yamt /* FAILED(code.func2(3, 11) != 16381, "test16 case 1 failed\n"); */
1190 1.1.1.2.2.2 yamt
1191 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1192 1.1.1.2.2.2 yamt printf("test16 ok\n");
1193 1.1.1.2.2.2 yamt successful_tests++;
1194 1.1.1.2.2.2 yamt }
1195 1.1.1.2.2.2 yamt
1196 1.1.1.2.2.2 yamt static void test17(void)
1197 1.1.1.2.2.2 yamt {
1198 1.1.1.2.2.2 yamt /* Test arm constant pool. */
1199 1.1.1.2.2.2 yamt executable_code code;
1200 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1201 1.1.1.2.2.2 yamt int i;
1202 1.1.1.2.2.2 yamt sljit_w buf[5];
1203 1.1.1.2.2.2 yamt
1204 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1205 1.1.1.2.2.2 yamt buf[0] = 0;
1206 1.1.1.2.2.2 yamt buf[1] = 0;
1207 1.1.1.2.2.2 yamt buf[2] = 0;
1208 1.1.1.2.2.2 yamt buf[3] = 0;
1209 1.1.1.2.2.2 yamt buf[4] = 0;
1210 1.1.1.2.2.2 yamt
1211 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
1212 1.1.1.2.2.2 yamt for (i = 0; i <= 0xfff; i++) {
1213 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x81818000 | i);
1214 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x81818000 | i);
1215 1.1.1.2.2.2 yamt if ((i & 0x3ff) == 0)
1216 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), (i >> 10) * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1217 1.1.1.2.2.2 yamt }
1218 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1219 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1220 1.1.1.2.2.2 yamt
1221 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1222 1.1.1.2.2.2 yamt CHECK(compiler);
1223 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1224 1.1.1.2.2.2 yamt
1225 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
1226 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[0] != 0x81818000, "test17 case 1 failed\n");
1227 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[1] != 0x81818400, "test17 case 2 failed\n");
1228 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[2] != 0x81818800, "test17 case 3 failed\n");
1229 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[3] != 0x81818c00, "test17 case 4 failed\n");
1230 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[4] != 0x81818fff, "test17 case 5 failed\n");
1231 1.1.1.2.2.2 yamt
1232 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1233 1.1.1.2.2.2 yamt printf("test17 ok\n");
1234 1.1.1.2.2.2 yamt successful_tests++;
1235 1.1.1.2.2.2 yamt }
1236 1.1.1.2.2.2 yamt
1237 1.1.1.2.2.2 yamt static void test18(void)
1238 1.1.1.2.2.2 yamt {
1239 1.1.1.2.2.2 yamt /* Test 64 bit. */
1240 1.1.1.2.2.2 yamt executable_code code;
1241 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1242 1.1.1.2.2.2 yamt sljit_w buf[11];
1243 1.1.1.2.2.2 yamt
1244 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1245 1.1.1.2.2.2 yamt buf[0] = 0;
1246 1.1.1.2.2.2 yamt buf[1] = 0;
1247 1.1.1.2.2.2 yamt buf[2] = 0;
1248 1.1.1.2.2.2 yamt buf[3] = 0;
1249 1.1.1.2.2.2 yamt buf[4] = 0;
1250 1.1.1.2.2.2 yamt buf[5] = 100;
1251 1.1.1.2.2.2 yamt buf[6] = 100;
1252 1.1.1.2.2.2 yamt buf[7] = 100;
1253 1.1.1.2.2.2 yamt buf[8] = 100;
1254 1.1.1.2.2.2 yamt buf[9] = 0;
1255 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
1256 1.1.1.2.2.2 yamt buf[10] = SLJIT_W(1) << 32;
1257 1.1.1.2.2.2 yamt #else
1258 1.1.1.2.2.2 yamt buf[10] = 1;
1259 1.1.1.2.2.2 yamt #endif
1260 1.1.1.2.2.2 yamt
1261 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 0);
1262 1.1.1.2.2.2 yamt
1263 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1264 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, SLJIT_W(0x1122334455667788));
1265 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x1122334455667788));
1266 1.1.1.2.2.2 yamt
1267 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(1000000000000));
1268 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(1000000000000));
1269 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_IMM, SLJIT_W(5000000000000), SLJIT_TEMPORARY_REG1, 0);
1270 1.1.1.2.2.2 yamt
1271 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
1272 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
1273 1.1.1.2.2.2 yamt
1274 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
1275 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
1276 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_C_ZERO);
1277 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_SAVED_REG2, 0);
1278 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1120202020));
1279 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_ZERO);
1280 1.1.1.2.2.2 yamt
1281 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1108080808));
1282 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x2208080808));
1283 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_LESS);
1284 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x1104040404));
1285 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_NOT_ZERO);
1286 1.1.1.2.2.2 yamt
1287 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
1288 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 9, SLJIT_IMM, SLJIT_W(0xffff0000), SLJIT_TEMPORARY_REG1, 0);
1289 1.1.1.2.2.2 yamt
1290 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 10, SLJIT_IMM, -1);
1291 1.1.1.2.2.2 yamt #else
1292 1.1.1.2.2.2 yamt /* 32 bit operations. */
1293 1.1.1.2.2.2 yamt
1294 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0x11223344);
1295 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, 0x44332211);
1296 1.1.1.2.2.2 yamt
1297 1.1.1.2.2.2 yamt #endif
1298 1.1.1.2.2.2 yamt
1299 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1300 1.1.1.2.2.2 yamt
1301 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1302 1.1.1.2.2.2 yamt CHECK(compiler);
1303 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1304 1.1.1.2.2.2 yamt
1305 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
1306 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1307 1.1.1.2.2.2 yamt FAILED(buf[0] != SLJIT_W(0x1122334455667788), "test18 case 1 failed\n");
1308 1.1.1.2.2.2 yamt #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1309 1.1.1.2.2.2 yamt FAILED(buf[1] != 0x55667788, "test18 case 2 failed\n");
1310 1.1.1.2.2.2 yamt #else
1311 1.1.1.2.2.2 yamt FAILED(buf[1] != SLJIT_W(0x5566778800000000), "test18 case 2 failed\n");
1312 1.1.1.2.2.2 yamt #endif
1313 1.1.1.2.2.2 yamt FAILED(buf[2] != SLJIT_W(2000000000000), "test18 case 3 failed\n");
1314 1.1.1.2.2.2 yamt FAILED(buf[3] != SLJIT_W(4000000000000), "test18 case 4 failed\n");
1315 1.1.1.2.2.2 yamt #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1316 1.1.1.2.2.2 yamt FAILED(buf[4] != 0x28282828, "test18 case 5 failed\n");
1317 1.1.1.2.2.2 yamt #else
1318 1.1.1.2.2.2 yamt FAILED(buf[4] != SLJIT_W(0x2828282800000000), "test18 case 5 failed\n");
1319 1.1.1.2.2.2 yamt #endif
1320 1.1.1.2.2.2 yamt FAILED(buf[5] != 0, "test18 case 6 failed\n");
1321 1.1.1.2.2.2 yamt FAILED(buf[6] != 1, "test18 case 7 failed\n");
1322 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test18 case 8 failed\n");
1323 1.1.1.2.2.2 yamt FAILED(buf[8] != 0, "test18 case 9 failed\n");
1324 1.1.1.2.2.2 yamt #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1325 1.1.1.2.2.2 yamt FAILED(buf[9] != 0xfff00000, "test18 case 10 failed\n");
1326 1.1.1.2.2.2 yamt FAILED(buf[10] != 0xffffffff, "test18 case 11 failed\n");
1327 1.1.1.2.2.2 yamt #else
1328 1.1.1.2.2.2 yamt FAILED(buf[9] != SLJIT_W(0xfff0000000000000), "test18 case 10 failed\n");
1329 1.1.1.2.2.2 yamt FAILED(buf[10] != SLJIT_W(0xffffffff00000000), "test18 case 11 failed\n");
1330 1.1.1.2.2.2 yamt #endif
1331 1.1.1.2.2.2 yamt #else
1332 1.1.1.2.2.2 yamt FAILED(buf[0] != 0x11223344, "test18 case 1 failed\n");
1333 1.1.1.2.2.2 yamt FAILED(buf[1] != 0x44332211, "test18 case 2 failed\n");
1334 1.1.1.2.2.2 yamt #endif
1335 1.1.1.2.2.2 yamt
1336 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1337 1.1.1.2.2.2 yamt printf("test18 ok\n");
1338 1.1.1.2.2.2 yamt successful_tests++;
1339 1.1.1.2.2.2 yamt }
1340 1.1.1.2.2.2 yamt
1341 1.1.1.2.2.2 yamt static void test19(void)
1342 1.1.1.2.2.2 yamt {
1343 1.1.1.2.2.2 yamt /* Test arm partial instruction caching. */
1344 1.1.1.2.2.2 yamt executable_code code;
1345 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1346 1.1.1.2.2.2 yamt sljit_w buf[10];
1347 1.1.1.2.2.2 yamt
1348 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1349 1.1.1.2.2.2 yamt buf[0] = 6;
1350 1.1.1.2.2.2 yamt buf[1] = 4;
1351 1.1.1.2.2.2 yamt buf[2] = 0;
1352 1.1.1.2.2.2 yamt buf[3] = 0;
1353 1.1.1.2.2.2 yamt buf[4] = 0;
1354 1.1.1.2.2.2 yamt buf[5] = 0;
1355 1.1.1.2.2.2 yamt buf[6] = 2;
1356 1.1.1.2.2.2 yamt buf[7] = 0;
1357 1.1.1.2.2.2 yamt
1358 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
1359 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
1360 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1361 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg == 0);
1362 1.1.1.2.2.2 yamt #endif
1363 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM0(), (sljit_w)&buf[2], SLJIT_MEM0(), (sljit_w)&buf[1], SLJIT_MEM0(), (sljit_w)&buf[0]);
1364 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1365 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1366 1.1.1.2.2.2 yamt #endif
1367 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
1368 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
1369 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[0], SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[0]);
1370 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1371 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1372 1.1.1.2.2.2 yamt #endif
1373 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_IMM, 2);
1374 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1375 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1376 1.1.1.2.2.2 yamt #endif
1377 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[0] + 4 * sizeof(sljit_w));
1378 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1379 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1380 1.1.1.2.2.2 yamt #endif
1381 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_IMM, 10);
1382 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
1383 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[5], SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&buf[5]);
1384 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1385 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1386 1.1.1.2.2.2 yamt #endif
1387 1.1.1.2.2.2 yamt
1388 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1389 1.1.1.2.2.2 yamt
1390 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1391 1.1.1.2.2.2 yamt CHECK(compiler);
1392 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1393 1.1.1.2.2.2 yamt
1394 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
1395 1.1.1.2.2.2 yamt FAILED(buf[0] != 10, "test19 case 1 failed\n");
1396 1.1.1.2.2.2 yamt FAILED(buf[1] != 4, "test19 case 2 failed\n");
1397 1.1.1.2.2.2 yamt FAILED(buf[2] != 14, "test19 case 3 failed\n");
1398 1.1.1.2.2.2 yamt FAILED(buf[3] != 14, "test19 case 4 failed\n");
1399 1.1.1.2.2.2 yamt FAILED(buf[4] != 8, "test19 case 5 failed\n");
1400 1.1.1.2.2.2 yamt FAILED(buf[5] != 6, "test19 case 6 failed\n");
1401 1.1.1.2.2.2 yamt FAILED(buf[6] != 12, "test19 case 7 failed\n");
1402 1.1.1.2.2.2 yamt FAILED(buf[7] != 10, "test19 case 8 failed\n");
1403 1.1.1.2.2.2 yamt
1404 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1405 1.1.1.2.2.2 yamt printf("test19 ok\n");
1406 1.1.1.2.2.2 yamt successful_tests++;
1407 1.1.1.2.2.2 yamt }
1408 1.1.1.2.2.2 yamt
1409 1.1.1.2.2.2 yamt static void test20(void)
1410 1.1.1.2.2.2 yamt {
1411 1.1.1.2.2.2 yamt /* Test stack. */
1412 1.1.1.2.2.2 yamt executable_code code;
1413 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1414 1.1.1.2.2.2 yamt struct sljit_jump* jump;
1415 1.1.1.2.2.2 yamt struct sljit_label* label;
1416 1.1.1.2.2.2 yamt sljit_w buf[6];
1417 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1418 1.1.1.2.2.2 yamt sljit_w offset_value = SLJIT_W(0x1234567812345678);
1419 1.1.1.2.2.2 yamt #else
1420 1.1.1.2.2.2 yamt sljit_w offset_value = SLJIT_W(0x12345678);
1421 1.1.1.2.2.2 yamt #endif
1422 1.1.1.2.2.2 yamt
1423 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1424 1.1.1.2.2.2 yamt buf[0] = 5;
1425 1.1.1.2.2.2 yamt buf[1] = 12;
1426 1.1.1.2.2.2 yamt buf[2] = 0;
1427 1.1.1.2.2.2 yamt buf[3] = 0;
1428 1.1.1.2.2.2 yamt buf[4] = 111;
1429 1.1.1.2.2.2 yamt buf[5] = -12345;
1430 1.1.1.2.2.2 yamt
1431 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 4 * sizeof(sljit_w));
1432 1.1.1.2.2.2 yamt
1433 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw), SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
1434 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw));
1435 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, -1);
1436 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, -1);
1437 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, -1);
1438 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, -1);
1439 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw));
1440 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_uw), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
1441 1.1.1.2.2.2 yamt sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG1, 0, -offset_value);
1442 1.1.1.2.2.2 yamt sljit_get_local_base(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, -0x1234);
1443 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
1444 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_uw), SLJIT_MEM1(SLJIT_TEMPORARY_REG1), offset_value, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0x1234 + sizeof(sljit_w));
1445 1.1.1.2.2.2 yamt
1446 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_uw));
1447 1.1.1.2.2.2 yamt /* Dummy last instructions. */
1448 1.1.1.2.2.2 yamt sljit_emit_const(compiler, SLJIT_TEMPORARY_REG1, 0, -9);
1449 1.1.1.2.2.2 yamt sljit_emit_label(compiler);
1450 1.1.1.2.2.2 yamt
1451 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1452 1.1.1.2.2.2 yamt CHECK(compiler);
1453 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1454 1.1.1.2.2.2 yamt
1455 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != -12345, "test20 case 1 failed\n")
1456 1.1.1.2.2.2 yamt
1457 1.1.1.2.2.2 yamt FAILED(buf[2] != 60, "test20 case 2 failed\n");
1458 1.1.1.2.2.2 yamt FAILED(buf[3] != 17, "test20 case 3 failed\n");
1459 1.1.1.2.2.2 yamt FAILED(buf[4] != 7, "test20 case 4 failed\n");
1460 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1461 1.1.1.2.2.2 yamt
1462 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
1463 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 0, 3, 0, SLJIT_MAX_LOCAL_SIZE);
1464 1.1.1.2.2.2 yamt
1465 1.1.1.2.2.2 yamt sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG1, 0, SLJIT_MAX_LOCAL_SIZE - sizeof(sljit_w));
1466 1.1.1.2.2.2 yamt sljit_get_local_base(compiler, SLJIT_TEMPORARY_REG2, 0, -(sljit_w)sizeof(sljit_w));
1467 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -1);
1468 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
1469 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
1470 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
1471 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_C_NOT_EQUAL);
1472 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
1473 1.1.1.2.2.2 yamt
1474 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1475 1.1.1.2.2.2 yamt
1476 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1477 1.1.1.2.2.2 yamt CHECK(compiler);
1478 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1479 1.1.1.2.2.2 yamt
1480 1.1.1.2.2.2 yamt /* Just survive this code. */
1481 1.1.1.2.2.2 yamt code.func0();
1482 1.1.1.2.2.2 yamt
1483 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1484 1.1.1.2.2.2 yamt printf("test20 ok\n");
1485 1.1.1.2.2.2 yamt successful_tests++;
1486 1.1.1.2.2.2 yamt }
1487 1.1.1.2.2.2 yamt
1488 1.1.1.2.2.2 yamt static void test21(void)
1489 1.1.1.2.2.2 yamt {
1490 1.1.1.2.2.2 yamt /* Test fake enter. The parts of the jit code can be separated in the memory. */
1491 1.1.1.2.2.2 yamt executable_code code1;
1492 1.1.1.2.2.2 yamt executable_code code2;
1493 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1494 1.1.1.2.2.2 yamt struct sljit_jump* jump;
1495 1.1.1.2.2.2 yamt sljit_uw addr;
1496 1.1.1.2.2.2 yamt sljit_w buf[4];
1497 1.1.1.2.2.2 yamt
1498 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1499 1.1.1.2.2.2 yamt buf[0] = 9;
1500 1.1.1.2.2.2 yamt buf[1] = -6;
1501 1.1.1.2.2.2 yamt buf[2] = 0;
1502 1.1.1.2.2.2 yamt buf[3] = 0;
1503 1.1.1.2.2.2 yamt
1504 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 2, 2 * sizeof(sljit_w));
1505 1.1.1.2.2.2 yamt
1506 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_IMM, 10);
1507 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
1508 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_JUMP | SLJIT_REWRITABLE_JUMP);
1509 1.1.1.2.2.2 yamt sljit_set_target(jump, 0);
1510 1.1.1.2.2.2 yamt
1511 1.1.1.2.2.2 yamt code1.code = sljit_generate_code(compiler);
1512 1.1.1.2.2.2 yamt CHECK(compiler);
1513 1.1.1.2.2.2 yamt addr = sljit_get_jump_addr(jump);
1514 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1515 1.1.1.2.2.2 yamt
1516 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
1517 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1518 1.1.1.2.2.2 yamt
1519 1.1.1.2.2.2 yamt /* Other part of the jit code. */
1520 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 3, 2, 2 * sizeof(sljit_w));
1521 1.1.1.2.2.2 yamt
1522 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
1523 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
1524 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
1525 1.1.1.2.2.2 yamt
1526 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
1527 1.1.1.2.2.2 yamt
1528 1.1.1.2.2.2 yamt code2.code = sljit_generate_code(compiler);
1529 1.1.1.2.2.2 yamt CHECK(compiler);
1530 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1531 1.1.1.2.2.2 yamt
1532 1.1.1.2.2.2 yamt sljit_set_jump_addr(addr, SLJIT_FUNC_OFFSET(code2.code));
1533 1.1.1.2.2.2 yamt
1534 1.1.1.2.2.2 yamt FAILED(code1.func1((sljit_w)&buf) != 19, "test21 case 1 failed\n");
1535 1.1.1.2.2.2 yamt FAILED(buf[2] != -16, "test21 case 2 failed\n");
1536 1.1.1.2.2.2 yamt FAILED(buf[3] != 100, "test21 case 3 failed\n");
1537 1.1.1.2.2.2 yamt
1538 1.1.1.2.2.2 yamt sljit_free_code(code1.code);
1539 1.1.1.2.2.2 yamt sljit_free_code(code2.code);
1540 1.1.1.2.2.2 yamt printf("test21 ok\n");
1541 1.1.1.2.2.2 yamt successful_tests++;
1542 1.1.1.2.2.2 yamt }
1543 1.1.1.2.2.2 yamt
1544 1.1.1.2.2.2 yamt static void test22(void)
1545 1.1.1.2.2.2 yamt {
1546 1.1.1.2.2.2 yamt /* Test simple byte and half-int data transfers. */
1547 1.1.1.2.2.2 yamt executable_code code;
1548 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1549 1.1.1.2.2.2 yamt sljit_w buf[9];
1550 1.1.1.2.2.2 yamt short sbuf[7];
1551 1.1.1.2.2.2 yamt signed char bbuf[5];
1552 1.1.1.2.2.2 yamt
1553 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1554 1.1.1.2.2.2 yamt buf[0] = 5;
1555 1.1.1.2.2.2 yamt buf[1] = 0;
1556 1.1.1.2.2.2 yamt buf[2] = 0;
1557 1.1.1.2.2.2 yamt buf[3] = 0;
1558 1.1.1.2.2.2 yamt buf[4] = 0;
1559 1.1.1.2.2.2 yamt buf[5] = 0;
1560 1.1.1.2.2.2 yamt buf[6] = 0;
1561 1.1.1.2.2.2 yamt buf[7] = 0;
1562 1.1.1.2.2.2 yamt buf[8] = 0;
1563 1.1.1.2.2.2 yamt
1564 1.1.1.2.2.2 yamt sbuf[0] = 0;
1565 1.1.1.2.2.2 yamt sbuf[1] = 0;
1566 1.1.1.2.2.2 yamt sbuf[2] = -9;
1567 1.1.1.2.2.2 yamt sbuf[3] = 0;
1568 1.1.1.2.2.2 yamt sbuf[4] = 0;
1569 1.1.1.2.2.2 yamt sbuf[5] = 0;
1570 1.1.1.2.2.2 yamt sbuf[6] = 0;
1571 1.1.1.2.2.2 yamt
1572 1.1.1.2.2.2 yamt bbuf[0] = 0;
1573 1.1.1.2.2.2 yamt bbuf[1] = 0;
1574 1.1.1.2.2.2 yamt bbuf[2] = -56;
1575 1.1.1.2.2.2 yamt bbuf[3] = 0;
1576 1.1.1.2.2.2 yamt bbuf[4] = 0;
1577 1.1.1.2.2.2 yamt
1578 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 3, 3, 3, 0);
1579 1.1.1.2.2.2 yamt
1580 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
1581 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0);
1582 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_IMM, -13);
1583 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w));
1584 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
1585 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w));
1586 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
1587 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_TEMPORARY_REG2, 0);
1588 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
1589 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
1590 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
1591 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_TEMPORARY_REG2, 0);
1592 1.1.1.2.2.2 yamt
1593 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -13);
1594 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_IMM, 0x1234);
1595 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short));
1596 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1597 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_MEM1(SLJIT_SAVED_REG2), -(int)sizeof(short));
1598 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xff0000 + 8000);
1599 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 2);
1600 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
1601 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 3);
1602 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
1603 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -9317);
1604 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 5 * sizeof(short));
1605 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
1606 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 1);
1607 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(short), SLJIT_TEMPORARY_REG2, 0);
1608 1.1.1.2.2.2 yamt
1609 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_MEM1(SLJIT_SAVED_REG3), 0, SLJIT_IMM, -45);
1610 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char), SLJIT_IMM, 0x12);
1611 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2 * sizeof(char));
1612 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char));
1613 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_SAVED_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
1614 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0);
1615 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG2, 0);
1616 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG3, 0);
1617 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(char), SLJIT_SAVED_REG2, 0);
1618 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM2(SLJIT_SAVED_REG3, SLJIT_TEMPORARY_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
1619 1.1.1.2.2.2 yamt
1620 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1621 1.1.1.2.2.2 yamt
1622 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1623 1.1.1.2.2.2 yamt CHECK(compiler);
1624 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1625 1.1.1.2.2.2 yamt
1626 1.1.1.2.2.2 yamt code.func3((sljit_w)&buf, (sljit_w)&sbuf, (sljit_w)&bbuf);
1627 1.1.1.2.2.2 yamt FAILED(buf[1] != -13, "test22 case 1 failed\n");
1628 1.1.1.2.2.2 yamt FAILED(buf[2] != 5, "test22 case 2 failed\n");
1629 1.1.1.2.2.2 yamt FAILED(buf[3] != -13, "test22 case 3 failed\n");
1630 1.1.1.2.2.2 yamt FAILED(buf[4] != (sljit_w)&buf[3], "test22 case 4 failed\n");
1631 1.1.1.2.2.2 yamt FAILED(buf[5] != (sljit_w)&buf[4], "test22 case 5 failed\n");
1632 1.1.1.2.2.2 yamt FAILED(buf[6] != (sljit_w)&buf[4], "test22 case 6 failed\n");
1633 1.1.1.2.2.2 yamt FAILED(buf[7] != -9, "test22 case 7 failed\n");
1634 1.1.1.2.2.2 yamt FAILED(buf[8] != -56, "test22 case 8 failed\n");
1635 1.1.1.2.2.2 yamt
1636 1.1.1.2.2.2 yamt FAILED(sbuf[0] != -13, "test22 case 9 failed\n");
1637 1.1.1.2.2.2 yamt FAILED(sbuf[1] != 0x1234, "test22 case 10 failed\n");
1638 1.1.1.2.2.2 yamt FAILED(sbuf[3] != 0x1234, "test22 case 11 failed\n");
1639 1.1.1.2.2.2 yamt FAILED(sbuf[4] != 8000, "test22 case 12 failed\n");
1640 1.1.1.2.2.2 yamt FAILED(sbuf[5] != -9317, "test22 case 13 failed\n");
1641 1.1.1.2.2.2 yamt FAILED(sbuf[6] != -9317, "test22 case 14 failed\n");
1642 1.1.1.2.2.2 yamt
1643 1.1.1.2.2.2 yamt FAILED(bbuf[0] != -45, "test22 case 15 failed\n");
1644 1.1.1.2.2.2 yamt FAILED(bbuf[1] != 0x12, "test22 case 16 failed\n");
1645 1.1.1.2.2.2 yamt FAILED(bbuf[3] != -56, "test22 case 17 failed\n");
1646 1.1.1.2.2.2 yamt FAILED(bbuf[4] != 2, "test22 case 18 failed\n");
1647 1.1.1.2.2.2 yamt
1648 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1649 1.1.1.2.2.2 yamt printf("test22 ok\n");
1650 1.1.1.2.2.2 yamt successful_tests++;
1651 1.1.1.2.2.2 yamt }
1652 1.1.1.2.2.2 yamt
1653 1.1.1.2.2.2 yamt static void test23(void)
1654 1.1.1.2.2.2 yamt {
1655 1.1.1.2.2.2 yamt /* Test 32 bit / 64 bit signed / unsigned int transfer and conversion.
1656 1.1.1.2.2.2 yamt This test has do real things on 64 bit systems, but works on 32 bit systems as well. */
1657 1.1.1.2.2.2 yamt executable_code code;
1658 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1659 1.1.1.2.2.2 yamt sljit_w buf[9];
1660 1.1.1.2.2.2 yamt int ibuf[5];
1661 1.1.1.2.2.2 yamt union {
1662 1.1.1.2.2.2 yamt int asint;
1663 1.1.1.2.2.2 yamt sljit_ub asbytes[4];
1664 1.1.1.2.2.2 yamt } u;
1665 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1666 1.1.1.2.2.2 yamt sljit_w garbage = SLJIT_W(0x1234567812345678);
1667 1.1.1.2.2.2 yamt #else
1668 1.1.1.2.2.2 yamt sljit_w garbage = 0x12345678;
1669 1.1.1.2.2.2 yamt #endif
1670 1.1.1.2.2.2 yamt
1671 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1672 1.1.1.2.2.2 yamt buf[0] = 0;
1673 1.1.1.2.2.2 yamt buf[1] = 0;
1674 1.1.1.2.2.2 yamt buf[2] = 0;
1675 1.1.1.2.2.2 yamt buf[3] = 0;
1676 1.1.1.2.2.2 yamt buf[4] = 0;
1677 1.1.1.2.2.2 yamt buf[5] = 0;
1678 1.1.1.2.2.2 yamt buf[6] = 0;
1679 1.1.1.2.2.2 yamt buf[7] = 0;
1680 1.1.1.2.2.2 yamt buf[8] = 0;
1681 1.1.1.2.2.2 yamt
1682 1.1.1.2.2.2 yamt ibuf[0] = 0;
1683 1.1.1.2.2.2 yamt ibuf[1] = 0;
1684 1.1.1.2.2.2 yamt ibuf[2] = -5791;
1685 1.1.1.2.2.2 yamt ibuf[3] = 43579;
1686 1.1.1.2.2.2 yamt ibuf[4] = 658923;
1687 1.1.1.2.2.2 yamt
1688 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 3, 0);
1689 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, 34567);
1690 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
1691 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), 2, SLJIT_IMM, -7654);
1692 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
1693 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
1694 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
1695 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
1696 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
1697 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1698 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, garbage);
1699 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int));
1700 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
1701 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1702 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x0f00f00);
1703 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0x7777);
1704 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 0x7777 + 2 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1705 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 0x7777);
1706 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), -0x7777 + (int)sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1707 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 16 - sizeof(sljit_w));
1708 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1709 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
1710 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), 1, SLJIT_TEMPORARY_REG1, 0);
1711 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_IMM, 64, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0);
1712 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
1713 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&buf[6], SLJIT_MEM0(), (sljit_w)&buf[6]);
1714 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_IMM, 0x123456);
1715 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_REG1, 0);
1716 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, sizeof(sljit_w));
1717 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 100000 * sizeof(sljit_w));
1718 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), 100001 * sizeof(sljit_w), SLJIT_SAVED_REG1, 0);
1719 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, sizeof(sljit_w));
1720 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int), SLJIT_IMM, 0x12345678);
1721 1.1.1.2.2.2 yamt
1722 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x2bd700 | 243);
1723 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG2, 0);
1724 1.1.1.2.2.2 yamt
1725 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1726 1.1.1.2.2.2 yamt CHECK(compiler);
1727 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1728 1.1.1.2.2.2 yamt
1729 1.1.1.2.2.2 yamt FAILED(code.func2((sljit_w)&buf, (sljit_w)&ibuf) != -13, "test23 case 1 failed\n");
1730 1.1.1.2.2.2 yamt FAILED(buf[0] != -5791, "test23 case 2 failed\n");
1731 1.1.1.2.2.2 yamt FAILED(buf[1] != 43579, "test23 case 3 failed\n");
1732 1.1.1.2.2.2 yamt FAILED(buf[2] != 658923, "test23 case 4 failed\n");
1733 1.1.1.2.2.2 yamt FAILED(buf[3] != 0x0f00f00, "test23 case 5 failed\n");
1734 1.1.1.2.2.2 yamt FAILED(buf[4] != 0x0f00f00, "test23 case 6 failed\n");
1735 1.1.1.2.2.2 yamt FAILED(buf[5] != 80, "test23 case 7 failed\n");
1736 1.1.1.2.2.2 yamt FAILED(buf[6] != 0x123456, "test23 case 8 failed\n");
1737 1.1.1.2.2.2 yamt FAILED(buf[7] != (sljit_w)&buf[5], "test23 case 9 failed\n");
1738 1.1.1.2.2.2 yamt FAILED(buf[8] != (sljit_w)&buf[8] - 100000 * sizeof(sljit_w), "test23 case 10 failed\n");
1739 1.1.1.2.2.2 yamt
1740 1.1.1.2.2.2 yamt FAILED(ibuf[0] != 34567, "test23 case 11 failed\n");
1741 1.1.1.2.2.2 yamt FAILED(ibuf[1] != -7654, "test23 case 12 failed\n");
1742 1.1.1.2.2.2 yamt u.asint = ibuf[4];
1743 1.1.1.2.2.2 yamt #if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
1744 1.1.1.2.2.2 yamt FAILED(u.asbytes[0] != 0x78, "test23 case 13 failed\n");
1745 1.1.1.2.2.2 yamt FAILED(u.asbytes[1] != 0x56, "test23 case 14 failed\n");
1746 1.1.1.2.2.2 yamt FAILED(u.asbytes[2] != 0x34, "test23 case 15 failed\n");
1747 1.1.1.2.2.2 yamt FAILED(u.asbytes[3] != 0x12, "test23 case 16 failed\n");
1748 1.1.1.2.2.2 yamt #else
1749 1.1.1.2.2.2 yamt FAILED(u.asbytes[0] != 0x12, "test23 case 13 failed\n");
1750 1.1.1.2.2.2 yamt FAILED(u.asbytes[1] != 0x34, "test23 case 14 failed\n");
1751 1.1.1.2.2.2 yamt FAILED(u.asbytes[2] != 0x56, "test23 case 15 failed\n");
1752 1.1.1.2.2.2 yamt FAILED(u.asbytes[3] != 0x78, "test23 case 16 failed\n");
1753 1.1.1.2.2.2 yamt #endif
1754 1.1.1.2.2.2 yamt
1755 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1756 1.1.1.2.2.2 yamt printf("test23 ok\n");
1757 1.1.1.2.2.2 yamt successful_tests++;
1758 1.1.1.2.2.2 yamt }
1759 1.1.1.2.2.2 yamt
1760 1.1.1.2.2.2 yamt static void test24(void)
1761 1.1.1.2.2.2 yamt {
1762 1.1.1.2.2.2 yamt /* Some complicated addressing modes. */
1763 1.1.1.2.2.2 yamt executable_code code;
1764 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1765 1.1.1.2.2.2 yamt sljit_w buf[6];
1766 1.1.1.2.2.2 yamt short sbuf[5];
1767 1.1.1.2.2.2 yamt sljit_b bbuf[4];
1768 1.1.1.2.2.2 yamt
1769 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1770 1.1.1.2.2.2 yamt
1771 1.1.1.2.2.2 yamt buf[0] = 100567;
1772 1.1.1.2.2.2 yamt buf[1] = 75799;
1773 1.1.1.2.2.2 yamt buf[2] = 0;
1774 1.1.1.2.2.2 yamt buf[3] = -8;
1775 1.1.1.2.2.2 yamt buf[4] = -50;
1776 1.1.1.2.2.2 yamt buf[5] = 0;
1777 1.1.1.2.2.2 yamt
1778 1.1.1.2.2.2 yamt sbuf[0] = 30000;
1779 1.1.1.2.2.2 yamt sbuf[1] = 0;
1780 1.1.1.2.2.2 yamt sbuf[2] = 0;
1781 1.1.1.2.2.2 yamt sbuf[3] = -12345;
1782 1.1.1.2.2.2 yamt sbuf[4] = 0;
1783 1.1.1.2.2.2 yamt
1784 1.1.1.2.2.2 yamt bbuf[0] = -128;
1785 1.1.1.2.2.2 yamt bbuf[1] = 0;
1786 1.1.1.2.2.2 yamt bbuf[2] = 0;
1787 1.1.1.2.2.2 yamt bbuf[3] = 99;
1788 1.1.1.2.2.2 yamt
1789 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 3, 3, 3, 0);
1790 1.1.1.2.2.2 yamt
1791 1.1.1.2.2.2 yamt /* Nothing should be updated. */
1792 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_MEM0(), (sljit_w)&sbuf[1], SLJIT_MEM0(), (sljit_w)&sbuf[0]);
1793 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1794 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1795 1.1.1.2.2.2 yamt #endif
1796 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_MEM0(), (sljit_w)&bbuf[1], SLJIT_MEM0(), (sljit_w)&bbuf[0]);
1797 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1798 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1799 1.1.1.2.2.2 yamt #endif
1800 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
1801 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), 1, SLJIT_MEM0(), (sljit_w)&sbuf[3]);
1802 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1803 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1804 1.1.1.2.2.2 yamt #endif
1805 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (sljit_w)&buf[0]);
1806 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(sljit_w));
1807 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 2);
1808 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT, SLJIT_MEM0(), (sljit_w)&buf[0], SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), 0);
1809 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1810 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1811 1.1.1.2.2.2 yamt #endif
1812 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, sizeof(signed char));
1813 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(signed char));
1814 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), (sljit_w)&bbuf[1], SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&bbuf[0]);
1815 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1816 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1817 1.1.1.2.2.2 yamt #endif
1818 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 2 * sizeof(signed char));
1819 1.1.1.2.2.2 yamt
1820 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, sizeof(short));
1821 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), (sljit_w)&sbuf[3], SLJIT_TEMPORARY_REG2, 0);
1822 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM)
1823 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg == 0);
1824 1.1.1.2.2.2 yamt #endif
1825 1.1.1.2.2.2 yamt
1826 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
1827 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
1828 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1829 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1830 1.1.1.2.2.2 yamt #endif
1831 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
1832 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0);
1833 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
1834 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1835 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1836 1.1.1.2.2.2 yamt #endif
1837 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
1838 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
1839 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 4);
1840 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM2(SLJIT_TEMPORARY_REG2, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG3), SLJIT_WORD_SHIFT);
1841 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
1842 1.1.1.2.2.2 yamt SLJIT_ASSERT(compiler->cache_arg > 0);
1843 1.1.1.2.2.2 yamt #endif
1844 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
1845 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
1846 1.1.1.2.2.2 yamt
1847 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1848 1.1.1.2.2.2 yamt
1849 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1850 1.1.1.2.2.2 yamt CHECK(compiler);
1851 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1852 1.1.1.2.2.2 yamt
1853 1.1.1.2.2.2 yamt code.func3((sljit_w)&buf, (sljit_w)&sbuf, (sljit_w)&bbuf);
1854 1.1.1.2.2.2 yamt FAILED(buf[2] != 176366, "test24 case 1 failed\n");
1855 1.1.1.2.2.2 yamt FAILED(buf[3] != 64, "test24 case 2 failed\n");
1856 1.1.1.2.2.2 yamt FAILED(buf[4] != -100, "test24 case 3 failed\n");
1857 1.1.1.2.2.2 yamt FAILED(buf[5] != -100 + (sljit_w)&buf[5] + (sljit_w)&buf[4], "test24 case 4 failed\n");
1858 1.1.1.2.2.2 yamt
1859 1.1.1.2.2.2 yamt FAILED(sbuf[1] != 30000, "test24 case 5 failed\n");
1860 1.1.1.2.2.2 yamt FAILED(sbuf[2] != -12345, "test24 case 6 failed\n");
1861 1.1.1.2.2.2 yamt FAILED(sbuf[4] != sizeof(short), "test24 case 7 failed\n");
1862 1.1.1.2.2.2 yamt
1863 1.1.1.2.2.2 yamt FAILED(bbuf[1] != -128, "test24 case 8 failed\n");
1864 1.1.1.2.2.2 yamt FAILED(bbuf[2] != 99, "test24 case 9 failed\n");
1865 1.1.1.2.2.2 yamt
1866 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1867 1.1.1.2.2.2 yamt printf("test24 ok\n");
1868 1.1.1.2.2.2 yamt successful_tests++;
1869 1.1.1.2.2.2 yamt }
1870 1.1.1.2.2.2 yamt
1871 1.1.1.2.2.2 yamt static void test25(void)
1872 1.1.1.2.2.2 yamt {
1873 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
1874 1.1.1.2.2.2 yamt /* 64 bit loads. */
1875 1.1.1.2.2.2 yamt executable_code code;
1876 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1877 1.1.1.2.2.2 yamt sljit_w buf[14];
1878 1.1.1.2.2.2 yamt
1879 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1880 1.1.1.2.2.2 yamt buf[0] = 7;
1881 1.1.1.2.2.2 yamt buf[1] = 0;
1882 1.1.1.2.2.2 yamt buf[2] = 0;
1883 1.1.1.2.2.2 yamt buf[3] = 0;
1884 1.1.1.2.2.2 yamt buf[4] = 0;
1885 1.1.1.2.2.2 yamt buf[5] = 0;
1886 1.1.1.2.2.2 yamt buf[6] = 0;
1887 1.1.1.2.2.2 yamt buf[7] = 0;
1888 1.1.1.2.2.2 yamt buf[8] = 0;
1889 1.1.1.2.2.2 yamt buf[9] = 0;
1890 1.1.1.2.2.2 yamt buf[10] = 0;
1891 1.1.1.2.2.2 yamt buf[11] = 0;
1892 1.1.1.2.2.2 yamt buf[12] = 0;
1893 1.1.1.2.2.2 yamt buf[13] = 0;
1894 1.1.1.2.2.2 yamt
1895 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 1, 0);
1896 1.1.1.2.2.2 yamt
1897 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0);
1898 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 1 * sizeof(sljit_w), SLJIT_IMM, 0x7fff);
1899 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_IMM, -0x8000);
1900 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_IMM, 0x7fffffff);
1901 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(-0x80000000));
1902 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x1234567887654321));
1903 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xff80000000));
1904 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x3ff0000000));
1905 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xfffffff800100000));
1906 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0xfffffff80010f000));
1907 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00000008001));
1908 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00080010000));
1909 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00080018001));
1910 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_IMM, SLJIT_W(0x07fff00ffff00000));
1911 1.1.1.2.2.2 yamt
1912 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1913 1.1.1.2.2.2 yamt
1914 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1915 1.1.1.2.2.2 yamt CHECK(compiler);
1916 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1917 1.1.1.2.2.2 yamt
1918 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
1919 1.1.1.2.2.2 yamt FAILED(buf[0] != 0, "test25 case 1 failed\n");
1920 1.1.1.2.2.2 yamt FAILED(buf[1] != 0x7fff, "test25 case 2 failed\n");
1921 1.1.1.2.2.2 yamt FAILED(buf[2] != -0x8000, "test25 case 3 failed\n");
1922 1.1.1.2.2.2 yamt FAILED(buf[3] != 0x7fffffff, "test25 case 4 failed\n");
1923 1.1.1.2.2.2 yamt FAILED(buf[4] != SLJIT_W(-0x80000000), "test25 case 5 failed\n");
1924 1.1.1.2.2.2 yamt FAILED(buf[5] != SLJIT_W(0x1234567887654321), "test25 case 6 failed\n");
1925 1.1.1.2.2.2 yamt FAILED(buf[6] != SLJIT_W(0xff80000000), "test25 case 7 failed\n");
1926 1.1.1.2.2.2 yamt FAILED(buf[7] != SLJIT_W(0x3ff0000000), "test25 case 8 failed\n");
1927 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[8] != SLJIT_W(0xfffffff800100000), "test25 case 9 failed\n");
1928 1.1.1.2.2.2 yamt FAILED((sljit_uw)buf[9] != SLJIT_W(0xfffffff80010f000), "test25 case 10 failed\n");
1929 1.1.1.2.2.2 yamt FAILED(buf[10] != SLJIT_W(0x07fff00000008001), "test25 case 11 failed\n");
1930 1.1.1.2.2.2 yamt FAILED(buf[11] != SLJIT_W(0x07fff00080010000), "test25 case 12 failed\n");
1931 1.1.1.2.2.2 yamt FAILED(buf[12] != SLJIT_W(0x07fff00080018001), "test25 case 13 failed\n");
1932 1.1.1.2.2.2 yamt FAILED(buf[13] != SLJIT_W(0x07fff00ffff00000), "test25 case 14 failed\n");
1933 1.1.1.2.2.2 yamt
1934 1.1.1.2.2.2 yamt sljit_free_code(code.code);
1935 1.1.1.2.2.2 yamt #endif
1936 1.1.1.2.2.2 yamt printf("test25 ok\n");
1937 1.1.1.2.2.2 yamt successful_tests++;
1938 1.1.1.2.2.2 yamt }
1939 1.1.1.2.2.2 yamt
1940 1.1.1.2.2.2 yamt static void test26(void)
1941 1.1.1.2.2.2 yamt {
1942 1.1.1.2.2.2 yamt /* Aligned access without aligned offsets. */
1943 1.1.1.2.2.2 yamt executable_code code;
1944 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
1945 1.1.1.2.2.2 yamt sljit_w buf[4];
1946 1.1.1.2.2.2 yamt int ibuf[4];
1947 1.1.1.2.2.2 yamt double dbuf[4];
1948 1.1.1.2.2.2 yamt
1949 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
1950 1.1.1.2.2.2 yamt
1951 1.1.1.2.2.2 yamt buf[0] = -2789;
1952 1.1.1.2.2.2 yamt buf[1] = 0;
1953 1.1.1.2.2.2 yamt buf[2] = 4;
1954 1.1.1.2.2.2 yamt buf[3] = -4;
1955 1.1.1.2.2.2 yamt
1956 1.1.1.2.2.2 yamt ibuf[0] = -689;
1957 1.1.1.2.2.2 yamt ibuf[1] = 0;
1958 1.1.1.2.2.2 yamt ibuf[2] = -6;
1959 1.1.1.2.2.2 yamt ibuf[3] = 3;
1960 1.1.1.2.2.2 yamt
1961 1.1.1.2.2.2 yamt dbuf[0] = 5.75;
1962 1.1.1.2.2.2 yamt dbuf[1] = 0.0;
1963 1.1.1.2.2.2 yamt dbuf[2] = 0.0;
1964 1.1.1.2.2.2 yamt dbuf[3] = -4.0;
1965 1.1.1.2.2.2 yamt
1966 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 3, 3, 3, 0);
1967 1.1.1.2.2.2 yamt
1968 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 3);
1969 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
1970 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), -3);
1971 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) - 1, SLJIT_TEMPORARY_REG1, 0);
1972 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), -1);
1973 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) - 3, SLJIT_TEMPORARY_REG1, 0);
1974 1.1.1.2.2.2 yamt
1975 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 100);
1976 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w) * 2 - 103, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2 - 3, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 3 - 3);
1977 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 100);
1978 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(int) * 2 - 101, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) * 2 - 1, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int) * 3 - 1);
1979 1.1.1.2.2.2 yamt
1980 1.1.1.2.2.2 yamt if (sljit_is_fpu_available()) {
1981 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 3);
1982 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) - 3, SLJIT_MEM1(SLJIT_SAVED_REG3), -3);
1983 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) * 2 - 3, SLJIT_MEM1(SLJIT_SAVED_REG3), -3, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) - 3);
1984 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 2);
1985 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sizeof(double) * 3 - 4) >> 1);
1986 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 1);
1987 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(double) * 3 - 5, SLJIT_MEM1(SLJIT_SAVED_REG3), sizeof(double) * 2 - 3, SLJIT_MEM2(SLJIT_TEMPORARY_REG3, SLJIT_TEMPORARY_REG2), 1);
1988 1.1.1.2.2.2 yamt }
1989 1.1.1.2.2.2 yamt
1990 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
1991 1.1.1.2.2.2 yamt
1992 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
1993 1.1.1.2.2.2 yamt CHECK(compiler);
1994 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
1995 1.1.1.2.2.2 yamt
1996 1.1.1.2.2.2 yamt code.func3((sljit_w)&buf, (sljit_w)&ibuf, (sljit_w)&dbuf);
1997 1.1.1.2.2.2 yamt
1998 1.1.1.2.2.2 yamt FAILED(buf[1] != -689, "test26 case 1 failed\n");
1999 1.1.1.2.2.2 yamt FAILED(buf[2] != -16, "test26 case 2 failed\n");
2000 1.1.1.2.2.2 yamt FAILED(ibuf[1] != -2789, "test26 case 3 failed\n");
2001 1.1.1.2.2.2 yamt FAILED(ibuf[2] != -18, "test26 case 4 failed\n");
2002 1.1.1.2.2.2 yamt
2003 1.1.1.2.2.2 yamt if (sljit_is_fpu_available()) {
2004 1.1.1.2.2.2 yamt FAILED(dbuf[1] != 5.75, "test26 case 5 failed\n");
2005 1.1.1.2.2.2 yamt FAILED(dbuf[2] != 11.5, "test26 case 6 failed\n");
2006 1.1.1.2.2.2 yamt FAILED(dbuf[3] != -2.875, "test26 case 7 failed\n");
2007 1.1.1.2.2.2 yamt }
2008 1.1.1.2.2.2 yamt
2009 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2010 1.1.1.2.2.2 yamt printf("test26 ok\n");
2011 1.1.1.2.2.2 yamt successful_tests++;
2012 1.1.1.2.2.2 yamt }
2013 1.1.1.2.2.2 yamt
2014 1.1.1.2.2.2 yamt static void test27(void)
2015 1.1.1.2.2.2 yamt {
2016 1.1.1.2.2.2 yamt #define SET_NEXT_BYTE(type) \
2017 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_TEMPORARY_REG3, 0, type); \
2018 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
2019 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2020 1.1.1.2.2.2 yamt #define RESULT(i) i
2021 1.1.1.2.2.2 yamt #else
2022 1.1.1.2.2.2 yamt #define RESULT(i) (3 - i)
2023 1.1.1.2.2.2 yamt #endif
2024 1.1.1.2.2.2 yamt
2025 1.1.1.2.2.2 yamt /* Playing with conditional flags. */
2026 1.1.1.2.2.2 yamt executable_code code;
2027 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2028 1.1.1.2.2.2 yamt sljit_b buf[37];
2029 1.1.1.2.2.2 yamt int i;
2030 1.1.1.2.2.2 yamt
2031 1.1.1.2.2.2 yamt for (i = 0; i < 37; ++i)
2032 1.1.1.2.2.2 yamt buf[i] = 10;
2033 1.1.1.2.2.2 yamt
2034 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2035 1.1.1.2.2.2 yamt
2036 1.1.1.2.2.2 yamt /* 3 arguments passed, 3 arguments used. */
2037 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 3, 0);
2038 1.1.1.2.2.2 yamt
2039 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
2040 1.1.1.2.2.2 yamt
2041 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1001);
2042 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
2043 1.1.1.2.2.2 yamt /* 0x100100000 on 64 bit machines, 0x100000 on 32 bit machines. */
2044 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x800000);
2045 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2046 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_NOP); /* Nop should keep the flags. */
2047 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER);
2048 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2049 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2050 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_NOP); /* Nop should keep the flags. */
2051 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER);
2052 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2053 1.1.1.2.2.2 yamt
2054 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1000);
2055 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 20);
2056 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x10);
2057 1.1.1.2.2.2 yamt /* 0x100000010 on 64 bit machines, 0x10 on 32 bit machines. */
2058 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80);
2059 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER);
2060 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2061 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80);
2062 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER);
2063 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2064 1.1.1.2.2.2 yamt
2065 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2066 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2067 1.1.1.2.2.2 yamt /* 0xff..ff on all machines. */
2068 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2069 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS_EQUAL);
2070 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER_EQUAL);
2071 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -1);
2072 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_SIG_GREATER);
2073 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_SIG_LESS);
2074 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0);
2075 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_EQUAL);
2076 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
2077 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_O | SLJIT_SET_U, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -2);
2078 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
2079 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
2080 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_GREATER_EQUAL);
2081 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS_EQUAL);
2082 1.1.1.2.2.2 yamt
2083 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x80000000);
2084 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
2085 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 16);
2086 1.1.1.2.2.2 yamt /* 0x80..0 on 64 bit machines, 0 on 32 bit machines. */
2087 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0xffffffff);
2088 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2089 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
2090 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
2091 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2092 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_OVERFLOW);
2093 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_OVERFLOW);
2094 1.1.1.2.2.2 yamt
2095 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2096 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2097 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2098 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6, SLJIT_TEMPORARY_REG1, 0);
2099 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG1, 0);
2100 1.1.1.2.2.2 yamt
2101 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
2102 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2103 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2104 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 9);
2105 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG1, 0);
2106 1.1.1.2.2.2 yamt
2107 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2108 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (8 * sizeof(sljit_w)) - 1);
2109 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2110 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_EQUAL);
2111 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
2112 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_EQUAL);
2113 1.1.1.2.2.2 yamt
2114 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2115 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2116 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_EQUAL);
2117 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2118 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xffffc0);
2119 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
2120 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
2121 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2122 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ASHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2123 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_EQUAL);
2124 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_PREF_SHIFT_REG, 0, SLJIT_IMM, 0);
2125 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2126 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
2127 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_NOT_EQUAL);
2128 1.1.1.2.2.2 yamt
2129 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2130 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
2131 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
2132 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1, SLJIT_TEMPORARY_REG1, 0);
2133 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
2134 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC | SLJIT_SET_C, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2135 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUBC, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1, SLJIT_TEMPORARY_REG1, 0);
2136 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_TEMPORARY_REG3, 0);
2137 1.1.1.2.2.2 yamt
2138 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -34);
2139 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x1234);
2140 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2141 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_SIG_LESS);
2142 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2143 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x12300000000) - 43);
2144 1.1.1.2.2.2 yamt #else
2145 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -43);
2146 1.1.1.2.2.2 yamt #endif
2147 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -96);
2148 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_S | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2149 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_LESS);
2150 1.1.1.2.2.2 yamt SET_NEXT_BYTE(SLJIT_C_SIG_GREATER);
2151 1.1.1.2.2.2 yamt
2152 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2153 1.1.1.2.2.2 yamt
2154 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2155 1.1.1.2.2.2 yamt CHECK(compiler);
2156 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2157 1.1.1.2.2.2 yamt
2158 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
2159 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2160 1.1.1.2.2.2 yamt
2161 1.1.1.2.2.2 yamt FAILED(buf[0] != RESULT(1), "test27 case 1 failed\n");
2162 1.1.1.2.2.2 yamt FAILED(buf[1] != RESULT(2), "test27 case 2 failed\n");
2163 1.1.1.2.2.2 yamt FAILED(buf[2] != 2, "test27 case 3 failed\n");
2164 1.1.1.2.2.2 yamt FAILED(buf[3] != 1, "test27 case 4 failed\n");
2165 1.1.1.2.2.2 yamt FAILED(buf[4] != RESULT(1), "test27 case 5 failed\n");
2166 1.1.1.2.2.2 yamt FAILED(buf[5] != RESULT(2), "test27 case 6 failed\n");
2167 1.1.1.2.2.2 yamt FAILED(buf[6] != 2, "test27 case 7 failed\n");
2168 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test27 case 8 failed\n");
2169 1.1.1.2.2.2 yamt
2170 1.1.1.2.2.2 yamt FAILED(buf[8] != 2, "test27 case 9 failed\n");
2171 1.1.1.2.2.2 yamt FAILED(buf[9] != 1, "test27 case 10 failed\n");
2172 1.1.1.2.2.2 yamt FAILED(buf[10] != 2, "test27 case 11 failed\n");
2173 1.1.1.2.2.2 yamt FAILED(buf[11] != 1, "test27 case 12 failed\n");
2174 1.1.1.2.2.2 yamt FAILED(buf[12] != 1, "test27 case 13 failed\n");
2175 1.1.1.2.2.2 yamt FAILED(buf[13] != 2, "test27 case 14 failed\n");
2176 1.1.1.2.2.2 yamt FAILED(buf[14] != 2, "test27 case 15 failed\n");
2177 1.1.1.2.2.2 yamt FAILED(buf[15] != 1, "test27 case 16 failed\n");
2178 1.1.1.2.2.2 yamt FAILED(buf[16] != 1, "test27 case 17 failed\n");
2179 1.1.1.2.2.2 yamt FAILED(buf[17] != 2, "test27 case 18 failed\n");
2180 1.1.1.2.2.2 yamt
2181 1.1.1.2.2.2 yamt FAILED(buf[18] != RESULT(1), "test27 case 19 failed\n");
2182 1.1.1.2.2.2 yamt FAILED(buf[19] != RESULT(2), "test27 case 20 failed\n");
2183 1.1.1.2.2.2 yamt FAILED(buf[20] != 2, "test27 case 21 failed\n");
2184 1.1.1.2.2.2 yamt FAILED(buf[21] != 1, "test27 case 22 failed\n");
2185 1.1.1.2.2.2 yamt
2186 1.1.1.2.2.2 yamt FAILED(buf[22] != 5, "test27 case 23 failed\n");
2187 1.1.1.2.2.2 yamt FAILED(buf[23] != 9, "test27 case 24 failed\n");
2188 1.1.1.2.2.2 yamt
2189 1.1.1.2.2.2 yamt FAILED(buf[24] != 2, "test27 case 25 failed\n");
2190 1.1.1.2.2.2 yamt FAILED(buf[25] != 1, "test27 case 26 failed\n");
2191 1.1.1.2.2.2 yamt
2192 1.1.1.2.2.2 yamt FAILED(buf[26] != 1, "test27 case 27 failed\n");
2193 1.1.1.2.2.2 yamt FAILED(buf[27] != 1, "test27 case 28 failed\n");
2194 1.1.1.2.2.2 yamt FAILED(buf[28] != 1, "test27 case 29 failed\n");
2195 1.1.1.2.2.2 yamt FAILED(buf[29] != 1, "test27 case 30 failed\n");
2196 1.1.1.2.2.2 yamt
2197 1.1.1.2.2.2 yamt FAILED(buf[30] != 1, "test27 case 31 failed\n");
2198 1.1.1.2.2.2 yamt FAILED(buf[31] != 0, "test27 case 32 failed\n");
2199 1.1.1.2.2.2 yamt
2200 1.1.1.2.2.2 yamt FAILED(buf[32] != 2, "test27 case 33 failed\n");
2201 1.1.1.2.2.2 yamt FAILED(buf[33] != 1, "test27 case 34 failed\n");
2202 1.1.1.2.2.2 yamt FAILED(buf[34] != 2, "test27 case 35 failed\n");
2203 1.1.1.2.2.2 yamt FAILED(buf[35] != 1, "test27 case 36 failed\n");
2204 1.1.1.2.2.2 yamt FAILED(buf[36] != 10, "test27 case 37 failed\n");
2205 1.1.1.2.2.2 yamt printf("test27 ok\n");
2206 1.1.1.2.2.2 yamt successful_tests++;
2207 1.1.1.2.2.2 yamt #undef SET_NEXT_BYTE
2208 1.1.1.2.2.2 yamt #undef RESULT
2209 1.1.1.2.2.2 yamt }
2210 1.1.1.2.2.2 yamt
2211 1.1.1.2.2.2 yamt static void test28(void)
2212 1.1.1.2.2.2 yamt {
2213 1.1.1.2.2.2 yamt /* Test mov. */
2214 1.1.1.2.2.2 yamt executable_code code;
2215 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2216 1.1.1.2.2.2 yamt struct sljit_const* const1;
2217 1.1.1.2.2.2 yamt struct sljit_label* label;
2218 1.1.1.2.2.2 yamt sljit_uw label_addr;
2219 1.1.1.2.2.2 yamt sljit_w buf[5];
2220 1.1.1.2.2.2 yamt
2221 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2222 1.1.1.2.2.2 yamt
2223 1.1.1.2.2.2 yamt buf[0] = -36;
2224 1.1.1.2.2.2 yamt buf[1] = 8;
2225 1.1.1.2.2.2 yamt buf[2] = 0;
2226 1.1.1.2.2.2 yamt buf[3] = 10;
2227 1.1.1.2.2.2 yamt buf[4] = 0;
2228 1.1.1.2.2.2 yamt
2229 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2230 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 0);
2231 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, -234);
2232 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
2233 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_SAVED_EREG1, 0, SLJIT_TEMPORARY_EREG1, 0, SLJIT_TEMPORARY_EREG2, 0);
2234 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
2235 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0);
2236 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_C_NOT_ZERO);
2237 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
2238 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w));
2239 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_EREG2, 0, SLJIT_SAVED_EREG2, 0, SLJIT_TEMPORARY_EREG2, 0);
2240 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_EREG2, 0);
2241 1.1.1.2.2.2 yamt const1 = sljit_emit_const(compiler, SLJIT_SAVED_EREG1, 0, 0);
2242 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_SAVED_EREG1, 0);
2243 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_EREG1, 0, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 100);
2244 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
2245 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
2246 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0);
2247 1.1.1.2.2.2 yamt
2248 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2249 1.1.1.2.2.2 yamt CHECK(compiler);
2250 1.1.1.2.2.2 yamt label_addr = sljit_get_label_addr(label);
2251 1.1.1.2.2.2 yamt sljit_set_const(sljit_get_const_addr(const1), label_addr);
2252 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2253 1.1.1.2.2.2 yamt
2254 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 8, "test28 case 1 failed\n");
2255 1.1.1.2.2.2 yamt FAILED(buf[1] != -1872, "test28 case 2 failed\n");
2256 1.1.1.2.2.2 yamt FAILED(buf[2] != 1, "test28 case 3 failed\n");
2257 1.1.1.2.2.2 yamt FAILED(buf[3] != 2, "test28 case 4 failed\n");
2258 1.1.1.2.2.2 yamt FAILED(buf[4] != label_addr, "test28 case 5 failed\n");
2259 1.1.1.2.2.2 yamt
2260 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2261 1.1.1.2.2.2 yamt printf("test28 ok\n");
2262 1.1.1.2.2.2 yamt successful_tests++;
2263 1.1.1.2.2.2 yamt }
2264 1.1.1.2.2.2 yamt
2265 1.1.1.2.2.2 yamt static void test29(void)
2266 1.1.1.2.2.2 yamt {
2267 1.1.1.2.2.2 yamt /* Test signed/unsigned bytes and halfs. */
2268 1.1.1.2.2.2 yamt executable_code code;
2269 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2270 1.1.1.2.2.2 yamt
2271 1.1.1.2.2.2 yamt sljit_w buf[25];
2272 1.1.1.2.2.2 yamt buf[0] = 0;
2273 1.1.1.2.2.2 yamt buf[1] = 0;
2274 1.1.1.2.2.2 yamt buf[2] = 0;
2275 1.1.1.2.2.2 yamt buf[3] = 0;
2276 1.1.1.2.2.2 yamt buf[4] = 0;
2277 1.1.1.2.2.2 yamt buf[5] = 0;
2278 1.1.1.2.2.2 yamt buf[6] = 0;
2279 1.1.1.2.2.2 yamt buf[7] = 0;
2280 1.1.1.2.2.2 yamt buf[8] = 0;
2281 1.1.1.2.2.2 yamt buf[9] = 0;
2282 1.1.1.2.2.2 yamt buf[10] = 0;
2283 1.1.1.2.2.2 yamt buf[11] = 0;
2284 1.1.1.2.2.2 yamt buf[12] = 0;
2285 1.1.1.2.2.2 yamt buf[13] = 0;
2286 1.1.1.2.2.2 yamt buf[14] = 0;
2287 1.1.1.2.2.2 yamt buf[15] = 0;
2288 1.1.1.2.2.2 yamt buf[16] = 0;
2289 1.1.1.2.2.2 yamt buf[17] = 0;
2290 1.1.1.2.2.2 yamt buf[18] = 0;
2291 1.1.1.2.2.2 yamt buf[19] = 0;
2292 1.1.1.2.2.2 yamt buf[20] = 0;
2293 1.1.1.2.2.2 yamt buf[21] = 0;
2294 1.1.1.2.2.2 yamt buf[22] = 0;
2295 1.1.1.2.2.2 yamt buf[23] = 0;
2296 1.1.1.2.2.2 yamt buf[24] = 0;
2297 1.1.1.2.2.2 yamt
2298 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2299 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 0);
2300 1.1.1.2.2.2 yamt
2301 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -187);
2302 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
2303 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -605);
2304 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2305 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -56);
2306 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2307 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0xcde5);
2308 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2309 1.1.1.2.2.2 yamt
2310 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -45896);
2311 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2312 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1472797);
2313 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2314 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -12890);
2315 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2316 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0x9cb0a6);
2317 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2318 1.1.1.2.2.2 yamt
2319 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2320 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-3580429715));
2321 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2322 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-100722768662));
2323 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2324 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-1457052677972));
2325 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2326 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, SLJIT_W(0xcef97a70b5));
2327 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2328 1.1.1.2.2.2 yamt #else
2329 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 4 * sizeof(sljit_uw));
2330 1.1.1.2.2.2 yamt #endif
2331 1.1.1.2.2.2 yamt
2332 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -187);
2333 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2334 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2335 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -605);
2336 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SB, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
2337 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2338 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -56);
2339 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
2340 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2341 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0xcde5);
2342 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
2343 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2344 1.1.1.2.2.2 yamt
2345 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -45896);
2346 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2347 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2348 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -1472797);
2349 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SH, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
2350 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2351 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -12890);
2352 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UH, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
2353 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2354 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0x9cb0a6);
2355 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UH, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
2356 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2357 1.1.1.2.2.2 yamt
2358 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2359 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(-3580429715));
2360 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2361 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2362 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, SLJIT_W(-100722768662));
2363 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
2364 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2365 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, SLJIT_W(-1457052677972));
2366 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
2367 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_REG1, 0);
2368 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, SLJIT_W(0xcef97a70b5));
2369 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU_UI, SLJIT_TEMPORARY_EREG2, 0, SLJIT_TEMPORARY_EREG1, 0);
2370 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_TEMPORARY_EREG2, 0);
2371 1.1.1.2.2.2 yamt #else
2372 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 4 * sizeof(sljit_uw));
2373 1.1.1.2.2.2 yamt #endif
2374 1.1.1.2.2.2 yamt
2375 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 0x9faa5);
2376 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SB, SLJIT_SAVED_REG3, 0, SLJIT_SAVED_REG3, 0);
2377 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_uw), SLJIT_SAVED_REG3, 0);
2378 1.1.1.2.2.2 yamt
2379 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2380 1.1.1.2.2.2 yamt
2381 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2382 1.1.1.2.2.2 yamt CHECK(compiler);
2383 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2384 1.1.1.2.2.2 yamt
2385 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
2386 1.1.1.2.2.2 yamt FAILED(buf[0] != 69, "test29 case 1 failed\n");
2387 1.1.1.2.2.2 yamt FAILED(buf[1] != -93, "test29 case 2 failed\n");
2388 1.1.1.2.2.2 yamt FAILED(buf[2] != 200, "test29 case 3 failed\n");
2389 1.1.1.2.2.2 yamt FAILED(buf[3] != 0xe5, "test29 case 4 failed\n");
2390 1.1.1.2.2.2 yamt FAILED(buf[4] != 19640, "test29 case 5 failed\n");
2391 1.1.1.2.2.2 yamt FAILED(buf[5] != -31005, "test29 case 6 failed\n");
2392 1.1.1.2.2.2 yamt FAILED(buf[6] != 52646, "test29 case 7 failed\n");
2393 1.1.1.2.2.2 yamt FAILED(buf[7] != 0xb0a6, "test29 case 8 failed\n");
2394 1.1.1.2.2.2 yamt
2395 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2396 1.1.1.2.2.2 yamt FAILED(buf[8] != SLJIT_W(714537581), "test29 case 9 failed\n");
2397 1.1.1.2.2.2 yamt FAILED(buf[9] != SLJIT_W(-1938520854), "test29 case 10 failed\n");
2398 1.1.1.2.2.2 yamt FAILED(buf[10] != SLJIT_W(3236202668), "test29 case 11 failed\n");
2399 1.1.1.2.2.2 yamt FAILED(buf[11] != SLJIT_W(0xf97a70b5), "test29 case 12 failed\n");
2400 1.1.1.2.2.2 yamt #endif
2401 1.1.1.2.2.2 yamt
2402 1.1.1.2.2.2 yamt FAILED(buf[12] != 69, "test29 case 13 failed\n");
2403 1.1.1.2.2.2 yamt FAILED(buf[13] != -93, "test29 case 14 failed\n");
2404 1.1.1.2.2.2 yamt FAILED(buf[14] != 200, "test29 case 15 failed\n");
2405 1.1.1.2.2.2 yamt FAILED(buf[15] != 0xe5, "test29 case 16 failed\n");
2406 1.1.1.2.2.2 yamt FAILED(buf[16] != 19640, "test29 case 17 failed\n");
2407 1.1.1.2.2.2 yamt FAILED(buf[17] != -31005, "test29 case 18 failed\n");
2408 1.1.1.2.2.2 yamt FAILED(buf[18] != 52646, "test29 case 19 failed\n");
2409 1.1.1.2.2.2 yamt FAILED(buf[19] != 0xb0a6, "test29 case 20 failed\n");
2410 1.1.1.2.2.2 yamt
2411 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2412 1.1.1.2.2.2 yamt FAILED(buf[20] != SLJIT_W(714537581), "test29 case 21 failed\n");
2413 1.1.1.2.2.2 yamt FAILED(buf[21] != SLJIT_W(-1938520854), "test29 case 22 failed\n");
2414 1.1.1.2.2.2 yamt FAILED(buf[22] != SLJIT_W(3236202668), "test29 case 23 failed\n");
2415 1.1.1.2.2.2 yamt FAILED(buf[23] != SLJIT_W(0xf97a70b5), "test29 case 24 failed\n");
2416 1.1.1.2.2.2 yamt #endif
2417 1.1.1.2.2.2 yamt
2418 1.1.1.2.2.2 yamt FAILED(buf[24] != -91, "test29 case 25 failed\n");
2419 1.1.1.2.2.2 yamt
2420 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2421 1.1.1.2.2.2 yamt printf("test29 ok\n");
2422 1.1.1.2.2.2 yamt successful_tests++;
2423 1.1.1.2.2.2 yamt }
2424 1.1.1.2.2.2 yamt
2425 1.1.1.2.2.2 yamt static void test30(void)
2426 1.1.1.2.2.2 yamt {
2427 1.1.1.2.2.2 yamt /* Test unused results. */
2428 1.1.1.2.2.2 yamt executable_code code;
2429 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2430 1.1.1.2.2.2 yamt
2431 1.1.1.2.2.2 yamt sljit_w buf[1];
2432 1.1.1.2.2.2 yamt buf[0] = 0;
2433 1.1.1.2.2.2 yamt
2434 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2435 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 0);
2436 1.1.1.2.2.2 yamt
2437 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2438 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
2439 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1);
2440 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 1);
2441 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 1);
2442 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 1);
2443 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, 1);
2444 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 1);
2445 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 1);
2446 1.1.1.2.2.2 yamt
2447 1.1.1.2.2.2 yamt /* Some calculations with unused results. */
2448 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0);
2449 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0);
2450 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NEG, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2451 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2452 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_INT_OP | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2453 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL, SLJIT_UNUSED, 0, SLJIT_SAVED_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2454 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_EREG1, 0, SLJIT_TEMPORARY_REG3, 0);
2455 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_LSHR | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 5);
2456 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 0xff);
2457 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_NOT | SLJIT_INT_OP | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_SAVED_REG2, 0);
2458 1.1.1.2.2.2 yamt
2459 1.1.1.2.2.2 yamt /* Testing that any change happens. */
2460 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2461 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG3, 0);
2462 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_EREG1, 0);
2463 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_EREG2, 0);
2464 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG2, 0);
2465 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG3, 0);
2466 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_EREG1, 0);
2467 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_EREG2, 0);
2468 1.1.1.2.2.2 yamt
2469 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2470 1.1.1.2.2.2 yamt
2471 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2472 1.1.1.2.2.2 yamt CHECK(compiler);
2473 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2474 1.1.1.2.2.2 yamt
2475 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
2476 1.1.1.2.2.2 yamt FAILED(buf[0] != 9, "test30 case 1 failed\n");
2477 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2478 1.1.1.2.2.2 yamt printf("test30 ok\n");
2479 1.1.1.2.2.2 yamt successful_tests++;
2480 1.1.1.2.2.2 yamt }
2481 1.1.1.2.2.2 yamt
2482 1.1.1.2.2.2 yamt static void test31(void)
2483 1.1.1.2.2.2 yamt {
2484 1.1.1.2.2.2 yamt /* Integer mul and set flags. */
2485 1.1.1.2.2.2 yamt executable_code code;
2486 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2487 1.1.1.2.2.2 yamt
2488 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2489 1.1.1.2.2.2 yamt sljit_w big_word = SLJIT_W(0x7fffffff00000000);
2490 1.1.1.2.2.2 yamt sljit_w big_word2 = SLJIT_W(0x7fffffff00000012);
2491 1.1.1.2.2.2 yamt #else
2492 1.1.1.2.2.2 yamt sljit_w big_word = 0x7fffffff;
2493 1.1.1.2.2.2 yamt sljit_w big_word2 = 0x00000012;
2494 1.1.1.2.2.2 yamt #endif
2495 1.1.1.2.2.2 yamt
2496 1.1.1.2.2.2 yamt sljit_w buf[12];
2497 1.1.1.2.2.2 yamt buf[0] = 3;
2498 1.1.1.2.2.2 yamt buf[1] = 3;
2499 1.1.1.2.2.2 yamt buf[2] = 3;
2500 1.1.1.2.2.2 yamt buf[3] = 3;
2501 1.1.1.2.2.2 yamt buf[4] = 3;
2502 1.1.1.2.2.2 yamt buf[5] = 3;
2503 1.1.1.2.2.2 yamt buf[6] = 3;
2504 1.1.1.2.2.2 yamt buf[7] = 3;
2505 1.1.1.2.2.2 yamt buf[8] = 3;
2506 1.1.1.2.2.2 yamt buf[9] = 3;
2507 1.1.1.2.2.2 yamt buf[10] = 3;
2508 1.1.1.2.2.2 yamt buf[11] = 3;
2509 1.1.1.2.2.2 yamt
2510 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2511 1.1.1.2.2.2 yamt
2512 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 5, 0);
2513 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
2514 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -45);
2515 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_C_MUL_NOT_OVERFLOW);
2516 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
2517 1.1.1.2.2.2 yamt
2518 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, big_word);
2519 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -2);
2520 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 33); /* Should not change flags. */
2521 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0); /* Should not change flags. */
2522 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
2523 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
2524 1.1.1.2.2.2 yamt
2525 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x3f6b0);
2526 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 0x2a783);
2527 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_SAVED_EREG1, 0, SLJIT_SAVED_EREG2, 0);
2528 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
2529 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
2530 1.1.1.2.2.2 yamt
2531 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, big_word2);
2532 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG2, 0);
2533 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 23);
2534 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_MUL_OVERFLOW);
2535 1.1.1.2.2.2 yamt
2536 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_INT_OP | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -23);
2537 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
2538 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -23);
2539 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_MUL_NOT_OVERFLOW);
2540 1.1.1.2.2.2 yamt
2541 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 67);
2542 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_MUL | SLJIT_SET_O, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -23);
2543 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
2544 1.1.1.2.2.2 yamt
2545 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2546 1.1.1.2.2.2 yamt
2547 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2548 1.1.1.2.2.2 yamt CHECK(compiler);
2549 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2550 1.1.1.2.2.2 yamt
2551 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
2552 1.1.1.2.2.2 yamt
2553 1.1.1.2.2.2 yamt FAILED(buf[0] != 1, "test31 case 1 failed\n");
2554 1.1.1.2.2.2 yamt FAILED(buf[1] != 2, "test31 case 2 failed\n");
2555 1.1.1.2.2.2 yamt /* Qemu issues for 64 bit muls. */
2556 1.1.1.2.2.2 yamt #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2557 1.1.1.2.2.2 yamt FAILED(buf[2] != 1, "test31 case 3 failed\n");
2558 1.1.1.2.2.2 yamt FAILED(buf[3] != 2, "test31 case 4 failed\n");
2559 1.1.1.2.2.2 yamt #endif
2560 1.1.1.2.2.2 yamt FAILED(buf[4] != 1, "test31 case 5 failed\n");
2561 1.1.1.2.2.2 yamt FAILED((buf[5] & 0xffffffff) != 0x85540c10, "test31 case 6 failed\n");
2562 1.1.1.2.2.2 yamt FAILED(buf[6] != 2, "test31 case 7 failed\n");
2563 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test31 case 8 failed\n");
2564 1.1.1.2.2.2 yamt #if !(defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2565 1.1.1.2.2.2 yamt FAILED(buf[8] != 1, "test31 case 9 failed\n");
2566 1.1.1.2.2.2 yamt #endif
2567 1.1.1.2.2.2 yamt FAILED(buf[9] != -1541, "test31 case 10 failed\n");
2568 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2569 1.1.1.2.2.2 yamt printf("test31 ok\n");
2570 1.1.1.2.2.2 yamt successful_tests++;
2571 1.1.1.2.2.2 yamt }
2572 1.1.1.2.2.2 yamt
2573 1.1.1.2.2.2 yamt static void test32(void)
2574 1.1.1.2.2.2 yamt {
2575 1.1.1.2.2.2 yamt /* Floating point set flags. */
2576 1.1.1.2.2.2 yamt executable_code code;
2577 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2578 1.1.1.2.2.2 yamt
2579 1.1.1.2.2.2 yamt sljit_w buf[16];
2580 1.1.1.2.2.2 yamt union {
2581 1.1.1.2.2.2 yamt double value;
2582 1.1.1.2.2.2 yamt struct {
2583 1.1.1.2.2.2 yamt int value1;
2584 1.1.1.2.2.2 yamt int value2;
2585 1.1.1.2.2.2 yamt } u;
2586 1.1.1.2.2.2 yamt } dbuf[4];
2587 1.1.1.2.2.2 yamt
2588 1.1.1.2.2.2 yamt buf[0] = 5;
2589 1.1.1.2.2.2 yamt buf[1] = 5;
2590 1.1.1.2.2.2 yamt buf[2] = 5;
2591 1.1.1.2.2.2 yamt buf[3] = 5;
2592 1.1.1.2.2.2 yamt buf[4] = 5;
2593 1.1.1.2.2.2 yamt buf[5] = 5;
2594 1.1.1.2.2.2 yamt buf[6] = 5;
2595 1.1.1.2.2.2 yamt buf[7] = 5;
2596 1.1.1.2.2.2 yamt buf[8] = 5;
2597 1.1.1.2.2.2 yamt buf[9] = 5;
2598 1.1.1.2.2.2 yamt buf[10] = 5;
2599 1.1.1.2.2.2 yamt buf[11] = 5;
2600 1.1.1.2.2.2 yamt buf[12] = 5;
2601 1.1.1.2.2.2 yamt buf[13] = 5;
2602 1.1.1.2.2.2 yamt buf[14] = 5;
2603 1.1.1.2.2.2 yamt buf[15] = 5;
2604 1.1.1.2.2.2 yamt
2605 1.1.1.2.2.2 yamt /* Two NaNs */
2606 1.1.1.2.2.2 yamt dbuf[0].u.value1 = 0x7fffffff;
2607 1.1.1.2.2.2 yamt dbuf[0].u.value2 = 0x7fffffff;
2608 1.1.1.2.2.2 yamt dbuf[1].u.value1 = 0x7fffffff;
2609 1.1.1.2.2.2 yamt dbuf[1].u.value2 = 0x7fffffff;
2610 1.1.1.2.2.2 yamt dbuf[2].value = -13.0;
2611 1.1.1.2.2.2 yamt dbuf[3].value = 27.0;
2612 1.1.1.2.2.2 yamt
2613 1.1.1.2.2.2 yamt if (!sljit_is_fpu_available()) {
2614 1.1.1.2.2.2 yamt printf("no fpu available, test32 skipped\n");
2615 1.1.1.2.2.2 yamt successful_tests++;
2616 1.1.1.2.2.2 yamt if (compiler)
2617 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2618 1.1.1.2.2.2 yamt return;
2619 1.1.1.2.2.2 yamt }
2620 1.1.1.2.2.2 yamt
2621 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2622 1.1.1.2.2.2 yamt SLJIT_ASSERT(sizeof(double) == 8 && sizeof(int) == 4 && sizeof(dbuf[0]) == 8);
2623 1.1.1.2.2.2 yamt
2624 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 1, 2, 0);
2625 1.1.1.2.2.2 yamt
2626 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 0);
2627 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double), SLJIT_FLOAT_REG1, 0);
2628 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(double));
2629 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_C_FLOAT_UNORDERED);
2630 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_FLOAT_ORDERED);
2631 1.1.1.2.2.2 yamt
2632 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double));
2633 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E | SLJIT_SET_S, SLJIT_FLOAT_REG2, 0, SLJIT_FLOAT_REG3, 0);
2634 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_FLOAT_UNORDERED);
2635 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_C_FLOAT_ORDERED);
2636 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS);
2637 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_C_FLOAT_GREATER_EQUAL);
2638 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_FLOAT_GREATER);
2639 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_C_FLOAT_LESS_EQUAL);
2640 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
2641 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_C_FLOAT_NOT_EQUAL);
2642 1.1.1.2.2.2 yamt
2643 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_E, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(double));
2644 1.1.1.2.2.2 yamt sljit_emit_fop2(compiler, SLJIT_FADD, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(double));
2645 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_C_FLOAT_UNORDERED);
2646 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_C_FLOAT_EQUAL);
2647 1.1.1.2.2.2 yamt
2648 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(double), SLJIT_FLOAT_REG1, 0);
2649 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_C_FLOAT_ORDERED);
2650 1.1.1.2.2.2 yamt
2651 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FCMP | SLJIT_SET_S, SLJIT_FLOAT_REG4, 0, SLJIT_FLOAT_REG3, 0);
2652 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 0);
2653 1.1.1.2.2.2 yamt cond_set(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_C_FLOAT_UNORDERED);
2654 1.1.1.2.2.2 yamt
2655 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2656 1.1.1.2.2.2 yamt
2657 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2658 1.1.1.2.2.2 yamt CHECK(compiler);
2659 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2660 1.1.1.2.2.2 yamt
2661 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, (sljit_w)&dbuf);
2662 1.1.1.2.2.2 yamt
2663 1.1.1.2.2.2 yamt FAILED(buf[0] != 1, "test32 case 1 failed\n");
2664 1.1.1.2.2.2 yamt FAILED(buf[1] != 2, "test32 case 2 failed\n");
2665 1.1.1.2.2.2 yamt FAILED(buf[2] != 2, "test32 case 3 failed\n");
2666 1.1.1.2.2.2 yamt FAILED(buf[3] != 1, "test32 case 4 failed\n");
2667 1.1.1.2.2.2 yamt FAILED(buf[4] != 1, "test32 case 5 failed\n");
2668 1.1.1.2.2.2 yamt FAILED(buf[5] != 2, "test32 case 6 failed\n");
2669 1.1.1.2.2.2 yamt FAILED(buf[6] != 2, "test32 case 7 failed\n");
2670 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test32 case 8 failed\n");
2671 1.1.1.2.2.2 yamt FAILED(buf[8] != 2, "test32 case 9 failed\n");
2672 1.1.1.2.2.2 yamt FAILED(buf[9] != 1, "test32 case 10 failed\n");
2673 1.1.1.2.2.2 yamt FAILED(buf[10] != 2, "test32 case 11 failed\n");
2674 1.1.1.2.2.2 yamt FAILED(buf[11] != 1, "test32 case 12 failed\n");
2675 1.1.1.2.2.2 yamt FAILED(buf[12] != 2, "test32 case 13 failed\n");
2676 1.1.1.2.2.2 yamt FAILED(buf[13] != 1, "test32 case 14 failed\n");
2677 1.1.1.2.2.2 yamt
2678 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2679 1.1.1.2.2.2 yamt printf("test32 ok\n");
2680 1.1.1.2.2.2 yamt successful_tests++;
2681 1.1.1.2.2.2 yamt }
2682 1.1.1.2.2.2 yamt
2683 1.1.1.2.2.2 yamt static void test33(void)
2684 1.1.1.2.2.2 yamt {
2685 1.1.1.2.2.2 yamt /* Test keep flags. */
2686 1.1.1.2.2.2 yamt executable_code code;
2687 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2688 1.1.1.2.2.2 yamt
2689 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
2690 1.1.1.2.2.2 yamt sljit_w big_word = SLJIT_W(0x8000000000000003);
2691 1.1.1.2.2.2 yamt #else
2692 1.1.1.2.2.2 yamt sljit_w big_word = 0x80000003;
2693 1.1.1.2.2.2 yamt #endif
2694 1.1.1.2.2.2 yamt
2695 1.1.1.2.2.2 yamt sljit_w buf[12];
2696 1.1.1.2.2.2 yamt buf[0] = 3;
2697 1.1.1.2.2.2 yamt buf[1] = 3;
2698 1.1.1.2.2.2 yamt buf[2] = 3;
2699 1.1.1.2.2.2 yamt buf[3] = 3;
2700 1.1.1.2.2.2 yamt buf[4] = 3;
2701 1.1.1.2.2.2 yamt buf[5] = 3;
2702 1.1.1.2.2.2 yamt buf[6] = 3;
2703 1.1.1.2.2.2 yamt buf[7] = 3;
2704 1.1.1.2.2.2 yamt buf[8] = 3;
2705 1.1.1.2.2.2 yamt buf[9] = 3;
2706 1.1.1.2.2.2 yamt buf[10] = 3;
2707 1.1.1.2.2.2 yamt buf[11] = 3;
2708 1.1.1.2.2.2 yamt
2709 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2710 1.1.1.2.2.2 yamt
2711 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 3, 0);
2712 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, big_word);
2713 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_SET_E | SLJIT_SET_C, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, big_word);
2714 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
2715 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
2716 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
2717 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_NOT_ZERO);
2718 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2719 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2720 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADDC, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
2721 1.1.1.2.2.2 yamt
2722 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
2723 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
2724 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SHL | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
2725 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_EQUAL);
2726 1.1.1.2.2.2 yamt
2727 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_IMM, 0x124);
2728 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
2729 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
2730 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_KEEP_FLAGS, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
2731 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_C_NOT_EQUAL);
2732 1.1.1.2.2.2 yamt
2733 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
2734 1.1.1.2.2.2 yamt
2735 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
2736 1.1.1.2.2.2 yamt CHECK(compiler);
2737 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2738 1.1.1.2.2.2 yamt
2739 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
2740 1.1.1.2.2.2 yamt
2741 1.1.1.2.2.2 yamt FAILED(buf[0] != 6, "test33 case 1 failed\n");
2742 1.1.1.2.2.2 yamt FAILED(buf[1] != 1, "test33 case 2 failed\n");
2743 1.1.1.2.2.2 yamt FAILED(buf[2] != 8, "test33 case 3 failed\n");
2744 1.1.1.2.2.2 yamt FAILED(buf[3] != 16, "test33 case 4 failed\n");
2745 1.1.1.2.2.2 yamt FAILED(buf[4] != 1, "test33 case 5 failed\n");
2746 1.1.1.2.2.2 yamt FAILED(buf[5] != 0x125, "test33 case 6 failed\n");
2747 1.1.1.2.2.2 yamt
2748 1.1.1.2.2.2 yamt sljit_free_code(code.code);
2749 1.1.1.2.2.2 yamt printf("test33 ok\n");
2750 1.1.1.2.2.2 yamt successful_tests++;
2751 1.1.1.2.2.2 yamt }
2752 1.1.1.2.2.2 yamt
2753 1.1.1.2.2.2 yamt static void test34(void)
2754 1.1.1.2.2.2 yamt {
2755 1.1.1.2.2.2 yamt /* Test fast calls. */
2756 1.1.1.2.2.2 yamt executable_code codeA;
2757 1.1.1.2.2.2 yamt executable_code codeB;
2758 1.1.1.2.2.2 yamt executable_code codeC;
2759 1.1.1.2.2.2 yamt executable_code codeD;
2760 1.1.1.2.2.2 yamt executable_code codeE;
2761 1.1.1.2.2.2 yamt executable_code codeF;
2762 1.1.1.2.2.2 yamt struct sljit_compiler* compiler;
2763 1.1.1.2.2.2 yamt struct sljit_jump *jump;
2764 1.1.1.2.2.2 yamt struct sljit_label* label;
2765 1.1.1.2.2.2 yamt sljit_uw addr;
2766 1.1.1.2.2.2 yamt
2767 1.1.1.2.2.2 yamt sljit_w buf[2];
2768 1.1.1.2.2.2 yamt buf[0] = 0;
2769 1.1.1.2.2.2 yamt buf[1] = 0;
2770 1.1.1.2.2.2 yamt
2771 1.1.1.2.2.2 yamt /* A */
2772 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2773 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2774 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2775 1.1.1.2.2.2 yamt
2776 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_TEMPORARY_REG2, 0);
2777 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
2778 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_TEMPORARY_REG2, 0);
2779 1.1.1.2.2.2 yamt
2780 1.1.1.2.2.2 yamt codeA.code = sljit_generate_code(compiler);
2781 1.1.1.2.2.2 yamt CHECK(compiler);
2782 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2783 1.1.1.2.2.2 yamt
2784 1.1.1.2.2.2 yamt /* B */
2785 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2786 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2787 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2788 1.1.1.2.2.2 yamt
2789 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_TEMPORARY_EREG2, 0);
2790 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 6);
2791 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeA.code));
2792 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_TEMPORARY_REG2, 0);
2793 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_TEMPORARY_EREG2, 0);
2794 1.1.1.2.2.2 yamt
2795 1.1.1.2.2.2 yamt codeB.code = sljit_generate_code(compiler);
2796 1.1.1.2.2.2 yamt CHECK(compiler);
2797 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2798 1.1.1.2.2.2 yamt
2799 1.1.1.2.2.2 yamt /* C */
2800 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2801 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2802 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2803 1.1.1.2.2.2 yamt
2804 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
2805 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
2806 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_FAST_CALL);
2807 1.1.1.2.2.2 yamt sljit_set_target(jump, SLJIT_FUNC_OFFSET(codeB.code));
2808 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_w));
2809 1.1.1.2.2.2 yamt
2810 1.1.1.2.2.2 yamt codeC.code = sljit_generate_code(compiler);
2811 1.1.1.2.2.2 yamt CHECK(compiler);
2812 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2813 1.1.1.2.2.2 yamt
2814 1.1.1.2.2.2 yamt /* D */
2815 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2816 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2817 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2818 1.1.1.2.2.2 yamt
2819 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
2820 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 10);
2821 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeC.code));
2822 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
2823 1.1.1.2.2.2 yamt
2824 1.1.1.2.2.2 yamt codeD.code = sljit_generate_code(compiler);
2825 1.1.1.2.2.2 yamt CHECK(compiler);
2826 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2827 1.1.1.2.2.2 yamt
2828 1.1.1.2.2.2 yamt /* E */
2829 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2830 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2831 1.1.1.2.2.2 yamt sljit_set_context(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2832 1.1.1.2.2.2 yamt
2833 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2834 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 12);
2835 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_IMM, SLJIT_FUNC_OFFSET(codeD.code));
2836 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w));
2837 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
2838 1.1.1.2.2.2 yamt
2839 1.1.1.2.2.2 yamt codeE.code = sljit_generate_code(compiler);
2840 1.1.1.2.2.2 yamt CHECK(compiler);
2841 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2842 1.1.1.2.2.2 yamt
2843 1.1.1.2.2.2 yamt /* F */
2844 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2845 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2846 1.1.1.2.2.2 yamt
2847 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 2 * sizeof(sljit_w));
2848 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2849 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeE.code));
2850 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
2851 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
2852 1.1.1.2.2.2 yamt
2853 1.1.1.2.2.2 yamt codeF.code = sljit_generate_code(compiler);
2854 1.1.1.2.2.2 yamt CHECK(compiler);
2855 1.1.1.2.2.2 yamt addr = sljit_get_label_addr(label);
2856 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2857 1.1.1.2.2.2 yamt
2858 1.1.1.2.2.2 yamt FAILED(codeF.func1((sljit_w)&buf) != 40, "test34 case 1 failed\n");
2859 1.1.1.2.2.2 yamt FAILED(buf[0] != addr - SLJIT_RETURN_ADDRESS_OFFSET, "test34 case 2 failed\n");
2860 1.1.1.2.2.2 yamt
2861 1.1.1.2.2.2 yamt sljit_free_code(codeA.code);
2862 1.1.1.2.2.2 yamt sljit_free_code(codeB.code);
2863 1.1.1.2.2.2 yamt sljit_free_code(codeC.code);
2864 1.1.1.2.2.2 yamt sljit_free_code(codeD.code);
2865 1.1.1.2.2.2 yamt sljit_free_code(codeE.code);
2866 1.1.1.2.2.2 yamt sljit_free_code(codeF.code);
2867 1.1.1.2.2.2 yamt
2868 1.1.1.2.2.2 yamt printf("test34 ok\n");
2869 1.1.1.2.2.2 yamt successful_tests++;
2870 1.1.1.2.2.2 yamt }
2871 1.1.1.2.2.2 yamt
2872 1.1.1.2.2.2 yamt static void test35(void)
2873 1.1.1.2.2.2 yamt {
2874 1.1.1.2.2.2 yamt /* More complicated tests for fast calls. */
2875 1.1.1.2.2.2 yamt executable_code codeA;
2876 1.1.1.2.2.2 yamt executable_code codeB;
2877 1.1.1.2.2.2 yamt executable_code codeC;
2878 1.1.1.2.2.2 yamt struct sljit_compiler* compiler;
2879 1.1.1.2.2.2 yamt struct sljit_jump *jump;
2880 1.1.1.2.2.2 yamt struct sljit_label* label;
2881 1.1.1.2.2.2 yamt sljit_uw return_addr, jump_addr;
2882 1.1.1.2.2.2 yamt
2883 1.1.1.2.2.2 yamt sljit_w buf[1];
2884 1.1.1.2.2.2 yamt buf[0] = 0;
2885 1.1.1.2.2.2 yamt
2886 1.1.1.2.2.2 yamt /* A */
2887 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2888 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2889 1.1.1.2.2.2 yamt sljit_set_context(compiler, 0, 2, 2, 0);
2890 1.1.1.2.2.2 yamt
2891 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_MEM0(), (sljit_w)&buf[0]);
2892 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
2893 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_REWRITABLE_JUMP | SLJIT_FAST_CALL);
2894 1.1.1.2.2.2 yamt sljit_set_target(jump, 0);
2895 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
2896 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_MEM0(), (sljit_w)&buf[0]);
2897 1.1.1.2.2.2 yamt
2898 1.1.1.2.2.2 yamt codeA.code = sljit_generate_code(compiler);
2899 1.1.1.2.2.2 yamt CHECK(compiler);
2900 1.1.1.2.2.2 yamt return_addr = sljit_get_label_addr(label) - SLJIT_RETURN_ADDRESS_OFFSET;
2901 1.1.1.2.2.2 yamt jump_addr = sljit_get_jump_addr(jump);
2902 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2903 1.1.1.2.2.2 yamt
2904 1.1.1.2.2.2 yamt /* B */
2905 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2906 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2907 1.1.1.2.2.2 yamt sljit_set_context(compiler, 0, 2, 2, 0);
2908 1.1.1.2.2.2 yamt
2909 1.1.1.2.2.2 yamt sljit_emit_fast_enter(compiler, SLJIT_UNUSED, 0);
2910 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 7);
2911 1.1.1.2.2.2 yamt sljit_emit_fast_return(compiler, SLJIT_IMM, return_addr);
2912 1.1.1.2.2.2 yamt
2913 1.1.1.2.2.2 yamt codeB.code = sljit_generate_code(compiler);
2914 1.1.1.2.2.2 yamt CHECK(compiler);
2915 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2916 1.1.1.2.2.2 yamt sljit_set_jump_addr(jump_addr, SLJIT_FUNC_OFFSET(codeB.code));
2917 1.1.1.2.2.2 yamt
2918 1.1.1.2.2.2 yamt /* C */
2919 1.1.1.2.2.2 yamt compiler = sljit_create_compiler();
2920 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2921 1.1.1.2.2.2 yamt
2922 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 0, 2, 2, 0);
2923 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
2924 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_FAST_CALL, SLJIT_IMM, SLJIT_FUNC_OFFSET(codeA.code));
2925 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
2926 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0);
2927 1.1.1.2.2.2 yamt
2928 1.1.1.2.2.2 yamt codeC.code = sljit_generate_code(compiler);
2929 1.1.1.2.2.2 yamt CHECK(compiler);
2930 1.1.1.2.2.2 yamt return_addr = sljit_get_label_addr(label);
2931 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
2932 1.1.1.2.2.2 yamt
2933 1.1.1.2.2.2 yamt FAILED(codeC.func0() != 12, "test35 case 1 failed\n");
2934 1.1.1.2.2.2 yamt FAILED(buf[0] != return_addr - SLJIT_RETURN_ADDRESS_OFFSET, "test35 case 2 failed\n");
2935 1.1.1.2.2.2 yamt
2936 1.1.1.2.2.2 yamt sljit_free_code(codeA.code);
2937 1.1.1.2.2.2 yamt sljit_free_code(codeB.code);
2938 1.1.1.2.2.2 yamt sljit_free_code(codeC.code);
2939 1.1.1.2.2.2 yamt
2940 1.1.1.2.2.2 yamt printf("test35 ok\n");
2941 1.1.1.2.2.2 yamt successful_tests++;
2942 1.1.1.2.2.2 yamt }
2943 1.1.1.2.2.2 yamt
2944 1.1.1.2.2.2 yamt static int cmp_test(struct sljit_compiler *compiler, int type, int src1, sljit_w src1w, int src2, sljit_w src2w)
2945 1.1.1.2.2.2 yamt {
2946 1.1.1.2.2.2 yamt /* 2 = true, 1 = false */
2947 1.1.1.2.2.2 yamt struct sljit_jump* jump;
2948 1.1.1.2.2.2 yamt struct sljit_label* label;
2949 1.1.1.2.2.2 yamt
2950 1.1.1.2.2.2 yamt if (sljit_emit_op1(compiler, SLJIT_MOVU_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 1, SLJIT_IMM, 2))
2951 1.1.1.2.2.2 yamt return compiler->error;
2952 1.1.1.2.2.2 yamt jump = sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w);
2953 1.1.1.2.2.2 yamt if (!jump)
2954 1.1.1.2.2.2 yamt return compiler->error;
2955 1.1.1.2.2.2 yamt if (sljit_emit_op1(compiler, SLJIT_MOV_UB, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_IMM, 1))
2956 1.1.1.2.2.2 yamt return compiler->error;
2957 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
2958 1.1.1.2.2.2 yamt if (!label)
2959 1.1.1.2.2.2 yamt return compiler->error;
2960 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
2961 1.1.1.2.2.2 yamt return SLJIT_SUCCESS;
2962 1.1.1.2.2.2 yamt }
2963 1.1.1.2.2.2 yamt
2964 1.1.1.2.2.2 yamt #define TEST_CASES (7 + 10 + 12 + 11 + 4)
2965 1.1.1.2.2.2 yamt static void test36(void)
2966 1.1.1.2.2.2 yamt {
2967 1.1.1.2.2.2 yamt /* Compare instruction. */
2968 1.1.1.2.2.2 yamt executable_code code;
2969 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
2970 1.1.1.2.2.2 yamt
2971 1.1.1.2.2.2 yamt sljit_b buf[TEST_CASES];
2972 1.1.1.2.2.2 yamt sljit_b compare_buf[TEST_CASES] = {
2973 1.1.1.2.2.2 yamt 1, 1, 2, 2, 1, 2, 2,
2974 1.1.1.2.2.2 yamt 1, 1, 2, 2, 2, 1, 2, 2, 1, 1,
2975 1.1.1.2.2.2 yamt 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2,
2976 1.1.1.2.2.2 yamt 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2,
2977 1.1.1.2.2.2 yamt 2, 1, 1, 2
2978 1.1.1.2.2.2 yamt };
2979 1.1.1.2.2.2 yamt sljit_w data[4];
2980 1.1.1.2.2.2 yamt int i;
2981 1.1.1.2.2.2 yamt
2982 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
2983 1.1.1.2.2.2 yamt for (i = 0; i < TEST_CASES; ++i)
2984 1.1.1.2.2.2 yamt buf[i] = 100;
2985 1.1.1.2.2.2 yamt data[0] = 32;
2986 1.1.1.2.2.2 yamt data[1] = -9;
2987 1.1.1.2.2.2 yamt data[2] = 43;
2988 1.1.1.2.2.2 yamt data[3] = -13;
2989 1.1.1.2.2.2 yamt
2990 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 2, 0);
2991 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, 1);
2992 1.1.1.2.2.2 yamt
2993 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 13);
2994 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 15);
2995 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_IMM, 9, SLJIT_TEMPORARY_REG1, 0);
2996 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
2997 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 3);
2998 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_IMM, -13);
2999 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_NOT_EQUAL, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG1, 0);
3000 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3001 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_NOT_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG1, 0);
3002 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_EQUAL, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT, SLJIT_MEM2(SLJIT_SAVED_REG2, SLJIT_TEMPORARY_REG1), SLJIT_WORD_SHIFT);
3003 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3004 1.1.1.2.2.2 yamt
3005 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, 0);
3006 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -8);
3007 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
3008 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3009 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3010 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3011 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
3012 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w));
3013 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_IMM, 0, SLJIT_TEMPORARY_REG2, 0);
3014 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 2 * sizeof(sljit_w));
3015 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
3016 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
3017 1.1.1.2.2.2 yamt
3018 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
3019 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
3020 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(sljit_w));
3021 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
3022 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -10);
3023 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8);
3024 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER_EQUAL, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
3025 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER_EQUAL | SLJIT_REWRITABLE_JUMP, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
3026 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER, SLJIT_IMM, 8, SLJIT_TEMPORARY_REG2, 0);
3027 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS_EQUAL, SLJIT_IMM, 7, SLJIT_TEMPORARY_REG1, 0);
3028 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER, SLJIT_IMM, 1, SLJIT_MEM1(SLJIT_SAVED_REG2), 3 * sizeof(sljit_w));
3029 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3030 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3031 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3032 1.1.1.2.2.2 yamt
3033 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -3);
3034 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3035 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3036 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
3037 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
3038 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -1);
3039 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_REWRITABLE_JUMP, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_IMM, -1);
3040 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3041 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3042 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_IMM, -4, SLJIT_TEMPORARY_REG1, 0);
3043 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_IMM, -1, SLJIT_TEMPORARY_REG2, 0);
3044 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_REWRITABLE_JUMP, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, -1);
3045 1.1.1.2.2.2 yamt
3046 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3047 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xf00000004));
3048 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3049 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3050 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xff0000004));
3051 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3052 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3053 1.1.1.2.2.2 yamt #else
3054 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 4);
3055 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3056 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3057 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xf0000004);
3058 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_GREATER | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3059 1.1.1.2.2.2 yamt cmp_test(compiler, SLJIT_C_SIG_LESS | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 5);
3060 1.1.1.2.2.2 yamt #endif
3061 1.1.1.2.2.2 yamt
3062 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
3063 1.1.1.2.2.2 yamt
3064 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3065 1.1.1.2.2.2 yamt CHECK(compiler);
3066 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3067 1.1.1.2.2.2 yamt
3068 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, (sljit_w)&data);
3069 1.1.1.2.2.2 yamt
3070 1.1.1.2.2.2 yamt for (i = 0; i < TEST_CASES; ++i)
3071 1.1.1.2.2.2 yamt if (SLJIT_UNLIKELY(buf[i] != compare_buf[i])) {
3072 1.1.1.2.2.2 yamt printf("test36 case %d failed\n", i + 1);
3073 1.1.1.2.2.2 yamt return;
3074 1.1.1.2.2.2 yamt }
3075 1.1.1.2.2.2 yamt sljit_free_code(code.code);
3076 1.1.1.2.2.2 yamt
3077 1.1.1.2.2.2 yamt printf("test36 ok\n");
3078 1.1.1.2.2.2 yamt successful_tests++;
3079 1.1.1.2.2.2 yamt }
3080 1.1.1.2.2.2 yamt #undef TEST_CASES
3081 1.1.1.2.2.2 yamt
3082 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3083 1.1.1.2.2.2 yamt #define BITN(n) (SLJIT_W(1) << (63 - (n)))
3084 1.1.1.2.2.2 yamt #define RESN(n) (n)
3085 1.1.1.2.2.2 yamt #else
3086 1.1.1.2.2.2 yamt #define BITN(n) (1 << (31 - ((n) & 0x1f)))
3087 1.1.1.2.2.2 yamt #define RESN(n) ((n) & 0x1f)
3088 1.1.1.2.2.2 yamt #endif
3089 1.1.1.2.2.2 yamt
3090 1.1.1.2.2.2 yamt static void test37(void)
3091 1.1.1.2.2.2 yamt {
3092 1.1.1.2.2.2 yamt /* Test count leading zeroes. */
3093 1.1.1.2.2.2 yamt executable_code code;
3094 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3095 1.1.1.2.2.2 yamt sljit_w buf[15];
3096 1.1.1.2.2.2 yamt int ibuf[2];
3097 1.1.1.2.2.2 yamt int i;
3098 1.1.1.2.2.2 yamt
3099 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3100 1.1.1.2.2.2 yamt
3101 1.1.1.2.2.2 yamt for (i = 0; i < 15; i++)
3102 1.1.1.2.2.2 yamt buf[i] = -1;
3103 1.1.1.2.2.2 yamt buf[3] = 0;
3104 1.1.1.2.2.2 yamt buf[7] = BITN(13);
3105 1.1.1.2.2.2 yamt ibuf[0] = -1;
3106 1.1.1.2.2.2 yamt ibuf[1] = -1;
3107 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 1, 2, 0);
3108 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(27));
3109 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
3110 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(47));
3111 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3112 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_C_ZERO);
3113 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w));
3114 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
3115 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
3116 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_C_ZERO);
3117 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3118 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3119 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG2), 0, SLJIT_TEMPORARY_REG1, 0);
3120 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -1);
3121 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0);
3122 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_C_ZERO);
3123 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_KEEP_FLAGS, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w));
3124 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3125 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_C_NOT_ZERO);
3126 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, BITN(58));
3127 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3128 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w));
3129 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_C_NOT_ZERO);
3130 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0);
3131 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3132 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3133 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xff08a00000));
3134 1.1.1.2.2.2 yamt #else
3135 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x08a00000);
3136 1.1.1.2.2.2 yamt #endif
3137 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_MEM1(SLJIT_SAVED_REG2), sizeof(int), SLJIT_TEMPORARY_REG1, 0);
3138 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
3139 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3140 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3141 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0xffc8a00000));
3142 1.1.1.2.2.2 yamt #else
3143 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xc8a00000);
3144 1.1.1.2.2.2 yamt #endif
3145 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E | SLJIT_INT_OP, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0);
3146 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_C_ZERO);
3147 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_CLZ | SLJIT_SET_E | SLJIT_INT_OP, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
3148 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3149 1.1.1.2.2.2 yamt
3150 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
3151 1.1.1.2.2.2 yamt
3152 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3153 1.1.1.2.2.2 yamt CHECK(compiler);
3154 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3155 1.1.1.2.2.2 yamt
3156 1.1.1.2.2.2 yamt code.func2((sljit_w)&buf, (sljit_w)&ibuf);
3157 1.1.1.2.2.2 yamt FAILED(buf[0] != RESN(27), "test37 case 1 failed\n");
3158 1.1.1.2.2.2 yamt FAILED(buf[1] != RESN(47), "test37 case 2 failed\n");
3159 1.1.1.2.2.2 yamt FAILED(buf[2] != 0, "test37 case 3 failed\n");
3160 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3161 1.1.1.2.2.2 yamt FAILED(buf[3] != 64, "test37 case 4 failed\n");
3162 1.1.1.2.2.2 yamt #else
3163 1.1.1.2.2.2 yamt FAILED(buf[3] != 32, "test37 case 4 failed\n");
3164 1.1.1.2.2.2 yamt #endif
3165 1.1.1.2.2.2 yamt FAILED(buf[4] != 1, "test37 case 5 failed\n");
3166 1.1.1.2.2.2 yamt FAILED(buf[5] != 0, "test37 case 6 failed\n");
3167 1.1.1.2.2.2 yamt FAILED(ibuf[0] != 32, "test37 case 7 failed\n");
3168 1.1.1.2.2.2 yamt FAILED(buf[6] != 1, "test37 case 8 failed\n");
3169 1.1.1.2.2.2 yamt FAILED(buf[7] != RESN(13), "test37 case 9 failed\n");
3170 1.1.1.2.2.2 yamt #if !(defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3171 1.1.1.2.2.2 yamt FAILED(buf[8] != 0, "test37 case 10 failed\n");
3172 1.1.1.2.2.2 yamt #endif
3173 1.1.1.2.2.2 yamt FAILED(buf[9] != RESN(58), "test37 case 11 failed\n");
3174 1.1.1.2.2.2 yamt FAILED(buf[10] != 0, "test37 case 12 failed\n");
3175 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3176 1.1.1.2.2.2 yamt FAILED(buf[11] != 64, "test37 case 13 failed\n");
3177 1.1.1.2.2.2 yamt #else
3178 1.1.1.2.2.2 yamt FAILED(buf[11] != 32, "test37 case 13 failed\n");
3179 1.1.1.2.2.2 yamt #endif
3180 1.1.1.2.2.2 yamt FAILED(ibuf[1] != 4, "test37 case 14 failed\n");
3181 1.1.1.2.2.2 yamt FAILED(buf[12] != 4, "test37 case 15 failed\n");
3182 1.1.1.2.2.2 yamt FAILED(buf[13] != 1, "test37 case 16 failed\n");
3183 1.1.1.2.2.2 yamt FAILED(buf[14] != 0, "test37 case 17 failed\n");
3184 1.1.1.2.2.2 yamt
3185 1.1.1.2.2.2 yamt sljit_free_code(code.code);
3186 1.1.1.2.2.2 yamt printf("test37 ok\n");
3187 1.1.1.2.2.2 yamt successful_tests++;
3188 1.1.1.2.2.2 yamt }
3189 1.1.1.2.2.2 yamt #undef BITN
3190 1.1.1.2.2.2 yamt #undef RESN
3191 1.1.1.2.2.2 yamt
3192 1.1.1.2.2.2 yamt static void test38(void)
3193 1.1.1.2.2.2 yamt {
3194 1.1.1.2.2.2 yamt #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
3195 1.1.1.2.2.2 yamt /* Test stack utility. */
3196 1.1.1.2.2.2 yamt executable_code code;
3197 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3198 1.1.1.2.2.2 yamt struct sljit_jump* alloc_fail;
3199 1.1.1.2.2.2 yamt struct sljit_jump* alloc2_fail;
3200 1.1.1.2.2.2 yamt struct sljit_jump* alloc3_fail;
3201 1.1.1.2.2.2 yamt struct sljit_jump* jump;
3202 1.1.1.2.2.2 yamt struct sljit_label* label;
3203 1.1.1.2.2.2 yamt
3204 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3205 1.1.1.2.2.2 yamt
3206 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 0, 2, 1, 0);
3207 1.1.1.2.2.2 yamt
3208 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8192);
3209 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 65536);
3210 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_allocate_stack));
3211 1.1.1.2.2.2 yamt alloc_fail = sljit_emit_cmp(compiler, SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
3212 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_RETURN_REG, 0);
3213 1.1.1.2.2.2 yamt
3214 1.1.1.2.2.2 yamt /* Write 8k data. */
3215 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
3216 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 8192);
3217 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
3218 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
3219 1.1.1.2.2.2 yamt jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3220 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
3221 1.1.1.2.2.2 yamt
3222 1.1.1.2.2.2 yamt /* Grow stack. */
3223 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
3224 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, 65536);
3225 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize));
3226 1.1.1.2.2.2 yamt alloc2_fail = sljit_emit_cmp(compiler, SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
3227 1.1.1.2.2.2 yamt
3228 1.1.1.2.2.2 yamt /* Write 64k data. */
3229 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
3230 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 65536);
3231 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
3232 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
3233 1.1.1.2.2.2 yamt jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3234 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
3235 1.1.1.2.2.2 yamt
3236 1.1.1.2.2.2 yamt /* Shrink stack. */
3237 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
3238 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, 32768);
3239 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize));
3240 1.1.1.2.2.2 yamt alloc3_fail = sljit_emit_cmp(compiler, SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
3241 1.1.1.2.2.2 yamt
3242 1.1.1.2.2.2 yamt /* Write 32k data. */
3243 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, base), SLJIT_IMM, sizeof(sljit_w));
3244 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(struct sljit_stack, limit), SLJIT_IMM, sizeof(sljit_w));
3245 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
3246 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), sizeof(sljit_w), SLJIT_IMM, -1);
3247 1.1.1.2.2.2 yamt jump = sljit_emit_cmp(compiler, SLJIT_C_LESS, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3248 1.1.1.2.2.2 yamt sljit_set_label(jump, label);
3249 1.1.1.2.2.2 yamt
3250 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_SAVED_REG1, 0);
3251 1.1.1.2.2.2 yamt sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_free_stack));
3252 1.1.1.2.2.2 yamt
3253 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
3254 1.1.1.2.2.2 yamt label = sljit_emit_label(compiler);
3255 1.1.1.2.2.2 yamt sljit_set_label(alloc_fail, label);
3256 1.1.1.2.2.2 yamt sljit_set_label(alloc2_fail, label);
3257 1.1.1.2.2.2 yamt sljit_set_label(alloc3_fail, label);
3258 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
3259 1.1.1.2.2.2 yamt
3260 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3261 1.1.1.2.2.2 yamt CHECK(compiler);
3262 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3263 1.1.1.2.2.2 yamt
3264 1.1.1.2.2.2 yamt /* Just survive this. */
3265 1.1.1.2.2.2 yamt FAILED(code.func0() != 1, "test38 case 1 failed\n");
3266 1.1.1.2.2.2 yamt sljit_free_code(code.code);
3267 1.1.1.2.2.2 yamt #endif
3268 1.1.1.2.2.2 yamt printf("test38 ok\n");
3269 1.1.1.2.2.2 yamt successful_tests++;
3270 1.1.1.2.2.2 yamt }
3271 1.1.1.2.2.2 yamt
3272 1.1.1.2.2.2 yamt static void test39(void)
3273 1.1.1.2.2.2 yamt {
3274 1.1.1.2.2.2 yamt /* Test error handling. */
3275 1.1.1.2.2.2 yamt executable_code code;
3276 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3277 1.1.1.2.2.2 yamt struct sljit_jump* jump;
3278 1.1.1.2.2.2 yamt
3279 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3280 1.1.1.2.2.2 yamt
3281 1.1.1.2.2.2 yamt /* Such assignment should never happen in a regular program. */
3282 1.1.1.2.2.2 yamt compiler->error = -3967;
3283 1.1.1.2.2.2 yamt
3284 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_enter(compiler, 2, 5, 5, 32) == -3967);
3285 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_return(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0) == -3967);
3286 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_op0(compiler, SLJIT_NOP) == -3967);
3287 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_TEMPORARY_REG2), 1) == -3967);
3288 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_op2(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 64, SLJIT_MEM1(SLJIT_SAVED_REG1), -64) == -3967);
3289 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_fop1(compiler, SLJIT_FABS, SLJIT_FLOAT_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0) == -3967);
3290 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_fop2(compiler, SLJIT_FDIV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM2(SLJIT_TEMPORARY_REG1, SLJIT_SAVED_REG1), 0, SLJIT_FLOAT_REG3, 0) == -3967);
3291 1.1.1.2.2.2 yamt SLJIT_ASSERT(!sljit_emit_label(compiler));
3292 1.1.1.2.2.2 yamt jump = sljit_emit_jump(compiler, SLJIT_CALL3);
3293 1.1.1.2.2.2 yamt SLJIT_ASSERT(!jump);
3294 1.1.1.2.2.2 yamt sljit_set_label(jump, (struct sljit_label*)0x123450);
3295 1.1.1.2.2.2 yamt sljit_set_target(jump, 0x123450);
3296 1.1.1.2.2.2 yamt jump = sljit_emit_cmp(compiler, SLJIT_C_SIG_LESS_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3297 1.1.1.2.2.2 yamt SLJIT_ASSERT(!jump);
3298 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), 8) == -3967);
3299 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_C_MUL_OVERFLOW) == -3967);
3300 1.1.1.2.2.2 yamt SLJIT_ASSERT(!sljit_emit_const(compiler, SLJIT_TEMPORARY_REG1, 0, 99));
3301 1.1.1.2.2.2 yamt
3302 1.1.1.2.2.2 yamt SLJIT_ASSERT(!compiler->labels && !compiler->jumps && !compiler->consts);
3303 1.1.1.2.2.2 yamt SLJIT_ASSERT(!compiler->last_label && !compiler->last_jump && !compiler->last_const);
3304 1.1.1.2.2.2 yamt SLJIT_ASSERT(!compiler->buf->next && !compiler->buf->used_size);
3305 1.1.1.2.2.2 yamt SLJIT_ASSERT(!compiler->abuf->next && !compiler->abuf->used_size);
3306 1.1.1.2.2.2 yamt
3307 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3308 1.1.1.2.2.2 yamt SLJIT_ASSERT(!code.code && sljit_get_compiler_error(compiler) == -3967);
3309 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3310 1.1.1.2.2.2 yamt
3311 1.1.1.2.2.2 yamt printf("test39 ok\n");
3312 1.1.1.2.2.2 yamt successful_tests++;
3313 1.1.1.2.2.2 yamt }
3314 1.1.1.2.2.2 yamt
3315 1.1.1.2.2.2 yamt static void test40(void)
3316 1.1.1.2.2.2 yamt {
3317 1.1.1.2.2.2 yamt /* Test emit_cond_value. */
3318 1.1.1.2.2.2 yamt executable_code code;
3319 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3320 1.1.1.2.2.2 yamt sljit_w buf[9];
3321 1.1.1.2.2.2 yamt
3322 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3323 1.1.1.2.2.2 yamt buf[0] = -100;
3324 1.1.1.2.2.2 yamt buf[1] = -100;
3325 1.1.1.2.2.2 yamt buf[2] = -100;
3326 1.1.1.2.2.2 yamt buf[3] = -8;
3327 1.1.1.2.2.2 yamt buf[4] = -100;
3328 1.1.1.2.2.2 yamt buf[5] = -100;
3329 1.1.1.2.2.2 yamt buf[6] = 0;
3330 1.1.1.2.2.2 yamt buf[7] = 0;
3331 1.1.1.2.2.2 yamt buf[8] = -100;
3332 1.1.1.2.2.2 yamt
3333 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 3, 4, sizeof(sljit_w));
3334 1.1.1.2.2.2 yamt
3335 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -5);
3336 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_IMM, -6, SLJIT_TEMPORARY_REG1, 0);
3337 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x123456);
3338 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_TEMPORARY_REG2, 0, SLJIT_C_SIG_LESS);
3339 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG2, 0);
3340 1.1.1.2.2.2 yamt
3341 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -13);
3342 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, -13, SLJIT_TEMPORARY_REG1, 0);
3343 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_IMM, 0);
3344 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_C_EQUAL);
3345 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_C_EQUAL);
3346 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
3347 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
3348 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_C_EQUAL);
3349 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 2, SLJIT_C_EQUAL);
3350 1.1.1.2.2.2 yamt
3351 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -13);
3352 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 3);
3353 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_S, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3354 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG2), SLJIT_WORD_SHIFT, SLJIT_C_SIG_LESS);
3355 1.1.1.2.2.2 yamt
3356 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -8);
3357 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 33);
3358 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG2, 0);
3359 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0);
3360 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_C_GREATER);
3361 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_SAVED_REG2, 0, SLJIT_C_EQUAL);
3362 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x88);
3363 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_KEEP_FLAGS, SLJIT_SAVED_EREG1, 0, SLJIT_C_NOT_EQUAL);
3364 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 4, SLJIT_SAVED_REG2, 0);
3365 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 5, SLJIT_SAVED_EREG1, 0);
3366 1.1.1.2.2.2 yamt
3367 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x84);
3368 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_IMM, 0x180, SLJIT_TEMPORARY_REG1, 0);
3369 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 6, SLJIT_C_EQUAL);
3370 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 7, SLJIT_C_EQUAL);
3371 1.1.1.2.2.2 yamt
3372 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
3373 1.1.1.2.2.2 yamt sljit_emit_op2(compiler, SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 1);
3374 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_OR | SLJIT_SET_E, SLJIT_TEMPORARY_REG1, 0, SLJIT_C_NOT_EQUAL);
3375 1.1.1.2.2.2 yamt sljit_emit_cond_value(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w) * 8, SLJIT_C_NOT_EQUAL);
3376 1.1.1.2.2.2 yamt
3377 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0, SLJIT_IMM, 0xbaddead);
3378 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), 0);
3379 1.1.1.2.2.2 yamt
3380 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3381 1.1.1.2.2.2 yamt CHECK(compiler);
3382 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3383 1.1.1.2.2.2 yamt
3384 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&buf) != 0xbaddead, "test40 case 1 failed\n");
3385 1.1.1.2.2.2 yamt FAILED(buf[0] != 0x123457, "test40 case 2 failed\n");
3386 1.1.1.2.2.2 yamt FAILED(buf[1] != 1, "test40 case 3 failed\n");
3387 1.1.1.2.2.2 yamt FAILED(buf[2] != 0, "test40 case 4 failed\n");
3388 1.1.1.2.2.2 yamt FAILED(buf[3] != -7, "test40 case 5 failed\n");
3389 1.1.1.2.2.2 yamt FAILED(buf[4] != 0, "test40 case 6 failed\n");
3390 1.1.1.2.2.2 yamt FAILED(buf[5] != 0x89, "test40 case 7 failed\n");
3391 1.1.1.2.2.2 yamt FAILED(buf[6] != 0, "test40 case 8 failed\n");
3392 1.1.1.2.2.2 yamt FAILED(buf[7] != 1, "test40 case 9 failed\n");
3393 1.1.1.2.2.2 yamt FAILED(buf[8] != 1, "test40 case 10 failed\n");
3394 1.1.1.2.2.2 yamt
3395 1.1.1.2.2.2 yamt printf("test40 ok\n");
3396 1.1.1.2.2.2 yamt successful_tests++;
3397 1.1.1.2.2.2 yamt }
3398 1.1.1.2.2.2 yamt
3399 1.1.1.2.2.2 yamt static void test41(void)
3400 1.1.1.2.2.2 yamt {
3401 1.1.1.2.2.2 yamt /* Test inline assembly. */
3402 1.1.1.2.2.2 yamt executable_code code;
3403 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3404 1.1.1.2.2.2 yamt int i;
3405 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3406 1.1.1.2.2.2 yamt sljit_ub inst[16];
3407 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3408 1.1.1.2.2.2 yamt sljit_ub inst[16];
3409 1.1.1.2.2.2 yamt int reg;
3410 1.1.1.2.2.2 yamt #else
3411 1.1.1.2.2.2 yamt sljit_ui inst;
3412 1.1.1.2.2.2 yamt #endif
3413 1.1.1.2.2.2 yamt
3414 1.1.1.2.2.2 yamt for (i = 1; i <= SLJIT_NO_REGISTERS; i++) {
3415 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3416 1.1.1.2.2.2 yamt if (i == SLJIT_TEMPORARY_EREG1 || i == SLJIT_TEMPORARY_EREG2
3417 1.1.1.2.2.2 yamt || i == SLJIT_SAVED_EREG1 || i == SLJIT_SAVED_EREG2) {
3418 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_get_register_index(i) == -1);
3419 1.1.1.2.2.2 yamt continue;
3420 1.1.1.2.2.2 yamt }
3421 1.1.1.2.2.2 yamt #endif
3422 1.1.1.2.2.2 yamt SLJIT_ASSERT(sljit_get_register_index(i) >= 0 && sljit_get_register_index(i) < 32);
3423 1.1.1.2.2.2 yamt }
3424 1.1.1.2.2.2 yamt
3425 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3426 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 2, 3, 3, 0);
3427 1.1.1.2.2.2 yamt
3428 1.1.1.2.2.2 yamt /* Returns with the sum of SLJIT_SAVED_REG1 and SLJIT_SAVED_REG2. */
3429 1.1.1.2.2.2 yamt #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
3430 1.1.1.2.2.2 yamt /* lea SLJIT_RETURN_REG, [SLJIT_SAVED_REG1, SLJIT_SAVED_REG2] */
3431 1.1.1.2.2.2 yamt inst[0] = 0x48;
3432 1.1.1.2.2.2 yamt inst[1] = 0x8d;
3433 1.1.1.2.2.2 yamt inst[2] = 0x04 | ((sljit_get_register_index(SLJIT_RETURN_REG) & 0x7) << 3);
3434 1.1.1.2.2.2 yamt inst[3] = (sljit_get_register_index(SLJIT_SAVED_REG1) & 0x7)
3435 1.1.1.2.2.2 yamt | ((sljit_get_register_index(SLJIT_SAVED_REG2) & 0x7) << 3);
3436 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, inst, 4);
3437 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
3438 1.1.1.2.2.2 yamt /* lea SLJIT_RETURN_REG, [SLJIT_SAVED_REG1, SLJIT_SAVED_REG2] */
3439 1.1.1.2.2.2 yamt inst[0] = 0x48; /* REX_W */
3440 1.1.1.2.2.2 yamt inst[1] = 0x8d;
3441 1.1.1.2.2.2 yamt inst[2] = 0x04;
3442 1.1.1.2.2.2 yamt reg = sljit_get_register_index(SLJIT_RETURN_REG);
3443 1.1.1.2.2.2 yamt inst[2] |= ((reg & 0x7) << 3);
3444 1.1.1.2.2.2 yamt if (reg > 7)
3445 1.1.1.2.2.2 yamt inst[0] |= 0x04; /* REX_R */
3446 1.1.1.2.2.2 yamt reg = sljit_get_register_index(SLJIT_SAVED_REG1);
3447 1.1.1.2.2.2 yamt inst[3] = reg & 0x7;
3448 1.1.1.2.2.2 yamt if (reg > 7)
3449 1.1.1.2.2.2 yamt inst[0] |= 0x01; /* REX_B */
3450 1.1.1.2.2.2 yamt reg = sljit_get_register_index(SLJIT_SAVED_REG2);
3451 1.1.1.2.2.2 yamt inst[3] |= (reg & 0x7) << 3;
3452 1.1.1.2.2.2 yamt if (reg > 7)
3453 1.1.1.2.2.2 yamt inst[0] |= 0x02; /* REX_X */
3454 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, inst, 4);
3455 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
3456 1.1.1.2.2.2 yamt /* add rd, rn, rm */
3457 1.1.1.2.2.2 yamt inst = 0xe0800000 | (sljit_get_register_index(SLJIT_RETURN_REG) << 12)
3458 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
3459 1.1.1.2.2.2 yamt | sljit_get_register_index(SLJIT_SAVED_REG2);
3460 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
3461 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
3462 1.1.1.2.2.2 yamt /* add rd, rn, rm */
3463 1.1.1.2.2.2 yamt inst = 0xeb000000 | (sljit_get_register_index(SLJIT_RETURN_REG) << 8)
3464 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
3465 1.1.1.2.2.2 yamt | sljit_get_register_index(SLJIT_SAVED_REG2);
3466 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
3467 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
3468 1.1.1.2.2.2 yamt /* add rD, rA, rB */
3469 1.1.1.2.2.2 yamt inst = (31 << 26) | (266 << 1) | (sljit_get_register_index(SLJIT_RETURN_REG) << 21)
3470 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG1) << 16)
3471 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG2) << 11);
3472 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
3473 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
3474 1.1.1.2.2.2 yamt /* addu rd, rs, rt */
3475 1.1.1.2.2.2 yamt inst = 33 | (sljit_get_register_index(SLJIT_RETURN_REG) << 11)
3476 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG1) << 21)
3477 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG2) << 16);
3478 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
3479 1.1.1.2.2.2 yamt #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
3480 1.1.1.2.2.2 yamt /* add rd, rs1, rs2 */
3481 1.1.1.2.2.2 yamt inst = (0x2 << 30) | (sljit_get_register_index(SLJIT_RETURN_REG) << 25)
3482 1.1.1.2.2.2 yamt | (sljit_get_register_index(SLJIT_SAVED_REG1) << 14)
3483 1.1.1.2.2.2 yamt | sljit_get_register_index(SLJIT_SAVED_REG2);
3484 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, sizeof(sljit_ui));
3485 1.1.1.2.2.2 yamt #else
3486 1.1.1.2.2.2 yamt inst = 0;
3487 1.1.1.2.2.2 yamt sljit_emit_op_custom(compiler, &inst, 0);
3488 1.1.1.2.2.2 yamt #endif
3489 1.1.1.2.2.2 yamt
3490 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
3491 1.1.1.2.2.2 yamt
3492 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3493 1.1.1.2.2.2 yamt CHECK(compiler);
3494 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3495 1.1.1.2.2.2 yamt
3496 1.1.1.2.2.2 yamt FAILED(code.func2(32, -11) != 21, "test41 case 1 failed\n");
3497 1.1.1.2.2.2 yamt FAILED(code.func2(1000, 234) != 1234, "test41 case 2 failed\n");
3498 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3499 1.1.1.2.2.2 yamt FAILED(code.func2(SLJIT_W(0x20f0a04090c06070), SLJIT_W(0x020f0a04090c0607)) != SLJIT_W(0x22ffaa4499cc6677), "test41 case 3 failed\n");
3500 1.1.1.2.2.2 yamt #endif
3501 1.1.1.2.2.2 yamt
3502 1.1.1.2.2.2 yamt printf("test41 ok\n");
3503 1.1.1.2.2.2 yamt successful_tests++;
3504 1.1.1.2.2.2 yamt }
3505 1.1.1.2.2.2 yamt
3506 1.1.1.2.2.2 yamt static void test42(void)
3507 1.1.1.2.2.2 yamt {
3508 1.1.1.2.2.2 yamt /* Test long multiply and division. */
3509 1.1.1.2.2.2 yamt executable_code code;
3510 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3511 1.1.1.2.2.2 yamt int i;
3512 1.1.1.2.2.2 yamt sljit_w buf[7 + 8 + 4];
3513 1.1.1.2.2.2 yamt
3514 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3515 1.1.1.2.2.2 yamt for (i = 0; i < 7 + 8; i++)
3516 1.1.1.2.2.2 yamt buf[i] = -1;
3517 1.1.1.2.2.2 yamt
3518 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 5, 5, 0);
3519 1.1.1.2.2.2 yamt
3520 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, -0x1fb308a);
3521 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG1, 0, SLJIT_IMM, 0xf50c873);
3522 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_EREG2, 0, SLJIT_IMM, 0x8a0475b);
3523 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG2, 0, SLJIT_IMM, 0x9dc849b);
3524 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_IMM, -0x7c69a35);
3525 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG1, 0, SLJIT_IMM, 0x5a4d0c4);
3526 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_SAVED_EREG2, 0, SLJIT_IMM, 0x9a3b06d);
3527 1.1.1.2.2.2 yamt
3528 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3529 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
3530 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
3531 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UMUL);
3532 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3533 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3534 1.1.1.2.2.2 yamt
3535 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
3536 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
3537 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SMUL);
3538 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3539 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3540 1.1.1.2.2.2 yamt
3541 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
3542 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
3543 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UDIV);
3544 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3545 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3546 1.1.1.2.2.2 yamt
3547 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(-0x5dc4f897b8cd67f5));
3548 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3f8b5c026cb088df));
3549 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SDIV);
3550 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3551 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3552 1.1.1.2.2.2 yamt
3553 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x5cf783d3cf0a74b0));
3554 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x3d5df42d03a28fc7));
3555 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UDIV | SLJIT_INT_OP);
3556 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
3557 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_UI, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
3558 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 15 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3559 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 16 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3560 1.1.1.2.2.2 yamt
3561 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, SLJIT_W(0x371df5197ba26a28));
3562 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, SLJIT_W(0x46c78a5cfd6a420c));
3563 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SDIV | SLJIT_INT_OP);
3564 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG1, 0, SLJIT_TEMPORARY_REG1, 0);
3565 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV_SI, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0);
3566 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 17 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3567 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 18 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3568 1.1.1.2.2.2 yamt
3569 1.1.1.2.2.2 yamt #else
3570 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
3571 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
3572 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UMUL);
3573 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 7 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3574 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 8 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3575 1.1.1.2.2.2 yamt
3576 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
3577 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
3578 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SMUL);
3579 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 9 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3580 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 10 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3581 1.1.1.2.2.2 yamt
3582 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
3583 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
3584 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UDIV);
3585 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 11 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3586 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 12 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3587 1.1.1.2.2.2 yamt
3588 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, -0x58cd67f5);
3589 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x3cb088df);
3590 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SDIV);
3591 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 13 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3592 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 14 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3593 1.1.1.2.2.2 yamt
3594 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0xcf0a74b0);
3595 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0x03a28fc7);
3596 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_UDIV | SLJIT_INT_OP);
3597 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 15 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3598 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 16 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3599 1.1.1.2.2.2 yamt
3600 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0x7ba26a28);
3601 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, (sljit_w)0xfd6a420c);
3602 1.1.1.2.2.2 yamt sljit_emit_op0(compiler, SLJIT_SDIV | SLJIT_INT_OP);
3603 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 17 * sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);
3604 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 18 * sizeof(sljit_w), SLJIT_TEMPORARY_REG2, 0);
3605 1.1.1.2.2.2 yamt #endif
3606 1.1.1.2.2.2 yamt
3607 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG3, 0);
3608 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), sizeof(sljit_w), SLJIT_TEMPORARY_EREG1, 0);
3609 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 2 * sizeof(sljit_w), SLJIT_TEMPORARY_EREG2, 0);
3610 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(sljit_w), SLJIT_SAVED_REG2, 0);
3611 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 4 * sizeof(sljit_w), SLJIT_SAVED_REG3, 0);
3612 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 5 * sizeof(sljit_w), SLJIT_SAVED_EREG1, 0);
3613 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_MEM1(SLJIT_SAVED_REG1), 6 * sizeof(sljit_w), SLJIT_SAVED_EREG2, 0);
3614 1.1.1.2.2.2 yamt
3615 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_UNUSED, 0, 0);
3616 1.1.1.2.2.2 yamt
3617 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3618 1.1.1.2.2.2 yamt CHECK(compiler);
3619 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3620 1.1.1.2.2.2 yamt
3621 1.1.1.2.2.2 yamt code.func1((sljit_w)&buf);
3622 1.1.1.2.2.2 yamt
3623 1.1.1.2.2.2 yamt FAILED(buf[0] != -0x1fb308a, "test42 case 1 failed\n");
3624 1.1.1.2.2.2 yamt FAILED(buf[1] != 0xf50c873, "test42 case 2 failed\n");
3625 1.1.1.2.2.2 yamt FAILED(buf[2] != 0x8a0475b, "test42 case 3 failed\n");
3626 1.1.1.2.2.2 yamt FAILED(buf[3] != 0x9dc849b, "test42 case 4 failed\n");
3627 1.1.1.2.2.2 yamt FAILED(buf[4] != -0x7c69a35, "test42 case 5 failed\n");
3628 1.1.1.2.2.2 yamt FAILED(buf[5] != 0x5a4d0c4, "test42 case 6 failed\n");
3629 1.1.1.2.2.2 yamt FAILED(buf[6] != 0x9a3b06d, "test42 case 7 failed\n");
3630 1.1.1.2.2.2 yamt
3631 1.1.1.2.2.2 yamt #if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
3632 1.1.1.2.2.2 yamt FAILED(buf[7] != SLJIT_W(-4388959407985636971), "test42 case 8 failed\n");
3633 1.1.1.2.2.2 yamt FAILED(buf[8] != SLJIT_W(2901680654366567099), "test42 case 9 failed\n");
3634 1.1.1.2.2.2 yamt FAILED(buf[9] != SLJIT_W(-4388959407985636971), "test42 case 10 failed\n");
3635 1.1.1.2.2.2 yamt FAILED(buf[10] != SLJIT_W(-1677173957268872740), "test42 case 11 failed\n");
3636 1.1.1.2.2.2 yamt FAILED(buf[11] != SLJIT_W(2), "test42 case 12 failed\n");
3637 1.1.1.2.2.2 yamt FAILED(buf[12] != SLJIT_W(2532236178951865933), "test42 case 13 failed\n");
3638 1.1.1.2.2.2 yamt FAILED(buf[13] != SLJIT_W(-1), "test42 case 14 failed\n");
3639 1.1.1.2.2.2 yamt FAILED(buf[14] != SLJIT_W(-2177944059851366166), "test42 case 15 failed\n");
3640 1.1.1.2.2.2 yamt #else
3641 1.1.1.2.2.2 yamt FAILED(buf[7] != -1587000939, "test42 case 8 failed\n");
3642 1.1.1.2.2.2 yamt FAILED(buf[8] != 665003983, "test42 case 9 failed\n");
3643 1.1.1.2.2.2 yamt FAILED(buf[9] != -1587000939, "test42 case 10 failed\n");
3644 1.1.1.2.2.2 yamt FAILED(buf[10] != -353198352, "test42 case 11 failed\n");
3645 1.1.1.2.2.2 yamt FAILED(buf[11] != 2, "test42 case 12 failed\n");
3646 1.1.1.2.2.2 yamt FAILED(buf[12] != 768706125, "test42 case 13 failed\n");
3647 1.1.1.2.2.2 yamt FAILED(buf[13] != -1, "test42 case 14 failed\n");
3648 1.1.1.2.2.2 yamt FAILED(buf[14] != -471654166, "test42 case 15 failed\n");
3649 1.1.1.2.2.2 yamt #endif
3650 1.1.1.2.2.2 yamt
3651 1.1.1.2.2.2 yamt FAILED(buf[15] != SLJIT_W(56), "test42 case 16 failed\n");
3652 1.1.1.2.2.2 yamt FAILED(buf[16] != SLJIT_W(58392872), "test42 case 17 failed\n");
3653 1.1.1.2.2.2 yamt FAILED(buf[17] != SLJIT_W(-47), "test42 case 18 failed\n");
3654 1.1.1.2.2.2 yamt FAILED(buf[18] != SLJIT_W(35949148), "test42 case 19 failed\n");
3655 1.1.1.2.2.2 yamt printf("test42 ok\n");
3656 1.1.1.2.2.2 yamt successful_tests++;
3657 1.1.1.2.2.2 yamt }
3658 1.1.1.2.2.2 yamt
3659 1.1.1.2.2.2 yamt static void test43(void)
3660 1.1.1.2.2.2 yamt {
3661 1.1.1.2.2.2 yamt /* Test floating point compare. */
3662 1.1.1.2.2.2 yamt executable_code code;
3663 1.1.1.2.2.2 yamt struct sljit_compiler* compiler = sljit_create_compiler();
3664 1.1.1.2.2.2 yamt struct sljit_jump* jump;
3665 1.1.1.2.2.2 yamt
3666 1.1.1.2.2.2 yamt union {
3667 1.1.1.2.2.2 yamt double value;
3668 1.1.1.2.2.2 yamt struct {
3669 1.1.1.2.2.2 yamt int value1;
3670 1.1.1.2.2.2 yamt int value2;
3671 1.1.1.2.2.2 yamt } u;
3672 1.1.1.2.2.2 yamt } dbuf[4];
3673 1.1.1.2.2.2 yamt
3674 1.1.1.2.2.2 yamt if (!sljit_is_fpu_available()) {
3675 1.1.1.2.2.2 yamt printf("no fpu available, test43 skipped\n");
3676 1.1.1.2.2.2 yamt successful_tests++;
3677 1.1.1.2.2.2 yamt if (compiler)
3678 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3679 1.1.1.2.2.2 yamt return;
3680 1.1.1.2.2.2 yamt }
3681 1.1.1.2.2.2 yamt
3682 1.1.1.2.2.2 yamt FAILED(!compiler, "cannot create compiler\n");
3683 1.1.1.2.2.2 yamt
3684 1.1.1.2.2.2 yamt dbuf[0].value = 12.125;
3685 1.1.1.2.2.2 yamt /* a NaN */
3686 1.1.1.2.2.2 yamt dbuf[1].u.value1 = 0x7fffffff;
3687 1.1.1.2.2.2 yamt dbuf[1].u.value2 = 0x7fffffff;
3688 1.1.1.2.2.2 yamt dbuf[2].value = -13.5;
3689 1.1.1.2.2.2 yamt dbuf[3].value = 12.125;
3690 1.1.1.2.2.2 yamt
3691 1.1.1.2.2.2 yamt sljit_emit_enter(compiler, 1, 1, 1, 0);
3692 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 2);
3693 1.1.1.2.2.2 yamt /* dbuf[0] < dbuf[2] -> -2 */
3694 1.1.1.2.2.2 yamt jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_MEM2(SLJIT_SAVED_REG1, SLJIT_TEMPORARY_REG1), SLJIT_FLOAT_SHIFT);
3695 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_IMM, -2);
3696 1.1.1.2.2.2 yamt
3697 1.1.1.2.2.2 yamt sljit_set_label(jump, sljit_emit_label(compiler));
3698 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0);
3699 1.1.1.2.2.2 yamt /* dbuf[0] and dbuf[1] is not NaN -> 5 */
3700 1.1.1.2.2.2 yamt jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_UNORDERED, SLJIT_MEM0(), (sljit_w)&dbuf[1], SLJIT_FLOAT_REG2, 0);
3701 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_IMM, 5);
3702 1.1.1.2.2.2 yamt
3703 1.1.1.2.2.2 yamt sljit_set_label(jump, sljit_emit_label(compiler));
3704 1.1.1.2.2.2 yamt sljit_emit_fop1(compiler, SLJIT_FMOV, SLJIT_FLOAT_REG3, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 3 * sizeof(double));
3705 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 11);
3706 1.1.1.2.2.2 yamt /* dbuf[0] == dbuf[3] -> 11 */
3707 1.1.1.2.2.2 yamt jump = sljit_emit_fcmp(compiler, SLJIT_C_FLOAT_EQUAL, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_FLOAT_REG3, 0);
3708 1.1.1.2.2.2 yamt
3709 1.1.1.2.2.2 yamt /* else -> -17 */
3710 1.1.1.2.2.2 yamt sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, -17);
3711 1.1.1.2.2.2 yamt sljit_set_label(jump, sljit_emit_label(compiler));
3712 1.1.1.2.2.2 yamt sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
3713 1.1.1.2.2.2 yamt
3714 1.1.1.2.2.2 yamt code.code = sljit_generate_code(compiler);
3715 1.1.1.2.2.2 yamt CHECK(compiler);
3716 1.1.1.2.2.2 yamt sljit_free_compiler(compiler);
3717 1.1.1.2.2.2 yamt
3718 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&dbuf) != 11, "test43 case 1 failed\n");
3719 1.1.1.2.2.2 yamt dbuf[3].value = 12;
3720 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&dbuf) != -17, "test43 case 2 failed\n");
3721 1.1.1.2.2.2 yamt dbuf[1].value = 0;
3722 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&dbuf) != 5, "test43 case 3 failed\n");
3723 1.1.1.2.2.2 yamt dbuf[2].value = 20;
3724 1.1.1.2.2.2 yamt FAILED(code.func1((sljit_w)&dbuf) != -2, "test43 case 4 failed\n");
3725 1.1.1.2.2.2 yamt
3726 1.1.1.2.2.2 yamt printf("test43 ok\n");
3727 1.1.1.2.2.2 yamt successful_tests++;
3728 1.1.1.2.2.2 yamt }
3729 1.1.1.2.2.2 yamt
3730 1.1.1.2.2.3 yamt void sljit_test(void);
3731 1.1.1.2.2.2 yamt void sljit_test(void)
3732 1.1.1.2.2.2 yamt {
3733 1.1.1.2.2.2 yamt #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
3734 1.1.1.2.2.2 yamt test_exec_allocator();
3735 1.1.1.2.2.2 yamt #endif
3736 1.1.1.2.2.2 yamt test1();
3737 1.1.1.2.2.2 yamt test2();
3738 1.1.1.2.2.2 yamt test3();
3739 1.1.1.2.2.2 yamt test4();
3740 1.1.1.2.2.2 yamt test5();
3741 1.1.1.2.2.2 yamt test6();
3742 1.1.1.2.2.2 yamt test7();
3743 1.1.1.2.2.2 yamt test8();
3744 1.1.1.2.2.2 yamt test9();
3745 1.1.1.2.2.2 yamt test10();
3746 1.1.1.2.2.2 yamt test11();
3747 1.1.1.2.2.2 yamt test12();
3748 1.1.1.2.2.2 yamt test13();
3749 1.1.1.2.2.2 yamt test14();
3750 1.1.1.2.2.2 yamt test15();
3751 1.1.1.2.2.2 yamt test16();
3752 1.1.1.2.2.2 yamt test17();
3753 1.1.1.2.2.2 yamt test18();
3754 1.1.1.2.2.2 yamt test19();
3755 1.1.1.2.2.2 yamt test20();
3756 1.1.1.2.2.2 yamt test21();
3757 1.1.1.2.2.2 yamt test22();
3758 1.1.1.2.2.2 yamt test23();
3759 1.1.1.2.2.2 yamt test24();
3760 1.1.1.2.2.2 yamt test25();
3761 1.1.1.2.2.2 yamt test26();
3762 1.1.1.2.2.2 yamt test27();
3763 1.1.1.2.2.2 yamt test28();
3764 1.1.1.2.2.2 yamt test29();
3765 1.1.1.2.2.2 yamt test30();
3766 1.1.1.2.2.2 yamt test31();
3767 1.1.1.2.2.2 yamt test32();
3768 1.1.1.2.2.2 yamt test33();
3769 1.1.1.2.2.2 yamt test34();
3770 1.1.1.2.2.2 yamt test35();
3771 1.1.1.2.2.2 yamt test36();
3772 1.1.1.2.2.2 yamt test37();
3773 1.1.1.2.2.2 yamt test38();
3774 1.1.1.2.2.2 yamt test39();
3775 1.1.1.2.2.2 yamt test40();
3776 1.1.1.2.2.2 yamt test41();
3777 1.1.1.2.2.2 yamt test42();
3778 1.1.1.2.2.2 yamt test43();
3779 1.1.1.2.2.2 yamt printf("On %s%s: ", sljit_get_platform_name(), sljit_is_fpu_available() ? " (+fpu)" : "");
3780 1.1.1.2.2.2 yamt if (successful_tests == 43)
3781 1.1.1.2.2.2 yamt printf("All tests are passed!\n");
3782 1.1.1.2.2.2 yamt else
3783 1.1.1.2.2.2 yamt printf("Successful test ratio: %d%%.\n", successful_tests * 100 / 43);
3784 1.1.1.2.2.2 yamt }
3785