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.1 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/>.
21 #include "qemu/osdep.h"
23 #include "disas/disas.h"
24 #include "exec/exec-all.h"
25 #include "tcg/tcg-op.h"
26 #include "exec/cpu_ldst.h"
27 #include "qemu/qemu-print.h"
29 #include "exec/helper-proto.h"
30 #include "exec/helper-gen.h"
32 #include "tricore-opcodes.h"
33 #include "exec/translator.h"
44 static TCGv cpu_gpr_a
[16];
45 static TCGv cpu_gpr_d
[16];
47 static TCGv cpu_PSW_C
;
48 static TCGv cpu_PSW_V
;
49 static TCGv cpu_PSW_SV
;
50 static TCGv cpu_PSW_AV
;
51 static TCGv cpu_PSW_SAV
;
53 #include "exec/gen-icount.h"
55 static const char *regnames_a
[] = {
56 "a0" , "a1" , "a2" , "a3" , "a4" , "a5" ,
57 "a6" , "a7" , "a8" , "a9" , "sp" , "a11" ,
58 "a12" , "a13" , "a14" , "a15",
61 static const char *regnames_d
[] = {
62 "d0" , "d1" , "d2" , "d3" , "d4" , "d5" ,
63 "d6" , "d7" , "d8" , "d9" , "d10" , "d11" ,
64 "d12" , "d13" , "d14" , "d15",
67 typedef struct DisasContext
{
68 DisasContextBase base
;
70 target_ulong pc_succ_insn
;
72 /* Routine used to access memory */
74 uint32_t hflags
, saved_hflags
;
84 void tricore_cpu_dump_state(CPUState
*cs
, FILE *f
, int flags
)
86 TriCoreCPU
*cpu
= TRICORE_CPU(cs
);
87 CPUTriCoreState
*env
= &cpu
->env
;
93 qemu_fprintf(f
, "PC: " TARGET_FMT_lx
, env
->PC
);
94 qemu_fprintf(f
, " PSW: " TARGET_FMT_lx
, psw
);
95 qemu_fprintf(f
, " ICR: " TARGET_FMT_lx
, env
->ICR
);
96 qemu_fprintf(f
, "\nPCXI: " TARGET_FMT_lx
, env
->PCXI
);
97 qemu_fprintf(f
, " FCX: " TARGET_FMT_lx
, env
->FCX
);
98 qemu_fprintf(f
, " LCX: " TARGET_FMT_lx
, env
->LCX
);
100 for (i
= 0; i
< 16; ++i
) {
102 qemu_fprintf(f
, "\nGPR A%02d:", i
);
104 qemu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_a
[i
]);
106 for (i
= 0; i
< 16; ++i
) {
108 qemu_fprintf(f
, "\nGPR D%02d:", i
);
110 qemu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_d
[i
]);
112 qemu_fprintf(f
, "\n");
116 * Functions to generate micro-ops
119 /* Makros for generating helpers */
121 #define gen_helper_1arg(name, arg) do { \
122 TCGv_i32 helper_tmp = tcg_const_i32(arg); \
123 gen_helper_##name(cpu_env, helper_tmp); \
124 tcg_temp_free_i32(helper_tmp); \
127 #define GEN_HELPER_LL(name, ret, arg0, arg1, n) do { \
128 TCGv arg00 = tcg_temp_new(); \
129 TCGv arg01 = tcg_temp_new(); \
130 TCGv arg11 = tcg_temp_new(); \
131 tcg_gen_sari_tl(arg00, arg0, 16); \
132 tcg_gen_ext16s_tl(arg01, arg0); \
133 tcg_gen_ext16s_tl(arg11, arg1); \
134 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
135 tcg_temp_free(arg00); \
136 tcg_temp_free(arg01); \
137 tcg_temp_free(arg11); \
140 #define GEN_HELPER_LU(name, ret, arg0, arg1, n) do { \
141 TCGv arg00 = tcg_temp_new(); \
142 TCGv arg01 = tcg_temp_new(); \
143 TCGv arg10 = tcg_temp_new(); \
144 TCGv arg11 = tcg_temp_new(); \
145 tcg_gen_sari_tl(arg00, arg0, 16); \
146 tcg_gen_ext16s_tl(arg01, arg0); \
147 tcg_gen_sari_tl(arg11, arg1, 16); \
148 tcg_gen_ext16s_tl(arg10, arg1); \
149 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
150 tcg_temp_free(arg00); \
151 tcg_temp_free(arg01); \
152 tcg_temp_free(arg10); \
153 tcg_temp_free(arg11); \
156 #define GEN_HELPER_UL(name, ret, arg0, arg1, n) do { \
157 TCGv arg00 = tcg_temp_new(); \
158 TCGv arg01 = tcg_temp_new(); \
159 TCGv arg10 = tcg_temp_new(); \
160 TCGv arg11 = tcg_temp_new(); \
161 tcg_gen_sari_tl(arg00, arg0, 16); \
162 tcg_gen_ext16s_tl(arg01, arg0); \
163 tcg_gen_sari_tl(arg10, arg1, 16); \
164 tcg_gen_ext16s_tl(arg11, arg1); \
165 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
166 tcg_temp_free(arg00); \
167 tcg_temp_free(arg01); \
168 tcg_temp_free(arg10); \
169 tcg_temp_free(arg11); \
172 #define GEN_HELPER_UU(name, ret, arg0, arg1, n) do { \
173 TCGv arg00 = tcg_temp_new(); \
174 TCGv arg01 = tcg_temp_new(); \
175 TCGv arg11 = tcg_temp_new(); \
176 tcg_gen_sari_tl(arg01, arg0, 16); \
177 tcg_gen_ext16s_tl(arg00, arg0); \
178 tcg_gen_sari_tl(arg11, arg1, 16); \
179 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
180 tcg_temp_free(arg00); \
181 tcg_temp_free(arg01); \
182 tcg_temp_free(arg11); \
185 #define GEN_HELPER_RRR(name, rl, rh, al1, ah1, arg2) do { \
186 TCGv_i64 ret = tcg_temp_new_i64(); \
187 TCGv_i64 arg1 = tcg_temp_new_i64(); \
189 tcg_gen_concat_i32_i64(arg1, al1, ah1); \
190 gen_helper_##name(ret, arg1, arg2); \
191 tcg_gen_extr_i64_i32(rl, rh, ret); \
193 tcg_temp_free_i64(ret); \
194 tcg_temp_free_i64(arg1); \
197 #define GEN_HELPER_RR(name, rl, rh, arg1, arg2) do { \
198 TCGv_i64 ret = tcg_temp_new_i64(); \
200 gen_helper_##name(ret, cpu_env, arg1, arg2); \
201 tcg_gen_extr_i64_i32(rl, rh, ret); \
203 tcg_temp_free_i64(ret); \
206 #define EA_ABS_FORMAT(con) (((con & 0x3C000) << 14) + (con & 0x3FFF))
207 #define EA_B_ABSOLUT(con) (((offset & 0xf00000) << 8) | \
208 ((offset & 0x0fffff) << 1))
210 /* For two 32-bit registers used a 64-bit register, the first
211 registernumber needs to be even. Otherwise we trap. */
212 static inline void generate_trap(DisasContext
*ctx
, int class, int tin
);
213 #define CHECK_REG_PAIR(reg) do { \
215 generate_trap(ctx, TRAPC_INSN_ERR, TIN2_OPD); \
219 /* Functions for load/save to/from memory */
221 static inline void gen_offset_ld(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
222 int16_t con
, MemOp mop
)
224 TCGv temp
= tcg_temp_new();
225 tcg_gen_addi_tl(temp
, r2
, con
);
226 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
230 static inline void gen_offset_st(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
231 int16_t con
, MemOp mop
)
233 TCGv temp
= tcg_temp_new();
234 tcg_gen_addi_tl(temp
, r2
, con
);
235 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
239 static void gen_st_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
241 TCGv_i64 temp
= tcg_temp_new_i64();
243 tcg_gen_concat_i32_i64(temp
, rl
, rh
);
244 tcg_gen_qemu_st_i64(temp
, address
, ctx
->mem_idx
, MO_LEQ
);
246 tcg_temp_free_i64(temp
);
249 static void gen_offset_st_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
252 TCGv temp
= tcg_temp_new();
253 tcg_gen_addi_tl(temp
, base
, con
);
254 gen_st_2regs_64(rh
, rl
, temp
, ctx
);
258 static void gen_ld_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
260 TCGv_i64 temp
= tcg_temp_new_i64();
262 tcg_gen_qemu_ld_i64(temp
, address
, ctx
->mem_idx
, MO_LEQ
);
263 /* write back to two 32 bit regs */
264 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
266 tcg_temp_free_i64(temp
);
269 static void gen_offset_ld_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
272 TCGv temp
= tcg_temp_new();
273 tcg_gen_addi_tl(temp
, base
, con
);
274 gen_ld_2regs_64(rh
, rl
, temp
, ctx
);
278 static void gen_st_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
281 TCGv temp
= tcg_temp_new();
282 tcg_gen_addi_tl(temp
, r2
, off
);
283 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
284 tcg_gen_mov_tl(r2
, temp
);
288 static void gen_ld_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
291 TCGv temp
= tcg_temp_new();
292 tcg_gen_addi_tl(temp
, r2
, off
);
293 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
294 tcg_gen_mov_tl(r2
, temp
);
298 /* M(EA, word) = (M(EA, word) & ~E[a][63:32]) | (E[a][31:0] & E[a][63:32]); */
299 static void gen_ldmst(DisasContext
*ctx
, int ereg
, TCGv ea
)
301 TCGv temp
= tcg_temp_new();
302 TCGv temp2
= tcg_temp_new();
304 CHECK_REG_PAIR(ereg
);
305 /* temp = (M(EA, word) */
306 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
307 /* temp = temp & ~E[a][63:32]) */
308 tcg_gen_andc_tl(temp
, temp
, cpu_gpr_d
[ereg
+1]);
309 /* temp2 = (E[a][31:0] & E[a][63:32]); */
310 tcg_gen_and_tl(temp2
, cpu_gpr_d
[ereg
], cpu_gpr_d
[ereg
+1]);
311 /* temp = temp | temp2; */
312 tcg_gen_or_tl(temp
, temp
, temp2
);
313 /* M(EA, word) = temp; */
314 tcg_gen_qemu_st_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
317 tcg_temp_free(temp2
);
320 /* tmp = M(EA, word);
323 static void gen_swap(DisasContext
*ctx
, int reg
, TCGv ea
)
325 TCGv temp
= tcg_temp_new();
327 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
328 tcg_gen_qemu_st_tl(cpu_gpr_d
[reg
], ea
, ctx
->mem_idx
, MO_LEUL
);
329 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
334 static void gen_cmpswap(DisasContext
*ctx
, int reg
, TCGv ea
)
336 TCGv temp
= tcg_temp_new();
337 TCGv temp2
= tcg_temp_new();
338 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
339 tcg_gen_movcond_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[reg
+1], temp
,
340 cpu_gpr_d
[reg
], temp
);
341 tcg_gen_qemu_st_tl(temp2
, ea
, ctx
->mem_idx
, MO_LEUL
);
342 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
345 tcg_temp_free(temp2
);
348 static void gen_swapmsk(DisasContext
*ctx
, int reg
, TCGv ea
)
350 TCGv temp
= tcg_temp_new();
351 TCGv temp2
= tcg_temp_new();
352 TCGv temp3
= tcg_temp_new();
354 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
355 tcg_gen_and_tl(temp2
, cpu_gpr_d
[reg
], cpu_gpr_d
[reg
+1]);
356 tcg_gen_andc_tl(temp3
, temp
, cpu_gpr_d
[reg
+1]);
357 tcg_gen_or_tl(temp2
, temp2
, temp3
);
358 tcg_gen_qemu_st_tl(temp2
, ea
, ctx
->mem_idx
, MO_LEUL
);
359 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
362 tcg_temp_free(temp2
);
363 tcg_temp_free(temp3
);
367 /* We generate loads and store to core special function register (csfr) through
368 the function gen_mfcr and gen_mtcr. To handle access permissions, we use 3
369 makros R, A and E, which allow read-only, all and endinit protected access.
370 These makros also specify in which ISA version the csfr was introduced. */
371 #define R(ADDRESS, REG, FEATURE) \
373 if (tricore_feature(ctx->env, FEATURE)) { \
374 tcg_gen_ld_tl(ret, cpu_env, offsetof(CPUTriCoreState, REG)); \
377 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
378 #define E(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
379 static inline void gen_mfcr(DisasContext
*ctx
, TCGv ret
, int32_t offset
)
381 /* since we're caching PSW make this a special case */
382 if (offset
== 0xfe04) {
383 gen_helper_psw_read(ret
, cpu_env
);
394 #define R(ADDRESS, REG, FEATURE) /* don't gen writes to read-only reg,
395 since no execption occurs */
396 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE) \
398 if (tricore_feature(ctx->env, FEATURE)) { \
399 tcg_gen_st_tl(r1, cpu_env, offsetof(CPUTriCoreState, REG)); \
402 /* Endinit protected registers
403 TODO: Since the endinit bit is in a register of a not yet implemented
404 watchdog device, we handle endinit protected registers like
405 all-access registers for now. */
406 #define E(ADDRESS, REG, FEATURE) A(ADDRESS, REG, FEATURE)
407 static inline void gen_mtcr(DisasContext
*ctx
, TCGv r1
,
410 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
) {
411 /* since we're caching PSW make this a special case */
412 if (offset
== 0xfe04) {
413 gen_helper_psw_write(cpu_env
, r1
);
420 /* generate privilege trap */
424 /* Functions for arithmetic instructions */
426 static inline void gen_add_d(TCGv ret
, TCGv r1
, TCGv r2
)
428 TCGv t0
= tcg_temp_new_i32();
429 TCGv result
= tcg_temp_new_i32();
430 /* Addition and set V/SV bits */
431 tcg_gen_add_tl(result
, r1
, r2
);
433 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
434 tcg_gen_xor_tl(t0
, r1
, r2
);
435 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
437 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
438 /* Calc AV/SAV bits */
439 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
440 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
442 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
443 /* write back result */
444 tcg_gen_mov_tl(ret
, result
);
446 tcg_temp_free(result
);
451 gen_add64_d(TCGv_i64 ret
, TCGv_i64 r1
, TCGv_i64 r2
)
453 TCGv temp
= tcg_temp_new();
454 TCGv_i64 t0
= tcg_temp_new_i64();
455 TCGv_i64 t1
= tcg_temp_new_i64();
456 TCGv_i64 result
= tcg_temp_new_i64();
458 tcg_gen_add_i64(result
, r1
, r2
);
460 tcg_gen_xor_i64(t1
, result
, r1
);
461 tcg_gen_xor_i64(t0
, r1
, r2
);
462 tcg_gen_andc_i64(t1
, t1
, t0
);
463 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t1
);
465 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
466 /* calc AV/SAV bits */
467 tcg_gen_extrh_i64_i32(temp
, result
);
468 tcg_gen_add_tl(cpu_PSW_AV
, temp
, temp
);
469 tcg_gen_xor_tl(cpu_PSW_AV
, temp
, cpu_PSW_AV
);
471 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
472 /* write back result */
473 tcg_gen_mov_i64(ret
, result
);
476 tcg_temp_free_i64(result
);
477 tcg_temp_free_i64(t0
);
478 tcg_temp_free_i64(t1
);
482 gen_addsub64_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
483 TCGv r3
, void(*op1
)(TCGv
, TCGv
, TCGv
),
484 void(*op2
)(TCGv
, TCGv
, TCGv
))
486 TCGv temp
= tcg_temp_new();
487 TCGv temp2
= tcg_temp_new();
488 TCGv temp3
= tcg_temp_new();
489 TCGv temp4
= tcg_temp_new();
491 (*op1
)(temp
, r1_low
, r2
);
493 tcg_gen_xor_tl(temp2
, temp
, r1_low
);
494 tcg_gen_xor_tl(temp3
, r1_low
, r2
);
495 if (op1
== tcg_gen_add_tl
) {
496 tcg_gen_andc_tl(temp2
, temp2
, temp3
);
498 tcg_gen_and_tl(temp2
, temp2
, temp3
);
501 (*op2
)(temp3
, r1_high
, r3
);
503 tcg_gen_xor_tl(cpu_PSW_V
, temp3
, r1_high
);
504 tcg_gen_xor_tl(temp4
, r1_high
, r3
);
505 if (op2
== tcg_gen_add_tl
) {
506 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
508 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
510 /* combine V0/V1 bits */
511 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp2
);
513 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
515 tcg_gen_mov_tl(ret_low
, temp
);
516 tcg_gen_mov_tl(ret_high
, temp3
);
518 tcg_gen_add_tl(temp
, ret_low
, ret_low
);
519 tcg_gen_xor_tl(temp
, temp
, ret_low
);
520 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
521 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, ret_high
);
522 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
524 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
527 tcg_temp_free(temp2
);
528 tcg_temp_free(temp3
);
529 tcg_temp_free(temp4
);
532 /* ret = r2 + (r1 * r3); */
533 static inline void gen_madd32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
535 TCGv_i64 t1
= tcg_temp_new_i64();
536 TCGv_i64 t2
= tcg_temp_new_i64();
537 TCGv_i64 t3
= tcg_temp_new_i64();
539 tcg_gen_ext_i32_i64(t1
, r1
);
540 tcg_gen_ext_i32_i64(t2
, r2
);
541 tcg_gen_ext_i32_i64(t3
, r3
);
543 tcg_gen_mul_i64(t1
, t1
, t3
);
544 tcg_gen_add_i64(t1
, t2
, t1
);
546 tcg_gen_extrl_i64_i32(ret
, t1
);
549 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
550 /* t1 < -0x80000000 */
551 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
552 tcg_gen_or_i64(t2
, t2
, t3
);
553 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
554 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
556 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
557 /* Calc AV/SAV bits */
558 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
559 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
561 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
563 tcg_temp_free_i64(t1
);
564 tcg_temp_free_i64(t2
);
565 tcg_temp_free_i64(t3
);
568 static inline void gen_maddi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
570 TCGv temp
= tcg_const_i32(con
);
571 gen_madd32_d(ret
, r1
, r2
, temp
);
576 gen_madd64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
579 TCGv t1
= tcg_temp_new();
580 TCGv t2
= tcg_temp_new();
581 TCGv t3
= tcg_temp_new();
582 TCGv t4
= tcg_temp_new();
584 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
585 /* only the add can overflow */
586 tcg_gen_add2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
588 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
589 tcg_gen_xor_tl(t1
, r2_high
, t2
);
590 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
592 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
593 /* Calc AV/SAV bits */
594 tcg_gen_add_tl(cpu_PSW_AV
, t4
, t4
);
595 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
597 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
598 /* write back the result */
599 tcg_gen_mov_tl(ret_low
, t3
);
600 tcg_gen_mov_tl(ret_high
, t4
);
609 gen_maddu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
612 TCGv_i64 t1
= tcg_temp_new_i64();
613 TCGv_i64 t2
= tcg_temp_new_i64();
614 TCGv_i64 t3
= tcg_temp_new_i64();
616 tcg_gen_extu_i32_i64(t1
, r1
);
617 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
618 tcg_gen_extu_i32_i64(t3
, r3
);
620 tcg_gen_mul_i64(t1
, t1
, t3
);
621 tcg_gen_add_i64(t2
, t2
, t1
);
622 /* write back result */
623 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t2
);
624 /* only the add overflows, if t2 < t1
626 tcg_gen_setcond_i64(TCG_COND_LTU
, t2
, t2
, t1
);
627 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
628 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
630 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
631 /* Calc AV/SAV bits */
632 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
633 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
635 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
637 tcg_temp_free_i64(t1
);
638 tcg_temp_free_i64(t2
);
639 tcg_temp_free_i64(t3
);
643 gen_maddi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
646 TCGv temp
= tcg_const_i32(con
);
647 gen_madd64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
652 gen_maddui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
655 TCGv temp
= tcg_const_i32(con
);
656 gen_maddu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
661 gen_madd_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
662 TCGv r3
, uint32_t n
, uint32_t mode
)
664 TCGv temp
= tcg_const_i32(n
);
665 TCGv temp2
= tcg_temp_new();
666 TCGv_i64 temp64
= tcg_temp_new_i64();
669 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
672 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
675 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
678 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
681 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
682 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
683 tcg_gen_add_tl
, tcg_gen_add_tl
);
685 tcg_temp_free(temp2
);
686 tcg_temp_free_i64(temp64
);
690 gen_maddsu_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
691 TCGv r3
, uint32_t n
, uint32_t mode
)
693 TCGv temp
= tcg_const_i32(n
);
694 TCGv temp2
= tcg_temp_new();
695 TCGv_i64 temp64
= tcg_temp_new_i64();
698 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
701 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
704 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
707 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
710 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
711 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
712 tcg_gen_sub_tl
, tcg_gen_add_tl
);
714 tcg_temp_free(temp2
);
715 tcg_temp_free_i64(temp64
);
719 gen_maddsum_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
720 TCGv r3
, uint32_t n
, uint32_t mode
)
722 TCGv temp
= tcg_const_i32(n
);
723 TCGv_i64 temp64
= tcg_temp_new_i64();
724 TCGv_i64 temp64_2
= tcg_temp_new_i64();
725 TCGv_i64 temp64_3
= tcg_temp_new_i64();
728 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
731 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
734 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
737 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
740 tcg_gen_concat_i32_i64(temp64_3
, r1_low
, r1_high
);
741 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
742 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
743 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
744 tcg_gen_shli_i64(temp64
, temp64
, 16);
746 gen_add64_d(temp64_2
, temp64_3
, temp64
);
747 /* write back result */
748 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_2
);
751 tcg_temp_free_i64(temp64
);
752 tcg_temp_free_i64(temp64_2
);
753 tcg_temp_free_i64(temp64_3
);
756 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
);
759 gen_madds_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
760 TCGv r3
, uint32_t n
, uint32_t mode
)
762 TCGv temp
= tcg_const_i32(n
);
763 TCGv temp2
= tcg_temp_new();
764 TCGv temp3
= tcg_temp_new();
765 TCGv_i64 temp64
= tcg_temp_new_i64();
769 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
772 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
775 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
778 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
781 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
782 gen_adds(ret_low
, r1_low
, temp
);
783 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
784 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
785 gen_adds(ret_high
, r1_high
, temp2
);
787 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
788 /* combine av bits */
789 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
792 tcg_temp_free(temp2
);
793 tcg_temp_free(temp3
);
794 tcg_temp_free_i64(temp64
);
798 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
);
801 gen_maddsus_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
802 TCGv r3
, uint32_t n
, uint32_t mode
)
804 TCGv temp
= tcg_const_i32(n
);
805 TCGv temp2
= tcg_temp_new();
806 TCGv temp3
= tcg_temp_new();
807 TCGv_i64 temp64
= tcg_temp_new_i64();
811 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
814 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
817 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
820 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
823 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
824 gen_subs(ret_low
, r1_low
, temp
);
825 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
826 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
827 gen_adds(ret_high
, r1_high
, temp2
);
829 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
830 /* combine av bits */
831 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
834 tcg_temp_free(temp2
);
835 tcg_temp_free(temp3
);
836 tcg_temp_free_i64(temp64
);
841 gen_maddsums_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
842 TCGv r3
, uint32_t n
, uint32_t mode
)
844 TCGv temp
= tcg_const_i32(n
);
845 TCGv_i64 temp64
= tcg_temp_new_i64();
846 TCGv_i64 temp64_2
= tcg_temp_new_i64();
850 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
853 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
856 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
859 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
862 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
863 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
864 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
865 tcg_gen_shli_i64(temp64
, temp64
, 16);
866 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
868 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
869 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
872 tcg_temp_free_i64(temp64
);
873 tcg_temp_free_i64(temp64_2
);
878 gen_maddm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
879 TCGv r3
, uint32_t n
, uint32_t mode
)
881 TCGv temp
= tcg_const_i32(n
);
882 TCGv_i64 temp64
= tcg_temp_new_i64();
883 TCGv_i64 temp64_2
= tcg_temp_new_i64();
884 TCGv_i64 temp64_3
= tcg_temp_new_i64();
887 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
890 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
893 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
896 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
899 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
900 gen_add64_d(temp64_3
, temp64_2
, temp64
);
901 /* write back result */
902 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_3
);
905 tcg_temp_free_i64(temp64
);
906 tcg_temp_free_i64(temp64_2
);
907 tcg_temp_free_i64(temp64_3
);
911 gen_maddms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
912 TCGv r3
, uint32_t n
, uint32_t mode
)
914 TCGv temp
= tcg_const_i32(n
);
915 TCGv_i64 temp64
= tcg_temp_new_i64();
916 TCGv_i64 temp64_2
= tcg_temp_new_i64();
919 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
922 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
925 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
928 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
931 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
932 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
933 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
936 tcg_temp_free_i64(temp64
);
937 tcg_temp_free_i64(temp64_2
);
941 gen_maddr64_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
, uint32_t n
,
944 TCGv temp
= tcg_const_i32(n
);
945 TCGv_i64 temp64
= tcg_temp_new_i64();
948 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
951 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
954 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
957 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
960 gen_helper_addr_h(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
963 tcg_temp_free_i64(temp64
);
967 gen_maddr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
969 TCGv temp
= tcg_temp_new();
970 TCGv temp2
= tcg_temp_new();
972 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
973 tcg_gen_shli_tl(temp
, r1
, 16);
974 gen_maddr64_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
977 tcg_temp_free(temp2
);
981 gen_maddsur32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
983 TCGv temp
= tcg_const_i32(n
);
984 TCGv temp2
= tcg_temp_new();
985 TCGv_i64 temp64
= tcg_temp_new_i64();
988 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
991 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
994 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
997 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1000 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1001 tcg_gen_shli_tl(temp
, r1
, 16);
1002 gen_helper_addsur_h(ret
, cpu_env
, temp64
, temp
, temp2
);
1004 tcg_temp_free(temp
);
1005 tcg_temp_free(temp2
);
1006 tcg_temp_free_i64(temp64
);
1011 gen_maddr64s_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
,
1012 uint32_t n
, uint32_t mode
)
1014 TCGv temp
= tcg_const_i32(n
);
1015 TCGv_i64 temp64
= tcg_temp_new_i64();
1018 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1021 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1024 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1027 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1030 gen_helper_addr_h_ssov(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
1032 tcg_temp_free(temp
);
1033 tcg_temp_free_i64(temp64
);
1037 gen_maddr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1039 TCGv temp
= tcg_temp_new();
1040 TCGv temp2
= tcg_temp_new();
1042 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1043 tcg_gen_shli_tl(temp
, r1
, 16);
1044 gen_maddr64s_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1046 tcg_temp_free(temp
);
1047 tcg_temp_free(temp2
);
1051 gen_maddsur32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1053 TCGv temp
= tcg_const_i32(n
);
1054 TCGv temp2
= tcg_temp_new();
1055 TCGv_i64 temp64
= tcg_temp_new_i64();
1058 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1061 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1064 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1067 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1070 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1071 tcg_gen_shli_tl(temp
, r1
, 16);
1072 gen_helper_addsur_h_ssov(ret
, cpu_env
, temp64
, temp
, temp2
);
1074 tcg_temp_free(temp
);
1075 tcg_temp_free(temp2
);
1076 tcg_temp_free_i64(temp64
);
1080 gen_maddr_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1082 TCGv temp
= tcg_const_i32(n
);
1083 gen_helper_maddr_q(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1084 tcg_temp_free(temp
);
1088 gen_maddrs_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1090 TCGv temp
= tcg_const_i32(n
);
1091 gen_helper_maddr_q_ssov(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1092 tcg_temp_free(temp
);
1096 gen_madd32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1099 TCGv temp
= tcg_temp_new();
1100 TCGv temp2
= tcg_temp_new();
1101 TCGv temp3
= tcg_temp_new();
1102 TCGv_i64 t1
= tcg_temp_new_i64();
1103 TCGv_i64 t2
= tcg_temp_new_i64();
1104 TCGv_i64 t3
= tcg_temp_new_i64();
1106 tcg_gen_ext_i32_i64(t2
, arg2
);
1107 tcg_gen_ext_i32_i64(t3
, arg3
);
1109 tcg_gen_mul_i64(t2
, t2
, t3
);
1110 tcg_gen_shli_i64(t2
, t2
, n
);
1112 tcg_gen_ext_i32_i64(t1
, arg1
);
1113 tcg_gen_sari_i64(t2
, t2
, up_shift
);
1115 tcg_gen_add_i64(t3
, t1
, t2
);
1116 tcg_gen_extrl_i64_i32(temp3
, t3
);
1118 tcg_gen_setcondi_i64(TCG_COND_GT
, t1
, t3
, 0x7fffffffLL
);
1119 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t3
, -0x80000000LL
);
1120 tcg_gen_or_i64(t1
, t1
, t2
);
1121 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1122 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1123 /* We produce an overflow on the host if the mul before was
1124 (0x80000000 * 0x80000000) << 1). If this is the
1125 case, we negate the ovf. */
1127 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1128 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1129 tcg_gen_and_tl(temp
, temp
, temp2
);
1130 tcg_gen_shli_tl(temp
, temp
, 31);
1131 /* negate v bit, if special condition */
1132 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1135 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1136 /* Calc AV/SAV bits */
1137 tcg_gen_add_tl(cpu_PSW_AV
, temp3
, temp3
);
1138 tcg_gen_xor_tl(cpu_PSW_AV
, temp3
, cpu_PSW_AV
);
1140 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1141 /* write back result */
1142 tcg_gen_mov_tl(ret
, temp3
);
1144 tcg_temp_free(temp
);
1145 tcg_temp_free(temp2
);
1146 tcg_temp_free(temp3
);
1147 tcg_temp_free_i64(t1
);
1148 tcg_temp_free_i64(t2
);
1149 tcg_temp_free_i64(t3
);
1153 gen_m16add32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1155 TCGv temp
= tcg_temp_new();
1156 TCGv temp2
= tcg_temp_new();
1158 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1159 } else { /* n is expected 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 gen_add_d(ret
, arg1
, temp
);
1168 tcg_temp_free(temp
);
1169 tcg_temp_free(temp2
);
1173 gen_m16adds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1175 TCGv temp
= tcg_temp_new();
1176 TCGv temp2
= tcg_temp_new();
1178 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1179 } else { /* n is expected to be 1 */
1180 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1181 tcg_gen_shli_tl(temp
, temp
, 1);
1182 /* catch special case r1 = r2 = 0x8000 */
1183 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1184 tcg_gen_sub_tl(temp
, temp
, temp2
);
1186 gen_adds(ret
, arg1
, temp
);
1188 tcg_temp_free(temp
);
1189 tcg_temp_free(temp2
);
1193 gen_m16add64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1194 TCGv arg3
, uint32_t n
)
1196 TCGv temp
= tcg_temp_new();
1197 TCGv temp2
= tcg_temp_new();
1198 TCGv_i64 t1
= tcg_temp_new_i64();
1199 TCGv_i64 t2
= tcg_temp_new_i64();
1200 TCGv_i64 t3
= tcg_temp_new_i64();
1203 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1204 } else { /* n is expected to be 1 */
1205 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1206 tcg_gen_shli_tl(temp
, temp
, 1);
1207 /* catch special case r1 = r2 = 0x8000 */
1208 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1209 tcg_gen_sub_tl(temp
, temp
, temp2
);
1211 tcg_gen_ext_i32_i64(t2
, temp
);
1212 tcg_gen_shli_i64(t2
, t2
, 16);
1213 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1214 gen_add64_d(t3
, t1
, t2
);
1215 /* write back result */
1216 tcg_gen_extr_i64_i32(rl
, rh
, t3
);
1218 tcg_temp_free_i64(t1
);
1219 tcg_temp_free_i64(t2
);
1220 tcg_temp_free_i64(t3
);
1221 tcg_temp_free(temp
);
1222 tcg_temp_free(temp2
);
1226 gen_m16adds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1227 TCGv arg3
, uint32_t n
)
1229 TCGv temp
= tcg_temp_new();
1230 TCGv temp2
= tcg_temp_new();
1231 TCGv_i64 t1
= tcg_temp_new_i64();
1232 TCGv_i64 t2
= tcg_temp_new_i64();
1235 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1236 } else { /* n is expected to be 1 */
1237 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1238 tcg_gen_shli_tl(temp
, temp
, 1);
1239 /* catch special case r1 = r2 = 0x8000 */
1240 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1241 tcg_gen_sub_tl(temp
, temp
, temp2
);
1243 tcg_gen_ext_i32_i64(t2
, temp
);
1244 tcg_gen_shli_i64(t2
, t2
, 16);
1245 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1247 gen_helper_add64_ssov(t1
, cpu_env
, t1
, t2
);
1248 tcg_gen_extr_i64_i32(rl
, rh
, t1
);
1250 tcg_temp_free(temp
);
1251 tcg_temp_free(temp2
);
1252 tcg_temp_free_i64(t1
);
1253 tcg_temp_free_i64(t2
);
1257 gen_madd64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1258 TCGv arg3
, uint32_t n
)
1260 TCGv_i64 t1
= tcg_temp_new_i64();
1261 TCGv_i64 t2
= tcg_temp_new_i64();
1262 TCGv_i64 t3
= tcg_temp_new_i64();
1263 TCGv_i64 t4
= tcg_temp_new_i64();
1266 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1267 tcg_gen_ext_i32_i64(t2
, arg2
);
1268 tcg_gen_ext_i32_i64(t3
, arg3
);
1270 tcg_gen_mul_i64(t2
, t2
, t3
);
1272 tcg_gen_shli_i64(t2
, t2
, 1);
1274 tcg_gen_add_i64(t4
, t1
, t2
);
1276 tcg_gen_xor_i64(t3
, t4
, t1
);
1277 tcg_gen_xor_i64(t2
, t1
, t2
);
1278 tcg_gen_andc_i64(t3
, t3
, t2
);
1279 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t3
);
1280 /* We produce an overflow on the host if the mul before was
1281 (0x80000000 * 0x80000000) << 1). If this is the
1282 case, we negate the ovf. */
1284 temp
= tcg_temp_new();
1285 temp2
= tcg_temp_new();
1286 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1287 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1288 tcg_gen_and_tl(temp
, temp
, temp2
);
1289 tcg_gen_shli_tl(temp
, temp
, 31);
1290 /* negate v bit, if special condition */
1291 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1293 tcg_temp_free(temp
);
1294 tcg_temp_free(temp2
);
1296 /* write back result */
1297 tcg_gen_extr_i64_i32(rl
, rh
, t4
);
1299 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1300 /* Calc AV/SAV bits */
1301 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
1302 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
1304 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1306 tcg_temp_free_i64(t1
);
1307 tcg_temp_free_i64(t2
);
1308 tcg_temp_free_i64(t3
);
1309 tcg_temp_free_i64(t4
);
1313 gen_madds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1316 TCGv_i64 t1
= tcg_temp_new_i64();
1317 TCGv_i64 t2
= tcg_temp_new_i64();
1318 TCGv_i64 t3
= tcg_temp_new_i64();
1320 tcg_gen_ext_i32_i64(t1
, arg1
);
1321 tcg_gen_ext_i32_i64(t2
, arg2
);
1322 tcg_gen_ext_i32_i64(t3
, arg3
);
1324 tcg_gen_mul_i64(t2
, t2
, t3
);
1325 tcg_gen_sari_i64(t2
, t2
, up_shift
- n
);
1327 gen_helper_madd32_q_add_ssov(ret
, cpu_env
, t1
, t2
);
1329 tcg_temp_free_i64(t1
);
1330 tcg_temp_free_i64(t2
);
1331 tcg_temp_free_i64(t3
);
1335 gen_madds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1336 TCGv arg3
, uint32_t n
)
1338 TCGv_i64 r1
= tcg_temp_new_i64();
1339 TCGv temp
= tcg_const_i32(n
);
1341 tcg_gen_concat_i32_i64(r1
, arg1_low
, arg1_high
);
1342 gen_helper_madd64_q_ssov(r1
, cpu_env
, r1
, arg2
, arg3
, temp
);
1343 tcg_gen_extr_i64_i32(rl
, rh
, r1
);
1345 tcg_temp_free_i64(r1
);
1346 tcg_temp_free(temp
);
1348 /* ret = r2 - (r1 * r3); */
1349 static inline void gen_msub32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
1351 TCGv_i64 t1
= tcg_temp_new_i64();
1352 TCGv_i64 t2
= tcg_temp_new_i64();
1353 TCGv_i64 t3
= tcg_temp_new_i64();
1355 tcg_gen_ext_i32_i64(t1
, r1
);
1356 tcg_gen_ext_i32_i64(t2
, r2
);
1357 tcg_gen_ext_i32_i64(t3
, r3
);
1359 tcg_gen_mul_i64(t1
, t1
, t3
);
1360 tcg_gen_sub_i64(t1
, t2
, t1
);
1362 tcg_gen_extrl_i64_i32(ret
, t1
);
1365 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
1366 /* result < -0x80000000 */
1367 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
1368 tcg_gen_or_i64(t2
, t2
, t3
);
1369 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
1370 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1373 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1374 /* Calc AV/SAV bits */
1375 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1376 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1378 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1380 tcg_temp_free_i64(t1
);
1381 tcg_temp_free_i64(t2
);
1382 tcg_temp_free_i64(t3
);
1385 static inline void gen_msubi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1387 TCGv temp
= tcg_const_i32(con
);
1388 gen_msub32_d(ret
, r1
, r2
, temp
);
1389 tcg_temp_free(temp
);
1393 gen_msub64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1396 TCGv t1
= tcg_temp_new();
1397 TCGv t2
= tcg_temp_new();
1398 TCGv t3
= tcg_temp_new();
1399 TCGv t4
= tcg_temp_new();
1401 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
1402 /* only the sub can overflow */
1403 tcg_gen_sub2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
1405 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
1406 tcg_gen_xor_tl(t1
, r2_high
, t2
);
1407 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
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
, t4
, t4
);
1412 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
1414 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1415 /* write back the result */
1416 tcg_gen_mov_tl(ret_low
, t3
);
1417 tcg_gen_mov_tl(ret_high
, t4
);
1426 gen_msubi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1429 TCGv temp
= tcg_const_i32(con
);
1430 gen_msub64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1431 tcg_temp_free(temp
);
1435 gen_msubu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1438 TCGv_i64 t1
= tcg_temp_new_i64();
1439 TCGv_i64 t2
= tcg_temp_new_i64();
1440 TCGv_i64 t3
= tcg_temp_new_i64();
1442 tcg_gen_extu_i32_i64(t1
, r1
);
1443 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
1444 tcg_gen_extu_i32_i64(t3
, r3
);
1446 tcg_gen_mul_i64(t1
, t1
, t3
);
1447 tcg_gen_sub_i64(t3
, t2
, t1
);
1448 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t3
);
1449 /* calc V bit, only the sub can overflow, if t1 > t2 */
1450 tcg_gen_setcond_i64(TCG_COND_GTU
, t1
, t1
, t2
);
1451 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1452 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1454 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1455 /* Calc AV/SAV bits */
1456 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
1457 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
1459 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1461 tcg_temp_free_i64(t1
);
1462 tcg_temp_free_i64(t2
);
1463 tcg_temp_free_i64(t3
);
1467 gen_msubui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1470 TCGv temp
= tcg_const_i32(con
);
1471 gen_msubu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1472 tcg_temp_free(temp
);
1475 static inline void gen_addi_d(TCGv ret
, TCGv r1
, target_ulong r2
)
1477 TCGv temp
= tcg_const_i32(r2
);
1478 gen_add_d(ret
, r1
, temp
);
1479 tcg_temp_free(temp
);
1481 /* calculate the carry bit too */
1482 static inline void gen_add_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1484 TCGv t0
= tcg_temp_new_i32();
1485 TCGv result
= tcg_temp_new_i32();
1487 tcg_gen_movi_tl(t0
, 0);
1488 /* Addition and set C/V/SV bits */
1489 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, r2
, t0
);
1491 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1492 tcg_gen_xor_tl(t0
, r1
, r2
);
1493 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1495 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1496 /* Calc AV/SAV bits */
1497 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1498 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1500 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1501 /* write back result */
1502 tcg_gen_mov_tl(ret
, result
);
1504 tcg_temp_free(result
);
1508 static inline void gen_addi_CC(TCGv ret
, TCGv r1
, int32_t con
)
1510 TCGv temp
= tcg_const_i32(con
);
1511 gen_add_CC(ret
, r1
, temp
);
1512 tcg_temp_free(temp
);
1515 static inline void gen_addc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1517 TCGv carry
= tcg_temp_new_i32();
1518 TCGv t0
= tcg_temp_new_i32();
1519 TCGv result
= tcg_temp_new_i32();
1521 tcg_gen_movi_tl(t0
, 0);
1522 tcg_gen_setcondi_tl(TCG_COND_NE
, carry
, cpu_PSW_C
, 0);
1523 /* Addition, carry and set C/V/SV bits */
1524 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, carry
, t0
);
1525 tcg_gen_add2_i32(result
, cpu_PSW_C
, result
, cpu_PSW_C
, r2
, t0
);
1527 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1528 tcg_gen_xor_tl(t0
, r1
, r2
);
1529 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1531 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1532 /* Calc AV/SAV bits */
1533 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1534 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1536 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1537 /* write back result */
1538 tcg_gen_mov_tl(ret
, result
);
1540 tcg_temp_free(result
);
1542 tcg_temp_free(carry
);
1545 static inline void gen_addci_CC(TCGv ret
, TCGv r1
, int32_t con
)
1547 TCGv temp
= tcg_const_i32(con
);
1548 gen_addc_CC(ret
, r1
, temp
);
1549 tcg_temp_free(temp
);
1552 static inline void gen_cond_add(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1555 TCGv temp
= tcg_temp_new();
1556 TCGv temp2
= tcg_temp_new();
1557 TCGv result
= tcg_temp_new();
1558 TCGv mask
= tcg_temp_new();
1559 TCGv t0
= tcg_const_i32(0);
1561 /* create mask for sticky bits */
1562 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1563 tcg_gen_shli_tl(mask
, mask
, 31);
1565 tcg_gen_add_tl(result
, r1
, r2
);
1567 tcg_gen_xor_tl(temp
, result
, r1
);
1568 tcg_gen_xor_tl(temp2
, r1
, r2
);
1569 tcg_gen_andc_tl(temp
, temp
, temp2
);
1570 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1572 tcg_gen_and_tl(temp
, temp
, mask
);
1573 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1575 tcg_gen_add_tl(temp
, result
, result
);
1576 tcg_gen_xor_tl(temp
, temp
, result
);
1577 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1579 tcg_gen_and_tl(temp
, temp
, mask
);
1580 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1581 /* write back result */
1582 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1585 tcg_temp_free(temp
);
1586 tcg_temp_free(temp2
);
1587 tcg_temp_free(result
);
1588 tcg_temp_free(mask
);
1591 static inline void gen_condi_add(TCGCond cond
, TCGv r1
, int32_t r2
,
1594 TCGv temp
= tcg_const_i32(r2
);
1595 gen_cond_add(cond
, r1
, temp
, r3
, r4
);
1596 tcg_temp_free(temp
);
1599 static inline void gen_sub_d(TCGv ret
, TCGv r1
, TCGv r2
)
1601 TCGv temp
= tcg_temp_new_i32();
1602 TCGv result
= tcg_temp_new_i32();
1604 tcg_gen_sub_tl(result
, r1
, r2
);
1606 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1607 tcg_gen_xor_tl(temp
, r1
, r2
);
1608 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1610 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1612 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1613 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1615 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1616 /* write back result */
1617 tcg_gen_mov_tl(ret
, result
);
1619 tcg_temp_free(temp
);
1620 tcg_temp_free(result
);
1624 gen_sub64_d(TCGv_i64 ret
, TCGv_i64 r1
, TCGv_i64 r2
)
1626 TCGv temp
= tcg_temp_new();
1627 TCGv_i64 t0
= tcg_temp_new_i64();
1628 TCGv_i64 t1
= tcg_temp_new_i64();
1629 TCGv_i64 result
= tcg_temp_new_i64();
1631 tcg_gen_sub_i64(result
, r1
, r2
);
1633 tcg_gen_xor_i64(t1
, result
, r1
);
1634 tcg_gen_xor_i64(t0
, r1
, r2
);
1635 tcg_gen_and_i64(t1
, t1
, t0
);
1636 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t1
);
1638 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1639 /* calc AV/SAV bits */
1640 tcg_gen_extrh_i64_i32(temp
, result
);
1641 tcg_gen_add_tl(cpu_PSW_AV
, temp
, temp
);
1642 tcg_gen_xor_tl(cpu_PSW_AV
, temp
, cpu_PSW_AV
);
1644 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1645 /* write back result */
1646 tcg_gen_mov_i64(ret
, result
);
1648 tcg_temp_free(temp
);
1649 tcg_temp_free_i64(result
);
1650 tcg_temp_free_i64(t0
);
1651 tcg_temp_free_i64(t1
);
1654 static inline void gen_sub_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1656 TCGv result
= tcg_temp_new();
1657 TCGv temp
= tcg_temp_new();
1659 tcg_gen_sub_tl(result
, r1
, r2
);
1661 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_PSW_C
, r1
, r2
);
1663 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1664 tcg_gen_xor_tl(temp
, r1
, r2
);
1665 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1667 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1669 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1670 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1672 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1673 /* write back result */
1674 tcg_gen_mov_tl(ret
, result
);
1676 tcg_temp_free(result
);
1677 tcg_temp_free(temp
);
1680 static inline void gen_subc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1682 TCGv temp
= tcg_temp_new();
1683 tcg_gen_not_tl(temp
, r2
);
1684 gen_addc_CC(ret
, r1
, temp
);
1685 tcg_temp_free(temp
);
1688 static inline void gen_cond_sub(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1691 TCGv temp
= tcg_temp_new();
1692 TCGv temp2
= tcg_temp_new();
1693 TCGv result
= tcg_temp_new();
1694 TCGv mask
= tcg_temp_new();
1695 TCGv t0
= tcg_const_i32(0);
1697 /* create mask for sticky bits */
1698 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1699 tcg_gen_shli_tl(mask
, mask
, 31);
1701 tcg_gen_sub_tl(result
, r1
, r2
);
1703 tcg_gen_xor_tl(temp
, result
, r1
);
1704 tcg_gen_xor_tl(temp2
, r1
, r2
);
1705 tcg_gen_and_tl(temp
, temp
, temp2
);
1706 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1708 tcg_gen_and_tl(temp
, temp
, mask
);
1709 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1711 tcg_gen_add_tl(temp
, result
, result
);
1712 tcg_gen_xor_tl(temp
, temp
, result
);
1713 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1715 tcg_gen_and_tl(temp
, temp
, mask
);
1716 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1717 /* write back result */
1718 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1721 tcg_temp_free(temp
);
1722 tcg_temp_free(temp2
);
1723 tcg_temp_free(result
);
1724 tcg_temp_free(mask
);
1728 gen_msub_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1729 TCGv r3
, uint32_t n
, uint32_t mode
)
1731 TCGv temp
= tcg_const_i32(n
);
1732 TCGv temp2
= tcg_temp_new();
1733 TCGv_i64 temp64
= tcg_temp_new_i64();
1736 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1739 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1742 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1745 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1748 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
1749 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
1750 tcg_gen_sub_tl
, tcg_gen_sub_tl
);
1751 tcg_temp_free(temp
);
1752 tcg_temp_free(temp2
);
1753 tcg_temp_free_i64(temp64
);
1757 gen_msubs_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1758 TCGv r3
, uint32_t n
, uint32_t mode
)
1760 TCGv temp
= tcg_const_i32(n
);
1761 TCGv temp2
= tcg_temp_new();
1762 TCGv temp3
= tcg_temp_new();
1763 TCGv_i64 temp64
= tcg_temp_new_i64();
1767 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1770 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1773 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1776 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1779 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
1780 gen_subs(ret_low
, r1_low
, temp
);
1781 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
1782 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
1783 gen_subs(ret_high
, r1_high
, temp2
);
1784 /* combine v bits */
1785 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1786 /* combine av bits */
1787 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
1789 tcg_temp_free(temp
);
1790 tcg_temp_free(temp2
);
1791 tcg_temp_free(temp3
);
1792 tcg_temp_free_i64(temp64
);
1796 gen_msubm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1797 TCGv r3
, uint32_t n
, uint32_t mode
)
1799 TCGv temp
= tcg_const_i32(n
);
1800 TCGv_i64 temp64
= tcg_temp_new_i64();
1801 TCGv_i64 temp64_2
= tcg_temp_new_i64();
1802 TCGv_i64 temp64_3
= tcg_temp_new_i64();
1805 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
1808 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
1811 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
1814 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
1817 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
1818 gen_sub64_d(temp64_3
, temp64_2
, temp64
);
1819 /* write back result */
1820 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_3
);
1822 tcg_temp_free(temp
);
1823 tcg_temp_free_i64(temp64
);
1824 tcg_temp_free_i64(temp64_2
);
1825 tcg_temp_free_i64(temp64_3
);
1829 gen_msubms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1830 TCGv r3
, uint32_t n
, uint32_t mode
)
1832 TCGv temp
= tcg_const_i32(n
);
1833 TCGv_i64 temp64
= tcg_temp_new_i64();
1834 TCGv_i64 temp64_2
= tcg_temp_new_i64();
1837 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, temp
);
1840 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, temp
);
1843 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, temp
);
1846 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, temp
);
1849 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
1850 gen_helper_sub64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
1851 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
1853 tcg_temp_free(temp
);
1854 tcg_temp_free_i64(temp64
);
1855 tcg_temp_free_i64(temp64_2
);
1859 gen_msubr64_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
, uint32_t n
,
1862 TCGv temp
= tcg_const_i32(n
);
1863 TCGv_i64 temp64
= tcg_temp_new_i64();
1866 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1869 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1872 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1875 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1878 gen_helper_subr_h(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
1880 tcg_temp_free(temp
);
1881 tcg_temp_free_i64(temp64
);
1885 gen_msubr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1887 TCGv temp
= tcg_temp_new();
1888 TCGv temp2
= tcg_temp_new();
1890 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1891 tcg_gen_shli_tl(temp
, r1
, 16);
1892 gen_msubr64_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1894 tcg_temp_free(temp
);
1895 tcg_temp_free(temp2
);
1899 gen_msubr64s_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
,
1900 uint32_t n
, uint32_t mode
)
1902 TCGv temp
= tcg_const_i32(n
);
1903 TCGv_i64 temp64
= tcg_temp_new_i64();
1906 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
1909 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
1912 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
1915 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
1918 gen_helper_subr_h_ssov(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
1920 tcg_temp_free(temp
);
1921 tcg_temp_free_i64(temp64
);
1925 gen_msubr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1927 TCGv temp
= tcg_temp_new();
1928 TCGv temp2
= tcg_temp_new();
1930 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1931 tcg_gen_shli_tl(temp
, r1
, 16);
1932 gen_msubr64s_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1934 tcg_temp_free(temp
);
1935 tcg_temp_free(temp2
);
1939 gen_msubr_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1941 TCGv temp
= tcg_const_i32(n
);
1942 gen_helper_msubr_q(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1943 tcg_temp_free(temp
);
1947 gen_msubrs_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1949 TCGv temp
= tcg_const_i32(n
);
1950 gen_helper_msubr_q_ssov(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1951 tcg_temp_free(temp
);
1955 gen_msub32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1958 TCGv temp
= tcg_temp_new();
1959 TCGv temp2
= tcg_temp_new();
1960 TCGv temp3
= tcg_temp_new();
1961 TCGv_i64 t1
= tcg_temp_new_i64();
1962 TCGv_i64 t2
= tcg_temp_new_i64();
1963 TCGv_i64 t3
= tcg_temp_new_i64();
1964 TCGv_i64 t4
= tcg_temp_new_i64();
1966 tcg_gen_ext_i32_i64(t2
, arg2
);
1967 tcg_gen_ext_i32_i64(t3
, arg3
);
1969 tcg_gen_mul_i64(t2
, t2
, t3
);
1971 tcg_gen_ext_i32_i64(t1
, arg1
);
1972 /* if we shift part of the fraction out, we need to round up */
1973 tcg_gen_andi_i64(t4
, t2
, (1ll << (up_shift
- n
)) - 1);
1974 tcg_gen_setcondi_i64(TCG_COND_NE
, t4
, t4
, 0);
1975 tcg_gen_sari_i64(t2
, t2
, up_shift
- n
);
1976 tcg_gen_add_i64(t2
, t2
, t4
);
1978 tcg_gen_sub_i64(t3
, t1
, t2
);
1979 tcg_gen_extrl_i64_i32(temp3
, t3
);
1981 tcg_gen_setcondi_i64(TCG_COND_GT
, t1
, t3
, 0x7fffffffLL
);
1982 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t3
, -0x80000000LL
);
1983 tcg_gen_or_i64(t1
, t1
, t2
);
1984 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1985 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1987 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1988 /* Calc AV/SAV bits */
1989 tcg_gen_add_tl(cpu_PSW_AV
, temp3
, temp3
);
1990 tcg_gen_xor_tl(cpu_PSW_AV
, temp3
, cpu_PSW_AV
);
1992 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1993 /* write back result */
1994 tcg_gen_mov_tl(ret
, temp3
);
1996 tcg_temp_free(temp
);
1997 tcg_temp_free(temp2
);
1998 tcg_temp_free(temp3
);
1999 tcg_temp_free_i64(t1
);
2000 tcg_temp_free_i64(t2
);
2001 tcg_temp_free_i64(t3
);
2002 tcg_temp_free_i64(t4
);
2006 gen_m16sub32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
2008 TCGv temp
= tcg_temp_new();
2009 TCGv temp2
= tcg_temp_new();
2011 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2012 } else { /* n is expected to be 1 */
2013 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2014 tcg_gen_shli_tl(temp
, temp
, 1);
2015 /* catch special case r1 = r2 = 0x8000 */
2016 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
2017 tcg_gen_sub_tl(temp
, temp
, temp2
);
2019 gen_sub_d(ret
, arg1
, temp
);
2021 tcg_temp_free(temp
);
2022 tcg_temp_free(temp2
);
2026 gen_m16subs32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
2028 TCGv temp
= tcg_temp_new();
2029 TCGv temp2
= tcg_temp_new();
2031 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2032 } else { /* n is expected to be 1 */
2033 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2034 tcg_gen_shli_tl(temp
, temp
, 1);
2035 /* catch special case r1 = r2 = 0x8000 */
2036 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
2037 tcg_gen_sub_tl(temp
, temp
, temp2
);
2039 gen_subs(ret
, arg1
, temp
);
2041 tcg_temp_free(temp
);
2042 tcg_temp_free(temp2
);
2046 gen_m16sub64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
2047 TCGv arg3
, uint32_t n
)
2049 TCGv temp
= tcg_temp_new();
2050 TCGv temp2
= tcg_temp_new();
2051 TCGv_i64 t1
= tcg_temp_new_i64();
2052 TCGv_i64 t2
= tcg_temp_new_i64();
2053 TCGv_i64 t3
= tcg_temp_new_i64();
2056 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2057 } else { /* n is expected to be 1 */
2058 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2059 tcg_gen_shli_tl(temp
, temp
, 1);
2060 /* catch special case r1 = r2 = 0x8000 */
2061 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
2062 tcg_gen_sub_tl(temp
, temp
, temp2
);
2064 tcg_gen_ext_i32_i64(t2
, temp
);
2065 tcg_gen_shli_i64(t2
, t2
, 16);
2066 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
2067 gen_sub64_d(t3
, t1
, t2
);
2068 /* write back result */
2069 tcg_gen_extr_i64_i32(rl
, rh
, t3
);
2071 tcg_temp_free_i64(t1
);
2072 tcg_temp_free_i64(t2
);
2073 tcg_temp_free_i64(t3
);
2074 tcg_temp_free(temp
);
2075 tcg_temp_free(temp2
);
2079 gen_m16subs64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
2080 TCGv arg3
, uint32_t n
)
2082 TCGv temp
= tcg_temp_new();
2083 TCGv temp2
= tcg_temp_new();
2084 TCGv_i64 t1
= tcg_temp_new_i64();
2085 TCGv_i64 t2
= tcg_temp_new_i64();
2088 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2089 } else { /* n is expected to be 1 */
2090 tcg_gen_mul_tl(temp
, arg2
, arg3
);
2091 tcg_gen_shli_tl(temp
, temp
, 1);
2092 /* catch special case r1 = r2 = 0x8000 */
2093 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
2094 tcg_gen_sub_tl(temp
, temp
, temp2
);
2096 tcg_gen_ext_i32_i64(t2
, temp
);
2097 tcg_gen_shli_i64(t2
, t2
, 16);
2098 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
2100 gen_helper_sub64_ssov(t1
, cpu_env
, t1
, t2
);
2101 tcg_gen_extr_i64_i32(rl
, rh
, t1
);
2103 tcg_temp_free(temp
);
2104 tcg_temp_free(temp2
);
2105 tcg_temp_free_i64(t1
);
2106 tcg_temp_free_i64(t2
);
2110 gen_msub64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
2111 TCGv arg3
, uint32_t n
)
2113 TCGv_i64 t1
= tcg_temp_new_i64();
2114 TCGv_i64 t2
= tcg_temp_new_i64();
2115 TCGv_i64 t3
= tcg_temp_new_i64();
2116 TCGv_i64 t4
= tcg_temp_new_i64();
2119 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
2120 tcg_gen_ext_i32_i64(t2
, arg2
);
2121 tcg_gen_ext_i32_i64(t3
, arg3
);
2123 tcg_gen_mul_i64(t2
, t2
, t3
);
2125 tcg_gen_shli_i64(t2
, t2
, 1);
2127 tcg_gen_sub_i64(t4
, t1
, t2
);
2129 tcg_gen_xor_i64(t3
, t4
, t1
);
2130 tcg_gen_xor_i64(t2
, t1
, t2
);
2131 tcg_gen_and_i64(t3
, t3
, t2
);
2132 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t3
);
2133 /* We produce an overflow on the host if the mul before was
2134 (0x80000000 * 0x80000000) << 1). If this is the
2135 case, we negate the ovf. */
2137 temp
= tcg_temp_new();
2138 temp2
= tcg_temp_new();
2139 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
2140 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
2141 tcg_gen_and_tl(temp
, temp
, temp2
);
2142 tcg_gen_shli_tl(temp
, temp
, 31);
2143 /* negate v bit, if special condition */
2144 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
2146 tcg_temp_free(temp
);
2147 tcg_temp_free(temp2
);
2149 /* write back result */
2150 tcg_gen_extr_i64_i32(rl
, rh
, t4
);
2152 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2153 /* Calc AV/SAV bits */
2154 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
2155 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
2157 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2159 tcg_temp_free_i64(t1
);
2160 tcg_temp_free_i64(t2
);
2161 tcg_temp_free_i64(t3
);
2162 tcg_temp_free_i64(t4
);
2166 gen_msubs32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
2169 TCGv_i64 t1
= tcg_temp_new_i64();
2170 TCGv_i64 t2
= tcg_temp_new_i64();
2171 TCGv_i64 t3
= tcg_temp_new_i64();
2172 TCGv_i64 t4
= tcg_temp_new_i64();
2174 tcg_gen_ext_i32_i64(t1
, arg1
);
2175 tcg_gen_ext_i32_i64(t2
, arg2
);
2176 tcg_gen_ext_i32_i64(t3
, arg3
);
2178 tcg_gen_mul_i64(t2
, t2
, t3
);
2179 /* if we shift part of the fraction out, we need to round up */
2180 tcg_gen_andi_i64(t4
, t2
, (1ll << (up_shift
- n
)) - 1);
2181 tcg_gen_setcondi_i64(TCG_COND_NE
, t4
, t4
, 0);
2182 tcg_gen_sari_i64(t3
, t2
, up_shift
- n
);
2183 tcg_gen_add_i64(t3
, t3
, t4
);
2185 gen_helper_msub32_q_sub_ssov(ret
, cpu_env
, t1
, t3
);
2187 tcg_temp_free_i64(t1
);
2188 tcg_temp_free_i64(t2
);
2189 tcg_temp_free_i64(t3
);
2190 tcg_temp_free_i64(t4
);
2194 gen_msubs64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
2195 TCGv arg3
, uint32_t n
)
2197 TCGv_i64 r1
= tcg_temp_new_i64();
2198 TCGv temp
= tcg_const_i32(n
);
2200 tcg_gen_concat_i32_i64(r1
, arg1_low
, arg1_high
);
2201 gen_helper_msub64_q_ssov(r1
, cpu_env
, r1
, arg2
, arg3
, temp
);
2202 tcg_gen_extr_i64_i32(rl
, rh
, r1
);
2204 tcg_temp_free_i64(r1
);
2205 tcg_temp_free(temp
);
2209 gen_msubad_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2210 TCGv r3
, uint32_t n
, uint32_t mode
)
2212 TCGv temp
= tcg_const_i32(n
);
2213 TCGv temp2
= tcg_temp_new();
2214 TCGv_i64 temp64
= tcg_temp_new_i64();
2217 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2220 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2223 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2226 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2229 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
2230 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
2231 tcg_gen_add_tl
, tcg_gen_sub_tl
);
2232 tcg_temp_free(temp
);
2233 tcg_temp_free(temp2
);
2234 tcg_temp_free_i64(temp64
);
2238 gen_msubadm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2239 TCGv r3
, uint32_t n
, uint32_t mode
)
2241 TCGv temp
= tcg_const_i32(n
);
2242 TCGv_i64 temp64
= tcg_temp_new_i64();
2243 TCGv_i64 temp64_2
= tcg_temp_new_i64();
2244 TCGv_i64 temp64_3
= tcg_temp_new_i64();
2247 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2250 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2253 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2256 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2259 tcg_gen_concat_i32_i64(temp64_3
, r1_low
, r1_high
);
2260 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
2261 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
2262 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
2263 tcg_gen_shli_i64(temp64
, temp64
, 16);
2265 gen_sub64_d(temp64_2
, temp64_3
, temp64
);
2266 /* write back result */
2267 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_2
);
2269 tcg_temp_free(temp
);
2270 tcg_temp_free_i64(temp64
);
2271 tcg_temp_free_i64(temp64_2
);
2272 tcg_temp_free_i64(temp64_3
);
2276 gen_msubadr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
2278 TCGv temp
= tcg_const_i32(n
);
2279 TCGv temp2
= tcg_temp_new();
2280 TCGv_i64 temp64
= tcg_temp_new_i64();
2283 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2286 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2289 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2292 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2295 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
2296 tcg_gen_shli_tl(temp
, r1
, 16);
2297 gen_helper_subadr_h(ret
, cpu_env
, temp64
, temp
, temp2
);
2299 tcg_temp_free(temp
);
2300 tcg_temp_free(temp2
);
2301 tcg_temp_free_i64(temp64
);
2305 gen_msubads_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2306 TCGv r3
, uint32_t n
, uint32_t mode
)
2308 TCGv temp
= tcg_const_i32(n
);
2309 TCGv temp2
= tcg_temp_new();
2310 TCGv temp3
= tcg_temp_new();
2311 TCGv_i64 temp64
= tcg_temp_new_i64();
2315 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2318 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2321 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2324 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2327 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
2328 gen_adds(ret_low
, r1_low
, temp
);
2329 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
2330 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
2331 gen_subs(ret_high
, r1_high
, temp2
);
2332 /* combine v bits */
2333 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
2334 /* combine av bits */
2335 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
2337 tcg_temp_free(temp
);
2338 tcg_temp_free(temp2
);
2339 tcg_temp_free(temp3
);
2340 tcg_temp_free_i64(temp64
);
2344 gen_msubadms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2345 TCGv r3
, uint32_t n
, uint32_t mode
)
2347 TCGv temp
= tcg_const_i32(n
);
2348 TCGv_i64 temp64
= tcg_temp_new_i64();
2349 TCGv_i64 temp64_2
= tcg_temp_new_i64();
2353 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2356 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2359 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2362 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2365 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
2366 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
2367 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
2368 tcg_gen_shli_i64(temp64
, temp64
, 16);
2369 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
2371 gen_helper_sub64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
2372 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2374 tcg_temp_free(temp
);
2375 tcg_temp_free_i64(temp64
);
2376 tcg_temp_free_i64(temp64_2
);
2380 gen_msubadr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
2382 TCGv temp
= tcg_const_i32(n
);
2383 TCGv temp2
= tcg_temp_new();
2384 TCGv_i64 temp64
= tcg_temp_new_i64();
2387 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, temp
);
2390 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, temp
);
2393 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, temp
);
2396 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, temp
);
2399 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
2400 tcg_gen_shli_tl(temp
, r1
, 16);
2401 gen_helper_subadr_h_ssov(ret
, cpu_env
, temp64
, temp
, temp2
);
2403 tcg_temp_free(temp
);
2404 tcg_temp_free(temp2
);
2405 tcg_temp_free_i64(temp64
);
2408 static inline void gen_abs(TCGv ret
, TCGv r1
)
2410 tcg_gen_abs_tl(ret
, r1
);
2411 /* overflow can only happen, if r1 = 0x80000000 */
2412 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, r1
, 0x80000000);
2413 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2415 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2417 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2418 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2420 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2423 static inline void gen_absdif(TCGv ret
, TCGv r1
, TCGv r2
)
2425 TCGv temp
= tcg_temp_new_i32();
2426 TCGv result
= tcg_temp_new_i32();
2428 tcg_gen_sub_tl(result
, r1
, r2
);
2429 tcg_gen_sub_tl(temp
, r2
, r1
);
2430 tcg_gen_movcond_tl(TCG_COND_GT
, result
, r1
, r2
, result
, temp
);
2433 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
2434 tcg_gen_xor_tl(temp
, result
, r2
);
2435 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_PSW_V
, r1
, r2
, cpu_PSW_V
, temp
);
2436 tcg_gen_xor_tl(temp
, r1
, r2
);
2437 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
2439 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2441 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
2442 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
2444 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2445 /* write back result */
2446 tcg_gen_mov_tl(ret
, result
);
2448 tcg_temp_free(temp
);
2449 tcg_temp_free(result
);
2452 static inline void gen_absdifi(TCGv ret
, TCGv r1
, int32_t con
)
2454 TCGv temp
= tcg_const_i32(con
);
2455 gen_absdif(ret
, r1
, temp
);
2456 tcg_temp_free(temp
);
2459 static inline void gen_absdifsi(TCGv ret
, TCGv r1
, int32_t con
)
2461 TCGv temp
= tcg_const_i32(con
);
2462 gen_helper_absdif_ssov(ret
, cpu_env
, r1
, temp
);
2463 tcg_temp_free(temp
);
2466 static inline void gen_mul_i32s(TCGv ret
, TCGv r1
, TCGv r2
)
2468 TCGv high
= tcg_temp_new();
2469 TCGv low
= tcg_temp_new();
2471 tcg_gen_muls2_tl(low
, high
, r1
, r2
);
2472 tcg_gen_mov_tl(ret
, low
);
2474 tcg_gen_sari_tl(low
, low
, 31);
2475 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_PSW_V
, high
, low
);
2476 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2478 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2480 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2481 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2483 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2485 tcg_temp_free(high
);
2489 static inline void gen_muli_i32s(TCGv ret
, TCGv r1
, int32_t con
)
2491 TCGv temp
= tcg_const_i32(con
);
2492 gen_mul_i32s(ret
, r1
, temp
);
2493 tcg_temp_free(temp
);
2496 static inline void gen_mul_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
2498 tcg_gen_muls2_tl(ret_low
, ret_high
, r1
, r2
);
2500 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2502 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2504 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
2505 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
2507 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2510 static inline void gen_muli_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
2513 TCGv temp
= tcg_const_i32(con
);
2514 gen_mul_i64s(ret_low
, ret_high
, r1
, temp
);
2515 tcg_temp_free(temp
);
2518 static inline void gen_mul_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
2520 tcg_gen_mulu2_tl(ret_low
, ret_high
, r1
, r2
);
2522 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2524 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2526 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
2527 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
2529 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2532 static inline void gen_muli_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
2535 TCGv temp
= tcg_const_i32(con
);
2536 gen_mul_i64u(ret_low
, ret_high
, r1
, temp
);
2537 tcg_temp_free(temp
);
2540 static inline void gen_mulsi_i32(TCGv ret
, TCGv r1
, int32_t con
)
2542 TCGv temp
= tcg_const_i32(con
);
2543 gen_helper_mul_ssov(ret
, cpu_env
, r1
, temp
);
2544 tcg_temp_free(temp
);
2547 static inline void gen_mulsui_i32(TCGv ret
, TCGv r1
, int32_t con
)
2549 TCGv temp
= tcg_const_i32(con
);
2550 gen_helper_mul_suov(ret
, cpu_env
, r1
, temp
);
2551 tcg_temp_free(temp
);
2553 /* gen_maddsi_32(cpu_gpr_d[r4], cpu_gpr_d[r1], cpu_gpr_d[r3], const9); */
2554 static inline void gen_maddsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2556 TCGv temp
= tcg_const_i32(con
);
2557 gen_helper_madd32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
2558 tcg_temp_free(temp
);
2561 static inline void gen_maddsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2563 TCGv temp
= tcg_const_i32(con
);
2564 gen_helper_madd32_suov(ret
, cpu_env
, r1
, r2
, temp
);
2565 tcg_temp_free(temp
);
2569 gen_mul_q(TCGv rl
, TCGv rh
, TCGv arg1
, TCGv arg2
, uint32_t n
, uint32_t up_shift
)
2571 TCGv temp
= tcg_temp_new();
2572 TCGv_i64 temp_64
= tcg_temp_new_i64();
2573 TCGv_i64 temp2_64
= tcg_temp_new_i64();
2576 if (up_shift
== 32) {
2577 tcg_gen_muls2_tl(rh
, rl
, arg1
, arg2
);
2578 } else if (up_shift
== 16) {
2579 tcg_gen_ext_i32_i64(temp_64
, arg1
);
2580 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
2582 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
2583 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
);
2584 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
2586 tcg_gen_muls2_tl(rl
, rh
, arg1
, arg2
);
2589 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2590 } else { /* n is expected to be 1 */
2591 tcg_gen_ext_i32_i64(temp_64
, arg1
);
2592 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
2594 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
2596 if (up_shift
== 0) {
2597 tcg_gen_shli_i64(temp_64
, temp_64
, 1);
2599 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
- 1);
2601 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
2602 /* overflow only occurs if r1 = r2 = 0x8000 */
2603 if (up_shift
== 0) {/* result is 64 bit */
2604 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rh
,
2606 } else { /* result is 32 bit */
2607 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rl
,
2610 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2611 /* calc sv overflow bit */
2612 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2614 /* calc av overflow bit */
2615 if (up_shift
== 0) {
2616 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
2617 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
2619 tcg_gen_add_tl(cpu_PSW_AV
, rl
, rl
);
2620 tcg_gen_xor_tl(cpu_PSW_AV
, rl
, cpu_PSW_AV
);
2622 /* calc sav overflow bit */
2623 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2624 tcg_temp_free(temp
);
2625 tcg_temp_free_i64(temp_64
);
2626 tcg_temp_free_i64(temp2_64
);
2630 gen_mul_q_16(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
2632 TCGv temp
= tcg_temp_new();
2634 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2635 } else { /* n is expected to be 1 */
2636 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2637 tcg_gen_shli_tl(ret
, ret
, 1);
2638 /* catch special case r1 = r2 = 0x8000 */
2639 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80000000);
2640 tcg_gen_sub_tl(ret
, ret
, temp
);
2643 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2644 /* calc av overflow bit */
2645 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2646 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2647 /* calc sav overflow bit */
2648 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2650 tcg_temp_free(temp
);
2653 static void gen_mulr_q(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
2655 TCGv temp
= tcg_temp_new();
2657 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2658 tcg_gen_addi_tl(ret
, ret
, 0x8000);
2660 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2661 tcg_gen_shli_tl(ret
, ret
, 1);
2662 tcg_gen_addi_tl(ret
, ret
, 0x8000);
2663 /* catch special case r1 = r2 = 0x8000 */
2664 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80008000);
2665 tcg_gen_muli_tl(temp
, temp
, 0x8001);
2666 tcg_gen_sub_tl(ret
, ret
, temp
);
2669 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2670 /* calc av overflow bit */
2671 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2672 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2673 /* calc sav overflow bit */
2674 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2675 /* cut halfword off */
2676 tcg_gen_andi_tl(ret
, ret
, 0xffff0000);
2678 tcg_temp_free(temp
);
2682 gen_madds_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2685 TCGv_i64 temp64
= tcg_temp_new_i64();
2686 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2687 gen_helper_madd64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
2688 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2689 tcg_temp_free_i64(temp64
);
2693 gen_maddsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2696 TCGv temp
= tcg_const_i32(con
);
2697 gen_madds_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2698 tcg_temp_free(temp
);
2702 gen_maddsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2705 TCGv_i64 temp64
= tcg_temp_new_i64();
2706 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2707 gen_helper_madd64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
2708 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2709 tcg_temp_free_i64(temp64
);
2713 gen_maddsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2716 TCGv temp
= tcg_const_i32(con
);
2717 gen_maddsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2718 tcg_temp_free(temp
);
2721 static inline void gen_msubsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2723 TCGv temp
= tcg_const_i32(con
);
2724 gen_helper_msub32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
2725 tcg_temp_free(temp
);
2728 static inline void gen_msubsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2730 TCGv temp
= tcg_const_i32(con
);
2731 gen_helper_msub32_suov(ret
, cpu_env
, r1
, r2
, temp
);
2732 tcg_temp_free(temp
);
2736 gen_msubs_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2739 TCGv_i64 temp64
= tcg_temp_new_i64();
2740 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2741 gen_helper_msub64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
2742 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2743 tcg_temp_free_i64(temp64
);
2747 gen_msubsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2750 TCGv temp
= tcg_const_i32(con
);
2751 gen_msubs_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2752 tcg_temp_free(temp
);
2756 gen_msubsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2759 TCGv_i64 temp64
= tcg_temp_new_i64();
2760 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2761 gen_helper_msub64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
2762 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2763 tcg_temp_free_i64(temp64
);
2767 gen_msubsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2770 TCGv temp
= tcg_const_i32(con
);
2771 gen_msubsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2772 tcg_temp_free(temp
);
2775 static void gen_saturate(TCGv ret
, TCGv arg
, int32_t up
, int32_t low
)
2777 TCGv sat_neg
= tcg_const_i32(low
);
2778 TCGv temp
= tcg_const_i32(up
);
2780 /* sat_neg = (arg < low ) ? low : arg; */
2781 tcg_gen_movcond_tl(TCG_COND_LT
, sat_neg
, arg
, sat_neg
, sat_neg
, arg
);
2783 /* ret = (sat_neg > up ) ? up : sat_neg; */
2784 tcg_gen_movcond_tl(TCG_COND_GT
, ret
, sat_neg
, temp
, temp
, sat_neg
);
2786 tcg_temp_free(sat_neg
);
2787 tcg_temp_free(temp
);
2790 static void gen_saturate_u(TCGv ret
, TCGv arg
, int32_t up
)
2792 TCGv temp
= tcg_const_i32(up
);
2793 /* sat_neg = (arg > up ) ? up : arg; */
2794 tcg_gen_movcond_tl(TCG_COND_GTU
, ret
, arg
, temp
, temp
, arg
);
2795 tcg_temp_free(temp
);
2798 static void gen_shi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2800 if (shift_count
== -32) {
2801 tcg_gen_movi_tl(ret
, 0);
2802 } else if (shift_count
>= 0) {
2803 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2805 tcg_gen_shri_tl(ret
, r1
, -shift_count
);
2809 static void gen_sh_hi(TCGv ret
, TCGv r1
, int32_t shiftcount
)
2811 TCGv temp_low
, temp_high
;
2813 if (shiftcount
== -16) {
2814 tcg_gen_movi_tl(ret
, 0);
2816 temp_high
= tcg_temp_new();
2817 temp_low
= tcg_temp_new();
2819 tcg_gen_andi_tl(temp_low
, r1
, 0xffff);
2820 tcg_gen_andi_tl(temp_high
, r1
, 0xffff0000);
2821 gen_shi(temp_low
, temp_low
, shiftcount
);
2822 gen_shi(ret
, temp_high
, shiftcount
);
2823 tcg_gen_deposit_tl(ret
, ret
, temp_low
, 0, 16);
2825 tcg_temp_free(temp_low
);
2826 tcg_temp_free(temp_high
);
2830 static void gen_shaci(TCGv ret
, TCGv r1
, int32_t shift_count
)
2832 uint32_t msk
, msk_start
;
2833 TCGv temp
= tcg_temp_new();
2834 TCGv temp2
= tcg_temp_new();
2835 TCGv t_0
= tcg_const_i32(0);
2837 if (shift_count
== 0) {
2838 /* Clear PSW.C and PSW.V */
2839 tcg_gen_movi_tl(cpu_PSW_C
, 0);
2840 tcg_gen_mov_tl(cpu_PSW_V
, cpu_PSW_C
);
2841 tcg_gen_mov_tl(ret
, r1
);
2842 } else if (shift_count
== -32) {
2844 tcg_gen_mov_tl(cpu_PSW_C
, r1
);
2845 /* fill ret completely with sign bit */
2846 tcg_gen_sari_tl(ret
, r1
, 31);
2848 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2849 } else if (shift_count
> 0) {
2850 TCGv t_max
= tcg_const_i32(0x7FFFFFFF >> shift_count
);
2851 TCGv t_min
= tcg_const_i32(((int32_t) -0x80000000) >> shift_count
);
2854 msk_start
= 32 - shift_count
;
2855 msk
= ((1 << shift_count
) - 1) << msk_start
;
2856 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2857 /* calc v/sv bits */
2858 tcg_gen_setcond_tl(TCG_COND_GT
, temp
, r1
, t_max
);
2859 tcg_gen_setcond_tl(TCG_COND_LT
, temp2
, r1
, t_min
);
2860 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
2861 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2863 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_V
, cpu_PSW_SV
);
2865 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2867 tcg_temp_free(t_max
);
2868 tcg_temp_free(t_min
);
2871 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2873 msk
= (1 << -shift_count
) - 1;
2874 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2876 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2878 /* calc av overflow bit */
2879 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2880 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2881 /* calc sav overflow bit */
2882 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2884 tcg_temp_free(temp
);
2885 tcg_temp_free(temp2
);
2889 static void gen_shas(TCGv ret
, TCGv r1
, TCGv r2
)
2891 gen_helper_sha_ssov(ret
, cpu_env
, r1
, r2
);
2894 static void gen_shasi(TCGv ret
, TCGv r1
, int32_t con
)
2896 TCGv temp
= tcg_const_i32(con
);
2897 gen_shas(ret
, r1
, temp
);
2898 tcg_temp_free(temp
);
2901 static void gen_sha_hi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2905 if (shift_count
== 0) {
2906 tcg_gen_mov_tl(ret
, r1
);
2907 } else if (shift_count
> 0) {
2908 low
= tcg_temp_new();
2909 high
= tcg_temp_new();
2911 tcg_gen_andi_tl(high
, r1
, 0xffff0000);
2912 tcg_gen_shli_tl(low
, r1
, shift_count
);
2913 tcg_gen_shli_tl(ret
, high
, shift_count
);
2914 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2917 tcg_temp_free(high
);
2919 low
= tcg_temp_new();
2920 high
= tcg_temp_new();
2922 tcg_gen_ext16s_tl(low
, r1
);
2923 tcg_gen_sari_tl(low
, low
, -shift_count
);
2924 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2925 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2928 tcg_temp_free(high
);
2933 /* ret = {ret[30:0], (r1 cond r2)}; */
2934 static void gen_sh_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
)
2936 TCGv temp
= tcg_temp_new();
2937 TCGv temp2
= tcg_temp_new();
2939 tcg_gen_shli_tl(temp
, ret
, 1);
2940 tcg_gen_setcond_tl(cond
, temp2
, r1
, r2
);
2941 tcg_gen_or_tl(ret
, temp
, temp2
);
2943 tcg_temp_free(temp
);
2944 tcg_temp_free(temp2
);
2947 static void gen_sh_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
)
2949 TCGv temp
= tcg_const_i32(con
);
2950 gen_sh_cond(cond
, ret
, r1
, temp
);
2951 tcg_temp_free(temp
);
2954 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
)
2956 gen_helper_add_ssov(ret
, cpu_env
, r1
, r2
);
2959 static inline void gen_addsi(TCGv ret
, TCGv r1
, int32_t con
)
2961 TCGv temp
= tcg_const_i32(con
);
2962 gen_helper_add_ssov(ret
, cpu_env
, r1
, temp
);
2963 tcg_temp_free(temp
);
2966 static inline void gen_addsui(TCGv ret
, TCGv r1
, int32_t con
)
2968 TCGv temp
= tcg_const_i32(con
);
2969 gen_helper_add_suov(ret
, cpu_env
, r1
, temp
);
2970 tcg_temp_free(temp
);
2973 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
)
2975 gen_helper_sub_ssov(ret
, cpu_env
, r1
, r2
);
2978 static inline void gen_subsu(TCGv ret
, TCGv r1
, TCGv r2
)
2980 gen_helper_sub_suov(ret
, cpu_env
, r1
, r2
);
2983 static inline void gen_bit_2op(TCGv ret
, TCGv r1
, TCGv r2
,
2985 void(*op1
)(TCGv
, TCGv
, TCGv
),
2986 void(*op2
)(TCGv
, TCGv
, TCGv
))
2990 temp1
= tcg_temp_new();
2991 temp2
= tcg_temp_new();
2993 tcg_gen_shri_tl(temp2
, r2
, pos2
);
2994 tcg_gen_shri_tl(temp1
, r1
, pos1
);
2996 (*op1
)(temp1
, temp1
, temp2
);
2997 (*op2
)(temp1
, ret
, temp1
);
2999 tcg_gen_deposit_tl(ret
, ret
, temp1
, 0, 1);
3001 tcg_temp_free(temp1
);
3002 tcg_temp_free(temp2
);
3005 /* ret = r1[pos1] op1 r2[pos2]; */
3006 static inline void gen_bit_1op(TCGv ret
, TCGv r1
, TCGv r2
,
3008 void(*op1
)(TCGv
, TCGv
, TCGv
))
3012 temp1
= tcg_temp_new();
3013 temp2
= tcg_temp_new();
3015 tcg_gen_shri_tl(temp2
, r2
, pos2
);
3016 tcg_gen_shri_tl(temp1
, r1
, pos1
);
3018 (*op1
)(ret
, temp1
, temp2
);
3020 tcg_gen_andi_tl(ret
, ret
, 0x1);
3022 tcg_temp_free(temp1
);
3023 tcg_temp_free(temp2
);
3026 static inline void gen_accumulating_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
,
3027 void(*op
)(TCGv
, TCGv
, TCGv
))
3029 TCGv temp
= tcg_temp_new();
3030 TCGv temp2
= tcg_temp_new();
3031 /* temp = (arg1 cond arg2 )*/
3032 tcg_gen_setcond_tl(cond
, temp
, r1
, r2
);
3034 tcg_gen_andi_tl(temp2
, ret
, 0x1);
3035 /* temp = temp insn temp2 */
3036 (*op
)(temp
, temp
, temp2
);
3037 /* ret = {ret[31:1], temp} */
3038 tcg_gen_deposit_tl(ret
, ret
, temp
, 0, 1);
3040 tcg_temp_free(temp
);
3041 tcg_temp_free(temp2
);
3045 gen_accumulating_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
,
3046 void(*op
)(TCGv
, TCGv
, TCGv
))
3048 TCGv temp
= tcg_const_i32(con
);
3049 gen_accumulating_cond(cond
, ret
, r1
, temp
, op
);
3050 tcg_temp_free(temp
);
3053 /* ret = (r1 cond r2) ? 0xFFFFFFFF ? 0x00000000;*/
3054 static inline void gen_cond_w(TCGCond cond
, TCGv ret
, TCGv r1
, TCGv r2
)
3056 tcg_gen_setcond_tl(cond
, ret
, r1
, r2
);
3057 tcg_gen_neg_tl(ret
, ret
);
3060 static inline void gen_eqany_bi(TCGv ret
, TCGv r1
, int32_t con
)
3062 TCGv b0
= tcg_temp_new();
3063 TCGv b1
= tcg_temp_new();
3064 TCGv b2
= tcg_temp_new();
3065 TCGv b3
= tcg_temp_new();
3068 tcg_gen_andi_tl(b0
, r1
, 0xff);
3069 tcg_gen_setcondi_tl(TCG_COND_EQ
, b0
, b0
, con
& 0xff);
3072 tcg_gen_andi_tl(b1
, r1
, 0xff00);
3073 tcg_gen_setcondi_tl(TCG_COND_EQ
, b1
, b1
, con
& 0xff00);
3076 tcg_gen_andi_tl(b2
, r1
, 0xff0000);
3077 tcg_gen_setcondi_tl(TCG_COND_EQ
, b2
, b2
, con
& 0xff0000);
3080 tcg_gen_andi_tl(b3
, r1
, 0xff000000);
3081 tcg_gen_setcondi_tl(TCG_COND_EQ
, b3
, b3
, con
& 0xff000000);
3084 tcg_gen_or_tl(ret
, b0
, b1
);
3085 tcg_gen_or_tl(ret
, ret
, b2
);
3086 tcg_gen_or_tl(ret
, ret
, b3
);
3094 static inline void gen_eqany_hi(TCGv ret
, TCGv r1
, int32_t con
)
3096 TCGv h0
= tcg_temp_new();
3097 TCGv h1
= tcg_temp_new();
3100 tcg_gen_andi_tl(h0
, r1
, 0xffff);
3101 tcg_gen_setcondi_tl(TCG_COND_EQ
, h0
, h0
, con
& 0xffff);
3104 tcg_gen_andi_tl(h1
, r1
, 0xffff0000);
3105 tcg_gen_setcondi_tl(TCG_COND_EQ
, h1
, h1
, con
& 0xffff0000);
3108 tcg_gen_or_tl(ret
, h0
, h1
);
3113 /* mask = ((1 << width) -1) << pos;
3114 ret = (r1 & ~mask) | (r2 << pos) & mask); */
3115 static inline void gen_insert(TCGv ret
, TCGv r1
, TCGv r2
, TCGv width
, TCGv pos
)
3117 TCGv mask
= tcg_temp_new();
3118 TCGv temp
= tcg_temp_new();
3119 TCGv temp2
= tcg_temp_new();
3121 tcg_gen_movi_tl(mask
, 1);
3122 tcg_gen_shl_tl(mask
, mask
, width
);
3123 tcg_gen_subi_tl(mask
, mask
, 1);
3124 tcg_gen_shl_tl(mask
, mask
, pos
);
3126 tcg_gen_shl_tl(temp
, r2
, pos
);
3127 tcg_gen_and_tl(temp
, temp
, mask
);
3128 tcg_gen_andc_tl(temp2
, r1
, mask
);
3129 tcg_gen_or_tl(ret
, temp
, temp2
);
3131 tcg_temp_free(mask
);
3132 tcg_temp_free(temp
);
3133 tcg_temp_free(temp2
);
3136 static inline void gen_bsplit(TCGv rl
, TCGv rh
, TCGv r1
)
3138 TCGv_i64 temp
= tcg_temp_new_i64();
3140 gen_helper_bsplit(temp
, r1
);
3141 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
3143 tcg_temp_free_i64(temp
);
3146 static inline void gen_unpack(TCGv rl
, TCGv rh
, TCGv r1
)
3148 TCGv_i64 temp
= tcg_temp_new_i64();
3150 gen_helper_unpack(temp
, r1
);
3151 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
3153 tcg_temp_free_i64(temp
);
3157 gen_dvinit_b(DisasContext
*ctx
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
3159 TCGv_i64 ret
= tcg_temp_new_i64();
3161 if (!tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
3162 gen_helper_dvinit_b_13(ret
, cpu_env
, r1
, r2
);
3164 gen_helper_dvinit_b_131(ret
, cpu_env
, r1
, r2
);
3166 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
3168 tcg_temp_free_i64(ret
);
3172 gen_dvinit_h(DisasContext
*ctx
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
3174 TCGv_i64 ret
= tcg_temp_new_i64();
3176 if (!tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
3177 gen_helper_dvinit_h_13(ret
, cpu_env
, r1
, r2
);
3179 gen_helper_dvinit_h_131(ret
, cpu_env
, r1
, r2
);
3181 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
3183 tcg_temp_free_i64(ret
);
3186 static void gen_calc_usb_mul_h(TCGv arg_low
, TCGv arg_high
)
3188 TCGv temp
= tcg_temp_new();
3190 tcg_gen_add_tl(temp
, arg_low
, arg_low
);
3191 tcg_gen_xor_tl(temp
, temp
, arg_low
);
3192 tcg_gen_add_tl(cpu_PSW_AV
, arg_high
, arg_high
);
3193 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, arg_high
);
3194 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
3196 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
3197 tcg_gen_movi_tl(cpu_PSW_V
, 0);
3198 tcg_temp_free(temp
);
3201 static void gen_calc_usb_mulr_h(TCGv arg
)
3203 TCGv temp
= tcg_temp_new();
3205 tcg_gen_add_tl(temp
, arg
, arg
);
3206 tcg_gen_xor_tl(temp
, temp
, arg
);
3207 tcg_gen_shli_tl(cpu_PSW_AV
, temp
, 16);
3208 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
3210 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
3212 tcg_gen_movi_tl(cpu_PSW_V
, 0);
3213 tcg_temp_free(temp
);
3216 /* helpers for generating program flow micro-ops */
3218 static inline void gen_save_pc(target_ulong pc
)
3220 tcg_gen_movi_tl(cpu_PC
, pc
);
3223 static inline bool use_goto_tb(DisasContext
*ctx
, target_ulong dest
)
3225 if (unlikely(ctx
->base
.singlestep_enabled
)) {
3229 #ifndef CONFIG_USER_ONLY
3230 return (ctx
->base
.tb
->pc
& TARGET_PAGE_MASK
) == (dest
& TARGET_PAGE_MASK
);
3236 static inline void gen_goto_tb(DisasContext
*ctx
, int n
, target_ulong dest
)
3238 if (use_goto_tb(ctx
, dest
)) {
3241 tcg_gen_exit_tb(ctx
->base
.tb
, n
);
3244 if (ctx
->base
.singlestep_enabled
) {
3245 /* raise exception debug */
3247 tcg_gen_exit_tb(NULL
, 0);
3251 static void generate_trap(DisasContext
*ctx
, int class, int tin
)
3253 TCGv_i32 classtemp
= tcg_const_i32(class);
3254 TCGv_i32 tintemp
= tcg_const_i32(tin
);
3256 gen_save_pc(ctx
->base
.pc_next
);
3257 gen_helper_raise_exception_sync(cpu_env
, classtemp
, tintemp
);
3258 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3260 tcg_temp_free(classtemp
);
3261 tcg_temp_free(tintemp
);
3264 static void generate_qemu_excp(DisasContext
*ctx
, int excp
)
3266 TCGv_i32 tmp
= tcg_const_i32(excp
);
3267 gen_save_pc(ctx
->base
.pc_next
);
3268 gen_helper_qemu_excp(cpu_env
, tmp
);
3269 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3273 static inline void gen_branch_cond(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
3274 TCGv r2
, int16_t address
)
3276 TCGLabel
*jumpLabel
= gen_new_label();
3277 tcg_gen_brcond_tl(cond
, r1
, r2
, jumpLabel
);
3279 gen_goto_tb(ctx
, 1, ctx
->pc_succ_insn
);
3281 gen_set_label(jumpLabel
);
3282 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ address
* 2);
3285 static inline void gen_branch_condi(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
3286 int r2
, int16_t address
)
3288 TCGv temp
= tcg_const_i32(r2
);
3289 gen_branch_cond(ctx
, cond
, r1
, temp
, address
);
3290 tcg_temp_free(temp
);
3293 static void gen_loop(DisasContext
*ctx
, int r1
, int32_t offset
)
3295 TCGLabel
*l1
= gen_new_label();
3297 tcg_gen_subi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], 1);
3298 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr_a
[r1
], -1, l1
);
3299 gen_goto_tb(ctx
, 1, ctx
->base
.pc_next
+ offset
);
3301 gen_goto_tb(ctx
, 0, ctx
->pc_succ_insn
);
3304 static void gen_fcall_save_ctx(DisasContext
*ctx
)
3306 TCGv temp
= tcg_temp_new();
3308 tcg_gen_addi_tl(temp
, cpu_gpr_a
[10], -4);
3309 tcg_gen_qemu_st_tl(cpu_gpr_a
[11], temp
, ctx
->mem_idx
, MO_LESL
);
3310 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
3311 tcg_gen_mov_tl(cpu_gpr_a
[10], temp
);
3313 tcg_temp_free(temp
);
3316 static void gen_fret(DisasContext
*ctx
)
3318 TCGv temp
= tcg_temp_new();
3320 tcg_gen_andi_tl(temp
, cpu_gpr_a
[11], ~0x1);
3321 tcg_gen_qemu_ld_tl(cpu_gpr_a
[11], cpu_gpr_a
[10], ctx
->mem_idx
, MO_LESL
);
3322 tcg_gen_addi_tl(cpu_gpr_a
[10], cpu_gpr_a
[10], 4);
3323 tcg_gen_mov_tl(cpu_PC
, temp
);
3324 tcg_gen_exit_tb(NULL
, 0);
3325 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3327 tcg_temp_free(temp
);
3330 static void gen_compute_branch(DisasContext
*ctx
, uint32_t opc
, int r1
,
3331 int r2
, int32_t constant
, int32_t offset
)
3337 /* SB-format jumps */
3340 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3342 case OPC1_32_B_CALL
:
3343 case OPC1_16_SB_CALL
:
3344 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
3345 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3348 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], 0, offset
);
3350 case OPC1_16_SB_JNZ
:
3351 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], 0, offset
);
3353 /* SBC-format jumps */
3354 case OPC1_16_SBC_JEQ
:
3355 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], constant
, offset
);
3357 case OPC1_16_SBC_JEQ2
:
3358 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], constant
,
3361 case OPC1_16_SBC_JNE
:
3362 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], constant
, offset
);
3364 case OPC1_16_SBC_JNE2
:
3365 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15],
3366 constant
, offset
+ 16);
3368 /* SBRN-format jumps */
3369 case OPC1_16_SBRN_JZ_T
:
3370 temp
= tcg_temp_new();
3371 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
3372 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
3373 tcg_temp_free(temp
);
3375 case OPC1_16_SBRN_JNZ_T
:
3376 temp
= tcg_temp_new();
3377 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
3378 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
3379 tcg_temp_free(temp
);
3381 /* SBR-format jumps */
3382 case OPC1_16_SBR_JEQ
:
3383 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
3386 case OPC1_16_SBR_JEQ2
:
3387 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
3390 case OPC1_16_SBR_JNE
:
3391 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
3394 case OPC1_16_SBR_JNE2
:
3395 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
3398 case OPC1_16_SBR_JNZ
:
3399 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], 0, offset
);
3401 case OPC1_16_SBR_JNZ_A
:
3402 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
3404 case OPC1_16_SBR_JGEZ
:
3405 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], 0, offset
);
3407 case OPC1_16_SBR_JGTZ
:
3408 gen_branch_condi(ctx
, TCG_COND_GT
, cpu_gpr_d
[r1
], 0, offset
);
3410 case OPC1_16_SBR_JLEZ
:
3411 gen_branch_condi(ctx
, TCG_COND_LE
, cpu_gpr_d
[r1
], 0, offset
);
3413 case OPC1_16_SBR_JLTZ
:
3414 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], 0, offset
);
3416 case OPC1_16_SBR_JZ
:
3417 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], 0, offset
);
3419 case OPC1_16_SBR_JZ_A
:
3420 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
3422 case OPC1_16_SBR_LOOP
:
3423 gen_loop(ctx
, r1
, offset
* 2 - 32);
3425 /* SR-format jumps */
3427 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], 0xfffffffe);
3428 tcg_gen_exit_tb(NULL
, 0);
3430 case OPC2_32_SYS_RET
:
3431 case OPC2_16_SR_RET
:
3432 gen_helper_ret(cpu_env
);
3433 tcg_gen_exit_tb(NULL
, 0);
3436 case OPC1_32_B_CALLA
:
3437 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
3438 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3440 case OPC1_32_B_FCALL
:
3441 gen_fcall_save_ctx(ctx
);
3442 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3444 case OPC1_32_B_FCALLA
:
3445 gen_fcall_save_ctx(ctx
);
3446 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3449 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
3452 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3455 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
3456 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3459 case OPCM_32_BRC_EQ_NEQ
:
3460 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JEQ
) {
3461 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], constant
, offset
);
3463 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], constant
, offset
);
3466 case OPCM_32_BRC_GE
:
3467 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OP2_32_BRC_JGE
) {
3468 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], constant
, offset
);
3470 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
3471 gen_branch_condi(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], constant
,
3475 case OPCM_32_BRC_JLT
:
3476 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JLT
) {
3477 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], constant
, offset
);
3479 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
3480 gen_branch_condi(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], constant
,
3484 case OPCM_32_BRC_JNE
:
3485 temp
= tcg_temp_new();
3486 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JNED
) {
3487 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3488 /* subi is unconditional */
3489 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3490 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
3492 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3493 /* addi is unconditional */
3494 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3495 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
3497 tcg_temp_free(temp
);
3500 case OPCM_32_BRN_JTT
:
3501 n
= MASK_OP_BRN_N(ctx
->opcode
);
3503 temp
= tcg_temp_new();
3504 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r1
], (1 << n
));
3506 if (MASK_OP_BRN_OP2(ctx
->opcode
) == OPC2_32_BRN_JNZ_T
) {
3507 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
3509 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
3511 tcg_temp_free(temp
);
3514 case OPCM_32_BRR_EQ_NEQ
:
3515 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ
) {
3516 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3519 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3523 case OPCM_32_BRR_ADDR_EQ_NEQ
:
3524 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ_A
) {
3525 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
3528 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
3532 case OPCM_32_BRR_GE
:
3533 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JGE
) {
3534 gen_branch_cond(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3537 gen_branch_cond(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3541 case OPCM_32_BRR_JLT
:
3542 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JLT
) {
3543 gen_branch_cond(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3546 gen_branch_cond(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3550 case OPCM_32_BRR_LOOP
:
3551 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_LOOP
) {
3552 gen_loop(ctx
, r2
, offset
* 2);
3554 /* OPC2_32_BRR_LOOPU */
3555 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3558 case OPCM_32_BRR_JNE
:
3559 temp
= tcg_temp_new();
3560 temp2
= tcg_temp_new();
3561 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRR_JNED
) {
3562 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3563 /* also save r2, in case of r1 == r2, so r2 is not decremented */
3564 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
3565 /* subi is unconditional */
3566 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3567 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
3569 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3570 /* also save r2, in case of r1 == r2, so r2 is not decremented */
3571 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
3572 /* addi is unconditional */
3573 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3574 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
3576 tcg_temp_free(temp
);
3577 tcg_temp_free(temp2
);
3579 case OPCM_32_BRR_JNZ
:
3580 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JNZ_A
) {
3581 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
3583 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
3587 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3589 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3594 * Functions for decoding instructions
3597 static void decode_src_opc(DisasContext
*ctx
, int op1
)
3603 r1
= MASK_OP_SRC_S1D(ctx
->opcode
);
3604 const4
= MASK_OP_SRC_CONST4_SEXT(ctx
->opcode
);
3607 case OPC1_16_SRC_ADD
:
3608 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3610 case OPC1_16_SRC_ADD_A15
:
3611 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], const4
);
3613 case OPC1_16_SRC_ADD_15A
:
3614 gen_addi_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], const4
);
3616 case OPC1_16_SRC_ADD_A
:
3617 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], const4
);
3619 case OPC1_16_SRC_CADD
:
3620 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
3623 case OPC1_16_SRC_CADDN
:
3624 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
3627 case OPC1_16_SRC_CMOV
:
3628 temp
= tcg_const_tl(0);
3629 temp2
= tcg_const_tl(const4
);
3630 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3631 temp2
, cpu_gpr_d
[r1
]);
3632 tcg_temp_free(temp
);
3633 tcg_temp_free(temp2
);
3635 case OPC1_16_SRC_CMOVN
:
3636 temp
= tcg_const_tl(0);
3637 temp2
= tcg_const_tl(const4
);
3638 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3639 temp2
, cpu_gpr_d
[r1
]);
3640 tcg_temp_free(temp
);
3641 tcg_temp_free(temp2
);
3643 case OPC1_16_SRC_EQ
:
3644 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3647 case OPC1_16_SRC_LT
:
3648 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3651 case OPC1_16_SRC_MOV
:
3652 tcg_gen_movi_tl(cpu_gpr_d
[r1
], const4
);
3654 case OPC1_16_SRC_MOV_A
:
3655 const4
= MASK_OP_SRC_CONST4(ctx
->opcode
);
3656 tcg_gen_movi_tl(cpu_gpr_a
[r1
], const4
);
3658 case OPC1_16_SRC_MOV_E
:
3659 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
3660 tcg_gen_movi_tl(cpu_gpr_d
[r1
], const4
);
3661 tcg_gen_sari_tl(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], 31);
3663 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3666 case OPC1_16_SRC_SH
:
3667 gen_shi(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3669 case OPC1_16_SRC_SHA
:
3670 gen_shaci(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3673 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3677 static void decode_srr_opc(DisasContext
*ctx
, int op1
)
3682 r1
= MASK_OP_SRR_S1D(ctx
->opcode
);
3683 r2
= MASK_OP_SRR_S2(ctx
->opcode
);
3686 case OPC1_16_SRR_ADD
:
3687 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3689 case OPC1_16_SRR_ADD_A15
:
3690 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
3692 case OPC1_16_SRR_ADD_15A
:
3693 gen_add_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3695 case OPC1_16_SRR_ADD_A
:
3696 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
3698 case OPC1_16_SRR_ADDS
:
3699 gen_adds(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3701 case OPC1_16_SRR_AND
:
3702 tcg_gen_and_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3704 case OPC1_16_SRR_CMOV
:
3705 temp
= tcg_const_tl(0);
3706 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3707 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
3708 tcg_temp_free(temp
);
3710 case OPC1_16_SRR_CMOVN
:
3711 temp
= tcg_const_tl(0);
3712 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3713 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
3714 tcg_temp_free(temp
);
3716 case OPC1_16_SRR_EQ
:
3717 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3720 case OPC1_16_SRR_LT
:
3721 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3724 case OPC1_16_SRR_MOV
:
3725 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3727 case OPC1_16_SRR_MOV_A
:
3728 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_d
[r2
]);
3730 case OPC1_16_SRR_MOV_AA
:
3731 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
3733 case OPC1_16_SRR_MOV_D
:
3734 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
]);
3736 case OPC1_16_SRR_MUL
:
3737 gen_mul_i32s(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3739 case OPC1_16_SRR_OR
:
3740 tcg_gen_or_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3742 case OPC1_16_SRR_SUB
:
3743 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3745 case OPC1_16_SRR_SUB_A15B
:
3746 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
3748 case OPC1_16_SRR_SUB_15AB
:
3749 gen_sub_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3751 case OPC1_16_SRR_SUBS
:
3752 gen_subs(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3754 case OPC1_16_SRR_XOR
:
3755 tcg_gen_xor_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3758 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3762 static void decode_ssr_opc(DisasContext
*ctx
, int op1
)
3766 r1
= MASK_OP_SSR_S1(ctx
->opcode
);
3767 r2
= MASK_OP_SSR_S2(ctx
->opcode
);
3770 case OPC1_16_SSR_ST_A
:
3771 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3773 case OPC1_16_SSR_ST_A_POSTINC
:
3774 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3775 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3777 case OPC1_16_SSR_ST_B
:
3778 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3780 case OPC1_16_SSR_ST_B_POSTINC
:
3781 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3782 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
3784 case OPC1_16_SSR_ST_H
:
3785 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
3787 case OPC1_16_SSR_ST_H_POSTINC
:
3788 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
3789 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
3791 case OPC1_16_SSR_ST_W
:
3792 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3794 case OPC1_16_SSR_ST_W_POSTINC
:
3795 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3796 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3799 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3803 static void decode_sc_opc(DisasContext
*ctx
, int op1
)
3807 const16
= MASK_OP_SC_CONST8(ctx
->opcode
);
3810 case OPC1_16_SC_AND
:
3811 tcg_gen_andi_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
3813 case OPC1_16_SC_BISR
:
3814 gen_helper_1arg(bisr
, const16
& 0xff);
3816 case OPC1_16_SC_LD_A
:
3817 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3819 case OPC1_16_SC_LD_W
:
3820 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3822 case OPC1_16_SC_MOV
:
3823 tcg_gen_movi_tl(cpu_gpr_d
[15], const16
);
3826 tcg_gen_ori_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
3828 case OPC1_16_SC_ST_A
:
3829 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3831 case OPC1_16_SC_ST_W
:
3832 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3834 case OPC1_16_SC_SUB_A
:
3835 tcg_gen_subi_tl(cpu_gpr_a
[10], cpu_gpr_a
[10], const16
);
3838 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3842 static void decode_slr_opc(DisasContext
*ctx
, int op1
)
3846 r1
= MASK_OP_SLR_D(ctx
->opcode
);
3847 r2
= MASK_OP_SLR_S2(ctx
->opcode
);
3851 case OPC1_16_SLR_LD_A
:
3852 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3854 case OPC1_16_SLR_LD_A_POSTINC
:
3855 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3856 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3858 case OPC1_16_SLR_LD_BU
:
3859 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3861 case OPC1_16_SLR_LD_BU_POSTINC
:
3862 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3863 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
3865 case OPC1_16_SLR_LD_H
:
3866 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3868 case OPC1_16_SLR_LD_H_POSTINC
:
3869 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3870 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
3872 case OPC1_16_SLR_LD_W
:
3873 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3875 case OPC1_16_SLR_LD_W_POSTINC
:
3876 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3877 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3880 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3884 static void decode_sro_opc(DisasContext
*ctx
, int op1
)
3889 r2
= MASK_OP_SRO_S2(ctx
->opcode
);
3890 address
= MASK_OP_SRO_OFF4(ctx
->opcode
);
3894 case OPC1_16_SRO_LD_A
:
3895 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3897 case OPC1_16_SRO_LD_BU
:
3898 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3900 case OPC1_16_SRO_LD_H
:
3901 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_LESW
);
3903 case OPC1_16_SRO_LD_W
:
3904 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3906 case OPC1_16_SRO_ST_A
:
3907 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3909 case OPC1_16_SRO_ST_B
:
3910 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3912 case OPC1_16_SRO_ST_H
:
3913 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 2, MO_LESW
);
3915 case OPC1_16_SRO_ST_W
:
3916 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3919 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3923 static void decode_sr_system(DisasContext
*ctx
)
3926 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3929 case OPC2_16_SR_NOP
:
3931 case OPC2_16_SR_RET
:
3932 gen_compute_branch(ctx
, op2
, 0, 0, 0, 0);
3934 case OPC2_16_SR_RFE
:
3935 gen_helper_rfe(cpu_env
);
3936 tcg_gen_exit_tb(NULL
, 0);
3937 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3939 case OPC2_16_SR_DEBUG
:
3940 /* raise EXCP_DEBUG */
3942 case OPC2_16_SR_FRET
:
3946 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3950 static void decode_sr_accu(DisasContext
*ctx
)
3956 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3957 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3960 case OPC2_16_SR_RSUB
:
3961 /* overflow only if r1 = -0x80000000 */
3962 temp
= tcg_const_i32(-0x80000000);
3964 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r1
], temp
);
3965 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
3967 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
3969 tcg_gen_neg_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3971 tcg_gen_add_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3972 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_PSW_AV
);
3974 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
3975 tcg_temp_free(temp
);
3977 case OPC2_16_SR_SAT_B
:
3978 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7f, -0x80);
3980 case OPC2_16_SR_SAT_BU
:
3981 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xff);
3983 case OPC2_16_SR_SAT_H
:
3984 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
3986 case OPC2_16_SR_SAT_HU
:
3987 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xffff);
3990 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3994 static void decode_16Bit_opc(DisasContext
*ctx
)
4002 op1
= MASK_OP_MAJOR(ctx
->opcode
);
4004 /* handle ADDSC.A opcode only being 6 bit long */
4005 if (unlikely((op1
& 0x3f) == OPC1_16_SRRS_ADDSC_A
)) {
4006 op1
= OPC1_16_SRRS_ADDSC_A
;
4010 case OPC1_16_SRC_ADD
:
4011 case OPC1_16_SRC_ADD_A15
:
4012 case OPC1_16_SRC_ADD_15A
:
4013 case OPC1_16_SRC_ADD_A
:
4014 case OPC1_16_SRC_CADD
:
4015 case OPC1_16_SRC_CADDN
:
4016 case OPC1_16_SRC_CMOV
:
4017 case OPC1_16_SRC_CMOVN
:
4018 case OPC1_16_SRC_EQ
:
4019 case OPC1_16_SRC_LT
:
4020 case OPC1_16_SRC_MOV
:
4021 case OPC1_16_SRC_MOV_A
:
4022 case OPC1_16_SRC_MOV_E
:
4023 case OPC1_16_SRC_SH
:
4024 case OPC1_16_SRC_SHA
:
4025 decode_src_opc(ctx
, op1
);
4028 case OPC1_16_SRR_ADD
:
4029 case OPC1_16_SRR_ADD_A15
:
4030 case OPC1_16_SRR_ADD_15A
:
4031 case OPC1_16_SRR_ADD_A
:
4032 case OPC1_16_SRR_ADDS
:
4033 case OPC1_16_SRR_AND
:
4034 case OPC1_16_SRR_CMOV
:
4035 case OPC1_16_SRR_CMOVN
:
4036 case OPC1_16_SRR_EQ
:
4037 case OPC1_16_SRR_LT
:
4038 case OPC1_16_SRR_MOV
:
4039 case OPC1_16_SRR_MOV_A
:
4040 case OPC1_16_SRR_MOV_AA
:
4041 case OPC1_16_SRR_MOV_D
:
4042 case OPC1_16_SRR_MUL
:
4043 case OPC1_16_SRR_OR
:
4044 case OPC1_16_SRR_SUB
:
4045 case OPC1_16_SRR_SUB_A15B
:
4046 case OPC1_16_SRR_SUB_15AB
:
4047 case OPC1_16_SRR_SUBS
:
4048 case OPC1_16_SRR_XOR
:
4049 decode_srr_opc(ctx
, op1
);
4052 case OPC1_16_SSR_ST_A
:
4053 case OPC1_16_SSR_ST_A_POSTINC
:
4054 case OPC1_16_SSR_ST_B
:
4055 case OPC1_16_SSR_ST_B_POSTINC
:
4056 case OPC1_16_SSR_ST_H
:
4057 case OPC1_16_SSR_ST_H_POSTINC
:
4058 case OPC1_16_SSR_ST_W
:
4059 case OPC1_16_SSR_ST_W_POSTINC
:
4060 decode_ssr_opc(ctx
, op1
);
4063 case OPC1_16_SRRS_ADDSC_A
:
4064 r2
= MASK_OP_SRRS_S2(ctx
->opcode
);
4065 r1
= MASK_OP_SRRS_S1D(ctx
->opcode
);
4066 const16
= MASK_OP_SRRS_N(ctx
->opcode
);
4067 temp
= tcg_temp_new();
4068 tcg_gen_shli_tl(temp
, cpu_gpr_d
[15], const16
);
4069 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], temp
);
4070 tcg_temp_free(temp
);
4073 case OPC1_16_SLRO_LD_A
:
4074 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
4075 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
4076 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
4078 case OPC1_16_SLRO_LD_BU
:
4079 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
4080 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
4081 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
4083 case OPC1_16_SLRO_LD_H
:
4084 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
4085 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
4086 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
4088 case OPC1_16_SLRO_LD_W
:
4089 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
4090 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
4091 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
4094 case OPC1_16_SB_CALL
:
4096 case OPC1_16_SB_JNZ
:
4098 address
= MASK_OP_SB_DISP8_SEXT(ctx
->opcode
);
4099 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
4102 case OPC1_16_SBC_JEQ
:
4103 case OPC1_16_SBC_JNE
:
4104 address
= MASK_OP_SBC_DISP4(ctx
->opcode
);
4105 const16
= MASK_OP_SBC_CONST4_SEXT(ctx
->opcode
);
4106 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
4108 case OPC1_16_SBC_JEQ2
:
4109 case OPC1_16_SBC_JNE2
:
4110 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
4111 address
= MASK_OP_SBC_DISP4(ctx
->opcode
);
4112 const16
= MASK_OP_SBC_CONST4_SEXT(ctx
->opcode
);
4113 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
4115 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4119 case OPC1_16_SBRN_JNZ_T
:
4120 case OPC1_16_SBRN_JZ_T
:
4121 address
= MASK_OP_SBRN_DISP4(ctx
->opcode
);
4122 const16
= MASK_OP_SBRN_N(ctx
->opcode
);
4123 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
4126 case OPC1_16_SBR_JEQ2
:
4127 case OPC1_16_SBR_JNE2
:
4128 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
4129 r1
= MASK_OP_SBR_S2(ctx
->opcode
);
4130 address
= MASK_OP_SBR_DISP4(ctx
->opcode
);
4131 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
4133 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4136 case OPC1_16_SBR_JEQ
:
4137 case OPC1_16_SBR_JGEZ
:
4138 case OPC1_16_SBR_JGTZ
:
4139 case OPC1_16_SBR_JLEZ
:
4140 case OPC1_16_SBR_JLTZ
:
4141 case OPC1_16_SBR_JNE
:
4142 case OPC1_16_SBR_JNZ
:
4143 case OPC1_16_SBR_JNZ_A
:
4144 case OPC1_16_SBR_JZ
:
4145 case OPC1_16_SBR_JZ_A
:
4146 case OPC1_16_SBR_LOOP
:
4147 r1
= MASK_OP_SBR_S2(ctx
->opcode
);
4148 address
= MASK_OP_SBR_DISP4(ctx
->opcode
);
4149 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
4152 case OPC1_16_SC_AND
:
4153 case OPC1_16_SC_BISR
:
4154 case OPC1_16_SC_LD_A
:
4155 case OPC1_16_SC_LD_W
:
4156 case OPC1_16_SC_MOV
:
4158 case OPC1_16_SC_ST_A
:
4159 case OPC1_16_SC_ST_W
:
4160 case OPC1_16_SC_SUB_A
:
4161 decode_sc_opc(ctx
, op1
);
4164 case OPC1_16_SLR_LD_A
:
4165 case OPC1_16_SLR_LD_A_POSTINC
:
4166 case OPC1_16_SLR_LD_BU
:
4167 case OPC1_16_SLR_LD_BU_POSTINC
:
4168 case OPC1_16_SLR_LD_H
:
4169 case OPC1_16_SLR_LD_H_POSTINC
:
4170 case OPC1_16_SLR_LD_W
:
4171 case OPC1_16_SLR_LD_W_POSTINC
:
4172 decode_slr_opc(ctx
, op1
);
4175 case OPC1_16_SRO_LD_A
:
4176 case OPC1_16_SRO_LD_BU
:
4177 case OPC1_16_SRO_LD_H
:
4178 case OPC1_16_SRO_LD_W
:
4179 case OPC1_16_SRO_ST_A
:
4180 case OPC1_16_SRO_ST_B
:
4181 case OPC1_16_SRO_ST_H
:
4182 case OPC1_16_SRO_ST_W
:
4183 decode_sro_opc(ctx
, op1
);
4186 case OPC1_16_SSRO_ST_A
:
4187 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
4188 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
4189 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
4191 case OPC1_16_SSRO_ST_B
:
4192 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
4193 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
4194 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
4196 case OPC1_16_SSRO_ST_H
:
4197 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
4198 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
4199 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
4201 case OPC1_16_SSRO_ST_W
:
4202 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
4203 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
4204 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
4207 case OPCM_16_SR_SYSTEM
:
4208 decode_sr_system(ctx
);
4210 case OPCM_16_SR_ACCU
:
4211 decode_sr_accu(ctx
);
4214 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
4215 gen_compute_branch(ctx
, op1
, r1
, 0, 0, 0);
4217 case OPC1_16_SR_NOT
:
4218 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
4219 tcg_gen_not_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
4222 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4227 * 32 bit instructions
4231 static void decode_abs_ldw(DisasContext
*ctx
)
4238 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
4239 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4240 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4242 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
4245 case OPC2_32_ABS_LD_A
:
4246 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
4248 case OPC2_32_ABS_LD_D
:
4250 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4252 case OPC2_32_ABS_LD_DA
:
4254 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4256 case OPC2_32_ABS_LD_W
:
4257 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
4260 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4263 tcg_temp_free(temp
);
4266 static void decode_abs_ldb(DisasContext
*ctx
)
4273 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
4274 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4275 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4277 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
4280 case OPC2_32_ABS_LD_B
:
4281 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_SB
);
4283 case OPC2_32_ABS_LD_BU
:
4284 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
4286 case OPC2_32_ABS_LD_H
:
4287 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESW
);
4289 case OPC2_32_ABS_LD_HU
:
4290 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
4293 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4296 tcg_temp_free(temp
);
4299 static void decode_abs_ldst_swap(DisasContext
*ctx
)
4306 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
4307 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4308 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4310 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
4313 case OPC2_32_ABS_LDMST
:
4314 gen_ldmst(ctx
, r1
, temp
);
4316 case OPC2_32_ABS_SWAP_W
:
4317 gen_swap(ctx
, r1
, temp
);
4320 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4323 tcg_temp_free(temp
);
4326 static void decode_abs_ldst_context(DisasContext
*ctx
)
4331 off18
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4332 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4335 case OPC2_32_ABS_LDLCX
:
4336 gen_helper_1arg(ldlcx
, EA_ABS_FORMAT(off18
));
4338 case OPC2_32_ABS_LDUCX
:
4339 gen_helper_1arg(lducx
, EA_ABS_FORMAT(off18
));
4341 case OPC2_32_ABS_STLCX
:
4342 gen_helper_1arg(stlcx
, EA_ABS_FORMAT(off18
));
4344 case OPC2_32_ABS_STUCX
:
4345 gen_helper_1arg(stucx
, EA_ABS_FORMAT(off18
));
4348 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4352 static void decode_abs_store(DisasContext
*ctx
)
4359 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
4360 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4361 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4363 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
4366 case OPC2_32_ABS_ST_A
:
4367 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
4369 case OPC2_32_ABS_ST_D
:
4371 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4373 case OPC2_32_ABS_ST_DA
:
4375 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4377 case OPC2_32_ABS_ST_W
:
4378 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
4381 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4383 tcg_temp_free(temp
);
4386 static void decode_abs_storeb_h(DisasContext
*ctx
)
4393 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
4394 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
4395 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
4397 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
4400 case OPC2_32_ABS_ST_B
:
4401 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
4403 case OPC2_32_ABS_ST_H
:
4404 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
4407 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4409 tcg_temp_free(temp
);
4414 static void decode_bit_andacc(DisasContext
*ctx
)
4420 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4421 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4422 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4423 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4424 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4425 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4429 case OPC2_32_BIT_AND_AND_T
:
4430 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4431 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_and_tl
);
4433 case OPC2_32_BIT_AND_ANDN_T
:
4434 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4435 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_and_tl
);
4437 case OPC2_32_BIT_AND_NOR_T
:
4438 if (TCG_TARGET_HAS_andc_i32
) {
4439 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4440 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_andc_tl
);
4442 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4443 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_and_tl
);
4446 case OPC2_32_BIT_AND_OR_T
:
4447 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4448 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_and_tl
);
4451 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4455 static void decode_bit_logical_t(DisasContext
*ctx
)
4460 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4461 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4462 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4463 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4464 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4465 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4468 case OPC2_32_BIT_AND_T
:
4469 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4470 pos1
, pos2
, &tcg_gen_and_tl
);
4472 case OPC2_32_BIT_ANDN_T
:
4473 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4474 pos1
, pos2
, &tcg_gen_andc_tl
);
4476 case OPC2_32_BIT_NOR_T
:
4477 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4478 pos1
, pos2
, &tcg_gen_nor_tl
);
4480 case OPC2_32_BIT_OR_T
:
4481 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4482 pos1
, pos2
, &tcg_gen_or_tl
);
4485 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4489 static void decode_bit_insert(DisasContext
*ctx
)
4495 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4496 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4497 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4498 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4499 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4500 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4502 temp
= tcg_temp_new();
4504 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r2
], pos2
);
4505 if (op2
== OPC2_32_BIT_INSN_T
) {
4506 tcg_gen_not_tl(temp
, temp
);
4508 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], temp
, pos1
, 1);
4509 tcg_temp_free(temp
);
4512 static void decode_bit_logical_t2(DisasContext
*ctx
)
4519 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4520 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4521 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4522 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4523 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4524 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4527 case OPC2_32_BIT_NAND_T
:
4528 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4529 pos1
, pos2
, &tcg_gen_nand_tl
);
4531 case OPC2_32_BIT_ORN_T
:
4532 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4533 pos1
, pos2
, &tcg_gen_orc_tl
);
4535 case OPC2_32_BIT_XNOR_T
:
4536 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4537 pos1
, pos2
, &tcg_gen_eqv_tl
);
4539 case OPC2_32_BIT_XOR_T
:
4540 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4541 pos1
, pos2
, &tcg_gen_xor_tl
);
4544 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4548 static void decode_bit_orand(DisasContext
*ctx
)
4555 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4556 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4557 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4558 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4559 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4560 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4563 case OPC2_32_BIT_OR_AND_T
:
4564 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4565 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_or_tl
);
4567 case OPC2_32_BIT_OR_ANDN_T
:
4568 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4569 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_or_tl
);
4571 case OPC2_32_BIT_OR_NOR_T
:
4572 if (TCG_TARGET_HAS_orc_i32
) {
4573 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4574 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_orc_tl
);
4576 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4577 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_or_tl
);
4580 case OPC2_32_BIT_OR_OR_T
:
4581 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4582 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_or_tl
);
4585 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4589 static void decode_bit_sh_logic1(DisasContext
*ctx
)
4596 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4597 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4598 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4599 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4600 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4601 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4603 temp
= tcg_temp_new();
4606 case OPC2_32_BIT_SH_AND_T
:
4607 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4608 pos1
, pos2
, &tcg_gen_and_tl
);
4610 case OPC2_32_BIT_SH_ANDN_T
:
4611 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4612 pos1
, pos2
, &tcg_gen_andc_tl
);
4614 case OPC2_32_BIT_SH_NOR_T
:
4615 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4616 pos1
, pos2
, &tcg_gen_nor_tl
);
4618 case OPC2_32_BIT_SH_OR_T
:
4619 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4620 pos1
, pos2
, &tcg_gen_or_tl
);
4623 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4625 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
4626 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
4627 tcg_temp_free(temp
);
4630 static void decode_bit_sh_logic2(DisasContext
*ctx
)
4637 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4638 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4639 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4640 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4641 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4642 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4644 temp
= tcg_temp_new();
4647 case OPC2_32_BIT_SH_NAND_T
:
4648 gen_bit_1op(temp
, cpu_gpr_d
[r1
] , cpu_gpr_d
[r2
] ,
4649 pos1
, pos2
, &tcg_gen_nand_tl
);
4651 case OPC2_32_BIT_SH_ORN_T
:
4652 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4653 pos1
, pos2
, &tcg_gen_orc_tl
);
4655 case OPC2_32_BIT_SH_XNOR_T
:
4656 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4657 pos1
, pos2
, &tcg_gen_eqv_tl
);
4659 case OPC2_32_BIT_SH_XOR_T
:
4660 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4661 pos1
, pos2
, &tcg_gen_xor_tl
);
4664 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4666 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
4667 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
4668 tcg_temp_free(temp
);
4674 static void decode_bo_addrmode_post_pre_base(DisasContext
*ctx
)
4681 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4682 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4683 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4684 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4687 case OPC2_32_BO_CACHEA_WI_SHORTOFF
:
4688 case OPC2_32_BO_CACHEA_W_SHORTOFF
:
4689 case OPC2_32_BO_CACHEA_I_SHORTOFF
:
4690 /* instruction to access the cache */
4692 case OPC2_32_BO_CACHEA_WI_POSTINC
:
4693 case OPC2_32_BO_CACHEA_W_POSTINC
:
4694 case OPC2_32_BO_CACHEA_I_POSTINC
:
4695 /* instruction to access the cache, but we still need to handle
4696 the addressing mode */
4697 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4699 case OPC2_32_BO_CACHEA_WI_PREINC
:
4700 case OPC2_32_BO_CACHEA_W_PREINC
:
4701 case OPC2_32_BO_CACHEA_I_PREINC
:
4702 /* instruction to access the cache, but we still need to handle
4703 the addressing mode */
4704 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4706 case OPC2_32_BO_CACHEI_WI_SHORTOFF
:
4707 case OPC2_32_BO_CACHEI_W_SHORTOFF
:
4708 if (!tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
4709 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4712 case OPC2_32_BO_CACHEI_W_POSTINC
:
4713 case OPC2_32_BO_CACHEI_WI_POSTINC
:
4714 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
4715 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4717 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4720 case OPC2_32_BO_CACHEI_W_PREINC
:
4721 case OPC2_32_BO_CACHEI_WI_PREINC
:
4722 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
4723 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4725 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4728 case OPC2_32_BO_ST_A_SHORTOFF
:
4729 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
4731 case OPC2_32_BO_ST_A_POSTINC
:
4732 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4734 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4736 case OPC2_32_BO_ST_A_PREINC
:
4737 gen_st_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
4739 case OPC2_32_BO_ST_B_SHORTOFF
:
4740 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4742 case OPC2_32_BO_ST_B_POSTINC
:
4743 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4745 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4747 case OPC2_32_BO_ST_B_PREINC
:
4748 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4750 case OPC2_32_BO_ST_D_SHORTOFF
:
4752 gen_offset_st_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
4755 case OPC2_32_BO_ST_D_POSTINC
:
4757 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
4758 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4760 case OPC2_32_BO_ST_D_PREINC
:
4762 temp
= tcg_temp_new();
4763 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4764 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4765 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4766 tcg_temp_free(temp
);
4768 case OPC2_32_BO_ST_DA_SHORTOFF
:
4770 gen_offset_st_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
4773 case OPC2_32_BO_ST_DA_POSTINC
:
4775 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
4776 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4778 case OPC2_32_BO_ST_DA_PREINC
:
4780 temp
= tcg_temp_new();
4781 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4782 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4783 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4784 tcg_temp_free(temp
);
4786 case OPC2_32_BO_ST_H_SHORTOFF
:
4787 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4789 case OPC2_32_BO_ST_H_POSTINC
:
4790 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4792 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4794 case OPC2_32_BO_ST_H_PREINC
:
4795 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4797 case OPC2_32_BO_ST_Q_SHORTOFF
:
4798 temp
= tcg_temp_new();
4799 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4800 gen_offset_st(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4801 tcg_temp_free(temp
);
4803 case OPC2_32_BO_ST_Q_POSTINC
:
4804 temp
= tcg_temp_new();
4805 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4806 tcg_gen_qemu_st_tl(temp
, cpu_gpr_a
[r2
], ctx
->mem_idx
,
4808 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4809 tcg_temp_free(temp
);
4811 case OPC2_32_BO_ST_Q_PREINC
:
4812 temp
= tcg_temp_new();
4813 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4814 gen_st_preincr(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4815 tcg_temp_free(temp
);
4817 case OPC2_32_BO_ST_W_SHORTOFF
:
4818 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4820 case OPC2_32_BO_ST_W_POSTINC
:
4821 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4823 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4825 case OPC2_32_BO_ST_W_PREINC
:
4826 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4829 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4833 static void decode_bo_addrmode_bitreverse_circular(DisasContext
*ctx
)
4838 TCGv temp
, temp2
, temp3
;
4840 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4841 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4842 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4843 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4845 temp
= tcg_temp_new();
4846 temp2
= tcg_temp_new();
4847 temp3
= tcg_const_i32(off10
);
4849 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4850 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4853 case OPC2_32_BO_CACHEA_WI_BR
:
4854 case OPC2_32_BO_CACHEA_W_BR
:
4855 case OPC2_32_BO_CACHEA_I_BR
:
4856 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4858 case OPC2_32_BO_CACHEA_WI_CIRC
:
4859 case OPC2_32_BO_CACHEA_W_CIRC
:
4860 case OPC2_32_BO_CACHEA_I_CIRC
:
4861 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4863 case OPC2_32_BO_ST_A_BR
:
4864 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4865 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4867 case OPC2_32_BO_ST_A_CIRC
:
4868 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4869 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4871 case OPC2_32_BO_ST_B_BR
:
4872 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4873 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4875 case OPC2_32_BO_ST_B_CIRC
:
4876 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4877 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4879 case OPC2_32_BO_ST_D_BR
:
4881 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
4882 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4884 case OPC2_32_BO_ST_D_CIRC
:
4886 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4887 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4888 tcg_gen_addi_tl(temp
, temp
, 4);
4889 tcg_gen_rem_tl(temp
, temp
, temp2
);
4890 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4891 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4892 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4894 case OPC2_32_BO_ST_DA_BR
:
4896 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
4897 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4899 case OPC2_32_BO_ST_DA_CIRC
:
4901 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4902 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4903 tcg_gen_addi_tl(temp
, temp
, 4);
4904 tcg_gen_rem_tl(temp
, temp
, temp2
);
4905 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4906 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4907 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4909 case OPC2_32_BO_ST_H_BR
:
4910 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4911 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4913 case OPC2_32_BO_ST_H_CIRC
:
4914 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4915 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4917 case OPC2_32_BO_ST_Q_BR
:
4918 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4919 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
4920 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4922 case OPC2_32_BO_ST_Q_CIRC
:
4923 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4924 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
4925 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4927 case OPC2_32_BO_ST_W_BR
:
4928 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4929 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4931 case OPC2_32_BO_ST_W_CIRC
:
4932 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4933 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
4936 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4938 tcg_temp_free(temp
);
4939 tcg_temp_free(temp2
);
4940 tcg_temp_free(temp3
);
4943 static void decode_bo_addrmode_ld_post_pre_base(DisasContext
*ctx
)
4950 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4951 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4952 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4953 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4956 case OPC2_32_BO_LD_A_SHORTOFF
:
4957 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4959 case OPC2_32_BO_LD_A_POSTINC
:
4960 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4962 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4964 case OPC2_32_BO_LD_A_PREINC
:
4965 gen_ld_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4967 case OPC2_32_BO_LD_B_SHORTOFF
:
4968 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4970 case OPC2_32_BO_LD_B_POSTINC
:
4971 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4973 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4975 case OPC2_32_BO_LD_B_PREINC
:
4976 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4978 case OPC2_32_BO_LD_BU_SHORTOFF
:
4979 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4981 case OPC2_32_BO_LD_BU_POSTINC
:
4982 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4984 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4986 case OPC2_32_BO_LD_BU_PREINC
:
4987 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4989 case OPC2_32_BO_LD_D_SHORTOFF
:
4991 gen_offset_ld_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
4994 case OPC2_32_BO_LD_D_POSTINC
:
4996 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
4997 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4999 case OPC2_32_BO_LD_D_PREINC
:
5001 temp
= tcg_temp_new();
5002 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5003 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
5004 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
5005 tcg_temp_free(temp
);
5007 case OPC2_32_BO_LD_DA_SHORTOFF
:
5009 gen_offset_ld_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
5012 case OPC2_32_BO_LD_DA_POSTINC
:
5014 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
5015 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5017 case OPC2_32_BO_LD_DA_PREINC
:
5019 temp
= tcg_temp_new();
5020 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5021 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
5022 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
5023 tcg_temp_free(temp
);
5025 case OPC2_32_BO_LD_H_SHORTOFF
:
5026 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
5028 case OPC2_32_BO_LD_H_POSTINC
:
5029 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
5031 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5033 case OPC2_32_BO_LD_H_PREINC
:
5034 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
5036 case OPC2_32_BO_LD_HU_SHORTOFF
:
5037 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
5039 case OPC2_32_BO_LD_HU_POSTINC
:
5040 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
5042 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5044 case OPC2_32_BO_LD_HU_PREINC
:
5045 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
5047 case OPC2_32_BO_LD_Q_SHORTOFF
:
5048 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
5049 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
5051 case OPC2_32_BO_LD_Q_POSTINC
:
5052 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
5054 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
5055 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5057 case OPC2_32_BO_LD_Q_PREINC
:
5058 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
5059 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
5061 case OPC2_32_BO_LD_W_SHORTOFF
:
5062 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
5064 case OPC2_32_BO_LD_W_POSTINC
:
5065 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
5067 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5069 case OPC2_32_BO_LD_W_PREINC
:
5070 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
5073 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5077 static void decode_bo_addrmode_ld_bitreverse_circular(DisasContext
*ctx
)
5083 TCGv temp
, temp2
, temp3
;
5085 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
5086 r2
= MASK_OP_BO_S2(ctx
->opcode
);
5087 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
5088 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
5090 temp
= tcg_temp_new();
5091 temp2
= tcg_temp_new();
5092 temp3
= tcg_const_i32(off10
);
5094 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
5095 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
5099 case OPC2_32_BO_LD_A_BR
:
5100 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5101 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5103 case OPC2_32_BO_LD_A_CIRC
:
5104 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5105 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5107 case OPC2_32_BO_LD_B_BR
:
5108 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
5109 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5111 case OPC2_32_BO_LD_B_CIRC
:
5112 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
5113 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5115 case OPC2_32_BO_LD_BU_BR
:
5116 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
5117 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5119 case OPC2_32_BO_LD_BU_CIRC
:
5120 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
5121 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5123 case OPC2_32_BO_LD_D_BR
:
5125 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
5126 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5128 case OPC2_32_BO_LD_D_CIRC
:
5130 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5131 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
5132 tcg_gen_addi_tl(temp
, temp
, 4);
5133 tcg_gen_rem_tl(temp
, temp
, temp2
);
5134 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
5135 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
5136 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5138 case OPC2_32_BO_LD_DA_BR
:
5140 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
5141 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5143 case OPC2_32_BO_LD_DA_CIRC
:
5145 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5146 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
5147 tcg_gen_addi_tl(temp
, temp
, 4);
5148 tcg_gen_rem_tl(temp
, temp
, temp2
);
5149 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
5150 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
5151 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5153 case OPC2_32_BO_LD_H_BR
:
5154 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
5155 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5157 case OPC2_32_BO_LD_H_CIRC
:
5158 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
5159 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5161 case OPC2_32_BO_LD_HU_BR
:
5162 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
5163 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5165 case OPC2_32_BO_LD_HU_CIRC
:
5166 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
5167 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5169 case OPC2_32_BO_LD_Q_BR
:
5170 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
5171 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
5172 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5174 case OPC2_32_BO_LD_Q_CIRC
:
5175 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
5176 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
5177 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5179 case OPC2_32_BO_LD_W_BR
:
5180 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5181 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5183 case OPC2_32_BO_LD_W_CIRC
:
5184 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
5185 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5188 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5190 tcg_temp_free(temp
);
5191 tcg_temp_free(temp2
);
5192 tcg_temp_free(temp3
);
5195 static void decode_bo_addrmode_stctx_post_pre_base(DisasContext
*ctx
)
5203 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
5204 r2
= MASK_OP_BO_S2(ctx
->opcode
);
5205 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
5206 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
5209 temp
= tcg_temp_new();
5210 temp2
= tcg_temp_new();
5213 case OPC2_32_BO_LDLCX_SHORTOFF
:
5214 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5215 gen_helper_ldlcx(cpu_env
, temp
);
5217 case OPC2_32_BO_LDMST_SHORTOFF
:
5218 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5219 gen_ldmst(ctx
, r1
, temp
);
5221 case OPC2_32_BO_LDMST_POSTINC
:
5222 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
5223 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5225 case OPC2_32_BO_LDMST_PREINC
:
5226 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5227 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
5229 case OPC2_32_BO_LDUCX_SHORTOFF
:
5230 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5231 gen_helper_lducx(cpu_env
, temp
);
5233 case OPC2_32_BO_LEA_SHORTOFF
:
5234 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
);
5236 case OPC2_32_BO_STLCX_SHORTOFF
:
5237 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5238 gen_helper_stlcx(cpu_env
, temp
);
5240 case OPC2_32_BO_STUCX_SHORTOFF
:
5241 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5242 gen_helper_stucx(cpu_env
, temp
);
5244 case OPC2_32_BO_SWAP_W_SHORTOFF
:
5245 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5246 gen_swap(ctx
, r1
, temp
);
5248 case OPC2_32_BO_SWAP_W_POSTINC
:
5249 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
5250 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5252 case OPC2_32_BO_SWAP_W_PREINC
:
5253 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5254 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
5256 case OPC2_32_BO_CMPSWAP_W_SHORTOFF
:
5257 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5258 gen_cmpswap(ctx
, r1
, temp
);
5260 case OPC2_32_BO_CMPSWAP_W_POSTINC
:
5261 gen_cmpswap(ctx
, r1
, cpu_gpr_a
[r2
]);
5262 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5264 case OPC2_32_BO_CMPSWAP_W_PREINC
:
5265 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5266 gen_cmpswap(ctx
, r1
, cpu_gpr_a
[r2
]);
5268 case OPC2_32_BO_SWAPMSK_W_SHORTOFF
:
5269 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
5270 gen_swapmsk(ctx
, r1
, temp
);
5272 case OPC2_32_BO_SWAPMSK_W_POSTINC
:
5273 gen_swapmsk(ctx
, r1
, cpu_gpr_a
[r2
]);
5274 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5276 case OPC2_32_BO_SWAPMSK_W_PREINC
:
5277 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
5278 gen_swapmsk(ctx
, r1
, cpu_gpr_a
[r2
]);
5281 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5283 tcg_temp_free(temp
);
5284 tcg_temp_free(temp2
);
5287 static void decode_bo_addrmode_ldmst_bitreverse_circular(DisasContext
*ctx
)
5293 TCGv temp
, temp2
, temp3
;
5295 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
5296 r2
= MASK_OP_BO_S2(ctx
->opcode
);
5297 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
5298 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
5300 temp
= tcg_temp_new();
5301 temp2
= tcg_temp_new();
5302 temp3
= tcg_const_i32(off10
);
5304 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
5305 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
5308 case OPC2_32_BO_LDMST_BR
:
5309 gen_ldmst(ctx
, r1
, temp2
);
5310 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5312 case OPC2_32_BO_LDMST_CIRC
:
5313 gen_ldmst(ctx
, r1
, temp2
);
5314 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5316 case OPC2_32_BO_SWAP_W_BR
:
5317 gen_swap(ctx
, r1
, temp2
);
5318 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5320 case OPC2_32_BO_SWAP_W_CIRC
:
5321 gen_swap(ctx
, r1
, temp2
);
5322 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5324 case OPC2_32_BO_CMPSWAP_W_BR
:
5325 gen_cmpswap(ctx
, r1
, temp2
);
5326 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5328 case OPC2_32_BO_CMPSWAP_W_CIRC
:
5329 gen_cmpswap(ctx
, r1
, temp2
);
5330 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5332 case OPC2_32_BO_SWAPMSK_W_BR
:
5333 gen_swapmsk(ctx
, r1
, temp2
);
5334 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
5336 case OPC2_32_BO_SWAPMSK_W_CIRC
:
5337 gen_swapmsk(ctx
, r1
, temp2
);
5338 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], temp3
);
5341 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5344 tcg_temp_free(temp
);
5345 tcg_temp_free(temp2
);
5346 tcg_temp_free(temp3
);
5349 static void decode_bol_opc(DisasContext
*ctx
, int32_t op1
)
5355 r1
= MASK_OP_BOL_S1D(ctx
->opcode
);
5356 r2
= MASK_OP_BOL_S2(ctx
->opcode
);
5357 address
= MASK_OP_BOL_OFF16_SEXT(ctx
->opcode
);
5360 case OPC1_32_BOL_LD_A_LONGOFF
:
5361 temp
= tcg_temp_new();
5362 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
5363 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
5364 tcg_temp_free(temp
);
5366 case OPC1_32_BOL_LD_W_LONGOFF
:
5367 temp
= tcg_temp_new();
5368 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
5369 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
5370 tcg_temp_free(temp
);
5372 case OPC1_32_BOL_LEA_LONGOFF
:
5373 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
);
5375 case OPC1_32_BOL_ST_A_LONGOFF
:
5376 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5377 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
5379 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5382 case OPC1_32_BOL_ST_W_LONGOFF
:
5383 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
5385 case OPC1_32_BOL_LD_B_LONGOFF
:
5386 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5387 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
5389 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5392 case OPC1_32_BOL_LD_BU_LONGOFF
:
5393 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5394 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_UB
);
5396 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5399 case OPC1_32_BOL_LD_H_LONGOFF
:
5400 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5401 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
5403 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5406 case OPC1_32_BOL_LD_HU_LONGOFF
:
5407 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5408 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUW
);
5410 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5413 case OPC1_32_BOL_ST_B_LONGOFF
:
5414 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5415 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
5417 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5420 case OPC1_32_BOL_ST_H_LONGOFF
:
5421 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
5422 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
5424 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5428 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5433 static void decode_rc_logical_shift(DisasContext
*ctx
)
5440 r2
= MASK_OP_RC_D(ctx
->opcode
);
5441 r1
= MASK_OP_RC_S1(ctx
->opcode
);
5442 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5443 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5445 temp
= tcg_temp_new();
5448 case OPC2_32_RC_AND
:
5449 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5451 case OPC2_32_RC_ANDN
:
5452 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
5454 case OPC2_32_RC_NAND
:
5455 tcg_gen_movi_tl(temp
, const9
);
5456 tcg_gen_nand_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
5458 case OPC2_32_RC_NOR
:
5459 tcg_gen_movi_tl(temp
, const9
);
5460 tcg_gen_nor_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
5463 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5465 case OPC2_32_RC_ORN
:
5466 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
5469 const9
= sextract32(const9
, 0, 6);
5470 gen_shi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5472 case OPC2_32_RC_SH_H
:
5473 const9
= sextract32(const9
, 0, 5);
5474 gen_sh_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5476 case OPC2_32_RC_SHA
:
5477 const9
= sextract32(const9
, 0, 6);
5478 gen_shaci(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5480 case OPC2_32_RC_SHA_H
:
5481 const9
= sextract32(const9
, 0, 5);
5482 gen_sha_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5484 case OPC2_32_RC_SHAS
:
5485 gen_shasi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5487 case OPC2_32_RC_XNOR
:
5488 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5489 tcg_gen_not_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
]);
5491 case OPC2_32_RC_XOR
:
5492 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5495 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5497 tcg_temp_free(temp
);
5500 static void decode_rc_accumulator(DisasContext
*ctx
)
5508 r2
= MASK_OP_RC_D(ctx
->opcode
);
5509 r1
= MASK_OP_RC_S1(ctx
->opcode
);
5510 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
5512 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5514 temp
= tcg_temp_new();
5517 case OPC2_32_RC_ABSDIF
:
5518 gen_absdifi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5520 case OPC2_32_RC_ABSDIFS
:
5521 gen_absdifsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5523 case OPC2_32_RC_ADD
:
5524 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5526 case OPC2_32_RC_ADDC
:
5527 gen_addci_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5529 case OPC2_32_RC_ADDS
:
5530 gen_addsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5532 case OPC2_32_RC_ADDS_U
:
5533 gen_addsui(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5535 case OPC2_32_RC_ADDX
:
5536 gen_addi_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5538 case OPC2_32_RC_AND_EQ
:
5539 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5540 const9
, &tcg_gen_and_tl
);
5542 case OPC2_32_RC_AND_GE
:
5543 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5544 const9
, &tcg_gen_and_tl
);
5546 case OPC2_32_RC_AND_GE_U
:
5547 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5548 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5549 const9
, &tcg_gen_and_tl
);
5551 case OPC2_32_RC_AND_LT
:
5552 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5553 const9
, &tcg_gen_and_tl
);
5555 case OPC2_32_RC_AND_LT_U
:
5556 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5557 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5558 const9
, &tcg_gen_and_tl
);
5560 case OPC2_32_RC_AND_NE
:
5561 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5562 const9
, &tcg_gen_and_tl
);
5565 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5567 case OPC2_32_RC_EQANY_B
:
5568 gen_eqany_bi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5570 case OPC2_32_RC_EQANY_H
:
5571 gen_eqany_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5574 tcg_gen_setcondi_tl(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5576 case OPC2_32_RC_GE_U
:
5577 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5578 tcg_gen_setcondi_tl(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5581 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5583 case OPC2_32_RC_LT_U
:
5584 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5585 tcg_gen_setcondi_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5587 case OPC2_32_RC_MAX
:
5588 tcg_gen_movi_tl(temp
, const9
);
5589 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5590 cpu_gpr_d
[r1
], temp
);
5592 case OPC2_32_RC_MAX_U
:
5593 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
5594 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5595 cpu_gpr_d
[r1
], temp
);
5597 case OPC2_32_RC_MIN
:
5598 tcg_gen_movi_tl(temp
, const9
);
5599 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5600 cpu_gpr_d
[r1
], temp
);
5602 case OPC2_32_RC_MIN_U
:
5603 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
5604 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5605 cpu_gpr_d
[r1
], temp
);
5608 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5610 case OPC2_32_RC_OR_EQ
:
5611 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5612 const9
, &tcg_gen_or_tl
);
5614 case OPC2_32_RC_OR_GE
:
5615 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5616 const9
, &tcg_gen_or_tl
);
5618 case OPC2_32_RC_OR_GE_U
:
5619 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5620 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5621 const9
, &tcg_gen_or_tl
);
5623 case OPC2_32_RC_OR_LT
:
5624 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5625 const9
, &tcg_gen_or_tl
);
5627 case OPC2_32_RC_OR_LT_U
:
5628 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5629 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5630 const9
, &tcg_gen_or_tl
);
5632 case OPC2_32_RC_OR_NE
:
5633 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5634 const9
, &tcg_gen_or_tl
);
5636 case OPC2_32_RC_RSUB
:
5637 tcg_gen_movi_tl(temp
, const9
);
5638 gen_sub_d(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5640 case OPC2_32_RC_RSUBS
:
5641 tcg_gen_movi_tl(temp
, const9
);
5642 gen_subs(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5644 case OPC2_32_RC_RSUBS_U
:
5645 tcg_gen_movi_tl(temp
, const9
);
5646 gen_subsu(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5648 case OPC2_32_RC_SH_EQ
:
5649 gen_sh_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5651 case OPC2_32_RC_SH_GE
:
5652 gen_sh_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5654 case OPC2_32_RC_SH_GE_U
:
5655 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5656 gen_sh_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5658 case OPC2_32_RC_SH_LT
:
5659 gen_sh_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5661 case OPC2_32_RC_SH_LT_U
:
5662 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5663 gen_sh_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5665 case OPC2_32_RC_SH_NE
:
5666 gen_sh_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5668 case OPC2_32_RC_XOR_EQ
:
5669 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5670 const9
, &tcg_gen_xor_tl
);
5672 case OPC2_32_RC_XOR_GE
:
5673 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5674 const9
, &tcg_gen_xor_tl
);
5676 case OPC2_32_RC_XOR_GE_U
:
5677 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5678 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5679 const9
, &tcg_gen_xor_tl
);
5681 case OPC2_32_RC_XOR_LT
:
5682 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5683 const9
, &tcg_gen_xor_tl
);
5685 case OPC2_32_RC_XOR_LT_U
:
5686 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5687 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5688 const9
, &tcg_gen_xor_tl
);
5690 case OPC2_32_RC_XOR_NE
:
5691 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5692 const9
, &tcg_gen_xor_tl
);
5695 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5697 tcg_temp_free(temp
);
5700 static void decode_rc_serviceroutine(DisasContext
*ctx
)
5705 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5706 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5709 case OPC2_32_RC_BISR
:
5710 gen_helper_1arg(bisr
, const9
);
5712 case OPC2_32_RC_SYSCALL
:
5713 /* TODO: Add exception generation */
5716 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5720 static void decode_rc_mul(DisasContext
*ctx
)
5726 r2
= MASK_OP_RC_D(ctx
->opcode
);
5727 r1
= MASK_OP_RC_S1(ctx
->opcode
);
5728 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
5730 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5733 case OPC2_32_RC_MUL_32
:
5734 gen_muli_i32s(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5736 case OPC2_32_RC_MUL_64
:
5738 gen_muli_i64s(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
5740 case OPC2_32_RC_MULS_32
:
5741 gen_mulsi_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5743 case OPC2_32_RC_MUL_U_64
:
5744 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5746 gen_muli_i64u(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
5748 case OPC2_32_RC_MULS_U_32
:
5749 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5750 gen_mulsui_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5753 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5758 static void decode_rcpw_insert(DisasContext
*ctx
)
5762 int32_t pos
, width
, const4
;
5766 op2
= MASK_OP_RCPW_OP2(ctx
->opcode
);
5767 r1
= MASK_OP_RCPW_S1(ctx
->opcode
);
5768 r2
= MASK_OP_RCPW_D(ctx
->opcode
);
5769 const4
= MASK_OP_RCPW_CONST4(ctx
->opcode
);
5770 width
= MASK_OP_RCPW_WIDTH(ctx
->opcode
);
5771 pos
= MASK_OP_RCPW_POS(ctx
->opcode
);
5774 case OPC2_32_RCPW_IMASK
:
5776 /* if pos + width > 31 undefined result */
5777 if (pos
+ width
<= 31) {
5778 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], ((1u << width
) - 1) << pos
);
5779 tcg_gen_movi_tl(cpu_gpr_d
[r2
], (const4
<< pos
));
5782 case OPC2_32_RCPW_INSERT
:
5783 /* if pos + width > 32 undefined result */
5784 if (pos
+ width
<= 32) {
5785 temp
= tcg_const_i32(const4
);
5786 tcg_gen_deposit_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, pos
, width
);
5787 tcg_temp_free(temp
);
5791 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5797 static void decode_rcrw_insert(DisasContext
*ctx
)
5801 int32_t width
, const4
;
5803 TCGv temp
, temp2
, temp3
;
5805 op2
= MASK_OP_RCRW_OP2(ctx
->opcode
);
5806 r1
= MASK_OP_RCRW_S1(ctx
->opcode
);
5807 r3
= MASK_OP_RCRW_S3(ctx
->opcode
);
5808 r4
= MASK_OP_RCRW_D(ctx
->opcode
);
5809 width
= MASK_OP_RCRW_WIDTH(ctx
->opcode
);
5810 const4
= MASK_OP_RCRW_CONST4(ctx
->opcode
);
5812 temp
= tcg_temp_new();
5813 temp2
= tcg_temp_new();
5816 case OPC2_32_RCRW_IMASK
:
5817 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r4
], 0x1f);
5818 tcg_gen_movi_tl(temp2
, (1 << width
) - 1);
5819 tcg_gen_shl_tl(cpu_gpr_d
[r3
+ 1], temp2
, temp
);
5820 tcg_gen_movi_tl(temp2
, const4
);
5821 tcg_gen_shl_tl(cpu_gpr_d
[r3
], temp2
, temp
);
5823 case OPC2_32_RCRW_INSERT
:
5824 temp3
= tcg_temp_new();
5826 tcg_gen_movi_tl(temp
, width
);
5827 tcg_gen_movi_tl(temp2
, const4
);
5828 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r4
], 0x1f);
5829 gen_insert(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], temp2
, temp
, temp3
);
5831 tcg_temp_free(temp3
);
5834 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5836 tcg_temp_free(temp
);
5837 tcg_temp_free(temp2
);
5842 static void decode_rcr_cond_select(DisasContext
*ctx
)
5850 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5851 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5852 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5853 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5854 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5857 case OPC2_32_RCR_CADD
:
5858 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r4
],
5861 case OPC2_32_RCR_CADDN
:
5862 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r4
],
5865 case OPC2_32_RCR_SEL
:
5866 temp
= tcg_const_i32(0);
5867 temp2
= tcg_const_i32(const9
);
5868 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5869 cpu_gpr_d
[r1
], temp2
);
5870 tcg_temp_free(temp
);
5871 tcg_temp_free(temp2
);
5873 case OPC2_32_RCR_SELN
:
5874 temp
= tcg_const_i32(0);
5875 temp2
= tcg_const_i32(const9
);
5876 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5877 cpu_gpr_d
[r1
], temp2
);
5878 tcg_temp_free(temp
);
5879 tcg_temp_free(temp2
);
5882 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5886 static void decode_rcr_madd(DisasContext
*ctx
)
5893 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5894 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5895 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5896 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5897 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5900 case OPC2_32_RCR_MADD_32
:
5901 gen_maddi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5903 case OPC2_32_RCR_MADD_64
:
5906 gen_maddi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5907 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5909 case OPC2_32_RCR_MADDS_32
:
5910 gen_maddsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5912 case OPC2_32_RCR_MADDS_64
:
5915 gen_maddsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5916 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5918 case OPC2_32_RCR_MADD_U_64
:
5921 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5922 gen_maddui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5923 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5925 case OPC2_32_RCR_MADDS_U_32
:
5926 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5927 gen_maddsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5929 case OPC2_32_RCR_MADDS_U_64
:
5932 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5933 gen_maddsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5934 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5937 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5941 static void decode_rcr_msub(DisasContext
*ctx
)
5948 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5949 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5950 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5951 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5952 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5955 case OPC2_32_RCR_MSUB_32
:
5956 gen_msubi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5958 case OPC2_32_RCR_MSUB_64
:
5961 gen_msubi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5962 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5964 case OPC2_32_RCR_MSUBS_32
:
5965 gen_msubsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5967 case OPC2_32_RCR_MSUBS_64
:
5970 gen_msubsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5971 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5973 case OPC2_32_RCR_MSUB_U_64
:
5976 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5977 gen_msubui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5978 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5980 case OPC2_32_RCR_MSUBS_U_32
:
5981 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5982 gen_msubsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5984 case OPC2_32_RCR_MSUBS_U_64
:
5987 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5988 gen_msubsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5989 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5992 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5998 static void decode_rlc_opc(DisasContext
*ctx
,
6004 const16
= MASK_OP_RLC_CONST16_SEXT(ctx
->opcode
);
6005 r1
= MASK_OP_RLC_S1(ctx
->opcode
);
6006 r2
= MASK_OP_RLC_D(ctx
->opcode
);
6009 case OPC1_32_RLC_ADDI
:
6010 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
);
6012 case OPC1_32_RLC_ADDIH
:
6013 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
<< 16);
6015 case OPC1_32_RLC_ADDIH_A
:
6016 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r1
], const16
<< 16);
6018 case OPC1_32_RLC_MFCR
:
6019 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
6020 gen_mfcr(ctx
, cpu_gpr_d
[r2
], const16
);
6022 case OPC1_32_RLC_MOV
:
6023 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
6025 case OPC1_32_RLC_MOV_64
:
6026 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
6028 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
6029 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], const16
>> 15);
6031 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6034 case OPC1_32_RLC_MOV_U
:
6035 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
6036 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
6038 case OPC1_32_RLC_MOV_H
:
6039 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
<< 16);
6041 case OPC1_32_RLC_MOVH_A
:
6042 tcg_gen_movi_tl(cpu_gpr_a
[r2
], const16
<< 16);
6044 case OPC1_32_RLC_MTCR
:
6045 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
6046 gen_mtcr(ctx
, cpu_gpr_d
[r1
], const16
);
6049 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6054 static void decode_rr_accumulator(DisasContext
*ctx
)
6061 r3
= MASK_OP_RR_D(ctx
->opcode
);
6062 r2
= MASK_OP_RR_S2(ctx
->opcode
);
6063 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6064 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6067 case OPC2_32_RR_ABS
:
6068 gen_abs(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6070 case OPC2_32_RR_ABS_B
:
6071 gen_helper_abs_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
6073 case OPC2_32_RR_ABS_H
:
6074 gen_helper_abs_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
6076 case OPC2_32_RR_ABSDIF
:
6077 gen_absdif(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6079 case OPC2_32_RR_ABSDIF_B
:
6080 gen_helper_absdif_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6083 case OPC2_32_RR_ABSDIF_H
:
6084 gen_helper_absdif_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6087 case OPC2_32_RR_ABSDIFS
:
6088 gen_helper_absdif_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6091 case OPC2_32_RR_ABSDIFS_H
:
6092 gen_helper_absdif_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6095 case OPC2_32_RR_ABSS
:
6096 gen_helper_abs_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
6098 case OPC2_32_RR_ABSS_H
:
6099 gen_helper_abs_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
6101 case OPC2_32_RR_ADD
:
6102 gen_add_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6104 case OPC2_32_RR_ADD_B
:
6105 gen_helper_add_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6107 case OPC2_32_RR_ADD_H
:
6108 gen_helper_add_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6110 case OPC2_32_RR_ADDC
:
6111 gen_addc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6113 case OPC2_32_RR_ADDS
:
6114 gen_adds(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6116 case OPC2_32_RR_ADDS_H
:
6117 gen_helper_add_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6120 case OPC2_32_RR_ADDS_HU
:
6121 gen_helper_add_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6124 case OPC2_32_RR_ADDS_U
:
6125 gen_helper_add_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6128 case OPC2_32_RR_ADDX
:
6129 gen_add_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6131 case OPC2_32_RR_AND_EQ
:
6132 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6133 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6135 case OPC2_32_RR_AND_GE
:
6136 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6137 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6139 case OPC2_32_RR_AND_GE_U
:
6140 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6141 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6143 case OPC2_32_RR_AND_LT
:
6144 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6145 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6147 case OPC2_32_RR_AND_LT_U
:
6148 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6149 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6151 case OPC2_32_RR_AND_NE
:
6152 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6153 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
6156 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6159 case OPC2_32_RR_EQ_B
:
6160 gen_helper_eq_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6162 case OPC2_32_RR_EQ_H
:
6163 gen_helper_eq_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6165 case OPC2_32_RR_EQ_W
:
6166 gen_cond_w(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6168 case OPC2_32_RR_EQANY_B
:
6169 gen_helper_eqany_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6171 case OPC2_32_RR_EQANY_H
:
6172 gen_helper_eqany_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6175 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6178 case OPC2_32_RR_GE_U
:
6179 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6183 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6186 case OPC2_32_RR_LT_U
:
6187 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6190 case OPC2_32_RR_LT_B
:
6191 gen_helper_lt_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6193 case OPC2_32_RR_LT_BU
:
6194 gen_helper_lt_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6196 case OPC2_32_RR_LT_H
:
6197 gen_helper_lt_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6199 case OPC2_32_RR_LT_HU
:
6200 gen_helper_lt_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6202 case OPC2_32_RR_LT_W
:
6203 gen_cond_w(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6205 case OPC2_32_RR_LT_WU
:
6206 gen_cond_w(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6208 case OPC2_32_RR_MAX
:
6209 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6210 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6212 case OPC2_32_RR_MAX_U
:
6213 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6214 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6216 case OPC2_32_RR_MAX_B
:
6217 gen_helper_max_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6219 case OPC2_32_RR_MAX_BU
:
6220 gen_helper_max_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6222 case OPC2_32_RR_MAX_H
:
6223 gen_helper_max_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6225 case OPC2_32_RR_MAX_HU
:
6226 gen_helper_max_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6228 case OPC2_32_RR_MIN
:
6229 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6230 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6232 case OPC2_32_RR_MIN_U
:
6233 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6234 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6236 case OPC2_32_RR_MIN_B
:
6237 gen_helper_min_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6239 case OPC2_32_RR_MIN_BU
:
6240 gen_helper_min_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6242 case OPC2_32_RR_MIN_H
:
6243 gen_helper_min_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6245 case OPC2_32_RR_MIN_HU
:
6246 gen_helper_min_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6248 case OPC2_32_RR_MOV
:
6249 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6251 case OPC2_32_RR_MOV_64
:
6252 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
6253 temp
= tcg_temp_new();
6256 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
6257 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6258 tcg_gen_mov_tl(cpu_gpr_d
[r3
+ 1], temp
);
6260 tcg_temp_free(temp
);
6262 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6265 case OPC2_32_RR_MOVS_64
:
6266 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
6268 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6269 tcg_gen_sari_tl(cpu_gpr_d
[r3
+ 1], cpu_gpr_d
[r2
], 31);
6271 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6275 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6278 case OPC2_32_RR_OR_EQ
:
6279 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6280 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6282 case OPC2_32_RR_OR_GE
:
6283 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6284 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6286 case OPC2_32_RR_OR_GE_U
:
6287 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6288 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6290 case OPC2_32_RR_OR_LT
:
6291 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6292 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6294 case OPC2_32_RR_OR_LT_U
:
6295 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6296 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6298 case OPC2_32_RR_OR_NE
:
6299 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6300 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
6302 case OPC2_32_RR_SAT_B
:
6303 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7f, -0x80);
6305 case OPC2_32_RR_SAT_BU
:
6306 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xff);
6308 case OPC2_32_RR_SAT_H
:
6309 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
6311 case OPC2_32_RR_SAT_HU
:
6312 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xffff);
6314 case OPC2_32_RR_SH_EQ
:
6315 gen_sh_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6318 case OPC2_32_RR_SH_GE
:
6319 gen_sh_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6322 case OPC2_32_RR_SH_GE_U
:
6323 gen_sh_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6326 case OPC2_32_RR_SH_LT
:
6327 gen_sh_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6330 case OPC2_32_RR_SH_LT_U
:
6331 gen_sh_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6334 case OPC2_32_RR_SH_NE
:
6335 gen_sh_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6338 case OPC2_32_RR_SUB
:
6339 gen_sub_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6341 case OPC2_32_RR_SUB_B
:
6342 gen_helper_sub_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6344 case OPC2_32_RR_SUB_H
:
6345 gen_helper_sub_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6347 case OPC2_32_RR_SUBC
:
6348 gen_subc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6350 case OPC2_32_RR_SUBS
:
6351 gen_subs(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6353 case OPC2_32_RR_SUBS_U
:
6354 gen_subsu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6356 case OPC2_32_RR_SUBS_H
:
6357 gen_helper_sub_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6360 case OPC2_32_RR_SUBS_HU
:
6361 gen_helper_sub_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6364 case OPC2_32_RR_SUBX
:
6365 gen_sub_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6367 case OPC2_32_RR_XOR_EQ
:
6368 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6369 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6371 case OPC2_32_RR_XOR_GE
:
6372 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6373 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6375 case OPC2_32_RR_XOR_GE_U
:
6376 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6377 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6379 case OPC2_32_RR_XOR_LT
:
6380 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6381 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6383 case OPC2_32_RR_XOR_LT_U
:
6384 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6385 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6387 case OPC2_32_RR_XOR_NE
:
6388 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6389 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
6392 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6396 static void decode_rr_logical_shift(DisasContext
*ctx
)
6402 r3
= MASK_OP_RR_D(ctx
->opcode
);
6403 r2
= MASK_OP_RR_S2(ctx
->opcode
);
6404 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6406 temp
= tcg_temp_new();
6407 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6410 case OPC2_32_RR_AND
:
6411 tcg_gen_and_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6413 case OPC2_32_RR_ANDN
:
6414 tcg_gen_andc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6416 case OPC2_32_RR_CLO
:
6417 tcg_gen_not_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6418 tcg_gen_clzi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], TARGET_LONG_BITS
);
6420 case OPC2_32_RR_CLO_H
:
6421 gen_helper_clo_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6423 case OPC2_32_RR_CLS
:
6424 tcg_gen_clrsb_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6426 case OPC2_32_RR_CLS_H
:
6427 gen_helper_cls_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6429 case OPC2_32_RR_CLZ
:
6430 tcg_gen_clzi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], TARGET_LONG_BITS
);
6432 case OPC2_32_RR_CLZ_H
:
6433 gen_helper_clz_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6435 case OPC2_32_RR_NAND
:
6436 tcg_gen_nand_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6438 case OPC2_32_RR_NOR
:
6439 tcg_gen_nor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6442 tcg_gen_or_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6444 case OPC2_32_RR_ORN
:
6445 tcg_gen_orc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6448 gen_helper_sh(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6450 case OPC2_32_RR_SH_H
:
6451 gen_helper_sh_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6453 case OPC2_32_RR_SHA
:
6454 gen_helper_sha(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6456 case OPC2_32_RR_SHA_H
:
6457 gen_helper_sha_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6459 case OPC2_32_RR_SHAS
:
6460 gen_shas(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6462 case OPC2_32_RR_XNOR
:
6463 tcg_gen_eqv_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6465 case OPC2_32_RR_XOR
:
6466 tcg_gen_xor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6469 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6471 tcg_temp_free(temp
);
6474 static void decode_rr_address(DisasContext
*ctx
)
6480 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6481 r3
= MASK_OP_RR_D(ctx
->opcode
);
6482 r2
= MASK_OP_RR_S2(ctx
->opcode
);
6483 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6484 n
= MASK_OP_RR_N(ctx
->opcode
);
6487 case OPC2_32_RR_ADD_A
:
6488 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
6490 case OPC2_32_RR_ADDSC_A
:
6491 temp
= tcg_temp_new();
6492 tcg_gen_shli_tl(temp
, cpu_gpr_d
[r1
], n
);
6493 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
], temp
);
6494 tcg_temp_free(temp
);
6496 case OPC2_32_RR_ADDSC_AT
:
6497 temp
= tcg_temp_new();
6498 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 3);
6499 tcg_gen_add_tl(temp
, cpu_gpr_a
[r2
], temp
);
6500 tcg_gen_andi_tl(cpu_gpr_a
[r3
], temp
, 0xFFFFFFFC);
6501 tcg_temp_free(temp
);
6503 case OPC2_32_RR_EQ_A
:
6504 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6507 case OPC2_32_RR_EQZ
:
6508 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
6510 case OPC2_32_RR_GE_A
:
6511 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6514 case OPC2_32_RR_LT_A
:
6515 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6518 case OPC2_32_RR_MOV_A
:
6519 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_d
[r2
]);
6521 case OPC2_32_RR_MOV_AA
:
6522 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
]);
6524 case OPC2_32_RR_MOV_D
:
6525 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_a
[r2
]);
6527 case OPC2_32_RR_NE_A
:
6528 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6531 case OPC2_32_RR_NEZ_A
:
6532 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
6534 case OPC2_32_RR_SUB_A
:
6535 tcg_gen_sub_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
6538 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6542 static void decode_rr_idirect(DisasContext
*ctx
)
6547 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6548 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6552 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6554 case OPC2_32_RR_JLI
:
6555 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
6556 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6558 case OPC2_32_RR_CALLI
:
6559 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
6560 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6562 case OPC2_32_RR_FCALLI
:
6563 gen_fcall_save_ctx(ctx
);
6564 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6567 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6569 tcg_gen_exit_tb(NULL
, 0);
6570 ctx
->base
.is_jmp
= DISAS_NORETURN
;
6573 static void decode_rr_divide(DisasContext
*ctx
)
6578 TCGv temp
, temp2
, temp3
;
6580 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6581 r3
= MASK_OP_RR_D(ctx
->opcode
);
6582 r2
= MASK_OP_RR_S2(ctx
->opcode
);
6583 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6586 case OPC2_32_RR_BMERGE
:
6587 gen_helper_bmerge(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6589 case OPC2_32_RR_BSPLIT
:
6591 gen_bsplit(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
6593 case OPC2_32_RR_DVINIT_B
:
6595 gen_dvinit_b(ctx
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6598 case OPC2_32_RR_DVINIT_BU
:
6599 temp
= tcg_temp_new();
6600 temp2
= tcg_temp_new();
6601 temp3
= tcg_temp_new();
6603 tcg_gen_shri_tl(temp3
, cpu_gpr_d
[r1
], 8);
6605 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6606 if (!tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
6607 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
6608 tcg_gen_abs_tl(temp
, temp3
);
6609 tcg_gen_abs_tl(temp2
, cpu_gpr_d
[r2
]);
6610 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
6612 /* overflow = (D[b] == 0) */
6613 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6615 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6617 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6619 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 24);
6620 tcg_gen_mov_tl(cpu_gpr_d
[r3
+1], temp3
);
6622 tcg_temp_free(temp
);
6623 tcg_temp_free(temp2
);
6624 tcg_temp_free(temp3
);
6626 case OPC2_32_RR_DVINIT_H
:
6628 gen_dvinit_h(ctx
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6631 case OPC2_32_RR_DVINIT_HU
:
6632 temp
= tcg_temp_new();
6633 temp2
= tcg_temp_new();
6634 temp3
= tcg_temp_new();
6636 tcg_gen_shri_tl(temp3
, cpu_gpr_d
[r1
], 16);
6638 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6639 if (!tricore_feature(ctx
->env
, TRICORE_FEATURE_131
)) {
6640 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
6641 tcg_gen_abs_tl(temp
, temp3
);
6642 tcg_gen_abs_tl(temp2
, cpu_gpr_d
[r2
]);
6643 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
6645 /* overflow = (D[b] == 0) */
6646 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6648 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6650 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6652 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 16);
6653 tcg_gen_mov_tl(cpu_gpr_d
[r3
+1], temp3
);
6654 tcg_temp_free(temp
);
6655 tcg_temp_free(temp2
);
6656 tcg_temp_free(temp3
);
6658 case OPC2_32_RR_DVINIT
:
6659 temp
= tcg_temp_new();
6660 temp2
= tcg_temp_new();
6662 /* overflow = ((D[b] == 0) ||
6663 ((D[b] == 0xFFFFFFFF) && (D[a] == 0x80000000))) */
6664 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, cpu_gpr_d
[r2
], 0xffffffff);
6665 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r1
], 0x80000000);
6666 tcg_gen_and_tl(temp
, temp
, temp2
);
6667 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r2
], 0);
6668 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
6669 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6671 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6673 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6675 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6676 /* sign extend to high reg */
6677 tcg_gen_sari_tl(cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], 31);
6678 tcg_temp_free(temp
);
6679 tcg_temp_free(temp2
);
6681 case OPC2_32_RR_DVINIT_U
:
6682 /* overflow = (D[b] == 0) */
6683 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6684 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6686 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6688 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6690 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6691 /* zero extend to high reg*/
6692 tcg_gen_movi_tl(cpu_gpr_d
[r3
+1], 0);
6694 case OPC2_32_RR_PARITY
:
6695 gen_helper_parity(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6697 case OPC2_32_RR_UNPACK
:
6699 gen_unpack(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
6701 case OPC2_32_RR_CRC32
:
6702 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_161
)) {
6703 gen_helper_crc32(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6705 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6708 case OPC2_32_RR_DIV
:
6709 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
6710 GEN_HELPER_RR(divide
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6713 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6716 case OPC2_32_RR_DIV_U
:
6717 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
6718 GEN_HELPER_RR(divide_u
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
6719 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6721 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6724 case OPC2_32_RR_MUL_F
:
6725 gen_helper_fmul(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6727 case OPC2_32_RR_DIV_F
:
6728 gen_helper_fdiv(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6730 case OPC2_32_RR_CMP_F
:
6731 gen_helper_fcmp(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6733 case OPC2_32_RR_FTOI
:
6734 gen_helper_ftoi(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6736 case OPC2_32_RR_ITOF
:
6737 gen_helper_itof(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6739 case OPC2_32_RR_FTOUZ
:
6740 gen_helper_ftouz(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6742 case OPC2_32_RR_UPDFL
:
6743 gen_helper_updfl(cpu_env
, cpu_gpr_d
[r1
]);
6745 case OPC2_32_RR_UTOF
:
6746 gen_helper_utof(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6748 case OPC2_32_RR_FTOIZ
:
6749 gen_helper_ftoiz(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6751 case OPC2_32_RR_QSEED_F
:
6752 gen_helper_qseed(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6755 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6760 static void decode_rr1_mul(DisasContext
*ctx
)
6768 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
6769 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
6770 r3
= MASK_OP_RR1_D(ctx
->opcode
);
6771 n
= tcg_const_i32(MASK_OP_RR1_N(ctx
->opcode
));
6772 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
6775 case OPC2_32_RR1_MUL_H_32_LL
:
6776 temp64
= tcg_temp_new_i64();
6778 GEN_HELPER_LL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6779 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6780 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6781 tcg_temp_free_i64(temp64
);
6783 case OPC2_32_RR1_MUL_H_32_LU
:
6784 temp64
= tcg_temp_new_i64();
6786 GEN_HELPER_LU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6787 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6788 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6789 tcg_temp_free_i64(temp64
);
6791 case OPC2_32_RR1_MUL_H_32_UL
:
6792 temp64
= tcg_temp_new_i64();
6794 GEN_HELPER_UL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6795 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6796 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6797 tcg_temp_free_i64(temp64
);
6799 case OPC2_32_RR1_MUL_H_32_UU
:
6800 temp64
= tcg_temp_new_i64();
6802 GEN_HELPER_UU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6803 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6804 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6805 tcg_temp_free_i64(temp64
);
6807 case OPC2_32_RR1_MULM_H_64_LL
:
6808 temp64
= tcg_temp_new_i64();
6810 GEN_HELPER_LL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6811 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6813 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6815 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6816 tcg_temp_free_i64(temp64
);
6818 case OPC2_32_RR1_MULM_H_64_LU
:
6819 temp64
= tcg_temp_new_i64();
6821 GEN_HELPER_LU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6822 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6824 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6826 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6827 tcg_temp_free_i64(temp64
);
6829 case OPC2_32_RR1_MULM_H_64_UL
:
6830 temp64
= tcg_temp_new_i64();
6832 GEN_HELPER_UL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6833 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6835 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6837 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6838 tcg_temp_free_i64(temp64
);
6840 case OPC2_32_RR1_MULM_H_64_UU
:
6841 temp64
= tcg_temp_new_i64();
6843 GEN_HELPER_UU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6844 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6846 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6848 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6849 tcg_temp_free_i64(temp64
);
6852 case OPC2_32_RR1_MULR_H_16_LL
:
6853 GEN_HELPER_LL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6854 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6856 case OPC2_32_RR1_MULR_H_16_LU
:
6857 GEN_HELPER_LU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6858 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6860 case OPC2_32_RR1_MULR_H_16_UL
:
6861 GEN_HELPER_UL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6862 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6864 case OPC2_32_RR1_MULR_H_16_UU
:
6865 GEN_HELPER_UU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6866 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6869 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6874 static void decode_rr1_mulq(DisasContext
*ctx
)
6882 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
6883 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
6884 r3
= MASK_OP_RR1_D(ctx
->opcode
);
6885 n
= MASK_OP_RR1_N(ctx
->opcode
);
6886 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
6888 temp
= tcg_temp_new();
6889 temp2
= tcg_temp_new();
6892 case OPC2_32_RR1_MUL_Q_32
:
6893 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 32);
6895 case OPC2_32_RR1_MUL_Q_64
:
6897 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6900 case OPC2_32_RR1_MUL_Q_32_L
:
6901 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6902 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
6904 case OPC2_32_RR1_MUL_Q_64_L
:
6906 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6907 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
6909 case OPC2_32_RR1_MUL_Q_32_U
:
6910 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6911 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
6913 case OPC2_32_RR1_MUL_Q_64_U
:
6915 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6916 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
6918 case OPC2_32_RR1_MUL_Q_32_LL
:
6919 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6920 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6921 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6923 case OPC2_32_RR1_MUL_Q_32_UU
:
6924 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6925 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6926 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6928 case OPC2_32_RR1_MULR_Q_32_L
:
6929 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6930 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6931 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6933 case OPC2_32_RR1_MULR_Q_32_U
:
6934 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6935 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6936 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6939 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6941 tcg_temp_free(temp
);
6942 tcg_temp_free(temp2
);
6946 static void decode_rr2_mul(DisasContext
*ctx
)
6951 op2
= MASK_OP_RR2_OP2(ctx
->opcode
);
6952 r1
= MASK_OP_RR2_S1(ctx
->opcode
);
6953 r2
= MASK_OP_RR2_S2(ctx
->opcode
);
6954 r3
= MASK_OP_RR2_D(ctx
->opcode
);
6956 case OPC2_32_RR2_MUL_32
:
6957 gen_mul_i32s(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6959 case OPC2_32_RR2_MUL_64
:
6961 gen_mul_i64s(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6964 case OPC2_32_RR2_MULS_32
:
6965 gen_helper_mul_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6968 case OPC2_32_RR2_MUL_U_64
:
6970 gen_mul_i64u(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6973 case OPC2_32_RR2_MULS_U_32
:
6974 gen_helper_mul_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6978 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6983 static void decode_rrpw_extract_insert(DisasContext
*ctx
)
6989 op2
= MASK_OP_RRPW_OP2(ctx
->opcode
);
6990 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
6991 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
6992 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
6993 pos
= MASK_OP_RRPW_POS(ctx
->opcode
);
6994 width
= MASK_OP_RRPW_WIDTH(ctx
->opcode
);
6997 case OPC2_32_RRPW_EXTR
:
6998 if (pos
+ width
<= 31) {
6999 /* optimize special cases */
7000 if ((pos
== 0) && (width
== 8)) {
7001 tcg_gen_ext8s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
7002 } else if ((pos
== 0) && (width
== 16)) {
7003 tcg_gen_ext16s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
7005 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 32 - pos
- width
);
7006 tcg_gen_sari_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 32 - width
);
7010 case OPC2_32_RRPW_EXTR_U
:
7012 tcg_gen_movi_tl(cpu_gpr_d
[r3
], 0);
7014 tcg_gen_shri_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], pos
);
7015 tcg_gen_andi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], ~0u >> (32-width
));
7018 case OPC2_32_RRPW_IMASK
:
7020 if (pos
+ width
<= 31) {
7021 tcg_gen_movi_tl(cpu_gpr_d
[r3
+1], ((1u << width
) - 1) << pos
);
7022 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], pos
);
7025 case OPC2_32_RRPW_INSERT
:
7026 if (pos
+ width
<= 32) {
7027 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7032 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7037 static void decode_rrr_cond_select(DisasContext
*ctx
)
7043 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
7044 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
7045 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
7046 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
7047 r4
= MASK_OP_RRR_D(ctx
->opcode
);
7050 case OPC2_32_RRR_CADD
:
7051 gen_cond_add(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7052 cpu_gpr_d
[r4
], cpu_gpr_d
[r3
]);
7054 case OPC2_32_RRR_CADDN
:
7055 gen_cond_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
7058 case OPC2_32_RRR_CSUB
:
7059 gen_cond_sub(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
7062 case OPC2_32_RRR_CSUBN
:
7063 gen_cond_sub(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
7066 case OPC2_32_RRR_SEL
:
7067 temp
= tcg_const_i32(0);
7068 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
7069 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
7070 tcg_temp_free(temp
);
7072 case OPC2_32_RRR_SELN
:
7073 temp
= tcg_const_i32(0);
7074 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
7075 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
7076 tcg_temp_free(temp
);
7079 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7083 static void decode_rrr_divide(DisasContext
*ctx
)
7089 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
7090 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
7091 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
7092 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
7093 r4
= MASK_OP_RRR_D(ctx
->opcode
);
7096 case OPC2_32_RRR_DVADJ
:
7099 GEN_HELPER_RRR(dvadj
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7100 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7102 case OPC2_32_RRR_DVSTEP
:
7105 GEN_HELPER_RRR(dvstep
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7106 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7108 case OPC2_32_RRR_DVSTEP_U
:
7111 GEN_HELPER_RRR(dvstep_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7112 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7114 case OPC2_32_RRR_IXMAX
:
7117 GEN_HELPER_RRR(ixmax
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7118 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7120 case OPC2_32_RRR_IXMAX_U
:
7123 GEN_HELPER_RRR(ixmax_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7124 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7126 case OPC2_32_RRR_IXMIN
:
7129 GEN_HELPER_RRR(ixmin
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7130 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7132 case OPC2_32_RRR_IXMIN_U
:
7135 GEN_HELPER_RRR(ixmin_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7136 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7138 case OPC2_32_RRR_PACK
:
7140 gen_helper_pack(cpu_gpr_d
[r4
], cpu_PSW_C
, cpu_gpr_d
[r3
],
7141 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
7143 case OPC2_32_RRR_ADD_F
:
7144 gen_helper_fadd(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r3
]);
7146 case OPC2_32_RRR_SUB_F
:
7147 gen_helper_fsub(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r3
]);
7149 case OPC2_32_RRR_MADD_F
:
7150 gen_helper_fmadd(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7151 cpu_gpr_d
[r2
], cpu_gpr_d
[r3
]);
7153 case OPC2_32_RRR_MSUB_F
:
7154 gen_helper_fmsub(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7155 cpu_gpr_d
[r2
], cpu_gpr_d
[r3
]);
7158 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7163 static void decode_rrr2_madd(DisasContext
*ctx
)
7166 uint32_t r1
, r2
, r3
, r4
;
7168 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
7169 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
7170 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
7171 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
7172 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
7174 case OPC2_32_RRR2_MADD_32
:
7175 gen_madd32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
7178 case OPC2_32_RRR2_MADD_64
:
7181 gen_madd64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7182 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7184 case OPC2_32_RRR2_MADDS_32
:
7185 gen_helper_madd32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7186 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
7188 case OPC2_32_RRR2_MADDS_64
:
7191 gen_madds_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7192 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7194 case OPC2_32_RRR2_MADD_U_64
:
7197 gen_maddu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7198 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7200 case OPC2_32_RRR2_MADDS_U_32
:
7201 gen_helper_madd32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7202 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
7204 case OPC2_32_RRR2_MADDS_U_64
:
7207 gen_maddsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7208 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7211 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7215 static void decode_rrr2_msub(DisasContext
*ctx
)
7218 uint32_t r1
, r2
, r3
, r4
;
7220 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
7221 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
7222 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
7223 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
7224 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
7227 case OPC2_32_RRR2_MSUB_32
:
7228 gen_msub32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
7231 case OPC2_32_RRR2_MSUB_64
:
7234 gen_msub64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7235 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7237 case OPC2_32_RRR2_MSUBS_32
:
7238 gen_helper_msub32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7239 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
7241 case OPC2_32_RRR2_MSUBS_64
:
7244 gen_msubs_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7245 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7247 case OPC2_32_RRR2_MSUB_U_64
:
7248 gen_msubu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7249 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7251 case OPC2_32_RRR2_MSUBS_U_32
:
7252 gen_helper_msub32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
7253 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
7255 case OPC2_32_RRR2_MSUBS_U_64
:
7258 gen_msubsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
7259 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
7262 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7267 static void decode_rrr1_madd(DisasContext
*ctx
)
7270 uint32_t r1
, r2
, r3
, r4
, n
;
7272 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7273 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7274 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7275 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7276 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7277 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7280 case OPC2_32_RRR1_MADD_H_LL
:
7283 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7284 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7286 case OPC2_32_RRR1_MADD_H_LU
:
7289 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7290 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7292 case OPC2_32_RRR1_MADD_H_UL
:
7295 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7296 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7298 case OPC2_32_RRR1_MADD_H_UU
:
7301 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7302 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7304 case OPC2_32_RRR1_MADDS_H_LL
:
7307 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7308 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7310 case OPC2_32_RRR1_MADDS_H_LU
:
7313 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7314 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7316 case OPC2_32_RRR1_MADDS_H_UL
:
7319 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7320 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7322 case OPC2_32_RRR1_MADDS_H_UU
:
7325 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7326 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7328 case OPC2_32_RRR1_MADDM_H_LL
:
7331 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7332 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7334 case OPC2_32_RRR1_MADDM_H_LU
:
7337 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7338 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7340 case OPC2_32_RRR1_MADDM_H_UL
:
7343 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7344 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7346 case OPC2_32_RRR1_MADDM_H_UU
:
7349 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7350 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7352 case OPC2_32_RRR1_MADDMS_H_LL
:
7355 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7356 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7358 case OPC2_32_RRR1_MADDMS_H_LU
:
7361 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7362 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7364 case OPC2_32_RRR1_MADDMS_H_UL
:
7367 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7368 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7370 case OPC2_32_RRR1_MADDMS_H_UU
:
7373 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7374 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7376 case OPC2_32_RRR1_MADDR_H_LL
:
7377 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7378 cpu_gpr_d
[r2
], n
, MODE_LL
);
7380 case OPC2_32_RRR1_MADDR_H_LU
:
7381 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7382 cpu_gpr_d
[r2
], n
, MODE_LU
);
7384 case OPC2_32_RRR1_MADDR_H_UL
:
7385 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7386 cpu_gpr_d
[r2
], n
, MODE_UL
);
7388 case OPC2_32_RRR1_MADDR_H_UU
:
7389 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7390 cpu_gpr_d
[r2
], n
, MODE_UU
);
7392 case OPC2_32_RRR1_MADDRS_H_LL
:
7393 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7394 cpu_gpr_d
[r2
], n
, MODE_LL
);
7396 case OPC2_32_RRR1_MADDRS_H_LU
:
7397 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7398 cpu_gpr_d
[r2
], n
, MODE_LU
);
7400 case OPC2_32_RRR1_MADDRS_H_UL
:
7401 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7402 cpu_gpr_d
[r2
], n
, MODE_UL
);
7404 case OPC2_32_RRR1_MADDRS_H_UU
:
7405 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7406 cpu_gpr_d
[r2
], n
, MODE_UU
);
7409 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7413 static void decode_rrr1_maddq_h(DisasContext
*ctx
)
7416 uint32_t r1
, r2
, r3
, r4
, n
;
7419 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7420 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7421 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7422 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7423 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7424 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7426 temp
= tcg_const_i32(n
);
7427 temp2
= tcg_temp_new();
7430 case OPC2_32_RRR1_MADD_Q_32
:
7431 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7432 cpu_gpr_d
[r2
], n
, 32);
7434 case OPC2_32_RRR1_MADD_Q_64
:
7437 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7438 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7441 case OPC2_32_RRR1_MADD_Q_32_L
:
7442 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7443 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7446 case OPC2_32_RRR1_MADD_Q_64_L
:
7449 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7450 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7451 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7454 case OPC2_32_RRR1_MADD_Q_32_U
:
7455 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7456 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7459 case OPC2_32_RRR1_MADD_Q_64_U
:
7462 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7463 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7464 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7467 case OPC2_32_RRR1_MADD_Q_32_LL
:
7468 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7469 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7470 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7472 case OPC2_32_RRR1_MADD_Q_64_LL
:
7475 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7476 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7477 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7478 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7480 case OPC2_32_RRR1_MADD_Q_32_UU
:
7481 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7482 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7483 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7485 case OPC2_32_RRR1_MADD_Q_64_UU
:
7488 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7489 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7490 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7491 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7493 case OPC2_32_RRR1_MADDS_Q_32
:
7494 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7495 cpu_gpr_d
[r2
], n
, 32);
7497 case OPC2_32_RRR1_MADDS_Q_64
:
7500 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7501 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7504 case OPC2_32_RRR1_MADDS_Q_32_L
:
7505 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7506 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7509 case OPC2_32_RRR1_MADDS_Q_64_L
:
7512 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7513 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7514 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7517 case OPC2_32_RRR1_MADDS_Q_32_U
:
7518 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7519 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7522 case OPC2_32_RRR1_MADDS_Q_64_U
:
7525 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7526 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7527 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7530 case OPC2_32_RRR1_MADDS_Q_32_LL
:
7531 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7532 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7533 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7535 case OPC2_32_RRR1_MADDS_Q_64_LL
:
7538 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7539 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7540 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7541 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7543 case OPC2_32_RRR1_MADDS_Q_32_UU
:
7544 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7545 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7546 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7548 case OPC2_32_RRR1_MADDS_Q_64_UU
:
7551 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7552 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7553 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7554 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7556 case OPC2_32_RRR1_MADDR_H_64_UL
:
7558 gen_maddr64_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7559 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7561 case OPC2_32_RRR1_MADDRS_H_64_UL
:
7563 gen_maddr64s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7564 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7566 case OPC2_32_RRR1_MADDR_Q_32_LL
:
7567 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7568 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7569 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7571 case OPC2_32_RRR1_MADDR_Q_32_UU
:
7572 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7573 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7574 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7576 case OPC2_32_RRR1_MADDRS_Q_32_LL
:
7577 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7578 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7579 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7581 case OPC2_32_RRR1_MADDRS_Q_32_UU
:
7582 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7583 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7584 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7587 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7589 tcg_temp_free(temp
);
7590 tcg_temp_free(temp2
);
7593 static void decode_rrr1_maddsu_h(DisasContext
*ctx
)
7596 uint32_t r1
, r2
, r3
, r4
, n
;
7598 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7599 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7600 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7601 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7602 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7603 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7606 case OPC2_32_RRR1_MADDSU_H_32_LL
:
7609 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7610 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7612 case OPC2_32_RRR1_MADDSU_H_32_LU
:
7615 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7616 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7618 case OPC2_32_RRR1_MADDSU_H_32_UL
:
7621 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7622 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7624 case OPC2_32_RRR1_MADDSU_H_32_UU
:
7627 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7628 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7630 case OPC2_32_RRR1_MADDSUS_H_32_LL
:
7633 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7634 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7637 case OPC2_32_RRR1_MADDSUS_H_32_LU
:
7640 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7641 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7644 case OPC2_32_RRR1_MADDSUS_H_32_UL
:
7647 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7648 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7651 case OPC2_32_RRR1_MADDSUS_H_32_UU
:
7654 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7655 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7658 case OPC2_32_RRR1_MADDSUM_H_64_LL
:
7661 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7662 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7665 case OPC2_32_RRR1_MADDSUM_H_64_LU
:
7668 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7669 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7672 case OPC2_32_RRR1_MADDSUM_H_64_UL
:
7675 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7676 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7679 case OPC2_32_RRR1_MADDSUM_H_64_UU
:
7682 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7683 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7686 case OPC2_32_RRR1_MADDSUMS_H_64_LL
:
7689 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7690 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7693 case OPC2_32_RRR1_MADDSUMS_H_64_LU
:
7696 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7697 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7700 case OPC2_32_RRR1_MADDSUMS_H_64_UL
:
7703 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7704 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7707 case OPC2_32_RRR1_MADDSUMS_H_64_UU
:
7710 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7711 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7714 case OPC2_32_RRR1_MADDSUR_H_16_LL
:
7715 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7716 cpu_gpr_d
[r2
], n
, MODE_LL
);
7718 case OPC2_32_RRR1_MADDSUR_H_16_LU
:
7719 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7720 cpu_gpr_d
[r2
], n
, MODE_LU
);
7722 case OPC2_32_RRR1_MADDSUR_H_16_UL
:
7723 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7724 cpu_gpr_d
[r2
], n
, MODE_UL
);
7726 case OPC2_32_RRR1_MADDSUR_H_16_UU
:
7727 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7728 cpu_gpr_d
[r2
], n
, MODE_UU
);
7730 case OPC2_32_RRR1_MADDSURS_H_16_LL
:
7731 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7732 cpu_gpr_d
[r2
], n
, MODE_LL
);
7734 case OPC2_32_RRR1_MADDSURS_H_16_LU
:
7735 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7736 cpu_gpr_d
[r2
], n
, MODE_LU
);
7738 case OPC2_32_RRR1_MADDSURS_H_16_UL
:
7739 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7740 cpu_gpr_d
[r2
], n
, MODE_UL
);
7742 case OPC2_32_RRR1_MADDSURS_H_16_UU
:
7743 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7744 cpu_gpr_d
[r2
], n
, MODE_UU
);
7747 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7751 static void decode_rrr1_msub(DisasContext
*ctx
)
7754 uint32_t r1
, r2
, r3
, r4
, n
;
7756 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7757 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7758 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7759 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7760 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7761 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7764 case OPC2_32_RRR1_MSUB_H_LL
:
7767 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7768 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7770 case OPC2_32_RRR1_MSUB_H_LU
:
7773 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7774 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7776 case OPC2_32_RRR1_MSUB_H_UL
:
7779 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7780 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7782 case OPC2_32_RRR1_MSUB_H_UU
:
7785 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7786 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7788 case OPC2_32_RRR1_MSUBS_H_LL
:
7791 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7792 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7794 case OPC2_32_RRR1_MSUBS_H_LU
:
7797 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7798 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7800 case OPC2_32_RRR1_MSUBS_H_UL
:
7803 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7804 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7806 case OPC2_32_RRR1_MSUBS_H_UU
:
7809 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7810 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7812 case OPC2_32_RRR1_MSUBM_H_LL
:
7815 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7816 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7818 case OPC2_32_RRR1_MSUBM_H_LU
:
7821 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7822 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7824 case OPC2_32_RRR1_MSUBM_H_UL
:
7827 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7828 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7830 case OPC2_32_RRR1_MSUBM_H_UU
:
7833 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7834 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7836 case OPC2_32_RRR1_MSUBMS_H_LL
:
7839 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7840 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7842 case OPC2_32_RRR1_MSUBMS_H_LU
:
7845 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7846 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7848 case OPC2_32_RRR1_MSUBMS_H_UL
:
7851 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7852 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7854 case OPC2_32_RRR1_MSUBMS_H_UU
:
7857 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7858 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7860 case OPC2_32_RRR1_MSUBR_H_LL
:
7861 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7862 cpu_gpr_d
[r2
], n
, MODE_LL
);
7864 case OPC2_32_RRR1_MSUBR_H_LU
:
7865 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7866 cpu_gpr_d
[r2
], n
, MODE_LU
);
7868 case OPC2_32_RRR1_MSUBR_H_UL
:
7869 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7870 cpu_gpr_d
[r2
], n
, MODE_UL
);
7872 case OPC2_32_RRR1_MSUBR_H_UU
:
7873 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7874 cpu_gpr_d
[r2
], n
, MODE_UU
);
7876 case OPC2_32_RRR1_MSUBRS_H_LL
:
7877 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7878 cpu_gpr_d
[r2
], n
, MODE_LL
);
7880 case OPC2_32_RRR1_MSUBRS_H_LU
:
7881 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7882 cpu_gpr_d
[r2
], n
, MODE_LU
);
7884 case OPC2_32_RRR1_MSUBRS_H_UL
:
7885 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7886 cpu_gpr_d
[r2
], n
, MODE_UL
);
7888 case OPC2_32_RRR1_MSUBRS_H_UU
:
7889 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7890 cpu_gpr_d
[r2
], n
, MODE_UU
);
7893 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7897 static void decode_rrr1_msubq_h(DisasContext
*ctx
)
7900 uint32_t r1
, r2
, r3
, r4
, n
;
7903 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7904 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7905 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7906 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7907 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7908 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7910 temp
= tcg_const_i32(n
);
7911 temp2
= tcg_temp_new();
7914 case OPC2_32_RRR1_MSUB_Q_32
:
7915 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7916 cpu_gpr_d
[r2
], n
, 32);
7918 case OPC2_32_RRR1_MSUB_Q_64
:
7921 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7922 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7925 case OPC2_32_RRR1_MSUB_Q_32_L
:
7926 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7927 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7930 case OPC2_32_RRR1_MSUB_Q_64_L
:
7933 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7934 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7935 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7938 case OPC2_32_RRR1_MSUB_Q_32_U
:
7939 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7940 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7943 case OPC2_32_RRR1_MSUB_Q_64_U
:
7946 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7947 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7948 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7951 case OPC2_32_RRR1_MSUB_Q_32_LL
:
7952 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7953 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7954 gen_m16sub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7956 case OPC2_32_RRR1_MSUB_Q_64_LL
:
7959 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7960 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7961 gen_m16sub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7962 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7964 case OPC2_32_RRR1_MSUB_Q_32_UU
:
7965 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7966 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7967 gen_m16sub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7969 case OPC2_32_RRR1_MSUB_Q_64_UU
:
7972 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7973 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7974 gen_m16sub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7975 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7977 case OPC2_32_RRR1_MSUBS_Q_32
:
7978 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7979 cpu_gpr_d
[r2
], n
, 32);
7981 case OPC2_32_RRR1_MSUBS_Q_64
:
7984 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7985 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7988 case OPC2_32_RRR1_MSUBS_Q_32_L
:
7989 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7990 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7993 case OPC2_32_RRR1_MSUBS_Q_64_L
:
7996 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7997 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7998 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
8001 case OPC2_32_RRR1_MSUBS_Q_32_U
:
8002 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
8003 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8006 case OPC2_32_RRR1_MSUBS_Q_64_U
:
8009 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
8010 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8011 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
8014 case OPC2_32_RRR1_MSUBS_Q_32_LL
:
8015 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
8016 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
8017 gen_m16subs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8019 case OPC2_32_RRR1_MSUBS_Q_64_LL
:
8022 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
8023 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
8024 gen_m16subs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8025 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
8027 case OPC2_32_RRR1_MSUBS_Q_32_UU
:
8028 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
8029 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
8030 gen_m16subs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8032 case OPC2_32_RRR1_MSUBS_Q_64_UU
:
8035 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
8036 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
8037 gen_m16subs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8038 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
8040 case OPC2_32_RRR1_MSUBR_H_64_UL
:
8042 gen_msubr64_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
8043 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
8045 case OPC2_32_RRR1_MSUBRS_H_64_UL
:
8047 gen_msubr64s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
8048 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
8050 case OPC2_32_RRR1_MSUBR_Q_32_LL
:
8051 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
8052 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
8053 gen_msubr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8055 case OPC2_32_RRR1_MSUBR_Q_32_UU
:
8056 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
8057 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
8058 gen_msubr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8060 case OPC2_32_RRR1_MSUBRS_Q_32_LL
:
8061 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
8062 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
8063 gen_msubrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8065 case OPC2_32_RRR1_MSUBRS_Q_32_UU
:
8066 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
8067 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
8068 gen_msubrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
8071 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8073 tcg_temp_free(temp
);
8074 tcg_temp_free(temp2
);
8077 static void decode_rrr1_msubad_h(DisasContext
*ctx
)
8080 uint32_t r1
, r2
, r3
, r4
, n
;
8082 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
8083 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
8084 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
8085 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
8086 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
8087 n
= MASK_OP_RRR1_N(ctx
->opcode
);
8090 case OPC2_32_RRR1_MSUBAD_H_32_LL
:
8093 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8094 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
8096 case OPC2_32_RRR1_MSUBAD_H_32_LU
:
8099 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8100 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
8102 case OPC2_32_RRR1_MSUBAD_H_32_UL
:
8105 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8106 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
8108 case OPC2_32_RRR1_MSUBAD_H_32_UU
:
8111 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8112 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
8114 case OPC2_32_RRR1_MSUBADS_H_32_LL
:
8117 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8118 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8121 case OPC2_32_RRR1_MSUBADS_H_32_LU
:
8124 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8125 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8128 case OPC2_32_RRR1_MSUBADS_H_32_UL
:
8131 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8132 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8135 case OPC2_32_RRR1_MSUBADS_H_32_UU
:
8138 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8139 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8142 case OPC2_32_RRR1_MSUBADM_H_64_LL
:
8145 gen_msubadm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8146 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8149 case OPC2_32_RRR1_MSUBADM_H_64_LU
:
8152 gen_msubadm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8153 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8156 case OPC2_32_RRR1_MSUBADM_H_64_UL
:
8159 gen_msubadm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8160 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8163 case OPC2_32_RRR1_MSUBADM_H_64_UU
:
8166 gen_msubadm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8167 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8170 case OPC2_32_RRR1_MSUBADMS_H_64_LL
:
8173 gen_msubadms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8174 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8177 case OPC2_32_RRR1_MSUBADMS_H_64_LU
:
8180 gen_msubadms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8181 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8184 case OPC2_32_RRR1_MSUBADMS_H_64_UL
:
8187 gen_msubadms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8188 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8191 case OPC2_32_RRR1_MSUBADMS_H_64_UU
:
8194 gen_msubadms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
8195 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
8198 case OPC2_32_RRR1_MSUBADR_H_16_LL
:
8199 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8200 cpu_gpr_d
[r2
], n
, MODE_LL
);
8202 case OPC2_32_RRR1_MSUBADR_H_16_LU
:
8203 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8204 cpu_gpr_d
[r2
], n
, MODE_LU
);
8206 case OPC2_32_RRR1_MSUBADR_H_16_UL
:
8207 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8208 cpu_gpr_d
[r2
], n
, MODE_UL
);
8210 case OPC2_32_RRR1_MSUBADR_H_16_UU
:
8211 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8212 cpu_gpr_d
[r2
], n
, MODE_UU
);
8214 case OPC2_32_RRR1_MSUBADRS_H_16_LL
:
8215 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8216 cpu_gpr_d
[r2
], n
, MODE_LL
);
8218 case OPC2_32_RRR1_MSUBADRS_H_16_LU
:
8219 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8220 cpu_gpr_d
[r2
], n
, MODE_LU
);
8222 case OPC2_32_RRR1_MSUBADRS_H_16_UL
:
8223 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8224 cpu_gpr_d
[r2
], n
, MODE_UL
);
8226 case OPC2_32_RRR1_MSUBADRS_H_16_UU
:
8227 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
8228 cpu_gpr_d
[r2
], n
, MODE_UU
);
8231 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8236 static void decode_rrrr_extract_insert(DisasContext
*ctx
)
8240 TCGv tmp_width
, tmp_pos
;
8242 r1
= MASK_OP_RRRR_S1(ctx
->opcode
);
8243 r2
= MASK_OP_RRRR_S2(ctx
->opcode
);
8244 r3
= MASK_OP_RRRR_S3(ctx
->opcode
);
8245 r4
= MASK_OP_RRRR_D(ctx
->opcode
);
8246 op2
= MASK_OP_RRRR_OP2(ctx
->opcode
);
8248 tmp_pos
= tcg_temp_new();
8249 tmp_width
= tcg_temp_new();
8252 case OPC2_32_RRRR_DEXTR
:
8253 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
8255 tcg_gen_rotl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], tmp_pos
);
8257 tcg_gen_shl_tl(tmp_width
, cpu_gpr_d
[r1
], tmp_pos
);
8258 tcg_gen_subfi_tl(tmp_pos
, 32, tmp_pos
);
8259 tcg_gen_shr_tl(tmp_pos
, cpu_gpr_d
[r2
], tmp_pos
);
8260 tcg_gen_or_tl(cpu_gpr_d
[r4
], tmp_width
, tmp_pos
);
8263 case OPC2_32_RRRR_EXTR
:
8264 case OPC2_32_RRRR_EXTR_U
:
8266 tcg_gen_andi_tl(tmp_width
, cpu_gpr_d
[r3
+1], 0x1f);
8267 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
8268 tcg_gen_add_tl(tmp_pos
, tmp_pos
, tmp_width
);
8269 tcg_gen_subfi_tl(tmp_pos
, 32, tmp_pos
);
8270 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], tmp_pos
);
8271 tcg_gen_subfi_tl(tmp_width
, 32, tmp_width
);
8272 if (op2
== OPC2_32_RRRR_EXTR
) {
8273 tcg_gen_sar_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], tmp_width
);
8275 tcg_gen_shr_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], tmp_width
);
8278 case OPC2_32_RRRR_INSERT
:
8280 tcg_gen_andi_tl(tmp_width
, cpu_gpr_d
[r3
+1], 0x1f);
8281 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
8282 gen_insert(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], tmp_width
,
8286 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8288 tcg_temp_free(tmp_pos
);
8289 tcg_temp_free(tmp_width
);
8293 static void decode_rrrw_extract_insert(DisasContext
*ctx
)
8301 op2
= MASK_OP_RRRW_OP2(ctx
->opcode
);
8302 r1
= MASK_OP_RRRW_S1(ctx
->opcode
);
8303 r2
= MASK_OP_RRRW_S2(ctx
->opcode
);
8304 r3
= MASK_OP_RRRW_S3(ctx
->opcode
);
8305 r4
= MASK_OP_RRRW_D(ctx
->opcode
);
8306 width
= MASK_OP_RRRW_WIDTH(ctx
->opcode
);
8308 temp
= tcg_temp_new();
8311 case OPC2_32_RRRW_EXTR
:
8312 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
8313 tcg_gen_addi_tl(temp
, temp
, width
);
8314 tcg_gen_subfi_tl(temp
, 32, temp
);
8315 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], temp
);
8316 tcg_gen_sari_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], 32 - width
);
8318 case OPC2_32_RRRW_EXTR_U
:
8320 tcg_gen_movi_tl(cpu_gpr_d
[r4
], 0);
8322 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
8323 tcg_gen_shr_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], temp
);
8324 tcg_gen_andi_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], ~0u >> (32-width
));
8327 case OPC2_32_RRRW_IMASK
:
8328 temp2
= tcg_temp_new();
8330 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
8331 tcg_gen_movi_tl(temp2
, (1 << width
) - 1);
8332 tcg_gen_shl_tl(temp2
, temp2
, temp
);
8333 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r2
], temp
);
8334 tcg_gen_mov_tl(cpu_gpr_d
[r4
+1], temp2
);
8336 tcg_temp_free(temp2
);
8338 case OPC2_32_RRRW_INSERT
:
8339 temp2
= tcg_temp_new();
8341 tcg_gen_movi_tl(temp
, width
);
8342 tcg_gen_andi_tl(temp2
, cpu_gpr_d
[r3
], 0x1f);
8343 gen_insert(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], temp
, temp2
);
8345 tcg_temp_free(temp2
);
8348 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8350 tcg_temp_free(temp
);
8354 static void decode_sys_interrupts(DisasContext
*ctx
)
8361 op2
= MASK_OP_SYS_OP2(ctx
->opcode
);
8362 r1
= MASK_OP_SYS_S1D(ctx
->opcode
);
8365 case OPC2_32_SYS_DEBUG
:
8366 /* raise EXCP_DEBUG */
8368 case OPC2_32_SYS_DISABLE
:
8369 tcg_gen_andi_tl(cpu_ICR
, cpu_ICR
, ~MASK_ICR_IE_1_3
);
8371 case OPC2_32_SYS_DSYNC
:
8373 case OPC2_32_SYS_ENABLE
:
8374 tcg_gen_ori_tl(cpu_ICR
, cpu_ICR
, MASK_ICR_IE_1_3
);
8376 case OPC2_32_SYS_ISYNC
:
8378 case OPC2_32_SYS_NOP
:
8380 case OPC2_32_SYS_RET
:
8381 gen_compute_branch(ctx
, op2
, 0, 0, 0, 0);
8383 case OPC2_32_SYS_FRET
:
8386 case OPC2_32_SYS_RFE
:
8387 gen_helper_rfe(cpu_env
);
8388 tcg_gen_exit_tb(NULL
, 0);
8389 ctx
->base
.is_jmp
= DISAS_NORETURN
;
8391 case OPC2_32_SYS_RFM
:
8392 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
) {
8393 tmp
= tcg_temp_new();
8394 l1
= gen_new_label();
8396 tcg_gen_ld32u_tl(tmp
, cpu_env
, offsetof(CPUTriCoreState
, DBGSR
));
8397 tcg_gen_andi_tl(tmp
, tmp
, MASK_DBGSR_DE
);
8398 tcg_gen_brcondi_tl(TCG_COND_NE
, tmp
, 1, l1
);
8399 gen_helper_rfm(cpu_env
);
8401 tcg_gen_exit_tb(NULL
, 0);
8402 ctx
->base
.is_jmp
= DISAS_NORETURN
;
8405 /* generate privilege trap */
8408 case OPC2_32_SYS_RSLCX
:
8409 gen_helper_rslcx(cpu_env
);
8411 case OPC2_32_SYS_SVLCX
:
8412 gen_helper_svlcx(cpu_env
);
8414 case OPC2_32_SYS_RESTORE
:
8415 if (tricore_feature(ctx
->env
, TRICORE_FEATURE_16
)) {
8416 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
||
8417 (ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_UM1
) {
8418 tcg_gen_deposit_tl(cpu_ICR
, cpu_ICR
, cpu_gpr_d
[r1
], 8, 1);
8419 } /* else raise privilege trap */
8421 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8424 case OPC2_32_SYS_TRAPSV
:
8425 l1
= gen_new_label();
8426 tcg_gen_brcondi_tl(TCG_COND_GE
, cpu_PSW_SV
, 0, l1
);
8427 generate_trap(ctx
, TRAPC_ASSERT
, TIN5_SOVF
);
8430 case OPC2_32_SYS_TRAPV
:
8431 l1
= gen_new_label();
8432 tcg_gen_brcondi_tl(TCG_COND_GE
, cpu_PSW_V
, 0, l1
);
8433 generate_trap(ctx
, TRAPC_ASSERT
, TIN5_OVF
);
8437 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8441 static void decode_32Bit_opc(DisasContext
*ctx
)
8445 int32_t address
, const16
;
8448 TCGv temp
, temp2
, temp3
;
8450 op1
= MASK_OP_MAJOR(ctx
->opcode
);
8452 /* handle JNZ.T opcode only being 7 bit long */
8453 if (unlikely((op1
& 0x7f) == OPCM_32_BRN_JTT
)) {
8454 op1
= OPCM_32_BRN_JTT
;
8459 case OPCM_32_ABS_LDW
:
8460 decode_abs_ldw(ctx
);
8462 case OPCM_32_ABS_LDB
:
8463 decode_abs_ldb(ctx
);
8465 case OPCM_32_ABS_LDMST_SWAP
:
8466 decode_abs_ldst_swap(ctx
);
8468 case OPCM_32_ABS_LDST_CONTEXT
:
8469 decode_abs_ldst_context(ctx
);
8471 case OPCM_32_ABS_STORE
:
8472 decode_abs_store(ctx
);
8474 case OPCM_32_ABS_STOREB_H
:
8475 decode_abs_storeb_h(ctx
);
8477 case OPC1_32_ABS_STOREQ
:
8478 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
8479 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
8480 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
8481 temp2
= tcg_temp_new();
8483 tcg_gen_shri_tl(temp2
, cpu_gpr_d
[r1
], 16);
8484 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_LEUW
);
8486 tcg_temp_free(temp2
);
8487 tcg_temp_free(temp
);
8489 case OPC1_32_ABS_LD_Q
:
8490 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
8491 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
8492 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
8494 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
8495 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
8497 tcg_temp_free(temp
);
8499 case OPC1_32_ABS_LEA
:
8500 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
8501 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
8502 tcg_gen_movi_tl(cpu_gpr_a
[r1
], EA_ABS_FORMAT(address
));
8505 case OPC1_32_ABSB_ST_T
:
8506 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
8507 b
= MASK_OP_ABSB_B(ctx
->opcode
);
8508 bpos
= MASK_OP_ABSB_BPOS(ctx
->opcode
);
8510 temp
= tcg_const_i32(EA_ABS_FORMAT(address
));
8511 temp2
= tcg_temp_new();
8513 tcg_gen_qemu_ld_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
8514 tcg_gen_andi_tl(temp2
, temp2
, ~(0x1u
<< bpos
));
8515 tcg_gen_ori_tl(temp2
, temp2
, (b
<< bpos
));
8516 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
8518 tcg_temp_free(temp
);
8519 tcg_temp_free(temp2
);
8522 case OPC1_32_B_CALL
:
8523 case OPC1_32_B_CALLA
:
8524 case OPC1_32_B_FCALL
:
8525 case OPC1_32_B_FCALLA
:
8530 address
= MASK_OP_B_DISP24_SEXT(ctx
->opcode
);
8531 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
8534 case OPCM_32_BIT_ANDACC
:
8535 decode_bit_andacc(ctx
);
8537 case OPCM_32_BIT_LOGICAL_T1
:
8538 decode_bit_logical_t(ctx
);
8540 case OPCM_32_BIT_INSERT
:
8541 decode_bit_insert(ctx
);
8543 case OPCM_32_BIT_LOGICAL_T2
:
8544 decode_bit_logical_t2(ctx
);
8546 case OPCM_32_BIT_ORAND
:
8547 decode_bit_orand(ctx
);
8549 case OPCM_32_BIT_SH_LOGIC1
:
8550 decode_bit_sh_logic1(ctx
);
8552 case OPCM_32_BIT_SH_LOGIC2
:
8553 decode_bit_sh_logic2(ctx
);
8556 case OPCM_32_BO_ADDRMODE_POST_PRE_BASE
:
8557 decode_bo_addrmode_post_pre_base(ctx
);
8559 case OPCM_32_BO_ADDRMODE_BITREVERSE_CIRCULAR
:
8560 decode_bo_addrmode_bitreverse_circular(ctx
);
8562 case OPCM_32_BO_ADDRMODE_LD_POST_PRE_BASE
:
8563 decode_bo_addrmode_ld_post_pre_base(ctx
);
8565 case OPCM_32_BO_ADDRMODE_LD_BITREVERSE_CIRCULAR
:
8566 decode_bo_addrmode_ld_bitreverse_circular(ctx
);
8568 case OPCM_32_BO_ADDRMODE_STCTX_POST_PRE_BASE
:
8569 decode_bo_addrmode_stctx_post_pre_base(ctx
);
8571 case OPCM_32_BO_ADDRMODE_LDMST_BITREVERSE_CIRCULAR
:
8572 decode_bo_addrmode_ldmst_bitreverse_circular(ctx
);
8575 case OPC1_32_BOL_LD_A_LONGOFF
:
8576 case OPC1_32_BOL_LD_W_LONGOFF
:
8577 case OPC1_32_BOL_LEA_LONGOFF
:
8578 case OPC1_32_BOL_ST_W_LONGOFF
:
8579 case OPC1_32_BOL_ST_A_LONGOFF
:
8580 case OPC1_32_BOL_LD_B_LONGOFF
:
8581 case OPC1_32_BOL_LD_BU_LONGOFF
:
8582 case OPC1_32_BOL_LD_H_LONGOFF
:
8583 case OPC1_32_BOL_LD_HU_LONGOFF
:
8584 case OPC1_32_BOL_ST_B_LONGOFF
:
8585 case OPC1_32_BOL_ST_H_LONGOFF
:
8586 decode_bol_opc(ctx
, op1
);
8589 case OPCM_32_BRC_EQ_NEQ
:
8590 case OPCM_32_BRC_GE
:
8591 case OPCM_32_BRC_JLT
:
8592 case OPCM_32_BRC_JNE
:
8593 const4
= MASK_OP_BRC_CONST4_SEXT(ctx
->opcode
);
8594 address
= MASK_OP_BRC_DISP15_SEXT(ctx
->opcode
);
8595 r1
= MASK_OP_BRC_S1(ctx
->opcode
);
8596 gen_compute_branch(ctx
, op1
, r1
, 0, const4
, address
);
8599 case OPCM_32_BRN_JTT
:
8600 address
= MASK_OP_BRN_DISP15_SEXT(ctx
->opcode
);
8601 r1
= MASK_OP_BRN_S1(ctx
->opcode
);
8602 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
8605 case OPCM_32_BRR_EQ_NEQ
:
8606 case OPCM_32_BRR_ADDR_EQ_NEQ
:
8607 case OPCM_32_BRR_GE
:
8608 case OPCM_32_BRR_JLT
:
8609 case OPCM_32_BRR_JNE
:
8610 case OPCM_32_BRR_JNZ
:
8611 case OPCM_32_BRR_LOOP
:
8612 address
= MASK_OP_BRR_DISP15_SEXT(ctx
->opcode
);
8613 r2
= MASK_OP_BRR_S2(ctx
->opcode
);
8614 r1
= MASK_OP_BRR_S1(ctx
->opcode
);
8615 gen_compute_branch(ctx
, op1
, r1
, r2
, 0, address
);
8618 case OPCM_32_RC_LOGICAL_SHIFT
:
8619 decode_rc_logical_shift(ctx
);
8621 case OPCM_32_RC_ACCUMULATOR
:
8622 decode_rc_accumulator(ctx
);
8624 case OPCM_32_RC_SERVICEROUTINE
:
8625 decode_rc_serviceroutine(ctx
);
8627 case OPCM_32_RC_MUL
:
8631 case OPCM_32_RCPW_MASK_INSERT
:
8632 decode_rcpw_insert(ctx
);
8635 case OPC1_32_RCRR_INSERT
:
8636 r1
= MASK_OP_RCRR_S1(ctx
->opcode
);
8637 r2
= MASK_OP_RCRR_S3(ctx
->opcode
);
8638 r3
= MASK_OP_RCRR_D(ctx
->opcode
);
8639 const16
= MASK_OP_RCRR_CONST4(ctx
->opcode
);
8640 temp
= tcg_const_i32(const16
);
8641 temp2
= tcg_temp_new(); /* width*/
8642 temp3
= tcg_temp_new(); /* pos */
8646 tcg_gen_andi_tl(temp2
, cpu_gpr_d
[r3
+1], 0x1f);
8647 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r3
], 0x1f);
8649 gen_insert(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, temp2
, temp3
);
8651 tcg_temp_free(temp
);
8652 tcg_temp_free(temp2
);
8653 tcg_temp_free(temp3
);
8656 case OPCM_32_RCRW_MASK_INSERT
:
8657 decode_rcrw_insert(ctx
);
8660 case OPCM_32_RCR_COND_SELECT
:
8661 decode_rcr_cond_select(ctx
);
8663 case OPCM_32_RCR_MADD
:
8664 decode_rcr_madd(ctx
);
8666 case OPCM_32_RCR_MSUB
:
8667 decode_rcr_msub(ctx
);
8670 case OPC1_32_RLC_ADDI
:
8671 case OPC1_32_RLC_ADDIH
:
8672 case OPC1_32_RLC_ADDIH_A
:
8673 case OPC1_32_RLC_MFCR
:
8674 case OPC1_32_RLC_MOV
:
8675 case OPC1_32_RLC_MOV_64
:
8676 case OPC1_32_RLC_MOV_U
:
8677 case OPC1_32_RLC_MOV_H
:
8678 case OPC1_32_RLC_MOVH_A
:
8679 case OPC1_32_RLC_MTCR
:
8680 decode_rlc_opc(ctx
, op1
);
8683 case OPCM_32_RR_ACCUMULATOR
:
8684 decode_rr_accumulator(ctx
);
8686 case OPCM_32_RR_LOGICAL_SHIFT
:
8687 decode_rr_logical_shift(ctx
);
8689 case OPCM_32_RR_ADDRESS
:
8690 decode_rr_address(ctx
);
8692 case OPCM_32_RR_IDIRECT
:
8693 decode_rr_idirect(ctx
);
8695 case OPCM_32_RR_DIVIDE
:
8696 decode_rr_divide(ctx
);
8699 case OPCM_32_RR1_MUL
:
8700 decode_rr1_mul(ctx
);
8702 case OPCM_32_RR1_MULQ
:
8703 decode_rr1_mulq(ctx
);
8706 case OPCM_32_RR2_MUL
:
8707 decode_rr2_mul(ctx
);
8710 case OPCM_32_RRPW_EXTRACT_INSERT
:
8711 decode_rrpw_extract_insert(ctx
);
8713 case OPC1_32_RRPW_DEXTR
:
8714 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
8715 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
8716 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
8717 const16
= MASK_OP_RRPW_POS(ctx
->opcode
);
8719 tcg_gen_rotli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], const16
);
8721 temp
= tcg_temp_new();
8722 tcg_gen_shli_tl(temp
, cpu_gpr_d
[r1
], const16
);
8723 tcg_gen_shri_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], 32 - const16
);
8724 tcg_gen_or_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
8725 tcg_temp_free(temp
);
8729 case OPCM_32_RRR_COND_SELECT
:
8730 decode_rrr_cond_select(ctx
);
8732 case OPCM_32_RRR_DIVIDE
:
8733 decode_rrr_divide(ctx
);
8736 case OPCM_32_RRR2_MADD
:
8737 decode_rrr2_madd(ctx
);
8739 case OPCM_32_RRR2_MSUB
:
8740 decode_rrr2_msub(ctx
);
8743 case OPCM_32_RRR1_MADD
:
8744 decode_rrr1_madd(ctx
);
8746 case OPCM_32_RRR1_MADDQ_H
:
8747 decode_rrr1_maddq_h(ctx
);
8749 case OPCM_32_RRR1_MADDSU_H
:
8750 decode_rrr1_maddsu_h(ctx
);
8752 case OPCM_32_RRR1_MSUB_H
:
8753 decode_rrr1_msub(ctx
);
8755 case OPCM_32_RRR1_MSUB_Q
:
8756 decode_rrr1_msubq_h(ctx
);
8758 case OPCM_32_RRR1_MSUBAD_H
:
8759 decode_rrr1_msubad_h(ctx
);
8762 case OPCM_32_RRRR_EXTRACT_INSERT
:
8763 decode_rrrr_extract_insert(ctx
);
8766 case OPCM_32_RRRW_EXTRACT_INSERT
:
8767 decode_rrrw_extract_insert(ctx
);
8770 case OPCM_32_SYS_INTERRUPTS
:
8771 decode_sys_interrupts(ctx
);
8773 case OPC1_32_SYS_RSTV
:
8774 tcg_gen_movi_tl(cpu_PSW_V
, 0);
8775 tcg_gen_mov_tl(cpu_PSW_SV
, cpu_PSW_V
);
8776 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
8777 tcg_gen_mov_tl(cpu_PSW_SAV
, cpu_PSW_V
);
8780 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8784 static bool tricore_insn_is_16bit(uint32_t insn
)
8786 return (insn
& 0x1) == 0;
8789 static void tricore_tr_init_disas_context(DisasContextBase
*dcbase
,
8792 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8793 CPUTriCoreState
*env
= cs
->env_ptr
;
8794 ctx
->mem_idx
= cpu_mmu_index(env
, false);
8795 ctx
->hflags
= (uint32_t)ctx
->base
.tb
->flags
;
8798 static void tricore_tr_tb_start(DisasContextBase
*db
, CPUState
*cpu
)
8802 static void tricore_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
8804 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8806 tcg_gen_insn_start(ctx
->base
.pc_next
);
8809 static bool tricore_tr_breakpoint_check(DisasContextBase
*dcbase
, CPUState
*cpu
,
8810 const CPUBreakpoint
*bp
)
8812 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8813 generate_qemu_excp(ctx
, EXCP_DEBUG
);
8815 * The address covered by the breakpoint must be included in
8816 * [tb->pc, tb->pc + tb->size) in order to for it to be
8817 * properly cleared -- thus we increment the PC here so that
8818 * the logic setting tb->size below does the right thing.
8820 ctx
->base
.pc_next
+= 4;
8824 static bool insn_crosses_page(CPUTriCoreState
*env
, DisasContext
*ctx
)
8827 * Return true if the insn at ctx->base.pc_next might cross a page boundary.
8828 * (False positives are OK, false negatives are not.)
8829 * Our caller ensures we are only called if dc->base.pc_next is less than
8830 * 4 bytes from the page boundary, so we cross the page if the first
8831 * 16 bits indicate that this is a 32 bit insn.
8833 uint16_t insn
= cpu_lduw_code(env
, ctx
->base
.pc_next
);
8835 return !tricore_insn_is_16bit(insn
);
8839 static void tricore_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cpu
)
8841 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8842 CPUTriCoreState
*env
= cpu
->env_ptr
;
8846 insn_lo
= cpu_lduw_code(env
, ctx
->base
.pc_next
);
8847 is_16bit
= tricore_insn_is_16bit(insn_lo
);
8849 ctx
->opcode
= insn_lo
;
8850 ctx
->pc_succ_insn
= ctx
->base
.pc_next
+ 2;
8851 decode_16Bit_opc(ctx
);
8853 uint32_t insn_hi
= cpu_lduw_code(env
, ctx
->base
.pc_next
+ 2);
8854 ctx
->opcode
= insn_hi
<< 16 | insn_lo
;
8855 ctx
->pc_succ_insn
= ctx
->base
.pc_next
+ 4;
8856 decode_32Bit_opc(ctx
);
8858 ctx
->base
.pc_next
= ctx
->pc_succ_insn
;
8860 if (ctx
->base
.is_jmp
== DISAS_NEXT
) {
8861 target_ulong page_start
;
8863 page_start
= ctx
->base
.pc_first
& TARGET_PAGE_MASK
;
8864 if (ctx
->base
.pc_next
- page_start
>= TARGET_PAGE_SIZE
8865 || (ctx
->base
.pc_next
- page_start
>= TARGET_PAGE_SIZE
- 3
8866 && insn_crosses_page(env
, ctx
))) {
8867 ctx
->base
.is_jmp
= DISAS_TOO_MANY
;
8872 static void tricore_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cpu
)
8874 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8876 switch (ctx
->base
.is_jmp
) {
8877 case DISAS_TOO_MANY
:
8878 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
);
8880 case DISAS_NORETURN
:
8883 g_assert_not_reached();
8887 static void tricore_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cpu
)
8889 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
8890 log_target_disas(cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
8893 static const TranslatorOps tricore_tr_ops
= {
8894 .init_disas_context
= tricore_tr_init_disas_context
,
8895 .tb_start
= tricore_tr_tb_start
,
8896 .insn_start
= tricore_tr_insn_start
,
8897 .breakpoint_check
= tricore_tr_breakpoint_check
,
8898 .translate_insn
= tricore_tr_translate_insn
,
8899 .tb_stop
= tricore_tr_tb_stop
,
8900 .disas_log
= tricore_tr_disas_log
,
8904 void gen_intermediate_code(CPUState
*cs
, TranslationBlock
*tb
, int max_insns
)
8907 translator_loop(&tricore_tr_ops
, &ctx
.base
, cs
, tb
, max_insns
);
8911 restore_state_to_opc(CPUTriCoreState
*env
, TranslationBlock
*tb
,
8922 void cpu_state_reset(CPUTriCoreState
*env
)
8924 /* Reset Regs to Default Value */
8929 static void tricore_tcg_init_csfr(void)
8931 cpu_PCXI
= tcg_global_mem_new(cpu_env
,
8932 offsetof(CPUTriCoreState
, PCXI
), "PCXI");
8933 cpu_PSW
= tcg_global_mem_new(cpu_env
,
8934 offsetof(CPUTriCoreState
, PSW
), "PSW");
8935 cpu_PC
= tcg_global_mem_new(cpu_env
,
8936 offsetof(CPUTriCoreState
, PC
), "PC");
8937 cpu_ICR
= tcg_global_mem_new(cpu_env
,
8938 offsetof(CPUTriCoreState
, ICR
), "ICR");
8941 void tricore_tcg_init(void)
8946 for (i
= 0 ; i
< 16 ; i
++) {
8947 cpu_gpr_a
[i
] = tcg_global_mem_new(cpu_env
,
8948 offsetof(CPUTriCoreState
, gpr_a
[i
]),
8951 for (i
= 0 ; i
< 16 ; i
++) {
8952 cpu_gpr_d
[i
] = tcg_global_mem_new(cpu_env
,
8953 offsetof(CPUTriCoreState
, gpr_d
[i
]),
8956 tricore_tcg_init_csfr();
8957 /* init PSW flag cache */
8958 cpu_PSW_C
= tcg_global_mem_new(cpu_env
,
8959 offsetof(CPUTriCoreState
, PSW_USB_C
),
8961 cpu_PSW_V
= tcg_global_mem_new(cpu_env
,
8962 offsetof(CPUTriCoreState
, PSW_USB_V
),
8964 cpu_PSW_SV
= tcg_global_mem_new(cpu_env
,
8965 offsetof(CPUTriCoreState
, PSW_USB_SV
),
8967 cpu_PSW_AV
= tcg_global_mem_new(cpu_env
,
8968 offsetof(CPUTriCoreState
, PSW_USB_AV
),
8970 cpu_PSW_SAV
= tcg_global_mem_new(cpu_env
,
8971 offsetof(CPUTriCoreState
, PSW_USB_SAV
),