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
;
69 target_ulong pc_succ_insn
;
71 /* Routine used to access memory */
73 uint32_t hflags
, saved_hflags
;
77 static int has_feature(DisasContext
*ctx
, int feature
)
79 return (ctx
->features
& (1ULL << feature
)) != 0;
89 void tricore_cpu_dump_state(CPUState
*cs
, FILE *f
, int flags
)
91 TriCoreCPU
*cpu
= TRICORE_CPU(cs
);
92 CPUTriCoreState
*env
= &cpu
->env
;
98 qemu_fprintf(f
, "PC: " TARGET_FMT_lx
, env
->PC
);
99 qemu_fprintf(f
, " PSW: " TARGET_FMT_lx
, psw
);
100 qemu_fprintf(f
, " ICR: " TARGET_FMT_lx
, env
->ICR
);
101 qemu_fprintf(f
, "\nPCXI: " TARGET_FMT_lx
, env
->PCXI
);
102 qemu_fprintf(f
, " FCX: " TARGET_FMT_lx
, env
->FCX
);
103 qemu_fprintf(f
, " LCX: " TARGET_FMT_lx
, env
->LCX
);
105 for (i
= 0; i
< 16; ++i
) {
107 qemu_fprintf(f
, "\nGPR A%02d:", i
);
109 qemu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_a
[i
]);
111 for (i
= 0; i
< 16; ++i
) {
113 qemu_fprintf(f
, "\nGPR D%02d:", i
);
115 qemu_fprintf(f
, " " TARGET_FMT_lx
, env
->gpr_d
[i
]);
117 qemu_fprintf(f
, "\n");
121 * Functions to generate micro-ops
124 /* Makros for generating helpers */
126 #define gen_helper_1arg(name, arg) do { \
127 TCGv_i32 helper_tmp = tcg_constant_i32(arg); \
128 gen_helper_##name(cpu_env, helper_tmp); \
131 #define GEN_HELPER_LL(name, ret, arg0, arg1, n) do { \
132 TCGv arg00 = tcg_temp_new(); \
133 TCGv arg01 = tcg_temp_new(); \
134 TCGv arg11 = tcg_temp_new(); \
135 tcg_gen_sari_tl(arg00, arg0, 16); \
136 tcg_gen_ext16s_tl(arg01, arg0); \
137 tcg_gen_ext16s_tl(arg11, arg1); \
138 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
141 #define GEN_HELPER_LU(name, ret, arg0, arg1, n) do { \
142 TCGv arg00 = tcg_temp_new(); \
143 TCGv arg01 = tcg_temp_new(); \
144 TCGv arg10 = tcg_temp_new(); \
145 TCGv arg11 = tcg_temp_new(); \
146 tcg_gen_sari_tl(arg00, arg0, 16); \
147 tcg_gen_ext16s_tl(arg01, arg0); \
148 tcg_gen_sari_tl(arg11, arg1, 16); \
149 tcg_gen_ext16s_tl(arg10, arg1); \
150 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
153 #define GEN_HELPER_UL(name, ret, arg0, arg1, n) do { \
154 TCGv arg00 = tcg_temp_new(); \
155 TCGv arg01 = tcg_temp_new(); \
156 TCGv arg10 = tcg_temp_new(); \
157 TCGv arg11 = tcg_temp_new(); \
158 tcg_gen_sari_tl(arg00, arg0, 16); \
159 tcg_gen_ext16s_tl(arg01, arg0); \
160 tcg_gen_sari_tl(arg10, arg1, 16); \
161 tcg_gen_ext16s_tl(arg11, arg1); \
162 gen_helper_##name(ret, arg00, arg01, arg10, arg11, n); \
165 #define GEN_HELPER_UU(name, ret, arg0, arg1, n) do { \
166 TCGv arg00 = tcg_temp_new(); \
167 TCGv arg01 = tcg_temp_new(); \
168 TCGv arg11 = tcg_temp_new(); \
169 tcg_gen_sari_tl(arg01, arg0, 16); \
170 tcg_gen_ext16s_tl(arg00, arg0); \
171 tcg_gen_sari_tl(arg11, arg1, 16); \
172 gen_helper_##name(ret, arg00, arg01, arg11, arg11, n); \
175 #define GEN_HELPER_RRR(name, rl, rh, al1, ah1, arg2) do { \
176 TCGv_i64 ret = tcg_temp_new_i64(); \
177 TCGv_i64 arg1 = tcg_temp_new_i64(); \
179 tcg_gen_concat_i32_i64(arg1, al1, ah1); \
180 gen_helper_##name(ret, arg1, arg2); \
181 tcg_gen_extr_i64_i32(rl, rh, ret); \
184 #define GEN_HELPER_RR(name, rl, rh, arg1, arg2) do { \
185 TCGv_i64 ret = tcg_temp_new_i64(); \
187 gen_helper_##name(ret, cpu_env, arg1, arg2); \
188 tcg_gen_extr_i64_i32(rl, rh, ret); \
191 #define EA_ABS_FORMAT(con) (((con & 0x3C000) << 14) + (con & 0x3FFF))
192 #define EA_B_ABSOLUT(con) (((offset & 0xf00000) << 8) | \
193 ((offset & 0x0fffff) << 1))
195 /* For two 32-bit registers used a 64-bit register, the first
196 registernumber needs to be even. Otherwise we trap. */
197 static inline void generate_trap(DisasContext
*ctx
, int class, int tin
);
198 #define CHECK_REG_PAIR(reg) do { \
200 generate_trap(ctx, TRAPC_INSN_ERR, TIN2_OPD); \
204 /* Functions for load/save to/from memory */
206 static inline void gen_offset_ld(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
207 int16_t con
, MemOp mop
)
209 TCGv temp
= tcg_temp_new();
210 tcg_gen_addi_tl(temp
, r2
, con
);
211 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
214 static inline void gen_offset_st(DisasContext
*ctx
, TCGv r1
, TCGv r2
,
215 int16_t con
, MemOp mop
)
217 TCGv temp
= tcg_temp_new();
218 tcg_gen_addi_tl(temp
, r2
, con
);
219 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
222 static void gen_st_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
224 TCGv_i64 temp
= tcg_temp_new_i64();
226 tcg_gen_concat_i32_i64(temp
, rl
, rh
);
227 tcg_gen_qemu_st_i64(temp
, address
, ctx
->mem_idx
, MO_LEUQ
);
230 static void gen_offset_st_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
233 TCGv temp
= tcg_temp_new();
234 tcg_gen_addi_tl(temp
, base
, con
);
235 gen_st_2regs_64(rh
, rl
, temp
, ctx
);
238 static void gen_ld_2regs_64(TCGv rh
, TCGv rl
, TCGv address
, DisasContext
*ctx
)
240 TCGv_i64 temp
= tcg_temp_new_i64();
242 tcg_gen_qemu_ld_i64(temp
, address
, ctx
->mem_idx
, MO_LEUQ
);
243 /* write back to two 32 bit regs */
244 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
247 static void gen_offset_ld_2regs(TCGv rh
, TCGv rl
, TCGv base
, int16_t con
,
250 TCGv temp
= tcg_temp_new();
251 tcg_gen_addi_tl(temp
, base
, con
);
252 gen_ld_2regs_64(rh
, rl
, temp
, ctx
);
255 static void gen_st_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
258 TCGv temp
= tcg_temp_new();
259 tcg_gen_addi_tl(temp
, r2
, off
);
260 tcg_gen_qemu_st_tl(r1
, temp
, ctx
->mem_idx
, mop
);
261 tcg_gen_mov_tl(r2
, temp
);
264 static void gen_ld_preincr(DisasContext
*ctx
, TCGv r1
, TCGv r2
, int16_t off
,
267 TCGv temp
= tcg_temp_new();
268 tcg_gen_addi_tl(temp
, r2
, off
);
269 tcg_gen_qemu_ld_tl(r1
, temp
, ctx
->mem_idx
, mop
);
270 tcg_gen_mov_tl(r2
, temp
);
273 /* M(EA, word) = (M(EA, word) & ~E[a][63:32]) | (E[a][31:0] & E[a][63:32]); */
274 static void gen_ldmst(DisasContext
*ctx
, int ereg
, TCGv ea
)
276 TCGv temp
= tcg_temp_new();
277 TCGv temp2
= tcg_temp_new();
279 CHECK_REG_PAIR(ereg
);
280 /* temp = (M(EA, word) */
281 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
282 /* temp = temp & ~E[a][63:32]) */
283 tcg_gen_andc_tl(temp
, temp
, cpu_gpr_d
[ereg
+1]);
284 /* temp2 = (E[a][31:0] & E[a][63:32]); */
285 tcg_gen_and_tl(temp2
, cpu_gpr_d
[ereg
], cpu_gpr_d
[ereg
+1]);
286 /* temp = temp | temp2; */
287 tcg_gen_or_tl(temp
, temp
, temp2
);
288 /* M(EA, word) = temp; */
289 tcg_gen_qemu_st_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
292 /* tmp = M(EA, word);
295 static void gen_swap(DisasContext
*ctx
, int reg
, TCGv ea
)
297 TCGv temp
= tcg_temp_new();
299 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
300 tcg_gen_qemu_st_tl(cpu_gpr_d
[reg
], ea
, ctx
->mem_idx
, MO_LEUL
);
301 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
304 static void gen_cmpswap(DisasContext
*ctx
, int reg
, TCGv ea
)
306 TCGv temp
= tcg_temp_new();
307 TCGv temp2
= tcg_temp_new();
308 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
309 tcg_gen_movcond_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[reg
+1], temp
,
310 cpu_gpr_d
[reg
], temp
);
311 tcg_gen_qemu_st_tl(temp2
, ea
, ctx
->mem_idx
, MO_LEUL
);
312 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
315 static void gen_swapmsk(DisasContext
*ctx
, int reg
, TCGv ea
)
317 TCGv temp
= tcg_temp_new();
318 TCGv temp2
= tcg_temp_new();
319 TCGv temp3
= tcg_temp_new();
321 tcg_gen_qemu_ld_tl(temp
, ea
, ctx
->mem_idx
, MO_LEUL
);
322 tcg_gen_and_tl(temp2
, cpu_gpr_d
[reg
], cpu_gpr_d
[reg
+1]);
323 tcg_gen_andc_tl(temp3
, temp
, cpu_gpr_d
[reg
+1]);
324 tcg_gen_or_tl(temp2
, temp2
, temp3
);
325 tcg_gen_qemu_st_tl(temp2
, ea
, ctx
->mem_idx
, MO_LEUL
);
326 tcg_gen_mov_tl(cpu_gpr_d
[reg
], temp
);
330 /* We generate loads and store to core special function register (csfr) through
331 the function gen_mfcr and gen_mtcr. To handle access permissions, we use 3
332 makros R, A and E, which allow read-only, all and endinit protected access.
333 These makros also specify in which ISA version the csfr was introduced. */
334 #define R(ADDRESS, REG, FEATURE) \
336 if (has_feature(ctx, FEATURE)) { \
337 tcg_gen_ld_tl(ret, cpu_env, offsetof(CPUTriCoreState, REG)); \
340 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
341 #define E(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE)
342 static inline void gen_mfcr(DisasContext
*ctx
, TCGv ret
, int32_t offset
)
344 /* since we're caching PSW make this a special case */
345 if (offset
== 0xfe04) {
346 gen_helper_psw_read(ret
, cpu_env
);
349 #include "csfr.h.inc"
357 #define R(ADDRESS, REG, FEATURE) /* don't gen writes to read-only reg,
358 since no execption occurs */
359 #define A(ADDRESS, REG, FEATURE) R(ADDRESS, REG, FEATURE) \
361 if (has_feature(ctx, FEATURE)) { \
362 tcg_gen_st_tl(r1, cpu_env, offsetof(CPUTriCoreState, REG)); \
365 /* Endinit protected registers
366 TODO: Since the endinit bit is in a register of a not yet implemented
367 watchdog device, we handle endinit protected registers like
368 all-access registers for now. */
369 #define E(ADDRESS, REG, FEATURE) A(ADDRESS, REG, FEATURE)
370 static inline void gen_mtcr(DisasContext
*ctx
, TCGv r1
,
373 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
) {
374 /* since we're caching PSW make this a special case */
375 if (offset
== 0xfe04) {
376 gen_helper_psw_write(cpu_env
, r1
);
379 #include "csfr.h.inc"
383 /* generate privilege trap */
387 /* Functions for arithmetic instructions */
389 static inline void gen_add_d(TCGv ret
, TCGv r1
, TCGv r2
)
391 TCGv t0
= tcg_temp_new_i32();
392 TCGv result
= tcg_temp_new_i32();
393 /* Addition and set V/SV bits */
394 tcg_gen_add_tl(result
, r1
, r2
);
396 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
397 tcg_gen_xor_tl(t0
, r1
, r2
);
398 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
400 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
401 /* Calc AV/SAV bits */
402 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
403 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
405 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
406 /* write back result */
407 tcg_gen_mov_tl(ret
, result
);
411 gen_add64_d(TCGv_i64 ret
, TCGv_i64 r1
, TCGv_i64 r2
)
413 TCGv temp
= tcg_temp_new();
414 TCGv_i64 t0
= tcg_temp_new_i64();
415 TCGv_i64 t1
= tcg_temp_new_i64();
416 TCGv_i64 result
= tcg_temp_new_i64();
418 tcg_gen_add_i64(result
, r1
, r2
);
420 tcg_gen_xor_i64(t1
, result
, r1
);
421 tcg_gen_xor_i64(t0
, r1
, r2
);
422 tcg_gen_andc_i64(t1
, t1
, t0
);
423 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t1
);
425 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
426 /* calc AV/SAV bits */
427 tcg_gen_extrh_i64_i32(temp
, result
);
428 tcg_gen_add_tl(cpu_PSW_AV
, temp
, temp
);
429 tcg_gen_xor_tl(cpu_PSW_AV
, temp
, cpu_PSW_AV
);
431 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
432 /* write back result */
433 tcg_gen_mov_i64(ret
, result
);
437 gen_addsub64_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
438 TCGv r3
, void(*op1
)(TCGv
, TCGv
, TCGv
),
439 void(*op2
)(TCGv
, TCGv
, TCGv
))
441 TCGv temp
= tcg_temp_new();
442 TCGv temp2
= tcg_temp_new();
443 TCGv temp3
= tcg_temp_new();
444 TCGv temp4
= tcg_temp_new();
446 (*op1
)(temp
, r1_low
, r2
);
448 tcg_gen_xor_tl(temp2
, temp
, r1_low
);
449 tcg_gen_xor_tl(temp3
, r1_low
, r2
);
450 if (op1
== tcg_gen_add_tl
) {
451 tcg_gen_andc_tl(temp2
, temp2
, temp3
);
453 tcg_gen_and_tl(temp2
, temp2
, temp3
);
456 (*op2
)(temp3
, r1_high
, r3
);
458 tcg_gen_xor_tl(cpu_PSW_V
, temp3
, r1_high
);
459 tcg_gen_xor_tl(temp4
, r1_high
, r3
);
460 if (op2
== tcg_gen_add_tl
) {
461 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
463 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp4
);
465 /* combine V0/V1 bits */
466 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp2
);
468 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
470 tcg_gen_mov_tl(ret_low
, temp
);
471 tcg_gen_mov_tl(ret_high
, temp3
);
473 tcg_gen_add_tl(temp
, ret_low
, ret_low
);
474 tcg_gen_xor_tl(temp
, temp
, ret_low
);
475 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
476 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, ret_high
);
477 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
479 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
482 /* ret = r2 + (r1 * r3); */
483 static inline void gen_madd32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
485 TCGv_i64 t1
= tcg_temp_new_i64();
486 TCGv_i64 t2
= tcg_temp_new_i64();
487 TCGv_i64 t3
= tcg_temp_new_i64();
489 tcg_gen_ext_i32_i64(t1
, r1
);
490 tcg_gen_ext_i32_i64(t2
, r2
);
491 tcg_gen_ext_i32_i64(t3
, r3
);
493 tcg_gen_mul_i64(t1
, t1
, t3
);
494 tcg_gen_add_i64(t1
, t2
, t1
);
496 tcg_gen_extrl_i64_i32(ret
, t1
);
499 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
500 /* t1 < -0x80000000 */
501 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
502 tcg_gen_or_i64(t2
, t2
, t3
);
503 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
504 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
506 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
507 /* Calc AV/SAV bits */
508 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
509 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
511 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
514 static inline void gen_maddi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
516 TCGv temp
= tcg_constant_i32(con
);
517 gen_madd32_d(ret
, r1
, r2
, temp
);
521 gen_madd64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
524 TCGv t1
= tcg_temp_new();
525 TCGv t2
= tcg_temp_new();
526 TCGv t3
= tcg_temp_new();
527 TCGv t4
= tcg_temp_new();
529 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
530 /* only the add can overflow */
531 tcg_gen_add2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
533 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
534 tcg_gen_xor_tl(t1
, r2_high
, t2
);
535 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
537 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
538 /* Calc AV/SAV bits */
539 tcg_gen_add_tl(cpu_PSW_AV
, t4
, t4
);
540 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
542 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
543 /* write back the result */
544 tcg_gen_mov_tl(ret_low
, t3
);
545 tcg_gen_mov_tl(ret_high
, t4
);
549 gen_maddu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
552 TCGv_i64 t1
= tcg_temp_new_i64();
553 TCGv_i64 t2
= tcg_temp_new_i64();
554 TCGv_i64 t3
= tcg_temp_new_i64();
556 tcg_gen_extu_i32_i64(t1
, r1
);
557 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
558 tcg_gen_extu_i32_i64(t3
, r3
);
560 tcg_gen_mul_i64(t1
, t1
, t3
);
561 tcg_gen_add_i64(t2
, t2
, t1
);
562 /* write back result */
563 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t2
);
564 /* only the add overflows, if t2 < t1
566 tcg_gen_setcond_i64(TCG_COND_LTU
, t2
, t2
, t1
);
567 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
568 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
570 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
571 /* Calc AV/SAV bits */
572 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
573 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
575 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
579 gen_maddi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
582 TCGv temp
= tcg_constant_i32(con
);
583 gen_madd64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
587 gen_maddui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
590 TCGv temp
= tcg_constant_i32(con
);
591 gen_maddu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
595 gen_madd_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
596 TCGv r3
, uint32_t n
, uint32_t mode
)
598 TCGv t_n
= tcg_constant_i32(n
);
599 TCGv temp
= tcg_temp_new();
600 TCGv temp2
= tcg_temp_new();
601 TCGv_i64 temp64
= tcg_temp_new_i64();
604 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
607 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
610 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
613 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
616 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
617 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
618 tcg_gen_add_tl
, tcg_gen_add_tl
);
622 gen_maddsu_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
623 TCGv r3
, uint32_t n
, uint32_t mode
)
625 TCGv t_n
= tcg_constant_i32(n
);
626 TCGv temp
= tcg_temp_new();
627 TCGv temp2
= tcg_temp_new();
628 TCGv_i64 temp64
= tcg_temp_new_i64();
631 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
634 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
637 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
640 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
643 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
644 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
645 tcg_gen_sub_tl
, tcg_gen_add_tl
);
649 gen_maddsum_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
650 TCGv r3
, uint32_t n
, uint32_t mode
)
652 TCGv t_n
= tcg_constant_i32(n
);
653 TCGv_i64 temp64
= tcg_temp_new_i64();
654 TCGv_i64 temp64_2
= tcg_temp_new_i64();
655 TCGv_i64 temp64_3
= tcg_temp_new_i64();
658 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
661 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
664 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
667 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
670 tcg_gen_concat_i32_i64(temp64_3
, r1_low
, r1_high
);
671 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
672 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
673 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
674 tcg_gen_shli_i64(temp64
, temp64
, 16);
676 gen_add64_d(temp64_2
, temp64_3
, temp64
);
677 /* write back result */
678 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_2
);
681 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
);
684 gen_madds_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
685 TCGv r3
, uint32_t n
, uint32_t mode
)
687 TCGv t_n
= tcg_constant_i32(n
);
688 TCGv temp
= tcg_temp_new();
689 TCGv temp2
= tcg_temp_new();
690 TCGv temp3
= tcg_temp_new();
691 TCGv_i64 temp64
= tcg_temp_new_i64();
695 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
698 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
701 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
704 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
707 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
708 gen_adds(ret_low
, r1_low
, temp
);
709 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
710 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
711 gen_adds(ret_high
, r1_high
, temp2
);
713 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
714 /* combine av bits */
715 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
718 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
);
721 gen_maddsus_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
722 TCGv r3
, uint32_t n
, uint32_t mode
)
724 TCGv t_n
= tcg_constant_i32(n
);
725 TCGv temp
= tcg_temp_new();
726 TCGv temp2
= tcg_temp_new();
727 TCGv temp3
= tcg_temp_new();
728 TCGv_i64 temp64
= tcg_temp_new_i64();
732 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
735 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
738 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
741 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
744 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
745 gen_subs(ret_low
, r1_low
, temp
);
746 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
747 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
748 gen_adds(ret_high
, r1_high
, temp2
);
750 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
751 /* combine av bits */
752 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
756 gen_maddsums_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
757 TCGv r3
, uint32_t n
, uint32_t mode
)
759 TCGv t_n
= tcg_constant_i32(n
);
760 TCGv_i64 temp64
= tcg_temp_new_i64();
761 TCGv_i64 temp64_2
= tcg_temp_new_i64();
765 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
768 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
771 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
774 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
777 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
778 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
779 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
780 tcg_gen_shli_i64(temp64
, temp64
, 16);
781 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
783 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
784 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
789 gen_maddm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
790 TCGv r3
, uint32_t n
, uint32_t mode
)
792 TCGv t_n
= tcg_constant_i32(n
);
793 TCGv_i64 temp64
= tcg_temp_new_i64();
794 TCGv_i64 temp64_2
= tcg_temp_new_i64();
795 TCGv_i64 temp64_3
= tcg_temp_new_i64();
798 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, t_n
);
801 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, t_n
);
804 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, t_n
);
807 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, t_n
);
810 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
811 gen_add64_d(temp64_3
, temp64_2
, temp64
);
812 /* write back result */
813 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_3
);
817 gen_maddms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
818 TCGv r3
, uint32_t n
, uint32_t mode
)
820 TCGv t_n
= tcg_constant_i32(n
);
821 TCGv_i64 temp64
= tcg_temp_new_i64();
822 TCGv_i64 temp64_2
= tcg_temp_new_i64();
825 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, t_n
);
828 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, t_n
);
831 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, t_n
);
834 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, t_n
);
837 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
838 gen_helper_add64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
839 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
843 gen_maddr64_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
, uint32_t n
,
846 TCGv t_n
= tcg_constant_i32(n
);
847 TCGv_i64 temp64
= tcg_temp_new_i64();
850 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
853 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
856 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
859 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
862 gen_helper_addr_h(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
866 gen_maddr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
868 TCGv temp
= tcg_temp_new();
869 TCGv temp2
= tcg_temp_new();
871 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
872 tcg_gen_shli_tl(temp
, r1
, 16);
873 gen_maddr64_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
877 gen_maddsur32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
879 TCGv t_n
= tcg_constant_i32(n
);
880 TCGv temp
= tcg_temp_new();
881 TCGv temp2
= tcg_temp_new();
882 TCGv_i64 temp64
= tcg_temp_new_i64();
885 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
888 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
891 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
894 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
897 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
898 tcg_gen_shli_tl(temp
, r1
, 16);
899 gen_helper_addsur_h(ret
, cpu_env
, temp64
, temp
, temp2
);
904 gen_maddr64s_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
,
905 uint32_t n
, uint32_t mode
)
907 TCGv t_n
= tcg_constant_i32(n
);
908 TCGv_i64 temp64
= tcg_temp_new_i64();
911 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
914 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
917 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
920 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
923 gen_helper_addr_h_ssov(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
927 gen_maddr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
929 TCGv temp
= tcg_temp_new();
930 TCGv temp2
= tcg_temp_new();
932 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
933 tcg_gen_shli_tl(temp
, r1
, 16);
934 gen_maddr64s_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
938 gen_maddsur32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
940 TCGv t_n
= tcg_constant_i32(n
);
941 TCGv temp
= tcg_temp_new();
942 TCGv temp2
= tcg_temp_new();
943 TCGv_i64 temp64
= tcg_temp_new_i64();
946 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
949 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
952 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
955 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
958 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
959 tcg_gen_shli_tl(temp
, r1
, 16);
960 gen_helper_addsur_h_ssov(ret
, cpu_env
, temp64
, temp
, temp2
);
964 gen_maddr_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
966 TCGv t_n
= tcg_constant_i32(n
);
967 gen_helper_maddr_q(ret
, cpu_env
, r1
, r2
, r3
, t_n
);
971 gen_maddrs_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
973 TCGv t_n
= tcg_constant_i32(n
);
974 gen_helper_maddr_q_ssov(ret
, cpu_env
, r1
, r2
, r3
, t_n
);
978 gen_madd32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
981 TCGv temp
= tcg_temp_new();
982 TCGv temp2
= tcg_temp_new();
983 TCGv temp3
= tcg_temp_new();
984 TCGv_i64 t1
= tcg_temp_new_i64();
985 TCGv_i64 t2
= tcg_temp_new_i64();
986 TCGv_i64 t3
= tcg_temp_new_i64();
988 tcg_gen_ext_i32_i64(t2
, arg2
);
989 tcg_gen_ext_i32_i64(t3
, arg3
);
991 tcg_gen_mul_i64(t2
, t2
, t3
);
992 tcg_gen_shli_i64(t2
, t2
, n
);
994 tcg_gen_ext_i32_i64(t1
, arg1
);
995 tcg_gen_sari_i64(t2
, t2
, up_shift
);
997 tcg_gen_add_i64(t3
, t1
, t2
);
998 tcg_gen_extrl_i64_i32(temp3
, t3
);
1000 tcg_gen_setcondi_i64(TCG_COND_GT
, t1
, t3
, 0x7fffffffLL
);
1001 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t3
, -0x80000000LL
);
1002 tcg_gen_or_i64(t1
, t1
, t2
);
1003 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1004 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1005 /* We produce an overflow on the host if the mul before was
1006 (0x80000000 * 0x80000000) << 1). If this is the
1007 case, we negate the ovf. */
1009 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1010 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1011 tcg_gen_and_tl(temp
, temp
, temp2
);
1012 tcg_gen_shli_tl(temp
, temp
, 31);
1013 /* negate v bit, if special condition */
1014 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1017 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1018 /* Calc AV/SAV bits */
1019 tcg_gen_add_tl(cpu_PSW_AV
, temp3
, temp3
);
1020 tcg_gen_xor_tl(cpu_PSW_AV
, temp3
, cpu_PSW_AV
);
1022 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1023 /* write back result */
1024 tcg_gen_mov_tl(ret
, temp3
);
1028 gen_m16add32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1030 TCGv temp
= tcg_temp_new();
1031 TCGv temp2
= tcg_temp_new();
1033 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1034 } else { /* n is expected to be 1 */
1035 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1036 tcg_gen_shli_tl(temp
, temp
, 1);
1037 /* catch special case r1 = r2 = 0x8000 */
1038 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1039 tcg_gen_sub_tl(temp
, temp
, temp2
);
1041 gen_add_d(ret
, arg1
, temp
);
1045 gen_m16adds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1047 TCGv temp
= tcg_temp_new();
1048 TCGv temp2
= tcg_temp_new();
1050 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1051 } else { /* n is expected to be 1 */
1052 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1053 tcg_gen_shli_tl(temp
, temp
, 1);
1054 /* catch special case r1 = r2 = 0x8000 */
1055 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1056 tcg_gen_sub_tl(temp
, temp
, temp2
);
1058 gen_adds(ret
, arg1
, temp
);
1062 gen_m16add64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1063 TCGv arg3
, uint32_t n
)
1065 TCGv temp
= tcg_temp_new();
1066 TCGv temp2
= tcg_temp_new();
1067 TCGv_i64 t1
= tcg_temp_new_i64();
1068 TCGv_i64 t2
= tcg_temp_new_i64();
1069 TCGv_i64 t3
= tcg_temp_new_i64();
1072 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1073 } else { /* n is expected to be 1 */
1074 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1075 tcg_gen_shli_tl(temp
, temp
, 1);
1076 /* catch special case r1 = r2 = 0x8000 */
1077 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1078 tcg_gen_sub_tl(temp
, temp
, temp2
);
1080 tcg_gen_ext_i32_i64(t2
, temp
);
1081 tcg_gen_shli_i64(t2
, t2
, 16);
1082 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1083 gen_add64_d(t3
, t1
, t2
);
1084 /* write back result */
1085 tcg_gen_extr_i64_i32(rl
, rh
, t3
);
1089 gen_m16adds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1090 TCGv arg3
, uint32_t n
)
1092 TCGv temp
= tcg_temp_new();
1093 TCGv temp2
= tcg_temp_new();
1094 TCGv_i64 t1
= tcg_temp_new_i64();
1095 TCGv_i64 t2
= tcg_temp_new_i64();
1098 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1099 } else { /* n is expected to be 1 */
1100 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1101 tcg_gen_shli_tl(temp
, temp
, 1);
1102 /* catch special case r1 = r2 = 0x8000 */
1103 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1104 tcg_gen_sub_tl(temp
, temp
, temp2
);
1106 tcg_gen_ext_i32_i64(t2
, temp
);
1107 tcg_gen_shli_i64(t2
, t2
, 16);
1108 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1110 gen_helper_add64_ssov(t1
, cpu_env
, t1
, t2
);
1111 tcg_gen_extr_i64_i32(rl
, rh
, t1
);
1115 gen_madd64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1116 TCGv arg3
, uint32_t n
)
1118 TCGv_i64 t1
= tcg_temp_new_i64();
1119 TCGv_i64 t2
= tcg_temp_new_i64();
1120 TCGv_i64 t3
= tcg_temp_new_i64();
1121 TCGv_i64 t4
= tcg_temp_new_i64();
1124 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1125 tcg_gen_ext_i32_i64(t2
, arg2
);
1126 tcg_gen_ext_i32_i64(t3
, arg3
);
1128 tcg_gen_mul_i64(t2
, t2
, t3
);
1130 tcg_gen_shli_i64(t2
, t2
, 1);
1132 tcg_gen_add_i64(t4
, t1
, t2
);
1134 tcg_gen_xor_i64(t3
, t4
, t1
);
1135 tcg_gen_xor_i64(t2
, t1
, t2
);
1136 tcg_gen_andc_i64(t3
, t3
, t2
);
1137 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t3
);
1138 /* We produce an overflow on the host if the mul before was
1139 (0x80000000 * 0x80000000) << 1). If this is the
1140 case, we negate the ovf. */
1142 temp
= tcg_temp_new();
1143 temp2
= tcg_temp_new();
1144 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1145 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1146 tcg_gen_and_tl(temp
, temp
, temp2
);
1147 tcg_gen_shli_tl(temp
, temp
, 31);
1148 /* negate v bit, if special condition */
1149 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1151 /* write back result */
1152 tcg_gen_extr_i64_i32(rl
, rh
, t4
);
1154 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1155 /* Calc AV/SAV bits */
1156 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
1157 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
1159 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1163 gen_madds32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1166 TCGv_i64 t1
= tcg_temp_new_i64();
1167 TCGv_i64 t2
= tcg_temp_new_i64();
1168 TCGv_i64 t3
= tcg_temp_new_i64();
1170 tcg_gen_ext_i32_i64(t1
, arg1
);
1171 tcg_gen_ext_i32_i64(t2
, arg2
);
1172 tcg_gen_ext_i32_i64(t3
, arg3
);
1174 tcg_gen_mul_i64(t2
, t2
, t3
);
1175 tcg_gen_sari_i64(t2
, t2
, up_shift
- n
);
1177 gen_helper_madd32_q_add_ssov(ret
, cpu_env
, t1
, t2
);
1181 gen_madds64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1182 TCGv arg3
, uint32_t n
)
1184 TCGv_i64 r1
= tcg_temp_new_i64();
1185 TCGv t_n
= tcg_constant_i32(n
);
1187 tcg_gen_concat_i32_i64(r1
, arg1_low
, arg1_high
);
1188 gen_helper_madd64_q_ssov(r1
, cpu_env
, r1
, arg2
, arg3
, t_n
);
1189 tcg_gen_extr_i64_i32(rl
, rh
, r1
);
1192 /* ret = r2 - (r1 * r3); */
1193 static inline void gen_msub32_d(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
)
1195 TCGv_i64 t1
= tcg_temp_new_i64();
1196 TCGv_i64 t2
= tcg_temp_new_i64();
1197 TCGv_i64 t3
= tcg_temp_new_i64();
1199 tcg_gen_ext_i32_i64(t1
, r1
);
1200 tcg_gen_ext_i32_i64(t2
, r2
);
1201 tcg_gen_ext_i32_i64(t3
, r3
);
1203 tcg_gen_mul_i64(t1
, t1
, t3
);
1204 tcg_gen_sub_i64(t1
, t2
, t1
);
1206 tcg_gen_extrl_i64_i32(ret
, t1
);
1209 tcg_gen_setcondi_i64(TCG_COND_GT
, t3
, t1
, 0x7fffffffLL
);
1210 /* result < -0x80000000 */
1211 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t1
, -0x80000000LL
);
1212 tcg_gen_or_i64(t2
, t2
, t3
);
1213 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t2
);
1214 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1217 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1218 /* Calc AV/SAV bits */
1219 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
1220 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
1222 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1225 static inline void gen_msubi32_d(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
1227 TCGv temp
= tcg_constant_i32(con
);
1228 gen_msub32_d(ret
, r1
, r2
, temp
);
1232 gen_msub64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1235 TCGv t1
= tcg_temp_new();
1236 TCGv t2
= tcg_temp_new();
1237 TCGv t3
= tcg_temp_new();
1238 TCGv t4
= tcg_temp_new();
1240 tcg_gen_muls2_tl(t1
, t2
, r1
, r3
);
1241 /* only the sub can overflow */
1242 tcg_gen_sub2_tl(t3
, t4
, r2_low
, r2_high
, t1
, t2
);
1244 tcg_gen_xor_tl(cpu_PSW_V
, t4
, r2_high
);
1245 tcg_gen_xor_tl(t1
, r2_high
, t2
);
1246 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, t1
);
1248 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1249 /* Calc AV/SAV bits */
1250 tcg_gen_add_tl(cpu_PSW_AV
, t4
, t4
);
1251 tcg_gen_xor_tl(cpu_PSW_AV
, t4
, cpu_PSW_AV
);
1253 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1254 /* write back the result */
1255 tcg_gen_mov_tl(ret_low
, t3
);
1256 tcg_gen_mov_tl(ret_high
, t4
);
1260 gen_msubi64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1263 TCGv temp
= tcg_constant_i32(con
);
1264 gen_msub64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1268 gen_msubu64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1271 TCGv_i64 t1
= tcg_temp_new_i64();
1272 TCGv_i64 t2
= tcg_temp_new_i64();
1273 TCGv_i64 t3
= tcg_temp_new_i64();
1275 tcg_gen_extu_i32_i64(t1
, r1
);
1276 tcg_gen_concat_i32_i64(t2
, r2_low
, r2_high
);
1277 tcg_gen_extu_i32_i64(t3
, r3
);
1279 tcg_gen_mul_i64(t1
, t1
, t3
);
1280 tcg_gen_sub_i64(t3
, t2
, t1
);
1281 tcg_gen_extr_i64_i32(ret_low
, ret_high
, t3
);
1282 /* calc V bit, only the sub can overflow, if t1 > t2 */
1283 tcg_gen_setcond_i64(TCG_COND_GTU
, t1
, t1
, t2
);
1284 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1285 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1287 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1288 /* Calc AV/SAV bits */
1289 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
1290 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
1292 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1296 gen_msubui64_d(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
1299 TCGv temp
= tcg_constant_i32(con
);
1300 gen_msubu64_d(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
1303 static inline void gen_addi_d(TCGv ret
, TCGv r1
, target_ulong r2
)
1305 TCGv temp
= tcg_constant_i32(r2
);
1306 gen_add_d(ret
, r1
, temp
);
1309 /* calculate the carry bit too */
1310 static inline void gen_add_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1312 TCGv t0
= tcg_temp_new_i32();
1313 TCGv result
= tcg_temp_new_i32();
1315 tcg_gen_movi_tl(t0
, 0);
1316 /* Addition and set C/V/SV bits */
1317 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, r2
, t0
);
1319 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1320 tcg_gen_xor_tl(t0
, r1
, r2
);
1321 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1323 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1324 /* Calc AV/SAV bits */
1325 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1326 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1328 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1329 /* write back result */
1330 tcg_gen_mov_tl(ret
, result
);
1333 static inline void gen_addi_CC(TCGv ret
, TCGv r1
, int32_t con
)
1335 TCGv temp
= tcg_constant_i32(con
);
1336 gen_add_CC(ret
, r1
, temp
);
1339 static inline void gen_addc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1341 TCGv carry
= tcg_temp_new_i32();
1342 TCGv t0
= tcg_temp_new_i32();
1343 TCGv result
= tcg_temp_new_i32();
1345 tcg_gen_movi_tl(t0
, 0);
1346 tcg_gen_setcondi_tl(TCG_COND_NE
, carry
, cpu_PSW_C
, 0);
1347 /* Addition, carry and set C/V/SV bits */
1348 tcg_gen_add2_i32(result
, cpu_PSW_C
, r1
, t0
, carry
, t0
);
1349 tcg_gen_add2_i32(result
, cpu_PSW_C
, result
, cpu_PSW_C
, r2
, t0
);
1351 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1352 tcg_gen_xor_tl(t0
, r1
, r2
);
1353 tcg_gen_andc_tl(cpu_PSW_V
, cpu_PSW_V
, t0
);
1355 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1356 /* Calc AV/SAV bits */
1357 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1358 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1360 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1361 /* write back result */
1362 tcg_gen_mov_tl(ret
, result
);
1365 static inline void gen_addci_CC(TCGv ret
, TCGv r1
, int32_t con
)
1367 TCGv temp
= tcg_constant_i32(con
);
1368 gen_addc_CC(ret
, r1
, temp
);
1371 static inline void gen_cond_add(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1374 TCGv temp
= tcg_temp_new();
1375 TCGv temp2
= tcg_temp_new();
1376 TCGv result
= tcg_temp_new();
1377 TCGv mask
= tcg_temp_new();
1378 TCGv t0
= tcg_constant_i32(0);
1380 /* create mask for sticky bits */
1381 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1382 tcg_gen_shli_tl(mask
, mask
, 31);
1384 tcg_gen_add_tl(result
, r1
, r2
);
1386 tcg_gen_xor_tl(temp
, result
, r1
);
1387 tcg_gen_xor_tl(temp2
, r1
, r2
);
1388 tcg_gen_andc_tl(temp
, temp
, temp2
);
1389 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1391 tcg_gen_and_tl(temp
, temp
, mask
);
1392 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1394 tcg_gen_add_tl(temp
, result
, result
);
1395 tcg_gen_xor_tl(temp
, temp
, result
);
1396 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1398 tcg_gen_and_tl(temp
, temp
, mask
);
1399 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1400 /* write back result */
1401 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1404 static inline void gen_condi_add(TCGCond cond
, TCGv r1
, int32_t r2
,
1407 TCGv temp
= tcg_constant_i32(r2
);
1408 gen_cond_add(cond
, r1
, temp
, r3
, r4
);
1411 static inline void gen_sub_d(TCGv ret
, TCGv r1
, TCGv r2
)
1413 TCGv temp
= tcg_temp_new_i32();
1414 TCGv result
= tcg_temp_new_i32();
1416 tcg_gen_sub_tl(result
, r1
, r2
);
1418 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1419 tcg_gen_xor_tl(temp
, r1
, r2
);
1420 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1422 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1424 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1425 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1427 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1428 /* write back result */
1429 tcg_gen_mov_tl(ret
, result
);
1433 gen_sub64_d(TCGv_i64 ret
, TCGv_i64 r1
, TCGv_i64 r2
)
1435 TCGv temp
= tcg_temp_new();
1436 TCGv_i64 t0
= tcg_temp_new_i64();
1437 TCGv_i64 t1
= tcg_temp_new_i64();
1438 TCGv_i64 result
= tcg_temp_new_i64();
1440 tcg_gen_sub_i64(result
, r1
, r2
);
1442 tcg_gen_xor_i64(t1
, result
, r1
);
1443 tcg_gen_xor_i64(t0
, r1
, r2
);
1444 tcg_gen_and_i64(t1
, t1
, t0
);
1445 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t1
);
1447 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1448 /* calc AV/SAV bits */
1449 tcg_gen_extrh_i64_i32(temp
, result
);
1450 tcg_gen_add_tl(cpu_PSW_AV
, temp
, temp
);
1451 tcg_gen_xor_tl(cpu_PSW_AV
, temp
, cpu_PSW_AV
);
1453 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1454 /* write back result */
1455 tcg_gen_mov_i64(ret
, result
);
1458 static inline void gen_sub_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1460 TCGv result
= tcg_temp_new();
1461 TCGv temp
= tcg_temp_new();
1463 tcg_gen_sub_tl(result
, r1
, r2
);
1465 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_PSW_C
, r1
, r2
);
1467 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
1468 tcg_gen_xor_tl(temp
, r1
, r2
);
1469 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1471 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1473 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
1474 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
1476 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1477 /* write back result */
1478 tcg_gen_mov_tl(ret
, result
);
1481 static inline void gen_subc_CC(TCGv ret
, TCGv r1
, TCGv r2
)
1483 TCGv temp
= tcg_temp_new();
1484 tcg_gen_not_tl(temp
, r2
);
1485 gen_addc_CC(ret
, r1
, temp
);
1488 static inline void gen_cond_sub(TCGCond cond
, TCGv r1
, TCGv r2
, TCGv r3
,
1491 TCGv temp
= tcg_temp_new();
1492 TCGv temp2
= tcg_temp_new();
1493 TCGv result
= tcg_temp_new();
1494 TCGv mask
= tcg_temp_new();
1495 TCGv t0
= tcg_constant_i32(0);
1497 /* create mask for sticky bits */
1498 tcg_gen_setcond_tl(cond
, mask
, r4
, t0
);
1499 tcg_gen_shli_tl(mask
, mask
, 31);
1501 tcg_gen_sub_tl(result
, r1
, r2
);
1503 tcg_gen_xor_tl(temp
, result
, r1
);
1504 tcg_gen_xor_tl(temp2
, r1
, r2
);
1505 tcg_gen_and_tl(temp
, temp
, temp2
);
1506 tcg_gen_movcond_tl(cond
, cpu_PSW_V
, r4
, t0
, temp
, cpu_PSW_V
);
1508 tcg_gen_and_tl(temp
, temp
, mask
);
1509 tcg_gen_or_tl(cpu_PSW_SV
, temp
, cpu_PSW_SV
);
1511 tcg_gen_add_tl(temp
, result
, result
);
1512 tcg_gen_xor_tl(temp
, temp
, result
);
1513 tcg_gen_movcond_tl(cond
, cpu_PSW_AV
, r4
, t0
, temp
, cpu_PSW_AV
);
1515 tcg_gen_and_tl(temp
, temp
, mask
);
1516 tcg_gen_or_tl(cpu_PSW_SAV
, temp
, cpu_PSW_SAV
);
1517 /* write back result */
1518 tcg_gen_movcond_tl(cond
, r3
, r4
, t0
, result
, r1
);
1522 gen_msub_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1523 TCGv r3
, uint32_t n
, uint32_t mode
)
1525 TCGv t_n
= tcg_constant_i32(n
);
1526 TCGv temp
= tcg_temp_new();
1527 TCGv temp2
= tcg_temp_new();
1528 TCGv_i64 temp64
= tcg_temp_new_i64();
1531 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1534 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1537 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1540 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1543 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
1544 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
1545 tcg_gen_sub_tl
, tcg_gen_sub_tl
);
1549 gen_msubs_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1550 TCGv r3
, uint32_t n
, uint32_t mode
)
1552 TCGv t_n
= tcg_constant_i32(n
);
1553 TCGv temp
= tcg_temp_new();
1554 TCGv temp2
= tcg_temp_new();
1555 TCGv temp3
= tcg_temp_new();
1556 TCGv_i64 temp64
= tcg_temp_new_i64();
1560 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1563 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1566 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1569 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1572 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
1573 gen_subs(ret_low
, r1_low
, temp
);
1574 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
1575 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
1576 gen_subs(ret_high
, r1_high
, temp2
);
1577 /* combine v bits */
1578 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1579 /* combine av bits */
1580 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
1584 gen_msubm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1585 TCGv r3
, uint32_t n
, uint32_t mode
)
1587 TCGv t_n
= tcg_constant_i32(n
);
1588 TCGv_i64 temp64
= tcg_temp_new_i64();
1589 TCGv_i64 temp64_2
= tcg_temp_new_i64();
1590 TCGv_i64 temp64_3
= tcg_temp_new_i64();
1593 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, t_n
);
1596 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, t_n
);
1599 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, t_n
);
1602 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, t_n
);
1605 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
1606 gen_sub64_d(temp64_3
, temp64_2
, temp64
);
1607 /* write back result */
1608 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_3
);
1612 gen_msubms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1613 TCGv r3
, uint32_t n
, uint32_t mode
)
1615 TCGv t_n
= tcg_constant_i32(n
);
1616 TCGv_i64 temp64
= tcg_temp_new_i64();
1617 TCGv_i64 temp64_2
= tcg_temp_new_i64();
1620 GEN_HELPER_LL(mulm_h
, temp64
, r2
, r3
, t_n
);
1623 GEN_HELPER_LU(mulm_h
, temp64
, r2
, r3
, t_n
);
1626 GEN_HELPER_UL(mulm_h
, temp64
, r2
, r3
, t_n
);
1629 GEN_HELPER_UU(mulm_h
, temp64
, r2
, r3
, t_n
);
1632 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
1633 gen_helper_sub64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
1634 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
1638 gen_msubr64_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
, uint32_t n
,
1641 TCGv t_n
= tcg_constant_i32(n
);
1642 TCGv_i64 temp64
= tcg_temp_new_i64();
1645 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1648 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1651 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1654 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1657 gen_helper_subr_h(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
1661 gen_msubr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1663 TCGv temp
= tcg_temp_new();
1664 TCGv temp2
= tcg_temp_new();
1666 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1667 tcg_gen_shli_tl(temp
, r1
, 16);
1668 gen_msubr64_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1672 gen_msubr64s_h(TCGv ret
, TCGv r1_low
, TCGv r1_high
, TCGv r2
, TCGv r3
,
1673 uint32_t n
, uint32_t mode
)
1675 TCGv t_n
= tcg_constant_i32(n
);
1676 TCGv_i64 temp64
= tcg_temp_new_i64();
1679 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1682 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1685 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1688 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1691 gen_helper_subr_h_ssov(ret
, cpu_env
, temp64
, r1_low
, r1_high
);
1695 gen_msubr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1697 TCGv temp
= tcg_temp_new();
1698 TCGv temp2
= tcg_temp_new();
1700 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
1701 tcg_gen_shli_tl(temp
, r1
, 16);
1702 gen_msubr64s_h(ret
, temp
, temp2
, r2
, r3
, n
, mode
);
1706 gen_msubr_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1708 TCGv temp
= tcg_constant_i32(n
);
1709 gen_helper_msubr_q(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1713 gen_msubrs_q(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
)
1715 TCGv temp
= tcg_constant_i32(n
);
1716 gen_helper_msubr_q_ssov(ret
, cpu_env
, r1
, r2
, r3
, temp
);
1720 gen_msub32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1723 TCGv temp3
= tcg_temp_new();
1724 TCGv_i64 t1
= tcg_temp_new_i64();
1725 TCGv_i64 t2
= tcg_temp_new_i64();
1726 TCGv_i64 t3
= tcg_temp_new_i64();
1727 TCGv_i64 t4
= tcg_temp_new_i64();
1729 tcg_gen_ext_i32_i64(t2
, arg2
);
1730 tcg_gen_ext_i32_i64(t3
, arg3
);
1732 tcg_gen_mul_i64(t2
, t2
, t3
);
1734 tcg_gen_ext_i32_i64(t1
, arg1
);
1735 /* if we shift part of the fraction out, we need to round up */
1736 tcg_gen_andi_i64(t4
, t2
, (1ll << (up_shift
- n
)) - 1);
1737 tcg_gen_setcondi_i64(TCG_COND_NE
, t4
, t4
, 0);
1738 tcg_gen_sari_i64(t2
, t2
, up_shift
- n
);
1739 tcg_gen_add_i64(t2
, t2
, t4
);
1741 tcg_gen_sub_i64(t3
, t1
, t2
);
1742 tcg_gen_extrl_i64_i32(temp3
, t3
);
1744 tcg_gen_setcondi_i64(TCG_COND_GT
, t1
, t3
, 0x7fffffffLL
);
1745 tcg_gen_setcondi_i64(TCG_COND_LT
, t2
, t3
, -0x80000000LL
);
1746 tcg_gen_or_i64(t1
, t1
, t2
);
1747 tcg_gen_extrl_i64_i32(cpu_PSW_V
, t1
);
1748 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
1750 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1751 /* Calc AV/SAV bits */
1752 tcg_gen_add_tl(cpu_PSW_AV
, temp3
, temp3
);
1753 tcg_gen_xor_tl(cpu_PSW_AV
, temp3
, cpu_PSW_AV
);
1755 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1756 /* write back result */
1757 tcg_gen_mov_tl(ret
, temp3
);
1761 gen_m16sub32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1763 TCGv temp
= tcg_temp_new();
1764 TCGv temp2
= tcg_temp_new();
1766 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1767 } else { /* n is expected to be 1 */
1768 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1769 tcg_gen_shli_tl(temp
, temp
, 1);
1770 /* catch special case r1 = r2 = 0x8000 */
1771 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1772 tcg_gen_sub_tl(temp
, temp
, temp2
);
1774 gen_sub_d(ret
, arg1
, temp
);
1778 gen_m16subs32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
)
1780 TCGv temp
= tcg_temp_new();
1781 TCGv temp2
= tcg_temp_new();
1783 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1784 } else { /* n is expected to be 1 */
1785 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1786 tcg_gen_shli_tl(temp
, temp
, 1);
1787 /* catch special case r1 = r2 = 0x8000 */
1788 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1789 tcg_gen_sub_tl(temp
, temp
, temp2
);
1791 gen_subs(ret
, arg1
, temp
);
1795 gen_m16sub64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1796 TCGv arg3
, uint32_t n
)
1798 TCGv temp
= tcg_temp_new();
1799 TCGv temp2
= tcg_temp_new();
1800 TCGv_i64 t1
= tcg_temp_new_i64();
1801 TCGv_i64 t2
= tcg_temp_new_i64();
1802 TCGv_i64 t3
= tcg_temp_new_i64();
1805 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1806 } else { /* n is expected to be 1 */
1807 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1808 tcg_gen_shli_tl(temp
, temp
, 1);
1809 /* catch special case r1 = r2 = 0x8000 */
1810 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1811 tcg_gen_sub_tl(temp
, temp
, temp2
);
1813 tcg_gen_ext_i32_i64(t2
, temp
);
1814 tcg_gen_shli_i64(t2
, t2
, 16);
1815 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1816 gen_sub64_d(t3
, t1
, t2
);
1817 /* write back result */
1818 tcg_gen_extr_i64_i32(rl
, rh
, t3
);
1822 gen_m16subs64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1823 TCGv arg3
, uint32_t n
)
1825 TCGv temp
= tcg_temp_new();
1826 TCGv temp2
= tcg_temp_new();
1827 TCGv_i64 t1
= tcg_temp_new_i64();
1828 TCGv_i64 t2
= tcg_temp_new_i64();
1831 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1832 } else { /* n is expected to be 1 */
1833 tcg_gen_mul_tl(temp
, arg2
, arg3
);
1834 tcg_gen_shli_tl(temp
, temp
, 1);
1835 /* catch special case r1 = r2 = 0x8000 */
1836 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, temp
, 0x80000000);
1837 tcg_gen_sub_tl(temp
, temp
, temp2
);
1839 tcg_gen_ext_i32_i64(t2
, temp
);
1840 tcg_gen_shli_i64(t2
, t2
, 16);
1841 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1843 gen_helper_sub64_ssov(t1
, cpu_env
, t1
, t2
);
1844 tcg_gen_extr_i64_i32(rl
, rh
, t1
);
1848 gen_msub64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1849 TCGv arg3
, uint32_t n
)
1851 TCGv_i64 t1
= tcg_temp_new_i64();
1852 TCGv_i64 t2
= tcg_temp_new_i64();
1853 TCGv_i64 t3
= tcg_temp_new_i64();
1854 TCGv_i64 t4
= tcg_temp_new_i64();
1857 tcg_gen_concat_i32_i64(t1
, arg1_low
, arg1_high
);
1858 tcg_gen_ext_i32_i64(t2
, arg2
);
1859 tcg_gen_ext_i32_i64(t3
, arg3
);
1861 tcg_gen_mul_i64(t2
, t2
, t3
);
1863 tcg_gen_shli_i64(t2
, t2
, 1);
1865 tcg_gen_sub_i64(t4
, t1
, t2
);
1867 tcg_gen_xor_i64(t3
, t4
, t1
);
1868 tcg_gen_xor_i64(t2
, t1
, t2
);
1869 tcg_gen_and_i64(t3
, t3
, t2
);
1870 tcg_gen_extrh_i64_i32(cpu_PSW_V
, t3
);
1871 /* We produce an overflow on the host if the mul before was
1872 (0x80000000 * 0x80000000) << 1). If this is the
1873 case, we negate the ovf. */
1875 temp
= tcg_temp_new();
1876 temp2
= tcg_temp_new();
1877 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, arg2
, 0x80000000);
1878 tcg_gen_setcond_tl(TCG_COND_EQ
, temp2
, arg2
, arg3
);
1879 tcg_gen_and_tl(temp
, temp
, temp2
);
1880 tcg_gen_shli_tl(temp
, temp
, 31);
1881 /* negate v bit, if special condition */
1882 tcg_gen_xor_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
1884 /* write back result */
1885 tcg_gen_extr_i64_i32(rl
, rh
, t4
);
1887 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
1888 /* Calc AV/SAV bits */
1889 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
1890 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
1892 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
1896 gen_msubs32_q(TCGv ret
, TCGv arg1
, TCGv arg2
, TCGv arg3
, uint32_t n
,
1899 TCGv_i64 t1
= tcg_temp_new_i64();
1900 TCGv_i64 t2
= tcg_temp_new_i64();
1901 TCGv_i64 t3
= tcg_temp_new_i64();
1902 TCGv_i64 t4
= tcg_temp_new_i64();
1904 tcg_gen_ext_i32_i64(t1
, arg1
);
1905 tcg_gen_ext_i32_i64(t2
, arg2
);
1906 tcg_gen_ext_i32_i64(t3
, arg3
);
1908 tcg_gen_mul_i64(t2
, t2
, t3
);
1909 /* if we shift part of the fraction out, we need to round up */
1910 tcg_gen_andi_i64(t4
, t2
, (1ll << (up_shift
- n
)) - 1);
1911 tcg_gen_setcondi_i64(TCG_COND_NE
, t4
, t4
, 0);
1912 tcg_gen_sari_i64(t3
, t2
, up_shift
- n
);
1913 tcg_gen_add_i64(t3
, t3
, t4
);
1915 gen_helper_msub32_q_sub_ssov(ret
, cpu_env
, t1
, t3
);
1919 gen_msubs64_q(TCGv rl
, TCGv rh
, TCGv arg1_low
, TCGv arg1_high
, TCGv arg2
,
1920 TCGv arg3
, uint32_t n
)
1922 TCGv_i64 r1
= tcg_temp_new_i64();
1923 TCGv t_n
= tcg_constant_i32(n
);
1925 tcg_gen_concat_i32_i64(r1
, arg1_low
, arg1_high
);
1926 gen_helper_msub64_q_ssov(r1
, cpu_env
, r1
, arg2
, arg3
, t_n
);
1927 tcg_gen_extr_i64_i32(rl
, rh
, r1
);
1931 gen_msubad_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1932 TCGv r3
, uint32_t n
, uint32_t mode
)
1934 TCGv t_n
= tcg_constant_i32(n
);
1935 TCGv temp
= tcg_temp_new();
1936 TCGv temp2
= tcg_temp_new();
1937 TCGv_i64 temp64
= tcg_temp_new_i64();
1940 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1943 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1946 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1949 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1952 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
1953 gen_addsub64_h(ret_low
, ret_high
, r1_low
, r1_high
, temp
, temp2
,
1954 tcg_gen_add_tl
, tcg_gen_sub_tl
);
1958 gen_msubadm_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
1959 TCGv r3
, uint32_t n
, uint32_t mode
)
1961 TCGv t_n
= tcg_constant_i32(n
);
1962 TCGv_i64 temp64
= tcg_temp_new_i64();
1963 TCGv_i64 temp64_2
= tcg_temp_new_i64();
1964 TCGv_i64 temp64_3
= tcg_temp_new_i64();
1967 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
1970 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
1973 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
1976 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
1979 tcg_gen_concat_i32_i64(temp64_3
, r1_low
, r1_high
);
1980 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
1981 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
1982 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
1983 tcg_gen_shli_i64(temp64
, temp64
, 16);
1985 gen_sub64_d(temp64_2
, temp64_3
, temp64
);
1986 /* write back result */
1987 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64_2
);
1991 gen_msubadr32_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
1993 TCGv t_n
= tcg_constant_i32(n
);
1994 TCGv temp
= tcg_temp_new();
1995 TCGv temp2
= tcg_temp_new();
1996 TCGv_i64 temp64
= tcg_temp_new_i64();
1999 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
2002 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
2005 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
2008 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
2011 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
2012 tcg_gen_shli_tl(temp
, r1
, 16);
2013 gen_helper_subadr_h(ret
, cpu_env
, temp64
, temp
, temp2
);
2017 gen_msubads_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2018 TCGv r3
, uint32_t n
, uint32_t mode
)
2020 TCGv t_n
= tcg_constant_i32(n
);
2021 TCGv temp
= tcg_temp_new();
2022 TCGv temp2
= tcg_temp_new();
2023 TCGv temp3
= tcg_temp_new();
2024 TCGv_i64 temp64
= tcg_temp_new_i64();
2028 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
2031 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
2034 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
2037 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
2040 tcg_gen_extr_i64_i32(temp
, temp2
, temp64
);
2041 gen_adds(ret_low
, r1_low
, temp
);
2042 tcg_gen_mov_tl(temp
, cpu_PSW_V
);
2043 tcg_gen_mov_tl(temp3
, cpu_PSW_AV
);
2044 gen_subs(ret_high
, r1_high
, temp2
);
2045 /* combine v bits */
2046 tcg_gen_or_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
2047 /* combine av bits */
2048 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp3
);
2052 gen_msubadms_h(TCGv ret_low
, TCGv ret_high
, TCGv r1_low
, TCGv r1_high
, TCGv r2
,
2053 TCGv r3
, uint32_t n
, uint32_t mode
)
2055 TCGv t_n
= tcg_constant_i32(n
);
2056 TCGv_i64 temp64
= tcg_temp_new_i64();
2057 TCGv_i64 temp64_2
= tcg_temp_new_i64();
2061 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
2064 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
2067 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
2070 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
2073 tcg_gen_sari_i64(temp64_2
, temp64
, 32); /* high */
2074 tcg_gen_ext32s_i64(temp64
, temp64
); /* low */
2075 tcg_gen_sub_i64(temp64
, temp64_2
, temp64
);
2076 tcg_gen_shli_i64(temp64
, temp64
, 16);
2077 tcg_gen_concat_i32_i64(temp64_2
, r1_low
, r1_high
);
2079 gen_helper_sub64_ssov(temp64
, cpu_env
, temp64_2
, temp64
);
2080 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2084 gen_msubadr32s_h(TCGv ret
, TCGv r1
, TCGv r2
, TCGv r3
, uint32_t n
, uint32_t mode
)
2086 TCGv t_n
= tcg_constant_i32(n
);
2087 TCGv temp
= tcg_temp_new();
2088 TCGv temp2
= tcg_temp_new();
2089 TCGv_i64 temp64
= tcg_temp_new_i64();
2092 GEN_HELPER_LL(mul_h
, temp64
, r2
, r3
, t_n
);
2095 GEN_HELPER_LU(mul_h
, temp64
, r2
, r3
, t_n
);
2098 GEN_HELPER_UL(mul_h
, temp64
, r2
, r3
, t_n
);
2101 GEN_HELPER_UU(mul_h
, temp64
, r2
, r3
, t_n
);
2104 tcg_gen_andi_tl(temp2
, r1
, 0xffff0000);
2105 tcg_gen_shli_tl(temp
, r1
, 16);
2106 gen_helper_subadr_h_ssov(ret
, cpu_env
, temp64
, temp
, temp2
);
2109 static inline void gen_abs(TCGv ret
, TCGv r1
)
2111 tcg_gen_abs_tl(ret
, r1
);
2112 /* overflow can only happen, if r1 = 0x80000000 */
2113 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, r1
, 0x80000000);
2114 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2116 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2118 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2119 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2121 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2124 static inline void gen_absdif(TCGv ret
, TCGv r1
, TCGv r2
)
2126 TCGv temp
= tcg_temp_new_i32();
2127 TCGv result
= tcg_temp_new_i32();
2129 tcg_gen_sub_tl(result
, r1
, r2
);
2130 tcg_gen_sub_tl(temp
, r2
, r1
);
2131 tcg_gen_movcond_tl(TCG_COND_GT
, result
, r1
, r2
, result
, temp
);
2134 tcg_gen_xor_tl(cpu_PSW_V
, result
, r1
);
2135 tcg_gen_xor_tl(temp
, result
, r2
);
2136 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_PSW_V
, r1
, r2
, cpu_PSW_V
, temp
);
2137 tcg_gen_xor_tl(temp
, r1
, r2
);
2138 tcg_gen_and_tl(cpu_PSW_V
, cpu_PSW_V
, temp
);
2140 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2142 tcg_gen_add_tl(cpu_PSW_AV
, result
, result
);
2143 tcg_gen_xor_tl(cpu_PSW_AV
, result
, cpu_PSW_AV
);
2145 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2146 /* write back result */
2147 tcg_gen_mov_tl(ret
, result
);
2150 static inline void gen_absdifi(TCGv ret
, TCGv r1
, int32_t con
)
2152 TCGv temp
= tcg_constant_i32(con
);
2153 gen_absdif(ret
, r1
, temp
);
2156 static inline void gen_absdifsi(TCGv ret
, TCGv r1
, int32_t con
)
2158 TCGv temp
= tcg_constant_i32(con
);
2159 gen_helper_absdif_ssov(ret
, cpu_env
, r1
, temp
);
2162 static inline void gen_mul_i32s(TCGv ret
, TCGv r1
, TCGv r2
)
2164 TCGv high
= tcg_temp_new();
2165 TCGv low
= tcg_temp_new();
2167 tcg_gen_muls2_tl(low
, high
, r1
, r2
);
2168 tcg_gen_mov_tl(ret
, low
);
2170 tcg_gen_sari_tl(low
, low
, 31);
2171 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_PSW_V
, high
, low
);
2172 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2174 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2176 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2177 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2179 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2182 static inline void gen_muli_i32s(TCGv ret
, TCGv r1
, int32_t con
)
2184 TCGv temp
= tcg_constant_i32(con
);
2185 gen_mul_i32s(ret
, r1
, temp
);
2188 static inline void gen_mul_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
2190 tcg_gen_muls2_tl(ret_low
, ret_high
, r1
, r2
);
2192 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2194 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2196 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
2197 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
2199 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2202 static inline void gen_muli_i64s(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
2205 TCGv temp
= tcg_constant_i32(con
);
2206 gen_mul_i64s(ret_low
, ret_high
, r1
, temp
);
2209 static inline void gen_mul_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2
)
2211 tcg_gen_mulu2_tl(ret_low
, ret_high
, r1
, r2
);
2213 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2215 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2217 tcg_gen_add_tl(cpu_PSW_AV
, ret_high
, ret_high
);
2218 tcg_gen_xor_tl(cpu_PSW_AV
, ret_high
, cpu_PSW_AV
);
2220 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2223 static inline void gen_muli_i64u(TCGv ret_low
, TCGv ret_high
, TCGv r1
,
2226 TCGv temp
= tcg_constant_i32(con
);
2227 gen_mul_i64u(ret_low
, ret_high
, r1
, temp
);
2230 static inline void gen_mulsi_i32(TCGv ret
, TCGv r1
, int32_t con
)
2232 TCGv temp
= tcg_constant_i32(con
);
2233 gen_helper_mul_ssov(ret
, cpu_env
, r1
, temp
);
2236 static inline void gen_mulsui_i32(TCGv ret
, TCGv r1
, int32_t con
)
2238 TCGv temp
= tcg_constant_i32(con
);
2239 gen_helper_mul_suov(ret
, cpu_env
, r1
, temp
);
2242 /* gen_maddsi_32(cpu_gpr_d[r4], cpu_gpr_d[r1], cpu_gpr_d[r3], const9); */
2243 static inline void gen_maddsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2245 TCGv temp
= tcg_constant_i32(con
);
2246 gen_helper_madd32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
2249 static inline void gen_maddsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2251 TCGv temp
= tcg_constant_i32(con
);
2252 gen_helper_madd32_suov(ret
, cpu_env
, r1
, r2
, temp
);
2256 gen_mul_q(TCGv rl
, TCGv rh
, TCGv arg1
, TCGv arg2
, uint32_t n
, uint32_t up_shift
)
2258 TCGv_i64 temp_64
= tcg_temp_new_i64();
2259 TCGv_i64 temp2_64
= tcg_temp_new_i64();
2262 if (up_shift
== 32) {
2263 tcg_gen_muls2_tl(rh
, rl
, arg1
, arg2
);
2264 } else if (up_shift
== 16) {
2265 tcg_gen_ext_i32_i64(temp_64
, arg1
);
2266 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
2268 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
2269 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
);
2270 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
2272 tcg_gen_muls2_tl(rl
, rh
, arg1
, arg2
);
2275 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2276 } else { /* n is expected to be 1 */
2277 tcg_gen_ext_i32_i64(temp_64
, arg1
);
2278 tcg_gen_ext_i32_i64(temp2_64
, arg2
);
2280 tcg_gen_mul_i64(temp_64
, temp_64
, temp2_64
);
2282 if (up_shift
== 0) {
2283 tcg_gen_shli_i64(temp_64
, temp_64
, 1);
2285 tcg_gen_shri_i64(temp_64
, temp_64
, up_shift
- 1);
2287 tcg_gen_extr_i64_i32(rl
, rh
, temp_64
);
2288 /* overflow only occurs if r1 = r2 = 0x8000 */
2289 if (up_shift
== 0) {/* result is 64 bit */
2290 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rh
,
2292 } else { /* result is 32 bit */
2293 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, rl
,
2296 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2297 /* calc sv overflow bit */
2298 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
2300 /* calc av overflow bit */
2301 if (up_shift
== 0) {
2302 tcg_gen_add_tl(cpu_PSW_AV
, rh
, rh
);
2303 tcg_gen_xor_tl(cpu_PSW_AV
, rh
, cpu_PSW_AV
);
2305 tcg_gen_add_tl(cpu_PSW_AV
, rl
, rl
);
2306 tcg_gen_xor_tl(cpu_PSW_AV
, rl
, cpu_PSW_AV
);
2308 /* calc sav overflow bit */
2309 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2313 gen_mul_q_16(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
2315 TCGv temp
= tcg_temp_new();
2317 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2318 } else { /* n is expected to be 1 */
2319 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2320 tcg_gen_shli_tl(ret
, ret
, 1);
2321 /* catch special case r1 = r2 = 0x8000 */
2322 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80000000);
2323 tcg_gen_sub_tl(ret
, ret
, temp
);
2326 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2327 /* calc av overflow bit */
2328 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2329 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2330 /* calc sav overflow bit */
2331 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2334 static void gen_mulr_q(TCGv ret
, TCGv arg1
, TCGv arg2
, uint32_t n
)
2336 TCGv temp
= tcg_temp_new();
2338 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2339 tcg_gen_addi_tl(ret
, ret
, 0x8000);
2341 tcg_gen_mul_tl(ret
, arg1
, arg2
);
2342 tcg_gen_shli_tl(ret
, ret
, 1);
2343 tcg_gen_addi_tl(ret
, ret
, 0x8000);
2344 /* catch special case r1 = r2 = 0x8000 */
2345 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, ret
, 0x80008000);
2346 tcg_gen_muli_tl(temp
, temp
, 0x8001);
2347 tcg_gen_sub_tl(ret
, ret
, temp
);
2350 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2351 /* calc av overflow bit */
2352 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2353 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2354 /* calc sav overflow bit */
2355 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2356 /* cut halfword off */
2357 tcg_gen_andi_tl(ret
, ret
, 0xffff0000);
2361 gen_madds_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2364 TCGv_i64 temp64
= tcg_temp_new_i64();
2365 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2366 gen_helper_madd64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
2367 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2371 gen_maddsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2374 TCGv temp
= tcg_constant_i32(con
);
2375 gen_madds_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2379 gen_maddsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2382 TCGv_i64 temp64
= tcg_temp_new_i64();
2383 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2384 gen_helper_madd64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
2385 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2389 gen_maddsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2392 TCGv temp
= tcg_constant_i32(con
);
2393 gen_maddsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2396 static inline void gen_msubsi_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2398 TCGv temp
= tcg_constant_i32(con
);
2399 gen_helper_msub32_ssov(ret
, cpu_env
, r1
, r2
, temp
);
2402 static inline void gen_msubsui_32(TCGv ret
, TCGv r1
, TCGv r2
, int32_t con
)
2404 TCGv temp
= tcg_constant_i32(con
);
2405 gen_helper_msub32_suov(ret
, cpu_env
, r1
, r2
, temp
);
2409 gen_msubs_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2412 TCGv_i64 temp64
= tcg_temp_new_i64();
2413 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2414 gen_helper_msub64_ssov(temp64
, cpu_env
, r1
, temp64
, r3
);
2415 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2419 gen_msubsi_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2422 TCGv temp
= tcg_constant_i32(con
);
2423 gen_msubs_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2427 gen_msubsu_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2430 TCGv_i64 temp64
= tcg_temp_new_i64();
2431 tcg_gen_concat_i32_i64(temp64
, r2_low
, r2_high
);
2432 gen_helper_msub64_suov(temp64
, cpu_env
, r1
, temp64
, r3
);
2433 tcg_gen_extr_i64_i32(ret_low
, ret_high
, temp64
);
2437 gen_msubsui_64(TCGv ret_low
, TCGv ret_high
, TCGv r1
, TCGv r2_low
, TCGv r2_high
,
2440 TCGv temp
= tcg_constant_i32(con
);
2441 gen_msubsu_64(ret_low
, ret_high
, r1
, r2_low
, r2_high
, temp
);
2444 static void gen_saturate(TCGv ret
, TCGv arg
, int32_t up
, int32_t low
)
2446 TCGv sat_neg
= tcg_const_i32(low
);
2447 TCGv temp
= tcg_const_i32(up
);
2449 /* sat_neg = (arg < low ) ? low : arg; */
2450 tcg_gen_movcond_tl(TCG_COND_LT
, sat_neg
, arg
, sat_neg
, sat_neg
, arg
);
2452 /* ret = (sat_neg > up ) ? up : sat_neg; */
2453 tcg_gen_movcond_tl(TCG_COND_GT
, ret
, sat_neg
, temp
, temp
, sat_neg
);
2456 static void gen_saturate_u(TCGv ret
, TCGv arg
, int32_t up
)
2458 TCGv temp
= tcg_const_i32(up
);
2459 /* sat_neg = (arg > up ) ? up : arg; */
2460 tcg_gen_movcond_tl(TCG_COND_GTU
, ret
, arg
, temp
, temp
, arg
);
2463 static void gen_shi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2465 if (shift_count
== -32) {
2466 tcg_gen_movi_tl(ret
, 0);
2467 } else if (shift_count
>= 0) {
2468 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2470 tcg_gen_shri_tl(ret
, r1
, -shift_count
);
2474 static void gen_sh_hi(TCGv ret
, TCGv r1
, int32_t shiftcount
)
2476 TCGv temp_low
, temp_high
;
2478 if (shiftcount
== -16) {
2479 tcg_gen_movi_tl(ret
, 0);
2481 temp_high
= tcg_temp_new();
2482 temp_low
= tcg_temp_new();
2484 tcg_gen_andi_tl(temp_low
, r1
, 0xffff);
2485 tcg_gen_andi_tl(temp_high
, r1
, 0xffff0000);
2486 gen_shi(temp_low
, temp_low
, shiftcount
);
2487 gen_shi(ret
, temp_high
, shiftcount
);
2488 tcg_gen_deposit_tl(ret
, ret
, temp_low
, 0, 16);
2492 static void gen_shaci(TCGv ret
, TCGv r1
, int32_t shift_count
)
2494 uint32_t msk
, msk_start
;
2495 TCGv temp
= tcg_temp_new();
2496 TCGv temp2
= tcg_temp_new();
2498 if (shift_count
== 0) {
2499 /* Clear PSW.C and PSW.V */
2500 tcg_gen_movi_tl(cpu_PSW_C
, 0);
2501 tcg_gen_mov_tl(cpu_PSW_V
, cpu_PSW_C
);
2502 tcg_gen_mov_tl(ret
, r1
);
2503 } else if (shift_count
== -32) {
2505 tcg_gen_mov_tl(cpu_PSW_C
, r1
);
2506 /* fill ret completely with sign bit */
2507 tcg_gen_sari_tl(ret
, r1
, 31);
2509 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2510 } else if (shift_count
> 0) {
2511 TCGv t_max
= tcg_constant_i32(0x7FFFFFFF >> shift_count
);
2512 TCGv t_min
= tcg_constant_i32(((int32_t) -0x80000000) >> shift_count
);
2515 msk_start
= 32 - shift_count
;
2516 msk
= ((1 << shift_count
) - 1) << msk_start
;
2517 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2518 /* calc v/sv bits */
2519 tcg_gen_setcond_tl(TCG_COND_GT
, temp
, r1
, t_max
);
2520 tcg_gen_setcond_tl(TCG_COND_LT
, temp2
, r1
, t_min
);
2521 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
2522 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
2524 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_V
, cpu_PSW_SV
);
2526 tcg_gen_shli_tl(ret
, r1
, shift_count
);
2529 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2531 msk
= (1 << -shift_count
) - 1;
2532 tcg_gen_andi_tl(cpu_PSW_C
, r1
, msk
);
2534 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2536 /* calc av overflow bit */
2537 tcg_gen_add_tl(cpu_PSW_AV
, ret
, ret
);
2538 tcg_gen_xor_tl(cpu_PSW_AV
, ret
, cpu_PSW_AV
);
2539 /* calc sav overflow bit */
2540 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2543 static void gen_shas(TCGv ret
, TCGv r1
, TCGv r2
)
2545 gen_helper_sha_ssov(ret
, cpu_env
, r1
, r2
);
2548 static void gen_shasi(TCGv ret
, TCGv r1
, int32_t con
)
2550 TCGv temp
= tcg_constant_i32(con
);
2551 gen_shas(ret
, r1
, temp
);
2554 static void gen_sha_hi(TCGv ret
, TCGv r1
, int32_t shift_count
)
2558 if (shift_count
== 0) {
2559 tcg_gen_mov_tl(ret
, r1
);
2560 } else if (shift_count
> 0) {
2561 low
= tcg_temp_new();
2562 high
= tcg_temp_new();
2564 tcg_gen_andi_tl(high
, r1
, 0xffff0000);
2565 tcg_gen_shli_tl(low
, r1
, shift_count
);
2566 tcg_gen_shli_tl(ret
, high
, shift_count
);
2567 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2569 low
= tcg_temp_new();
2570 high
= tcg_temp_new();
2572 tcg_gen_ext16s_tl(low
, r1
);
2573 tcg_gen_sari_tl(low
, low
, -shift_count
);
2574 tcg_gen_sari_tl(ret
, r1
, -shift_count
);
2575 tcg_gen_deposit_tl(ret
, ret
, low
, 0, 16);
2579 /* ret = {ret[30:0], (r1 cond r2)}; */
2580 static void gen_sh_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
)
2582 TCGv temp
= tcg_temp_new();
2583 TCGv temp2
= tcg_temp_new();
2585 tcg_gen_shli_tl(temp
, ret
, 1);
2586 tcg_gen_setcond_tl(cond
, temp2
, r1
, r2
);
2587 tcg_gen_or_tl(ret
, temp
, temp2
);
2590 static void gen_sh_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
)
2592 TCGv temp
= tcg_constant_i32(con
);
2593 gen_sh_cond(cond
, ret
, r1
, temp
);
2596 static inline void gen_adds(TCGv ret
, TCGv r1
, TCGv r2
)
2598 gen_helper_add_ssov(ret
, cpu_env
, r1
, r2
);
2601 static inline void gen_addsi(TCGv ret
, TCGv r1
, int32_t con
)
2603 TCGv temp
= tcg_constant_i32(con
);
2604 gen_helper_add_ssov(ret
, cpu_env
, r1
, temp
);
2607 static inline void gen_addsui(TCGv ret
, TCGv r1
, int32_t con
)
2609 TCGv temp
= tcg_constant_i32(con
);
2610 gen_helper_add_suov(ret
, cpu_env
, r1
, temp
);
2613 static inline void gen_subs(TCGv ret
, TCGv r1
, TCGv r2
)
2615 gen_helper_sub_ssov(ret
, cpu_env
, r1
, r2
);
2618 static inline void gen_subsu(TCGv ret
, TCGv r1
, TCGv r2
)
2620 gen_helper_sub_suov(ret
, cpu_env
, r1
, r2
);
2623 static inline void gen_bit_2op(TCGv ret
, TCGv r1
, TCGv r2
,
2625 void(*op1
)(TCGv
, TCGv
, TCGv
),
2626 void(*op2
)(TCGv
, TCGv
, TCGv
))
2630 temp1
= tcg_temp_new();
2631 temp2
= tcg_temp_new();
2633 tcg_gen_shri_tl(temp2
, r2
, pos2
);
2634 tcg_gen_shri_tl(temp1
, r1
, pos1
);
2636 (*op1
)(temp1
, temp1
, temp2
);
2637 (*op2
)(temp1
, ret
, temp1
);
2639 tcg_gen_deposit_tl(ret
, ret
, temp1
, 0, 1);
2642 /* ret = r1[pos1] op1 r2[pos2]; */
2643 static inline void gen_bit_1op(TCGv ret
, TCGv r1
, TCGv r2
,
2645 void(*op1
)(TCGv
, TCGv
, TCGv
))
2649 temp1
= tcg_temp_new();
2650 temp2
= tcg_temp_new();
2652 tcg_gen_shri_tl(temp2
, r2
, pos2
);
2653 tcg_gen_shri_tl(temp1
, r1
, pos1
);
2655 (*op1
)(ret
, temp1
, temp2
);
2657 tcg_gen_andi_tl(ret
, ret
, 0x1);
2660 static inline void gen_accumulating_cond(int cond
, TCGv ret
, TCGv r1
, TCGv r2
,
2661 void(*op
)(TCGv
, TCGv
, TCGv
))
2663 TCGv temp
= tcg_temp_new();
2664 TCGv temp2
= tcg_temp_new();
2665 /* temp = (arg1 cond arg2 )*/
2666 tcg_gen_setcond_tl(cond
, temp
, r1
, r2
);
2668 tcg_gen_andi_tl(temp2
, ret
, 0x1);
2669 /* temp = temp insn temp2 */
2670 (*op
)(temp
, temp
, temp2
);
2671 /* ret = {ret[31:1], temp} */
2672 tcg_gen_deposit_tl(ret
, ret
, temp
, 0, 1);
2676 gen_accumulating_condi(int cond
, TCGv ret
, TCGv r1
, int32_t con
,
2677 void(*op
)(TCGv
, TCGv
, TCGv
))
2679 TCGv temp
= tcg_constant_i32(con
);
2680 gen_accumulating_cond(cond
, ret
, r1
, temp
, op
);
2683 /* ret = (r1 cond r2) ? 0xFFFFFFFF ? 0x00000000;*/
2684 static inline void gen_cond_w(TCGCond cond
, TCGv ret
, TCGv r1
, TCGv r2
)
2686 tcg_gen_setcond_tl(cond
, ret
, r1
, r2
);
2687 tcg_gen_neg_tl(ret
, ret
);
2690 static inline void gen_eqany_bi(TCGv ret
, TCGv r1
, int32_t con
)
2692 TCGv b0
= tcg_temp_new();
2693 TCGv b1
= tcg_temp_new();
2694 TCGv b2
= tcg_temp_new();
2695 TCGv b3
= tcg_temp_new();
2698 tcg_gen_andi_tl(b0
, r1
, 0xff);
2699 tcg_gen_setcondi_tl(TCG_COND_EQ
, b0
, b0
, con
& 0xff);
2702 tcg_gen_andi_tl(b1
, r1
, 0xff00);
2703 tcg_gen_setcondi_tl(TCG_COND_EQ
, b1
, b1
, con
& 0xff00);
2706 tcg_gen_andi_tl(b2
, r1
, 0xff0000);
2707 tcg_gen_setcondi_tl(TCG_COND_EQ
, b2
, b2
, con
& 0xff0000);
2710 tcg_gen_andi_tl(b3
, r1
, 0xff000000);
2711 tcg_gen_setcondi_tl(TCG_COND_EQ
, b3
, b3
, con
& 0xff000000);
2714 tcg_gen_or_tl(ret
, b0
, b1
);
2715 tcg_gen_or_tl(ret
, ret
, b2
);
2716 tcg_gen_or_tl(ret
, ret
, b3
);
2719 static inline void gen_eqany_hi(TCGv ret
, TCGv r1
, int32_t con
)
2721 TCGv h0
= tcg_temp_new();
2722 TCGv h1
= tcg_temp_new();
2725 tcg_gen_andi_tl(h0
, r1
, 0xffff);
2726 tcg_gen_setcondi_tl(TCG_COND_EQ
, h0
, h0
, con
& 0xffff);
2729 tcg_gen_andi_tl(h1
, r1
, 0xffff0000);
2730 tcg_gen_setcondi_tl(TCG_COND_EQ
, h1
, h1
, con
& 0xffff0000);
2733 tcg_gen_or_tl(ret
, h0
, h1
);
2736 /* mask = ((1 << width) -1) << pos;
2737 ret = (r1 & ~mask) | (r2 << pos) & mask); */
2738 static inline void gen_insert(TCGv ret
, TCGv r1
, TCGv r2
, TCGv width
, TCGv pos
)
2740 TCGv mask
= tcg_temp_new();
2741 TCGv temp
= tcg_temp_new();
2742 TCGv temp2
= tcg_temp_new();
2744 tcg_gen_movi_tl(mask
, 1);
2745 tcg_gen_shl_tl(mask
, mask
, width
);
2746 tcg_gen_subi_tl(mask
, mask
, 1);
2747 tcg_gen_shl_tl(mask
, mask
, pos
);
2749 tcg_gen_shl_tl(temp
, r2
, pos
);
2750 tcg_gen_and_tl(temp
, temp
, mask
);
2751 tcg_gen_andc_tl(temp2
, r1
, mask
);
2752 tcg_gen_or_tl(ret
, temp
, temp2
);
2755 static inline void gen_bsplit(TCGv rl
, TCGv rh
, TCGv r1
)
2757 TCGv_i64 temp
= tcg_temp_new_i64();
2759 gen_helper_bsplit(temp
, r1
);
2760 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
2763 static inline void gen_unpack(TCGv rl
, TCGv rh
, TCGv r1
)
2765 TCGv_i64 temp
= tcg_temp_new_i64();
2767 gen_helper_unpack(temp
, r1
);
2768 tcg_gen_extr_i64_i32(rl
, rh
, temp
);
2772 gen_dvinit_b(DisasContext
*ctx
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
2774 TCGv_i64 ret
= tcg_temp_new_i64();
2776 if (!has_feature(ctx
, TRICORE_FEATURE_131
)) {
2777 gen_helper_dvinit_b_13(ret
, cpu_env
, r1
, r2
);
2779 gen_helper_dvinit_b_131(ret
, cpu_env
, r1
, r2
);
2781 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
2785 gen_dvinit_h(DisasContext
*ctx
, TCGv rl
, TCGv rh
, TCGv r1
, TCGv r2
)
2787 TCGv_i64 ret
= tcg_temp_new_i64();
2789 if (!has_feature(ctx
, TRICORE_FEATURE_131
)) {
2790 gen_helper_dvinit_h_13(ret
, cpu_env
, r1
, r2
);
2792 gen_helper_dvinit_h_131(ret
, cpu_env
, r1
, r2
);
2794 tcg_gen_extr_i64_i32(rl
, rh
, ret
);
2797 static void gen_calc_usb_mul_h(TCGv arg_low
, TCGv arg_high
)
2799 TCGv temp
= tcg_temp_new();
2801 tcg_gen_add_tl(temp
, arg_low
, arg_low
);
2802 tcg_gen_xor_tl(temp
, temp
, arg_low
);
2803 tcg_gen_add_tl(cpu_PSW_AV
, arg_high
, arg_high
);
2804 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_PSW_AV
, arg_high
);
2805 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
2807 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2808 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2811 static void gen_calc_usb_mulr_h(TCGv arg
)
2813 TCGv temp
= tcg_temp_new();
2815 tcg_gen_add_tl(temp
, arg
, arg
);
2816 tcg_gen_xor_tl(temp
, temp
, arg
);
2817 tcg_gen_shli_tl(cpu_PSW_AV
, temp
, 16);
2818 tcg_gen_or_tl(cpu_PSW_AV
, cpu_PSW_AV
, temp
);
2820 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
2822 tcg_gen_movi_tl(cpu_PSW_V
, 0);
2825 /* helpers for generating program flow micro-ops */
2827 static inline void gen_save_pc(target_ulong pc
)
2829 tcg_gen_movi_tl(cpu_PC
, pc
);
2832 static void gen_goto_tb(DisasContext
*ctx
, int n
, target_ulong dest
)
2834 if (translator_use_goto_tb(&ctx
->base
, dest
)) {
2837 tcg_gen_exit_tb(ctx
->base
.tb
, n
);
2840 tcg_gen_lookup_and_goto_ptr();
2844 static void generate_trap(DisasContext
*ctx
, int class, int tin
)
2846 TCGv_i32 classtemp
= tcg_constant_i32(class);
2847 TCGv_i32 tintemp
= tcg_constant_i32(tin
);
2849 gen_save_pc(ctx
->base
.pc_next
);
2850 gen_helper_raise_exception_sync(cpu_env
, classtemp
, tintemp
);
2851 ctx
->base
.is_jmp
= DISAS_NORETURN
;
2854 static inline void gen_branch_cond(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
2855 TCGv r2
, int16_t address
)
2857 TCGLabel
*jumpLabel
= gen_new_label();
2858 tcg_gen_brcond_tl(cond
, r1
, r2
, jumpLabel
);
2860 gen_goto_tb(ctx
, 1, ctx
->pc_succ_insn
);
2862 gen_set_label(jumpLabel
);
2863 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ address
* 2);
2866 static inline void gen_branch_condi(DisasContext
*ctx
, TCGCond cond
, TCGv r1
,
2867 int r2
, int16_t address
)
2869 TCGv temp
= tcg_constant_i32(r2
);
2870 gen_branch_cond(ctx
, cond
, r1
, temp
, address
);
2873 static void gen_loop(DisasContext
*ctx
, int r1
, int32_t offset
)
2875 TCGLabel
*l1
= gen_new_label();
2877 tcg_gen_subi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], 1);
2878 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_gpr_a
[r1
], -1, l1
);
2879 gen_goto_tb(ctx
, 1, ctx
->base
.pc_next
+ offset
);
2881 gen_goto_tb(ctx
, 0, ctx
->pc_succ_insn
);
2884 static void gen_fcall_save_ctx(DisasContext
*ctx
)
2886 TCGv temp
= tcg_temp_new();
2888 tcg_gen_addi_tl(temp
, cpu_gpr_a
[10], -4);
2889 tcg_gen_qemu_st_tl(cpu_gpr_a
[11], temp
, ctx
->mem_idx
, MO_LESL
);
2890 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
2891 tcg_gen_mov_tl(cpu_gpr_a
[10], temp
);
2894 static void gen_fret(DisasContext
*ctx
)
2896 TCGv temp
= tcg_temp_new();
2898 tcg_gen_andi_tl(temp
, cpu_gpr_a
[11], ~0x1);
2899 tcg_gen_qemu_ld_tl(cpu_gpr_a
[11], cpu_gpr_a
[10], ctx
->mem_idx
, MO_LESL
);
2900 tcg_gen_addi_tl(cpu_gpr_a
[10], cpu_gpr_a
[10], 4);
2901 tcg_gen_mov_tl(cpu_PC
, temp
);
2902 tcg_gen_exit_tb(NULL
, 0);
2903 ctx
->base
.is_jmp
= DISAS_NORETURN
;
2906 static void gen_compute_branch(DisasContext
*ctx
, uint32_t opc
, int r1
,
2907 int r2
, int32_t constant
, int32_t offset
)
2913 /* SB-format jumps */
2916 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
2918 case OPC1_32_B_CALL
:
2919 case OPC1_16_SB_CALL
:
2920 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
2921 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
2924 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], 0, offset
);
2926 case OPC1_16_SB_JNZ
:
2927 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], 0, offset
);
2929 /* SBC-format jumps */
2930 case OPC1_16_SBC_JEQ
:
2931 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], constant
, offset
);
2933 case OPC1_16_SBC_JEQ2
:
2934 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[15], constant
,
2937 case OPC1_16_SBC_JNE
:
2938 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15], constant
, offset
);
2940 case OPC1_16_SBC_JNE2
:
2941 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[15],
2942 constant
, offset
+ 16);
2944 /* SBRN-format jumps */
2945 case OPC1_16_SBRN_JZ_T
:
2946 temp
= tcg_temp_new();
2947 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
2948 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
2950 case OPC1_16_SBRN_JNZ_T
:
2951 temp
= tcg_temp_new();
2952 tcg_gen_andi_tl(temp
, cpu_gpr_d
[15], 0x1u
<< constant
);
2953 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
2955 /* SBR-format jumps */
2956 case OPC1_16_SBR_JEQ
:
2957 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2960 case OPC1_16_SBR_JEQ2
:
2961 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2964 case OPC1_16_SBR_JNE
:
2965 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2968 case OPC1_16_SBR_JNE2
:
2969 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15],
2972 case OPC1_16_SBR_JNZ
:
2973 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], 0, offset
);
2975 case OPC1_16_SBR_JNZ_A
:
2976 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
2978 case OPC1_16_SBR_JGEZ
:
2979 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], 0, offset
);
2981 case OPC1_16_SBR_JGTZ
:
2982 gen_branch_condi(ctx
, TCG_COND_GT
, cpu_gpr_d
[r1
], 0, offset
);
2984 case OPC1_16_SBR_JLEZ
:
2985 gen_branch_condi(ctx
, TCG_COND_LE
, cpu_gpr_d
[r1
], 0, offset
);
2987 case OPC1_16_SBR_JLTZ
:
2988 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], 0, offset
);
2990 case OPC1_16_SBR_JZ
:
2991 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], 0, offset
);
2993 case OPC1_16_SBR_JZ_A
:
2994 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
2996 case OPC1_16_SBR_LOOP
:
2997 gen_loop(ctx
, r1
, offset
* 2 - 32);
2999 /* SR-format jumps */
3001 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], 0xfffffffe);
3002 tcg_gen_exit_tb(NULL
, 0);
3004 case OPC2_32_SYS_RET
:
3005 case OPC2_16_SR_RET
:
3006 gen_helper_ret(cpu_env
);
3007 tcg_gen_exit_tb(NULL
, 0);
3010 case OPC1_32_B_CALLA
:
3011 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
3012 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3014 case OPC1_32_B_FCALL
:
3015 gen_fcall_save_ctx(ctx
);
3016 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3018 case OPC1_32_B_FCALLA
:
3019 gen_fcall_save_ctx(ctx
);
3020 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3023 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
3026 gen_goto_tb(ctx
, 0, EA_B_ABSOLUT(offset
));
3029 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
3030 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3033 case OPCM_32_BRC_EQ_NEQ
:
3034 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JEQ
) {
3035 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], constant
, offset
);
3037 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], constant
, offset
);
3040 case OPCM_32_BRC_GE
:
3041 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OP2_32_BRC_JGE
) {
3042 gen_branch_condi(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], constant
, offset
);
3044 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
3045 gen_branch_condi(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], constant
,
3049 case OPCM_32_BRC_JLT
:
3050 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JLT
) {
3051 gen_branch_condi(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], constant
, offset
);
3053 constant
= MASK_OP_BRC_CONST4(ctx
->opcode
);
3054 gen_branch_condi(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], constant
,
3058 case OPCM_32_BRC_JNE
:
3059 temp
= tcg_temp_new();
3060 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRC_JNED
) {
3061 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3062 /* subi is unconditional */
3063 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3064 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
3066 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3067 /* addi is unconditional */
3068 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3069 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, constant
, offset
);
3073 case OPCM_32_BRN_JTT
:
3074 n
= MASK_OP_BRN_N(ctx
->opcode
);
3076 temp
= tcg_temp_new();
3077 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r1
], (1 << n
));
3079 if (MASK_OP_BRN_OP2(ctx
->opcode
) == OPC2_32_BRN_JNZ_T
) {
3080 gen_branch_condi(ctx
, TCG_COND_NE
, temp
, 0, offset
);
3082 gen_branch_condi(ctx
, TCG_COND_EQ
, temp
, 0, offset
);
3086 case OPCM_32_BRR_EQ_NEQ
:
3087 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ
) {
3088 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3091 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3095 case OPCM_32_BRR_ADDR_EQ_NEQ
:
3096 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JEQ_A
) {
3097 gen_branch_cond(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
3100 gen_branch_cond(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
3104 case OPCM_32_BRR_GE
:
3105 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JGE
) {
3106 gen_branch_cond(ctx
, TCG_COND_GE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3109 gen_branch_cond(ctx
, TCG_COND_GEU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3113 case OPCM_32_BRR_JLT
:
3114 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JLT
) {
3115 gen_branch_cond(ctx
, TCG_COND_LT
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3118 gen_branch_cond(ctx
, TCG_COND_LTU
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3122 case OPCM_32_BRR_LOOP
:
3123 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_LOOP
) {
3124 gen_loop(ctx
, r2
, offset
* 2);
3126 /* OPC2_32_BRR_LOOPU */
3127 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
+ offset
* 2);
3130 case OPCM_32_BRR_JNE
:
3131 temp
= tcg_temp_new();
3132 temp2
= tcg_temp_new();
3133 if (MASK_OP_BRC_OP2(ctx
->opcode
) == OPC2_32_BRR_JNED
) {
3134 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3135 /* also save r2, in case of r1 == r2, so r2 is not decremented */
3136 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
3137 /* subi is unconditional */
3138 tcg_gen_subi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3139 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
3141 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
3142 /* also save r2, in case of r1 == r2, so r2 is not decremented */
3143 tcg_gen_mov_tl(temp2
, cpu_gpr_d
[r2
]);
3144 /* addi is unconditional */
3145 tcg_gen_addi_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 1);
3146 gen_branch_cond(ctx
, TCG_COND_NE
, temp
, temp2
, offset
);
3149 case OPCM_32_BRR_JNZ
:
3150 if (MASK_OP_BRR_OP2(ctx
->opcode
) == OPC2_32_BRR_JNZ_A
) {
3151 gen_branch_condi(ctx
, TCG_COND_NE
, cpu_gpr_a
[r1
], 0, offset
);
3153 gen_branch_condi(ctx
, TCG_COND_EQ
, cpu_gpr_a
[r1
], 0, offset
);
3157 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3159 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3164 * Functions for decoding instructions
3167 static void decode_src_opc(DisasContext
*ctx
, int op1
)
3173 r1
= MASK_OP_SRC_S1D(ctx
->opcode
);
3174 const4
= MASK_OP_SRC_CONST4_SEXT(ctx
->opcode
);
3177 case OPC1_16_SRC_ADD
:
3178 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3180 case OPC1_16_SRC_ADD_A15
:
3181 gen_addi_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], const4
);
3183 case OPC1_16_SRC_ADD_15A
:
3184 gen_addi_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], const4
);
3186 case OPC1_16_SRC_ADD_A
:
3187 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], const4
);
3189 case OPC1_16_SRC_CADD
:
3190 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
3193 case OPC1_16_SRC_CADDN
:
3194 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const4
, cpu_gpr_d
[r1
],
3197 case OPC1_16_SRC_CMOV
:
3198 temp
= tcg_constant_tl(0);
3199 temp2
= tcg_constant_tl(const4
);
3200 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3201 temp2
, cpu_gpr_d
[r1
]);
3203 case OPC1_16_SRC_CMOVN
:
3204 temp
= tcg_constant_tl(0);
3205 temp2
= tcg_constant_tl(const4
);
3206 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3207 temp2
, cpu_gpr_d
[r1
]);
3209 case OPC1_16_SRC_EQ
:
3210 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3213 case OPC1_16_SRC_LT
:
3214 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3217 case OPC1_16_SRC_MOV
:
3218 tcg_gen_movi_tl(cpu_gpr_d
[r1
], const4
);
3220 case OPC1_16_SRC_MOV_A
:
3221 const4
= MASK_OP_SRC_CONST4(ctx
->opcode
);
3222 tcg_gen_movi_tl(cpu_gpr_a
[r1
], const4
);
3224 case OPC1_16_SRC_MOV_E
:
3225 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
3226 tcg_gen_movi_tl(cpu_gpr_d
[r1
], const4
);
3227 tcg_gen_sari_tl(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], 31);
3229 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3232 case OPC1_16_SRC_SH
:
3233 gen_shi(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3235 case OPC1_16_SRC_SHA
:
3236 gen_shaci(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], const4
);
3239 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3243 static void decode_srr_opc(DisasContext
*ctx
, int op1
)
3248 r1
= MASK_OP_SRR_S1D(ctx
->opcode
);
3249 r2
= MASK_OP_SRR_S2(ctx
->opcode
);
3252 case OPC1_16_SRR_ADD
:
3253 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3255 case OPC1_16_SRR_ADD_A15
:
3256 gen_add_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
3258 case OPC1_16_SRR_ADD_15A
:
3259 gen_add_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3261 case OPC1_16_SRR_ADD_A
:
3262 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
3264 case OPC1_16_SRR_ADDS
:
3265 gen_adds(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3267 case OPC1_16_SRR_AND
:
3268 tcg_gen_and_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3270 case OPC1_16_SRR_CMOV
:
3271 temp
= tcg_constant_tl(0);
3272 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3273 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
3275 case OPC1_16_SRR_CMOVN
:
3276 temp
= tcg_constant_tl(0);
3277 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[15], temp
,
3278 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
]);
3280 case OPC1_16_SRR_EQ
:
3281 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3284 case OPC1_16_SRR_LT
:
3285 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[15], cpu_gpr_d
[r1
],
3288 case OPC1_16_SRR_MOV
:
3289 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3291 case OPC1_16_SRR_MOV_A
:
3292 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_d
[r2
]);
3294 case OPC1_16_SRR_MOV_AA
:
3295 tcg_gen_mov_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
3297 case OPC1_16_SRR_MOV_D
:
3298 tcg_gen_mov_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
]);
3300 case OPC1_16_SRR_MUL
:
3301 gen_mul_i32s(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3303 case OPC1_16_SRR_OR
:
3304 tcg_gen_or_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3306 case OPC1_16_SRR_SUB
:
3307 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3309 case OPC1_16_SRR_SUB_A15B
:
3310 gen_sub_d(cpu_gpr_d
[r1
], cpu_gpr_d
[15], cpu_gpr_d
[r2
]);
3312 case OPC1_16_SRR_SUB_15AB
:
3313 gen_sub_d(cpu_gpr_d
[15], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3315 case OPC1_16_SRR_SUBS
:
3316 gen_subs(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3318 case OPC1_16_SRR_XOR
:
3319 tcg_gen_xor_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
3322 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3326 static void decode_ssr_opc(DisasContext
*ctx
, int op1
)
3330 r1
= MASK_OP_SSR_S1(ctx
->opcode
);
3331 r2
= MASK_OP_SSR_S2(ctx
->opcode
);
3334 case OPC1_16_SSR_ST_A
:
3335 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3337 case OPC1_16_SSR_ST_A_POSTINC
:
3338 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3339 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3341 case OPC1_16_SSR_ST_B
:
3342 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3344 case OPC1_16_SSR_ST_B_POSTINC
:
3345 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3346 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
3348 case OPC1_16_SSR_ST_H
:
3349 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
3351 case OPC1_16_SSR_ST_H_POSTINC
:
3352 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUW
);
3353 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
3355 case OPC1_16_SSR_ST_W
:
3356 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3358 case OPC1_16_SSR_ST_W_POSTINC
:
3359 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LEUL
);
3360 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3363 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3367 static void decode_sc_opc(DisasContext
*ctx
, int op1
)
3371 const16
= MASK_OP_SC_CONST8(ctx
->opcode
);
3374 case OPC1_16_SC_AND
:
3375 tcg_gen_andi_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
3377 case OPC1_16_SC_BISR
:
3378 gen_helper_1arg(bisr
, const16
& 0xff);
3380 case OPC1_16_SC_LD_A
:
3381 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3383 case OPC1_16_SC_LD_W
:
3384 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3386 case OPC1_16_SC_MOV
:
3387 tcg_gen_movi_tl(cpu_gpr_d
[15], const16
);
3390 tcg_gen_ori_tl(cpu_gpr_d
[15], cpu_gpr_d
[15], const16
);
3392 case OPC1_16_SC_ST_A
:
3393 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3395 case OPC1_16_SC_ST_W
:
3396 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[10], const16
* 4, MO_LESL
);
3398 case OPC1_16_SC_SUB_A
:
3399 tcg_gen_subi_tl(cpu_gpr_a
[10], cpu_gpr_a
[10], const16
);
3402 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3406 static void decode_slr_opc(DisasContext
*ctx
, int op1
)
3410 r1
= MASK_OP_SLR_D(ctx
->opcode
);
3411 r2
= MASK_OP_SLR_S2(ctx
->opcode
);
3415 case OPC1_16_SLR_LD_A
:
3416 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3418 case OPC1_16_SLR_LD_A_POSTINC
:
3419 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3420 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3422 case OPC1_16_SLR_LD_BU
:
3423 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3425 case OPC1_16_SLR_LD_BU_POSTINC
:
3426 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_UB
);
3427 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 1);
3429 case OPC1_16_SLR_LD_H
:
3430 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3432 case OPC1_16_SLR_LD_H_POSTINC
:
3433 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESW
);
3434 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 2);
3436 case OPC1_16_SLR_LD_W
:
3437 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3439 case OPC1_16_SLR_LD_W_POSTINC
:
3440 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
, MO_LESL
);
3441 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], 4);
3444 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3448 static void decode_sro_opc(DisasContext
*ctx
, int op1
)
3453 r2
= MASK_OP_SRO_S2(ctx
->opcode
);
3454 address
= MASK_OP_SRO_OFF4(ctx
->opcode
);
3458 case OPC1_16_SRO_LD_A
:
3459 gen_offset_ld(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3461 case OPC1_16_SRO_LD_BU
:
3462 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3464 case OPC1_16_SRO_LD_H
:
3465 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 2, MO_LESW
);
3467 case OPC1_16_SRO_LD_W
:
3468 gen_offset_ld(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3470 case OPC1_16_SRO_ST_A
:
3471 gen_offset_st(ctx
, cpu_gpr_a
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3473 case OPC1_16_SRO_ST_B
:
3474 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
, MO_UB
);
3476 case OPC1_16_SRO_ST_H
:
3477 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 2, MO_LESW
);
3479 case OPC1_16_SRO_ST_W
:
3480 gen_offset_st(ctx
, cpu_gpr_d
[15], cpu_gpr_a
[r2
], address
* 4, MO_LESL
);
3483 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3487 static void decode_sr_system(DisasContext
*ctx
)
3490 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3493 case OPC2_16_SR_NOP
:
3495 case OPC2_16_SR_RET
:
3496 gen_compute_branch(ctx
, op2
, 0, 0, 0, 0);
3498 case OPC2_16_SR_RFE
:
3499 gen_helper_rfe(cpu_env
);
3500 tcg_gen_exit_tb(NULL
, 0);
3501 ctx
->base
.is_jmp
= DISAS_NORETURN
;
3503 case OPC2_16_SR_DEBUG
:
3504 /* raise EXCP_DEBUG */
3506 case OPC2_16_SR_FRET
:
3510 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3514 static void decode_sr_accu(DisasContext
*ctx
)
3519 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3520 op2
= MASK_OP_SR_OP2(ctx
->opcode
);
3523 case OPC2_16_SR_RSUB
:
3524 /* calc V bit -- overflow only if r1 = -0x80000000 */
3525 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r1
], -0x80000000);
3526 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
3528 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
3530 tcg_gen_neg_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3532 tcg_gen_add_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3533 tcg_gen_xor_tl(cpu_PSW_AV
, cpu_gpr_d
[r1
], cpu_PSW_AV
);
3535 tcg_gen_or_tl(cpu_PSW_SAV
, cpu_PSW_SAV
, cpu_PSW_AV
);
3537 case OPC2_16_SR_SAT_B
:
3538 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7f, -0x80);
3540 case OPC2_16_SR_SAT_BU
:
3541 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xff);
3543 case OPC2_16_SR_SAT_H
:
3544 gen_saturate(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
3546 case OPC2_16_SR_SAT_HU
:
3547 gen_saturate_u(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 0xffff);
3550 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3554 static void decode_16Bit_opc(DisasContext
*ctx
)
3562 op1
= MASK_OP_MAJOR(ctx
->opcode
);
3564 /* handle ADDSC.A opcode only being 6 bit long */
3565 if (unlikely((op1
& 0x3f) == OPC1_16_SRRS_ADDSC_A
)) {
3566 op1
= OPC1_16_SRRS_ADDSC_A
;
3570 case OPC1_16_SRC_ADD
:
3571 case OPC1_16_SRC_ADD_A15
:
3572 case OPC1_16_SRC_ADD_15A
:
3573 case OPC1_16_SRC_ADD_A
:
3574 case OPC1_16_SRC_CADD
:
3575 case OPC1_16_SRC_CADDN
:
3576 case OPC1_16_SRC_CMOV
:
3577 case OPC1_16_SRC_CMOVN
:
3578 case OPC1_16_SRC_EQ
:
3579 case OPC1_16_SRC_LT
:
3580 case OPC1_16_SRC_MOV
:
3581 case OPC1_16_SRC_MOV_A
:
3582 case OPC1_16_SRC_MOV_E
:
3583 case OPC1_16_SRC_SH
:
3584 case OPC1_16_SRC_SHA
:
3585 decode_src_opc(ctx
, op1
);
3588 case OPC1_16_SRR_ADD
:
3589 case OPC1_16_SRR_ADD_A15
:
3590 case OPC1_16_SRR_ADD_15A
:
3591 case OPC1_16_SRR_ADD_A
:
3592 case OPC1_16_SRR_ADDS
:
3593 case OPC1_16_SRR_AND
:
3594 case OPC1_16_SRR_CMOV
:
3595 case OPC1_16_SRR_CMOVN
:
3596 case OPC1_16_SRR_EQ
:
3597 case OPC1_16_SRR_LT
:
3598 case OPC1_16_SRR_MOV
:
3599 case OPC1_16_SRR_MOV_A
:
3600 case OPC1_16_SRR_MOV_AA
:
3601 case OPC1_16_SRR_MOV_D
:
3602 case OPC1_16_SRR_MUL
:
3603 case OPC1_16_SRR_OR
:
3604 case OPC1_16_SRR_SUB
:
3605 case OPC1_16_SRR_SUB_A15B
:
3606 case OPC1_16_SRR_SUB_15AB
:
3607 case OPC1_16_SRR_SUBS
:
3608 case OPC1_16_SRR_XOR
:
3609 decode_srr_opc(ctx
, op1
);
3612 case OPC1_16_SSR_ST_A
:
3613 case OPC1_16_SSR_ST_A_POSTINC
:
3614 case OPC1_16_SSR_ST_B
:
3615 case OPC1_16_SSR_ST_B_POSTINC
:
3616 case OPC1_16_SSR_ST_H
:
3617 case OPC1_16_SSR_ST_H_POSTINC
:
3618 case OPC1_16_SSR_ST_W
:
3619 case OPC1_16_SSR_ST_W_POSTINC
:
3620 decode_ssr_opc(ctx
, op1
);
3623 case OPC1_16_SRRS_ADDSC_A
:
3624 r2
= MASK_OP_SRRS_S2(ctx
->opcode
);
3625 r1
= MASK_OP_SRRS_S1D(ctx
->opcode
);
3626 const16
= MASK_OP_SRRS_N(ctx
->opcode
);
3627 temp
= tcg_temp_new();
3628 tcg_gen_shli_tl(temp
, cpu_gpr_d
[15], const16
);
3629 tcg_gen_add_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], temp
);
3632 case OPC1_16_SLRO_LD_A
:
3633 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3634 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3635 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3637 case OPC1_16_SLRO_LD_BU
:
3638 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3639 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3640 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
3642 case OPC1_16_SLRO_LD_H
:
3643 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3644 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3645 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
3647 case OPC1_16_SLRO_LD_W
:
3648 r1
= MASK_OP_SLRO_D(ctx
->opcode
);
3649 const16
= MASK_OP_SLRO_OFF4(ctx
->opcode
);
3650 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3653 case OPC1_16_SB_CALL
:
3655 case OPC1_16_SB_JNZ
:
3657 address
= MASK_OP_SB_DISP8_SEXT(ctx
->opcode
);
3658 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
3661 case OPC1_16_SBC_JEQ
:
3662 case OPC1_16_SBC_JNE
:
3663 address
= MASK_OP_SBC_DISP4(ctx
->opcode
);
3664 const16
= MASK_OP_SBC_CONST4_SEXT(ctx
->opcode
);
3665 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
3667 case OPC1_16_SBC_JEQ2
:
3668 case OPC1_16_SBC_JNE2
:
3669 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
3670 address
= MASK_OP_SBC_DISP4(ctx
->opcode
);
3671 const16
= MASK_OP_SBC_CONST4_SEXT(ctx
->opcode
);
3672 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
3674 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3678 case OPC1_16_SBRN_JNZ_T
:
3679 case OPC1_16_SBRN_JZ_T
:
3680 address
= MASK_OP_SBRN_DISP4(ctx
->opcode
);
3681 const16
= MASK_OP_SBRN_N(ctx
->opcode
);
3682 gen_compute_branch(ctx
, op1
, 0, 0, const16
, address
);
3685 case OPC1_16_SBR_JEQ2
:
3686 case OPC1_16_SBR_JNE2
:
3687 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
3688 r1
= MASK_OP_SBR_S2(ctx
->opcode
);
3689 address
= MASK_OP_SBR_DISP4(ctx
->opcode
);
3690 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
3692 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3695 case OPC1_16_SBR_JEQ
:
3696 case OPC1_16_SBR_JGEZ
:
3697 case OPC1_16_SBR_JGTZ
:
3698 case OPC1_16_SBR_JLEZ
:
3699 case OPC1_16_SBR_JLTZ
:
3700 case OPC1_16_SBR_JNE
:
3701 case OPC1_16_SBR_JNZ
:
3702 case OPC1_16_SBR_JNZ_A
:
3703 case OPC1_16_SBR_JZ
:
3704 case OPC1_16_SBR_JZ_A
:
3705 case OPC1_16_SBR_LOOP
:
3706 r1
= MASK_OP_SBR_S2(ctx
->opcode
);
3707 address
= MASK_OP_SBR_DISP4(ctx
->opcode
);
3708 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
3711 case OPC1_16_SC_AND
:
3712 case OPC1_16_SC_BISR
:
3713 case OPC1_16_SC_LD_A
:
3714 case OPC1_16_SC_LD_W
:
3715 case OPC1_16_SC_MOV
:
3717 case OPC1_16_SC_ST_A
:
3718 case OPC1_16_SC_ST_W
:
3719 case OPC1_16_SC_SUB_A
:
3720 decode_sc_opc(ctx
, op1
);
3723 case OPC1_16_SLR_LD_A
:
3724 case OPC1_16_SLR_LD_A_POSTINC
:
3725 case OPC1_16_SLR_LD_BU
:
3726 case OPC1_16_SLR_LD_BU_POSTINC
:
3727 case OPC1_16_SLR_LD_H
:
3728 case OPC1_16_SLR_LD_H_POSTINC
:
3729 case OPC1_16_SLR_LD_W
:
3730 case OPC1_16_SLR_LD_W_POSTINC
:
3731 decode_slr_opc(ctx
, op1
);
3734 case OPC1_16_SRO_LD_A
:
3735 case OPC1_16_SRO_LD_BU
:
3736 case OPC1_16_SRO_LD_H
:
3737 case OPC1_16_SRO_LD_W
:
3738 case OPC1_16_SRO_ST_A
:
3739 case OPC1_16_SRO_ST_B
:
3740 case OPC1_16_SRO_ST_H
:
3741 case OPC1_16_SRO_ST_W
:
3742 decode_sro_opc(ctx
, op1
);
3745 case OPC1_16_SSRO_ST_A
:
3746 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3747 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3748 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3750 case OPC1_16_SSRO_ST_B
:
3751 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3752 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3753 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
, MO_UB
);
3755 case OPC1_16_SSRO_ST_H
:
3756 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3757 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3758 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 2, MO_LESW
);
3760 case OPC1_16_SSRO_ST_W
:
3761 r1
= MASK_OP_SSRO_S1(ctx
->opcode
);
3762 const16
= MASK_OP_SSRO_OFF4(ctx
->opcode
);
3763 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[15], const16
* 4, MO_LESL
);
3766 case OPCM_16_SR_SYSTEM
:
3767 decode_sr_system(ctx
);
3769 case OPCM_16_SR_ACCU
:
3770 decode_sr_accu(ctx
);
3773 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3774 gen_compute_branch(ctx
, op1
, r1
, 0, 0, 0);
3776 case OPC1_16_SR_NOT
:
3777 r1
= MASK_OP_SR_S1D(ctx
->opcode
);
3778 tcg_gen_not_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
]);
3781 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3786 * 32 bit instructions
3790 static void decode_abs_ldw(DisasContext
*ctx
)
3797 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3798 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3799 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3801 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
3804 case OPC2_32_ABS_LD_A
:
3805 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3807 case OPC2_32_ABS_LD_D
:
3809 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
3811 case OPC2_32_ABS_LD_DA
:
3813 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
3815 case OPC2_32_ABS_LD_W
:
3816 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3819 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3823 static void decode_abs_ldb(DisasContext
*ctx
)
3830 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3831 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3832 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3834 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
3837 case OPC2_32_ABS_LD_B
:
3838 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_SB
);
3840 case OPC2_32_ABS_LD_BU
:
3841 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
3843 case OPC2_32_ABS_LD_H
:
3844 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESW
);
3846 case OPC2_32_ABS_LD_HU
:
3847 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
3850 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3854 static void decode_abs_ldst_swap(DisasContext
*ctx
)
3861 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3862 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3863 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3865 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
3868 case OPC2_32_ABS_LDMST
:
3869 gen_ldmst(ctx
, r1
, temp
);
3871 case OPC2_32_ABS_SWAP_W
:
3872 gen_swap(ctx
, r1
, temp
);
3875 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3879 static void decode_abs_ldst_context(DisasContext
*ctx
)
3884 off18
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3885 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3888 case OPC2_32_ABS_LDLCX
:
3889 gen_helper_1arg(ldlcx
, EA_ABS_FORMAT(off18
));
3891 case OPC2_32_ABS_LDUCX
:
3892 gen_helper_1arg(lducx
, EA_ABS_FORMAT(off18
));
3894 case OPC2_32_ABS_STLCX
:
3895 gen_helper_1arg(stlcx
, EA_ABS_FORMAT(off18
));
3897 case OPC2_32_ABS_STUCX
:
3898 gen_helper_1arg(stucx
, EA_ABS_FORMAT(off18
));
3901 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3905 static void decode_abs_store(DisasContext
*ctx
)
3912 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3913 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3914 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3916 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
3919 case OPC2_32_ABS_ST_A
:
3920 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3922 case OPC2_32_ABS_ST_D
:
3924 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
3926 case OPC2_32_ABS_ST_DA
:
3928 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
3930 case OPC2_32_ABS_ST_W
:
3931 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LESL
);
3934 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3938 static void decode_abs_storeb_h(DisasContext
*ctx
)
3945 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
3946 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
3947 op2
= MASK_OP_ABS_OP2(ctx
->opcode
);
3949 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
3952 case OPC2_32_ABS_ST_B
:
3953 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_UB
);
3955 case OPC2_32_ABS_ST_H
:
3956 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
3959 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
3965 static void decode_bit_andacc(DisasContext
*ctx
)
3971 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
3972 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
3973 r3
= MASK_OP_BIT_D(ctx
->opcode
);
3974 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
3975 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
3976 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
3980 case OPC2_32_BIT_AND_AND_T
:
3981 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3982 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_and_tl
);
3984 case OPC2_32_BIT_AND_ANDN_T
:
3985 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3986 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_and_tl
);
3988 case OPC2_32_BIT_AND_NOR_T
:
3989 if (TCG_TARGET_HAS_andc_i32
) {
3990 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3991 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_andc_tl
);
3993 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3994 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_and_tl
);
3997 case OPC2_32_BIT_AND_OR_T
:
3998 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
3999 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_and_tl
);
4002 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4006 static void decode_bit_logical_t(DisasContext
*ctx
)
4011 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4012 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4013 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4014 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4015 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4016 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4019 case OPC2_32_BIT_AND_T
:
4020 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4021 pos1
, pos2
, &tcg_gen_and_tl
);
4023 case OPC2_32_BIT_ANDN_T
:
4024 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4025 pos1
, pos2
, &tcg_gen_andc_tl
);
4027 case OPC2_32_BIT_NOR_T
:
4028 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4029 pos1
, pos2
, &tcg_gen_nor_tl
);
4031 case OPC2_32_BIT_OR_T
:
4032 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4033 pos1
, pos2
, &tcg_gen_or_tl
);
4036 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4040 static void decode_bit_insert(DisasContext
*ctx
)
4046 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4047 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4048 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4049 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4050 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4051 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4053 temp
= tcg_temp_new();
4055 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r2
], pos2
);
4056 if (op2
== OPC2_32_BIT_INSN_T
) {
4057 tcg_gen_not_tl(temp
, temp
);
4059 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], temp
, pos1
, 1);
4062 static void decode_bit_logical_t2(DisasContext
*ctx
)
4069 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4070 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4071 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4072 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4073 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4074 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4077 case OPC2_32_BIT_NAND_T
:
4078 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4079 pos1
, pos2
, &tcg_gen_nand_tl
);
4081 case OPC2_32_BIT_ORN_T
:
4082 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4083 pos1
, pos2
, &tcg_gen_orc_tl
);
4085 case OPC2_32_BIT_XNOR_T
:
4086 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4087 pos1
, pos2
, &tcg_gen_eqv_tl
);
4089 case OPC2_32_BIT_XOR_T
:
4090 gen_bit_1op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4091 pos1
, pos2
, &tcg_gen_xor_tl
);
4094 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4098 static void decode_bit_orand(DisasContext
*ctx
)
4105 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4106 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4107 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4108 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4109 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4110 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4113 case OPC2_32_BIT_OR_AND_T
:
4114 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4115 pos1
, pos2
, &tcg_gen_and_tl
, &tcg_gen_or_tl
);
4117 case OPC2_32_BIT_OR_ANDN_T
:
4118 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4119 pos1
, pos2
, &tcg_gen_andc_tl
, &tcg_gen_or_tl
);
4121 case OPC2_32_BIT_OR_NOR_T
:
4122 if (TCG_TARGET_HAS_orc_i32
) {
4123 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4124 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_orc_tl
);
4126 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4127 pos1
, pos2
, &tcg_gen_nor_tl
, &tcg_gen_or_tl
);
4130 case OPC2_32_BIT_OR_OR_T
:
4131 gen_bit_2op(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4132 pos1
, pos2
, &tcg_gen_or_tl
, &tcg_gen_or_tl
);
4135 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4139 static void decode_bit_sh_logic1(DisasContext
*ctx
)
4146 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4147 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4148 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4149 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4150 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4151 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4153 temp
= tcg_temp_new();
4156 case OPC2_32_BIT_SH_AND_T
:
4157 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4158 pos1
, pos2
, &tcg_gen_and_tl
);
4160 case OPC2_32_BIT_SH_ANDN_T
:
4161 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4162 pos1
, pos2
, &tcg_gen_andc_tl
);
4164 case OPC2_32_BIT_SH_NOR_T
:
4165 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4166 pos1
, pos2
, &tcg_gen_nor_tl
);
4168 case OPC2_32_BIT_SH_OR_T
:
4169 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4170 pos1
, pos2
, &tcg_gen_or_tl
);
4173 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4175 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
4176 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
4179 static void decode_bit_sh_logic2(DisasContext
*ctx
)
4186 op2
= MASK_OP_BIT_OP2(ctx
->opcode
);
4187 r1
= MASK_OP_BIT_S1(ctx
->opcode
);
4188 r2
= MASK_OP_BIT_S2(ctx
->opcode
);
4189 r3
= MASK_OP_BIT_D(ctx
->opcode
);
4190 pos1
= MASK_OP_BIT_POS1(ctx
->opcode
);
4191 pos2
= MASK_OP_BIT_POS2(ctx
->opcode
);
4193 temp
= tcg_temp_new();
4196 case OPC2_32_BIT_SH_NAND_T
:
4197 gen_bit_1op(temp
, cpu_gpr_d
[r1
] , cpu_gpr_d
[r2
] ,
4198 pos1
, pos2
, &tcg_gen_nand_tl
);
4200 case OPC2_32_BIT_SH_ORN_T
:
4201 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4202 pos1
, pos2
, &tcg_gen_orc_tl
);
4204 case OPC2_32_BIT_SH_XNOR_T
:
4205 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4206 pos1
, pos2
, &tcg_gen_eqv_tl
);
4208 case OPC2_32_BIT_SH_XOR_T
:
4209 gen_bit_1op(temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
4210 pos1
, pos2
, &tcg_gen_xor_tl
);
4213 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4215 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 1);
4216 tcg_gen_add_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], temp
);
4222 static void decode_bo_addrmode_post_pre_base(DisasContext
*ctx
)
4229 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4230 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4231 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4232 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4235 case OPC2_32_BO_CACHEA_WI_SHORTOFF
:
4236 case OPC2_32_BO_CACHEA_W_SHORTOFF
:
4237 case OPC2_32_BO_CACHEA_I_SHORTOFF
:
4238 /* instruction to access the cache */
4240 case OPC2_32_BO_CACHEA_WI_POSTINC
:
4241 case OPC2_32_BO_CACHEA_W_POSTINC
:
4242 case OPC2_32_BO_CACHEA_I_POSTINC
:
4243 /* instruction to access the cache, but we still need to handle
4244 the addressing mode */
4245 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4247 case OPC2_32_BO_CACHEA_WI_PREINC
:
4248 case OPC2_32_BO_CACHEA_W_PREINC
:
4249 case OPC2_32_BO_CACHEA_I_PREINC
:
4250 /* instruction to access the cache, but we still need to handle
4251 the addressing mode */
4252 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4254 case OPC2_32_BO_CACHEI_WI_SHORTOFF
:
4255 case OPC2_32_BO_CACHEI_W_SHORTOFF
:
4256 if (!has_feature(ctx
, TRICORE_FEATURE_131
)) {
4257 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4260 case OPC2_32_BO_CACHEI_W_POSTINC
:
4261 case OPC2_32_BO_CACHEI_WI_POSTINC
:
4262 if (has_feature(ctx
, TRICORE_FEATURE_131
)) {
4263 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4265 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4268 case OPC2_32_BO_CACHEI_W_PREINC
:
4269 case OPC2_32_BO_CACHEI_WI_PREINC
:
4270 if (has_feature(ctx
, TRICORE_FEATURE_131
)) {
4271 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4273 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4276 case OPC2_32_BO_ST_A_SHORTOFF
:
4277 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
4279 case OPC2_32_BO_ST_A_POSTINC
:
4280 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4282 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4284 case OPC2_32_BO_ST_A_PREINC
:
4285 gen_st_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESL
);
4287 case OPC2_32_BO_ST_B_SHORTOFF
:
4288 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4290 case OPC2_32_BO_ST_B_POSTINC
:
4291 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4293 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4295 case OPC2_32_BO_ST_B_PREINC
:
4296 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4298 case OPC2_32_BO_ST_D_SHORTOFF
:
4300 gen_offset_st_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
4303 case OPC2_32_BO_ST_D_POSTINC
:
4305 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
4306 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4308 case OPC2_32_BO_ST_D_PREINC
:
4310 temp
= tcg_temp_new();
4311 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4312 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4313 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4315 case OPC2_32_BO_ST_DA_SHORTOFF
:
4317 gen_offset_st_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
4320 case OPC2_32_BO_ST_DA_POSTINC
:
4322 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
4323 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4325 case OPC2_32_BO_ST_DA_PREINC
:
4327 temp
= tcg_temp_new();
4328 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4329 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4330 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4332 case OPC2_32_BO_ST_H_SHORTOFF
:
4333 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4335 case OPC2_32_BO_ST_H_POSTINC
:
4336 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4338 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4340 case OPC2_32_BO_ST_H_PREINC
:
4341 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4343 case OPC2_32_BO_ST_Q_SHORTOFF
:
4344 temp
= tcg_temp_new();
4345 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4346 gen_offset_st(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4348 case OPC2_32_BO_ST_Q_POSTINC
:
4349 temp
= tcg_temp_new();
4350 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4351 tcg_gen_qemu_st_tl(temp
, cpu_gpr_a
[r2
], ctx
->mem_idx
,
4353 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4355 case OPC2_32_BO_ST_Q_PREINC
:
4356 temp
= tcg_temp_new();
4357 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4358 gen_st_preincr(ctx
, temp
, cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4360 case OPC2_32_BO_ST_W_SHORTOFF
:
4361 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4363 case OPC2_32_BO_ST_W_POSTINC
:
4364 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4366 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4368 case OPC2_32_BO_ST_W_PREINC
:
4369 gen_st_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4372 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4376 static void decode_bo_addrmode_bitreverse_circular(DisasContext
*ctx
)
4381 TCGv temp
, temp2
, t_off10
;
4383 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4384 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4385 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4386 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4388 temp
= tcg_temp_new();
4389 temp2
= tcg_temp_new();
4390 t_off10
= tcg_constant_i32(off10
);
4392 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4393 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4396 case OPC2_32_BO_CACHEA_WI_BR
:
4397 case OPC2_32_BO_CACHEA_W_BR
:
4398 case OPC2_32_BO_CACHEA_I_BR
:
4399 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4401 case OPC2_32_BO_CACHEA_WI_CIRC
:
4402 case OPC2_32_BO_CACHEA_W_CIRC
:
4403 case OPC2_32_BO_CACHEA_I_CIRC
:
4404 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4406 case OPC2_32_BO_ST_A_BR
:
4407 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4408 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4410 case OPC2_32_BO_ST_A_CIRC
:
4411 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4412 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4414 case OPC2_32_BO_ST_B_BR
:
4415 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4416 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4418 case OPC2_32_BO_ST_B_CIRC
:
4419 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4420 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4422 case OPC2_32_BO_ST_D_BR
:
4424 gen_st_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
4425 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4427 case OPC2_32_BO_ST_D_CIRC
:
4429 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4430 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4431 tcg_gen_addi_tl(temp
, temp
, 4);
4432 tcg_gen_rem_tl(temp
, temp
, temp2
);
4433 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4434 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4435 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4437 case OPC2_32_BO_ST_DA_BR
:
4439 gen_st_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
4440 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4442 case OPC2_32_BO_ST_DA_CIRC
:
4444 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4445 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4446 tcg_gen_addi_tl(temp
, temp
, 4);
4447 tcg_gen_rem_tl(temp
, temp
, temp2
);
4448 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4449 tcg_gen_qemu_st_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4450 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4452 case OPC2_32_BO_ST_H_BR
:
4453 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4454 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4456 case OPC2_32_BO_ST_H_CIRC
:
4457 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4458 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4460 case OPC2_32_BO_ST_Q_BR
:
4461 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4462 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
4463 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4465 case OPC2_32_BO_ST_Q_CIRC
:
4466 tcg_gen_shri_tl(temp
, cpu_gpr_d
[r1
], 16);
4467 tcg_gen_qemu_st_tl(temp
, temp2
, ctx
->mem_idx
, MO_LEUW
);
4468 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4470 case OPC2_32_BO_ST_W_BR
:
4471 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4472 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4474 case OPC2_32_BO_ST_W_CIRC
:
4475 tcg_gen_qemu_st_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4476 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4479 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4483 static void decode_bo_addrmode_ld_post_pre_base(DisasContext
*ctx
)
4490 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4491 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4492 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4493 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4496 case OPC2_32_BO_LD_A_SHORTOFF
:
4497 gen_offset_ld(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4499 case OPC2_32_BO_LD_A_POSTINC
:
4500 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4502 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4504 case OPC2_32_BO_LD_A_PREINC
:
4505 gen_ld_preincr(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4507 case OPC2_32_BO_LD_B_SHORTOFF
:
4508 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4510 case OPC2_32_BO_LD_B_POSTINC
:
4511 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4513 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4515 case OPC2_32_BO_LD_B_PREINC
:
4516 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_SB
);
4518 case OPC2_32_BO_LD_BU_SHORTOFF
:
4519 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4521 case OPC2_32_BO_LD_BU_POSTINC
:
4522 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4524 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4526 case OPC2_32_BO_LD_BU_PREINC
:
4527 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_UB
);
4529 case OPC2_32_BO_LD_D_SHORTOFF
:
4531 gen_offset_ld_2regs(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
],
4534 case OPC2_32_BO_LD_D_POSTINC
:
4536 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
);
4537 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4539 case OPC2_32_BO_LD_D_PREINC
:
4541 temp
= tcg_temp_new();
4542 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4543 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp
, ctx
);
4544 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4546 case OPC2_32_BO_LD_DA_SHORTOFF
:
4548 gen_offset_ld_2regs(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
],
4551 case OPC2_32_BO_LD_DA_POSTINC
:
4553 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], ctx
);
4554 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4556 case OPC2_32_BO_LD_DA_PREINC
:
4558 temp
= tcg_temp_new();
4559 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4560 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp
, ctx
);
4561 tcg_gen_mov_tl(cpu_gpr_a
[r2
], temp
);
4563 case OPC2_32_BO_LD_H_SHORTOFF
:
4564 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
4566 case OPC2_32_BO_LD_H_POSTINC
:
4567 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4569 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4571 case OPC2_32_BO_LD_H_PREINC
:
4572 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LESW
);
4574 case OPC2_32_BO_LD_HU_SHORTOFF
:
4575 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4577 case OPC2_32_BO_LD_HU_POSTINC
:
4578 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4580 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4582 case OPC2_32_BO_LD_HU_PREINC
:
4583 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4585 case OPC2_32_BO_LD_Q_SHORTOFF
:
4586 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4587 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4589 case OPC2_32_BO_LD_Q_POSTINC
:
4590 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4592 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4593 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4595 case OPC2_32_BO_LD_Q_PREINC
:
4596 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUW
);
4597 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4599 case OPC2_32_BO_LD_W_SHORTOFF
:
4600 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4602 case OPC2_32_BO_LD_W_POSTINC
:
4603 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], ctx
->mem_idx
,
4605 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4607 case OPC2_32_BO_LD_W_PREINC
:
4608 gen_ld_preincr(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], off10
, MO_LEUL
);
4611 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4615 static void decode_bo_addrmode_ld_bitreverse_circular(DisasContext
*ctx
)
4620 TCGv temp
, temp2
, t_off10
;
4622 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4623 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4624 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4625 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4627 temp
= tcg_temp_new();
4628 temp2
= tcg_temp_new();
4629 t_off10
= tcg_constant_i32(off10
);
4631 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4632 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4636 case OPC2_32_BO_LD_A_BR
:
4637 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4638 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4640 case OPC2_32_BO_LD_A_CIRC
:
4641 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4642 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4644 case OPC2_32_BO_LD_B_BR
:
4645 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
4646 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4648 case OPC2_32_BO_LD_B_CIRC
:
4649 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_SB
);
4650 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4652 case OPC2_32_BO_LD_BU_BR
:
4653 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4654 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4656 case OPC2_32_BO_LD_BU_CIRC
:
4657 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_UB
);
4658 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4660 case OPC2_32_BO_LD_D_BR
:
4662 gen_ld_2regs_64(cpu_gpr_d
[r1
+1], cpu_gpr_d
[r1
], temp2
, ctx
);
4663 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4665 case OPC2_32_BO_LD_D_CIRC
:
4667 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4668 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4669 tcg_gen_addi_tl(temp
, temp
, 4);
4670 tcg_gen_rem_tl(temp
, temp
, temp2
);
4671 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4672 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4673 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4675 case OPC2_32_BO_LD_DA_BR
:
4677 gen_ld_2regs_64(cpu_gpr_a
[r1
+1], cpu_gpr_a
[r1
], temp2
, ctx
);
4678 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4680 case OPC2_32_BO_LD_DA_CIRC
:
4682 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4683 tcg_gen_shri_tl(temp2
, cpu_gpr_a
[r2
+1], 16);
4684 tcg_gen_addi_tl(temp
, temp
, 4);
4685 tcg_gen_rem_tl(temp
, temp
, temp2
);
4686 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4687 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
+1], temp2
, ctx
->mem_idx
, MO_LEUL
);
4688 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4690 case OPC2_32_BO_LD_H_BR
:
4691 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
4692 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4694 case OPC2_32_BO_LD_H_CIRC
:
4695 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LESW
);
4696 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4698 case OPC2_32_BO_LD_HU_BR
:
4699 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4700 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4702 case OPC2_32_BO_LD_HU_CIRC
:
4703 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4704 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4706 case OPC2_32_BO_LD_Q_BR
:
4707 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4708 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4709 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4711 case OPC2_32_BO_LD_Q_CIRC
:
4712 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUW
);
4713 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
4714 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4716 case OPC2_32_BO_LD_W_BR
:
4717 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4718 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4720 case OPC2_32_BO_LD_W_CIRC
:
4721 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp2
, ctx
->mem_idx
, MO_LEUL
);
4722 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4725 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4729 static void decode_bo_addrmode_stctx_post_pre_base(DisasContext
*ctx
)
4737 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4738 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4739 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4740 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4743 temp
= tcg_temp_new();
4746 case OPC2_32_BO_LDLCX_SHORTOFF
:
4747 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4748 gen_helper_ldlcx(cpu_env
, temp
);
4750 case OPC2_32_BO_LDMST_SHORTOFF
:
4751 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4752 gen_ldmst(ctx
, r1
, temp
);
4754 case OPC2_32_BO_LDMST_POSTINC
:
4755 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
4756 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4758 case OPC2_32_BO_LDMST_PREINC
:
4759 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4760 gen_ldmst(ctx
, r1
, cpu_gpr_a
[r2
]);
4762 case OPC2_32_BO_LDUCX_SHORTOFF
:
4763 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4764 gen_helper_lducx(cpu_env
, temp
);
4766 case OPC2_32_BO_LEA_SHORTOFF
:
4767 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], off10
);
4769 case OPC2_32_BO_STLCX_SHORTOFF
:
4770 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4771 gen_helper_stlcx(cpu_env
, temp
);
4773 case OPC2_32_BO_STUCX_SHORTOFF
:
4774 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4775 gen_helper_stucx(cpu_env
, temp
);
4777 case OPC2_32_BO_SWAP_W_SHORTOFF
:
4778 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4779 gen_swap(ctx
, r1
, temp
);
4781 case OPC2_32_BO_SWAP_W_POSTINC
:
4782 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
4783 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4785 case OPC2_32_BO_SWAP_W_PREINC
:
4786 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4787 gen_swap(ctx
, r1
, cpu_gpr_a
[r2
]);
4789 case OPC2_32_BO_CMPSWAP_W_SHORTOFF
:
4790 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4791 gen_cmpswap(ctx
, r1
, temp
);
4793 case OPC2_32_BO_CMPSWAP_W_POSTINC
:
4794 gen_cmpswap(ctx
, r1
, cpu_gpr_a
[r2
]);
4795 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4797 case OPC2_32_BO_CMPSWAP_W_PREINC
:
4798 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4799 gen_cmpswap(ctx
, r1
, cpu_gpr_a
[r2
]);
4801 case OPC2_32_BO_SWAPMSK_W_SHORTOFF
:
4802 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], off10
);
4803 gen_swapmsk(ctx
, r1
, temp
);
4805 case OPC2_32_BO_SWAPMSK_W_POSTINC
:
4806 gen_swapmsk(ctx
, r1
, cpu_gpr_a
[r2
]);
4807 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4809 case OPC2_32_BO_SWAPMSK_W_PREINC
:
4810 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r2
], off10
);
4811 gen_swapmsk(ctx
, r1
, cpu_gpr_a
[r2
]);
4814 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4818 static void decode_bo_addrmode_ldmst_bitreverse_circular(DisasContext
*ctx
)
4823 TCGv temp
, temp2
, t_off10
;
4825 r1
= MASK_OP_BO_S1D(ctx
->opcode
);
4826 r2
= MASK_OP_BO_S2(ctx
->opcode
);
4827 off10
= MASK_OP_BO_OFF10_SEXT(ctx
->opcode
);
4828 op2
= MASK_OP_BO_OP2(ctx
->opcode
);
4830 temp
= tcg_temp_new();
4831 temp2
= tcg_temp_new();
4832 t_off10
= tcg_constant_i32(off10
);
4834 tcg_gen_ext16u_tl(temp
, cpu_gpr_a
[r2
+1]);
4835 tcg_gen_add_tl(temp2
, cpu_gpr_a
[r2
], temp
);
4838 case OPC2_32_BO_LDMST_BR
:
4839 gen_ldmst(ctx
, r1
, temp2
);
4840 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4842 case OPC2_32_BO_LDMST_CIRC
:
4843 gen_ldmst(ctx
, r1
, temp2
);
4844 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4846 case OPC2_32_BO_SWAP_W_BR
:
4847 gen_swap(ctx
, r1
, temp2
);
4848 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4850 case OPC2_32_BO_SWAP_W_CIRC
:
4851 gen_swap(ctx
, r1
, temp2
);
4852 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4854 case OPC2_32_BO_CMPSWAP_W_BR
:
4855 gen_cmpswap(ctx
, r1
, temp2
);
4856 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4858 case OPC2_32_BO_CMPSWAP_W_CIRC
:
4859 gen_cmpswap(ctx
, r1
, temp2
);
4860 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4862 case OPC2_32_BO_SWAPMSK_W_BR
:
4863 gen_swapmsk(ctx
, r1
, temp2
);
4864 gen_helper_br_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1]);
4866 case OPC2_32_BO_SWAPMSK_W_CIRC
:
4867 gen_swapmsk(ctx
, r1
, temp2
);
4868 gen_helper_circ_update(cpu_gpr_a
[r2
+1], cpu_gpr_a
[r2
+1], t_off10
);
4871 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4875 static void decode_bol_opc(DisasContext
*ctx
, int32_t op1
)
4881 r1
= MASK_OP_BOL_S1D(ctx
->opcode
);
4882 r2
= MASK_OP_BOL_S2(ctx
->opcode
);
4883 address
= MASK_OP_BOL_OFF16_SEXT(ctx
->opcode
);
4886 case OPC1_32_BOL_LD_A_LONGOFF
:
4887 temp
= tcg_temp_new();
4888 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
4889 tcg_gen_qemu_ld_tl(cpu_gpr_a
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
4891 case OPC1_32_BOL_LD_W_LONGOFF
:
4892 temp
= tcg_temp_new();
4893 tcg_gen_addi_tl(temp
, cpu_gpr_a
[r2
], address
);
4894 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUL
);
4896 case OPC1_32_BOL_LEA_LONGOFF
:
4897 tcg_gen_addi_tl(cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
);
4899 case OPC1_32_BOL_ST_A_LONGOFF
:
4900 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4901 gen_offset_st(ctx
, cpu_gpr_a
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
4903 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4906 case OPC1_32_BOL_ST_W_LONGOFF
:
4907 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUL
);
4909 case OPC1_32_BOL_LD_B_LONGOFF
:
4910 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4911 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
4913 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4916 case OPC1_32_BOL_LD_BU_LONGOFF
:
4917 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4918 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_UB
);
4920 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4923 case OPC1_32_BOL_LD_H_LONGOFF
:
4924 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4925 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
4927 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4930 case OPC1_32_BOL_LD_HU_LONGOFF
:
4931 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4932 gen_offset_ld(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LEUW
);
4934 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4937 case OPC1_32_BOL_ST_B_LONGOFF
:
4938 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4939 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_SB
);
4941 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4944 case OPC1_32_BOL_ST_H_LONGOFF
:
4945 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
4946 gen_offset_st(ctx
, cpu_gpr_d
[r1
], cpu_gpr_a
[r2
], address
, MO_LESW
);
4948 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4952 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
4957 static void decode_rc_logical_shift(DisasContext
*ctx
)
4964 r2
= MASK_OP_RC_D(ctx
->opcode
);
4965 r1
= MASK_OP_RC_S1(ctx
->opcode
);
4966 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
4967 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
4969 temp
= tcg_temp_new();
4972 case OPC2_32_RC_AND
:
4973 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4975 case OPC2_32_RC_ANDN
:
4976 tcg_gen_andi_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
4978 case OPC2_32_RC_NAND
:
4979 tcg_gen_movi_tl(temp
, const9
);
4980 tcg_gen_nand_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
4982 case OPC2_32_RC_NOR
:
4983 tcg_gen_movi_tl(temp
, const9
);
4984 tcg_gen_nor_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
);
4987 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4989 case OPC2_32_RC_ORN
:
4990 tcg_gen_ori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], ~const9
);
4993 const9
= sextract32(const9
, 0, 6);
4994 gen_shi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
4996 case OPC2_32_RC_SH_H
:
4997 const9
= sextract32(const9
, 0, 5);
4998 gen_sh_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5000 case OPC2_32_RC_SHA
:
5001 const9
= sextract32(const9
, 0, 6);
5002 gen_shaci(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5004 case OPC2_32_RC_SHA_H
:
5005 const9
= sextract32(const9
, 0, 5);
5006 gen_sha_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5008 case OPC2_32_RC_SHAS
:
5009 gen_shasi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5011 case OPC2_32_RC_XNOR
:
5012 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5013 tcg_gen_not_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
]);
5015 case OPC2_32_RC_XOR
:
5016 tcg_gen_xori_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5019 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5023 static void decode_rc_accumulator(DisasContext
*ctx
)
5031 r2
= MASK_OP_RC_D(ctx
->opcode
);
5032 r1
= MASK_OP_RC_S1(ctx
->opcode
);
5033 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
5035 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5037 temp
= tcg_temp_new();
5040 case OPC2_32_RC_ABSDIF
:
5041 gen_absdifi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5043 case OPC2_32_RC_ABSDIFS
:
5044 gen_absdifsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5046 case OPC2_32_RC_ADD
:
5047 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5049 case OPC2_32_RC_ADDC
:
5050 gen_addci_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5052 case OPC2_32_RC_ADDS
:
5053 gen_addsi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5055 case OPC2_32_RC_ADDS_U
:
5056 gen_addsui(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5058 case OPC2_32_RC_ADDX
:
5059 gen_addi_CC(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5061 case OPC2_32_RC_AND_EQ
:
5062 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5063 const9
, &tcg_gen_and_tl
);
5065 case OPC2_32_RC_AND_GE
:
5066 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5067 const9
, &tcg_gen_and_tl
);
5069 case OPC2_32_RC_AND_GE_U
:
5070 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5071 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5072 const9
, &tcg_gen_and_tl
);
5074 case OPC2_32_RC_AND_LT
:
5075 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5076 const9
, &tcg_gen_and_tl
);
5078 case OPC2_32_RC_AND_LT_U
:
5079 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5080 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5081 const9
, &tcg_gen_and_tl
);
5083 case OPC2_32_RC_AND_NE
:
5084 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5085 const9
, &tcg_gen_and_tl
);
5088 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5090 case OPC2_32_RC_EQANY_B
:
5091 gen_eqany_bi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5093 case OPC2_32_RC_EQANY_H
:
5094 gen_eqany_hi(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5097 tcg_gen_setcondi_tl(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5099 case OPC2_32_RC_GE_U
:
5100 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5101 tcg_gen_setcondi_tl(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5104 tcg_gen_setcondi_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5106 case OPC2_32_RC_LT_U
:
5107 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5108 tcg_gen_setcondi_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5110 case OPC2_32_RC_MAX
:
5111 tcg_gen_movi_tl(temp
, const9
);
5112 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5113 cpu_gpr_d
[r1
], temp
);
5115 case OPC2_32_RC_MAX_U
:
5116 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
5117 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5118 cpu_gpr_d
[r1
], temp
);
5120 case OPC2_32_RC_MIN
:
5121 tcg_gen_movi_tl(temp
, const9
);
5122 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5123 cpu_gpr_d
[r1
], temp
);
5125 case OPC2_32_RC_MIN_U
:
5126 tcg_gen_movi_tl(temp
, MASK_OP_RC_CONST9(ctx
->opcode
));
5127 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
,
5128 cpu_gpr_d
[r1
], temp
);
5131 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5133 case OPC2_32_RC_OR_EQ
:
5134 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5135 const9
, &tcg_gen_or_tl
);
5137 case OPC2_32_RC_OR_GE
:
5138 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5139 const9
, &tcg_gen_or_tl
);
5141 case OPC2_32_RC_OR_GE_U
:
5142 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5143 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5144 const9
, &tcg_gen_or_tl
);
5146 case OPC2_32_RC_OR_LT
:
5147 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5148 const9
, &tcg_gen_or_tl
);
5150 case OPC2_32_RC_OR_LT_U
:
5151 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5152 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5153 const9
, &tcg_gen_or_tl
);
5155 case OPC2_32_RC_OR_NE
:
5156 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5157 const9
, &tcg_gen_or_tl
);
5159 case OPC2_32_RC_RSUB
:
5160 tcg_gen_movi_tl(temp
, const9
);
5161 gen_sub_d(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5163 case OPC2_32_RC_RSUBS
:
5164 tcg_gen_movi_tl(temp
, const9
);
5165 gen_subs(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5167 case OPC2_32_RC_RSUBS_U
:
5168 tcg_gen_movi_tl(temp
, const9
);
5169 gen_subsu(cpu_gpr_d
[r2
], temp
, cpu_gpr_d
[r1
]);
5171 case OPC2_32_RC_SH_EQ
:
5172 gen_sh_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5174 case OPC2_32_RC_SH_GE
:
5175 gen_sh_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5177 case OPC2_32_RC_SH_GE_U
:
5178 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5179 gen_sh_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5181 case OPC2_32_RC_SH_LT
:
5182 gen_sh_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5184 case OPC2_32_RC_SH_LT_U
:
5185 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5186 gen_sh_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5188 case OPC2_32_RC_SH_NE
:
5189 gen_sh_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5191 case OPC2_32_RC_XOR_EQ
:
5192 gen_accumulating_condi(TCG_COND_EQ
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5193 const9
, &tcg_gen_xor_tl
);
5195 case OPC2_32_RC_XOR_GE
:
5196 gen_accumulating_condi(TCG_COND_GE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5197 const9
, &tcg_gen_xor_tl
);
5199 case OPC2_32_RC_XOR_GE_U
:
5200 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5201 gen_accumulating_condi(TCG_COND_GEU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5202 const9
, &tcg_gen_xor_tl
);
5204 case OPC2_32_RC_XOR_LT
:
5205 gen_accumulating_condi(TCG_COND_LT
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5206 const9
, &tcg_gen_xor_tl
);
5208 case OPC2_32_RC_XOR_LT_U
:
5209 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5210 gen_accumulating_condi(TCG_COND_LTU
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5211 const9
, &tcg_gen_xor_tl
);
5213 case OPC2_32_RC_XOR_NE
:
5214 gen_accumulating_condi(TCG_COND_NE
, cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
5215 const9
, &tcg_gen_xor_tl
);
5218 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5222 static void decode_rc_serviceroutine(DisasContext
*ctx
)
5227 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5228 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5231 case OPC2_32_RC_BISR
:
5232 gen_helper_1arg(bisr
, const9
);
5234 case OPC2_32_RC_SYSCALL
:
5235 /* TODO: Add exception generation */
5238 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5242 static void decode_rc_mul(DisasContext
*ctx
)
5248 r2
= MASK_OP_RC_D(ctx
->opcode
);
5249 r1
= MASK_OP_RC_S1(ctx
->opcode
);
5250 const9
= MASK_OP_RC_CONST9_SEXT(ctx
->opcode
);
5252 op2
= MASK_OP_RC_OP2(ctx
->opcode
);
5255 case OPC2_32_RC_MUL_32
:
5256 gen_muli_i32s(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5258 case OPC2_32_RC_MUL_64
:
5260 gen_muli_i64s(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
5262 case OPC2_32_RC_MULS_32
:
5263 gen_mulsi_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5265 case OPC2_32_RC_MUL_U_64
:
5266 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5268 gen_muli_i64u(cpu_gpr_d
[r2
], cpu_gpr_d
[r2
+1], cpu_gpr_d
[r1
], const9
);
5270 case OPC2_32_RC_MULS_U_32
:
5271 const9
= MASK_OP_RC_CONST9(ctx
->opcode
);
5272 gen_mulsui_i32(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const9
);
5275 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5280 static void decode_rcpw_insert(DisasContext
*ctx
)
5284 int32_t pos
, width
, const4
;
5288 op2
= MASK_OP_RCPW_OP2(ctx
->opcode
);
5289 r1
= MASK_OP_RCPW_S1(ctx
->opcode
);
5290 r2
= MASK_OP_RCPW_D(ctx
->opcode
);
5291 const4
= MASK_OP_RCPW_CONST4(ctx
->opcode
);
5292 width
= MASK_OP_RCPW_WIDTH(ctx
->opcode
);
5293 pos
= MASK_OP_RCPW_POS(ctx
->opcode
);
5296 case OPC2_32_RCPW_IMASK
:
5298 /* if pos + width > 32 undefined result */
5299 if (pos
+ width
<= 32) {
5300 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], ((1u << width
) - 1) << pos
);
5301 tcg_gen_movi_tl(cpu_gpr_d
[r2
], (const4
<< pos
));
5304 case OPC2_32_RCPW_INSERT
:
5305 /* if pos + width > 32 undefined result */
5306 if (pos
+ width
<= 32) {
5307 temp
= tcg_constant_i32(const4
);
5308 tcg_gen_deposit_tl(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, pos
, width
);
5312 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5318 static void decode_rcrw_insert(DisasContext
*ctx
)
5322 int32_t width
, const4
;
5324 TCGv temp
, temp2
, temp3
;
5326 op2
= MASK_OP_RCRW_OP2(ctx
->opcode
);
5327 r1
= MASK_OP_RCRW_S1(ctx
->opcode
);
5328 r3
= MASK_OP_RCRW_S3(ctx
->opcode
);
5329 r4
= MASK_OP_RCRW_D(ctx
->opcode
);
5330 width
= MASK_OP_RCRW_WIDTH(ctx
->opcode
);
5331 const4
= MASK_OP_RCRW_CONST4(ctx
->opcode
);
5333 temp
= tcg_temp_new();
5334 temp2
= tcg_temp_new();
5337 case OPC2_32_RCRW_IMASK
:
5338 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
5339 tcg_gen_movi_tl(temp2
, (1 << width
) - 1);
5340 tcg_gen_shl_tl(cpu_gpr_d
[r4
+ 1], temp2
, temp
);
5341 tcg_gen_movi_tl(temp2
, const4
);
5342 tcg_gen_shl_tl(cpu_gpr_d
[r4
], temp2
, temp
);
5344 case OPC2_32_RCRW_INSERT
:
5345 temp3
= tcg_temp_new();
5347 tcg_gen_movi_tl(temp
, width
);
5348 tcg_gen_movi_tl(temp2
, const4
);
5349 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r3
], 0x1f);
5350 gen_insert(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], temp2
, temp
, temp3
);
5353 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5359 static void decode_rcr_cond_select(DisasContext
*ctx
)
5367 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5368 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5369 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5370 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5371 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5374 case OPC2_32_RCR_CADD
:
5375 gen_condi_add(TCG_COND_NE
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r4
],
5378 case OPC2_32_RCR_CADDN
:
5379 gen_condi_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], const9
, cpu_gpr_d
[r4
],
5382 case OPC2_32_RCR_SEL
:
5383 temp
= tcg_constant_i32(0);
5384 temp2
= tcg_constant_i32(const9
);
5385 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5386 cpu_gpr_d
[r1
], temp2
);
5388 case OPC2_32_RCR_SELN
:
5389 temp
= tcg_constant_i32(0);
5390 temp2
= tcg_constant_i32(const9
);
5391 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
5392 cpu_gpr_d
[r1
], temp2
);
5395 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5399 static void decode_rcr_madd(DisasContext
*ctx
)
5406 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5407 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5408 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5409 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5410 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5413 case OPC2_32_RCR_MADD_32
:
5414 gen_maddi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5416 case OPC2_32_RCR_MADD_64
:
5419 gen_maddi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5420 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5422 case OPC2_32_RCR_MADDS_32
:
5423 gen_maddsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5425 case OPC2_32_RCR_MADDS_64
:
5428 gen_maddsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5429 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5431 case OPC2_32_RCR_MADD_U_64
:
5434 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5435 gen_maddui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5436 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5438 case OPC2_32_RCR_MADDS_U_32
:
5439 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5440 gen_maddsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5442 case OPC2_32_RCR_MADDS_U_64
:
5445 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5446 gen_maddsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5447 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5450 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5454 static void decode_rcr_msub(DisasContext
*ctx
)
5461 op2
= MASK_OP_RCR_OP2(ctx
->opcode
);
5462 r1
= MASK_OP_RCR_S1(ctx
->opcode
);
5463 const9
= MASK_OP_RCR_CONST9_SEXT(ctx
->opcode
);
5464 r3
= MASK_OP_RCR_S3(ctx
->opcode
);
5465 r4
= MASK_OP_RCR_D(ctx
->opcode
);
5468 case OPC2_32_RCR_MSUB_32
:
5469 gen_msubi32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5471 case OPC2_32_RCR_MSUB_64
:
5474 gen_msubi64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5475 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5477 case OPC2_32_RCR_MSUBS_32
:
5478 gen_msubsi_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5480 case OPC2_32_RCR_MSUBS_64
:
5483 gen_msubsi_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5484 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5486 case OPC2_32_RCR_MSUB_U_64
:
5489 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5490 gen_msubui64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5491 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5493 case OPC2_32_RCR_MSUBS_U_32
:
5494 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5495 gen_msubsui_32(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
], const9
);
5497 case OPC2_32_RCR_MSUBS_U_64
:
5500 const9
= MASK_OP_RCR_CONST9(ctx
->opcode
);
5501 gen_msubsui_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
5502 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], const9
);
5505 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5511 static void decode_rlc_opc(DisasContext
*ctx
,
5517 const16
= MASK_OP_RLC_CONST16_SEXT(ctx
->opcode
);
5518 r1
= MASK_OP_RLC_S1(ctx
->opcode
);
5519 r2
= MASK_OP_RLC_D(ctx
->opcode
);
5522 case OPC1_32_RLC_ADDI
:
5523 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
);
5525 case OPC1_32_RLC_ADDIH
:
5526 gen_addi_d(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], const16
<< 16);
5528 case OPC1_32_RLC_ADDIH_A
:
5529 tcg_gen_addi_tl(cpu_gpr_a
[r2
], cpu_gpr_a
[r1
], const16
<< 16);
5531 case OPC1_32_RLC_MFCR
:
5532 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
5533 gen_mfcr(ctx
, cpu_gpr_d
[r2
], const16
);
5535 case OPC1_32_RLC_MOV
:
5536 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5538 case OPC1_32_RLC_MOV_64
:
5539 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
5541 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5542 tcg_gen_movi_tl(cpu_gpr_d
[r2
+1], const16
>> 15);
5544 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5547 case OPC1_32_RLC_MOV_U
:
5548 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
5549 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
);
5551 case OPC1_32_RLC_MOV_H
:
5552 tcg_gen_movi_tl(cpu_gpr_d
[r2
], const16
<< 16);
5554 case OPC1_32_RLC_MOVH_A
:
5555 tcg_gen_movi_tl(cpu_gpr_a
[r2
], const16
<< 16);
5557 case OPC1_32_RLC_MTCR
:
5558 const16
= MASK_OP_RLC_CONST16(ctx
->opcode
);
5559 gen_mtcr(ctx
, cpu_gpr_d
[r1
], const16
);
5562 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5567 static void decode_rr_accumulator(DisasContext
*ctx
)
5574 r3
= MASK_OP_RR_D(ctx
->opcode
);
5575 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5576 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5577 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5580 case OPC2_32_RR_ABS
:
5581 gen_abs(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5583 case OPC2_32_RR_ABS_B
:
5584 gen_helper_abs_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5586 case OPC2_32_RR_ABS_H
:
5587 gen_helper_abs_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5589 case OPC2_32_RR_ABSDIF
:
5590 gen_absdif(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5592 case OPC2_32_RR_ABSDIF_B
:
5593 gen_helper_absdif_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5596 case OPC2_32_RR_ABSDIF_H
:
5597 gen_helper_absdif_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5600 case OPC2_32_RR_ABSDIFS
:
5601 gen_helper_absdif_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5604 case OPC2_32_RR_ABSDIFS_H
:
5605 gen_helper_absdif_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5608 case OPC2_32_RR_ABSS
:
5609 gen_helper_abs_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5611 case OPC2_32_RR_ABSS_H
:
5612 gen_helper_abs_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r2
]);
5614 case OPC2_32_RR_ADD
:
5615 gen_add_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5617 case OPC2_32_RR_ADD_B
:
5618 gen_helper_add_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5620 case OPC2_32_RR_ADD_H
:
5621 gen_helper_add_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5623 case OPC2_32_RR_ADDC
:
5624 gen_addc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5626 case OPC2_32_RR_ADDS
:
5627 gen_adds(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5629 case OPC2_32_RR_ADDS_H
:
5630 gen_helper_add_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5633 case OPC2_32_RR_ADDS_HU
:
5634 gen_helper_add_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5637 case OPC2_32_RR_ADDS_U
:
5638 gen_helper_add_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5641 case OPC2_32_RR_ADDX
:
5642 gen_add_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5644 case OPC2_32_RR_AND_EQ
:
5645 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5646 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5648 case OPC2_32_RR_AND_GE
:
5649 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5650 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5652 case OPC2_32_RR_AND_GE_U
:
5653 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5654 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5656 case OPC2_32_RR_AND_LT
:
5657 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5658 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5660 case OPC2_32_RR_AND_LT_U
:
5661 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5662 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5664 case OPC2_32_RR_AND_NE
:
5665 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5666 cpu_gpr_d
[r2
], &tcg_gen_and_tl
);
5669 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5672 case OPC2_32_RR_EQ_B
:
5673 gen_helper_eq_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5675 case OPC2_32_RR_EQ_H
:
5676 gen_helper_eq_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5678 case OPC2_32_RR_EQ_W
:
5679 gen_cond_w(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5681 case OPC2_32_RR_EQANY_B
:
5682 gen_helper_eqany_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5684 case OPC2_32_RR_EQANY_H
:
5685 gen_helper_eqany_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5688 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5691 case OPC2_32_RR_GE_U
:
5692 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5696 tcg_gen_setcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5699 case OPC2_32_RR_LT_U
:
5700 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5703 case OPC2_32_RR_LT_B
:
5704 gen_helper_lt_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5706 case OPC2_32_RR_LT_BU
:
5707 gen_helper_lt_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5709 case OPC2_32_RR_LT_H
:
5710 gen_helper_lt_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5712 case OPC2_32_RR_LT_HU
:
5713 gen_helper_lt_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5715 case OPC2_32_RR_LT_W
:
5716 gen_cond_w(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5718 case OPC2_32_RR_LT_WU
:
5719 gen_cond_w(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5721 case OPC2_32_RR_MAX
:
5722 tcg_gen_movcond_tl(TCG_COND_GT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5723 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5725 case OPC2_32_RR_MAX_U
:
5726 tcg_gen_movcond_tl(TCG_COND_GTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5727 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5729 case OPC2_32_RR_MAX_B
:
5730 gen_helper_max_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5732 case OPC2_32_RR_MAX_BU
:
5733 gen_helper_max_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5735 case OPC2_32_RR_MAX_H
:
5736 gen_helper_max_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5738 case OPC2_32_RR_MAX_HU
:
5739 gen_helper_max_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5741 case OPC2_32_RR_MIN
:
5742 tcg_gen_movcond_tl(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5743 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5745 case OPC2_32_RR_MIN_U
:
5746 tcg_gen_movcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5747 cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5749 case OPC2_32_RR_MIN_B
:
5750 gen_helper_min_b(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5752 case OPC2_32_RR_MIN_BU
:
5753 gen_helper_min_bu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5755 case OPC2_32_RR_MIN_H
:
5756 gen_helper_min_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5758 case OPC2_32_RR_MIN_HU
:
5759 gen_helper_min_hu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5761 case OPC2_32_RR_MOV
:
5762 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5764 case OPC2_32_RR_MOV_64
:
5765 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
5766 temp
= tcg_temp_new();
5769 tcg_gen_mov_tl(temp
, cpu_gpr_d
[r1
]);
5770 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5771 tcg_gen_mov_tl(cpu_gpr_d
[r3
+ 1], temp
);
5773 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5776 case OPC2_32_RR_MOVS_64
:
5777 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
5779 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
5780 tcg_gen_sari_tl(cpu_gpr_d
[r3
+ 1], cpu_gpr_d
[r2
], 31);
5782 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5786 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5789 case OPC2_32_RR_OR_EQ
:
5790 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5791 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5793 case OPC2_32_RR_OR_GE
:
5794 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5795 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5797 case OPC2_32_RR_OR_GE_U
:
5798 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5799 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5801 case OPC2_32_RR_OR_LT
:
5802 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5803 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5805 case OPC2_32_RR_OR_LT_U
:
5806 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5807 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5809 case OPC2_32_RR_OR_NE
:
5810 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5811 cpu_gpr_d
[r2
], &tcg_gen_or_tl
);
5813 case OPC2_32_RR_SAT_B
:
5814 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7f, -0x80);
5816 case OPC2_32_RR_SAT_BU
:
5817 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xff);
5819 case OPC2_32_RR_SAT_H
:
5820 gen_saturate(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0x7fff, -0x8000);
5822 case OPC2_32_RR_SAT_HU
:
5823 gen_saturate_u(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 0xffff);
5825 case OPC2_32_RR_SH_EQ
:
5826 gen_sh_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5829 case OPC2_32_RR_SH_GE
:
5830 gen_sh_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5833 case OPC2_32_RR_SH_GE_U
:
5834 gen_sh_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5837 case OPC2_32_RR_SH_LT
:
5838 gen_sh_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5841 case OPC2_32_RR_SH_LT_U
:
5842 gen_sh_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5845 case OPC2_32_RR_SH_NE
:
5846 gen_sh_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5849 case OPC2_32_RR_SUB
:
5850 gen_sub_d(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5852 case OPC2_32_RR_SUB_B
:
5853 gen_helper_sub_b(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5855 case OPC2_32_RR_SUB_H
:
5856 gen_helper_sub_h(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5858 case OPC2_32_RR_SUBC
:
5859 gen_subc_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5861 case OPC2_32_RR_SUBS
:
5862 gen_subs(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5864 case OPC2_32_RR_SUBS_U
:
5865 gen_subsu(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5867 case OPC2_32_RR_SUBS_H
:
5868 gen_helper_sub_h_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5871 case OPC2_32_RR_SUBS_HU
:
5872 gen_helper_sub_h_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
5875 case OPC2_32_RR_SUBX
:
5876 gen_sub_CC(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5878 case OPC2_32_RR_XOR_EQ
:
5879 gen_accumulating_cond(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5880 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5882 case OPC2_32_RR_XOR_GE
:
5883 gen_accumulating_cond(TCG_COND_GE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5884 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5886 case OPC2_32_RR_XOR_GE_U
:
5887 gen_accumulating_cond(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5888 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5890 case OPC2_32_RR_XOR_LT
:
5891 gen_accumulating_cond(TCG_COND_LT
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5892 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5894 case OPC2_32_RR_XOR_LT_U
:
5895 gen_accumulating_cond(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5896 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5898 case OPC2_32_RR_XOR_NE
:
5899 gen_accumulating_cond(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
5900 cpu_gpr_d
[r2
], &tcg_gen_xor_tl
);
5903 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5907 static void decode_rr_logical_shift(DisasContext
*ctx
)
5912 r3
= MASK_OP_RR_D(ctx
->opcode
);
5913 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5914 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5915 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5918 case OPC2_32_RR_AND
:
5919 tcg_gen_and_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5921 case OPC2_32_RR_ANDN
:
5922 tcg_gen_andc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5924 case OPC2_32_RR_CLO
:
5925 tcg_gen_not_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5926 tcg_gen_clzi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], TARGET_LONG_BITS
);
5928 case OPC2_32_RR_CLO_H
:
5929 gen_helper_clo_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5931 case OPC2_32_RR_CLS
:
5932 tcg_gen_clrsb_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5934 case OPC2_32_RR_CLS_H
:
5935 gen_helper_cls_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5937 case OPC2_32_RR_CLZ
:
5938 tcg_gen_clzi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], TARGET_LONG_BITS
);
5940 case OPC2_32_RR_CLZ_H
:
5941 gen_helper_clz_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
5943 case OPC2_32_RR_NAND
:
5944 tcg_gen_nand_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5946 case OPC2_32_RR_NOR
:
5947 tcg_gen_nor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5950 tcg_gen_or_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5952 case OPC2_32_RR_ORN
:
5953 tcg_gen_orc_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5956 gen_helper_sh(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5958 case OPC2_32_RR_SH_H
:
5959 gen_helper_sh_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5961 case OPC2_32_RR_SHA
:
5962 gen_helper_sha(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5964 case OPC2_32_RR_SHA_H
:
5965 gen_helper_sha_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5967 case OPC2_32_RR_SHAS
:
5968 gen_shas(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5970 case OPC2_32_RR_XNOR
:
5971 tcg_gen_eqv_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5973 case OPC2_32_RR_XOR
:
5974 tcg_gen_xor_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
5977 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
5981 static void decode_rr_address(DisasContext
*ctx
)
5987 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
5988 r3
= MASK_OP_RR_D(ctx
->opcode
);
5989 r2
= MASK_OP_RR_S2(ctx
->opcode
);
5990 r1
= MASK_OP_RR_S1(ctx
->opcode
);
5991 n
= MASK_OP_RR_N(ctx
->opcode
);
5994 case OPC2_32_RR_ADD_A
:
5995 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
5997 case OPC2_32_RR_ADDSC_A
:
5998 temp
= tcg_temp_new();
5999 tcg_gen_shli_tl(temp
, cpu_gpr_d
[r1
], n
);
6000 tcg_gen_add_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
], temp
);
6002 case OPC2_32_RR_ADDSC_AT
:
6003 temp
= tcg_temp_new();
6004 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 3);
6005 tcg_gen_add_tl(temp
, cpu_gpr_a
[r2
], temp
);
6006 tcg_gen_andi_tl(cpu_gpr_a
[r3
], temp
, 0xFFFFFFFC);
6008 case OPC2_32_RR_EQ_A
:
6009 tcg_gen_setcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6012 case OPC2_32_RR_EQZ
:
6013 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
6015 case OPC2_32_RR_GE_A
:
6016 tcg_gen_setcond_tl(TCG_COND_GEU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6019 case OPC2_32_RR_LT_A
:
6020 tcg_gen_setcond_tl(TCG_COND_LTU
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6023 case OPC2_32_RR_MOV_A
:
6024 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_d
[r2
]);
6026 case OPC2_32_RR_MOV_AA
:
6027 tcg_gen_mov_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r2
]);
6029 case OPC2_32_RR_MOV_D
:
6030 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_a
[r2
]);
6032 case OPC2_32_RR_NE_A
:
6033 tcg_gen_setcond_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
],
6036 case OPC2_32_RR_NEZ_A
:
6037 tcg_gen_setcondi_tl(TCG_COND_NE
, cpu_gpr_d
[r3
], cpu_gpr_a
[r1
], 0);
6039 case OPC2_32_RR_SUB_A
:
6040 tcg_gen_sub_tl(cpu_gpr_a
[r3
], cpu_gpr_a
[r1
], cpu_gpr_a
[r2
]);
6043 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6047 static void decode_rr_idirect(DisasContext
*ctx
)
6052 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6053 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6057 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6059 case OPC2_32_RR_JLI
:
6060 tcg_gen_movi_tl(cpu_gpr_a
[11], ctx
->pc_succ_insn
);
6061 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6063 case OPC2_32_RR_CALLI
:
6064 gen_helper_1arg(call
, ctx
->pc_succ_insn
);
6065 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6067 case OPC2_32_RR_FCALLI
:
6068 gen_fcall_save_ctx(ctx
);
6069 tcg_gen_andi_tl(cpu_PC
, cpu_gpr_a
[r1
], ~0x1);
6072 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6074 tcg_gen_exit_tb(NULL
, 0);
6075 ctx
->base
.is_jmp
= DISAS_NORETURN
;
6078 static void decode_rr_divide(DisasContext
*ctx
)
6083 TCGv temp
, temp2
, temp3
;
6085 op2
= MASK_OP_RR_OP2(ctx
->opcode
);
6086 r3
= MASK_OP_RR_D(ctx
->opcode
);
6087 r2
= MASK_OP_RR_S2(ctx
->opcode
);
6088 r1
= MASK_OP_RR_S1(ctx
->opcode
);
6091 case OPC2_32_RR_BMERGE
:
6092 gen_helper_bmerge(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6094 case OPC2_32_RR_BSPLIT
:
6096 gen_bsplit(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
6098 case OPC2_32_RR_DVINIT_B
:
6100 gen_dvinit_b(ctx
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6103 case OPC2_32_RR_DVINIT_BU
:
6104 temp
= tcg_temp_new();
6105 temp2
= tcg_temp_new();
6106 temp3
= tcg_temp_new();
6108 tcg_gen_shri_tl(temp3
, cpu_gpr_d
[r1
], 8);
6110 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6111 if (!has_feature(ctx
, TRICORE_FEATURE_131
)) {
6112 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
6113 tcg_gen_abs_tl(temp
, temp3
);
6114 tcg_gen_abs_tl(temp2
, cpu_gpr_d
[r2
]);
6115 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
6117 /* overflow = (D[b] == 0) */
6118 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6120 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6122 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6124 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 24);
6125 tcg_gen_mov_tl(cpu_gpr_d
[r3
+1], temp3
);
6127 case OPC2_32_RR_DVINIT_H
:
6129 gen_dvinit_h(ctx
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6132 case OPC2_32_RR_DVINIT_HU
:
6133 temp
= tcg_temp_new();
6134 temp2
= tcg_temp_new();
6135 temp3
= tcg_temp_new();
6137 tcg_gen_shri_tl(temp3
, cpu_gpr_d
[r1
], 16);
6139 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6140 if (!has_feature(ctx
, TRICORE_FEATURE_131
)) {
6141 /* overflow = (abs(D[r3+1]) >= abs(D[r2])) */
6142 tcg_gen_abs_tl(temp
, temp3
);
6143 tcg_gen_abs_tl(temp2
, cpu_gpr_d
[r2
]);
6144 tcg_gen_setcond_tl(TCG_COND_GE
, cpu_PSW_V
, temp
, temp2
);
6146 /* overflow = (D[b] == 0) */
6147 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6149 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6151 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6153 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 16);
6154 tcg_gen_mov_tl(cpu_gpr_d
[r3
+1], temp3
);
6156 case OPC2_32_RR_DVINIT
:
6157 temp
= tcg_temp_new();
6158 temp2
= tcg_temp_new();
6160 /* overflow = ((D[b] == 0) ||
6161 ((D[b] == 0xFFFFFFFF) && (D[a] == 0x80000000))) */
6162 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp
, cpu_gpr_d
[r2
], 0xffffffff);
6163 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r1
], 0x80000000);
6164 tcg_gen_and_tl(temp
, temp
, temp2
);
6165 tcg_gen_setcondi_tl(TCG_COND_EQ
, temp2
, cpu_gpr_d
[r2
], 0);
6166 tcg_gen_or_tl(cpu_PSW_V
, temp
, temp2
);
6167 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6169 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6171 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6173 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6174 /* sign extend to high reg */
6175 tcg_gen_sari_tl(cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], 31);
6177 case OPC2_32_RR_DVINIT_U
:
6178 /* overflow = (D[b] == 0) */
6179 tcg_gen_setcondi_tl(TCG_COND_EQ
, cpu_PSW_V
, cpu_gpr_d
[r2
], 0);
6180 tcg_gen_shli_tl(cpu_PSW_V
, cpu_PSW_V
, 31);
6182 tcg_gen_or_tl(cpu_PSW_SV
, cpu_PSW_SV
, cpu_PSW_V
);
6184 tcg_gen_movi_tl(cpu_PSW_AV
, 0);
6186 tcg_gen_mov_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6187 /* zero extend to high reg*/
6188 tcg_gen_movi_tl(cpu_gpr_d
[r3
+1], 0);
6190 case OPC2_32_RR_PARITY
:
6191 gen_helper_parity(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6193 case OPC2_32_RR_UNPACK
:
6195 gen_unpack(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
6197 case OPC2_32_RR_CRC32
:
6198 if (has_feature(ctx
, TRICORE_FEATURE_161
)) {
6199 gen_helper_crc32(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6201 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6204 case OPC2_32_RR_DIV
:
6205 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
6206 GEN_HELPER_RR(divide
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6209 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6212 case OPC2_32_RR_DIV_U
:
6213 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
6214 GEN_HELPER_RR(divide_u
, cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
6215 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6217 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6220 case OPC2_32_RR_MUL_F
:
6221 gen_helper_fmul(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6223 case OPC2_32_RR_DIV_F
:
6224 gen_helper_fdiv(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6226 case OPC2_32_RR_CMP_F
:
6227 gen_helper_fcmp(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6229 case OPC2_32_RR_FTOI
:
6230 gen_helper_ftoi(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6232 case OPC2_32_RR_ITOF
:
6233 gen_helper_itof(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6235 case OPC2_32_RR_FTOUZ
:
6236 gen_helper_ftouz(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6238 case OPC2_32_RR_UPDFL
:
6239 gen_helper_updfl(cpu_env
, cpu_gpr_d
[r1
]);
6241 case OPC2_32_RR_UTOF
:
6242 gen_helper_utof(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6244 case OPC2_32_RR_FTOIZ
:
6245 gen_helper_ftoiz(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6247 case OPC2_32_RR_QSEED_F
:
6248 gen_helper_qseed(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
]);
6251 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6256 static void decode_rr1_mul(DisasContext
*ctx
)
6264 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
6265 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
6266 r3
= MASK_OP_RR1_D(ctx
->opcode
);
6267 n
= tcg_constant_i32(MASK_OP_RR1_N(ctx
->opcode
));
6268 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
6271 case OPC2_32_RR1_MUL_H_32_LL
:
6272 temp64
= tcg_temp_new_i64();
6274 GEN_HELPER_LL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6275 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6276 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6278 case OPC2_32_RR1_MUL_H_32_LU
:
6279 temp64
= tcg_temp_new_i64();
6281 GEN_HELPER_LU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6282 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6283 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6285 case OPC2_32_RR1_MUL_H_32_UL
:
6286 temp64
= tcg_temp_new_i64();
6288 GEN_HELPER_UL(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6289 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6290 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6292 case OPC2_32_RR1_MUL_H_32_UU
:
6293 temp64
= tcg_temp_new_i64();
6295 GEN_HELPER_UU(mul_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6296 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6297 gen_calc_usb_mul_h(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1]);
6299 case OPC2_32_RR1_MULM_H_64_LL
:
6300 temp64
= tcg_temp_new_i64();
6302 GEN_HELPER_LL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6303 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6305 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6307 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6309 case OPC2_32_RR1_MULM_H_64_LU
:
6310 temp64
= tcg_temp_new_i64();
6312 GEN_HELPER_LU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6313 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6315 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6317 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6319 case OPC2_32_RR1_MULM_H_64_UL
:
6320 temp64
= tcg_temp_new_i64();
6322 GEN_HELPER_UL(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6323 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6325 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6327 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6329 case OPC2_32_RR1_MULM_H_64_UU
:
6330 temp64
= tcg_temp_new_i64();
6332 GEN_HELPER_UU(mulm_h
, temp64
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6333 tcg_gen_extr_i64_i32(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], temp64
);
6335 tcg_gen_movi_tl(cpu_PSW_V
, 0);
6337 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
6339 case OPC2_32_RR1_MULR_H_16_LL
:
6340 GEN_HELPER_LL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6341 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6343 case OPC2_32_RR1_MULR_H_16_LU
:
6344 GEN_HELPER_LU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6345 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6347 case OPC2_32_RR1_MULR_H_16_UL
:
6348 GEN_HELPER_UL(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6349 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6351 case OPC2_32_RR1_MULR_H_16_UU
:
6352 GEN_HELPER_UU(mulr_h
, cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
);
6353 gen_calc_usb_mulr_h(cpu_gpr_d
[r3
]);
6356 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6360 static void decode_rr1_mulq(DisasContext
*ctx
)
6368 r1
= MASK_OP_RR1_S1(ctx
->opcode
);
6369 r2
= MASK_OP_RR1_S2(ctx
->opcode
);
6370 r3
= MASK_OP_RR1_D(ctx
->opcode
);
6371 n
= MASK_OP_RR1_N(ctx
->opcode
);
6372 op2
= MASK_OP_RR1_OP2(ctx
->opcode
);
6374 temp
= tcg_temp_new();
6375 temp2
= tcg_temp_new();
6378 case OPC2_32_RR1_MUL_Q_32
:
6379 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 32);
6381 case OPC2_32_RR1_MUL_Q_64
:
6383 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6386 case OPC2_32_RR1_MUL_Q_32_L
:
6387 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6388 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
6390 case OPC2_32_RR1_MUL_Q_64_L
:
6392 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6393 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
6395 case OPC2_32_RR1_MUL_Q_32_U
:
6396 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6397 gen_mul_q(cpu_gpr_d
[r3
], temp
, cpu_gpr_d
[r1
], temp
, n
, 16);
6399 case OPC2_32_RR1_MUL_Q_64_U
:
6401 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6402 gen_mul_q(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
, n
, 0);
6404 case OPC2_32_RR1_MUL_Q_32_LL
:
6405 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6406 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6407 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6409 case OPC2_32_RR1_MUL_Q_32_UU
:
6410 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6411 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6412 gen_mul_q_16(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6414 case OPC2_32_RR1_MULR_Q_32_L
:
6415 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6416 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6417 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6419 case OPC2_32_RR1_MULR_Q_32_U
:
6420 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6421 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6422 gen_mulr_q(cpu_gpr_d
[r3
], temp
, temp2
, n
);
6425 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6430 static void decode_rr2_mul(DisasContext
*ctx
)
6435 op2
= MASK_OP_RR2_OP2(ctx
->opcode
);
6436 r1
= MASK_OP_RR2_S1(ctx
->opcode
);
6437 r2
= MASK_OP_RR2_S2(ctx
->opcode
);
6438 r3
= MASK_OP_RR2_D(ctx
->opcode
);
6440 case OPC2_32_RR2_MUL_32
:
6441 gen_mul_i32s(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6443 case OPC2_32_RR2_MUL_64
:
6445 gen_mul_i64s(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6448 case OPC2_32_RR2_MULS_32
:
6449 gen_helper_mul_ssov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6452 case OPC2_32_RR2_MUL_U_64
:
6454 gen_mul_i64u(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
],
6457 case OPC2_32_RR2_MULS_U_32
:
6458 gen_helper_mul_suov(cpu_gpr_d
[r3
], cpu_env
, cpu_gpr_d
[r1
],
6462 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6467 static void decode_rrpw_extract_insert(DisasContext
*ctx
)
6474 op2
= MASK_OP_RRPW_OP2(ctx
->opcode
);
6475 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
6476 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
6477 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
6478 pos
= MASK_OP_RRPW_POS(ctx
->opcode
);
6479 width
= MASK_OP_RRPW_WIDTH(ctx
->opcode
);
6482 case OPC2_32_RRPW_EXTR
:
6484 tcg_gen_movi_tl(cpu_gpr_d
[r3
], 0);
6488 if (pos
+ width
<= 32) {
6489 /* optimize special cases */
6490 if ((pos
== 0) && (width
== 8)) {
6491 tcg_gen_ext8s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6492 } else if ((pos
== 0) && (width
== 16)) {
6493 tcg_gen_ext16s_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
]);
6495 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], 32 - pos
- width
);
6496 tcg_gen_sari_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], 32 - width
);
6500 case OPC2_32_RRPW_EXTR_U
:
6502 tcg_gen_movi_tl(cpu_gpr_d
[r3
], 0);
6504 tcg_gen_shri_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], pos
);
6505 tcg_gen_andi_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r3
], ~0u >> (32-width
));
6508 case OPC2_32_RRPW_IMASK
:
6511 if (pos
+ width
<= 32) {
6512 temp
= tcg_temp_new();
6513 tcg_gen_movi_tl(temp
, ((1u << width
) - 1) << pos
);
6514 tcg_gen_shli_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], pos
);
6515 tcg_gen_mov_tl(cpu_gpr_d
[r3
+ 1], temp
);
6519 case OPC2_32_RRPW_INSERT
:
6520 if (pos
+ width
<= 32) {
6521 tcg_gen_deposit_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6526 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6531 static void decode_rrr_cond_select(DisasContext
*ctx
)
6537 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
6538 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
6539 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
6540 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
6541 r4
= MASK_OP_RRR_D(ctx
->opcode
);
6544 case OPC2_32_RRR_CADD
:
6545 gen_cond_add(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6546 cpu_gpr_d
[r4
], cpu_gpr_d
[r3
]);
6548 case OPC2_32_RRR_CADDN
:
6549 gen_cond_add(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
6552 case OPC2_32_RRR_CSUB
:
6553 gen_cond_sub(TCG_COND_NE
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
6556 case OPC2_32_RRR_CSUBN
:
6557 gen_cond_sub(TCG_COND_EQ
, cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], cpu_gpr_d
[r4
],
6560 case OPC2_32_RRR_SEL
:
6561 temp
= tcg_constant_i32(0);
6562 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
6563 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6565 case OPC2_32_RRR_SELN
:
6566 temp
= tcg_constant_i32(0);
6567 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
,
6568 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
]);
6571 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6575 static void decode_rrr_divide(DisasContext
*ctx
)
6581 op2
= MASK_OP_RRR_OP2(ctx
->opcode
);
6582 r1
= MASK_OP_RRR_S1(ctx
->opcode
);
6583 r2
= MASK_OP_RRR_S2(ctx
->opcode
);
6584 r3
= MASK_OP_RRR_S3(ctx
->opcode
);
6585 r4
= MASK_OP_RRR_D(ctx
->opcode
);
6588 case OPC2_32_RRR_DVADJ
:
6591 GEN_HELPER_RRR(dvadj
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6592 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6594 case OPC2_32_RRR_DVSTEP
:
6597 GEN_HELPER_RRR(dvstep
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6598 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6600 case OPC2_32_RRR_DVSTEP_U
:
6603 GEN_HELPER_RRR(dvstep_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6604 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6606 case OPC2_32_RRR_IXMAX
:
6609 GEN_HELPER_RRR(ixmax
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6610 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6612 case OPC2_32_RRR_IXMAX_U
:
6615 GEN_HELPER_RRR(ixmax_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6616 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6618 case OPC2_32_RRR_IXMIN
:
6621 GEN_HELPER_RRR(ixmin
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6622 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6624 case OPC2_32_RRR_IXMIN_U
:
6627 GEN_HELPER_RRR(ixmin_u
, cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6628 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6630 case OPC2_32_RRR_PACK
:
6632 gen_helper_pack(cpu_gpr_d
[r4
], cpu_PSW_C
, cpu_gpr_d
[r3
],
6633 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
]);
6635 case OPC2_32_RRR_ADD_F
:
6636 gen_helper_fadd(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r3
]);
6638 case OPC2_32_RRR_SUB_F
:
6639 gen_helper_fsub(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
], cpu_gpr_d
[r3
]);
6641 case OPC2_32_RRR_MADD_F
:
6642 gen_helper_fmadd(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6643 cpu_gpr_d
[r2
], cpu_gpr_d
[r3
]);
6645 case OPC2_32_RRR_MSUB_F
:
6646 gen_helper_fmsub(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6647 cpu_gpr_d
[r2
], cpu_gpr_d
[r3
]);
6650 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6655 static void decode_rrr2_madd(DisasContext
*ctx
)
6658 uint32_t r1
, r2
, r3
, r4
;
6660 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
6661 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
6662 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
6663 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
6664 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
6666 case OPC2_32_RRR2_MADD_32
:
6667 gen_madd32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
6670 case OPC2_32_RRR2_MADD_64
:
6673 gen_madd64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6674 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6676 case OPC2_32_RRR2_MADDS_32
:
6677 gen_helper_madd32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6678 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6680 case OPC2_32_RRR2_MADDS_64
:
6683 gen_madds_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6684 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6686 case OPC2_32_RRR2_MADD_U_64
:
6689 gen_maddu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6690 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6692 case OPC2_32_RRR2_MADDS_U_32
:
6693 gen_helper_madd32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6694 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6696 case OPC2_32_RRR2_MADDS_U_64
:
6699 gen_maddsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6700 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6703 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6707 static void decode_rrr2_msub(DisasContext
*ctx
)
6710 uint32_t r1
, r2
, r3
, r4
;
6712 op2
= MASK_OP_RRR2_OP2(ctx
->opcode
);
6713 r1
= MASK_OP_RRR2_S1(ctx
->opcode
);
6714 r2
= MASK_OP_RRR2_S2(ctx
->opcode
);
6715 r3
= MASK_OP_RRR2_S3(ctx
->opcode
);
6716 r4
= MASK_OP_RRR2_D(ctx
->opcode
);
6719 case OPC2_32_RRR2_MSUB_32
:
6720 gen_msub32_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r3
],
6723 case OPC2_32_RRR2_MSUB_64
:
6726 gen_msub64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6727 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6729 case OPC2_32_RRR2_MSUBS_32
:
6730 gen_helper_msub32_ssov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6731 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6733 case OPC2_32_RRR2_MSUBS_64
:
6736 gen_msubs_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6737 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6739 case OPC2_32_RRR2_MSUB_U_64
:
6740 gen_msubu64_d(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6741 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6743 case OPC2_32_RRR2_MSUBS_U_32
:
6744 gen_helper_msub32_suov(cpu_gpr_d
[r4
], cpu_env
, cpu_gpr_d
[r1
],
6745 cpu_gpr_d
[r3
], cpu_gpr_d
[r2
]);
6747 case OPC2_32_RRR2_MSUBS_U_64
:
6750 gen_msubsu_64(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r1
],
6751 cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1], cpu_gpr_d
[r2
]);
6754 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6759 static void decode_rrr1_madd(DisasContext
*ctx
)
6762 uint32_t r1
, r2
, r3
, r4
, n
;
6764 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
6765 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
6766 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
6767 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
6768 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
6769 n
= MASK_OP_RRR1_N(ctx
->opcode
);
6772 case OPC2_32_RRR1_MADD_H_LL
:
6775 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6776 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6778 case OPC2_32_RRR1_MADD_H_LU
:
6781 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6782 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6784 case OPC2_32_RRR1_MADD_H_UL
:
6787 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6788 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6790 case OPC2_32_RRR1_MADD_H_UU
:
6793 gen_madd_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6794 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6796 case OPC2_32_RRR1_MADDS_H_LL
:
6799 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6800 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6802 case OPC2_32_RRR1_MADDS_H_LU
:
6805 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6806 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6808 case OPC2_32_RRR1_MADDS_H_UL
:
6811 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6812 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6814 case OPC2_32_RRR1_MADDS_H_UU
:
6817 gen_madds_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6818 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6820 case OPC2_32_RRR1_MADDM_H_LL
:
6823 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6824 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6826 case OPC2_32_RRR1_MADDM_H_LU
:
6829 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6830 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6832 case OPC2_32_RRR1_MADDM_H_UL
:
6835 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6836 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6838 case OPC2_32_RRR1_MADDM_H_UU
:
6841 gen_maddm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6842 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6844 case OPC2_32_RRR1_MADDMS_H_LL
:
6847 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6848 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
6850 case OPC2_32_RRR1_MADDMS_H_LU
:
6853 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6854 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
6856 case OPC2_32_RRR1_MADDMS_H_UL
:
6859 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6860 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
6862 case OPC2_32_RRR1_MADDMS_H_UU
:
6865 gen_maddms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6866 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
6868 case OPC2_32_RRR1_MADDR_H_LL
:
6869 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6870 cpu_gpr_d
[r2
], n
, MODE_LL
);
6872 case OPC2_32_RRR1_MADDR_H_LU
:
6873 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6874 cpu_gpr_d
[r2
], n
, MODE_LU
);
6876 case OPC2_32_RRR1_MADDR_H_UL
:
6877 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6878 cpu_gpr_d
[r2
], n
, MODE_UL
);
6880 case OPC2_32_RRR1_MADDR_H_UU
:
6881 gen_maddr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6882 cpu_gpr_d
[r2
], n
, MODE_UU
);
6884 case OPC2_32_RRR1_MADDRS_H_LL
:
6885 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6886 cpu_gpr_d
[r2
], n
, MODE_LL
);
6888 case OPC2_32_RRR1_MADDRS_H_LU
:
6889 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6890 cpu_gpr_d
[r2
], n
, MODE_LU
);
6892 case OPC2_32_RRR1_MADDRS_H_UL
:
6893 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6894 cpu_gpr_d
[r2
], n
, MODE_UL
);
6896 case OPC2_32_RRR1_MADDRS_H_UU
:
6897 gen_maddr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6898 cpu_gpr_d
[r2
], n
, MODE_UU
);
6901 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
6905 static void decode_rrr1_maddq_h(DisasContext
*ctx
)
6908 uint32_t r1
, r2
, r3
, r4
, n
;
6911 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
6912 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
6913 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
6914 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
6915 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
6916 n
= MASK_OP_RRR1_N(ctx
->opcode
);
6918 temp
= tcg_temp_new();
6919 temp2
= tcg_temp_new();
6922 case OPC2_32_RRR1_MADD_Q_32
:
6923 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6924 cpu_gpr_d
[r2
], n
, 32);
6926 case OPC2_32_RRR1_MADD_Q_64
:
6929 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6930 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6933 case OPC2_32_RRR1_MADD_Q_32_L
:
6934 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6935 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6938 case OPC2_32_RRR1_MADD_Q_64_L
:
6941 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6942 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6943 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6946 case OPC2_32_RRR1_MADD_Q_32_U
:
6947 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6948 gen_madd32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6951 case OPC2_32_RRR1_MADD_Q_64_U
:
6954 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
6955 gen_madd64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6956 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
6959 case OPC2_32_RRR1_MADD_Q_32_LL
:
6960 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6961 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6962 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6964 case OPC2_32_RRR1_MADD_Q_64_LL
:
6967 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
6968 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
6969 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6970 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6972 case OPC2_32_RRR1_MADD_Q_32_UU
:
6973 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6974 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6975 gen_m16add32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
6977 case OPC2_32_RRR1_MADD_Q_64_UU
:
6980 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
6981 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
6982 gen_m16add64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6983 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
6985 case OPC2_32_RRR1_MADDS_Q_32
:
6986 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
6987 cpu_gpr_d
[r2
], n
, 32);
6989 case OPC2_32_RRR1_MADDS_Q_64
:
6992 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
6993 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
6996 case OPC2_32_RRR1_MADDS_Q_32_L
:
6997 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
6998 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7001 case OPC2_32_RRR1_MADDS_Q_64_L
:
7004 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7005 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7006 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7009 case OPC2_32_RRR1_MADDS_Q_32_U
:
7010 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7011 gen_madds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7014 case OPC2_32_RRR1_MADDS_Q_64_U
:
7017 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7018 gen_madds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7019 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7022 case OPC2_32_RRR1_MADDS_Q_32_LL
:
7023 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7024 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7025 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7027 case OPC2_32_RRR1_MADDS_Q_64_LL
:
7030 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7031 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7032 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7033 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7035 case OPC2_32_RRR1_MADDS_Q_32_UU
:
7036 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7037 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7038 gen_m16adds32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7040 case OPC2_32_RRR1_MADDS_Q_64_UU
:
7043 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7044 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7045 gen_m16adds64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7046 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7048 case OPC2_32_RRR1_MADDR_H_64_UL
:
7050 gen_maddr64_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7051 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7053 case OPC2_32_RRR1_MADDRS_H_64_UL
:
7055 gen_maddr64s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7056 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7058 case OPC2_32_RRR1_MADDR_Q_32_LL
:
7059 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7060 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7061 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7063 case OPC2_32_RRR1_MADDR_Q_32_UU
:
7064 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7065 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7066 gen_maddr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7068 case OPC2_32_RRR1_MADDRS_Q_32_LL
:
7069 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7070 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7071 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7073 case OPC2_32_RRR1_MADDRS_Q_32_UU
:
7074 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7075 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7076 gen_maddrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7079 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7083 static void decode_rrr1_maddsu_h(DisasContext
*ctx
)
7086 uint32_t r1
, r2
, r3
, r4
, n
;
7088 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7089 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7090 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7091 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7092 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7093 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7096 case OPC2_32_RRR1_MADDSU_H_32_LL
:
7099 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7100 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7102 case OPC2_32_RRR1_MADDSU_H_32_LU
:
7105 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7106 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7108 case OPC2_32_RRR1_MADDSU_H_32_UL
:
7111 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7112 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7114 case OPC2_32_RRR1_MADDSU_H_32_UU
:
7117 gen_maddsu_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7118 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7120 case OPC2_32_RRR1_MADDSUS_H_32_LL
:
7123 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7124 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7127 case OPC2_32_RRR1_MADDSUS_H_32_LU
:
7130 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7131 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7134 case OPC2_32_RRR1_MADDSUS_H_32_UL
:
7137 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7138 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7141 case OPC2_32_RRR1_MADDSUS_H_32_UU
:
7144 gen_maddsus_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7145 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7148 case OPC2_32_RRR1_MADDSUM_H_64_LL
:
7151 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7152 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7155 case OPC2_32_RRR1_MADDSUM_H_64_LU
:
7158 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7159 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7162 case OPC2_32_RRR1_MADDSUM_H_64_UL
:
7165 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7166 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7169 case OPC2_32_RRR1_MADDSUM_H_64_UU
:
7172 gen_maddsum_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7173 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7176 case OPC2_32_RRR1_MADDSUMS_H_64_LL
:
7179 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7180 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7183 case OPC2_32_RRR1_MADDSUMS_H_64_LU
:
7186 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7187 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7190 case OPC2_32_RRR1_MADDSUMS_H_64_UL
:
7193 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7194 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7197 case OPC2_32_RRR1_MADDSUMS_H_64_UU
:
7200 gen_maddsums_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7201 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7204 case OPC2_32_RRR1_MADDSUR_H_16_LL
:
7205 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7206 cpu_gpr_d
[r2
], n
, MODE_LL
);
7208 case OPC2_32_RRR1_MADDSUR_H_16_LU
:
7209 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7210 cpu_gpr_d
[r2
], n
, MODE_LU
);
7212 case OPC2_32_RRR1_MADDSUR_H_16_UL
:
7213 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7214 cpu_gpr_d
[r2
], n
, MODE_UL
);
7216 case OPC2_32_RRR1_MADDSUR_H_16_UU
:
7217 gen_maddsur32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7218 cpu_gpr_d
[r2
], n
, MODE_UU
);
7220 case OPC2_32_RRR1_MADDSURS_H_16_LL
:
7221 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7222 cpu_gpr_d
[r2
], n
, MODE_LL
);
7224 case OPC2_32_RRR1_MADDSURS_H_16_LU
:
7225 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7226 cpu_gpr_d
[r2
], n
, MODE_LU
);
7228 case OPC2_32_RRR1_MADDSURS_H_16_UL
:
7229 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7230 cpu_gpr_d
[r2
], n
, MODE_UL
);
7232 case OPC2_32_RRR1_MADDSURS_H_16_UU
:
7233 gen_maddsur32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7234 cpu_gpr_d
[r2
], n
, MODE_UU
);
7237 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7241 static void decode_rrr1_msub(DisasContext
*ctx
)
7244 uint32_t r1
, r2
, r3
, r4
, n
;
7246 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7247 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7248 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7249 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7250 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7251 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7254 case OPC2_32_RRR1_MSUB_H_LL
:
7257 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7258 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7260 case OPC2_32_RRR1_MSUB_H_LU
:
7263 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7264 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7266 case OPC2_32_RRR1_MSUB_H_UL
:
7269 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7270 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7272 case OPC2_32_RRR1_MSUB_H_UU
:
7275 gen_msub_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7276 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7278 case OPC2_32_RRR1_MSUBS_H_LL
:
7281 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7282 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7284 case OPC2_32_RRR1_MSUBS_H_LU
:
7287 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7288 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7290 case OPC2_32_RRR1_MSUBS_H_UL
:
7293 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7294 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7296 case OPC2_32_RRR1_MSUBS_H_UU
:
7299 gen_msubs_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7300 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7302 case OPC2_32_RRR1_MSUBM_H_LL
:
7305 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7306 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7308 case OPC2_32_RRR1_MSUBM_H_LU
:
7311 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7312 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7314 case OPC2_32_RRR1_MSUBM_H_UL
:
7317 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7318 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7320 case OPC2_32_RRR1_MSUBM_H_UU
:
7323 gen_msubm_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7324 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7326 case OPC2_32_RRR1_MSUBMS_H_LL
:
7329 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7330 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7332 case OPC2_32_RRR1_MSUBMS_H_LU
:
7335 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7336 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7338 case OPC2_32_RRR1_MSUBMS_H_UL
:
7341 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7342 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7344 case OPC2_32_RRR1_MSUBMS_H_UU
:
7347 gen_msubms_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7348 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7350 case OPC2_32_RRR1_MSUBR_H_LL
:
7351 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7352 cpu_gpr_d
[r2
], n
, MODE_LL
);
7354 case OPC2_32_RRR1_MSUBR_H_LU
:
7355 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7356 cpu_gpr_d
[r2
], n
, MODE_LU
);
7358 case OPC2_32_RRR1_MSUBR_H_UL
:
7359 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7360 cpu_gpr_d
[r2
], n
, MODE_UL
);
7362 case OPC2_32_RRR1_MSUBR_H_UU
:
7363 gen_msubr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7364 cpu_gpr_d
[r2
], n
, MODE_UU
);
7366 case OPC2_32_RRR1_MSUBRS_H_LL
:
7367 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7368 cpu_gpr_d
[r2
], n
, MODE_LL
);
7370 case OPC2_32_RRR1_MSUBRS_H_LU
:
7371 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7372 cpu_gpr_d
[r2
], n
, MODE_LU
);
7374 case OPC2_32_RRR1_MSUBRS_H_UL
:
7375 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7376 cpu_gpr_d
[r2
], n
, MODE_UL
);
7378 case OPC2_32_RRR1_MSUBRS_H_UU
:
7379 gen_msubr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7380 cpu_gpr_d
[r2
], n
, MODE_UU
);
7383 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7387 static void decode_rrr1_msubq_h(DisasContext
*ctx
)
7390 uint32_t r1
, r2
, r3
, r4
, n
;
7393 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7394 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7395 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7396 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7397 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7398 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7400 temp
= tcg_temp_new();
7401 temp2
= tcg_temp_new();
7404 case OPC2_32_RRR1_MSUB_Q_32
:
7405 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7406 cpu_gpr_d
[r2
], n
, 32);
7408 case OPC2_32_RRR1_MSUB_Q_64
:
7411 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7412 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7415 case OPC2_32_RRR1_MSUB_Q_32_L
:
7416 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7417 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7420 case OPC2_32_RRR1_MSUB_Q_64_L
:
7423 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7424 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7425 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7428 case OPC2_32_RRR1_MSUB_Q_32_U
:
7429 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7430 gen_msub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7433 case OPC2_32_RRR1_MSUB_Q_64_U
:
7436 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7437 gen_msub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7438 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7441 case OPC2_32_RRR1_MSUB_Q_32_LL
:
7442 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7443 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7444 gen_m16sub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7446 case OPC2_32_RRR1_MSUB_Q_64_LL
:
7449 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7450 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7451 gen_m16sub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7452 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7454 case OPC2_32_RRR1_MSUB_Q_32_UU
:
7455 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7456 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7457 gen_m16sub32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7459 case OPC2_32_RRR1_MSUB_Q_64_UU
:
7462 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7463 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7464 gen_m16sub64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7465 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7467 case OPC2_32_RRR1_MSUBS_Q_32
:
7468 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7469 cpu_gpr_d
[r2
], n
, 32);
7471 case OPC2_32_RRR1_MSUBS_Q_64
:
7474 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7475 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7478 case OPC2_32_RRR1_MSUBS_Q_32_L
:
7479 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7480 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7483 case OPC2_32_RRR1_MSUBS_Q_64_L
:
7486 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r2
]);
7487 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7488 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7491 case OPC2_32_RRR1_MSUBS_Q_32_U
:
7492 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7493 gen_msubs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7496 case OPC2_32_RRR1_MSUBS_Q_64_U
:
7499 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r2
], 16);
7500 gen_msubs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7501 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], temp
,
7504 case OPC2_32_RRR1_MSUBS_Q_32_LL
:
7505 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7506 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7507 gen_m16subs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7509 case OPC2_32_RRR1_MSUBS_Q_64_LL
:
7512 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7513 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7514 gen_m16subs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7515 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7517 case OPC2_32_RRR1_MSUBS_Q_32_UU
:
7518 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7519 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7520 gen_m16subs32_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7522 case OPC2_32_RRR1_MSUBS_Q_64_UU
:
7525 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7526 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7527 gen_m16subs64_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7528 cpu_gpr_d
[r3
+1], temp
, temp2
, n
);
7530 case OPC2_32_RRR1_MSUBR_H_64_UL
:
7532 gen_msubr64_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7533 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7535 case OPC2_32_RRR1_MSUBRS_H_64_UL
:
7537 gen_msubr64s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r3
+1],
7538 cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, 2);
7540 case OPC2_32_RRR1_MSUBR_Q_32_LL
:
7541 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7542 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7543 gen_msubr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7545 case OPC2_32_RRR1_MSUBR_Q_32_UU
:
7546 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7547 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7548 gen_msubr_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7550 case OPC2_32_RRR1_MSUBRS_Q_32_LL
:
7551 tcg_gen_ext16s_tl(temp
, cpu_gpr_d
[r1
]);
7552 tcg_gen_ext16s_tl(temp2
, cpu_gpr_d
[r2
]);
7553 gen_msubrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7555 case OPC2_32_RRR1_MSUBRS_Q_32_UU
:
7556 tcg_gen_sari_tl(temp
, cpu_gpr_d
[r1
], 16);
7557 tcg_gen_sari_tl(temp2
, cpu_gpr_d
[r2
], 16);
7558 gen_msubrs_q(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], temp
, temp2
, n
);
7561 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7565 static void decode_rrr1_msubad_h(DisasContext
*ctx
)
7568 uint32_t r1
, r2
, r3
, r4
, n
;
7570 op2
= MASK_OP_RRR1_OP2(ctx
->opcode
);
7571 r1
= MASK_OP_RRR1_S1(ctx
->opcode
);
7572 r2
= MASK_OP_RRR1_S2(ctx
->opcode
);
7573 r3
= MASK_OP_RRR1_S3(ctx
->opcode
);
7574 r4
= MASK_OP_RRR1_D(ctx
->opcode
);
7575 n
= MASK_OP_RRR1_N(ctx
->opcode
);
7578 case OPC2_32_RRR1_MSUBAD_H_32_LL
:
7581 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7582 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LL
);
7584 case OPC2_32_RRR1_MSUBAD_H_32_LU
:
7587 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7588 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_LU
);
7590 case OPC2_32_RRR1_MSUBAD_H_32_UL
:
7593 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7594 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UL
);
7596 case OPC2_32_RRR1_MSUBAD_H_32_UU
:
7599 gen_msubad_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7600 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], n
, MODE_UU
);
7602 case OPC2_32_RRR1_MSUBADS_H_32_LL
:
7605 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7606 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7609 case OPC2_32_RRR1_MSUBADS_H_32_LU
:
7612 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7613 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7616 case OPC2_32_RRR1_MSUBADS_H_32_UL
:
7619 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7620 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7623 case OPC2_32_RRR1_MSUBADS_H_32_UU
:
7626 gen_msubads_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
+1], cpu_gpr_d
[r3
],
7627 cpu_gpr_d
[r3
+1], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
],
7630 case OPC2_32_RRR1_MSUBADM_H_64_LL
:
7633 gen_msubadm_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_MSUBADM_H_64_LU
:
7640 gen_msubadm_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_MSUBADM_H_64_UL
:
7647 gen_msubadm_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_MSUBADM_H_64_UU
:
7654 gen_msubadm_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_MSUBADMS_H_64_LL
:
7661 gen_msubadms_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_MSUBADMS_H_64_LU
:
7668 gen_msubadms_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_MSUBADMS_H_64_UL
:
7675 gen_msubadms_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_MSUBADMS_H_64_UU
:
7682 gen_msubadms_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_MSUBADR_H_16_LL
:
7687 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7688 cpu_gpr_d
[r2
], n
, MODE_LL
);
7690 case OPC2_32_RRR1_MSUBADR_H_16_LU
:
7691 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7692 cpu_gpr_d
[r2
], n
, MODE_LU
);
7694 case OPC2_32_RRR1_MSUBADR_H_16_UL
:
7695 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7696 cpu_gpr_d
[r2
], n
, MODE_UL
);
7698 case OPC2_32_RRR1_MSUBADR_H_16_UU
:
7699 gen_msubadr32_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7700 cpu_gpr_d
[r2
], n
, MODE_UU
);
7702 case OPC2_32_RRR1_MSUBADRS_H_16_LL
:
7703 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7704 cpu_gpr_d
[r2
], n
, MODE_LL
);
7706 case OPC2_32_RRR1_MSUBADRS_H_16_LU
:
7707 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7708 cpu_gpr_d
[r2
], n
, MODE_LU
);
7710 case OPC2_32_RRR1_MSUBADRS_H_16_UL
:
7711 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7712 cpu_gpr_d
[r2
], n
, MODE_UL
);
7714 case OPC2_32_RRR1_MSUBADRS_H_16_UU
:
7715 gen_msubadr32s_h(cpu_gpr_d
[r4
], cpu_gpr_d
[r3
], cpu_gpr_d
[r1
],
7716 cpu_gpr_d
[r2
], n
, MODE_UU
);
7719 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7724 static void decode_rrrr_extract_insert(DisasContext
*ctx
)
7728 TCGv tmp_width
, tmp_pos
;
7730 r1
= MASK_OP_RRRR_S1(ctx
->opcode
);
7731 r2
= MASK_OP_RRRR_S2(ctx
->opcode
);
7732 r3
= MASK_OP_RRRR_S3(ctx
->opcode
);
7733 r4
= MASK_OP_RRRR_D(ctx
->opcode
);
7734 op2
= MASK_OP_RRRR_OP2(ctx
->opcode
);
7736 tmp_pos
= tcg_temp_new();
7737 tmp_width
= tcg_temp_new();
7740 case OPC2_32_RRRR_DEXTR
:
7741 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
7743 tcg_gen_rotl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], tmp_pos
);
7745 TCGv msw
= tcg_temp_new();
7746 TCGv zero
= tcg_constant_tl(0);
7747 tcg_gen_shl_tl(tmp_width
, cpu_gpr_d
[r1
], tmp_pos
);
7748 tcg_gen_subfi_tl(msw
, 32, tmp_pos
);
7749 tcg_gen_shr_tl(msw
, cpu_gpr_d
[r2
], msw
);
7751 * if pos == 0, then we do cpu_gpr_d[r2] << 32, which is undefined
7752 * behaviour. So check that case here and set the low bits to zero
7753 * which effectivly returns cpu_gpr_d[r1]
7755 tcg_gen_movcond_tl(TCG_COND_EQ
, msw
, tmp_pos
, zero
, zero
, msw
);
7756 tcg_gen_or_tl(cpu_gpr_d
[r4
], tmp_width
, msw
);
7759 case OPC2_32_RRRR_EXTR
:
7760 case OPC2_32_RRRR_EXTR_U
:
7762 tcg_gen_andi_tl(tmp_width
, cpu_gpr_d
[r3
+1], 0x1f);
7763 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
7764 tcg_gen_add_tl(tmp_pos
, tmp_pos
, tmp_width
);
7765 tcg_gen_subfi_tl(tmp_pos
, 32, tmp_pos
);
7766 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], tmp_pos
);
7767 tcg_gen_subfi_tl(tmp_width
, 32, tmp_width
);
7768 if (op2
== OPC2_32_RRRR_EXTR
) {
7769 tcg_gen_sar_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], tmp_width
);
7771 tcg_gen_shr_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], tmp_width
);
7774 case OPC2_32_RRRR_INSERT
:
7776 tcg_gen_andi_tl(tmp_width
, cpu_gpr_d
[r3
+1], 0x1f);
7777 tcg_gen_andi_tl(tmp_pos
, cpu_gpr_d
[r3
], 0x1f);
7778 gen_insert(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], tmp_width
,
7782 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7787 static void decode_rrrw_extract_insert(DisasContext
*ctx
)
7795 op2
= MASK_OP_RRRW_OP2(ctx
->opcode
);
7796 r1
= MASK_OP_RRRW_S1(ctx
->opcode
);
7797 r2
= MASK_OP_RRRW_S2(ctx
->opcode
);
7798 r3
= MASK_OP_RRRW_S3(ctx
->opcode
);
7799 r4
= MASK_OP_RRRW_D(ctx
->opcode
);
7800 width
= MASK_OP_RRRW_WIDTH(ctx
->opcode
);
7802 temp
= tcg_temp_new();
7805 case OPC2_32_RRRW_EXTR
:
7806 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
7807 tcg_gen_addi_tl(temp
, temp
, width
);
7808 tcg_gen_subfi_tl(temp
, 32, temp
);
7809 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], temp
);
7810 tcg_gen_sari_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], 32 - width
);
7812 case OPC2_32_RRRW_EXTR_U
:
7814 tcg_gen_movi_tl(cpu_gpr_d
[r4
], 0);
7816 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
7817 tcg_gen_shr_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], temp
);
7818 tcg_gen_andi_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r4
], ~0u >> (32-width
));
7821 case OPC2_32_RRRW_IMASK
:
7822 temp2
= tcg_temp_new();
7824 tcg_gen_andi_tl(temp
, cpu_gpr_d
[r3
], 0x1f);
7825 tcg_gen_movi_tl(temp2
, (1 << width
) - 1);
7826 tcg_gen_shl_tl(temp2
, temp2
, temp
);
7827 tcg_gen_shl_tl(cpu_gpr_d
[r4
], cpu_gpr_d
[r2
], temp
);
7828 tcg_gen_mov_tl(cpu_gpr_d
[r4
+1], temp2
);
7830 case OPC2_32_RRRW_INSERT
:
7831 temp2
= tcg_temp_new();
7833 tcg_gen_movi_tl(temp
, width
);
7834 tcg_gen_andi_tl(temp2
, cpu_gpr_d
[r3
], 0x1f);
7835 gen_insert(cpu_gpr_d
[r4
], cpu_gpr_d
[r1
], cpu_gpr_d
[r2
], temp
, temp2
);
7838 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7843 static void decode_sys_interrupts(DisasContext
*ctx
)
7850 op2
= MASK_OP_SYS_OP2(ctx
->opcode
);
7851 r1
= MASK_OP_SYS_S1D(ctx
->opcode
);
7854 case OPC2_32_SYS_DEBUG
:
7855 /* raise EXCP_DEBUG */
7857 case OPC2_32_SYS_DISABLE
:
7858 tcg_gen_andi_tl(cpu_ICR
, cpu_ICR
, ~MASK_ICR_IE_1_3
);
7860 case OPC2_32_SYS_DSYNC
:
7862 case OPC2_32_SYS_ENABLE
:
7863 tcg_gen_ori_tl(cpu_ICR
, cpu_ICR
, MASK_ICR_IE_1_3
);
7865 case OPC2_32_SYS_ISYNC
:
7867 case OPC2_32_SYS_NOP
:
7869 case OPC2_32_SYS_RET
:
7870 gen_compute_branch(ctx
, op2
, 0, 0, 0, 0);
7872 case OPC2_32_SYS_FRET
:
7875 case OPC2_32_SYS_RFE
:
7876 gen_helper_rfe(cpu_env
);
7877 tcg_gen_exit_tb(NULL
, 0);
7878 ctx
->base
.is_jmp
= DISAS_NORETURN
;
7880 case OPC2_32_SYS_RFM
:
7881 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
) {
7882 tmp
= tcg_temp_new();
7883 l1
= gen_new_label();
7885 tcg_gen_ld32u_tl(tmp
, cpu_env
, offsetof(CPUTriCoreState
, DBGSR
));
7886 tcg_gen_andi_tl(tmp
, tmp
, MASK_DBGSR_DE
);
7887 tcg_gen_brcondi_tl(TCG_COND_NE
, tmp
, 1, l1
);
7888 gen_helper_rfm(cpu_env
);
7890 tcg_gen_exit_tb(NULL
, 0);
7891 ctx
->base
.is_jmp
= DISAS_NORETURN
;
7893 /* generate privilege trap */
7896 case OPC2_32_SYS_RSLCX
:
7897 gen_helper_rslcx(cpu_env
);
7899 case OPC2_32_SYS_SVLCX
:
7900 gen_helper_svlcx(cpu_env
);
7902 case OPC2_32_SYS_RESTORE
:
7903 if (has_feature(ctx
, TRICORE_FEATURE_16
)) {
7904 if ((ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_SM
||
7905 (ctx
->hflags
& TRICORE_HFLAG_KUU
) == TRICORE_HFLAG_UM1
) {
7906 tcg_gen_deposit_tl(cpu_ICR
, cpu_ICR
, cpu_gpr_d
[r1
], 8, 1);
7907 } /* else raise privilege trap */
7909 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7912 case OPC2_32_SYS_TRAPSV
:
7913 l1
= gen_new_label();
7914 tcg_gen_brcondi_tl(TCG_COND_GE
, cpu_PSW_SV
, 0, l1
);
7915 generate_trap(ctx
, TRAPC_ASSERT
, TIN5_SOVF
);
7918 case OPC2_32_SYS_TRAPV
:
7919 l1
= gen_new_label();
7920 tcg_gen_brcondi_tl(TCG_COND_GE
, cpu_PSW_V
, 0, l1
);
7921 generate_trap(ctx
, TRAPC_ASSERT
, TIN5_OVF
);
7925 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
7929 static void decode_32Bit_opc(DisasContext
*ctx
)
7933 int32_t address
, const16
;
7936 TCGv temp
, temp2
, temp3
;
7938 op1
= MASK_OP_MAJOR(ctx
->opcode
);
7940 /* handle JNZ.T opcode only being 7 bit long */
7941 if (unlikely((op1
& 0x7f) == OPCM_32_BRN_JTT
)) {
7942 op1
= OPCM_32_BRN_JTT
;
7947 case OPCM_32_ABS_LDW
:
7948 decode_abs_ldw(ctx
);
7950 case OPCM_32_ABS_LDB
:
7951 decode_abs_ldb(ctx
);
7953 case OPCM_32_ABS_LDMST_SWAP
:
7954 decode_abs_ldst_swap(ctx
);
7956 case OPCM_32_ABS_LDST_CONTEXT
:
7957 decode_abs_ldst_context(ctx
);
7959 case OPCM_32_ABS_STORE
:
7960 decode_abs_store(ctx
);
7962 case OPCM_32_ABS_STOREB_H
:
7963 decode_abs_storeb_h(ctx
);
7965 case OPC1_32_ABS_STOREQ
:
7966 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
7967 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
7968 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
7969 temp2
= tcg_temp_new();
7971 tcg_gen_shri_tl(temp2
, cpu_gpr_d
[r1
], 16);
7972 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_LEUW
);
7974 case OPC1_32_ABS_LD_Q
:
7975 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
7976 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
7977 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
7979 tcg_gen_qemu_ld_tl(cpu_gpr_d
[r1
], temp
, ctx
->mem_idx
, MO_LEUW
);
7980 tcg_gen_shli_tl(cpu_gpr_d
[r1
], cpu_gpr_d
[r1
], 16);
7982 case OPC1_32_ABS_LEA
:
7983 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
7984 r1
= MASK_OP_ABS_S1D(ctx
->opcode
);
7985 tcg_gen_movi_tl(cpu_gpr_a
[r1
], EA_ABS_FORMAT(address
));
7988 case OPC1_32_ABSB_ST_T
:
7989 address
= MASK_OP_ABS_OFF18(ctx
->opcode
);
7990 b
= MASK_OP_ABSB_B(ctx
->opcode
);
7991 bpos
= MASK_OP_ABSB_BPOS(ctx
->opcode
);
7993 temp
= tcg_constant_i32(EA_ABS_FORMAT(address
));
7994 temp2
= tcg_temp_new();
7996 tcg_gen_qemu_ld_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
7997 tcg_gen_andi_tl(temp2
, temp2
, ~(0x1u
<< bpos
));
7998 tcg_gen_ori_tl(temp2
, temp2
, (b
<< bpos
));
7999 tcg_gen_qemu_st_tl(temp2
, temp
, ctx
->mem_idx
, MO_UB
);
8002 case OPC1_32_B_CALL
:
8003 case OPC1_32_B_CALLA
:
8004 case OPC1_32_B_FCALL
:
8005 case OPC1_32_B_FCALLA
:
8010 address
= MASK_OP_B_DISP24_SEXT(ctx
->opcode
);
8011 gen_compute_branch(ctx
, op1
, 0, 0, 0, address
);
8014 case OPCM_32_BIT_ANDACC
:
8015 decode_bit_andacc(ctx
);
8017 case OPCM_32_BIT_LOGICAL_T1
:
8018 decode_bit_logical_t(ctx
);
8020 case OPCM_32_BIT_INSERT
:
8021 decode_bit_insert(ctx
);
8023 case OPCM_32_BIT_LOGICAL_T2
:
8024 decode_bit_logical_t2(ctx
);
8026 case OPCM_32_BIT_ORAND
:
8027 decode_bit_orand(ctx
);
8029 case OPCM_32_BIT_SH_LOGIC1
:
8030 decode_bit_sh_logic1(ctx
);
8032 case OPCM_32_BIT_SH_LOGIC2
:
8033 decode_bit_sh_logic2(ctx
);
8036 case OPCM_32_BO_ADDRMODE_POST_PRE_BASE
:
8037 decode_bo_addrmode_post_pre_base(ctx
);
8039 case OPCM_32_BO_ADDRMODE_BITREVERSE_CIRCULAR
:
8040 decode_bo_addrmode_bitreverse_circular(ctx
);
8042 case OPCM_32_BO_ADDRMODE_LD_POST_PRE_BASE
:
8043 decode_bo_addrmode_ld_post_pre_base(ctx
);
8045 case OPCM_32_BO_ADDRMODE_LD_BITREVERSE_CIRCULAR
:
8046 decode_bo_addrmode_ld_bitreverse_circular(ctx
);
8048 case OPCM_32_BO_ADDRMODE_STCTX_POST_PRE_BASE
:
8049 decode_bo_addrmode_stctx_post_pre_base(ctx
);
8051 case OPCM_32_BO_ADDRMODE_LDMST_BITREVERSE_CIRCULAR
:
8052 decode_bo_addrmode_ldmst_bitreverse_circular(ctx
);
8055 case OPC1_32_BOL_LD_A_LONGOFF
:
8056 case OPC1_32_BOL_LD_W_LONGOFF
:
8057 case OPC1_32_BOL_LEA_LONGOFF
:
8058 case OPC1_32_BOL_ST_W_LONGOFF
:
8059 case OPC1_32_BOL_ST_A_LONGOFF
:
8060 case OPC1_32_BOL_LD_B_LONGOFF
:
8061 case OPC1_32_BOL_LD_BU_LONGOFF
:
8062 case OPC1_32_BOL_LD_H_LONGOFF
:
8063 case OPC1_32_BOL_LD_HU_LONGOFF
:
8064 case OPC1_32_BOL_ST_B_LONGOFF
:
8065 case OPC1_32_BOL_ST_H_LONGOFF
:
8066 decode_bol_opc(ctx
, op1
);
8069 case OPCM_32_BRC_EQ_NEQ
:
8070 case OPCM_32_BRC_GE
:
8071 case OPCM_32_BRC_JLT
:
8072 case OPCM_32_BRC_JNE
:
8073 const4
= MASK_OP_BRC_CONST4_SEXT(ctx
->opcode
);
8074 address
= MASK_OP_BRC_DISP15_SEXT(ctx
->opcode
);
8075 r1
= MASK_OP_BRC_S1(ctx
->opcode
);
8076 gen_compute_branch(ctx
, op1
, r1
, 0, const4
, address
);
8079 case OPCM_32_BRN_JTT
:
8080 address
= MASK_OP_BRN_DISP15_SEXT(ctx
->opcode
);
8081 r1
= MASK_OP_BRN_S1(ctx
->opcode
);
8082 gen_compute_branch(ctx
, op1
, r1
, 0, 0, address
);
8085 case OPCM_32_BRR_EQ_NEQ
:
8086 case OPCM_32_BRR_ADDR_EQ_NEQ
:
8087 case OPCM_32_BRR_GE
:
8088 case OPCM_32_BRR_JLT
:
8089 case OPCM_32_BRR_JNE
:
8090 case OPCM_32_BRR_JNZ
:
8091 case OPCM_32_BRR_LOOP
:
8092 address
= MASK_OP_BRR_DISP15_SEXT(ctx
->opcode
);
8093 r2
= MASK_OP_BRR_S2(ctx
->opcode
);
8094 r1
= MASK_OP_BRR_S1(ctx
->opcode
);
8095 gen_compute_branch(ctx
, op1
, r1
, r2
, 0, address
);
8098 case OPCM_32_RC_LOGICAL_SHIFT
:
8099 decode_rc_logical_shift(ctx
);
8101 case OPCM_32_RC_ACCUMULATOR
:
8102 decode_rc_accumulator(ctx
);
8104 case OPCM_32_RC_SERVICEROUTINE
:
8105 decode_rc_serviceroutine(ctx
);
8107 case OPCM_32_RC_MUL
:
8111 case OPCM_32_RCPW_MASK_INSERT
:
8112 decode_rcpw_insert(ctx
);
8115 case OPC1_32_RCRR_INSERT
:
8116 r1
= MASK_OP_RCRR_S1(ctx
->opcode
);
8117 r2
= MASK_OP_RCRR_S3(ctx
->opcode
);
8118 r3
= MASK_OP_RCRR_D(ctx
->opcode
);
8119 const16
= MASK_OP_RCRR_CONST4(ctx
->opcode
);
8120 temp
= tcg_constant_i32(const16
);
8121 temp2
= tcg_temp_new(); /* width*/
8122 temp3
= tcg_temp_new(); /* pos */
8126 tcg_gen_andi_tl(temp2
, cpu_gpr_d
[r3
+1], 0x1f);
8127 tcg_gen_andi_tl(temp3
, cpu_gpr_d
[r3
], 0x1f);
8129 gen_insert(cpu_gpr_d
[r2
], cpu_gpr_d
[r1
], temp
, temp2
, temp3
);
8132 case OPCM_32_RCRW_MASK_INSERT
:
8133 decode_rcrw_insert(ctx
);
8136 case OPCM_32_RCR_COND_SELECT
:
8137 decode_rcr_cond_select(ctx
);
8139 case OPCM_32_RCR_MADD
:
8140 decode_rcr_madd(ctx
);
8142 case OPCM_32_RCR_MSUB
:
8143 decode_rcr_msub(ctx
);
8146 case OPC1_32_RLC_ADDI
:
8147 case OPC1_32_RLC_ADDIH
:
8148 case OPC1_32_RLC_ADDIH_A
:
8149 case OPC1_32_RLC_MFCR
:
8150 case OPC1_32_RLC_MOV
:
8151 case OPC1_32_RLC_MOV_64
:
8152 case OPC1_32_RLC_MOV_U
:
8153 case OPC1_32_RLC_MOV_H
:
8154 case OPC1_32_RLC_MOVH_A
:
8155 case OPC1_32_RLC_MTCR
:
8156 decode_rlc_opc(ctx
, op1
);
8159 case OPCM_32_RR_ACCUMULATOR
:
8160 decode_rr_accumulator(ctx
);
8162 case OPCM_32_RR_LOGICAL_SHIFT
:
8163 decode_rr_logical_shift(ctx
);
8165 case OPCM_32_RR_ADDRESS
:
8166 decode_rr_address(ctx
);
8168 case OPCM_32_RR_IDIRECT
:
8169 decode_rr_idirect(ctx
);
8171 case OPCM_32_RR_DIVIDE
:
8172 decode_rr_divide(ctx
);
8175 case OPCM_32_RR1_MUL
:
8176 decode_rr1_mul(ctx
);
8178 case OPCM_32_RR1_MULQ
:
8179 decode_rr1_mulq(ctx
);
8182 case OPCM_32_RR2_MUL
:
8183 decode_rr2_mul(ctx
);
8186 case OPCM_32_RRPW_EXTRACT_INSERT
:
8187 decode_rrpw_extract_insert(ctx
);
8189 case OPC1_32_RRPW_DEXTR
:
8190 r1
= MASK_OP_RRPW_S1(ctx
->opcode
);
8191 r2
= MASK_OP_RRPW_S2(ctx
->opcode
);
8192 r3
= MASK_OP_RRPW_D(ctx
->opcode
);
8193 const16
= MASK_OP_RRPW_POS(ctx
->opcode
);
8195 tcg_gen_extract2_tl(cpu_gpr_d
[r3
], cpu_gpr_d
[r2
], cpu_gpr_d
[r1
],
8199 case OPCM_32_RRR_COND_SELECT
:
8200 decode_rrr_cond_select(ctx
);
8202 case OPCM_32_RRR_DIVIDE
:
8203 decode_rrr_divide(ctx
);
8206 case OPCM_32_RRR2_MADD
:
8207 decode_rrr2_madd(ctx
);
8209 case OPCM_32_RRR2_MSUB
:
8210 decode_rrr2_msub(ctx
);
8213 case OPCM_32_RRR1_MADD
:
8214 decode_rrr1_madd(ctx
);
8216 case OPCM_32_RRR1_MADDQ_H
:
8217 decode_rrr1_maddq_h(ctx
);
8219 case OPCM_32_RRR1_MADDSU_H
:
8220 decode_rrr1_maddsu_h(ctx
);
8222 case OPCM_32_RRR1_MSUB_H
:
8223 decode_rrr1_msub(ctx
);
8225 case OPCM_32_RRR1_MSUB_Q
:
8226 decode_rrr1_msubq_h(ctx
);
8228 case OPCM_32_RRR1_MSUBAD_H
:
8229 decode_rrr1_msubad_h(ctx
);
8232 case OPCM_32_RRRR_EXTRACT_INSERT
:
8233 decode_rrrr_extract_insert(ctx
);
8236 case OPCM_32_RRRW_EXTRACT_INSERT
:
8237 decode_rrrw_extract_insert(ctx
);
8240 case OPCM_32_SYS_INTERRUPTS
:
8241 decode_sys_interrupts(ctx
);
8243 case OPC1_32_SYS_RSTV
:
8244 tcg_gen_movi_tl(cpu_PSW_V
, 0);
8245 tcg_gen_mov_tl(cpu_PSW_SV
, cpu_PSW_V
);
8246 tcg_gen_mov_tl(cpu_PSW_AV
, cpu_PSW_V
);
8247 tcg_gen_mov_tl(cpu_PSW_SAV
, cpu_PSW_V
);
8250 generate_trap(ctx
, TRAPC_INSN_ERR
, TIN2_IOPC
);
8254 static bool tricore_insn_is_16bit(uint32_t insn
)
8256 return (insn
& 0x1) == 0;
8259 static void tricore_tr_init_disas_context(DisasContextBase
*dcbase
,
8262 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8263 CPUTriCoreState
*env
= cs
->env_ptr
;
8264 ctx
->mem_idx
= cpu_mmu_index(env
, false);
8265 ctx
->hflags
= (uint32_t)ctx
->base
.tb
->flags
;
8266 ctx
->features
= env
->features
;
8269 static void tricore_tr_tb_start(DisasContextBase
*db
, CPUState
*cpu
)
8273 static void tricore_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
8275 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8277 tcg_gen_insn_start(ctx
->base
.pc_next
);
8280 static bool insn_crosses_page(CPUTriCoreState
*env
, DisasContext
*ctx
)
8283 * Return true if the insn at ctx->base.pc_next might cross a page boundary.
8284 * (False positives are OK, false negatives are not.)
8285 * Our caller ensures we are only called if dc->base.pc_next is less than
8286 * 4 bytes from the page boundary, so we cross the page if the first
8287 * 16 bits indicate that this is a 32 bit insn.
8289 uint16_t insn
= cpu_lduw_code(env
, ctx
->base
.pc_next
);
8291 return !tricore_insn_is_16bit(insn
);
8295 static void tricore_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cpu
)
8297 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8298 CPUTriCoreState
*env
= cpu
->env_ptr
;
8302 insn_lo
= cpu_lduw_code(env
, ctx
->base
.pc_next
);
8303 is_16bit
= tricore_insn_is_16bit(insn_lo
);
8305 ctx
->opcode
= insn_lo
;
8306 ctx
->pc_succ_insn
= ctx
->base
.pc_next
+ 2;
8307 decode_16Bit_opc(ctx
);
8309 uint32_t insn_hi
= cpu_lduw_code(env
, ctx
->base
.pc_next
+ 2);
8310 ctx
->opcode
= insn_hi
<< 16 | insn_lo
;
8311 ctx
->pc_succ_insn
= ctx
->base
.pc_next
+ 4;
8312 decode_32Bit_opc(ctx
);
8314 ctx
->base
.pc_next
= ctx
->pc_succ_insn
;
8316 if (ctx
->base
.is_jmp
== DISAS_NEXT
) {
8317 target_ulong page_start
;
8319 page_start
= ctx
->base
.pc_first
& TARGET_PAGE_MASK
;
8320 if (ctx
->base
.pc_next
- page_start
>= TARGET_PAGE_SIZE
8321 || (ctx
->base
.pc_next
- page_start
>= TARGET_PAGE_SIZE
- 3
8322 && insn_crosses_page(env
, ctx
))) {
8323 ctx
->base
.is_jmp
= DISAS_TOO_MANY
;
8328 static void tricore_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cpu
)
8330 DisasContext
*ctx
= container_of(dcbase
, DisasContext
, base
);
8332 switch (ctx
->base
.is_jmp
) {
8333 case DISAS_TOO_MANY
:
8334 gen_goto_tb(ctx
, 0, ctx
->base
.pc_next
);
8336 case DISAS_NORETURN
:
8339 g_assert_not_reached();
8343 static void tricore_tr_disas_log(const DisasContextBase
*dcbase
,
8344 CPUState
*cpu
, FILE *logfile
)
8346 fprintf(logfile
, "IN: %s\n", lookup_symbol(dcbase
->pc_first
));
8347 target_disas(logfile
, cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
8350 static const TranslatorOps tricore_tr_ops
= {
8351 .init_disas_context
= tricore_tr_init_disas_context
,
8352 .tb_start
= tricore_tr_tb_start
,
8353 .insn_start
= tricore_tr_insn_start
,
8354 .translate_insn
= tricore_tr_translate_insn
,
8355 .tb_stop
= tricore_tr_tb_stop
,
8356 .disas_log
= tricore_tr_disas_log
,
8360 void gen_intermediate_code(CPUState
*cs
, TranslationBlock
*tb
, int *max_insns
,
8361 target_ulong pc
, void *host_pc
)
8364 translator_loop(cs
, tb
, max_insns
, pc
, host_pc
,
8365 &tricore_tr_ops
, &ctx
.base
);
8374 void cpu_state_reset(CPUTriCoreState
*env
)
8376 /* Reset Regs to Default Value */
8381 static void tricore_tcg_init_csfr(void)
8383 cpu_PCXI
= tcg_global_mem_new(cpu_env
,
8384 offsetof(CPUTriCoreState
, PCXI
), "PCXI");
8385 cpu_PSW
= tcg_global_mem_new(cpu_env
,
8386 offsetof(CPUTriCoreState
, PSW
), "PSW");
8387 cpu_PC
= tcg_global_mem_new(cpu_env
,
8388 offsetof(CPUTriCoreState
, PC
), "PC");
8389 cpu_ICR
= tcg_global_mem_new(cpu_env
,
8390 offsetof(CPUTriCoreState
, ICR
), "ICR");
8393 void tricore_tcg_init(void)
8398 for (i
= 0 ; i
< 16 ; i
++) {
8399 cpu_gpr_a
[i
] = tcg_global_mem_new(cpu_env
,
8400 offsetof(CPUTriCoreState
, gpr_a
[i
]),
8403 for (i
= 0 ; i
< 16 ; i
++) {
8404 cpu_gpr_d
[i
] = tcg_global_mem_new(cpu_env
,
8405 offsetof(CPUTriCoreState
, gpr_d
[i
]),
8408 tricore_tcg_init_csfr();
8409 /* init PSW flag cache */
8410 cpu_PSW_C
= tcg_global_mem_new(cpu_env
,
8411 offsetof(CPUTriCoreState
, PSW_USB_C
),
8413 cpu_PSW_V
= tcg_global_mem_new(cpu_env
,
8414 offsetof(CPUTriCoreState
, PSW_USB_V
),
8416 cpu_PSW_SV
= tcg_global_mem_new(cpu_env
,
8417 offsetof(CPUTriCoreState
, PSW_USB_SV
),
8419 cpu_PSW_AV
= tcg_global_mem_new(cpu_env
,
8420 offsetof(CPUTriCoreState
, PSW_USB_AV
),
8422 cpu_PSW_SAV
= tcg_global_mem_new(cpu_env
,
8423 offsetof(CPUTriCoreState
, PSW_USB_SAV
),