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
25 #include "host-utils.h"
27 #include "op_helper.h"
30 #include "op_template.h"
33 #include "op_template.h"
36 #include "op_template.h"
39 #include "op_template.h"
42 #include "op_template.h"
45 #include "op_template.h"
48 #include "op_template.h"
51 #include "op_template.h"
54 #include "op_template.h"
57 #include "op_template.h"
60 #include "op_template.h"
63 #include "op_template.h"
66 #include "op_template.h"
69 #include "op_template.h"
72 #include "op_template.h"
75 #include "op_template.h"
78 #include "op_template.h"
81 #include "op_template.h"
84 #include "op_template.h"
87 #include "op_template.h"
90 #include "op_template.h"
93 #include "op_template.h"
96 #include "op_template.h"
99 #include "op_template.h"
102 #include "op_template.h"
105 #include "op_template.h"
108 #include "op_template.h"
111 #include "op_template.h"
114 #include "op_template.h"
117 #include "op_template.h"
120 #include "op_template.h"
123 #include "op_template.h"
126 void OPPROTO
op_no_op (void)
128 #if !defined (DEBUG_OP)
129 __asm__
__volatile__("nop" : : : "memory");
134 void OPPROTO
op_tb_flush (void)
140 /* Load and stores */
141 #define MEMSUFFIX _raw
143 #if !defined(CONFIG_USER_ONLY)
144 #define MEMSUFFIX _kernel
146 #define MEMSUFFIX _executive
148 #define MEMSUFFIX _supervisor
150 #define MEMSUFFIX _user
152 /* This is used for pal modes */
153 #define MEMSUFFIX _data
157 /* Special operation for load and store */
158 void OPPROTO
op_n7 (void)
160 T0
&= ~(uint64_t)0x7;
165 void OPPROTO
op_excp (void)
167 helper_excp(PARAM(1), PARAM(2));
171 void OPPROTO
op_load_amask (void)
177 void OPPROTO
op_load_pcc (void)
183 void OPPROTO
op_load_implver (void)
185 helper_load_implver();
189 void OPPROTO
op_load_fpcr (void)
195 void OPPROTO
op_store_fpcr (void)
201 void OPPROTO
op_load_irf (void)
207 void OPPROTO
op_set_irf (void)
213 void OPPROTO
op_clear_irf (void)
220 void OPPROTO
op_addq (void)
226 void OPPROTO
op_addqv (void)
232 void OPPROTO
op_addl (void)
234 T0
= (int64_t)((int32_t)(T0
+ T1
));
238 void OPPROTO
op_addlv (void)
244 void OPPROTO
op_subq (void)
250 void OPPROTO
op_subqv (void)
256 void OPPROTO
op_subl (void)
258 T0
= (int64_t)((int32_t)(T0
- T1
));
262 void OPPROTO
op_sublv (void)
268 void OPPROTO
op_s4 (void)
274 void OPPROTO
op_s8 (void)
280 void OPPROTO
op_mull (void)
282 T0
= (int64_t)((int32_t)T0
* (int32_t)T1
);
286 void OPPROTO
op_mullv (void)
292 void OPPROTO
op_mulq (void)
294 T0
= (int64_t)T0
* (int64_t)T1
;
298 void OPPROTO
op_mulqv (void)
304 void OPPROTO
op_umulh (void)
308 mulu64(&tl
, &th
, T0
, T1
);
314 void OPPROTO
op_and (void)
320 void OPPROTO
op_bic (void)
326 void OPPROTO
op_bis (void)
332 void OPPROTO
op_eqv (void)
338 void OPPROTO
op_ornot (void)
344 void OPPROTO
op_xor (void)
350 void OPPROTO
op_sll (void)
356 void OPPROTO
op_srl (void)
362 void OPPROTO
op_sra (void)
364 T0
= (int64_t)T0
>> T1
;
368 void OPPROTO
op_sextb (void)
370 T0
= (int64_t)((int8_t)T0
);
374 void OPPROTO
op_sextw (void)
376 T0
= (int64_t)((int16_t)T0
);
381 void OPPROTO
op_ctpop (void)
387 void OPPROTO
op_ctlz (void)
393 void OPPROTO
op_cttz (void)
399 void OPPROTO
op_mskbl (void)
405 void OPPROTO
op_extbl (void)
411 void OPPROTO
op_insbl (void)
417 void OPPROTO
op_mskwl (void)
423 void OPPROTO
op_extwl (void)
429 void OPPROTO
op_inswl (void)
435 void OPPROTO
op_mskll (void)
441 void OPPROTO
op_extll (void)
447 void OPPROTO
op_insll (void)
453 void OPPROTO
op_zap (void)
459 void OPPROTO
op_zapnot (void)
465 void OPPROTO
op_mskql (void)
471 void OPPROTO
op_extql (void)
477 void OPPROTO
op_insql (void)
483 void OPPROTO
op_mskwh (void)
489 void OPPROTO
op_inswh (void)
495 void OPPROTO
op_extwh (void)
501 void OPPROTO
op_msklh (void)
507 void OPPROTO
op_inslh (void)
513 void OPPROTO
op_extlh (void)
519 void OPPROTO
op_mskqh (void)
525 void OPPROTO
op_insqh (void)
531 void OPPROTO
op_extqh (void)
538 void OPPROTO
op_cmpult (void)
547 void OPPROTO
op_cmpule (void)
556 void OPPROTO
op_cmpeq (void)
565 void OPPROTO
op_cmplt (void)
567 if ((int64_t)T0
< (int64_t)T1
)
574 void OPPROTO
op_cmple (void)
576 if ((int64_t)T0
<= (int64_t)T1
)
583 void OPPROTO
op_cmpbge (void)
589 void OPPROTO
op_cmpeqz (void)
598 void OPPROTO
op_cmpnez (void)
607 void OPPROTO
op_cmpltz (void)
616 void OPPROTO
op_cmplez (void)
618 if ((int64_t)T0
<= 0)
625 void OPPROTO
op_cmpgtz (void)
634 void OPPROTO
op_cmpgez (void)
636 if ((int64_t)T0
>= 0)
643 void OPPROTO
op_cmplbs (void)
649 void OPPROTO
op_cmplbc (void)
656 void OPPROTO
op_branch (void)
662 void OPPROTO
op_addq1 (void)
668 #if 0 // Qemu does not know how to do this...
669 void OPPROTO
op_bcond (void)
678 void OPPROTO
op_bcond (void)
683 env
->pc
= ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
688 #if 0 // Qemu does not know how to do this...
689 void OPPROTO
op_update_pc (void)
695 void OPPROTO
op_update_pc (void)
697 env
->pc
= ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
702 /* Optimization for 32 bits hosts architectures */
703 void OPPROTO
op_update_pc32 (void)
705 env
->pc
= (uint64_t)PARAM(1);
709 /* IEEE floating point arithmetic */
710 /* S floating (single) */
711 void OPPROTO
op_adds (void)
713 FT0
= float32_add(FT0
, FT1
, &FP_STATUS
);
717 void OPPROTO
op_subs (void)
719 FT0
= float32_sub(FT0
, FT1
, &FP_STATUS
);
723 void OPPROTO
op_muls (void)
725 FT0
= float32_mul(FT0
, FT1
, &FP_STATUS
);
729 void OPPROTO
op_divs (void)
731 FT0
= float32_div(FT0
, FT1
, &FP_STATUS
);
735 void OPPROTO
op_sqrts (void)
741 void OPPROTO
op_cpys (void)
747 void OPPROTO
op_cpysn (void)
753 void OPPROTO
op_cpyse (void)
759 void OPPROTO
op_itofs (void)
765 void OPPROTO
op_ftois (void)
771 /* T floating (double) */
772 void OPPROTO
op_addt (void)
774 FT0
= float64_add(FT0
, FT1
, &FP_STATUS
);
778 void OPPROTO
op_subt (void)
780 FT0
= float64_sub(FT0
, FT1
, &FP_STATUS
);
784 void OPPROTO
op_mult (void)
786 FT0
= float64_mul(FT0
, FT1
, &FP_STATUS
);
790 void OPPROTO
op_divt (void)
792 FT0
= float64_div(FT0
, FT1
, &FP_STATUS
);
796 void OPPROTO
op_sqrtt (void)
802 void OPPROTO
op_cmptun (void)
808 void OPPROTO
op_cmpteq (void)
814 void OPPROTO
op_cmptle (void)
820 void OPPROTO
op_cmptlt (void)
826 void OPPROTO
op_itoft (void)
832 void OPPROTO
op_ftoit (void)
838 /* VAX floating point arithmetic */
840 void OPPROTO
op_addf (void)
846 void OPPROTO
op_subf (void)
852 void OPPROTO
op_mulf (void)
858 void OPPROTO
op_divf (void)
864 void OPPROTO
op_sqrtf (void)
870 void OPPROTO
op_cmpfeq (void)
876 void OPPROTO
op_cmpfne (void)
882 void OPPROTO
op_cmpflt (void)
888 void OPPROTO
op_cmpfle (void)
894 void OPPROTO
op_cmpfgt (void)
900 void OPPROTO
op_cmpfge (void)
906 void OPPROTO
op_itoff (void)
913 void OPPROTO
op_addg (void)
919 void OPPROTO
op_subg (void)
925 void OPPROTO
op_mulg (void)
931 void OPPROTO
op_divg (void)
937 void OPPROTO
op_sqrtg (void)
943 void OPPROTO
op_cmpgeq (void)
949 void OPPROTO
op_cmpglt (void)
955 void OPPROTO
op_cmpgle (void)
961 /* Floating point format conversion */
962 void OPPROTO
op_cvtst (void)
968 void OPPROTO
op_cvtqs (void)
974 void OPPROTO
op_cvtts (void)
980 void OPPROTO
op_cvttq (void)
986 void OPPROTO
op_cvtqt (void)
992 void OPPROTO
op_cvtqf (void)
998 void OPPROTO
op_cvtgf (void)
1004 void OPPROTO
op_cvtgd (void)
1010 void OPPROTO
op_cvtgq (void)
1016 void OPPROTO
op_cvtqg (void)
1022 void OPPROTO
op_cvtdg (void)
1028 void OPPROTO
op_cvtlq (void)
1034 void OPPROTO
op_cvtql (void)
1040 void OPPROTO
op_cvtqlv (void)
1046 void OPPROTO
op_cvtqlsv (void)
1052 /* PALcode support special instructions */
1053 #if !defined (CONFIG_USER_ONLY)
1054 void OPPROTO
op_hw_rei (void)
1056 env
->pc
= env
->ipr
[IPR_EXC_ADDR
] & ~3;
1057 env
->ipr
[IPR_EXC_ADDR
] = env
->ipr
[IPR_EXC_ADDR
] & 1;
1058 /* XXX: re-enable interrupts and memory mapping */
1062 void OPPROTO
op_hw_ret (void)
1065 env
->ipr
[IPR_EXC_ADDR
] = T0
& 1;
1066 /* XXX: re-enable interrupts and memory mapping */
1070 void OPPROTO
op_mfpr (void)
1072 helper_mfpr(PARAM(1));
1076 void OPPROTO
op_mtpr (void)
1078 helper_mtpr(PARAM(1));
1082 void OPPROTO
op_set_alt_mode (void)
1084 env
->saved_mode
= env
->ps
& 0xC;
1085 env
->ps
= (env
->ps
& ~0xC) | (env
->ipr
[IPR_ALT_MODE
] & 0xC);
1089 void OPPROTO
op_restore_mode (void)
1091 env
->ps
= (env
->ps
& ~0xC) | env
->saved_mode
;
1095 void OPPROTO
op_ld_phys_to_virt (void)
1097 helper_ld_phys_to_virt();
1101 void OPPROTO
op_st_phys_to_virt (void)
1103 helper_st_phys_to_virt();
1106 #endif /* !defined (CONFIG_USER_ONLY) */