Fix typo in comment, by Andreas Faerber.
[qemu/dscho.git] / target-arm / op.c
blob771f9c470ac04c2a32dbdc1b1229e03b8b025d06
1 /*
2 * ARM micro operations
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 * Copyright (c) 2005 CodeSourcery, LLC
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "exec.h"
23 #define REGNAME r0
24 #define REG (env->regs[0])
25 #include "op_template.h"
27 #define REGNAME r1
28 #define REG (env->regs[1])
29 #include "op_template.h"
31 #define REGNAME r2
32 #define REG (env->regs[2])
33 #include "op_template.h"
35 #define REGNAME r3
36 #define REG (env->regs[3])
37 #include "op_template.h"
39 #define REGNAME r4
40 #define REG (env->regs[4])
41 #include "op_template.h"
43 #define REGNAME r5
44 #define REG (env->regs[5])
45 #include "op_template.h"
47 #define REGNAME r6
48 #define REG (env->regs[6])
49 #include "op_template.h"
51 #define REGNAME r7
52 #define REG (env->regs[7])
53 #include "op_template.h"
55 #define REGNAME r8
56 #define REG (env->regs[8])
57 #include "op_template.h"
59 #define REGNAME r9
60 #define REG (env->regs[9])
61 #include "op_template.h"
63 #define REGNAME r10
64 #define REG (env->regs[10])
65 #include "op_template.h"
67 #define REGNAME r11
68 #define REG (env->regs[11])
69 #include "op_template.h"
71 #define REGNAME r12
72 #define REG (env->regs[12])
73 #include "op_template.h"
75 #define REGNAME r13
76 #define REG (env->regs[13])
77 #include "op_template.h"
79 #define REGNAME r14
80 #define REG (env->regs[14])
81 #include "op_template.h"
83 #define REGNAME r15
84 #define REG (env->regs[15])
85 #define SET_REG(x) REG = x & ~(uint32_t)1
86 #include "op_template.h"
88 void OPPROTO op_bx_T0(void)
90 env->regs[15] = T0 & ~(uint32_t)1;
91 env->thumb = (T0 & 1) != 0;
94 void OPPROTO op_movl_T0_0(void)
96 T0 = 0;
99 void OPPROTO op_movl_T0_im(void)
101 T0 = PARAM1;
104 void OPPROTO op_movl_T0_T1(void)
106 T0 = T1;
109 void OPPROTO op_movl_T1_im(void)
111 T1 = PARAM1;
114 void OPPROTO op_mov_CF_T1(void)
116 env->CF = ((uint32_t)T1) >> 31;
119 void OPPROTO op_movl_T2_im(void)
121 T2 = PARAM1;
124 void OPPROTO op_addl_T1_im(void)
126 T1 += PARAM1;
129 void OPPROTO op_addl_T1_T2(void)
131 T1 += T2;
134 void OPPROTO op_subl_T1_T2(void)
136 T1 -= T2;
139 void OPPROTO op_addl_T0_T1(void)
141 T0 += T1;
144 void OPPROTO op_addl_T0_T1_cc(void)
146 unsigned int src1;
147 src1 = T0;
148 T0 += T1;
149 env->NZF = T0;
150 env->CF = T0 < src1;
151 env->VF = (src1 ^ T1 ^ -1) & (src1 ^ T0);
154 void OPPROTO op_adcl_T0_T1(void)
156 T0 += T1 + env->CF;
159 void OPPROTO op_adcl_T0_T1_cc(void)
161 unsigned int src1;
162 src1 = T0;
163 if (!env->CF) {
164 T0 += T1;
165 env->CF = T0 < src1;
166 } else {
167 T0 += T1 + 1;
168 env->CF = T0 <= src1;
170 env->VF = (src1 ^ T1 ^ -1) & (src1 ^ T0);
171 env->NZF = T0;
172 FORCE_RET();
175 #define OPSUB(sub, sbc, res, T0, T1) \
177 void OPPROTO op_ ## sub ## l_T0_T1(void) \
179 res = T0 - T1; \
182 void OPPROTO op_ ## sub ## l_T0_T1_cc(void) \
184 unsigned int src1; \
185 src1 = T0; \
186 T0 -= T1; \
187 env->NZF = T0; \
188 env->CF = src1 >= T1; \
189 env->VF = (src1 ^ T1) & (src1 ^ T0); \
190 res = T0; \
193 void OPPROTO op_ ## sbc ## l_T0_T1(void) \
195 res = T0 - T1 + env->CF - 1; \
198 void OPPROTO op_ ## sbc ## l_T0_T1_cc(void) \
200 unsigned int src1; \
201 src1 = T0; \
202 if (!env->CF) { \
203 T0 = T0 - T1 - 1; \
204 env->CF = src1 > T1; \
205 } else { \
206 T0 = T0 - T1; \
207 env->CF = src1 >= T1; \
209 env->VF = (src1 ^ T1) & (src1 ^ T0); \
210 env->NZF = T0; \
211 res = T0; \
212 FORCE_RET(); \
215 OPSUB(sub, sbc, T0, T0, T1)
217 OPSUB(rsb, rsc, T0, T1, T0)
219 void OPPROTO op_andl_T0_T1(void)
221 T0 &= T1;
224 void OPPROTO op_xorl_T0_T1(void)
226 T0 ^= T1;
229 void OPPROTO op_orl_T0_T1(void)
231 T0 |= T1;
234 void OPPROTO op_bicl_T0_T1(void)
236 T0 &= ~T1;
239 void OPPROTO op_notl_T1(void)
241 T1 = ~T1;
244 void OPPROTO op_logic_T0_cc(void)
246 env->NZF = T0;
249 void OPPROTO op_logic_T1_cc(void)
251 env->NZF = T1;
254 #define EIP (env->regs[15])
256 void OPPROTO op_test_eq(void)
258 if (env->NZF == 0)
259 GOTO_LABEL_PARAM(1);;
260 FORCE_RET();
263 void OPPROTO op_test_ne(void)
265 if (env->NZF != 0)
266 GOTO_LABEL_PARAM(1);;
267 FORCE_RET();
270 void OPPROTO op_test_cs(void)
272 if (env->CF != 0)
273 GOTO_LABEL_PARAM(1);
274 FORCE_RET();
277 void OPPROTO op_test_cc(void)
279 if (env->CF == 0)
280 GOTO_LABEL_PARAM(1);
281 FORCE_RET();
284 void OPPROTO op_test_mi(void)
286 if ((env->NZF & 0x80000000) != 0)
287 GOTO_LABEL_PARAM(1);
288 FORCE_RET();
291 void OPPROTO op_test_pl(void)
293 if ((env->NZF & 0x80000000) == 0)
294 GOTO_LABEL_PARAM(1);
295 FORCE_RET();
298 void OPPROTO op_test_vs(void)
300 if ((env->VF & 0x80000000) != 0)
301 GOTO_LABEL_PARAM(1);
302 FORCE_RET();
305 void OPPROTO op_test_vc(void)
307 if ((env->VF & 0x80000000) == 0)
308 GOTO_LABEL_PARAM(1);
309 FORCE_RET();
312 void OPPROTO op_test_hi(void)
314 if (env->CF != 0 && env->NZF != 0)
315 GOTO_LABEL_PARAM(1);
316 FORCE_RET();
319 void OPPROTO op_test_ls(void)
321 if (env->CF == 0 || env->NZF == 0)
322 GOTO_LABEL_PARAM(1);
323 FORCE_RET();
326 void OPPROTO op_test_ge(void)
328 if (((env->VF ^ env->NZF) & 0x80000000) == 0)
329 GOTO_LABEL_PARAM(1);
330 FORCE_RET();
333 void OPPROTO op_test_lt(void)
335 if (((env->VF ^ env->NZF) & 0x80000000) != 0)
336 GOTO_LABEL_PARAM(1);
337 FORCE_RET();
340 void OPPROTO op_test_gt(void)
342 if (env->NZF != 0 && ((env->VF ^ env->NZF) & 0x80000000) == 0)
343 GOTO_LABEL_PARAM(1);
344 FORCE_RET();
347 void OPPROTO op_test_le(void)
349 if (env->NZF == 0 || ((env->VF ^ env->NZF) & 0x80000000) != 0)
350 GOTO_LABEL_PARAM(1);
351 FORCE_RET();
354 void OPPROTO op_goto_tb0(void)
356 GOTO_TB(op_goto_tb0, PARAM1, 0);
359 void OPPROTO op_goto_tb1(void)
361 GOTO_TB(op_goto_tb1, PARAM1, 1);
364 void OPPROTO op_exit_tb(void)
366 EXIT_TB();
369 void OPPROTO op_movl_T0_cpsr(void)
371 T0 = cpsr_read(env);
372 FORCE_RET();
375 void OPPROTO op_movl_T0_spsr(void)
377 T0 = env->spsr;
380 void OPPROTO op_movl_spsr_T0(void)
382 uint32_t mask = PARAM1;
383 env->spsr = (env->spsr & ~mask) | (T0 & mask);
386 void OPPROTO op_movl_cpsr_T0(void)
388 cpsr_write(env, T0, PARAM1);
389 FORCE_RET();
392 void OPPROTO op_mul_T0_T1(void)
394 T0 = T0 * T1;
397 /* 64 bit unsigned mul */
398 void OPPROTO op_mull_T0_T1(void)
400 uint64_t res;
401 res = (uint64_t)T0 * (uint64_t)T1;
402 T1 = res >> 32;
403 T0 = res;
406 /* 64 bit signed mul */
407 void OPPROTO op_imull_T0_T1(void)
409 uint64_t res;
410 res = (int64_t)((int32_t)T0) * (int64_t)((int32_t)T1);
411 T1 = res >> 32;
412 T0 = res;
415 /* 48 bit signed mul, top 32 bits */
416 void OPPROTO op_imulw_T0_T1(void)
418 uint64_t res;
419 res = (int64_t)((int32_t)T0) * (int64_t)((int32_t)T1);
420 T0 = res >> 16;
423 void OPPROTO op_addq_T0_T1(void)
425 uint64_t res;
426 res = ((uint64_t)T1 << 32) | T0;
427 res += ((uint64_t)(env->regs[PARAM2]) << 32) | (env->regs[PARAM1]);
428 T1 = res >> 32;
429 T0 = res;
432 void OPPROTO op_addq_lo_T0_T1(void)
434 uint64_t res;
435 res = ((uint64_t)T1 << 32) | T0;
436 res += (uint64_t)(env->regs[PARAM1]);
437 T1 = res >> 32;
438 T0 = res;
441 void OPPROTO op_logicq_cc(void)
443 env->NZF = (T1 & 0x80000000) | ((T0 | T1) != 0);
446 /* memory access */
448 #define MEMSUFFIX _raw
449 #include "op_mem.h"
451 #if !defined(CONFIG_USER_ONLY)
452 #define MEMSUFFIX _user
453 #include "op_mem.h"
454 #define MEMSUFFIX _kernel
455 #include "op_mem.h"
456 #endif
458 /* shifts */
460 /* T1 based */
462 void OPPROTO op_shll_T1_im(void)
464 T1 = T1 << PARAM1;
467 void OPPROTO op_shrl_T1_im(void)
469 T1 = (uint32_t)T1 >> PARAM1;
472 void OPPROTO op_shrl_T1_0(void)
474 T1 = 0;
477 void OPPROTO op_sarl_T1_im(void)
479 T1 = (int32_t)T1 >> PARAM1;
482 void OPPROTO op_sarl_T1_0(void)
484 T1 = (int32_t)T1 >> 31;
487 void OPPROTO op_rorl_T1_im(void)
489 int shift;
490 shift = PARAM1;
491 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
494 void OPPROTO op_rrxl_T1(void)
496 T1 = ((uint32_t)T1 >> 1) | ((uint32_t)env->CF << 31);
499 /* T1 based, set C flag */
500 void OPPROTO op_shll_T1_im_cc(void)
502 env->CF = (T1 >> (32 - PARAM1)) & 1;
503 T1 = T1 << PARAM1;
506 void OPPROTO op_shrl_T1_im_cc(void)
508 env->CF = (T1 >> (PARAM1 - 1)) & 1;
509 T1 = (uint32_t)T1 >> PARAM1;
512 void OPPROTO op_shrl_T1_0_cc(void)
514 env->CF = (T1 >> 31) & 1;
515 T1 = 0;
518 void OPPROTO op_sarl_T1_im_cc(void)
520 env->CF = (T1 >> (PARAM1 - 1)) & 1;
521 T1 = (int32_t)T1 >> PARAM1;
524 void OPPROTO op_sarl_T1_0_cc(void)
526 env->CF = (T1 >> 31) & 1;
527 T1 = (int32_t)T1 >> 31;
530 void OPPROTO op_rorl_T1_im_cc(void)
532 int shift;
533 shift = PARAM1;
534 env->CF = (T1 >> (shift - 1)) & 1;
535 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
538 void OPPROTO op_rrxl_T1_cc(void)
540 uint32_t c;
541 c = T1 & 1;
542 T1 = ((uint32_t)T1 >> 1) | ((uint32_t)env->CF << 31);
543 env->CF = c;
546 /* T2 based */
547 void OPPROTO op_shll_T2_im(void)
549 T2 = T2 << PARAM1;
552 void OPPROTO op_shrl_T2_im(void)
554 T2 = (uint32_t)T2 >> PARAM1;
557 void OPPROTO op_shrl_T2_0(void)
559 T2 = 0;
562 void OPPROTO op_sarl_T2_im(void)
564 T2 = (int32_t)T2 >> PARAM1;
567 void OPPROTO op_sarl_T2_0(void)
569 T2 = (int32_t)T2 >> 31;
572 void OPPROTO op_rorl_T2_im(void)
574 int shift;
575 shift = PARAM1;
576 T2 = ((uint32_t)T2 >> shift) | (T2 << (32 - shift));
579 void OPPROTO op_rrxl_T2(void)
581 T2 = ((uint32_t)T2 >> 1) | ((uint32_t)env->CF << 31);
584 /* T1 based, use T0 as shift count */
586 void OPPROTO op_shll_T1_T0(void)
588 int shift;
589 shift = T0 & 0xff;
590 if (shift >= 32)
591 T1 = 0;
592 else
593 T1 = T1 << shift;
594 FORCE_RET();
597 void OPPROTO op_shrl_T1_T0(void)
599 int shift;
600 shift = T0 & 0xff;
601 if (shift >= 32)
602 T1 = 0;
603 else
604 T1 = (uint32_t)T1 >> shift;
605 FORCE_RET();
608 void OPPROTO op_sarl_T1_T0(void)
610 int shift;
611 shift = T0 & 0xff;
612 if (shift >= 32)
613 shift = 31;
614 T1 = (int32_t)T1 >> shift;
617 void OPPROTO op_rorl_T1_T0(void)
619 int shift;
620 shift = T0 & 0x1f;
621 if (shift) {
622 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
624 FORCE_RET();
627 /* T1 based, use T0 as shift count and compute CF */
629 void OPPROTO op_shll_T1_T0_cc(void)
631 int shift;
632 shift = T0 & 0xff;
633 if (shift >= 32) {
634 if (shift == 32)
635 env->CF = T1 & 1;
636 else
637 env->CF = 0;
638 T1 = 0;
639 } else if (shift != 0) {
640 env->CF = (T1 >> (32 - shift)) & 1;
641 T1 = T1 << shift;
643 FORCE_RET();
646 void OPPROTO op_shrl_T1_T0_cc(void)
648 int shift;
649 shift = T0 & 0xff;
650 if (shift >= 32) {
651 if (shift == 32)
652 env->CF = (T1 >> 31) & 1;
653 else
654 env->CF = 0;
655 T1 = 0;
656 } else if (shift != 0) {
657 env->CF = (T1 >> (shift - 1)) & 1;
658 T1 = (uint32_t)T1 >> shift;
660 FORCE_RET();
663 void OPPROTO op_sarl_T1_T0_cc(void)
665 int shift;
666 shift = T0 & 0xff;
667 if (shift >= 32) {
668 env->CF = (T1 >> 31) & 1;
669 T1 = (int32_t)T1 >> 31;
670 } else if (shift != 0) {
671 env->CF = (T1 >> (shift - 1)) & 1;
672 T1 = (int32_t)T1 >> shift;
674 FORCE_RET();
677 void OPPROTO op_rorl_T1_T0_cc(void)
679 int shift1, shift;
680 shift1 = T0 & 0xff;
681 shift = shift1 & 0x1f;
682 if (shift == 0) {
683 if (shift1 != 0)
684 env->CF = (T1 >> 31) & 1;
685 } else {
686 env->CF = (T1 >> (shift - 1)) & 1;
687 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
689 FORCE_RET();
692 /* misc */
693 void OPPROTO op_clz_T0(void)
695 int count;
696 for (count = 32; T0 > 0; count--)
697 T0 = T0 >> 1;
698 T0 = count;
699 FORCE_RET();
702 void OPPROTO op_sarl_T0_im(void)
704 T0 = (int32_t)T0 >> PARAM1;
707 /* Sign/zero extend */
708 void OPPROTO op_sxth_T0(void)
710 T0 = (int16_t)T0;
713 void OPPROTO op_sxth_T1(void)
715 T1 = (int16_t)T1;
718 void OPPROTO op_sxtb_T1(void)
720 T1 = (int8_t)T1;
723 void OPPROTO op_uxtb_T1(void)
725 T1 = (uint8_t)T1;
728 void OPPROTO op_uxth_T1(void)
730 T1 = (uint16_t)T1;
733 void OPPROTO op_sxtb16_T1(void)
735 uint32_t res;
736 res = (uint16_t)(int8_t)T1;
737 res |= (uint32_t)(int8_t)(T1 >> 16) << 16;
738 T1 = res;
741 void OPPROTO op_uxtb16_T1(void)
743 uint32_t res;
744 res = (uint16_t)(uint8_t)T1;
745 res |= (uint32_t)(uint8_t)(T1 >> 16) << 16;
746 T1 = res;
749 #define SIGNBIT (uint32_t)0x80000000
750 /* saturating arithmetic */
751 void OPPROTO op_addl_T0_T1_setq(void)
753 uint32_t res;
755 res = T0 + T1;
756 if (((res ^ T0) & SIGNBIT) && !((T0 ^ T1) & SIGNBIT))
757 env->QF = 1;
759 T0 = res;
760 FORCE_RET();
763 void OPPROTO op_addl_T0_T1_saturate(void)
765 uint32_t res;
767 res = T0 + T1;
768 if (((res ^ T0) & SIGNBIT) && !((T0 ^ T1) & SIGNBIT)) {
769 env->QF = 1;
770 if (T0 & SIGNBIT)
771 T0 = 0x80000000;
772 else
773 T0 = 0x7fffffff;
775 else
776 T0 = res;
778 FORCE_RET();
781 void OPPROTO op_subl_T0_T1_saturate(void)
783 uint32_t res;
785 res = T0 - T1;
786 if (((res ^ T0) & SIGNBIT) && ((T0 ^ T1) & SIGNBIT)) {
787 env->QF = 1;
788 if (T0 & SIGNBIT)
789 T0 = 0x80000000;
790 else
791 T0 = 0x7fffffff;
793 else
794 T0 = res;
796 FORCE_RET();
799 void OPPROTO op_double_T1_saturate(void)
801 int32_t val;
803 val = T1;
804 if (val >= 0x40000000) {
805 T1 = 0x7fffffff;
806 env->QF = 1;
807 } else if (val <= (int32_t)0xc0000000) {
808 T1 = 0x80000000;
809 env->QF = 1;
810 } else {
811 T1 = val << 1;
813 FORCE_RET();
816 /* thumb shift by immediate */
817 void OPPROTO op_shll_T0_im_thumb(void)
819 int shift;
820 shift = PARAM1;
821 if (shift != 0) {
822 env->CF = (T0 >> (32 - shift)) & 1;
823 T0 = T0 << shift;
825 env->NZF = T0;
826 FORCE_RET();
829 void OPPROTO op_shrl_T0_im_thumb(void)
831 int shift;
833 shift = PARAM1;
834 if (shift == 0) {
835 env->CF = ((uint32_t)T0) >> 31;
836 T0 = 0;
837 } else {
838 env->CF = (T0 >> (shift - 1)) & 1;
839 T0 = T0 >> shift;
841 env->NZF = T0;
842 FORCE_RET();
845 void OPPROTO op_sarl_T0_im_thumb(void)
847 int shift;
849 shift = PARAM1;
850 if (shift == 0) {
851 T0 = ((int32_t)T0) >> 31;
852 env->CF = T0 & 1;
853 } else {
854 env->CF = (T0 >> (shift - 1)) & 1;
855 T0 = ((int32_t)T0) >> shift;
857 env->NZF = T0;
858 FORCE_RET();
861 /* exceptions */
863 void OPPROTO op_swi(void)
865 env->exception_index = EXCP_SWI;
866 cpu_loop_exit();
869 void OPPROTO op_undef_insn(void)
871 env->exception_index = EXCP_UDEF;
872 cpu_loop_exit();
875 void OPPROTO op_debug(void)
877 env->exception_index = EXCP_DEBUG;
878 cpu_loop_exit();
881 void OPPROTO op_wfi(void)
883 env->exception_index = EXCP_HLT;
884 env->halted = 1;
885 cpu_loop_exit();
888 void OPPROTO op_bkpt(void)
890 env->exception_index = EXCP_BKPT;
891 cpu_loop_exit();
894 /* VFP support. We follow the convention used for VFP instrunctions:
895 Single precition routines have a "s" suffix, double precision a
896 "d" suffix. */
898 #define VFP_OP(name, p) void OPPROTO op_vfp_##name##p(void)
900 #define VFP_BINOP(name) \
901 VFP_OP(name, s) \
903 FT0s = float32_ ## name (FT0s, FT1s, &env->vfp.fp_status); \
905 VFP_OP(name, d) \
907 FT0d = float64_ ## name (FT0d, FT1d, &env->vfp.fp_status); \
909 VFP_BINOP(add)
910 VFP_BINOP(sub)
911 VFP_BINOP(mul)
912 VFP_BINOP(div)
913 #undef VFP_BINOP
915 #define VFP_HELPER(name) \
916 VFP_OP(name, s) \
918 do_vfp_##name##s(); \
920 VFP_OP(name, d) \
922 do_vfp_##name##d(); \
924 VFP_HELPER(abs)
925 VFP_HELPER(sqrt)
926 VFP_HELPER(cmp)
927 VFP_HELPER(cmpe)
928 #undef VFP_HELPER
930 /* XXX: Will this do the right thing for NANs. Should invert the signbit
931 without looking at the rest of the value. */
932 VFP_OP(neg, s)
934 FT0s = float32_chs(FT0s);
937 VFP_OP(neg, d)
939 FT0d = float64_chs(FT0d);
942 VFP_OP(F1_ld0, s)
944 union {
945 uint32_t i;
946 float32 s;
947 } v;
948 v.i = 0;
949 FT1s = v.s;
952 VFP_OP(F1_ld0, d)
954 union {
955 uint64_t i;
956 float64 d;
957 } v;
958 v.i = 0;
959 FT1d = v.d;
962 /* Helper routines to perform bitwise copies between float and int. */
963 static inline float32 vfp_itos(uint32_t i)
965 union {
966 uint32_t i;
967 float32 s;
968 } v;
970 v.i = i;
971 return v.s;
974 static inline uint32_t vfp_stoi(float32 s)
976 union {
977 uint32_t i;
978 float32 s;
979 } v;
981 v.s = s;
982 return v.i;
985 /* Integer to float conversion. */
986 VFP_OP(uito, s)
988 FT0s = uint32_to_float32(vfp_stoi(FT0s), &env->vfp.fp_status);
991 VFP_OP(uito, d)
993 FT0d = uint32_to_float64(vfp_stoi(FT0s), &env->vfp.fp_status);
996 VFP_OP(sito, s)
998 FT0s = int32_to_float32(vfp_stoi(FT0s), &env->vfp.fp_status);
1001 VFP_OP(sito, d)
1003 FT0d = int32_to_float64(vfp_stoi(FT0s), &env->vfp.fp_status);
1006 /* Float to integer conversion. */
1007 VFP_OP(toui, s)
1009 FT0s = vfp_itos(float32_to_uint32(FT0s, &env->vfp.fp_status));
1012 VFP_OP(toui, d)
1014 FT0s = vfp_itos(float64_to_uint32(FT0d, &env->vfp.fp_status));
1017 VFP_OP(tosi, s)
1019 FT0s = vfp_itos(float32_to_int32(FT0s, &env->vfp.fp_status));
1022 VFP_OP(tosi, d)
1024 FT0s = vfp_itos(float64_to_int32(FT0d, &env->vfp.fp_status));
1027 /* TODO: Set rounding mode properly. */
1028 VFP_OP(touiz, s)
1030 FT0s = vfp_itos(float32_to_uint32_round_to_zero(FT0s, &env->vfp.fp_status));
1033 VFP_OP(touiz, d)
1035 FT0s = vfp_itos(float64_to_uint32_round_to_zero(FT0d, &env->vfp.fp_status));
1038 VFP_OP(tosiz, s)
1040 FT0s = vfp_itos(float32_to_int32_round_to_zero(FT0s, &env->vfp.fp_status));
1043 VFP_OP(tosiz, d)
1045 FT0s = vfp_itos(float64_to_int32_round_to_zero(FT0d, &env->vfp.fp_status));
1048 /* floating point conversion */
1049 VFP_OP(fcvtd, s)
1051 FT0d = float32_to_float64(FT0s, &env->vfp.fp_status);
1054 VFP_OP(fcvts, d)
1056 FT0s = float64_to_float32(FT0d, &env->vfp.fp_status);
1059 /* Get and Put values from registers. */
1060 VFP_OP(getreg_F0, d)
1062 FT0d = *(float64 *)((char *) env + PARAM1);
1065 VFP_OP(getreg_F0, s)
1067 FT0s = *(float32 *)((char *) env + PARAM1);
1070 VFP_OP(getreg_F1, d)
1072 FT1d = *(float64 *)((char *) env + PARAM1);
1075 VFP_OP(getreg_F1, s)
1077 FT1s = *(float32 *)((char *) env + PARAM1);
1080 VFP_OP(setreg_F0, d)
1082 *(float64 *)((char *) env + PARAM1) = FT0d;
1085 VFP_OP(setreg_F0, s)
1087 *(float32 *)((char *) env + PARAM1) = FT0s;
1090 void OPPROTO op_vfp_movl_T0_fpscr(void)
1092 do_vfp_get_fpscr ();
1095 void OPPROTO op_vfp_movl_T0_fpscr_flags(void)
1097 T0 = env->vfp.xregs[ARM_VFP_FPSCR] & (0xf << 28);
1100 void OPPROTO op_vfp_movl_fpscr_T0(void)
1102 do_vfp_set_fpscr();
1105 void OPPROTO op_vfp_movl_T0_xreg(void)
1107 T0 = env->vfp.xregs[PARAM1];
1110 void OPPROTO op_vfp_movl_xreg_T0(void)
1112 env->vfp.xregs[PARAM1] = T0;
1115 /* Move between FT0s to T0 */
1116 void OPPROTO op_vfp_mrs(void)
1118 T0 = vfp_stoi(FT0s);
1121 void OPPROTO op_vfp_msr(void)
1123 FT0s = vfp_itos(T0);
1126 /* Move between FT0d and {T0,T1} */
1127 void OPPROTO op_vfp_mrrd(void)
1129 CPU_DoubleU u;
1131 u.d = FT0d;
1132 T0 = u.l.lower;
1133 T1 = u.l.upper;
1136 void OPPROTO op_vfp_mdrr(void)
1138 CPU_DoubleU u;
1140 u.l.lower = T0;
1141 u.l.upper = T1;
1142 FT0d = u.d;
1145 /* Copy the most significant bit of T0 to all bits of T1. */
1146 void OPPROTO op_signbit_T1_T0(void)
1148 T1 = (int32_t)T0 >> 31;
1151 void OPPROTO op_movl_cp_T0(void)
1153 helper_set_cp(env, PARAM1, T0);
1154 FORCE_RET();
1157 void OPPROTO op_movl_T0_cp(void)
1159 T0 = helper_get_cp(env, PARAM1);
1160 FORCE_RET();
1163 void OPPROTO op_movl_cp15_T0(void)
1165 helper_set_cp15(env, PARAM1, T0);
1166 FORCE_RET();
1169 void OPPROTO op_movl_T0_cp15(void)
1171 T0 = helper_get_cp15(env, PARAM1);
1172 FORCE_RET();
1175 /* Access to user mode registers from privileged modes. */
1176 void OPPROTO op_movl_T0_user(void)
1178 int regno = PARAM1;
1179 if (regno == 13) {
1180 T0 = env->banked_r13[0];
1181 } else if (regno == 14) {
1182 T0 = env->banked_r14[0];
1183 } else if ((env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
1184 T0 = env->usr_regs[regno - 8];
1185 } else {
1186 T0 = env->regs[regno];
1188 FORCE_RET();
1192 void OPPROTO op_movl_user_T0(void)
1194 int regno = PARAM1;
1195 if (regno == 13) {
1196 env->banked_r13[0] = T0;
1197 } else if (regno == 14) {
1198 env->banked_r14[0] = T0;
1199 } else if ((env->uncached_cpsr & 0x1f) == ARM_CPU_MODE_FIQ) {
1200 env->usr_regs[regno - 8] = T0;
1201 } else {
1202 env->regs[regno] = T0;
1204 FORCE_RET();
1207 void OPPROTO op_movl_T2_T0(void)
1209 T2 = T0;
1212 void OPPROTO op_movl_T0_T2(void)
1214 T0 = T2;
1217 /* iwMMXt support */
1218 #include "op_iwmmxt.c"