]>
Commit | Line | Data |
---|---|---|
fdf9b3e8 FB |
1 | /* |
2 | * SH4 emulation | |
5fafdf24 | 3 | * |
fdf9b3e8 FB |
4 | * Copyright (c) 2005 Samuel Tardieu |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
8167ee88 | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
fdf9b3e8 | 18 | */ |
9d4c9946 | 19 | #include "qemu/osdep.h" |
3e457172 | 20 | #include "cpu.h" |
2ef6175a | 21 | #include "exec/helper-proto.h" |
63c91552 | 22 | #include "exec/exec-all.h" |
f08b6170 | 23 | #include "exec/cpu_ldst.h" |
24f91e81 | 24 | #include "fpu/softfloat.h" |
fdf9b3e8 | 25 | |
fdf9b3e8 FB |
26 | #ifndef CONFIG_USER_ONLY |
27 | ||
34257c21 AJ |
28 | void superh_cpu_do_unaligned_access(CPUState *cs, vaddr addr, |
29 | MMUAccessType access_type, | |
30 | int mmu_idx, uintptr_t retaddr) | |
31 | { | |
32 | switch (access_type) { | |
33 | case MMU_INST_FETCH: | |
34 | case MMU_DATA_LOAD: | |
35 | cs->exception_index = 0x0e0; | |
36 | break; | |
37 | case MMU_DATA_STORE: | |
38 | cs->exception_index = 0x100; | |
39 | break; | |
40 | } | |
41 | cpu_loop_exit_restore(cs, retaddr); | |
42 | } | |
43 | ||
98670d47 LV |
44 | void tlb_fill(CPUState *cs, target_ulong addr, int size, |
45 | MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) | |
fdf9b3e8 | 46 | { |
fdf9b3e8 FB |
47 | int ret; |
48 | ||
98670d47 | 49 | ret = superh_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); |
fdf9b3e8 | 50 | if (ret) { |
21829e9b | 51 | /* now we have a real cpu fault */ |
57e2d417 | 52 | cpu_loop_exit_restore(cs, retaddr); |
fdf9b3e8 | 53 | } |
fdf9b3e8 FB |
54 | } |
55 | ||
56 | #endif | |
57 | ||
485d0035 | 58 | void helper_ldtlb(CPUSH4State *env) |
ea2b542a AJ |
59 | { |
60 | #ifdef CONFIG_USER_ONLY | |
a47dddd7 AF |
61 | SuperHCPU *cpu = sh_env_get_cpu(env); |
62 | ||
ea2b542a | 63 | /* XXXXX */ |
a47dddd7 | 64 | cpu_abort(CPU(cpu), "Unhandled ldtlb"); |
ea2b542a AJ |
65 | #else |
66 | cpu_load_tlb(env); | |
67 | #endif | |
68 | } | |
69 | ||
10127400 AJ |
70 | static inline void QEMU_NORETURN raise_exception(CPUSH4State *env, int index, |
71 | uintptr_t retaddr) | |
e6afc2f4 | 72 | { |
27103424 AF |
73 | CPUState *cs = CPU(sh_env_get_cpu(env)); |
74 | ||
75 | cs->exception_index = index; | |
57e2d417 | 76 | cpu_loop_exit_restore(cs, retaddr); |
e6afc2f4 AJ |
77 | } |
78 | ||
485d0035 | 79 | void helper_raise_illegal_instruction(CPUSH4State *env) |
fd4bab10 | 80 | { |
10127400 | 81 | raise_exception(env, 0x180, 0); |
fd4bab10 AJ |
82 | } |
83 | ||
485d0035 | 84 | void helper_raise_slot_illegal_instruction(CPUSH4State *env) |
e6afc2f4 | 85 | { |
10127400 | 86 | raise_exception(env, 0x1a0, 0); |
e6afc2f4 AJ |
87 | } |
88 | ||
485d0035 | 89 | void helper_raise_fpu_disable(CPUSH4State *env) |
d8299bcc | 90 | { |
10127400 | 91 | raise_exception(env, 0x800, 0); |
d8299bcc AJ |
92 | } |
93 | ||
485d0035 | 94 | void helper_raise_slot_fpu_disable(CPUSH4State *env) |
d8299bcc | 95 | { |
10127400 | 96 | raise_exception(env, 0x820, 0); |
d8299bcc AJ |
97 | } |
98 | ||
485d0035 | 99 | void helper_debug(CPUSH4State *env) |
e6afc2f4 | 100 | { |
10127400 | 101 | raise_exception(env, EXCP_DEBUG, 0); |
e6afc2f4 AJ |
102 | } |
103 | ||
10127400 | 104 | void helper_sleep(CPUSH4State *env) |
e6afc2f4 | 105 | { |
259186a7 AF |
106 | CPUState *cs = CPU(sh_env_get_cpu(env)); |
107 | ||
108 | cs->halted = 1; | |
efac4154 | 109 | env->in_sleep = 1; |
10127400 | 110 | raise_exception(env, EXCP_HLT, 0); |
e6afc2f4 AJ |
111 | } |
112 | ||
485d0035 | 113 | void helper_trapa(CPUSH4State *env, uint32_t tra) |
e6afc2f4 AJ |
114 | { |
115 | env->tra = tra << 2; | |
10127400 | 116 | raise_exception(env, 0x160, 0); |
e6afc2f4 AJ |
117 | } |
118 | ||
4bfa602b RH |
119 | void helper_exclusive(CPUSH4State *env) |
120 | { | |
121 | /* We do not want cpu_restore_state to run. */ | |
122 | cpu_loop_exit_atomic(ENV_GET_CPU(env), 0); | |
123 | } | |
124 | ||
485d0035 | 125 | void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value) |
852d481f EI |
126 | { |
127 | if (cpu_sh4_is_cached (env, address)) | |
128 | { | |
01a72012 PM |
129 | memory_content *r = g_new(memory_content, 1); |
130 | ||
852d481f EI |
131 | r->address = address; |
132 | r->value = value; | |
133 | r->next = NULL; | |
134 | ||
135 | *(env->movcal_backup_tail) = r; | |
136 | env->movcal_backup_tail = &(r->next); | |
137 | } | |
138 | } | |
139 | ||
485d0035 | 140 | void helper_discard_movcal_backup(CPUSH4State *env) |
852d481f EI |
141 | { |
142 | memory_content *current = env->movcal_backup; | |
143 | ||
144 | while(current) | |
145 | { | |
146 | memory_content *next = current->next; | |
01a72012 | 147 | g_free(current); |
852d481f | 148 | env->movcal_backup = current = next; |
b9d38e95 | 149 | if (current == NULL) |
852d481f EI |
150 | env->movcal_backup_tail = &(env->movcal_backup); |
151 | } | |
152 | } | |
153 | ||
485d0035 | 154 | void helper_ocbi(CPUSH4State *env, uint32_t address) |
852d481f EI |
155 | { |
156 | memory_content **current = &(env->movcal_backup); | |
157 | while (*current) | |
158 | { | |
159 | uint32_t a = (*current)->address; | |
160 | if ((a & ~0x1F) == (address & ~0x1F)) | |
161 | { | |
162 | memory_content *next = (*current)->next; | |
485d0035 | 163 | cpu_stl_data(env, a, (*current)->value); |
852d481f | 164 | |
b9d38e95 | 165 | if (next == NULL) |
852d481f EI |
166 | { |
167 | env->movcal_backup_tail = current; | |
168 | } | |
169 | ||
01a72012 | 170 | g_free(*current); |
852d481f EI |
171 | *current = next; |
172 | break; | |
173 | } | |
174 | } | |
175 | } | |
176 | ||
485d0035 | 177 | void helper_macl(CPUSH4State *env, uint32_t arg0, uint32_t arg1) |
fdf9b3e8 FB |
178 | { |
179 | int64_t res; | |
180 | ||
181 | res = ((uint64_t) env->mach << 32) | env->macl; | |
6f06939b | 182 | res += (int64_t) (int32_t) arg0 *(int64_t) (int32_t) arg1; |
fdf9b3e8 FB |
183 | env->mach = (res >> 32) & 0xffffffff; |
184 | env->macl = res & 0xffffffff; | |
5ed9a259 | 185 | if (env->sr & (1u << SR_S)) { |
fdf9b3e8 FB |
186 | if (res < 0) |
187 | env->mach |= 0xffff0000; | |
188 | else | |
189 | env->mach &= 0x00007fff; | |
190 | } | |
191 | } | |
192 | ||
485d0035 | 193 | void helper_macw(CPUSH4State *env, uint32_t arg0, uint32_t arg1) |
fdf9b3e8 FB |
194 | { |
195 | int64_t res; | |
196 | ||
197 | res = ((uint64_t) env->mach << 32) | env->macl; | |
6f06939b | 198 | res += (int64_t) (int16_t) arg0 *(int64_t) (int16_t) arg1; |
fdf9b3e8 FB |
199 | env->mach = (res >> 32) & 0xffffffff; |
200 | env->macl = res & 0xffffffff; | |
5ed9a259 | 201 | if (env->sr & (1u << SR_S)) { |
fdf9b3e8 FB |
202 | if (res < -0x80000000) { |
203 | env->mach = 1; | |
204 | env->macl = 0x80000000; | |
205 | } else if (res > 0x000000007fffffff) { | |
206 | env->mach = 1; | |
207 | env->macl = 0x7fffffff; | |
208 | } | |
209 | } | |
210 | } | |
211 | ||
485d0035 | 212 | void helper_ld_fpscr(CPUSH4State *env, uint32_t val) |
390af821 | 213 | { |
26ac1ea5 AJ |
214 | env->fpscr = val & FPSCR_MASK; |
215 | if ((val & FPSCR_RM_MASK) == FPSCR_RM_ZERO) { | |
390af821 | 216 | set_float_rounding_mode(float_round_to_zero, &env->fp_status); |
26ac1ea5 | 217 | } else { |
390af821 | 218 | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); |
26ac1ea5 | 219 | } |
a0d4ac33 | 220 | set_flush_to_zero((val & FPSCR_DN) != 0, &env->fp_status); |
390af821 | 221 | } |
cc4ba6a9 | 222 | |
485d0035 | 223 | static void update_fpscr(CPUSH4State *env, uintptr_t retaddr) |
21829e9b AJ |
224 | { |
225 | int xcpt, cause, enable; | |
226 | ||
227 | xcpt = get_float_exception_flags(&env->fp_status); | |
228 | ||
801f4dac AJ |
229 | /* Clear the cause entries */ |
230 | env->fpscr &= ~FPSCR_CAUSE_MASK; | |
21829e9b AJ |
231 | |
232 | if (unlikely(xcpt)) { | |
233 | if (xcpt & float_flag_invalid) { | |
801f4dac | 234 | env->fpscr |= FPSCR_CAUSE_V; |
21829e9b AJ |
235 | } |
236 | if (xcpt & float_flag_divbyzero) { | |
801f4dac | 237 | env->fpscr |= FPSCR_CAUSE_Z; |
21829e9b AJ |
238 | } |
239 | if (xcpt & float_flag_overflow) { | |
801f4dac | 240 | env->fpscr |= FPSCR_CAUSE_O; |
21829e9b AJ |
241 | } |
242 | if (xcpt & float_flag_underflow) { | |
801f4dac | 243 | env->fpscr |= FPSCR_CAUSE_U; |
21829e9b AJ |
244 | } |
245 | if (xcpt & float_flag_inexact) { | |
801f4dac | 246 | env->fpscr |= FPSCR_CAUSE_I; |
21829e9b AJ |
247 | } |
248 | ||
801f4dac AJ |
249 | /* Accumulate in flag entries */ |
250 | env->fpscr |= (env->fpscr & FPSCR_CAUSE_MASK) | |
251 | >> (FPSCR_CAUSE_SHIFT - FPSCR_FLAG_SHIFT); | |
21829e9b AJ |
252 | |
253 | /* Generate an exception if enabled */ | |
254 | cause = (env->fpscr & FPSCR_CAUSE_MASK) >> FPSCR_CAUSE_SHIFT; | |
255 | enable = (env->fpscr & FPSCR_ENABLE_MASK) >> FPSCR_ENABLE_SHIFT; | |
256 | if (cause & enable) { | |
10127400 | 257 | raise_exception(env, 0x120, retaddr); |
21829e9b AJ |
258 | } |
259 | } | |
260 | } | |
261 | ||
485d0035 | 262 | float32 helper_fadd_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 263 | { |
21829e9b | 264 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 265 | t0 = float32_add(t0, t1, &env->fp_status); |
485d0035 | 266 | update_fpscr(env, GETPC()); |
d6c424c5 | 267 | return t0; |
cc4ba6a9 AJ |
268 | } |
269 | ||
485d0035 | 270 | float64 helper_fadd_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 271 | { |
21829e9b | 272 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 273 | t0 = float64_add(t0, t1, &env->fp_status); |
485d0035 | 274 | update_fpscr(env, GETPC()); |
d6c424c5 | 275 | return t0; |
cc4ba6a9 AJ |
276 | } |
277 | ||
92f1f83e | 278 | uint32_t helper_fcmp_eq_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 279 | { |
21829e9b | 280 | int relation; |
9850d1e8 | 281 | |
21829e9b | 282 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 283 | relation = float32_compare(t0, t1, &env->fp_status); |
fea7d77d | 284 | update_fpscr(env, GETPC()); |
92f1f83e | 285 | return relation == float_relation_equal; |
cc4ba6a9 AJ |
286 | } |
287 | ||
92f1f83e | 288 | uint32_t helper_fcmp_eq_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 289 | { |
21829e9b | 290 | int relation; |
9850d1e8 | 291 | |
21829e9b | 292 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 293 | relation = float64_compare(t0, t1, &env->fp_status); |
fea7d77d | 294 | update_fpscr(env, GETPC()); |
92f1f83e | 295 | return relation == float_relation_equal; |
cc4ba6a9 AJ |
296 | } |
297 | ||
92f1f83e | 298 | uint32_t helper_fcmp_gt_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 299 | { |
21829e9b | 300 | int relation; |
9850d1e8 | 301 | |
21829e9b | 302 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 303 | relation = float32_compare(t0, t1, &env->fp_status); |
fea7d77d | 304 | update_fpscr(env, GETPC()); |
92f1f83e | 305 | return relation == float_relation_greater; |
cc4ba6a9 AJ |
306 | } |
307 | ||
92f1f83e | 308 | uint32_t helper_fcmp_gt_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 309 | { |
21829e9b | 310 | int relation; |
9850d1e8 | 311 | |
21829e9b | 312 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 313 | relation = float64_compare(t0, t1, &env->fp_status); |
fea7d77d | 314 | update_fpscr(env, GETPC()); |
92f1f83e | 315 | return relation == float_relation_greater; |
cc4ba6a9 AJ |
316 | } |
317 | ||
485d0035 | 318 | float64 helper_fcnvsd_FT_DT(CPUSH4State *env, float32 t0) |
cc4ba6a9 | 319 | { |
d6c424c5 | 320 | float64 ret; |
21829e9b | 321 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 322 | ret = float32_to_float64(t0, &env->fp_status); |
485d0035 | 323 | update_fpscr(env, GETPC()); |
d6c424c5 | 324 | return ret; |
cc4ba6a9 AJ |
325 | } |
326 | ||
485d0035 | 327 | float32 helper_fcnvds_DT_FT(CPUSH4State *env, float64 t0) |
cc4ba6a9 | 328 | { |
d6c424c5 | 329 | float32 ret; |
21829e9b | 330 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 331 | ret = float64_to_float32(t0, &env->fp_status); |
485d0035 | 332 | update_fpscr(env, GETPC()); |
d6c424c5 | 333 | return ret; |
cc4ba6a9 AJ |
334 | } |
335 | ||
485d0035 | 336 | float32 helper_fdiv_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 337 | { |
21829e9b | 338 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 339 | t0 = float32_div(t0, t1, &env->fp_status); |
485d0035 | 340 | update_fpscr(env, GETPC()); |
d6c424c5 | 341 | return t0; |
cc4ba6a9 AJ |
342 | } |
343 | ||
485d0035 | 344 | float64 helper_fdiv_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 345 | { |
21829e9b | 346 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 347 | t0 = float64_div(t0, t1, &env->fp_status); |
485d0035 | 348 | update_fpscr(env, GETPC()); |
d6c424c5 | 349 | return t0; |
cc4ba6a9 AJ |
350 | } |
351 | ||
485d0035 | 352 | float32 helper_float_FT(CPUSH4State *env, uint32_t t0) |
cc4ba6a9 | 353 | { |
d6c424c5 | 354 | float32 ret; |
21829e9b | 355 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 356 | ret = int32_to_float32(t0, &env->fp_status); |
485d0035 | 357 | update_fpscr(env, GETPC()); |
d6c424c5 | 358 | return ret; |
cc4ba6a9 AJ |
359 | } |
360 | ||
485d0035 | 361 | float64 helper_float_DT(CPUSH4State *env, uint32_t t0) |
cc4ba6a9 | 362 | { |
d6c424c5 | 363 | float64 ret; |
21829e9b | 364 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 365 | ret = int32_to_float64(t0, &env->fp_status); |
485d0035 | 366 | update_fpscr(env, GETPC()); |
d6c424c5 | 367 | return ret; |
cc4ba6a9 AJ |
368 | } |
369 | ||
485d0035 | 370 | float32 helper_fmac_FT(CPUSH4State *env, float32 t0, float32 t1, float32 t2) |
5b7141a1 | 371 | { |
21829e9b | 372 | set_float_exception_flags(0, &env->fp_status); |
ff2086fe | 373 | t0 = float32_muladd(t0, t1, t2, 0, &env->fp_status); |
485d0035 | 374 | update_fpscr(env, GETPC()); |
d6c424c5 | 375 | return t0; |
5b7141a1 AJ |
376 | } |
377 | ||
485d0035 | 378 | float32 helper_fmul_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 379 | { |
21829e9b | 380 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 381 | t0 = float32_mul(t0, t1, &env->fp_status); |
485d0035 | 382 | update_fpscr(env, GETPC()); |
d6c424c5 | 383 | return t0; |
cc4ba6a9 AJ |
384 | } |
385 | ||
485d0035 | 386 | float64 helper_fmul_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 387 | { |
21829e9b | 388 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 389 | t0 = float64_mul(t0, t1, &env->fp_status); |
485d0035 | 390 | update_fpscr(env, GETPC()); |
d6c424c5 | 391 | return t0; |
cc4ba6a9 AJ |
392 | } |
393 | ||
485d0035 | 394 | float32 helper_fsqrt_FT(CPUSH4State *env, float32 t0) |
cc4ba6a9 | 395 | { |
21829e9b | 396 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 397 | t0 = float32_sqrt(t0, &env->fp_status); |
485d0035 | 398 | update_fpscr(env, GETPC()); |
d6c424c5 | 399 | return t0; |
cc4ba6a9 AJ |
400 | } |
401 | ||
485d0035 | 402 | float64 helper_fsqrt_DT(CPUSH4State *env, float64 t0) |
cc4ba6a9 | 403 | { |
21829e9b | 404 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 405 | t0 = float64_sqrt(t0, &env->fp_status); |
485d0035 | 406 | update_fpscr(env, GETPC()); |
d6c424c5 | 407 | return t0; |
cc4ba6a9 AJ |
408 | } |
409 | ||
11b7aa23 RH |
410 | float32 helper_fsrra_FT(CPUSH4State *env, float32 t0) |
411 | { | |
412 | set_float_exception_flags(0, &env->fp_status); | |
413 | /* "Approximate" 1/sqrt(x) via actual computation. */ | |
414 | t0 = float32_sqrt(t0, &env->fp_status); | |
415 | t0 = float32_div(float32_one, t0, &env->fp_status); | |
416 | /* Since this is supposed to be an approximation, an imprecision | |
417 | exception is required. One supposes this also follows the usual | |
418 | IEEE rule that other exceptions take precidence. */ | |
419 | if (get_float_exception_flags(&env->fp_status) == 0) { | |
420 | set_float_exception_flags(float_flag_inexact, &env->fp_status); | |
421 | } | |
422 | update_fpscr(env, GETPC()); | |
423 | return t0; | |
424 | } | |
425 | ||
485d0035 | 426 | float32 helper_fsub_FT(CPUSH4State *env, float32 t0, float32 t1) |
cc4ba6a9 | 427 | { |
21829e9b | 428 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 429 | t0 = float32_sub(t0, t1, &env->fp_status); |
485d0035 | 430 | update_fpscr(env, GETPC()); |
d6c424c5 | 431 | return t0; |
cc4ba6a9 AJ |
432 | } |
433 | ||
485d0035 | 434 | float64 helper_fsub_DT(CPUSH4State *env, float64 t0, float64 t1) |
cc4ba6a9 | 435 | { |
21829e9b | 436 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 437 | t0 = float64_sub(t0, t1, &env->fp_status); |
485d0035 | 438 | update_fpscr(env, GETPC()); |
d6c424c5 | 439 | return t0; |
cc4ba6a9 AJ |
440 | } |
441 | ||
485d0035 | 442 | uint32_t helper_ftrc_FT(CPUSH4State *env, float32 t0) |
cc4ba6a9 | 443 | { |
21829e9b | 444 | uint32_t ret; |
21829e9b | 445 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 446 | ret = float32_to_int32_round_to_zero(t0, &env->fp_status); |
485d0035 | 447 | update_fpscr(env, GETPC()); |
21829e9b | 448 | return ret; |
cc4ba6a9 AJ |
449 | } |
450 | ||
485d0035 | 451 | uint32_t helper_ftrc_DT(CPUSH4State *env, float64 t0) |
cc4ba6a9 | 452 | { |
21829e9b | 453 | uint32_t ret; |
21829e9b | 454 | set_float_exception_flags(0, &env->fp_status); |
d6c424c5 | 455 | ret = float64_to_int32_round_to_zero(t0, &env->fp_status); |
485d0035 | 456 | update_fpscr(env, GETPC()); |
21829e9b | 457 | return ret; |
cc4ba6a9 | 458 | } |
af8c2bde | 459 | |
485d0035 | 460 | void helper_fipr(CPUSH4State *env, uint32_t m, uint32_t n) |
af8c2bde AJ |
461 | { |
462 | int bank, i; | |
463 | float32 r, p; | |
464 | ||
465 | bank = (env->sr & FPSCR_FR) ? 16 : 0; | |
466 | r = float32_zero; | |
467 | set_float_exception_flags(0, &env->fp_status); | |
468 | ||
469 | for (i = 0 ; i < 4 ; i++) { | |
470 | p = float32_mul(env->fregs[bank + m + i], | |
471 | env->fregs[bank + n + i], | |
472 | &env->fp_status); | |
473 | r = float32_add(r, p, &env->fp_status); | |
474 | } | |
485d0035 | 475 | update_fpscr(env, GETPC()); |
af8c2bde AJ |
476 | |
477 | env->fregs[bank + n + 3] = r; | |
478 | } | |
17075f10 | 479 | |
485d0035 | 480 | void helper_ftrv(CPUSH4State *env, uint32_t n) |
17075f10 AJ |
481 | { |
482 | int bank_matrix, bank_vector; | |
483 | int i, j; | |
484 | float32 r[4]; | |
485 | float32 p; | |
486 | ||
487 | bank_matrix = (env->sr & FPSCR_FR) ? 0 : 16; | |
488 | bank_vector = (env->sr & FPSCR_FR) ? 16 : 0; | |
489 | set_float_exception_flags(0, &env->fp_status); | |
490 | for (i = 0 ; i < 4 ; i++) { | |
491 | r[i] = float32_zero; | |
492 | for (j = 0 ; j < 4 ; j++) { | |
493 | p = float32_mul(env->fregs[bank_matrix + 4 * j + i], | |
494 | env->fregs[bank_vector + j], | |
495 | &env->fp_status); | |
496 | r[i] = float32_add(r[i], p, &env->fp_status); | |
497 | } | |
498 | } | |
485d0035 | 499 | update_fpscr(env, GETPC()); |
17075f10 AJ |
500 | |
501 | for (i = 0 ; i < 4 ; i++) { | |
502 | env->fregs[bank_vector + i] = r[i]; | |
503 | } | |
504 | } |