2 * TriCore emulation for qemu: main translation routines.
4 * Copyright (c) 2013-2014 Bastian Koppelmann C-Lab/University Paderborn
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.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 #include "disas/disas.h"
24 #include "exec/cpu_ldst.h"
26 #include "exec/helper-proto.h"
27 #include "exec/helper-gen.h"
29 #include "tricore-opcodes.h"
39 static TCGv cpu_gpr_a
[16];
40 static TCGv cpu_gpr_d
[16];
42 static TCGv cpu_PSW_C
;
43 static TCGv cpu_PSW_V
;
44 static TCGv cpu_PSW_SV
;
45 static TCGv cpu_PSW_AV
;
46 static TCGv cpu_PSW_SAV
;
48 static TCGv_ptr cpu_env
;
50 #include "exec/gen-icount.h"
52 static const char *regnames_a
[] = {
53 "a0" , "a1" , "a2" , "a3" , "a4" , "a5" ,
54 "a6" , "a7" , "a8" , "a9" , "sp" , "a11" ,
55 "a12" , "a13" , "a14" , "a15",
58 static const char *regnames_d
[] = {
59 "d0" , "d1" , "d2" , "d3" , "d4" , "d5" ,
60 "d6" , "d7" , "d8" , "d9" , "d10" , "d11" ,
61 "d12" , "d13" , "d14" , "d15",
64 typedef struct DisasContext
{
65 struct TranslationBlock
*tb
;
66 target_ulong pc
, saved_pc
, next_pc
;
68 int singlestep_enabled
;
69 /* Routine used to access memory */
71 uint32_t hflags
, saved_hflags
;
90 void tricore_cpu_dump_state(CPUState
*cs
, FILE *f
,
91 fprintf_function cpu_fprintf
, int flags
)
93 TriCoreCPU
*cpu
= TRICORE_CPU(cs
);
94 CPUTriCoreState
*env
= &cpu
->env
;
100 cpu_fprintf(f
, "PC: " TARGET_FMT_lx
, env
->PC
);
101 cpu_fprintf(f
, " PSW: " TARGET_FMT_lx
, psw
);
102 cpu_fprintf(f
, " ICR: " TARGET_FMT_lx
, env
->ICR
);
103 cpu_fprintf(f
, "\nPCXI: " TARGET_FMT_lx
, env
->PCXI
);
104 cpu_fprintf(f
, " FCX: " TARGET_FMT_lx
, env
->FCX
);
105 cpu_fprintf(f
, " LCX: " TARGET_FMT_lx
, env
->LCX
);
107 for (i
= 0; i
< 16; ++i
) {
109 cpu_fprintf(f
, "\nGPR A%02d:", i
);
111 cpu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_a
[i
]);
113 for (i
= 0; i
< 16; ++i
) {
115 cpu_fprintf(f
, "\nGPR D%02d:", i
);
117 cpu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_d
[i
]);
119 cpu_fprintf(f
, "\n");
123 * Functions to generate micro-ops
126 /* Makros for generating helpers */
128 #define gen_helper_1arg(name, arg) do { \
129 TCGv_i32 helper_tmp = tcg_const_i32(arg); \
130 gen_helper_##name(cpu_env, helper_tmp); \
131 tcg_temp_free_i32(helper_tmp); \
134 #define GEN_HELPER_LL(name, ret, arg0, arg1, n) do { \
135 TCGv arg00 = tcg_temp_new(); \
136 TCGv arg01 = tcg_temp_new(); \
137 TCGv arg11 = tcg_temp_new(); \
138 tcg_gen_sari_tl(arg00, arg0, 16); \
139 tcg_gen_ext16s_tl(arg01, arg0); \
140 tcg_gen_ext16s_tl(arg11, arg1); \
141 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
142 tcg_temp_free(arg00); \
143 tcg_temp_free(arg01); \
144 tcg_temp_free(arg11); \
147 #define GEN_HELPER_LU(name, ret, arg0, arg1, n) do { \
148 TCGv arg00 = tcg_temp_new(); \
149 TCGv arg01 = tcg_temp_new(); \
150 TCGv arg10 = tcg_temp_new(); \
151 TCGv arg11 = tcg_temp_new(); \
152 tcg_gen_sari_tl(arg00, arg0, 16); \
153 tcg_gen_ext16s_tl(arg01, arg0); \
154 tcg_gen_sari_tl(arg11, arg1, 16); \
155 tcg_gen_ext16s_tl(arg10, arg1); \
156 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
157 tcg_temp_free(arg00); \
158 tcg_temp_free(arg01); \
159 tcg_temp_free(arg10); \
160 tcg_temp_free(arg11); \
163 #define GEN_HELPER_UL(name, ret, arg0, arg1, n) do { \
164 TCGv arg00 = tcg_temp_new(); \
165 TCGv arg01 = tcg_temp_new(); \
166 TCGv arg10 = tcg_temp_new(); \
167 TCGv arg11 = tcg_temp_new(); \
168 tcg_gen_sari_tl(arg00, arg0, 16); \
169 tcg_gen_ext16s_tl(arg01, arg0); \
170 tcg_gen_sari_tl(arg10, arg1, 16); \
171 tcg_gen_ext16s_tl(arg11, arg1); \
172 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
173 tcg_temp_free(arg00); \
174 tcg_temp_free(arg01); \
175 tcg_temp_free(arg10); \
176 tcg_temp_free(arg11); \
179 #define GEN_HELPER_UU(name, ret, arg0, arg1, n) do { \
180 TCGv arg00 = tcg_temp_new(); \
181 TCGv arg01 = tcg_temp_new(); \
182 TCGv arg11 = tcg_temp_new(); \
183 tcg_gen_sari_tl(arg01, arg0, 16); \
184 tcg_gen_ext16s_tl(arg00, arg0); \
185 tcg_gen_sari_tl(arg11, arg1, 16); \
186 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
187 tcg_temp_free(arg00); \
188 tcg_temp_free(arg01); \
189 tcg_temp_free(arg11); \
192 #define GEN_HELPER_RRR(name, rl, rh, al1, ah1, arg2) do { \
193 TCGv_i64 ret = tcg_temp_new_i64(); \
194 TCGv_i64 arg1 = tcg_temp_new_i64(); \
196 tcg_gen_concat_i32_i64(arg1, al1, ah1); \
197 gen_helper_##name(ret, arg1, arg2); \
198 tcg_gen_extr_i64_i32(rl, rh, ret); \
200 tcg_temp_free_i64(ret); \
201 tcg_temp_free_i64(arg1); \
204 #define EA_ABS_FORMAT(con) (((con & 0x3C000) << 14) + (con & 0x3FFF))
205 #define EA_B_ABSOLUT(con) (((offset & 0xf00000) << 8) | \
206 ((offset & 0x0fffff) << 1))
208 /* Functions for load/save to/from memory */
210 static inline void gen_offset_ld(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
211 int16_t con
, TCGMemOp mop
)
213 TCGv temp
= tcg_temp_new();
214 tcg_gen_addi_tl(temp
, r2
, con
);
215 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
219 static inline void gen_offset_st(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
220 int16_t con
, TCGMemOp mop
)
222 TCGv temp
= tcg_temp_new();
223 tcg_gen_addi_tl(temp
, r2
, con
);
224 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
228 static void gen_st_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
230 TCGv_i64 temp
= tcg_temp_new_i64();
232 tcg_gen_concat_i32_i64(temp
, rl
, rh
);
233 tcg_gen_qemu_st_i64(temp
, address
, ctx
->mem_idx
, MO_LEQ
);
235 tcg_temp_free_i64(temp
);
238 static void gen_offset_st_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
241 TCGv temp
= tcg_temp_new();
242 tcg_gen_addi_tl(temp
, base
, con
);
243 gen_st_2regs_64(rh
, rl
, temp
, ctx
);
247 static void gen_ld_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
249 TCGv_i64 temp
= tcg_temp_new_i64();
251 tcg_gen_qemu_ld_i64(temp
, address
, ctx
->mem_idx
, MO_LEQ
);
252 /* write back to two 32 bit regs */
253 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
255 tcg_temp_free_i64(temp
);
258 static void gen_offset_ld_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
261 TCGv temp
= tcg_temp_new();
262 tcg_gen_addi_tl(temp
, base
, con
);
263 gen_ld_2regs_64(rh
, rl
, temp
, ctx
);
267 static void gen_st_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
270 TCGv temp
= tcg_temp_new();
271 tcg_gen_addi_tl(temp
, r2
, off
);
272 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
273 tcg_gen_mov_tl(r2
, temp
);
277 static void gen_ld_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
280 TCGv temp
= tcg_temp_new();
281 tcg_gen_addi_tl(temp
, r2
, off
);
282 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
283 tcg_gen_mov_tl(r2
, temp
);
287 /* M(EA, word) = (M(EA, word) & ~E[a][63:32]) | (E[a][31:0] & E[a][63:32]); */
288 static void gen_ldmst(DisasContext
*ctx
, int ereg
, TCGv ea
)
290 TCGv temp
= tcg_temp_new();
291 TCGv temp2
= tcg_temp_new();
293 /* temp = (M(EA, word) */
294 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
295 /* temp = temp & ~E[a][63:32]) */
296 tcg_gen_andc_tl(temp
, temp
, cpu_gpr_d
[ereg
+1]);
297 /* temp2 = (E[a][31:0] & E[a][63:32]); */
298 tcg_gen_and_tl(temp2
, cpu_gpr_d
[ereg
], cpu_gpr_d
[ereg
+1]);
299 /* temp = temp | temp2; */
300 tcg_gen_or_tl(temp
, temp
, temp2
);
301 /* M(EA, word) = temp; */
302 tcg_gen_qemu_st_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
305 tcg_temp_free(temp2
);
308 /* tmp = M(EA, word);
311 static void gen_swap(DisasContext
*ctx
, int reg
, TCGv ea
)
313 TCGv temp
= tcg_temp_new();
315 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
316 tcg_gen_qemu_st_tl(cpu_gpr_d
[reg
], ea
, ctx
->mem_idx
, MO_LEUL
);
317 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
322 /* We generate loads and store to core special function register (csfr) through
323 the function gen_mfcr and gen_mtcr. To handle access permissions, we use 3
324 makros R, A and E, which allow read-only, all and endinit protected access.
325 These makros also specify in which ISA version the csfr was introduced. */
326 #define R(ADDRESS, REG, FEATURE) \
328 if (tricore_feature(env, FEATURE)) { \
329 tcg_gen_ld_tl(ret, cpu_env, offsetof(CPUTriCoreState, REG)); \
332 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
333 #define E(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
334 static inline void gen_mfcr(CPUTriCoreState
*env
, TCGv ret
, int32_t offset
)
336 /* since we're caching PSW make this a special case */
337 if (offset
== 0xfe04) {
338 gen_helper_psw_read(ret
, cpu_env
);
349 #define R(ADDRESS, REG, FEATURE) /* don't gen writes to read-only reg,
350 since no execption occurs */
351 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE) \
353 if (tricore_feature(env, FEATURE)) { \
354 tcg_gen_st_tl(r1, cpu_env, offsetof(CPUTriCoreState, REG)); \
357 /* Endinit protected registers
358 TODO: Since the endinit bit is in a register of a not yet implemented
359 watchdog device, we handle endinit protected registers like
360 all-access registers for now. */
361 #define E(ADDRESS, REG, FEATURE) A(ADDRESS, REG, FEATURE)
362 static inline void gen_mtcr(CPUTriCoreState
*env
, DisasContext
*ctx
, TCGv r1
,
365 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
) {
366 /* since we're caching PSW make this a special case */
367 if (offset
== 0xfe04) {
368 gen_helper_psw_write(cpu_env
, r1
);
375 /* generate privilege trap */
379 /* Functions for arithmetic instructions */
381 static inline void gen_add_d(TCGv ret
, TCGv r1
, TCGv r2
)
383 TCGv t0
= tcg_temp_new_i32();
384 TCGv result
= tcg_temp_new_i32();
385 /* Addition and set V/SV bits */
386 tcg_gen_add_tl(result
, r1
, r2
);
388 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
389 tcg_gen_xor_tl(t0
, r1
, r2
);
390 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
392 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
393 /* Calc AV/SAV bits */
394 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
395 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
397 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
398 /* write back result */
399 tcg_gen_mov_tl(ret
, result
);
401 tcg_temp_free(result
);
406 gen_add64_d(TCGv_i64 ret
, TCGv_i64 r1
, TCGv_i64 r2
)
408 TCGv temp
= tcg_temp_new();
409 TCGv_i64 t0
= tcg_temp_new_i64();
410 TCGv_i64 t1
= tcg_temp_new_i64();
411 TCGv_i64 result
= tcg_temp_new_i64();
413 tcg_gen_add_i64(result
, r1
, r2
);
415 tcg_gen_xor_i64(t1
, result
, r1
);
416 tcg_gen_xor_i64(t0
, r1
, r2
);
417 tcg_gen_andc_i64(t1
, t1
, t0
);
418 tcg_gen_trunc_shr_i64_i32(cpu_PSW_V
, t1
, 32);
420 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
421 /* calc AV/SAV bits */
422 tcg_gen_trunc_shr_i64_i32(temp
, result
, 32);
423 tcg_gen_add_tl(cpu_PSW_AV
, temp
, temp
);
424 tcg_gen_xor_tl(cpu_PSW_AV
, temp
, cpu_PSW_AV
);
426 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
427 /* write back result */
428 tcg_gen_mov_i64(ret
, result
);
431 tcg_temp_free_i64(result
);
432 tcg_temp_free_i64(t0
);
433 tcg_temp_free_i64(t1
);
437 gen_addsub64_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
438 TCGv r3
, void(*op1
)(TCGv
, TCGv
, TCGv
),
439 void(*op2
)(TCGv
, TCGv
, TCGv
))
441 TCGv temp
= tcg_temp_new();
442 TCGv temp2
= tcg_temp_new();
443 TCGv temp3
= tcg_temp_new();
444 TCGv temp4
= tcg_temp_new();
446 (*op1
)(temp
, r1_low
, r2
);
448 tcg_gen_xor_tl(temp2
, temp
, r1_low
);
449 tcg_gen_xor_tl(temp3
, r1_low
, r2
);
450 if (op1
== tcg_gen_add_tl
) {
451 tcg_gen_andc_tl(temp2
, temp2
, temp3
);
453 tcg_gen_and_tl(temp2
, temp2
, temp3
);
456 (*op2
)(temp3
, r1_high
, r3
);
458 tcg_gen_xor_tl(cpu_PSW_V
, temp3
, r1_high
);
459 tcg_gen_xor_tl(temp4
, r1_high
, r3
);
460 if (op2
== tcg_gen_add_tl
) {
461 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
463 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
465 /* combine V0/V1 bits */
466 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp2
);
468 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
470 tcg_gen_mov_tl(ret_low
, temp
);
471 tcg_gen_mov_tl(ret_high
, temp3
);
473 tcg_gen_add_tl(temp
, ret_low
, ret_low
);
474 tcg_gen_xor_tl(temp
, temp
, ret_low
);
475 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
476 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, ret_high
);
477 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
479 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
482 tcg_temp_free(temp2
);
483 tcg_temp_free(temp3
);
484 tcg_temp_free(temp4
);
487 /* ret = r2 + (r1 * r3); */
488 static inline void gen_madd32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
490 TCGv_i64 t1
= tcg_temp_new_i64();
491 TCGv_i64 t2
= tcg_temp_new_i64();
492 TCGv_i64 t3
= tcg_temp_new_i64();
494 tcg_gen_ext_i32_i64(t1
, r1
);
495 tcg_gen_ext_i32_i64(t2
, r2
);
496 tcg_gen_ext_i32_i64(t3
, r3
);
498 tcg_gen_mul_i64(t1
, t1
, t3
);
499 tcg_gen_add_i64(t1
, t2
, t1
);
501 tcg_gen_trunc_i64_i32(ret
, t1
);
504 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
505 /* t1 < -0x80000000 */
506 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
507 tcg_gen_or_i64(t2
, t2
, t3
);
508 tcg_gen_trunc_i64_i32(cpu_PSW_V
, t2
);
509 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
511 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
512 /* Calc AV/SAV bits */
513 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
514 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
516 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
518 tcg_temp_free_i64(t1
);
519 tcg_temp_free_i64(t2
);
520 tcg_temp_free_i64(t3
);
523 static inline void gen_maddi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
525 TCGv temp
= tcg_const_i32(con
);
526 gen_madd32_d(ret
, r1
, r2
, temp
);
531 gen_madd64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
534 TCGv t1
= tcg_temp_new();
535 TCGv t2
= tcg_temp_new();
536 TCGv t3
= tcg_temp_new();
537 TCGv t4
= tcg_temp_new();
539 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
540 /* only the add can overflow */
541 tcg_gen_add2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
543 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
544 tcg_gen_xor_tl(t1
, r2_high
, t2
);
545 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
547 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
548 /* Calc AV/SAV bits */
549 tcg_gen_add_tl(cpu_PSW_AV
, t4
, t4
);
550 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
552 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
553 /* write back the result */
554 tcg_gen_mov_tl(ret_low
, t3
);
555 tcg_gen_mov_tl(ret_high
, t4
);
564 gen_maddu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
567 TCGv_i64 t1
= tcg_temp_new_i64();
568 TCGv_i64 t2
= tcg_temp_new_i64();
569 TCGv_i64 t3
= tcg_temp_new_i64();
571 tcg_gen_extu_i32_i64(t1
, r1
);
572 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
573 tcg_gen_extu_i32_i64(t3
, r3
);
575 tcg_gen_mul_i64(t1
, t1
, t3
);
576 tcg_gen_add_i64(t2
, t2
, t1
);
577 /* write back result */
578 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t2
);
579 /* only the add overflows, if t2 < t1
581 tcg_gen_setcond_i64(TCG_COND_LTU
, t2
, t2
, t1
);
582 tcg_gen_trunc_i64_i32(cpu_PSW_V
, t2
);
583 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
585 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
586 /* Calc AV/SAV bits */
587 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
588 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
590 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
592 tcg_temp_free_i64(t1
);
593 tcg_temp_free_i64(t2
);
594 tcg_temp_free_i64(t3
);
598 gen_maddi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
601 TCGv temp
= tcg_const_i32(con
);
602 gen_madd64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
607 gen_maddui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
610 TCGv temp
= tcg_const_i32(con
);
611 gen_maddu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
616 gen_madd_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
617 TCGv r3
, uint32_t n
, uint32_t mode
)
619 TCGv temp
= tcg_const_i32(n
);
620 TCGv temp2
= tcg_temp_new();
621 TCGv_i64 temp64
= tcg_temp_new_i64();
624 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
627 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
630 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
633 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
636 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
637 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
638 tcg_gen_add_tl
, tcg_gen_add_tl
);
640 tcg_temp_free(temp2
);
641 tcg_temp_free_i64(temp64
);
645 gen_maddsu_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
646 TCGv r3
, uint32_t n
, uint32_t mode
)
648 TCGv temp
= tcg_const_i32(n
);
649 TCGv temp2
= tcg_temp_new();
650 TCGv_i64 temp64
= tcg_temp_new_i64();
653 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
656 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
659 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
662 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
665 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
666 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
667 tcg_gen_sub_tl
, tcg_gen_add_tl
);
669 tcg_temp_free(temp2
);
670 tcg_temp_free_i64(temp64
);
674 gen_maddsum_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
675 TCGv r3
, uint32_t n
, uint32_t mode
)
677 TCGv temp
= tcg_const_i32(n
);
678 TCGv_i64 temp64
= tcg_temp_new_i64();
679 TCGv_i64 temp64_2
= tcg_temp_new_i64();
680 TCGv_i64 temp64_3
= tcg_temp_new_i64();
683 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
686 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
689 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
692 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
695 tcg_gen_concat_i32_i64(temp64_3
, r1_low
, r1_high
);
696 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
697 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
698 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
699 tcg_gen_shli_i64(temp64
, temp64
, 16);
701 gen_add64_d(temp64_2
, temp64_3
, temp64
);
702 /* write back result */
703 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_2
);
706 tcg_temp_free_i64(temp64
);
707 tcg_temp_free_i64(temp64_2
);
708 tcg_temp_free_i64(temp64_3
);
711 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
);
714 gen_madds_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
715 TCGv r3
, uint32_t n
, uint32_t mode
)
717 TCGv temp
= tcg_const_i32(n
);
718 TCGv temp2
= tcg_temp_new();
719 TCGv temp3
= tcg_temp_new();
720 TCGv_i64 temp64
= tcg_temp_new_i64();
724 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
727 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
730 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
733 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
736 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
737 gen_adds(ret_low
, r1_low
, temp
);
738 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
739 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
740 gen_adds(ret_high
, r1_high
, temp2
);
742 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
743 /* combine av bits */
744 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
747 tcg_temp_free(temp2
);
748 tcg_temp_free(temp3
);
749 tcg_temp_free_i64(temp64
);
753 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
);
756 gen_maddsus_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
757 TCGv r3
, uint32_t n
, uint32_t mode
)
759 TCGv temp
= tcg_const_i32(n
);
760 TCGv temp2
= tcg_temp_new();
761 TCGv temp3
= tcg_temp_new();
762 TCGv_i64 temp64
= tcg_temp_new_i64();
766 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
769 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
772 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
775 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
778 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
779 gen_subs(ret_low
, r1_low
, temp
);
780 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
781 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
782 gen_adds(ret_high
, r1_high
, temp2
);
784 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
785 /* combine av bits */
786 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
789 tcg_temp_free(temp2
);
790 tcg_temp_free(temp3
);
791 tcg_temp_free_i64(temp64
);
796 gen_maddsums_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
797 TCGv r3
, uint32_t n
, uint32_t mode
)
799 TCGv temp
= tcg_const_i32(n
);
800 TCGv_i64 temp64
= tcg_temp_new_i64();
801 TCGv_i64 temp64_2
= tcg_temp_new_i64();
805 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
808 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
811 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
814 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
817 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
818 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
819 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
820 tcg_gen_shli_i64(temp64
, temp64
, 16);
821 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
823 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
824 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
827 tcg_temp_free_i64(temp64
);
828 tcg_temp_free_i64(temp64_2
);
833 gen_maddm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
834 TCGv r3
, uint32_t n
, uint32_t mode
)
836 TCGv temp
= tcg_const_i32(n
);
837 TCGv_i64 temp64
= tcg_temp_new_i64();
838 TCGv_i64 temp64_2
= tcg_temp_new_i64();
839 TCGv_i64 temp64_3
= tcg_temp_new_i64();
842 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
845 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
848 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
851 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
854 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
855 gen_add64_d(temp64_3
, temp64_2
, temp64
);
856 /* write back result */
857 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_3
);
860 tcg_temp_free_i64(temp64
);
861 tcg_temp_free_i64(temp64_2
);
862 tcg_temp_free_i64(temp64_3
);
866 gen_maddms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
867 TCGv r3
, uint32_t n
, uint32_t mode
)
869 TCGv temp
= tcg_const_i32(n
);
870 TCGv_i64 temp64
= tcg_temp_new_i64();
871 TCGv_i64 temp64_2
= tcg_temp_new_i64();
874 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
877 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
880 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
883 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
886 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
887 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
888 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
891 tcg_temp_free_i64(temp64
);
892 tcg_temp_free_i64(temp64_2
);
896 gen_maddr64_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
, uint32_t n
,
899 TCGv temp
= tcg_const_i32(n
);
900 TCGv_i64 temp64
= tcg_temp_new_i64();
903 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
906 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
909 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
912 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
915 gen_helper_addr_h(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
918 tcg_temp_free_i64(temp64
);
922 gen_maddr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
924 TCGv temp
= tcg_temp_new();
925 TCGv temp2
= tcg_temp_new();
927 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
928 tcg_gen_shli_tl(temp
, r1
, 16);
929 gen_maddr64_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
932 tcg_temp_free(temp2
);
936 gen_maddsur32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
938 TCGv temp
= tcg_const_i32(n
);
939 TCGv temp2
= tcg_temp_new();
940 TCGv_i64 temp64
= tcg_temp_new_i64();
943 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
946 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
949 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
952 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
955 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
956 tcg_gen_shli_tl(temp
, r1
, 16);
957 gen_helper_addsur_h(ret
, cpu_env
, temp64
, temp
, temp2
);
960 tcg_temp_free(temp2
);
961 tcg_temp_free_i64(temp64
);
966 gen_maddr64s_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
,
967 uint32_t n
, uint32_t mode
)
969 TCGv temp
= tcg_const_i32(n
);
970 TCGv_i64 temp64
= tcg_temp_new_i64();
973 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
976 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
979 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
982 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
985 gen_helper_addr_h_ssov(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
988 tcg_temp_free_i64(temp64
);
992 gen_maddr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
994 TCGv temp
= tcg_temp_new();
995 TCGv temp2
= tcg_temp_new();
997 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
998 tcg_gen_shli_tl(temp
, r1
, 16);
999 gen_maddr64s_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1001 tcg_temp_free(temp
);
1002 tcg_temp_free(temp2
);
1006 gen_maddsur32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1008 TCGv temp
= tcg_const_i32(n
);
1009 TCGv temp2
= tcg_temp_new();
1010 TCGv_i64 temp64
= tcg_temp_new_i64();
1013 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1016 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1019 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1022 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1025 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1026 tcg_gen_shli_tl(temp
, r1
, 16);
1027 gen_helper_addsur_h_ssov(ret
, cpu_env
, temp64
, temp
, temp2
);
1029 tcg_temp_free(temp
);
1030 tcg_temp_free(temp2
);
1031 tcg_temp_free_i64(temp64
);
1035 gen_maddr_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1037 TCGv temp
= tcg_const_i32(n
);
1038 gen_helper_maddr_q(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1039 tcg_temp_free(temp
);
1043 gen_maddrs_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1045 TCGv temp
= tcg_const_i32(n
);
1046 gen_helper_maddr_q_ssov(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1047 tcg_temp_free(temp
);
1051 gen_madd32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1052 uint32_t up_shift
, CPUTriCoreState
*env
)
1054 TCGv temp
= tcg_temp_new();
1055 TCGv temp2
= tcg_temp_new();
1056 TCGv temp3
= tcg_temp_new();
1057 TCGv_i64 t1
= tcg_temp_new_i64();
1058 TCGv_i64 t2
= tcg_temp_new_i64();
1059 TCGv_i64 t3
= tcg_temp_new_i64();
1061 tcg_gen_ext_i32_i64(t2
, arg2
);
1062 tcg_gen_ext_i32_i64(t3
, arg3
);
1064 tcg_gen_mul_i64(t2
, t2
, t3
);
1065 tcg_gen_shli_i64(t2
, t2
, n
);
1067 tcg_gen_ext_i32_i64(t1
, arg1
);
1068 tcg_gen_sari_i64(t2
, t2
, up_shift
);
1070 tcg_gen_add_i64(t3
, t1
, t2
);
1071 tcg_gen_trunc_i64_i32(temp3
, t3
);
1073 tcg_gen_setcondi_i64(TCG_COND_GT
, t1
, t3
, 0x7fffffffLL
);
1074 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t3
, -0x80000000LL
);
1075 tcg_gen_or_i64(t1
, t1
, t2
);
1076 tcg_gen_trunc_i64_i32(cpu_PSW_V
, t1
);
1077 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1078 /* We produce an overflow on the host if the mul before was
1079 (0x80000000 * 0x80000000) << 1). If this is the
1080 case, we negate the ovf. */
1082 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1083 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1084 tcg_gen_and_tl(temp
, temp
, temp2
);
1085 tcg_gen_shli_tl(temp
, temp
, 31);
1086 /* negate v bit, if special condition */
1087 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1090 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1091 /* Calc AV/SAV bits */
1092 tcg_gen_add_tl(cpu_PSW_AV
, temp3
, temp3
);
1093 tcg_gen_xor_tl(cpu_PSW_AV
, temp3
, cpu_PSW_AV
);
1095 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1096 /* write back result */
1097 tcg_gen_mov_tl(ret
, temp3
);
1099 tcg_temp_free(temp
);
1100 tcg_temp_free(temp2
);
1101 tcg_temp_free(temp3
);
1102 tcg_temp_free_i64(t1
);
1103 tcg_temp_free_i64(t2
);
1104 tcg_temp_free_i64(t3
);
1108 gen_m16add32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1110 TCGv temp
= tcg_temp_new();
1111 TCGv temp2
= tcg_temp_new();
1113 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1114 } else { /* n is exspected to be 1 */
1115 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1116 tcg_gen_shli_tl(temp
, temp
, 1);
1117 /* catch special case r1 = r2 = 0x8000 */
1118 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1119 tcg_gen_sub_tl(temp
, temp
, temp2
);
1121 gen_add_d(ret
, arg1
, temp
);
1123 tcg_temp_free(temp
);
1124 tcg_temp_free(temp2
);
1128 gen_m16adds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1130 TCGv temp
= tcg_temp_new();
1131 TCGv temp2
= tcg_temp_new();
1133 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1134 } else { /* n is exspected to be 1 */
1135 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1136 tcg_gen_shli_tl(temp
, temp
, 1);
1137 /* catch special case r1 = r2 = 0x8000 */
1138 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1139 tcg_gen_sub_tl(temp
, temp
, temp2
);
1141 gen_adds(ret
, arg1
, temp
);
1143 tcg_temp_free(temp
);
1144 tcg_temp_free(temp2
);
1148 gen_m16add64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1149 TCGv arg3
, uint32_t n
)
1151 TCGv temp
= tcg_temp_new();
1152 TCGv temp2
= tcg_temp_new();
1153 TCGv_i64 t1
= tcg_temp_new_i64();
1154 TCGv_i64 t2
= tcg_temp_new_i64();
1155 TCGv_i64 t3
= tcg_temp_new_i64();
1158 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1159 } else { /* n is exspected to be 1 */
1160 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1161 tcg_gen_shli_tl(temp
, temp
, 1);
1162 /* catch special case r1 = r2 = 0x8000 */
1163 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1164 tcg_gen_sub_tl(temp
, temp
, temp2
);
1166 tcg_gen_ext_i32_i64(t2
, temp
);
1167 tcg_gen_shli_i64(t2
, t2
, 16);
1168 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1169 gen_add64_d(t3
, t1
, t2
);
1170 /* write back result */
1171 tcg_gen_extr_i64_i32(rl
, rh
, t3
);
1173 tcg_temp_free_i64(t1
);
1174 tcg_temp_free_i64(t2
);
1175 tcg_temp_free_i64(t3
);
1176 tcg_temp_free(temp
);
1177 tcg_temp_free(temp2
);
1181 gen_m16adds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1182 TCGv arg3
, uint32_t n
)
1184 TCGv temp
= tcg_temp_new();
1185 TCGv temp2
= tcg_temp_new();
1186 TCGv_i64 t1
= tcg_temp_new_i64();
1187 TCGv_i64 t2
= tcg_temp_new_i64();
1190 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1191 } else { /* n is exspected to be 1 */
1192 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1193 tcg_gen_shli_tl(temp
, temp
, 1);
1194 /* catch special case r1 = r2 = 0x8000 */
1195 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1196 tcg_gen_sub_tl(temp
, temp
, temp2
);
1198 tcg_gen_ext_i32_i64(t2
, temp
);
1199 tcg_gen_shli_i64(t2
, t2
, 16);
1200 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1202 gen_helper_add64_ssov(t1
, cpu_env
, t1
, t2
);
1203 tcg_gen_extr_i64_i32(rl
, rh
, t1
);
1205 tcg_temp_free(temp
);
1206 tcg_temp_free(temp2
);
1207 tcg_temp_free_i64(t1
);
1208 tcg_temp_free_i64(t2
);
1212 gen_madd64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1213 TCGv arg3
, uint32_t n
, CPUTriCoreState
*env
)
1215 TCGv_i64 t1
= tcg_temp_new_i64();
1216 TCGv_i64 t2
= tcg_temp_new_i64();
1217 TCGv_i64 t3
= tcg_temp_new_i64();
1218 TCGv_i64 t4
= tcg_temp_new_i64();
1221 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1222 tcg_gen_ext_i32_i64(t2
, arg2
);
1223 tcg_gen_ext_i32_i64(t3
, arg3
);
1225 tcg_gen_mul_i64(t2
, t2
, t3
);
1227 tcg_gen_shli_i64(t2
, t2
, 1);
1229 tcg_gen_add_i64(t4
, t1
, t2
);
1231 tcg_gen_xor_i64(t3
, t4
, t1
);
1232 tcg_gen_xor_i64(t2
, t1
, t2
);
1233 tcg_gen_andc_i64(t3
, t3
, t2
);
1234 tcg_gen_trunc_shr_i64_i32(cpu_PSW_V
, t3
, 32);
1235 /* We produce an overflow on the host if the mul before was
1236 (0x80000000 * 0x80000000) << 1). If this is the
1237 case, we negate the ovf. */
1239 temp
= tcg_temp_new();
1240 temp2
= tcg_temp_new();
1241 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1242 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1243 tcg_gen_and_tl(temp
, temp
, temp2
);
1244 tcg_gen_shli_tl(temp
, temp
, 31);
1245 /* negate v bit, if special condition */
1246 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1248 tcg_temp_free(temp
);
1249 tcg_temp_free(temp2
);
1251 /* write back result */
1252 tcg_gen_extr_i64_i32(rl
, rh
, t4
);
1254 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1255 /* Calc AV/SAV bits */
1256 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
1257 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
1259 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1261 tcg_temp_free_i64(t1
);
1262 tcg_temp_free_i64(t2
);
1263 tcg_temp_free_i64(t3
);
1264 tcg_temp_free_i64(t4
);
1268 gen_madds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1271 TCGv_i64 t1
= tcg_temp_new_i64();
1272 TCGv_i64 t2
= tcg_temp_new_i64();
1273 TCGv_i64 t3
= tcg_temp_new_i64();
1275 tcg_gen_ext_i32_i64(t1
, arg1
);
1276 tcg_gen_ext_i32_i64(t2
, arg2
);
1277 tcg_gen_ext_i32_i64(t3
, arg3
);
1279 tcg_gen_mul_i64(t2
, t2
, t3
);
1280 tcg_gen_sari_i64(t2
, t2
, up_shift
- n
);
1282 gen_helper_madd32_q_add_ssov(ret
, cpu_env
, t1
, t2
);
1284 tcg_temp_free_i64(t1
);
1285 tcg_temp_free_i64(t2
);
1286 tcg_temp_free_i64(t3
);
1290 gen_madds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1291 TCGv arg3
, uint32_t n
)
1293 TCGv_i64 r1
= tcg_temp_new_i64();
1294 TCGv temp
= tcg_const_i32(n
);
1296 tcg_gen_concat_i32_i64(r1
, arg1_low
, arg1_high
);
1297 gen_helper_madd64_q_ssov(r1
, cpu_env
, r1
, arg2
, arg3
, temp
);
1298 tcg_gen_extr_i64_i32(rl
, rh
, r1
);
1300 tcg_temp_free_i64(r1
);
1301 tcg_temp_free(temp
);
1303 /* ret = r2 - (r1 * r3); */
1304 static inline void gen_msub32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
1306 TCGv_i64 t1
= tcg_temp_new_i64();
1307 TCGv_i64 t2
= tcg_temp_new_i64();
1308 TCGv_i64 t3
= tcg_temp_new_i64();
1310 tcg_gen_ext_i32_i64(t1
, r1
);
1311 tcg_gen_ext_i32_i64(t2
, r2
);
1312 tcg_gen_ext_i32_i64(t3
, r3
);
1314 tcg_gen_mul_i64(t1
, t1
, t3
);
1315 tcg_gen_sub_i64(t1
, t2
, t1
);
1317 tcg_gen_trunc_i64_i32(ret
, t1
);
1320 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
1321 /* result < -0x80000000 */
1322 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
1323 tcg_gen_or_i64(t2
, t2
, t3
);
1324 tcg_gen_trunc_i64_i32(cpu_PSW_V
, t2
);
1325 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1328 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1329 /* Calc AV/SAV bits */
1330 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1331 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1333 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1335 tcg_temp_free_i64(t1
);
1336 tcg_temp_free_i64(t2
);
1337 tcg_temp_free_i64(t3
);
1340 static inline void gen_msubi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1342 TCGv temp
= tcg_const_i32(con
);
1343 gen_msub32_d(ret
, r1
, r2
, temp
);
1344 tcg_temp_free(temp
);
1348 gen_msub64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1351 TCGv t1
= tcg_temp_new();
1352 TCGv t2
= tcg_temp_new();
1353 TCGv t3
= tcg_temp_new();
1354 TCGv t4
= tcg_temp_new();
1356 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
1357 /* only the sub can overflow */
1358 tcg_gen_sub2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
1360 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
1361 tcg_gen_xor_tl(t1
, r2_high
, t2
);
1362 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
1364 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1365 /* Calc AV/SAV bits */
1366 tcg_gen_add_tl(cpu_PSW_AV
, t4
, t4
);
1367 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
1369 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1370 /* write back the result */
1371 tcg_gen_mov_tl(ret_low
, t3
);
1372 tcg_gen_mov_tl(ret_high
, t4
);
1381 gen_msubi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1384 TCGv temp
= tcg_const_i32(con
);
1385 gen_msub64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1386 tcg_temp_free(temp
);
1390 gen_msubu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1393 TCGv_i64 t1
= tcg_temp_new_i64();
1394 TCGv_i64 t2
= tcg_temp_new_i64();
1395 TCGv_i64 t3
= tcg_temp_new_i64();
1397 tcg_gen_extu_i32_i64(t1
, r1
);
1398 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
1399 tcg_gen_extu_i32_i64(t3
, r3
);
1401 tcg_gen_mul_i64(t1
, t1
, t3
);
1402 tcg_gen_sub_i64(t3
, t2
, t1
);
1403 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t3
);
1404 /* calc V bit, only the sub can overflow, if t1 > t2 */
1405 tcg_gen_setcond_i64(TCG_COND_GTU
, t1
, t1
, t2
);
1406 tcg_gen_trunc_i64_i32(cpu_PSW_V
, t1
);
1407 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1409 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1410 /* Calc AV/SAV bits */
1411 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
1412 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
1414 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1416 tcg_temp_free_i64(t1
);
1417 tcg_temp_free_i64(t2
);
1418 tcg_temp_free_i64(t3
);
1422 gen_msubui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1425 TCGv temp
= tcg_const_i32(con
);
1426 gen_msubu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1427 tcg_temp_free(temp
);
1430 static inline void gen_addi_d(TCGv ret
, TCGv r1
, target_ulong r2
)
1432 TCGv temp
= tcg_const_i32(r2
);
1433 gen_add_d(ret
, r1
, temp
);
1434 tcg_temp_free(temp
);
1436 /* calculate the carry bit too */
1437 static inline void gen_add_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1439 TCGv t0
= tcg_temp_new_i32();
1440 TCGv result
= tcg_temp_new_i32();
1442 tcg_gen_movi_tl(t0
, 0);
1443 /* Addition and set C/V/SV bits */
1444 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, r2
, t0
);
1446 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1447 tcg_gen_xor_tl(t0
, r1
, r2
);
1448 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1450 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1451 /* Calc AV/SAV bits */
1452 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1453 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1455 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1456 /* write back result */
1457 tcg_gen_mov_tl(ret
, result
);
1459 tcg_temp_free(result
);
1463 static inline void gen_addi_CC(TCGv ret
, TCGv r1
, int32_t con
)
1465 TCGv temp
= tcg_const_i32(con
);
1466 gen_add_CC(ret
, r1
, temp
);
1467 tcg_temp_free(temp
);
1470 static inline void gen_addc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1472 TCGv carry
= tcg_temp_new_i32();
1473 TCGv t0
= tcg_temp_new_i32();
1474 TCGv result
= tcg_temp_new_i32();
1476 tcg_gen_movi_tl(t0
, 0);
1477 tcg_gen_setcondi_tl(TCG_COND_NE
, carry
, cpu_PSW_C
, 0);
1478 /* Addition, carry and set C/V/SV bits */
1479 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, carry
, t0
);
1480 tcg_gen_add2_i32(result
, cpu_PSW_C
, result
, cpu_PSW_C
, r2
, t0
);
1482 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1483 tcg_gen_xor_tl(t0
, r1
, r2
);
1484 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1486 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1487 /* Calc AV/SAV bits */
1488 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1489 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1491 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1492 /* write back result */
1493 tcg_gen_mov_tl(ret
, result
);
1495 tcg_temp_free(result
);
1497 tcg_temp_free(carry
);
1500 static inline void gen_addci_CC(TCGv ret
, TCGv r1
, int32_t con
)
1502 TCGv temp
= tcg_const_i32(con
);
1503 gen_addc_CC(ret
, r1
, temp
);
1504 tcg_temp_free(temp
);
1507 static inline void gen_cond_add(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1510 TCGv temp
= tcg_temp_new();
1511 TCGv temp2
= tcg_temp_new();
1512 TCGv result
= tcg_temp_new();
1513 TCGv mask
= tcg_temp_new();
1514 TCGv t0
= tcg_const_i32(0);
1516 /* create mask for sticky bits */
1517 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1518 tcg_gen_shli_tl(mask
, mask
, 31);
1520 tcg_gen_add_tl(result
, r1
, r2
);
1522 tcg_gen_xor_tl(temp
, result
, r1
);
1523 tcg_gen_xor_tl(temp2
, r1
, r2
);
1524 tcg_gen_andc_tl(temp
, temp
, temp2
);
1525 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1527 tcg_gen_and_tl(temp
, temp
, mask
);
1528 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1530 tcg_gen_add_tl(temp
, result
, result
);
1531 tcg_gen_xor_tl(temp
, temp
, result
);
1532 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1534 tcg_gen_and_tl(temp
, temp
, mask
);
1535 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1536 /* write back result */
1537 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1540 tcg_temp_free(temp
);
1541 tcg_temp_free(temp2
);
1542 tcg_temp_free(result
);
1543 tcg_temp_free(mask
);
1546 static inline void gen_condi_add(TCGCond cond
, TCGv r1
, int32_t r2
,
1549 TCGv temp
= tcg_const_i32(r2
);
1550 gen_cond_add(cond
, r1
, temp
, r3
, r4
);
1551 tcg_temp_free(temp
);
1554 static inline void gen_sub_d(TCGv ret
, TCGv r1
, TCGv r2
)
1556 TCGv temp
= tcg_temp_new_i32();
1557 TCGv result
= tcg_temp_new_i32();
1559 tcg_gen_sub_tl(result
, r1
, r2
);
1561 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1562 tcg_gen_xor_tl(temp
, r1
, r2
);
1563 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1565 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1567 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1568 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1570 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1571 /* write back result */
1572 tcg_gen_mov_tl(ret
, result
);
1574 tcg_temp_free(temp
);
1575 tcg_temp_free(result
);
1578 static inline void gen_sub_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1580 TCGv result
= tcg_temp_new();
1581 TCGv temp
= tcg_temp_new();
1583 tcg_gen_sub_tl(result
, r1
, r2
);
1585 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_PSW_C
, r1
, r2
);
1587 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1588 tcg_gen_xor_tl(temp
, r1
, r2
);
1589 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1591 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1593 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1594 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1596 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1597 /* write back result */
1598 tcg_gen_mov_tl(ret
, result
);
1600 tcg_temp_free(result
);
1601 tcg_temp_free(temp
);
1604 static inline void gen_subc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1606 TCGv temp
= tcg_temp_new();
1607 tcg_gen_not_tl(temp
, r2
);
1608 gen_addc_CC(ret
, r1
, temp
);
1609 tcg_temp_free(temp
);
1612 static inline void gen_cond_sub(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1615 TCGv temp
= tcg_temp_new();
1616 TCGv temp2
= tcg_temp_new();
1617 TCGv result
= tcg_temp_new();
1618 TCGv mask
= tcg_temp_new();
1619 TCGv t0
= tcg_const_i32(0);
1621 /* create mask for sticky bits */
1622 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1623 tcg_gen_shli_tl(mask
, mask
, 31);
1625 tcg_gen_sub_tl(result
, r1
, r2
);
1627 tcg_gen_xor_tl(temp
, result
, r1
);
1628 tcg_gen_xor_tl(temp2
, r1
, r2
);
1629 tcg_gen_and_tl(temp
, temp
, temp2
);
1630 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1632 tcg_gen_and_tl(temp
, temp
, mask
);
1633 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1635 tcg_gen_add_tl(temp
, result
, result
);
1636 tcg_gen_xor_tl(temp
, temp
, result
);
1637 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1639 tcg_gen_and_tl(temp
, temp
, mask
);
1640 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1641 /* write back result */
1642 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1645 tcg_temp_free(temp
);
1646 tcg_temp_free(temp2
);
1647 tcg_temp_free(result
);
1648 tcg_temp_free(mask
);
1651 static inline void gen_abs(TCGv ret
, TCGv r1
)
1653 TCGv temp
= tcg_temp_new();
1654 TCGv t0
= tcg_const_i32(0);
1656 tcg_gen_neg_tl(temp
, r1
);
1657 tcg_gen_movcond_tl(TCG_COND_GE
, ret
, r1
, t0
, r1
, temp
);
1658 /* overflow can only happen, if r1 = 0x80000000 */
1659 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, r1
, 0x80000000);
1660 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1662 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1664 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1665 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1667 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1669 tcg_temp_free(temp
);
1673 static inline void gen_absdif(TCGv ret
, TCGv r1
, TCGv r2
)
1675 TCGv temp
= tcg_temp_new_i32();
1676 TCGv result
= tcg_temp_new_i32();
1678 tcg_gen_sub_tl(result
, r1
, r2
);
1679 tcg_gen_sub_tl(temp
, r2
, r1
);
1680 tcg_gen_movcond_tl(TCG_COND_GT
, result
, r1
, r2
, result
, temp
);
1683 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1684 tcg_gen_xor_tl(temp
, result
, r2
);
1685 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_PSW_V
, r1
, r2
, cpu_PSW_V
, temp
);
1686 tcg_gen_xor_tl(temp
, r1
, r2
);
1687 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1689 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1691 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1692 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1694 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1695 /* write back result */
1696 tcg_gen_mov_tl(ret
, result
);
1698 tcg_temp_free(temp
);
1699 tcg_temp_free(result
);
1702 static inline void gen_absdifi(TCGv ret
, TCGv r1
, int32_t con
)
1704 TCGv temp
= tcg_const_i32(con
);
1705 gen_absdif(ret
, r1
, temp
);
1706 tcg_temp_free(temp
);
1709 static inline void gen_absdifsi(TCGv ret
, TCGv r1
, int32_t con
)
1711 TCGv temp
= tcg_const_i32(con
);
1712 gen_helper_absdif_ssov(ret
, cpu_env
, r1
, temp
);
1713 tcg_temp_free(temp
);
1716 static inline void gen_mul_i32s(TCGv ret
, TCGv r1
, TCGv r2
)
1718 TCGv high
= tcg_temp_new();
1719 TCGv low
= tcg_temp_new();
1721 tcg_gen_muls2_tl(low
, high
, r1
, r2
);
1722 tcg_gen_mov_tl(ret
, low
);
1724 tcg_gen_sari_tl(low
, low
, 31);
1725 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_PSW_V
, high
, low
);
1726 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1728 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1730 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1731 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1733 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1735 tcg_temp_free(high
);
1739 static inline void gen_muli_i32s(TCGv ret
, TCGv r1
, int32_t con
)
1741 TCGv temp
= tcg_const_i32(con
);
1742 gen_mul_i32s(ret
, r1
, temp
);
1743 tcg_temp_free(temp
);
1746 static inline void gen_mul_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
1748 tcg_gen_muls2_tl(ret_low
, ret_high
, r1
, r2
);
1750 tcg_gen_movi_tl(cpu_PSW_V
, 0);
1752 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1754 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
1755 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
1757 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1760 static inline void gen_muli_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
1763 TCGv temp
= tcg_const_i32(con
);
1764 gen_mul_i64s(ret_low
, ret_high
, r1
, temp
);
1765 tcg_temp_free(temp
);
1768 static inline void gen_mul_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
1770 tcg_gen_mulu2_tl(ret_low
, ret_high
, r1
, r2
);
1772 tcg_gen_movi_tl(cpu_PSW_V
, 0);
1774 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1776 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
1777 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
1779 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1782 static inline void gen_muli_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
1785 TCGv temp
= tcg_const_i32(con
);
1786 gen_mul_i64u(ret_low
, ret_high
, r1
, temp
);
1787 tcg_temp_free(temp
);
1790 static inline void gen_mulsi_i32(TCGv ret
, TCGv r1
, int32_t con
)
1792 TCGv temp
= tcg_const_i32(con
);
1793 gen_helper_mul_ssov(ret
, cpu_env
, r1
, temp
);
1794 tcg_temp_free(temp
);
1797 static inline void gen_mulsui_i32(TCGv ret
, TCGv r1
, int32_t con
)
1799 TCGv temp
= tcg_const_i32(con
);
1800 gen_helper_mul_suov(ret
, cpu_env
, r1
, temp
);
1801 tcg_temp_free(temp
);
1803 /* gen_maddsi_32(cpu_gpr_d[r4], cpu_gpr_d[r1], cpu_gpr_d[r3], const9); */
1804 static inline void gen_maddsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1806 TCGv temp
= tcg_const_i32(con
);
1807 gen_helper_madd32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
1808 tcg_temp_free(temp
);
1811 static inline void gen_maddsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1813 TCGv temp
= tcg_const_i32(con
);
1814 gen_helper_madd32_suov(ret
, cpu_env
, r1
, r2
, temp
);
1815 tcg_temp_free(temp
);
1819 gen_mul_q(TCGv rl
, TCGv rh
, TCGv arg1
, TCGv arg2
, uint32_t n
, uint32_t up_shift
)
1821 TCGv temp
= tcg_temp_new();
1822 TCGv_i64 temp_64
= tcg_temp_new_i64();
1823 TCGv_i64 temp2_64
= tcg_temp_new_i64();
1826 if (up_shift
== 32) {
1827 tcg_gen_muls2_tl(rh
, rl
, arg1
, arg2
);
1828 } else if (up_shift
== 16) {
1829 tcg_gen_ext_i32_i64(temp_64
, arg1
);
1830 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
1832 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
1833 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
);
1834 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
1836 tcg_gen_muls2_tl(rl
, rh
, arg1
, arg2
);
1839 tcg_gen_movi_tl(cpu_PSW_V
, 0);
1840 } else { /* n is exspected to be 1 */
1841 tcg_gen_ext_i32_i64(temp_64
, arg1
);
1842 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
1844 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
1846 if (up_shift
== 0) {
1847 tcg_gen_shli_i64(temp_64
, temp_64
, 1);
1849 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
- 1);
1851 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
1852 /* overflow only occours if r1 = r2 = 0x8000 */
1853 if (up_shift
== 0) {/* result is 64 bit */
1854 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rh
,
1856 } else { /* result is 32 bit */
1857 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rl
,
1860 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1861 /* calc sv overflow bit */
1862 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1864 /* calc av overflow bit */
1865 if (up_shift
== 0) {
1866 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
1867 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
1869 tcg_gen_add_tl(cpu_PSW_AV
, rl
, rl
);
1870 tcg_gen_xor_tl(cpu_PSW_AV
, rl
, cpu_PSW_AV
);
1872 /* calc sav overflow bit */
1873 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1874 tcg_temp_free(temp
);
1875 tcg_temp_free_i64(temp_64
);
1876 tcg_temp_free_i64(temp2_64
);
1880 gen_mul_q_16(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
1882 TCGv temp
= tcg_temp_new();
1884 tcg_gen_mul_tl(ret
, arg1
, arg2
);
1885 } else { /* n is exspected to be 1 */
1886 tcg_gen_mul_tl(ret
, arg1
, arg2
);
1887 tcg_gen_shli_tl(ret
, ret
, 1);
1888 /* catch special case r1 = r2 = 0x8000 */
1889 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80000000);
1890 tcg_gen_sub_tl(ret
, ret
, temp
);
1893 tcg_gen_movi_tl(cpu_PSW_V
, 0);
1894 /* calc av overflow bit */
1895 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1896 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1897 /* calc sav overflow bit */
1898 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1900 tcg_temp_free(temp
);
1903 static void gen_mulr_q(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
1905 TCGv temp
= tcg_temp_new();
1907 tcg_gen_mul_tl(ret
, arg1
, arg2
);
1908 tcg_gen_addi_tl(ret
, ret
, 0x8000);
1910 tcg_gen_mul_tl(ret
, arg1
, arg2
);
1911 tcg_gen_shli_tl(ret
, ret
, 1);
1912 tcg_gen_addi_tl(ret
, ret
, 0x8000);
1913 /* catch special case r1 = r2 = 0x8000 */
1914 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80008000);
1915 tcg_gen_muli_tl(temp
, temp
, 0x8001);
1916 tcg_gen_sub_tl(ret
, ret
, temp
);
1919 tcg_gen_movi_tl(cpu_PSW_V
, 0);
1920 /* calc av overflow bit */
1921 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1922 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1923 /* calc sav overflow bit */
1924 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1925 /* cut halfword off */
1926 tcg_gen_andi_tl(ret
, ret
, 0xffff0000);
1928 tcg_temp_free(temp
);
1932 gen_madds_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1935 TCGv_i64 temp64
= tcg_temp_new_i64();
1936 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
1937 gen_helper_madd64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
1938 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
1939 tcg_temp_free_i64(temp64
);
1943 gen_maddsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1946 TCGv temp
= tcg_const_i32(con
);
1947 gen_madds_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1948 tcg_temp_free(temp
);
1952 gen_maddsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1955 TCGv_i64 temp64
= tcg_temp_new_i64();
1956 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
1957 gen_helper_madd64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
1958 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
1959 tcg_temp_free_i64(temp64
);
1963 gen_maddsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1966 TCGv temp
= tcg_const_i32(con
);
1967 gen_maddsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1968 tcg_temp_free(temp
);
1971 static inline void gen_msubsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1973 TCGv temp
= tcg_const_i32(con
);
1974 gen_helper_msub32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
1975 tcg_temp_free(temp
);
1978 static inline void gen_msubsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1980 TCGv temp
= tcg_const_i32(con
);
1981 gen_helper_msub32_suov(ret
, cpu_env
, r1
, r2
, temp
);
1982 tcg_temp_free(temp
);
1986 gen_msubs_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1989 TCGv_i64 temp64
= tcg_temp_new_i64();
1990 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
1991 gen_helper_msub64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
1992 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
1993 tcg_temp_free_i64(temp64
);
1997 gen_msubsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2000 TCGv temp
= tcg_const_i32(con
);
2001 gen_msubs_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2002 tcg_temp_free(temp
);
2006 gen_msubsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2009 TCGv_i64 temp64
= tcg_temp_new_i64();
2010 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2011 gen_helper_msub64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
2012 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2013 tcg_temp_free_i64(temp64
);
2017 gen_msubsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2020 TCGv temp
= tcg_const_i32(con
);
2021 gen_msubsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2022 tcg_temp_free(temp
);
2025 static void gen_saturate(TCGv ret
, TCGv arg
, int32_t up
, int32_t low
)
2027 TCGv sat_neg
= tcg_const_i32(low
);
2028 TCGv temp
= tcg_const_i32(up
);
2030 /* sat_neg = (arg < low ) ? low : arg; */
2031 tcg_gen_movcond_tl(TCG_COND_LT
, sat_neg
, arg
, sat_neg
, sat_neg
, arg
);
2033 /* ret = (sat_neg > up ) ? up : sat_neg; */
2034 tcg_gen_movcond_tl(TCG_COND_GT
, ret
, sat_neg
, temp
, temp
, sat_neg
);
2036 tcg_temp_free(sat_neg
);
2037 tcg_temp_free(temp
);
2040 static void gen_saturate_u(TCGv ret
, TCGv arg
, int32_t up
)
2042 TCGv temp
= tcg_const_i32(up
);
2043 /* sat_neg = (arg > up ) ? up : arg; */
2044 tcg_gen_movcond_tl(TCG_COND_GTU
, ret
, arg
, temp
, temp
, arg
);
2045 tcg_temp_free(temp
);
2048 static void gen_shi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2050 if (shift_count
== -32) {
2051 tcg_gen_movi_tl(ret
, 0);
2052 } else if (shift_count
>= 0) {
2053 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2055 tcg_gen_shri_tl(ret
, r1
, -shift_count
);
2059 static void gen_sh_hi(TCGv ret
, TCGv r1
, int32_t shiftcount
)
2061 TCGv temp_low
, temp_high
;
2063 if (shiftcount
== -16) {
2064 tcg_gen_movi_tl(ret
, 0);
2066 temp_high
= tcg_temp_new();
2067 temp_low
= tcg_temp_new();
2069 tcg_gen_andi_tl(temp_low
, r1
, 0xffff);
2070 tcg_gen_andi_tl(temp_high
, r1
, 0xffff0000);
2071 gen_shi(temp_low
, temp_low
, shiftcount
);
2072 gen_shi(ret
, temp_high
, shiftcount
);
2073 tcg_gen_deposit_tl(ret
, ret
, temp_low
, 0, 16);
2075 tcg_temp_free(temp_low
);
2076 tcg_temp_free(temp_high
);
2080 static void gen_shaci(TCGv ret
, TCGv r1
, int32_t shift_count
)
2082 uint32_t msk
, msk_start
;
2083 TCGv temp
= tcg_temp_new();
2084 TCGv temp2
= tcg_temp_new();
2085 TCGv t_0
= tcg_const_i32(0);
2087 if (shift_count
== 0) {
2088 /* Clear PSW.C and PSW.V */
2089 tcg_gen_movi_tl(cpu_PSW_C
, 0);
2090 tcg_gen_mov_tl(cpu_PSW_V
, cpu_PSW_C
);
2091 tcg_gen_mov_tl(ret
, r1
);
2092 } else if (shift_count
== -32) {
2094 tcg_gen_mov_tl(cpu_PSW_C
, r1
);
2095 /* fill ret completly with sign bit */
2096 tcg_gen_sari_tl(ret
, r1
, 31);
2098 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2099 } else if (shift_count
> 0) {
2100 TCGv t_max
= tcg_const_i32(0x7FFFFFFF >> shift_count
);
2101 TCGv t_min
= tcg_const_i32(((int32_t) -0x80000000) >> shift_count
);
2104 msk_start
= 32 - shift_count
;
2105 msk
= ((1 << shift_count
) - 1) << msk_start
;
2106 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2107 /* calc v/sv bits */
2108 tcg_gen_setcond_tl(TCG_COND_GT
, temp
, r1
, t_max
);
2109 tcg_gen_setcond_tl(TCG_COND_LT
, temp2
, r1
, t_min
);
2110 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
2111 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2113 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_V
, cpu_PSW_SV
);
2115 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2117 tcg_temp_free(t_max
);
2118 tcg_temp_free(t_min
);
2121 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2123 msk
= (1 << -shift_count
) - 1;
2124 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2126 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2128 /* calc av overflow bit */
2129 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2130 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2131 /* calc sav overflow bit */
2132 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2134 tcg_temp_free(temp
);
2135 tcg_temp_free(temp2
);
2139 static void gen_shas(TCGv ret
, TCGv r1
, TCGv r2
)
2141 gen_helper_sha_ssov(ret
, cpu_env
, r1
, r2
);
2144 static void gen_shasi(TCGv ret
, TCGv r1
, int32_t con
)
2146 TCGv temp
= tcg_const_i32(con
);
2147 gen_shas(ret
, r1
, temp
);
2148 tcg_temp_free(temp
);
2151 static void gen_sha_hi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2155 if (shift_count
== 0) {
2156 tcg_gen_mov_tl(ret
, r1
);
2157 } else if (shift_count
> 0) {
2158 low
= tcg_temp_new();
2159 high
= tcg_temp_new();
2161 tcg_gen_andi_tl(high
, r1
, 0xffff0000);
2162 tcg_gen_shli_tl(low
, r1
, shift_count
);
2163 tcg_gen_shli_tl(ret
, high
, shift_count
);
2164 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2167 tcg_temp_free(high
);
2169 low
= tcg_temp_new();
2170 high
= tcg_temp_new();
2172 tcg_gen_ext16s_tl(low
, r1
);
2173 tcg_gen_sari_tl(low
, low
, -shift_count
);
2174 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2175 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2178 tcg_temp_free(high
);
2183 /* ret = {ret[30:0], (r1 cond r2)}; */
2184 static void gen_sh_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
)
2186 TCGv temp
= tcg_temp_new();
2187 TCGv temp2
= tcg_temp_new();
2189 tcg_gen_shli_tl(temp
, ret
, 1);
2190 tcg_gen_setcond_tl(cond
, temp2
, r1
, r2
);
2191 tcg_gen_or_tl(ret
, temp
, temp2
);
2193 tcg_temp_free(temp
);
2194 tcg_temp_free(temp2
);
2197 static void gen_sh_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
)
2199 TCGv temp
= tcg_const_i32(con
);
2200 gen_sh_cond(cond
, ret
, r1
, temp
);
2201 tcg_temp_free(temp
);
2204 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
)
2206 gen_helper_add_ssov(ret
, cpu_env
, r1
, r2
);
2209 static inline void gen_addsi(TCGv ret
, TCGv r1
, int32_t con
)
2211 TCGv temp
= tcg_const_i32(con
);
2212 gen_helper_add_ssov(ret
, cpu_env
, r1
, temp
);
2213 tcg_temp_free(temp
);
2216 static inline void gen_addsui(TCGv ret
, TCGv r1
, int32_t con
)
2218 TCGv temp
= tcg_const_i32(con
);
2219 gen_helper_add_suov(ret
, cpu_env
, r1
, temp
);
2220 tcg_temp_free(temp
);
2223 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
)
2225 gen_helper_sub_ssov(ret
, cpu_env
, r1
, r2
);
2228 static inline void gen_subsu(TCGv ret
, TCGv r1
, TCGv r2
)
2230 gen_helper_sub_suov(ret
, cpu_env
, r1
, r2
);
2233 static inline void gen_bit_2op(TCGv ret
, TCGv r1
, TCGv r2
,
2235 void(*op1
)(TCGv
, TCGv
, TCGv
),
2236 void(*op2
)(TCGv
, TCGv
, TCGv
))
2240 temp1
= tcg_temp_new();
2241 temp2
= tcg_temp_new();
2243 tcg_gen_shri_tl(temp2
, r2
, pos2
);
2244 tcg_gen_shri_tl(temp1
, r1
, pos1
);
2246 (*op1
)(temp1
, temp1
, temp2
);
2247 (*op2
)(temp1
, ret
, temp1
);
2249 tcg_gen_deposit_tl(ret
, ret
, temp1
, 0, 1);
2251 tcg_temp_free(temp1
);
2252 tcg_temp_free(temp2
);
2255 /* ret = r1[pos1] op1 r2[pos2]; */
2256 static inline void gen_bit_1op(TCGv ret
, TCGv r1
, TCGv r2
,
2258 void(*op1
)(TCGv
, TCGv
, TCGv
))
2262 temp1
= tcg_temp_new();
2263 temp2
= tcg_temp_new();
2265 tcg_gen_shri_tl(temp2
, r2
, pos2
);
2266 tcg_gen_shri_tl(temp1
, r1
, pos1
);
2268 (*op1
)(ret
, temp1
, temp2
);
2270 tcg_gen_andi_tl(ret
, ret
, 0x1);
2272 tcg_temp_free(temp1
);
2273 tcg_temp_free(temp2
);
2276 static inline void gen_accumulating_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
,
2277 void(*op
)(TCGv
, TCGv
, TCGv
))
2279 TCGv temp
= tcg_temp_new();
2280 TCGv temp2
= tcg_temp_new();
2281 /* temp = (arg1 cond arg2 )*/
2282 tcg_gen_setcond_tl(cond
, temp
, r1
, r2
);
2284 tcg_gen_andi_tl(temp2
, ret
, 0x1);
2285 /* temp = temp insn temp2 */
2286 (*op
)(temp
, temp
, temp2
);
2287 /* ret = {ret[31:1], temp} */
2288 tcg_gen_deposit_tl(ret
, ret
, temp
, 0, 1);
2290 tcg_temp_free(temp
);
2291 tcg_temp_free(temp2
);
2295 gen_accumulating_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
,
2296 void(*op
)(TCGv
, TCGv
, TCGv
))
2298 TCGv temp
= tcg_const_i32(con
);
2299 gen_accumulating_cond(cond
, ret
, r1
, temp
, op
);
2300 tcg_temp_free(temp
);
2303 /* ret = (r1 cond r2) ? 0xFFFFFFFF ? 0x00000000;*/
2304 static inline void gen_cond_w(TCGCond cond
, TCGv ret
, TCGv r1
, TCGv r2
)
2306 tcg_gen_setcond_tl(cond
, ret
, r1
, r2
);
2307 tcg_gen_neg_tl(ret
, ret
);
2310 static inline void gen_eqany_bi(TCGv ret
, TCGv r1
, int32_t con
)
2312 TCGv b0
= tcg_temp_new();
2313 TCGv b1
= tcg_temp_new();
2314 TCGv b2
= tcg_temp_new();
2315 TCGv b3
= tcg_temp_new();
2318 tcg_gen_andi_tl(b0
, r1
, 0xff);
2319 tcg_gen_setcondi_tl(TCG_COND_EQ
, b0
, b0
, con
& 0xff);
2322 tcg_gen_andi_tl(b1
, r1
, 0xff00);
2323 tcg_gen_setcondi_tl(TCG_COND_EQ
, b1
, b1
, con
& 0xff00);
2326 tcg_gen_andi_tl(b2
, r1
, 0xff0000);
2327 tcg_gen_setcondi_tl(TCG_COND_EQ
, b2
, b2
, con
& 0xff0000);
2330 tcg_gen_andi_tl(b3
, r1
, 0xff000000);
2331 tcg_gen_setcondi_tl(TCG_COND_EQ
, b3
, b3
, con
& 0xff000000);
2334 tcg_gen_or_tl(ret
, b0
, b1
);
2335 tcg_gen_or_tl(ret
, ret
, b2
);
2336 tcg_gen_or_tl(ret
, ret
, b3
);
2344 static inline void gen_eqany_hi(TCGv ret
, TCGv r1
, int32_t con
)
2346 TCGv h0
= tcg_temp_new();
2347 TCGv h1
= tcg_temp_new();
2350 tcg_gen_andi_tl(h0
, r1
, 0xffff);
2351 tcg_gen_setcondi_tl(TCG_COND_EQ
, h0
, h0
, con
& 0xffff);
2354 tcg_gen_andi_tl(h1
, r1
, 0xffff0000);
2355 tcg_gen_setcondi_tl(TCG_COND_EQ
, h1
, h1
, con
& 0xffff0000);
2358 tcg_gen_or_tl(ret
, h0
, h1
);
2363 /* mask = ((1 << width) -1) << pos;
2364 ret = (r1 & ~mask) | (r2 << pos) & mask); */
2365 static inline void gen_insert(TCGv ret
, TCGv r1
, TCGv r2
, TCGv width
, TCGv pos
)
2367 TCGv mask
= tcg_temp_new();
2368 TCGv temp
= tcg_temp_new();
2369 TCGv temp2
= tcg_temp_new();
2371 tcg_gen_movi_tl(mask
, 1);
2372 tcg_gen_shl_tl(mask
, mask
, width
);
2373 tcg_gen_subi_tl(mask
, mask
, 1);
2374 tcg_gen_shl_tl(mask
, mask
, pos
);
2376 tcg_gen_shl_tl(temp
, r2
, pos
);
2377 tcg_gen_and_tl(temp
, temp
, mask
);
2378 tcg_gen_andc_tl(temp2
, r1
, mask
);
2379 tcg_gen_or_tl(ret
, temp
, temp2
);
2381 tcg_temp_free(mask
);
2382 tcg_temp_free(temp
);
2383 tcg_temp_free(temp2
);
2386 static inline void gen_bsplit(TCGv rl
, TCGv rh
, TCGv r1
)
2388 TCGv_i64 temp
= tcg_temp_new_i64();
2390 gen_helper_bsplit(temp
, r1
);
2391 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
2393 tcg_temp_free_i64(temp
);
2396 static inline void gen_unpack(TCGv rl
, TCGv rh
, TCGv r1
)
2398 TCGv_i64 temp
= tcg_temp_new_i64();
2400 gen_helper_unpack(temp
, r1
);
2401 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
2403 tcg_temp_free_i64(temp
);
2407 gen_dvinit_b(CPUTriCoreState
*env
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
2409 TCGv_i64 ret
= tcg_temp_new_i64();
2411 if (!tricore_feature(env
, TRICORE_FEATURE_131
)) {
2412 gen_helper_dvinit_b_13(ret
, cpu_env
, r1
, r2
);
2414 gen_helper_dvinit_b_131(ret
, cpu_env
, r1
, r2
);
2416 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
2418 tcg_temp_free_i64(ret
);
2422 gen_dvinit_h(CPUTriCoreState
*env
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
2424 TCGv_i64 ret
= tcg_temp_new_i64();
2426 if (!tricore_feature(env
, TRICORE_FEATURE_131
)) {
2427 gen_helper_dvinit_h_13(ret
, cpu_env
, r1
, r2
);
2429 gen_helper_dvinit_h_131(ret
, cpu_env
, r1
, r2
);
2431 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
2433 tcg_temp_free_i64(ret
);
2436 static void gen_calc_usb_mul_h(TCGv arg_low
, TCGv arg_high
)
2438 TCGv temp
= tcg_temp_new();
2440 tcg_gen_add_tl(temp
, arg_low
, arg_low
);
2441 tcg_gen_xor_tl(temp
, temp
, arg_low
);
2442 tcg_gen_add_tl(cpu_PSW_AV
, arg_high
, arg_high
);
2443 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, arg_high
);
2444 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
2446 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2447 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2448 tcg_temp_free(temp
);
2451 static void gen_calc_usb_mulr_h(TCGv arg
)
2453 TCGv temp
= tcg_temp_new();
2455 tcg_gen_add_tl(temp
, arg
, arg
);
2456 tcg_gen_xor_tl(temp
, temp
, arg
);
2457 tcg_gen_shli_tl(cpu_PSW_AV
, temp
, 16);
2458 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
2460 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2462 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2463 tcg_temp_free(temp
);
2466 /* helpers for generating program flow micro-ops */
2468 static inline void gen_save_pc(target_ulong pc
)
2470 tcg_gen_movi_tl(cpu_PC
, pc
);
2473 static inline void gen_goto_tb(DisasContext
*ctx
, int n
, target_ulong dest
)
2475 TranslationBlock
*tb
;
2477 if ((tb
->pc
& TARGET_PAGE_MASK
) == (dest
& TARGET_PAGE_MASK
) &&
2478 likely(!ctx
->singlestep_enabled
)) {
2481 tcg_gen_exit_tb((uintptr_t)tb
+ n
);
2484 if (ctx
->singlestep_enabled
) {
2485 /* raise exception debug */
2491 static inline void gen_branch_cond(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
2492 TCGv r2
, int16_t address
)
2494 TCGLabel
*jumpLabel
= gen_new_label();
2495 tcg_gen_brcond_tl(cond
, r1
, r2
, jumpLabel
);
2497 gen_goto_tb(ctx
, 1, ctx
->next_pc
);
2499 gen_set_label(jumpLabel
);
2500 gen_goto_tb(ctx
, 0, ctx
->pc
+ address
* 2);
2503 static inline void gen_branch_condi(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
2504 int r2
, int16_t address
)
2506 TCGv temp
= tcg_const_i32(r2
);
2507 gen_branch_cond(ctx
, cond
, r1
, temp
, address
);
2508 tcg_temp_free(temp
);
2511 static void gen_loop(DisasContext
*ctx
, int r1
, int32_t offset
)
2513 TCGLabel
*l1
= gen_new_label();
2515 tcg_gen_subi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], 1);
2516 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr_a
[r1
], -1, l1
);
2517 gen_goto_tb(ctx
, 1, ctx
->pc
+ offset
);
2519 gen_goto_tb(ctx
, 0, ctx
->next_pc
);
2522 static void gen_compute_branch(DisasContext
*ctx
, uint32_t opc
, int r1
,
2523 int r2
, int32_t constant
, int32_t offset
)
2529 /* SB-format jumps */
2532 gen_goto_tb(ctx
, 0, ctx
->pc
+ offset
* 2);
2534 case OPC1_32_B_CALL
:
2535 case OPC1_16_SB_CALL
:
2536 gen_helper_1arg(call
, ctx
->next_pc
);
2537 gen_goto_tb(ctx
, 0, ctx
->pc
+ offset
* 2);
2540 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], 0, offset
);
2542 case OPC1_16_SB_JNZ
:
2543 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], 0, offset
);
2545 /* SBC-format jumps */
2546 case OPC1_16_SBC_JEQ
:
2547 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], constant
, offset
);
2549 case OPC1_16_SBC_JNE
:
2550 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], constant
, offset
);
2552 /* SBRN-format jumps */
2553 case OPC1_16_SBRN_JZ_T
:
2554 temp
= tcg_temp_new();
2555 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
2556 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
2557 tcg_temp_free(temp
);
2559 case OPC1_16_SBRN_JNZ_T
:
2560 temp
= tcg_temp_new();
2561 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
2562 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
2563 tcg_temp_free(temp
);
2565 /* SBR-format jumps */
2566 case OPC1_16_SBR_JEQ
:
2567 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2570 case OPC1_16_SBR_JNE
:
2571 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2574 case OPC1_16_SBR_JNZ
:
2575 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], 0, offset
);
2577 case OPC1_16_SBR_JNZ_A
:
2578 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
2580 case OPC1_16_SBR_JGEZ
:
2581 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], 0, offset
);
2583 case OPC1_16_SBR_JGTZ
:
2584 gen_branch_condi(ctx
, TCG_COND_GT
, cpu_gpr_d
[r1
], 0, offset
);
2586 case OPC1_16_SBR_JLEZ
:
2587 gen_branch_condi(ctx
, TCG_COND_LE
, cpu_gpr_d
[r1
], 0, offset
);
2589 case OPC1_16_SBR_JLTZ
:
2590 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], 0, offset
);
2592 case OPC1_16_SBR_JZ
:
2593 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], 0, offset
);
2595 case OPC1_16_SBR_JZ_A
:
2596 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
2598 case OPC1_16_SBR_LOOP
:
2599 gen_loop(ctx
, r1
, offset
* 2 - 32);
2601 /* SR-format jumps */
2603 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], 0xfffffffe);
2606 case OPC2_16_SR_RET
:
2607 gen_helper_ret(cpu_env
);
2611 case OPC1_32_B_CALLA
:
2612 gen_helper_1arg(call
, ctx
->next_pc
);
2613 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
2616 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->next_pc
);
2619 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
2622 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->next_pc
);
2623 gen_goto_tb(ctx
, 0, ctx
->pc
+ offset
* 2);
2626 case OPCM_32_BRC_EQ_NEQ
:
2627 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JEQ
) {
2628 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], constant
, offset
);
2630 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], constant
, offset
);
2633 case OPCM_32_BRC_GE
:
2634 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OP2_32_BRC_JGE
) {
2635 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], constant
, offset
);
2637 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
2638 gen_branch_condi(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], constant
,
2642 case OPCM_32_BRC_JLT
:
2643 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JLT
) {
2644 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], constant
, offset
);
2646 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
2647 gen_branch_condi(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], constant
,
2651 case OPCM_32_BRC_JNE
:
2652 temp
= tcg_temp_new();
2653 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JNED
) {
2654 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
2655 /* subi is unconditional */
2656 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
2657 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
2659 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
2660 /* addi is unconditional */
2661 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
2662 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
2664 tcg_temp_free(temp
);
2667 case OPCM_32_BRN_JTT
:
2668 n
= MASK_OP_BRN_N(ctx
->opcode
);
2670 temp
= tcg_temp_new();
2671 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r1
], (1 << n
));
2673 if (MASK_OP_BRN_OP2(ctx
->opcode
) == OPC2_32_BRN_JNZ_T
) {
2674 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
2676 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
2678 tcg_temp_free(temp
);
2681 case OPCM_32_BRR_EQ_NEQ
:
2682 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ
) {
2683 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2686 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2690 case OPCM_32_BRR_ADDR_EQ_NEQ
:
2691 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ_A
) {
2692 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
2695 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
2699 case OPCM_32_BRR_GE
:
2700 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JGE
) {
2701 gen_branch_cond(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2704 gen_branch_cond(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2708 case OPCM_32_BRR_JLT
:
2709 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JLT
) {
2710 gen_branch_cond(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2713 gen_branch_cond(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
2717 case OPCM_32_BRR_LOOP
:
2718 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_LOOP
) {
2719 gen_loop(ctx
, r1
, offset
* 2);
2721 /* OPC2_32_BRR_LOOPU */
2722 gen_goto_tb(ctx
, 0, ctx
->pc
+ offset
* 2);
2725 case OPCM_32_BRR_JNE
:
2726 temp
= tcg_temp_new();
2727 temp2
= tcg_temp_new();
2728 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRR_JNED
) {
2729 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
2730 /* also save r2, in case of r1 == r2, so r2 is not decremented */
2731 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
2732 /* subi is unconditional */
2733 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
2734 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
2736 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
2737 /* also save r2, in case of r1 == r2, so r2 is not decremented */
2738 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
2739 /* addi is unconditional */
2740 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
2741 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
2743 tcg_temp_free(temp
);
2744 tcg_temp_free(temp2
);
2746 case OPCM_32_BRR_JNZ
:
2747 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JNZ_A
) {
2748 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
2750 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
2754 printf("Branch Error at %x\n", ctx
->pc
);
2756 ctx
->bstate
= BS_BRANCH
;
2761 * Functions for decoding instructions
2764 static void decode_src_opc(DisasContext
*ctx
, int op1
)
2770 r1
= MASK_OP_SRC_S1D(ctx
->opcode
);
2771 const4
= MASK_OP_SRC_CONST4_SEXT(ctx
->opcode
);
2774 case OPC1_16_SRC_ADD
:
2775 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
2777 case OPC1_16_SRC_ADD_A15
:
2778 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], const4
);
2780 case OPC1_16_SRC_ADD_15A
:
2781 gen_addi_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], const4
);
2783 case OPC1_16_SRC_ADD_A
:
2784 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], const4
);
2786 case OPC1_16_SRC_CADD
:
2787 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
2790 case OPC1_16_SRC_CADDN
:
2791 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
2794 case OPC1_16_SRC_CMOV
:
2795 temp
= tcg_const_tl(0);
2796 temp2
= tcg_const_tl(const4
);
2797 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
2798 temp2
, cpu_gpr_d
[r1
]);
2799 tcg_temp_free(temp
);
2800 tcg_temp_free(temp2
);
2802 case OPC1_16_SRC_CMOVN
:
2803 temp
= tcg_const_tl(0);
2804 temp2
= tcg_const_tl(const4
);
2805 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
2806 temp2
, cpu_gpr_d
[r1
]);
2807 tcg_temp_free(temp
);
2808 tcg_temp_free(temp2
);
2810 case OPC1_16_SRC_EQ
:
2811 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
2814 case OPC1_16_SRC_LT
:
2815 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
2818 case OPC1_16_SRC_MOV
:
2819 tcg_gen_movi_tl(cpu_gpr_d
[r1
], const4
);
2821 case OPC1_16_SRC_MOV_A
:
2822 const4
= MASK_OP_SRC_CONST4(ctx
->opcode
);
2823 tcg_gen_movi_tl(cpu_gpr_a
[r1
], const4
);
2825 case OPC1_16_SRC_SH
:
2826 gen_shi(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
2828 case OPC1_16_SRC_SHA
:
2829 gen_shaci(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
2834 static void decode_srr_opc(DisasContext
*ctx
, int op1
)
2839 r1
= MASK_OP_SRR_S1D(ctx
->opcode
);
2840 r2
= MASK_OP_SRR_S2(ctx
->opcode
);
2843 case OPC1_16_SRR_ADD
:
2844 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2846 case OPC1_16_SRR_ADD_A15
:
2847 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
2849 case OPC1_16_SRR_ADD_15A
:
2850 gen_add_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2852 case OPC1_16_SRR_ADD_A
:
2853 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
2855 case OPC1_16_SRR_ADDS
:
2856 gen_adds(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2858 case OPC1_16_SRR_AND
:
2859 tcg_gen_and_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2861 case OPC1_16_SRR_CMOV
:
2862 temp
= tcg_const_tl(0);
2863 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
2864 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
2865 tcg_temp_free(temp
);
2867 case OPC1_16_SRR_CMOVN
:
2868 temp
= tcg_const_tl(0);
2869 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
2870 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
2871 tcg_temp_free(temp
);
2873 case OPC1_16_SRR_EQ
:
2874 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
2877 case OPC1_16_SRR_LT
:
2878 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
2881 case OPC1_16_SRR_MOV
:
2882 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2884 case OPC1_16_SRR_MOV_A
:
2885 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_d
[r2
]);
2887 case OPC1_16_SRR_MOV_AA
:
2888 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
2890 case OPC1_16_SRR_MOV_D
:
2891 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
]);
2893 case OPC1_16_SRR_MUL
:
2894 gen_mul_i32s(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2896 case OPC1_16_SRR_OR
:
2897 tcg_gen_or_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2899 case OPC1_16_SRR_SUB
:
2900 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2902 case OPC1_16_SRR_SUB_A15B
:
2903 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
2905 case OPC1_16_SRR_SUB_15AB
:
2906 gen_sub_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2908 case OPC1_16_SRR_SUBS
:
2909 gen_subs(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2911 case OPC1_16_SRR_XOR
:
2912 tcg_gen_xor_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
2917 static void decode_ssr_opc(DisasContext
*ctx
, int op1
)
2921 r1
= MASK_OP_SSR_S1(ctx
->opcode
);
2922 r2
= MASK_OP_SSR_S2(ctx
->opcode
);
2925 case OPC1_16_SSR_ST_A
:
2926 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
2928 case OPC1_16_SSR_ST_A_POSTINC
:
2929 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
2930 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
2932 case OPC1_16_SSR_ST_B
:
2933 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
2935 case OPC1_16_SSR_ST_B_POSTINC
:
2936 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
2937 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
2939 case OPC1_16_SSR_ST_H
:
2940 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
2942 case OPC1_16_SSR_ST_H_POSTINC
:
2943 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
2944 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
2946 case OPC1_16_SSR_ST_W
:
2947 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
2949 case OPC1_16_SSR_ST_W_POSTINC
:
2950 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
2951 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
2956 static void decode_sc_opc(DisasContext
*ctx
, int op1
)
2960 const16
= MASK_OP_SC_CONST8(ctx
->opcode
);
2963 case OPC1_16_SC_AND
:
2964 tcg_gen_andi_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
2966 case OPC1_16_SC_BISR
:
2967 gen_helper_1arg(bisr
, const16
& 0xff);
2969 case OPC1_16_SC_LD_A
:
2970 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
2972 case OPC1_16_SC_LD_W
:
2973 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
2975 case OPC1_16_SC_MOV
:
2976 tcg_gen_movi_tl(cpu_gpr_d
[15], const16
);
2979 tcg_gen_ori_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
2981 case OPC1_16_SC_ST_A
:
2982 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
2984 case OPC1_16_SC_ST_W
:
2985 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
2987 case OPC1_16_SC_SUB_A
:
2988 tcg_gen_subi_tl(cpu_gpr_a
[10], cpu_gpr_a
[10], const16
);
2993 static void decode_slr_opc(DisasContext
*ctx
, int op1
)
2997 r1
= MASK_OP_SLR_D(ctx
->opcode
);
2998 r2
= MASK_OP_SLR_S2(ctx
->opcode
);
3002 case OPC1_16_SLR_LD_A
:
3003 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3005 case OPC1_16_SLR_LD_A_POSTINC
:
3006 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3007 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3009 case OPC1_16_SLR_LD_BU
:
3010 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3012 case OPC1_16_SLR_LD_BU_POSTINC
:
3013 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3014 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
3016 case OPC1_16_SLR_LD_H
:
3017 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3019 case OPC1_16_SLR_LD_H_POSTINC
:
3020 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3021 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
3023 case OPC1_16_SLR_LD_W
:
3024 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3026 case OPC1_16_SLR_LD_W_POSTINC
:
3027 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3028 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3033 static void decode_sro_opc(DisasContext
*ctx
, int op1
)
3038 r2
= MASK_OP_SRO_S2(ctx
->opcode
);
3039 address
= MASK_OP_SRO_OFF4(ctx
->opcode
);
3043 case OPC1_16_SRO_LD_A
:
3044 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3046 case OPC1_16_SRO_LD_BU
:
3047 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3049 case OPC1_16_SRO_LD_H
:
3050 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_LESW
);
3052 case OPC1_16_SRO_LD_W
:
3053 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3055 case OPC1_16_SRO_ST_A
:
3056 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3058 case OPC1_16_SRO_ST_B
:
3059 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3061 case OPC1_16_SRO_ST_H
:
3062 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 2, MO_LESW
);
3064 case OPC1_16_SRO_ST_W
:
3065 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3070 static void decode_sr_system(CPUTriCoreState
*env
, DisasContext
*ctx
)
3073 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3076 case OPC2_16_SR_NOP
:
3078 case OPC2_16_SR_RET
:
3079 gen_compute_branch(ctx
, op2
, 0, 0, 0, 0);
3081 case OPC2_16_SR_RFE
:
3082 gen_helper_rfe(cpu_env
);
3084 ctx
->bstate
= BS_BRANCH
;
3086 case OPC2_16_SR_DEBUG
:
3087 /* raise EXCP_DEBUG */
3092 static void decode_sr_accu(CPUTriCoreState
*env
, DisasContext
*ctx
)
3098 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3099 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3102 case OPC2_16_SR_RSUB
:
3103 /* overflow only if r1 = -0x80000000 */
3104 temp
= tcg_const_i32(-0x80000000);
3106 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r1
], temp
);
3107 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
3109 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
3111 tcg_gen_neg_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3113 tcg_gen_add_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3114 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_PSW_AV
);
3116 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
3117 tcg_temp_free(temp
);
3119 case OPC2_16_SR_SAT_B
:
3120 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7f, -0x80);
3122 case OPC2_16_SR_SAT_BU
:
3123 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xff);
3125 case OPC2_16_SR_SAT_H
:
3126 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
3128 case OPC2_16_SR_SAT_HU
:
3129 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xffff);
3134 static void decode_16Bit_opc(CPUTriCoreState
*env
, DisasContext
*ctx
)
3142 op1
= MASK_OP_MAJOR(ctx
->opcode
);
3144 /* handle ADDSC.A opcode only being 6 bit long */
3145 if (unlikely((op1
& 0x3f) == OPC1_16_SRRS_ADDSC_A
)) {
3146 op1
= OPC1_16_SRRS_ADDSC_A
;
3150 case OPC1_16_SRC_ADD
:
3151 case OPC1_16_SRC_ADD_A15
:
3152 case OPC1_16_SRC_ADD_15A
:
3153 case OPC1_16_SRC_ADD_A
:
3154 case OPC1_16_SRC_CADD
:
3155 case OPC1_16_SRC_CADDN
:
3156 case OPC1_16_SRC_CMOV
:
3157 case OPC1_16_SRC_CMOVN
:
3158 case OPC1_16_SRC_EQ
:
3159 case OPC1_16_SRC_LT
:
3160 case OPC1_16_SRC_MOV
:
3161 case OPC1_16_SRC_MOV_A
:
3162 case OPC1_16_SRC_SH
:
3163 case OPC1_16_SRC_SHA
:
3164 decode_src_opc(ctx
, op1
);
3167 case OPC1_16_SRR_ADD
:
3168 case OPC1_16_SRR_ADD_A15
:
3169 case OPC1_16_SRR_ADD_15A
:
3170 case OPC1_16_SRR_ADD_A
:
3171 case OPC1_16_SRR_ADDS
:
3172 case OPC1_16_SRR_AND
:
3173 case OPC1_16_SRR_CMOV
:
3174 case OPC1_16_SRR_CMOVN
:
3175 case OPC1_16_SRR_EQ
:
3176 case OPC1_16_SRR_LT
:
3177 case OPC1_16_SRR_MOV
:
3178 case OPC1_16_SRR_MOV_A
:
3179 case OPC1_16_SRR_MOV_AA
:
3180 case OPC1_16_SRR_MOV_D
:
3181 case OPC1_16_SRR_MUL
:
3182 case OPC1_16_SRR_OR
:
3183 case OPC1_16_SRR_SUB
:
3184 case OPC1_16_SRR_SUB_A15B
:
3185 case OPC1_16_SRR_SUB_15AB
:
3186 case OPC1_16_SRR_SUBS
:
3187 case OPC1_16_SRR_XOR
:
3188 decode_srr_opc(ctx
, op1
);
3191 case OPC1_16_SSR_ST_A
:
3192 case OPC1_16_SSR_ST_A_POSTINC
:
3193 case OPC1_16_SSR_ST_B
:
3194 case OPC1_16_SSR_ST_B_POSTINC
:
3195 case OPC1_16_SSR_ST_H
:
3196 case OPC1_16_SSR_ST_H_POSTINC
:
3197 case OPC1_16_SSR_ST_W
:
3198 case OPC1_16_SSR_ST_W_POSTINC
:
3199 decode_ssr_opc(ctx
, op1
);
3202 case OPC1_16_SRRS_ADDSC_A
:
3203 r2
= MASK_OP_SRRS_S2(ctx
->opcode
);
3204 r1
= MASK_OP_SRRS_S1D(ctx
->opcode
);
3205 const16
= MASK_OP_SRRS_N(ctx
->opcode
);
3206 temp
= tcg_temp_new();
3207 tcg_gen_shli_tl(temp
, cpu_gpr_d
[15], const16
);
3208 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], temp
);
3209 tcg_temp_free(temp
);
3212 case OPC1_16_SLRO_LD_A
:
3213 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3214 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3215 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3217 case OPC1_16_SLRO_LD_BU
:
3218 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3219 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3220 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
3222 case OPC1_16_SLRO_LD_H
:
3223 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3224 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3225 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
3227 case OPC1_16_SLRO_LD_W
:
3228 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3229 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3230 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3233 case OPC1_16_SB_CALL
:
3235 case OPC1_16_SB_JNZ
:
3237 address
= MASK_OP_SB_DISP8_SEXT(ctx
->opcode
);
3238 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
3241 case OPC1_16_SBC_JEQ
:
3242 case OPC1_16_SBC_JNE
:
3243 address
= MASK_OP_SBC_DISP4(ctx
->opcode
);
3244 const16
= MASK_OP_SBC_CONST4_SEXT(ctx
->opcode
);
3245 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
3248 case OPC1_16_SBRN_JNZ_T
:
3249 case OPC1_16_SBRN_JZ_T
:
3250 address
= MASK_OP_SBRN_DISP4(ctx
->opcode
);
3251 const16
= MASK_OP_SBRN_N(ctx
->opcode
);
3252 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
3255 case OPC1_16_SBR_JEQ
:
3256 case OPC1_16_SBR_JGEZ
:
3257 case OPC1_16_SBR_JGTZ
:
3258 case OPC1_16_SBR_JLEZ
:
3259 case OPC1_16_SBR_JLTZ
:
3260 case OPC1_16_SBR_JNE
:
3261 case OPC1_16_SBR_JNZ
:
3262 case OPC1_16_SBR_JNZ_A
:
3263 case OPC1_16_SBR_JZ
:
3264 case OPC1_16_SBR_JZ_A
:
3265 case OPC1_16_SBR_LOOP
:
3266 r1
= MASK_OP_SBR_S2(ctx
->opcode
);
3267 address
= MASK_OP_SBR_DISP4(ctx
->opcode
);
3268 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
3271 case OPC1_16_SC_AND
:
3272 case OPC1_16_SC_BISR
:
3273 case OPC1_16_SC_LD_A
:
3274 case OPC1_16_SC_LD_W
:
3275 case OPC1_16_SC_MOV
:
3277 case OPC1_16_SC_ST_A
:
3278 case OPC1_16_SC_ST_W
:
3279 case OPC1_16_SC_SUB_A
:
3280 decode_sc_opc(ctx
, op1
);
3283 case OPC1_16_SLR_LD_A
:
3284 case OPC1_16_SLR_LD_A_POSTINC
:
3285 case OPC1_16_SLR_LD_BU
:
3286 case OPC1_16_SLR_LD_BU_POSTINC
:
3287 case OPC1_16_SLR_LD_H
:
3288 case OPC1_16_SLR_LD_H_POSTINC
:
3289 case OPC1_16_SLR_LD_W
:
3290 case OPC1_16_SLR_LD_W_POSTINC
:
3291 decode_slr_opc(ctx
, op1
);
3294 case OPC1_16_SRO_LD_A
:
3295 case OPC1_16_SRO_LD_BU
:
3296 case OPC1_16_SRO_LD_H
:
3297 case OPC1_16_SRO_LD_W
:
3298 case OPC1_16_SRO_ST_A
:
3299 case OPC1_16_SRO_ST_B
:
3300 case OPC1_16_SRO_ST_H
:
3301 case OPC1_16_SRO_ST_W
:
3302 decode_sro_opc(ctx
, op1
);
3305 case OPC1_16_SSRO_ST_A
:
3306 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3307 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3308 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3310 case OPC1_16_SSRO_ST_B
:
3311 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3312 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3313 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
3315 case OPC1_16_SSRO_ST_H
:
3316 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3317 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3318 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
3320 case OPC1_16_SSRO_ST_W
:
3321 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3322 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3323 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3326 case OPCM_16_SR_SYSTEM
:
3327 decode_sr_system(env
, ctx
);
3329 case OPCM_16_SR_ACCU
:
3330 decode_sr_accu(env
, ctx
);
3333 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3334 gen_compute_branch(ctx
, op1
, r1
, 0, 0, 0);
3336 case OPC1_16_SR_NOT
:
3337 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3338 tcg_gen_not_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3344 * 32 bit instructions
3348 static void decode_abs_ldw(CPUTriCoreState
*env
, DisasContext
*ctx
)
3355 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3356 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3357 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3359 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
3362 case OPC2_32_ABS_LD_A
:
3363 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3365 case OPC2_32_ABS_LD_D
:
3366 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
3368 case OPC2_32_ABS_LD_DA
:
3369 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
3371 case OPC2_32_ABS_LD_W
:
3372 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3376 tcg_temp_free(temp
);
3379 static void decode_abs_ldb(CPUTriCoreState
*env
, DisasContext
*ctx
)
3386 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3387 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3388 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3390 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
3393 case OPC2_32_ABS_LD_B
:
3394 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_SB
);
3396 case OPC2_32_ABS_LD_BU
:
3397 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
3399 case OPC2_32_ABS_LD_H
:
3400 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESW
);
3402 case OPC2_32_ABS_LD_HU
:
3403 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
3407 tcg_temp_free(temp
);
3410 static void decode_abs_ldst_swap(CPUTriCoreState
*env
, DisasContext
*ctx
)
3417 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3418 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3419 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3421 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
3424 case OPC2_32_ABS_LDMST
:
3425 gen_ldmst(ctx
, r1
, temp
);
3427 case OPC2_32_ABS_SWAP_W
:
3428 gen_swap(ctx
, r1
, temp
);
3432 tcg_temp_free(temp
);
3435 static void decode_abs_ldst_context(CPUTriCoreState
*env
, DisasContext
*ctx
)
3440 off18
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3441 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3444 case OPC2_32_ABS_LDLCX
:
3445 gen_helper_1arg(ldlcx
, EA_ABS_FORMAT(off18
));
3447 case OPC2_32_ABS_LDUCX
:
3448 gen_helper_1arg(lducx
, EA_ABS_FORMAT(off18
));
3450 case OPC2_32_ABS_STLCX
:
3451 gen_helper_1arg(stlcx
, EA_ABS_FORMAT(off18
));
3453 case OPC2_32_ABS_STUCX
:
3454 gen_helper_1arg(stucx
, EA_ABS_FORMAT(off18
));
3459 static void decode_abs_store(CPUTriCoreState
*env
, DisasContext
*ctx
)
3466 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3467 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3468 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3470 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
3473 case OPC2_32_ABS_ST_A
:
3474 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3476 case OPC2_32_ABS_ST_D
:
3477 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
3479 case OPC2_32_ABS_ST_DA
:
3480 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
3482 case OPC2_32_ABS_ST_W
:
3483 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3487 tcg_temp_free(temp
);
3490 static void decode_abs_storeb_h(CPUTriCoreState
*env
, DisasContext
*ctx
)
3497 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3498 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3499 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3501 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
3504 case OPC2_32_ABS_ST_B
:
3505 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
3507 case OPC2_32_ABS_ST_H
:
3508 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
3511 tcg_temp_free(temp
);
3516 static void decode_bit_andacc(CPUTriCoreState
*env
, DisasContext
*ctx
)
3522 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3523 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3524 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3525 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3526 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3527 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3531 case OPC2_32_BIT_AND_AND_T
:
3532 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3533 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_and_tl
);
3535 case OPC2_32_BIT_AND_ANDN_T
:
3536 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3537 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_and_tl
);
3539 case OPC2_32_BIT_AND_NOR_T
:
3540 if (TCG_TARGET_HAS_andc_i32
) {
3541 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3542 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_andc_tl
);
3544 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3545 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_and_tl
);
3548 case OPC2_32_BIT_AND_OR_T
:
3549 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3550 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_and_tl
);
3555 static void decode_bit_logical_t(CPUTriCoreState
*env
, DisasContext
*ctx
)
3560 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3561 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3562 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3563 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3564 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3565 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3568 case OPC2_32_BIT_AND_T
:
3569 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3570 pos1
, pos2
, &tcg_gen_and_tl
);
3572 case OPC2_32_BIT_ANDN_T
:
3573 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3574 pos1
, pos2
, &tcg_gen_andc_tl
);
3576 case OPC2_32_BIT_NOR_T
:
3577 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3578 pos1
, pos2
, &tcg_gen_nor_tl
);
3580 case OPC2_32_BIT_OR_T
:
3581 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3582 pos1
, pos2
, &tcg_gen_or_tl
);
3587 static void decode_bit_insert(CPUTriCoreState
*env
, DisasContext
*ctx
)
3593 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3594 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3595 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3596 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3597 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3598 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3600 temp
= tcg_temp_new();
3602 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r2
], pos2
);
3603 if (op2
== OPC2_32_BIT_INSN_T
) {
3604 tcg_gen_not_tl(temp
, temp
);
3606 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], temp
, pos1
, 1);
3607 tcg_temp_free(temp
);
3610 static void decode_bit_logical_t2(CPUTriCoreState
*env
, DisasContext
*ctx
)
3617 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3618 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3619 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3620 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3621 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3622 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3625 case OPC2_32_BIT_NAND_T
:
3626 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3627 pos1
, pos2
, &tcg_gen_nand_tl
);
3629 case OPC2_32_BIT_ORN_T
:
3630 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3631 pos1
, pos2
, &tcg_gen_orc_tl
);
3633 case OPC2_32_BIT_XNOR_T
:
3634 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3635 pos1
, pos2
, &tcg_gen_eqv_tl
);
3637 case OPC2_32_BIT_XOR_T
:
3638 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3639 pos1
, pos2
, &tcg_gen_xor_tl
);
3644 static void decode_bit_orand(CPUTriCoreState
*env
, DisasContext
*ctx
)
3651 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3652 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3653 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3654 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3655 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3656 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3659 case OPC2_32_BIT_OR_AND_T
:
3660 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3661 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_or_tl
);
3663 case OPC2_32_BIT_OR_ANDN_T
:
3664 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3665 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_or_tl
);
3667 case OPC2_32_BIT_OR_NOR_T
:
3668 if (TCG_TARGET_HAS_orc_i32
) {
3669 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3670 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_orc_tl
);
3672 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3673 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_or_tl
);
3676 case OPC2_32_BIT_OR_OR_T
:
3677 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3678 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_or_tl
);
3683 static void decode_bit_sh_logic1(CPUTriCoreState
*env
, DisasContext
*ctx
)
3690 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3691 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3692 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3693 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3694 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3695 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3697 temp
= tcg_temp_new();
3700 case OPC2_32_BIT_SH_AND_T
:
3701 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3702 pos1
, pos2
, &tcg_gen_and_tl
);
3704 case OPC2_32_BIT_SH_ANDN_T
:
3705 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3706 pos1
, pos2
, &tcg_gen_andc_tl
);
3708 case OPC2_32_BIT_SH_NOR_T
:
3709 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3710 pos1
, pos2
, &tcg_gen_nor_tl
);
3712 case OPC2_32_BIT_SH_OR_T
:
3713 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3714 pos1
, pos2
, &tcg_gen_or_tl
);
3717 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
3718 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
3719 tcg_temp_free(temp
);
3722 static void decode_bit_sh_logic2(CPUTriCoreState
*env
, DisasContext
*ctx
)
3729 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3730 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3731 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3732 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3733 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3734 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3736 temp
= tcg_temp_new();
3739 case OPC2_32_BIT_SH_NAND_T
:
3740 gen_bit_1op(temp
, cpu_gpr_d
[r1
] , cpu_gpr_d
[r2
] ,
3741 pos1
, pos2
, &tcg_gen_nand_tl
);
3743 case OPC2_32_BIT_SH_ORN_T
:
3744 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3745 pos1
, pos2
, &tcg_gen_orc_tl
);
3747 case OPC2_32_BIT_SH_XNOR_T
:
3748 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3749 pos1
, pos2
, &tcg_gen_eqv_tl
);
3751 case OPC2_32_BIT_SH_XOR_T
:
3752 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3753 pos1
, pos2
, &tcg_gen_xor_tl
);
3756 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
3757 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
3758 tcg_temp_free(temp
);
3764 static void decode_bo_addrmode_post_pre_base(CPUTriCoreState
*env
,
3772 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
3773 r2
= MASK_OP_BO_S2(ctx
->opcode
);
3774 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
3775 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
3778 case OPC2_32_BO_CACHEA_WI_SHORTOFF
:
3779 case OPC2_32_BO_CACHEA_W_SHORTOFF
:
3780 case OPC2_32_BO_CACHEA_I_SHORTOFF
:
3781 /* instruction to access the cache */
3783 case OPC2_32_BO_CACHEA_WI_POSTINC
:
3784 case OPC2_32_BO_CACHEA_W_POSTINC
:
3785 case OPC2_32_BO_CACHEA_I_POSTINC
:
3786 /* instruction to access the cache, but we still need to handle
3787 the addressing mode */
3788 tcg_gen_addi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
], off10
);
3790 case OPC2_32_BO_CACHEA_WI_PREINC
:
3791 case OPC2_32_BO_CACHEA_W_PREINC
:
3792 case OPC2_32_BO_CACHEA_I_PREINC
:
3793 /* instruction to access the cache, but we still need to handle
3794 the addressing mode */
3795 tcg_gen_addi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
], off10
);
3797 case OPC2_32_BO_CACHEI_WI_SHORTOFF
:
3798 case OPC2_32_BO_CACHEI_W_SHORTOFF
:
3799 /* TODO: Raise illegal opcode trap,
3800 if !tricore_feature(TRICORE_FEATURE_131) */
3802 case OPC2_32_BO_CACHEI_W_POSTINC
:
3803 case OPC2_32_BO_CACHEI_WI_POSTINC
:
3804 if (tricore_feature(env
, TRICORE_FEATURE_131
)) {
3805 tcg_gen_addi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
], off10
);
3806 } /* TODO: else raise illegal opcode trap */
3808 case OPC2_32_BO_CACHEI_W_PREINC
:
3809 case OPC2_32_BO_CACHEI_WI_PREINC
:
3810 if (tricore_feature(env
, TRICORE_FEATURE_131
)) {
3811 tcg_gen_addi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
], off10
);
3812 } /* TODO: else raise illegal opcode trap */
3814 case OPC2_32_BO_ST_A_SHORTOFF
:
3815 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
3817 case OPC2_32_BO_ST_A_POSTINC
:
3818 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
3820 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3822 case OPC2_32_BO_ST_A_PREINC
:
3823 gen_st_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
3825 case OPC2_32_BO_ST_B_SHORTOFF
:
3826 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
3828 case OPC2_32_BO_ST_B_POSTINC
:
3829 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
3831 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3833 case OPC2_32_BO_ST_B_PREINC
:
3834 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
3836 case OPC2_32_BO_ST_D_SHORTOFF
:
3837 gen_offset_st_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
3840 case OPC2_32_BO_ST_D_POSTINC
:
3841 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
3842 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3844 case OPC2_32_BO_ST_D_PREINC
:
3845 temp
= tcg_temp_new();
3846 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
3847 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
3848 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
3849 tcg_temp_free(temp
);
3851 case OPC2_32_BO_ST_DA_SHORTOFF
:
3852 gen_offset_st_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
3855 case OPC2_32_BO_ST_DA_POSTINC
:
3856 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
3857 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3859 case OPC2_32_BO_ST_DA_PREINC
:
3860 temp
= tcg_temp_new();
3861 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
3862 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
3863 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
3864 tcg_temp_free(temp
);
3866 case OPC2_32_BO_ST_H_SHORTOFF
:
3867 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
3869 case OPC2_32_BO_ST_H_POSTINC
:
3870 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
3872 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3874 case OPC2_32_BO_ST_H_PREINC
:
3875 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
3877 case OPC2_32_BO_ST_Q_SHORTOFF
:
3878 temp
= tcg_temp_new();
3879 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
3880 gen_offset_st(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
3881 tcg_temp_free(temp
);
3883 case OPC2_32_BO_ST_Q_POSTINC
:
3884 temp
= tcg_temp_new();
3885 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
3886 tcg_gen_qemu_st_tl(temp
, cpu_gpr_a
[r2
], ctx
->mem_idx
,
3888 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3889 tcg_temp_free(temp
);
3891 case OPC2_32_BO_ST_Q_PREINC
:
3892 temp
= tcg_temp_new();
3893 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
3894 gen_st_preincr(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
3895 tcg_temp_free(temp
);
3897 case OPC2_32_BO_ST_W_SHORTOFF
:
3898 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
3900 case OPC2_32_BO_ST_W_POSTINC
:
3901 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
3903 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
3905 case OPC2_32_BO_ST_W_PREINC
:
3906 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
3911 static void decode_bo_addrmode_bitreverse_circular(CPUTriCoreState
*env
,
3917 TCGv temp
, temp2
, temp3
;
3919 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
3920 r2
= MASK_OP_BO_S2(ctx
->opcode
);
3921 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
3922 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
3924 temp
= tcg_temp_new();
3925 temp2
= tcg_temp_new();
3926 temp3
= tcg_const_i32(off10
);
3928 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
3929 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
3932 case OPC2_32_BO_CACHEA_WI_BR
:
3933 case OPC2_32_BO_CACHEA_W_BR
:
3934 case OPC2_32_BO_CACHEA_I_BR
:
3935 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3937 case OPC2_32_BO_CACHEA_WI_CIRC
:
3938 case OPC2_32_BO_CACHEA_W_CIRC
:
3939 case OPC2_32_BO_CACHEA_I_CIRC
:
3940 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3942 case OPC2_32_BO_ST_A_BR
:
3943 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
3944 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3946 case OPC2_32_BO_ST_A_CIRC
:
3947 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
3948 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3950 case OPC2_32_BO_ST_B_BR
:
3951 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
3952 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3954 case OPC2_32_BO_ST_B_CIRC
:
3955 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
3956 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3958 case OPC2_32_BO_ST_D_BR
:
3959 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
3960 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3962 case OPC2_32_BO_ST_D_CIRC
:
3963 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
3964 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
3965 tcg_gen_addi_tl(temp
, temp
, 4);
3966 tcg_gen_rem_tl(temp
, temp
, temp2
);
3967 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
3968 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
3969 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3971 case OPC2_32_BO_ST_DA_BR
:
3972 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
3973 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3975 case OPC2_32_BO_ST_DA_CIRC
:
3976 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
3977 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
3978 tcg_gen_addi_tl(temp
, temp
, 4);
3979 tcg_gen_rem_tl(temp
, temp
, temp2
);
3980 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
3981 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
3982 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3984 case OPC2_32_BO_ST_H_BR
:
3985 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
3986 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3988 case OPC2_32_BO_ST_H_CIRC
:
3989 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
3990 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
3992 case OPC2_32_BO_ST_Q_BR
:
3993 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
3994 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
3995 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
3997 case OPC2_32_BO_ST_Q_CIRC
:
3998 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
3999 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
4000 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4002 case OPC2_32_BO_ST_W_BR
:
4003 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4004 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4006 case OPC2_32_BO_ST_W_CIRC
:
4007 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4008 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4011 tcg_temp_free(temp
);
4012 tcg_temp_free(temp2
);
4013 tcg_temp_free(temp3
);
4016 static void decode_bo_addrmode_ld_post_pre_base(CPUTriCoreState
*env
,
4024 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4025 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4026 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4027 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4030 case OPC2_32_BO_LD_A_SHORTOFF
:
4031 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4033 case OPC2_32_BO_LD_A_POSTINC
:
4034 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4036 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4038 case OPC2_32_BO_LD_A_PREINC
:
4039 gen_ld_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4041 case OPC2_32_BO_LD_B_SHORTOFF
:
4042 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4044 case OPC2_32_BO_LD_B_POSTINC
:
4045 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4047 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4049 case OPC2_32_BO_LD_B_PREINC
:
4050 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4052 case OPC2_32_BO_LD_BU_SHORTOFF
:
4053 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4055 case OPC2_32_BO_LD_BU_POSTINC
:
4056 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4058 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4060 case OPC2_32_BO_LD_BU_PREINC
:
4061 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4063 case OPC2_32_BO_LD_D_SHORTOFF
:
4064 gen_offset_ld_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
4067 case OPC2_32_BO_LD_D_POSTINC
:
4068 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
4069 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4071 case OPC2_32_BO_LD_D_PREINC
:
4072 temp
= tcg_temp_new();
4073 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4074 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4075 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4076 tcg_temp_free(temp
);
4078 case OPC2_32_BO_LD_DA_SHORTOFF
:
4079 gen_offset_ld_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
4082 case OPC2_32_BO_LD_DA_POSTINC
:
4083 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
4084 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4086 case OPC2_32_BO_LD_DA_PREINC
:
4087 temp
= tcg_temp_new();
4088 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4089 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4090 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4091 tcg_temp_free(temp
);
4093 case OPC2_32_BO_LD_H_SHORTOFF
:
4094 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
4096 case OPC2_32_BO_LD_H_POSTINC
:
4097 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4099 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4101 case OPC2_32_BO_LD_H_PREINC
:
4102 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
4104 case OPC2_32_BO_LD_HU_SHORTOFF
:
4105 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4107 case OPC2_32_BO_LD_HU_POSTINC
:
4108 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4110 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4112 case OPC2_32_BO_LD_HU_PREINC
:
4113 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4115 case OPC2_32_BO_LD_Q_SHORTOFF
:
4116 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4117 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4119 case OPC2_32_BO_LD_Q_POSTINC
:
4120 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4122 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4123 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4125 case OPC2_32_BO_LD_Q_PREINC
:
4126 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4127 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4129 case OPC2_32_BO_LD_W_SHORTOFF
:
4130 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4132 case OPC2_32_BO_LD_W_POSTINC
:
4133 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4135 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4137 case OPC2_32_BO_LD_W_PREINC
:
4138 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4143 static void decode_bo_addrmode_ld_bitreverse_circular(CPUTriCoreState
*env
,
4150 TCGv temp
, temp2
, temp3
;
4152 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4153 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4154 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4155 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4157 temp
= tcg_temp_new();
4158 temp2
= tcg_temp_new();
4159 temp3
= tcg_const_i32(off10
);
4161 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4162 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4166 case OPC2_32_BO_LD_A_BR
:
4167 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4168 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4170 case OPC2_32_BO_LD_A_CIRC
:
4171 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4172 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4174 case OPC2_32_BO_LD_B_BR
:
4175 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
4176 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4178 case OPC2_32_BO_LD_B_CIRC
:
4179 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
4180 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4182 case OPC2_32_BO_LD_BU_BR
:
4183 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4184 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4186 case OPC2_32_BO_LD_BU_CIRC
:
4187 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4188 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4190 case OPC2_32_BO_LD_D_BR
:
4191 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
4192 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4194 case OPC2_32_BO_LD_D_CIRC
:
4195 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4196 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4197 tcg_gen_addi_tl(temp
, temp
, 4);
4198 tcg_gen_rem_tl(temp
, temp
, temp2
);
4199 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4200 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4201 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4203 case OPC2_32_BO_LD_DA_BR
:
4204 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
4205 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4207 case OPC2_32_BO_LD_DA_CIRC
:
4208 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4209 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4210 tcg_gen_addi_tl(temp
, temp
, 4);
4211 tcg_gen_rem_tl(temp
, temp
, temp2
);
4212 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4213 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4214 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4216 case OPC2_32_BO_LD_H_BR
:
4217 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
4218 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4220 case OPC2_32_BO_LD_H_CIRC
:
4221 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
4222 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4224 case OPC2_32_BO_LD_HU_BR
:
4225 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4226 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4228 case OPC2_32_BO_LD_HU_CIRC
:
4229 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4230 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4232 case OPC2_32_BO_LD_Q_BR
:
4233 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4234 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4235 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4237 case OPC2_32_BO_LD_Q_CIRC
:
4238 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4239 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4240 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4242 case OPC2_32_BO_LD_W_BR
:
4243 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4244 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4246 case OPC2_32_BO_LD_W_CIRC
:
4247 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4248 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4251 tcg_temp_free(temp
);
4252 tcg_temp_free(temp2
);
4253 tcg_temp_free(temp3
);
4256 static void decode_bo_addrmode_stctx_post_pre_base(CPUTriCoreState
*env
,
4265 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4266 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4267 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4268 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4271 temp
= tcg_temp_new();
4272 temp2
= tcg_temp_new();
4275 case OPC2_32_BO_LDLCX_SHORTOFF
:
4276 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4277 gen_helper_ldlcx(cpu_env
, temp
);
4279 case OPC2_32_BO_LDMST_SHORTOFF
:
4280 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4281 gen_ldmst(ctx
, r1
, temp
);
4283 case OPC2_32_BO_LDMST_POSTINC
:
4284 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
4285 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4287 case OPC2_32_BO_LDMST_PREINC
:
4288 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4289 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
4291 case OPC2_32_BO_LDUCX_SHORTOFF
:
4292 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4293 gen_helper_lducx(cpu_env
, temp
);
4295 case OPC2_32_BO_LEA_SHORTOFF
:
4296 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
);
4298 case OPC2_32_BO_STLCX_SHORTOFF
:
4299 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4300 gen_helper_stlcx(cpu_env
, temp
);
4302 case OPC2_32_BO_STUCX_SHORTOFF
:
4303 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4304 gen_helper_stucx(cpu_env
, temp
);
4306 case OPC2_32_BO_SWAP_W_SHORTOFF
:
4307 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4308 gen_swap(ctx
, r1
, temp
);
4310 case OPC2_32_BO_SWAP_W_POSTINC
:
4311 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
4312 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4314 case OPC2_32_BO_SWAP_W_PREINC
:
4315 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4316 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
4319 tcg_temp_free(temp
);
4320 tcg_temp_free(temp2
);
4323 static void decode_bo_addrmode_ldmst_bitreverse_circular(CPUTriCoreState
*env
,
4330 TCGv temp
, temp2
, temp3
;
4332 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4333 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4334 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4335 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4337 temp
= tcg_temp_new();
4338 temp2
= tcg_temp_new();
4339 temp3
= tcg_const_i32(off10
);
4341 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4342 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4345 case OPC2_32_BO_LDMST_BR
:
4346 gen_ldmst(ctx
, r1
, temp2
);
4347 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4349 case OPC2_32_BO_LDMST_CIRC
:
4350 gen_ldmst(ctx
, r1
, temp2
);
4351 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4353 case OPC2_32_BO_SWAP_W_BR
:
4354 gen_swap(ctx
, r1
, temp2
);
4355 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4357 case OPC2_32_BO_SWAP_W_CIRC
:
4358 gen_swap(ctx
, r1
, temp2
);
4359 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4362 tcg_temp_free(temp
);
4363 tcg_temp_free(temp2
);
4364 tcg_temp_free(temp3
);
4367 static void decode_bol_opc(CPUTriCoreState
*env
, DisasContext
*ctx
, int32_t op1
)
4373 r1
= MASK_OP_BOL_S1D(ctx
->opcode
);
4374 r2
= MASK_OP_BOL_S2(ctx
->opcode
);
4375 address
= MASK_OP_BOL_OFF16_SEXT(ctx
->opcode
);
4378 case OPC1_32_BOL_LD_A_LONGOFF
:
4379 temp
= tcg_temp_new();
4380 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
4381 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
4382 tcg_temp_free(temp
);
4384 case OPC1_32_BOL_LD_W_LONGOFF
:
4385 temp
= tcg_temp_new();
4386 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
4387 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
4388 tcg_temp_free(temp
);
4390 case OPC1_32_BOL_LEA_LONGOFF
:
4391 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
);
4393 case OPC1_32_BOL_ST_A_LONGOFF
:
4394 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4395 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
4397 /* raise illegal opcode trap */
4400 case OPC1_32_BOL_ST_W_LONGOFF
:
4401 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
4403 case OPC1_32_BOL_LD_B_LONGOFF
:
4404 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4405 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
4407 /* raise illegal opcode trap */
4410 case OPC1_32_BOL_LD_BU_LONGOFF
:
4411 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4412 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_UB
);
4414 /* raise illegal opcode trap */
4417 case OPC1_32_BOL_LD_H_LONGOFF
:
4418 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4419 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
4421 /* raise illegal opcode trap */
4424 case OPC1_32_BOL_LD_HU_LONGOFF
:
4425 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4426 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUW
);
4428 /* raise illegal opcode trap */
4431 case OPC1_32_BOL_ST_B_LONGOFF
:
4432 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4433 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
4435 /* raise illegal opcode trap */
4438 case OPC1_32_BOL_ST_H_LONGOFF
:
4439 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
4440 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
4442 /* raise illegal opcode trap */
4449 static void decode_rc_logical_shift(CPUTriCoreState
*env
, DisasContext
*ctx
)
4456 r2
= MASK_OP_RC_D(ctx
->opcode
);
4457 r1
= MASK_OP_RC_S1(ctx
->opcode
);
4458 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4459 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
4461 temp
= tcg_temp_new();
4464 case OPC2_32_RC_AND
:
4465 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4467 case OPC2_32_RC_ANDN
:
4468 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
4470 case OPC2_32_RC_NAND
:
4471 tcg_gen_movi_tl(temp
, const9
);
4472 tcg_gen_nand_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
4474 case OPC2_32_RC_NOR
:
4475 tcg_gen_movi_tl(temp
, const9
);
4476 tcg_gen_nor_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
4479 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4481 case OPC2_32_RC_ORN
:
4482 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
4485 const9
= sextract32(const9
, 0, 6);
4486 gen_shi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4488 case OPC2_32_RC_SH_H
:
4489 const9
= sextract32(const9
, 0, 5);
4490 gen_sh_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4492 case OPC2_32_RC_SHA
:
4493 const9
= sextract32(const9
, 0, 6);
4494 gen_shaci(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4496 case OPC2_32_RC_SHA_H
:
4497 const9
= sextract32(const9
, 0, 5);
4498 gen_sha_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4500 case OPC2_32_RC_SHAS
:
4501 gen_shasi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4503 case OPC2_32_RC_XNOR
:
4504 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4505 tcg_gen_not_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
]);
4507 case OPC2_32_RC_XOR
:
4508 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4511 tcg_temp_free(temp
);
4514 static void decode_rc_accumulator(CPUTriCoreState
*env
, DisasContext
*ctx
)
4522 r2
= MASK_OP_RC_D(ctx
->opcode
);
4523 r1
= MASK_OP_RC_S1(ctx
->opcode
);
4524 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
4526 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
4528 temp
= tcg_temp_new();
4531 case OPC2_32_RC_ABSDIF
:
4532 gen_absdifi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4534 case OPC2_32_RC_ABSDIFS
:
4535 gen_absdifsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4537 case OPC2_32_RC_ADD
:
4538 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4540 case OPC2_32_RC_ADDC
:
4541 gen_addci_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4543 case OPC2_32_RC_ADDS
:
4544 gen_addsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4546 case OPC2_32_RC_ADDS_U
:
4547 gen_addsui(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4549 case OPC2_32_RC_ADDX
:
4550 gen_addi_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4552 case OPC2_32_RC_AND_EQ
:
4553 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4554 const9
, &tcg_gen_and_tl
);
4556 case OPC2_32_RC_AND_GE
:
4557 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4558 const9
, &tcg_gen_and_tl
);
4560 case OPC2_32_RC_AND_GE_U
:
4561 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4562 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4563 const9
, &tcg_gen_and_tl
);
4565 case OPC2_32_RC_AND_LT
:
4566 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4567 const9
, &tcg_gen_and_tl
);
4569 case OPC2_32_RC_AND_LT_U
:
4570 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4571 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4572 const9
, &tcg_gen_and_tl
);
4574 case OPC2_32_RC_AND_NE
:
4575 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4576 const9
, &tcg_gen_and_tl
);
4579 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4581 case OPC2_32_RC_EQANY_B
:
4582 gen_eqany_bi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4584 case OPC2_32_RC_EQANY_H
:
4585 gen_eqany_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4588 tcg_gen_setcondi_tl(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4590 case OPC2_32_RC_GE_U
:
4591 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4592 tcg_gen_setcondi_tl(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4595 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4597 case OPC2_32_RC_LT_U
:
4598 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4599 tcg_gen_setcondi_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4601 case OPC2_32_RC_MAX
:
4602 tcg_gen_movi_tl(temp
, const9
);
4603 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
4604 cpu_gpr_d
[r1
], temp
);
4606 case OPC2_32_RC_MAX_U
:
4607 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
4608 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
4609 cpu_gpr_d
[r1
], temp
);
4611 case OPC2_32_RC_MIN
:
4612 tcg_gen_movi_tl(temp
, const9
);
4613 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
4614 cpu_gpr_d
[r1
], temp
);
4616 case OPC2_32_RC_MIN_U
:
4617 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
4618 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
4619 cpu_gpr_d
[r1
], temp
);
4622 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4624 case OPC2_32_RC_OR_EQ
:
4625 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4626 const9
, &tcg_gen_or_tl
);
4628 case OPC2_32_RC_OR_GE
:
4629 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4630 const9
, &tcg_gen_or_tl
);
4632 case OPC2_32_RC_OR_GE_U
:
4633 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4634 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4635 const9
, &tcg_gen_or_tl
);
4637 case OPC2_32_RC_OR_LT
:
4638 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4639 const9
, &tcg_gen_or_tl
);
4641 case OPC2_32_RC_OR_LT_U
:
4642 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4643 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4644 const9
, &tcg_gen_or_tl
);
4646 case OPC2_32_RC_OR_NE
:
4647 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4648 const9
, &tcg_gen_or_tl
);
4650 case OPC2_32_RC_RSUB
:
4651 tcg_gen_movi_tl(temp
, const9
);
4652 gen_sub_d(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
4654 case OPC2_32_RC_RSUBS
:
4655 tcg_gen_movi_tl(temp
, const9
);
4656 gen_subs(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
4658 case OPC2_32_RC_RSUBS_U
:
4659 tcg_gen_movi_tl(temp
, const9
);
4660 gen_subsu(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
4662 case OPC2_32_RC_SH_EQ
:
4663 gen_sh_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4665 case OPC2_32_RC_SH_GE
:
4666 gen_sh_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4668 case OPC2_32_RC_SH_GE_U
:
4669 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4670 gen_sh_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4672 case OPC2_32_RC_SH_LT
:
4673 gen_sh_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4675 case OPC2_32_RC_SH_LT_U
:
4676 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4677 gen_sh_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4679 case OPC2_32_RC_SH_NE
:
4680 gen_sh_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4682 case OPC2_32_RC_XOR_EQ
:
4683 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4684 const9
, &tcg_gen_xor_tl
);
4686 case OPC2_32_RC_XOR_GE
:
4687 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4688 const9
, &tcg_gen_xor_tl
);
4690 case OPC2_32_RC_XOR_GE_U
:
4691 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4692 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4693 const9
, &tcg_gen_xor_tl
);
4695 case OPC2_32_RC_XOR_LT
:
4696 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4697 const9
, &tcg_gen_xor_tl
);
4699 case OPC2_32_RC_XOR_LT_U
:
4700 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4701 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4702 const9
, &tcg_gen_xor_tl
);
4704 case OPC2_32_RC_XOR_NE
:
4705 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
4706 const9
, &tcg_gen_xor_tl
);
4709 tcg_temp_free(temp
);
4712 static void decode_rc_serviceroutine(CPUTriCoreState
*env
, DisasContext
*ctx
)
4717 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
4718 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4721 case OPC2_32_RC_BISR
:
4722 gen_helper_1arg(bisr
, const9
);
4724 case OPC2_32_RC_SYSCALL
:
4725 /* TODO: Add exception generation */
4730 static void decode_rc_mul(CPUTriCoreState
*env
, DisasContext
*ctx
)
4736 r2
= MASK_OP_RC_D(ctx
->opcode
);
4737 r1
= MASK_OP_RC_S1(ctx
->opcode
);
4738 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
4740 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
4743 case OPC2_32_RC_MUL_32
:
4744 gen_muli_i32s(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4746 case OPC2_32_RC_MUL_64
:
4747 gen_muli_i64s(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
4749 case OPC2_32_RC_MULS_32
:
4750 gen_mulsi_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4752 case OPC2_32_RC_MUL_U_64
:
4753 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4754 gen_muli_i64u(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
4756 case OPC2_32_RC_MULS_U_32
:
4757 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4758 gen_mulsui_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4764 static void decode_rcpw_insert(CPUTriCoreState
*env
, DisasContext
*ctx
)
4768 int32_t pos
, width
, const4
;
4772 op2
= MASK_OP_RCPW_OP2(ctx
->opcode
);
4773 r1
= MASK_OP_RCPW_S1(ctx
->opcode
);
4774 r2
= MASK_OP_RCPW_D(ctx
->opcode
);
4775 const4
= MASK_OP_RCPW_CONST4(ctx
->opcode
);
4776 width
= MASK_OP_RCPW_WIDTH(ctx
->opcode
);
4777 pos
= MASK_OP_RCPW_POS(ctx
->opcode
);
4780 case OPC2_32_RCPW_IMASK
:
4781 /* if pos + width > 31 undefined result */
4782 if (pos
+ width
<= 31) {
4783 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], ((1u << width
) - 1) << pos
);
4784 tcg_gen_movi_tl(cpu_gpr_d
[r2
], (const4
<< pos
));
4787 case OPC2_32_RCPW_INSERT
:
4788 /* if pos + width > 32 undefined result */
4789 if (pos
+ width
<= 32) {
4790 temp
= tcg_const_i32(const4
);
4791 tcg_gen_deposit_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, pos
, width
);
4792 tcg_temp_free(temp
);
4800 static void decode_rcrw_insert(CPUTriCoreState
*env
, DisasContext
*ctx
)
4804 int32_t width
, const4
;
4806 TCGv temp
, temp2
, temp3
;
4808 op2
= MASK_OP_RCRW_OP2(ctx
->opcode
);
4809 r1
= MASK_OP_RCRW_S1(ctx
->opcode
);
4810 r3
= MASK_OP_RCRW_S3(ctx
->opcode
);
4811 r4
= MASK_OP_RCRW_D(ctx
->opcode
);
4812 width
= MASK_OP_RCRW_WIDTH(ctx
->opcode
);
4813 const4
= MASK_OP_RCRW_CONST4(ctx
->opcode
);
4815 temp
= tcg_temp_new();
4816 temp2
= tcg_temp_new();
4819 case OPC2_32_RCRW_IMASK
:
4820 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r4
], 0x1f);
4821 tcg_gen_movi_tl(temp2
, (1 << width
) - 1);
4822 tcg_gen_shl_tl(cpu_gpr_d
[r3
+ 1], temp2
, temp
);
4823 tcg_gen_movi_tl(temp2
, const4
);
4824 tcg_gen_shl_tl(cpu_gpr_d
[r3
], temp2
, temp
);
4826 case OPC2_32_RCRW_INSERT
:
4827 temp3
= tcg_temp_new();
4829 tcg_gen_movi_tl(temp
, width
);
4830 tcg_gen_movi_tl(temp2
, const4
);
4831 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r4
], 0x1f);
4832 gen_insert(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], temp2
, temp
, temp3
);
4834 tcg_temp_free(temp3
);
4837 tcg_temp_free(temp
);
4838 tcg_temp_free(temp2
);
4843 static void decode_rcr_cond_select(CPUTriCoreState
*env
, DisasContext
*ctx
)
4851 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
4852 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
4853 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
4854 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
4855 r4
= MASK_OP_RCR_D(ctx
->opcode
);
4858 case OPC2_32_RCR_CADD
:
4859 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r3
],
4862 case OPC2_32_RCR_CADDN
:
4863 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r3
],
4866 case OPC2_32_RCR_SEL
:
4867 temp
= tcg_const_i32(0);
4868 temp2
= tcg_const_i32(const9
);
4869 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
4870 cpu_gpr_d
[r1
], temp2
);
4871 tcg_temp_free(temp
);
4872 tcg_temp_free(temp2
);
4874 case OPC2_32_RCR_SELN
:
4875 temp
= tcg_const_i32(0);
4876 temp2
= tcg_const_i32(const9
);
4877 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
4878 cpu_gpr_d
[r1
], temp2
);
4879 tcg_temp_free(temp
);
4880 tcg_temp_free(temp2
);
4885 static void decode_rcr_madd(CPUTriCoreState
*env
, DisasContext
*ctx
)
4892 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
4893 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
4894 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
4895 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
4896 r4
= MASK_OP_RCR_D(ctx
->opcode
);
4899 case OPC2_32_RCR_MADD_32
:
4900 gen_maddi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4902 case OPC2_32_RCR_MADD_64
:
4903 gen_maddi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4904 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4906 case OPC2_32_RCR_MADDS_32
:
4907 gen_maddsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4909 case OPC2_32_RCR_MADDS_64
:
4910 gen_maddsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4911 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4913 case OPC2_32_RCR_MADD_U_64
:
4914 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4915 gen_maddui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4916 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4918 case OPC2_32_RCR_MADDS_U_32
:
4919 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4920 gen_maddsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4922 case OPC2_32_RCR_MADDS_U_64
:
4923 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4924 gen_maddsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4925 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4930 static void decode_rcr_msub(CPUTriCoreState
*env
, DisasContext
*ctx
)
4937 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
4938 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
4939 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
4940 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
4941 r4
= MASK_OP_RCR_D(ctx
->opcode
);
4944 case OPC2_32_RCR_MSUB_32
:
4945 gen_msubi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4947 case OPC2_32_RCR_MSUB_64
:
4948 gen_msubi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4949 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4951 case OPC2_32_RCR_MSUBS_32
:
4952 gen_msubsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4954 case OPC2_32_RCR_MSUBS_64
:
4955 gen_msubsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4956 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4958 case OPC2_32_RCR_MSUB_U_64
:
4959 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4960 gen_msubui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4961 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4963 case OPC2_32_RCR_MSUBS_U_32
:
4964 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4965 gen_msubsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
4967 case OPC2_32_RCR_MSUBS_U_64
:
4968 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
4969 gen_msubsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
4970 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
4977 static void decode_rlc_opc(CPUTriCoreState
*env
, DisasContext
*ctx
,
4983 const16
= MASK_OP_RLC_CONST16_SEXT(ctx
->opcode
);
4984 r1
= MASK_OP_RLC_S1(ctx
->opcode
);
4985 r2
= MASK_OP_RLC_D(ctx
->opcode
);
4988 case OPC1_32_RLC_ADDI
:
4989 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
);
4991 case OPC1_32_RLC_ADDIH
:
4992 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
<< 16);
4994 case OPC1_32_RLC_ADDIH_A
:
4995 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r1
], const16
<< 16);
4997 case OPC1_32_RLC_MFCR
:
4998 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
4999 gen_mfcr(env
, cpu_gpr_d
[r2
], const16
);
5001 case OPC1_32_RLC_MOV
:
5002 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5004 case OPC1_32_RLC_MOV_64
:
5005 if (tricore_feature(env
, TRICORE_FEATURE_16
)) {
5006 if ((r2
& 0x1) != 0) {
5007 /* TODO: raise OPD trap */
5009 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5010 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], const16
>> 15);
5012 /* TODO: raise illegal opcode trap */
5015 case OPC1_32_RLC_MOV_U
:
5016 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
5017 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5019 case OPC1_32_RLC_MOV_H
:
5020 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
<< 16);
5022 case OPC1_32_RLC_MOVH_A
:
5023 tcg_gen_movi_tl(cpu_gpr_a
[r2
], const16
<< 16);
5025 case OPC1_32_RLC_MTCR
:
5026 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
5027 gen_mtcr(env
, ctx
, cpu_gpr_d
[r1
], const16
);
5033 static void decode_rr_accumulator(CPUTriCoreState
*env
, DisasContext
*ctx
)
5038 r3
= MASK_OP_RR_D(ctx
->opcode
);
5039 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5040 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5041 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5044 case OPC2_32_RR_ABS
:
5045 gen_abs(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5047 case OPC2_32_RR_ABS_B
:
5048 gen_helper_abs_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5050 case OPC2_32_RR_ABS_H
:
5051 gen_helper_abs_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5053 case OPC2_32_RR_ABSDIF
:
5054 gen_absdif(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5056 case OPC2_32_RR_ABSDIF_B
:
5057 gen_helper_absdif_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5060 case OPC2_32_RR_ABSDIF_H
:
5061 gen_helper_absdif_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5064 case OPC2_32_RR_ABSDIFS
:
5065 gen_helper_absdif_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5068 case OPC2_32_RR_ABSDIFS_H
:
5069 gen_helper_absdif_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5072 case OPC2_32_RR_ABSS
:
5073 gen_helper_abs_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5075 case OPC2_32_RR_ABSS_H
:
5076 gen_helper_abs_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5078 case OPC2_32_RR_ADD
:
5079 gen_add_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5081 case OPC2_32_RR_ADD_B
:
5082 gen_helper_add_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5084 case OPC2_32_RR_ADD_H
:
5085 gen_helper_add_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5087 case OPC2_32_RR_ADDC
:
5088 gen_addc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5090 case OPC2_32_RR_ADDS
:
5091 gen_adds(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5093 case OPC2_32_RR_ADDS_H
:
5094 gen_helper_add_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5097 case OPC2_32_RR_ADDS_HU
:
5098 gen_helper_add_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5101 case OPC2_32_RR_ADDS_U
:
5102 gen_helper_add_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5105 case OPC2_32_RR_ADDX
:
5106 gen_add_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5108 case OPC2_32_RR_AND_EQ
:
5109 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5110 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5112 case OPC2_32_RR_AND_GE
:
5113 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5114 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5116 case OPC2_32_RR_AND_GE_U
:
5117 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5118 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5120 case OPC2_32_RR_AND_LT
:
5121 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5122 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5124 case OPC2_32_RR_AND_LT_U
:
5125 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5126 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5128 case OPC2_32_RR_AND_NE
:
5129 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5130 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5133 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5136 case OPC2_32_RR_EQ_B
:
5137 gen_helper_eq_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5139 case OPC2_32_RR_EQ_H
:
5140 gen_helper_eq_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5142 case OPC2_32_RR_EQ_W
:
5143 gen_cond_w(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5145 case OPC2_32_RR_EQANY_B
:
5146 gen_helper_eqany_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5148 case OPC2_32_RR_EQANY_H
:
5149 gen_helper_eqany_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5152 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5155 case OPC2_32_RR_GE_U
:
5156 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5160 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5163 case OPC2_32_RR_LT_U
:
5164 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5167 case OPC2_32_RR_LT_B
:
5168 gen_helper_lt_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5170 case OPC2_32_RR_LT_BU
:
5171 gen_helper_lt_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5173 case OPC2_32_RR_LT_H
:
5174 gen_helper_lt_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5176 case OPC2_32_RR_LT_HU
:
5177 gen_helper_lt_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5179 case OPC2_32_RR_LT_W
:
5180 gen_cond_w(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5182 case OPC2_32_RR_LT_WU
:
5183 gen_cond_w(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5185 case OPC2_32_RR_MAX
:
5186 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5187 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5189 case OPC2_32_RR_MAX_U
:
5190 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5191 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5193 case OPC2_32_RR_MAX_B
:
5194 gen_helper_max_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5196 case OPC2_32_RR_MAX_BU
:
5197 gen_helper_max_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5199 case OPC2_32_RR_MAX_H
:
5200 gen_helper_max_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5202 case OPC2_32_RR_MAX_HU
:
5203 gen_helper_max_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5205 case OPC2_32_RR_MIN
:
5206 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5207 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5209 case OPC2_32_RR_MIN_U
:
5210 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5211 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5213 case OPC2_32_RR_MIN_B
:
5214 gen_helper_min_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5216 case OPC2_32_RR_MIN_BU
:
5217 gen_helper_min_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5219 case OPC2_32_RR_MIN_H
:
5220 gen_helper_min_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5222 case OPC2_32_RR_MIN_HU
:
5223 gen_helper_min_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5225 case OPC2_32_RR_MOV
:
5226 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5229 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5232 case OPC2_32_RR_OR_EQ
:
5233 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5234 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5236 case OPC2_32_RR_OR_GE
:
5237 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5238 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5240 case OPC2_32_RR_OR_GE_U
:
5241 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5242 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5244 case OPC2_32_RR_OR_LT
:
5245 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5246 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5248 case OPC2_32_RR_OR_LT_U
:
5249 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5250 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5252 case OPC2_32_RR_OR_NE
:
5253 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5254 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5256 case OPC2_32_RR_SAT_B
:
5257 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7f, -0x80);
5259 case OPC2_32_RR_SAT_BU
:
5260 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xff);
5262 case OPC2_32_RR_SAT_H
:
5263 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
5265 case OPC2_32_RR_SAT_HU
:
5266 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xffff);
5268 case OPC2_32_RR_SH_EQ
:
5269 gen_sh_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5272 case OPC2_32_RR_SH_GE
:
5273 gen_sh_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5276 case OPC2_32_RR_SH_GE_U
:
5277 gen_sh_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5280 case OPC2_32_RR_SH_LT
:
5281 gen_sh_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5284 case OPC2_32_RR_SH_LT_U
:
5285 gen_sh_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5288 case OPC2_32_RR_SH_NE
:
5289 gen_sh_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5292 case OPC2_32_RR_SUB
:
5293 gen_sub_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5295 case OPC2_32_RR_SUB_B
:
5296 gen_helper_sub_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5298 case OPC2_32_RR_SUB_H
:
5299 gen_helper_sub_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5301 case OPC2_32_RR_SUBC
:
5302 gen_subc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5304 case OPC2_32_RR_SUBS
:
5305 gen_subs(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5307 case OPC2_32_RR_SUBS_U
:
5308 gen_subsu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5310 case OPC2_32_RR_SUBS_H
:
5311 gen_helper_sub_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5314 case OPC2_32_RR_SUBS_HU
:
5315 gen_helper_sub_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5318 case OPC2_32_RR_SUBX
:
5319 gen_sub_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5321 case OPC2_32_RR_XOR_EQ
:
5322 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5323 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5325 case OPC2_32_RR_XOR_GE
:
5326 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5327 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5329 case OPC2_32_RR_XOR_GE_U
:
5330 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5331 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5333 case OPC2_32_RR_XOR_LT
:
5334 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5335 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5337 case OPC2_32_RR_XOR_LT_U
:
5338 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5339 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5341 case OPC2_32_RR_XOR_NE
:
5342 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5343 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5348 static void decode_rr_logical_shift(CPUTriCoreState
*env
, DisasContext
*ctx
)
5354 r3
= MASK_OP_RR_D(ctx
->opcode
);
5355 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5356 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5358 temp
= tcg_temp_new();
5359 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5362 case OPC2_32_RR_AND
:
5363 tcg_gen_and_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5365 case OPC2_32_RR_ANDN
:
5366 tcg_gen_andc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5368 case OPC2_32_RR_CLO
:
5369 gen_helper_clo(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5371 case OPC2_32_RR_CLO_H
:
5372 gen_helper_clo_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5374 case OPC2_32_RR_CLS
:
5375 gen_helper_cls(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5377 case OPC2_32_RR_CLS_H
:
5378 gen_helper_cls_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5380 case OPC2_32_RR_CLZ
:
5381 gen_helper_clz(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5383 case OPC2_32_RR_CLZ_H
:
5384 gen_helper_clz_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5386 case OPC2_32_RR_NAND
:
5387 tcg_gen_nand_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5389 case OPC2_32_RR_NOR
:
5390 tcg_gen_nor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5393 tcg_gen_or_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5395 case OPC2_32_RR_ORN
:
5396 tcg_gen_orc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5399 gen_helper_sh(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5401 case OPC2_32_RR_SH_H
:
5402 gen_helper_sh_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5404 case OPC2_32_RR_SHA
:
5405 gen_helper_sha(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5407 case OPC2_32_RR_SHA_H
:
5408 gen_helper_sha_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5410 case OPC2_32_RR_SHAS
:
5411 gen_shas(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5413 case OPC2_32_RR_XNOR
:
5414 tcg_gen_eqv_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5416 case OPC2_32_RR_XOR
:
5417 tcg_gen_xor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5420 tcg_temp_free(temp
);
5423 static void decode_rr_address(CPUTriCoreState
*env
, DisasContext
*ctx
)
5429 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5430 r3
= MASK_OP_RR_D(ctx
->opcode
);
5431 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5432 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5433 n
= MASK_OP_RR_N(ctx
->opcode
);
5436 case OPC2_32_RR_ADD_A
:
5437 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
5439 case OPC2_32_RR_ADDSC_A
:
5440 temp
= tcg_temp_new();
5441 tcg_gen_shli_tl(temp
, cpu_gpr_d
[r1
], n
);
5442 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
], temp
);
5443 tcg_temp_free(temp
);
5445 case OPC2_32_RR_ADDSC_AT
:
5446 temp
= tcg_temp_new();
5447 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 3);
5448 tcg_gen_add_tl(temp
, cpu_gpr_a
[r2
], temp
);
5449 tcg_gen_andi_tl(cpu_gpr_a
[r3
], temp
, 0xFFFFFFFC);
5450 tcg_temp_free(temp
);
5452 case OPC2_32_RR_EQ_A
:
5453 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
5456 case OPC2_32_RR_EQZ
:
5457 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
5459 case OPC2_32_RR_GE_A
:
5460 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
5463 case OPC2_32_RR_LT_A
:
5464 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
5467 case OPC2_32_RR_MOV_A
:
5468 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_d
[r2
]);
5470 case OPC2_32_RR_MOV_AA
:
5471 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
]);
5473 case OPC2_32_RR_MOV_D
:
5474 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_a
[r2
]);
5476 case OPC2_32_RR_NE_A
:
5477 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
5480 case OPC2_32_RR_NEZ_A
:
5481 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
5483 case OPC2_32_RR_SUB_A
:
5484 tcg_gen_sub_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
5489 static void decode_rr_idirect(CPUTriCoreState
*env
, DisasContext
*ctx
)
5494 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5495 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5499 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
5501 case OPC2_32_RR_JLI
:
5502 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->next_pc
);
5503 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
5505 case OPC2_32_RR_CALLI
:
5506 gen_helper_1arg(call
, ctx
->next_pc
);
5507 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
5511 ctx
->bstate
= BS_BRANCH
;
5514 static void decode_rr_divide(CPUTriCoreState
*env
, DisasContext
*ctx
)
5521 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5522 r3
= MASK_OP_RR_D(ctx
->opcode
);
5523 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5524 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5527 case OPC2_32_RR_BMERGE
:
5528 gen_helper_bmerge(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5530 case OPC2_32_RR_BSPLIT
:
5531 gen_bsplit(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
5533 case OPC2_32_RR_DVINIT_B
:
5534 gen_dvinit_b(env
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
5537 case OPC2_32_RR_DVINIT_BU
:
5538 temp
= tcg_temp_new();
5539 temp2
= tcg_temp_new();
5541 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
5542 if (!tricore_feature(env
, TRICORE_FEATURE_131
)) {
5543 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
5544 tcg_gen_neg_tl(temp
, cpu_gpr_d
[r3
+1]);
5545 /* use cpu_PSW_AV to compare against 0 */
5546 tcg_gen_movcond_tl(TCG_COND_LT
, temp
, cpu_gpr_d
[r3
+1], cpu_PSW_AV
,
5547 temp
, cpu_gpr_d
[r3
+1]);
5548 tcg_gen_neg_tl(temp2
, cpu_gpr_d
[r2
]);
5549 tcg_gen_movcond_tl(TCG_COND_LT
, temp2
, cpu_gpr_d
[r2
], cpu_PSW_AV
,
5550 temp2
, cpu_gpr_d
[r2
]);
5551 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
5553 /* overflow = (D[b] == 0) */
5554 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
5556 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
5558 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
5560 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 8);
5561 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 24);
5562 tcg_gen_mov_tl(cpu_gpr_d
[r3
+1], temp
);
5564 tcg_temp_free(temp
);
5565 tcg_temp_free(temp2
);
5567 case OPC2_32_RR_DVINIT_H
:
5568 gen_dvinit_h(env
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
5571 case OPC2_32_RR_DVINIT_HU
:
5572 temp
= tcg_temp_new();
5573 temp2
= tcg_temp_new();
5575 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
5576 if (!tricore_feature(env
, TRICORE_FEATURE_131
)) {
5577 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
5578 tcg_gen_neg_tl(temp
, cpu_gpr_d
[r3
+1]);
5579 /* use cpu_PSW_AV to compare against 0 */
5580 tcg_gen_movcond_tl(TCG_COND_LT
, temp
, cpu_gpr_d
[r3
+1], cpu_PSW_AV
,
5581 temp
, cpu_gpr_d
[r3
+1]);
5582 tcg_gen_neg_tl(temp2
, cpu_gpr_d
[r2
]);
5583 tcg_gen_movcond_tl(TCG_COND_LT
, temp2
, cpu_gpr_d
[r2
], cpu_PSW_AV
,
5584 temp2
, cpu_gpr_d
[r2
]);
5585 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
5587 /* overflow = (D[b] == 0) */
5588 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
5590 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
5592 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
5594 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
5595 tcg_gen_shri_tl(cpu_gpr_d
[r3
+1], temp
, 16);
5596 tcg_gen_shli_tl(cpu_gpr_d
[r3
], temp
, 16);
5597 tcg_temp_free(temp
);
5598 tcg_temp_free(temp2
);
5600 case OPC2_32_RR_DVINIT
:
5601 temp
= tcg_temp_new();
5602 temp2
= tcg_temp_new();
5603 /* overflow = ((D[b] == 0) ||
5604 ((D[b] == 0xFFFFFFFF) && (D[a] == 0x80000000))) */
5605 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, cpu_gpr_d
[r2
], 0xffffffff);
5606 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r1
], 0x80000000);
5607 tcg_gen_and_tl(temp
, temp
, temp2
);
5608 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r2
], 0);
5609 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
5610 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
5612 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
5614 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
5616 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5617 /* sign extend to high reg */
5618 tcg_gen_sari_tl(cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], 31);
5619 tcg_temp_free(temp
);
5620 tcg_temp_free(temp2
);
5622 case OPC2_32_RR_DVINIT_U
:
5623 /* overflow = (D[b] == 0) */
5624 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
5625 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
5627 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
5629 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
5631 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5632 /* zero extend to high reg*/
5633 tcg_gen_movi_tl(cpu_gpr_d
[r3
+1], 0);
5635 case OPC2_32_RR_PARITY
:
5636 gen_helper_parity(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5638 case OPC2_32_RR_UNPACK
:
5639 gen_unpack(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
5645 static void decode_rr1_mul(CPUTriCoreState
*env
, DisasContext
*ctx
)
5653 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
5654 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
5655 r3
= MASK_OP_RR1_D(ctx
->opcode
);
5656 n
= tcg_const_i32(MASK_OP_RR1_N(ctx
->opcode
));
5657 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
5660 case OPC2_32_RR1_MUL_H_32_LL
:
5661 temp64
= tcg_temp_new_i64();
5662 GEN_HELPER_LL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5663 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5664 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
5665 tcg_temp_free_i64(temp64
);
5667 case OPC2_32_RR1_MUL_H_32_LU
:
5668 temp64
= tcg_temp_new_i64();
5669 GEN_HELPER_LU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5670 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5671 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
5672 tcg_temp_free_i64(temp64
);
5674 case OPC2_32_RR1_MUL_H_32_UL
:
5675 temp64
= tcg_temp_new_i64();
5676 GEN_HELPER_UL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5677 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5678 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
5679 tcg_temp_free_i64(temp64
);
5681 case OPC2_32_RR1_MUL_H_32_UU
:
5682 temp64
= tcg_temp_new_i64();
5683 GEN_HELPER_UU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5684 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5685 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
5686 tcg_temp_free_i64(temp64
);
5688 case OPC2_32_RR1_MULM_H_64_LL
:
5689 temp64
= tcg_temp_new_i64();
5690 GEN_HELPER_LL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5691 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5693 tcg_gen_movi_tl(cpu_PSW_V
, 0);
5695 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
5696 tcg_temp_free_i64(temp64
);
5698 case OPC2_32_RR1_MULM_H_64_LU
:
5699 temp64
= tcg_temp_new_i64();
5700 GEN_HELPER_LU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5701 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5703 tcg_gen_movi_tl(cpu_PSW_V
, 0);
5705 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
5706 tcg_temp_free_i64(temp64
);
5708 case OPC2_32_RR1_MULM_H_64_UL
:
5709 temp64
= tcg_temp_new_i64();
5710 GEN_HELPER_UL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5711 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5713 tcg_gen_movi_tl(cpu_PSW_V
, 0);
5715 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
5716 tcg_temp_free_i64(temp64
);
5718 case OPC2_32_RR1_MULM_H_64_UU
:
5719 temp64
= tcg_temp_new_i64();
5720 GEN_HELPER_UU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5721 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
5723 tcg_gen_movi_tl(cpu_PSW_V
, 0);
5725 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
5726 tcg_temp_free_i64(temp64
);
5729 case OPC2_32_RR1_MULR_H_16_LL
:
5730 GEN_HELPER_LL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5731 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
5733 case OPC2_32_RR1_MULR_H_16_LU
:
5734 GEN_HELPER_LU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5735 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
5737 case OPC2_32_RR1_MULR_H_16_UL
:
5738 GEN_HELPER_UL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5739 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
5741 case OPC2_32_RR1_MULR_H_16_UU
:
5742 GEN_HELPER_UU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
5743 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
5749 static void decode_rr1_mulq(CPUTriCoreState
*env
, DisasContext
*ctx
)
5757 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
5758 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
5759 r3
= MASK_OP_RR1_D(ctx
->opcode
);
5760 n
= MASK_OP_RR1_N(ctx
->opcode
);
5761 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
5763 temp
= tcg_temp_new();
5764 temp2
= tcg_temp_new();
5767 case OPC2_32_RR1_MUL_Q_32
:
5768 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 32);
5770 case OPC2_32_RR1_MUL_Q_64
:
5771 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
5774 case OPC2_32_RR1_MUL_Q_32_L
:
5775 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
5776 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
5778 case OPC2_32_RR1_MUL_Q_64_L
:
5779 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
5780 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
5782 case OPC2_32_RR1_MUL_Q_32_U
:
5783 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
5784 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
5786 case OPC2_32_RR1_MUL_Q_64_U
:
5787 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
5788 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
5790 case OPC2_32_RR1_MUL_Q_32_LL
:
5791 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
5792 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
5793 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
5795 case OPC2_32_RR1_MUL_Q_32_UU
:
5796 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
5797 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
5798 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
5800 case OPC2_32_RR1_MULR_Q_32_L
:
5801 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
5802 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
5803 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
5805 case OPC2_32_RR1_MULR_Q_32_U
:
5806 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
5807 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
5808 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
5811 tcg_temp_free(temp
);
5812 tcg_temp_free(temp2
);
5816 static void decode_rr2_mul(CPUTriCoreState
*env
, DisasContext
*ctx
)
5821 op2
= MASK_OP_RR2_OP2(ctx
->opcode
);
5822 r1
= MASK_OP_RR2_S1(ctx
->opcode
);
5823 r2
= MASK_OP_RR2_S2(ctx
->opcode
);
5824 r3
= MASK_OP_RR2_D(ctx
->opcode
);
5826 case OPC2_32_RR2_MUL_32
:
5827 gen_mul_i32s(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5829 case OPC2_32_RR2_MUL_64
:
5830 gen_mul_i64s(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
5833 case OPC2_32_RR2_MULS_32
:
5834 gen_helper_mul_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5837 case OPC2_32_RR2_MUL_U_64
:
5838 gen_mul_i64u(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
5841 case OPC2_32_RR2_MULS_U_32
:
5842 gen_helper_mul_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5849 static void decode_rrpw_extract_insert(CPUTriCoreState
*env
, DisasContext
*ctx
)
5855 op2
= MASK_OP_RRPW_OP2(ctx
->opcode
);
5856 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
5857 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
5858 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
5859 pos
= MASK_OP_RRPW_POS(ctx
->opcode
);
5860 width
= MASK_OP_RRPW_WIDTH(ctx
->opcode
);
5863 case OPC2_32_RRPW_EXTR
:
5864 if (pos
+ width
<= 31) {
5865 /* optimize special cases */
5866 if ((pos
== 0) && (width
== 8)) {
5867 tcg_gen_ext8s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5868 } else if ((pos
== 0) && (width
== 16)) {
5869 tcg_gen_ext16s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5871 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 32 - pos
- width
);
5872 tcg_gen_sari_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 32 - width
);
5876 case OPC2_32_RRPW_EXTR_U
:
5878 tcg_gen_movi_tl(cpu_gpr_d
[r3
], 0);
5880 tcg_gen_shri_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], pos
);
5881 tcg_gen_andi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], ~0u >> (32-width
));
5884 case OPC2_32_RRPW_IMASK
:
5885 if (pos
+ width
<= 31) {
5886 tcg_gen_movi_tl(cpu_gpr_d
[r3
+1], ((1u << width
) - 1) << pos
);
5887 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], pos
);
5890 case OPC2_32_RRPW_INSERT
:
5891 if (pos
+ width
<= 31) {
5892 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
5900 static void decode_rrr_cond_select(CPUTriCoreState
*env
, DisasContext
*ctx
)
5906 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
5907 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
5908 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
5909 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
5910 r4
= MASK_OP_RRR_D(ctx
->opcode
);
5913 case OPC2_32_RRR_CADD
:
5914 gen_cond_add(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
5915 cpu_gpr_d
[r4
], cpu_gpr_d
[r3
]);
5917 case OPC2_32_RRR_CADDN
:
5918 gen_cond_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
5921 case OPC2_32_RRR_CSUB
:
5922 gen_cond_sub(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
5925 case OPC2_32_RRR_CSUBN
:
5926 gen_cond_sub(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
5929 case OPC2_32_RRR_SEL
:
5930 temp
= tcg_const_i32(0);
5931 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5932 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5933 tcg_temp_free(temp
);
5935 case OPC2_32_RRR_SELN
:
5936 temp
= tcg_const_i32(0);
5937 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5938 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5939 tcg_temp_free(temp
);
5944 static void decode_rrr_divide(CPUTriCoreState
*env
, DisasContext
*ctx
)
5950 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
5951 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
5952 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
5953 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
5954 r4
= MASK_OP_RRR_D(ctx
->opcode
);
5957 case OPC2_32_RRR_DVADJ
:
5958 GEN_HELPER_RRR(dvadj
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5959 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5961 case OPC2_32_RRR_DVSTEP
:
5962 GEN_HELPER_RRR(dvstep
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5963 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5965 case OPC2_32_RRR_DVSTEP_U
:
5966 GEN_HELPER_RRR(dvstep_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5967 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5969 case OPC2_32_RRR_IXMAX
:
5970 GEN_HELPER_RRR(ixmax
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5971 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5973 case OPC2_32_RRR_IXMAX_U
:
5974 GEN_HELPER_RRR(ixmax_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5975 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5977 case OPC2_32_RRR_IXMIN
:
5978 GEN_HELPER_RRR(ixmin
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5979 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5981 case OPC2_32_RRR_IXMIN_U
:
5982 GEN_HELPER_RRR(ixmin_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
5983 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
5985 case OPC2_32_RRR_PACK
:
5986 gen_helper_pack(cpu_gpr_d
[r4
], cpu_PSW_C
, cpu_gpr_d
[r3
],
5987 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
5993 static void decode_rrr2_madd(CPUTriCoreState
*env
, DisasContext
*ctx
)
5996 uint32_t r1
, r2
, r3
, r4
;
5998 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
5999 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
6000 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
6001 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
6002 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
6004 case OPC2_32_RRR2_MADD_32
:
6005 gen_madd32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
6008 case OPC2_32_RRR2_MADD_64
:
6009 gen_madd64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6010 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6012 case OPC2_32_RRR2_MADDS_32
:
6013 gen_helper_madd32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6014 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6016 case OPC2_32_RRR2_MADDS_64
:
6017 gen_madds_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6018 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6020 case OPC2_32_RRR2_MADD_U_64
:
6021 gen_maddu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6022 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6024 case OPC2_32_RRR2_MADDS_U_32
:
6025 gen_helper_madd32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6026 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6028 case OPC2_32_RRR2_MADDS_U_64
:
6029 gen_maddsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6030 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6035 static void decode_rrr2_msub(CPUTriCoreState
*env
, DisasContext
*ctx
)
6038 uint32_t r1
, r2
, r3
, r4
;
6040 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
6041 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
6042 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
6043 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
6044 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
6047 case OPC2_32_RRR2_MSUB_32
:
6048 gen_msub32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
6051 case OPC2_32_RRR2_MSUB_64
:
6052 gen_msub64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6053 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6055 case OPC2_32_RRR2_MSUBS_32
:
6056 gen_helper_msub32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6057 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6059 case OPC2_32_RRR2_MSUBS_64
:
6060 gen_msubs_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6061 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6063 case OPC2_32_RRR2_MSUB_U_64
:
6064 gen_msubu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6065 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6067 case OPC2_32_RRR2_MSUBS_U_32
:
6068 gen_helper_msub32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6069 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6071 case OPC2_32_RRR2_MSUBS_U_64
:
6072 gen_msubsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6073 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6079 static void decode_rrr1_madd(CPUTriCoreState
*env
, DisasContext
*ctx
)
6082 uint32_t r1
, r2
, r3
, r4
, n
;
6084 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
6085 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
6086 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
6087 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
6088 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
6089 n
= MASK_OP_RRR1_N(ctx
->opcode
);
6092 case OPC2_32_RRR1_MADD_H_LL
:
6093 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6094 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6096 case OPC2_32_RRR1_MADD_H_LU
:
6097 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6098 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6100 case OPC2_32_RRR1_MADD_H_UL
:
6101 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6102 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6104 case OPC2_32_RRR1_MADD_H_UU
:
6105 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6106 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6108 case OPC2_32_RRR1_MADDS_H_LL
:
6109 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6110 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6112 case OPC2_32_RRR1_MADDS_H_LU
:
6113 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6114 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6116 case OPC2_32_RRR1_MADDS_H_UL
:
6117 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6118 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6120 case OPC2_32_RRR1_MADDS_H_UU
:
6121 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6122 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6124 case OPC2_32_RRR1_MADDM_H_LL
:
6125 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6126 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6128 case OPC2_32_RRR1_MADDM_H_LU
:
6129 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6130 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6132 case OPC2_32_RRR1_MADDM_H_UL
:
6133 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6134 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6136 case OPC2_32_RRR1_MADDM_H_UU
:
6137 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6138 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6140 case OPC2_32_RRR1_MADDMS_H_LL
:
6141 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6142 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6144 case OPC2_32_RRR1_MADDMS_H_LU
:
6145 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6146 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6148 case OPC2_32_RRR1_MADDMS_H_UL
:
6149 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6150 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6152 case OPC2_32_RRR1_MADDMS_H_UU
:
6153 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6154 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6156 case OPC2_32_RRR1_MADDR_H_LL
:
6157 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6158 cpu_gpr_d
[r2
], n
, MODE_LL
);
6160 case OPC2_32_RRR1_MADDR_H_LU
:
6161 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6162 cpu_gpr_d
[r2
], n
, MODE_LU
);
6164 case OPC2_32_RRR1_MADDR_H_UL
:
6165 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6166 cpu_gpr_d
[r2
], n
, MODE_UL
);
6168 case OPC2_32_RRR1_MADDR_H_UU
:
6169 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6170 cpu_gpr_d
[r2
], n
, MODE_UU
);
6172 case OPC2_32_RRR1_MADDRS_H_LL
:
6173 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6174 cpu_gpr_d
[r2
], n
, MODE_LL
);
6176 case OPC2_32_RRR1_MADDRS_H_LU
:
6177 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6178 cpu_gpr_d
[r2
], n
, MODE_LU
);
6180 case OPC2_32_RRR1_MADDRS_H_UL
:
6181 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6182 cpu_gpr_d
[r2
], n
, MODE_UL
);
6184 case OPC2_32_RRR1_MADDRS_H_UU
:
6185 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6186 cpu_gpr_d
[r2
], n
, MODE_UU
);
6191 static void decode_rrr1_maddq_h(CPUTriCoreState
*env
, DisasContext
*ctx
)
6194 uint32_t r1
, r2
, r3
, r4
, n
;
6197 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
6198 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
6199 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
6200 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
6201 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
6202 n
= MASK_OP_RRR1_N(ctx
->opcode
);
6204 temp
= tcg_const_i32(n
);
6205 temp2
= tcg_temp_new();
6208 case OPC2_32_RRR1_MADD_Q_32
:
6209 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6210 cpu_gpr_d
[r2
], n
, 32, env
);
6212 case OPC2_32_RRR1_MADD_Q_64
:
6213 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6214 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6217 case OPC2_32_RRR1_MADD_Q_32_L
:
6218 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6219 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6222 case OPC2_32_RRR1_MADD_Q_64_L
:
6223 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6224 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6225 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6228 case OPC2_32_RRR1_MADD_Q_32_U
:
6229 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6230 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6233 case OPC2_32_RRR1_MADD_Q_64_U
:
6234 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6235 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6236 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6239 case OPC2_32_RRR1_MADD_Q_32_LL
:
6240 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6241 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6242 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6244 case OPC2_32_RRR1_MADD_Q_64_LL
:
6245 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6246 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6247 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6248 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6250 case OPC2_32_RRR1_MADD_Q_32_UU
:
6251 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6252 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6253 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6255 case OPC2_32_RRR1_MADD_Q_64_UU
:
6256 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6257 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6258 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6259 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6261 case OPC2_32_RRR1_MADDS_Q_32
:
6262 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6263 cpu_gpr_d
[r2
], n
, 32);
6265 case OPC2_32_RRR1_MADDS_Q_64
:
6266 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6267 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6270 case OPC2_32_RRR1_MADDS_Q_32_L
:
6271 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6272 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6275 case OPC2_32_RRR1_MADDS_Q_64_L
:
6276 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6277 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6278 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6281 case OPC2_32_RRR1_MADDS_Q_32_U
:
6282 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6283 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6286 case OPC2_32_RRR1_MADDS_Q_64_U
:
6287 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6288 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6289 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6292 case OPC2_32_RRR1_MADDS_Q_32_LL
:
6293 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6294 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6295 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6297 case OPC2_32_RRR1_MADDS_Q_64_LL
:
6298 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6299 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6300 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6301 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6303 case OPC2_32_RRR1_MADDS_Q_32_UU
:
6304 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6305 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6306 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6308 case OPC2_32_RRR1_MADDS_Q_64_UU
:
6309 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6310 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6311 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6312 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6314 case OPC2_32_RRR1_MADDR_H_64_UL
:
6315 gen_maddr64_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
6316 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
6318 case OPC2_32_RRR1_MADDRS_H_64_UL
:
6319 gen_maddr64s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
6320 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
6322 case OPC2_32_RRR1_MADDR_Q_32_LL
:
6323 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6324 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6325 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6327 case OPC2_32_RRR1_MADDR_Q_32_UU
:
6328 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6329 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6330 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6332 case OPC2_32_RRR1_MADDRS_Q_32_LL
:
6333 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6334 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6335 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6337 case OPC2_32_RRR1_MADDRS_Q_32_UU
:
6338 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6339 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6340 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6343 tcg_temp_free(temp
);
6344 tcg_temp_free(temp2
);
6347 static void decode_rrr1_maddsu_h(CPUTriCoreState
*env
, DisasContext
*ctx
)
6350 uint32_t r1
, r2
, r3
, r4
, n
;
6352 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
6353 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
6354 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
6355 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
6356 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
6357 n
= MASK_OP_RRR1_N(ctx
->opcode
);
6360 case OPC2_32_RRR1_MADDSU_H_32_LL
:
6361 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6362 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6364 case OPC2_32_RRR1_MADDSU_H_32_LU
:
6365 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6366 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6368 case OPC2_32_RRR1_MADDSU_H_32_UL
:
6369 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6370 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6372 case OPC2_32_RRR1_MADDSU_H_32_UU
:
6373 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6374 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6376 case OPC2_32_RRR1_MADDSUS_H_32_LL
:
6377 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6378 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6381 case OPC2_32_RRR1_MADDSUS_H_32_LU
:
6382 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6383 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6386 case OPC2_32_RRR1_MADDSUS_H_32_UL
:
6387 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6388 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6391 case OPC2_32_RRR1_MADDSUS_H_32_UU
:
6392 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6393 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6396 case OPC2_32_RRR1_MADDSUM_H_64_LL
:
6397 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6398 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6401 case OPC2_32_RRR1_MADDSUM_H_64_LU
:
6402 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6403 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6406 case OPC2_32_RRR1_MADDSUM_H_64_UL
:
6407 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6408 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6411 case OPC2_32_RRR1_MADDSUM_H_64_UU
:
6412 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6413 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6416 case OPC2_32_RRR1_MADDSUMS_H_64_LL
:
6417 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6418 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6421 case OPC2_32_RRR1_MADDSUMS_H_64_LU
:
6422 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6423 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6426 case OPC2_32_RRR1_MADDSUMS_H_64_UL
:
6427 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6428 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6431 case OPC2_32_RRR1_MADDSUMS_H_64_UU
:
6432 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6433 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6436 case OPC2_32_RRR1_MADDSUR_H_16_LL
:
6437 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6438 cpu_gpr_d
[r2
], n
, MODE_LL
);
6440 case OPC2_32_RRR1_MADDSUR_H_16_LU
:
6441 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6442 cpu_gpr_d
[r2
], n
, MODE_LU
);
6444 case OPC2_32_RRR1_MADDSUR_H_16_UL
:
6445 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6446 cpu_gpr_d
[r2
], n
, MODE_UL
);
6448 case OPC2_32_RRR1_MADDSUR_H_16_UU
:
6449 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6450 cpu_gpr_d
[r2
], n
, MODE_UU
);
6452 case OPC2_32_RRR1_MADDSURS_H_16_LL
:
6453 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6454 cpu_gpr_d
[r2
], n
, MODE_LL
);
6456 case OPC2_32_RRR1_MADDSURS_H_16_LU
:
6457 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6458 cpu_gpr_d
[r2
], n
, MODE_LU
);
6460 case OPC2_32_RRR1_MADDSURS_H_16_UL
:
6461 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6462 cpu_gpr_d
[r2
], n
, MODE_UL
);
6464 case OPC2_32_RRR1_MADDSURS_H_16_UU
:
6465 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6466 cpu_gpr_d
[r2
], n
, MODE_UU
);
6471 static void decode_32Bit_opc(CPUTriCoreState
*env
, DisasContext
*ctx
)
6475 int32_t address
, const16
;
6478 TCGv temp
, temp2
, temp3
;
6480 op1
= MASK_OP_MAJOR(ctx
->opcode
);
6482 /* handle JNZ.T opcode only being 7 bit long */
6483 if (unlikely((op1
& 0x7f) == OPCM_32_BRN_JTT
)) {
6484 op1
= OPCM_32_BRN_JTT
;
6489 case OPCM_32_ABS_LDW
:
6490 decode_abs_ldw(env
, ctx
);
6492 case OPCM_32_ABS_LDB
:
6493 decode_abs_ldb(env
, ctx
);
6495 case OPCM_32_ABS_LDMST_SWAP
:
6496 decode_abs_ldst_swap(env
, ctx
);
6498 case OPCM_32_ABS_LDST_CONTEXT
:
6499 decode_abs_ldst_context(env
, ctx
);
6501 case OPCM_32_ABS_STORE
:
6502 decode_abs_store(env
, ctx
);
6504 case OPCM_32_ABS_STOREB_H
:
6505 decode_abs_storeb_h(env
, ctx
);
6507 case OPC1_32_ABS_STOREQ
:
6508 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
6509 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
6510 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
6511 temp2
= tcg_temp_new();
6513 tcg_gen_shri_tl(temp2
, cpu_gpr_d
[r1
], 16);
6514 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_LEUW
);
6516 tcg_temp_free(temp2
);
6517 tcg_temp_free(temp
);
6519 case OPC1_32_ABS_LD_Q
:
6520 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
6521 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
6522 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
6524 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
6525 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
6527 tcg_temp_free(temp
);
6529 case OPC1_32_ABS_LEA
:
6530 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
6531 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
6532 tcg_gen_movi_tl(cpu_gpr_a
[r1
], EA_ABS_FORMAT(address
));
6535 case OPC1_32_ABSB_ST_T
:
6536 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
6537 b
= MASK_OP_ABSB_B(ctx
->opcode
);
6538 bpos
= MASK_OP_ABSB_BPOS(ctx
->opcode
);
6540 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
6541 temp2
= tcg_temp_new();
6543 tcg_gen_qemu_ld_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
6544 tcg_gen_andi_tl(temp2
, temp2
, ~(0x1u
<< bpos
));
6545 tcg_gen_ori_tl(temp2
, temp2
, (b
<< bpos
));
6546 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
6548 tcg_temp_free(temp
);
6549 tcg_temp_free(temp2
);
6552 case OPC1_32_B_CALL
:
6553 case OPC1_32_B_CALLA
:
6558 address
= MASK_OP_B_DISP24_SEXT(ctx
->opcode
);
6559 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
6562 case OPCM_32_BIT_ANDACC
:
6563 decode_bit_andacc(env
, ctx
);
6565 case OPCM_32_BIT_LOGICAL_T1
:
6566 decode_bit_logical_t(env
, ctx
);
6568 case OPCM_32_BIT_INSERT
:
6569 decode_bit_insert(env
, ctx
);
6571 case OPCM_32_BIT_LOGICAL_T2
:
6572 decode_bit_logical_t2(env
, ctx
);
6574 case OPCM_32_BIT_ORAND
:
6575 decode_bit_orand(env
, ctx
);
6577 case OPCM_32_BIT_SH_LOGIC1
:
6578 decode_bit_sh_logic1(env
, ctx
);
6580 case OPCM_32_BIT_SH_LOGIC2
:
6581 decode_bit_sh_logic2(env
, ctx
);
6584 case OPCM_32_BO_ADDRMODE_POST_PRE_BASE
:
6585 decode_bo_addrmode_post_pre_base(env
, ctx
);
6587 case OPCM_32_BO_ADDRMODE_BITREVERSE_CIRCULAR
:
6588 decode_bo_addrmode_bitreverse_circular(env
, ctx
);
6590 case OPCM_32_BO_ADDRMODE_LD_POST_PRE_BASE
:
6591 decode_bo_addrmode_ld_post_pre_base(env
, ctx
);
6593 case OPCM_32_BO_ADDRMODE_LD_BITREVERSE_CIRCULAR
:
6594 decode_bo_addrmode_ld_bitreverse_circular(env
, ctx
);
6596 case OPCM_32_BO_ADDRMODE_STCTX_POST_PRE_BASE
:
6597 decode_bo_addrmode_stctx_post_pre_base(env
, ctx
);
6599 case OPCM_32_BO_ADDRMODE_LDMST_BITREVERSE_CIRCULAR
:
6600 decode_bo_addrmode_ldmst_bitreverse_circular(env
, ctx
);
6603 case OPC1_32_BOL_LD_A_LONGOFF
:
6604 case OPC1_32_BOL_LD_W_LONGOFF
:
6605 case OPC1_32_BOL_LEA_LONGOFF
:
6606 case OPC1_32_BOL_ST_W_LONGOFF
:
6607 case OPC1_32_BOL_ST_A_LONGOFF
:
6608 case OPC1_32_BOL_LD_B_LONGOFF
:
6609 case OPC1_32_BOL_LD_BU_LONGOFF
:
6610 case OPC1_32_BOL_LD_H_LONGOFF
:
6611 case OPC1_32_BOL_LD_HU_LONGOFF
:
6612 case OPC1_32_BOL_ST_B_LONGOFF
:
6613 case OPC1_32_BOL_ST_H_LONGOFF
:
6614 decode_bol_opc(env
, ctx
, op1
);
6617 case OPCM_32_BRC_EQ_NEQ
:
6618 case OPCM_32_BRC_GE
:
6619 case OPCM_32_BRC_JLT
:
6620 case OPCM_32_BRC_JNE
:
6621 const4
= MASK_OP_BRC_CONST4_SEXT(ctx
->opcode
);
6622 address
= MASK_OP_BRC_DISP15_SEXT(ctx
->opcode
);
6623 r1
= MASK_OP_BRC_S1(ctx
->opcode
);
6624 gen_compute_branch(ctx
, op1
, r1
, 0, const4
, address
);
6627 case OPCM_32_BRN_JTT
:
6628 address
= MASK_OP_BRN_DISP15_SEXT(ctx
->opcode
);
6629 r1
= MASK_OP_BRN_S1(ctx
->opcode
);
6630 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
6633 case OPCM_32_BRR_EQ_NEQ
:
6634 case OPCM_32_BRR_ADDR_EQ_NEQ
:
6635 case OPCM_32_BRR_GE
:
6636 case OPCM_32_BRR_JLT
:
6637 case OPCM_32_BRR_JNE
:
6638 case OPCM_32_BRR_JNZ
:
6639 case OPCM_32_BRR_LOOP
:
6640 address
= MASK_OP_BRR_DISP15_SEXT(ctx
->opcode
);
6641 r2
= MASK_OP_BRR_S2(ctx
->opcode
);
6642 r1
= MASK_OP_BRR_S1(ctx
->opcode
);
6643 gen_compute_branch(ctx
, op1
, r1
, r2
, 0, address
);
6646 case OPCM_32_RC_LOGICAL_SHIFT
:
6647 decode_rc_logical_shift(env
, ctx
);
6649 case OPCM_32_RC_ACCUMULATOR
:
6650 decode_rc_accumulator(env
, ctx
);
6652 case OPCM_32_RC_SERVICEROUTINE
:
6653 decode_rc_serviceroutine(env
, ctx
);
6655 case OPCM_32_RC_MUL
:
6656 decode_rc_mul(env
, ctx
);
6659 case OPCM_32_RCPW_MASK_INSERT
:
6660 decode_rcpw_insert(env
, ctx
);
6663 case OPC1_32_RCRR_INSERT
:
6664 r1
= MASK_OP_RCRR_S1(ctx
->opcode
);
6665 r2
= MASK_OP_RCRR_S3(ctx
->opcode
);
6666 r3
= MASK_OP_RCRR_D(ctx
->opcode
);
6667 const16
= MASK_OP_RCRR_CONST4(ctx
->opcode
);
6668 temp
= tcg_const_i32(const16
);
6669 temp2
= tcg_temp_new(); /* width*/
6670 temp3
= tcg_temp_new(); /* pos */
6672 tcg_gen_andi_tl(temp2
, cpu_gpr_d
[r3
+1], 0x1f);
6673 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r3
], 0x1f);
6675 gen_insert(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, temp2
, temp3
);
6677 tcg_temp_free(temp
);
6678 tcg_temp_free(temp2
);
6679 tcg_temp_free(temp3
);
6682 case OPCM_32_RCRW_MASK_INSERT
:
6683 decode_rcrw_insert(env
, ctx
);
6686 case OPCM_32_RCR_COND_SELECT
:
6687 decode_rcr_cond_select(env
, ctx
);
6689 case OPCM_32_RCR_MADD
:
6690 decode_rcr_madd(env
, ctx
);
6692 case OPCM_32_RCR_MSUB
:
6693 decode_rcr_msub(env
, ctx
);
6696 case OPC1_32_RLC_ADDI
:
6697 case OPC1_32_RLC_ADDIH
:
6698 case OPC1_32_RLC_ADDIH_A
:
6699 case OPC1_32_RLC_MFCR
:
6700 case OPC1_32_RLC_MOV
:
6701 case OPC1_32_RLC_MOV_64
:
6702 case OPC1_32_RLC_MOV_U
:
6703 case OPC1_32_RLC_MOV_H
:
6704 case OPC1_32_RLC_MOVH_A
:
6705 case OPC1_32_RLC_MTCR
:
6706 decode_rlc_opc(env
, ctx
, op1
);
6709 case OPCM_32_RR_ACCUMULATOR
:
6710 decode_rr_accumulator(env
, ctx
);
6712 case OPCM_32_RR_LOGICAL_SHIFT
:
6713 decode_rr_logical_shift(env
, ctx
);
6715 case OPCM_32_RR_ADDRESS
:
6716 decode_rr_address(env
, ctx
);
6718 case OPCM_32_RR_IDIRECT
:
6719 decode_rr_idirect(env
, ctx
);
6721 case OPCM_32_RR_DIVIDE
:
6722 decode_rr_divide(env
, ctx
);
6725 case OPCM_32_RR1_MUL
:
6726 decode_rr1_mul(env
, ctx
);
6728 case OPCM_32_RR1_MULQ
:
6729 decode_rr1_mulq(env
, ctx
);
6732 case OPCM_32_RR2_MUL
:
6733 decode_rr2_mul(env
, ctx
);
6736 case OPCM_32_RRPW_EXTRACT_INSERT
:
6737 decode_rrpw_extract_insert(env
, ctx
);
6739 case OPC1_32_RRPW_DEXTR
:
6740 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
6741 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
6742 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
6743 const16
= MASK_OP_RRPW_POS(ctx
->opcode
);
6745 tcg_gen_rotli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], const16
);
6747 temp
= tcg_temp_new();
6748 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], const16
);
6749 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 32 - const16
);
6750 tcg_gen_or_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
6751 tcg_temp_free(temp
);
6755 case OPCM_32_RRR_COND_SELECT
:
6756 decode_rrr_cond_select(env
, ctx
);
6758 case OPCM_32_RRR_DIVIDE
:
6759 decode_rrr_divide(env
, ctx
);
6761 case OPCM_32_RRR2_MADD
:
6762 decode_rrr2_madd(env
, ctx
);
6764 case OPCM_32_RRR2_MSUB
:
6765 decode_rrr2_msub(env
, ctx
);
6768 case OPCM_32_RRR1_MADD
:
6769 decode_rrr1_madd(env
, ctx
);
6771 case OPCM_32_RRR1_MADDQ_H
:
6772 decode_rrr1_maddq_h(env
, ctx
);
6774 case OPCM_32_RRR1_MADDSU_H
:
6775 decode_rrr1_maddsu_h(env
, ctx
);
6780 static void decode_opc(CPUTriCoreState
*env
, DisasContext
*ctx
, int *is_branch
)
6782 /* 16-Bit Instruction */
6783 if ((ctx
->opcode
& 0x1) == 0) {
6784 ctx
->next_pc
= ctx
->pc
+ 2;
6785 decode_16Bit_opc(env
, ctx
);
6786 /* 32-Bit Instruction */
6788 ctx
->next_pc
= ctx
->pc
+ 4;
6789 decode_32Bit_opc(env
, ctx
);
6794 gen_intermediate_code_internal(TriCoreCPU
*cpu
, struct TranslationBlock
*tb
,
6797 CPUState
*cs
= CPU(cpu
);
6798 CPUTriCoreState
*env
= &cpu
->env
;
6800 target_ulong pc_start
;
6804 qemu_log("search pc %d\n", search_pc
);
6812 ctx
.singlestep_enabled
= cs
->singlestep_enabled
;
6813 ctx
.bstate
= BS_NONE
;
6814 ctx
.mem_idx
= cpu_mmu_index(env
);
6816 tcg_clear_temp_count();
6818 while (ctx
.bstate
== BS_NONE
) {
6819 ctx
.opcode
= cpu_ldl_code(env
, ctx
.pc
);
6820 decode_opc(env
, &ctx
, 0);
6824 if (tcg_op_buf_full()) {
6825 gen_save_pc(ctx
.next_pc
);
6830 gen_save_pc(ctx
.next_pc
);
6834 ctx
.pc
= ctx
.next_pc
;
6837 gen_tb_end(tb
, num_insns
);
6839 printf("done_generating search pc\n");
6841 tb
->size
= ctx
.pc
- pc_start
;
6842 tb
->icount
= num_insns
;
6844 if (tcg_check_temp_count()) {
6845 printf("LEAK at %08x\n", env
->PC
);
6849 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
6850 qemu_log("IN: %s\n", lookup_symbol(pc_start
));
6851 log_target_disas(env
, pc_start
, ctx
.pc
- pc_start
, 0);
6858 gen_intermediate_code(CPUTriCoreState
*env
, struct TranslationBlock
*tb
)
6860 gen_intermediate_code_internal(tricore_env_get_cpu(env
), tb
, false);
6864 gen_intermediate_code_pc(CPUTriCoreState
*env
, struct TranslationBlock
*tb
)
6866 gen_intermediate_code_internal(tricore_env_get_cpu(env
), tb
, true);
6870 restore_state_to_opc(CPUTriCoreState
*env
, TranslationBlock
*tb
, int pc_pos
)
6872 env
->PC
= tcg_ctx
.gen_opc_pc
[pc_pos
];
6880 void cpu_state_reset(CPUTriCoreState
*env
)
6882 /* Reset Regs to Default Value */
6886 static void tricore_tcg_init_csfr(void)
6888 cpu_PCXI
= tcg_global_mem_new(TCG_AREG0
,
6889 offsetof(CPUTriCoreState
, PCXI
), "PCXI");
6890 cpu_PSW
= tcg_global_mem_new(TCG_AREG0
,
6891 offsetof(CPUTriCoreState
, PSW
), "PSW");
6892 cpu_PC
= tcg_global_mem_new(TCG_AREG0
,
6893 offsetof(CPUTriCoreState
, PC
), "PC");
6894 cpu_ICR
= tcg_global_mem_new(TCG_AREG0
,
6895 offsetof(CPUTriCoreState
, ICR
), "ICR");
6898 void tricore_tcg_init(void)
6905 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
6907 for (i
= 0 ; i
< 16 ; i
++) {
6908 cpu_gpr_a
[i
] = tcg_global_mem_new(TCG_AREG0
,
6909 offsetof(CPUTriCoreState
, gpr_a
[i
]),
6912 for (i
= 0 ; i
< 16 ; i
++) {
6913 cpu_gpr_d
[i
] = tcg_global_mem_new(TCG_AREG0
,
6914 offsetof(CPUTriCoreState
, gpr_d
[i
]),
6917 tricore_tcg_init_csfr();
6918 /* init PSW flag cache */
6919 cpu_PSW_C
= tcg_global_mem_new(TCG_AREG0
,
6920 offsetof(CPUTriCoreState
, PSW_USB_C
),
6922 cpu_PSW_V
= tcg_global_mem_new(TCG_AREG0
,
6923 offsetof(CPUTriCoreState
, PSW_USB_V
),
6925 cpu_PSW_SV
= tcg_global_mem_new(TCG_AREG0
,
6926 offsetof(CPUTriCoreState
, PSW_USB_SV
),
6928 cpu_PSW_AV
= tcg_global_mem_new(TCG_AREG0
,
6929 offsetof(CPUTriCoreState
, PSW_USB_AV
),
6931 cpu_PSW_SAV
= tcg_global_mem_new(TCG_AREG0
,
6932 offsetof(CPUTriCoreState
, PSW_USB_SAV
),