root / target-ppc / op_helper.h @ 1c27f8fb
History | View | Annotate | Download (11.1 kB)
1 | 76a66253 | j_mayer | /*
|
---|---|---|---|
2 | 76a66253 | j_mayer | * PowerPC emulation helpers header for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 76a66253 | j_mayer | * Copyright (c) 2003-2007 Jocelyn Mayer
|
5 | 76a66253 | j_mayer | *
|
6 | 76a66253 | j_mayer | * This library is free software; you can redistribute it and/or
|
7 | 76a66253 | j_mayer | * modify it under the terms of the GNU Lesser General Public
|
8 | 76a66253 | j_mayer | * License as published by the Free Software Foundation; either
|
9 | 76a66253 | j_mayer | * version 2 of the License, or (at your option) any later version.
|
10 | 76a66253 | j_mayer | *
|
11 | 76a66253 | j_mayer | * This library is distributed in the hope that it will be useful,
|
12 | 76a66253 | j_mayer | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 76a66253 | j_mayer | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 76a66253 | j_mayer | * Lesser General Public License for more details.
|
15 | 76a66253 | j_mayer | *
|
16 | 76a66253 | j_mayer | * You should have received a copy of the GNU Lesser General Public
|
17 | 76a66253 | j_mayer | * License along with this library; if not, write to the Free Software
|
18 | 76a66253 | j_mayer | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 76a66253 | j_mayer | */
|
20 | 76a66253 | j_mayer | |
21 | 76a66253 | j_mayer | #if defined(MEMSUFFIX)
|
22 | 76a66253 | j_mayer | |
23 | 76a66253 | j_mayer | /* Memory load/store helpers */
|
24 | 76a66253 | j_mayer | void glue(do_lsw, MEMSUFFIX) (int dst); |
25 | 76a66253 | j_mayer | void glue(do_lsw_le, MEMSUFFIX) (int dst); |
26 | 76a66253 | j_mayer | void glue(do_stsw, MEMSUFFIX) (int src); |
27 | 76a66253 | j_mayer | void glue(do_stsw_le, MEMSUFFIX) (int src); |
28 | 76a66253 | j_mayer | void glue(do_lmw, MEMSUFFIX) (int dst); |
29 | 76a66253 | j_mayer | void glue(do_lmw_le, MEMSUFFIX) (int dst); |
30 | 76a66253 | j_mayer | void glue(do_stmw, MEMSUFFIX) (int src); |
31 | 76a66253 | j_mayer | void glue(do_stmw_le, MEMSUFFIX) (int src); |
32 | 36f69651 | j_mayer | void glue(do_icbi, MEMSUFFIX) (void); |
33 | d63001d1 | j_mayer | void glue(do_dcbz, MEMSUFFIX) (void); |
34 | 76a66253 | j_mayer | void glue(do_POWER_lscbx, MEMSUFFIX) (int dest, int ra, int rb); |
35 | 76a66253 | j_mayer | void glue(do_POWER2_lfq, MEMSUFFIX) (void); |
36 | 76a66253 | j_mayer | void glue(do_POWER2_lfq_le, MEMSUFFIX) (void); |
37 | 76a66253 | j_mayer | void glue(do_POWER2_stfq, MEMSUFFIX) (void); |
38 | 76a66253 | j_mayer | void glue(do_POWER2_stfq_le, MEMSUFFIX) (void); |
39 | 76a66253 | j_mayer | |
40 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
41 | d9bce9d9 | j_mayer | void glue(do_lsw_64, MEMSUFFIX) (int dst); |
42 | d9bce9d9 | j_mayer | void glue(do_lsw_le_64, MEMSUFFIX) (int dst); |
43 | d9bce9d9 | j_mayer | void glue(do_stsw_64, MEMSUFFIX) (int src); |
44 | d9bce9d9 | j_mayer | void glue(do_stsw_le_64, MEMSUFFIX) (int src); |
45 | d9bce9d9 | j_mayer | void glue(do_lmw_64, MEMSUFFIX) (int dst); |
46 | d9bce9d9 | j_mayer | void glue(do_lmw_le_64, MEMSUFFIX) (int dst); |
47 | d9bce9d9 | j_mayer | void glue(do_stmw_64, MEMSUFFIX) (int src); |
48 | d9bce9d9 | j_mayer | void glue(do_stmw_le_64, MEMSUFFIX) (int src); |
49 | 36f69651 | j_mayer | void glue(do_icbi_64, MEMSUFFIX) (void); |
50 | d63001d1 | j_mayer | void glue(do_dcbz_64, MEMSUFFIX) (void); |
51 | d9bce9d9 | j_mayer | #endif
|
52 | d9bce9d9 | j_mayer | |
53 | 76a66253 | j_mayer | #else
|
54 | 76a66253 | j_mayer | |
55 | a496775f | j_mayer | void do_print_mem_EA (target_ulong EA);
|
56 | a496775f | j_mayer | |
57 | 76a66253 | j_mayer | /* Registers load and stores */
|
58 | 76a66253 | j_mayer | void do_load_cr (void); |
59 | 76a66253 | j_mayer | void do_store_cr (uint32_t mask);
|
60 | 76a66253 | j_mayer | void do_load_xer (void); |
61 | 76a66253 | j_mayer | void do_store_xer (void); |
62 | c80f84e3 | j_mayer | #if defined(TARGET_PPC64)
|
63 | c80f84e3 | j_mayer | void do_store_pri (int prio); |
64 | c80f84e3 | j_mayer | #endif
|
65 | 76a66253 | j_mayer | void do_load_fpscr (void); |
66 | 76a66253 | j_mayer | void do_store_fpscr (uint32_t mask);
|
67 | a496775f | j_mayer | target_ulong ppc_load_dump_spr (int sprn);
|
68 | a496775f | j_mayer | void ppc_store_dump_spr (int sprn, target_ulong val); |
69 | 76a66253 | j_mayer | |
70 | 76a66253 | j_mayer | /* Integer arithmetic helpers */
|
71 | 76a66253 | j_mayer | void do_adde (void); |
72 | 76a66253 | j_mayer | void do_addmeo (void); |
73 | 76a66253 | j_mayer | void do_divwo (void); |
74 | 76a66253 | j_mayer | void do_divwuo (void); |
75 | 76a66253 | j_mayer | void do_mullwo (void); |
76 | 76a66253 | j_mayer | void do_nego (void); |
77 | 76a66253 | j_mayer | void do_subfe (void); |
78 | 76a66253 | j_mayer | void do_subfmeo (void); |
79 | 76a66253 | j_mayer | void do_subfzeo (void); |
80 | d9bce9d9 | j_mayer | void do_sraw (void); |
81 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
82 | d9bce9d9 | j_mayer | void do_adde_64 (void); |
83 | d9bce9d9 | j_mayer | void do_addmeo_64 (void); |
84 | d9bce9d9 | j_mayer | void do_imul64 (uint64_t *tl, uint64_t *th);
|
85 | d9bce9d9 | j_mayer | void do_mul64 (uint64_t *tl, uint64_t *th);
|
86 | d9bce9d9 | j_mayer | void do_divdo (void); |
87 | d9bce9d9 | j_mayer | void do_divduo (void); |
88 | d9bce9d9 | j_mayer | void do_mulldo (void); |
89 | d9bce9d9 | j_mayer | void do_nego_64 (void); |
90 | d9bce9d9 | j_mayer | void do_subfe_64 (void); |
91 | d9bce9d9 | j_mayer | void do_subfmeo_64 (void); |
92 | d9bce9d9 | j_mayer | void do_subfzeo_64 (void); |
93 | d9bce9d9 | j_mayer | void do_srad (void); |
94 | d9bce9d9 | j_mayer | #endif
|
95 | d9bce9d9 | j_mayer | void do_popcntb (void); |
96 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
97 | d9bce9d9 | j_mayer | void do_popcntb_64 (void); |
98 | d9bce9d9 | j_mayer | #endif
|
99 | 76a66253 | j_mayer | |
100 | 76a66253 | j_mayer | /* Floating-point arithmetic helpers */
|
101 | 76a66253 | j_mayer | void do_fsqrt (void); |
102 | d7e4b87e | j_mayer | void do_fre (void); |
103 | 76a66253 | j_mayer | void do_fres (void); |
104 | 76a66253 | j_mayer | void do_frsqrte (void); |
105 | 76a66253 | j_mayer | void do_fsel (void); |
106 | e864cabd | j_mayer | #if USE_PRECISE_EMULATION
|
107 | e864cabd | j_mayer | void do_fmadd (void); |
108 | e864cabd | j_mayer | void do_fmsub (void); |
109 | e864cabd | j_mayer | #endif
|
110 | 76a66253 | j_mayer | void do_fnmadd (void); |
111 | 76a66253 | j_mayer | void do_fnmsub (void); |
112 | 76a66253 | j_mayer | void do_fctiw (void); |
113 | 76a66253 | j_mayer | void do_fctiwz (void); |
114 | 426613db | j_mayer | #if defined(TARGET_PPC64)
|
115 | 426613db | j_mayer | void do_fcfid (void); |
116 | 426613db | j_mayer | void do_fctid (void); |
117 | 426613db | j_mayer | void do_fctidz (void); |
118 | 426613db | j_mayer | #endif
|
119 | d7e4b87e | j_mayer | void do_frin (void); |
120 | d7e4b87e | j_mayer | void do_friz (void); |
121 | d7e4b87e | j_mayer | void do_frip (void); |
122 | d7e4b87e | j_mayer | void do_frim (void); |
123 | 76a66253 | j_mayer | void do_fcmpu (void); |
124 | 76a66253 | j_mayer | void do_fcmpo (void); |
125 | 76a66253 | j_mayer | |
126 | 0487d6a8 | j_mayer | /* Misc */
|
127 | 76a66253 | j_mayer | void do_tw (int flags); |
128 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
129 | d9bce9d9 | j_mayer | void do_td (int flags); |
130 | d9bce9d9 | j_mayer | #endif
|
131 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
132 | 76a66253 | j_mayer | void do_rfi (void); |
133 | d9bce9d9 | j_mayer | #if defined(TARGET_PPC64)
|
134 | 426613db | j_mayer | void do_rfid (void); |
135 | d9bce9d9 | j_mayer | #endif
|
136 | be147d08 | j_mayer | #if defined(TARGET_PPC64H)
|
137 | be147d08 | j_mayer | void do_hrfid (void); |
138 | be147d08 | j_mayer | #endif
|
139 | 76a66253 | j_mayer | void do_load_6xx_tlb (int is_code); |
140 | 7dbe11ac | j_mayer | void do_load_74xx_tlb (int is_code); |
141 | 76a66253 | j_mayer | #endif
|
142 | 76a66253 | j_mayer | |
143 | 76a66253 | j_mayer | /* POWER / PowerPC 601 specific helpers */
|
144 | 76a66253 | j_mayer | void do_store_601_batu (int nr); |
145 | 76a66253 | j_mayer | void do_POWER_abso (void); |
146 | 76a66253 | j_mayer | void do_POWER_clcs (void); |
147 | 76a66253 | j_mayer | void do_POWER_div (void); |
148 | 76a66253 | j_mayer | void do_POWER_divo (void); |
149 | 76a66253 | j_mayer | void do_POWER_divs (void); |
150 | 76a66253 | j_mayer | void do_POWER_divso (void); |
151 | 76a66253 | j_mayer | void do_POWER_dozo (void); |
152 | 76a66253 | j_mayer | void do_POWER_maskg (void); |
153 | 76a66253 | j_mayer | void do_POWER_mulo (void); |
154 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
155 | 76a66253 | j_mayer | void do_POWER_rac (void); |
156 | 76a66253 | j_mayer | void do_POWER_rfsvc (void); |
157 | 76a66253 | j_mayer | #endif
|
158 | 76a66253 | j_mayer | |
159 | 76a66253 | j_mayer | /* PowerPC 602 specific helper */
|
160 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
161 | 76a66253 | j_mayer | void do_op_602_mfrom (void); |
162 | 76a66253 | j_mayer | #endif
|
163 | 76a66253 | j_mayer | |
164 | a4bb6c3e | j_mayer | /* PowerPC 440 specific helpers */
|
165 | 5eb7995e | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
166 | a4bb6c3e | j_mayer | void do_440_tlbre (int word); |
167 | a4bb6c3e | j_mayer | void do_440_tlbwe (int word); |
168 | 5eb7995e | j_mayer | #endif
|
169 | 5eb7995e | j_mayer | |
170 | 76a66253 | j_mayer | /* PowerPC 4xx specific helpers */
|
171 | 76a66253 | j_mayer | void do_405_check_ov (void); |
172 | 76a66253 | j_mayer | void do_405_check_sat (void); |
173 | a42bd6cc | j_mayer | void do_load_dcr (void); |
174 | a42bd6cc | j_mayer | void do_store_dcr (void); |
175 | a750fc0b | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
176 | a42bd6cc | j_mayer | void do_40x_rfci (void); |
177 | a42bd6cc | j_mayer | void do_rfci (void); |
178 | a42bd6cc | j_mayer | void do_rfdi (void); |
179 | a42bd6cc | j_mayer | void do_rfmci (void); |
180 | 76a66253 | j_mayer | void do_4xx_tlbre_lo (void); |
181 | 76a66253 | j_mayer | void do_4xx_tlbre_hi (void); |
182 | 76a66253 | j_mayer | void do_4xx_tlbwe_lo (void); |
183 | 76a66253 | j_mayer | void do_4xx_tlbwe_hi (void); |
184 | 76a66253 | j_mayer | #endif
|
185 | 76a66253 | j_mayer | |
186 | 0487d6a8 | j_mayer | /* PowerPC 440 specific helpers */
|
187 | 76a66253 | j_mayer | void do_440_dlmzb (void); |
188 | 76a66253 | j_mayer | |
189 | 0487d6a8 | j_mayer | /* PowerPC 403 specific helpers */
|
190 | 76a66253 | j_mayer | #if !defined(CONFIG_USER_ONLY)
|
191 | 76a66253 | j_mayer | void do_load_403_pb (int num); |
192 | 76a66253 | j_mayer | void do_store_403_pb (int num); |
193 | 76a66253 | j_mayer | #endif
|
194 | 76a66253 | j_mayer | |
195 | 35cdaad6 | j_mayer | #if defined(TARGET_PPCEMB)
|
196 | 0487d6a8 | j_mayer | /* SPE extension helpers */
|
197 | 0487d6a8 | j_mayer | void do_brinc (void); |
198 | 0487d6a8 | j_mayer | /* Fixed-point vector helpers */
|
199 | 0487d6a8 | j_mayer | void do_evabs (void); |
200 | 0487d6a8 | j_mayer | void do_evaddw (void); |
201 | 0487d6a8 | j_mayer | void do_evcntlsw (void); |
202 | 0487d6a8 | j_mayer | void do_evcntlzw (void); |
203 | 0487d6a8 | j_mayer | void do_evneg (void); |
204 | 0487d6a8 | j_mayer | void do_evrlw (void); |
205 | 0487d6a8 | j_mayer | void do_evsel (void); |
206 | 0487d6a8 | j_mayer | void do_evrndw (void); |
207 | 0487d6a8 | j_mayer | void do_evslw (void); |
208 | 0487d6a8 | j_mayer | void do_evsrws (void); |
209 | 0487d6a8 | j_mayer | void do_evsrwu (void); |
210 | 0487d6a8 | j_mayer | void do_evsubfw (void); |
211 | 0487d6a8 | j_mayer | void do_evcmpeq (void); |
212 | 0487d6a8 | j_mayer | void do_evcmpgts (void); |
213 | 0487d6a8 | j_mayer | void do_evcmpgtu (void); |
214 | 0487d6a8 | j_mayer | void do_evcmplts (void); |
215 | 0487d6a8 | j_mayer | void do_evcmpltu (void); |
216 | 0487d6a8 | j_mayer | |
217 | 0487d6a8 | j_mayer | /* Single precision floating-point helpers */
|
218 | 0487d6a8 | j_mayer | void do_efscmplt (void); |
219 | 0487d6a8 | j_mayer | void do_efscmpgt (void); |
220 | 0487d6a8 | j_mayer | void do_efscmpeq (void); |
221 | 0487d6a8 | j_mayer | void do_efscfsf (void); |
222 | 0487d6a8 | j_mayer | void do_efscfuf (void); |
223 | 0487d6a8 | j_mayer | void do_efsctsf (void); |
224 | 0487d6a8 | j_mayer | void do_efsctuf (void); |
225 | 0487d6a8 | j_mayer | |
226 | 0487d6a8 | j_mayer | void do_efscfsi (void); |
227 | 0487d6a8 | j_mayer | void do_efscfui (void); |
228 | 0487d6a8 | j_mayer | void do_efsctsi (void); |
229 | 0487d6a8 | j_mayer | void do_efsctui (void); |
230 | 0487d6a8 | j_mayer | void do_efsctsiz (void); |
231 | 0487d6a8 | j_mayer | void do_efsctuiz (void); |
232 | 0487d6a8 | j_mayer | |
233 | 0487d6a8 | j_mayer | /* Double precision floating-point helpers */
|
234 | 0487d6a8 | j_mayer | void do_efdcmplt (void); |
235 | 0487d6a8 | j_mayer | void do_efdcmpgt (void); |
236 | 0487d6a8 | j_mayer | void do_efdcmpeq (void); |
237 | 0487d6a8 | j_mayer | void do_efdcfsf (void); |
238 | 0487d6a8 | j_mayer | void do_efdcfuf (void); |
239 | 0487d6a8 | j_mayer | void do_efdctsf (void); |
240 | 0487d6a8 | j_mayer | void do_efdctuf (void); |
241 | 0487d6a8 | j_mayer | |
242 | 0487d6a8 | j_mayer | void do_efdcfsi (void); |
243 | 0487d6a8 | j_mayer | void do_efdcfui (void); |
244 | 0487d6a8 | j_mayer | void do_efdctsi (void); |
245 | 0487d6a8 | j_mayer | void do_efdctui (void); |
246 | 0487d6a8 | j_mayer | void do_efdctsiz (void); |
247 | 0487d6a8 | j_mayer | void do_efdctuiz (void); |
248 | 0487d6a8 | j_mayer | |
249 | 0487d6a8 | j_mayer | void do_efdcfs (void); |
250 | 0487d6a8 | j_mayer | void do_efscfd (void); |
251 | 0487d6a8 | j_mayer | |
252 | 0487d6a8 | j_mayer | /* Floating-point vector helpers */
|
253 | 0487d6a8 | j_mayer | void do_evfsabs (void); |
254 | 0487d6a8 | j_mayer | void do_evfsnabs (void); |
255 | 0487d6a8 | j_mayer | void do_evfsneg (void); |
256 | 0487d6a8 | j_mayer | void do_evfsadd (void); |
257 | 0487d6a8 | j_mayer | void do_evfssub (void); |
258 | 0487d6a8 | j_mayer | void do_evfsmul (void); |
259 | 0487d6a8 | j_mayer | void do_evfsdiv (void); |
260 | 0487d6a8 | j_mayer | void do_evfscmplt (void); |
261 | 0487d6a8 | j_mayer | void do_evfscmpgt (void); |
262 | 0487d6a8 | j_mayer | void do_evfscmpeq (void); |
263 | 0487d6a8 | j_mayer | void do_evfststlt (void); |
264 | 0487d6a8 | j_mayer | void do_evfststgt (void); |
265 | 0487d6a8 | j_mayer | void do_evfststeq (void); |
266 | 0487d6a8 | j_mayer | void do_evfscfsi (void); |
267 | 0487d6a8 | j_mayer | void do_evfscfui (void); |
268 | 0487d6a8 | j_mayer | void do_evfscfsf (void); |
269 | 0487d6a8 | j_mayer | void do_evfscfuf (void); |
270 | 0487d6a8 | j_mayer | void do_evfsctsf (void); |
271 | 0487d6a8 | j_mayer | void do_evfsctuf (void); |
272 | 0487d6a8 | j_mayer | void do_evfsctsi (void); |
273 | 0487d6a8 | j_mayer | void do_evfsctui (void); |
274 | 0487d6a8 | j_mayer | void do_evfsctsiz (void); |
275 | 0487d6a8 | j_mayer | void do_evfsctuiz (void); |
276 | 35cdaad6 | j_mayer | #endif /* defined(TARGET_PPCEMB) */ |
277 | 0487d6a8 | j_mayer | |
278 | 0487d6a8 | j_mayer | /* Inlined helpers: used in micro-operation as well as helpers */
|
279 | 0487d6a8 | j_mayer | /* Generic fixed-point helpers */
|
280 | 0487d6a8 | j_mayer | static inline int _do_cntlzw (uint32_t val) |
281 | 0487d6a8 | j_mayer | { |
282 | 0487d6a8 | j_mayer | int cnt = 0; |
283 | 0487d6a8 | j_mayer | if (!(val & 0xFFFF0000UL)) { |
284 | 0487d6a8 | j_mayer | cnt += 16;
|
285 | 0487d6a8 | j_mayer | val <<= 16;
|
286 | 0487d6a8 | j_mayer | } |
287 | 0487d6a8 | j_mayer | if (!(val & 0xFF000000UL)) { |
288 | 0487d6a8 | j_mayer | cnt += 8;
|
289 | 0487d6a8 | j_mayer | val <<= 8;
|
290 | 0487d6a8 | j_mayer | } |
291 | 0487d6a8 | j_mayer | if (!(val & 0xF0000000UL)) { |
292 | 0487d6a8 | j_mayer | cnt += 4;
|
293 | 0487d6a8 | j_mayer | val <<= 4;
|
294 | 0487d6a8 | j_mayer | } |
295 | 0487d6a8 | j_mayer | if (!(val & 0xC0000000UL)) { |
296 | 0487d6a8 | j_mayer | cnt += 2;
|
297 | 0487d6a8 | j_mayer | val <<= 2;
|
298 | 0487d6a8 | j_mayer | } |
299 | 0487d6a8 | j_mayer | if (!(val & 0x80000000UL)) { |
300 | 0487d6a8 | j_mayer | cnt++; |
301 | 0487d6a8 | j_mayer | val <<= 1;
|
302 | 0487d6a8 | j_mayer | } |
303 | 0487d6a8 | j_mayer | if (!(val & 0x80000000UL)) { |
304 | 0487d6a8 | j_mayer | cnt++; |
305 | 0487d6a8 | j_mayer | } |
306 | 0487d6a8 | j_mayer | return cnt;
|
307 | 0487d6a8 | j_mayer | } |
308 | 0487d6a8 | j_mayer | |
309 | 0487d6a8 | j_mayer | static inline int _do_cntlzd (uint64_t val) |
310 | 0487d6a8 | j_mayer | { |
311 | 0487d6a8 | j_mayer | int cnt = 0; |
312 | 0487d6a8 | j_mayer | #if HOST_LONG_BITS == 64 |
313 | 0487d6a8 | j_mayer | if (!(val & 0xFFFFFFFF00000000ULL)) { |
314 | 0487d6a8 | j_mayer | cnt += 32;
|
315 | 0487d6a8 | j_mayer | val <<= 32;
|
316 | 0487d6a8 | j_mayer | } |
317 | 0487d6a8 | j_mayer | if (!(val & 0xFFFF000000000000ULL)) { |
318 | 0487d6a8 | j_mayer | cnt += 16;
|
319 | 0487d6a8 | j_mayer | val <<= 16;
|
320 | 0487d6a8 | j_mayer | } |
321 | 0487d6a8 | j_mayer | if (!(val & 0xFF00000000000000ULL)) { |
322 | 0487d6a8 | j_mayer | cnt += 8;
|
323 | 0487d6a8 | j_mayer | val <<= 8;
|
324 | 0487d6a8 | j_mayer | } |
325 | 0487d6a8 | j_mayer | if (!(val & 0xF000000000000000ULL)) { |
326 | 0487d6a8 | j_mayer | cnt += 4;
|
327 | 0487d6a8 | j_mayer | val <<= 4;
|
328 | 0487d6a8 | j_mayer | } |
329 | 0487d6a8 | j_mayer | if (!(val & 0xC000000000000000ULL)) { |
330 | 0487d6a8 | j_mayer | cnt += 2;
|
331 | 0487d6a8 | j_mayer | val <<= 2;
|
332 | 0487d6a8 | j_mayer | } |
333 | 0487d6a8 | j_mayer | if (!(val & 0x8000000000000000ULL)) { |
334 | 0487d6a8 | j_mayer | cnt++; |
335 | 0487d6a8 | j_mayer | val <<= 1;
|
336 | 0487d6a8 | j_mayer | } |
337 | 0487d6a8 | j_mayer | if (!(val & 0x8000000000000000ULL)) { |
338 | 0487d6a8 | j_mayer | cnt++; |
339 | 0487d6a8 | j_mayer | } |
340 | 0487d6a8 | j_mayer | #else
|
341 | 0487d6a8 | j_mayer | /* Make it easier on 32 bits host machines */
|
342 | 0487d6a8 | j_mayer | if (!(val >> 32)) |
343 | 1698b741 | j_mayer | cnt = _do_cntlzw(val) + 32;
|
344 | 0487d6a8 | j_mayer | else
|
345 | 1698b741 | j_mayer | cnt = _do_cntlzw(val >> 32);
|
346 | 0487d6a8 | j_mayer | #endif
|
347 | 0487d6a8 | j_mayer | return cnt;
|
348 | 0487d6a8 | j_mayer | } |
349 | 0487d6a8 | j_mayer | |
350 | 35cdaad6 | j_mayer | #if defined(TARGET_PPCEMB)
|
351 | 0487d6a8 | j_mayer | /* SPE extension */
|
352 | 0487d6a8 | j_mayer | /* Single precision floating-point helpers */
|
353 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsabs (uint32_t val) |
354 | 0487d6a8 | j_mayer | { |
355 | 0487d6a8 | j_mayer | return val & ~0x80000000; |
356 | 0487d6a8 | j_mayer | } |
357 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsnabs (uint32_t val) |
358 | 0487d6a8 | j_mayer | { |
359 | 0487d6a8 | j_mayer | return val | 0x80000000; |
360 | 0487d6a8 | j_mayer | } |
361 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsneg (uint32_t val) |
362 | 0487d6a8 | j_mayer | { |
363 | 0487d6a8 | j_mayer | return val ^ 0x80000000; |
364 | 0487d6a8 | j_mayer | } |
365 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsadd (uint32_t op1, uint32_t op2) |
366 | 0487d6a8 | j_mayer | { |
367 | 0487d6a8 | j_mayer | union {
|
368 | 0487d6a8 | j_mayer | uint32_t u; |
369 | 0487d6a8 | j_mayer | float32 f; |
370 | 0487d6a8 | j_mayer | } u1, u2; |
371 | 0487d6a8 | j_mayer | u1.u = op1; |
372 | 0487d6a8 | j_mayer | u2.u = op2; |
373 | 0487d6a8 | j_mayer | u1.f = float32_add(u1.f, u2.f, &env->spe_status); |
374 | 0487d6a8 | j_mayer | return u1.u;
|
375 | 0487d6a8 | j_mayer | } |
376 | 0487d6a8 | j_mayer | static inline uint32_t _do_efssub (uint32_t op1, uint32_t op2) |
377 | 0487d6a8 | j_mayer | { |
378 | 0487d6a8 | j_mayer | union {
|
379 | 0487d6a8 | j_mayer | uint32_t u; |
380 | 0487d6a8 | j_mayer | float32 f; |
381 | 0487d6a8 | j_mayer | } u1, u2; |
382 | 0487d6a8 | j_mayer | u1.u = op1; |
383 | 0487d6a8 | j_mayer | u2.u = op2; |
384 | 0487d6a8 | j_mayer | u1.f = float32_sub(u1.f, u2.f, &env->spe_status); |
385 | 0487d6a8 | j_mayer | return u1.u;
|
386 | 0487d6a8 | j_mayer | } |
387 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsmul (uint32_t op1, uint32_t op2) |
388 | 0487d6a8 | j_mayer | { |
389 | 0487d6a8 | j_mayer | union {
|
390 | 0487d6a8 | j_mayer | uint32_t u; |
391 | 0487d6a8 | j_mayer | float32 f; |
392 | 0487d6a8 | j_mayer | } u1, u2; |
393 | 0487d6a8 | j_mayer | u1.u = op1; |
394 | 0487d6a8 | j_mayer | u2.u = op2; |
395 | 0487d6a8 | j_mayer | u1.f = float32_mul(u1.f, u2.f, &env->spe_status); |
396 | 0487d6a8 | j_mayer | return u1.u;
|
397 | 0487d6a8 | j_mayer | } |
398 | 0487d6a8 | j_mayer | static inline uint32_t _do_efsdiv (uint32_t op1, uint32_t op2) |
399 | 0487d6a8 | j_mayer | { |
400 | 0487d6a8 | j_mayer | union {
|
401 | 0487d6a8 | j_mayer | uint32_t u; |
402 | 0487d6a8 | j_mayer | float32 f; |
403 | 0487d6a8 | j_mayer | } u1, u2; |
404 | 0487d6a8 | j_mayer | u1.u = op1; |
405 | 0487d6a8 | j_mayer | u2.u = op2; |
406 | 0487d6a8 | j_mayer | u1.f = float32_div(u1.f, u2.f, &env->spe_status); |
407 | 0487d6a8 | j_mayer | return u1.u;
|
408 | 0487d6a8 | j_mayer | } |
409 | 0487d6a8 | j_mayer | |
410 | 0487d6a8 | j_mayer | static inline int _do_efststlt (uint32_t op1, uint32_t op2) |
411 | 0487d6a8 | j_mayer | { |
412 | 0487d6a8 | j_mayer | union {
|
413 | 0487d6a8 | j_mayer | uint32_t u; |
414 | 0487d6a8 | j_mayer | float32 f; |
415 | 0487d6a8 | j_mayer | } u1, u2; |
416 | 0487d6a8 | j_mayer | u1.u = op1; |
417 | 0487d6a8 | j_mayer | u2.u = op2; |
418 | 0487d6a8 | j_mayer | return float32_lt(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
419 | 0487d6a8 | j_mayer | } |
420 | 0487d6a8 | j_mayer | static inline int _do_efststgt (uint32_t op1, uint32_t op2) |
421 | 0487d6a8 | j_mayer | { |
422 | 0487d6a8 | j_mayer | union {
|
423 | 0487d6a8 | j_mayer | uint32_t u; |
424 | 0487d6a8 | j_mayer | float32 f; |
425 | 0487d6a8 | j_mayer | } u1, u2; |
426 | 0487d6a8 | j_mayer | u1.u = op1; |
427 | 0487d6a8 | j_mayer | u2.u = op2; |
428 | 0487d6a8 | j_mayer | return float32_le(u1.f, u2.f, &env->spe_status) ? 0 : 1; |
429 | 0487d6a8 | j_mayer | } |
430 | 0487d6a8 | j_mayer | static inline int _do_efststeq (uint32_t op1, uint32_t op2) |
431 | 0487d6a8 | j_mayer | { |
432 | 0487d6a8 | j_mayer | union {
|
433 | 0487d6a8 | j_mayer | uint32_t u; |
434 | 0487d6a8 | j_mayer | float32 f; |
435 | 0487d6a8 | j_mayer | } u1, u2; |
436 | 0487d6a8 | j_mayer | u1.u = op1; |
437 | 0487d6a8 | j_mayer | u2.u = op2; |
438 | 0487d6a8 | j_mayer | return float32_eq(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
439 | 0487d6a8 | j_mayer | } |
440 | 0487d6a8 | j_mayer | /* Double precision floating-point helpers */
|
441 | 0487d6a8 | j_mayer | static inline int _do_efdtstlt (uint64_t op1, uint64_t op2) |
442 | 0487d6a8 | j_mayer | { |
443 | 0487d6a8 | j_mayer | union {
|
444 | 0487d6a8 | j_mayer | uint64_t u; |
445 | 0487d6a8 | j_mayer | float64 f; |
446 | 0487d6a8 | j_mayer | } u1, u2; |
447 | 0487d6a8 | j_mayer | u1.u = op1; |
448 | 0487d6a8 | j_mayer | u2.u = op2; |
449 | 0487d6a8 | j_mayer | return float64_lt(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
450 | 0487d6a8 | j_mayer | } |
451 | 0487d6a8 | j_mayer | static inline int _do_efdtstgt (uint64_t op1, uint64_t op2) |
452 | 0487d6a8 | j_mayer | { |
453 | 0487d6a8 | j_mayer | union {
|
454 | 0487d6a8 | j_mayer | uint64_t u; |
455 | 0487d6a8 | j_mayer | float64 f; |
456 | 0487d6a8 | j_mayer | } u1, u2; |
457 | 0487d6a8 | j_mayer | u1.u = op1; |
458 | 0487d6a8 | j_mayer | u2.u = op2; |
459 | 0487d6a8 | j_mayer | return float64_le(u1.f, u2.f, &env->spe_status) ? 0 : 1; |
460 | 0487d6a8 | j_mayer | } |
461 | 0487d6a8 | j_mayer | static inline int _do_efdtsteq (uint64_t op1, uint64_t op2) |
462 | 0487d6a8 | j_mayer | { |
463 | 0487d6a8 | j_mayer | union {
|
464 | 0487d6a8 | j_mayer | uint64_t u; |
465 | 0487d6a8 | j_mayer | float64 f; |
466 | 0487d6a8 | j_mayer | } u1, u2; |
467 | 0487d6a8 | j_mayer | u1.u = op1; |
468 | 0487d6a8 | j_mayer | u2.u = op2; |
469 | 0487d6a8 | j_mayer | return float64_eq(u1.f, u2.f, &env->spe_status) ? 1 : 0; |
470 | 0487d6a8 | j_mayer | } |
471 | 35cdaad6 | j_mayer | #endif /* defined(TARGET_PPCEMB) */ |
472 | 76a66253 | j_mayer | #endif |