root / target-mips / op_helper.c @ 95af5ce5
History | View | Annotate | Download (44.4 kB)
1 | 6af0bf9c | bellard | /*
|
---|---|---|---|
2 | 6af0bf9c | bellard | * MIPS emulation helpers for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 6af0bf9c | bellard | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 6af0bf9c | bellard | *
|
6 | 6af0bf9c | bellard | * This library is free software; you can redistribute it and/or
|
7 | 6af0bf9c | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 6af0bf9c | bellard | * License as published by the Free Software Foundation; either
|
9 | 6af0bf9c | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 6af0bf9c | bellard | *
|
11 | 6af0bf9c | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 6af0bf9c | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 6af0bf9c | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 6af0bf9c | bellard | * Lesser General Public License for more details.
|
15 | 6af0bf9c | bellard | *
|
16 | 6af0bf9c | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 6af0bf9c | bellard | * License along with this library; if not, write to the Free Software
|
18 | 6af0bf9c | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 6af0bf9c | bellard | */
|
20 | 2d0e944d | ths | #include <stdlib.h> |
21 | 6af0bf9c | bellard | #include "exec.h" |
22 | 6af0bf9c | bellard | |
23 | 05f778c8 | ths | #include "host-utils.h" |
24 | 05f778c8 | ths | |
25 | 273af660 | ths | #ifdef __s390__
|
26 | 273af660 | ths | # define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL)) |
27 | 273af660 | ths | #else
|
28 | 273af660 | ths | # define GETPC() (__builtin_return_address(0)) |
29 | 273af660 | ths | #endif
|
30 | 4ad40f36 | bellard | |
31 | 6af0bf9c | bellard | /*****************************************************************************/
|
32 | 6af0bf9c | bellard | /* Exceptions processing helpers */
|
33 | 6af0bf9c | bellard | |
34 | 6af0bf9c | bellard | void do_raise_exception_err (uint32_t exception, int error_code) |
35 | 6af0bf9c | bellard | { |
36 | 6af0bf9c | bellard | #if 1 |
37 | 6af0bf9c | bellard | if (logfile && exception < 0x100) |
38 | 6af0bf9c | bellard | fprintf(logfile, "%s: %d %d\n", __func__, exception, error_code);
|
39 | 6af0bf9c | bellard | #endif
|
40 | 6af0bf9c | bellard | env->exception_index = exception; |
41 | 6af0bf9c | bellard | env->error_code = error_code; |
42 | 6af0bf9c | bellard | T0 = 0;
|
43 | 6af0bf9c | bellard | cpu_loop_exit(); |
44 | 6af0bf9c | bellard | } |
45 | 6af0bf9c | bellard | |
46 | 6af0bf9c | bellard | void do_raise_exception (uint32_t exception)
|
47 | 6af0bf9c | bellard | { |
48 | 6af0bf9c | bellard | do_raise_exception_err(exception, 0);
|
49 | 6af0bf9c | bellard | } |
50 | 6af0bf9c | bellard | |
51 | 48d38ca5 | ths | void do_interrupt_restart (void) |
52 | 48d38ca5 | ths | { |
53 | 48d38ca5 | ths | if (!(env->CP0_Status & (1 << CP0St_EXL)) && |
54 | 48d38ca5 | ths | !(env->CP0_Status & (1 << CP0St_ERL)) &&
|
55 | 48d38ca5 | ths | !(env->hflags & MIPS_HFLAG_DM) && |
56 | 48d38ca5 | ths | (env->CP0_Status & (1 << CP0St_IE)) &&
|
57 | 48d38ca5 | ths | (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask)) { |
58 | 48d38ca5 | ths | env->CP0_Cause &= ~(0x1f << CP0Ca_EC);
|
59 | 48d38ca5 | ths | do_raise_exception(EXCP_EXT_INTERRUPT); |
60 | 48d38ca5 | ths | } |
61 | 48d38ca5 | ths | } |
62 | 48d38ca5 | ths | |
63 | 4ad40f36 | bellard | void do_restore_state (void *pc_ptr) |
64 | 4ad40f36 | bellard | { |
65 | a607922c | bellard | TranslationBlock *tb; |
66 | a607922c | bellard | unsigned long pc = (unsigned long) pc_ptr; |
67 | a607922c | bellard | |
68 | a607922c | bellard | tb = tb_find_pc (pc); |
69 | a607922c | bellard | if (tb) {
|
70 | a607922c | bellard | cpu_restore_state (tb, env, pc, NULL);
|
71 | a607922c | bellard | } |
72 | 4ad40f36 | bellard | } |
73 | 4ad40f36 | bellard | |
74 | 30898801 | ths | void do_clo (void) |
75 | 30898801 | ths | { |
76 | 30898801 | ths | T0 = clo32(T0); |
77 | 30898801 | ths | } |
78 | 30898801 | ths | |
79 | 30898801 | ths | void do_clz (void) |
80 | 30898801 | ths | { |
81 | 30898801 | ths | T0 = clz32(T0); |
82 | 30898801 | ths | } |
83 | 30898801 | ths | |
84 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
85 | c570fd16 | ths | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
86 | c570fd16 | ths | /* Those might call libgcc functions. */
|
87 | c570fd16 | ths | void do_dsll (void) |
88 | c570fd16 | ths | { |
89 | c570fd16 | ths | T0 = T0 << T1; |
90 | c570fd16 | ths | } |
91 | c570fd16 | ths | |
92 | c570fd16 | ths | void do_dsll32 (void) |
93 | c570fd16 | ths | { |
94 | c570fd16 | ths | T0 = T0 << (T1 + 32);
|
95 | c570fd16 | ths | } |
96 | c570fd16 | ths | |
97 | c570fd16 | ths | void do_dsra (void) |
98 | c570fd16 | ths | { |
99 | c570fd16 | ths | T0 = (int64_t)T0 >> T1; |
100 | c570fd16 | ths | } |
101 | c570fd16 | ths | |
102 | c570fd16 | ths | void do_dsra32 (void) |
103 | c570fd16 | ths | { |
104 | c570fd16 | ths | T0 = (int64_t)T0 >> (T1 + 32);
|
105 | c570fd16 | ths | } |
106 | c570fd16 | ths | |
107 | c570fd16 | ths | void do_dsrl (void) |
108 | c570fd16 | ths | { |
109 | c570fd16 | ths | T0 = T0 >> T1; |
110 | c570fd16 | ths | } |
111 | c570fd16 | ths | |
112 | c570fd16 | ths | void do_dsrl32 (void) |
113 | c570fd16 | ths | { |
114 | c570fd16 | ths | T0 = T0 >> (T1 + 32);
|
115 | c570fd16 | ths | } |
116 | c570fd16 | ths | |
117 | c570fd16 | ths | void do_drotr (void) |
118 | c570fd16 | ths | { |
119 | c570fd16 | ths | target_ulong tmp; |
120 | c570fd16 | ths | |
121 | c570fd16 | ths | if (T1) {
|
122 | c6d6dd7c | ths | tmp = T0 << (0x40 - T1);
|
123 | c6d6dd7c | ths | T0 = (T0 >> T1) | tmp; |
124 | 5a63bcb2 | ths | } |
125 | c570fd16 | ths | } |
126 | c570fd16 | ths | |
127 | c570fd16 | ths | void do_drotr32 (void) |
128 | c570fd16 | ths | { |
129 | c570fd16 | ths | target_ulong tmp; |
130 | c570fd16 | ths | |
131 | c6d6dd7c | ths | tmp = T0 << (0x40 - (32 + T1)); |
132 | c6d6dd7c | ths | T0 = (T0 >> (32 + T1)) | tmp;
|
133 | c570fd16 | ths | } |
134 | c570fd16 | ths | |
135 | c570fd16 | ths | void do_dsllv (void) |
136 | c570fd16 | ths | { |
137 | c570fd16 | ths | T0 = T1 << (T0 & 0x3F);
|
138 | c570fd16 | ths | } |
139 | c570fd16 | ths | |
140 | c570fd16 | ths | void do_dsrav (void) |
141 | c570fd16 | ths | { |
142 | c570fd16 | ths | T0 = (int64_t)T1 >> (T0 & 0x3F);
|
143 | c570fd16 | ths | } |
144 | c570fd16 | ths | |
145 | c570fd16 | ths | void do_dsrlv (void) |
146 | c570fd16 | ths | { |
147 | c570fd16 | ths | T0 = T1 >> (T0 & 0x3F);
|
148 | c570fd16 | ths | } |
149 | c570fd16 | ths | |
150 | c570fd16 | ths | void do_drotrv (void) |
151 | c570fd16 | ths | { |
152 | c570fd16 | ths | target_ulong tmp; |
153 | c570fd16 | ths | |
154 | c570fd16 | ths | T0 &= 0x3F;
|
155 | c570fd16 | ths | if (T0) {
|
156 | c6d6dd7c | ths | tmp = T1 << (0x40 - T0);
|
157 | c6d6dd7c | ths | T0 = (T1 >> T0) | tmp; |
158 | c570fd16 | ths | } else
|
159 | c6d6dd7c | ths | T0 = T1; |
160 | c570fd16 | ths | } |
161 | 05f778c8 | ths | |
162 | 95af5ce5 | ths | #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
163 | 95af5ce5 | ths | |
164 | 05f778c8 | ths | void do_dclo (void) |
165 | 05f778c8 | ths | { |
166 | 05f778c8 | ths | T0 = clo64(T0); |
167 | 05f778c8 | ths | } |
168 | 05f778c8 | ths | |
169 | 05f778c8 | ths | void do_dclz (void) |
170 | 05f778c8 | ths | { |
171 | 05f778c8 | ths | T0 = clz64(T0); |
172 | 05f778c8 | ths | } |
173 | 05f778c8 | ths | |
174 | d26bc211 | ths | #endif /* TARGET_MIPS64 */ |
175 | c570fd16 | ths | |
176 | 6af0bf9c | bellard | /* 64 bits arithmetic for 32 bits hosts */
|
177 | c570fd16 | ths | #if TARGET_LONG_BITS > HOST_LONG_BITS
|
178 | aa343735 | ths | static always_inline uint64_t get_HILO (void) |
179 | 6af0bf9c | bellard | { |
180 | d0dc7dc3 | ths | return (env->HI[env->current_tc][0] << 32) | (uint32_t)env->LO[env->current_tc][0]; |
181 | 6af0bf9c | bellard | } |
182 | 6af0bf9c | bellard | |
183 | aa343735 | ths | static always_inline void set_HILO (uint64_t HILO) |
184 | 6af0bf9c | bellard | { |
185 | d0dc7dc3 | ths | env->LO[env->current_tc][0] = (int32_t)HILO;
|
186 | d0dc7dc3 | ths | env->HI[env->current_tc][0] = (int32_t)(HILO >> 32); |
187 | 6af0bf9c | bellard | } |
188 | 6af0bf9c | bellard | |
189 | e9c71dd1 | ths | static always_inline void set_HIT0_LO (uint64_t HILO) |
190 | e9c71dd1 | ths | { |
191 | d0dc7dc3 | ths | env->LO[env->current_tc][0] = (int32_t)(HILO & 0xFFFFFFFF); |
192 | d0dc7dc3 | ths | T0 = env->HI[env->current_tc][0] = (int32_t)(HILO >> 32); |
193 | e9c71dd1 | ths | } |
194 | e9c71dd1 | ths | |
195 | e9c71dd1 | ths | static always_inline void set_HI_LOT0 (uint64_t HILO) |
196 | e9c71dd1 | ths | { |
197 | d0dc7dc3 | ths | T0 = env->LO[env->current_tc][0] = (int32_t)(HILO & 0xFFFFFFFF); |
198 | d0dc7dc3 | ths | env->HI[env->current_tc][0] = (int32_t)(HILO >> 32); |
199 | e9c71dd1 | ths | } |
200 | e9c71dd1 | ths | |
201 | 6af0bf9c | bellard | void do_mult (void) |
202 | 6af0bf9c | bellard | { |
203 | 4ad40f36 | bellard | set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
204 | 6af0bf9c | bellard | } |
205 | 6af0bf9c | bellard | |
206 | 6af0bf9c | bellard | void do_multu (void) |
207 | 6af0bf9c | bellard | { |
208 | c570fd16 | ths | set_HILO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
209 | 6af0bf9c | bellard | } |
210 | 6af0bf9c | bellard | |
211 | 6af0bf9c | bellard | void do_madd (void) |
212 | 6af0bf9c | bellard | { |
213 | 6af0bf9c | bellard | int64_t tmp; |
214 | 6af0bf9c | bellard | |
215 | 4ad40f36 | bellard | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
216 | 6af0bf9c | bellard | set_HILO((int64_t)get_HILO() + tmp); |
217 | 6af0bf9c | bellard | } |
218 | 6af0bf9c | bellard | |
219 | 6af0bf9c | bellard | void do_maddu (void) |
220 | 6af0bf9c | bellard | { |
221 | 6af0bf9c | bellard | uint64_t tmp; |
222 | 6af0bf9c | bellard | |
223 | c570fd16 | ths | tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
224 | 6af0bf9c | bellard | set_HILO(get_HILO() + tmp); |
225 | 6af0bf9c | bellard | } |
226 | 6af0bf9c | bellard | |
227 | 6af0bf9c | bellard | void do_msub (void) |
228 | 6af0bf9c | bellard | { |
229 | 6af0bf9c | bellard | int64_t tmp; |
230 | 6af0bf9c | bellard | |
231 | 4ad40f36 | bellard | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
232 | 6af0bf9c | bellard | set_HILO((int64_t)get_HILO() - tmp); |
233 | 6af0bf9c | bellard | } |
234 | 6af0bf9c | bellard | |
235 | 6af0bf9c | bellard | void do_msubu (void) |
236 | 6af0bf9c | bellard | { |
237 | 6af0bf9c | bellard | uint64_t tmp; |
238 | 6af0bf9c | bellard | |
239 | c570fd16 | ths | tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
240 | 6af0bf9c | bellard | set_HILO(get_HILO() - tmp); |
241 | 6af0bf9c | bellard | } |
242 | e9c71dd1 | ths | |
243 | e9c71dd1 | ths | /* Multiplication variants of the vr54xx. */
|
244 | e9c71dd1 | ths | void do_muls (void) |
245 | e9c71dd1 | ths | { |
246 | e9c71dd1 | ths | set_HI_LOT0(0 - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
247 | e9c71dd1 | ths | } |
248 | e9c71dd1 | ths | |
249 | e9c71dd1 | ths | void do_mulsu (void) |
250 | e9c71dd1 | ths | { |
251 | e9c71dd1 | ths | set_HI_LOT0(0 - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
252 | e9c71dd1 | ths | } |
253 | e9c71dd1 | ths | |
254 | e9c71dd1 | ths | void do_macc (void) |
255 | e9c71dd1 | ths | { |
256 | e9c71dd1 | ths | set_HI_LOT0(((int64_t)get_HILO()) + ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1)); |
257 | e9c71dd1 | ths | } |
258 | e9c71dd1 | ths | |
259 | e9c71dd1 | ths | void do_macchi (void) |
260 | e9c71dd1 | ths | { |
261 | e9c71dd1 | ths | set_HIT0_LO(((int64_t)get_HILO()) + ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1)); |
262 | e9c71dd1 | ths | } |
263 | e9c71dd1 | ths | |
264 | e9c71dd1 | ths | void do_maccu (void) |
265 | e9c71dd1 | ths | { |
266 | e9c71dd1 | ths | set_HI_LOT0(((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1)); |
267 | e9c71dd1 | ths | } |
268 | e9c71dd1 | ths | |
269 | e9c71dd1 | ths | void do_macchiu (void) |
270 | e9c71dd1 | ths | { |
271 | e9c71dd1 | ths | set_HIT0_LO(((uint64_t)get_HILO()) + ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1)); |
272 | e9c71dd1 | ths | } |
273 | e9c71dd1 | ths | |
274 | e9c71dd1 | ths | void do_msac (void) |
275 | e9c71dd1 | ths | { |
276 | e9c71dd1 | ths | set_HI_LOT0(((int64_t)get_HILO()) - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1)); |
277 | e9c71dd1 | ths | } |
278 | e9c71dd1 | ths | |
279 | e9c71dd1 | ths | void do_msachi (void) |
280 | e9c71dd1 | ths | { |
281 | e9c71dd1 | ths | set_HIT0_LO(((int64_t)get_HILO()) - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1)); |
282 | e9c71dd1 | ths | } |
283 | e9c71dd1 | ths | |
284 | e9c71dd1 | ths | void do_msacu (void) |
285 | e9c71dd1 | ths | { |
286 | e9c71dd1 | ths | set_HI_LOT0(((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1)); |
287 | e9c71dd1 | ths | } |
288 | e9c71dd1 | ths | |
289 | e9c71dd1 | ths | void do_msachiu (void) |
290 | e9c71dd1 | ths | { |
291 | e9c71dd1 | ths | set_HIT0_LO(((uint64_t)get_HILO()) - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1)); |
292 | e9c71dd1 | ths | } |
293 | e9c71dd1 | ths | |
294 | e9c71dd1 | ths | void do_mulhi (void) |
295 | e9c71dd1 | ths | { |
296 | e9c71dd1 | ths | set_HIT0_LO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
297 | e9c71dd1 | ths | } |
298 | e9c71dd1 | ths | |
299 | e9c71dd1 | ths | void do_mulhiu (void) |
300 | e9c71dd1 | ths | { |
301 | e9c71dd1 | ths | set_HIT0_LO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1); |
302 | e9c71dd1 | ths | } |
303 | e9c71dd1 | ths | |
304 | e9c71dd1 | ths | void do_mulshi (void) |
305 | e9c71dd1 | ths | { |
306 | e9c71dd1 | ths | set_HIT0_LO(0 - ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1));
|
307 | e9c71dd1 | ths | } |
308 | e9c71dd1 | ths | |
309 | e9c71dd1 | ths | void do_mulshiu (void) |
310 | e9c71dd1 | ths | { |
311 | e9c71dd1 | ths | set_HIT0_LO(0 - ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1));
|
312 | e9c71dd1 | ths | } |
313 | e9c71dd1 | ths | #endif /* TARGET_LONG_BITS > HOST_LONG_BITS */ |
314 | 6af0bf9c | bellard | |
315 | 5fafdf24 | ths | #if defined(CONFIG_USER_ONLY)
|
316 | 873eb012 | ths | void do_mfc0_random (void) |
317 | 048f6b4d | bellard | { |
318 | 873eb012 | ths | cpu_abort(env, "mfc0 random\n");
|
319 | 048f6b4d | bellard | } |
320 | 873eb012 | ths | |
321 | 873eb012 | ths | void do_mfc0_count (void) |
322 | 873eb012 | ths | { |
323 | 873eb012 | ths | cpu_abort(env, "mfc0 count\n");
|
324 | 873eb012 | ths | } |
325 | 873eb012 | ths | |
326 | 8c0fdd85 | ths | void cpu_mips_store_count(CPUState *env, uint32_t value)
|
327 | 048f6b4d | bellard | { |
328 | 8c0fdd85 | ths | cpu_abort(env, "mtc0 count\n");
|
329 | 8c0fdd85 | ths | } |
330 | 8c0fdd85 | ths | |
331 | 8c0fdd85 | ths | void cpu_mips_store_compare(CPUState *env, uint32_t value)
|
332 | 8c0fdd85 | ths | { |
333 | 8c0fdd85 | ths | cpu_abort(env, "mtc0 compare\n");
|
334 | 8c0fdd85 | ths | } |
335 | 8c0fdd85 | ths | |
336 | 42532189 | ths | void cpu_mips_start_count(CPUState *env)
|
337 | 42532189 | ths | { |
338 | 42532189 | ths | cpu_abort(env, "start count\n");
|
339 | 42532189 | ths | } |
340 | 42532189 | ths | |
341 | 42532189 | ths | void cpu_mips_stop_count(CPUState *env)
|
342 | 42532189 | ths | { |
343 | 42532189 | ths | cpu_abort(env, "stop count\n");
|
344 | 42532189 | ths | } |
345 | 42532189 | ths | |
346 | 4de9b249 | ths | void cpu_mips_update_irq(CPUState *env)
|
347 | 4de9b249 | ths | { |
348 | 4de9b249 | ths | cpu_abort(env, "mtc0 status / mtc0 cause\n");
|
349 | 4de9b249 | ths | } |
350 | 4de9b249 | ths | |
351 | 8c0fdd85 | ths | void do_mtc0_status_debug(uint32_t old, uint32_t val)
|
352 | 8c0fdd85 | ths | { |
353 | 7a387fff | ths | cpu_abort(env, "mtc0 status debug\n");
|
354 | 8c0fdd85 | ths | } |
355 | 8c0fdd85 | ths | |
356 | 7a387fff | ths | void do_mtc0_status_irqraise_debug (void) |
357 | 8c0fdd85 | ths | { |
358 | 7a387fff | ths | cpu_abort(env, "mtc0 status irqraise debug\n");
|
359 | 048f6b4d | bellard | } |
360 | 048f6b4d | bellard | |
361 | 8c0fdd85 | ths | void cpu_mips_tlb_flush (CPUState *env, int flush_global) |
362 | 8c0fdd85 | ths | { |
363 | 8c0fdd85 | ths | cpu_abort(env, "mips_tlb_flush\n");
|
364 | 8c0fdd85 | ths | } |
365 | 8c0fdd85 | ths | |
366 | 048f6b4d | bellard | #else
|
367 | 048f6b4d | bellard | |
368 | 6af0bf9c | bellard | /* CP0 helpers */
|
369 | 873eb012 | ths | void do_mfc0_random (void) |
370 | 6af0bf9c | bellard | { |
371 | 5dc4b744 | ths | T0 = (int32_t)cpu_mips_get_random(env); |
372 | 873eb012 | ths | } |
373 | 6af0bf9c | bellard | |
374 | 873eb012 | ths | void do_mfc0_count (void) |
375 | 873eb012 | ths | { |
376 | 5dc4b744 | ths | T0 = (int32_t)cpu_mips_get_count(env); |
377 | 6af0bf9c | bellard | } |
378 | 6af0bf9c | bellard | |
379 | 8c0fdd85 | ths | void do_mtc0_status_debug(uint32_t old, uint32_t val)
|
380 | 6af0bf9c | bellard | { |
381 | f41c52f1 | ths | fprintf(logfile, "Status %08x (%08x) => %08x (%08x) Cause %08x",
|
382 | f41c52f1 | ths | old, old & env->CP0_Cause & CP0Ca_IP_mask, |
383 | f41c52f1 | ths | val, val & env->CP0_Cause & CP0Ca_IP_mask, |
384 | f41c52f1 | ths | env->CP0_Cause); |
385 | 623a930e | ths | switch (env->hflags & MIPS_HFLAG_KSU) {
|
386 | 623a930e | ths | case MIPS_HFLAG_UM: fputs(", UM\n", logfile); break; |
387 | 623a930e | ths | case MIPS_HFLAG_SM: fputs(", SM\n", logfile); break; |
388 | 623a930e | ths | case MIPS_HFLAG_KM: fputs("\n", logfile); break; |
389 | 623a930e | ths | default: cpu_abort(env, "Invalid MMU mode!\n"); break; |
390 | 623a930e | ths | } |
391 | 8c0fdd85 | ths | } |
392 | 8c0fdd85 | ths | |
393 | 8c0fdd85 | ths | void do_mtc0_status_irqraise_debug(void) |
394 | 8c0fdd85 | ths | { |
395 | 8c0fdd85 | ths | fprintf(logfile, "Raise pending IRQs\n");
|
396 | 6af0bf9c | bellard | } |
397 | 6af0bf9c | bellard | |
398 | 6ea83fed | bellard | void fpu_handle_exception(void) |
399 | 6ea83fed | bellard | { |
400 | 6ea83fed | bellard | #ifdef CONFIG_SOFTFLOAT
|
401 | ead9360e | ths | int flags = get_float_exception_flags(&env->fpu->fp_status);
|
402 | 6ea83fed | bellard | unsigned int cpuflags = 0, enable, cause = 0; |
403 | 6ea83fed | bellard | |
404 | ead9360e | ths | enable = GET_FP_ENABLE(env->fpu->fcr31); |
405 | 6ea83fed | bellard | |
406 | 3b46e624 | ths | /* determine current flags */
|
407 | 6ea83fed | bellard | if (flags & float_flag_invalid) {
|
408 | 6ea83fed | bellard | cpuflags |= FP_INVALID; |
409 | 6ea83fed | bellard | cause |= FP_INVALID & enable; |
410 | 6ea83fed | bellard | } |
411 | 6ea83fed | bellard | if (flags & float_flag_divbyzero) {
|
412 | 3b46e624 | ths | cpuflags |= FP_DIV0; |
413 | 6ea83fed | bellard | cause |= FP_DIV0 & enable; |
414 | 6ea83fed | bellard | } |
415 | 6ea83fed | bellard | if (flags & float_flag_overflow) {
|
416 | 3b46e624 | ths | cpuflags |= FP_OVERFLOW; |
417 | 6ea83fed | bellard | cause |= FP_OVERFLOW & enable; |
418 | 6ea83fed | bellard | } |
419 | 6ea83fed | bellard | if (flags & float_flag_underflow) {
|
420 | 3b46e624 | ths | cpuflags |= FP_UNDERFLOW; |
421 | 6ea83fed | bellard | cause |= FP_UNDERFLOW & enable; |
422 | 6ea83fed | bellard | } |
423 | 6ea83fed | bellard | if (flags & float_flag_inexact) {
|
424 | 5fafdf24 | ths | cpuflags |= FP_INEXACT; |
425 | 6ea83fed | bellard | cause |= FP_INEXACT & enable; |
426 | 6ea83fed | bellard | } |
427 | ead9360e | ths | SET_FP_FLAGS(env->fpu->fcr31, cpuflags); |
428 | ead9360e | ths | SET_FP_CAUSE(env->fpu->fcr31, cause); |
429 | 6ea83fed | bellard | #else
|
430 | ead9360e | ths | SET_FP_FLAGS(env->fpu->fcr31, 0);
|
431 | ead9360e | ths | SET_FP_CAUSE(env->fpu->fcr31, 0);
|
432 | 6ea83fed | bellard | #endif
|
433 | 6ea83fed | bellard | } |
434 | 6ea83fed | bellard | |
435 | 6af0bf9c | bellard | /* TLB management */
|
436 | 814b9a47 | ths | void cpu_mips_tlb_flush (CPUState *env, int flush_global) |
437 | 814b9a47 | ths | { |
438 | 814b9a47 | ths | /* Flush qemu's TLB and discard all shadowed entries. */
|
439 | 814b9a47 | ths | tlb_flush (env, flush_global); |
440 | ead9360e | ths | env->tlb->tlb_in_use = env->tlb->nb_tlb; |
441 | 814b9a47 | ths | } |
442 | 814b9a47 | ths | |
443 | 29929e34 | ths | static void r4k_mips_tlb_flush_extra (CPUState *env, int first) |
444 | 814b9a47 | ths | { |
445 | 814b9a47 | ths | /* Discard entries from env->tlb[first] onwards. */
|
446 | ead9360e | ths | while (env->tlb->tlb_in_use > first) {
|
447 | ead9360e | ths | r4k_invalidate_tlb(env, --env->tlb->tlb_in_use, 0);
|
448 | 814b9a47 | ths | } |
449 | 814b9a47 | ths | } |
450 | 814b9a47 | ths | |
451 | 29929e34 | ths | static void r4k_fill_tlb (int idx) |
452 | 6af0bf9c | bellard | { |
453 | 29929e34 | ths | r4k_tlb_t *tlb; |
454 | 6af0bf9c | bellard | |
455 | 6af0bf9c | bellard | /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
|
456 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[idx]; |
457 | f2e9ebef | ths | tlb->VPN = env->CP0_EntryHi & (TARGET_PAGE_MASK << 1);
|
458 | d26bc211 | ths | #if defined(TARGET_MIPS64)
|
459 | e034e2c3 | ths | tlb->VPN &= env->SEGMask; |
460 | 100ce988 | ths | #endif
|
461 | 98c1b82b | pbrook | tlb->ASID = env->CP0_EntryHi & 0xFF;
|
462 | 3b1c8be4 | ths | tlb->PageMask = env->CP0_PageMask; |
463 | 6af0bf9c | bellard | tlb->G = env->CP0_EntryLo0 & env->CP0_EntryLo1 & 1;
|
464 | 98c1b82b | pbrook | tlb->V0 = (env->CP0_EntryLo0 & 2) != 0; |
465 | 98c1b82b | pbrook | tlb->D0 = (env->CP0_EntryLo0 & 4) != 0; |
466 | 98c1b82b | pbrook | tlb->C0 = (env->CP0_EntryLo0 >> 3) & 0x7; |
467 | 6af0bf9c | bellard | tlb->PFN[0] = (env->CP0_EntryLo0 >> 6) << 12; |
468 | 98c1b82b | pbrook | tlb->V1 = (env->CP0_EntryLo1 & 2) != 0; |
469 | 98c1b82b | pbrook | tlb->D1 = (env->CP0_EntryLo1 & 4) != 0; |
470 | 98c1b82b | pbrook | tlb->C1 = (env->CP0_EntryLo1 >> 3) & 0x7; |
471 | 6af0bf9c | bellard | tlb->PFN[1] = (env->CP0_EntryLo1 >> 6) << 12; |
472 | 6af0bf9c | bellard | } |
473 | 6af0bf9c | bellard | |
474 | 29929e34 | ths | void r4k_do_tlbwi (void) |
475 | 6af0bf9c | bellard | { |
476 | 814b9a47 | ths | /* Discard cached TLB entries. We could avoid doing this if the
|
477 | 814b9a47 | ths | tlbwi is just upgrading access permissions on the current entry;
|
478 | 814b9a47 | ths | that might be a further win. */
|
479 | ead9360e | ths | r4k_mips_tlb_flush_extra (env, env->tlb->nb_tlb); |
480 | 814b9a47 | ths | |
481 | ead9360e | ths | r4k_invalidate_tlb(env, env->CP0_Index % env->tlb->nb_tlb, 0);
|
482 | ead9360e | ths | r4k_fill_tlb(env->CP0_Index % env->tlb->nb_tlb); |
483 | 6af0bf9c | bellard | } |
484 | 6af0bf9c | bellard | |
485 | 29929e34 | ths | void r4k_do_tlbwr (void) |
486 | 6af0bf9c | bellard | { |
487 | 6af0bf9c | bellard | int r = cpu_mips_get_random(env);
|
488 | 6af0bf9c | bellard | |
489 | 29929e34 | ths | r4k_invalidate_tlb(env, r, 1);
|
490 | 29929e34 | ths | r4k_fill_tlb(r); |
491 | 6af0bf9c | bellard | } |
492 | 6af0bf9c | bellard | |
493 | 29929e34 | ths | void r4k_do_tlbp (void) |
494 | 6af0bf9c | bellard | { |
495 | 29929e34 | ths | r4k_tlb_t *tlb; |
496 | f2e9ebef | ths | target_ulong mask; |
497 | 6af0bf9c | bellard | target_ulong tag; |
498 | f2e9ebef | ths | target_ulong VPN; |
499 | 6af0bf9c | bellard | uint8_t ASID; |
500 | 6af0bf9c | bellard | int i;
|
501 | 6af0bf9c | bellard | |
502 | 3d9fb9fe | bellard | ASID = env->CP0_EntryHi & 0xFF;
|
503 | ead9360e | ths | for (i = 0; i < env->tlb->nb_tlb; i++) { |
504 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[i]; |
505 | f2e9ebef | ths | /* 1k pages are not supported. */
|
506 | f2e9ebef | ths | mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
|
507 | f2e9ebef | ths | tag = env->CP0_EntryHi & ~mask; |
508 | f2e9ebef | ths | VPN = tlb->VPN & ~mask; |
509 | 6af0bf9c | bellard | /* Check ASID, virtual page number & size */
|
510 | f2e9ebef | ths | if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { |
511 | 6af0bf9c | bellard | /* TLB match */
|
512 | 9c2149c8 | ths | env->CP0_Index = i; |
513 | 6af0bf9c | bellard | break;
|
514 | 6af0bf9c | bellard | } |
515 | 6af0bf9c | bellard | } |
516 | ead9360e | ths | if (i == env->tlb->nb_tlb) {
|
517 | 814b9a47 | ths | /* No match. Discard any shadow entries, if any of them match. */
|
518 | ead9360e | ths | for (i = env->tlb->nb_tlb; i < env->tlb->tlb_in_use; i++) {
|
519 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[i]; |
520 | f2e9ebef | ths | /* 1k pages are not supported. */
|
521 | f2e9ebef | ths | mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
|
522 | f2e9ebef | ths | tag = env->CP0_EntryHi & ~mask; |
523 | f2e9ebef | ths | VPN = tlb->VPN & ~mask; |
524 | 814b9a47 | ths | /* Check ASID, virtual page number & size */
|
525 | f2e9ebef | ths | if ((tlb->G == 1 || tlb->ASID == ASID) && VPN == tag) { |
526 | 29929e34 | ths | r4k_mips_tlb_flush_extra (env, i); |
527 | 814b9a47 | ths | break;
|
528 | 814b9a47 | ths | } |
529 | 814b9a47 | ths | } |
530 | 814b9a47 | ths | |
531 | 9c2149c8 | ths | env->CP0_Index |= 0x80000000;
|
532 | 6af0bf9c | bellard | } |
533 | 6af0bf9c | bellard | } |
534 | 6af0bf9c | bellard | |
535 | 29929e34 | ths | void r4k_do_tlbr (void) |
536 | 6af0bf9c | bellard | { |
537 | 29929e34 | ths | r4k_tlb_t *tlb; |
538 | 09c56b84 | pbrook | uint8_t ASID; |
539 | 6af0bf9c | bellard | |
540 | 09c56b84 | pbrook | ASID = env->CP0_EntryHi & 0xFF;
|
541 | ead9360e | ths | tlb = &env->tlb->mmu.r4k.tlb[env->CP0_Index % env->tlb->nb_tlb]; |
542 | 4ad40f36 | bellard | |
543 | 4ad40f36 | bellard | /* If this will change the current ASID, flush qemu's TLB. */
|
544 | 814b9a47 | ths | if (ASID != tlb->ASID)
|
545 | 814b9a47 | ths | cpu_mips_tlb_flush (env, 1);
|
546 | 814b9a47 | ths | |
547 | ead9360e | ths | r4k_mips_tlb_flush_extra(env, env->tlb->nb_tlb); |
548 | 4ad40f36 | bellard | |
549 | 6af0bf9c | bellard | env->CP0_EntryHi = tlb->VPN | tlb->ASID; |
550 | 3b1c8be4 | ths | env->CP0_PageMask = tlb->PageMask; |
551 | 7495fd0f | ths | env->CP0_EntryLo0 = tlb->G | (tlb->V0 << 1) | (tlb->D0 << 2) | |
552 | 7495fd0f | ths | (tlb->C0 << 3) | (tlb->PFN[0] >> 6); |
553 | 7495fd0f | ths | env->CP0_EntryLo1 = tlb->G | (tlb->V1 << 1) | (tlb->D1 << 2) | |
554 | 7495fd0f | ths | (tlb->C1 << 3) | (tlb->PFN[1] >> 6); |
555 | 6af0bf9c | bellard | } |
556 | 6af0bf9c | bellard | |
557 | 048f6b4d | bellard | #endif /* !CONFIG_USER_ONLY */ |
558 | 048f6b4d | bellard | |
559 | c570fd16 | ths | void dump_ldst (const unsigned char *func) |
560 | 6af0bf9c | bellard | { |
561 | 6af0bf9c | bellard | if (loglevel)
|
562 | 3594c774 | ths | fprintf(logfile, "%s => " TARGET_FMT_lx " " TARGET_FMT_lx "\n", __func__, T0, T1); |
563 | 6af0bf9c | bellard | } |
564 | 6af0bf9c | bellard | |
565 | 6af0bf9c | bellard | void dump_sc (void) |
566 | 6af0bf9c | bellard | { |
567 | 6af0bf9c | bellard | if (loglevel) {
|
568 | 3594c774 | ths | fprintf(logfile, "%s " TARGET_FMT_lx " at " TARGET_FMT_lx " (" TARGET_FMT_lx ")\n", __func__, |
569 | 6af0bf9c | bellard | T1, T0, env->CP0_LLAddr); |
570 | 6af0bf9c | bellard | } |
571 | 6af0bf9c | bellard | } |
572 | 6af0bf9c | bellard | |
573 | f41c52f1 | ths | void debug_pre_eret (void) |
574 | 6af0bf9c | bellard | { |
575 | f41c52f1 | ths | fprintf(logfile, "ERET: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx, |
576 | ead9360e | ths | env->PC[env->current_tc], env->CP0_EPC); |
577 | f41c52f1 | ths | if (env->CP0_Status & (1 << CP0St_ERL)) |
578 | f41c52f1 | ths | fprintf(logfile, " ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
|
579 | f41c52f1 | ths | if (env->hflags & MIPS_HFLAG_DM)
|
580 | f41c52f1 | ths | fprintf(logfile, " DEPC " TARGET_FMT_lx, env->CP0_DEPC);
|
581 | f41c52f1 | ths | fputs("\n", logfile);
|
582 | f41c52f1 | ths | } |
583 | f41c52f1 | ths | |
584 | f41c52f1 | ths | void debug_post_eret (void) |
585 | f41c52f1 | ths | { |
586 | 744e0915 | ths | fprintf(logfile, " => PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx, |
587 | ead9360e | ths | env->PC[env->current_tc], env->CP0_EPC); |
588 | f41c52f1 | ths | if (env->CP0_Status & (1 << CP0St_ERL)) |
589 | f41c52f1 | ths | fprintf(logfile, " ErrorEPC " TARGET_FMT_lx, env->CP0_ErrorEPC);
|
590 | f41c52f1 | ths | if (env->hflags & MIPS_HFLAG_DM)
|
591 | f41c52f1 | ths | fprintf(logfile, " DEPC " TARGET_FMT_lx, env->CP0_DEPC);
|
592 | 623a930e | ths | switch (env->hflags & MIPS_HFLAG_KSU) {
|
593 | 623a930e | ths | case MIPS_HFLAG_UM: fputs(", UM\n", logfile); break; |
594 | 623a930e | ths | case MIPS_HFLAG_SM: fputs(", SM\n", logfile); break; |
595 | 623a930e | ths | case MIPS_HFLAG_KM: fputs("\n", logfile); break; |
596 | 623a930e | ths | default: cpu_abort(env, "Invalid MMU mode!\n"); break; |
597 | 623a930e | ths | } |
598 | 6af0bf9c | bellard | } |
599 | 6af0bf9c | bellard | |
600 | 6af0bf9c | bellard | void do_pmon (int function) |
601 | 6af0bf9c | bellard | { |
602 | 6af0bf9c | bellard | function /= 2;
|
603 | 6af0bf9c | bellard | switch (function) {
|
604 | 6af0bf9c | bellard | case 2: /* TODO: char inbyte(int waitflag); */ |
605 | d0dc7dc3 | ths | if (env->gpr[env->current_tc][4] == 0) |
606 | d0dc7dc3 | ths | env->gpr[env->current_tc][2] = -1; |
607 | 6af0bf9c | bellard | /* Fall through */
|
608 | 6af0bf9c | bellard | case 11: /* TODO: char inbyte (void); */ |
609 | d0dc7dc3 | ths | env->gpr[env->current_tc][2] = -1; |
610 | 6af0bf9c | bellard | break;
|
611 | 6af0bf9c | bellard | case 3: |
612 | 6af0bf9c | bellard | case 12: |
613 | d0dc7dc3 | ths | printf("%c", (char)(env->gpr[env->current_tc][4] & 0xFF)); |
614 | 6af0bf9c | bellard | break;
|
615 | 6af0bf9c | bellard | case 17: |
616 | 6af0bf9c | bellard | break;
|
617 | 6af0bf9c | bellard | case 158: |
618 | 6af0bf9c | bellard | { |
619 | d0dc7dc3 | ths | unsigned char *fmt = (void *)(unsigned long)env->gpr[env->current_tc][4]; |
620 | 6af0bf9c | bellard | printf("%s", fmt);
|
621 | 6af0bf9c | bellard | } |
622 | 6af0bf9c | bellard | break;
|
623 | 6af0bf9c | bellard | } |
624 | 6af0bf9c | bellard | } |
625 | e37e863f | bellard | |
626 | 5fafdf24 | ths | #if !defined(CONFIG_USER_ONLY)
|
627 | e37e863f | bellard | |
628 | 4ad40f36 | bellard | static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr); |
629 | 4ad40f36 | bellard | |
630 | e37e863f | bellard | #define MMUSUFFIX _mmu
|
631 | 4ad40f36 | bellard | #define ALIGNED_ONLY
|
632 | e37e863f | bellard | |
633 | e37e863f | bellard | #define SHIFT 0 |
634 | e37e863f | bellard | #include "softmmu_template.h" |
635 | e37e863f | bellard | |
636 | e37e863f | bellard | #define SHIFT 1 |
637 | e37e863f | bellard | #include "softmmu_template.h" |
638 | e37e863f | bellard | |
639 | e37e863f | bellard | #define SHIFT 2 |
640 | e37e863f | bellard | #include "softmmu_template.h" |
641 | e37e863f | bellard | |
642 | e37e863f | bellard | #define SHIFT 3 |
643 | e37e863f | bellard | #include "softmmu_template.h" |
644 | e37e863f | bellard | |
645 | 4ad40f36 | bellard | static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr) |
646 | 4ad40f36 | bellard | { |
647 | 4ad40f36 | bellard | env->CP0_BadVAddr = addr; |
648 | 4ad40f36 | bellard | do_restore_state (retaddr); |
649 | 4ad40f36 | bellard | do_raise_exception ((is_write == 1) ? EXCP_AdES : EXCP_AdEL);
|
650 | 4ad40f36 | bellard | } |
651 | 4ad40f36 | bellard | |
652 | 6ebbf390 | j_mayer | void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr) |
653 | e37e863f | bellard | { |
654 | e37e863f | bellard | TranslationBlock *tb; |
655 | e37e863f | bellard | CPUState *saved_env; |
656 | e37e863f | bellard | unsigned long pc; |
657 | e37e863f | bellard | int ret;
|
658 | e37e863f | bellard | |
659 | e37e863f | bellard | /* XXX: hack to restore env in all cases, even if not called from
|
660 | e37e863f | bellard | generated code */
|
661 | e37e863f | bellard | saved_env = env; |
662 | e37e863f | bellard | env = cpu_single_env; |
663 | 6ebbf390 | j_mayer | ret = cpu_mips_handle_mmu_fault(env, addr, is_write, mmu_idx, 1);
|
664 | e37e863f | bellard | if (ret) {
|
665 | e37e863f | bellard | if (retaddr) {
|
666 | e37e863f | bellard | /* now we have a real cpu fault */
|
667 | e37e863f | bellard | pc = (unsigned long)retaddr; |
668 | e37e863f | bellard | tb = tb_find_pc(pc); |
669 | e37e863f | bellard | if (tb) {
|
670 | e37e863f | bellard | /* the PC is inside the translated code. It means that we have
|
671 | e37e863f | bellard | a virtual CPU fault */
|
672 | e37e863f | bellard | cpu_restore_state(tb, env, pc, NULL);
|
673 | e37e863f | bellard | } |
674 | e37e863f | bellard | } |
675 | e37e863f | bellard | do_raise_exception_err(env->exception_index, env->error_code); |
676 | e37e863f | bellard | } |
677 | e37e863f | bellard | env = saved_env; |
678 | e37e863f | bellard | } |
679 | e37e863f | bellard | |
680 | 647de6ca | ths | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
681 | 647de6ca | ths | int unused)
|
682 | 647de6ca | ths | { |
683 | 647de6ca | ths | if (is_exec)
|
684 | 647de6ca | ths | do_raise_exception(EXCP_IBE); |
685 | 647de6ca | ths | else
|
686 | 647de6ca | ths | do_raise_exception(EXCP_DBE); |
687 | 647de6ca | ths | } |
688 | e37e863f | bellard | #endif
|
689 | fd4a04eb | ths | |
690 | fd4a04eb | ths | /* Complex FPU operations which may need stack space. */
|
691 | fd4a04eb | ths | |
692 | f090c9d4 | pbrook | #define FLOAT_ONE32 make_float32(0x3f8 << 20) |
693 | f090c9d4 | pbrook | #define FLOAT_ONE64 make_float64(0x3ffULL << 52) |
694 | f090c9d4 | pbrook | #define FLOAT_TWO32 make_float32(1 << 30) |
695 | f090c9d4 | pbrook | #define FLOAT_TWO64 make_float64(1ULL << 62) |
696 | 54454097 | ths | #define FLOAT_QNAN32 0x7fbfffff |
697 | 54454097 | ths | #define FLOAT_QNAN64 0x7ff7ffffffffffffULL |
698 | 54454097 | ths | #define FLOAT_SNAN32 0x7fffffff |
699 | 54454097 | ths | #define FLOAT_SNAN64 0x7fffffffffffffffULL |
700 | 8dfdb87c | ths | |
701 | fd4a04eb | ths | /* convert MIPS rounding mode in FCR31 to IEEE library */
|
702 | fd4a04eb | ths | unsigned int ieee_rm[] = { |
703 | fd4a04eb | ths | float_round_nearest_even, |
704 | fd4a04eb | ths | float_round_to_zero, |
705 | fd4a04eb | ths | float_round_up, |
706 | fd4a04eb | ths | float_round_down |
707 | fd4a04eb | ths | }; |
708 | fd4a04eb | ths | |
709 | fd4a04eb | ths | #define RESTORE_ROUNDING_MODE \
|
710 | ead9360e | ths | set_float_rounding_mode(ieee_rm[env->fpu->fcr31 & 3], &env->fpu->fp_status)
|
711 | fd4a04eb | ths | |
712 | ead9360e | ths | void do_cfc1 (int reg) |
713 | fd4a04eb | ths | { |
714 | ead9360e | ths | switch (reg) {
|
715 | ead9360e | ths | case 0: |
716 | ead9360e | ths | T0 = (int32_t)env->fpu->fcr0; |
717 | ead9360e | ths | break;
|
718 | ead9360e | ths | case 25: |
719 | ead9360e | ths | T0 = ((env->fpu->fcr31 >> 24) & 0xfe) | ((env->fpu->fcr31 >> 23) & 0x1); |
720 | ead9360e | ths | break;
|
721 | ead9360e | ths | case 26: |
722 | ead9360e | ths | T0 = env->fpu->fcr31 & 0x0003f07c;
|
723 | ead9360e | ths | break;
|
724 | ead9360e | ths | case 28: |
725 | ead9360e | ths | T0 = (env->fpu->fcr31 & 0x00000f83) | ((env->fpu->fcr31 >> 22) & 0x4); |
726 | ead9360e | ths | break;
|
727 | ead9360e | ths | default:
|
728 | ead9360e | ths | T0 = (int32_t)env->fpu->fcr31; |
729 | ead9360e | ths | break;
|
730 | ead9360e | ths | } |
731 | ead9360e | ths | } |
732 | ead9360e | ths | |
733 | ead9360e | ths | void do_ctc1 (int reg) |
734 | ead9360e | ths | { |
735 | ead9360e | ths | switch(reg) {
|
736 | fd4a04eb | ths | case 25: |
737 | fd4a04eb | ths | if (T0 & 0xffffff00) |
738 | fd4a04eb | ths | return;
|
739 | ead9360e | ths | env->fpu->fcr31 = (env->fpu->fcr31 & 0x017fffff) | ((T0 & 0xfe) << 24) | |
740 | fd4a04eb | ths | ((T0 & 0x1) << 23); |
741 | fd4a04eb | ths | break;
|
742 | fd4a04eb | ths | case 26: |
743 | fd4a04eb | ths | if (T0 & 0x007c0000) |
744 | fd4a04eb | ths | return;
|
745 | ead9360e | ths | env->fpu->fcr31 = (env->fpu->fcr31 & 0xfffc0f83) | (T0 & 0x0003f07c); |
746 | fd4a04eb | ths | break;
|
747 | fd4a04eb | ths | case 28: |
748 | fd4a04eb | ths | if (T0 & 0x007c0000) |
749 | fd4a04eb | ths | return;
|
750 | ead9360e | ths | env->fpu->fcr31 = (env->fpu->fcr31 & 0xfefff07c) | (T0 & 0x00000f83) | |
751 | fd4a04eb | ths | ((T0 & 0x4) << 22); |
752 | fd4a04eb | ths | break;
|
753 | fd4a04eb | ths | case 31: |
754 | fd4a04eb | ths | if (T0 & 0x007c0000) |
755 | fd4a04eb | ths | return;
|
756 | ead9360e | ths | env->fpu->fcr31 = T0; |
757 | fd4a04eb | ths | break;
|
758 | fd4a04eb | ths | default:
|
759 | fd4a04eb | ths | return;
|
760 | fd4a04eb | ths | } |
761 | fd4a04eb | ths | /* set rounding mode */
|
762 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
763 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
764 | ead9360e | ths | if ((GET_FP_ENABLE(env->fpu->fcr31) | 0x20) & GET_FP_CAUSE(env->fpu->fcr31)) |
765 | fd4a04eb | ths | do_raise_exception(EXCP_FPE); |
766 | fd4a04eb | ths | } |
767 | fd4a04eb | ths | |
768 | aa343735 | ths | static always_inline char ieee_ex_to_mips(char xcpt) |
769 | fd4a04eb | ths | { |
770 | fd4a04eb | ths | return (xcpt & float_flag_inexact) >> 5 | |
771 | fd4a04eb | ths | (xcpt & float_flag_underflow) >> 3 |
|
772 | fd4a04eb | ths | (xcpt & float_flag_overflow) >> 1 |
|
773 | fd4a04eb | ths | (xcpt & float_flag_divbyzero) << 1 |
|
774 | fd4a04eb | ths | (xcpt & float_flag_invalid) << 4;
|
775 | fd4a04eb | ths | } |
776 | fd4a04eb | ths | |
777 | aa343735 | ths | static always_inline char mips_ex_to_ieee(char xcpt) |
778 | fd4a04eb | ths | { |
779 | fd4a04eb | ths | return (xcpt & FP_INEXACT) << 5 | |
780 | fd4a04eb | ths | (xcpt & FP_UNDERFLOW) << 3 |
|
781 | fd4a04eb | ths | (xcpt & FP_OVERFLOW) << 1 |
|
782 | fd4a04eb | ths | (xcpt & FP_DIV0) >> 1 |
|
783 | fd4a04eb | ths | (xcpt & FP_INVALID) >> 4;
|
784 | fd4a04eb | ths | } |
785 | fd4a04eb | ths | |
786 | aa343735 | ths | static always_inline void update_fcr31(void) |
787 | fd4a04eb | ths | { |
788 | ead9360e | ths | int tmp = ieee_ex_to_mips(get_float_exception_flags(&env->fpu->fp_status));
|
789 | fd4a04eb | ths | |
790 | ead9360e | ths | SET_FP_CAUSE(env->fpu->fcr31, tmp); |
791 | ead9360e | ths | if (GET_FP_ENABLE(env->fpu->fcr31) & tmp)
|
792 | fd4a04eb | ths | do_raise_exception(EXCP_FPE); |
793 | fd4a04eb | ths | else
|
794 | ead9360e | ths | UPDATE_FP_FLAGS(env->fpu->fcr31, tmp); |
795 | fd4a04eb | ths | } |
796 | fd4a04eb | ths | |
797 | fd4a04eb | ths | #define FLOAT_OP(name, p) void do_float_##name##_##p(void) |
798 | fd4a04eb | ths | |
799 | fd4a04eb | ths | FLOAT_OP(cvtd, s) |
800 | fd4a04eb | ths | { |
801 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
802 | ead9360e | ths | FDT2 = float32_to_float64(FST0, &env->fpu->fp_status); |
803 | fd4a04eb | ths | update_fcr31(); |
804 | fd4a04eb | ths | } |
805 | fd4a04eb | ths | FLOAT_OP(cvtd, w) |
806 | fd4a04eb | ths | { |
807 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
808 | ead9360e | ths | FDT2 = int32_to_float64(WT0, &env->fpu->fp_status); |
809 | fd4a04eb | ths | update_fcr31(); |
810 | fd4a04eb | ths | } |
811 | fd4a04eb | ths | FLOAT_OP(cvtd, l) |
812 | fd4a04eb | ths | { |
813 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
814 | ead9360e | ths | FDT2 = int64_to_float64(DT0, &env->fpu->fp_status); |
815 | fd4a04eb | ths | update_fcr31(); |
816 | fd4a04eb | ths | } |
817 | fd4a04eb | ths | FLOAT_OP(cvtl, d) |
818 | fd4a04eb | ths | { |
819 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
820 | ead9360e | ths | DT2 = float64_to_int64(FDT0, &env->fpu->fp_status); |
821 | fd4a04eb | ths | update_fcr31(); |
822 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
823 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
824 | fd4a04eb | ths | } |
825 | fd4a04eb | ths | FLOAT_OP(cvtl, s) |
826 | fd4a04eb | ths | { |
827 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
828 | ead9360e | ths | DT2 = float32_to_int64(FST0, &env->fpu->fp_status); |
829 | fd4a04eb | ths | update_fcr31(); |
830 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
831 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
832 | fd4a04eb | ths | } |
833 | fd4a04eb | ths | |
834 | fd4a04eb | ths | FLOAT_OP(cvtps, pw) |
835 | fd4a04eb | ths | { |
836 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
837 | ead9360e | ths | FST2 = int32_to_float32(WT0, &env->fpu->fp_status); |
838 | ead9360e | ths | FSTH2 = int32_to_float32(WTH0, &env->fpu->fp_status); |
839 | fd4a04eb | ths | update_fcr31(); |
840 | fd4a04eb | ths | } |
841 | fd4a04eb | ths | FLOAT_OP(cvtpw, ps) |
842 | fd4a04eb | ths | { |
843 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
844 | ead9360e | ths | WT2 = float32_to_int32(FST0, &env->fpu->fp_status); |
845 | ead9360e | ths | WTH2 = float32_to_int32(FSTH0, &env->fpu->fp_status); |
846 | fd4a04eb | ths | update_fcr31(); |
847 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
848 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
849 | fd4a04eb | ths | } |
850 | fd4a04eb | ths | FLOAT_OP(cvts, d) |
851 | fd4a04eb | ths | { |
852 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
853 | ead9360e | ths | FST2 = float64_to_float32(FDT0, &env->fpu->fp_status); |
854 | fd4a04eb | ths | update_fcr31(); |
855 | fd4a04eb | ths | } |
856 | fd4a04eb | ths | FLOAT_OP(cvts, w) |
857 | fd4a04eb | ths | { |
858 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
859 | ead9360e | ths | FST2 = int32_to_float32(WT0, &env->fpu->fp_status); |
860 | fd4a04eb | ths | update_fcr31(); |
861 | fd4a04eb | ths | } |
862 | fd4a04eb | ths | FLOAT_OP(cvts, l) |
863 | fd4a04eb | ths | { |
864 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
865 | ead9360e | ths | FST2 = int64_to_float32(DT0, &env->fpu->fp_status); |
866 | fd4a04eb | ths | update_fcr31(); |
867 | fd4a04eb | ths | } |
868 | fd4a04eb | ths | FLOAT_OP(cvts, pl) |
869 | fd4a04eb | ths | { |
870 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
871 | fd4a04eb | ths | WT2 = WT0; |
872 | fd4a04eb | ths | update_fcr31(); |
873 | fd4a04eb | ths | } |
874 | fd4a04eb | ths | FLOAT_OP(cvts, pu) |
875 | fd4a04eb | ths | { |
876 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
877 | fd4a04eb | ths | WT2 = WTH0; |
878 | fd4a04eb | ths | update_fcr31(); |
879 | fd4a04eb | ths | } |
880 | fd4a04eb | ths | FLOAT_OP(cvtw, s) |
881 | fd4a04eb | ths | { |
882 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
883 | ead9360e | ths | WT2 = float32_to_int32(FST0, &env->fpu->fp_status); |
884 | fd4a04eb | ths | update_fcr31(); |
885 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
886 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
887 | fd4a04eb | ths | } |
888 | fd4a04eb | ths | FLOAT_OP(cvtw, d) |
889 | fd4a04eb | ths | { |
890 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
891 | ead9360e | ths | WT2 = float64_to_int32(FDT0, &env->fpu->fp_status); |
892 | fd4a04eb | ths | update_fcr31(); |
893 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
894 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
895 | fd4a04eb | ths | } |
896 | fd4a04eb | ths | |
897 | fd4a04eb | ths | FLOAT_OP(roundl, d) |
898 | fd4a04eb | ths | { |
899 | ead9360e | ths | set_float_rounding_mode(float_round_nearest_even, &env->fpu->fp_status); |
900 | ead9360e | ths | DT2 = float64_to_int64(FDT0, &env->fpu->fp_status); |
901 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
902 | fd4a04eb | ths | update_fcr31(); |
903 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
904 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
905 | fd4a04eb | ths | } |
906 | fd4a04eb | ths | FLOAT_OP(roundl, s) |
907 | fd4a04eb | ths | { |
908 | ead9360e | ths | set_float_rounding_mode(float_round_nearest_even, &env->fpu->fp_status); |
909 | ead9360e | ths | DT2 = float32_to_int64(FST0, &env->fpu->fp_status); |
910 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
911 | fd4a04eb | ths | update_fcr31(); |
912 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
913 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
914 | fd4a04eb | ths | } |
915 | fd4a04eb | ths | FLOAT_OP(roundw, d) |
916 | fd4a04eb | ths | { |
917 | ead9360e | ths | set_float_rounding_mode(float_round_nearest_even, &env->fpu->fp_status); |
918 | ead9360e | ths | WT2 = float64_to_int32(FDT0, &env->fpu->fp_status); |
919 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
920 | fd4a04eb | ths | update_fcr31(); |
921 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
922 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
923 | fd4a04eb | ths | } |
924 | fd4a04eb | ths | FLOAT_OP(roundw, s) |
925 | fd4a04eb | ths | { |
926 | ead9360e | ths | set_float_rounding_mode(float_round_nearest_even, &env->fpu->fp_status); |
927 | ead9360e | ths | WT2 = float32_to_int32(FST0, &env->fpu->fp_status); |
928 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
929 | fd4a04eb | ths | update_fcr31(); |
930 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
931 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
932 | fd4a04eb | ths | } |
933 | fd4a04eb | ths | |
934 | fd4a04eb | ths | FLOAT_OP(truncl, d) |
935 | fd4a04eb | ths | { |
936 | ead9360e | ths | DT2 = float64_to_int64_round_to_zero(FDT0, &env->fpu->fp_status); |
937 | fd4a04eb | ths | update_fcr31(); |
938 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
939 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
940 | fd4a04eb | ths | } |
941 | fd4a04eb | ths | FLOAT_OP(truncl, s) |
942 | fd4a04eb | ths | { |
943 | ead9360e | ths | DT2 = float32_to_int64_round_to_zero(FST0, &env->fpu->fp_status); |
944 | fd4a04eb | ths | update_fcr31(); |
945 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
946 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
947 | fd4a04eb | ths | } |
948 | fd4a04eb | ths | FLOAT_OP(truncw, d) |
949 | fd4a04eb | ths | { |
950 | ead9360e | ths | WT2 = float64_to_int32_round_to_zero(FDT0, &env->fpu->fp_status); |
951 | fd4a04eb | ths | update_fcr31(); |
952 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
953 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
954 | fd4a04eb | ths | } |
955 | fd4a04eb | ths | FLOAT_OP(truncw, s) |
956 | fd4a04eb | ths | { |
957 | ead9360e | ths | WT2 = float32_to_int32_round_to_zero(FST0, &env->fpu->fp_status); |
958 | fd4a04eb | ths | update_fcr31(); |
959 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
960 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
961 | fd4a04eb | ths | } |
962 | fd4a04eb | ths | |
963 | fd4a04eb | ths | FLOAT_OP(ceill, d) |
964 | fd4a04eb | ths | { |
965 | ead9360e | ths | set_float_rounding_mode(float_round_up, &env->fpu->fp_status); |
966 | ead9360e | ths | DT2 = float64_to_int64(FDT0, &env->fpu->fp_status); |
967 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
968 | fd4a04eb | ths | update_fcr31(); |
969 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
970 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
971 | fd4a04eb | ths | } |
972 | fd4a04eb | ths | FLOAT_OP(ceill, s) |
973 | fd4a04eb | ths | { |
974 | ead9360e | ths | set_float_rounding_mode(float_round_up, &env->fpu->fp_status); |
975 | ead9360e | ths | DT2 = float32_to_int64(FST0, &env->fpu->fp_status); |
976 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
977 | fd4a04eb | ths | update_fcr31(); |
978 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
979 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
980 | fd4a04eb | ths | } |
981 | fd4a04eb | ths | FLOAT_OP(ceilw, d) |
982 | fd4a04eb | ths | { |
983 | ead9360e | ths | set_float_rounding_mode(float_round_up, &env->fpu->fp_status); |
984 | ead9360e | ths | WT2 = float64_to_int32(FDT0, &env->fpu->fp_status); |
985 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
986 | fd4a04eb | ths | update_fcr31(); |
987 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
988 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
989 | fd4a04eb | ths | } |
990 | fd4a04eb | ths | FLOAT_OP(ceilw, s) |
991 | fd4a04eb | ths | { |
992 | ead9360e | ths | set_float_rounding_mode(float_round_up, &env->fpu->fp_status); |
993 | ead9360e | ths | WT2 = float32_to_int32(FST0, &env->fpu->fp_status); |
994 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
995 | fd4a04eb | ths | update_fcr31(); |
996 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
997 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
998 | fd4a04eb | ths | } |
999 | fd4a04eb | ths | |
1000 | fd4a04eb | ths | FLOAT_OP(floorl, d) |
1001 | fd4a04eb | ths | { |
1002 | ead9360e | ths | set_float_rounding_mode(float_round_down, &env->fpu->fp_status); |
1003 | ead9360e | ths | DT2 = float64_to_int64(FDT0, &env->fpu->fp_status); |
1004 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
1005 | fd4a04eb | ths | update_fcr31(); |
1006 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
1007 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
1008 | fd4a04eb | ths | } |
1009 | fd4a04eb | ths | FLOAT_OP(floorl, s) |
1010 | fd4a04eb | ths | { |
1011 | ead9360e | ths | set_float_rounding_mode(float_round_down, &env->fpu->fp_status); |
1012 | ead9360e | ths | DT2 = float32_to_int64(FST0, &env->fpu->fp_status); |
1013 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
1014 | fd4a04eb | ths | update_fcr31(); |
1015 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
1016 | 54454097 | ths | DT2 = FLOAT_SNAN64; |
1017 | fd4a04eb | ths | } |
1018 | fd4a04eb | ths | FLOAT_OP(floorw, d) |
1019 | fd4a04eb | ths | { |
1020 | ead9360e | ths | set_float_rounding_mode(float_round_down, &env->fpu->fp_status); |
1021 | ead9360e | ths | WT2 = float64_to_int32(FDT0, &env->fpu->fp_status); |
1022 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
1023 | fd4a04eb | ths | update_fcr31(); |
1024 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
1025 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
1026 | fd4a04eb | ths | } |
1027 | fd4a04eb | ths | FLOAT_OP(floorw, s) |
1028 | fd4a04eb | ths | { |
1029 | ead9360e | ths | set_float_rounding_mode(float_round_down, &env->fpu->fp_status); |
1030 | ead9360e | ths | WT2 = float32_to_int32(FST0, &env->fpu->fp_status); |
1031 | fd4a04eb | ths | RESTORE_ROUNDING_MODE; |
1032 | fd4a04eb | ths | update_fcr31(); |
1033 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & (FP_OVERFLOW | FP_INVALID))
|
1034 | 54454097 | ths | WT2 = FLOAT_SNAN32; |
1035 | fd4a04eb | ths | } |
1036 | fd4a04eb | ths | |
1037 | 8dfdb87c | ths | /* MIPS specific unary operations */
|
1038 | 8dfdb87c | ths | FLOAT_OP(recip, d) |
1039 | 8dfdb87c | ths | { |
1040 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1041 | ead9360e | ths | FDT2 = float64_div(FLOAT_ONE64, FDT0, &env->fpu->fp_status); |
1042 | 8dfdb87c | ths | update_fcr31(); |
1043 | 8dfdb87c | ths | } |
1044 | 8dfdb87c | ths | FLOAT_OP(recip, s) |
1045 | 8dfdb87c | ths | { |
1046 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1047 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST0, &env->fpu->fp_status); |
1048 | 8dfdb87c | ths | update_fcr31(); |
1049 | 57fa1fb3 | ths | } |
1050 | 57fa1fb3 | ths | |
1051 | 8dfdb87c | ths | FLOAT_OP(rsqrt, d) |
1052 | 8dfdb87c | ths | { |
1053 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1054 | ead9360e | ths | FDT2 = float64_sqrt(FDT0, &env->fpu->fp_status); |
1055 | ead9360e | ths | FDT2 = float64_div(FLOAT_ONE64, FDT2, &env->fpu->fp_status); |
1056 | 8dfdb87c | ths | update_fcr31(); |
1057 | 8dfdb87c | ths | } |
1058 | 8dfdb87c | ths | FLOAT_OP(rsqrt, s) |
1059 | 8dfdb87c | ths | { |
1060 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1061 | ead9360e | ths | FST2 = float32_sqrt(FST0, &env->fpu->fp_status); |
1062 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST2, &env->fpu->fp_status); |
1063 | 8dfdb87c | ths | update_fcr31(); |
1064 | 8dfdb87c | ths | } |
1065 | 8dfdb87c | ths | |
1066 | 8dfdb87c | ths | FLOAT_OP(recip1, d) |
1067 | 8dfdb87c | ths | { |
1068 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1069 | ead9360e | ths | FDT2 = float64_div(FLOAT_ONE64, FDT0, &env->fpu->fp_status); |
1070 | 8dfdb87c | ths | update_fcr31(); |
1071 | 8dfdb87c | ths | } |
1072 | 8dfdb87c | ths | FLOAT_OP(recip1, s) |
1073 | 8dfdb87c | ths | { |
1074 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1075 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST0, &env->fpu->fp_status); |
1076 | 8dfdb87c | ths | update_fcr31(); |
1077 | 8dfdb87c | ths | } |
1078 | 8dfdb87c | ths | FLOAT_OP(recip1, ps) |
1079 | 8dfdb87c | ths | { |
1080 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1081 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST0, &env->fpu->fp_status); |
1082 | ead9360e | ths | FSTH2 = float32_div(FLOAT_ONE32, FSTH0, &env->fpu->fp_status); |
1083 | 8dfdb87c | ths | update_fcr31(); |
1084 | 8dfdb87c | ths | } |
1085 | 8dfdb87c | ths | |
1086 | 8dfdb87c | ths | FLOAT_OP(rsqrt1, d) |
1087 | 8dfdb87c | ths | { |
1088 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1089 | ead9360e | ths | FDT2 = float64_sqrt(FDT0, &env->fpu->fp_status); |
1090 | ead9360e | ths | FDT2 = float64_div(FLOAT_ONE64, FDT2, &env->fpu->fp_status); |
1091 | 8dfdb87c | ths | update_fcr31(); |
1092 | 8dfdb87c | ths | } |
1093 | 8dfdb87c | ths | FLOAT_OP(rsqrt1, s) |
1094 | 8dfdb87c | ths | { |
1095 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1096 | ead9360e | ths | FST2 = float32_sqrt(FST0, &env->fpu->fp_status); |
1097 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST2, &env->fpu->fp_status); |
1098 | 8dfdb87c | ths | update_fcr31(); |
1099 | 8dfdb87c | ths | } |
1100 | 8dfdb87c | ths | FLOAT_OP(rsqrt1, ps) |
1101 | 8dfdb87c | ths | { |
1102 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1103 | ead9360e | ths | FST2 = float32_sqrt(FST0, &env->fpu->fp_status); |
1104 | ead9360e | ths | FSTH2 = float32_sqrt(FSTH0, &env->fpu->fp_status); |
1105 | ead9360e | ths | FST2 = float32_div(FLOAT_ONE32, FST2, &env->fpu->fp_status); |
1106 | ead9360e | ths | FSTH2 = float32_div(FLOAT_ONE32, FSTH2, &env->fpu->fp_status); |
1107 | 8dfdb87c | ths | update_fcr31(); |
1108 | 57fa1fb3 | ths | } |
1109 | 57fa1fb3 | ths | |
1110 | fd4a04eb | ths | /* binary operations */
|
1111 | fd4a04eb | ths | #define FLOAT_BINOP(name) \
|
1112 | fd4a04eb | ths | FLOAT_OP(name, d) \ |
1113 | fd4a04eb | ths | { \ |
1114 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status); \
|
1115 | ead9360e | ths | FDT2 = float64_ ## name (FDT0, FDT1, &env->fpu->fp_status); \ |
1116 | ead9360e | ths | update_fcr31(); \ |
1117 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) \
|
1118 | 5747c073 | pbrook | DT2 = FLOAT_QNAN64; \ |
1119 | fd4a04eb | ths | } \ |
1120 | fd4a04eb | ths | FLOAT_OP(name, s) \ |
1121 | fd4a04eb | ths | { \ |
1122 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status); \
|
1123 | ead9360e | ths | FST2 = float32_ ## name (FST0, FST1, &env->fpu->fp_status); \ |
1124 | ead9360e | ths | update_fcr31(); \ |
1125 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) \
|
1126 | 5747c073 | pbrook | WT2 = FLOAT_QNAN32; \ |
1127 | fd4a04eb | ths | } \ |
1128 | fd4a04eb | ths | FLOAT_OP(name, ps) \ |
1129 | fd4a04eb | ths | { \ |
1130 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status); \
|
1131 | ead9360e | ths | FST2 = float32_ ## name (FST0, FST1, &env->fpu->fp_status); \ |
1132 | ead9360e | ths | FSTH2 = float32_ ## name (FSTH0, FSTH1, &env->fpu->fp_status); \ |
1133 | fd4a04eb | ths | update_fcr31(); \ |
1134 | ead9360e | ths | if (GET_FP_CAUSE(env->fpu->fcr31) & FP_INVALID) { \
|
1135 | 5747c073 | pbrook | WT2 = FLOAT_QNAN32; \ |
1136 | 5747c073 | pbrook | WTH2 = FLOAT_QNAN32; \ |
1137 | 3a5b360d | ths | } \ |
1138 | fd4a04eb | ths | } |
1139 | fd4a04eb | ths | FLOAT_BINOP(add) |
1140 | fd4a04eb | ths | FLOAT_BINOP(sub) |
1141 | fd4a04eb | ths | FLOAT_BINOP(mul) |
1142 | fd4a04eb | ths | FLOAT_BINOP(div) |
1143 | fd4a04eb | ths | #undef FLOAT_BINOP
|
1144 | fd4a04eb | ths | |
1145 | 8dfdb87c | ths | /* MIPS specific binary operations */
|
1146 | 8dfdb87c | ths | FLOAT_OP(recip2, d) |
1147 | 8dfdb87c | ths | { |
1148 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1149 | ead9360e | ths | FDT2 = float64_mul(FDT0, FDT2, &env->fpu->fp_status); |
1150 | 5747c073 | pbrook | FDT2 = float64_chs(float64_sub(FDT2, FLOAT_ONE64, &env->fpu->fp_status)); |
1151 | 8dfdb87c | ths | update_fcr31(); |
1152 | 8dfdb87c | ths | } |
1153 | 8dfdb87c | ths | FLOAT_OP(recip2, s) |
1154 | 8dfdb87c | ths | { |
1155 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1156 | ead9360e | ths | FST2 = float32_mul(FST0, FST2, &env->fpu->fp_status); |
1157 | 5747c073 | pbrook | FST2 = float32_chs(float32_sub(FST2, FLOAT_ONE32, &env->fpu->fp_status)); |
1158 | 8dfdb87c | ths | update_fcr31(); |
1159 | 8dfdb87c | ths | } |
1160 | 8dfdb87c | ths | FLOAT_OP(recip2, ps) |
1161 | 8dfdb87c | ths | { |
1162 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1163 | ead9360e | ths | FST2 = float32_mul(FST0, FST2, &env->fpu->fp_status); |
1164 | ead9360e | ths | FSTH2 = float32_mul(FSTH0, FSTH2, &env->fpu->fp_status); |
1165 | 5747c073 | pbrook | FST2 = float32_chs(float32_sub(FST2, FLOAT_ONE32, &env->fpu->fp_status)); |
1166 | 5747c073 | pbrook | FSTH2 = float32_chs(float32_sub(FSTH2, FLOAT_ONE32, &env->fpu->fp_status)); |
1167 | 8dfdb87c | ths | update_fcr31(); |
1168 | 8dfdb87c | ths | } |
1169 | 8dfdb87c | ths | |
1170 | 8dfdb87c | ths | FLOAT_OP(rsqrt2, d) |
1171 | 8dfdb87c | ths | { |
1172 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1173 | ead9360e | ths | FDT2 = float64_mul(FDT0, FDT2, &env->fpu->fp_status); |
1174 | ead9360e | ths | FDT2 = float64_sub(FDT2, FLOAT_ONE64, &env->fpu->fp_status); |
1175 | 5747c073 | pbrook | FDT2 = float64_chs(float64_div(FDT2, FLOAT_TWO64, &env->fpu->fp_status)); |
1176 | 8dfdb87c | ths | update_fcr31(); |
1177 | 8dfdb87c | ths | } |
1178 | 8dfdb87c | ths | FLOAT_OP(rsqrt2, s) |
1179 | 8dfdb87c | ths | { |
1180 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1181 | ead9360e | ths | FST2 = float32_mul(FST0, FST2, &env->fpu->fp_status); |
1182 | ead9360e | ths | FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fpu->fp_status); |
1183 | 5747c073 | pbrook | FST2 = float32_chs(float32_div(FST2, FLOAT_TWO32, &env->fpu->fp_status)); |
1184 | 8dfdb87c | ths | update_fcr31(); |
1185 | 8dfdb87c | ths | } |
1186 | 8dfdb87c | ths | FLOAT_OP(rsqrt2, ps) |
1187 | 8dfdb87c | ths | { |
1188 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1189 | ead9360e | ths | FST2 = float32_mul(FST0, FST2, &env->fpu->fp_status); |
1190 | ead9360e | ths | FSTH2 = float32_mul(FSTH0, FSTH2, &env->fpu->fp_status); |
1191 | ead9360e | ths | FST2 = float32_sub(FST2, FLOAT_ONE32, &env->fpu->fp_status); |
1192 | ead9360e | ths | FSTH2 = float32_sub(FSTH2, FLOAT_ONE32, &env->fpu->fp_status); |
1193 | 5747c073 | pbrook | FST2 = float32_chs(float32_div(FST2, FLOAT_TWO32, &env->fpu->fp_status)); |
1194 | 5747c073 | pbrook | FSTH2 = float32_chs(float32_div(FSTH2, FLOAT_TWO32, &env->fpu->fp_status)); |
1195 | 8dfdb87c | ths | update_fcr31(); |
1196 | 57fa1fb3 | ths | } |
1197 | 57fa1fb3 | ths | |
1198 | fd4a04eb | ths | FLOAT_OP(addr, ps) |
1199 | fd4a04eb | ths | { |
1200 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1201 | ead9360e | ths | FST2 = float32_add (FST0, FSTH0, &env->fpu->fp_status); |
1202 | ead9360e | ths | FSTH2 = float32_add (FST1, FSTH1, &env->fpu->fp_status); |
1203 | fd4a04eb | ths | update_fcr31(); |
1204 | fd4a04eb | ths | } |
1205 | fd4a04eb | ths | |
1206 | 57fa1fb3 | ths | FLOAT_OP(mulr, ps) |
1207 | 57fa1fb3 | ths | { |
1208 | ead9360e | ths | set_float_exception_flags(0, &env->fpu->fp_status);
|
1209 | ead9360e | ths | FST2 = float32_mul (FST0, FSTH0, &env->fpu->fp_status); |
1210 | ead9360e | ths | FSTH2 = float32_mul (FST1, FSTH1, &env->fpu->fp_status); |
1211 | 57fa1fb3 | ths | update_fcr31(); |
1212 | 57fa1fb3 | ths | } |
1213 | 57fa1fb3 | ths | |
1214 | 8dfdb87c | ths | /* compare operations */
|
1215 | fd4a04eb | ths | #define FOP_COND_D(op, cond) \
|
1216 | fd4a04eb | ths | void do_cmp_d_ ## op (long cc) \ |
1217 | fd4a04eb | ths | { \ |
1218 | fd4a04eb | ths | int c = cond; \
|
1219 | fd4a04eb | ths | update_fcr31(); \ |
1220 | fd4a04eb | ths | if (c) \
|
1221 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1222 | fd4a04eb | ths | else \
|
1223 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1224 | fd4a04eb | ths | } \ |
1225 | fd4a04eb | ths | void do_cmpabs_d_ ## op (long cc) \ |
1226 | fd4a04eb | ths | { \ |
1227 | fd4a04eb | ths | int c; \
|
1228 | 6b5435d7 | ths | FDT0 = float64_abs(FDT0); \ |
1229 | 6b5435d7 | ths | FDT1 = float64_abs(FDT1); \ |
1230 | fd4a04eb | ths | c = cond; \ |
1231 | fd4a04eb | ths | update_fcr31(); \ |
1232 | fd4a04eb | ths | if (c) \
|
1233 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1234 | fd4a04eb | ths | else \
|
1235 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1236 | fd4a04eb | ths | } |
1237 | fd4a04eb | ths | |
1238 | fd4a04eb | ths | int float64_is_unordered(int sig, float64 a, float64 b STATUS_PARAM) |
1239 | fd4a04eb | ths | { |
1240 | fd4a04eb | ths | if (float64_is_signaling_nan(a) ||
|
1241 | fd4a04eb | ths | float64_is_signaling_nan(b) || |
1242 | fd4a04eb | ths | (sig && (float64_is_nan(a) || float64_is_nan(b)))) { |
1243 | fd4a04eb | ths | float_raise(float_flag_invalid, status); |
1244 | fd4a04eb | ths | return 1; |
1245 | fd4a04eb | ths | } else if (float64_is_nan(a) || float64_is_nan(b)) { |
1246 | fd4a04eb | ths | return 1; |
1247 | fd4a04eb | ths | } else {
|
1248 | fd4a04eb | ths | return 0; |
1249 | fd4a04eb | ths | } |
1250 | fd4a04eb | ths | } |
1251 | fd4a04eb | ths | |
1252 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1253 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1254 | ead9360e | ths | FOP_COND_D(f, (float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status), 0)) |
1255 | ead9360e | ths | FOP_COND_D(un, float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status))
|
1256 | ead9360e | ths | FOP_COND_D(eq, !float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) && float64_eq(FDT0, FDT1, &env->fpu->fp_status))
|
1257 | ead9360e | ths | FOP_COND_D(ueq, float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) || float64_eq(FDT0, FDT1, &env->fpu->fp_status))
|
1258 | ead9360e | ths | FOP_COND_D(olt, !float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) && float64_lt(FDT0, FDT1, &env->fpu->fp_status))
|
1259 | ead9360e | ths | FOP_COND_D(ult, float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) || float64_lt(FDT0, FDT1, &env->fpu->fp_status))
|
1260 | ead9360e | ths | FOP_COND_D(ole, !float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) && float64_le(FDT0, FDT1, &env->fpu->fp_status))
|
1261 | ead9360e | ths | FOP_COND_D(ule, float64_is_unordered(0, FDT1, FDT0, &env->fpu->fp_status) || float64_le(FDT0, FDT1, &env->fpu->fp_status))
|
1262 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1263 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1264 | ead9360e | ths | FOP_COND_D(sf, (float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status), 0)) |
1265 | ead9360e | ths | FOP_COND_D(ngle,float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status))
|
1266 | ead9360e | ths | FOP_COND_D(seq, !float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) && float64_eq(FDT0, FDT1, &env->fpu->fp_status))
|
1267 | ead9360e | ths | FOP_COND_D(ngl, float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) || float64_eq(FDT0, FDT1, &env->fpu->fp_status))
|
1268 | ead9360e | ths | FOP_COND_D(lt, !float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) && float64_lt(FDT0, FDT1, &env->fpu->fp_status))
|
1269 | ead9360e | ths | FOP_COND_D(nge, float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) || float64_lt(FDT0, FDT1, &env->fpu->fp_status))
|
1270 | ead9360e | ths | FOP_COND_D(le, !float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) && float64_le(FDT0, FDT1, &env->fpu->fp_status))
|
1271 | ead9360e | ths | FOP_COND_D(ngt, float64_is_unordered(1, FDT1, FDT0, &env->fpu->fp_status) || float64_le(FDT0, FDT1, &env->fpu->fp_status))
|
1272 | fd4a04eb | ths | |
1273 | fd4a04eb | ths | #define FOP_COND_S(op, cond) \
|
1274 | fd4a04eb | ths | void do_cmp_s_ ## op (long cc) \ |
1275 | fd4a04eb | ths | { \ |
1276 | fd4a04eb | ths | int c = cond; \
|
1277 | fd4a04eb | ths | update_fcr31(); \ |
1278 | fd4a04eb | ths | if (c) \
|
1279 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1280 | fd4a04eb | ths | else \
|
1281 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1282 | fd4a04eb | ths | } \ |
1283 | fd4a04eb | ths | void do_cmpabs_s_ ## op (long cc) \ |
1284 | fd4a04eb | ths | { \ |
1285 | fd4a04eb | ths | int c; \
|
1286 | 5747c073 | pbrook | FST0 = float32_abs(FST0); \ |
1287 | 5747c073 | pbrook | FST1 = float32_abs(FST1); \ |
1288 | fd4a04eb | ths | c = cond; \ |
1289 | fd4a04eb | ths | update_fcr31(); \ |
1290 | fd4a04eb | ths | if (c) \
|
1291 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1292 | fd4a04eb | ths | else \
|
1293 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1294 | fd4a04eb | ths | } |
1295 | fd4a04eb | ths | |
1296 | fd4a04eb | ths | flag float32_is_unordered(int sig, float32 a, float32 b STATUS_PARAM)
|
1297 | fd4a04eb | ths | { |
1298 | fd4a04eb | ths | if (float32_is_signaling_nan(a) ||
|
1299 | fd4a04eb | ths | float32_is_signaling_nan(b) || |
1300 | fd4a04eb | ths | (sig && (float32_is_nan(a) || float32_is_nan(b)))) { |
1301 | fd4a04eb | ths | float_raise(float_flag_invalid, status); |
1302 | fd4a04eb | ths | return 1; |
1303 | fd4a04eb | ths | } else if (float32_is_nan(a) || float32_is_nan(b)) { |
1304 | fd4a04eb | ths | return 1; |
1305 | fd4a04eb | ths | } else {
|
1306 | fd4a04eb | ths | return 0; |
1307 | fd4a04eb | ths | } |
1308 | fd4a04eb | ths | } |
1309 | fd4a04eb | ths | |
1310 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1311 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1312 | ead9360e | ths | FOP_COND_S(f, (float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status), 0)) |
1313 | ead9360e | ths | FOP_COND_S(un, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status))
|
1314 | ead9360e | ths | FOP_COND_S(eq, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_eq(FST0, FST1, &env->fpu->fp_status))
|
1315 | ead9360e | ths | FOP_COND_S(ueq, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_eq(FST0, FST1, &env->fpu->fp_status))
|
1316 | ead9360e | ths | FOP_COND_S(olt, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_lt(FST0, FST1, &env->fpu->fp_status))
|
1317 | ead9360e | ths | FOP_COND_S(ult, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_lt(FST0, FST1, &env->fpu->fp_status))
|
1318 | ead9360e | ths | FOP_COND_S(ole, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_le(FST0, FST1, &env->fpu->fp_status))
|
1319 | ead9360e | ths | FOP_COND_S(ule, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_le(FST0, FST1, &env->fpu->fp_status))
|
1320 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1321 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1322 | ead9360e | ths | FOP_COND_S(sf, (float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status), 0)) |
1323 | ead9360e | ths | FOP_COND_S(ngle,float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status))
|
1324 | ead9360e | ths | FOP_COND_S(seq, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_eq(FST0, FST1, &env->fpu->fp_status))
|
1325 | ead9360e | ths | FOP_COND_S(ngl, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_eq(FST0, FST1, &env->fpu->fp_status))
|
1326 | ead9360e | ths | FOP_COND_S(lt, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_lt(FST0, FST1, &env->fpu->fp_status))
|
1327 | ead9360e | ths | FOP_COND_S(nge, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_lt(FST0, FST1, &env->fpu->fp_status))
|
1328 | ead9360e | ths | FOP_COND_S(le, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_le(FST0, FST1, &env->fpu->fp_status))
|
1329 | ead9360e | ths | FOP_COND_S(ngt, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_le(FST0, FST1, &env->fpu->fp_status))
|
1330 | fd4a04eb | ths | |
1331 | fd4a04eb | ths | #define FOP_COND_PS(op, condl, condh) \
|
1332 | fd4a04eb | ths | void do_cmp_ps_ ## op (long cc) \ |
1333 | fd4a04eb | ths | { \ |
1334 | fd4a04eb | ths | int cl = condl; \
|
1335 | fd4a04eb | ths | int ch = condh; \
|
1336 | fd4a04eb | ths | update_fcr31(); \ |
1337 | fd4a04eb | ths | if (cl) \
|
1338 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1339 | fd4a04eb | ths | else \
|
1340 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1341 | fd4a04eb | ths | if (ch) \
|
1342 | ead9360e | ths | SET_FP_COND(cc + 1, env->fpu); \
|
1343 | fd4a04eb | ths | else \
|
1344 | ead9360e | ths | CLEAR_FP_COND(cc + 1, env->fpu); \
|
1345 | fd4a04eb | ths | } \ |
1346 | fd4a04eb | ths | void do_cmpabs_ps_ ## op (long cc) \ |
1347 | fd4a04eb | ths | { \ |
1348 | fd4a04eb | ths | int cl, ch; \
|
1349 | 5747c073 | pbrook | FST0 = float32_abs(FST0); \ |
1350 | 5747c073 | pbrook | FSTH0 = float32_abs(FSTH0); \ |
1351 | 5747c073 | pbrook | FST1 = float32_abs(FST1); \ |
1352 | 5747c073 | pbrook | FSTH1 = float32_abs(FSTH1); \ |
1353 | fd4a04eb | ths | cl = condl; \ |
1354 | fd4a04eb | ths | ch = condh; \ |
1355 | fd4a04eb | ths | update_fcr31(); \ |
1356 | fd4a04eb | ths | if (cl) \
|
1357 | ead9360e | ths | SET_FP_COND(cc, env->fpu); \ |
1358 | fd4a04eb | ths | else \
|
1359 | ead9360e | ths | CLEAR_FP_COND(cc, env->fpu); \ |
1360 | fd4a04eb | ths | if (ch) \
|
1361 | ead9360e | ths | SET_FP_COND(cc + 1, env->fpu); \
|
1362 | fd4a04eb | ths | else \
|
1363 | ead9360e | ths | CLEAR_FP_COND(cc + 1, env->fpu); \
|
1364 | fd4a04eb | ths | } |
1365 | fd4a04eb | ths | |
1366 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1367 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1368 | ead9360e | ths | FOP_COND_PS(f, (float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status), 0), |
1369 | ead9360e | ths | (float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status), 0)) |
1370 | ead9360e | ths | FOP_COND_PS(un, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status),
|
1371 | ead9360e | ths | float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status))
|
1372 | ead9360e | ths | FOP_COND_PS(eq, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_eq(FST0, FST1, &env->fpu->fp_status),
|
1373 | ead9360e | ths | !float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) && float32_eq(FSTH0, FSTH1, &env->fpu->fp_status))
|
1374 | ead9360e | ths | FOP_COND_PS(ueq, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_eq(FST0, FST1, &env->fpu->fp_status),
|
1375 | ead9360e | ths | float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) || float32_eq(FSTH0, FSTH1, &env->fpu->fp_status))
|
1376 | ead9360e | ths | FOP_COND_PS(olt, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_lt(FST0, FST1, &env->fpu->fp_status),
|
1377 | ead9360e | ths | !float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) && float32_lt(FSTH0, FSTH1, &env->fpu->fp_status))
|
1378 | ead9360e | ths | FOP_COND_PS(ult, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_lt(FST0, FST1, &env->fpu->fp_status),
|
1379 | ead9360e | ths | float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) || float32_lt(FSTH0, FSTH1, &env->fpu->fp_status))
|
1380 | ead9360e | ths | FOP_COND_PS(ole, !float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) && float32_le(FST0, FST1, &env->fpu->fp_status),
|
1381 | ead9360e | ths | !float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) && float32_le(FSTH0, FSTH1, &env->fpu->fp_status))
|
1382 | ead9360e | ths | FOP_COND_PS(ule, float32_is_unordered(0, FST1, FST0, &env->fpu->fp_status) || float32_le(FST0, FST1, &env->fpu->fp_status),
|
1383 | ead9360e | ths | float32_is_unordered(0, FSTH1, FSTH0, &env->fpu->fp_status) || float32_le(FSTH0, FSTH1, &env->fpu->fp_status))
|
1384 | fd4a04eb | ths | /* NOTE: the comma operator will make "cond" to eval to false,
|
1385 | fd4a04eb | ths | * but float*_is_unordered() is still called. */
|
1386 | ead9360e | ths | FOP_COND_PS(sf, (float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status), 0), |
1387 | ead9360e | ths | (float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status), 0)) |
1388 | ead9360e | ths | FOP_COND_PS(ngle,float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status),
|
1389 | ead9360e | ths | float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status))
|
1390 | ead9360e | ths | FOP_COND_PS(seq, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_eq(FST0, FST1, &env->fpu->fp_status),
|
1391 | ead9360e | ths | !float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) && float32_eq(FSTH0, FSTH1, &env->fpu->fp_status))
|
1392 | ead9360e | ths | FOP_COND_PS(ngl, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_eq(FST0, FST1, &env->fpu->fp_status),
|
1393 | ead9360e | ths | float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) || float32_eq(FSTH0, FSTH1, &env->fpu->fp_status))
|
1394 | ead9360e | ths | FOP_COND_PS(lt, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_lt(FST0, FST1, &env->fpu->fp_status),
|
1395 | ead9360e | ths | !float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) && float32_lt(FSTH0, FSTH1, &env->fpu->fp_status))
|
1396 | ead9360e | ths | FOP_COND_PS(nge, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_lt(FST0, FST1, &env->fpu->fp_status),
|
1397 | ead9360e | ths | float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) || float32_lt(FSTH0, FSTH1, &env->fpu->fp_status))
|
1398 | ead9360e | ths | FOP_COND_PS(le, !float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) && float32_le(FST0, FST1, &env->fpu->fp_status),
|
1399 | ead9360e | ths | !float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) && float32_le(FSTH0, FSTH1, &env->fpu->fp_status))
|
1400 | ead9360e | ths | FOP_COND_PS(ngt, float32_is_unordered(1, FST1, FST0, &env->fpu->fp_status) || float32_le(FST0, FST1, &env->fpu->fp_status),
|
1401 | ead9360e | ths | float32_is_unordered(1, FSTH1, FSTH0, &env->fpu->fp_status) || float32_le(FSTH0, FSTH1, &env->fpu->fp_status)) |