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)
219 void OPPROTO
op_exit_tb (void)
225 void OPPROTO
op_addq (void)
231 void OPPROTO
op_addqv (void)
237 void OPPROTO
op_addl (void)
239 T0
= (int64_t)((int32_t)(T0
+ T1
));
243 void OPPROTO
op_addlv (void)
249 void OPPROTO
op_subq (void)
255 void OPPROTO
op_subqv (void)
261 void OPPROTO
op_subl (void)
263 T0
= (int64_t)((int32_t)(T0
- T1
));
267 void OPPROTO
op_sublv (void)
273 void OPPROTO
op_s4 (void)
279 void OPPROTO
op_s8 (void)
285 void OPPROTO
op_mull (void)
287 T0
= (int64_t)((int32_t)T0
* (int32_t)T1
);
291 void OPPROTO
op_mullv (void)
297 void OPPROTO
op_mulq (void)
299 T0
= (int64_t)T0
* (int64_t)T1
;
303 void OPPROTO
op_mulqv (void)
309 void OPPROTO
op_umulh (void)
313 mulu64(&tl
, &th
, T0
, T1
);
319 void OPPROTO
op_and (void)
325 void OPPROTO
op_bic (void)
331 void OPPROTO
op_bis (void)
337 void OPPROTO
op_eqv (void)
343 void OPPROTO
op_ornot (void)
349 void OPPROTO
op_xor (void)
355 void OPPROTO
op_sll (void)
361 void OPPROTO
op_srl (void)
367 void OPPROTO
op_sra (void)
369 T0
= (int64_t)T0
>> T1
;
373 void OPPROTO
op_sextb (void)
375 T0
= (int64_t)((int8_t)T0
);
379 void OPPROTO
op_sextw (void)
381 T0
= (int64_t)((int16_t)T0
);
386 void OPPROTO
op_ctpop (void)
392 void OPPROTO
op_ctlz (void)
398 void OPPROTO
op_cttz (void)
404 void OPPROTO
op_mskbl (void)
410 void OPPROTO
op_extbl (void)
416 void OPPROTO
op_insbl (void)
422 void OPPROTO
op_mskwl (void)
428 void OPPROTO
op_extwl (void)
434 void OPPROTO
op_inswl (void)
440 void OPPROTO
op_mskll (void)
446 void OPPROTO
op_extll (void)
452 void OPPROTO
op_insll (void)
458 void OPPROTO
op_zap (void)
464 void OPPROTO
op_zapnot (void)
470 void OPPROTO
op_mskql (void)
476 void OPPROTO
op_extql (void)
482 void OPPROTO
op_insql (void)
488 void OPPROTO
op_mskwh (void)
494 void OPPROTO
op_inswh (void)
500 void OPPROTO
op_extwh (void)
506 void OPPROTO
op_msklh (void)
512 void OPPROTO
op_inslh (void)
518 void OPPROTO
op_extlh (void)
524 void OPPROTO
op_mskqh (void)
530 void OPPROTO
op_insqh (void)
536 void OPPROTO
op_extqh (void)
543 void OPPROTO
op_cmpult (void)
552 void OPPROTO
op_cmpule (void)
561 void OPPROTO
op_cmpeq (void)
570 void OPPROTO
op_cmplt (void)
572 if ((int64_t)T0
< (int64_t)T1
)
579 void OPPROTO
op_cmple (void)
581 if ((int64_t)T0
<= (int64_t)T1
)
588 void OPPROTO
op_cmpbge (void)
594 void OPPROTO
op_cmpeqz (void)
603 void OPPROTO
op_cmpnez (void)
612 void OPPROTO
op_cmpltz (void)
621 void OPPROTO
op_cmplez (void)
623 if ((int64_t)T0
<= 0)
630 void OPPROTO
op_cmpgtz (void)
639 void OPPROTO
op_cmpgez (void)
641 if ((int64_t)T0
>= 0)
648 void OPPROTO
op_cmplbs (void)
654 void OPPROTO
op_cmplbc (void)
661 void OPPROTO
op_branch (void)
667 void OPPROTO
op_addq1 (void)
673 #if 0 // Qemu does not know how to do this...
674 void OPPROTO
op_bcond (void)
683 void OPPROTO
op_bcond (void)
688 env
->pc
= ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
693 #if 0 // Qemu does not know how to do this...
694 void OPPROTO
op_update_pc (void)
700 void OPPROTO
op_update_pc (void)
702 env
->pc
= ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
707 /* Optimization for 32 bits hosts architectures */
708 void OPPROTO
op_update_pc32 (void)
710 env
->pc
= (uint64_t)PARAM(1);
714 /* IEEE floating point arithmetic */
715 /* S floating (single) */
716 void OPPROTO
op_adds (void)
718 FT0
= float32_add(FT0
, FT1
, &FP_STATUS
);
722 void OPPROTO
op_subs (void)
724 FT0
= float32_sub(FT0
, FT1
, &FP_STATUS
);
728 void OPPROTO
op_muls (void)
730 FT0
= float32_mul(FT0
, FT1
, &FP_STATUS
);
734 void OPPROTO
op_divs (void)
736 FT0
= float32_div(FT0
, FT1
, &FP_STATUS
);
740 void OPPROTO
op_sqrts (void)
746 void OPPROTO
op_cpys (void)
752 void OPPROTO
op_cpysn (void)
758 void OPPROTO
op_cpyse (void)
764 void OPPROTO
op_itofs (void)
770 void OPPROTO
op_ftois (void)
776 /* T floating (double) */
777 void OPPROTO
op_addt (void)
779 FT0
= float64_add(FT0
, FT1
, &FP_STATUS
);
783 void OPPROTO
op_subt (void)
785 FT0
= float64_sub(FT0
, FT1
, &FP_STATUS
);
789 void OPPROTO
op_mult (void)
791 FT0
= float64_mul(FT0
, FT1
, &FP_STATUS
);
795 void OPPROTO
op_divt (void)
797 FT0
= float64_div(FT0
, FT1
, &FP_STATUS
);
801 void OPPROTO
op_sqrtt (void)
807 void OPPROTO
op_cmptun (void)
813 void OPPROTO
op_cmpteq (void)
819 void OPPROTO
op_cmptle (void)
825 void OPPROTO
op_cmptlt (void)
831 void OPPROTO
op_itoft (void)
837 void OPPROTO
op_ftoit (void)
843 /* VAX floating point arithmetic */
845 void OPPROTO
op_addf (void)
851 void OPPROTO
op_subf (void)
857 void OPPROTO
op_mulf (void)
863 void OPPROTO
op_divf (void)
869 void OPPROTO
op_sqrtf (void)
875 void OPPROTO
op_cmpfeq (void)
881 void OPPROTO
op_cmpfne (void)
887 void OPPROTO
op_cmpflt (void)
893 void OPPROTO
op_cmpfle (void)
899 void OPPROTO
op_cmpfgt (void)
905 void OPPROTO
op_cmpfge (void)
911 void OPPROTO
op_itoff (void)
918 void OPPROTO
op_addg (void)
924 void OPPROTO
op_subg (void)
930 void OPPROTO
op_mulg (void)
936 void OPPROTO
op_divg (void)
942 void OPPROTO
op_sqrtg (void)
948 void OPPROTO
op_cmpgeq (void)
954 void OPPROTO
op_cmpglt (void)
960 void OPPROTO
op_cmpgle (void)
966 /* Floating point format conversion */
967 void OPPROTO
op_cvtst (void)
973 void OPPROTO
op_cvtqs (void)
979 void OPPROTO
op_cvtts (void)
985 void OPPROTO
op_cvttq (void)
991 void OPPROTO
op_cvtqt (void)
997 void OPPROTO
op_cvtqf (void)
1003 void OPPROTO
op_cvtgf (void)
1009 void OPPROTO
op_cvtgd (void)
1015 void OPPROTO
op_cvtgq (void)
1021 void OPPROTO
op_cvtqg (void)
1027 void OPPROTO
op_cvtdg (void)
1033 void OPPROTO
op_cvtlq (void)
1039 void OPPROTO
op_cvtql (void)
1045 void OPPROTO
op_cvtqlv (void)
1051 void OPPROTO
op_cvtqlsv (void)
1057 /* PALcode support special instructions */
1058 #if !defined (CONFIG_USER_ONLY)
1059 void OPPROTO
op_hw_rei (void)
1061 env
->pc
= env
->ipr
[IPR_EXC_ADDR
] & ~3;
1062 env
->ipr
[IPR_EXC_ADDR
] = env
->ipr
[IPR_EXC_ADDR
] & 1;
1063 /* XXX: re-enable interrupts and memory mapping */
1067 void OPPROTO
op_hw_ret (void)
1070 env
->ipr
[IPR_EXC_ADDR
] = T0
& 1;
1071 /* XXX: re-enable interrupts and memory mapping */
1075 void OPPROTO
op_mfpr (void)
1077 helper_mfpr(PARAM(1));
1081 void OPPROTO
op_mtpr (void)
1083 helper_mtpr(PARAM(1));
1087 void OPPROTO
op_set_alt_mode (void)
1089 env
->saved_mode
= env
->ps
& 0xC;
1090 env
->ps
= (env
->ps
& ~0xC) | (env
->ipr
[IPR_ALT_MODE
] & 0xC);
1094 void OPPROTO
op_restore_mode (void)
1096 env
->ps
= (env
->ps
& ~0xC) | env
->saved_mode
;
1100 void OPPROTO
op_ld_phys_to_virt (void)
1102 helper_ld_phys_to_virt();
1106 void OPPROTO
op_st_phys_to_virt (void)
1108 helper_st_phys_to_virt();
1111 #endif /* !defined (CONFIG_USER_ONLY) */