|
|
1.1 root 1: /*
2: * compiler/compemu_midfunc_arm.cpp - Native MIDFUNCS for IA-32 and AMD64
3: *
4: * Copyright (c) 2014 Jens Heitmann of ARAnyM dev team (see AUTHORS)
5: *
6: * Inspired by Christian Bauer's Basilisk II
7: *
8: * Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer
9: *
10: * Adaptation for Basilisk II and improvements, copyright 2000-2002
11: * Gwenole Beauchesne
12: *
13: * Basilisk II (C) 1997-2002 Christian Bauer
14: *
15: * This program is free software; you can redistribute it and/or modify
16: * it under the terms of the GNU General Public License as published by
17: * the Free Software Foundation; either version 2 of the License, or
18: * (at your option) any later version.
19: *
20: * This program is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: * GNU General Public License for more details.
24: *
25: * You should have received a copy of the GNU General Public License
1.1.1.2 root 26: * along with this program; if not, write to the Free Software Foundation,
27: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
1.1 root 28: *
29: * Note:
30: * File is included by compemu_support.cpp
31: *
32: */
33:
1.1.1.3 ! root 34: static int f_rmw(int r)
! 35: {
! 36: int n;
! 37:
! 38: f_make_exclusive(r,0);
! 39: if (f_isinreg(r)) {
! 40: n=live.fate[r].realreg;
! 41: }
! 42: else
! 43: n=f_alloc_reg(r,0);
! 44: live.fate[r].status=DIRTY;
! 45: live.fat[n].locked++;
! 46: live.fat[n].touched=touchcnt++;
! 47: return n;
! 48: }
! 49:
! 50: static void fflags_into_flags_internal(uae_u32 tmp)
! 51: {
! 52: int r;
! 53:
! 54: clobber_flags();
! 55: r=f_readreg(FP_RESULT);
! 56: if (FFLAG_NREG_CLOBBER_CONDITION) {
! 57: int tmp2=tmp;
! 58: tmp=writereg_specific(tmp,4,FFLAG_NREG);
! 59: raw_fflags_into_flags(r);
! 60: unlock2(tmp);
! 61: forget_about(tmp2);
! 62: }
! 63: else
! 64: raw_fflags_into_flags(r);
! 65: f_unlock(r);
! 66: live_flags();
! 67: }
! 68:
! 69:
1.1 root 70: /********************************************************************
71: * CPU functions exposed to gencomp. Both CREATE and EMIT time *
72: ********************************************************************/
73:
74:
75: /*
76: * RULES FOR HANDLING REGISTERS:
77: *
78: * * In the function headers, order the parameters
79: * - 1st registers written to
80: * - 2nd read/modify/write registers
81: * - 3rd registers read from
82: * * Before calling raw_*, you must call readreg, writereg or rmw for
83: * each register
84: * * The order for this is
85: * - 1st call remove_offset for all registers written to with size<4
86: * - 2nd call readreg for all registers read without offset
87: * - 3rd call rmw for all rmw registers
88: * - 4th call readreg_offset for all registers that can handle offsets
89: * - 5th call get_offset for all the registers from the previous step
90: * - 6th call writereg for all written-to registers
91: * - 7th call raw_*
92: * - 8th unlock2 all registers that were locked
93: */
94:
95: MIDFUNC(0,live_flags,(void))
96: {
97: live.flags_on_stack=TRASH;
98: live.flags_in_flags=VALID;
99: live.flags_are_important=1;
100: }
101: MENDFUNC(0,live_flags,(void))
102:
103: MIDFUNC(0,dont_care_flags,(void))
104: {
105: live.flags_are_important=0;
106: }
107: MENDFUNC(0,dont_care_flags,(void))
108:
109: MIDFUNC(0,duplicate_carry,(void))
110: {
111: evict(FLAGX);
112: make_flags_live_internal();
113: #ifdef UAE
114: COMPCALL(setcc_m)((uintptr)live.state[FLAGX].mem + 1, NATIVE_CC_CS);
115: #else
116: COMPCALL(setcc_m)((uintptr)live.state[FLAGX].mem, NATIVE_CC_CS);
117: #endif
118: log_vwrite(FLAGX);
119: }
120: MENDFUNC(0,duplicate_carry,(void))
121:
1.1.1.3 ! root 122: MIDFUNC(0, setcc_for_cntzero, (RR4))
! 123: {
! 124: uae_u8 * branchadd;
! 125:
! 126: evict(FLAGX);
! 127: make_flags_live_internal();
! 128:
! 129: raw_pushfl();
! 130: /*
! 131: * shift count can only be in CL register; see shrl_b_rr
! 132: */
! 133: raw_test_b_rr(X86_CL, X86_CL);
! 134: /* if zero, leave X unaffected; carry flag will already be cleared */
! 135: raw_jz_b_oponly();
! 136: branchadd = get_target();
! 137: skip_byte();
! 138: raw_popfl();
! 139: raw_pushfl();
! 140: #ifdef UAE
! 141: COMPCALL(setcc_m)((uintptr)live.state[FLAGX].mem + 1, NATIVE_CC_CS);
! 142: #else
! 143: COMPCALL(setcc_m)((uintptr)live.state[FLAGX].mem, NATIVE_CC_CS);
! 144: #endif
! 145: log_vwrite(FLAGX);
! 146: *branchadd = (uintptr)get_target() - ((uintptr)branchadd + 1);
! 147: raw_popfl();
! 148: }
! 149:
1.1 root 150: MIDFUNC(0,restore_carry,(void))
151: {
152: if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
153: #ifdef UAE
154: bt_l_ri_noclobber(FLAGX, 8);
155: #else
156: bt_l_ri_noclobber(FLAGX, 0);
157: #endif
158: }
159: else { /* Avoid the stall the above creates.
160: This is slow on non-P6, though.
161: */
162: #ifdef UAE
163: COMPCALL(rol_w_ri(FLAGX, 8));
164: #else
165: COMPCALL(rol_b_ri(FLAGX, 8));
166: #endif
167: isclean(FLAGX);
168: }
169: }
170: MENDFUNC(0,restore_carry,(void))
171:
172: MIDFUNC(0,start_needflags,(void))
173: {
174: needflags=1;
175: }
176: MENDFUNC(0,start_needflags,(void))
177:
178: MIDFUNC(0,end_needflags,(void))
179: {
180: needflags=0;
181: }
182: MENDFUNC(0,end_needflags,(void))
183:
184: MIDFUNC(0,make_flags_live,(void))
185: {
186: make_flags_live_internal();
187: }
188: MENDFUNC(0,make_flags_live,(void))
189:
190: MIDFUNC(1,fflags_into_flags,(W2 tmp))
191: {
192: clobber_flags();
193: fflags_into_flags_internal(tmp);
194: }
195: MENDFUNC(1,fflags_into_flags,(W2 tmp))
196:
197: MIDFUNC(2,bt_l_ri,(RR4 r, IMM i)) /* This is defined as only affecting C */
198: {
199: int size=4;
200: if (i<16)
201: size=2;
202: CLOBBER_BT;
203: r=readreg(r,size);
204: raw_bt_l_ri(r,i);
205: unlock2(r);
206: }
207: MENDFUNC(2,bt_l_ri,(RR4 r, IMM i)) /* This is defined as only affecting C */
208:
209: MIDFUNC(2,bt_l_rr,(RR4 r, RR4 b)) /* This is defined as only affecting C */
210: {
211: CLOBBER_BT;
212: r=readreg(r,4);
213: b=readreg(b,4);
214: raw_bt_l_rr(r,b);
215: unlock2(r);
216: unlock2(b);
217: }
218: MENDFUNC(2,bt_l_rr,(RR4 r, RR4 b)) /* This is defined as only affecting C */
219:
220: MIDFUNC(2,btc_l_ri,(RW4 r, IMM i))
221: {
222: int size=4;
223: if (i<16)
224: size=2;
225: CLOBBER_BT;
226: r=rmw(r,size,size);
227: raw_btc_l_ri(r,i);
228: unlock2(r);
229: }
230: MENDFUNC(2,btc_l_ri,(RW4 r, IMM i))
231:
232: MIDFUNC(2,btc_l_rr,(RW4 r, RR4 b))
233: {
234: CLOBBER_BT;
235: b=readreg(b,4);
236: r=rmw(r,4,4);
237: raw_btc_l_rr(r,b);
238: unlock2(r);
239: unlock2(b);
240: }
241: MENDFUNC(2,btc_l_rr,(RW4 r, RR4 b))
242:
243: MIDFUNC(2,btr_l_ri,(RW4 r, IMM i))
244: {
245: int size=4;
246: if (i<16)
247: size=2;
248: CLOBBER_BT;
249: r=rmw(r,size,size);
250: raw_btr_l_ri(r,i);
251: unlock2(r);
252: }
253: MENDFUNC(2,btr_l_ri,(RW4 r, IMM i))
254:
255: MIDFUNC(2,btr_l_rr,(RW4 r, RR4 b))
256: {
257: CLOBBER_BT;
258: b=readreg(b,4);
259: r=rmw(r,4,4);
260: raw_btr_l_rr(r,b);
261: unlock2(r);
262: unlock2(b);
263: }
264: MENDFUNC(2,btr_l_rr,(RW4 r, RR4 b))
265:
266: MIDFUNC(2,bts_l_ri,(RW4 r, IMM i))
267: {
268: int size=4;
269: if (i<16)
270: size=2;
271: CLOBBER_BT;
272: r=rmw(r,size,size);
273: raw_bts_l_ri(r,i);
274: unlock2(r);
275: }
276: MENDFUNC(2,bts_l_ri,(RW4 r, IMM i))
277:
278: MIDFUNC(2,bts_l_rr,(RW4 r, RR4 b))
279: {
280: CLOBBER_BT;
281: b=readreg(b,4);
282: r=rmw(r,4,4);
283: raw_bts_l_rr(r,b);
284: unlock2(r);
285: unlock2(b);
286: }
287: MENDFUNC(2,bts_l_rr,(RW4 r, RR4 b))
288:
289: MIDFUNC(2,mov_l_rm,(W4 d, IMM s))
290: {
291: CLOBBER_MOV;
292: d=writereg(d,4);
293: raw_mov_l_rm(d,s);
294: unlock2(d);
295: }
296: MENDFUNC(2,mov_l_rm,(W4 d, IMM s))
297:
298: MIDFUNC(1,call_r,(RR4 r)) /* Clobbering is implicit */
299: {
300: r=readreg(r,4);
301: raw_dec_sp(STACK_SHADOW_SPACE);
302: raw_call_r(r);
303: raw_inc_sp(STACK_SHADOW_SPACE);
304: unlock2(r);
305: }
306: MENDFUNC(1,call_r,(RR4 r)) /* Clobbering is implicit */
307:
308: MIDFUNC(2,sub_l_mi,(IMM d, IMM s))
309: {
310: CLOBBER_SUB;
311: raw_sub_l_mi(d,s) ;
312: }
313: MENDFUNC(2,sub_l_mi,(IMM d, IMM s))
314:
315: MIDFUNC(2,mov_l_mi,(IMM d, IMM s))
316: {
317: CLOBBER_MOV;
318: raw_mov_l_mi(d,s) ;
319: }
320: MENDFUNC(2,mov_l_mi,(IMM d, IMM s))
321:
322: MIDFUNC(2,mov_w_mi,(IMM d, IMM s))
323: {
324: CLOBBER_MOV;
325: raw_mov_w_mi(d,s) ;
326: }
327: MENDFUNC(2,mov_w_mi,(IMM d, IMM s))
328:
329: MIDFUNC(2,mov_b_mi,(IMM d, IMM s))
330: {
331: CLOBBER_MOV;
332: raw_mov_b_mi(d,s) ;
333: }
334: MENDFUNC(2,mov_b_mi,(IMM d, IMM s))
335:
336: MIDFUNC(2,rol_b_ri,(RW1 r, IMM i))
337: {
338: if (!i && !needflags)
339: return;
340: CLOBBER_ROL;
341: r=rmw(r,1,1);
342: raw_rol_b_ri(r,i);
343: unlock2(r);
344: }
345: MENDFUNC(2,rol_b_ri,(RW1 r, IMM i))
346:
347: MIDFUNC(2,rol_w_ri,(RW2 r, IMM i))
348: {
349: if (!i && !needflags)
350: return;
351: CLOBBER_ROL;
352: r=rmw(r,2,2);
353: raw_rol_w_ri(r,i);
354: unlock2(r);
355: }
356: MENDFUNC(2,rol_w_ri,(RW2 r, IMM i))
357:
358: MIDFUNC(2,rol_l_ri,(RW4 r, IMM i))
359: {
360: if (!i && !needflags)
361: return;
362: CLOBBER_ROL;
363: r=rmw(r,4,4);
364: raw_rol_l_ri(r,i);
365: unlock2(r);
366: }
367: MENDFUNC(2,rol_l_ri,(RW4 r, IMM i))
368:
369: MIDFUNC(2,rol_l_rr,(RW4 d, RR1 r))
370: {
371: if (isconst(r)) {
372: COMPCALL(rol_l_ri)(d,(uae_u8)live.state[r].val);
373: return;
374: }
375: CLOBBER_ROL;
376: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
377: d=rmw(d,4,4);
378: Dif (r!=1) {
379: jit_abort("Illegal register %d in raw_rol_b",r);
380: }
381: raw_rol_l_rr(d,r) ;
382: unlock2(r);
383: unlock2(d);
384: }
385: MENDFUNC(2,rol_l_rr,(RW4 d, RR1 r))
386:
387: MIDFUNC(2,rol_w_rr,(RW2 d, RR1 r))
388: { /* Can only do this with r==1, i.e. cl */
389:
390: if (isconst(r)) {
391: COMPCALL(rol_w_ri)(d,(uae_u8)live.state[r].val);
392: return;
393: }
394: CLOBBER_ROL;
395: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
396: d=rmw(d,2,2);
397: Dif (r!=1) {
398: jit_abort("Illegal register %d in raw_rol_b",r);
399: }
400: raw_rol_w_rr(d,r) ;
401: unlock2(r);
402: unlock2(d);
403: }
404: MENDFUNC(2,rol_w_rr,(RW2 d, RR1 r))
405:
406: MIDFUNC(2,rol_b_rr,(RW1 d, RR1 r))
407: { /* Can only do this with r==1, i.e. cl */
408:
409: if (isconst(r)) {
410: COMPCALL(rol_b_ri)(d,(uae_u8)live.state[r].val);
411: return;
412: }
413:
414: CLOBBER_ROL;
415: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
416: d=rmw(d,1,1);
417: Dif (r!=1) {
418: jit_abort("Illegal register %d in raw_rol_b",r);
419: }
420: raw_rol_b_rr(d,r) ;
421: unlock2(r);
422: unlock2(d);
423: }
424: MENDFUNC(2,rol_b_rr,(RW1 d, RR1 r))
425:
426:
427: MIDFUNC(2,shll_l_rr,(RW4 d, RR1 r))
428: {
429: if (isconst(r)) {
430: COMPCALL(shll_l_ri)(d,(uae_u8)live.state[r].val);
431: return;
432: }
433: CLOBBER_SHLL;
434: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
435: d=rmw(d,4,4);
436: Dif (r!=1) {
437: jit_abort("Illegal register %d in raw_rol_b",r);
438: }
439: raw_shll_l_rr(d,r) ;
440: unlock2(r);
441: unlock2(d);
442: }
443: MENDFUNC(2,shll_l_rr,(RW4 d, RR1 r))
444:
445: MIDFUNC(2,shll_w_rr,(RW2 d, RR1 r))
446: { /* Can only do this with r==1, i.e. cl */
447:
448: if (isconst(r)) {
449: COMPCALL(shll_w_ri)(d,(uae_u8)live.state[r].val);
450: return;
451: }
452: CLOBBER_SHLL;
453: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
454: d=rmw(d,2,2);
455: Dif (r!=1) {
456: jit_abort("Illegal register %d in raw_shll_b",r);
457: }
458: raw_shll_w_rr(d,r) ;
459: unlock2(r);
460: unlock2(d);
461: }
462: MENDFUNC(2,shll_w_rr,(RW2 d, RR1 r))
463:
464: MIDFUNC(2,shll_b_rr,(RW1 d, RR1 r))
465: { /* Can only do this with r==1, i.e. cl */
466:
467: if (isconst(r)) {
468: COMPCALL(shll_b_ri)(d,(uae_u8)live.state[r].val);
469: return;
470: }
471:
472: CLOBBER_SHLL;
473: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
474: d=rmw(d,1,1);
475: Dif (r!=1) {
476: jit_abort("Illegal register %d in raw_shll_b",r);
477: }
478: raw_shll_b_rr(d,r) ;
479: unlock2(r);
480: unlock2(d);
481: }
482: MENDFUNC(2,shll_b_rr,(RW1 d, RR1 r))
483:
484:
485: MIDFUNC(2,ror_b_ri,(RR1 r, IMM i))
486: {
487: if (!i && !needflags)
488: return;
489: CLOBBER_ROR;
490: r=rmw(r,1,1);
491: raw_ror_b_ri(r,i);
492: unlock2(r);
493: }
494: MENDFUNC(2,ror_b_ri,(RR1 r, IMM i))
495:
496: MIDFUNC(2,ror_w_ri,(RR2 r, IMM i))
497: {
498: if (!i && !needflags)
499: return;
500: CLOBBER_ROR;
501: r=rmw(r,2,2);
502: raw_ror_w_ri(r,i);
503: unlock2(r);
504: }
505: MENDFUNC(2,ror_w_ri,(RR2 r, IMM i))
506:
507: MIDFUNC(2,ror_l_ri,(RR4 r, IMM i))
508: {
509: if (!i && !needflags)
510: return;
511: CLOBBER_ROR;
512: r=rmw(r,4,4);
513: raw_ror_l_ri(r,i);
514: unlock2(r);
515: }
516: MENDFUNC(2,ror_l_ri,(RR4 r, IMM i))
517:
518: MIDFUNC(2,ror_l_rr,(RR4 d, RR1 r))
519: {
520: if (isconst(r)) {
521: COMPCALL(ror_l_ri)(d,(uae_u8)live.state[r].val);
522: return;
523: }
524: CLOBBER_ROR;
525: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
526: d=rmw(d,4,4);
527: raw_ror_l_rr(d,r) ;
528: unlock2(r);
529: unlock2(d);
530: }
531: MENDFUNC(2,ror_l_rr,(RR4 d, RR1 r))
532:
533: MIDFUNC(2,ror_w_rr,(RR2 d, RR1 r))
534: {
535: if (isconst(r)) {
536: COMPCALL(ror_w_ri)(d,(uae_u8)live.state[r].val);
537: return;
538: }
539: CLOBBER_ROR;
540: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
541: d=rmw(d,2,2);
542: raw_ror_w_rr(d,r) ;
543: unlock2(r);
544: unlock2(d);
545: }
546: MENDFUNC(2,ror_w_rr,(RR2 d, RR1 r))
547:
548: MIDFUNC(2,ror_b_rr,(RR1 d, RR1 r))
549: {
550: if (isconst(r)) {
551: COMPCALL(ror_b_ri)(d,(uae_u8)live.state[r].val);
552: return;
553: }
554:
555: CLOBBER_ROR;
556: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
557: d=rmw(d,1,1);
558: raw_ror_b_rr(d,r) ;
559: unlock2(r);
560: unlock2(d);
561: }
562: MENDFUNC(2,ror_b_rr,(RR1 d, RR1 r))
563:
564: MIDFUNC(2,shrl_l_rr,(RW4 d, RR1 r))
565: {
566: if (isconst(r)) {
567: COMPCALL(shrl_l_ri)(d,(uae_u8)live.state[r].val);
568: return;
569: }
570: CLOBBER_SHRL;
571: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
572: d=rmw(d,4,4);
573: Dif (r!=1) {
574: jit_abort("Illegal register %d in raw_rol_b",r);
575: }
576: raw_shrl_l_rr(d,r) ;
577: unlock2(r);
578: unlock2(d);
579: }
580: MENDFUNC(2,shrl_l_rr,(RW4 d, RR1 r))
581:
582: MIDFUNC(2,shrl_w_rr,(RW2 d, RR1 r))
583: { /* Can only do this with r==1, i.e. cl */
584:
585: if (isconst(r)) {
586: COMPCALL(shrl_w_ri)(d,(uae_u8)live.state[r].val);
587: return;
588: }
589: CLOBBER_SHRL;
590: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
591: d=rmw(d,2,2);
592: Dif (r!=1) {
593: jit_abort("Illegal register %d in raw_shrl_b",r);
594: }
595: raw_shrl_w_rr(d,r) ;
596: unlock2(r);
597: unlock2(d);
598: }
599: MENDFUNC(2,shrl_w_rr,(RW2 d, RR1 r))
600:
601: MIDFUNC(2,shrl_b_rr,(RW1 d, RR1 r))
602: { /* Can only do this with r==1, i.e. cl */
603:
604: if (isconst(r)) {
605: COMPCALL(shrl_b_ri)(d,(uae_u8)live.state[r].val);
606: return;
607: }
608:
609: CLOBBER_SHRL;
610: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
611: d=rmw(d,1,1);
612: Dif (r!=1) {
613: jit_abort("Illegal register %d in raw_shrl_b",r);
614: }
615: raw_shrl_b_rr(d,r) ;
616: unlock2(r);
617: unlock2(d);
618: }
619: MENDFUNC(2,shrl_b_rr,(RW1 d, RR1 r))
620:
621:
622:
623: MIDFUNC(2,shll_l_ri,(RW4 r, IMM i))
624: {
625: if (!i && !needflags)
626: return;
627: if (isconst(r) && !needflags) {
628: live.state[r].val<<=i;
629: return;
630: }
631: CLOBBER_SHLL;
632: r=rmw(r,4,4);
633: raw_shll_l_ri(r,i);
634: unlock2(r);
635: }
636: MENDFUNC(2,shll_l_ri,(RW4 r, IMM i))
637:
638: MIDFUNC(2,shll_w_ri,(RW2 r, IMM i))
639: {
640: if (!i && !needflags)
641: return;
642: CLOBBER_SHLL;
643: r=rmw(r,2,2);
644: raw_shll_w_ri(r,i);
645: unlock2(r);
646: }
647: MENDFUNC(2,shll_w_ri,(RW2 r, IMM i))
648:
649: MIDFUNC(2,shll_b_ri,(RW1 r, IMM i))
650: {
651: if (!i && !needflags)
652: return;
653: CLOBBER_SHLL;
654: r=rmw(r,1,1);
655: raw_shll_b_ri(r,i);
656: unlock2(r);
657: }
658: MENDFUNC(2,shll_b_ri,(RW1 r, IMM i))
659:
660: MIDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
661: {
662: if (!i && !needflags)
663: return;
664: if (isconst(r) && !needflags) {
665: live.state[r].val>>=i;
666: return;
667: }
668: CLOBBER_SHRL;
669: r=rmw(r,4,4);
670: raw_shrl_l_ri(r,i);
671: unlock2(r);
672: }
673: MENDFUNC(2,shrl_l_ri,(RW4 r, IMM i))
674:
675: MIDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
676: {
677: if (!i && !needflags)
678: return;
679: CLOBBER_SHRL;
680: r=rmw(r,2,2);
681: raw_shrl_w_ri(r,i);
682: unlock2(r);
683: }
684: MENDFUNC(2,shrl_w_ri,(RW2 r, IMM i))
685:
686: MIDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
687: {
688: if (!i && !needflags)
689: return;
690: CLOBBER_SHRL;
691: r=rmw(r,1,1);
692: raw_shrl_b_ri(r,i);
693: unlock2(r);
694: }
695: MENDFUNC(2,shrl_b_ri,(RW1 r, IMM i))
696:
697: MIDFUNC(2,shra_l_ri,(RW4 r, IMM i))
698: {
699: if (!i && !needflags)
700: return;
701: CLOBBER_SHRA;
702: r=rmw(r,4,4);
703: raw_shra_l_ri(r,i);
704: unlock2(r);
705: }
706: MENDFUNC(2,shra_l_ri,(RW4 r, IMM i))
707:
708: MIDFUNC(2,shra_w_ri,(RW2 r, IMM i))
709: {
710: if (!i && !needflags)
711: return;
712: CLOBBER_SHRA;
713: r=rmw(r,2,2);
714: raw_shra_w_ri(r,i);
715: unlock2(r);
716: }
717: MENDFUNC(2,shra_w_ri,(RW2 r, IMM i))
718:
719: MIDFUNC(2,shra_b_ri,(RW1 r, IMM i))
720: {
721: if (!i && !needflags)
722: return;
723: CLOBBER_SHRA;
724: r=rmw(r,1,1);
725: raw_shra_b_ri(r,i);
726: unlock2(r);
727: }
728: MENDFUNC(2,shra_b_ri,(RW1 r, IMM i))
729:
730: MIDFUNC(2,shra_l_rr,(RW4 d, RR1 r))
731: {
732: if (isconst(r)) {
733: COMPCALL(shra_l_ri)(d,(uae_u8)live.state[r].val);
734: return;
735: }
736: CLOBBER_SHRA;
737: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
738: d=rmw(d,4,4);
739: Dif (r!=1) {
740: jit_abort("Illegal register %d in raw_rol_b",r);
741: }
742: raw_shra_l_rr(d,r) ;
743: unlock2(r);
744: unlock2(d);
745: }
746: MENDFUNC(2,shra_l_rr,(RW4 d, RR1 r))
747:
748: MIDFUNC(2,shra_w_rr,(RW2 d, RR1 r))
749: { /* Can only do this with r==1, i.e. cl */
750:
751: if (isconst(r)) {
752: COMPCALL(shra_w_ri)(d,(uae_u8)live.state[r].val);
753: return;
754: }
755: CLOBBER_SHRA;
756: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
757: d=rmw(d,2,2);
758: Dif (r!=1) {
759: jit_abort("Illegal register %d in raw_shra_b",r);
760: }
761: raw_shra_w_rr(d,r) ;
762: unlock2(r);
763: unlock2(d);
764: }
765: MENDFUNC(2,shra_w_rr,(RW2 d, RR1 r))
766:
767: MIDFUNC(2,shra_b_rr,(RW1 d, RR1 r))
768: { /* Can only do this with r==1, i.e. cl */
769:
770: if (isconst(r)) {
771: COMPCALL(shra_b_ri)(d,(uae_u8)live.state[r].val);
772: return;
773: }
774:
775: CLOBBER_SHRA;
776: r=readreg_specific(r,1,SHIFTCOUNT_NREG);
777: d=rmw(d,1,1);
778: Dif (r!=1) {
779: jit_abort("Illegal register %d in raw_shra_b",r);
780: }
781: raw_shra_b_rr(d,r) ;
782: unlock2(r);
783: unlock2(d);
784: }
785: MENDFUNC(2,shra_b_rr,(RW1 d, RR1 r))
786:
787:
788: MIDFUNC(2,setcc,(W1 d, IMM cc))
789: {
790: CLOBBER_SETCC;
791: d=writereg(d,1);
792: raw_setcc(d,cc);
793: unlock2(d);
794: }
795: MENDFUNC(2,setcc,(W1 d, IMM cc))
796:
797: MIDFUNC(2,setcc_m,(IMM d, IMM cc))
798: {
799: CLOBBER_SETCC;
800: raw_setcc_m(d,cc);
801: }
802: MENDFUNC(2,setcc_m,(IMM d, IMM cc))
803:
804: MIDFUNC(3,cmov_l_rr,(RW4 d, RR4 s, IMM cc))
805: {
806: if (d==s)
807: return;
808: CLOBBER_CMOV;
809: s=readreg(s,4);
810: d=rmw(d,4,4);
811: raw_cmov_l_rr(d,s,cc);
812: unlock2(s);
813: unlock2(d);
814: }
815: MENDFUNC(3,cmov_l_rr,(RW4 d, RR4 s, IMM cc))
816:
817: MIDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
818: {
819: CLOBBER_CMOV;
820: d=rmw(d,4,4);
821: raw_cmov_l_rm(d,s,cc);
822: unlock2(d);
823: }
824: MENDFUNC(3,cmov_l_rm,(RW4 d, IMM s, IMM cc))
825:
826: MIDFUNC(2,bsf_l_rr,(W4 d, RR4 s))
827: {
828: CLOBBER_BSF;
1.1.1.3 ! root 829: s = readreg(s, 4);
! 830: d = writereg(d, 4);
! 831: raw_bsf_l_rr(d, s);
1.1 root 832: unlock2(s);
833: unlock2(d);
834: }
835: MENDFUNC(2,bsf_l_rr,(W4 d, RR4 s))
836:
837: /* Set the Z flag depending on the value in s. Note that the
838: value has to be 0 or -1 (or, more precisely, for non-zero
839: values, bit 14 must be set)! */
840: MIDFUNC(2,simulate_bsf,(W4 tmp, RW4 s))
841: {
1.1.1.3 ! root 842: CLOBBER_BSF;
! 843: s=rmw_specific(s,4,4,FLAG_NREG3);
! 844: tmp=writereg(tmp,4);
! 845: raw_flags_set_zero(s, tmp);
! 846: unlock2(tmp);
! 847: unlock2(s);
1.1 root 848: }
849: MENDFUNC(2,simulate_bsf,(W4 tmp, RW4 s))
850:
851: MIDFUNC(2,imul_32_32,(RW4 d, RR4 s))
852: {
853: CLOBBER_MUL;
854: s=readreg(s,4);
855: d=rmw(d,4,4);
856: raw_imul_32_32(d,s);
857: unlock2(s);
858: unlock2(d);
859: }
860: MENDFUNC(2,imul_32_32,(RW4 d, RR4 s))
861:
862: MIDFUNC(2,imul_64_32,(RW4 d, RW4 s))
863: {
864: CLOBBER_MUL;
865: s=rmw_specific(s,4,4,MUL_NREG2);
866: d=rmw_specific(d,4,4,MUL_NREG1);
867: raw_imul_64_32(d,s);
868: unlock2(s);
869: unlock2(d);
870: }
871: MENDFUNC(2,imul_64_32,(RW4 d, RW4 s))
872:
873: MIDFUNC(2,mul_64_32,(RW4 d, RW4 s))
874: {
875: CLOBBER_MUL;
876: s=rmw_specific(s,4,4,MUL_NREG2);
877: d=rmw_specific(d,4,4,MUL_NREG1);
878: raw_mul_64_32(d,s);
879: unlock2(s);
880: unlock2(d);
881: }
882: MENDFUNC(2,mul_64_32,(RW4 d, RW4 s))
883:
884: MIDFUNC(2,mul_32_32,(RW4 d, RR4 s))
885: {
1.1.1.3 ! root 886: CLOBBER_MUL;
! 887: s=readreg(s,4);
! 888: d=rmw(d,4,4);
! 889: raw_mul_32_32(d,s);
! 890: unlock2(s);
! 891: unlock2(d);
1.1 root 892: }
893: MENDFUNC(2,mul_32_32,(RW4 d, RR4 s))
894:
895: #if SIZEOF_VOID_P == 8
896: MIDFUNC(2,sign_extend_32_rr,(W4 d, RR2 s))
897: {
1.1.1.3 ! root 898: int isrmw;
1.1 root 899:
1.1.1.3 ! root 900: if (isconst(s)) {
1.1 root 901: set_const(d,(uae_s32)live.state[s].val);
902: return;
1.1.1.3 ! root 903: }
1.1 root 904:
1.1.1.3 ! root 905: CLOBBER_SE32;
! 906: isrmw=(s==d);
! 907: if (!isrmw) {
! 908: s=readreg(s,4);
! 909: d=writereg(d,4);
! 910: }
! 911: else { /* If we try to lock this twice, with different sizes, we
! 912: are int trouble! */
! 913: s=d=rmw(s,4,4);
! 914: }
! 915: raw_sign_extend_32_rr(d,s);
! 916: if (!isrmw) {
! 917: unlock2(d);
! 918: unlock2(s);
! 919: }
! 920: else {
! 921: unlock2(s);
! 922: }
1.1 root 923: }
924: MENDFUNC(2,sign_extend_32_rr,(W4 d, RR2 s))
925: #endif
926:
927: MIDFUNC(2,sign_extend_16_rr,(W4 d, RR2 s))
928: {
929: int isrmw;
930:
931: if (isconst(s)) {
932: set_const(d,(uae_s32)(uae_s16)live.state[s].val);
933: return;
934: }
935:
936: CLOBBER_SE16;
937: isrmw=(s==d);
938: if (!isrmw) {
939: s=readreg(s,2);
940: d=writereg(d,4);
941: }
942: else { /* If we try to lock this twice, with different sizes, we
1.1.1.3 ! root 943: are int trouble! */
1.1 root 944: s=d=rmw(s,4,2);
945: }
946: raw_sign_extend_16_rr(d,s);
947: if (!isrmw) {
948: unlock2(d);
949: unlock2(s);
950: }
951: else {
952: unlock2(s);
953: }
954: }
955: MENDFUNC(2,sign_extend_16_rr,(W4 d, RR2 s))
956:
957: MIDFUNC(2,sign_extend_8_rr,(W4 d, RR1 s))
958: {
959: int isrmw;
960:
961: if (isconst(s)) {
962: set_const(d,(uae_s32)(uae_s8)live.state[s].val);
963: return;
964: }
965:
966: isrmw=(s==d);
967: CLOBBER_SE8;
968: if (!isrmw) {
969: s=readreg(s,1);
970: d=writereg(d,4);
971: }
972: else { /* If we try to lock this twice, with different sizes, we
1.1.1.3 ! root 973: are int trouble! */
1.1 root 974: s=d=rmw(s,4,1);
975: }
976:
977: raw_sign_extend_8_rr(d,s);
978:
979: if (!isrmw) {
980: unlock2(d);
981: unlock2(s);
982: }
983: else {
984: unlock2(s);
985: }
986: }
987: MENDFUNC(2,sign_extend_8_rr,(W4 d, RR1 s))
988:
989:
990: MIDFUNC(2,zero_extend_16_rr,(W4 d, RR2 s))
991: {
992: int isrmw;
993:
994: if (isconst(s)) {
995: set_const(d,(uae_u32)(uae_u16)live.state[s].val);
996: return;
997: }
998:
999: isrmw=(s==d);
1000: CLOBBER_ZE16;
1001: if (!isrmw) {
1002: s=readreg(s,2);
1003: d=writereg(d,4);
1004: }
1005: else { /* If we try to lock this twice, with different sizes, we
1.1.1.3 ! root 1006: are int trouble! */
1.1 root 1007: s=d=rmw(s,4,2);
1008: }
1009: raw_zero_extend_16_rr(d,s);
1010: if (!isrmw) {
1011: unlock2(d);
1012: unlock2(s);
1013: }
1014: else {
1015: unlock2(s);
1016: }
1017: }
1018: MENDFUNC(2,zero_extend_16_rr,(W4 d, RR2 s))
1019:
1020: MIDFUNC(2,zero_extend_8_rr,(W4 d, RR1 s))
1021: {
1022: int isrmw;
1023: if (isconst(s)) {
1024: set_const(d,(uae_u32)(uae_u8)live.state[s].val);
1025: return;
1026: }
1027:
1028: isrmw=(s==d);
1029: CLOBBER_ZE8;
1030: if (!isrmw) {
1031: s=readreg(s,1);
1032: d=writereg(d,4);
1033: }
1034: else { /* If we try to lock this twice, with different sizes, we
1.1.1.3 ! root 1035: are int trouble! */
1.1 root 1036: s=d=rmw(s,4,1);
1037: }
1038:
1039: raw_zero_extend_8_rr(d,s);
1040:
1041: if (!isrmw) {
1042: unlock2(d);
1043: unlock2(s);
1044: }
1045: else {
1046: unlock2(s);
1047: }
1048: }
1049: MENDFUNC(2,zero_extend_8_rr,(W4 d, RR1 s))
1050:
1051: MIDFUNC(2,mov_b_rr,(W1 d, RR1 s))
1052: {
1053: if (d==s)
1054: return;
1055: if (isconst(s)) {
1056: COMPCALL(mov_b_ri)(d,(uae_u8)live.state[s].val);
1057: return;
1058: }
1059:
1060: CLOBBER_MOV;
1061: s=readreg(s,1);
1062: d=writereg(d,1);
1063: raw_mov_b_rr(d,s);
1064: unlock2(d);
1065: unlock2(s);
1066: }
1067: MENDFUNC(2,mov_b_rr,(W1 d, RR1 s))
1068:
1069: MIDFUNC(2,mov_w_rr,(W2 d, RR2 s))
1070: {
1071: if (d==s)
1072: return;
1073: if (isconst(s)) {
1074: COMPCALL(mov_w_ri)(d,(uae_u16)live.state[s].val);
1075: return;
1076: }
1077:
1078: CLOBBER_MOV;
1079: s=readreg(s,2);
1080: d=writereg(d,2);
1081: raw_mov_w_rr(d,s);
1082: unlock2(d);
1083: unlock2(s);
1084: }
1085: MENDFUNC(2,mov_w_rr,(W2 d, RR2 s))
1086:
1087: MIDFUNC(4,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index, IMM factor))
1088: {
1089: CLOBBER_MOV;
1090: baser=readreg(baser,4);
1091: index=readreg(index,4);
1092: d=writereg(d,4);
1093:
1094: raw_mov_l_rrm_indexed(d,baser,index,factor);
1095: unlock2(d);
1096: unlock2(baser);
1097: unlock2(index);
1098: }
1099: MENDFUNC(4,mov_l_rrm_indexed,(W4 d,RR4 baser, RR4 index, IMM factor))
1100:
1101: MIDFUNC(4,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index, IMM factor))
1102: {
1103: CLOBBER_MOV;
1104: baser=readreg(baser,4);
1105: index=readreg(index,4);
1106: d=writereg(d,2);
1107:
1108: raw_mov_w_rrm_indexed(d,baser,index,factor);
1109: unlock2(d);
1110: unlock2(baser);
1111: unlock2(index);
1112: }
1113: MENDFUNC(4,mov_w_rrm_indexed,(W2 d, RR4 baser, RR4 index, IMM factor))
1114:
1115: MIDFUNC(4,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index, IMM factor))
1116: {
1117: CLOBBER_MOV;
1118: baser=readreg(baser,4);
1119: index=readreg(index,4);
1120: d=writereg(d,1);
1121:
1122: raw_mov_b_rrm_indexed(d,baser,index,factor);
1123:
1124: unlock2(d);
1125: unlock2(baser);
1126: unlock2(index);
1127: }
1128: MENDFUNC(4,mov_b_rrm_indexed,(W1 d, RR4 baser, RR4 index, IMM factor))
1129:
1130:
1131: MIDFUNC(4,mov_l_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR4 s))
1132: {
1133: CLOBBER_MOV;
1134: baser=readreg(baser,4);
1135: index=readreg(index,4);
1136: s=readreg(s,4);
1137:
1138: Dif (baser==s || index==s)
1139: jit_abort("mov_l_mrr_indexed");
1140:
1141:
1142: raw_mov_l_mrr_indexed(baser,index,factor,s);
1143: unlock2(s);
1144: unlock2(baser);
1145: unlock2(index);
1146: }
1147: MENDFUNC(4,mov_l_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR4 s))
1148:
1149: MIDFUNC(4,mov_w_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR2 s))
1150: {
1151: CLOBBER_MOV;
1152: baser=readreg(baser,4);
1153: index=readreg(index,4);
1154: s=readreg(s,2);
1155:
1156: raw_mov_w_mrr_indexed(baser,index,factor,s);
1157: unlock2(s);
1158: unlock2(baser);
1159: unlock2(index);
1160: }
1161: MENDFUNC(4,mov_w_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR2 s))
1162:
1163: MIDFUNC(4,mov_b_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR1 s))
1164: {
1165: CLOBBER_MOV;
1166: s=readreg(s,1);
1167: baser=readreg(baser,4);
1168: index=readreg(index,4);
1169:
1170: raw_mov_b_mrr_indexed(baser,index,factor,s);
1171: unlock2(s);
1172: unlock2(baser);
1173: unlock2(index);
1174: }
1175: MENDFUNC(4,mov_b_mrr_indexed,(RR4 baser, RR4 index, IMM factor, RR1 s))
1176:
1177:
1178: MIDFUNC(5,mov_l_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR4 s))
1179: {
1.1.1.3 ! root 1180: int basereg=baser;
! 1181: int indexreg=index;
1.1 root 1182:
1.1.1.3 ! root 1183: CLOBBER_MOV;
! 1184: s=readreg(s,4);
! 1185: baser=readreg_offset(baser,4);
! 1186: index=readreg_offset(index,4);
! 1187:
! 1188: base+=get_offset(basereg);
! 1189: base+=factor*get_offset(indexreg);
! 1190:
! 1191: raw_mov_l_bmrr_indexed(base,baser,index,factor,s);
! 1192: unlock2(s);
! 1193: unlock2(baser);
! 1194: unlock2(index);
1.1 root 1195: }
1196: MENDFUNC(5,mov_l_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR4 s))
1197:
1198: MIDFUNC(5,mov_w_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR2 s))
1199: {
1.1.1.3 ! root 1200: int basereg=baser;
! 1201: int indexreg=index;
1.1 root 1202:
1.1.1.3 ! root 1203: CLOBBER_MOV;
! 1204: s=readreg(s,2);
! 1205: baser=readreg_offset(baser,4);
! 1206: index=readreg_offset(index,4);
! 1207:
! 1208: base+=get_offset(basereg);
! 1209: base+=factor*get_offset(indexreg);
! 1210:
! 1211: raw_mov_w_bmrr_indexed(base,baser,index,factor,s);
! 1212: unlock2(s);
! 1213: unlock2(baser);
! 1214: unlock2(index);
1.1 root 1215: }
1216: MENDFUNC(5,mov_w_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR2 s))
1217:
1218: MIDFUNC(5,mov_b_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR1 s))
1219: {
1.1.1.3 ! root 1220: int basereg=baser;
! 1221: int indexreg=index;
1.1 root 1222:
1.1.1.3 ! root 1223: CLOBBER_MOV;
! 1224: s=readreg(s,1);
! 1225: baser=readreg_offset(baser,4);
! 1226: index=readreg_offset(index,4);
! 1227:
! 1228: base+=get_offset(basereg);
! 1229: base+=factor*get_offset(indexreg);
! 1230:
! 1231: raw_mov_b_bmrr_indexed(base,baser,index,factor,s);
! 1232: unlock2(s);
! 1233: unlock2(baser);
! 1234: unlock2(index);
1.1 root 1235: }
1236: MENDFUNC(5,mov_b_bmrr_indexed,(IMM base, RR4 baser, RR4 index, IMM factor, RR1 s))
1237:
1238:
1239:
1240: /* Read a long from base+baser+factor*index */
1241: MIDFUNC(5,mov_l_brrm_indexed,(W4 d, IMM base, RR4 baser, RR4 index, IMM factor))
1242: {
1.1.1.3 ! root 1243: int basereg=baser;
! 1244: int indexreg=index;
1.1 root 1245:
1.1.1.3 ! root 1246: CLOBBER_MOV;
! 1247: baser=readreg_offset(baser,4);
! 1248: index=readreg_offset(index,4);
! 1249: base+=get_offset(basereg);
! 1250: base+=factor*get_offset(indexreg);
! 1251: d=writereg(d,4);
! 1252: raw_mov_l_brrm_indexed(d,base,baser,index,factor);
! 1253: unlock2(d);
! 1254: unlock2(baser);
! 1255: unlock2(index);
1.1 root 1256: }
1257: MENDFUNC(5,mov_l_brrm_indexed,(W4 d, IMM base, RR4 baser, RR4 index, IMM factor))
1258:
1259:
1260: MIDFUNC(5,mov_w_brrm_indexed,(W2 d, IMM base, RR4 baser, RR4 index, IMM factor))
1261: {
1.1.1.3 ! root 1262: int basereg=baser;
! 1263: int indexreg=index;
1.1 root 1264:
1.1.1.3 ! root 1265: CLOBBER_MOV;
! 1266: remove_offset(d,-1);
! 1267: baser=readreg_offset(baser,4);
! 1268: index=readreg_offset(index,4);
! 1269: base+=get_offset(basereg);
! 1270: base+=factor*get_offset(indexreg);
! 1271: d=writereg(d,2);
! 1272: raw_mov_w_brrm_indexed(d,base,baser,index,factor);
! 1273: unlock2(d);
! 1274: unlock2(baser);
! 1275: unlock2(index);
1.1 root 1276: }
1277: MENDFUNC(5,mov_w_brrm_indexed,(W2 d, IMM base, RR4 baser, RR4 index, IMM factor))
1278:
1279:
1280: MIDFUNC(5,mov_b_brrm_indexed,(W1 d, IMM base, RR4 baser, RR4 index, IMM factor))
1281: {
1.1.1.3 ! root 1282: int basereg=baser;
! 1283: int indexreg=index;
1.1 root 1284:
1.1.1.3 ! root 1285: CLOBBER_MOV;
! 1286: remove_offset(d,-1);
! 1287: baser=readreg_offset(baser,4);
! 1288: index=readreg_offset(index,4);
! 1289: base+=get_offset(basereg);
! 1290: base+=factor*get_offset(indexreg);
! 1291: d=writereg(d,1);
! 1292: raw_mov_b_brrm_indexed(d,base,baser,index,factor);
! 1293: unlock2(d);
! 1294: unlock2(baser);
! 1295: unlock2(index);
1.1 root 1296: }
1297: MENDFUNC(5,mov_b_brrm_indexed,(W1 d, IMM base, RR4 baser, RR4 index, IMM factor))
1298:
1299: /* Read a long from base+factor*index */
1300: MIDFUNC(4,mov_l_rm_indexed,(W4 d, IMM base, RR4 index, IMM factor))
1301: {
1302: int indexreg=index;
1303:
1304: if (isconst(index)) {
1305: COMPCALL(mov_l_rm)(d,base+factor*live.state[index].val);
1306: return;
1307: }
1308:
1309: CLOBBER_MOV;
1310: index=readreg_offset(index,4);
1311: base+=get_offset(indexreg)*factor;
1312: d=writereg(d,4);
1313:
1314: raw_mov_l_rm_indexed(d,base,index,factor);
1315: unlock2(index);
1316: unlock2(d);
1317: }
1318: MENDFUNC(4,mov_l_rm_indexed,(W4 d, IMM base, RR4 index, IMM factor))
1319:
1320: /* read the long at the address contained in s+offset and store in d */
1321: MIDFUNC(3,mov_l_rR,(W4 d, RR4 s, IMM offset))
1322: {
1323: if (isconst(s)) {
1324: COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
1325: return;
1326: }
1327: CLOBBER_MOV;
1328: s=readreg(s,4);
1329: d=writereg(d,4);
1330:
1331: raw_mov_l_rR(d,s,offset);
1332: unlock2(d);
1333: unlock2(s);
1334: }
1335: MENDFUNC(3,mov_l_rR,(W4 d, RR4 s, IMM offset))
1336:
1337: /* read the word at the address contained in s+offset and store in d */
1338: MIDFUNC(3,mov_w_rR,(W2 d, RR4 s, IMM offset))
1339: {
1340: if (isconst(s)) {
1341: COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
1342: return;
1343: }
1344: CLOBBER_MOV;
1345: s=readreg(s,4);
1346: d=writereg(d,2);
1347:
1348: raw_mov_w_rR(d,s,offset);
1349: unlock2(d);
1350: unlock2(s);
1351: }
1352: MENDFUNC(3,mov_w_rR,(W2 d, RR4 s, IMM offset))
1353:
1354: /* read the word at the address contained in s+offset and store in d */
1355: MIDFUNC(3,mov_b_rR,(W1 d, RR4 s, IMM offset))
1356: {
1357: if (isconst(s)) {
1358: COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
1359: return;
1360: }
1361: CLOBBER_MOV;
1362: s=readreg(s,4);
1363: d=writereg(d,1);
1364:
1365: raw_mov_b_rR(d,s,offset);
1366: unlock2(d);
1367: unlock2(s);
1368: }
1369: MENDFUNC(3,mov_b_rR,(W1 d, RR4 s, IMM offset))
1370:
1371: /* read the long at the address contained in s+offset and store in d */
1372: MIDFUNC(3,mov_l_brR,(W4 d, RR4 s, IMM offset))
1373: {
1374: int sreg=s;
1375: if (isconst(s)) {
1376: COMPCALL(mov_l_rm)(d,live.state[s].val+offset);
1377: return;
1378: }
1379: CLOBBER_MOV;
1380: s=readreg_offset(s,4);
1381: offset+=get_offset(sreg);
1382: d=writereg(d,4);
1383:
1384: raw_mov_l_brR(d,s,offset);
1385: unlock2(d);
1386: unlock2(s);
1387: }
1388: MENDFUNC(3,mov_l_brR,(W4 d, RR4 s, IMM offset))
1389:
1390: /* read the word at the address contained in s+offset and store in d */
1391: MIDFUNC(3,mov_w_brR,(W2 d, RR4 s, IMM offset))
1392: {
1393: int sreg=s;
1394: if (isconst(s)) {
1395: COMPCALL(mov_w_rm)(d,live.state[s].val+offset);
1396: return;
1397: }
1398: CLOBBER_MOV;
1399: remove_offset(d,-1);
1400: s=readreg_offset(s,4);
1401: offset+=get_offset(sreg);
1402: d=writereg(d,2);
1403:
1404: raw_mov_w_brR(d,s,offset);
1405: unlock2(d);
1406: unlock2(s);
1407: }
1408: MENDFUNC(3,mov_w_brR,(W2 d, RR4 s, IMM offset))
1409:
1410: /* read the word at the address contained in s+offset and store in d */
1411: MIDFUNC(3,mov_b_brR,(W1 d, RR4 s, IMM offset))
1412: {
1413: int sreg=s;
1414: if (isconst(s)) {
1415: COMPCALL(mov_b_rm)(d,live.state[s].val+offset);
1416: return;
1417: }
1418: CLOBBER_MOV;
1419: remove_offset(d,-1);
1420: s=readreg_offset(s,4);
1421: offset+=get_offset(sreg);
1422: d=writereg(d,1);
1423:
1424: raw_mov_b_brR(d,s,offset);
1425: unlock2(d);
1426: unlock2(s);
1427: }
1428: MENDFUNC(3,mov_b_brR,(W1 d, RR4 s, IMM offset))
1429:
1430: MIDFUNC(3,mov_l_Ri,(RR4 d, IMM i, IMM offset))
1431: {
1432: int dreg=d;
1433: if (isconst(d)) {
1434: COMPCALL(mov_l_mi)(live.state[d].val+offset,i);
1435: return;
1436: }
1437:
1438: CLOBBER_MOV;
1439: d=readreg_offset(d,4);
1440: offset+=get_offset(dreg);
1441: raw_mov_l_Ri(d,i,offset);
1442: unlock2(d);
1443: }
1444: MENDFUNC(3,mov_l_Ri,(RR4 d, IMM i, IMM offset))
1445:
1446: MIDFUNC(3,mov_w_Ri,(RR4 d, IMM i, IMM offset))
1447: {
1448: int dreg=d;
1449: if (isconst(d)) {
1450: COMPCALL(mov_w_mi)(live.state[d].val+offset,i);
1451: return;
1452: }
1453:
1454: CLOBBER_MOV;
1455: d=readreg_offset(d,4);
1456: offset+=get_offset(dreg);
1457: raw_mov_w_Ri(d,i,offset);
1458: unlock2(d);
1459: }
1460: MENDFUNC(3,mov_w_Ri,(RR4 d, IMM i, IMM offset))
1461:
1462: MIDFUNC(3,mov_b_Ri,(RR4 d, IMM i, IMM offset))
1463: {
1464: int dreg=d;
1465: if (isconst(d)) {
1466: COMPCALL(mov_b_mi)(live.state[d].val+offset,i);
1467: return;
1468: }
1469:
1470: CLOBBER_MOV;
1471: d=readreg_offset(d,4);
1472: offset+=get_offset(dreg);
1473: raw_mov_b_Ri(d,i,offset);
1474: unlock2(d);
1475: }
1476: MENDFUNC(3,mov_b_Ri,(RR4 d, IMM i, IMM offset))
1477:
1478: /* Warning! OFFSET is byte sized only! */
1479: MIDFUNC(3,mov_l_Rr,(RR4 d, RR4 s, IMM offset))
1480: {
1481: if (isconst(d)) {
1482: COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
1483: return;
1484: }
1485: if (isconst(s)) {
1486: COMPCALL(mov_l_Ri)(d,live.state[s].val,offset);
1487: return;
1488: }
1489:
1490: CLOBBER_MOV;
1491: s=readreg(s,4);
1492: d=readreg(d,4);
1493:
1494: raw_mov_l_Rr(d,s,offset);
1495: unlock2(d);
1496: unlock2(s);
1497: }
1498: MENDFUNC(3,mov_l_Rr,(RR4 d, RR4 s, IMM offset))
1499:
1500: MIDFUNC(3,mov_w_Rr,(RR4 d, RR2 s, IMM offset))
1501: {
1502: if (isconst(d)) {
1503: COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
1504: return;
1505: }
1506: if (isconst(s)) {
1507: COMPCALL(mov_w_Ri)(d,(uae_u16)live.state[s].val,offset);
1508: return;
1509: }
1510:
1511: CLOBBER_MOV;
1512: s=readreg(s,2);
1513: d=readreg(d,4);
1514: raw_mov_w_Rr(d,s,offset);
1515: unlock2(d);
1516: unlock2(s);
1517: }
1518: MENDFUNC(3,mov_w_Rr,(RR4 d, RR2 s, IMM offset))
1519:
1520: MIDFUNC(3,mov_b_Rr,(RR4 d, RR1 s, IMM offset))
1521: {
1522: if (isconst(d)) {
1523: COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
1524: return;
1525: }
1526: if (isconst(s)) {
1527: COMPCALL(mov_b_Ri)(d,(uae_u8)live.state[s].val,offset);
1528: return;
1529: }
1530:
1531: CLOBBER_MOV;
1532: s=readreg(s,1);
1533: d=readreg(d,4);
1534: raw_mov_b_Rr(d,s,offset);
1535: unlock2(d);
1536: unlock2(s);
1537: }
1538: MENDFUNC(3,mov_b_Rr,(RR4 d, RR1 s, IMM offset))
1539:
1540: MIDFUNC(3,lea_l_brr,(W4 d, RR4 s, IMM offset))
1541: {
1542: if (isconst(s)) {
1543: COMPCALL(mov_l_ri)(d,live.state[s].val+offset);
1544: return;
1545: }
1546: #if USE_OFFSET
1547: if (d==s) {
1548: add_offset(d,offset);
1549: return;
1550: }
1551: #endif
1552: CLOBBER_LEA;
1553: s=readreg(s,4);
1554: d=writereg(d,4);
1555: raw_lea_l_brr(d,s,offset);
1556: unlock2(d);
1557: unlock2(s);
1558: }
1559: MENDFUNC(3,lea_l_brr,(W4 d, RR4 s, IMM offset))
1560:
1561: MIDFUNC(5,lea_l_brr_indexed,(W4 d, RR4 s, RR4 index, IMM factor, IMM offset))
1562: {
1563: if (!offset) {
1564: COMPCALL(lea_l_rr_indexed)(d,s,index,factor);
1565: return;
1566: }
1567: CLOBBER_LEA;
1568: s=readreg(s,4);
1569: index=readreg(index,4);
1570: d=writereg(d,4);
1571:
1572: raw_lea_l_brr_indexed(d,s,index,factor,offset);
1573: unlock2(d);
1574: unlock2(index);
1575: unlock2(s);
1576: }
1577: MENDFUNC(5,lea_l_brr_indexed,(W4 d, RR4 s, RR4 index, IMM factor, IMM offset))
1578:
1579: MIDFUNC(4,lea_l_rr_indexed,(W4 d, RR4 s, RR4 index, IMM factor))
1580: {
1.1.1.3 ! root 1581: CLOBBER_LEA;
! 1582: s=readreg(s,4);
! 1583: index=readreg(index,4);
! 1584: d=writereg(d,4);
! 1585:
! 1586: raw_lea_l_rr_indexed(d,s,index,factor);
! 1587: unlock2(d);
! 1588: unlock2(index);
! 1589: unlock2(s);
1.1 root 1590: }
1591: MENDFUNC(4,lea_l_rr_indexed,(W4 d, RR4 s, RR4 index, IMM factor))
1592:
1593: /* write d to the long at the address contained in s+offset */
1594: MIDFUNC(3,mov_l_bRr,(RR4 d, RR4 s, IMM offset))
1595: {
1596: int dreg=d;
1597: if (isconst(d)) {
1598: COMPCALL(mov_l_mr)(live.state[d].val+offset,s);
1599: return;
1600: }
1601:
1602: CLOBBER_MOV;
1603: s=readreg(s,4);
1604: d=readreg_offset(d,4);
1605: offset+=get_offset(dreg);
1606:
1607: raw_mov_l_bRr(d,s,offset);
1608: unlock2(d);
1609: unlock2(s);
1610: }
1611: MENDFUNC(3,mov_l_bRr,(RR4 d, RR4 s, IMM offset))
1612:
1613: /* write the word at the address contained in s+offset and store in d */
1614: MIDFUNC(3,mov_w_bRr,(RR4 d, RR2 s, IMM offset))
1615: {
1616: int dreg=d;
1617:
1618: if (isconst(d)) {
1619: COMPCALL(mov_w_mr)(live.state[d].val+offset,s);
1620: return;
1621: }
1622:
1623: CLOBBER_MOV;
1624: s=readreg(s,2);
1625: d=readreg_offset(d,4);
1626: offset+=get_offset(dreg);
1627: raw_mov_w_bRr(d,s,offset);
1628: unlock2(d);
1629: unlock2(s);
1630: }
1631: MENDFUNC(3,mov_w_bRr,(RR4 d, RR2 s, IMM offset))
1632:
1633: MIDFUNC(3,mov_b_bRr,(RR4 d, RR1 s, IMM offset))
1634: {
1635: int dreg=d;
1636: if (isconst(d)) {
1637: COMPCALL(mov_b_mr)(live.state[d].val+offset,s);
1638: return;
1639: }
1640:
1641: CLOBBER_MOV;
1642: s=readreg(s,1);
1643: d=readreg_offset(d,4);
1644: offset+=get_offset(dreg);
1645: raw_mov_b_bRr(d,s,offset);
1646: unlock2(d);
1647: unlock2(s);
1648: }
1649: MENDFUNC(3,mov_b_bRr,(RR4 d, RR1 s, IMM offset))
1650:
1651: MIDFUNC(1,mid_bswap_32,(RW4 r))
1652: {
1653:
1654: if (isconst(r)) {
1655: uae_u32 oldv=live.state[r].val;
1656: live.state[r].val=reverse32(oldv);
1657: return;
1658: }
1659:
1660: CLOBBER_SW32;
1661: r=rmw(r,4,4);
1662: raw_bswap_32(r);
1663: unlock2(r);
1664: }
1665: MENDFUNC(1,mid_bswap_32,(RW4 r))
1666:
1667: MIDFUNC(1,mid_bswap_16,(RW2 r))
1668: {
1669: if (isconst(r)) {
1670: uae_u32 oldv=live.state[r].val;
1.1.1.3 ! root 1671: live.state[r].val=((oldv>>8)&0xff) | ((oldv<<8)&0xff00) | (oldv&0xffff0000);
1.1 root 1672: return;
1673: }
1674:
1675: CLOBBER_SW16;
1676: r=rmw(r,2,2);
1677:
1678: raw_bswap_16(r);
1679: unlock2(r);
1680: }
1681: MENDFUNC(1,mid_bswap_16,(RW2 r))
1682:
1683:
1684:
1685: MIDFUNC(2,mov_l_rr,(W4 d, RR4 s))
1686: {
1687: int olds;
1688:
1689: if (d==s) { /* How pointless! */
1690: return;
1691: }
1692: if (isconst(s)) {
1693: COMPCALL(mov_l_ri)(d,live.state[s].val);
1694: return;
1695: }
1696: olds=s;
1697: disassociate(d);
1698: s=readreg_offset(s,4);
1699: live.state[d].realreg=s;
1700: live.state[d].realind=live.nat[s].nholds;
1701: live.state[d].val=live.state[olds].val;
1702: live.state[d].validsize=4;
1703: live.state[d].dirtysize=4;
1704: set_status(d,DIRTY);
1705:
1706: live.nat[s].holds[live.nat[s].nholds]=d;
1707: live.nat[s].nholds++;
1708: log_clobberreg(d);
1709: jit_log2("Added %d to nreg %d(%d), now holds %d regs", d,s,live.state[d].realind,live.nat[s].nholds);
1710: unlock2(s);
1711: }
1712: MENDFUNC(2,mov_l_rr,(W4 d, RR4 s))
1713:
1714: MIDFUNC(2,mov_l_mr,(IMM d, RR4 s))
1715: {
1716: if (isconst(s)) {
1717: COMPCALL(mov_l_mi)(d,live.state[s].val);
1718: return;
1719: }
1720: CLOBBER_MOV;
1721: s=readreg(s,4);
1722:
1723: raw_mov_l_mr(d,s);
1724: unlock2(s);
1725: }
1726: MENDFUNC(2,mov_l_mr,(IMM d, RR4 s))
1727:
1728:
1729: MIDFUNC(2,mov_w_mr,(IMM d, RR2 s))
1730: {
1731: if (isconst(s)) {
1732: COMPCALL(mov_w_mi)(d,(uae_u16)live.state[s].val);
1733: return;
1734: }
1735: CLOBBER_MOV;
1736: s=readreg(s,2);
1737:
1738: raw_mov_w_mr(d,s);
1739: unlock2(s);
1740: }
1741: MENDFUNC(2,mov_w_mr,(IMM d, RR2 s))
1742:
1743: MIDFUNC(2,mov_w_rm,(W2 d, IMM s))
1744: {
1745: CLOBBER_MOV;
1746: d=writereg(d,2);
1747:
1748: raw_mov_w_rm(d,s);
1749: unlock2(d);
1750: }
1751: MENDFUNC(2,mov_w_rm,(W2 d, IMM s))
1752:
1753: MIDFUNC(2,mov_b_mr,(IMM d, RR1 s))
1754: {
1755: if (isconst(s)) {
1756: COMPCALL(mov_b_mi)(d,(uae_u8)live.state[s].val);
1757: return;
1758: }
1759:
1760: CLOBBER_MOV;
1761: s=readreg(s,1);
1762:
1763: raw_mov_b_mr(d,s);
1764: unlock2(s);
1765: }
1766: MENDFUNC(2,mov_b_mr,(IMM d, RR1 s))
1767:
1768: MIDFUNC(2,mov_b_rm,(W1 d, IMM s))
1769: {
1770: CLOBBER_MOV;
1771: d=writereg(d,1);
1772:
1773: raw_mov_b_rm(d,s);
1774: unlock2(d);
1775: }
1776: MENDFUNC(2,mov_b_rm,(W1 d, IMM s))
1777:
1778: MIDFUNC(2,mov_l_ri,(W4 d, IMM s))
1779: {
1780: set_const(d,s);
1781: return;
1782: }
1783: MENDFUNC(2,mov_l_ri,(W4 d, IMM s))
1784:
1785: MIDFUNC(2,mov_w_ri,(W2 d, IMM s))
1786: {
1787: CLOBBER_MOV;
1788: d=writereg(d,2);
1789:
1790: raw_mov_w_ri(d,s);
1791: unlock2(d);
1792: }
1793: MENDFUNC(2,mov_w_ri,(W2 d, IMM s))
1794:
1795: MIDFUNC(2,mov_b_ri,(W1 d, IMM s))
1796: {
1797: CLOBBER_MOV;
1798: d=writereg(d,1);
1799:
1800: raw_mov_b_ri(d,s);
1801: unlock2(d);
1802: }
1803: MENDFUNC(2,mov_b_ri,(W1 d, IMM s))
1804:
1805: MIDFUNC(2,add_l_mi,(IMM d, IMM s))
1806: {
1807: CLOBBER_ADD;
1808: raw_add_l_mi(d,s) ;
1809: }
1810: MENDFUNC(2,add_l_mi,(IMM d, IMM s))
1811:
1812: MIDFUNC(2,add_w_mi,(IMM d, IMM s))
1813: {
1814: CLOBBER_ADD;
1815: raw_add_w_mi(d,s) ;
1816: }
1817: MENDFUNC(2,add_w_mi,(IMM d, IMM s))
1818:
1819: MIDFUNC(2,add_b_mi,(IMM d, IMM s))
1820: {
1821: CLOBBER_ADD;
1822: raw_add_b_mi(d,s) ;
1823: }
1824: MENDFUNC(2,add_b_mi,(IMM d, IMM s))
1825:
1826: MIDFUNC(2,test_l_ri,(RR4 d, IMM i))
1827: {
1828: CLOBBER_TEST;
1829: d=readreg(d,4);
1830:
1831: raw_test_l_ri(d,i);
1832: unlock2(d);
1833: }
1834: MENDFUNC(2,test_l_ri,(RR4 d, IMM i))
1835:
1836: MIDFUNC(2,test_l_rr,(RR4 d, RR4 s))
1837: {
1838: CLOBBER_TEST;
1839: d=readreg(d,4);
1840: s=readreg(s,4);
1841:
1842: raw_test_l_rr(d,s);;
1843: unlock2(d);
1844: unlock2(s);
1845: }
1846: MENDFUNC(2,test_l_rr,(RR4 d, RR4 s))
1847:
1848: MIDFUNC(2,test_w_rr,(RR2 d, RR2 s))
1849: {
1850: CLOBBER_TEST;
1851: d=readreg(d,2);
1852: s=readreg(s,2);
1853:
1854: raw_test_w_rr(d,s);
1855: unlock2(d);
1856: unlock2(s);
1857: }
1858: MENDFUNC(2,test_w_rr,(RR2 d, RR2 s))
1859:
1860: MIDFUNC(2,test_b_rr,(RR1 d, RR1 s))
1861: {
1862: CLOBBER_TEST;
1863: d=readreg(d,1);
1864: s=readreg(s,1);
1865:
1866: raw_test_b_rr(d,s);
1867: unlock2(d);
1868: unlock2(s);
1869: }
1870: MENDFUNC(2,test_b_rr,(RR1 d, RR1 s))
1871:
1872:
1873: MIDFUNC(2,and_l_ri,(RW4 d, IMM i))
1874: {
1.1.1.3 ! root 1875: if (isconst(d) && !needflags) {
1.1 root 1876: live.state[d].val &= i;
1877: return;
1878: }
1879:
1880: CLOBBER_AND;
1881: d=rmw(d,4,4);
1882:
1883: raw_and_l_ri(d,i);
1884: unlock2(d);
1885: }
1886: MENDFUNC(2,and_l_ri,(RW4 d, IMM i))
1887:
1888: MIDFUNC(2,and_l,(RW4 d, RR4 s))
1889: {
1890: CLOBBER_AND;
1891: s=readreg(s,4);
1892: d=rmw(d,4,4);
1893:
1894: raw_and_l(d,s);
1895: unlock2(d);
1896: unlock2(s);
1897: }
1898: MENDFUNC(2,and_l,(RW4 d, RR4 s))
1899:
1900: MIDFUNC(2,and_w,(RW2 d, RR2 s))
1901: {
1902: CLOBBER_AND;
1903: s=readreg(s,2);
1904: d=rmw(d,2,2);
1905:
1906: raw_and_w(d,s);
1907: unlock2(d);
1908: unlock2(s);
1909: }
1910: MENDFUNC(2,and_w,(RW2 d, RR2 s))
1911:
1912: MIDFUNC(2,and_b,(RW1 d, RR1 s))
1913: {
1914: CLOBBER_AND;
1915: s=readreg(s,1);
1916: d=rmw(d,1,1);
1917:
1918: raw_and_b(d,s);
1919: unlock2(d);
1920: unlock2(s);
1921: }
1922: MENDFUNC(2,and_b,(RW1 d, RR1 s))
1923:
1924: // gb-- used for making an fpcr value in compemu_fpp.cpp
1925: MIDFUNC(2,or_l_rm,(RW4 d, IMM s))
1926: {
1.1.1.3 ! root 1927: CLOBBER_OR;
! 1928: d=rmw(d,4,4);
1.1 root 1929:
1.1.1.3 ! root 1930: raw_or_l_rm(d,s);
! 1931: unlock2(d);
1.1 root 1932: }
1933: MENDFUNC(2,or_l_rm,(RW4 d, IMM s))
1934:
1935: MIDFUNC(2,or_l_ri,(RW4 d, IMM i))
1936: {
1937: if (isconst(d) && !needflags) {
1938: live.state[d].val|=i;
1939: return;
1940: }
1941: CLOBBER_OR;
1942: d=rmw(d,4,4);
1943:
1944: raw_or_l_ri(d,i);
1945: unlock2(d);
1946: }
1947: MENDFUNC(2,or_l_ri,(RW4 d, IMM i))
1948:
1949: MIDFUNC(2,or_l,(RW4 d, RR4 s))
1950: {
1951: if (isconst(d) && isconst(s) && !needflags) {
1952: live.state[d].val|=live.state[s].val;
1953: return;
1954: }
1955: CLOBBER_OR;
1956: s=readreg(s,4);
1957: d=rmw(d,4,4);
1958:
1959: raw_or_l(d,s);
1960: unlock2(d);
1961: unlock2(s);
1962: }
1963: MENDFUNC(2,or_l,(RW4 d, RR4 s))
1964:
1965: MIDFUNC(2,or_w,(RW2 d, RR2 s))
1966: {
1967: CLOBBER_OR;
1968: s=readreg(s,2);
1969: d=rmw(d,2,2);
1970:
1971: raw_or_w(d,s);
1972: unlock2(d);
1973: unlock2(s);
1974: }
1975: MENDFUNC(2,or_w,(RW2 d, RR2 s))
1976:
1977: MIDFUNC(2,or_b,(RW1 d, RR1 s))
1978: {
1979: CLOBBER_OR;
1980: s=readreg(s,1);
1981: d=rmw(d,1,1);
1982:
1983: raw_or_b(d,s);
1984: unlock2(d);
1985: unlock2(s);
1986: }
1987: MENDFUNC(2,or_b,(RW1 d, RR1 s))
1988:
1989: MIDFUNC(2,adc_l,(RW4 d, RR4 s))
1990: {
1991: CLOBBER_ADC;
1992: s=readreg(s,4);
1993: d=rmw(d,4,4);
1994:
1995: raw_adc_l(d,s);
1996:
1997: unlock2(d);
1998: unlock2(s);
1999: }
2000: MENDFUNC(2,adc_l,(RW4 d, RR4 s))
2001:
2002: MIDFUNC(2,adc_w,(RW2 d, RR2 s))
2003: {
2004: CLOBBER_ADC;
2005: s=readreg(s,2);
2006: d=rmw(d,2,2);
2007:
2008: raw_adc_w(d,s);
2009: unlock2(d);
2010: unlock2(s);
2011: }
2012: MENDFUNC(2,adc_w,(RW2 d, RR2 s))
2013:
2014: MIDFUNC(2,adc_b,(RW1 d, RR1 s))
2015: {
2016: CLOBBER_ADC;
2017: s=readreg(s,1);
2018: d=rmw(d,1,1);
2019:
2020: raw_adc_b(d,s);
2021: unlock2(d);
2022: unlock2(s);
2023: }
2024: MENDFUNC(2,adc_b,(RW1 d, RR1 s))
2025:
2026: MIDFUNC(2,add_l,(RW4 d, RR4 s))
2027: {
2028: if (isconst(s)) {
2029: COMPCALL(add_l_ri)(d,live.state[s].val);
2030: return;
2031: }
2032:
2033: CLOBBER_ADD;
2034: s=readreg(s,4);
2035: d=rmw(d,4,4);
2036:
2037: raw_add_l(d,s);
2038:
2039: unlock2(d);
2040: unlock2(s);
2041: }
2042: MENDFUNC(2,add_l,(RW4 d, RR4 s))
2043:
2044: MIDFUNC(2,add_w,(RW2 d, RR2 s))
2045: {
2046: if (isconst(s)) {
2047: COMPCALL(add_w_ri)(d,(uae_u16)live.state[s].val);
2048: return;
2049: }
2050:
2051: CLOBBER_ADD;
2052: s=readreg(s,2);
2053: d=rmw(d,2,2);
2054:
2055: raw_add_w(d,s);
2056: unlock2(d);
2057: unlock2(s);
2058: }
2059: MENDFUNC(2,add_w,(RW2 d, RR2 s))
2060:
2061: MIDFUNC(2,add_b,(RW1 d, RR1 s))
2062: {
2063: if (isconst(s)) {
2064: COMPCALL(add_b_ri)(d,(uae_u8)live.state[s].val);
2065: return;
2066: }
2067:
2068: CLOBBER_ADD;
2069: s=readreg(s,1);
2070: d=rmw(d,1,1);
2071:
2072: raw_add_b(d,s);
2073: unlock2(d);
2074: unlock2(s);
2075: }
2076: MENDFUNC(2,add_b,(RW1 d, RR1 s))
2077:
2078: MIDFUNC(2,sub_l_ri,(RW4 d, IMM i))
2079: {
2080: if (!i && !needflags)
2081: return;
2082: if (isconst(d) && !needflags) {
2083: live.state[d].val-=i;
2084: return;
2085: }
2086: #if USE_OFFSET
2087: if (!needflags) {
2088: add_offset(d,-i);
2089: return;
2090: }
2091: #endif
2092:
2093: CLOBBER_SUB;
2094: d=rmw(d,4,4);
2095:
2096: raw_sub_l_ri(d,i);
2097: unlock2(d);
2098: }
2099: MENDFUNC(2,sub_l_ri,(RW4 d, IMM i))
2100:
2101: MIDFUNC(2,sub_w_ri,(RW2 d, IMM i))
2102: {
2103: if (!i && !needflags)
2104: return;
2105:
2106: CLOBBER_SUB;
2107: d=rmw(d,2,2);
2108:
2109: raw_sub_w_ri(d,i);
2110: unlock2(d);
2111: }
2112: MENDFUNC(2,sub_w_ri,(RW2 d, IMM i))
2113:
2114: MIDFUNC(2,sub_b_ri,(RW1 d, IMM i))
2115: {
2116: if (!i && !needflags)
2117: return;
2118:
2119: CLOBBER_SUB;
2120: d=rmw(d,1,1);
2121:
2122: raw_sub_b_ri(d,i);
2123:
2124: unlock2(d);
2125: }
2126: MENDFUNC(2,sub_b_ri,(RW1 d, IMM i))
2127:
2128: MIDFUNC(2,add_l_ri,(RW4 d, IMM i))
2129: {
2130: if (!i && !needflags)
2131: return;
2132: if (isconst(d) && !needflags) {
2133: live.state[d].val+=i;
2134: return;
2135: }
2136: #if USE_OFFSET
2137: if (!needflags) {
2138: add_offset(d,i);
2139: return;
2140: }
2141: #endif
2142: CLOBBER_ADD;
2143: d=rmw(d,4,4);
2144: raw_add_l_ri(d,i);
2145: unlock2(d);
2146: }
2147: MENDFUNC(2,add_l_ri,(RW4 d, IMM i))
2148:
2149: MIDFUNC(2,add_w_ri,(RW2 d, IMM i))
2150: {
2151: if (!i && !needflags)
2152: return;
2153:
2154: CLOBBER_ADD;
2155: d=rmw(d,2,2);
2156:
2157: raw_add_w_ri(d,i);
2158: unlock2(d);
2159: }
2160: MENDFUNC(2,add_w_ri,(RW2 d, IMM i))
2161:
2162: MIDFUNC(2,add_b_ri,(RW1 d, IMM i))
2163: {
2164: if (!i && !needflags)
2165: return;
2166:
2167: CLOBBER_ADD;
2168: d=rmw(d,1,1);
2169:
2170: raw_add_b_ri(d,i);
2171:
2172: unlock2(d);
2173: }
2174: MENDFUNC(2,add_b_ri,(RW1 d, IMM i))
2175:
2176: MIDFUNC(2,sbb_l,(RW4 d, RR4 s))
2177: {
2178: CLOBBER_SBB;
2179: s=readreg(s,4);
2180: d=rmw(d,4,4);
2181:
2182: raw_sbb_l(d,s);
2183: unlock2(d);
2184: unlock2(s);
2185: }
2186: MENDFUNC(2,sbb_l,(RW4 d, RR4 s))
2187:
2188: MIDFUNC(2,sbb_w,(RW2 d, RR2 s))
2189: {
2190: CLOBBER_SBB;
2191: s=readreg(s,2);
2192: d=rmw(d,2,2);
2193:
2194: raw_sbb_w(d,s);
2195: unlock2(d);
2196: unlock2(s);
2197: }
2198: MENDFUNC(2,sbb_w,(RW2 d, RR2 s))
2199:
2200: MIDFUNC(2,sbb_b,(RW1 d, RR1 s))
2201: {
2202: CLOBBER_SBB;
2203: s=readreg(s,1);
2204: d=rmw(d,1,1);
2205:
2206: raw_sbb_b(d,s);
2207: unlock2(d);
2208: unlock2(s);
2209: }
2210: MENDFUNC(2,sbb_b,(RW1 d, RR1 s))
2211:
2212: MIDFUNC(2,sub_l,(RW4 d, RR4 s))
2213: {
2214: if (isconst(s)) {
2215: COMPCALL(sub_l_ri)(d,live.state[s].val);
2216: return;
2217: }
2218:
2219: CLOBBER_SUB;
2220: s=readreg(s,4);
2221: d=rmw(d,4,4);
2222:
2223: raw_sub_l(d,s);
2224: unlock2(d);
2225: unlock2(s);
2226: }
2227: MENDFUNC(2,sub_l,(RW4 d, RR4 s))
2228:
2229: MIDFUNC(2,sub_w,(RW2 d, RR2 s))
2230: {
2231: if (isconst(s)) {
2232: COMPCALL(sub_w_ri)(d,(uae_u16)live.state[s].val);
2233: return;
2234: }
2235:
2236: CLOBBER_SUB;
2237: s=readreg(s,2);
2238: d=rmw(d,2,2);
2239:
2240: raw_sub_w(d,s);
2241: unlock2(d);
2242: unlock2(s);
2243: }
2244: MENDFUNC(2,sub_w,(RW2 d, RR2 s))
2245:
2246: MIDFUNC(2,sub_b,(RW1 d, RR1 s))
2247: {
2248: if (isconst(s)) {
2249: COMPCALL(sub_b_ri)(d,(uae_u8)live.state[s].val);
2250: return;
2251: }
2252:
2253: CLOBBER_SUB;
2254: s=readreg(s,1);
2255: d=rmw(d,1,1);
2256:
2257: raw_sub_b(d,s);
2258: unlock2(d);
2259: unlock2(s);
2260: }
2261: MENDFUNC(2,sub_b,(RW1 d, RR1 s))
2262:
2263: MIDFUNC(2,cmp_l,(RR4 d, RR4 s))
2264: {
2265: CLOBBER_CMP;
2266: s=readreg(s,4);
2267: d=readreg(d,4);
2268:
2269: raw_cmp_l(d,s);
2270: unlock2(d);
2271: unlock2(s);
2272: }
2273: MENDFUNC(2,cmp_l,(RR4 d, RR4 s))
2274:
2275: MIDFUNC(2,cmp_l_ri,(RR4 r, IMM i))
2276: {
2277: CLOBBER_CMP;
2278: r=readreg(r,4);
2279:
2280: raw_cmp_l_ri(r,i);
2281: unlock2(r);
2282: }
2283: MENDFUNC(2,cmp_l_ri,(RR4 r, IMM i))
2284:
2285: MIDFUNC(2,cmp_w,(RR2 d, RR2 s))
2286: {
2287: CLOBBER_CMP;
2288: s=readreg(s,2);
2289: d=readreg(d,2);
2290:
2291: raw_cmp_w(d,s);
2292: unlock2(d);
2293: unlock2(s);
2294: }
2295: MENDFUNC(2,cmp_w,(RR2 d, RR2 s))
2296:
2297: MIDFUNC(2,cmp_b,(RR1 d, RR1 s))
2298: {
2299: CLOBBER_CMP;
2300: s=readreg(s,1);
2301: d=readreg(d,1);
2302:
2303: raw_cmp_b(d,s);
2304: unlock2(d);
2305: unlock2(s);
2306: }
2307: MENDFUNC(2,cmp_b,(RR1 d, RR1 s))
2308:
2309:
2310: MIDFUNC(2,xor_l,(RW4 d, RR4 s))
2311: {
2312: CLOBBER_XOR;
2313: s=readreg(s,4);
2314: d=rmw(d,4,4);
2315:
2316: raw_xor_l(d,s);
2317: unlock2(d);
2318: unlock2(s);
2319: }
2320: MENDFUNC(2,xor_l,(RW4 d, RR4 s))
2321:
2322: MIDFUNC(2,xor_w,(RW2 d, RR2 s))
2323: {
2324: CLOBBER_XOR;
2325: s=readreg(s,2);
2326: d=rmw(d,2,2);
2327:
2328: raw_xor_w(d,s);
2329: unlock2(d);
2330: unlock2(s);
2331: }
2332: MENDFUNC(2,xor_w,(RW2 d, RR2 s))
2333:
2334: MIDFUNC(2,xor_b,(RW1 d, RR1 s))
2335: {
2336: CLOBBER_XOR;
2337: s=readreg(s,1);
2338: d=rmw(d,1,1);
2339:
2340: raw_xor_b(d,s);
2341: unlock2(d);
2342: unlock2(s);
2343: }
2344: MENDFUNC(2,xor_b,(RW1 d, RR1 s))
2345:
2346: MIDFUNC(5,call_r_11,(W4 out1, RR4 r, RR4 in1, IMM osize, IMM isize))
2347: {
2348: clobber_flags();
2349: remove_all_offsets();
2350: if (osize==4) {
2351: if (out1!=in1 && out1!=r) {
2352: COMPCALL(forget_about)(out1);
2353: }
2354: }
2355: else {
2356: tomem_c(out1);
2357: }
2358:
2359: in1=readreg_specific(in1,isize,REG_PAR1);
2360: r=readreg(r,4);
2361: prepare_for_call_1(); /* This should ensure that there won't be
1.1.1.3 ! root 2362: any need for swapping nregs in prepare_for_call_2
! 2363: */
1.1 root 2364: #if USE_NORMAL_CALLING_CONVENTION
2365: raw_push_l_r(in1);
2366: #endif
2367: unlock2(in1);
2368: unlock2(r);
2369:
2370: prepare_for_call_2();
2371: raw_dec_sp(STACK_SHADOW_SPACE);
2372: raw_call_r(r);
2373: raw_inc_sp(STACK_SHADOW_SPACE);
2374:
2375: #if USE_NORMAL_CALLING_CONVENTION
2376: raw_inc_sp(4);
2377: #endif
2378:
2379:
2380: live.nat[REG_RESULT].holds[0]=out1;
2381: live.nat[REG_RESULT].nholds=1;
2382: live.nat[REG_RESULT].touched=touchcnt++;
2383:
2384: live.state[out1].realreg=REG_RESULT;
2385: live.state[out1].realind=0;
2386: live.state[out1].val=0;
2387: live.state[out1].validsize=osize;
2388: live.state[out1].dirtysize=osize;
2389: set_status(out1,DIRTY);
2390: }
2391: MENDFUNC(5,call_r_11,(W4 out1, RR4 r, RR4 in1, IMM osize, IMM isize))
2392:
2393: MIDFUNC(5,call_r_02,(RR4 r, RR4 in1, RR4 in2, IMM isize1, IMM isize2))
2394: {
2395: clobber_flags();
2396: remove_all_offsets();
2397: in1=readreg_specific(in1,isize1,REG_PAR1);
2398: in2=readreg_specific(in2,isize2,REG_PAR2);
2399: r=readreg(r,4);
2400: prepare_for_call_1(); /* This should ensure that there won't be
1.1.1.3 ! root 2401: any need for swapping nregs in prepare_for_call_2
! 2402: */
1.1 root 2403: #if USE_NORMAL_CALLING_CONVENTION
2404: raw_push_l_r(in2);
2405: raw_push_l_r(in1);
2406: #endif
2407: unlock2(r);
2408: unlock2(in1);
2409: unlock2(in2);
2410: prepare_for_call_2();
2411: raw_dec_sp(STACK_SHADOW_SPACE);
2412: raw_call_r(r);
2413: raw_inc_sp(STACK_SHADOW_SPACE);
2414: #if USE_NORMAL_CALLING_CONVENTION
2415: raw_inc_sp(8);
2416: #endif
2417: }
2418: MENDFUNC(5,call_r_02,(RR4 r, RR4 in1, RR4 in2, IMM isize1, IMM isize2))
2419:
2420: /* forget_about() takes a mid-layer register */
2421: MIDFUNC(1,forget_about,(W4 r))
2422: {
2423: if (isinreg(r))
2424: disassociate(r);
2425: live.state[r].val=0;
2426: set_status(r,UNDEF);
2427: }
2428: MENDFUNC(1,forget_about,(W4 r))
2429:
2430: MIDFUNC(0,nop,(void))
2431: {
1.1.1.3 ! root 2432: raw_emit_nop();
1.1 root 2433: }
2434: MENDFUNC(0,nop,(void))
2435:
2436: MIDFUNC(1,f_forget_about,(FW r))
2437: {
2438: if (f_isinreg(r))
2439: f_disassociate(r);
2440: live.fate[r].status=UNDEF;
2441: }
2442: MENDFUNC(1,f_forget_about,(FW r))
2443:
2444: MIDFUNC(1,fmov_pi,(FW r))
2445: {
2446: r=f_writereg(r);
2447: raw_fmov_pi(r);
2448: f_unlock(r);
2449: }
2450: MENDFUNC(1,fmov_pi,(FW r))
2451:
2452: MIDFUNC(1,fmov_log10_2,(FW r))
2453: {
2454: r=f_writereg(r);
2455: raw_fmov_log10_2(r);
2456: f_unlock(r);
2457: }
2458: MENDFUNC(1,fmov_log10_2,(FW r))
2459:
2460: MIDFUNC(1,fmov_log2_e,(FW r))
2461: {
2462: r=f_writereg(r);
2463: raw_fmov_log2_e(r);
2464: f_unlock(r);
2465: }
2466: MENDFUNC(1,fmov_log2_e,(FW r))
2467:
2468: MIDFUNC(1,fmov_loge_2,(FW r))
2469: {
2470: r=f_writereg(r);
2471: raw_fmov_loge_2(r);
2472: f_unlock(r);
2473: }
2474: MENDFUNC(1,fmov_loge_2,(FW r))
2475:
2476: MIDFUNC(1,fmov_1,(FW r))
2477: {
2478: r=f_writereg(r);
2479: raw_fmov_1(r);
2480: f_unlock(r);
2481: }
2482: MENDFUNC(1,fmov_1,(FW r))
2483:
2484: MIDFUNC(1,fmov_0,(FW r))
2485: {
2486: r=f_writereg(r);
2487: raw_fmov_0(r);
2488: f_unlock(r);
2489: }
2490: MENDFUNC(1,fmov_0,(FW r))
2491:
2492: MIDFUNC(2,fmov_rm,(FW r, MEMR m))
2493: {
2494: r=f_writereg(r);
2495: raw_fmov_rm(r,m);
2496: f_unlock(r);
2497: }
2498: MENDFUNC(2,fmov_rm,(FW r, MEMR m))
2499:
2500: MIDFUNC(2,fmovi_rm,(FW r, MEMR m))
2501: {
2502: r=f_writereg(r);
2503: raw_fmovi_rm(r,m);
2504: f_unlock(r);
2505: }
2506: MENDFUNC(2,fmovi_rm,(FW r, MEMR m))
2507:
1.1.1.3 ! root 2508: MIDFUNC(2,fmovi_mr,(MEMW m, FR r))
! 2509: {
! 2510: r=f_readreg(r);
! 2511: raw_fmovi_mr(m,r);
! 2512: f_unlock(r);
! 2513: }
! 2514: MENDFUNC(2,fmovi_mr,(MEMW m, FR r))
! 2515:
1.1 root 2516: MIDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
2517: {
2518: r=f_readreg(r);
2519: raw_fmovi_mrb(m,r,bounds);
2520: f_unlock(r);
2521: }
2522: MENDFUNC(3,fmovi_mrb,(MEMW m, FR r, double *bounds))
2523:
2524: MIDFUNC(2,fmovs_rm,(FW r, MEMR m))
2525: {
2526: r=f_writereg(r);
2527: raw_fmovs_rm(r,m);
2528: f_unlock(r);
2529: }
2530: MENDFUNC(2,fmovs_rm,(FW r, MEMR m))
2531:
2532: MIDFUNC(2,fmovs_mr,(MEMW m, FR r))
2533: {
2534: r=f_readreg(r);
2535: raw_fmovs_mr(m,r);
2536: f_unlock(r);
2537: }
2538: MENDFUNC(2,fmovs_mr,(MEMW m, FR r))
2539:
2540: MIDFUNC(1,fcuts_r,(FRW r))
2541: {
2542: r=f_rmw(r);
2543: raw_fcuts_r(r);
2544: f_unlock(r);
2545: }
2546: MENDFUNC(1,fcuts_r,(FRW r))
2547:
2548: MIDFUNC(1,fcut_r,(FRW r))
2549: {
2550: r=f_rmw(r);
2551: raw_fcut_r(r);
2552: f_unlock(r);
2553: }
2554: MENDFUNC(1,fcut_r,(FRW r))
2555:
2556: MIDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
2557: {
2558: r=f_readreg(r);
2559: raw_fmov_ext_mr(m,r);
2560: f_unlock(r);
2561: }
2562: MENDFUNC(2,fmov_ext_mr,(MEMW m, FR r))
2563:
2564: MIDFUNC(2,fmov_mr,(MEMW m, FR r))
2565: {
2566: r=f_readreg(r);
2567: raw_fmov_mr(m,r);
2568: f_unlock(r);
2569: }
2570: MENDFUNC(2,fmov_mr,(MEMW m, FR r))
2571:
2572: MIDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
2573: {
2574: r=f_writereg(r);
2575: raw_fmov_ext_rm(r,m);
2576: f_unlock(r);
2577: }
2578: MENDFUNC(2,fmov_ext_rm,(FW r, MEMR m))
2579:
2580: MIDFUNC(2,fmov_rr,(FW d, FR s))
2581: {
2582: if (d==s) { /* How pointless! */
2583: return;
2584: }
2585: #if USE_F_ALIAS
2586: f_disassociate(d);
2587: s=f_readreg(s);
2588: live.fate[d].realreg=s;
2589: live.fate[d].realind=live.fat[s].nholds;
2590: live.fate[d].status=DIRTY;
2591: live.fat[s].holds[live.fat[s].nholds]=d;
2592: live.fat[s].nholds++;
2593: f_unlock(s);
2594: #else
2595: s=f_readreg(s);
2596: d=f_writereg(d);
2597: raw_fmov_rr(d,s);
2598: f_unlock(s);
2599: f_unlock(d);
2600: #endif
2601: }
2602: MENDFUNC(2,fmov_rr,(FW d, FR s))
2603:
2604: MIDFUNC(2,fldcw_m_indexed,(RR4 index, IMM base))
2605: {
2606: index=readreg(index,4);
2607:
2608: raw_fldcw_m_indexed(index,base);
2609: unlock2(index);
2610: }
2611: MENDFUNC(2,fldcw_m_indexed,(RR4 index, IMM base))
2612:
2613: MIDFUNC(1,ftst_r,(FR r))
2614: {
2615: r=f_readreg(r);
2616: raw_ftst_r(r);
2617: f_unlock(r);
2618: }
2619: MENDFUNC(1,ftst_r,(FR r))
2620:
2621: MIDFUNC(0,dont_care_fflags,(void))
2622: {
2623: f_disassociate(FP_RESULT);
2624: }
2625: MENDFUNC(0,dont_care_fflags,(void))
2626:
2627: MIDFUNC(2,fsqrt_rr,(FW d, FR s))
2628: {
2629: s=f_readreg(s);
2630: d=f_writereg(d);
2631: raw_fsqrt_rr(d,s);
2632: f_unlock(s);
2633: f_unlock(d);
2634: }
2635: MENDFUNC(2,fsqrt_rr,(FW d, FR s))
2636:
2637: MIDFUNC(2,fabs_rr,(FW d, FR s))
2638: {
2639: s=f_readreg(s);
2640: d=f_writereg(d);
2641: raw_fabs_rr(d,s);
2642: f_unlock(s);
2643: f_unlock(d);
2644: }
2645: MENDFUNC(2,fabs_rr,(FW d, FR s))
2646:
2647: MIDFUNC(2,fgetexp_rr,(FW d, FR s))
2648: {
2649: s=f_readreg(s);
2650: d=f_writereg(d);
2651: raw_fgetexp_rr(d,s);
2652: f_unlock(s);
2653: f_unlock(d);
2654: }
2655: MENDFUNC(2,fgetexp_rr,(FW d, FR s))
2656:
2657: MIDFUNC(2,fgetman_rr,(FW d, FR s))
2658: {
2659: s=f_readreg(s);
2660: d=f_writereg(d);
2661: raw_fgetman_rr(d,s);
2662: f_unlock(s);
2663: f_unlock(d);
2664: }
2665: MENDFUNC(2,fgetman_rr,(FW d, FR s))
2666:
2667: MIDFUNC(2,fsin_rr,(FW d, FR s))
2668: {
2669: s=f_readreg(s);
2670: d=f_writereg(d);
2671: raw_fsin_rr(d,s);
2672: f_unlock(s);
2673: f_unlock(d);
2674: }
2675: MENDFUNC(2,fsin_rr,(FW d, FR s))
2676:
2677: MIDFUNC(2,fcos_rr,(FW d, FR s))
2678: {
2679: s=f_readreg(s);
2680: d=f_writereg(d);
2681: raw_fcos_rr(d,s);
2682: f_unlock(s);
2683: f_unlock(d);
2684: }
2685: MENDFUNC(2,fcos_rr,(FW d, FR s))
2686:
2687: MIDFUNC(2,ftan_rr,(FW d, FR s))
2688: {
2689: s=f_readreg(s);
2690: d=f_writereg(d);
2691: raw_ftan_rr(d,s);
2692: f_unlock(s);
2693: f_unlock(d);
2694: }
2695: MENDFUNC(2,ftan_rr,(FW d, FR s))
2696:
2697: MIDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
2698: {
2699: s=f_readreg(s); /* s for source */
2700: d=f_writereg(d); /* d for sine */
2701: c=f_writereg(c); /* c for cosine */
2702: raw_fsincos_rr(d,c,s);
2703: f_unlock(s);
2704: f_unlock(d);
2705: f_unlock(c);
2706: }
2707: MENDFUNC(3,fsincos_rr,(FW d, FW c, FR s))
2708:
2709: MIDFUNC(2,fscale_rr,(FRW d, FR s))
2710: {
2711: s=f_readreg(s);
2712: d=f_rmw(d);
2713: raw_fscale_rr(d,s);
2714: f_unlock(s);
2715: f_unlock(d);
2716: }
2717: MENDFUNC(2,fscale_rr,(FRW d, FR s))
2718:
2719: MIDFUNC(2,ftwotox_rr,(FW d, FR s))
2720: {
2721: s=f_readreg(s);
2722: d=f_writereg(d);
2723: raw_ftwotox_rr(d,s);
2724: f_unlock(s);
2725: f_unlock(d);
2726: }
2727: MENDFUNC(2,ftwotox_rr,(FW d, FR s))
2728:
2729: MIDFUNC(2,fetox_rr,(FW d, FR s))
2730: {
2731: s=f_readreg(s);
2732: d=f_writereg(d);
2733: raw_fetox_rr(d,s);
2734: f_unlock(s);
2735: f_unlock(d);
2736: }
2737: MENDFUNC(2,fetox_rr,(FW d, FR s))
2738:
2739: MIDFUNC(2,frndint_rr,(FW d, FR s))
2740: {
2741: s=f_readreg(s);
2742: d=f_writereg(d);
2743: raw_frndint_rr(d,s);
2744: f_unlock(s);
2745: f_unlock(d);
2746: }
2747: MENDFUNC(2,frndint_rr,(FW d, FR s))
2748:
2749: MIDFUNC(2,fetoxM1_rr,(FW d, FR s))
2750: {
2751: s=f_readreg(s);
2752: d=f_writereg(d);
2753: raw_fetoxM1_rr(d,s);
2754: f_unlock(s);
2755: f_unlock(d);
2756: }
2757: MENDFUNC(2,fetoxM1_rr,(FW d, FR s))
2758:
2759: MIDFUNC(2,ftentox_rr,(FW d, FR s))
2760: {
2761: s=f_readreg(s);
2762: d=f_writereg(d);
2763: raw_ftentox_rr(d,s);
2764: f_unlock(s);
2765: f_unlock(d);
2766: }
2767: MENDFUNC(2,ftentox_rr,(FW d, FR s))
2768:
2769: MIDFUNC(2,flog2_rr,(FW d, FR s))
2770: {
2771: s=f_readreg(s);
2772: d=f_writereg(d);
2773: raw_flog2_rr(d,s);
2774: f_unlock(s);
2775: f_unlock(d);
2776: }
2777: MENDFUNC(2,flog2_rr,(FW d, FR s))
2778:
2779: MIDFUNC(2,flogN_rr,(FW d, FR s))
2780: {
2781: s=f_readreg(s);
2782: d=f_writereg(d);
2783: raw_flogN_rr(d,s);
2784: f_unlock(s);
2785: f_unlock(d);
2786: }
2787: MENDFUNC(2,flogN_rr,(FW d, FR s))
2788:
2789: MIDFUNC(2,flogNP1_rr,(FW d, FR s))
2790: {
2791: s=f_readreg(s);
2792: d=f_writereg(d);
2793: raw_flogNP1_rr(d,s);
2794: f_unlock(s);
2795: f_unlock(d);
2796: }
2797: MENDFUNC(2,flogNP1_rr,(FW d, FR s))
2798:
2799: MIDFUNC(2,flog10_rr,(FW d, FR s))
2800: {
2801: s=f_readreg(s);
2802: d=f_writereg(d);
2803: raw_flog10_rr(d,s);
2804: f_unlock(s);
2805: f_unlock(d);
2806: }
2807: MENDFUNC(2,flog10_rr,(FW d, FR s))
2808:
2809: MIDFUNC(2,fasin_rr,(FW d, FR s))
2810: {
2811: s=f_readreg(s);
2812: d=f_writereg(d);
2813: raw_fasin_rr(d,s);
2814: f_unlock(s);
2815: f_unlock(d);
2816: }
2817: MENDFUNC(2,fasin_rr,(FW d, FR s))
2818:
2819: MIDFUNC(2,facos_rr,(FW d, FR s))
2820: {
2821: s=f_readreg(s);
2822: d=f_writereg(d);
2823: raw_facos_rr(d,s);
2824: f_unlock(s);
2825: f_unlock(d);
2826: }
2827: MENDFUNC(2,facos_rr,(FW d, FR s))
2828:
2829: MIDFUNC(2,fatan_rr,(FW d, FR s))
2830: {
2831: s=f_readreg(s);
2832: d=f_writereg(d);
2833: raw_fatan_rr(d,s);
2834: f_unlock(s);
2835: f_unlock(d);
2836: }
2837: MENDFUNC(2,fatan_rr,(FW d, FR s))
2838:
2839: MIDFUNC(2,fatanh_rr,(FW d, FR s))
2840: {
2841: s=f_readreg(s);
2842: d=f_writereg(d);
2843: raw_fatanh_rr(d,s);
2844: f_unlock(s);
2845: f_unlock(d);
2846: }
2847: MENDFUNC(2,fatanh_rr,(FW d, FR s))
2848:
2849: MIDFUNC(2,fsinh_rr,(FW d, FR s))
2850: {
2851: s=f_readreg(s);
2852: d=f_writereg(d);
2853: raw_fsinh_rr(d,s);
2854: f_unlock(s);
2855: f_unlock(d);
2856: }
2857: MENDFUNC(2,fsinh_rr,(FW d, FR s))
2858:
2859: MIDFUNC(2,fcosh_rr,(FW d, FR s))
2860: {
2861: s=f_readreg(s);
2862: d=f_writereg(d);
2863: raw_fcosh_rr(d,s);
2864: f_unlock(s);
2865: f_unlock(d);
2866: }
2867: MENDFUNC(2,fcosh_rr,(FW d, FR s))
2868:
2869: MIDFUNC(2,ftanh_rr,(FW d, FR s))
2870: {
2871: s=f_readreg(s);
2872: d=f_writereg(d);
2873: raw_ftanh_rr(d,s);
2874: f_unlock(s);
2875: f_unlock(d);
2876: }
2877: MENDFUNC(2,ftanh_rr,(FW d, FR s))
2878:
2879: MIDFUNC(2,fneg_rr,(FW d, FR s))
2880: {
2881: s=f_readreg(s);
2882: d=f_writereg(d);
2883: raw_fneg_rr(d,s);
2884: f_unlock(s);
2885: f_unlock(d);
2886: }
2887: MENDFUNC(2,fneg_rr,(FW d, FR s))
2888:
2889: MIDFUNC(2,fadd_rr,(FRW d, FR s))
2890: {
2891: s=f_readreg(s);
2892: d=f_rmw(d);
2893: raw_fadd_rr(d,s);
2894: f_unlock(s);
2895: f_unlock(d);
2896: }
2897: MENDFUNC(2,fadd_rr,(FRW d, FR s))
2898:
2899: MIDFUNC(2,fsub_rr,(FRW d, FR s))
2900: {
2901: s=f_readreg(s);
2902: d=f_rmw(d);
2903: raw_fsub_rr(d,s);
2904: f_unlock(s);
2905: f_unlock(d);
2906: }
2907: MENDFUNC(2,fsub_rr,(FRW d, FR s))
2908:
2909: MIDFUNC(2,fcmp_rr,(FR d, FR s))
2910: {
2911: d=f_readreg(d);
2912: s=f_readreg(s);
2913: raw_fcmp_rr(d,s);
2914: f_unlock(s);
2915: f_unlock(d);
2916: }
2917: MENDFUNC(2,fcmp_rr,(FR d, FR s))
2918:
2919: MIDFUNC(2,fdiv_rr,(FRW d, FR s))
2920: {
2921: s=f_readreg(s);
2922: d=f_rmw(d);
2923: raw_fdiv_rr(d,s);
2924: f_unlock(s);
2925: f_unlock(d);
2926: }
2927: MENDFUNC(2,fdiv_rr,(FRW d, FR s))
2928:
2929: MIDFUNC(2,frem_rr,(FRW d, FR s))
2930: {
2931: s=f_readreg(s);
2932: d=f_rmw(d);
2933: raw_frem_rr(d,s);
2934: f_unlock(s);
2935: f_unlock(d);
2936: }
2937: MENDFUNC(2,frem_rr,(FRW d, FR s))
2938:
2939: MIDFUNC(2,frem1_rr,(FRW d, FR s))
2940: {
2941: s=f_readreg(s);
2942: d=f_rmw(d);
2943: raw_frem1_rr(d,s);
2944: f_unlock(s);
2945: f_unlock(d);
2946: }
2947: MENDFUNC(2,frem1_rr,(FRW d, FR s))
2948:
2949: MIDFUNC(2,fmul_rr,(FRW d, FR s))
2950: {
2951: s=f_readreg(s);
2952: d=f_rmw(d);
2953: raw_fmul_rr(d,s);
2954: f_unlock(s);
2955: f_unlock(d);
2956: }
2957: MENDFUNC(2,fmul_rr,(FRW d, FR s))
2958:
2959: #ifdef __GNUC__
2960:
2961: static inline void mfence(void)
2962: {
2963: #ifdef CPU_i386
2964: if (!cpuinfo.x86_has_xmm2)
2965: __asm__ __volatile__("lock; addl $0,0(%%esp)":::"memory");
2966: else
2967: #endif
2968: __asm__ __volatile__("mfence":::"memory");
2969: }
2970:
2971: static inline void clflush(volatile void *__p)
2972: {
2973: __asm__ __volatile__("clflush %0" : "+m" (*(volatile char *)__p));
2974: }
2975:
2976: static inline void flush_cpu_icache(void *start, void *stop)
2977: {
2978: mfence();
2979: if (cpuinfo.x86_clflush_size != 0)
2980: {
2981: volatile char *vaddr = (volatile char *)(((uintptr)start / cpuinfo.x86_clflush_size) * cpuinfo.x86_clflush_size);
2982: volatile char *vend = (volatile char *)((((uintptr)stop + cpuinfo.x86_clflush_size - 1) / cpuinfo.x86_clflush_size) * cpuinfo.x86_clflush_size);
2983: while (vaddr < vend)
2984: {
2985: clflush(vaddr);
2986: vaddr += cpuinfo.x86_clflush_size;
2987: }
2988: }
2989: mfence();
2990: }
2991:
2992: #else
2993:
2994: static inline void flush_cpu_icache(void *start, void *stop)
2995: {
2996: UNUSED(start);
2997: UNUSED(stop);
2998: }
2999:
3000: #endif
3001:
3002: static inline void write_jmp_target(uae_u32 *jmpaddr, cpuop_func* a) {
3003: uintptr rel = (uintptr) a - ((uintptr) jmpaddr + 4);
3004: *(jmpaddr) = (uae_u32) rel;
3005: flush_cpu_icache((void *) jmpaddr, (void *) &jmpaddr[1]);
3006: }
3007:
3008: static inline void emit_jmp_target(uae_u32 a) {
3009: emit_long(a-((uintptr)target+4));
3010: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.