Fix warnings that would be caused by ld flag --warn-common
[qemu/mini2440.git] / target-alpha / op.c
blobb07b3d969c721e7a0824e47a65a4ddeb4c55cc4d
1 /*
2 * Alpha emulation cpu micro-operations for qemu.
4 * Copyright (c) 2007 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define DEBUG_OP
23 #include "config.h"
24 #include "exec.h"
25 #include "host-utils.h"
27 #include "op_helper.h"
29 #define REG 0
30 #include "op_template.h"
32 #define REG 1
33 #include "op_template.h"
35 #define REG 2
36 #include "op_template.h"
38 #define REG 3
39 #include "op_template.h"
41 #define REG 4
42 #include "op_template.h"
44 #define REG 5
45 #include "op_template.h"
47 #define REG 6
48 #include "op_template.h"
50 #define REG 7
51 #include "op_template.h"
53 #define REG 8
54 #include "op_template.h"
56 #define REG 9
57 #include "op_template.h"
59 #define REG 10
60 #include "op_template.h"
62 #define REG 11
63 #include "op_template.h"
65 #define REG 12
66 #include "op_template.h"
68 #define REG 13
69 #include "op_template.h"
71 #define REG 14
72 #include "op_template.h"
74 #define REG 15
75 #include "op_template.h"
77 #define REG 16
78 #include "op_template.h"
80 #define REG 17
81 #include "op_template.h"
83 #define REG 18
84 #include "op_template.h"
86 #define REG 19
87 #include "op_template.h"
89 #define REG 20
90 #include "op_template.h"
92 #define REG 21
93 #include "op_template.h"
95 #define REG 22
96 #include "op_template.h"
98 #define REG 23
99 #include "op_template.h"
101 #define REG 24
102 #include "op_template.h"
104 #define REG 25
105 #include "op_template.h"
107 #define REG 26
108 #include "op_template.h"
110 #define REG 27
111 #include "op_template.h"
113 #define REG 28
114 #include "op_template.h"
116 #define REG 29
117 #include "op_template.h"
119 #define REG 30
120 #include "op_template.h"
122 #define REG 31
123 #include "op_template.h"
125 /* Debug stuff */
126 void OPPROTO op_no_op (void)
128 #if !defined (DEBUG_OP)
129 __asm__ __volatile__("nop" : : : "memory");
130 #endif
131 RETURN();
134 /* Load and stores */
135 #define MEMSUFFIX _raw
136 #include "op_mem.h"
137 #if !defined(CONFIG_USER_ONLY)
138 #define MEMSUFFIX _kernel
139 #include "op_mem.h"
140 #define MEMSUFFIX _executive
141 #include "op_mem.h"
142 #define MEMSUFFIX _supervisor
143 #include "op_mem.h"
144 #define MEMSUFFIX _user
145 #include "op_mem.h"
146 /* This is used for pal modes */
147 #define MEMSUFFIX _data
148 #include "op_mem.h"
149 #endif
151 /* Misc */
152 void OPPROTO op_excp (void)
154 helper_excp(PARAM(1), PARAM(2));
155 RETURN();
158 void OPPROTO op_load_pcc (void)
160 helper_load_pcc();
161 RETURN();
164 void OPPROTO op_load_implver (void)
166 helper_load_implver();
167 RETURN();
170 void OPPROTO op_load_fpcr (void)
172 helper_load_fpcr();
173 RETURN();
176 void OPPROTO op_store_fpcr (void)
178 helper_store_fpcr();
179 RETURN();
182 void OPPROTO op_load_irf (void)
184 helper_load_irf();
185 RETURN();
188 void OPPROTO op_set_irf (void)
190 helper_set_irf();
191 RETURN();
194 void OPPROTO op_clear_irf (void)
196 helper_clear_irf();
197 RETURN();
200 /* Arithmetic */
201 void OPPROTO op_addqv (void)
203 helper_addqv();
204 RETURN();
207 void OPPROTO op_addlv (void)
209 helper_addlv();
210 RETURN();
213 void OPPROTO op_subqv (void)
215 helper_subqv();
216 RETURN();
219 void OPPROTO op_sublv (void)
221 helper_sublv();
222 RETURN();
225 void OPPROTO op_mullv (void)
227 helper_mullv();
228 RETURN();
231 void OPPROTO op_mulqv (void)
233 helper_mulqv();
234 RETURN();
237 void OPPROTO op_umulh (void)
239 uint64_t tl, th;
241 mulu64(&tl, &th, T0, T1);
242 T0 = th;
243 RETURN();
246 /* Logical */
247 void OPPROTO op_mskbl (void)
249 helper_mskbl();
250 RETURN();
253 void OPPROTO op_extbl (void)
255 helper_extbl();
256 RETURN();
259 void OPPROTO op_insbl (void)
261 helper_insbl();
262 RETURN();
265 void OPPROTO op_mskwl (void)
267 helper_mskwl();
268 RETURN();
271 void OPPROTO op_extwl (void)
273 helper_extwl();
274 RETURN();
277 void OPPROTO op_inswl (void)
279 helper_inswl();
280 RETURN();
283 void OPPROTO op_mskll (void)
285 helper_mskll();
286 RETURN();
289 void OPPROTO op_extll (void)
291 helper_extll();
292 RETURN();
295 void OPPROTO op_insll (void)
297 helper_insll();
298 RETURN();
301 void OPPROTO op_zap (void)
303 helper_zap();
304 RETURN();
307 void OPPROTO op_zapnot (void)
309 helper_zapnot();
310 RETURN();
313 void OPPROTO op_mskql (void)
315 helper_mskql();
316 RETURN();
319 void OPPROTO op_extql (void)
321 helper_extql();
322 RETURN();
325 void OPPROTO op_insql (void)
327 helper_insql();
328 RETURN();
331 void OPPROTO op_mskwh (void)
333 helper_mskwh();
334 RETURN();
337 void OPPROTO op_inswh (void)
339 helper_inswh();
340 RETURN();
343 void OPPROTO op_extwh (void)
345 helper_extwh();
346 RETURN();
349 void OPPROTO op_msklh (void)
351 helper_msklh();
352 RETURN();
355 void OPPROTO op_inslh (void)
357 helper_inslh();
358 RETURN();
361 void OPPROTO op_extlh (void)
363 helper_extlh();
364 RETURN();
367 void OPPROTO op_mskqh (void)
369 helper_mskqh();
370 RETURN();
373 void OPPROTO op_insqh (void)
375 helper_insqh();
376 RETURN();
379 void OPPROTO op_extqh (void)
381 helper_extqh();
382 RETURN();
385 /* Tests */
386 void OPPROTO op_cmpult (void)
388 if (T0 < T1)
389 T0 = 1;
390 else
391 T0 = 0;
392 RETURN();
395 void OPPROTO op_cmpule (void)
397 if (T0 <= T1)
398 T0 = 1;
399 else
400 T0 = 0;
401 RETURN();
404 void OPPROTO op_cmpeq (void)
406 if (T0 == T1)
407 T0 = 1;
408 else
409 T0 = 0;
410 RETURN();
413 void OPPROTO op_cmplt (void)
415 if ((int64_t)T0 < (int64_t)T1)
416 T0 = 1;
417 else
418 T0 = 0;
419 RETURN();
422 void OPPROTO op_cmple (void)
424 if ((int64_t)T0 <= (int64_t)T1)
425 T0 = 1;
426 else
427 T0 = 0;
428 RETURN();
431 void OPPROTO op_cmpbge (void)
433 helper_cmpbge();
434 RETURN();
437 void OPPROTO op_cmpeqz (void)
439 if (T0 == 0)
440 T0 = 1;
441 else
442 T0 = 0;
443 RETURN();
446 void OPPROTO op_cmpnez (void)
448 if (T0 != 0)
449 T0 = 1;
450 else
451 T0 = 0;
452 RETURN();
455 void OPPROTO op_cmpltz (void)
457 if ((int64_t)T0 < 0)
458 T0 = 1;
459 else
460 T0 = 0;
461 RETURN();
464 void OPPROTO op_cmplez (void)
466 if ((int64_t)T0 <= 0)
467 T0 = 1;
468 else
469 T0 = 0;
470 RETURN();
473 void OPPROTO op_cmpgtz (void)
475 if ((int64_t)T0 > 0)
476 T0 = 1;
477 else
478 T0 = 0;
479 RETURN();
482 void OPPROTO op_cmpgez (void)
484 if ((int64_t)T0 >= 0)
485 T0 = 1;
486 else
487 T0 = 0;
488 RETURN();
491 void OPPROTO op_cmplbs (void)
493 T0 &= 1;
494 RETURN();
497 void OPPROTO op_cmplbc (void)
499 T0 = (~T0) & 1;
500 RETURN();
503 #if 0 // Qemu does not know how to do this...
504 void OPPROTO op_bcond (void)
506 if (T0)
507 env->pc = T1 & ~3;
508 else
509 env->pc = PARAM(1);
510 RETURN();
512 #else
513 void OPPROTO op_bcond (void)
515 if (T0)
516 env->pc = T1 & ~3;
517 else
518 env->pc = ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
519 RETURN();
521 #endif
523 /* IEEE floating point arithmetic */
524 /* S floating (single) */
525 void OPPROTO op_adds (void)
527 FT0 = float32_add(FT0, FT1, &FP_STATUS);
528 RETURN();
531 void OPPROTO op_subs (void)
533 FT0 = float32_sub(FT0, FT1, &FP_STATUS);
534 RETURN();
537 void OPPROTO op_muls (void)
539 FT0 = float32_mul(FT0, FT1, &FP_STATUS);
540 RETURN();
543 void OPPROTO op_divs (void)
545 FT0 = float32_div(FT0, FT1, &FP_STATUS);
546 RETURN();
549 void OPPROTO op_sqrts (void)
551 helper_sqrts();
552 RETURN();
555 void OPPROTO op_cpys (void)
557 helper_cpys();
558 RETURN();
561 void OPPROTO op_cpysn (void)
563 helper_cpysn();
564 RETURN();
567 void OPPROTO op_cpyse (void)
569 helper_cpyse();
570 RETURN();
573 void OPPROTO op_itofs (void)
575 helper_itofs();
576 RETURN();
579 void OPPROTO op_ftois (void)
581 helper_ftois();
582 RETURN();
585 /* T floating (double) */
586 void OPPROTO op_addt (void)
588 FT0 = float64_add(FT0, FT1, &FP_STATUS);
589 RETURN();
592 void OPPROTO op_subt (void)
594 FT0 = float64_sub(FT0, FT1, &FP_STATUS);
595 RETURN();
598 void OPPROTO op_mult (void)
600 FT0 = float64_mul(FT0, FT1, &FP_STATUS);
601 RETURN();
604 void OPPROTO op_divt (void)
606 FT0 = float64_div(FT0, FT1, &FP_STATUS);
607 RETURN();
610 void OPPROTO op_sqrtt (void)
612 helper_sqrtt();
613 RETURN();
616 void OPPROTO op_cmptun (void)
618 helper_cmptun();
619 RETURN();
622 void OPPROTO op_cmpteq (void)
624 helper_cmpteq();
625 RETURN();
628 void OPPROTO op_cmptle (void)
630 helper_cmptle();
631 RETURN();
634 void OPPROTO op_cmptlt (void)
636 helper_cmptlt();
637 RETURN();
640 void OPPROTO op_itoft (void)
642 helper_itoft();
643 RETURN();
646 void OPPROTO op_ftoit (void)
648 helper_ftoit();
649 RETURN();
652 /* VAX floating point arithmetic */
653 /* F floating */
654 void OPPROTO op_addf (void)
656 helper_addf();
657 RETURN();
660 void OPPROTO op_subf (void)
662 helper_subf();
663 RETURN();
666 void OPPROTO op_mulf (void)
668 helper_mulf();
669 RETURN();
672 void OPPROTO op_divf (void)
674 helper_divf();
675 RETURN();
678 void OPPROTO op_sqrtf (void)
680 helper_sqrtf();
681 RETURN();
684 void OPPROTO op_cmpfeq (void)
686 helper_cmpfeq();
687 RETURN();
690 void OPPROTO op_cmpfne (void)
692 helper_cmpfne();
693 RETURN();
696 void OPPROTO op_cmpflt (void)
698 helper_cmpflt();
699 RETURN();
702 void OPPROTO op_cmpfle (void)
704 helper_cmpfle();
705 RETURN();
708 void OPPROTO op_cmpfgt (void)
710 helper_cmpfgt();
711 RETURN();
714 void OPPROTO op_cmpfge (void)
716 helper_cmpfge();
717 RETURN();
720 void OPPROTO op_itoff (void)
722 helper_itoff();
723 RETURN();
726 /* G floating */
727 void OPPROTO op_addg (void)
729 helper_addg();
730 RETURN();
733 void OPPROTO op_subg (void)
735 helper_subg();
736 RETURN();
739 void OPPROTO op_mulg (void)
741 helper_mulg();
742 RETURN();
745 void OPPROTO op_divg (void)
747 helper_divg();
748 RETURN();
751 void OPPROTO op_sqrtg (void)
753 helper_sqrtg();
754 RETURN();
757 void OPPROTO op_cmpgeq (void)
759 helper_cmpgeq();
760 RETURN();
763 void OPPROTO op_cmpglt (void)
765 helper_cmpglt();
766 RETURN();
769 void OPPROTO op_cmpgle (void)
771 helper_cmpgle();
772 RETURN();
775 /* Floating point format conversion */
776 void OPPROTO op_cvtst (void)
778 FT0 = (float)FT0;
779 RETURN();
782 void OPPROTO op_cvtqs (void)
784 helper_cvtqs();
785 RETURN();
788 void OPPROTO op_cvtts (void)
790 FT0 = (float)FT0;
791 RETURN();
794 void OPPROTO op_cvttq (void)
796 helper_cvttq();
797 RETURN();
800 void OPPROTO op_cvtqt (void)
802 helper_cvtqt();
803 RETURN();
806 void OPPROTO op_cvtqf (void)
808 helper_cvtqf();
809 RETURN();
812 void OPPROTO op_cvtgf (void)
814 helper_cvtgf();
815 RETURN();
818 void OPPROTO op_cvtgd (void)
820 helper_cvtgd();
821 RETURN();
824 void OPPROTO op_cvtgq (void)
826 helper_cvtgq();
827 RETURN();
830 void OPPROTO op_cvtqg (void)
832 helper_cvtqg();
833 RETURN();
836 void OPPROTO op_cvtdg (void)
838 helper_cvtdg();
839 RETURN();
842 void OPPROTO op_cvtlq (void)
844 helper_cvtlq();
845 RETURN();
848 void OPPROTO op_cvtql (void)
850 helper_cvtql();
851 RETURN();
854 void OPPROTO op_cvtqlv (void)
856 helper_cvtqlv();
857 RETURN();
860 void OPPROTO op_cvtqlsv (void)
862 helper_cvtqlsv();
863 RETURN();
866 /* PALcode support special instructions */
867 #if !defined (CONFIG_USER_ONLY)
868 void OPPROTO op_hw_rei (void)
870 env->pc = env->ipr[IPR_EXC_ADDR] & ~3;
871 env->ipr[IPR_EXC_ADDR] = env->ipr[IPR_EXC_ADDR] & 1;
872 /* XXX: re-enable interrupts and memory mapping */
873 RETURN();
876 void OPPROTO op_hw_ret (void)
878 env->pc = T0 & ~3;
879 env->ipr[IPR_EXC_ADDR] = T0 & 1;
880 /* XXX: re-enable interrupts and memory mapping */
881 RETURN();
884 void OPPROTO op_mfpr (void)
886 helper_mfpr(PARAM(1));
887 RETURN();
890 void OPPROTO op_mtpr (void)
892 helper_mtpr(PARAM(1));
893 RETURN();
896 void OPPROTO op_set_alt_mode (void)
898 env->saved_mode = env->ps & 0xC;
899 env->ps = (env->ps & ~0xC) | (env->ipr[IPR_ALT_MODE] & 0xC);
900 RETURN();
903 void OPPROTO op_restore_mode (void)
905 env->ps = (env->ps & ~0xC) | env->saved_mode;
906 RETURN();
909 void OPPROTO op_ld_phys_to_virt (void)
911 helper_ld_phys_to_virt();
912 RETURN();
915 void OPPROTO op_st_phys_to_virt (void)
917 helper_st_phys_to_virt();
918 RETURN();
920 #endif /* !defined (CONFIG_USER_ONLY) */