Rename misnamed BACK_CHAIN_OFFSET to LR_OFFSET
[qemu/mini2440.git] / target-ppc / op_helper.h
blob7280cf40c5e1522c767bfc57f5002af0e11c0c32
1 /*
2 * PowerPC emulation helpers header for qemu.
4 * Copyright (c) 2003-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 #if defined(MEMSUFFIX)
23 /* Memory load/store helpers */
24 void glue(do_lsw, MEMSUFFIX) (int dst);
25 void glue(do_stsw, MEMSUFFIX) (int src);
26 void glue(do_lmw, MEMSUFFIX) (int dst);
27 void glue(do_lmw_le, MEMSUFFIX) (int dst);
28 void glue(do_stmw, MEMSUFFIX) (int src);
29 void glue(do_stmw_le, MEMSUFFIX) (int src);
30 void glue(do_icbi, MEMSUFFIX) (void);
31 void glue(do_dcbz, MEMSUFFIX) (void);
32 void glue(do_POWER_lscbx, MEMSUFFIX) (int dest, int ra, int rb);
33 void glue(do_POWER2_lfq, MEMSUFFIX) (void);
34 void glue(do_POWER2_lfq_le, MEMSUFFIX) (void);
35 void glue(do_POWER2_stfq, MEMSUFFIX) (void);
36 void glue(do_POWER2_stfq_le, MEMSUFFIX) (void);
38 #if defined(TARGET_PPC64)
39 void glue(do_lsw_64, MEMSUFFIX) (int dst);
40 void glue(do_stsw_64, MEMSUFFIX) (int src);
41 void glue(do_lmw_64, MEMSUFFIX) (int dst);
42 void glue(do_lmw_le_64, MEMSUFFIX) (int dst);
43 void glue(do_stmw_64, MEMSUFFIX) (int src);
44 void glue(do_stmw_le_64, MEMSUFFIX) (int src);
45 void glue(do_icbi_64, MEMSUFFIX) (void);
46 void glue(do_dcbz_64, MEMSUFFIX) (void);
47 #endif
49 #else
51 void do_print_mem_EA (target_ulong EA);
53 /* Registers load and stores */
54 void do_load_cr (void);
55 void do_store_cr (uint32_t mask);
56 #if defined(TARGET_PPC64)
57 void do_store_pri (int prio);
58 #endif
59 void do_fpscr_setbit (int bit);
60 void do_store_fpscr (uint32_t mask);
61 target_ulong ppc_load_dump_spr (int sprn);
62 void ppc_store_dump_spr (int sprn, target_ulong val);
64 /* Floating-point arithmetic helpers */
65 void do_compute_fprf (int set_class);
66 #ifdef CONFIG_SOFTFLOAT
67 void do_float_check_status (void);
68 #endif
69 #if USE_PRECISE_EMULATION
70 void do_fadd (void);
71 void do_fsub (void);
72 void do_fmul (void);
73 void do_fdiv (void);
74 #endif
75 void do_fsqrt (void);
76 void do_fre (void);
77 void do_fres (void);
78 void do_frsqrte (void);
79 void do_fsel (void);
80 #if USE_PRECISE_EMULATION
81 void do_fmadd (void);
82 void do_fmsub (void);
83 #endif
84 void do_fnmadd (void);
85 void do_fnmsub (void);
86 #if USE_PRECISE_EMULATION
87 void do_frsp (void);
88 #endif
89 void do_fctiw (void);
90 void do_fctiwz (void);
91 #if defined(TARGET_PPC64)
92 void do_fcfid (void);
93 void do_fctid (void);
94 void do_fctidz (void);
95 #endif
96 void do_frin (void);
97 void do_friz (void);
98 void do_frip (void);
99 void do_frim (void);
100 void do_fcmpu (void);
101 void do_fcmpo (void);
103 /* Misc */
104 void do_tw (int flags);
105 #if defined(TARGET_PPC64)
106 void do_td (int flags);
107 #endif
108 #if !defined(CONFIG_USER_ONLY)
109 void do_store_msr (void);
110 void do_rfi (void);
111 #if defined(TARGET_PPC64)
112 void do_rfid (void);
113 void do_hrfid (void);
114 #endif
115 void do_load_6xx_tlb (int is_code);
116 void do_load_74xx_tlb (int is_code);
117 #endif
119 /* POWER / PowerPC 601 specific helpers */
120 void do_POWER_abso (void);
121 void do_POWER_clcs (void);
122 void do_POWER_div (void);
123 void do_POWER_divo (void);
124 void do_POWER_divs (void);
125 void do_POWER_divso (void);
126 void do_POWER_dozo (void);
127 void do_POWER_maskg (void);
128 void do_POWER_mulo (void);
129 #if !defined(CONFIG_USER_ONLY)
130 void do_POWER_rac (void);
131 void do_POWER_rfsvc (void);
132 void do_store_hid0_601 (void);
133 #endif
135 /* PowerPC 602 specific helper */
136 #if !defined(CONFIG_USER_ONLY)
137 void do_op_602_mfrom (void);
138 #endif
140 /* PowerPC 440 specific helpers */
141 #if !defined(CONFIG_USER_ONLY)
142 void do_440_tlbre (int word);
143 void do_440_tlbwe (int word);
144 #endif
146 /* PowerPC 4xx specific helpers */
147 void do_load_dcr (void);
148 void do_store_dcr (void);
149 #if !defined(CONFIG_USER_ONLY)
150 void do_40x_rfci (void);
151 void do_rfci (void);
152 void do_rfdi (void);
153 void do_rfmci (void);
154 void do_4xx_tlbre_lo (void);
155 void do_4xx_tlbre_hi (void);
156 void do_4xx_tlbwe_lo (void);
157 void do_4xx_tlbwe_hi (void);
158 #endif
160 /* PowerPC 440 specific helpers */
161 void do_440_dlmzb (void);
163 /* PowerPC 403 specific helpers */
164 #if !defined(CONFIG_USER_ONLY)
165 void do_load_403_pb (int num);
166 void do_store_403_pb (int num);
167 #endif
169 /* SPE extension helpers */
170 void do_brinc (void);
171 /* Fixed-point vector helpers */
172 void do_evabs (void);
173 void do_evaddw (void);
174 void do_evcntlsw (void);
175 void do_evcntlzw (void);
176 void do_evneg (void);
177 void do_evrlw (void);
178 void do_evsel (void);
179 void do_evrndw (void);
180 void do_evslw (void);
181 void do_evsrws (void);
182 void do_evsrwu (void);
183 void do_evsubfw (void);
184 void do_evcmpeq (void);
185 void do_evcmpgts (void);
186 void do_evcmpgtu (void);
187 void do_evcmplts (void);
188 void do_evcmpltu (void);
190 /* Single precision floating-point helpers */
191 void do_efscmplt (void);
192 void do_efscmpgt (void);
193 void do_efscmpeq (void);
194 void do_efscfsf (void);
195 void do_efscfuf (void);
196 void do_efsctsf (void);
197 void do_efsctuf (void);
199 void do_efscfsi (void);
200 void do_efscfui (void);
201 void do_efsctsi (void);
202 void do_efsctui (void);
203 void do_efsctsiz (void);
204 void do_efsctuiz (void);
206 /* Double precision floating-point helpers */
207 void do_efdcmplt (void);
208 void do_efdcmpgt (void);
209 void do_efdcmpeq (void);
210 void do_efdcfsf (void);
211 void do_efdcfuf (void);
212 void do_efdctsf (void);
213 void do_efdctuf (void);
215 void do_efdcfsi (void);
216 void do_efdcfui (void);
217 void do_efdctsi (void);
218 void do_efdctui (void);
219 void do_efdctsiz (void);
220 void do_efdctuiz (void);
222 void do_efdcfs (void);
223 void do_efscfd (void);
225 /* Floating-point vector helpers */
226 void do_evfsabs (void);
227 void do_evfsnabs (void);
228 void do_evfsneg (void);
229 void do_evfsadd (void);
230 void do_evfssub (void);
231 void do_evfsmul (void);
232 void do_evfsdiv (void);
233 void do_evfscmplt (void);
234 void do_evfscmpgt (void);
235 void do_evfscmpeq (void);
236 void do_evfststlt (void);
237 void do_evfststgt (void);
238 void do_evfststeq (void);
239 void do_evfscfsi (void);
240 void do_evfscfui (void);
241 void do_evfscfsf (void);
242 void do_evfscfuf (void);
243 void do_evfsctsf (void);
244 void do_evfsctuf (void);
245 void do_evfsctsi (void);
246 void do_evfsctui (void);
247 void do_evfsctsiz (void);
248 void do_evfsctuiz (void);
250 /* SPE extension */
251 /* Single precision floating-point helpers */
252 static always_inline uint32_t _do_efsabs (uint32_t val)
254 return val & ~0x80000000;
256 static always_inline uint32_t _do_efsnabs (uint32_t val)
258 return val | 0x80000000;
260 static always_inline uint32_t _do_efsneg (uint32_t val)
262 return val ^ 0x80000000;
264 static always_inline uint32_t _do_efsadd (uint32_t op1, uint32_t op2)
266 CPU_FloatU u1, u2;
267 u1.l = op1;
268 u2.l = op2;
269 u1.f = float32_add(u1.f, u2.f, &env->spe_status);
270 return u1.l;
272 static always_inline uint32_t _do_efssub (uint32_t op1, uint32_t op2)
274 CPU_FloatU u1, u2;
275 u1.l = op1;
276 u2.l = op2;
277 u1.f = float32_sub(u1.f, u2.f, &env->spe_status);
278 return u1.l;
280 static always_inline uint32_t _do_efsmul (uint32_t op1, uint32_t op2)
282 CPU_FloatU u1, u2;
283 u1.l = op1;
284 u2.l = op2;
285 u1.f = float32_mul(u1.f, u2.f, &env->spe_status);
286 return u1.l;
288 static always_inline uint32_t _do_efsdiv (uint32_t op1, uint32_t op2)
290 CPU_FloatU u1, u2;
291 u1.l = op1;
292 u2.l = op2;
293 u1.f = float32_div(u1.f, u2.f, &env->spe_status);
294 return u1.l;
297 static always_inline int _do_efststlt (uint32_t op1, uint32_t op2)
299 CPU_FloatU u1, u2;
300 u1.l = op1;
301 u2.l = op2;
302 return float32_lt(u1.f, u2.f, &env->spe_status) ? 4 : 0;
304 static always_inline int _do_efststgt (uint32_t op1, uint32_t op2)
306 CPU_FloatU u1, u2;
307 u1.l = op1;
308 u2.l = op2;
309 return float32_le(u1.f, u2.f, &env->spe_status) ? 0 : 4;
311 static always_inline int _do_efststeq (uint32_t op1, uint32_t op2)
313 CPU_FloatU u1, u2;
314 u1.l = op1;
315 u2.l = op2;
316 return float32_eq(u1.f, u2.f, &env->spe_status) ? 4 : 0;
318 /* Double precision floating-point helpers */
319 static always_inline int _do_efdtstlt (uint64_t op1, uint64_t op2)
321 CPU_DoubleU u1, u2;
322 u1.ll = op1;
323 u2.ll = op2;
324 return float64_lt(u1.d, u2.d, &env->spe_status) ? 4 : 0;
326 static always_inline int _do_efdtstgt (uint64_t op1, uint64_t op2)
328 CPU_DoubleU u1, u2;
329 u1.ll = op1;
330 u2.ll = op2;
331 return float64_le(u1.d, u2.d, &env->spe_status) ? 0 : 4;
333 static always_inline int _do_efdtsteq (uint64_t op1, uint64_t op2)
335 CPU_DoubleU u1, u2;
336 u1.ll = op1;
337 u2.ll = op2;
338 return float64_eq(u1.d, u2.d, &env->spe_status) ? 4 : 0;
340 #endif