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