3 |
|
* |
4 |
|
* Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer |
5 |
|
* |
6 |
< |
* Adaptation for Basilisk II and improvements, copyright 2000-2002 |
6 |
> |
* Adaptation for Basilisk II and improvements, copyright 2000-2005 |
7 |
|
* Gwenole Beauchesne |
8 |
|
* |
9 |
< |
* Basilisk II (C) 1997-2002 Christian Bauer |
9 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
10 |
> |
* |
11 |
> |
* Portions related to CPU detection come from linux/arch/i386/kernel/setup.c |
12 |
|
* |
13 |
|
* This program is free software; you can redistribute it and/or modify |
14 |
|
* it under the terms of the GNU General Public License as published by |
42 |
|
#define EBP_INDEX 5 |
43 |
|
#define ESI_INDEX 6 |
44 |
|
#define EDI_INDEX 7 |
45 |
+ |
#if defined(__x86_64__) |
46 |
+ |
#define R8_INDEX 8 |
47 |
+ |
#define R9_INDEX 9 |
48 |
+ |
#define R10_INDEX 10 |
49 |
+ |
#define R11_INDEX 11 |
50 |
+ |
#define R12_INDEX 12 |
51 |
+ |
#define R13_INDEX 13 |
52 |
+ |
#define R14_INDEX 14 |
53 |
+ |
#define R15_INDEX 15 |
54 |
+ |
#endif |
55 |
+ |
/* XXX this has to match X86_Reg8H_Base + 4 */ |
56 |
+ |
#define AH_INDEX (0x10+4+EAX_INDEX) |
57 |
+ |
#define CH_INDEX (0x10+4+ECX_INDEX) |
58 |
+ |
#define DH_INDEX (0x10+4+EDX_INDEX) |
59 |
+ |
#define BH_INDEX (0x10+4+EBX_INDEX) |
60 |
|
|
61 |
|
/* The register in which subroutines return an integer return value */ |
62 |
< |
#define REG_RESULT 0 |
62 |
> |
#define REG_RESULT EAX_INDEX |
63 |
|
|
64 |
|
/* The registers subroutines take their first and second argument in */ |
65 |
|
#if defined( _MSC_VER ) && !defined( USE_NORMAL_CALLING_CONVENTION ) |
66 |
|
/* Handle the _fastcall parameters of ECX and EDX */ |
67 |
< |
#define REG_PAR1 1 |
68 |
< |
#define REG_PAR2 2 |
67 |
> |
#define REG_PAR1 ECX_INDEX |
68 |
> |
#define REG_PAR2 EDX_INDEX |
69 |
> |
#elif defined(__x86_64__) |
70 |
> |
#define REG_PAR1 EDI_INDEX |
71 |
> |
#define REG_PAR2 ESI_INDEX |
72 |
|
#else |
73 |
< |
#define REG_PAR1 0 |
74 |
< |
#define REG_PAR2 2 |
73 |
> |
#define REG_PAR1 EAX_INDEX |
74 |
> |
#define REG_PAR2 EDX_INDEX |
75 |
|
#endif |
76 |
|
|
77 |
< |
/* Three registers that are not used for any of the above */ |
58 |
< |
#define REG_NOPAR1 6 |
59 |
< |
#define REG_NOPAR2 5 |
60 |
< |
#define REG_NOPAR3 3 |
61 |
< |
|
62 |
< |
#define REG_PC_PRE 0 /* The register we use for preloading regs.pc_p */ |
77 |
> |
#define REG_PC_PRE EAX_INDEX /* The register we use for preloading regs.pc_p */ |
78 |
|
#if defined( _MSC_VER ) && !defined( USE_NORMAL_CALLING_CONVENTION ) |
79 |
< |
#define REG_PC_TMP 0 |
79 |
> |
#define REG_PC_TMP EAX_INDEX |
80 |
|
#else |
81 |
< |
#define REG_PC_TMP 1 /* Another register that is not the above */ |
81 |
> |
#define REG_PC_TMP ECX_INDEX /* Another register that is not the above */ |
82 |
|
#endif |
83 |
|
|
84 |
< |
#define SHIFTCOUNT_NREG 1 /* Register that can be used for shiftcount. |
84 |
> |
#define SHIFTCOUNT_NREG ECX_INDEX /* Register that can be used for shiftcount. |
85 |
|
-1 if any reg will do */ |
86 |
< |
#define MUL_NREG1 0 /* %eax will hold the low 32 bits after a 32x32 mul */ |
87 |
< |
#define MUL_NREG2 2 /* %edx will hold the high 32 bits */ |
86 |
> |
#define MUL_NREG1 EAX_INDEX /* %eax will hold the low 32 bits after a 32x32 mul */ |
87 |
> |
#define MUL_NREG2 EDX_INDEX /* %edx will hold the high 32 bits */ |
88 |
> |
|
89 |
> |
#define STACK_ALIGN 16 |
90 |
> |
#define STACK_OFFSET sizeof(void *) |
91 |
|
|
92 |
|
uae_s8 always_used[]={4,-1}; |
93 |
+ |
#if defined(__x86_64__) |
94 |
+ |
uae_s8 can_byte[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1}; |
95 |
+ |
uae_s8 can_word[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1}; |
96 |
+ |
#else |
97 |
|
uae_s8 can_byte[]={0,1,2,3,-1}; |
98 |
|
uae_s8 can_word[]={0,1,2,3,5,6,7,-1}; |
99 |
+ |
#endif |
100 |
|
|
101 |
+ |
#if USE_OPTIMIZED_CALLS |
102 |
+ |
/* Make sure interpretive core does not use cpuopti */ |
103 |
+ |
uae_u8 call_saved[]={0,0,0,1,1,1,1,1}; |
104 |
+ |
#error FIXME: code not ready |
105 |
+ |
#else |
106 |
|
/* cpuopti mutate instruction handlers to assume registers are saved |
107 |
|
by the caller */ |
108 |
< |
uae_u8 call_saved[]={0,0,0,0,1,0,0,0}; |
108 |
> |
uae_u8 call_saved[]={0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0}; |
109 |
> |
#endif |
110 |
|
|
111 |
|
/* This *should* be the same as call_saved. But: |
112 |
|
- We might not really know which registers are saved, and which aren't, |
115 |
|
- Special registers (such like the stack pointer) should not be "preserved" |
116 |
|
by pushing, even though they are "saved" across function calls |
117 |
|
*/ |
118 |
< |
uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1}; |
118 |
> |
#if defined(__x86_64__) |
119 |
> |
/* callee-saved registers as defined by Linux AMD64 ABI: rbx, rbp, rsp, r12 - r15 */ |
120 |
> |
/* preserve r11 because it's generally used to hold pointers to functions */ |
121 |
> |
static const uae_u8 need_to_preserve[]={0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1}; |
122 |
> |
#else |
123 |
> |
/* callee-saved registers as defined by System V IA-32 ABI: edi, esi, ebx, ebp */ |
124 |
> |
static const uae_u8 need_to_preserve[]={0,0,0,1,0,1,1,1}; |
125 |
> |
#endif |
126 |
|
|
127 |
|
/* Whether classes of instructions do or don't clobber the native flags */ |
128 |
|
#define CLOBBER_MOV |
147 |
|
#define CLOBBER_TEST clobber_flags() |
148 |
|
#define CLOBBER_CL16 |
149 |
|
#define CLOBBER_CL8 |
150 |
+ |
#define CLOBBER_SE32 |
151 |
|
#define CLOBBER_SE16 |
152 |
|
#define CLOBBER_SE8 |
153 |
+ |
#define CLOBBER_ZE32 |
154 |
|
#define CLOBBER_ZE16 |
155 |
|
#define CLOBBER_ZE8 |
156 |
|
#define CLOBBER_SW16 clobber_flags() |
160 |
|
#define CLOBBER_BT clobber_flags() |
161 |
|
#define CLOBBER_BSF clobber_flags() |
162 |
|
|
163 |
+ |
/* The older code generator is now deprecated. */ |
164 |
+ |
#define USE_NEW_RTASM 1 |
165 |
+ |
|
166 |
+ |
#if USE_NEW_RTASM |
167 |
+ |
|
168 |
+ |
#if defined(__x86_64__) |
169 |
+ |
#define X86_TARGET_64BIT 1 |
170 |
+ |
/* The address override prefix causes a 5 cycles penalty on Intel Core |
171 |
+ |
processors. Another solution would be to decompose the load in an LEA, |
172 |
+ |
MOV (to zero-extend), MOV (from memory): is it better? */ |
173 |
+ |
#define ADDR32 x86_emit_byte(0x67), |
174 |
+ |
#else |
175 |
+ |
#define ADDR32 /**/ |
176 |
+ |
#endif |
177 |
+ |
#define X86_FLAT_REGISTERS 0 |
178 |
+ |
#define X86_OPTIMIZE_ALU 1 |
179 |
+ |
#define X86_OPTIMIZE_ROTSHI 1 |
180 |
+ |
#include "codegen_x86.h" |
181 |
+ |
|
182 |
+ |
#define x86_emit_byte(B) emit_byte(B) |
183 |
+ |
#define x86_emit_word(W) emit_word(W) |
184 |
+ |
#define x86_emit_long(L) emit_long(L) |
185 |
+ |
#define x86_emit_quad(Q) emit_quad(Q) |
186 |
+ |
#define x86_get_target() get_target() |
187 |
+ |
#define x86_emit_failure(MSG) jit_fail(MSG, __FILE__, __LINE__, __FUNCTION__) |
188 |
+ |
|
189 |
+ |
static void jit_fail(const char *msg, const char *file, int line, const char *function) |
190 |
+ |
{ |
191 |
+ |
fprintf(stderr, "JIT failure in function %s from file %s at line %d: %s\n", |
192 |
+ |
function, file, line, msg); |
193 |
+ |
abort(); |
194 |
+ |
} |
195 |
+ |
|
196 |
+ |
LOWFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r)) |
197 |
+ |
{ |
198 |
+ |
#if defined(__x86_64__) |
199 |
+ |
PUSHQr(r); |
200 |
+ |
#else |
201 |
+ |
PUSHLr(r); |
202 |
+ |
#endif |
203 |
+ |
} |
204 |
+ |
LENDFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r)) |
205 |
+ |
|
206 |
+ |
LOWFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) |
207 |
+ |
{ |
208 |
+ |
#if defined(__x86_64__) |
209 |
+ |
POPQr(r); |
210 |
+ |
#else |
211 |
+ |
POPLr(r); |
212 |
+ |
#endif |
213 |
+ |
} |
214 |
+ |
LENDFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) |
215 |
+ |
|
216 |
+ |
LOWFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d)) |
217 |
+ |
{ |
218 |
+ |
#if defined(__x86_64__) |
219 |
+ |
POPQm(d, X86_NOREG, X86_NOREG, 1); |
220 |
+ |
#else |
221 |
+ |
POPLm(d, X86_NOREG, X86_NOREG, 1); |
222 |
+ |
#endif |
223 |
+ |
} |
224 |
+ |
LENDFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d)) |
225 |
+ |
|
226 |
+ |
LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) |
227 |
+ |
{ |
228 |
+ |
BTLir(i, r); |
229 |
+ |
} |
230 |
+ |
LENDFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) |
231 |
+ |
|
232 |
+ |
LOWFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) |
233 |
+ |
{ |
234 |
+ |
BTLrr(b, r); |
235 |
+ |
} |
236 |
+ |
LENDFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) |
237 |
+ |
|
238 |
+ |
LOWFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) |
239 |
+ |
{ |
240 |
+ |
BTCLir(i, r); |
241 |
+ |
} |
242 |
+ |
LENDFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) |
243 |
+ |
|
244 |
+ |
LOWFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) |
245 |
+ |
{ |
246 |
+ |
BTCLrr(b, r); |
247 |
+ |
} |
248 |
+ |
LENDFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) |
249 |
+ |
|
250 |
+ |
LOWFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) |
251 |
+ |
{ |
252 |
+ |
BTRLir(i, r); |
253 |
+ |
} |
254 |
+ |
LENDFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) |
255 |
+ |
|
256 |
+ |
LOWFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) |
257 |
+ |
{ |
258 |
+ |
BTRLrr(b, r); |
259 |
+ |
} |
260 |
+ |
LENDFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) |
261 |
+ |
|
262 |
+ |
LOWFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) |
263 |
+ |
{ |
264 |
+ |
BTSLir(i, r); |
265 |
+ |
} |
266 |
+ |
LENDFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) |
267 |
+ |
|
268 |
+ |
LOWFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) |
269 |
+ |
{ |
270 |
+ |
BTSLrr(b, r); |
271 |
+ |
} |
272 |
+ |
LENDFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) |
273 |
+ |
|
274 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i)) |
275 |
+ |
{ |
276 |
+ |
SUBWir(i, d); |
277 |
+ |
} |
278 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i)) |
279 |
+ |
|
280 |
+ |
LOWFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s)) |
281 |
+ |
{ |
282 |
+ |
MOVLmr(s, X86_NOREG, X86_NOREG, 1, d); |
283 |
+ |
} |
284 |
+ |
LENDFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s)) |
285 |
+ |
|
286 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s)) |
287 |
+ |
{ |
288 |
+ |
MOVLim(s, d, X86_NOREG, X86_NOREG, 1); |
289 |
+ |
} |
290 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s)) |
291 |
+ |
|
292 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s)) |
293 |
+ |
{ |
294 |
+ |
MOVWim(s, d, X86_NOREG, X86_NOREG, 1); |
295 |
+ |
} |
296 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s)) |
297 |
+ |
|
298 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s)) |
299 |
+ |
{ |
300 |
+ |
MOVBim(s, d, X86_NOREG, X86_NOREG, 1); |
301 |
+ |
} |
302 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s)) |
303 |
+ |
|
304 |
+ |
LOWFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i)) |
305 |
+ |
{ |
306 |
+ |
ROLBim(i, d, X86_NOREG, X86_NOREG, 1); |
307 |
+ |
} |
308 |
+ |
LENDFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i)) |
309 |
+ |
|
310 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i)) |
311 |
+ |
{ |
312 |
+ |
ROLBir(i, r); |
313 |
+ |
} |
314 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i)) |
315 |
+ |
|
316 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i)) |
317 |
+ |
{ |
318 |
+ |
ROLWir(i, r); |
319 |
+ |
} |
320 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i)) |
321 |
+ |
|
322 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i)) |
323 |
+ |
{ |
324 |
+ |
ROLLir(i, r); |
325 |
+ |
} |
326 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i)) |
327 |
+ |
|
328 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r)) |
329 |
+ |
{ |
330 |
+ |
ROLLrr(r, d); |
331 |
+ |
} |
332 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r)) |
333 |
+ |
|
334 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r)) |
335 |
+ |
{ |
336 |
+ |
ROLWrr(r, d); |
337 |
+ |
} |
338 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r)) |
339 |
+ |
|
340 |
+ |
LOWFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r)) |
341 |
+ |
{ |
342 |
+ |
ROLBrr(r, d); |
343 |
+ |
} |
344 |
+ |
LENDFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r)) |
345 |
+ |
|
346 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r)) |
347 |
+ |
{ |
348 |
+ |
SHLLrr(r, d); |
349 |
+ |
} |
350 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r)) |
351 |
+ |
|
352 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r)) |
353 |
+ |
{ |
354 |
+ |
SHLWrr(r, d); |
355 |
+ |
} |
356 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r)) |
357 |
+ |
|
358 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r)) |
359 |
+ |
{ |
360 |
+ |
SHLBrr(r, d); |
361 |
+ |
} |
362 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r)) |
363 |
+ |
|
364 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i)) |
365 |
+ |
{ |
366 |
+ |
RORBir(i, r); |
367 |
+ |
} |
368 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i)) |
369 |
+ |
|
370 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i)) |
371 |
+ |
{ |
372 |
+ |
RORWir(i, r); |
373 |
+ |
} |
374 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i)) |
375 |
+ |
|
376 |
+ |
LOWFUNC(WRITE,READ,2,raw_or_l_rm,(RW4 d, MEMR s)) |
377 |
+ |
{ |
378 |
+ |
ORLmr(s, X86_NOREG, X86_NOREG, 1, d); |
379 |
+ |
} |
380 |
+ |
LENDFUNC(WRITE,READ,2,raw_or_l_rm,(RW4 d, MEMR s)) |
381 |
+ |
|
382 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i)) |
383 |
+ |
{ |
384 |
+ |
RORLir(i, r); |
385 |
+ |
} |
386 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i)) |
387 |
+ |
|
388 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r)) |
389 |
+ |
{ |
390 |
+ |
RORLrr(r, d); |
391 |
+ |
} |
392 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r)) |
393 |
+ |
|
394 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r)) |
395 |
+ |
{ |
396 |
+ |
RORWrr(r, d); |
397 |
+ |
} |
398 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r)) |
399 |
+ |
|
400 |
+ |
LOWFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r)) |
401 |
+ |
{ |
402 |
+ |
RORBrr(r, d); |
403 |
+ |
} |
404 |
+ |
LENDFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r)) |
405 |
+ |
|
406 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r)) |
407 |
+ |
{ |
408 |
+ |
SHRLrr(r, d); |
409 |
+ |
} |
410 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r)) |
411 |
+ |
|
412 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r)) |
413 |
+ |
{ |
414 |
+ |
SHRWrr(r, d); |
415 |
+ |
} |
416 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r)) |
417 |
+ |
|
418 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r)) |
419 |
+ |
{ |
420 |
+ |
SHRBrr(r, d); |
421 |
+ |
} |
422 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r)) |
423 |
+ |
|
424 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r)) |
425 |
+ |
{ |
426 |
+ |
SARLrr(r, d); |
427 |
+ |
} |
428 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r)) |
429 |
+ |
|
430 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r)) |
431 |
+ |
{ |
432 |
+ |
SARWrr(r, d); |
433 |
+ |
} |
434 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r)) |
435 |
+ |
|
436 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r)) |
437 |
+ |
{ |
438 |
+ |
SARBrr(r, d); |
439 |
+ |
} |
440 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r)) |
441 |
+ |
|
442 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i)) |
443 |
+ |
{ |
444 |
+ |
SHLLir(i, r); |
445 |
+ |
} |
446 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i)) |
447 |
+ |
|
448 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i)) |
449 |
+ |
{ |
450 |
+ |
SHLWir(i, r); |
451 |
+ |
} |
452 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i)) |
453 |
+ |
|
454 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i)) |
455 |
+ |
{ |
456 |
+ |
SHLBir(i, r); |
457 |
+ |
} |
458 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i)) |
459 |
+ |
|
460 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i)) |
461 |
+ |
{ |
462 |
+ |
SHRLir(i, r); |
463 |
+ |
} |
464 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i)) |
465 |
+ |
|
466 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i)) |
467 |
+ |
{ |
468 |
+ |
SHRWir(i, r); |
469 |
+ |
} |
470 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i)) |
471 |
+ |
|
472 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i)) |
473 |
+ |
{ |
474 |
+ |
SHRBir(i, r); |
475 |
+ |
} |
476 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i)) |
477 |
+ |
|
478 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i)) |
479 |
+ |
{ |
480 |
+ |
SARLir(i, r); |
481 |
+ |
} |
482 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i)) |
483 |
+ |
|
484 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i)) |
485 |
+ |
{ |
486 |
+ |
SARWir(i, r); |
487 |
+ |
} |
488 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i)) |
489 |
+ |
|
490 |
+ |
LOWFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i)) |
491 |
+ |
{ |
492 |
+ |
SARBir(i, r); |
493 |
+ |
} |
494 |
+ |
LENDFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i)) |
495 |
+ |
|
496 |
+ |
LOWFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah)) |
497 |
+ |
{ |
498 |
+ |
SAHF(); |
499 |
+ |
} |
500 |
+ |
LENDFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah)) |
501 |
+ |
|
502 |
+ |
LOWFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax)) |
503 |
+ |
{ |
504 |
+ |
CPUID(); |
505 |
+ |
} |
506 |
+ |
LENDFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax)) |
507 |
+ |
|
508 |
+ |
LOWFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah)) |
509 |
+ |
{ |
510 |
+ |
LAHF(); |
511 |
+ |
} |
512 |
+ |
LENDFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah)) |
513 |
+ |
|
514 |
+ |
LOWFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc)) |
515 |
+ |
{ |
516 |
+ |
SETCCir(cc, d); |
517 |
+ |
} |
518 |
+ |
LENDFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc)) |
519 |
+ |
|
520 |
+ |
LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) |
521 |
+ |
{ |
522 |
+ |
SETCCim(cc, d, X86_NOREG, X86_NOREG, 1); |
523 |
+ |
} |
524 |
+ |
LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) |
525 |
+ |
|
526 |
+ |
LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) |
527 |
+ |
{ |
528 |
+ |
if (have_cmov) |
529 |
+ |
CMOVLrr(cc, s, d); |
530 |
+ |
else { /* replacement using branch and mov */ |
531 |
+ |
int8 *target_p = (int8 *)x86_get_target() + 1; |
532 |
+ |
JCCSii(cc^1, 0); |
533 |
+ |
MOVLrr(s, d); |
534 |
+ |
*target_p = (uintptr)x86_get_target() - ((uintptr)target_p + 1); |
535 |
+ |
} |
536 |
+ |
} |
537 |
+ |
LENDFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) |
538 |
+ |
|
539 |
+ |
LOWFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s)) |
540 |
+ |
{ |
541 |
+ |
BSFLrr(s, d); |
542 |
+ |
} |
543 |
+ |
LENDFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s)) |
544 |
+ |
|
545 |
+ |
LOWFUNC(NONE,NONE,2,raw_sign_extend_32_rr,(W4 d, R4 s)) |
546 |
+ |
{ |
547 |
+ |
MOVSLQrr(s, d); |
548 |
+ |
} |
549 |
+ |
LENDFUNC(NONE,NONE,2,raw_sign_extend_32_rr,(W4 d, R4 s)) |
550 |
+ |
|
551 |
+ |
LOWFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s)) |
552 |
+ |
{ |
553 |
+ |
MOVSWLrr(s, d); |
554 |
+ |
} |
555 |
+ |
LENDFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s)) |
556 |
+ |
|
557 |
+ |
LOWFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s)) |
558 |
+ |
{ |
559 |
+ |
MOVSBLrr(s, d); |
560 |
+ |
} |
561 |
+ |
LENDFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s)) |
562 |
+ |
|
563 |
+ |
LOWFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s)) |
564 |
+ |
{ |
565 |
+ |
MOVZWLrr(s, d); |
566 |
+ |
} |
567 |
+ |
LENDFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s)) |
568 |
+ |
|
569 |
+ |
LOWFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s)) |
570 |
+ |
{ |
571 |
+ |
MOVZBLrr(s, d); |
572 |
+ |
} |
573 |
+ |
LENDFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s)) |
574 |
+ |
|
575 |
+ |
LOWFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s)) |
576 |
+ |
{ |
577 |
+ |
IMULLrr(s, d); |
578 |
+ |
} |
579 |
+ |
LENDFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s)) |
580 |
+ |
|
581 |
+ |
LOWFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s)) |
582 |
+ |
{ |
583 |
+ |
if (d!=MUL_NREG1 || s!=MUL_NREG2) { |
584 |
+ |
write_log("Bad register in IMUL: d=%d, s=%d\n",d,s); |
585 |
+ |
abort(); |
586 |
+ |
} |
587 |
+ |
IMULLr(s); |
588 |
+ |
} |
589 |
+ |
LENDFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s)) |
590 |
+ |
|
591 |
+ |
LOWFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s)) |
592 |
+ |
{ |
593 |
+ |
if (d!=MUL_NREG1 || s!=MUL_NREG2) { |
594 |
+ |
write_log("Bad register in MUL: d=%d, s=%d\n",d,s); |
595 |
+ |
abort(); |
596 |
+ |
} |
597 |
+ |
MULLr(s); |
598 |
+ |
} |
599 |
+ |
LENDFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s)) |
600 |
+ |
|
601 |
+ |
LOWFUNC(NONE,NONE,2,raw_mul_32_32,(RW4 d, R4 s)) |
602 |
+ |
{ |
603 |
+ |
abort(); /* %^$&%^$%#^ x86! */ |
604 |
+ |
} |
605 |
+ |
LENDFUNC(NONE,NONE,2,raw_mul_32_32,(RW4 d, R4 s)) |
606 |
+ |
|
607 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s)) |
608 |
+ |
{ |
609 |
+ |
MOVBrr(s, d); |
610 |
+ |
} |
611 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s)) |
612 |
+ |
|
613 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) |
614 |
+ |
{ |
615 |
+ |
MOVWrr(s, d); |
616 |
+ |
} |
617 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) |
618 |
+ |
|
619 |
+ |
LOWFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor)) |
620 |
+ |
{ |
621 |
+ |
ADDR32 MOVLmr(0, baser, index, factor, d); |
622 |
+ |
} |
623 |
+ |
LENDFUNC(NONE,READ,4,raw_mov_l_rrm_indexed,(W4 d,R4 baser, R4 index, IMM factor)) |
624 |
+ |
|
625 |
+ |
LOWFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor)) |
626 |
+ |
{ |
627 |
+ |
ADDR32 MOVWmr(0, baser, index, factor, d); |
628 |
+ |
} |
629 |
+ |
LENDFUNC(NONE,READ,4,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index, IMM factor)) |
630 |
+ |
|
631 |
+ |
LOWFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor)) |
632 |
+ |
{ |
633 |
+ |
ADDR32 MOVBmr(0, baser, index, factor, d); |
634 |
+ |
} |
635 |
+ |
LENDFUNC(NONE,READ,4,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index, IMM factor)) |
636 |
+ |
|
637 |
+ |
LOWFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s)) |
638 |
+ |
{ |
639 |
+ |
ADDR32 MOVLrm(s, 0, baser, index, factor); |
640 |
+ |
} |
641 |
+ |
LENDFUNC(NONE,WRITE,4,raw_mov_l_mrr_indexed,(R4 baser, R4 index, IMM factor, R4 s)) |
642 |
+ |
|
643 |
+ |
LOWFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s)) |
644 |
+ |
{ |
645 |
+ |
ADDR32 MOVWrm(s, 0, baser, index, factor); |
646 |
+ |
} |
647 |
+ |
LENDFUNC(NONE,WRITE,4,raw_mov_w_mrr_indexed,(R4 baser, R4 index, IMM factor, R2 s)) |
648 |
+ |
|
649 |
+ |
LOWFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s)) |
650 |
+ |
{ |
651 |
+ |
ADDR32 MOVBrm(s, 0, baser, index, factor); |
652 |
+ |
} |
653 |
+ |
LENDFUNC(NONE,WRITE,4,raw_mov_b_mrr_indexed,(R4 baser, R4 index, IMM factor, R1 s)) |
654 |
+ |
|
655 |
+ |
LOWFUNC(NONE,WRITE,5,raw_mov_l_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R4 s)) |
656 |
+ |
{ |
657 |
+ |
ADDR32 MOVLrm(s, base, baser, index, factor); |
658 |
+ |
} |
659 |
+ |
LENDFUNC(NONE,WRITE,5,raw_mov_l_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R4 s)) |
660 |
+ |
|
661 |
+ |
LOWFUNC(NONE,WRITE,5,raw_mov_w_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R2 s)) |
662 |
+ |
{ |
663 |
+ |
ADDR32 MOVWrm(s, base, baser, index, factor); |
664 |
+ |
} |
665 |
+ |
LENDFUNC(NONE,WRITE,5,raw_mov_w_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R2 s)) |
666 |
+ |
|
667 |
+ |
LOWFUNC(NONE,WRITE,5,raw_mov_b_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R1 s)) |
668 |
+ |
{ |
669 |
+ |
ADDR32 MOVBrm(s, base, baser, index, factor); |
670 |
+ |
} |
671 |
+ |
LENDFUNC(NONE,WRITE,5,raw_mov_b_bmrr_indexed,(IMM base, R4 baser, R4 index, IMM factor, R1 s)) |
672 |
+ |
|
673 |
+ |
LOWFUNC(NONE,READ,5,raw_mov_l_brrm_indexed,(W4 d, IMM base, R4 baser, R4 index, IMM factor)) |
674 |
+ |
{ |
675 |
+ |
ADDR32 MOVLmr(base, baser, index, factor, d); |
676 |
+ |
} |
677 |
+ |
LENDFUNC(NONE,READ,5,raw_mov_l_brrm_indexed,(W4 d, IMM base, R4 baser, R4 index, IMM factor)) |
678 |
+ |
|
679 |
+ |
LOWFUNC(NONE,READ,5,raw_mov_w_brrm_indexed,(W2 d, IMM base, R4 baser, R4 index, IMM factor)) |
680 |
+ |
{ |
681 |
+ |
ADDR32 MOVWmr(base, baser, index, factor, d); |
682 |
+ |
} |
683 |
+ |
LENDFUNC(NONE,READ,5,raw_mov_w_brrm_indexed,(W2 d, IMM base, R4 baser, R4 index, IMM factor)) |
684 |
+ |
|
685 |
+ |
LOWFUNC(NONE,READ,5,raw_mov_b_brrm_indexed,(W1 d, IMM base, R4 baser, R4 index, IMM factor)) |
686 |
+ |
{ |
687 |
+ |
ADDR32 MOVBmr(base, baser, index, factor, d); |
688 |
+ |
} |
689 |
+ |
LENDFUNC(NONE,READ,5,raw_mov_b_brrm_indexed,(W1 d, IMM base, R4 baser, R4 index, IMM factor)) |
690 |
+ |
|
691 |
+ |
LOWFUNC(NONE,READ,4,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor)) |
692 |
+ |
{ |
693 |
+ |
ADDR32 MOVLmr(base, X86_NOREG, index, factor, d); |
694 |
+ |
} |
695 |
+ |
LENDFUNC(NONE,READ,4,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor)) |
696 |
+ |
|
697 |
+ |
LOWFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, IMM cond)) |
698 |
+ |
{ |
699 |
+ |
if (have_cmov) |
700 |
+ |
ADDR32 CMOVLmr(cond, base, X86_NOREG, index, factor, d); |
701 |
+ |
else { /* replacement using branch and mov */ |
702 |
+ |
int8 *target_p = (int8 *)x86_get_target() + 1; |
703 |
+ |
JCCSii(cond^1, 0); |
704 |
+ |
ADDR32 MOVLmr(base, X86_NOREG, index, factor, d); |
705 |
+ |
*target_p = (uintptr)x86_get_target() - ((uintptr)target_p + 1); |
706 |
+ |
} |
707 |
+ |
} |
708 |
+ |
LENDFUNC(NONE,READ,5,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM factor, IMM cond)) |
709 |
+ |
|
710 |
+ |
LOWFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) |
711 |
+ |
{ |
712 |
+ |
if (have_cmov) |
713 |
+ |
CMOVLmr(cond, mem, X86_NOREG, X86_NOREG, 1, d); |
714 |
+ |
else { /* replacement using branch and mov */ |
715 |
+ |
int8 *target_p = (int8 *)x86_get_target() + 1; |
716 |
+ |
JCCSii(cond^1, 0); |
717 |
+ |
MOVLmr(mem, X86_NOREG, X86_NOREG, 1, d); |
718 |
+ |
*target_p = (uintptr)x86_get_target() - ((uintptr)target_p + 1); |
719 |
+ |
} |
720 |
+ |
} |
721 |
+ |
LENDFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) |
722 |
+ |
|
723 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) |
724 |
+ |
{ |
725 |
+ |
ADDR32 MOVLmr(offset, s, X86_NOREG, 1, d); |
726 |
+ |
} |
727 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) |
728 |
+ |
|
729 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) |
730 |
+ |
{ |
731 |
+ |
ADDR32 MOVWmr(offset, s, X86_NOREG, 1, d); |
732 |
+ |
} |
733 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) |
734 |
+ |
|
735 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) |
736 |
+ |
{ |
737 |
+ |
ADDR32 MOVBmr(offset, s, X86_NOREG, 1, d); |
738 |
+ |
} |
739 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) |
740 |
+ |
|
741 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset)) |
742 |
+ |
{ |
743 |
+ |
ADDR32 MOVLmr(offset, s, X86_NOREG, 1, d); |
744 |
+ |
} |
745 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset)) |
746 |
+ |
|
747 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset)) |
748 |
+ |
{ |
749 |
+ |
ADDR32 MOVWmr(offset, s, X86_NOREG, 1, d); |
750 |
+ |
} |
751 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset)) |
752 |
+ |
|
753 |
+ |
LOWFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset)) |
754 |
+ |
{ |
755 |
+ |
ADDR32 MOVBmr(offset, s, X86_NOREG, 1, d); |
756 |
+ |
} |
757 |
+ |
LENDFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset)) |
758 |
+ |
|
759 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) |
760 |
+ |
{ |
761 |
+ |
ADDR32 MOVLim(i, offset, d, X86_NOREG, 1); |
762 |
+ |
} |
763 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) |
764 |
+ |
|
765 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) |
766 |
+ |
{ |
767 |
+ |
ADDR32 MOVWim(i, offset, d, X86_NOREG, 1); |
768 |
+ |
} |
769 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) |
770 |
+ |
|
771 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) |
772 |
+ |
{ |
773 |
+ |
ADDR32 MOVBim(i, offset, d, X86_NOREG, 1); |
774 |
+ |
} |
775 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) |
776 |
+ |
|
777 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) |
778 |
+ |
{ |
779 |
+ |
ADDR32 MOVLrm(s, offset, d, X86_NOREG, 1); |
780 |
+ |
} |
781 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) |
782 |
+ |
|
783 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) |
784 |
+ |
{ |
785 |
+ |
ADDR32 MOVWrm(s, offset, d, X86_NOREG, 1); |
786 |
+ |
} |
787 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) |
788 |
+ |
|
789 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) |
790 |
+ |
{ |
791 |
+ |
ADDR32 MOVBrm(s, offset, d, X86_NOREG, 1); |
792 |
+ |
} |
793 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) |
794 |
+ |
|
795 |
+ |
LOWFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) |
796 |
+ |
{ |
797 |
+ |
LEALmr(offset, s, X86_NOREG, 1, d); |
798 |
+ |
} |
799 |
+ |
LENDFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) |
800 |
+ |
|
801 |
+ |
LOWFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) |
802 |
+ |
{ |
803 |
+ |
LEALmr(offset, s, index, factor, d); |
804 |
+ |
} |
805 |
+ |
LENDFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) |
806 |
+ |
|
807 |
+ |
LOWFUNC(NONE,NONE,4,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index, IMM factor)) |
808 |
+ |
{ |
809 |
+ |
LEALmr(0, s, index, factor, d); |
810 |
+ |
} |
811 |
+ |
LENDFUNC(NONE,NONE,4,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index, IMM factor)) |
812 |
+ |
|
813 |
+ |
LOWFUNC(NONE,NONE,4,raw_lea_l_r_scaled,(W4 d, R4 index, IMM factor)) |
814 |
+ |
{ |
815 |
+ |
LEALmr(0, X86_NOREG, index, factor, d); |
816 |
+ |
} |
817 |
+ |
LENDFUNC(NONE,NONE,4,raw_lea_l_r_scaled,(W4 d, R4 index, IMM factor)) |
818 |
+ |
|
819 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset)) |
820 |
+ |
{ |
821 |
+ |
ADDR32 MOVLrm(s, offset, d, X86_NOREG, 1); |
822 |
+ |
} |
823 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset)) |
824 |
+ |
|
825 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset)) |
826 |
+ |
{ |
827 |
+ |
ADDR32 MOVWrm(s, offset, d, X86_NOREG, 1); |
828 |
+ |
} |
829 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset)) |
830 |
+ |
|
831 |
+ |
LOWFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset)) |
832 |
+ |
{ |
833 |
+ |
ADDR32 MOVBrm(s, offset, d, X86_NOREG, 1); |
834 |
+ |
} |
835 |
+ |
LENDFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset)) |
836 |
+ |
|
837 |
+ |
LOWFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r)) |
838 |
+ |
{ |
839 |
+ |
BSWAPLr(r); |
840 |
+ |
} |
841 |
+ |
LENDFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r)) |
842 |
+ |
|
843 |
+ |
LOWFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r)) |
844 |
+ |
{ |
845 |
+ |
ROLWir(8, r); |
846 |
+ |
} |
847 |
+ |
LENDFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r)) |
848 |
+ |
|
849 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s)) |
850 |
+ |
{ |
851 |
+ |
MOVLrr(s, d); |
852 |
+ |
} |
853 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s)) |
854 |
+ |
|
855 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s)) |
856 |
+ |
{ |
857 |
+ |
MOVLrm(s, d, X86_NOREG, X86_NOREG, 1); |
858 |
+ |
} |
859 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s)) |
860 |
+ |
|
861 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s)) |
862 |
+ |
{ |
863 |
+ |
MOVWrm(s, d, X86_NOREG, X86_NOREG, 1); |
864 |
+ |
} |
865 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s)) |
866 |
+ |
|
867 |
+ |
LOWFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s)) |
868 |
+ |
{ |
869 |
+ |
MOVWmr(s, X86_NOREG, X86_NOREG, 1, d); |
870 |
+ |
} |
871 |
+ |
LENDFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s)) |
872 |
+ |
|
873 |
+ |
LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) |
874 |
+ |
{ |
875 |
+ |
MOVBrm(s, d, X86_NOREG, X86_NOREG, 1); |
876 |
+ |
} |
877 |
+ |
LENDFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) |
878 |
+ |
|
879 |
+ |
LOWFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s)) |
880 |
+ |
{ |
881 |
+ |
MOVBmr(s, X86_NOREG, X86_NOREG, 1, d); |
882 |
+ |
} |
883 |
+ |
LENDFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s)) |
884 |
+ |
|
885 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s)) |
886 |
+ |
{ |
887 |
+ |
MOVLir(s, d); |
888 |
+ |
} |
889 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s)) |
890 |
+ |
|
891 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s)) |
892 |
+ |
{ |
893 |
+ |
MOVWir(s, d); |
894 |
+ |
} |
895 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s)) |
896 |
+ |
|
897 |
+ |
LOWFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s)) |
898 |
+ |
{ |
899 |
+ |
MOVBir(s, d); |
900 |
+ |
} |
901 |
+ |
LENDFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s)) |
902 |
+ |
|
903 |
+ |
LOWFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) |
904 |
+ |
{ |
905 |
+ |
ADCLim(s, d, X86_NOREG, X86_NOREG, 1); |
906 |
+ |
} |
907 |
+ |
LENDFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) |
908 |
+ |
|
909 |
+ |
LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) |
910 |
+ |
{ |
911 |
+ |
ADDLim(s, d, X86_NOREG, X86_NOREG, 1); |
912 |
+ |
} |
913 |
+ |
LENDFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) |
914 |
+ |
|
915 |
+ |
LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) |
916 |
+ |
{ |
917 |
+ |
ADDWim(s, d, X86_NOREG, X86_NOREG, 1); |
918 |
+ |
} |
919 |
+ |
LENDFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) |
920 |
+ |
|
921 |
+ |
LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) |
922 |
+ |
{ |
923 |
+ |
ADDBim(s, d, X86_NOREG, X86_NOREG, 1); |
924 |
+ |
} |
925 |
+ |
LENDFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) |
926 |
+ |
|
927 |
+ |
LOWFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) |
928 |
+ |
{ |
929 |
+ |
TESTLir(i, d); |
930 |
+ |
} |
931 |
+ |
LENDFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) |
932 |
+ |
|
933 |
+ |
LOWFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s)) |
934 |
+ |
{ |
935 |
+ |
TESTLrr(s, d); |
936 |
+ |
} |
937 |
+ |
LENDFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s)) |
938 |
+ |
|
939 |
+ |
LOWFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s)) |
940 |
+ |
{ |
941 |
+ |
TESTWrr(s, d); |
942 |
+ |
} |
943 |
+ |
LENDFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s)) |
944 |
+ |
|
945 |
+ |
LOWFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) |
946 |
+ |
{ |
947 |
+ |
TESTBrr(s, d); |
948 |
+ |
} |
949 |
+ |
LENDFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) |
950 |
+ |
|
951 |
+ |
LOWFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i)) |
952 |
+ |
{ |
953 |
+ |
XORLir(i, d); |
954 |
+ |
} |
955 |
+ |
LENDFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i)) |
956 |
+ |
|
957 |
+ |
LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) |
958 |
+ |
{ |
959 |
+ |
ANDLir(i, d); |
960 |
+ |
} |
961 |
+ |
LENDFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) |
962 |
+ |
|
963 |
+ |
LOWFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i)) |
964 |
+ |
{ |
965 |
+ |
ANDWir(i, d); |
966 |
+ |
} |
967 |
+ |
LENDFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i)) |
968 |
+ |
|
969 |
+ |
LOWFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s)) |
970 |
+ |
{ |
971 |
+ |
ANDLrr(s, d); |
972 |
+ |
} |
973 |
+ |
LENDFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s)) |
974 |
+ |
|
975 |
+ |
LOWFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s)) |
976 |
+ |
{ |
977 |
+ |
ANDWrr(s, d); |
978 |
+ |
} |
979 |
+ |
LENDFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s)) |
980 |
+ |
|
981 |
+ |
LOWFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s)) |
982 |
+ |
{ |
983 |
+ |
ANDBrr(s, d); |
984 |
+ |
} |
985 |
+ |
LENDFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s)) |
986 |
+ |
|
987 |
+ |
LOWFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i)) |
988 |
+ |
{ |
989 |
+ |
ORLir(i, d); |
990 |
+ |
} |
991 |
+ |
LENDFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i)) |
992 |
+ |
|
993 |
+ |
LOWFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s)) |
994 |
+ |
{ |
995 |
+ |
ORLrr(s, d); |
996 |
+ |
} |
997 |
+ |
LENDFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s)) |
998 |
+ |
|
999 |
+ |
LOWFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s)) |
1000 |
+ |
{ |
1001 |
+ |
ORWrr(s, d); |
1002 |
+ |
} |
1003 |
+ |
LENDFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s)) |
1004 |
+ |
|
1005 |
+ |
LOWFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s)) |
1006 |
+ |
{ |
1007 |
+ |
ORBrr(s, d); |
1008 |
+ |
} |
1009 |
+ |
LENDFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s)) |
1010 |
+ |
|
1011 |
+ |
LOWFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s)) |
1012 |
+ |
{ |
1013 |
+ |
ADCLrr(s, d); |
1014 |
+ |
} |
1015 |
+ |
LENDFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s)) |
1016 |
+ |
|
1017 |
+ |
LOWFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s)) |
1018 |
+ |
{ |
1019 |
+ |
ADCWrr(s, d); |
1020 |
+ |
} |
1021 |
+ |
LENDFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s)) |
1022 |
+ |
|
1023 |
+ |
LOWFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s)) |
1024 |
+ |
{ |
1025 |
+ |
ADCBrr(s, d); |
1026 |
+ |
} |
1027 |
+ |
LENDFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s)) |
1028 |
+ |
|
1029 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s)) |
1030 |
+ |
{ |
1031 |
+ |
ADDLrr(s, d); |
1032 |
+ |
} |
1033 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s)) |
1034 |
+ |
|
1035 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s)) |
1036 |
+ |
{ |
1037 |
+ |
ADDWrr(s, d); |
1038 |
+ |
} |
1039 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s)) |
1040 |
+ |
|
1041 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s)) |
1042 |
+ |
{ |
1043 |
+ |
ADDBrr(s, d); |
1044 |
+ |
} |
1045 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s)) |
1046 |
+ |
|
1047 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i)) |
1048 |
+ |
{ |
1049 |
+ |
SUBLir(i, d); |
1050 |
+ |
} |
1051 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i)) |
1052 |
+ |
|
1053 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i)) |
1054 |
+ |
{ |
1055 |
+ |
SUBBir(i, d); |
1056 |
+ |
} |
1057 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i)) |
1058 |
+ |
|
1059 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i)) |
1060 |
+ |
{ |
1061 |
+ |
ADDLir(i, d); |
1062 |
+ |
} |
1063 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i)) |
1064 |
+ |
|
1065 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i)) |
1066 |
+ |
{ |
1067 |
+ |
ADDWir(i, d); |
1068 |
+ |
} |
1069 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i)) |
1070 |
+ |
|
1071 |
+ |
LOWFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i)) |
1072 |
+ |
{ |
1073 |
+ |
ADDBir(i, d); |
1074 |
+ |
} |
1075 |
+ |
LENDFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i)) |
1076 |
+ |
|
1077 |
+ |
LOWFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s)) |
1078 |
+ |
{ |
1079 |
+ |
SBBLrr(s, d); |
1080 |
+ |
} |
1081 |
+ |
LENDFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s)) |
1082 |
+ |
|
1083 |
+ |
LOWFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s)) |
1084 |
+ |
{ |
1085 |
+ |
SBBWrr(s, d); |
1086 |
+ |
} |
1087 |
+ |
LENDFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s)) |
1088 |
+ |
|
1089 |
+ |
LOWFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s)) |
1090 |
+ |
{ |
1091 |
+ |
SBBBrr(s, d); |
1092 |
+ |
} |
1093 |
+ |
LENDFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s)) |
1094 |
+ |
|
1095 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s)) |
1096 |
+ |
{ |
1097 |
+ |
SUBLrr(s, d); |
1098 |
+ |
} |
1099 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s)) |
1100 |
+ |
|
1101 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s)) |
1102 |
+ |
{ |
1103 |
+ |
SUBWrr(s, d); |
1104 |
+ |
} |
1105 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s)) |
1106 |
+ |
|
1107 |
+ |
LOWFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s)) |
1108 |
+ |
{ |
1109 |
+ |
SUBBrr(s, d); |
1110 |
+ |
} |
1111 |
+ |
LENDFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s)) |
1112 |
+ |
|
1113 |
+ |
LOWFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s)) |
1114 |
+ |
{ |
1115 |
+ |
CMPLrr(s, d); |
1116 |
+ |
} |
1117 |
+ |
LENDFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s)) |
1118 |
+ |
|
1119 |
+ |
LOWFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i)) |
1120 |
+ |
{ |
1121 |
+ |
CMPLir(i, r); |
1122 |
+ |
} |
1123 |
+ |
LENDFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i)) |
1124 |
+ |
|
1125 |
+ |
LOWFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s)) |
1126 |
+ |
{ |
1127 |
+ |
CMPWrr(s, d); |
1128 |
+ |
} |
1129 |
+ |
LENDFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s)) |
1130 |
+ |
|
1131 |
+ |
LOWFUNC(WRITE,READ,2,raw_cmp_b_mi,(MEMR d, IMM s)) |
1132 |
+ |
{ |
1133 |
+ |
CMPBim(s, d, X86_NOREG, X86_NOREG, 1); |
1134 |
+ |
} |
1135 |
+ |
LENDFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) |
1136 |
+ |
|
1137 |
+ |
LOWFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i)) |
1138 |
+ |
{ |
1139 |
+ |
CMPBir(i, d); |
1140 |
+ |
} |
1141 |
+ |
LENDFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i)) |
1142 |
+ |
|
1143 |
+ |
LOWFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) |
1144 |
+ |
{ |
1145 |
+ |
CMPBrr(s, d); |
1146 |
+ |
} |
1147 |
+ |
LENDFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) |
1148 |
+ |
|
1149 |
+ |
LOWFUNC(WRITE,READ,4,raw_cmp_l_rm_indexed,(R4 d, IMM offset, R4 index, IMM factor)) |
1150 |
+ |
{ |
1151 |
+ |
ADDR32 CMPLmr(offset, X86_NOREG, index, factor, d); |
1152 |
+ |
} |
1153 |
+ |
LENDFUNC(WRITE,READ,4,raw_cmp_l_rm_indexed,(R4 d, IMM offset, R4 index, IMM factor)) |
1154 |
+ |
|
1155 |
+ |
LOWFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s)) |
1156 |
+ |
{ |
1157 |
+ |
XORLrr(s, d); |
1158 |
+ |
} |
1159 |
+ |
LENDFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s)) |
1160 |
+ |
|
1161 |
+ |
LOWFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s)) |
1162 |
+ |
{ |
1163 |
+ |
XORWrr(s, d); |
1164 |
+ |
} |
1165 |
+ |
LENDFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s)) |
1166 |
+ |
|
1167 |
+ |
LOWFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s)) |
1168 |
+ |
{ |
1169 |
+ |
XORBrr(s, d); |
1170 |
+ |
} |
1171 |
+ |
LENDFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s)) |
1172 |
+ |
|
1173 |
+ |
LOWFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s)) |
1174 |
+ |
{ |
1175 |
+ |
SUBLim(s, d, X86_NOREG, X86_NOREG, 1); |
1176 |
+ |
} |
1177 |
+ |
LENDFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s)) |
1178 |
+ |
|
1179 |
+ |
LOWFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) |
1180 |
+ |
{ |
1181 |
+ |
CMPLim(s, d, X86_NOREG, X86_NOREG, 1); |
1182 |
+ |
} |
1183 |
+ |
LENDFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) |
1184 |
+ |
|
1185 |
+ |
LOWFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) |
1186 |
+ |
{ |
1187 |
+ |
XCHGLrr(r2, r1); |
1188 |
+ |
} |
1189 |
+ |
LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) |
1190 |
+ |
|
1191 |
+ |
LOWFUNC(NONE,NONE,2,raw_xchg_b_rr,(RW4 r1, RW4 r2)) |
1192 |
+ |
{ |
1193 |
+ |
XCHGBrr(r2, r1); |
1194 |
+ |
} |
1195 |
+ |
LENDFUNC(NONE,NONE,2,raw_xchg_b_rr,(RW4 r1, RW4 r2)) |
1196 |
+ |
|
1197 |
+ |
LOWFUNC(READ,WRITE,0,raw_pushfl,(void)) |
1198 |
+ |
{ |
1199 |
+ |
PUSHF(); |
1200 |
+ |
} |
1201 |
+ |
LENDFUNC(READ,WRITE,0,raw_pushfl,(void)) |
1202 |
+ |
|
1203 |
+ |
LOWFUNC(WRITE,READ,0,raw_popfl,(void)) |
1204 |
+ |
{ |
1205 |
+ |
POPF(); |
1206 |
+ |
} |
1207 |
+ |
LENDFUNC(WRITE,READ,0,raw_popfl,(void)) |
1208 |
+ |
|
1209 |
+ |
/* Generate floating-point instructions */ |
1210 |
+ |
static inline void x86_fadd_m(MEMR s) |
1211 |
+ |
{ |
1212 |
+ |
FADDLm(s,X86_NOREG,X86_NOREG,1); |
1213 |
+ |
} |
1214 |
+ |
|
1215 |
+ |
#else |
1216 |
+ |
|
1217 |
|
const bool optimize_accum = true; |
1218 |
|
const bool optimize_imm8 = true; |
1219 |
|
const bool optimize_shift_once = true; |
1249 |
|
} |
1250 |
|
LENDFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) |
1251 |
|
|
1252 |
+ |
LOWFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d)) |
1253 |
+ |
{ |
1254 |
+ |
emit_byte(0x8f); |
1255 |
+ |
emit_byte(0x05); |
1256 |
+ |
emit_long(d); |
1257 |
+ |
} |
1258 |
+ |
LENDFUNC(NONE,READ,1,raw_pop_l_m,(MEMW d)) |
1259 |
+ |
|
1260 |
|
LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) |
1261 |
|
{ |
1262 |
|
emit_byte(0x0f); |
2171 |
|
|
2172 |
|
LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) |
2173 |
|
{ |
2174 |
+ |
Dif(!isbyte(offset)) abort(); |
2175 |
|
emit_byte(0x8b); |
2176 |
|
emit_byte(0x40+8*d+s); |
2177 |
|
emit_byte(offset); |
2180 |
|
|
2181 |
|
LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) |
2182 |
|
{ |
2183 |
+ |
Dif(!isbyte(offset)) abort(); |
2184 |
|
emit_byte(0x66); |
2185 |
|
emit_byte(0x8b); |
2186 |
|
emit_byte(0x40+8*d+s); |
2190 |
|
|
2191 |
|
LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) |
2192 |
|
{ |
2193 |
+ |
Dif(!isbyte(offset)) abort(); |
2194 |
|
emit_byte(0x8a); |
2195 |
|
emit_byte(0x40+8*d+s); |
2196 |
|
emit_byte(offset); |
2224 |
|
|
2225 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) |
2226 |
|
{ |
2227 |
+ |
Dif(!isbyte(offset)) abort(); |
2228 |
|
emit_byte(0xc7); |
2229 |
|
emit_byte(0x40+d); |
2230 |
|
emit_byte(offset); |
2234 |
|
|
2235 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) |
2236 |
|
{ |
2237 |
+ |
Dif(!isbyte(offset)) abort(); |
2238 |
|
emit_byte(0x66); |
2239 |
|
emit_byte(0xc7); |
2240 |
|
emit_byte(0x40+d); |
2245 |
|
|
2246 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) |
2247 |
|
{ |
2248 |
+ |
Dif(!isbyte(offset)) abort(); |
2249 |
|
emit_byte(0xc6); |
2250 |
|
emit_byte(0x40+d); |
2251 |
|
emit_byte(offset); |
2255 |
|
|
2256 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) |
2257 |
|
{ |
2258 |
+ |
Dif(!isbyte(offset)) abort(); |
2259 |
|
emit_byte(0x89); |
2260 |
|
emit_byte(0x40+8*s+d); |
2261 |
|
emit_byte(offset); |
2264 |
|
|
2265 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) |
2266 |
|
{ |
2267 |
+ |
Dif(!isbyte(offset)) abort(); |
2268 |
|
emit_byte(0x66); |
2269 |
|
emit_byte(0x89); |
2270 |
|
emit_byte(0x40+8*s+d); |
2274 |
|
|
2275 |
|
LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) |
2276 |
|
{ |
2277 |
+ |
Dif(!isbyte(offset)) abort(); |
2278 |
|
emit_byte(0x88); |
2279 |
|
emit_byte(0x40+8*s+d); |
2280 |
|
emit_byte(offset); |
2435 |
|
LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) |
2436 |
|
{ |
2437 |
|
emit_byte(0x88); |
2438 |
< |
emit_byte(0x05+8*s); |
2438 |
> |
emit_byte(0x05+8*(s&0xf)); /* XXX this handles %ah case (defined as 0x10+4) and others */ |
2439 |
|
emit_long(d); |
2440 |
|
} |
2441 |
|
LENDFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) |
2549 |
|
} |
2550 |
|
LENDFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) |
2551 |
|
|
2552 |
+ |
LOWFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i)) |
2553 |
+ |
{ |
2554 |
+ |
emit_byte(0x81); |
2555 |
+ |
emit_byte(0xf0+d); |
2556 |
+ |
emit_long(i); |
2557 |
+ |
} |
2558 |
+ |
LENDFUNC(WRITE,NONE,2,raw_xor_l_ri,(RW4 d, IMM i)) |
2559 |
+ |
|
2560 |
|
LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) |
2561 |
|
{ |
2562 |
|
if (optimize_imm8 && isbyte(i)) { |
2972 |
|
} |
2973 |
|
LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) |
2974 |
|
|
2975 |
< |
/************************************************************************* |
1859 |
< |
* FIXME: string-related instructions * |
1860 |
< |
*************************************************************************/ |
1861 |
< |
|
1862 |
< |
LOWFUNC(WRITE,NONE,0,raw_cld,(void)) |
1863 |
< |
{ |
1864 |
< |
emit_byte(0xfc); |
1865 |
< |
} |
1866 |
< |
LENDFUNC(WRITE,NONE,0,raw_cld,(void)) |
1867 |
< |
|
1868 |
< |
LOWFUNC(WRITE,NONE,0,raw_std,(void)) |
1869 |
< |
{ |
1870 |
< |
emit_byte(0xfd); |
1871 |
< |
} |
1872 |
< |
LENDFUNC(WRITE,NONE,0,raw_std,(void)) |
1873 |
< |
|
1874 |
< |
LOWFUNC(NONE,RMW,0,raw_movs_b,(void)) |
1875 |
< |
{ |
1876 |
< |
emit_byte(0xa4); |
1877 |
< |
} |
1878 |
< |
LENDFUNC(NONE,RMW,0,raw_movs_b,(void)) |
1879 |
< |
|
1880 |
< |
LOWFUNC(NONE,RMW,0,raw_movs_l,(void)) |
1881 |
< |
{ |
1882 |
< |
emit_byte(0xa5); |
1883 |
< |
} |
1884 |
< |
LENDFUNC(NONE,RMW,0,raw_movs_l,(void)) |
1885 |
< |
|
1886 |
< |
LOWFUNC(NONE,RMW,0,raw_rep,(void)) |
2975 |
> |
LOWFUNC(NONE,NONE,2,raw_xchg_b_rr,(RW4 r1, RW4 r2)) |
2976 |
|
{ |
2977 |
< |
emit_byte(0xf3); |
2977 |
> |
emit_byte(0x86); |
2978 |
> |
emit_byte(0xc0+8*(r1&0xf)+(r2&0xf)); /* XXX this handles upper-halves registers (e.g. %ah defined as 0x10+4) */ |
2979 |
|
} |
2980 |
< |
LENDFUNC(NONE,RMW,0,raw_rep,(void)) |
1891 |
< |
|
1892 |
< |
LOWFUNC(NONE,RMW,0,raw_rep_movsb,(void)) |
1893 |
< |
{ |
1894 |
< |
raw_rep(); |
1895 |
< |
raw_movs_b(); |
1896 |
< |
} |
1897 |
< |
LENDFUNC(NONE,RMW,0,raw_rep_movsb,(void)) |
1898 |
< |
|
1899 |
< |
LOWFUNC(NONE,RMW,0,raw_rep_movsl,(void)) |
1900 |
< |
{ |
1901 |
< |
raw_rep(); |
1902 |
< |
raw_movs_l(); |
1903 |
< |
} |
1904 |
< |
LENDFUNC(NONE,RMW,0,raw_rep_movsl,(void)) |
2980 |
> |
LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) |
2981 |
|
|
2982 |
|
/************************************************************************* |
2983 |
|
* FIXME: mem access modes probably wrong * |
2995 |
|
} |
2996 |
|
LENDFUNC(WRITE,READ,0,raw_popfl,(void)) |
2997 |
|
|
2998 |
+ |
/* Generate floating-point instructions */ |
2999 |
+ |
static inline void x86_fadd_m(MEMR s) |
3000 |
+ |
{ |
3001 |
+ |
emit_byte(0xdc); |
3002 |
+ |
emit_byte(0x05); |
3003 |
+ |
emit_long(s); |
3004 |
+ |
} |
3005 |
+ |
|
3006 |
+ |
#endif |
3007 |
+ |
|
3008 |
|
/************************************************************************* |
3009 |
|
* Unoptimizable stuff --- jump * |
3010 |
|
*************************************************************************/ |
3011 |
|
|
3012 |
|
static __inline__ void raw_call_r(R4 r) |
3013 |
|
{ |
3014 |
+ |
#if USE_NEW_RTASM |
3015 |
+ |
CALLsr(r); |
3016 |
+ |
#else |
3017 |
|
emit_byte(0xff); |
3018 |
|
emit_byte(0xd0+r); |
3019 |
+ |
#endif |
3020 |
|
} |
3021 |
|
|
3022 |
|
static __inline__ void raw_call_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m) |
3023 |
|
{ |
3024 |
+ |
#if USE_NEW_RTASM |
3025 |
+ |
CALLsm(base, X86_NOREG, r, m); |
3026 |
+ |
#else |
3027 |
|
int mu; |
3028 |
|
switch(m) { |
3029 |
|
case 1: mu=0; break; |
3036 |
|
emit_byte(0x14); |
3037 |
|
emit_byte(0x05+8*r+0x40*mu); |
3038 |
|
emit_long(base); |
3039 |
+ |
#endif |
3040 |
|
} |
3041 |
|
|
3042 |
|
static __inline__ void raw_jmp_r(R4 r) |
3043 |
|
{ |
3044 |
+ |
#if USE_NEW_RTASM |
3045 |
+ |
JMPsr(r); |
3046 |
+ |
#else |
3047 |
|
emit_byte(0xff); |
3048 |
|
emit_byte(0xe0+r); |
3049 |
+ |
#endif |
3050 |
|
} |
3051 |
|
|
3052 |
|
static __inline__ void raw_jmp_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m) |
3053 |
|
{ |
3054 |
+ |
#if USE_NEW_RTASM |
3055 |
+ |
JMPsm(base, X86_NOREG, r, m); |
3056 |
+ |
#else |
3057 |
|
int mu; |
3058 |
|
switch(m) { |
3059 |
|
case 1: mu=0; break; |
3066 |
|
emit_byte(0x24); |
3067 |
|
emit_byte(0x05+8*r+0x40*mu); |
3068 |
|
emit_long(base); |
3069 |
+ |
#endif |
3070 |
|
} |
3071 |
|
|
3072 |
|
static __inline__ void raw_jmp_m(uae_u32 base) |
3079 |
|
|
3080 |
|
static __inline__ void raw_call(uae_u32 t) |
3081 |
|
{ |
3082 |
+ |
#if USE_NEW_RTASM |
3083 |
+ |
CALLm(t); |
3084 |
+ |
#else |
3085 |
|
emit_byte(0xe8); |
3086 |
|
emit_long(t-(uae_u32)target-4); |
3087 |
+ |
#endif |
3088 |
|
} |
3089 |
|
|
3090 |
|
static __inline__ void raw_jmp(uae_u32 t) |
3091 |
|
{ |
3092 |
+ |
#if USE_NEW_RTASM |
3093 |
+ |
JMPm(t); |
3094 |
+ |
#else |
3095 |
|
emit_byte(0xe9); |
3096 |
|
emit_long(t-(uae_u32)target-4); |
3097 |
+ |
#endif |
3098 |
|
} |
3099 |
|
|
3100 |
|
static __inline__ void raw_jl(uae_u32 t) |
3101 |
|
{ |
3102 |
|
emit_byte(0x0f); |
3103 |
|
emit_byte(0x8c); |
3104 |
< |
emit_long(t-(uae_u32)target-4); |
3104 |
> |
emit_long(t-(uintptr)target-4); |
3105 |
|
} |
3106 |
|
|
3107 |
|
static __inline__ void raw_jz(uae_u32 t) |
3108 |
|
{ |
3109 |
|
emit_byte(0x0f); |
3110 |
|
emit_byte(0x84); |
3111 |
< |
emit_long(t-(uae_u32)target-4); |
3111 |
> |
emit_long(t-(uintptr)target-4); |
3112 |
|
} |
3113 |
|
|
3114 |
|
static __inline__ void raw_jnz(uae_u32 t) |
3115 |
|
{ |
3116 |
|
emit_byte(0x0f); |
3117 |
|
emit_byte(0x85); |
3118 |
< |
emit_long(t-(uae_u32)target-4); |
3118 |
> |
emit_long(t-(uintptr)target-4); |
3119 |
|
} |
3120 |
|
|
3121 |
|
static __inline__ void raw_jnz_l_oponly(void) |
3165 |
|
emit_byte(0x90); |
3166 |
|
} |
3167 |
|
|
3168 |
+ |
static __inline__ void raw_emit_nop_filler(int nbytes) |
3169 |
+ |
{ |
3170 |
+ |
/* Source: GNU Binutils 2.12.90.0.15 */ |
3171 |
+ |
/* Various efficient no-op patterns for aligning code labels. |
3172 |
+ |
Note: Don't try to assemble the instructions in the comments. |
3173 |
+ |
0L and 0w are not legal. */ |
3174 |
+ |
static const uae_u8 f32_1[] = |
3175 |
+ |
{0x90}; /* nop */ |
3176 |
+ |
static const uae_u8 f32_2[] = |
3177 |
+ |
{0x89,0xf6}; /* movl %esi,%esi */ |
3178 |
+ |
static const uae_u8 f32_3[] = |
3179 |
+ |
{0x8d,0x76,0x00}; /* leal 0(%esi),%esi */ |
3180 |
+ |
static const uae_u8 f32_4[] = |
3181 |
+ |
{0x8d,0x74,0x26,0x00}; /* leal 0(%esi,1),%esi */ |
3182 |
+ |
static const uae_u8 f32_5[] = |
3183 |
+ |
{0x90, /* nop */ |
3184 |
+ |
0x8d,0x74,0x26,0x00}; /* leal 0(%esi,1),%esi */ |
3185 |
+ |
static const uae_u8 f32_6[] = |
3186 |
+ |
{0x8d,0xb6,0x00,0x00,0x00,0x00}; /* leal 0L(%esi),%esi */ |
3187 |
+ |
static const uae_u8 f32_7[] = |
3188 |
+ |
{0x8d,0xb4,0x26,0x00,0x00,0x00,0x00}; /* leal 0L(%esi,1),%esi */ |
3189 |
+ |
static const uae_u8 f32_8[] = |
3190 |
+ |
{0x90, /* nop */ |
3191 |
+ |
0x8d,0xb4,0x26,0x00,0x00,0x00,0x00}; /* leal 0L(%esi,1),%esi */ |
3192 |
+ |
static const uae_u8 f32_9[] = |
3193 |
+ |
{0x89,0xf6, /* movl %esi,%esi */ |
3194 |
+ |
0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ |
3195 |
+ |
static const uae_u8 f32_10[] = |
3196 |
+ |
{0x8d,0x76,0x00, /* leal 0(%esi),%esi */ |
3197 |
+ |
0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ |
3198 |
+ |
static const uae_u8 f32_11[] = |
3199 |
+ |
{0x8d,0x74,0x26,0x00, /* leal 0(%esi,1),%esi */ |
3200 |
+ |
0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ |
3201 |
+ |
static const uae_u8 f32_12[] = |
3202 |
+ |
{0x8d,0xb6,0x00,0x00,0x00,0x00, /* leal 0L(%esi),%esi */ |
3203 |
+ |
0x8d,0xbf,0x00,0x00,0x00,0x00}; /* leal 0L(%edi),%edi */ |
3204 |
+ |
static const uae_u8 f32_13[] = |
3205 |
+ |
{0x8d,0xb6,0x00,0x00,0x00,0x00, /* leal 0L(%esi),%esi */ |
3206 |
+ |
0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ |
3207 |
+ |
static const uae_u8 f32_14[] = |
3208 |
+ |
{0x8d,0xb4,0x26,0x00,0x00,0x00,0x00, /* leal 0L(%esi,1),%esi */ |
3209 |
+ |
0x8d,0xbc,0x27,0x00,0x00,0x00,0x00}; /* leal 0L(%edi,1),%edi */ |
3210 |
+ |
static const uae_u8 f32_15[] = |
3211 |
+ |
{0xeb,0x0d,0x90,0x90,0x90,0x90,0x90, /* jmp .+15; lotsa nops */ |
3212 |
+ |
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90}; |
3213 |
+ |
static const uae_u8 f32_16[] = |
3214 |
+ |
{0xeb,0x0d,0x90,0x90,0x90,0x90,0x90, /* jmp .+15; lotsa nops */ |
3215 |
+ |
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90}; |
3216 |
+ |
static const uae_u8 *const f32_patt[] = { |
3217 |
+ |
f32_1, f32_2, f32_3, f32_4, f32_5, f32_6, f32_7, f32_8, |
3218 |
+ |
f32_9, f32_10, f32_11, f32_12, f32_13, f32_14, f32_15 |
3219 |
+ |
}; |
3220 |
+ |
static const uae_u8 prefixes[4] = { 0x66, 0x66, 0x66, 0x66 }; |
3221 |
+ |
|
3222 |
+ |
#if defined(__x86_64__) |
3223 |
+ |
/* The recommended way to pad 64bit code is to use NOPs preceded by |
3224 |
+ |
maximally four 0x66 prefixes. Balance the size of nops. */ |
3225 |
+ |
if (nbytes == 0) |
3226 |
+ |
return; |
3227 |
+ |
|
3228 |
+ |
int i; |
3229 |
+ |
int nnops = (nbytes + 3) / 4; |
3230 |
+ |
int len = nbytes / nnops; |
3231 |
+ |
int remains = nbytes - nnops * len; |
3232 |
+ |
|
3233 |
+ |
for (i = 0; i < remains; i++) { |
3234 |
+ |
emit_block(prefixes, len); |
3235 |
+ |
raw_nop(); |
3236 |
+ |
} |
3237 |
+ |
for (; i < nnops; i++) { |
3238 |
+ |
emit_block(prefixes, len - 1); |
3239 |
+ |
raw_nop(); |
3240 |
+ |
} |
3241 |
+ |
#else |
3242 |
+ |
int nloops = nbytes / 16; |
3243 |
+ |
while (nloops-- > 0) |
3244 |
+ |
emit_block(f32_16, sizeof(f32_16)); |
3245 |
+ |
|
3246 |
+ |
nbytes %= 16; |
3247 |
+ |
if (nbytes) |
3248 |
+ |
emit_block(f32_patt[nbytes - 1], nbytes); |
3249 |
+ |
#endif |
3250 |
+ |
} |
3251 |
+ |
|
3252 |
|
|
3253 |
|
/************************************************************************* |
3254 |
|
* Flag handling, to and fro UAE flag register * |
3255 |
|
*************************************************************************/ |
3256 |
|
|
3257 |
< |
#ifdef SAHF_SETO_PROFITABLE |
2064 |
< |
|
2065 |
< |
#define FLAG_NREG1 0 /* Set to -1 if any register will do */ |
2066 |
< |
|
2067 |
< |
static __inline__ void raw_flags_to_reg(int r) |
3257 |
> |
static __inline__ void raw_flags_evicted(int r) |
3258 |
|
{ |
2069 |
– |
raw_lahf(0); /* Most flags in AH */ |
2070 |
– |
//raw_setcc(r,0); /* V flag in AL */ |
2071 |
– |
raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0); |
2072 |
– |
|
2073 |
– |
#if 1 /* Let's avoid those nasty partial register stalls */ |
2074 |
– |
//raw_mov_b_mr((uae_u32)live.state[FLAGTMP].mem,r); |
2075 |
– |
raw_mov_b_mr(((uae_u32)live.state[FLAGTMP].mem)+1,r+4); |
3259 |
|
//live.state[FLAGTMP].status=CLEAN; |
3260 |
|
live.state[FLAGTMP].status=INMEM; |
3261 |
|
live.state[FLAGTMP].realreg=-1; |
3265 |
|
abort(); |
3266 |
|
} |
3267 |
|
live.nat[r].nholds=0; |
3268 |
+ |
} |
3269 |
+ |
|
3270 |
+ |
#define FLAG_NREG1_FLAGREG 0 /* Set to -1 if any register will do */ |
3271 |
+ |
static __inline__ void raw_flags_to_reg_FLAGREG(int r) |
3272 |
+ |
{ |
3273 |
+ |
raw_lahf(0); /* Most flags in AH */ |
3274 |
+ |
//raw_setcc(r,0); /* V flag in AL */ |
3275 |
+ |
raw_setcc_m((uintptr)live.state[FLAGTMP].mem,0); |
3276 |
+ |
|
3277 |
+ |
#if 1 /* Let's avoid those nasty partial register stalls */ |
3278 |
+ |
//raw_mov_b_mr((uintptr)live.state[FLAGTMP].mem,r); |
3279 |
+ |
raw_mov_b_mr(((uintptr)live.state[FLAGTMP].mem)+1,AH_INDEX); |
3280 |
+ |
raw_flags_evicted(r); |
3281 |
|
#endif |
3282 |
|
} |
3283 |
|
|
3284 |
< |
#define FLAG_NREG2 0 /* Set to -1 if any register will do */ |
3285 |
< |
static __inline__ void raw_reg_to_flags(int r) |
3284 |
> |
#define FLAG_NREG2_FLAGREG 0 /* Set to -1 if any register will do */ |
3285 |
> |
static __inline__ void raw_reg_to_flags_FLAGREG(int r) |
3286 |
|
{ |
3287 |
|
raw_cmp_b_ri(r,-127); /* set V */ |
3288 |
|
raw_sahf(0); |
3289 |
|
} |
3290 |
|
|
3291 |
< |
#else |
3291 |
> |
#define FLAG_NREG3_FLAGREG 0 /* Set to -1 if any register will do */ |
3292 |
> |
static __inline__ void raw_flags_set_zero_FLAGREG(int s, int tmp) |
3293 |
> |
{ |
3294 |
> |
raw_mov_l_rr(tmp,s); |
3295 |
> |
raw_lahf(s); /* flags into ah */ |
3296 |
> |
raw_and_l_ri(s,0xffffbfff); |
3297 |
> |
raw_and_l_ri(tmp,0x00004000); |
3298 |
> |
raw_xor_l_ri(tmp,0x00004000); |
3299 |
> |
raw_or_l(s,tmp); |
3300 |
> |
raw_sahf(s); |
3301 |
> |
} |
3302 |
> |
|
3303 |
> |
static __inline__ void raw_flags_init_FLAGREG(void) { } |
3304 |
|
|
3305 |
< |
#define FLAG_NREG1 -1 /* Set to -1 if any register will do */ |
3306 |
< |
static __inline__ void raw_flags_to_reg(int r) |
3305 |
> |
#define FLAG_NREG1_FLAGSTK -1 /* Set to -1 if any register will do */ |
3306 |
> |
static __inline__ void raw_flags_to_reg_FLAGSTK(int r) |
3307 |
|
{ |
3308 |
|
raw_pushfl(); |
3309 |
|
raw_pop_l_r(r); |
3310 |
< |
raw_mov_l_mr((uae_u32)live.state[FLAGTMP].mem,r); |
3311 |
< |
// live.state[FLAGTMP].status=CLEAN; |
2104 |
< |
live.state[FLAGTMP].status=INMEM; |
2105 |
< |
live.state[FLAGTMP].realreg=-1; |
2106 |
< |
/* We just "evicted" FLAGTMP. */ |
2107 |
< |
if (live.nat[r].nholds!=1) { |
2108 |
< |
/* Huh? */ |
2109 |
< |
abort(); |
2110 |
< |
} |
2111 |
< |
live.nat[r].nholds=0; |
3310 |
> |
raw_mov_l_mr((uintptr)live.state[FLAGTMP].mem,r); |
3311 |
> |
raw_flags_evicted(r); |
3312 |
|
} |
3313 |
|
|
3314 |
< |
#define FLAG_NREG2 -1 /* Set to -1 if any register will do */ |
3315 |
< |
static __inline__ void raw_reg_to_flags(int r) |
3314 |
> |
#define FLAG_NREG2_FLAGSTK -1 /* Set to -1 if any register will do */ |
3315 |
> |
static __inline__ void raw_reg_to_flags_FLAGSTK(int r) |
3316 |
|
{ |
3317 |
|
raw_push_l_r(r); |
3318 |
|
raw_popfl(); |
3319 |
|
} |
3320 |
|
|
3321 |
+ |
#define FLAG_NREG3_FLAGSTK -1 /* Set to -1 if any register will do */ |
3322 |
+ |
static __inline__ void raw_flags_set_zero_FLAGSTK(int s, int tmp) |
3323 |
+ |
{ |
3324 |
+ |
raw_mov_l_rr(tmp,s); |
3325 |
+ |
raw_pushfl(); |
3326 |
+ |
raw_pop_l_r(s); |
3327 |
+ |
raw_and_l_ri(s,0xffffffbf); |
3328 |
+ |
raw_and_l_ri(tmp,0x00000040); |
3329 |
+ |
raw_xor_l_ri(tmp,0x00000040); |
3330 |
+ |
raw_or_l(s,tmp); |
3331 |
+ |
raw_push_l_r(s); |
3332 |
+ |
raw_popfl(); |
3333 |
+ |
} |
3334 |
+ |
|
3335 |
+ |
static __inline__ void raw_flags_init_FLAGSTK(void) { } |
3336 |
+ |
|
3337 |
+ |
#if defined(__x86_64__) |
3338 |
+ |
/* Try to use the LAHF/SETO method on x86_64 since it is faster. |
3339 |
+ |
This can't be the default because some older CPUs don't support |
3340 |
+ |
LAHF/SAHF in long mode. */ |
3341 |
+ |
static int FLAG_NREG1_FLAGGEN = 0; |
3342 |
+ |
static __inline__ void raw_flags_to_reg_FLAGGEN(int r) |
3343 |
+ |
{ |
3344 |
+ |
if (have_lahf_lm) { |
3345 |
+ |
// NOTE: the interpreter uses the normal EFLAGS layout |
3346 |
+ |
// pushf/popf CF(0) ZF( 6) SF( 7) OF(11) |
3347 |
+ |
// sahf/lahf CF(8) ZF(14) SF(15) OF( 0) |
3348 |
+ |
assert(r == 0); |
3349 |
+ |
raw_setcc(r,0); /* V flag in AL */ |
3350 |
+ |
raw_lea_l_r_scaled(0,0,8); /* move it to its EFLAGS location */ |
3351 |
+ |
raw_mov_b_mr(((uintptr)live.state[FLAGTMP].mem)+1,0); |
3352 |
+ |
raw_lahf(0); /* most flags in AH */ |
3353 |
+ |
raw_mov_b_mr((uintptr)live.state[FLAGTMP].mem,AH_INDEX); |
3354 |
+ |
raw_flags_evicted(r); |
3355 |
+ |
} |
3356 |
+ |
else |
3357 |
+ |
raw_flags_to_reg_FLAGSTK(r); |
3358 |
+ |
} |
3359 |
+ |
|
3360 |
+ |
static int FLAG_NREG2_FLAGGEN = 0; |
3361 |
+ |
static __inline__ void raw_reg_to_flags_FLAGGEN(int r) |
3362 |
+ |
{ |
3363 |
+ |
if (have_lahf_lm) { |
3364 |
+ |
raw_xchg_b_rr(0,AH_INDEX); |
3365 |
+ |
raw_cmp_b_ri(r,-120); /* set V */ |
3366 |
+ |
raw_sahf(0); |
3367 |
+ |
} |
3368 |
+ |
else |
3369 |
+ |
raw_reg_to_flags_FLAGSTK(r); |
3370 |
+ |
} |
3371 |
+ |
|
3372 |
+ |
static int FLAG_NREG3_FLAGGEN = 0; |
3373 |
+ |
static __inline__ void raw_flags_set_zero_FLAGGEN(int s, int tmp) |
3374 |
+ |
{ |
3375 |
+ |
if (have_lahf_lm) |
3376 |
+ |
raw_flags_set_zero_FLAGREG(s, tmp); |
3377 |
+ |
else |
3378 |
+ |
raw_flags_set_zero_FLAGSTK(s, tmp); |
3379 |
+ |
} |
3380 |
+ |
|
3381 |
+ |
static __inline__ void raw_flags_init_FLAGGEN(void) |
3382 |
+ |
{ |
3383 |
+ |
if (have_lahf_lm) { |
3384 |
+ |
FLAG_NREG1_FLAGGEN = FLAG_NREG1_FLAGREG; |
3385 |
+ |
FLAG_NREG2_FLAGGEN = FLAG_NREG2_FLAGREG; |
3386 |
+ |
FLAG_NREG1_FLAGGEN = FLAG_NREG3_FLAGREG; |
3387 |
+ |
} |
3388 |
+ |
else { |
3389 |
+ |
FLAG_NREG1_FLAGGEN = FLAG_NREG1_FLAGSTK; |
3390 |
+ |
FLAG_NREG2_FLAGGEN = FLAG_NREG2_FLAGSTK; |
3391 |
+ |
FLAG_NREG1_FLAGGEN = FLAG_NREG3_FLAGSTK; |
3392 |
+ |
} |
3393 |
+ |
} |
3394 |
+ |
#endif |
3395 |
+ |
|
3396 |
+ |
#ifdef SAHF_SETO_PROFITABLE |
3397 |
+ |
#define FLAG_SUFFIX FLAGREG |
3398 |
+ |
#elif defined __x86_64__ |
3399 |
+ |
#define FLAG_SUFFIX FLAGGEN |
3400 |
+ |
#else |
3401 |
+ |
#define FLAG_SUFFIX FLAGSTK |
3402 |
|
#endif |
3403 |
|
|
3404 |
+ |
#define FLAG_GLUE_2(x, y) x ## _ ## y |
3405 |
+ |
#define FLAG_GLUE_1(x, y) FLAG_GLUE_2(x, y) |
3406 |
+ |
#define FLAG_GLUE(x) FLAG_GLUE_1(x, FLAG_SUFFIX) |
3407 |
+ |
|
3408 |
+ |
#define raw_flags_init FLAG_GLUE(raw_flags_init) |
3409 |
+ |
#define FLAG_NREG1 FLAG_GLUE(FLAG_NREG1) |
3410 |
+ |
#define raw_flags_to_reg FLAG_GLUE(raw_flags_to_reg) |
3411 |
+ |
#define FLAG_NREG2 FLAG_GLUE(FLAG_NREG2) |
3412 |
+ |
#define raw_reg_to_flags FLAG_GLUE(raw_reg_to_flags) |
3413 |
+ |
#define FLAG_NREG3 FLAG_GLUE(FLAG_NREG3) |
3414 |
+ |
#define raw_flags_set_zero FLAG_GLUE(raw_flags_set_zero) |
3415 |
+ |
|
3416 |
|
/* Apparently, there are enough instructions between flag store and |
3417 |
|
flag reload to avoid the partial memory stall */ |
3418 |
|
static __inline__ void raw_load_flagreg(uae_u32 target, uae_u32 r) |
3419 |
|
{ |
3420 |
|
#if 1 |
3421 |
< |
raw_mov_l_rm(target,(uae_u32)live.state[r].mem); |
3421 |
> |
raw_mov_l_rm(target,(uintptr)live.state[r].mem); |
3422 |
|
#else |
3423 |
< |
raw_mov_b_rm(target,(uae_u32)live.state[r].mem); |
3424 |
< |
raw_mov_b_rm(target+4,((uae_u32)live.state[r].mem)+1); |
3423 |
> |
raw_mov_b_rm(target,(uintptr)live.state[r].mem); |
3424 |
> |
raw_mov_b_rm(target+4,((uintptr)live.state[r].mem)+1); |
3425 |
|
#endif |
3426 |
|
} |
3427 |
|
|
3429 |
|
static __inline__ void raw_load_flagx(uae_u32 target, uae_u32 r) |
3430 |
|
{ |
3431 |
|
if (live.nat[target].canbyte) |
3432 |
< |
raw_mov_b_rm(target,(uae_u32)live.state[r].mem); |
3432 |
> |
raw_mov_b_rm(target,(uintptr)live.state[r].mem); |
3433 |
|
else if (live.nat[target].canword) |
3434 |
< |
raw_mov_w_rm(target,(uae_u32)live.state[r].mem); |
3434 |
> |
raw_mov_w_rm(target,(uintptr)live.state[r].mem); |
3435 |
|
else |
3436 |
< |
raw_mov_l_rm(target,(uae_u32)live.state[r].mem); |
3436 |
> |
raw_mov_l_rm(target,(uintptr)live.state[r].mem); |
3437 |
|
} |
3438 |
|
|
3439 |
+ |
static __inline__ void raw_dec_sp(int off) |
3440 |
+ |
{ |
3441 |
+ |
if (off) raw_sub_l_ri(ESP_INDEX,off); |
3442 |
+ |
} |
3443 |
|
|
3444 |
|
static __inline__ void raw_inc_sp(int off) |
3445 |
|
{ |
3446 |
< |
raw_add_l_ri(ESP_INDEX,off); |
3446 |
> |
if (off) raw_add_l_ri(ESP_INDEX,off); |
3447 |
|
} |
3448 |
|
|
3449 |
|
/************************************************************************* |
3602 |
|
for (i=0;i<5;i++) |
3603 |
|
vecbuf[i]=target[i]; |
3604 |
|
emit_byte(0xe9); |
3605 |
< |
emit_long((uae_u32)veccode-(uae_u32)target-4); |
3605 |
> |
emit_long((uintptr)veccode-(uintptr)target-4); |
3606 |
|
write_log("Create jump to %p\n",veccode); |
3607 |
|
|
3608 |
|
write_log("Handled one access!\n"); |
3629 |
|
} |
3630 |
|
for (i=0;i<5;i++) |
3631 |
|
raw_mov_b_mi(sc.eip+i,vecbuf[i]); |
3632 |
< |
raw_mov_l_mi((uae_u32)&in_handler,0); |
3632 |
> |
raw_mov_l_mi((uintptr)&in_handler,0); |
3633 |
|
emit_byte(0xe9); |
3634 |
< |
emit_long(sc.eip+len-(uae_u32)target-4); |
3634 |
> |
emit_long(sc.eip+len-(uintptr)target-4); |
3635 |
|
in_handler=1; |
3636 |
|
target=tmp; |
3637 |
|
} |
3726 |
|
X86_PROCESSOR_K6, |
3727 |
|
X86_PROCESSOR_ATHLON, |
3728 |
|
X86_PROCESSOR_PENTIUM4, |
3729 |
+ |
X86_PROCESSOR_X86_64, |
3730 |
|
X86_PROCESSOR_max |
3731 |
|
}; |
3732 |
|
|
3737 |
|
"PentiumPro", |
3738 |
|
"K6", |
3739 |
|
"Athlon", |
3740 |
< |
"Pentium4" |
3740 |
> |
"Pentium4", |
3741 |
> |
"x86-64" |
3742 |
|
}; |
3743 |
|
|
3744 |
|
static struct ptt { |
3755 |
|
{ 16, 15, 16, 7, 16 }, |
3756 |
|
{ 32, 7, 32, 7, 32 }, |
3757 |
|
{ 16, 7, 16, 7, 16 }, |
3758 |
< |
{ 0, 0, 0, 0, 0 } |
3758 |
> |
{ 0, 0, 0, 0, 0 }, |
3759 |
> |
{ 16, 7, 16, 7, 16 } |
3760 |
|
}; |
3761 |
|
|
3762 |
|
static void |
3790 |
|
static void |
3791 |
|
cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) |
3792 |
|
{ |
3793 |
< |
static uae_u8 cpuid_space[256]; |
3793 |
> |
const int CPUID_SPACE = 4096; |
3794 |
> |
uae_u8* cpuid_space = (uae_u8 *)vm_acquire(CPUID_SPACE); |
3795 |
> |
if (cpuid_space == VM_MAP_FAILED) |
3796 |
> |
abort(); |
3797 |
> |
vm_protect(cpuid_space, CPUID_SPACE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE); |
3798 |
> |
|
3799 |
> |
static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; |
3800 |
|
uae_u8* tmp=get_target(); |
3801 |
|
|
3802 |
+ |
s_op = op; |
3803 |
|
set_target(cpuid_space); |
3804 |
|
raw_push_l_r(0); /* eax */ |
3805 |
|
raw_push_l_r(1); /* ecx */ |
3806 |
|
raw_push_l_r(2); /* edx */ |
3807 |
|
raw_push_l_r(3); /* ebx */ |
3808 |
< |
raw_mov_l_rm(0,(uae_u32)&op); |
3808 |
> |
raw_mov_l_rm(0,(uintptr)&s_op); |
3809 |
|
raw_cpuid(0); |
3810 |
< |
if (eax != NULL) raw_mov_l_mr((uae_u32)eax,0); |
3811 |
< |
if (ebx != NULL) raw_mov_l_mr((uae_u32)ebx,3); |
3812 |
< |
if (ecx != NULL) raw_mov_l_mr((uae_u32)ecx,1); |
3813 |
< |
if (edx != NULL) raw_mov_l_mr((uae_u32)edx,2); |
3810 |
> |
raw_mov_l_mr((uintptr)&s_eax,0); |
3811 |
> |
raw_mov_l_mr((uintptr)&s_ebx,3); |
3812 |
> |
raw_mov_l_mr((uintptr)&s_ecx,1); |
3813 |
> |
raw_mov_l_mr((uintptr)&s_edx,2); |
3814 |
|
raw_pop_l_r(3); |
3815 |
|
raw_pop_l_r(2); |
3816 |
|
raw_pop_l_r(1); |
3819 |
|
set_target(tmp); |
3820 |
|
|
3821 |
|
((cpuop_func*)cpuid_space)(0); |
3822 |
+ |
if (eax != NULL) *eax = s_eax; |
3823 |
+ |
if (ebx != NULL) *ebx = s_ebx; |
3824 |
+ |
if (ecx != NULL) *ecx = s_ecx; |
3825 |
+ |
if (edx != NULL) *edx = s_edx; |
3826 |
+ |
|
3827 |
+ |
vm_release(cpuid_space, CPUID_SPACE); |
3828 |
|
} |
3829 |
|
|
3830 |
|
static void |
3833 |
|
struct cpuinfo_x86 *c = &cpuinfo; |
3834 |
|
|
3835 |
|
/* Defaults */ |
3836 |
+ |
c->x86_processor = X86_PROCESSOR_max; |
3837 |
|
c->x86_vendor = X86_VENDOR_UNKNOWN; |
3838 |
|
c->cpuid_level = -1; /* CPUID not detected */ |
3839 |
|
c->x86_model = c->x86_mask = 0; /* So far unknown... */ |
3855 |
|
uae_u32 tfms, brand_id; |
3856 |
|
cpuid(0x00000001, &tfms, &brand_id, NULL, &c->x86_hwcap); |
3857 |
|
c->x86 = (tfms >> 8) & 15; |
3858 |
+ |
if (c->x86 == 0xf) |
3859 |
+ |
c->x86 += (tfms >> 20) & 0xff; /* extended family */ |
3860 |
|
c->x86_model = (tfms >> 4) & 15; |
3861 |
+ |
if (c->x86_model == 0xf) |
3862 |
+ |
c->x86_model |= (tfms >> 12) & 0xf0; /* extended model */ |
3863 |
|
c->x86_brand_id = brand_id & 0xff; |
2546 |
– |
if ( (c->x86_vendor == X86_VENDOR_AMD) && |
2547 |
– |
(c->x86 == 0xf)) { |
2548 |
– |
/* AMD Extended Family and Model Values */ |
2549 |
– |
c->x86 += (tfms >> 20) & 0xff; |
2550 |
– |
c->x86_model += (tfms >> 12) & 0xf0; |
2551 |
– |
} |
3864 |
|
c->x86_mask = tfms & 15; |
3865 |
|
} else { |
3866 |
|
/* Have CPUID level 0 only - unheard of */ |
3867 |
|
c->x86 = 4; |
3868 |
|
} |
3869 |
|
|
3870 |
+ |
/* AMD-defined flags: level 0x80000001 */ |
3871 |
+ |
uae_u32 xlvl; |
3872 |
+ |
cpuid(0x80000000, &xlvl, NULL, NULL, NULL); |
3873 |
+ |
if ( (xlvl & 0xffff0000) == 0x80000000 ) { |
3874 |
+ |
if ( xlvl >= 0x80000001 ) { |
3875 |
+ |
uae_u32 features, extra_features; |
3876 |
+ |
cpuid(0x80000001, NULL, NULL, &extra_features, &features); |
3877 |
+ |
if (features & (1 << 29)) { |
3878 |
+ |
/* Assume x86-64 if long mode is supported */ |
3879 |
+ |
c->x86_processor = X86_PROCESSOR_X86_64; |
3880 |
+ |
} |
3881 |
+ |
if (extra_features & (1 << 0)) |
3882 |
+ |
have_lahf_lm = true; |
3883 |
+ |
} |
3884 |
+ |
} |
3885 |
+ |
|
3886 |
|
/* Canonicalize processor ID */ |
2559 |
– |
c->x86_processor = X86_PROCESSOR_max; |
3887 |
|
switch (c->x86) { |
3888 |
|
case 3: |
3889 |
|
c->x86_processor = X86_PROCESSOR_I386; |
3904 |
|
c->x86_processor = X86_PROCESSOR_PENTIUMPRO; |
3905 |
|
break; |
3906 |
|
case 15: |
3907 |
< |
if (c->x86_vendor == X86_VENDOR_INTEL) { |
3908 |
< |
/* Assume any BranID >= 8 and family == 15 yields a Pentium 4 */ |
3909 |
< |
if (c->x86_brand_id >= 8) |
3910 |
< |
c->x86_processor = X86_PROCESSOR_PENTIUM4; |
3911 |
< |
} |
3912 |
< |
break; |
3907 |
> |
if (c->x86_processor == X86_PROCESSOR_max) { |
3908 |
> |
switch (c->x86_vendor) { |
3909 |
> |
case X86_VENDOR_INTEL: |
3910 |
> |
c->x86_processor = X86_PROCESSOR_PENTIUM4; |
3911 |
> |
break; |
3912 |
> |
case X86_VENDOR_AMD: |
3913 |
> |
/* Assume a 32-bit Athlon processor if not in long mode */ |
3914 |
> |
c->x86_processor = X86_PROCESSOR_ATHLON; |
3915 |
> |
break; |
3916 |
> |
} |
3917 |
> |
} |
3918 |
> |
break; |
3919 |
|
} |
3920 |
|
if (c->x86_processor == X86_PROCESSOR_max) { |
3921 |
< |
fprintf(stderr, "Error: unknown processor type\n"); |
3921 |
> |
c->x86_processor = X86_PROCESSOR_I386; |
3922 |
> |
fprintf(stderr, "Error: unknown processor type, assuming i386\n"); |
3923 |
|
fprintf(stderr, " Family : %d\n", c->x86); |
3924 |
|
fprintf(stderr, " Model : %d\n", c->x86_model); |
3925 |
|
fprintf(stderr, " Mask : %d\n", c->x86_mask); |
3926 |
+ |
fprintf(stderr, " Vendor : %s [%d]\n", c->x86_vendor_id, c->x86_vendor); |
3927 |
|
if (c->x86_brand_id) |
3928 |
|
fprintf(stderr, " BrandID : %02x\n", c->x86_brand_id); |
2594 |
– |
abort(); |
3929 |
|
} |
3930 |
|
|
3931 |
|
/* Have CMOV support? */ |
3932 |
< |
have_cmov = (c->x86_hwcap & (1 << 15)) && true; |
3932 |
> |
have_cmov = c->x86_hwcap & (1 << 15); |
3933 |
> |
#if defined(__x86_64__) |
3934 |
> |
if (!have_cmov) { |
3935 |
> |
write_log("x86-64 implementations are bound to have CMOV!\n"); |
3936 |
> |
abort(); |
3937 |
> |
} |
3938 |
> |
#endif |
3939 |
|
|
3940 |
|
/* Can the host CPU suffer from partial register stalls? */ |
3941 |
|
have_rat_stall = (c->x86_vendor == X86_VENDOR_INTEL); |
3956 |
|
write_log("Max CPUID level=%d Processor is %s [%s]\n", |
3957 |
|
c->cpuid_level, c->x86_vendor_id, |
3958 |
|
x86_processor_string_table[c->x86_processor]); |
3959 |
+ |
|
3960 |
+ |
raw_flags_init(); |
3961 |
+ |
} |
3962 |
+ |
|
3963 |
+ |
static bool target_check_bsf(void) |
3964 |
+ |
{ |
3965 |
+ |
bool mismatch = false; |
3966 |
+ |
for (int g_ZF = 0; g_ZF <= 1; g_ZF++) { |
3967 |
+ |
for (int g_CF = 0; g_CF <= 1; g_CF++) { |
3968 |
+ |
for (int g_OF = 0; g_OF <= 1; g_OF++) { |
3969 |
+ |
for (int g_SF = 0; g_SF <= 1; g_SF++) { |
3970 |
+ |
for (int value = -1; value <= 1; value++) { |
3971 |
+ |
unsigned long flags = (g_SF << 7) | (g_OF << 11) | (g_ZF << 6) | g_CF; |
3972 |
+ |
unsigned long tmp = value; |
3973 |
+ |
__asm__ __volatile__ ("push %0; popf; bsf %1,%1; pushf; pop %0" |
3974 |
+ |
: "+r" (flags), "+r" (tmp) : : "cc"); |
3975 |
+ |
int OF = (flags >> 11) & 1; |
3976 |
+ |
int SF = (flags >> 7) & 1; |
3977 |
+ |
int ZF = (flags >> 6) & 1; |
3978 |
+ |
int CF = flags & 1; |
3979 |
+ |
tmp = (value == 0); |
3980 |
+ |
if (ZF != tmp || SF != g_SF || OF != g_OF || CF != g_CF) |
3981 |
+ |
mismatch = true; |
3982 |
+ |
} |
3983 |
+ |
}}}} |
3984 |
+ |
if (mismatch) |
3985 |
+ |
write_log("Target CPU defines all flags on BSF instruction\n"); |
3986 |
+ |
return !mismatch; |
3987 |
|
} |
3988 |
|
|
3989 |
|
|
4108 |
|
emit_byte(0xd8+(live.tos+1)-live.spos[r]); /* store top of stack in reg, |
4109 |
|
and pop it*/ |
4110 |
|
} |
4111 |
< |
|
4112 |
< |
|
4111 |
> |
|
4112 |
> |
/* FP helper functions */ |
4113 |
> |
#if USE_NEW_RTASM |
4114 |
> |
#define DEFINE_OP(NAME, GEN) \ |
4115 |
> |
static inline void raw_##NAME(uint32 m) \ |
4116 |
> |
{ \ |
4117 |
> |
GEN(m, X86_NOREG, X86_NOREG, 1); \ |
4118 |
> |
} |
4119 |
> |
DEFINE_OP(fstl, FSTLm); |
4120 |
> |
DEFINE_OP(fstpl, FSTPLm); |
4121 |
> |
DEFINE_OP(fldl, FLDLm); |
4122 |
> |
DEFINE_OP(fildl, FILDLm); |
4123 |
> |
DEFINE_OP(fistl, FISTLm); |
4124 |
> |
DEFINE_OP(flds, FLDSm); |
4125 |
> |
DEFINE_OP(fsts, FSTSm); |
4126 |
> |
DEFINE_OP(fstpt, FSTPTm); |
4127 |
> |
DEFINE_OP(fldt, FLDTm); |
4128 |
> |
#else |
4129 |
> |
#define DEFINE_OP(NAME, OP1, OP2) \ |
4130 |
> |
static inline void raw_##NAME(uint32 m) \ |
4131 |
> |
{ \ |
4132 |
> |
emit_byte(OP1); \ |
4133 |
> |
emit_byte(OP2); \ |
4134 |
> |
emit_long(m); \ |
4135 |
> |
} |
4136 |
> |
DEFINE_OP(fstl, 0xdd, 0x15); |
4137 |
> |
DEFINE_OP(fstpl, 0xdd, 0x1d); |
4138 |
> |
DEFINE_OP(fldl, 0xdd, 0x05); |
4139 |
> |
DEFINE_OP(fildl, 0xdb, 0x05); |
4140 |
> |
DEFINE_OP(fistl, 0xdb, 0x15); |
4141 |
> |
DEFINE_OP(flds, 0xd9, 0x05); |
4142 |
> |
DEFINE_OP(fsts, 0xd9, 0x15); |
4143 |
> |
DEFINE_OP(fstpt, 0xdb, 0x3d); |
4144 |
> |
DEFINE_OP(fldt, 0xdb, 0x2d); |
4145 |
> |
#endif |
4146 |
> |
#undef DEFINE_OP |
4147 |
> |
|
4148 |
|
LOWFUNC(NONE,WRITE,2,raw_fmov_mr,(MEMW m, FR r)) |
4149 |
|
{ |
4150 |
|
make_tos(r); |
4151 |
< |
emit_byte(0xdd); |
2749 |
< |
emit_byte(0x15); |
2750 |
< |
emit_long(m); |
4151 |
> |
raw_fstl(m); |
4152 |
|
} |
4153 |
|
LENDFUNC(NONE,WRITE,2,raw_fmov_mr,(MEMW m, FR r)) |
4154 |
|
|
4155 |
|
LOWFUNC(NONE,WRITE,2,raw_fmov_mr_drop,(MEMW m, FR r)) |
4156 |
|
{ |
4157 |
|
make_tos(r); |
4158 |
< |
emit_byte(0xdd); |
2758 |
< |
emit_byte(0x1d); |
2759 |
< |
emit_long(m); |
4158 |
> |
raw_fstpl(m); |
4159 |
|
live.onstack[live.tos]=-1; |
4160 |
|
live.tos--; |
4161 |
|
live.spos[r]=-2; |
4164 |
|
|
4165 |
|
LOWFUNC(NONE,READ,2,raw_fmov_rm,(FW r, MEMR m)) |
4166 |
|
{ |
4167 |
< |
emit_byte(0xdd); |
2769 |
< |
emit_byte(0x05); |
2770 |
< |
emit_long(m); |
4167 |
> |
raw_fldl(m); |
4168 |
|
tos_make(r); |
4169 |
|
} |
4170 |
|
LENDFUNC(NONE,READ,2,raw_fmov_rm,(FW r, MEMR m)) |
4171 |
|
|
4172 |
|
LOWFUNC(NONE,READ,2,raw_fmovi_rm,(FW r, MEMR m)) |
4173 |
|
{ |
4174 |
< |
emit_byte(0xdb); |
2778 |
< |
emit_byte(0x05); |
2779 |
< |
emit_long(m); |
4174 |
> |
raw_fildl(m); |
4175 |
|
tos_make(r); |
4176 |
|
} |
4177 |
|
LENDFUNC(NONE,READ,2,raw_fmovi_rm,(FW r, MEMR m)) |
4179 |
|
LOWFUNC(NONE,WRITE,2,raw_fmovi_mr,(MEMW m, FR r)) |
4180 |
|
{ |
4181 |
|
make_tos(r); |
4182 |
< |
emit_byte(0xdb); |
2788 |
< |
emit_byte(0x15); |
2789 |
< |
emit_long(m); |
4182 |
> |
raw_fistl(m); |
4183 |
|
} |
4184 |
|
LENDFUNC(NONE,WRITE,2,raw_fmovi_mr,(MEMW m, FR r)) |
4185 |
|
|
4186 |
|
LOWFUNC(NONE,READ,2,raw_fmovs_rm,(FW r, MEMR m)) |
4187 |
|
{ |
4188 |
< |
emit_byte(0xd9); |
2796 |
< |
emit_byte(0x05); |
2797 |
< |
emit_long(m); |
4188 |
> |
raw_flds(m); |
4189 |
|
tos_make(r); |
4190 |
|
} |
4191 |
|
LENDFUNC(NONE,READ,2,raw_fmovs_rm,(FW r, MEMR m)) |
4193 |
|
LOWFUNC(NONE,WRITE,2,raw_fmovs_mr,(MEMW m, FR r)) |
4194 |
|
{ |
4195 |
|
make_tos(r); |
4196 |
< |
emit_byte(0xd9); |
2806 |
< |
emit_byte(0x15); |
2807 |
< |
emit_long(m); |
4196 |
> |
raw_fsts(m); |
4197 |
|
} |
4198 |
|
LENDFUNC(NONE,WRITE,2,raw_fmovs_mr,(MEMW m, FR r)) |
4199 |
|
|
4208 |
|
emit_byte(0xd9); /* Get a copy to the top of stack */ |
4209 |
|
emit_byte(0xc0+rs); |
4210 |
|
|
4211 |
< |
emit_byte(0xdb); /* store and pop it */ |
2823 |
< |
emit_byte(0x3d); |
2824 |
< |
emit_long(m); |
4211 |
> |
raw_fstpt(m); /* store and pop it */ |
4212 |
|
} |
4213 |
|
LENDFUNC(NONE,WRITE,2,raw_fmov_ext_mr,(MEMW m, FR r)) |
4214 |
|
|
4217 |
|
int rs; |
4218 |
|
|
4219 |
|
make_tos(r); |
4220 |
< |
emit_byte(0xdb); /* store and pop it */ |
2834 |
< |
emit_byte(0x3d); |
2835 |
< |
emit_long(m); |
4220 |
> |
raw_fstpt(m); /* store and pop it */ |
4221 |
|
live.onstack[live.tos]=-1; |
4222 |
|
live.tos--; |
4223 |
|
live.spos[r]=-2; |
4226 |
|
|
4227 |
|
LOWFUNC(NONE,READ,2,raw_fmov_ext_rm,(FW r, MEMR m)) |
4228 |
|
{ |
4229 |
< |
emit_byte(0xdb); |
2845 |
< |
emit_byte(0x2d); |
2846 |
< |
emit_long(m); |
4229 |
> |
raw_fldt(m); |
4230 |
|
tos_make(r); |
4231 |
|
} |
4232 |
|
LENDFUNC(NONE,READ,2,raw_fmov_ext_rm,(FW r, MEMR m)) |
4413 |
|
} |
4414 |
|
LENDFUNC(NONE,NONE,2,raw_fsin_rr,(FW d, FR s)) |
4415 |
|
|
4416 |
< |
double one=1; |
4416 |
> |
static const double one=1; |
4417 |
|
LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) |
4418 |
|
{ |
4419 |
|
int ds; |
4433 |
|
emit_byte(0xe1); /* subtract rounded from original */ |
4434 |
|
emit_byte(0xd9); |
4435 |
|
emit_byte(0xf0); /* f2xm1 */ |
4436 |
< |
emit_byte(0xdc); |
3054 |
< |
emit_byte(0x05); |
3055 |
< |
emit_long((uae_u32)&one); /* Add '1' without using extra stack space */ |
4436 |
> |
x86_fadd_m((uintptr)&one); /* Add '1' without using extra stack space */ |
4437 |
|
emit_byte(0xd9); |
4438 |
|
emit_byte(0xfd); /* and scale it */ |
4439 |
|
emit_byte(0xdd); |
4465 |
|
emit_byte(0xe1); /* subtract rounded from original */ |
4466 |
|
emit_byte(0xd9); |
4467 |
|
emit_byte(0xf0); /* f2xm1 */ |
4468 |
< |
emit_byte(0xdc); |
3088 |
< |
emit_byte(0x05); |
3089 |
< |
emit_long((uae_u32)&one); /* Add '1' without using extra stack space */ |
4468 |
> |
x86_fadd_m((uintptr)&one); /* Add '1' without using extra stack space */ |
4469 |
|
emit_byte(0xd9); |
4470 |
|
emit_byte(0xfd); /* and scale it */ |
4471 |
|
emit_byte(0xdd); |