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