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